diff --git a/CMakeLists.txt b/CMakeLists.txt index 24e7bcd545..b7f0fc1df1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ cmake_minimum_required(VERSION 3.13.0) #------------------------------------------------------------------------------ # Create the Top level Project # -project(SIMPLProj VERSION 1.2.0.0) +project(SIMPLProj VERSION 2.0.0.0) # ---------- Setup output Directories ------------------------- if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) @@ -260,7 +260,8 @@ endif() set(SIMPL_USE_EIGEN "") Find_Package(Eigen3 REQUIRED) if(EIGEN3_FOUND) - message(STATUS "Eigen3: ${EIGEN3_VERSION_STRING}") + message(STATUS "Eigen3 Location: ${EIGEN3_ROOT_DIR}") + message(STATUS "Eigen3 Version: ${EIGEN3_VERSION_STRING}") set(SIMPL_USE_EIGEN "1" CACHE INTERNAL "") else() message(WARNING "The Eigen Library is required for some algorithms to execute. These algorithms will be disabled.") diff --git a/Resources/UnitTestSupport.hpp b/Resources/UnitTestSupport.hpp index 46ca33aef7..44022760a3 100755 --- a/Resources/UnitTestSupport.hpp +++ b/Resources/UnitTestSupport.hpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once @@ -49,6 +49,8 @@ #include #include +#include "SIMPLib/DataContainers/DataArrayPath.h" + namespace SIMPL { namespace unittest @@ -63,7 +65,16 @@ static const char Passed[6] = {'P', 'A', 'S', 'S', 'E', 'D'}; static const char Failed[6] = {'F', 'A', 'I', 'L', 'E', 'D'}; static int SizeOfPassed = 6; static int SizeOfFailed = 6; -} +} // namespace unittest +} // namespace SIMPL + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QTextStream& operator<<(QTextStream& out, const DataArrayPath& v) +{ + out << v.getDataContainerName() << "|" << v.getAttributeMatrixName() << "|" << v.getDataArrayName(); + return out; } // ----------------------------------------------------------------------------- @@ -73,11 +84,11 @@ class TestException : public std::exception { public: /** - * @brief - * @param what - * @param file - * @param lineNumber - */ + * @brief + * @param what + * @param file + * @param lineNumber + */ TestException(const std::string& what, const std::string& filename, int lineNumber) : m_Message(what) , m_FileName(filename) @@ -87,8 +98,8 @@ class TestException : public std::exception } /** - * @brief Copy Constructor - */ + * @brief Copy Constructor + */ TestException(const TestException& te) { m_Message = (&te)->getMessage(); @@ -272,10 +283,10 @@ inline int Sign(float* A) bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) { -// There are several optional checks that you can do, depending -// on what behavior you want from your floating point comparisons. -// These checks should not be necessary and they are included -// mainly for completeness. + // There are several optional checks that you can do, depending + // on what behavior you want from your floating point comparisons. + // These checks should not be necessary and they are included + // mainly for completeness. #ifdef INFINITYCHECK // If A or B are infinity (positive or negative) then @@ -567,4 +578,3 @@ template void require_greater_than(T l, const QString& throw TestException(buf.toStdString(), file.toStdString(), line); } } - diff --git a/Source/H5Support/H5Utilities.h b/Source/H5Support/H5Utilities.h index ccbb0624c6..7b1355386f 100644 --- a/Source/H5Support/H5Utilities.h +++ b/Source/H5Support/H5Utilities.h @@ -36,12 +36,12 @@ namespace H5Support_NAMESPACE /** * @brief General Utilities for working with the HDF5 data files and API */ - class H5Utilities + class H5Support_EXPORT H5Utilities { public: - virtual ~H5Utilities(); + virtual ~H5Utilities() = default; enum CustomHDFDataTypes { @@ -53,11 +53,11 @@ namespace H5Support_NAMESPACE }; // -----------HDF5 File Operations - static H5Support_EXPORT hid_t openFile(const std::string& filename, bool readOnly = false); + static hid_t openFile(const std::string& filename, bool readOnly = false); - static H5Support_EXPORT hid_t createFile(const std::string& filename); + static hid_t createFile(const std::string& filename); - static H5Support_EXPORT herr_t closeFile(hid_t& fileId); + static herr_t closeFile(hid_t& fileId); // -------------- HDF Indentifier Methods ---------------------------- /** @@ -66,7 +66,7 @@ namespace H5Support_NAMESPACE * @param trim set to False to trim the path * @return The path to the object relative to the objId */ - static H5Support_EXPORT std::string getObjectPath(hid_t loc_id, bool trim = false); + static std::string getObjectPath(hid_t loc_id, bool trim = false); /** * @brief Returns the hdf object type @@ -75,7 +75,7 @@ namespace H5Support_NAMESPACE * @param objType The type of the object * @return Negative value on error */ - static H5Support_EXPORT herr_t getObjectType(hid_t objId, const std::string& objName, int32_t* objType); + static herr_t getObjectType(hid_t objId, const std::string& objName, int32_t* objType); /** * @brief Retrieves the object name for a given index @@ -84,7 +84,7 @@ namespace H5Support_NAMESPACE * @param name The variable to store the name * @return Negative value is error */ - static H5Support_EXPORT herr_t objectNameAtIndex(hid_t fileId, int32_t idx, std::string& name); + static herr_t objectNameAtIndex(hid_t fileId, int32_t idx, std::string& name); /** * @brief Returns the path to an object's parent @@ -92,7 +92,7 @@ namespace H5Support_NAMESPACE * @param trim set to False to trim the path * @return The path to the object relative to the objId */ - static H5Support_EXPORT std::string getParentPath(hid_t objId); + static std::string getParentPath(hid_t objId); /** * @brief Returns the path to an object's parent @@ -100,14 +100,14 @@ namespace H5Support_NAMESPACE * @param trim set to False to trim the path * @return The path to the object relative to the objId */ - static H5Support_EXPORT std::string getParentPath(const std::string& objectPath); + static std::string getParentPath(const std::string& objectPath); /** * @brief Returns the object's name from object path * @param objectPath The HDF5 path to the object * @return The object name */ - static H5Support_EXPORT std::string getObjectNameFromPath(const std::string& objectPath); + static std::string getObjectNameFromPath(const std::string& objectPath); /** * @brief Returns if a given hdf5 object is a group @@ -115,7 +115,7 @@ namespace H5Support_NAMESPACE * @param objName The name of the object to check * @return True if the given hdf5 object id is a group */ - static H5Support_EXPORT bool isGroup(hid_t nodeId, const std::string& objName); + static bool isGroup(hid_t nodeId, const std::string& objName); /** @@ -124,23 +124,23 @@ namespace H5Support_NAMESPACE * @param objectPath The path of the object to open * @return The hdf5 id of the opened object. Negative value is error. */ - static H5Support_EXPORT hid_t openHDF5Object(hid_t loc_id, const std::string& objName); + static hid_t openHDF5Object(hid_t loc_id, const std::string& objName); /** * @brief Closes the object id * @param locId The object id to close * @return Negative value is error. */ - static H5Support_EXPORT herr_t closeHDF5Object(hid_t obj_id); + static herr_t closeHDF5Object(hid_t obj_id); - static H5Support_EXPORT std::string HDFClassTypeAsStr(hid_t class_type); + static std::string HDFClassTypeAsStr(hid_t class_type); /** * @brief prints the class type of the given class * @param classT The Class Type to print */ - static H5Support_EXPORT void printHDFClassType(H5T_class_t class_type); + static void printHDFClassType(H5T_class_t class_type); // -------------- HDF Group Methods ---------------------------- /** @@ -150,7 +150,7 @@ namespace H5Support_NAMESPACE * @param names Variable to store the list * @return */ - static H5Support_EXPORT herr_t getGroupObjects(hid_t loc_id, int32_t typeFilter, std::list& names); + static herr_t getGroupObjects(hid_t loc_id, int32_t typeFilter, std::list& names); /** * @brief Creates a HDF Group by checking if the group already exists. If the @@ -160,7 +160,7 @@ namespace H5Support_NAMESPACE * @param group The name of the group to create. Note that this group name should * not be any sort of 'path'. It should be a single group. */ - static H5Support_EXPORT hid_t createGroup(hid_t loc_id, const std::string& group); + static hid_t createGroup(hid_t loc_id, const std::string& group); /** * @brief Given a path relative to the Parent ID, this method will create all @@ -169,7 +169,7 @@ namespace H5Support_NAMESPACE * @param parent The HDF unique id for the parent * @return Error Condition: Negative is error. Positive is success. */ - static H5Support_EXPORT hid_t createGroupsFromPath(const std::string& pathToCheck, hid_t parent); + static hid_t createGroupsFromPath(const std::string& pathToCheck, hid_t parent); /** * @brief Given a path relative to the Parent ID, this method will create all @@ -178,14 +178,14 @@ namespace H5Support_NAMESPACE * @param parent The HDF unique id for the parent * @return Error Condition: Negative is error. Positive is success. */ - static H5Support_EXPORT hid_t createGroupsForDataset(const std::string& datasetPath, hid_t parent); + static hid_t createGroupsForDataset(const std::string& datasetPath, hid_t parent); /** * @brief Extracts the object name from a given path * @param path The path which to extract the object name * @return The name of the object */ - static H5Support_EXPORT std::string extractObjectName(const std::string& path); + static std::string extractObjectName(const std::string& path); // -------------- HDF Attribute Methods ---------------------------- /** @@ -195,7 +195,7 @@ namespace H5Support_NAMESPACE * @param attr_name The attribute to look for (by name) * @return True if the attribute exists. */ - static H5Support_EXPORT bool probeForAttribute(hid_t loc_id, + static bool probeForAttribute(hid_t loc_id, const std::string& obj_name, const std::string& attr_name); @@ -206,7 +206,7 @@ namespace H5Support_NAMESPACE * @param names Variable to hold the list of attribute names * @return Negate value is error */ - static H5Support_EXPORT herr_t getAllAttributeNames(hid_t obj_id, std::list& results); + static herr_t getAllAttributeNames(hid_t obj_id, std::list& results); /** * @brief Returns a list of all the attribute names @@ -215,7 +215,7 @@ namespace H5Support_NAMESPACE * @param names Variable to hold the list of attribute names * @return Negative value is error */ - static H5Support_EXPORT herr_t getAllAttributeNames(hid_t loc_id, const std::string& obj_name, + static herr_t getAllAttributeNames(hid_t loc_id, const std::string& obj_name, std::list& names); diff --git a/Source/PipelineRunner/PipelineRunner.cpp b/Source/PipelineRunner/PipelineRunner.cpp index eb9f2a4ddb..5ad9c87b6c 100644 --- a/Source/PipelineRunner/PipelineRunner.cpp +++ b/Source/PipelineRunner/PipelineRunner.cpp @@ -154,7 +154,7 @@ int main(int argc, char* argv[]) } // Now actually execute the pipeline pipeline->execute(); - err = pipeline->getErrorCondition(); + err = pipeline->getErrorCode(); if(err < 0) { std::cout << "Error Condition of Pipeline: " << err << std::endl; diff --git a/Source/SIMPLib/CMakeLists.txt b/Source/SIMPLib/CMakeLists.txt index 732a265420..c25732fd2a 100755 --- a/Source/SIMPLib/CMakeLists.txt +++ b/Source/SIMPLib/CMakeLists.txt @@ -87,7 +87,7 @@ endMacro() #------------------------------------------------------------------------------ # Set up the directories that are used for each Group -set(SIMPL_Group_BASE_MODULES Common DataArrays DataContainers Geometry HDF5 Math StatsData Utilities ITK) +set(SIMPL_Group_BASE_MODULES Common DataArrays DataContainers Geometry HDF5 Math Messages StatsData Utilities ITK) set(SIMPL_Group_FILTERS_MODULES Filtering FilterParameters VTKUtils) set(SIMPL_Group_PLUGIN_MODULES Plugin) set(SIMPL_Group_REST_MODULES REST) diff --git a/Source/SIMPLib/Common/Constants.h b/Source/SIMPLib/Common/Constants.h index 6794f321a0..4f1bd78683 100644 --- a/Source/SIMPLib/Common/Constants.h +++ b/Source/SIMPLib/Common/Constants.h @@ -62,9 +62,9 @@ namespace SIMPL enum InfoStringFormat { - HtmlFormat = 0, + ToolTipFormat = 0, // JsonFormat, -// TextFormat, + HtmlFormat, // XmlFormat, UnknownFormat }; @@ -302,7 +302,7 @@ namespace SIMPL const QString GroupingFilters("Grouping"); const QString CropCutFilters("Croping/Cutting"); const QString RotationTransformationFilters("Rotating/Transforming"); - const QString ResolutionFilters("Resolution"); + const QString ResolutionFilters("Spacing"); const QString MorphologicalFilters("Morphological"); const QString PackingFilters("Packing"); const QString CrystallographyFilters("Crystallography"); @@ -313,6 +313,8 @@ namespace SIMPL const QString MappingFilters("Mapping"); const QString MiscFilters("Misc"); const QString GeometryFilters("Geometry"); + const QString ImportFilters("Import"); + const QString ExportFilters("Export"); } namespace GeneralData diff --git a/Source/SIMPLib/Common/IObserver.cpp b/Source/SIMPLib/Common/IObserver.cpp index 994bfd205a..fdacb87c06 100644 --- a/Source/SIMPLib/Common/IObserver.cpp +++ b/Source/SIMPLib/Common/IObserver.cpp @@ -50,34 +50,10 @@ IObserver::~IObserver() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IObserver::processPipelineMessage(const PipelineMessage& pm) +void IObserver::processPipelineMessage(const AbstractMessage::Pointer& pm) { - PipelineMessage msg = pm; QString str; QTextStream ss(&str); - if(msg.getType() == PipelineMessage::MessageType::Error) - { - ss << msg.generateErrorString(); - } - else if(msg.getType() == PipelineMessage::MessageType::Warning) - { - ss << msg.generateWarningString(); - } - else if(msg.getType() == PipelineMessage::MessageType::StatusMessage) - { - ss << msg.generateStatusString(); - } - else if(msg.getType() == PipelineMessage::MessageType::StandardOutputMessage) - { - ss << msg.generateStandardOutputString(); - } - else if(msg.getType() == PipelineMessage::MessageType::ProgressValue) - { - ss << msg.getProgressValue() << "%"; - } - else if(msg.getType() == PipelineMessage::MessageType::StatusMessageAndProgressValue) - { - ss << msg.getProgressValue() << msg.generateStatusString(); - } - std::cout << msg.getFilterHumanLabel().toStdString() << ": " << str.toStdString() << std::endl; + ss << pm->generateMessageString(); + std::cout << str.toStdString() << std::endl; } diff --git a/Source/SIMPLib/Common/IObserver.h b/Source/SIMPLib/Common/IObserver.h index 7d9811cec2..f55c2314ba 100755 --- a/Source/SIMPLib/Common/IObserver.h +++ b/Source/SIMPLib/Common/IObserver.h @@ -38,7 +38,7 @@ #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" class SIMPLib_EXPORT IObserver { @@ -47,7 +47,7 @@ class SIMPLib_EXPORT IObserver virtual ~IObserver(); SIMPL_TYPE_MACRO(IObserver) - virtual void processPipelineMessage(const PipelineMessage& pm); + virtual void processPipelineMessage(const AbstractMessage::Pointer& pm); public: IObserver(const IObserver&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/Common/Observable.cpp b/Source/SIMPLib/Common/Observable.cpp index d921d9090f..9ae0734723 100644 --- a/Source/SIMPLib/Common/Observable.cpp +++ b/Source/SIMPLib/Common/Observable.cpp @@ -35,6 +35,11 @@ #include "Observable.h" +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/GenericProgressMessage.h" +#include "SIMPLib/Messages/GenericStatusMessage.h" +#include "SIMPLib/Messages/GenericWarningMessage.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -65,65 +70,79 @@ void Observable::operator=(const Observable&) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::broadcastPipelineMessage(const PipelineMessage& msg) +void Observable::setErrorCondition(int code, const QString &messageText) { - emit filterGeneratedMessage(msg); + GenericErrorMessage::Pointer pm = GenericErrorMessage::New(messageText, code); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyErrorMessage(const QString& humanLabel, const QString& str, int code) +void Observable::setErrorConditionWithPrefix(int code, const QString &prefix, const QString &messageText) { - PipelineMessage pm = PipelineMessage::CreateErrorMessage(getNameOfClass(), humanLabel, str, code); - emit filterGeneratedMessage(pm); + QString msg = messageText; + msg.prepend(tr("%1 - ").arg(prefix)); + + setErrorCondition(code, msg); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyStatusMessage(const QString& humanLabel, const QString& str) +void Observable::setWarningCondition(int code, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - emit filterGeneratedMessage(pm); + GenericWarningMessage::Pointer pm = GenericWarningMessage::New(messageText, code); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& str) +void Observable::setWarningConditionWithPrefix(int code, const QString &prefix, const QString &messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - emit filterGeneratedMessage(pm); + QString msg = messageText; + msg.prepend(tr("%1 - ").arg(prefix)); + + setWarningCondition(code, msg); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& str) +void Observable::notifyStatusMessage(const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStandardOutputMessage(humanLabel, pipelineIndex, str); - emit filterGeneratedMessage(pm); + GenericStatusMessage::Pointer pm = GenericStatusMessage::New(messageText); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyWarningMessage(const QString& humanLabel, const QString& str, int code) +void Observable::notifyStatusMessageWithPrefix(const QString &prefix, const QString &messageText) { - PipelineMessage pm = PipelineMessage::CreateWarningMessage(getNameOfClass(), humanLabel, str, code); - emit filterGeneratedMessage(pm); + QString msg = messageText; + msg.prepend(tr("%1 - ").arg(prefix)); + + notifyStatusMessage(msg); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress) +void Observable::notifyProgressMessage(int progress, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - pm.setProgressValue(progress); - pm.setType(PipelineMessage::MessageType::StatusMessageAndProgressValue); - emit filterGeneratedMessage(pm); + GenericProgressMessage::Pointer pm = GenericProgressMessage::New(messageText, progress); + emit messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void Observable::notifyProgressMessageWithPrefix(int progress, const QString &prefix, const QString &messageText) +{ + QString msg = messageText; + msg.prepend(tr("%1: ").arg(prefix)); + + notifyProgressMessage(progress, msg); } diff --git a/Source/SIMPLib/Common/Observable.h b/Source/SIMPLib/Common/Observable.h index 8480156c43..ec8fd5b679 100755 --- a/Source/SIMPLib/Common/Observable.h +++ b/Source/SIMPLib/Common/Observable.h @@ -40,7 +40,7 @@ #include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" /** @@ -55,7 +55,14 @@ class SIMPLib_EXPORT Observable : public QObject { Q_OBJECT PYB11_CREATE_BINDINGS(Observable) - PYB11_METHOD(void notifyErrorMessage ARGS humanLabel ss code) + PYB11_METHOD(void setErrorCondition ARGS code messageText) + PYB11_METHOD(void setErrorConditionWithPrefix ARGS code prefix messageText) + PYB11_METHOD(void setWarningCondition ARGS code messageText) + PYB11_METHOD(void setWarningConditionWithPrefix ARGS code prefix messageText) + PYB11_METHOD(void notifyStatusMessage ARGS messageText) + PYB11_METHOD(void notifyStatusMessageWithPrefix ARGS prefix messageText) + PYB11_METHOD(void notifyProgressMessage ARGS progress messageText) + PYB11_METHOD(void notifyProgressMessageWithPrefix ARGS progress prefix messageText) public: SIMPL_TYPE_MACRO(Observable) @@ -69,38 +76,31 @@ class SIMPLib_EXPORT Observable : public QObject void operator=(const Observable&); // ------------------------------ - // These are convenience methods that construct a @see PipelineMessage object and then 'emit' that object + // These are convenience methods that construct a @see AbstractMessage object and then 'emit' that object // ------------------------------ - virtual void notifyErrorMessage(const QString& humanLabel, const QString& ss, int code); + virtual void setErrorCondition(int code, const QString& messageText); - virtual void notifyWarningMessage(const QString& humanLabel, const QString& ss, int code); + void setErrorConditionWithPrefix(int code, const QString &prefix, const QString& messageText); - virtual void notifyStatusMessage(const QString& humanLabel, const QString& ss); + virtual void setWarningCondition(int code, const QString& messageText); - virtual void notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& ss); + void setWarningConditionWithPrefix(int code, const QString &prefix, const QString& messageText); - virtual void notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& ss); + virtual void notifyStatusMessage(const QString& messageText); - virtual void notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress); + void notifyStatusMessageWithPrefix(const QString &prefix, const QString& messageText); - public slots: - - /** - * @brief This method will cause this object to 'emit' the filterGeneratedMessage() signal. This is useful if other - * classes need the filter to emit an error or warning messge from a class that is not able to emit the proper signals - * or the class is not connected to anything that would receive the signals - * @param msg - */ - void broadcastPipelineMessage(const PipelineMessage& msg); + virtual void notifyProgressMessage(int progress, const QString& messageText); + void notifyProgressMessageWithPrefix(int progress, const QString &prefix, const QString& messageText); signals: /** - * @brief filterGeneratedMessage This is a Qt Signal that is used when the filter generates Errors, Warnings, Status and Progress Messages + * @brief messageGenerated This is a Qt Signal that is used when the filter generates Errors, Warnings, Status and Progress Messages * @param msg */ - void filterGeneratedMessage(const PipelineMessage& msg); + void messageGenerated(const AbstractMessage::Pointer& msg); }; diff --git a/Source/SIMPLib/Common/Observer.cpp b/Source/SIMPLib/Common/Observer.cpp index 05936774cb..e4e2f3125a 100644 --- a/Source/SIMPLib/Common/Observer.cpp +++ b/Source/SIMPLib/Common/Observer.cpp @@ -50,7 +50,7 @@ Observer::~Observer() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observer::processPipelineMessage(const PipelineMessage& pm) +void Observer::processPipelineMessage(const AbstractMessage::Pointer& pm) { // Just call the superclass IObserver::processPipelineMessage(pm); diff --git a/Source/SIMPLib/Common/Observer.h b/Source/SIMPLib/Common/Observer.h index db5aa2a174..fc0fae5605 100755 --- a/Source/SIMPLib/Common/Observer.h +++ b/Source/SIMPLib/Common/Observer.h @@ -43,7 +43,7 @@ #include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Common/IObserver.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" /** * @class Observer Observer.h DREAM3D/Common/Observer.h @@ -65,7 +65,7 @@ class SIMPLib_EXPORT Observer : public QObject, public IObserver ~Observer() override; public slots: - void processPipelineMessage(const PipelineMessage& pm) override; + void processPipelineMessage(const AbstractMessage::Pointer& pm) override; public: Observer(const Observer&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/Common/PipelineMessage.h b/Source/SIMPLib/Common/PipelineMessage.h deleted file mode 100755 index 104190a972..0000000000 --- a/Source/SIMPLib/Common/PipelineMessage.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - -#include -#include - -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" - - -/** - * @class PipelineMessage PipelineMessage.h DREAM3DLib/Common/PipelineMessage.h - * @brief This class enables the creation of Error, Warning, and Status messages that - * can be sent up from filters to the DREAM3D GUI. - */ -class SIMPLib_EXPORT PipelineMessage -{ - public: - using EnumType = unsigned int; - - enum class MessageType : EnumType - { - Error = 0, - Warning = 1, - StatusMessage = 2, - StandardOutputMessage = 3, - ProgressValue = 4, - StatusMessageAndProgressValue = 5, - UnknownMessageType = 6 - }; - - PipelineMessage(); - - PipelineMessage(const PipelineMessage& rhs); - - PipelineMessage(const QString& className, const char* msg, int code, MessageType msgType = MessageType::UnknownMessageType, int progress = -1); - - PipelineMessage(const QString& className, const QString& msg, int code, MessageType msgType = MessageType::UnknownMessageType, int progress = -1); - PipelineMessage(const QString& className, const QString& humanLabel, const QString& msg, int code, MessageType msgType = MessageType::UnknownMessageType, int progress = -1); - - PipelineMessage(const QString& humanLabel, int pipelineIndex, const QString& msg, MessageType msgType = MessageType::UnknownMessageType); - - static PipelineMessage CreateErrorMessage(const QString className, const QString humanLabel, const QString msg, int code); - - static PipelineMessage CreateStatusMessage(const QString className, const QString humanLabel, const QString msg); - - static PipelineMessage CreateWarningMessage(const QString className, const QString humanLabel, const QString msg, int code); - - static PipelineMessage CreateStandardOutputMessage(const QString humanLabel, int pipelineIndex, const QString msg); - - - SIMPL_TYPE_MACRO(PipelineMessage) - - virtual ~PipelineMessage(); - - bool operator==(const PipelineMessage& rhs); - - void operator=(const PipelineMessage& rhs); - - SIMPL_INSTANCE_STRING_PROPERTY(FilterClassName) - - SIMPL_INSTANCE_STRING_PROPERTY(FilterHumanLabel) - - SIMPL_INSTANCE_STRING_PROPERTY(Prefix) - - SIMPL_INSTANCE_STRING_PROPERTY(Text) - - SIMPL_INSTANCE_PROPERTY(int, Code) - - SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) - - SIMPL_INSTANCE_PROPERTY(MessageType, Type) - - SIMPL_INSTANCE_PROPERTY(int, ProgressValue) - - /** - * @brief This method creates and returns a string for error messages - */ - QString generateErrorString() const; - - /** - * @brief This method creates and returns a string for warning messages - */ - QString generateWarningString() const; - - /** - * @brief This method creates and returns a string for status messages - */ - QString generateStatusString() const; - - /** - * @brief This method creates and returns a string for standard output messages - */ - QString generateStandardOutputString() const; - - /** - * @brief This method generates a status message that includes a progress value. - * @return - */ - QString generateProgressString() const; - - - private: - -}; - - -Q_DECLARE_METATYPE(PipelineMessage) - - diff --git a/Source/SIMPLib/Common/SIMPLArray.hpp b/Source/SIMPLib/Common/SIMPLArray.hpp new file mode 100644 index 0000000000..ca665298d6 --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLArray.hpp @@ -0,0 +1,440 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +#include +#include +#include + +#include + +/** + * @brief This class is a facade pattern around a std::array array to allow for some semantics + * for either a 2D or 3D point such as X,Y,Z. We Provide 3 concrete implementations that are for 2, 3 and 4 element + * arrays used in some of the filter parameters. The devloper can extend this quite easily to more + * elements should they need them + */ +template +class SIMPLArray +{ +public: + SIMPLArray() = default; + SIMPLArray(const SIMPLArray&) = default; + SIMPLArray(SIMPLArray&&) noexcept = default; + SIMPLArray& operator=(const SIMPLArray&) = default; + SIMPLArray& operator=(SIMPLArray&&) noexcept = default; + ~SIMPLArray() = default; + + //========================================= STL INTERFACE COMPATIBILITY ================================= + using size_type = size_t; + using value_type = T; + using reference = T&; + using const_reference = const T&; + using iterator_category = std::input_iterator_tag; + using pointer = T*; + using difference_type = value_type; + using iterator = typename std::array::iterator; + using const_iterator = typename std::array::const_iterator; + //========================================= END STL INTERFACE COMPATIBILITY ============================== + + /** + * @brief access specified element + * @param index + * @return + */ + inline reference operator[](size_type index) + { + return m_Array[index]; + } + + /** + * @brief access specified element + * @param index + * @return + */ + inline const_reference operator[](size_type index) const + { + return m_Array[index]; + } + + /** + * @brief access specified element with bounds checking + * @param index + * @return + */ + inline reference at(size_type index) + { + assert(index < Dimension); + return m_Array.at(index); + } + + /** + * @brief access specified element with bounds checking + * @param index + * @return + */ + inline const_reference at(size_type index) const + { + assert(index < Dimension); + return m_Array.at(index); + } + + /** + * @brief returns an iterator to the beginning + * @return + */ + iterator begin() + { + return m_Array.begin(); + } + + /** + * @brief returns an iterator to the end + * @return + */ + iterator end() + { + return m_Array.end(); + } + + /** + * @brief returns an iterator to the beginning + * @return + */ + const_iterator begin() const + { + return m_Array.cbegin(); + } + + /** + * @brief returns an iterator to the end + * @return + */ + const_iterator end() const + { + return m_Array.cend(); + } + + /** + * @brief direct access to the underlying array + * @return + */ + pointer data() + { + return m_Array.data(); + } + + /** + * @brief Returns the number of elements + * @return + */ + size_type size() + { + return Dimension; + } + + /** + * @brief operator == Tests for an element by element equivelance of the underlying data + * @param rhs + * @return + */ + bool operator==(const SIMPLArray& rhs) const + { + return m_Array == rhs.m_Array; + } + +protected: + void setValue(size_t i, value_type value) + { + m_Array[i] = value; + } + +private: + std::array m_Array; +}; + +// ----------------------------------------------------------------------------- +template +class IVec2 : public SIMPLArray +{ + using ParentType = SIMPLArray; + +public: + IVec2(const IVec2&) = default; + IVec2(IVec2&&) noexcept = default; + IVec2& operator=(const IVec2&) = default; + IVec2& operator=(IVec2&&) noexcept = default; + ~IVec2() = default; + + /** + * @brief IVec2 Default constructor initializes all values to ZERO. + */ + IVec2() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + } + + IVec2(T x, T y) + { + (*this)[0] = x; + (*this)[1] = y; + } + + IVec2(std::array data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + } + IVec2(std::tuple data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + } + IVec2(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + } + + inline T getX() const + { + return ParentType::operator[](0); + } + inline T getY() const + { + return ParentType::operator[](1); + } + inline void setX(const T& x) + { + (*this)[0] = x; + } + inline void setY(const T& y) + { + (*this)[1] = y; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple(getX(), getY()); + } +}; + +using FloatVec2Type = IVec2; +using IntVec2Type = IVec2; +using SizeVec2Type = IVec2; + +// ----------------------------------------------------------------------------- +template class IVec3 : public SIMPLArray +{ + using ParentType = SIMPLArray; +public: + IVec3(const IVec3&) = default; + IVec3(IVec3&&) noexcept = default; + IVec3& operator=(const IVec3&) = default; + IVec3& operator=(IVec3&&) noexcept = default; + ~IVec3() = default; + + /** + * @brief IVec3 Default constructor initializes all values to ZERO. + */ + IVec3() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + (*this)[2] = static_cast(0); + } + + IVec3(T x, T y, T z) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + } + + IVec3(std::array data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + } + IVec3(std::tuple data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + (*this)[2] = std::get<2>(data); + } + IVec3(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + } + + inline T getX() const + { + return ParentType::operator[](0); + } + inline T getY() const + { + return ParentType::operator[](1); + } + inline T getZ() const + { + return ParentType::operator[](2); + } + inline void setX(const T& x) + { + (*this)[0] = x; + } + inline void setY(const T& y) + { + (*this)[1] = y; + } + inline void setZ(const T& z) + { + (*this)[2] = z; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple(getX(), getY(), getZ()); + } +}; + +using FloatVec3Type = IVec3; +using IntVec3Type = IVec3; +using SizeVec3Type = IVec3; + +// ----------------------------------------------------------------------------- +template class IVec4 : public SIMPLArray +{ + using ParentType = SIMPLArray; +public: + IVec4(const IVec4&) = default; + IVec4(IVec4&&) noexcept = default; + IVec4& operator=(const IVec4&) = default; + IVec4& operator=(IVec4&&) noexcept = default; + ~IVec4() = default; + + /** + * @brief IVec4 Default constructor initializes all values to ZERO. + */ + IVec4() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + (*this)[2] = static_cast(0); + (*this)[3] = static_cast(0); + } + + IVec4(T x, T y, T z, T w) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = w; + } + + IVec4(std::array data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + } + IVec4(std::tuple data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + (*this)[2] = std::get<2>(data); + (*this)[3] = std::get<3>(data); + } + IVec4(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + } + + inline T getX() const + { + return ParentType::operator[](0); + } + inline T getY() const + { + return ParentType::operator[](1); + } + inline T getZ() const + { + return ParentType::operator[](2); + } + inline T getW() const + { + return ParentType::operator[](3); + } + inline void setX(const T& x) + { + (*this)[0] = x; + } + inline void setY(const T& y) + { + (*this)[1] = y; + } + inline void setZ(const T& z) + { + (*this)[2] = z; + } + inline void setW(const T& w) + { + (*this)[3] = w; + } + + std::tuple toTuple() const + { + return std::make_tuple(getX(), getY(), getZ(), getW()); + } +}; + +using QuaternionType = IVec4; +using FloatVec4Type = IVec4; +using IntVec4Type = IVec4; +using SizeVec4Type = IVec4; diff --git a/Source/SIMPLib/Common/SIMPLibSetGetMacros.h b/Source/SIMPLib/Common/SIMPLibSetGetMacros.h index 1e94449b29..db8c189f9e 100755 --- a/Source/SIMPLib/Common/SIMPLibSetGetMacros.h +++ b/Source/SIMPLib/Common/SIMPLibSetGetMacros.h @@ -260,21 +260,21 @@ public: \ #define SIMPL_INSTANCE_PROPERTY_DECL(type, prpty)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ public:\ SIMPL_SET_PROPERTY_DECL(type, prpty)\ SIMPL_GET_PROPERTY_DECL(type, prpty) #define SIMPL_INSTANCE_PROPERTY_DECL(type, prpty)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ public:\ SIMPL_SET_PROPERTY_DECL(type, prpty)\ SIMPL_GET_PROPERTY_DECL(type, prpty) #define SIMPL_VIRTUAL_INSTANCE_PROPERTY_DECL(type, prpty)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ public:\ virtual SIMPL_SET_PROPERTY_DECL(type, prpty)\ virtual SIMPL_GET_PROPERTY_DECL(type, prpty) @@ -299,7 +299,7 @@ public: \ */ #define SIMPL_VIRTUAL_INSTANCE_PROPERTY(type, prpty)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ public:\ virtual SIMPL_SET_PROPERTY(type, prpty)\ virtual SIMPL_GET_PROPERTY(type, prpty) @@ -307,37 +307,37 @@ public: \ #define SIMPL_INSTANCE_PROPERTY(type, prpty)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ public:\ SIMPL_SET_PROPERTY(type, prpty)\ SIMPL_GET_PROPERTY(type, prpty) - - -#define SIMPL_POINTER_PROPERTY(type, prpty)\ - private:\ - type* m_##prpty = nullptr;\ - public:\ - void set##prpty(type* f) { m_##prpty = f; }\ - SIMPL_GET_PROPERTY(type*, prpty) - +#define SIMPL_POINTER_PROPERTY(type, prpty) \ +private: \ + type* m_##prpty = nullptr; \ + \ +public: \ + void set##prpty(type* f) \ + { \ + m_##prpty = f; \ + } \ + SIMPL_GET_PROPERTY(type*, prpty) #define SIMPL_PRIVATE_INSTANCE_PROPERTY(type, prpty)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ SIMPL_SET_PROPERTY(type, prpty)\ public:\ SIMPL_GET_PROPERTY(type, prpty) - /* ***************************************************************************** * ***************************************************************************** * ***************************************************************************** - * + * * PyBind11 Macros that we can use to explicitly define which setters & getters * will be exposed to the Python library */ - + /** * @brief PYB11_CREATE_BINDINGS This macro lets the wrapper know that we want to * wrap this class with Python bindings. It should only take a single argument @@ -361,27 +361,34 @@ public: \ #define PYB11_NO_BINDINGS(...) /** -* @brief PYB11_STATIC_CREATION This macro will wrap the "static New()" function -* that most of the SIMPL classes implement as a way to instantiate the class in -* addition to other static methods that are used for a class. The argument types -* to the static method should be listed WITHOUT any spaces for each argument. -* -* @code -* PYB11_STATIC_CREATION(Create ARGS std::vector> std::list std::list) -* @endcode -*/ + * @brief PYB11_STATIC_CREATION This macro will wrap the "static New()" function + * that most of the SIMPL classes implement as a way to instantiate the class in + * addition to other static methods that are used for a class. The argument types + * to the static method should be listed WITHOUT any spaces for each argument. + * + * @code + * PYB11_STATIC_CREATION(Create ARGS std::vector> std::list std::list) + * @endcode + * + * If there are several static creation methods that overload each other then the following form can be used: + * + * @code + * PYB11_STATIC_CREATION(New OVERLOAD QString) + * PYB11_STATIC_CREATION(New OVERLOAD DataArrayPath) + * @endcode + */ #define PYB11_STATIC_CREATION(...) /** -* @brief PYB11_CREATION This macro is used for non-static constructors that need -* to be wrapped. The argument types need to be lists where each argument cannot -* containe spaces. Use a typedef if needed, but using a typedef also has its -* own issues. @see DataArrayPath for an example. -* -* @code -* PYB11_CREATION(ARGS QString QString QString) -* @endcode -*/ + * @brief PYB11_CREATION This macro is used for non-static constructors that need + * to be wrapped. The argument types need to be lists where each argument cannot + * containe spaces. Use a typedef if needed, but using a typedef also has its + * own issues. @see DataArrayPath for an example. + * + * @code + * PYB11_CREATION(ARGS QString QString QString) + * @endcode + */ #define PYB11_CREATION(...) /** @@ -448,6 +455,14 @@ public: \ * Note that in order to get the (const QString &) correct we used the '.' charater * to declare the type. This is required as the macro is split using spaces. When * then end code is generated the '.' characters will be replaced with spaces. + * + * If the method that is being wrapped in python is a 'const' method then the last argument should be CONST_METHOD. In + * the example below there is a pair of overloaded methods that are both 'const'. + * + * @code + * PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.QString.&,Name CONST_METHOD) + * PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) + * @endcode */ #define PYB11_METHOD(...) @@ -468,31 +483,42 @@ public: \ #define SIMPL_PIMPL_PROPERTY_DECL(type, prpty)\ public:\ - void set##prpty(const type& value);\ + SIMPL_PIMPL_GET_PROPERTY_DECL(type, prpty)\ + SIMPL_PIMPL_SET_PROPERTY_DECL(type, prpty)\ + +#define SIMPL_PIMPL_GET_PROPERTY_DECL(type, prpty)\ type get##prpty() const; +#define SIMPL_PIMPL_SET_PROPERTY_DECL(type, prpty)\ + void set##prpty(const type& value);\ #define SIMPL_PIMPL_PROPERTY_DEF(Class, type, prpty)\ - void Class::set##prpty(const type& value) {\ - Q_D(Class);\ - d->m_##prpty = value;\ - }\ + SIMPL_PIMPL_SET_PROPERTY_DEF(Class, type, prpty)\ + SIMPL_PIMPL_GET_PROPERTY_DEF(Class, type, prpty)\ + +#define SIMPL_PIMPL_GET_PROPERTY_DEF(Class, type, prpty)\ type Class::get##prpty() const {\ Q_D(const Class);\ return d->m_##prpty;\ } +#define SIMPL_PIMPL_SET_PROPERTY_DEF(Class, type, prpty)\ + void Class::set##prpty(const type& value) {\ + Q_D(Class);\ + d->m_##prpty = value;\ + }\ + #define SIMPL_OVERLOAD_PROPERTY(type, prpty, overload)\ private:\ - type m_##prpty;\ + type m_##prpty = {};\ public:\ SIMPL_SET_PROPERTY(overload, prpty)\ SIMPL_GET_PROPERTY(overload, prpty) #define SIMPL_BOOL_PROPERTY(prpty)\ private:\ - bool m_##prpty;\ + bool m_##prpty = false;\ public:\ virtual SIMPL_SET_PROPERTY(bool, prpty)\ SIMPL_GET_BOOL_PROPERTY(prpty)\ @@ -524,9 +550,6 @@ public: \ public:\ void set##prpty(const type& value) { this->m_##prpty = value; }\ type get##prpty() const { return m_##prpty; } - - - // ----------------------------------------------------------------------------- // @@ -565,7 +588,7 @@ public: \ (varname)[0] = value_0; (varname)[1] = value_1; (varname)[2] = value_2; }\ void set##prpty(const std::tuple &var) {\ (varname)[0] = std::get<0>(var); (varname)[1] = std::get<1>(var); (varname)[2] = std::get<2>(var); } - + #define SIMPL_GET_VEC3_PROPERTY(type, prpty, varname)\ void get##prpty(type value[3]) {\ value[0] = (varname)[0]; value[1] = (varname)[1]; value[2] = (varname)[2]; }\ @@ -604,7 +627,7 @@ public: \ public:\ SIMPL_SET_VEC3_PROPERTY_VO(type, prpty, m_##prpty)\ SIMPL_GET_VEC3_PROPERTY_VO(type, prpty, m_##prpty) - + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Common/SourceList.cmake b/Source/SIMPLib/Common/SourceList.cmake index 2217d459b0..00c1558c1c 100755 --- a/Source/SIMPLib/Common/SourceList.cmake +++ b/Source/SIMPLib/Common/SourceList.cmake @@ -19,23 +19,21 @@ set_source_files_properties( ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} PROPER set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AppVersion.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Constants.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/CreatedArrayHelpIndexEntry.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IObserver.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PhaseType.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineMessage.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLibDLLExport.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLibSetGetMacros.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ScopedFileMonitor.hpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ShapeType.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLArray.hpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/TemplateHelpers.h ) set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AppVersion.cpp - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/CreatedArrayHelpIndexEntry.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DocRequestManager.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/EnsembleInfo.cpp @@ -43,7 +41,6 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Observable.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Observer.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PhaseType.cpp - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineMessage.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ShapeType.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/TemplateHelpers.cpp @@ -62,4 +59,11 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} ) +#------------------------------------------------------------------------------- +# Add the unit testing sources +# -------------------------------------------------------------------- +# If Testing is enabled, turn on the Unit Tests +if(SIMPL_BUILD_TESTING) + include(${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx/SourceList.cmake) +endif() diff --git a/Source/SIMPLib/Common/TemplateHelpers.cpp b/Source/SIMPLib/Common/TemplateHelpers.cpp index 691b501a3f..42be46c80a 100644 --- a/Source/SIMPLib/Common/TemplateHelpers.cpp +++ b/Source/SIMPLib/Common/TemplateHelpers.cpp @@ -37,115 +37,113 @@ using namespace TemplateHelpers; // ----------------------------------------------------------------------------- -IDataArrayWkPtr CreateNonPrereqArrayFromArrayType::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, const IDataArrayShPtr& sourceArrayType) +IDataArrayWkPtr CreateNonPrereqArrayFromArrayType::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, const IDataArrayShPtr& sourceArrayType, RenameDataPath::DataID_t id) { IDataArrayShPtr ptr = IDataArray::NullPointer(); if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(f, arrayPath, 0.0f, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(f, arrayPath, 0.0f, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>(f, arrayPath, 0.0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>(f, arrayPath, 0.0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int8_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int8_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int16_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int16_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint16_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint16_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint32_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint32_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint64_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint64_t>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, false, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, false, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, 0, compDims, "", id); } else { QString msg = QObject::tr("The created array '%1' is of unsupported type. The following types are supported: %3").arg(arrayPath.getDataArrayName()).arg(SIMPL::TypeNames::SupportedTypeList); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); } return ptr; } // ----------------------------------------------------------------------------- -IDataArrayWkPtr CreateNonPrereqArrayFromTypeEnum::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, int arrayType, double initValue) +IDataArrayWkPtr CreateNonPrereqArrayFromTypeEnum::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, int arrayType, double initValue, RenameDataPath::DataID_t id) { IDataArrayShPtr ptr = IDataArray::NullPointer(); switch(arrayType) { case SIMPL::TypeEnums::Int8: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int8_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int8_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt8: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Int16: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int16_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int16_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt16: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint16_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint16_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Int32: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt32: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint32_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint32_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Int64: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt64: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint64_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint64_t>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Float: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Double: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Bool: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::SizeT: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, static_cast(initValue), compDims, "", id); break; default: QString msg = QObject::tr("The created array '%1' is of unsupported type. The following types are supported: %3").arg(arrayPath.getDataArrayName()).arg(SIMPL::TypeEnums::SupportedTypeList); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); break; } return ptr; @@ -217,8 +215,7 @@ IDataArrayShPtr CreateArrayFromArrayType::operator()(AbstractFilter* f, const QV else { QString msg = QObject::tr("The created array is of unsupported type."); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); } return ptr; } @@ -284,8 +281,7 @@ IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const QVector else { QString msg = QObject::tr("The created array is of unsupported type."); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); } return ptr; } @@ -294,28 +290,25 @@ IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const QVector IDataArrayWkPtr GetPrereqArrayFromPath::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, QVector& compDims) { IDataArrayShPtr retPtr = IDataArray::NullPointer(); - DataContainer::Pointer volDataCntr = f->getDataContainerArray()->template getPrereqDataContainer(f, arrayPath.getDataContainerName(), false); - if(f->getErrorCondition() < 0 || nullptr == volDataCntr) + DataContainer::Pointer volDataCntr = f->getDataContainerArray()->getPrereqDataContainer(f, arrayPath.getDataContainerName(), false); + if(f->getErrorCode() < 0 || nullptr == volDataCntr) { QString ss = QObject::tr("The Data Container '%1' does not exist").arg(arrayPath.getDataContainerName()); - f->setErrorCondition(Errors::MissingDataContainer); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::MissingDataContainer, ss); return retPtr; } AttributeMatrix::Pointer cell_attr_matrix = volDataCntr->getPrereqAttributeMatrix(f, arrayPath.getAttributeMatrixName(), Errors::MissingAttributeMatrix); - if(f->getErrorCondition() < 0 || nullptr == cell_attr_matrix.get()) + if(f->getErrorCode() < 0 || nullptr == cell_attr_matrix.get()) { QString ss = QObject::tr("The Attribute Matrix '%1' does not exist").arg(arrayPath.getAttributeMatrixName()); - f->setErrorCondition(Errors::MissingAttributeMatrix); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::MissingAttributeMatrix, ss); return retPtr; } IDataArrayShPtr templ_ptr = cell_attr_matrix->getAttributeArray(arrayPath.getDataArrayName()); if(nullptr == templ_ptr.get()) { QString ss = QObject::tr("The input array '%1' was not found in the AttributeMatrix '%2'.").arg(arrayPath.getDataArrayName()).arg(arrayPath.getAttributeMatrixName()); - f->setErrorCondition(Errors::MissingArray); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::MissingArray, ss); return retPtr; } if(compDims.isEmpty()) @@ -378,8 +371,7 @@ IDataArrayWkPtr GetPrereqArrayFromPath::operator()(AbstractFilter* f, const Data .arg(arrayPath.getDataArrayName()) .arg(i_data_array->getTypeAsString()) .arg(SIMPL::TypeNames::SupportedTypeList); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, ss); } return retPtr; } diff --git a/Source/SIMPLib/Common/TemplateHelpers.h b/Source/SIMPLib/Common/TemplateHelpers.h index 4f30b5ab62..bf9abc6181 100755 --- a/Source/SIMPLib/Common/TemplateHelpers.h +++ b/Source/SIMPLib/Common/TemplateHelpers.h @@ -40,6 +40,7 @@ #include #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/RenameDataPath.h" class AbstractFilter; @@ -106,7 +107,7 @@ namespace TemplateHelpers } \ else \ { \ - observableObj->notifyErrorMessage(#templateName, "The input array was of unsupported type", TemplateHelpers::Errors::UnsupportedType); \ + observableObj->setErrorConditionWithPrefix(TemplateHelpers::Errors::UnsupportedDataType, #templateName, "The input array was of unsupported type"); \ } #define EXECUTE_TEMPLATE(observableObj, templateName, inputData, ...) \ @@ -172,7 +173,7 @@ namespace TemplateHelpers } \ else \ { \ - observableObj->notifyErrorMessage(#templateName, "The input array was of unsupported type", TemplateHelpers::Errors::UnsupportedType); \ + observableObj->setErrorConditionWithPrefix(TemplateHelpers::Errors::UnsupportedDataType, #templateName, "The input array was of unsupported type"); \ } /** @@ -180,10 +181,11 @@ namespace TemplateHelpers */ namespace Errors { -const int UnsupportedType(-401); -const int MissingDataContainer(-402); -const int MissingAttributeMatrix(-403); -const int MissingArray(-404); +const int UnsupportedDataType(-401); +const int UnsupportedImageType(-402); +const int MissingDataContainer(-403); +const int MissingAttributeMatrix(-404); +const int MissingArray(-405); } // namespace Errors /** @@ -228,7 +230,7 @@ class SIMPLib_EXPORT CreateNonPrereqArrayFromArrayType * @param sourceArrayType * @return */ - IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, const IDataArrayShPtr& sourceArrayType); + IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, const IDataArrayShPtr& sourceArrayType, RenameDataPath::DataID_t = RenameDataPath::k_Invalid_ID); }; /** @@ -254,7 +256,7 @@ class SIMPLib_EXPORT CreateNonPrereqArrayFromTypeEnum * @param initValue * @return */ - IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, int arrayType, double initValue); + IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, int arrayType, double initValue, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); }; /** diff --git a/Source/SIMPLib/Common/Testing/Cxx/AbstractVecTest.cpp b/Source/SIMPLib/Common/Testing/Cxx/AbstractVecTest.cpp new file mode 100644 index 0000000000..cf464a684a --- /dev/null +++ b/Source/SIMPLib/Common/Testing/Cxx/AbstractVecTest.cpp @@ -0,0 +1,142 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/SIMPLib.h" + +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class AbstractVecTest +{ +public: + AbstractVecTest() = default; + virtual ~AbstractVecTest() = default; + + AbstractVecTest(const AbstractVecTest&) = delete; // Copy Constructor Not Implemented + AbstractVecTest(AbstractVecTest&&) = delete; // Move Constructor Not Implemented + AbstractVecTest& operator=(const AbstractVecTest&) = delete; // Copy Assignment Not Implemented + AbstractVecTest& operator=(AbstractVecTest&&) = delete; // Move Assignment Not Implemented + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void RemoveTestFiles() + { +#if REMOVE_TEST_FILES + +#endif + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestVec2() + { + FloatVec2Type f3(1.0f, 2.0f); + + std::array i32Array = {1, 2}; + IntVec2Type i3(i32Array); + + std::tuple tpl = std::make_tuple(1, 2); + i3 = tpl; + + std::vector iv3 = {4, 5}; + i3 = iv3.data(); + + int32_t x = i3.getX(); + DREAM3D_REQUIRED(x, ==, 4) + int32_t y = i3.getY(); + DREAM3D_REQUIRED(y, ==, 5) + + tpl = i3.toTuple(); + DREAM3D_REQUIRED(std::get<0>(tpl), ==, 4) + DREAM3D_REQUIRED(std::get<1>(tpl), ==, 5) + + DREAM3D_REQUIRED(i3.size(), ==, 2) + DREAM3D_REQUIRED(i3[0], ==, 4) + DREAM3D_REQUIRED(i3[1], ==, 5) + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestVec3() + { + FloatVec3Type f3(1.0f, 2.0f, 3.0f); + + std::array i32Array = {1, 2, 3}; + IntVec3Type i3(i32Array); + + std::tuple tpl = std::make_tuple(1, 2, 3); + i3 = tpl; + + std::vector iv3 = {4, 5, 6}; + i3 = iv3.data(); + + int32_t x = i3.getX(); + DREAM3D_REQUIRED(x, ==, 4) + int32_t y = i3.getY(); + DREAM3D_REQUIRED(y, ==, 5) + int32_t z = i3.getZ(); + DREAM3D_REQUIRED(z, ==, 6) + + tpl = i3.toTuple(); + DREAM3D_REQUIRED(std::get<0>(tpl), ==, 4) + DREAM3D_REQUIRED(std::get<1>(tpl), ==, 5) + DREAM3D_REQUIRED(std::get<2>(tpl), ==, 6) + + DREAM3D_REQUIRED(i3.size(), ==, 3) + DREAM3D_REQUIRED(i3[0], ==, 4) + DREAM3D_REQUIRED(i3[1], ==, 5) + DREAM3D_REQUIRED(i3[2], ==, 6) + } + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + int err = EXIT_SUCCESS; + + std::cout << "#### AbstractVecTest Starting ####" << std::endl; +#if !REMOVE_TEST_FILES + DREAM3D_REGISTER_TEST(RemoveTestFiles()) +#endif + DREAM3D_REGISTER_TEST(TestVec2()) + DREAM3D_REGISTER_TEST(TestVec3()) + +#if REMOVE_TEST_FILES + DREAM3D_REGISTER_TEST(RemoveTestFiles()) +#endif + } +}; diff --git a/Source/SIMPLib/Common/Testing/Cxx/SourceList.cmake b/Source/SIMPLib/Common/Testing/Cxx/SourceList.cmake new file mode 100644 index 0000000000..ac19f736c8 --- /dev/null +++ b/Source/SIMPLib/Common/Testing/Cxx/SourceList.cmake @@ -0,0 +1,6 @@ + +set(TEST_${SUBDIR_NAME}_NAMES + AbstractVecTest +) + +SIMPL_ADD_UNIT_TEST("${TEST_${SUBDIR_NAME}_NAMES}" "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") diff --git a/Source/SIMPLib/CoreFilters/ApplyImageTransforms.cpp b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.cpp new file mode 100644 index 0000000000..4515f4cbdb --- /dev/null +++ b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.cpp @@ -0,0 +1,247 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "ApplyImageTransforms.h" + +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/StringFilterParameter.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/TransformContainer.h" + +#include "SIMPLib/SIMPLibVersion.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ApplyImageTransforms::ApplyImageTransforms() +: AbstractFilter() +{ + initialize(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ApplyImageTransforms::~ApplyImageTransforms() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::initialize() +{ + clearErrorCode(); + clearWarningCode(); + setCancel(false); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::setupFilterParameters() +{ + FilterParameterVectorType parameters; + + { + MultiDataContainerSelectionFilterParameter::RequirementType req = + MultiDataContainerSelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Cell, IGeometry::Type::Image); + parameters.push_back(SIMPL_NEW_MDC_SELECTION_FP("Image Data Containers", ImageDataContainers, FilterParameter::RequiredArray, ApplyImageTransforms, req)); + } + + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + int selectedDCCount = getImageDataContainers().size(); + if(selectedDCCount < 1) + { + QString ss = QObject::tr("At least one Data Container must be selected"); + setErrorCondition(-11001, ss); + return; + } + + for(int i = 0; i < selectedDCCount; i++) + { + QString dcName = m_ImageDataContainers[i]; + + ImageGeom::Pointer imageGeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, dcName); + if(getErrorCode() < 0) + { + return; + } + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::preflight() +{ + // These are the REQUIRED lines of CODE to make sure the filter behaves correctly + setInPreflight(true); // Set the fact that we are preflighting. + emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update + emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter + dataCheck(); // Run our DataCheck to make sure everthing is setup correctly + emit preflightExecuted(); // We are done preflighting this filter + setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::execute() +{ + initialize(); + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + int selectedDCCount = getImageDataContainers().size(); + for(int i = 0; i < selectedDCCount; i++) + { + QString dcName = m_ImageDataContainers[i]; + + DataContainer::Pointer dc = getDataContainerArray()->getDataContainer(dcName); + ImageGeom::Pointer imageGeom = dc->getGeometryAs(); + + FloatVec3Type origin; + imageGeom->getOrigin(origin); + + ::ITransformContainer::Pointer iTransformContainer = imageGeom->getTransformContainer(); + if (iTransformContainer) + { + TransformContainer::Pointer transformContainer = std::dynamic_pointer_cast(iTransformContainer); + if (transformContainer) + { + TransformContainer::TransformParametersType parameters = transformContainer->getParameters(); + + double xTranslation = parameters[9]; + double yTranslation = parameters[10]; + + origin[0] = origin[0] - xTranslation; + origin[1] = origin[1] - yTranslation; + + imageGeom->setOrigin(origin); + + parameters[9] = 0; + parameters[10] = 0; + transformContainer->setParameters(parameters); + } + } + } + + notifyStatusMessage("Complete"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer ApplyImageTransforms::newFilterInstance(bool copyFilterParameters) const +{ + ApplyImageTransforms::Pointer filter = ApplyImageTransforms::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QString ApplyImageTransforms::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QString ApplyImageTransforms::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QString ApplyImageTransforms::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QString ApplyImageTransforms::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QString ApplyImageTransforms::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::ImageFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QString ApplyImageTransforms::getHumanLabel() const +{ + return "Apply Image Transforms"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +const QUuid ApplyImageTransforms::getUuid() +{ + return QUuid("{a4bd18bc-3306-5e41-bc41-4cb4248226bd}"); +} diff --git a/Source/SIMPLib/CoreFilters/ApplyImageTransforms.h b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.h new file mode 100644 index 0000000000..2ceeced4e2 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.h @@ -0,0 +1,167 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +/** + * @brief The ApplyImageTransforms class. See [Filter documentation](@ref applyimagetransforms) for details. + */ +class SIMPLib_EXPORT ApplyImageTransforms : public AbstractFilter +{ + Q_OBJECT + + public: + SIMPL_SHARED_POINTERS(ApplyImageTransforms) + SIMPL_FILTER_NEW_MACRO(ApplyImageTransforms) + SIMPL_TYPE_MACRO_SUPER(ApplyImageTransforms, AbstractFilter) + + ~ApplyImageTransforms() override; + + SIMPL_FILTER_PARAMETER(QStringList, ImageDataContainers) + Q_PROPERTY(QStringList ImageDataContainers READ getImageDataContainers WRITE setImageDataContainers) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + const QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + const QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + const QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + const QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + const QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + const QUuid getUuid() override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + const QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief preflight Reimplemented from @see AbstractFilter class + */ + void preflight() override; + + signals: + /** + * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters + * be pushed from a user-facing control (such as a widget) + * @param filter Filter instance pointer + */ + void updateFilterParameters(AbstractFilter* filter); + + /** + * @brief parametersChanged Emitted when any Filter parameter is changed internally + */ + void parametersChanged(); + + /** + * @brief preflightAboutToExecute Emitted just before calling dataCheck() + */ + void preflightAboutToExecute(); + + /** + * @brief preflightExecuted Emitted just after calling dataCheck() + */ + void preflightExecuted(); + + protected: + ApplyImageTransforms(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck(); + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + private: + + + public: + /* Rule of 5: All special member functions should be defined if any are defined. + * https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all + */ + ApplyImageTransforms(const ApplyImageTransforms&) = delete; // Copy Constructor Not Implemented + ApplyImageTransforms& operator=(const ApplyImageTransforms&) = delete; // Copy Assignment Not Implemented + ApplyImageTransforms(ApplyImageTransforms&&) = delete; // Move Constructor Not Implemented + ApplyImageTransforms& operator=(ApplyImageTransforms&&) = delete; // Move Assignment Not Implemented + +}; + diff --git a/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp b/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp index 911f47c4a7..11438f2573 100644 --- a/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp +++ b/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp @@ -131,6 +131,10 @@ itemPtr = CalculatorArray::New(arrayCast, ICalculatorArray::Array, !getInPreflight()); \ } +enum createdPathID : RenameDataPath::DataID_t { + DataArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -155,7 +159,7 @@ ArrayCalculator::~ArrayCalculator() = default; // ----------------------------------------------------------------------------- void ArrayCalculator::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(AttributeMatrix::Type::Any, IGeometry::Type::Any); parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Cell Attribute Matrix", SelectedAttributeMatrix, FilterParameter::Parameter, ArrayCalculator, req)); @@ -219,11 +223,11 @@ void ArrayCalculator::initialize() // ----------------------------------------------------------------------------- void ArrayCalculator::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -231,8 +235,7 @@ void ArrayCalculator::dataCheck() if(m_InfixEquation.isEmpty() || m_InfixEquation.split(" ", QString::SkipEmptyParts).empty()) { QString ss = QObject::tr("The infix expression is empty"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::EMPTY_EQUATION)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::EMPTY_EQUATION), ss); return; } @@ -250,17 +253,15 @@ void ArrayCalculator::dataCheck() int errInt = static_cast(err); if(errInt < 0) { - setErrorCondition(errInt); - notifyErrorMessage(getHumanLabel(), errMsg, getErrorCondition()); + setErrorCondition(errInt, errMsg); return; } } if(!m_CalculatedArray.isValid()) { - setErrorCondition(-4675); QString ss = QObject::tr("The output path must be valid"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4675, ss); return; } @@ -281,8 +282,7 @@ void ArrayCalculator::dataCheck() if(!cDims.isEmpty() && resultType == ICalculatorArray::ValueType::Array && cDims != array1->getArray()->getComponentDimensions()) { QString ss = QObject::tr("Attribute Array symbols in the infix expression have mismatching component dimensions"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS), ss); return; } @@ -300,8 +300,7 @@ void ArrayCalculator::dataCheck() if(resultType == ICalculatorArray::ValueType::Unknown) { QString ss = QObject::tr("The expression does not have any arguments that simplify down to a number."); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::NO_NUMERIC_ARGUMENTS)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::NO_NUMERIC_ARGUMENTS), ss); return; } @@ -311,8 +310,7 @@ void ArrayCalculator::dataCheck() { QString ss = QObject::tr("The AttributeMatrix at %1/%2 was not found") .arg(calculatedAMPath.getDataContainerName(), calculatedAMPath.getAttributeMatrixName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::LOST_ATTR_MATRIX)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::LOST_ATTR_MATRIX), ss); return; } @@ -321,8 +319,7 @@ void ArrayCalculator::dataCheck() { QString ss = QObject::tr("The result of the chosen expression will be a numeric value or contain one tuple." " This numeric value will be stored in an array with the number of tuples equal to 1"); - setWarningCondition(static_cast(CalculatorItem::WarningCode::NUMERIC_VALUE_WARNING)); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(static_cast(CalculatorItem::WarningCode::NUMERIC_VALUE_WARNING), ss); if(calculatedAM->getNumberOfTuples() > 1) { @@ -330,16 +327,14 @@ void ArrayCalculator::dataCheck() " expression evaluates to an array with a tuple count of 1, which does not match the output attribute matrix" " tuple count.") .arg(calculatedAMPath.getDataContainerName(), calculatedAMPath.getAttributeMatrixName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT), ss); return; } } else if(calculatedAM->getNumberOfTuples() != selectedAM->getNumberOfTuples()) { QString ss = QObject::tr("The tuple count of the output Attribute Matrix is not equal to the tuple count of the selected Attribute Matrix"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT), ss); return; } @@ -352,42 +347,41 @@ void ArrayCalculator::dataCheck() switch(m_ScalarType) { case SIMPL::ScalarTypes::Type::Int8: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt8: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Int16: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt16: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Int32: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt32: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Int64: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt64: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Float: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Double: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Bool: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; default: QString ss = QObject::tr("The output array type is not valid. No DataArray could be created."); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::InvalidOutputArrayType)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::InvalidOutputArrayType), ss); return; } } @@ -410,10 +404,10 @@ void ArrayCalculator::preflight() // ----------------------------------------------------------------------------- void ArrayCalculator::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -429,7 +423,7 @@ void ArrayCalculator::execute() int totalItems = rpn.size(); for(int rpnCount = 0; rpnCount < totalItems; rpnCount++) { - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), "Computing Operator " + QString::number(rpnCount + 1) + "/" + QString::number(totalItems)); + notifyStatusMessage("Computing Operator " + QString::number(rpnCount + 1) + "/" + QString::number(totalItems)); CalculatorItem::Pointer rpnItem = rpn[rpnCount]; ICalculatorArray::Pointer calcArray = std::dynamic_pointer_cast(rpnItem); @@ -444,7 +438,7 @@ void ArrayCalculator::execute() CalculatorOperator::Pointer rpnOperator = std::dynamic_pointer_cast(rpnItem); rpnOperator->calculate(this, m_CalculatedArray, m_ExecutionStack); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -461,8 +455,7 @@ void ArrayCalculator::execute() if(m_ExecutionStack.size() != 1) { QString ss = QObject::tr("The chosen infix equation is not a valid equation."); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_EQUATION)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_EQUATION), ss); return; } if(!m_ExecutionStack.isEmpty()) @@ -472,26 +465,28 @@ void ArrayCalculator::execute() if(arrayItem != ICalculatorArray::NullPointer()) { - IDataArray::Pointer resultArray = IDataArray::NullPointer(); - resultArray = arrayItem->getArray(); + IDataArray::Pointer resultArray = arrayItem->getArray(); - IDataArray::Pointer resultTypeArray = IDataArray::NullPointer(); - resultTypeArray = convertArrayType(resultArray, m_ScalarType); + IDataArray::Pointer resultTypeArray = convertArrayType(resultArray, m_ScalarType); DataArrayPath createdAMPath(m_CalculatedArray.getDataContainerName(), m_CalculatedArray.getAttributeMatrixName(), ""); AttributeMatrix::Pointer createdAM = getDataContainerArray()->getAttributeMatrix(createdAMPath); if(nullptr != createdAM) { resultTypeArray->setName(m_CalculatedArray.getDataArrayName()); - createdAM->addAttributeArray(resultTypeArray->getName(), resultTypeArray); + if(!createdAM->insertOrAssign(resultTypeArray)) + { + QString ss = QObject::tr("Error inserting Output Array into Attribute Matrix"); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::AttributeMatrixInsertionError), ss); + return; + } } } else { QString ss = QObject::tr("Unexpected output item from chosen infix expression; the output item must be an array\n" "Please contact the DREAM.3D developers for more information"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNEXPECTED_OUTPUT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNEXPECTED_OUTPUT), ss); return; } @@ -746,8 +741,7 @@ QVector ArrayCalculator::parseInfixEquation() else { QString ss = QObject::tr("An unrecognized item '%1' was found in the chosen infix expression").arg(strItem); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNRECOGNIZED_ITEM)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNRECOGNIZED_ITEM), ss); return QVector(); } } @@ -832,20 +826,17 @@ bool ArrayCalculator::parseIndexOperator(QString token, QVector(CalculatorItem::ErrorCode::ORPHANED_COMPONENT); if(idx < 0) { - setErrorCondition(errCode); - notifyErrorMessage(getHumanLabel(), errorMsg, getErrorCondition()); + setErrorCondition(errCode, errorMsg); return false; } if(!parsedInfix[idx]->isICalculatorArray()) { - setErrorCondition(errCode); - notifyErrorMessage(getHumanLabel(), errorMsg, getErrorCondition()); + setErrorCondition(errCode, errorMsg); return false; } if(parsedInfix[idx]->isNumber()) { - setErrorCondition(errCode); - notifyErrorMessage(getHumanLabel(), errorMsg, getErrorCondition()); + setErrorCondition(errCode, errorMsg); return false; } @@ -857,8 +848,7 @@ bool ArrayCalculator::parseIndexOperator(QString token, QVector(CalculatorItem::ErrorCode::INVALID_COMPONENT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_COMPONENT), ss); return false; } @@ -866,8 +856,7 @@ bool ArrayCalculator::parseIndexOperator(QString token, QVector= calcArray->getArray()->getNumberOfComponents()) { QString ss = QObject::tr("'%1' has an component index that is out of range").arg(calcArray->getArray()->getName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE), ss); return false; } @@ -929,8 +918,7 @@ bool ArrayCalculator::parseArray(QString token, QVector if(!selectedAM->getAttributeArrayNames().contains(token)) { QString ss = QObject::tr("The item '%1' is not the name of any valid array in the selected Attribute Matrix").arg(token); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_ARRAY_NAME)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_ARRAY_NAME), ss); return false; } @@ -943,8 +931,7 @@ bool ArrayCalculator::parseArray(QString token, QVector else if(dataArray->getNumberOfTuples() != firstArray_NumTuples) { QString ss = QObject::tr("Arrays '%1' and '%2' in the infix expression have an inconsistent number of tuples").arg(firstArray_Name).arg(dataArray->getName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_TUPLES)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_TUPLES), ss); return false; } @@ -1035,8 +1022,7 @@ QVector ArrayCalculator::toRPN(QVector(item)) { QString ss = QObject::tr("One or more parentheses are mismatched in the chosen infix expression '%1'").arg(m_InfixEquation); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::MISMATCHED_PARENTHESES)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::MISMATCHED_PARENTHESES), ss); return QVector(); } @@ -1057,7 +1043,7 @@ void ArrayCalculator::checkForAmbiguousArrayName(QString strItem, QString warnin { int err = 0; AttributeMatrix::Pointer selectedAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -1065,9 +1051,8 @@ void ArrayCalculator::checkForAmbiguousArrayName(QString strItem, QString warnin { IDataArray::Pointer dataArray = selectedAM->getAttributeArray(strItem); - setWarningCondition(static_cast(CalculatorItem::WarningCode::AMBIGUOUS_NAME_WARNING)); warningMsg.append("\nTo treat this item as an array name, please add double quotes around the item (i.e. \"" + strItem + "\")."); - notifyWarningMessage(getHumanLabel(), warningMsg, getWarningCondition()); + setWarningCondition(static_cast(CalculatorItem::WarningCode::AMBIGUOUS_NAME_WARNING), warningMsg); } } } diff --git a/Source/SIMPLib/CoreFilters/Breakpoint.cpp b/Source/SIMPLib/CoreFilters/Breakpoint.cpp index 0ae48bd92a..aba88972a9 100644 --- a/Source/SIMPLib/CoreFilters/Breakpoint.cpp +++ b/Source/SIMPLib/CoreFilters/Breakpoint.cpp @@ -56,7 +56,7 @@ Breakpoint::~Breakpoint() = default; // ----------------------------------------------------------------------------- void Breakpoint::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -83,8 +83,8 @@ void Breakpoint::initialize() // ----------------------------------------------------------------------------- void Breakpoint::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -119,7 +119,7 @@ void Breakpoint::pause() m_Mutex.lock(); QString ss = "The pipeline is paused - Press \"Resume\" to continue execution."; - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + notifyStatusMessage(ss); m_WaitCondition.wait(&m_Mutex); m_Mutex.unlock(); } diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp index de728baadf..0b6982b80e 100644 --- a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp +++ b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp @@ -43,6 +43,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + CombinedArrayID = 1 +}; + /** * @brief The CombineAttributeArraysTemplatePrivate class is a templated private implementation that deals with * combining the various input arrays into one contiguous array @@ -187,7 +191,7 @@ CombineAttributeArrays::~CombineAttributeArrays() = default; // ----------------------------------------------------------------------------- void CombineAttributeArrays::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_BOOL_FP("Normalize Data", NormalizeData, FilterParameter::Parameter, CombineAttributeArrays)); parameters.push_back(SIMPL_NEW_BOOL_FP("Move Data", MoveValues, FilterParameter::Parameter, CombineAttributeArrays)); { @@ -221,8 +225,7 @@ template void verifyArrayList(AbstractFilter* filter, QVecto { if(!TemplateHelpers::CanDynamicCast>()((*it).lock())) { - filter->setErrorCondition(-90000); - filter->notifyErrorMessage(filter->getHumanLabel(), "Selected Attribute Arrays must all be of the same type", filter->getErrorCondition()); + filter->setErrorCondition(-90000, "Selected Attribute Arrays must all be of the same type"); return; } } @@ -242,14 +245,13 @@ void CombineAttributeArrays::dataCheck() { m_SelectedWeakPtrVector.clear(); - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getSelectedDataArrayPaths().size() < 2) { - setErrorCondition(-11001); QString ss = QObject::tr("At least two Attribute Array must be selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); return; } @@ -257,9 +259,8 @@ void CombineAttributeArrays::dataCheck() if(!DataArrayPath::ValidateVector(paths)) { - setErrorCondition(-11002); QString ss = QObject::tr("There are Attribute Arrays selected that are not contained in the same Attribute Matrix. All selected Attribute Arrays must belong to the same Attribute Matrix"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } int32_t totalComps = 0; @@ -279,7 +280,7 @@ void CombineAttributeArrays::dataCheck() { EXECUTE_FUNCTION_TEMPLATE(this, verifyArrayList, m_SelectedWeakPtrVector[0].lock(), this, m_SelectedWeakPtrVector) } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -287,7 +288,7 @@ void CombineAttributeArrays::dataCheck() QVector cDims(1, totalComps); DataArrayPath tempPath(getSelectedDataArrayPaths()[0].getDataContainerName(), getSelectedDataArrayPaths()[0].getAttributeMatrixName(), getStackedDataArrayName()); - m_StackedDataPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_SelectedWeakPtrVector[0].lock()); + m_StackedDataPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_SelectedWeakPtrVector[0].lock(), CombinedArrayID); if(getMoveValues() && getInPreflight()) { @@ -318,10 +319,10 @@ void CombineAttributeArrays::preflight() // ----------------------------------------------------------------------------- void CombineAttributeArrays::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -339,6 +340,18 @@ void CombineAttributeArrays::execute() } } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list CombineAttributeArrays::getDeletedPaths() +{ + if(getMoveValues()) + { + return getSelectedDataArrayPaths().toList().toStdList(); + } + return std::list(); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h index 7f52bf7a36..8bfde7fa5b 100755 --- a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h +++ b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h @@ -134,6 +134,12 @@ class SIMPLib_EXPORT CombineAttributeArrays : public AbstractFilter */ void preflight() override; + /** + * @brief Returns the list of deleted data paths. + * @return + */ + std::list getDeletedPaths() override; + signals: /** * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp index 4e4d2f8fff..850eea5388 100644 --- a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp +++ b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp @@ -44,6 +44,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + CombinedMatrixID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -67,7 +71,7 @@ CombineAttributeMatrices::~CombineAttributeMatrices() = default; // ----------------------------------------------------------------------------- void CombineAttributeMatrices::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SeparatorFilterParameter::New("Feature/Ensemble Data", FilterParameter::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req; @@ -149,12 +153,12 @@ void CombineAttributeMatrices::initialize() // ----------------------------------------------------------------------------- void CombineAttributeMatrices::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getFirstAttributeMatrixPath().getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m.get()) + if(getErrorCode() < 0 || nullptr == m.get()) { return; } @@ -162,20 +166,18 @@ void CombineAttributeMatrices::dataCheck() if(getFirstAttributeMatrixPath().getDataContainerName().compare(getSecondAttributeMatrixPath().getDataContainerName()) != 0) { QString ss = QObject::tr("The selected attribute matrices must be in the same data container and currently are not"); - setErrorCondition(-5557); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5557, ss); } if(getFirstAttributeMatrixPath().getAttributeMatrixName().compare(getSecondAttributeMatrixPath().getAttributeMatrixName()) == 0) { QString ss = QObject::tr("The selected attribute matrices must be different and currently are the same"); - setErrorCondition(-5558); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5558, ss); } AttributeMatrix::Pointer firstAttrMat = m->getPrereqAttributeMatrix(this, getFirstAttributeMatrixPath().getAttributeMatrixName(), -301); AttributeMatrix::Pointer secondAttrMat = m->getPrereqAttributeMatrix(this, getSecondAttributeMatrixPath().getAttributeMatrixName(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -183,11 +185,10 @@ void CombineAttributeMatrices::dataCheck() if(firstAttrMat->getType() != secondAttrMat->getType()) { QString ss = QObject::tr("The selected attribute matrices must be of the same type (ie Feature) and currently are not"); - setErrorCondition(-5559); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5559, ss); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -196,8 +197,8 @@ void CombineAttributeMatrices::dataCheck() // All Feature or Ensemble AMs should start from 1 and the zeroth tuple can be combined in the two AMs size_t totalTuples = firstAttrMat->getNumberOfTuples() + secondAttrMat->getNumberOfTuples() - 1; QVector tDims(1, totalTuples); - m->createNonPrereqAttributeMatrix(this, getCombinedAttributeMatrixName(), tDims, firstAttrMat->getType()); - if(getErrorCondition() < 0) + m->createNonPrereqAttributeMatrix(this, getCombinedAttributeMatrixName(), tDims, firstAttrMat->getType(), CombinedMatrixID); + if(getErrorCode() < 0) { return; } @@ -210,7 +211,7 @@ void CombineAttributeMatrices::dataCheck() { m_FirstIndex = m_FirstIndexPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -221,7 +222,7 @@ void CombineAttributeMatrices::dataCheck() { m_SecondIndex = m_SecondIndexPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -232,7 +233,7 @@ void CombineAttributeMatrices::dataCheck() { tempPath.update(getFirstAttributeMatrixPath().getDataContainerName(), getCombinedAttributeMatrixName(), *iter); IDataArray::Pointer tmpDataArray = firstAttrMat->getPrereqIDataArray(this, *iter, -90001); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { QVector cDims = tmpDataArray->getComponentDimensions(); TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray); @@ -243,7 +244,7 @@ void CombineAttributeMatrices::dataCheck() { tempPath.update(getSecondAttributeMatrixPath().getDataContainerName(), getCombinedAttributeMatrixName(), *iter); IDataArray::Pointer tmpDataArray = secondAttrMat->getPrereqIDataArray(this, *iter, -90001); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { if(!fArrayNames.contains(*iter)) { @@ -254,13 +255,12 @@ void CombineAttributeMatrices::dataCheck() } tempPath.update(getFirstIndexArrayPath().getDataContainerName(), getFirstIndexArrayPath().getAttributeMatrixName(), getNewIndexArrayName()); - m_NewIndexPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(this, tempPath, 0, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ + m_NewIndexPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(this, tempPath, 0, cDims); if(nullptr != m_NewIndexPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ { m_NewIndex = m_NewIndexPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -296,10 +296,10 @@ template void copyData(IDataArray::Pointer fromData, IDataArray::Po // ----------------------------------------------------------------------------- void CombineAttributeMatrices::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -329,7 +329,7 @@ void CombineAttributeMatrices::execute() else if(m_SecondIndex[i] > 0 && m_NewIndex[i] != 0) { QString ss = QObject::tr("When copying the indices, the indices of the two attribute matrices overlapped. The index of the first attribute matrix was kept."); - notifyWarningMessage(getHumanLabel(), ss, -111); + setWarningCondition(-111, ss); } } @@ -354,6 +354,14 @@ void CombineAttributeMatrices::execute() } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list CombineAttributeMatrices::getDeletedPaths() +{ + return { getFirstAttributeMatrixPath(), getSecondAttributeMatrixPath() }; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h index 5013be64b6..22aa4df570 100755 --- a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h +++ b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h @@ -144,6 +144,12 @@ class SIMPLib_EXPORT CombineAttributeMatrices : public AbstractFilter */ void preflight() override; + /** + * @brief Returns the list of deleted data paths. + * @return + */ + std::list getDeletedPaths(); + signals: /** * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters diff --git a/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp b/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp index 67e915c41c..a376c5edcd 100644 --- a/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp +++ b/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp @@ -63,7 +63,7 @@ ConditionalSetValue::~ConditionalSetValue() = default; // ----------------------------------------------------------------------------- void ConditionalSetValue::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_DOUBLE_FP("New Value", ReplaceValue, FilterParameter::Parameter, ConditionalSetValue)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Bool, 1, AttributeMatrix::Category::Any); @@ -98,8 +98,7 @@ template void checkValuesInt(AbstractFilter* filter, double replace if(!((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max()))) { ss = QObject::tr("The %1 replace value was invalid. The valid range is %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-100); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-100, ss); } } @@ -114,8 +113,7 @@ template void checkValuesFloatDouble(AbstractFilter* filter, double ((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max())))) { ss = QObject::tr("The %1 replace value was invalid. The valid ranges are -%3 to -%2, 0, %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-101); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-101, ss); } } @@ -154,17 +152,17 @@ void ConditionalSetValue::initialize() // ----------------------------------------------------------------------------- void ConditionalSetValue::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QVector dataArrayPaths; m_ArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { dataArrayPaths.push_back(getSelectedArrayPath()); } @@ -174,8 +172,7 @@ void ConditionalSetValue::dataCheck() QString ss = QObject::tr("Selected array '%1' must be a scalar array (1 component). The number of components is %2") .arg(getSelectedArrayPath().getDataArrayName()) .arg(m_ArrayPtr.lock()->getNumberOfComponents()); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } @@ -186,7 +183,7 @@ void ConditionalSetValue::dataCheck() { m_ConditionalArray = m_ConditionalArrayPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { dataArrayPaths.push_back(getConditionalArrayPath()); } @@ -243,9 +240,8 @@ void ConditionalSetValue::dataCheck() } else { - setErrorCondition(-4060); QString ss = QObject::tr("Incorrect data scalar type"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4060, ss); } } @@ -267,10 +263,10 @@ void ConditionalSetValue::preflight() // ----------------------------------------------------------------------------- void ConditionalSetValue::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp index 35f66a6ff3..f39f0ed65f 100644 --- a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp +++ b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp @@ -62,11 +62,11 @@ class LuminosityImpl private: uint8_t* m_ImageData; uint8_t* m_FlatImageData; - FloatVec3_t m_ColorWeights; + FloatVec3Type m_ColorWeights; size_t m_NumComp; public: - LuminosityImpl(uint8_t* data, uint8_t* newdata, FloatVec3_t colorWeights, size_t comp) + LuminosityImpl(uint8_t* data, uint8_t* newdata, FloatVec3Type colorWeights, size_t comp) : m_ImageData(data) , m_FlatImageData(newdata) , m_ColorWeights(colorWeights) @@ -83,11 +83,8 @@ class LuminosityImpl { for(size_t i = start; i < end; i++) { - m_FlatImageData[i] = static_cast(roundf( - (m_ImageData[m_NumComp * i] * m_ColorWeights.x) - + (m_ImageData[m_NumComp * i + 1] * m_ColorWeights.y) - + (m_ImageData[m_NumComp * i + 2] * m_ColorWeights.z) - )); + m_FlatImageData[i] = static_cast( + roundf((m_ImageData[m_NumComp * i] * m_ColorWeights.getX()) + (m_ImageData[m_NumComp * i + 1] * m_ColorWeights.getY()) + (m_ImageData[m_NumComp * i + 2] * m_ColorWeights.getZ()))); } } @@ -215,7 +212,7 @@ ConvertColorToGrayScale::~ConvertColorToGrayScale() = default; void ConvertColorToGrayScale::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { QVector choices; choices.push_back("Luminosity"); @@ -265,34 +262,31 @@ void ConvertColorToGrayScale::initialize() { } // ----------------------------------------------------------------------------- void ConvertColorToGrayScale::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(!DataArrayPath::ValidateVector(getInputDataArrayVector())) { - setErrorCondition(-62100); QString ss = QObject::tr("All Attribute Arrays must belong to the same Data Container and Attribute Matrix"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62100, ss); } if(getOutputArrayPrefix().isEmpty()) { - setErrorCondition(-62102); QString message = QObject::tr("Using a prefix (even a single alphanumeric value) is required so that the output Xdmf files can be written correctly"); - notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); + setErrorCondition(-62102, message); } if(getInputDataArrayVector().isEmpty()) { - setErrorCondition(-62103); QString message = QObject::tr("At least one Attribute Array must be selected"); - notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); + setErrorCondition(-62103, message); return; } DataArrayPath inputAMPath = DataArrayPath::GetAttributeMatrixPath(getInputDataArrayVector()); AttributeMatrix::Pointer inAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, inputAMPath, -301); - if(getErrorCondition() < 0 || nullptr == inAM.get()) + if(getErrorCode() < 0 || nullptr == inAM.get()) { return; } @@ -307,7 +301,7 @@ void ConvertColorToGrayScale::dataCheck() QVector tDims = inAM->getTupleDimensions(); outAM = dc->createNonPrereqAttributeMatrix(this, getOutputAttributeMatrixName(), tDims, AttributeMatrix::Type::Cell); - if(getErrorCondition() < 0 || nullptr == outAM.get()) + if(getErrorCode() < 0 || nullptr == outAM.get()) { return; } @@ -323,7 +317,7 @@ void ConvertColorToGrayScale::dataCheck() QString newName = getOutputArrayPrefix() + arrayNames.at(i); inputAMPath.setDataArrayName(daName); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -341,9 +335,8 @@ void ConvertColorToGrayScale::dataCheck() { if(m_ColorChannel < 0 || m_ColorChannel > 2) { - setErrorCondition(-62104); QString message = QObject::tr("The color channel should be 0, 1 or 2"); - notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); + setErrorCondition(-62104, message); return; } } @@ -368,15 +361,14 @@ void ConvertColorToGrayScale::preflight() void ConvertColorToGrayScale::execute() { initialize(); - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QString ss; dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { - setErrorCondition(-62106); ss = QObject::tr("DataCheck did not pass during execute"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62106, ss); return; } @@ -395,9 +387,8 @@ void ConvertColorToGrayScale::execute() if(nullptr == inputColorData.get()) { - setErrorCondition(-62107); ss = QObject::tr("Input Color Data at ArrayPath '%1' was not available. This array will be skipped.").arg(arrayPath.serialize("/")); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62107, ss); continue; } @@ -408,9 +399,8 @@ void ConvertColorToGrayScale::execute() if(nullptr == outputGrayData.get()) { - setErrorCondition(-62108); ss = QObject::tr("Output Data at ArrayPath '%1' was not available. This array will be skipped.").arg(newPath.serialize("/")); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62108, ss); continue; } @@ -459,7 +449,7 @@ AbstractFilter::Pointer ConvertColorToGrayScale::newFilterInstance(bool copyFilt // ----------------------------------------------------------------------------- const QString ConvertColorToGrayScale::getCompiledLibraryName() const { - return Core::CoreBaseName; + return Core::CoreBaseName; } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h index 3c3e4165da..5135ba137b 100644 --- a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h +++ b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h @@ -34,8 +34,8 @@ * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" @@ -47,7 +47,7 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter Q_OBJECT PYB11_CREATE_BINDINGS(ConvertColorToGrayScale SUPERCLASS AbstractFilter) PYB11_PROPERTY(int ConversionAlgorithm READ getConversionAlgorithm WRITE setConversionAlgorithm) - PYB11_PROPERTY(FloatVec3_t ColorWeights READ getColorWeights WRITE setColorWeights) + PYB11_PROPERTY(FloatVec3Type ColorWeights READ getColorWeights WRITE setColorWeights) PYB11_PROPERTY(int ColorChannel READ getColorChannel WRITE setColorChannel) PYB11_PROPERTY(QVector InputDataArrayVector READ getInputDataArrayVector WRITE setInputDataArrayVector) PYB11_PROPERTY(bool CreateNewAttributeMatrix READ getCreateNewAttributeMatrix WRITE setCreateNewAttributeMatrix) @@ -73,8 +73,8 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter SIMPL_FILTER_PARAMETER(int, ConversionAlgorithm) Q_PROPERTY(int ConversionAlgorithm READ getConversionAlgorithm WRITE setConversionAlgorithm) - SIMPL_FILTER_PARAMETER(FloatVec3_t, ColorWeights) - Q_PROPERTY(FloatVec3_t ColorWeights READ getColorWeights WRITE setColorWeights) + SIMPL_FILTER_PARAMETER(FloatVec3Type, ColorWeights) + Q_PROPERTY(FloatVec3Type ColorWeights READ getColorWeights WRITE setColorWeights) SIMPL_FILTER_PARAMETER(int, ColorChannel) Q_PROPERTY(int ColorChannel READ getColorChannel WRITE setColorChannel) diff --git a/Source/SIMPLib/CoreFilters/ConvertData.cpp b/Source/SIMPLib/CoreFilters/ConvertData.cpp index 4756c492ac..dc88e478b7 100644 --- a/Source/SIMPLib/CoreFilters/ConvertData.cpp +++ b/Source/SIMPLib/CoreFilters/ConvertData.cpp @@ -76,7 +76,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta if(scalarType == SIMPL::NumericTypes::Type::Int8) { Int8ArrayType::Pointer p = Int8ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -85,7 +85,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::UInt8) { UInt8ArrayType::Pointer p = UInt8ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -94,7 +94,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::Int16) { Int16ArrayType::Pointer p = Int16ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -103,7 +103,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::UInt16) { UInt16ArrayType::Pointer p = UInt16ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -112,7 +112,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::Int32) { Int32ArrayType::Pointer p = Int32ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -121,7 +121,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::UInt32) { UInt32ArrayType::Pointer p = UInt32ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -130,7 +130,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::Int64) { Int64ArrayType::Pointer p = Int64ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -139,7 +139,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::UInt64) { UInt64ArrayType::Pointer p = UInt64ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -148,7 +148,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::Float) { FloatArrayType::Pointer p = FloatArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -157,7 +157,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::Double) { DoubleArrayType::Pointer p = DoubleArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -166,7 +166,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta else if(scalarType == SIMPL::NumericTypes::Type::Bool) { BoolArrayType::Pointer p = BoolArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -174,10 +174,9 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else { - filter->setErrorCondition(-399); QString ss = QString("Error Converting DataArray '%1/%2' from type %3 to type %4").arg(attributeMatrixName).arg(ptr->getName()).arg(static_cast(ptr->getType())).arg(static_cast(scalarType)); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-399, ss); } } } // End Namespace Detail @@ -202,7 +201,7 @@ ConvertData::~ConvertData() = default; // ----------------------------------------------------------------------------- void ConvertData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, ConvertData)); @@ -240,8 +239,8 @@ void ConvertData::initialize() // ----------------------------------------------------------------------------- void ConvertData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getSelectedCellArrayPath().getDataContainerName(), false); @@ -249,21 +248,20 @@ void ConvertData::dataCheck() if(m_OutputArrayName.isEmpty()) { ss = QObject::tr("The output array name must be set"); - setErrorCondition(-398); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-398, ss); return; } if(getInPreflight()) { AttributeMatrix::Pointer cellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedCellArrayPath, -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } IDataArray::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedCellArrayPath()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -314,7 +312,7 @@ void ConvertData::dataCheck() { p = BoolArrayType::CreateArray(voxels, dims, m_OutputArrayName, false); } - cellAttrMat->addAttributeArray(p->getName(), p); + cellAttrMat->insertOrAssign(p); } } @@ -336,10 +334,10 @@ void ConvertData::preflight() // ----------------------------------------------------------------------------- void ConvertData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -351,7 +349,7 @@ void ConvertData::execute() if (nullptr == iArray.get()) { - setErrorCondition(-90002); + setErrorCondition(-90002, tr("Data Array '%1' does not exist.").arg(m_SelectedCellArrayPath.getDataArrayName())); return; } diff --git a/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp b/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp index 4f667020f5..ea8dd07c1e 100644 --- a/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp +++ b/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp @@ -43,6 +43,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + ElementArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -63,7 +67,7 @@ CopyFeatureArrayToElementArray::~CopyFeatureArrayToElementArray() = default; // ----------------------------------------------------------------------------- void CopyFeatureArrayToElementArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SeparatorFilterParameter::New("Feature Data", FilterParameter::RequiredArray)); { @@ -107,13 +111,12 @@ void CopyFeatureArrayToElementArray::initialize() // ----------------------------------------------------------------------------- void CopyFeatureArrayToElementArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getCreatedArrayName().isEmpty()) { - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), "The new Element array name must be set", getErrorCondition()); + setErrorCondition(-11002, "The new Element array name must be set"); return; } @@ -131,13 +134,13 @@ void CopyFeatureArrayToElementArray::dataCheck() DataArrayPath tempPath(getFeatureIdsArrayPath().getDataContainerName(), getFeatureIdsArrayPath().getAttributeMatrixName(), ""); getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, tempPath, -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } tempPath.update(getFeatureIdsArrayPath().getDataContainerName(), getFeatureIdsArrayPath().getAttributeMatrixName(), getCreatedArrayName()); - TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock()); + TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock(), ElementArrayID); } // ----------------------------------------------------------------------------- @@ -172,7 +175,7 @@ template IDataArray::Pointer copyData(IDataArray::Pointer inputData T* fPtr = feature->getPointer(0); T* cPtr = cell->getPointer(0); - int32_t numComp = feature->getNumberOfComponents(); + size_t numComp = static_cast(feature->getNumberOfComponents()); int32_t featureIdx = 0; for(size_t i = 0; i < totalPoints; ++i) @@ -195,10 +198,10 @@ template IDataArray::Pointer copyData(IDataArray::Pointer inputData // ----------------------------------------------------------------------------- void CopyFeatureArrayToElementArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -227,16 +230,14 @@ void CopyFeatureArrayToElementArray::execute() if(mismatchedFeatures) { QString ss = QObject::tr("The largest Feature Id (%1) in the FeatureIds array is larger than the number of Features in the InArray array (%2)").arg(largestFeature).arg(numFeatures); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); return; } if(largestFeature != (numFeatures - 1)) { QString ss = QObject::tr("The number of Features in the InArray array (%1) does not match the largest Feature Id in the FeatureIds array").arg(numFeatures); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); return; } @@ -289,15 +290,14 @@ void CopyFeatureArrayToElementArray::execute() else { QString ss = QObject::tr("The selected array was of unsupported type. The path is %1").arg(m_SelectedFeatureArrayPath.serialize()); - setErrorCondition(-14000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-14000, ss); } if(p.get() != nullptr) { p->setName(getCreatedArrayName()); AttributeMatrix::Pointer am = getDataContainerArray()->getAttributeMatrix(getFeatureIdsArrayPath()); - am->addAttributeArray(p->getName(), p); + am->insertOrAssign(p); } } diff --git a/Source/SIMPLib/CoreFilters/CopyObject.cpp b/Source/SIMPLib/CoreFilters/CopyObject.cpp index a6fff681aa..6f36ed086c 100644 --- a/Source/SIMPLib/CoreFilters/CopyObject.cpp +++ b/Source/SIMPLib/CoreFilters/CopyObject.cpp @@ -44,6 +44,12 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + DataContainerID = 1, + AttributeMatrixID, + DataArrayID +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -66,7 +72,7 @@ CopyObject::~CopyObject() = default; // ----------------------------------------------------------------------------- void CopyObject::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Object Type to Copy"); @@ -110,7 +116,7 @@ void CopyObject::readFilterParameters(AbstractFilterParametersReader* reader, in { reader->openFilterGroup(this, index); setObjectToCopy(reader->readValue("ObjectToCopy", getObjectToCopy())); - setDataContainerToCopy(reader->readString("DataContainerToCopy", getDataContainerToCopy())); + setDataContainerToCopy(reader->readDataArrayPath("DataContainerToCopy", getDataContainerToCopy())); setAttributeMatrixToCopy(reader->readDataArrayPath("AttributeMatrixToCopy", getAttributeMatrixToCopy())); setAttributeArrayToCopy(reader->readDataArrayPath("AttributeArrayToCopy", getAttributeArrayToCopy())); setCopiedObjectName(reader->readString("CopiedObjectName", getCopiedObjectName())); @@ -129,14 +135,13 @@ void CopyObject::initialize() // ----------------------------------------------------------------------------- void CopyObject::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getCopiedObjectName().isEmpty()) { - setErrorCondition(-11001); QString ss = QObject::tr("The copied object name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } switch(getObjectToCopy()) @@ -146,21 +151,21 @@ void CopyObject::dataCheck() { if(getDataContainerArray()->doesDataContainerExist(getCopiedObjectName())) { - setErrorCondition(-11001); QString ss = QObject::tr("A Data Container already exists with the name %1").arg(getCopiedObjectName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerToCopy()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataContainer::Pointer dcCopy = m->deepCopy(getInPreflight()); dcCopy->setName(getCopiedObjectName()); - getDataContainerArray()->addDataContainer(dcCopy); + getDataContainerArray()->addOrReplaceDataContainer(dcCopy); + RenameDataPath::AlertFilterCreatedPath(this, DataContainerID, dcCopy->getDataArrayPath()); break; } @@ -170,21 +175,21 @@ void CopyObject::dataCheck() DataArrayPath path(getAttributeMatrixToCopy().getDataContainerName(), getCopiedObjectName(), ""); if(getDataContainerArray()->doesAttributeMatrixExist(path)) { - setErrorCondition(-11001); QString ss = QObject::tr("An Attribute Matrix already exists with the name %1").arg(getCopiedObjectName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getAttributeMatrixToCopy(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } AttributeMatrix::Pointer attrMatCopy = attrMat->deepCopy(getInPreflight()); attrMatCopy->setName(getCopiedObjectName()); - getDataContainerArray()->getDataContainer(getAttributeMatrixToCopy().getDataContainerName())->addAttributeMatrix(getCopiedObjectName(), attrMatCopy); + getDataContainerArray()->getDataContainer(getAttributeMatrixToCopy().getDataContainerName())->addOrReplaceAttributeMatrix(attrMatCopy); + RenameDataPath::AlertFilterCreatedPath(this, AttributeMatrixID, attrMatCopy->getDataArrayPath()); break; } @@ -194,24 +199,21 @@ void CopyObject::dataCheck() DataArrayPath path(getAttributeArrayToCopy().getDataContainerName(), getAttributeArrayToCopy().getAttributeMatrixName(), getCopiedObjectName()); if(getDataContainerArray()->doesAttributeArrayExist(path)) { - setErrorCondition(-11001); QString ss = QObject::tr("An Attribute Array already exists with the name %1").arg(getCopiedObjectName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } IDataArray::Pointer array = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getAttributeArrayToCopy()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } IDataArray::Pointer arrayCopy = array->deepCopy(getInPreflight()); arrayCopy->setName(getCopiedObjectName()); - getDataContainerArray() - ->getDataContainer(getAttributeArrayToCopy().getDataContainerName()) - ->getAttributeMatrix(getAttributeArrayToCopy().getAttributeMatrixName()) - ->addAttributeArray(getCopiedObjectName(), arrayCopy); + getDataContainerArray()->getDataContainer(getAttributeArrayToCopy().getDataContainerName())->getAttributeMatrix(getAttributeArrayToCopy().getAttributeMatrixName())->insertOrAssign(arrayCopy); + RenameDataPath::AlertFilterCreatedPath(this, DataArrayID, arrayCopy->getDataArrayPath()); break; } @@ -241,10 +243,10 @@ void CopyObject::preflight() // ----------------------------------------------------------------------------- void CopyObject::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/CopyObject.h b/Source/SIMPLib/CoreFilters/CopyObject.h index 5e2323d3c6..2ab28c64f7 100644 --- a/Source/SIMPLib/CoreFilters/CopyObject.h +++ b/Source/SIMPLib/CoreFilters/CopyObject.h @@ -47,7 +47,7 @@ class SIMPLib_EXPORT CopyObject : public AbstractFilter Q_OBJECT PYB11_CREATE_BINDINGS(CopyObject SUPERCLASS AbstractFilter) PYB11_PROPERTY(int ObjectToCopy READ getObjectToCopy WRITE setObjectToCopy) - PYB11_PROPERTY(QString DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) + PYB11_PROPERTY(DataArrayPath DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) PYB11_PROPERTY(DataArrayPath AttributeMatrixToCopy READ getAttributeMatrixToCopy WRITE setAttributeMatrixToCopy) PYB11_PROPERTY(DataArrayPath AttributeArrayToCopy READ getAttributeArrayToCopy WRITE setAttributeArrayToCopy) PYB11_PROPERTY(QString CopiedObjectName READ getCopiedObjectName WRITE setCopiedObjectName) @@ -62,8 +62,8 @@ class SIMPLib_EXPORT CopyObject : public AbstractFilter SIMPL_FILTER_PARAMETER(int, ObjectToCopy) Q_PROPERTY(int ObjectToCopy READ getObjectToCopy WRITE setObjectToCopy) - SIMPL_FILTER_PARAMETER(QString, DataContainerToCopy) - Q_PROPERTY(QString DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerToCopy) + Q_PROPERTY(DataArrayPath DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixToCopy) Q_PROPERTY(DataArrayPath AttributeMatrixToCopy READ getAttributeMatrixToCopy WRITE setAttributeMatrixToCopy) diff --git a/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp b/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp index 52607b37b8..2f2ac7706f 100644 --- a/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp +++ b/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp @@ -42,6 +42,10 @@ #include "SIMPLib/FilterParameters/DynamicTableFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + AttributeMatrixID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -61,7 +65,7 @@ CreateAttributeMatrix::~CreateAttributeMatrix() = default; // ----------------------------------------------------------------------------- void CreateAttributeMatrix::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { QVector choices; @@ -116,11 +120,11 @@ void CreateAttributeMatrix::initialize() // ----------------------------------------------------------------------------- void CreateAttributeMatrix::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getCreatedAttributeMatrix().getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -131,8 +135,7 @@ void CreateAttributeMatrix::dataCheck() if(rows.size() != 1) { QString ss = QObject::tr("The number of rows of data must be 1. The data currently has %1").arg(rows.size()); - setErrorCondition(-11000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11000, ss); return; } @@ -143,8 +146,8 @@ void CreateAttributeMatrix::dataCheck() tDims[i] = static_cast(cols[i]); } - m->createNonPrereqAttributeMatrix(this, getCreatedAttributeMatrix().getAttributeMatrixName(), tDims, static_cast(getAttributeMatrixType())); - if(getErrorCondition() < 0) + m->createNonPrereqAttributeMatrix(this, getCreatedAttributeMatrix().getAttributeMatrixName(), tDims, static_cast(getAttributeMatrixType()), AttributeMatrixID); + if(getErrorCode() < 0) { return; } @@ -169,10 +172,10 @@ void CreateAttributeMatrix::preflight() // ----------------------------------------------------------------------------- void CreateAttributeMatrix::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/CreateDataArray.cpp b/Source/SIMPLib/CoreFilters/CreateDataArray.cpp index 807e568e5e..f5eff9b894 100644 --- a/Source/SIMPLib/CoreFilters/CreateDataArray.cpp +++ b/Source/SIMPLib/CoreFilters/CreateDataArray.cpp @@ -52,6 +52,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + DataArrayID = 1 +}; + /** * @brief initializeArrayWithInts Initializes the array p with integers, either from the * manual value entered in the filter, or with a random number. This function does not @@ -256,7 +260,7 @@ CreateDataArray::~CreateDataArray() = default; // ----------------------------------------------------------------------------- void CreateDataArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_SCALARTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, CreateDataArray)); parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Parameter, CreateDataArray)); @@ -319,10 +323,10 @@ void CreateDataArray::initialize() // ----------------------------------------------------------------------------- void CreateDataArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -330,36 +334,32 @@ void CreateDataArray::dataCheck() if(m_InitializationType == RandomWithRange && m_InitializationRange.first > m_InitializationRange.second) { QString ss = "Invalid initialization range. Minimum value is larger than maximum value."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } if(getNumberOfComponents() < 0) { - setErrorCondition(-8050); QString ss = QObject::tr("The number of components must non-negative"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8050, ss); } if(getNumberOfComponents() == 0) { - setErrorCondition(-8051); QString ss = QObject::tr("The number of components is Zero. This will result in an array that has no memory allocated. Are you sure you wanted to do this?"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8051, ss); } if(!getNewArray().isValid()) { - setErrorCondition(-8051); QString ss = QObject::tr("The Created DataArrayPath is invalid. Please select the Data Container, Attribute Matrix and set an output DataArray name."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8051, ss); } QVector cDims(1, getNumberOfComponents()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } // Create the data array and initialize it to a placeholder value - m_OutputArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromTypeEnum()(this, getNewArray(), cDims, static_cast(getScalarType()), 0); + m_OutputArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromTypeEnum()(this, getNewArray(), cDims, static_cast(getScalarType()), 0, DataArrayID); QString dataArrayName = getNewArray().getDataArrayName(); @@ -427,10 +427,10 @@ void CreateDataArray::preflight() // ----------------------------------------------------------------------------- void CreateDataArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -493,16 +493,14 @@ template void CreateDataArray::checkInitialization(QString dataArra if(!ok) { QString ss = "Could not convert initialization value to a double."; - setErrorCondition(-5559); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5559, ss); return; } if(input < static_cast(std::numeric_limits().lowest()) || input > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4000); QString ss = QObject::tr("%1: Invalid initialization value. The valid range is %2 to %3").arg(dataArrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4000, ss); return; } } @@ -513,22 +511,19 @@ template void CreateDataArray::checkInitialization(QString dataArra if(min > max) { QString ss = dataArrayName + ": Invalid initialization range. Minimum value is larger than maximum value."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } if(min < static_cast(std::numeric_limits().lowest()) || max > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4001); QString ss = QObject::tr("%1: The initialization range can only be from %2 to %3").arg(dataArrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4001, ss); return; } if(min == max) { - setErrorCondition(-4002); QString ss = dataArrayName + ": The initialization range must have differing values"; - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4002, ss); return; } } diff --git a/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp b/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp index 903d68a16e..4d0da26086 100644 --- a/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp +++ b/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp @@ -40,6 +40,10 @@ #include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + DataContainerID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -58,7 +62,7 @@ CreateDataContainer::~CreateDataContainer() = default; // ----------------------------------------------------------------------------- void CreateDataContainer::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Data Container Name", DataContainerName, FilterParameter::CreatedArray, CreateDataContainer)); setFilterParameters(parameters); } @@ -69,7 +73,6 @@ void CreateDataContainer::setupFilterParameters() void CreateDataContainer::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); reader->closeFilterGroup(); } @@ -85,10 +88,10 @@ void CreateDataContainer::initialize() // ----------------------------------------------------------------------------- void CreateDataContainer::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName()); + getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName(), DataContainerID); } // ----------------------------------------------------------------------------- @@ -110,10 +113,10 @@ void CreateDataContainer::preflight() // ----------------------------------------------------------------------------- void CreateDataContainer::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/CreateDataContainer.h b/Source/SIMPLib/CoreFilters/CreateDataContainer.h index 5dc16a6cf2..21af43793b 100755 --- a/Source/SIMPLib/CoreFilters/CreateDataContainer.h +++ b/Source/SIMPLib/CoreFilters/CreateDataContainer.h @@ -47,7 +47,7 @@ class SIMPLib_EXPORT CreateDataContainer : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(CreateDataContainer SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) public: SIMPL_SHARED_POINTERS(CreateDataContainer) @@ -56,8 +56,8 @@ class SIMPLib_EXPORT CreateDataContainer : public AbstractFilter ~CreateDataContainer() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class diff --git a/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp b/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp index e4010e51cd..e58a7ac446 100644 --- a/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp +++ b/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp @@ -44,6 +44,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + FeatureArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -65,7 +69,7 @@ CreateFeatureArrayFromElementArray::~CreateFeatureArrayFromElementArray() = defa // ----------------------------------------------------------------------------- void CreateFeatureArrayFromElementArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SeparatorFilterParameter::New("Element Data", FilterParameter::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = @@ -110,13 +114,12 @@ void CreateFeatureArrayFromElementArray::initialize() // ----------------------------------------------------------------------------- void CreateFeatureArrayFromElementArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getCreatedArrayName().isEmpty()) { - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), "The new Feature Array name must be set", getErrorCondition()); + setErrorCondition(-11002, "The new Feature Array name must be set"); return; } @@ -132,13 +135,13 @@ void CreateFeatureArrayFromElementArray::dataCheck() getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellFeatureAttributeMatrixName(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataArrayPath tempPath(getCellFeatureAttributeMatrixName().getDataContainerName(), getCellFeatureAttributeMatrixName().getAttributeMatrixName(), getCreatedArrayName()); - TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock()); + TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock(), FeatureArrayID); } // ----------------------------------------------------------------------------- @@ -173,7 +176,7 @@ template IDataArray::Pointer copyCellData(AbstractFilter* filter, I T* fPtr = feature->getPointer(0); T* cPtr = cell->getPointer(0); - int32_t numComp = cell->getNumberOfComponents(); + size_t numComp = static_cast(cell->getNumberOfComponents()); int32_t featureIdx = 0; size_t cells = inputData->getNumberOfTuples(); @@ -202,9 +205,8 @@ template IDataArray::Pointer copyCellData(AbstractFilter* filter, I if(currentDataPtr[j] != cSourcePtr[j] && !warningThrown) { // The values are inconsistent with the first values for this feature id, so throw a warning - filter->setWarningCondition(-1000); QString ss = QObject::tr("Elements from Feature %1 do not all have the same value. The last value copied into Feature %1 will be used").arg(featureIdx); - filter->notifyWarningMessage(filter->getHumanLabel(), ss, filter->getWarningCondition()); + filter->setWarningCondition(-1000, ss); warningThrown = true; } } @@ -223,10 +225,10 @@ template IDataArray::Pointer copyCellData(AbstractFilter* filter, I // ----------------------------------------------------------------------------- void CreateFeatureArrayFromElementArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -255,16 +257,14 @@ void CreateFeatureArrayFromElementArray::execute() if(mismatchedFeatures) { QString ss = QObject::tr("Attribute Matrix %1 has %2 tuples but the input array %3 has a Feature ID value of at least %4").arg(m_CellFeatureAttributeMatrixName.serialize("/")).arg(totalFeatures).arg(getFeatureIdsArrayPath().serialize("/")).arg(largestFeature); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); return; } if(largestFeature != (totalFeatures - 1)) { QString ss = QObject::tr("The number of Features in the InArray array (%1) does not match the largest Feature Id in the FeatureIds array").arg(totalFeatures); - setErrorCondition(-5556); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5556, ss); return; } @@ -317,13 +317,12 @@ void CreateFeatureArrayFromElementArray::execute() else { QString ss = QObject::tr("The selected array was of unsupported type. The path is %1").arg(m_SelectedCellArrayPath.serialize()); - setErrorCondition(-14000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-14000, ss); } if(p.get() != nullptr) { - getDataContainerArray()->getAttributeMatrix(m_CellFeatureAttributeMatrixName)->addAttributeArray(p->getName(), p); + getDataContainerArray()->getAttributeMatrix(m_CellFeatureAttributeMatrixName)->insertOrAssign(p); } } diff --git a/Source/SIMPLib/CoreFilters/CreateGeometry.cpp b/Source/SIMPLib/CoreFilters/CreateGeometry.cpp index 707885aa26..e7761af6e0 100644 --- a/Source/SIMPLib/CoreFilters/CreateGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/CreateGeometry.cpp @@ -74,9 +74,9 @@ CreateGeometry::CreateGeometry() , m_XBoundsArrayPath("", "", "") , m_YBoundsArrayPath("", "", "") , m_ZBoundsArrayPath("", "", "") -, m_Dimensions({0, 0, 0}) -, m_Origin({0.0f, 0.0f, 0.0f}) -, m_Resolution({1.0f, 1.0f, 1.0f}) +, m_Dimensions(0, 0, 0) +, m_Origin(0.0f, 0.0f, 0.0f) +, m_Spacing(1.0f, 1.0f, 1.0f) , m_ImageCellAttributeMatrixName(SIMPL::Defaults::CellAttributeMatrixName) , m_RectGridCellAttributeMatrixName(SIMPL::Defaults::CellAttributeMatrixName) , m_VertexAttributeMatrixName0(SIMPL::Defaults::VertexAttributeMatrixName) @@ -94,17 +94,6 @@ CreateGeometry::CreateGeometry() , m_ArrayHandling(false) , m_NumVerts(0) { - m_Dimensions.x = 0; - m_Dimensions.y = 0; - m_Dimensions.z = 0; - - m_Origin.x = 0.0f; - m_Origin.y = 0.0f; - m_Origin.z = 0.0f; - - m_Resolution.x = 1.0f; - m_Resolution.y = 1.0f; - m_Resolution.z = 1.0f; } // ----------------------------------------------------------------------------- @@ -117,7 +106,7 @@ CreateGeometry::~CreateGeometry() = default; // ----------------------------------------------------------------------------- void CreateGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Geometry Type"); @@ -136,7 +125,7 @@ void CreateGeometry::setupFilterParameters() parameter->setChoices(choices); QStringList linkedProps = {"Dimensions", "Origin", - "Resolution", + "Spacing", "BoxDimensions", "ImageCellAttributeMatrixName", // ImageGeom "XBoundsArrayPath", @@ -164,7 +153,7 @@ void CreateGeometry::setupFilterParameters() "SharedVertexListArrayPath5", "SharedHexListArrayPath", "VertexAttributeMatrixName5", - "HexCellAttributeMatrixName" }; // HexahedralGeom + "HexCellAttributeMatrixName"}; // HexahedralGeom parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); parameter->setCategory(FilterParameter::Parameter); @@ -182,7 +171,7 @@ void CreateGeometry::setupFilterParameters() { parameters.push_back(SIMPL_NEW_INT_VEC3_FP("Dimensions", Dimensions, FilterParameter::Parameter, CreateGeometry, 0)); parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, CreateGeometry, 0)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resolution", Resolution, FilterParameter::Parameter, CreateGeometry, 0)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Spacing", Spacing, FilterParameter::Parameter, CreateGeometry, 0)); parameters.push_back(SIMPL_NEW_STRING_FP("Cell Attribute Matrix", ImageCellAttributeMatrixName, FilterParameter::CreatedArray, CreateGeometry, 0)); } { @@ -257,13 +246,13 @@ void CreateGeometry::initialize() // ----------------------------------------------------------------------------- void CreateGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -271,8 +260,7 @@ void CreateGeometry::dataCheck() if(dc->getGeometry()) { QString ss = QObject::tr("Selected Data Container already contains a Geometry"); - setErrorCondition(-701); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-701, ss); return; } @@ -280,28 +268,29 @@ void CreateGeometry::dataCheck() { case 0: // ImageGeom { - if(getDimensions().x <= 0 || getDimensions().y <= 0 || getDimensions().z <= 0) + if(getDimensions().getX() <= 0 || getDimensions().getY() <= 0 || getDimensions().getZ() <= 0) { QString ss = QObject::tr("One of the dimensions has a size less than or equal to zero; all dimensions must be positive\n" "X Dimension: %1\n" "Y Dimension: %2\n" "Z Dimension: %3\n") - .arg(getDimensions().x) - .arg(getDimensions().y) - .arg(getDimensions().z); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + .arg(getDimensions().getX()) + .arg(getDimensions().getY()) + .arg(getDimensions().getZ()); + setErrorCondition(-390, ss); return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); - image->setDimensions(getDimensions().x, getDimensions().y, getDimensions().z); - image->setOrigin(getOrigin().x, getOrigin().y, getOrigin().z); - image->setResolution(getResolution().x, getResolution().y, getResolution().z); + IntVec3Type dims = getDimensions(); + image->setDimensions(SizeVec3Type(dims[0], dims[1], dims[2])); + image->setOrigin(getOrigin()); + image->setSpacing(getSpacing()); dc->setGeometry(image); QVector tDims = {image->getXPoints(), image->getYPoints(), image->getZPoints()}; - DataArrayPath path(getDataContainerName(), getImageCellAttributeMatrixName(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getImageCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } @@ -325,7 +314,7 @@ void CreateGeometry::dataCheck() m_ZBounds = m_ZBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -339,8 +328,7 @@ void CreateGeometry::dataCheck() .arg(m_XBoundsPtr.lock()->getNumberOfTuples()) .arg(m_YBoundsPtr.lock()->getNumberOfTuples()) .arg(m_ZBoundsPtr.lock()->getNumberOfTuples()); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-390, ss); return; } @@ -361,11 +349,12 @@ void CreateGeometry::dataCheck() getDataContainerArray()->getAttributeMatrix(getYBoundsArrayPath())->removeAttributeArray(getYBoundsArrayPath().getDataArrayName()); getDataContainerArray()->getAttributeMatrix(getZBoundsArrayPath())->removeAttributeArray(getZBoundsArrayPath().getDataArrayName()); } - rectgrid->setDimensions(m_XBoundsPtr.lock()->getNumberOfTuples() - 1, m_YBoundsPtr.lock()->getNumberOfTuples() - 1, m_ZBoundsPtr.lock()->getNumberOfTuples() - 1); + rectgrid->setDimensions(SizeVec3Type(m_XBoundsPtr.lock()->getNumberOfTuples() - 1, m_YBoundsPtr.lock()->getNumberOfTuples() - 1, m_ZBoundsPtr.lock()->getNumberOfTuples() - 1)); dc->setGeometry(rectgrid); QVector tDims = {rectgrid->getXPoints(), rectgrid->getYPoints(), rectgrid->getZPoints()}; - DataArrayPath path(getDataContainerName(), getRectGridCellAttributeMatrixName(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getRectGridCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } @@ -375,7 +364,7 @@ void CreateGeometry::dataCheck() FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath0(), cDims); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -393,7 +382,8 @@ void CreateGeometry::dataCheck() dc->setGeometry(vertex); QVector tDims(1, vertex->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName0(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName0()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); break; } @@ -409,7 +399,7 @@ void CreateGeometry::dataCheck() m_Edges = m_EdgesPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -430,10 +420,11 @@ void CreateGeometry::dataCheck() m_NumVerts = edge->getNumberOfVertices(); QVector tDims(1, edge->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName1(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName1()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = edge->getNumberOfEdges(); - path.update(getDataContainerName(), getEdgeAttributeMatrixName(), ""); + path.setAttributeMatrixName(getEdgeAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Edge); break; } @@ -448,7 +439,7 @@ void CreateGeometry::dataCheck() m_Tris = m_TrisPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -469,10 +460,11 @@ void CreateGeometry::dataCheck() m_NumVerts = triangle->getNumberOfVertices(); QVector tDims(1, triangle->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName2(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName2()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = triangle->getNumberOfTris(); - path.update(getDataContainerName(), getFaceAttributeMatrixName0(), ""); + path.setAttributeMatrixName(getFaceAttributeMatrixName0()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Face); break; } @@ -488,7 +480,7 @@ void CreateGeometry::dataCheck() m_Quads = m_QuadsPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -509,10 +501,11 @@ void CreateGeometry::dataCheck() m_NumVerts = quadrilateral->getNumberOfVertices(); QVector tDims(1, quadrilateral->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName3(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName3()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = quadrilateral->getNumberOfQuads(); - path.update(getDataContainerName(), getFaceAttributeMatrixName1(), ""); + path.setAttributeMatrixName(getFaceAttributeMatrixName1()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Face); break; } @@ -528,7 +521,7 @@ void CreateGeometry::dataCheck() m_Tets = m_TetsPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -550,10 +543,11 @@ void CreateGeometry::dataCheck() m_NumVerts = tetrahedral->getNumberOfVertices(); QVector tDims(1, tetrahedral->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName4(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName4()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = tetrahedral->getNumberOfTets(); - path.update(getDataContainerName(), getTetCellAttributeMatrixName(), ""); + path.setAttributeMatrixName(getTetCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } @@ -569,7 +563,7 @@ void CreateGeometry::dataCheck() m_Hexes = m_HexesPtr.lock()->getPointer(0); } - if (getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -592,18 +586,18 @@ void CreateGeometry::dataCheck() m_NumVerts = hexahedral->getNumberOfVertices(); QVector tDims(1, hexahedral->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName5(), ""); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName5()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = hexahedral->getNumberOfHexas(); - path.update(getDataContainerName(), getHexCellAttributeMatrixName(), ""); + path.setAttributeMatrixName(getHexCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } default: { QString ss = QObject::tr("Invalid selection for Geometry type"); - setErrorCondition(-701); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-701, ss); break; } } @@ -628,10 +622,10 @@ void CreateGeometry::preflight() // ----------------------------------------------------------------------------- void CreateGeometry::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -659,13 +653,11 @@ void CreateGeometry::execute() .arg(m_XBounds[i]); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -686,13 +678,11 @@ void CreateGeometry::execute() .arg(m_YBounds[i]); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -713,13 +703,11 @@ void CreateGeometry::execute() .arg(m_ZBounds[i]); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -753,13 +741,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -786,13 +772,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -819,13 +803,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -852,13 +834,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -885,13 +865,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if (m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -913,15 +891,15 @@ QString CreateGeometry::getBoxDimensions() { QString desc; QTextStream ss(&desc); - float halfRes[3] = {m_Resolution.x / 2.0f, m_Resolution.y / 2.0f, m_Resolution.z / 2.0f}; + float halfRes[3] = {m_Spacing[0] * 0.5f, m_Spacing[1] * 0.5f, m_Spacing[2] * 0.5f}; ss << "Extents:\n" - << "X Extent: 0 to " << m_Dimensions.x - 1 << " (dimension: " << m_Dimensions.x << ")\n" - << "Y Extent: 0 to " << m_Dimensions.y - 1 << " (dimension: " << m_Dimensions.y << ")\n" - << "Z Extent: 0 to " << m_Dimensions.z - 1 << " (dimension: " << m_Dimensions.z << ")\n" + << "X Extent: 0 to " << m_Dimensions[0] - 1 << " (dimension: " << m_Dimensions[0] << ")\n" + << "Y Extent: 0 to " << m_Dimensions[1] - 1 << " (dimension: " << m_Dimensions[1] << ")\n" + << "Z Extent: 0 to " << m_Dimensions[2] - 1 << " (dimension: " << m_Dimensions[2] << ")\n" << "Bounds:\n" - << "X Range: " << (m_Origin.x - halfRes[0]) << " to " << (m_Origin.x - halfRes[0] + m_Dimensions.x * m_Resolution.x) << " (delta: " << (m_Dimensions.x * m_Resolution.x) << ")\n" - << "Y Range: " << (m_Origin.y - halfRes[1]) << " to " << (m_Origin.y - halfRes[1] + m_Dimensions.y * m_Resolution.y) << " (delta: " << (m_Dimensions.y * m_Resolution.y) << ")\n" - << "Z Range: " << (m_Origin.z - halfRes[2]) << " to " << (m_Origin.z - halfRes[2] + m_Dimensions.z * m_Resolution.z) << " (delta: " << (m_Dimensions.z * m_Resolution.z) << ")\n"; + << "X Range: " << (m_Origin[0] - halfRes[0]) << " to " << (m_Origin[0] - halfRes[0] + m_Dimensions[0] * m_Spacing[0]) << " (delta: " << (m_Dimensions[0] * m_Spacing[0]) << ")\n" + << "Y Range: " << (m_Origin[1] - halfRes[1]) << " to " << (m_Origin[1] - halfRes[1] + m_Dimensions[1] * m_Spacing[1]) << " (delta: " << (m_Dimensions[1] * m_Spacing[1]) << ")\n" + << "Z Range: " << (m_Origin[2] - halfRes[2]) << " to " << (m_Origin[2] - halfRes[2] + m_Dimensions[2] * m_Spacing[2]) << " (delta: " << (m_Dimensions[2] * m_Spacing[2]) << ")\n"; return desc; return desc; } diff --git a/Source/SIMPLib/CoreFilters/CreateGeometry.h b/Source/SIMPLib/CoreFilters/CreateGeometry.h index 5f7bddc61d..8c1549b903 100644 --- a/Source/SIMPLib/CoreFilters/CreateGeometry.h +++ b/Source/SIMPLib/CoreFilters/CreateGeometry.h @@ -47,7 +47,7 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter Q_OBJECT PYB11_CREATE_BINDINGS(CreateGeometry SUPERCLASS AbstractFilter) PYB11_PROPERTY(int GeometryType READ getGeometryType WRITE setGeometryType) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath1 READ getSharedVertexListArrayPath1 WRITE setSharedVertexListArrayPath1) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath2 READ getSharedVertexListArrayPath2 WRITE setSharedVertexListArrayPath2) @@ -60,9 +60,9 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter PYB11_PROPERTY(DataArrayPath XBoundsArrayPath READ getXBoundsArrayPath WRITE setXBoundsArrayPath) PYB11_PROPERTY(DataArrayPath YBoundsArrayPath READ getYBoundsArrayPath WRITE setYBoundsArrayPath) PYB11_PROPERTY(DataArrayPath ZBoundsArrayPath READ getZBoundsArrayPath WRITE setZBoundsArrayPath) - PYB11_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - PYB11_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + PYB11_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) PYB11_PROPERTY(QString ImageCellAttributeMatrixName READ getImageCellAttributeMatrixName WRITE setImageCellAttributeMatrixName) PYB11_PROPERTY(QString RectGridCellAttributeMatrixName READ getRectGridCellAttributeMatrixName WRITE setRectGridCellAttributeMatrixName) PYB11_PROPERTY(QString VertexAttributeMatrixName0 READ getVertexAttributeMatrixName0 WRITE setVertexAttributeMatrixName0) @@ -90,8 +90,8 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter SIMPL_FILTER_PARAMETER(int, GeometryType) Q_PROPERTY(int GeometryType READ getGeometryType WRITE setGeometryType) - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath0) Q_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) @@ -135,14 +135,14 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter SIMPL_FILTER_PARAMETER(DataArrayPath, ZBoundsArrayPath) Q_PROPERTY(DataArrayPath ZBoundsArrayPath READ getZBoundsArrayPath WRITE setZBoundsArrayPath) - SIMPL_FILTER_PARAMETER(IntVec3_t, Dimensions) - Q_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) + SIMPL_FILTER_PARAMETER(IntVec3Type, Dimensions) + Q_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Origin) + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Resolution) - Q_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Spacing) + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) SIMPL_FILTER_PARAMETER(QString, ImageCellAttributeMatrixName) Q_PROPERTY(QString ImageCellAttributeMatrixName READ getImageCellAttributeMatrixName WRITE setImageCellAttributeMatrixName) diff --git a/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp b/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp index b9e9b5c53d..c00eeb422d 100644 --- a/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp @@ -50,18 +50,17 @@ CreateImageGeometry::CreateImageGeometry() : m_SelectedDataContainer("ImageGeomDataContainer") { - m_Dimensions.x = 0; - m_Dimensions.y = 0; - m_Dimensions.z = 0; + m_Dimensions[0] = 0; + m_Dimensions[1] = 0; + m_Dimensions[2] = 0; - m_Origin.x = 0.0f; - m_Origin.y = 0.0f; - m_Origin.z = 0.0f; - - m_Resolution.x = 1.0f; - m_Resolution.y = 1.0f; - m_Resolution.z = 1.0f; + m_Origin[0] = 0.0f; + m_Origin[1] = 0.0f; + m_Origin[2] = 0.0f; + m_Spacing[0] = 1.0f; + m_Spacing[1] = 1.0f; + m_Spacing[2] = 1.0f; } // ----------------------------------------------------------------------------- @@ -74,7 +73,7 @@ CreateImageGeometry::~CreateImageGeometry() = default; // ----------------------------------------------------------------------------- void CreateImageGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerSelectionFilterParameter::RequirementType req; parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", SelectedDataContainer, FilterParameter::Parameter, CreateImageGeometry, req)); @@ -82,7 +81,7 @@ void CreateImageGeometry::setupFilterParameters() parameters.push_back(SIMPL_NEW_INT_VEC3_FP("Dimensions", Dimensions, FilterParameter::Parameter, CreateImageGeometry)); parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, CreateImageGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resolution", Resolution, FilterParameter::Parameter, CreateImageGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Spacing", Spacing, FilterParameter::Parameter, CreateImageGeometry)); PreflightUpdatedValueFilterParameter::Pointer param = SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Box Size in Length Units", BoxDimensions, FilterParameter::Parameter, CreateImageGeometry); @@ -100,8 +99,8 @@ void CreateImageGeometry::readFilterParameters(AbstractFilterParametersReader* r reader->openFilterGroup(this, index); setDimensions(reader->readIntVec3("Dimensions", getDimensions())); setOrigin(reader->readFloatVec3("Origin", getOrigin())); - setResolution(reader->readFloatVec3("Resolution", getResolution())); - setSelectedDataContainer(reader->readString("SelectedDataContainer", getSelectedDataContainer())); + setSpacing(reader->readFloatVec3("Spacing", getSpacing())); + setSelectedDataContainer(reader->readDataArrayPath("SelectedDataContainer", getSelectedDataContainer())); reader->closeFilterGroup(); } @@ -117,33 +116,31 @@ void CreateImageGeometry::initialize() // ----------------------------------------------------------------------------- void CreateImageGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(m_Dimensions.x == 0 || m_Dimensions.y == 0 || m_Dimensions.z == 0) + if(m_Dimensions[0] == 0 || m_Dimensions[1] == 0 || m_Dimensions[2] == 0) { QString ss = QObject::tr("One of the dimensions has a size less than or equal to zero. The minimum size must be postive"); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-390, ss); } if(getSelectedDataContainer().isEmpty()) { QString ss = QObject::tr("The Data Container must have a name"); - setErrorCondition(-391); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-391, ss); return; } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainer()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry("ImageGeometry"); - image->setDimensions(std::make_tuple(m_Dimensions.x, m_Dimensions.y, m_Dimensions.z)); - image->setResolution(std::make_tuple(m_Resolution.x, m_Resolution.y, m_Resolution.z)); - image->setOrigin(std::make_tuple(m_Origin.x, m_Origin.y, m_Origin.z)); + image->setDimensions(std::make_tuple(m_Dimensions[0], m_Dimensions[1], m_Dimensions[2])); + image->setSpacing(std::make_tuple(m_Spacing[0], m_Spacing[1], m_Spacing[2])); + image->setOrigin(std::make_tuple(m_Origin[0], m_Origin[1], m_Origin[2])); m->setGeometry(image); } @@ -165,10 +162,10 @@ void CreateImageGeometry::preflight() // ----------------------------------------------------------------------------- void CreateImageGeometry::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -182,15 +179,15 @@ QString CreateImageGeometry::getBoxDimensions() { QString desc; QTextStream ss(&desc); - float halfRes[3] = {m_Resolution.x / 2.0f, m_Resolution.y / 2.0f, m_Resolution.z / 2.0f}; + float halfRes[3] = {m_Spacing[0] / 2.0f, m_Spacing[1] / 2.0f, m_Spacing[2] / 2.0f}; ss << "Extents:\n" - << "X Extent: 0 to " << m_Dimensions.x - 1 << " (dimension: " << m_Dimensions.x << ")\n" - << "Y Extent: 0 to " << m_Dimensions.y - 1 << " (dimension: " << m_Dimensions.y << ")\n" - << "Z Extent: 0 to " << m_Dimensions.z - 1 << " (dimension: " << m_Dimensions.z << ")\n" + << "X Extent: 0 to " << m_Dimensions[0] - 1 << " (dimension: " << m_Dimensions[0] << ")\n" + << "Y Extent: 0 to " << m_Dimensions[1] - 1 << " (dimension: " << m_Dimensions[1] << ")\n" + << "Z Extent: 0 to " << m_Dimensions[2] - 1 << " (dimension: " << m_Dimensions[2] << ")\n" << "Bounds:\n" - << "X Range: " << (m_Origin.x - halfRes[0]) << " to " << (m_Origin.x - halfRes[0] + m_Dimensions.x * m_Resolution.x) << " (delta: " << (m_Dimensions.x * m_Resolution.x) << ")\n" - << "Y Range: " << (m_Origin.y - halfRes[1]) << " to " << (m_Origin.y - halfRes[1] + m_Dimensions.y * m_Resolution.y) << " (delta: " << (m_Dimensions.y * m_Resolution.y) << ")\n" - << "Z Range: " << (m_Origin.z - halfRes[2]) << " to " << (m_Origin.z - halfRes[2] + m_Dimensions.z * m_Resolution.z) << " (delta: " << (m_Dimensions.z * m_Resolution.z) << ")\n"; + << "X Range: " << (m_Origin[0] - halfRes[0]) << " to " << (m_Origin[0] - halfRes[0] + m_Dimensions[0] * m_Spacing[0]) << " (delta: " << (m_Dimensions[0] * m_Spacing[0]) << ")\n" + << "Y Range: " << (m_Origin[1] - halfRes[1]) << " to " << (m_Origin[1] - halfRes[1] + m_Dimensions[1] * m_Spacing[1]) << " (delta: " << (m_Dimensions[1] * m_Spacing[1]) << ")\n" + << "Z Range: " << (m_Origin[2] - halfRes[2]) << " to " << (m_Origin[2] - halfRes[2] + m_Dimensions[2] * m_Spacing[2]) << " (delta: " << (m_Dimensions[2] * m_Spacing[2]) << ")\n"; return desc; } diff --git a/Source/SIMPLib/CoreFilters/CreateImageGeometry.h b/Source/SIMPLib/CoreFilters/CreateImageGeometry.h index 3fc8aebab2..17af1eb371 100755 --- a/Source/SIMPLib/CoreFilters/CreateImageGeometry.h +++ b/Source/SIMPLib/CoreFilters/CreateImageGeometry.h @@ -49,10 +49,10 @@ class SIMPLib_EXPORT CreateImageGeometry : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(CreateImageGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) - PYB11_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - PYB11_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + PYB11_PROPERTY(DataArrayPath SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) + PYB11_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) public: SIMPL_SHARED_POINTERS(CreateImageGeometry) @@ -61,17 +61,17 @@ class SIMPLib_EXPORT CreateImageGeometry : public AbstractFilter ~CreateImageGeometry() override; - SIMPL_FILTER_PARAMETER(QString, SelectedDataContainer) - Q_PROPERTY(QString SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) + SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedDataContainer) + Q_PROPERTY(DataArrayPath SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) - SIMPL_FILTER_PARAMETER(IntVec3_t, Dimensions) - Q_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) + SIMPL_FILTER_PARAMETER(IntVec3Type, Dimensions) + Q_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Origin) + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Resolution) - Q_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Spacing) + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) QString getBoxDimensions(); Q_PROPERTY(QString BoxDimensions READ getBoxDimensions) diff --git a/Source/SIMPLib/CoreFilters/CreateStringArray.cpp b/Source/SIMPLib/CoreFilters/CreateStringArray.cpp index dbeab50795..cd47fcfbff 100644 --- a/Source/SIMPLib/CoreFilters/CreateStringArray.cpp +++ b/Source/SIMPLib/CoreFilters/CreateStringArray.cpp @@ -48,6 +48,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + StringArrayID = 1 +}; + /** * @brief initializeArrayWithInts Initializes the array p with integers, either from the * manual value entered in the filter, or with a random number. This function does not @@ -83,7 +87,7 @@ CreateStringArray::~CreateStringArray() = default; // ----------------------------------------------------------------------------- void CreateStringArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; // Do not let the user change the number of components in a StringDataArray setNumberOfComponents(1); @@ -121,46 +125,42 @@ void CreateStringArray::initialize() // ----------------------------------------------------------------------------- void CreateStringArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(getNumberOfComponents() < 0) { - setErrorCondition(-8150); QString ss = QObject::tr("The number of components must non-negative"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8150, ss); } if(getNumberOfComponents() == 0) { - setErrorCondition(-8151); QString ss = QObject::tr("The number of components is Zero. This will result in an array that has no memory allocated. Are you sure you wanted to do this?"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8151, ss); } if(!getNewArray().isValid()) { - setErrorCondition(-8152); QString ss = QObject::tr("The Created DataArrayPath is invalid. Please select the Data Container, Attribute Matrix and set an output DataArray name."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8152, ss); } if (m_InitializationValue.isEmpty()) { QString ss = "Empty initialization value."; - setErrorCondition(-5759); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5759, ss); } QVector cDims(1, getNumberOfComponents()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } // Create the data array and initialize it to a placeholder value - m_OutputArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getNewArray(), m_InitializationValue, cDims); + m_OutputArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getNewArray(), m_InitializationValue, cDims, "", StringArrayID); } // ----------------------------------------------------------------------------- @@ -181,10 +181,10 @@ void CreateStringArray::preflight() // ----------------------------------------------------------------------------- void CreateStringArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp b/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp index 14c9fce899..1872f92f3f 100644 --- a/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp @@ -40,12 +40,17 @@ #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/FloatFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + DataContainerID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -71,7 +76,7 @@ CropVertexGeometry::~CropVertexGeometry() = default; // ----------------------------------------------------------------------------- void CropVertexGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; DataContainerSelectionFilterParameter::RequirementType req; IGeometry::Types reqGeom = {IGeometry::Type::Vertex}; req.dcGeometryTypes = reqGeom; @@ -82,7 +87,7 @@ void CropVertexGeometry::setupFilterParameters() parameters.push_back(SIMPL_NEW_FLOAT_FP("X Max", XMax, FilterParameter::Parameter, CropVertexGeometry)); parameters.push_back(SIMPL_NEW_FLOAT_FP("Y Max", YMax, FilterParameter::Parameter, CropVertexGeometry)); parameters.push_back(SIMPL_NEW_FLOAT_FP("Z Max", ZMax, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_STRING_FP("Cropped Data Container", CroppedDataContainerName, FilterParameter::CreatedArray, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Cropped Data Container", CroppedDataContainerName, FilterParameter::CreatedArray, CropVertexGeometry)); setFilterParameters(parameters); } @@ -92,14 +97,14 @@ void CropVertexGeometry::setupFilterParameters() void CropVertexGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); setXMin(reader->readValue("XMin", getXMin())); setYMin(reader->readValue("YMin", getYMin())); setZMin(reader->readValue("ZMin", getZMin())); setXMax(reader->readValue("XMax", getXMax())); setYMax(reader->readValue("YMax", getYMax())); setZMax(reader->readValue("ZMax", getZMax())); - setCroppedDataContainerName(reader->readString("CroppedDataContainerName", getCroppedDataContainerName())); + setCroppedDataContainerName(reader->readDataArrayPath("CroppedDataContainerName", getCroppedDataContainerName())); reader->closeFilterGroup(); } @@ -108,8 +113,8 @@ void CropVertexGeometry::readFilterParameters(AbstractFilterParametersReader* re // ----------------------------------------------------------------------------- void CropVertexGeometry::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); m_AttrMatList.clear(); } @@ -119,8 +124,8 @@ void CropVertexGeometry::initialize() // ----------------------------------------------------------------------------- void CropVertexGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); @@ -128,25 +133,22 @@ void CropVertexGeometry::dataCheck() if(getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); } if(getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); } if(getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); } - DataContainer::Pointer dc = getDataContainerArray()->createNonPrereqDataContainer(this, getCroppedDataContainerName()); + DataContainer::Pointer dc = getDataContainerArray()->createNonPrereqDataContainer(this, getCroppedDataContainerName(), DataContainerID); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -161,7 +163,7 @@ void CropVertexGeometry::dataCheck() DataArrayPath tempPath; AttributeMatrix::Type tempAttrMatType = AttributeMatrix::Type::Vertex; - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -169,13 +171,13 @@ void CropVertexGeometry::dataCheck() for(auto&& attr_mat : m_AttrMatList) { AttributeMatrix::Pointer tmpAttrMat = m->getPrereqAttributeMatrix(this, attr_mat, -301); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { tempAttrMatType = tmpAttrMat->getType(); if(tempAttrMatType != AttributeMatrix::Type::Vertex) { AttributeMatrix::Pointer attrMat = tmpAttrMat->deepCopy(getInPreflight()); - dc->addAttributeMatrix(attr_mat, attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); } else { @@ -183,9 +185,9 @@ void CropVertexGeometry::dataCheck() tempDataArrayList = tmpAttrMat->getAttributeArrayNames(); for(auto&& data_array : tempDataArrayList) { - tempPath.update(getCroppedDataContainerName(), tmpAttrMat->getName(), data_array); + tempPath.update(getCroppedDataContainerName().getDataContainerName(), tmpAttrMat->getName(), data_array); IDataArray::Pointer tmpDataArray = tmpAttrMat->getPrereqIDataArray(this, data_array, -90002); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { QVector cDims = tmpDataArray->getComponentDimensions(); TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray); @@ -240,10 +242,10 @@ template void copyDataToCroppedGeometry(IDataArray::Pointer inDataP // ----------------------------------------------------------------------------- void CropVertexGeometry::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -290,7 +292,7 @@ void CropVertexGeometry::execute() for(auto&& attr_mat : m_AttrMatList) { AttributeMatrix::Pointer tmpAttrMat = dc->getPrereqAttributeMatrix(this, attr_mat, -301); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { AttributeMatrix::Type tempAttrMatType = tmpAttrMat->getType(); if(tempAttrMatType == AttributeMatrix::Type::Vertex) diff --git a/Source/SIMPLib/CoreFilters/CropVertexGeometry.h b/Source/SIMPLib/CoreFilters/CropVertexGeometry.h index aa190086fd..e3b082f62e 100644 --- a/Source/SIMPLib/CoreFilters/CropVertexGeometry.h +++ b/Source/SIMPLib/CoreFilters/CropVertexGeometry.h @@ -46,8 +46,8 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(CropVertexGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - PYB11_PROPERTY(QString CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) PYB11_PROPERTY(float XMin READ getXMin WRITE setXMin) PYB11_PROPERTY(float YMin READ getYMin WRITE setYMin) PYB11_PROPERTY(float ZMin READ getZMin WRITE setZMin) @@ -62,11 +62,11 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter ~CropVertexGeometry() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) - SIMPL_FILTER_PARAMETER(QString, CroppedDataContainerName) - Q_PROPERTY(QString CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, CroppedDataContainerName) + Q_PROPERTY(DataArrayPath CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) SIMPL_FILTER_PARAMETER(float, XMin) Q_PROPERTY(float XMin READ getXMin WRITE setXMin) diff --git a/Source/SIMPLib/CoreFilters/DataContainerReader.cpp b/Source/SIMPLib/CoreFilters/DataContainerReader.cpp index 12845d314a..8515f4af66 100644 --- a/Source/SIMPLib/CoreFilters/DataContainerReader.cpp +++ b/Source/SIMPLib/CoreFilters/DataContainerReader.cpp @@ -74,7 +74,7 @@ DataContainerReader::~DataContainerReader() = default; // ----------------------------------------------------------------------------- void DataContainerReader::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_BOOL_FP("Overwrite Existing Data Containers", OverwriteExistingDataContainers, FilterParameter::Parameter, DataContainerReader)); { @@ -155,17 +155,15 @@ void DataContainerReader::dataCheck() if(getInputFile().isEmpty()) { ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } else if(!fi.exists()) { ss = QObject::tr("The input file %1 does not exist").arg(getInputFile()); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-388, ss); } - if(getErrorCondition() != 0) + if(getErrorCode() != 0) { // something has gone wrong and errors were logged already so just return return; @@ -180,32 +178,27 @@ void DataContainerReader::dataCheck() return; } - QList& tempContainers = tempDCA->getDataContainers(); - - QListIterator iter(tempContainers); - while(iter.hasNext()) + DataContainerArray::Container tempContainers = tempDCA->getDataContainers(); + for(DataContainer::Pointer container : tempContainers) { - DataContainer::Pointer container = iter.next(); - if(getOverwriteExistingDataContainers()) { if(dca->doesDataContainerExist(container->getName())) { dca->removeDataContainer(container->getName()); } - dca->addDataContainer(container); + dca->addOrReplaceDataContainer(container); } else { if(dca->doesDataContainerExist(container->getName())) { ss = QObject::tr("The input file has a DataContainer with a name (%1) that already exists in the current DataContainerArray structure").arg(container->getName()); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-390, ss); } else { - dca->addDataContainer(container); + dca->addOrReplaceDataContainer(container); } } } @@ -250,14 +243,11 @@ void DataContainerReader::execute() // ----------------------------------------------------------------------------- DataContainerArray::Pointer DataContainerReader::readData(DataContainerArrayProxy& proxy) { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); SIMPLH5DataReader::Pointer simplReader = SIMPLH5DataReader::New(); - connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, const int& code) { - setErrorCondition(code); - notifyErrorMessage(getHumanLabel(), msg, getErrorCondition()); - }); + connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, const int& code) { setErrorCondition(code, msg); }); if (!simplReader->openFile(getInputFile())) { @@ -273,9 +263,8 @@ DataContainerArray::Pointer DataContainerReader::readData(DataContainerArrayProx hid_t fileId = QH5Utilities::openFile(getInputFile(), true); // Open the file Read Only if(fileId < 0) { - setErrorCondition(-150); QString ss = QObject::tr("Error opening input file '%1'").arg(getInputFile()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-150, ss); return DataContainerArray::NullPointer(); } H5ScopedFileSentinel sentinel(&fileId, true); @@ -285,9 +274,8 @@ DataContainerArray::Pointer DataContainerReader::readData(DataContainerArrayProx int32_t err = readExistingPipelineFromFile(fileId); if(err < 0) { - setErrorCondition(err); QString ss = QObject::tr("Error trying to read the existing pipeline from the file '%1'").arg(getInputFile()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return DataContainerArray::New(); } } @@ -417,10 +405,7 @@ bool DataContainerReader::syncProxies() SIMPLH5DataReaderRequirements req(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); SIMPLH5DataReader::Pointer simplReader = SIMPLH5DataReader::New(); - connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, const int& code) { - setErrorCondition(code); - notifyErrorMessage(getHumanLabel(), msg, getErrorCondition()); - }); + connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, const int& code) { setErrorCondition(code, msg); }); if(!simplReader->openFile(getInputFile())) { diff --git a/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp b/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp index 6f6ef64ba8..4997762092 100644 --- a/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp +++ b/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp @@ -83,7 +83,7 @@ DataContainerWriter::~DataContainerWriter() // ----------------------------------------------------------------------------- void DataContainerWriter::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File", OutputFile, FilterParameter::Parameter, DataContainerWriter, "*.dream3d", "")); parameters.push_back(SIMPL_NEW_BOOL_FP("Write Xdmf File", WriteXdmfFile, FilterParameter::Parameter, DataContainerWriter)); @@ -116,8 +116,8 @@ void DataContainerWriter::initialize() // ----------------------------------------------------------------------------- void DataContainerWriter::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QString ss; QFileInfo fi(m_OutputFile); @@ -147,10 +147,10 @@ void DataContainerWriter::preflight() // ----------------------------------------------------------------------------- void DataContainerWriter::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -165,8 +165,7 @@ void DataContainerWriter::execute() if(!dir.mkpath(parentPath)) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath); - setErrorCondition(-11110); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11110, ss); return; } @@ -174,8 +173,7 @@ void DataContainerWriter::execute() if(err < 0) { QString ss = QObject::tr("The HDF5 file could not be opened or created.\n The given filename was:\n\t[%1]").arg(m_OutputFile); - setErrorCondition(-11112); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11112, ss); return; } // qDebug() << "DREAM3D File: " << m_OutputFile; @@ -214,8 +212,7 @@ void DataContainerWriter::execute() if(err < 0) { QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(SIMPL::StringConstants::DataContainerGroupName); - setErrorCondition(-60); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-60, ss); return; } hid_t dcaGid = H5Gopen(m_FileId, SIMPL::StringConstants::DataContainerGroupName.toLatin1().data(), H5P_DEFAULT); @@ -230,26 +227,25 @@ void DataContainerWriter::execute() if(err < 0) { QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(dcNames[iter]); - setErrorCondition(-60); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-60, ss); return; } hid_t dcGid = H5Gopen(dcaGid, dcNames[iter].toLatin1().data(), H5P_DEFAULT); H5ScopedGroupSentinel groupSentinel(&dcGid, false); - // QString ss = QObject::tr("%1 |--> Writing %2 DataContainer ").arg(getMessagePrefix()).arg(dcNames[iter]); + // QString ss = QObject::tr("Writing %2 DataContainer").arg(dcNames[iter]); // Have the DataContainer write all of its Attribute Matrices and its Mesh err = dc->writeAttributeMatricesToHDF5(dcGid); if(err < 0) { - notifyErrorMessage(getHumanLabel(), "Error writing DataContainer AttributeMatrices", -803); + setErrorCondition(-803, "Error writing DataContainer AttributeMatrices"); return; } err = dc->writeMeshToHDF5(dcGid, m_WriteXdmfFile); if(err < 0) { - notifyErrorMessage(getHumanLabel(), "Error writing DataContainer Geometry", -804); + setErrorCondition(-804, "Error writing DataContainer Geometry"); return; } if(m_WriteXdmfFile && geometry.get() != nullptr) @@ -261,7 +257,7 @@ void DataContainerWriter::execute() dc->getGeometry()->setTimeValue(static_cast(iter)); } #if 0 - dc->getGeometry()->addAttributeMatrix(SIMPL::StringConstants::MetaData, dc->getAttributeMatrix(SIMPL::StringConstants::MetaData)); + dc->getGeometry()->addOrReplaceAttributeMatrix(SIMPL::StringConstants::MetaData, dc->getAttributeMatrix(SIMPL::StringConstants::MetaData)); dc->getGeometry()->setTemporalDataPath(DataArrayPath(dc->getName(), SIMPL::StringConstants::MetaData, "Step #")); #endif @@ -269,7 +265,7 @@ void DataContainerWriter::execute() err = dc->writeXdmf(xdmfOut, hdfFileName); if(err < 0) { - notifyErrorMessage(getHumanLabel(), "Error writing Xdmf File", -805); + setErrorCondition(-805, "Error writing Xdmf File"); return; } } @@ -280,8 +276,7 @@ void DataContainerWriter::execute() if(err < 0) { QString ss = QObject::tr("Error writing DataContainerBundles"); - setErrorCondition(-11113); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11113, ss); return; } @@ -306,8 +301,7 @@ int DataContainerWriter::writeDataContainerBundles(hid_t fileId) if(err < 0) { QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(SIMPL::StringConstants::DataContainerBundleGroupName); - setErrorCondition(-61); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-61, ss); return -1; } hid_t dcbGid = H5Gopen(m_FileId, SIMPL::StringConstants::DataContainerBundleGroupName.toLatin1().data(), H5P_DEFAULT); diff --git a/Source/SIMPLib/CoreFilters/EmptyFilter.cpp b/Source/SIMPLib/CoreFilters/EmptyFilter.cpp index d3c0a82498..2cb41e3805 100644 --- a/Source/SIMPLib/CoreFilters/EmptyFilter.cpp +++ b/Source/SIMPLib/CoreFilters/EmptyFilter.cpp @@ -58,7 +58,7 @@ EmptyFilter::~EmptyFilter() = default; // ----------------------------------------------------------------------------- void EmptyFilter::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; QString str; QTextStream ss(&str); @@ -100,8 +100,7 @@ void EmptyFilter::initialize() void EmptyFilter::dataCheck() { QString ss = QObject::tr("This filter does nothing and was inserted as a place holder for filter '%1' that does not exist anymore.").arg(getOriginalFilterName()); - setErrorCondition(-9999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-9999, ss); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp b/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp index be63ac1554..b673e71caf 100644 --- a/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp +++ b/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp @@ -60,7 +60,7 @@ ExecuteProcess::~ExecuteProcess() = default; // ----------------------------------------------------------------------------- void ExecuteProcess::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_STRING_FP("Command Line Arguments", Arguments, FilterParameter::Parameter, ExecuteProcess)); @@ -91,15 +91,14 @@ void ExecuteProcess::initialize() // ----------------------------------------------------------------------------- void ExecuteProcess::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QStringList arguments = splitArgumentsString(m_Arguments); if(arguments.empty()) { QString ss = QObject::tr("No command line arguments have been specified."); - setErrorCondition(-4001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4001, ss); return; } @@ -109,8 +108,7 @@ void ExecuteProcess::dataCheck() // if( !fi.exists()) // { // QString ss = QObject::tr("The executable at %1 does not exist.").arg(prog); - // setErrorCondition(-4000); - // notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + // setErrorCondition(-4000, ss); // return; // } } @@ -134,10 +132,10 @@ void ExecuteProcess::preflight() // ----------------------------------------------------------------------------- void ExecuteProcess::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -222,16 +220,14 @@ void ExecuteProcess::processHasFinished(int exitCode, QProcess::ExitStatus exitS else if(exitStatus == QProcess::CrashExit) { QString ss = QObject::tr("The process crashed during its exit."); - setErrorCondition(-4003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4003, ss); } else if(exitCode < 0) { QString ss = QObject::tr("The process finished with exit code %1.").arg(QString::number(exitCode)); - setErrorCondition(-4004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4004, ss); } - else if(getErrorCondition() >= 0) + else if(getErrorCode() >= 0) { } @@ -247,8 +243,7 @@ void ExecuteProcess::processHasErroredOut(QProcess::ProcessError error) if(getCancel()) { QString ss = QObject::tr("The process was killed by the user."); - setWarningCondition(-4004); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-4004, ss); } else if(error == QProcess::FailedToStart) { @@ -258,38 +253,32 @@ void ExecuteProcess::processHasErroredOut(QProcess::ProcessError error) QString ss = QObject::tr("The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program \ or the path containing the executble is not in the system's environment path. PATH=%1.\n Try using the absolute path to the executable.") .arg(pathEnv); - setErrorCondition(-4005); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4005, ss); } else if(error == QProcess::Crashed) { QString ss = QObject::tr("The process crashed some time after starting successfully."); - setErrorCondition(-4006); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4006, ss); } else if(error == QProcess::Timedout) { QString ss = QObject::tr("The process timed out."); - setErrorCondition(-4007); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4007, ss); } else if(error == QProcess::WriteError) { QString ss = QObject::tr("An error occurred when attempting to write to the process."); - setErrorCondition(-4008); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4008, ss); } else if(error == QProcess::ReadError) { QString ss = QObject::tr("An error occurred when attempting to read from the process."); - setErrorCondition(-4009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4009, ss); } else { QString ss = QObject::tr("An unknown error occurred."); - setErrorCondition(-4010); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4010, ss); } m_Pause = false; @@ -308,7 +297,7 @@ void ExecuteProcess::sendErrorOutput() { error.chop(1); } - notifyStandardOutputMessage(getHumanLabel(), getPipelineIndex() + 1, error); + notifyStatusMessage(error); m_WaitCondition.wakeAll(); } } @@ -320,7 +309,7 @@ void ExecuteProcess::sendStandardOutput() { if(m_ProcessPtr.data() != nullptr) { - notifyStandardOutputMessage(getHumanLabel(), getPipelineIndex() + 1, m_ProcessPtr->readAllStandardOutput()); + notifyStatusMessage(m_ProcessPtr->readAllStandardOutput()); m_WaitCondition.wakeAll(); } } diff --git a/Source/SIMPLib/CoreFilters/ExecuteProcess.h b/Source/SIMPLib/CoreFilters/ExecuteProcess.h index 786c044d2b..d5cab1cbff 100644 --- a/Source/SIMPLib/CoreFilters/ExecuteProcess.h +++ b/Source/SIMPLib/CoreFilters/ExecuteProcess.h @@ -175,7 +175,7 @@ class SIMPLib_EXPORT ExecuteProcess : public AbstractFilter private: QWaitCondition m_WaitCondition; QMutex m_Mutex; - bool m_Pause; + bool m_Pause = false; QSharedPointer m_ProcessPtr; /** diff --git a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp index d2eec9d1ca..d53706a638 100644 --- a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp @@ -52,6 +52,23 @@ #include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + RectGrid_XBoundsID = 1, + RectGrid_YBoundsID, + RectGrid_ZBoundsID, + Vert_SharedVertexID, + Edge_SharedVertexID, + Edge_SharedEdgeID, + Tri_SharedVertexID, + Tri_SharedTriangleID, + Quad_SharedVertexID, + Quad_SharedQuadID, + Tet_SharedVertexID, + Tet_SharedTetID, + Hex_SharedVertexID, + Hex_SharedHexID +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -85,8 +102,8 @@ ExtractAttributeArraysFromGeometry::~ExtractAttributeArraysFromGeometry() = defa // ----------------------------------------------------------------------------- void ExtractAttributeArraysFromGeometry::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -95,7 +112,7 @@ void ExtractAttributeArraysFromGeometry::initialize() // ----------------------------------------------------------------------------- void ExtractAttributeArraysFromGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedDataContainerSelectionFilterParameter::Pointer parameter = LinkedDataContainerSelectionFilterParameter::New(); parameter->setHumanLabel("Geometry"); @@ -180,7 +197,7 @@ void ExtractAttributeArraysFromGeometry::setupFilterParameters() void ExtractAttributeArraysFromGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); setSharedVertexListArrayPath0(reader->readDataArrayPath("SharedVertexListArrayPath0", getSharedVertexListArrayPath0())); setSharedVertexListArrayPath1(reader->readDataArrayPath("SharedVertexListArrayPath1", getSharedVertexListArrayPath1())); setSharedVertexListArrayPath2(reader->readDataArrayPath("SharedVertexListArrayPath2", getSharedVertexListArrayPath2())); @@ -203,13 +220,13 @@ void ExtractAttributeArraysFromGeometry::readFilterParameters(AbstractFilterPara // ----------------------------------------------------------------------------- void ExtractAttributeArraysFromGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); IGeometry::Pointer igeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -231,32 +248,32 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 1); - m_XBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getXBoundsArrayPath(), 0, cDims); + m_XBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getXBoundsArrayPath(), 0, cDims, "", RectGrid_XBoundsID); if(m_XBoundsPtr.lock()) { m_XBounds = m_XBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { xarrays.push_back(m_XBoundsPtr.lock()); } - m_YBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getYBoundsArrayPath(), 0, cDims); + m_YBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getYBoundsArrayPath(), 0, cDims, "", RectGrid_YBoundsID); if(m_YBoundsPtr.lock()) { m_YBounds = m_YBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { yarrays.push_back(m_YBoundsPtr.lock()); } - m_ZBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getZBoundsArrayPath(), 0, cDims); + m_ZBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getZBoundsArrayPath(), 0, cDims, "", RectGrid_ZBoundsID); if(m_ZBoundsPtr.lock()) { m_ZBounds = m_ZBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { zarrays.push_back(m_ZBoundsPtr.lock()); } @@ -276,12 +293,12 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath0(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath0(), 0, cDims, "", Vert_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { arrays.push_back(m_VertsPtr.lock()); } @@ -301,24 +318,24 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath1(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath1(), 0, cDims, "", Edge_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 2; - m_EdgesPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedEdgeListArrayPath(), 0, cDims); + m_EdgesPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedEdgeListArrayPath(), 0, cDims, "", Edge_SharedEdgeID); if(m_EdgesPtr.lock()) { m_Edges = m_EdgesPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_EdgesPtr.lock()); } @@ -339,22 +356,22 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath2(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath2(), 0, cDims, "", Tri_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } - m_TrisPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedTriListArrayPath(), 0, cDims); + m_TrisPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedTriListArrayPath(), 0, cDims, "", Tri_SharedTriangleID); if(m_TrisPtr.lock()) { m_Tris = m_TrisPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_TrisPtr.lock()); } @@ -375,24 +392,24 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath3(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath3(), 0, cDims, "", Quad_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 4; - m_QuadsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedQuadListArrayPath(), 0, cDims); + m_QuadsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedQuadListArrayPath(), 0, cDims, "", Quad_SharedQuadID); if(m_QuadsPtr.lock()) { m_Quads = m_QuadsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_QuadsPtr.lock()); } @@ -413,24 +430,24 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath4(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath4(), 0, cDims, "", Tet_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 4; - m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedTetListArrayPath(), 0, cDims); + m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedTetListArrayPath(), 0, cDims, "", Tet_SharedTetID); if(m_TetsPtr.lock()) { m_Tets = m_TetsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_TetsPtr.lock()); } @@ -451,24 +468,24 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath5(), 0, cDims); - if (m_VertsPtr.lock()) + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath5(), 0, cDims, "", Hex_SharedVertexID); + if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if (getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 8; - m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedHexListArrayPath(), 0, cDims); - if (m_TetsPtr.lock()) + m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedHexListArrayPath(), 0, cDims, "", Hex_SharedHexID); + if(m_TetsPtr.lock()) { m_Tets = m_TetsPtr.lock()->getPointer(0); } - if (getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_TetsPtr.lock()); } @@ -483,10 +500,9 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QString ss = QObject::tr("Selected Data Container (%1) does not contain a valid geometry\n" "Geometry Type: %2\n" "Valid Geometry Types: Rectilinear Grid, Vertex, Edge, Triangle, Quadrilateral, Tetrahedral") - .arg(getDataContainerName()) + .arg(getDataContainerName().getDataContainerName()) .arg(igeom->getGeometryTypeAsString()); - setErrorCondition(-701); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-701, ss); break; } } @@ -513,7 +529,7 @@ void ExtractAttributeArraysFromGeometry::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h index f1b70737e3..0ecaf8b7e8 100644 --- a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h +++ b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h @@ -46,7 +46,7 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(ExtractAttributeArraysFromGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath1 READ getSharedVertexListArrayPath1 WRITE setSharedVertexListArrayPath1) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath2 READ getSharedVertexListArrayPath2 WRITE setSharedVertexListArrayPath2) @@ -67,8 +67,8 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter ~ExtractAttributeArraysFromGeometry() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath0) Q_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) diff --git a/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp b/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp index 1f1c982c58..5e633da1e5 100644 --- a/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp +++ b/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp @@ -44,6 +44,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + DataArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -64,7 +68,7 @@ ExtractComponentAsArray::~ExtractComponentAsArray() = default; // ----------------------------------------------------------------------------- void ExtractComponentAsArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_INTEGER_FP("Component Number to Extract", CompNumber, FilterParameter::Parameter, ExtractComponentAsArray)); @@ -102,19 +106,18 @@ void ExtractComponentAsArray::initialize() // ----------------------------------------------------------------------------- void ExtractComponentAsArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); if(m_NewArrayArrayName.isEmpty()) { - setErrorCondition(-11003); - notifyErrorMessage(getHumanLabel(), "New array name must be set.", getErrorCondition()); + setErrorCondition(-11003, "New array name must be set."); return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -124,34 +127,31 @@ void ExtractComponentAsArray::dataCheck() QString ss = QObject::tr("Selected array '%1' must have more than 1 component. The number of components is %2") .arg(getSelectedArrayPath().getDataArrayName()) .arg(m_InArrayPtr.lock()->getNumberOfComponents()); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } if(m_CompNumber >= m_InArrayPtr.lock()->getNumberOfComponents()) { - setErrorCondition(-11004); QString ss = QObject::tr("Error extracting component from DataArray '%3', Component to extract (%1) is greater than or equal to the number of components (%2).") .arg(m_CompNumber) .arg(m_InArrayPtr.lock()->getNumberOfComponents()) .arg(getSelectedArrayPath().getDataArrayName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } if(m_CompNumber < 0) { - setErrorCondition(-11005); QString ss = QObject::tr("Component to extract (%1) is a negative value and this is not allowed. Value must be Zero (0) or greater.") .arg(m_CompNumber); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11005, ss); return; } QVector cDims(1, 1); DataArrayPath tempPath(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), getNewArrayArrayName()); - m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock()); + m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock(), DataArrayID); } // ----------------------------------------------------------------------------- @@ -196,10 +196,10 @@ template void extractComponent(IDataArray::Pointer inputData, IData // ----------------------------------------------------------------------------- void ExtractComponentAsArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp index 9d15a10aeb..2778d46fbe 100644 --- a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp @@ -45,6 +45,11 @@ #include "SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + DataContainerID = 1, + AttributeMatrixID +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -66,8 +71,8 @@ ExtractVertexGeometry::~ExtractVertexGeometry() = default; // ----------------------------------------------------------------------------- void ExtractVertexGeometry::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -79,7 +84,7 @@ void ExtractVertexGeometry::setupFilterParameters() m_NewDCGeometryChoices.clear(); m_ArrayHandlingChoices.clear(); - FilterParameterVector parameters; + FilterParameterVectorType parameters; // { // m_NewDCGeometryChoices.push_back("Vertex Geometry"); @@ -118,35 +123,32 @@ void ExtractVertexGeometry::setupFilterParameters() // ----------------------------------------------------------------------------- void ExtractVertexGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_ArrayHandling < 0) { QString ss = QObject::tr("'Array Handling' has not been selected."); - setErrorCondition(-2002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2002, ss); return; } if(m_ArrayHandling > m_ArrayHandlingChoices.size() - 1) { QString ss = QObject::tr("'Array Handling' index is out of bounds. Valid values are 0 or 1."); - setErrorCondition(-2003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2003, ss); return; } if(m_SelectedDataContainerName.isEmpty()) { QString ss = QObject::tr("The name of the input DataContainer is empty. Please specify a value."); - setErrorCondition(-2004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2004, ss); return; } - DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, m_SelectedDataContainerName); - if(getErrorCondition() < 0) + DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainerName()); + if(getErrorCode() < 0) { return; } @@ -154,16 +156,14 @@ void ExtractVertexGeometry::dataCheck() if(getVertexDataContainerName().isEmpty()) { QString ss = QObject::tr("The name of the created Vertex DataContainer is empty. Please specify a value."); - setErrorCondition(-2006); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2006, ss); return; } if(getDataContainerArray()->doesDataContainerExist(getVertexDataContainerName())) { - QString ss = QObject::tr("A Data Container with name '%1' already exists.").arg(getVertexDataContainerName()); - setErrorCondition(-2007); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("A Data Container with name '%1' already exists.").arg(getVertexDataContainerName().getDataContainerName()); + setErrorCondition(-2007, ss); return; } @@ -172,15 +172,14 @@ void ExtractVertexGeometry::dataCheck() if(nullptr == fromGeometry.get()) { QString ss = QObject::tr("Selected input DataContainer must contain either an Image Geometry or RectLinearGrid Geometry. The DataContainer did not contain a Geometry object."); - setErrorCondition(-2008); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2008, ss); return; } IGeometry::Type geomType = fromGeometry->getGeometryType(); size_t elementCount = 0; if(IGeometry::Type::Image == geomType || IGeometry::Type::RectGrid == geomType) { - vertexDataContainer = getDataContainerArray()->createNonPrereqDataContainer(this, getVertexDataContainerName()); + vertexDataContainer = getDataContainerArray()->createNonPrereqDataContainer(this, getVertexDataContainerName(), DataContainerID); IGeometryGrid::Pointer imageGeom = std::dynamic_pointer_cast(fromGeometry); SIMPL::Tuple3SVec imageDims = imageGeom->getDimensions(); VertexGeom::Pointer vertexGeom = VertexGeom::CreateGeometry(static_cast(std::get<0>(imageDims) * std::get<1>(imageDims) * std::get<2>(imageDims)), "VertexGeometry", !getInPreflight()); @@ -190,8 +189,7 @@ void ExtractVertexGeometry::dataCheck() else { QString ss = QObject::tr("Data Container's Geometry type must be either an Image Geometry or RectLinearGrid Geometry. The Geomerty is of type %1").arg(fromGeometry->getGeometryTypeAsString()); - setErrorCondition(-2010); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2010, ss); return; } @@ -199,11 +197,11 @@ void ExtractVertexGeometry::dataCheck() for(int i = 0; i < selectedArraysSize; i++) { DataArrayPath dap = m_IncludedDataArrayPaths[i]; - dc = getDataContainerArray()->getPrereqDataContainer(this, dap.getDataContainerName()); + dc = getDataContainerArray()->getPrereqDataContainer(this, dap.getDataContainerName()); int err = 0; AttributeMatrix::Pointer sourceCellAttrMat = dc->getPrereqAttributeMatrix(this, dap.getAttributeMatrixName(), err); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -215,14 +213,13 @@ void ExtractVertexGeometry::dataCheck() .arg(dap.serialize("/")) .arg(sourceCellAttrMat->getNumberOfTuples()) .arg(elementCount) - .arg(m_VertexDataContainerName); - setErrorCondition(-2009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + .arg(m_VertexDataContainerName.getDataContainerName()); + setErrorCondition(-2009, ss); return; } IDataArray::Pointer iDataArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, dap); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -237,17 +234,17 @@ void ExtractVertexGeometry::dataCheck() newArrayPtr = sourceCellAttrMat->removeAttributeArray(dap.getDataArrayName()); } - DataArrayPath newDap(m_VertexDataContainerName); + DataArrayPath newDap = m_VertexDataContainerName; newDap.setAttributeMatrixName(sourceCellAttrMat->getName()); newDap.setDataArrayName(""); AttributeMatrix::Pointer vertexCellAttrMat = vertexDataContainer->getAttributeMatrix(newDap); if(vertexCellAttrMat == nullptr) { - vertexCellAttrMat = vertexDataContainer->createNonPrereqAttributeMatrix(this, sourceCellAttrMat->getName(), sourceCellAttrMat->getTupleDimensions(), AttributeMatrix::Type::Vertex); + vertexCellAttrMat = vertexDataContainer->createNonPrereqAttributeMatrix(this, sourceCellAttrMat->getName(), sourceCellAttrMat->getTupleDimensions(), AttributeMatrix::Type::Vertex, AttributeMatrixID); } - vertexCellAttrMat->addAttributeArray(newArrayPtr->getName(), newArrayPtr); + vertexCellAttrMat->insertOrAssign(newArrayPtr); } } @@ -272,7 +269,7 @@ void ExtractVertexGeometry::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h index 366c38ddc2..eb08a111b6 100644 --- a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h +++ b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h @@ -51,9 +51,9 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter PYB11_CREATE_BINDINGS(ExtractVertexGeometry SUPERCLASS AbstractFilter) PYB11_PROPERTY(int ArrayHandling READ getArrayHandling WRITE setArrayHandling) - PYB11_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + PYB11_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) PYB11_PROPERTY(QVector IncludedDataArrayPaths READ getIncludedDataArrayPaths WRITE setIncludedDataArrayPaths) - PYB11_PROPERTY(QString VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) + PYB11_PROPERTY(DataArrayPath VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) public: SIMPL_SHARED_POINTERS(ExtractVertexGeometry) @@ -63,14 +63,14 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter SIMPL_FILTER_PARAMETER(int, ArrayHandling) Q_PROPERTY(int ArrayHandling READ getArrayHandling WRITE setArrayHandling) - SIMPL_FILTER_PARAMETER(QString, SelectedDataContainerName) - Q_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedDataContainerName) + Q_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) SIMPL_FILTER_PARAMETER(QVector, IncludedDataArrayPaths) Q_PROPERTY(QVector IncludedDataArrayPaths READ getIncludedDataArrayPaths WRITE setIncludedDataArrayPaths) - SIMPL_FILTER_PARAMETER(QString, VertexDataContainerName) - Q_PROPERTY(QString VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, VertexDataContainerName) + Q_PROPERTY(DataArrayPath VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) ~ExtractVertexGeometry() override; diff --git a/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp b/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp index 87d763ca0d..6ff61f8346 100644 --- a/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp +++ b/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp @@ -63,7 +63,7 @@ FeatureCountDecision::~FeatureCountDecision() = default; // ----------------------------------------------------------------------------- void FeatureCountDecision::setupFilterParameters() { - FilterParameterVector parameters = getFilterParameters(); + FilterParameterVectorType parameters = getFilterParameters(); parameters.push_back(SeparatorFilterParameter::New("Cell Ensemble Data", FilterParameter::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = @@ -98,8 +98,8 @@ void FeatureCountDecision::initialize() // ----------------------------------------------------------------------------- void FeatureCountDecision::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getFeatureIdsArrayPath().getDataContainerName()); @@ -131,10 +131,10 @@ void FeatureCountDecision::preflight() // ----------------------------------------------------------------------------- void FeatureCountDecision::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp b/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp index dcdcd55607..736010e646 100644 --- a/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp +++ b/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp @@ -70,7 +70,7 @@ FeatureDataCSVWriter::~FeatureDataCSVWriter() = default; // ----------------------------------------------------------------------------- void FeatureDataCSVWriter::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File", FeatureDataFile, FilterParameter::Parameter, FeatureDataCSVWriter, "*.csv", "Comma Separated Data")); parameters.push_back(SIMPL_NEW_BOOL_FP("Write Neighbor Data", WriteNeighborListData, FilterParameter::Parameter, FeatureDataCSVWriter)); parameters.push_back(SIMPL_NEW_BOOL_FP("Write Number of Features Line", WriteNumFeaturesLine, FilterParameter::Parameter, FeatureDataCSVWriter)); @@ -119,8 +119,8 @@ void FeatureDataCSVWriter::initialize() // ----------------------------------------------------------------------------- void FeatureDataCSVWriter::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellFeatureAttributeMatrixPath(), -301); @@ -173,10 +173,10 @@ void FeatureDataCSVWriter::preflight() // ----------------------------------------------------------------------------- void FeatureDataCSVWriter::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -188,8 +188,7 @@ void FeatureDataCSVWriter::execute() if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); return; } @@ -197,8 +196,7 @@ void FeatureDataCSVWriter::execute() if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getFeatureDataFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-100, ss); return; } @@ -261,7 +259,7 @@ void FeatureDataCSVWriter::execute() if(percentIncrement > threshold) { QString ss = QObject::tr("Writing Feature Data || %1% Complete").arg(static_cast(percentIncrement)); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + notifyStatusMessage(ss); threshold = threshold + 5.0f; if(threshold < percentIncrement) { diff --git a/Source/SIMPLib/CoreFilters/FileReader.cpp b/Source/SIMPLib/CoreFilters/FileReader.cpp index 138a03143c..e32fe7a5a4 100644 --- a/Source/SIMPLib/CoreFilters/FileReader.cpp +++ b/Source/SIMPLib/CoreFilters/FileReader.cpp @@ -67,8 +67,7 @@ void FileReader::dataCheck() // ----------------------------------------------------------------------------- int32_t FileReader::readHeader() { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileReader should be subclassed and functionality implemented there", -1); + setErrorCondition(-1, "FileReader should be subclassed and functionality implemented there"); return -1; } @@ -77,8 +76,7 @@ int32_t FileReader::readHeader() // ----------------------------------------------------------------------------- int32_t FileReader::readFile() { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileReader should be subclassed and functionality implemented there", -1); + setErrorCondition(-1, "FileReader should be subclassed and functionality implemented there"); return -1; } diff --git a/Source/SIMPLib/CoreFilters/FileWriter.cpp b/Source/SIMPLib/CoreFilters/FileWriter.cpp index e321096c09..4400da61e0 100644 --- a/Source/SIMPLib/CoreFilters/FileWriter.cpp +++ b/Source/SIMPLib/CoreFilters/FileWriter.cpp @@ -58,8 +58,7 @@ FileWriter::~FileWriter() = default; // ----------------------------------------------------------------------------- int32_t FileWriter::writeHeader() { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileWriter should be subclassed and functionality implemented there", -1); + setErrorCondition(-1, "FileWriter should be subclassed and functionality implemented there"); return -1; } @@ -68,8 +67,7 @@ int32_t FileWriter::writeHeader() // ----------------------------------------------------------------------------- int32_t FileWriter::writeFile() { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileWriter should be subclassed and functionality implemented there", -1); + setErrorCondition(-1, "FileWriter should be subclassed and functionality implemented there"); return -1; } @@ -78,8 +76,8 @@ int32_t FileWriter::writeFile() // ----------------------------------------------------------------------------- void FileWriter::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path @@ -88,9 +86,8 @@ void FileWriter::execute() QDir dir; if(!dir.mkpath(parentPath)) { - setErrorCondition(-200); QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-200, ss); return; } @@ -98,16 +95,14 @@ void FileWriter::execute() if(err < 0) { QString ss = QObject::tr("Error writing the header portion of the file"); - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return; } err = writeFile(); if(err < 0) { QString ss = QObject::tr("Error writing the data to the file"); - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return; } } diff --git a/Source/SIMPLib/CoreFilters/FindDerivatives.cpp b/Source/SIMPLib/CoreFilters/FindDerivatives.cpp index eff98128c8..b56f9a5fcc 100644 --- a/Source/SIMPLib/CoreFilters/FindDerivatives.cpp +++ b/Source/SIMPLib/CoreFilters/FindDerivatives.cpp @@ -47,8 +47,65 @@ #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Math/SIMPLibRandom.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/GenericProgressMessage.h" +#include "SIMPLib/Messages/GenericStatusMessage.h" +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/GenericWarningMessage.h" #include "SIMPLib/SIMPLibVersion.h" +/** + * @brief This message handler is used by the FindDerivatives filter to re-emit incoming generic + * messages from geometry classes as filter messages. It also prepends text to status messages to show that it is + * computing derivatives. + */ +class FilterMessageHandler : public AbstractMessageHandler +{ + public: + explicit FilterMessageHandler(FindDerivatives* filter) : m_Filter(filter) {} + + /** + * @brief Re-emits incoming GenericProgressMessages as FilterProgressMessages. + */ + void processMessage(const GenericProgressMessage* msg) const override + { + emit m_Filter->notifyProgressMessage(msg->getProgressValue(), msg->getMessageText()); + } + + /** + * @brief Re-emits incoming GenericStatusMessages as FilterStatusMessages. Prepends text to the + * message text that explains that we are computing the derivatives + */ + void processMessage(const GenericStatusMessage* msg) const override + { + QString messageText = QObject::tr("Computing Derivatives || %1").arg(msg->getMessageText()); + emit m_Filter->notifyStatusMessage(messageText); + } + + /** + * @brief Re-emits incoming GenericErrorMessages as FilterErrorMessages. + */ + void processMessage(const GenericErrorMessage* msg) const override + { + emit m_Filter->setErrorCondition(msg->getCode(), msg->getMessageText()); + } + + /** + * @brief Re-emits incoming GenericWarningMessages as FilterWarningMessages. + */ + void processMessage(const GenericWarningMessage* msg) const override + { + emit m_Filter->setWarningCondition(msg->getCode(), msg->getMessageText()); + } + + private: + FindDerivatives* m_Filter = nullptr; +}; + +enum createdPathID : RenameDataPath::DataID_t { + DerivativesArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -69,7 +126,7 @@ FindDerivatives::~FindDerivatives() = default; // ----------------------------------------------------------------------------- void FindDerivatives::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); @@ -151,7 +208,7 @@ template void interpolateCellValues(IDataArray::Pointer inDa { EdgeGeom::Pointer edgeGeom = m->getGeometryAs(); SharedVertexList::Pointer verts = edgeGeom->getVertices(); - outDataPtr->resize(edgeGeom->getNumberOfVertices()); + outDataPtr->resizeTuples(edgeGeom->getNumberOfVertices()); GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } @@ -159,7 +216,7 @@ template void interpolateCellValues(IDataArray::Pointer inDa { TriangleGeom::Pointer triGeom = m->getGeometryAs(); SharedVertexList::Pointer verts = triGeom->getVertices(); - outDataPtr->resize(triGeom->getNumberOfVertices()); + outDataPtr->resizeTuples(triGeom->getNumberOfVertices()); GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } @@ -167,7 +224,7 @@ template void interpolateCellValues(IDataArray::Pointer inDa { QuadGeom::Pointer quadGeom = m->getGeometryAs(); SharedVertexList::Pointer verts = quadGeom->getVertices(); - outDataPtr->resize(quadGeom->getNumberOfVertices()); + outDataPtr->resizeTuples(quadGeom->getNumberOfVertices()); GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } @@ -175,7 +232,7 @@ template void interpolateCellValues(IDataArray::Pointer inDa { TetrahedralGeom::Pointer tets = m->getGeometryAs(); SharedVertexList::Pointer verts = tets->getVertices(); - outDataPtr->resize(tets->getNumberOfVertices()); + outDataPtr->resizeTuples(tets->getNumberOfVertices()); GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } @@ -183,7 +240,7 @@ template void interpolateCellValues(IDataArray::Pointer inDa { HexahedralGeom::Pointer hexas = m->getGeometryAs(); SharedVertexList::Pointer verts = hexas->getVertices(); - outDataPtr->resize(hexas->getNumberOfVertices()); + outDataPtr->resizeTuples(hexas->getNumberOfVertices()); GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } @@ -207,16 +264,16 @@ void FindDerivatives::initialize() // ----------------------------------------------------------------------------- void FindDerivatives::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, m_SelectedArrayPath.getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m.get()) + if(getErrorCode() < 0 || nullptr == m.get()) { return; } IGeometry::Pointer geom = m->getPrereqGeometry(this); - if(getErrorCondition() < 0 || nullptr == geom.get()) + if(getErrorCode() < 0 || nullptr == geom.get()) { return; } @@ -224,7 +281,7 @@ void FindDerivatives::dataCheck() AttributeMatrix::Pointer inAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedArrayPath, -301); AttributeMatrix::Pointer destAttrMat = m->getPrereqAttributeMatrix(this, getDerivativesArrayPath().getAttributeMatrixName(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -240,15 +297,13 @@ void FindDerivatives::dataCheck() if(inAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected DataArray does not belong to a CellAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } if(destAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected destination AttributeMatrix is not a CellAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else if(geomType == IGeometry::Type::Vertex) // validate AttributeMatrices for VertexGeom @@ -256,14 +311,12 @@ void FindDerivatives::dataCheck() if(inAttrMatType != AttributeMatrix::Type::Vertex) { ss = QObject::tr("The Geometry type is %1, but the selected DataArray does not belong to a VertexAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } if(destAttrMatType != AttributeMatrix::Type::Vertex) { ss = QObject::tr("The Geometry type is %1, but the selected destination AttributeMatrix is not a VertexAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else // validate AttributeMatrices for all other geometries @@ -277,16 +330,14 @@ void FindDerivatives::dataCheck() inAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected DataArray does not belong to a Cell, Face, Edge or Vertex AttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } if(geomName == SIMPL::Geometry::QuadGeometry || geomName == SIMPL::Geometry::TriangleGeometry) { if(destAttrMatType != AttributeMatrix::Type::Face) { ss = QObject::tr("The Geometry type is %1, but the selected destination Attribute Matrix is not a Face Attribute Matrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else if(geomName == SIMPL::Geometry::TetrahedralGeometry || geomName == SIMPL::Geometry::HexahedralGeometry) @@ -294,8 +345,7 @@ void FindDerivatives::dataCheck() if(destAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected destination Attribute Matrix is not an Cell Attribute Matrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else if(geomName == SIMPL::Geometry::EdgeGeometry) @@ -303,14 +353,13 @@ void FindDerivatives::dataCheck() if(destAttrMatType != AttributeMatrix::Type::Edge) { ss = QObject::tr("The Geometry type is %1, but the selected destination Attribute Matrix is not an Edge Attribute Matrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } } m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -320,7 +369,7 @@ void FindDerivatives::dataCheck() QVector dims(1, cDims); m_DerivativesArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>( - this, getDerivativesArrayPath(), 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ + this, getDerivativesArrayPath(), 0, dims, "", DerivativesArrayID); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if(nullptr != m_DerivativesArrayPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ { m_DerivativesArray = m_DerivativesArrayPtr.lock()->getPointer(0); @@ -345,10 +394,10 @@ void FindDerivatives::preflight() // ----------------------------------------------------------------------------- void FindDerivatives::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -356,23 +405,27 @@ void FindDerivatives::execute() DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_SelectedArrayPath.getDataContainerName()); IGeometry::Pointer geom = m->getGeometry(); - geom->setMessagePrefix(getMessagePrefix()); - geom->setMessageTitle("Computing Derivatives"); - if(m_Interpolate) { DoubleArrayType::Pointer interpolatedValues = DoubleArrayType::CreateArray(m_InArrayPtr.lock()->getNumberOfTuples(), m_InArrayPtr.lock()->getComponentDimensions(), "FIND_DERIVATIVES_INTERNAL_USE_ONLY"); EXECUTE_FUNCTION_TEMPLATE(this, interpolateCellValues, m_InArrayPtr.lock(), m_InArrayPtr.lock(), interpolatedValues, m) + geom->findDerivatives(interpolatedValues, m_DerivativesArrayPtr.lock(), this); } else { EXECUTE_FUNCTION_TEMPLATE(this, findDerivs, m_InArrayPtr.lock(), m_InArrayPtr.lock(), m_DerivativesArrayPtr.lock(), m, this); } +} - geom->setMessagePrefix(""); - geom->setMessageTitle(""); +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FindDerivatives::processDerivativesMessage(const AbstractMessage::Pointer& msg) +{ + FilterMessageHandler msgHandler(this); + msg->visit(&msgHandler); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/FindDerivatives.h b/Source/SIMPLib/CoreFilters/FindDerivatives.h index 5122c69ce3..b2141b2552 100644 --- a/Source/SIMPLib/CoreFilters/FindDerivatives.h +++ b/Source/SIMPLib/CoreFilters/FindDerivatives.h @@ -169,6 +169,13 @@ class SIMPLib_EXPORT FindDerivatives : public AbstractFilter */ void initialize(); +protected slots: + /** + * @brief processDerivativesMessage + * @param msg + */ + void processDerivativesMessage(const AbstractMessage::Pointer& msg); + private: DEFINE_IDATAARRAY_WEAKPTR(InArray) DEFINE_DATAARRAY_VARIABLE(double, DerivativesArray) diff --git a/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp b/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp index bc2b467a4e..0736c5e6a2 100644 --- a/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp +++ b/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp @@ -18,6 +18,10 @@ #include "SIMPLib/Utilities/ColorTable.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + ColorArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -228,8 +232,8 @@ GenerateColorTable::~GenerateColorTable() = default; // ----------------------------------------------------------------------------- void GenerateColorTable::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -238,7 +242,7 @@ void GenerateColorTable::initialize() // ----------------------------------------------------------------------------- void GenerateColorTable::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { GenerateColorTableFilterParameter::Pointer parameter = GenerateColorTableFilterParameter::New(); @@ -264,15 +268,15 @@ void GenerateColorTable::setupFilterParameters() // ----------------------------------------------------------------------------- void GenerateColorTable::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedDataArrayPath()); DataArrayPath tmpPath = getSelectedDataArrayPath(); tmpPath.setDataArrayName(getRgbArrayName()); - getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(this, tmpPath, 0, QVector(1, 3)); + getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(this, tmpPath, 0, QVector(1, 3), "", ColorArrayID); } // ----------------------------------------------------------------------------- @@ -296,7 +300,10 @@ void GenerateColorTable::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) { return; } + if(getErrorCode() < 0) + { + return; + } if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) { @@ -356,8 +363,7 @@ void GenerateColorTable::execute() else { QString ss = QObject::tr("The selected array '%1' does not have a compatible type.").arg(getSelectedDataArrayPath().getDataArrayName()); - setErrorCondition(-10000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-10000, ss); return; } diff --git a/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp b/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp index 3ed72e14dc..921311d506 100644 --- a/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp +++ b/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp @@ -55,6 +55,9 @@ #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h" +enum createdPathID : RenameDataPath::DataID_t { + AsciiArrayID = 1 +}; #define RBR_FILE_NOT_OPEN -1000 #define RBR_FILE_TOO_SMALL -1010 @@ -190,7 +193,7 @@ template int32_t readAsciFile(typename DataArray::Po { return err; } - if(err == RBR_READ_ERROR || err == RBR_READ_ERROR) + if(err == RBR_READ_ERROR) { return err; } @@ -208,7 +211,7 @@ template int32_t readAsciFile(typename DataArray::Po { return err; } - if(err == RBR_READ_ERROR || err == RBR_READ_ERROR) + if(err == RBR_READ_ERROR) { return err; } @@ -301,9 +304,8 @@ void ImportAsciDataArray::readHeaderPortion() std::ifstream in(filename.toLatin1().constData(), std::ios_base::in | std::ios_base::binary); if(!in.is_open()) { - setErrorCondition(RBR_FILE_NOT_OPEN); QString errorMessage = QString("Error opening input file '%1'").arg(filename); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); + setErrorCondition(RBR_FILE_NOT_OPEN, errorMessage); return; } @@ -320,8 +322,7 @@ void ImportAsciDataArray::readHeaderPortion() if(err < 0) { QString errorMessage = QString("Error reading the input file at line %1 of the file").arg(i); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); - setErrorCondition(RBR_READ_ERROR); + setErrorCondition(RBR_READ_ERROR, errorMessage); return; } } @@ -329,8 +330,7 @@ void ImportAsciDataArray::readHeaderPortion() err = Detail::readLine(in, buffer, kBufferSize); if(err < 0) { - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), "Error reading the first line of data from the input file", getErrorCondition()); + setErrorCondition(err, "Error reading the first line of data from the input file"); } setFirstLine(buf); @@ -349,7 +349,7 @@ void ImportAsciDataArray::readHeaderPortion() // ----------------------------------------------------------------------------- void ImportAsciDataArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Parameter, ImportAsciDataArray, "*.*")); parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, ImportAsciDataArray)); @@ -401,32 +401,29 @@ void ImportAsciDataArray::initialize() // ----------------------------------------------------------------------------- void ImportAsciDataArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QFileInfo fi(getInputFile()); if(getInputFile().isEmpty()) { QString ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } else if(!fi.exists()) { QString ss = QObject::tr("The input file does not exist"); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-388, ss); } if(m_NumberOfComponents < 1) { QString ss = QObject::tr("The number of components must be positive"); - setErrorCondition(-391); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-391, ss); } AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCreatedAttributeArrayPath(), -30003); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -441,50 +438,49 @@ void ImportAsciDataArray::dataCheck() QVector cDims(1, m_NumberOfComponents); if(m_ScalarType == SIMPL::NumericTypes::Type::Int8) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt8) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int16) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt16) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int32) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt32) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int64) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt64) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Float) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Double) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Bool) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), false, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), false, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } - - + readHeaderPortion(); @@ -508,10 +504,11 @@ void ImportAsciDataArray::preflight() // ----------------------------------------------------------------------------- void ImportAsciDataArray::execute() { - int32_t err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); + dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -521,6 +518,7 @@ void ImportAsciDataArray::execute() char delimiter = converSelectedDelimiter(); QVector cDims(1, m_NumberOfComponents); + int32_t err = 0; if(m_ScalarType == SIMPL::NumericTypes::Type::Int8) { Int8ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); @@ -623,28 +621,23 @@ void ImportAsciDataArray::execute() if(err == RBR_FILE_NOT_OPEN) { - setErrorCondition(RBR_FILE_NOT_OPEN); - notifyErrorMessage(getHumanLabel(), "Unable to open the specified file", getErrorCondition()); + setErrorCondition(RBR_FILE_NOT_OPEN, "Unable to open the specified file"); } else if(err == RBR_FILE_TOO_SMALL) { - setErrorCondition(RBR_FILE_TOO_SMALL); - notifyErrorMessage(getHumanLabel(), "The file size is smaller than the allocated size", getErrorCondition()); + setErrorCondition(RBR_FILE_TOO_SMALL, "The file size is smaller than the allocated size"); } else if(err == RBR_FILE_TOO_BIG) { - setWarningCondition(RBR_FILE_TOO_BIG); - notifyWarningMessage(getHumanLabel(), "The file size is larger than the allocated size", getWarningCondition()); + setWarningCondition(RBR_FILE_TOO_BIG, "The file size is larger than the allocated size"); } else if(err == RBR_READ_ERROR) { - setErrorCondition(RBR_READ_ERROR); - notifyErrorMessage(getHumanLabel(), "General read error while importing ASCI file.", getErrorCondition()); + setErrorCondition(RBR_READ_ERROR, "General read error while importing ASCI file."); } else if(err == RBR_READ_EOF) { - setErrorCondition(RBR_READ_EOF); - notifyErrorMessage(getHumanLabel(), "ImportAsciDataArray read past the end of the specified file", getErrorCondition()); + setErrorCondition(RBR_READ_EOF, "ImportAsciDataArray read past the end of the specified file"); } } diff --git a/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp b/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp index fb747dd363..d7e818fecb 100644 --- a/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp +++ b/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp @@ -85,7 +85,7 @@ ImportHDF5Dataset::~ImportHDF5Dataset() = default; // ----------------------------------------------------------------------------- void ImportHDF5Dataset::initialize() { - setErrorCondition(0); + clearErrorCode(); setCancel(false); } @@ -94,7 +94,7 @@ void ImportHDF5Dataset::initialize() // ----------------------------------------------------------------------------- void ImportHDF5Dataset::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; ImportHDF5DatasetFilterParameter::Pointer parameter = ImportHDF5DatasetFilterParameter::New(QString("Select HDF5 File"), // Human Label QString("ImportHDF5File"), // Property Name @@ -117,14 +117,13 @@ void ImportHDF5Dataset::setupFilterParameters() // ----------------------------------------------------------------------------- void ImportHDF5Dataset::dataCheck() { - setErrorCondition(0); + clearErrorCode(); m_DatasetPathsWithErrors.clear(); if(m_HDF5FilePath.isEmpty()) { QString ss = "The HDF5 file path is empty. Please select an HDF5 file."; - setErrorCondition(-20001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20001, ss); return; } @@ -133,30 +132,27 @@ void ImportHDF5Dataset::dataCheck() if(ext != "h5" && ext != "hdf5" && ext != "dream3d") { QString ss = tr("The selected file '%1' is not an HDF5 file.").arg(hdf5FileInfo.fileName()); - setErrorCondition(-20002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20002, ss); return; } if(!hdf5FileInfo.exists()) { QString ss = tr("The selected file '%1' does not exist.").arg(hdf5FileInfo.fileName()); - setErrorCondition(-20003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20003, ss); return; } if(m_DatasetImportInfoList.isEmpty()) { QString ss = tr("No dataset has been checked. Please check a dataset."); - setErrorCondition(-20004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20004, ss); return; } int err = 0; AttributeMatrix::Pointer am = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -204,8 +200,7 @@ void ImportHDF5Dataset::dataCheck() if(err < 0) { QString ss = tr("Error reading type info from dataset with path '%1'").arg(datasetPath); - setErrorCondition(-20005); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20005, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } @@ -215,8 +210,7 @@ void ImportHDF5Dataset::dataCheck() { QString ss = tr("The component dimensions are empty for dataset with path '%1'. Please enter the component dimensions, using comma-separated values (ex: 4x2 would be '4, 2').").arg(datasetPath); - setErrorCondition(-20006); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20006, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } @@ -225,8 +219,7 @@ void ImportHDF5Dataset::dataCheck() if(cDims.isEmpty()) { QString ss = tr("Component Dimensions are not in the right format for dataset with path '%1'. Use comma-separated values (ex: 4x2 would be '4, 2').").arg(datasetPath); - setErrorCondition(-20007); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20007, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } @@ -317,36 +310,33 @@ void ImportHDF5Dataset::dataCheck() .arg(locale.toString(numOfAMTuples * totalComponents)) .arg(locale.toString(hdf5TotalElements)); - setErrorCondition(-20008); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20008, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } if(am->doesAttributeArrayExist(objectName)) { - setErrorCondition(-20010); ss.clear(); DataArrayPath dap = getSelectedAttributeMatrix(); dap.setDataArrayName(objectName); stream << tr("The selected dataset '") << dap.serialize("/") << tr("' already exists."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20010, ss); } else { IDataArray::Pointer dPtr = readIDataArray(parentId, objectName, am->getNumberOfTuples(), cDims, getInPreflight()); if(nullptr != dPtr) { - am->addAttributeArray(dPtr->getName(), dPtr); + am->insertOrAssign(dPtr); } else { - setErrorCondition(-20009); ss.clear(); stream << tr("The selected datatset is not a supported type for importing. Please select a different data set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20009, ss); } } } // End For Loop over dataset imoprt info list @@ -375,7 +365,7 @@ void ImportHDF5Dataset::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/InitializeData.cpp b/Source/SIMPLib/CoreFilters/InitializeData.cpp index 98afd4c3c9..9bef711254 100644 --- a/Source/SIMPLib/CoreFilters/InitializeData.cpp +++ b/Source/SIMPLib/CoreFilters/InitializeData.cpp @@ -89,7 +89,7 @@ InitializeData::~InitializeData() = default; // ----------------------------------------------------------------------------- void InitializeData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); { @@ -162,14 +162,13 @@ void InitializeData::initialize() // ----------------------------------------------------------------------------- void InitializeData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_CellAttributeMatrixPaths.empty()) { QString ss = "At least one data array must be selected."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } @@ -185,56 +184,47 @@ void InitializeData::dataCheck() if(getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); - setErrorCondition(-5551); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5551, ss); } if(getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); - setErrorCondition(-5552); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5552, ss); } if(getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); - setErrorCondition(-5553); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5553, ss); } if(getXMin() < 0) { QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin()); - setErrorCondition(-5554); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5554, ss); } if(getYMin() < 0) { QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin()); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); } if(getZMin() < 0) { QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin()); - setErrorCondition(-5556); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5556, ss); } if(getXMax() > (static_cast(image->getXPoints()) - 1)) { QString ss = QObject::tr("The X Max you entered of %1 is greater than your Max X Point of %2").arg(getXMax()).arg(static_cast(image->getXPoints()) - 1); - setErrorCondition(-5557); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5557, ss); } if(getYMax() > (static_cast(image->getYPoints()) - 1)) { QString ss = QObject::tr("The Y Max you entered of %1 is greater than your Max Y Point of %2").arg(getYMax()).arg(static_cast(image->getYPoints()) - 1); - setErrorCondition(-5558); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5558, ss); } if(getZMax() > (static_cast(image->getZPoints()) - 1)) { QString ss = QObject::tr("The Z Max you entered of %1) greater than your Max Z Point of %2").arg(getZMax()).arg(static_cast(image->getZPoints()) - 1); - setErrorCondition(-5559); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5559, ss); } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(attributeMatrixPath.getDataContainerName()); @@ -291,7 +281,7 @@ void InitializeData::dataCheck() checkInitialization(p); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -310,9 +300,8 @@ template void InitializeData::checkInitialization(IDataArray::Point double input = m_InitValue; if(input < static_cast(std::numeric_limits().lowest()) || input > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4000); QString ss = QObject::tr("%1: The initialization value could not be converted. The valid range is %2 to %3").arg(arrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4000, ss); return; } } @@ -323,22 +312,19 @@ template void InitializeData::checkInitialization(IDataArray::Point if(min > max) { QString ss = arrayName + ": Invalid initialization range. Minimum value is larger than maximum value."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } if(min < static_cast(std::numeric_limits().lowest()) || max > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4001); QString ss = QObject::tr("%1: The initialization range can only be from %2 to %3").arg(arrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4001, ss); return; } if(min == max) { - setErrorCondition(-4002); QString ss = arrayName + ": The initialization range must have differing values"; - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4002, ss); return; } } @@ -362,10 +348,10 @@ void InitializeData::preflight() // ----------------------------------------------------------------------------- void InitializeData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp b/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp index ebe7fb4486..efef56a495 100644 --- a/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp +++ b/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp @@ -43,6 +43,11 @@ #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" +enum createdPathID : RenameDataPath::DataID_t { + AttributeMatrixID = 1, + DataArrayID +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -63,7 +68,7 @@ LinkFeatureMapToElementArray::~LinkFeatureMapToElementArray() = default; // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SeparatorFilterParameter::New("Element Data", FilterParameter::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int32, 1, AttributeMatrix::Category::Element); @@ -93,8 +98,8 @@ void LinkFeatureMapToElementArray::readFilterParameters(AbstractFilterParameters // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::updateFeatureInstancePointers() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(nullptr != m_ActivePtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ { @@ -114,18 +119,18 @@ void LinkFeatureMapToElementArray::initialize() // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getSelectedCellArrayPath().getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m.get()) + if(getErrorCode() < 0 || nullptr == m.get()) { return; } QVector tDims(1, 0); - m->createNonPrereqAttributeMatrix(this, getCellFeatureAttributeMatrixName(), tDims, AttributeMatrix::Type::CellFeature); + m->createNonPrereqAttributeMatrix(this, getCellFeatureAttributeMatrixName(), tDims, AttributeMatrix::Type::CellFeature, AttributeMatrixID); QVector cDims(1, 1); m_SelectedCellDataPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSelectedCellArrayPath(), @@ -135,14 +140,13 @@ void LinkFeatureMapToElementArray::dataCheck() m_SelectedCellData = m_SelectedCellDataPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } tempPath.update(getSelectedCellArrayPath().getDataContainerName(), getCellFeatureAttributeMatrixName(), getActiveArrayName()); - m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, false, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ + m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, false, cDims, "", DataArrayID); if(nullptr != m_ActivePtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ { m_Active = m_ActivePtr.lock()->getPointer(0); @@ -167,10 +171,10 @@ void LinkFeatureMapToElementArray::preflight() // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp b/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp index 0425888587..a43db2fda8 100644 --- a/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp +++ b/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp @@ -61,7 +61,7 @@ MaskCountDecision::~MaskCountDecision() = default; // ----------------------------------------------------------------------------- void MaskCountDecision::setupFilterParameters() { - FilterParameterVector parameters = getFilterParameters(); + FilterParameterVectorType parameters = getFilterParameters(); DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::TypeNames::Bool, 1, AttributeMatrix::Type::Any, IGeometry::Type::Any); parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Mask", MaskArrayPath, FilterParameter::RequiredArray, MaskCountDecision, req)); @@ -93,8 +93,8 @@ void MaskCountDecision::initialize() // ----------------------------------------------------------------------------- void MaskCountDecision::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QVector cDims(1, 1); @@ -124,10 +124,10 @@ void MaskCountDecision::preflight() // ----------------------------------------------------------------------------- void MaskCountDecision::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/Common/PipelineMessage.cpp b/Source/SIMPLib/CoreFilters/MassCreateData.cpp similarity index 52% rename from Source/SIMPLib/Common/PipelineMessage.cpp rename to Source/SIMPLib/CoreFilters/MassCreateData.cpp index 589326c086..cc0291fe0c 100644 --- a/Source/SIMPLib/Common/PipelineMessage.cpp +++ b/Source/SIMPLib/CoreFilters/MassCreateData.cpp @@ -32,197 +32,177 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "PipelineMessage.h" -#include -#include +#include "MassCreateData.h" -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage() = default; +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" +#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t { + DataContainerBaseID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const PipelineMessage& rhs) +MassCreateData::MassCreateData() + : m_DataContainerName("DataContainer") { - m_FilterClassName = rhs.m_FilterClassName; - m_FilterHumanLabel = rhs.m_FilterHumanLabel; - m_Prefix = rhs.m_Prefix; - m_Text = rhs.m_Text; - m_Code = rhs.m_Code; - m_Type = rhs.m_Type; - m_ProgressValue = rhs.m_ProgressValue; - m_PipelineIndex = rhs.m_PipelineIndex; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& className, const char* msg, int code, MessageType msgType, int progress) -: m_FilterClassName(className) -, m_Text(msg) -, m_Code(code) -, m_Type(msgType) -, m_ProgressValue(progress) -{ -} +MassCreateData::~MassCreateData() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& className, const QString& msg, int code, MessageType msgType, int progress) -: m_FilterClassName(className) -, m_FilterHumanLabel("") -, m_Text(msg) -, m_Code(code) -, m_Type(msgType) -, m_ProgressValue(progress) +void MassCreateData::setupFilterParameters() { + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Data Container Name", DataContainerName, FilterParameter::CreatedArray, MassCreateData)); + setFilterParameters(parameters); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& className, const QString& humanLabel, const QString& msg, int code, MessageType msgType, int progress) -: m_FilterClassName(className) -, m_FilterHumanLabel(humanLabel) -, m_Text(msg) -, m_Code(code) -, m_Type(msgType) -, m_ProgressValue(progress) +void MassCreateData::readFilterParameters(AbstractFilterParametersReader* reader, int index) { + reader->openFilterGroup(this, index); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); + reader->closeFilterGroup(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& humanLabel, int pipelineIndex, const QString& msg, MessageType msgType) -: m_FilterHumanLabel(humanLabel) -, m_Text(msg) -, m_PipelineIndex(pipelineIndex) -, m_Type(msgType) +void MassCreateData::initialize() { } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateErrorMessage(const QString className, const QString humanLabel, const QString msg, int code) +void MassCreateData::dataCheck() { - PipelineMessage em(className, humanLabel, msg, code, MessageType::Error, -1); - return em; + clearErrorCode(); + clearWarningCode(); + + const int iterations = 4000; + for(int i = 0; i < iterations; i++) + { + DataContainerShPtr dc = getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName().getDataContainerName() + QString::number(i), DataContainerBaseID + i); + } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateStatusMessage(const QString className, const QString humanLabel, const QString msg) +void MassCreateData::preflight() { - PipelineMessage em(className, humanLabel, msg, 0, MessageType::StatusMessage, -1); - return em; + // These are the REQUIRED lines of CODE to make sure the filter behaves correctly + setInPreflight(true); // Set the fact that we are preflighting. + emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update + emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter + dataCheck(); // Run our DataCheck to make sure everthing is setup correctly + emit preflightExecuted(); // We are done preflighting this filter + setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateWarningMessage(const QString className, const QString humanLabel, const QString msg, int code) +void MassCreateData::execute() { - PipelineMessage em(className, humanLabel, msg, code, MessageType::Warning, -1); - return em; + clearErrorCode(); + clearWarningCode(); + + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + if(getCancel()) + { + return; + } + + notifyStatusMessage("Complete"); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateStandardOutputMessage(const QString humanLabel, int pipelineIndex, const QString msg) +AbstractFilter::Pointer MassCreateData::newFilterInstance(bool copyFilterParameters) const { - PipelineMessage em(humanLabel, pipelineIndex, msg, MessageType::StandardOutputMessage); - return em; + MassCreateData::Pointer filter = MassCreateData::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PipelineMessage::~PipelineMessage() = default; - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool PipelineMessage::operator==(const PipelineMessage& rhs) +const QString MassCreateData::getCompiledLibraryName() const { - return (m_FilterClassName == rhs.m_FilterClassName && m_Prefix == rhs.m_Prefix && m_FilterHumanLabel == rhs.m_FilterHumanLabel && m_Text == rhs.m_Text && m_Code == rhs.m_Code && - m_Type == rhs.m_Type && m_ProgressValue == rhs.m_ProgressValue && m_PipelineIndex == rhs.m_PipelineIndex); + return Core::CoreBaseName; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PipelineMessage::operator=(const PipelineMessage& rhs) +const QString MassCreateData::getBrandingString() const { - m_FilterClassName = rhs.m_FilterClassName; - m_Prefix = rhs.m_Prefix; - m_FilterHumanLabel = rhs.m_FilterHumanLabel; - m_Text = rhs.m_Text; - m_Code = rhs.m_Code; - m_Type = rhs.m_Type; - m_ProgressValue = rhs.m_ProgressValue; - m_PipelineIndex = rhs.m_PipelineIndex; + return "SIMPLib Core Filter"; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString PipelineMessage::generateErrorString() const +const QString MassCreateData::getFilterVersion() const { - QString ss = QObject::tr("Error (%1): %2: %3").arg(m_Code).arg(m_Prefix).arg(m_Text); - return ss; + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString PipelineMessage::generateWarningString() const +const QString MassCreateData::getGroupName() const { - QString ss = QObject::tr("Warning (%1): %2: %3").arg(m_Code).arg(m_Prefix).arg(m_Text); - return ss; + return SIMPL::FilterGroups::CoreFilters; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString PipelineMessage::generateStatusString() const +const QString MassCreateData::getHumanLabel() const { - if(m_Prefix.isEmpty()) - { - QString ss = QObject::tr("%2").arg(m_Text); - return ss; - } - - QString ss = QObject::tr("%1: %2").arg(m_Prefix).arg(m_Text); - return ss; + return "Mass Create Data Containers"; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString PipelineMessage::generateProgressString() const +const QUuid MassCreateData::getUuid() { - if(m_Prefix.isEmpty()) - { - QString ss = QObject::tr("%1 %2%%").arg(m_Text).arg(m_ProgressValue); - return ss; - } - - QString ss = QObject::tr("%1: %2 %3%%").arg(m_Prefix).arg(m_Text).arg(m_ProgressValue); - return ss; + return QUuid("{816fbe6b-7c38-581b-b149-3f839fb65b95}"); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString PipelineMessage::generateStandardOutputString() const +const QString MassCreateData::getSubGroupName() const { - return m_Text; + return SIMPL::FilterSubGroups::GenerationFilters; } diff --git a/Source/SIMPLib/CoreFilters/MassCreateData.h b/Source/SIMPLib/CoreFilters/MassCreateData.h new file mode 100644 index 0000000000..78ce86849a --- /dev/null +++ b/Source/SIMPLib/CoreFilters/MassCreateData.h @@ -0,0 +1,168 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + + +#pragma once + +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/SIMPLib.h" + +/** + * @brief The MassCreateData class. See [Filter documentation](@ref MassCreateData) for details. + */ +class SIMPLib_EXPORT MassCreateData : public AbstractFilter +{ + Q_OBJECT + PYB11_CREATE_BINDINGS(MassCreateData SUPERCLASS AbstractFilter) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + public: + SIMPL_SHARED_POINTERS(MassCreateData) + SIMPL_FILTER_NEW_MACRO(MassCreateData) + SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MassCreateData, AbstractFilter) + + ~MassCreateData() override; + + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + const QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + const QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + const QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + const QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + const QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + const QUuid getUuid() override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + const QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief preflight Reimplemented from @see AbstractFilter class + */ + void preflight() override; + + signals: + /** + * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters + * be pushed from a user-facing control (such as a widget) + * @param filter Filter instance pointer + */ + void updateFilterParameters(AbstractFilter* filter); + + /** + * @brief parametersChanged Emitted when any Filter parameter is changed internally + */ + void parametersChanged(); + + /** + * @brief preflightAboutToExecute Emitted just before calling dataCheck() + */ + void preflightAboutToExecute(); + + /** + * @brief preflightExecuted Emitted just after calling dataCheck() + */ + void preflightExecuted(); + + protected: + MassCreateData(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck(); + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + public: + MassCreateData(const MassCreateData&) = delete; // Copy Constructor Not Implemented + MassCreateData(MassCreateData&&) = delete; // Move Constructor Not Implemented + MassCreateData& operator=(const MassCreateData&) = delete; // Copy Assignment Not Implemented + MassCreateData& operator=(MassCreateData&&) = delete; // Move Assignment Not Implemented +}; + diff --git a/Source/SIMPLib/CoreFilters/MoveData.cpp b/Source/SIMPLib/CoreFilters/MoveData.cpp index cb7f0fb0ab..b4bc776ec4 100644 --- a/Source/SIMPLib/CoreFilters/MoveData.cpp +++ b/Source/SIMPLib/CoreFilters/MoveData.cpp @@ -55,7 +55,6 @@ const int32_t k_MoveDataArray = 1; // ----------------------------------------------------------------------------- MoveData::MoveData() : m_WhatToMove(k_MoveAttributeMatrix) -, m_DataContainerDestination("") { } @@ -69,7 +68,7 @@ MoveData::~MoveData() = default; // ----------------------------------------------------------------------------- void MoveData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; QStringList linkedProps; linkedProps << "DataContainerDestination" @@ -121,7 +120,7 @@ void MoveData::readFilterParameters(AbstractFilterParametersReader* reader, int { reader->openFilterGroup(this, index); setWhatToMove(reader->readValue("WhatToMove", getWhatToMove())); - setDataContainerDestination(reader->readString("DataContainerDestination", getDataContainerDestination())); + setDataContainerDestination(reader->readDataArrayPath("DataContainerDestination", getDataContainerDestination())); setAttributeMatrixSource(reader->readDataArrayPath("AttributeMatrixSource", getAttributeMatrixSource())); setAttributeMatrixDestination(reader->readDataArrayPath("AttributeMatrixDestination", getAttributeMatrixDestination())); setDataArraySource(reader->readDataArrayPath("DataArraySource", getDataArraySource())); @@ -140,8 +139,8 @@ void MoveData::initialize() // ----------------------------------------------------------------------------- void MoveData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataArrayPath amSrcPath = getAttributeMatrixSource(); DataArrayPath amDestPath = getAttributeMatrixDestination(); DataArrayPath daSrcPath = getDataArraySource(); @@ -152,21 +151,21 @@ void MoveData::dataCheck() DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer(this, amSrcPath.getDataContainerName()); AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amSrcPath, -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(amSrcDataContainer->getName() == amDestDataContainer->getName()) { - setWarningCondition(-11018); QString ss = QObject::tr("The source and destination Data Container are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11018, ss); return; } - amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix); - amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + amDestDataContainer->addOrReplaceAttributeMatrix(amSrcAttributeMatrix); + //amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + addPathRename(amSrcPath, amSrcAttributeMatrix->getDataArrayPath()); } else if(getWhatToMove() == k_MoveDataArray) { @@ -174,36 +173,34 @@ void MoveData::dataCheck() AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amDestPath, -301); IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath(this, daSrcPath); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(daDestAttributeMatrix->getNumberOfTuples() != daSrcDataArray->getNumberOfTuples()) { - setErrorCondition(-11019); QString ss = QObject::tr("The number of tuples of source Attribute Array (%1) and destination Attribute Matrix (%2) do not match") .arg(daSrcDataArray->getNumberOfTuples()) .arg(daDestAttributeMatrix->getNumberOfTuples()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11019, ss); return; } if(amSrcPath == amDestPath) { - setWarningCondition(-11020); QString ss = QObject::tr("The source and destination Attribute Matrix are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11020, ss); return; } - daDestAttributeMatrix->addAttributeArray(daSrcPath.getDataArrayName(), daSrcDataArray); - daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName()); + daDestAttributeMatrix->insertOrAssign(daSrcDataArray); + //daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName()); + addPathRename(daSrcPath, daSrcDataArray->getDataArrayPath()); } else { - setErrorCondition(-11021); QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11021, ss); return; } } @@ -226,11 +223,11 @@ void MoveData::preflight() // ----------------------------------------------------------------------------- void MoveData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Simply running the preflight will do what we need it to. dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/MoveData.h b/Source/SIMPLib/CoreFilters/MoveData.h index ec11182197..ace6546c88 100755 --- a/Source/SIMPLib/CoreFilters/MoveData.h +++ b/Source/SIMPLib/CoreFilters/MoveData.h @@ -48,7 +48,7 @@ class SIMPLib_EXPORT MoveData : public AbstractFilter Q_OBJECT PYB11_CREATE_BINDINGS(MoveData SUPERCLASS AbstractFilter) PYB11_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - PYB11_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + PYB11_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) PYB11_PROPERTY(DataArrayPath AttributeMatrixSource READ getAttributeMatrixSource WRITE setAttributeMatrixSource) PYB11_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) PYB11_PROPERTY(DataArrayPath DataArraySource READ getDataArraySource WRITE setDataArraySource) @@ -63,8 +63,8 @@ class SIMPLib_EXPORT MoveData : public AbstractFilter SIMPL_FILTER_PARAMETER(int, WhatToMove) Q_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - SIMPL_FILTER_PARAMETER(QString, DataContainerDestination) - Q_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerDestination) + Q_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixSource) Q_PROPERTY(DataArrayPath AttributeMatrixSource READ getAttributeMatrixSource WRITE setAttributeMatrixSource) diff --git a/Source/SIMPLib/CoreFilters/MoveMultiData.cpp b/Source/SIMPLib/CoreFilters/MoveMultiData.cpp index 120eb31ac9..3969846edb 100644 --- a/Source/SIMPLib/CoreFilters/MoveMultiData.cpp +++ b/Source/SIMPLib/CoreFilters/MoveMultiData.cpp @@ -71,7 +71,7 @@ MoveMultiData::~MoveMultiData() = default; // ----------------------------------------------------------------------------- void MoveMultiData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; QStringList linkedProps; linkedProps << "DataContainerDestination" @@ -123,7 +123,7 @@ void MoveMultiData::readFilterParameters(AbstractFilterParametersReader* reader, { reader->openFilterGroup(this, index); setWhatToMove(reader->readValue("WhatToMove", getWhatToMove())); - setDataContainerDestination(reader->readString("DataContainerDestination", getDataContainerDestination())); + setDataContainerDestination(reader->readDataArrayPath("DataContainerDestination", getDataContainerDestination())); setAttributeMatrixSources(reader->readDataArrayPathVector("AttributeMatrixSource", getAttributeMatrixSources())); setAttributeMatrixDestination(reader->readDataArrayPath("AttributeMatrixDestination", getAttributeMatrixDestination())); setDataArraySources(reader->readDataArrayPathVector("DataArraySources", getDataArraySources())); @@ -142,8 +142,8 @@ void MoveMultiData::initialize() // ----------------------------------------------------------------------------- void MoveMultiData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QVector amSrcPaths = getAttributeMatrixSources(); DataArrayPath amDestPath = getAttributeMatrixDestination(); QVector daSrcPaths = getDataArraySources(); @@ -158,7 +158,7 @@ void MoveMultiData::dataCheck() DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer(this, amSrcPaths[i].getDataContainerName()); AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amSrcPaths[i], -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -166,15 +166,15 @@ void MoveMultiData::dataCheck() // Source and Destination match if(amSrcDataContainer->getName() == amDestDataContainer->getName()) { - setWarningCondition(-11018); QString ss = QObject::tr("The source and destination Data Container are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11018, ss); return; } // Move Attribute Matrix - amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix); - amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + amDestDataContainer->addOrReplaceAttributeMatrix(amSrcAttributeMatrix); + //amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + addPathRename(amSrcPaths[i], amSrcAttributeMatrix->getDataArrayPath()); } } else if(getWhatToMove() == k_MoveMultiDataArray) @@ -187,7 +187,7 @@ void MoveMultiData::dataCheck() AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, daSrcPaths[i], -301); IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath(this, daSrcPaths[i]); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -195,32 +195,30 @@ void MoveMultiData::dataCheck() // Number of tuples does not match if(daDestAttributeMatrix->getNumberOfTuples() != daSrcDataArray->getNumberOfTuples()) { - setErrorCondition(-11019); QString ss = QObject::tr("The number of tuples of source Attribute Array (%1) and destination Attribute Matrix (%2) do not match") .arg(daSrcDataArray->getNumberOfTuples()) .arg(daDestAttributeMatrix->getNumberOfTuples()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11019, ss); return; } // Source and Destination match if(daSrcPaths[i].hasSameAttributeMatrix(amDestPath)) { - setWarningCondition(-11020); QString ss = QObject::tr("The source and destination Attribute Matrix are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11020, ss); return; } // Move Array - daDestAttributeMatrix->addAttributeArray(daSrcPaths[i].getDataArrayName(), daSrcDataArray); - daSrcAttributeMatrix->removeAttributeArray(daSrcPaths[i].getDataArrayName()); + daDestAttributeMatrix->insertOrAssign(daSrcDataArray); + //daSrcAttributeMatrix->removeAttributeArray(daSrcPaths[i].getDataArrayName()); + addPathRename(daSrcPaths[i], daSrcDataArray->getDataArrayPath()); } } else { - setErrorCondition(-11021); QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11021, ss); return; } } @@ -243,11 +241,11 @@ void MoveMultiData::preflight() // ----------------------------------------------------------------------------- void MoveMultiData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Simply running the preflight will do what we need it to. dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/MoveMultiData.h b/Source/SIMPLib/CoreFilters/MoveMultiData.h index 9ab0fb3200..80b942c24b 100644 --- a/Source/SIMPLib/CoreFilters/MoveMultiData.h +++ b/Source/SIMPLib/CoreFilters/MoveMultiData.h @@ -48,7 +48,7 @@ class SIMPLib_EXPORT MoveMultiData : public AbstractFilter Q_OBJECT PYB11_CREATE_BINDINGS(MoveMultiData SUPERCLASS AbstractFilter) PYB11_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - PYB11_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + PYB11_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) PYB11_PROPERTY(QVector AttributeMatrixSources READ getAttributeMatrixSources WRITE setAttributeMatrixSources) PYB11_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) PYB11_PROPERTY(QVector DataArraySources READ getDataArraySources WRITE setDataArraySources) @@ -63,8 +63,8 @@ class SIMPLib_EXPORT MoveMultiData : public AbstractFilter SIMPL_FILTER_PARAMETER(int, WhatToMove) Q_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - SIMPL_FILTER_PARAMETER(QString, DataContainerDestination) - Q_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerDestination) + Q_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) SIMPL_FILTER_PARAMETER(QVector, AttributeMatrixSources) Q_PROPERTY(QVector AttributeMatrixSources READ getAttributeMatrixSources WRITE setAttributeMatrixSources) diff --git a/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp b/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp index ffc226d7eb..60cbd4aaf3 100644 --- a/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp +++ b/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp @@ -43,6 +43,10 @@ #include "SIMPLib/Filtering/ThresholdFilterHelper.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + ThresholdArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -61,7 +65,7 @@ MultiThresholdObjects::~MultiThresholdObjects() = default; // ----------------------------------------------------------------------------- void MultiThresholdObjects::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { ComparisonSelectionFilterParameter::Pointer parameter = ComparisonSelectionFilterParameter::New(); parameter->setHumanLabel("Select Arrays to Threshold"); @@ -100,13 +104,12 @@ void MultiThresholdObjects::initialize() // ----------------------------------------------------------------------------- void MultiThresholdObjects::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_SelectedThresholds.size() == 0) { - setErrorCondition(-12000); - notifyErrorMessage(getHumanLabel(), "You must add at least 1 threshold value.", getErrorCondition()); + setErrorCondition(-12000, "You must add at least 1 threshold value."); } else { @@ -125,22 +128,19 @@ void MultiThresholdObjects::dataCheck() // Enforce that right now all the arrays MUST come from the same data container and attribute matrix if(dcSet.size() != 1) { - setErrorCondition(-13090); QString ss = QObject::tr("Threshold selections must come from the same DataContainer. %1 were selected").arg(dcSet.size()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13090, ss); } if(amSet.size() != 1) { - setErrorCondition(-13091); QString ss = QObject::tr("Threshold selections must come from the same AttributeMatrix. %1 were selected").arg(amSet.size()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13091, ss); } ComparisonInput_t comp = m_SelectedThresholds[0]; QVector cDims(1, 1); DataArrayPath tempPath(comp.dataContainerName, comp.attributeMatrixName, getDestinationArrayName()); - m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, true, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ + m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, true, cDims, "", ThresholdArrayID); if(nullptr != m_DestinationPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ { m_Destination = m_DestinationPtr.lock()->getPointer(0); @@ -152,7 +152,7 @@ void MultiThresholdObjects::dataCheck() ComparisonInput_t comp = m_SelectedThresholds[i]; tempPath.update(comp.dataContainerName, comp.attributeMatrixName, comp.attributeArrayName); IDataArray::Pointer inputData = getDataContainerArray()->getPrereqIDataArrayFromPath(this, tempPath); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { cDims = inputData->getComponentDimensions(); int32_t numComp = static_cast(cDims[0]); @@ -163,8 +163,7 @@ void MultiThresholdObjects::dataCheck() if(numComp > 1) { QString ss = QObject::tr("Selected array '%1' is not a scalar array").arg(m_SelectedThresholds[i].attributeArrayName); - setErrorCondition(-11003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); } } } @@ -189,10 +188,10 @@ void MultiThresholdObjects::preflight() // ----------------------------------------------------------------------------- void MultiThresholdObjects::execute() { - int32_t err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -210,13 +209,12 @@ void MultiThresholdObjects::execute() { ThresholdFilterHelper filter(static_cast(comp_0.compOperator), comp_0.compValue, m_DestinationPtr.lock().get()); // Run the first threshold and store the results in our output array - err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(comp_0.attributeArrayName).get(), m_DestinationPtr.lock().get()); + int32_t err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(comp_0.attributeArrayName).get(), m_DestinationPtr.lock().get()); if(err < 0) { DataArrayPath tempPath(comp_0.dataContainerName, comp_0.attributeMatrixName, comp_0.attributeArrayName); QString ss = QObject::tr("Error Executing threshold filter on first array. The path is %1").arg(tempPath.serialize()); - setErrorCondition(-13001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13001, ss); return; } } @@ -239,13 +237,12 @@ void MultiThresholdObjects::execute() ThresholdFilterHelper filter(static_cast(compRef.compOperator), compRef.compValue, currentArrayPtr.get()); - err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(compRef.attributeArrayName).get(), currentArrayPtr.get()); + int32_t err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(compRef.attributeArrayName).get(), currentArrayPtr.get()); if(err < 0) { DataArrayPath tempPath(compRef.dataContainerName, compRef.attributeMatrixName, compRef.attributeArrayName); QString ss = QObject::tr("Error Executing threshold filter on array. The path is %1").arg(tempPath.serialize()); - setErrorCondition(-13002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13002, ss); return; } for(int64_t p = 0; p < totalTuples; ++p) diff --git a/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp b/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp index 4c4613ace8..a1587c7c90 100644 --- a/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp +++ b/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp @@ -43,6 +43,10 @@ #include "SIMPLib/Filtering/ThresholdFilterHelper.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + ThresholdArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -61,7 +65,7 @@ MultiThresholdObjects2::~MultiThresholdObjects2() = default; // ----------------------------------------------------------------------------- void MultiThresholdObjects2::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { ComparisonSelectionAdvancedFilterParameter::Pointer parameter = ComparisonSelectionAdvancedFilterParameter::New(); parameter->setHumanLabel("Select Arrays to Threshold"); @@ -100,15 +104,14 @@ void MultiThresholdObjects2::initialize() // ----------------------------------------------------------------------------- void MultiThresholdObjects2::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QVector comparisonValues = m_SelectedThresholds.getComparisonValues(); if(comparisonValues.empty()) { - setErrorCondition(-12000); - notifyErrorMessage(getHumanLabel(), "You must add at least 1 threshold value.", getErrorCondition()); + setErrorCondition(-12000, "You must add at least 1 threshold value."); } else { @@ -119,22 +122,19 @@ void MultiThresholdObjects2::dataCheck() // Enforce that right now all the arrays MUST come from the same data container and attribute matrix if(dcName.isEmpty()) { - setErrorCondition(-13090); QString ss = QObject::tr("Threshold must have a DataContainer. None were selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13090, ss); } if(amName.isEmpty()) { - setErrorCondition(-13091); QString ss = QObject::tr("Threshold must have an AttributeMatrix. None were selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13091, ss); } //AbstractComparison::Pointer comp = m_SelectedThresholds[0]; QVector cDims(1, 1); DataArrayPath tempPath(dcName, amName, getDestinationArrayName()); - m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, true, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ + m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, true, cDims, "", ThresholdArrayID); if(nullptr != m_DestinationPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ { m_Destination = m_DestinationPtr.lock()->getPointer(0); @@ -149,7 +149,7 @@ void MultiThresholdObjects2::dataCheck() { tempPath.update(dcName, amName, comp->getAttributeArrayName()); IDataArray::Pointer inputData = getDataContainerArray()->getPrereqIDataArrayFromPath(this, tempPath); - if (getErrorCondition() >= 0) + if(getErrorCode() >= 0) { cDims = inputData->getComponentDimensions(); int32_t numComp = static_cast(cDims[0]); @@ -160,8 +160,7 @@ void MultiThresholdObjects2::dataCheck() if (numComp > 1) { QString ss = QObject::tr("Selected array '%1' is not a scalar array").arg(comp->getAttributeArrayName()); - setErrorCondition(-11003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); } } } @@ -187,10 +186,10 @@ void MultiThresholdObjects2::preflight() // ----------------------------------------------------------------------------- void MultiThresholdObjects2::execute() { - int32_t err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -208,8 +207,7 @@ void MultiThresholdObjects2::execute() if (!m_SelectedThresholds.hasComparisonValue()) { QString ss = QObject::tr("Error Executing threshold filter. There are no specified values to threshold against"); - setErrorCondition(-13001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13001, ss); return; } @@ -221,6 +219,8 @@ void MultiThresholdObjects2::execute() createBoolArray(thresholdSize, thresholdArray); bool firstValueFound = false; + int32_t err = 0; + // Loop on the remaining Comparison objects updating our final result array as we go for(int32_t i = 0; i < m_SelectedThresholds.size() && err >= 0; ++i) { @@ -409,8 +409,7 @@ void MultiThresholdObjects2::thresholdValue(ComparisonValue::Pointer comparisonV { DataArrayPath tempPath(m_SelectedThresholds.getDataContainerName(), m_SelectedThresholds.getAttributeMatrixName(), comparisonValue->getAttributeArrayName()); QString ss = QObject::tr("Error Executing threshold filter on array. The path is %1").arg(tempPath.serialize()); - setErrorCondition(-13002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13002, ss); return; } diff --git a/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp b/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp index 94f1aa1ceb..f5f228daea 100644 --- a/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp +++ b/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp @@ -53,7 +53,7 @@ PipelineAnnotation::~PipelineAnnotation() = default; // ----------------------------------------------------------------------------- void PipelineAnnotation::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_PARAGRAPH_FP("", Summary, FilterParameter::Parameter, PipelineAnnotation, false)); @@ -72,8 +72,8 @@ void PipelineAnnotation::initialize() // ----------------------------------------------------------------------------- void PipelineAnnotation::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -95,10 +95,10 @@ void PipelineAnnotation::preflight() // ----------------------------------------------------------------------------- void PipelineAnnotation::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp b/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp index 573951c819..747c1e3527 100644 --- a/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp +++ b/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp @@ -73,8 +73,8 @@ PostSlackMessage::~PostSlackMessage() // ----------------------------------------------------------------------------- void PostSlackMessage::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -83,7 +83,7 @@ void PostSlackMessage::initialize() // ----------------------------------------------------------------------------- void PostSlackMessage::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_STRING_FP("Slack User", SlackUser, FilterParameter::Parameter, PostSlackMessage)); parameters.push_back(SIMPL_NEW_STRING_FP("Slack Url", SlackUrl, FilterParameter::Parameter, PostSlackMessage)); @@ -98,8 +98,8 @@ void PostSlackMessage::setupFilterParameters() // ----------------------------------------------------------------------------- void PostSlackMessage::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -123,7 +123,7 @@ void PostSlackMessage::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -162,15 +162,13 @@ void PostSlackMessage::execute() { if(getWarningsAsError()) { - setErrorCondition(-76000); - QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCondition()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCode()); + setErrorCondition(-76000, ss); } else { - setWarningCondition(-76001); - QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCondition()); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCode()); + setWarningCondition(-76001, ss); } } diff --git a/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp b/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp index 2b4cfeefc5..5a8dd0dd7d 100644 --- a/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp +++ b/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp @@ -190,7 +190,7 @@ RawBinaryReader::~RawBinaryReader() = default; // ----------------------------------------------------------------------------- void RawBinaryReader::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Parameter, RawBinaryReader, "*.raw *.bin")); parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, RawBinaryReader)); @@ -245,32 +245,29 @@ void RawBinaryReader::initialize() // ----------------------------------------------------------------------------- void RawBinaryReader::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QFileInfo fi(getInputFile()); if(getInputFile().isEmpty()) { QString ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } else if(!fi.exists()) { QString ss = QObject::tr("The input file does not exist"); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-388, ss); } if(m_NumberOfComponents < 1) { QString ss = QObject::tr("The number of components must be positive"); - setErrorCondition(-391); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-391, ss); } AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCreatedAttributeArrayPath(), -30003); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -341,8 +338,7 @@ void RawBinaryReader::dataCheck() " Please adjust the input parameters to match the size of the file or select a different data file") .arg(fileSize) .arg(allocatedBytes); - setErrorCondition(RBR_FILE_TOO_SMALL); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(RBR_FILE_TOO_SMALL, ss); } else if(check == 1) { @@ -351,8 +347,7 @@ void RawBinaryReader::dataCheck() " SIMPLView will read only the first part of the file into the array") .arg(fileSize) .arg(allocatedBytes); - setWarningCondition(RBR_FILE_TOO_BIG); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(RBR_FILE_TOO_BIG, ss); } } @@ -374,16 +369,17 @@ void RawBinaryReader::preflight() // ----------------------------------------------------------------------------- void RawBinaryReader::execute() { - int32_t err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCreatedAttributeArrayPath().getDataContainerName()); + int32_t err = 0; switch(m_ScalarType) { case SIMPL::NumericTypes::Type::Int8: @@ -428,23 +424,19 @@ void RawBinaryReader::execute() if(err == RBR_FILE_NOT_OPEN) { - setErrorCondition(RBR_FILE_NOT_OPEN); - notifyErrorMessage(getHumanLabel(), "Unable to open the specified file", getErrorCondition()); + setErrorCondition(RBR_FILE_NOT_OPEN, "Unable to open the specified file"); } else if(err == RBR_FILE_TOO_SMALL) { - setErrorCondition(RBR_FILE_TOO_SMALL); - notifyErrorMessage(getHumanLabel(), "The file size is smaller than the allocated size", getErrorCondition()); + setErrorCondition(RBR_FILE_TOO_SMALL, "The file size is smaller than the allocated size"); } else if(err == RBR_FILE_TOO_BIG) { - setWarningCondition(RBR_FILE_TOO_BIG); - notifyWarningMessage(getHumanLabel(), "The file size is larger than the allocated size", getWarningCondition()); + setWarningCondition(RBR_FILE_TOO_BIG, "The file size is larger than the allocated size"); } else if(err == RBR_READ_EOF) { - setErrorCondition(RBR_READ_EOF); - notifyErrorMessage(getHumanLabel(), "RawBinaryReader read past the end of the specified file", getErrorCondition()); + setErrorCondition(RBR_READ_EOF, "RawBinaryReader read past the end of the specified file"); } } diff --git a/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp b/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp index 7c96c30d34..58d4009ee3 100644 --- a/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp +++ b/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp @@ -22,6 +22,7 @@ namespace { const QString k_Skip("Skip"); } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -38,7 +39,7 @@ ReadASCIIData::~ReadASCIIData() = default; // ----------------------------------------------------------------------------- void ReadASCIIData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(ReadASCIIDataFilterParameter::New("ASCII Wizard Data", "WizardData", "WizardData", FilterParameter::Parameter)); @@ -219,7 +220,7 @@ void ReadASCIIData::writeFilterParameters(QJsonObject& obj) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ReadASCIIData::renameDataArrayPath(DataArrayPath::RenameType renamePath) +void ReadASCIIData::renameDataArrayPath(const DataArrayPath::RenameType& renamePath) { getWizardData().updateDataArrayPath(renamePath); @@ -239,16 +240,15 @@ void ReadASCIIData::initialize() // ----------------------------------------------------------------------------- void ReadASCIIData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); m_ASCIIArrayMap.clear(); ASCIIWizardData wizardData = getWizardData(); if(wizardData.isEmpty()) { QString ss = "A file has not been chosen to import. Please pick a file to import."; - setErrorCondition(EMPTY_FILE); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(EMPTY_FILE, ss); return; } @@ -264,8 +264,7 @@ void ReadASCIIData::dataCheck() if(inputFilePath.isEmpty()) { QString ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } SIMPLDataPathValidator* validator = SIMPLDataPathValidator::Instance(); @@ -275,8 +274,7 @@ void ReadASCIIData::dataCheck() if(!fi.exists()) { QString ss = QObject::tr("The input file does not exist"); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-388, ss); } if(!automaticAM) @@ -285,8 +283,7 @@ void ReadASCIIData::dataCheck() if(nullptr == am.get()) { QString ss = "The attribute matrix input is empty. Please select an attribute matrix."; - setErrorCondition(EMPTY_ATTR_MATRIX); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(EMPTY_ATTR_MATRIX, ss); return; } @@ -300,8 +297,7 @@ void ReadASCIIData::dataCheck() if(amArrayName == headerName) { QString ss = "The header name \"" + headerName + "\" matches an array name that already exists in the selected attribute matrix."; - setErrorCondition(DUPLICATE_NAMES); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(DUPLICATE_NAMES, ss); return; } } @@ -317,8 +313,7 @@ void ReadASCIIData::dataCheck() // QTextStream out(&ss); // out << selectedPath.getAttributeMatrixName() << " tuple dims: " << am->getTupleDimensions().at(0) << "\n"; // out << fi.fileName() << "tuple dims: " << tDims[0] << "\n"; - // setErrorCondition(INCONSISTENT_TUPLES); - // notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + // setErrorCondition(INCONSISTENT_TUPLES, ss); // return; // } @@ -352,64 +347,63 @@ void ReadASCIIData::dataCheck() if(dataType == SIMPL::TypeNames::Double) { - DoubleArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + DoubleArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Float) { - FloatArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + FloatArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int8) { - Int8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int16) { - Int16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int32) { - Int32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int64) { - Int64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt8) { - UInt8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt16) { - UInt16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt32) { - UInt32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt64) { - UInt64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::String) { - StringDataArray::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, "", cDims); + StringDataArray::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, "", cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else { QString ss = "The data type that was chosen for column number " + QString::number(i + 1) + " is not a valid data array type."; - setErrorCondition(INVALID_ARRAY_TYPE); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(INVALID_ARRAY_TYPE, ss); return; } } @@ -434,11 +428,11 @@ void ReadASCIIData::preflight() // ----------------------------------------------------------------------------- void ReadASCIIData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -557,8 +551,7 @@ void ReadASCIIData::execute() out << "Expecting " << dataTypes.size() << " but found " << tokens.size() << "\n"; out << "Input line was:\n"; out << line; - setErrorCondition(INCONSISTENT_COLS); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(INCONSISTENT_COLS, ss); return; } @@ -572,21 +565,21 @@ void ReadASCIIData::execute() { QString errorMessage = obj.errorMessage; QString ss = errorMessage + "(line " + QString::number(lineNum) + ", column " + QString::number(index) + ")."; - setErrorCondition(CONVERSION_FAILURE); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(CONVERSION_FAILURE, ss); return; } } - if((static_cast(lineNum) / numTuples) * 100.0f > threshold) + const float percentCompleted = (static_cast(lineNum) / numTuples) * 100.0f; + if(percentCompleted > threshold) { // Print the status of the import - QString ss = QObject::tr("Importing ASCII Data || %1% Complete").arg((static_cast(lineNum) / numTuples) * 100.0f, 0, 'f', 0); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + QString ss = QObject::tr("Importing ASCII Data || %1% Complete").arg(static_cast(percentCompleted), 0, 'f', 0); + notifyStatusMessage(ss); threshold = threshold + 5.0f; - if(threshold < (static_cast(lineNum) / numTuples) * 100.0f) + if(threshold < percentCompleted) { - threshold = (static_cast(lineNum) / numTuples) * 100.0f; + threshold = percentCompleted; } } diff --git a/Source/SIMPLib/CoreFilters/ReadASCIIData.h b/Source/SIMPLib/CoreFilters/ReadASCIIData.h index 624c0c7480..371d03995e 100644 --- a/Source/SIMPLib/CoreFilters/ReadASCIIData.h +++ b/Source/SIMPLib/CoreFilters/ReadASCIIData.h @@ -122,7 +122,7 @@ class SIMPLib_EXPORT ReadASCIIData : public AbstractFilter * For DataArrayPaths longer than the given path, only the specified values are modified * @param renamePath */ - void renameDataArrayPath(DataArrayPath::RenameType renamePath) override; + void renameDataArrayPath(const DataArrayPath::RenameType& renamePath) override; signals: /** diff --git a/Source/SIMPLib/CoreFilters/RemoveArrays.cpp b/Source/SIMPLib/CoreFilters/RemoveArrays.cpp index dceccb2d0c..a0239949ac 100644 --- a/Source/SIMPLib/CoreFilters/RemoveArrays.cpp +++ b/Source/SIMPLib/CoreFilters/RemoveArrays.cpp @@ -55,7 +55,7 @@ RemoveArrays::~RemoveArrays() = default; // ----------------------------------------------------------------------------- void RemoveArrays::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerArrayProxyFilterParameter::Pointer parameter = DataContainerArrayProxyFilterParameter::New(); @@ -95,8 +95,8 @@ void RemoveArrays::initialize() // ----------------------------------------------------------------------------- void RemoveArrays::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); markSelectionsForDeletion(getDataContainerArray().get(), Qt::Checked); @@ -129,6 +129,8 @@ void RemoveArrays::markSelectionsForDeletion(DataContainerArray* dca, Qt::CheckS // ----------------------------------------------------------------------------- void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dca, Qt::CheckState state) { + m_RemovedPaths.clear(); + // Loop over the data containers until we find the proper data container QList containers = m_DataArraysToRemove.getDataContainers().values(); QMutableListIterator containerIter(containers); @@ -138,7 +140,7 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc DataContainerProxy dcProxy = containerIter.next(); dcList.push_back(dcProxy.getName()); DataContainer::Pointer dcItem = dca->getPrereqDataContainer(this, dcProxy.getName()); - if(getErrorCondition() < 0 || dcItem.get() == nullptr) + if(getErrorCode() < 0 || dcItem.get() == nullptr) { continue; } @@ -147,7 +149,8 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc // the DataContainerArray if(dcProxy.getFlag() == state) { - dca->removeDataContainer(dcProxy.getName()); // Remove it out + auto dc = dca->removeDataContainer(dcProxy.getName()); // Remove it out + m_RemovedPaths.merge(dc->getDescendantPaths()); continue; // Continue to the next DataContainer } QMap attrMats = dcProxy.getAttributeMatricies(); @@ -160,16 +163,16 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc // assert(amItem.get() != nullptr); if(amItem.get() == nullptr) { - setErrorCondition(-11008); QString ss = QObject::tr("The AttributeMatrix '%1' could not be removed because it was not found in DataContainer '%2'").arg(amName).arg(dcProxy.getName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11008, ss); continue; } AttributeMatrixProxy attrProxy = attrMatsIter.value(); // Check to see if this AttributeMatrix is checked, if not then remove it from the DataContainer and go to the next loop if(attrProxy.getFlag() == state) { - dcItem->removeAttributeMatrix(amName); + auto am = dcItem->removeAttributeMatrix(amName); + m_RemovedPaths.merge(am->getDescendantPaths()); continue; } // We found the selected AttributeMatrix, so loop over this attribute matrix arrays and populate the list widget @@ -182,16 +185,16 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc IDataArray::Pointer daItem = amItem->getAttributeArray(daName); if(daItem.get() == nullptr) { - setWarningCondition(-11009); QString ss = QObject::tr("%1/%2/%3 was not found. This could be due to another filter removing the array.").arg(dcProxy.getName()).arg(amName).arg(daName); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11009, ss); continue; } DataArrayProxy daProxy = dataArraysIter.value(); // Check to see if the user selected this item if(daProxy.getFlag() == state) { - amItem->removeAttributeArray(daName); + auto da = amItem->removeAttributeArray(daName); + m_RemovedPaths.push_back(da->getDataArrayPath()); continue; } } @@ -199,16 +202,24 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc } } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list RemoveArrays::getDeletedPaths() +{ + return m_RemovedPaths; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RemoveArrays::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Simply running the preflight will do what we need it to. dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/RemoveArrays.h b/Source/SIMPLib/CoreFilters/RemoveArrays.h index 4cbf883955..6f3efa6849 100644 --- a/Source/SIMPLib/CoreFilters/RemoveArrays.h +++ b/Source/SIMPLib/CoreFilters/RemoveArrays.h @@ -133,6 +133,12 @@ class SIMPLib_EXPORT RemoveArrays : public AbstractFilter */ void removeSelectionsFromDataContainerArray(DataContainerArray* dca, Qt::CheckState state); + /** + * @brief Returns the list of deleted data paths. + * @return + */ + std::list getDeletedPaths() override; + signals: /** * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters @@ -179,5 +185,8 @@ class SIMPLib_EXPORT RemoveArrays : public AbstractFilter RemoveArrays(RemoveArrays&&) = delete; // Move Constructor Not Implemented RemoveArrays& operator=(const RemoveArrays&) = delete; // Copy Assignment Not Implemented RemoveArrays& operator=(RemoveArrays&&) = delete; // Move Assignment Not Implemented + + private: + std::list m_RemovedPaths; }; diff --git a/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp b/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp index ead5f4d1a9..64b64e71ce 100644 --- a/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp +++ b/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp @@ -45,6 +45,11 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + NewDataArrayID = 1, + ReducedDataArrayID +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -66,7 +71,7 @@ RemoveComponentFromArray::~RemoveComponentFromArray() = default; // ----------------------------------------------------------------------------- void RemoveComponentFromArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_INTEGER_FP("Component Number to Remove", CompNumber, FilterParameter::Parameter, RemoveComponentFromArray)); @@ -112,8 +117,8 @@ void RemoveComponentFromArray::initialize() // ----------------------------------------------------------------------------- void RemoveComponentFromArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); @@ -121,42 +126,38 @@ void RemoveComponentFromArray::dataCheck() { if(m_NewArrayArrayName.isEmpty()) { - setErrorCondition(-11001); - notifyErrorMessage(getHumanLabel(), "Removed Component array name must be set.", getErrorCondition()); + setErrorCondition(-11001, "Removed Component array name must be set."); return; } } if(m_ReducedArrayArrayName.isEmpty()) { - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), "Reduced array name must be set.", getErrorCondition()); + setErrorCondition(-11002, "Reduced array name must be set."); return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(m_InArrayPtr.lock()->getNumberOfComponents() < 2) { - setErrorCondition(-11003); QString ss = QObject::tr("Selected array '%1' must have more than 1 component. The number of components is %2") .arg(getSelectedArrayPath().getDataArrayName()) .arg(m_InArrayPtr.lock()->getNumberOfComponents()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); return; } if(m_CompNumber >= m_InArrayPtr.lock()->getNumberOfComponents()) { - setErrorCondition(-11004); QString ss = QObject::tr("Error removing component from DataArray '%3', Component to remove (%1) is greater than or equal to the number of components (%2) for array selected.") .arg(m_CompNumber) .arg(m_InArrayPtr.lock()->getNumberOfComponents()) .arg(getSelectedArrayPath().getDataArrayName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } @@ -164,12 +165,12 @@ void RemoveComponentFromArray::dataCheck() if(m_SaveRemovedComponent) { DataArrayPath tempPath(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), getNewArrayArrayName()); - m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock()); + m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock(), NewDataArrayID); } - cDims[0] = m_InArrayPtr.lock()->getNumberOfComponents() - 1; + cDims[0] = static_cast(m_InArrayPtr.lock()->getNumberOfComponents()) - 1; DataArrayPath tempPath2(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), getReducedArrayArrayName()); - m_ReducedArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath2, cDims, m_InArrayPtr.lock()); + m_ReducedArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath2, cDims, m_InArrayPtr.lock(), ReducedDataArrayID); } // ----------------------------------------------------------------------------- @@ -267,10 +268,10 @@ template void reduceArrayOnly(IDataArray::Pointer inputData, IDataA // ----------------------------------------------------------------------------- void RemoveComponentFromArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp b/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp index eb5b727d14..9ce24bcc63 100644 --- a/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp +++ b/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp @@ -60,7 +60,7 @@ RenameAttributeArray::~RenameAttributeArray() = default; // ----------------------------------------------------------------------------- void RenameAttributeArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; DataArraySelectionFilterParameter::RequirementType req; parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Rename", SelectedArrayPath, FilterParameter::RequiredArray, RenameAttributeArray, req)); @@ -93,21 +93,31 @@ void RenameAttributeArray::initialize() // ----------------------------------------------------------------------------- void RenameAttributeArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_NewArrayName.isEmpty()) { - setErrorCondition(-11009); QString ss = QObject::tr("The new Attribute Array name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11009, ss); return; } QString daName = getSelectedArrayPath().getDataArrayName(); + // Update the last array name. This is important for creating rename paths. + if(m_LastArrayName != getNewArrayName()) + { + DataArrayPath newArrayPath = getSelectedArrayPath(); + newArrayPath.setAttributeMatrixName(m_NewArrayName); + DataArrayPath oldArrayPath = getSelectedArrayPath(); + oldArrayPath.setAttributeMatrixName(m_LastArrayName); + addPathRename(oldArrayPath, newArrayPath); + m_LastArrayName = getNewArrayName(); + } + AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getSelectedArrayPath(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -117,22 +127,29 @@ void RenameAttributeArray::dataCheck() { case OLD_DOES_NOT_EXIST: { - setErrorCondition(-11016); QString ss = QObject::tr("A DataArray with the name '%1' was not found in the AttributeMatrix").arg(daName); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11016, ss); return; } case NEW_EXISTS: { - setErrorCondition(-11017); QString ss = QObject::tr("A DataArray with the name '%1' already exists in the AttributeMatrix").arg(m_NewArrayName); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11017, ss); + return; + } + case RenameErrorCodes::SAME_PATH: + { + QString ss = QObject::tr("The new and original DataArray names cannot be identical"); + setErrorCondition(-11018, ss); return; } case SUCCESS: { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); + DataArrayPath newPath = getSelectedArrayPath(); + newPath.setDataArrayName(m_NewArrayName); + addPathRename(getSelectedArrayPath(), newPath); return; } } @@ -156,10 +173,10 @@ void RenameAttributeArray::preflight() // ----------------------------------------------------------------------------- void RenameAttributeArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); // calling the dataCheck will rename the array, so nothing is required here - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -246,8 +263,8 @@ DataArrayPath::RenameContainer RenameAttributeArray::getRenamedPaths() DataArrayPath newPath = getSelectedArrayPath(); newPath.setDataArrayName(getNewArrayName()); - DataArrayPath::RenameContainer container; - container.push_back(DataArrayPath::RenameType(oldPath, newPath)); + DataArrayPath::RenameContainer container = AbstractFilter::getRenamedPaths(); + container.push_back(std::make_pair(oldPath, newPath)); return container; } diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeArray.h b/Source/SIMPLib/CoreFilters/RenameAttributeArray.h index 9803cbf987..79d1426f9e 100755 --- a/Source/SIMPLib/CoreFilters/RenameAttributeArray.h +++ b/Source/SIMPLib/CoreFilters/RenameAttributeArray.h @@ -169,6 +169,8 @@ class SIMPLib_EXPORT RenameAttributeArray : public AbstractFilter */ void initialize(); + private: + QString m_LastArrayName = ""; public: RenameAttributeArray(const RenameAttributeArray&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp index 253d60ca15..baf43ebbc3 100644 --- a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp +++ b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp @@ -60,7 +60,7 @@ RenameAttributeMatrix::~RenameAttributeMatrix() = default; // ----------------------------------------------------------------------------- void RenameAttributeMatrix::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { AttributeMatrixSelectionFilterParameter::RequirementType req; @@ -95,23 +95,32 @@ void RenameAttributeMatrix::initialize() // ----------------------------------------------------------------------------- void RenameAttributeMatrix::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_NewAttributeMatrix.isEmpty()) { - setErrorCondition(-11004); QString ss = QObject::tr("The new Attribute Matrix name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } QString amName = getSelectedAttributeMatrixPath().getAttributeMatrixName(); + if(m_LastMatrixName != getNewAttributeMatrix()) + { + DataArrayPath newMatrixPath = getSelectedAttributeMatrixPath(); + newMatrixPath.setAttributeMatrixName(getNewAttributeMatrix()); + DataArrayPath oldMatrixPath = getSelectedAttributeMatrixPath(); + oldMatrixPath.setAttributeMatrixName(m_LastMatrixName); + addPathRename(oldMatrixPath, getSelectedAttributeMatrixPath()); + m_LastMatrixName = getNewAttributeMatrix(); + } + DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getSelectedAttributeMatrixPath().getDataContainerName()); getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getSelectedAttributeMatrixPath(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -119,9 +128,14 @@ void RenameAttributeMatrix::dataCheck() bool check = dc->renameAttributeMatrix(amName, getNewAttributeMatrix()); if(!check) { - setErrorCondition(-11006); QString ss = QObject::tr("Attempt to rename Attribute Matrix '%1' to '%2' failed").arg(amName).arg(getNewAttributeMatrix()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11006, ss); + } + else + { + DataArrayPath newPath = getSelectedAttributeMatrixPath(); + newPath.setAttributeMatrixName(getNewAttributeMatrix()); + addPathRename(getSelectedAttributeMatrixPath(), newPath); } } @@ -143,10 +157,10 @@ void RenameAttributeMatrix::preflight() // ----------------------------------------------------------------------------- void RenameAttributeMatrix::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); // calling the dataCheck will rename the array, so nothing is required here - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -233,8 +247,8 @@ DataArrayPath::RenameContainer RenameAttributeMatrix::getRenamedPaths() DataArrayPath newPath = getSelectedAttributeMatrixPath(); newPath.setAttributeMatrixName(getNewAttributeMatrix()); - DataArrayPath::RenameContainer container; - container.push_back(DataArrayPath::RenameType(oldPath, newPath)); + DataArrayPath::RenameContainer container = AbstractFilter::getRenamedPaths(); + container.push_back(std::make_pair(oldPath, newPath)); return container; } diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h index 417f001eaa..dc4d833372 100755 --- a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h +++ b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h @@ -169,6 +169,8 @@ class SIMPLib_EXPORT RenameAttributeMatrix : public AbstractFilter */ void initialize(); + private: + QString m_LastMatrixName = ""; public: RenameAttributeMatrix(const RenameAttributeMatrix&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp b/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp index 9c36d452a6..df8efd2c5d 100644 --- a/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp +++ b/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp @@ -37,8 +37,8 @@ #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" -#include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- @@ -60,29 +60,18 @@ RenameDataContainer::~RenameDataContainer() = default; // ----------------------------------------------------------------------------- void RenameDataContainer::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerSelectionFilterParameter::RequirementType req; parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container to Rename", SelectedDataContainerName, FilterParameter::RequiredArray, RenameDataContainer, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("New Data Container Name", NewDataContainerName, FilterParameter::Parameter, RenameDataContainer)); + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("New Data Container Name", NewDataContainerName, FilterParameter::Parameter, RenameDataContainer)); setFilterParameters(parameters); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RenameDataContainer::readFilterParameters(AbstractFilterParametersReader* reader, int index) -{ - reader->openFilterGroup(this, index); - setSelectedDataContainerName(reader->readString("SelectedDataContainerName", getSelectedDataContainerName())); - setNewDataContainerName(reader->readString("NewDataContainerName", getNewDataContainerName())); - reader->closeFilterGroup(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -95,19 +84,26 @@ void RenameDataContainer::initialize() // ----------------------------------------------------------------------------- void RenameDataContainer::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getNewDataContainerName().isEmpty()) { - setErrorCondition(-11001); QString ss = QObject::tr("The new Data Container name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); return; } + if(m_LastContainerName != m_NewDataContainerName) + { + DataArrayPath oldContainerPath = m_LastContainerName; + DataArrayPath newContainerPath = getNewDataContainerName(); + addPathRename(oldContainerPath, newContainerPath); + m_LastContainerName = getNewDataContainerName(); + } + getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -115,9 +111,14 @@ void RenameDataContainer::dataCheck() bool check = getDataContainerArray()->renameDataContainer(getSelectedDataContainerName(), getNewDataContainerName()); if(!check) { - setErrorCondition(-11006); - QString ss = QObject::tr("Attempt to rename DataContainer '%1' to '%2' failed").arg(getSelectedDataContainerName()).arg(getNewDataContainerName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("Attempt to rename DataContainer '%1' to '%2' failed").arg(getSelectedDataContainerName().getDataContainerName()).arg(getNewDataContainerName().getDataContainerName()); + setErrorCondition(-11006, ss); + } + else + { + DataArrayPath oldPath = getSelectedDataContainerName(); + DataArrayPath newPath = getNewDataContainerName(); + addPathRename(oldPath, newPath); } } @@ -139,10 +140,10 @@ void RenameDataContainer::preflight() // ----------------------------------------------------------------------------- void RenameDataContainer::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); // calling the dataCheck will rename the array, so nothing is required here - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -225,11 +226,11 @@ const QString RenameDataContainer::getHumanLabel() const // ----------------------------------------------------------------------------- DataArrayPath::RenameContainer RenameDataContainer::getRenamedPaths() { - DataArrayPath oldPath(getSelectedDataContainerName(), "", ""); - DataArrayPath newPath(getNewDataContainerName(), "", ""); + DataArrayPath oldPath = getSelectedDataContainerName(); + DataArrayPath newPath = getNewDataContainerName(); - DataArrayPath::RenameContainer container; - container.push_back(DataArrayPath::RenameType(oldPath, newPath)); + DataArrayPath::RenameContainer container = AbstractFilter::getRenamedPaths(); + container.push_back(std::make_pair(oldPath, newPath)); return container; } diff --git a/Source/SIMPLib/CoreFilters/RenameDataContainer.h b/Source/SIMPLib/CoreFilters/RenameDataContainer.h index 8ed3792957..324c3535df 100755 --- a/Source/SIMPLib/CoreFilters/RenameDataContainer.h +++ b/Source/SIMPLib/CoreFilters/RenameDataContainer.h @@ -47,8 +47,8 @@ class SIMPLib_EXPORT RenameDataContainer : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(RenameDataContainer SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) - PYB11_PROPERTY(QString NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) + PYB11_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + PYB11_PROPERTY(DataArrayPath NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) public: SIMPL_SHARED_POINTERS(RenameDataContainer) @@ -57,11 +57,11 @@ class SIMPLib_EXPORT RenameDataContainer : public AbstractFilter ~RenameDataContainer() override; - SIMPL_FILTER_PARAMETER(QString, SelectedDataContainerName) - Q_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedDataContainerName) + Q_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) - SIMPL_FILTER_PARAMETER(QString, NewDataContainerName) - Q_PROPERTY(QString NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, NewDataContainerName) + Q_PROPERTY(DataArrayPath NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class @@ -113,11 +113,6 @@ class SIMPLib_EXPORT RenameDataContainer : public AbstractFilter */ void setupFilterParameters() override; - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - /** * @brief execute Reimplemented from @see AbstractFilter class */ @@ -169,6 +164,8 @@ class SIMPLib_EXPORT RenameDataContainer : public AbstractFilter */ void initialize(); + private: + DataArrayPath m_LastContainerName; public: RenameDataContainer(const RenameDataContainer&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp b/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp index 3ad88da2e6..a13fb64b43 100644 --- a/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp +++ b/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp @@ -62,7 +62,7 @@ ReplaceValueInArray::~ReplaceValueInArray() = default; // ----------------------------------------------------------------------------- void ReplaceValueInArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_DOUBLE_FP("Value to Replace", RemoveValue, FilterParameter::Parameter, ReplaceValueInArray)); parameters.push_back(SIMPL_NEW_DOUBLE_FP("New Value", ReplaceValue, FilterParameter::Parameter, ReplaceValueInArray)); @@ -95,14 +95,12 @@ template void checkValuesInt(AbstractFilter* filter, double removeV if(!((removeValue >= std::numeric_limits::min()) && (removeValue <= std::numeric_limits::max()))) { ss = QObject::tr("The %1 remove value was invalid. The valid range is %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-100); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-100, ss); } if(!((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max()))) { ss = QObject::tr("The %1 replace value was invalid. The valid range is %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-100); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-100, ss); } } @@ -117,15 +115,13 @@ template void checkValuesFloatDouble(AbstractFilter* filter, double ((removeValue >= std::numeric_limits::min()) && (removeValue <= std::numeric_limits::max())))) { ss = QObject::tr("The %1 remove value was invalid. The valid ranges are -%3 to -%2, 0, %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-101); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-101, ss); } if(!(((replaceValue >= static_cast(-1) * std::numeric_limits::max()) && (replaceValue <= static_cast(-1) * std::numeric_limits::min())) || (replaceValue == 0) || ((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max())))) { ss = QObject::tr("The %1 replace value was invalid. The valid ranges are -%3 to -%2, 0, %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-101); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-101, ss); } } @@ -164,11 +160,11 @@ void ReplaceValueInArray::initialize() // ----------------------------------------------------------------------------- void ReplaceValueInArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); m_ArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArray()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -178,8 +174,7 @@ void ReplaceValueInArray::dataCheck() QString ss = QObject::tr("Selected array '%1' must be a scalar array (1 component). The number of components is %2") .arg(getSelectedArray().getDataArrayName()) .arg(m_ArrayPtr.lock()->getNumberOfComponents()); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } @@ -237,9 +232,8 @@ void ReplaceValueInArray::dataCheck() } else { - setErrorCondition(-4060); QString ss = QObject::tr("Incorrect data scalar type"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4060, ss); } } @@ -261,10 +255,10 @@ void ReplaceValueInArray::preflight() // ----------------------------------------------------------------------------- void ReplaceValueInArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp b/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp index 0f4cbbb287..43893d0b11 100644 --- a/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp +++ b/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp @@ -64,7 +64,7 @@ RequiredZThickness::~RequiredZThickness() = default; // ----------------------------------------------------------------------------- void RequiredZThickness::setupFilterParameters() { - FilterParameterVector parameters = getFilterParameters(); + FilterParameterVectorType parameters = getFilterParameters(); { DataContainerSelectionFilterParameter::RequirementType req; @@ -82,7 +82,7 @@ void RequiredZThickness::readFilterParameters(AbstractFilterParametersReader* re { AbstractDecisionFilter::readFilterParameters(reader, index); reader->openFilterGroup(this, index); - setDataContainerSelection(reader->readString("DataContainerSelection", getDataContainerSelection())); + setDataContainerSelection(reader->readDataArrayPath("DataContainerSelection", getDataContainerSelection())); setNumZVoxels(reader->readValue("NumZVoxels", getNumZVoxels())); setPreflightCheck(reader->readValue("PreflightCheck", getPreflightCheck())); reader->closeFilterGroup(); @@ -100,15 +100,15 @@ void RequiredZThickness::initialize() // ----------------------------------------------------------------------------- void RequiredZThickness::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); - if(getErrorCondition() < 0) + clearErrorCode(); + clearWarningCode(); + if(getErrorCode() < 0) { return; } DataContainer::Pointer dataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerSelection()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -116,8 +116,7 @@ void RequiredZThickness::dataCheck() ImageGeom::Pointer image = dataContainer->getGeometryAs(); if(nullptr == image.get()) { - setErrorCondition(-7789); - notifyErrorMessage(getHumanLabel(), "Missing Image Geometry in the selected DataContainer", getErrorCondition()); + setErrorCondition(-7789, "Missing Image Geometry in the selected DataContainer"); return; } @@ -126,14 +125,13 @@ void RequiredZThickness::dataCheck() if(dims[2] < getNumZVoxels() && m_PreflightCheck) { - setErrorCondition(-7787); QString str; QTextStream ss(&str); ss << "Number of Z Voxels does not meet required value during preflight of the filter. \n"; ss << " Required Z Voxels: " << m_NumZVoxels << "\n"; ss << " Current Z Voxels: " << dims[2]; - notifyErrorMessage(getHumanLabel(), str, getErrorCondition()); + setErrorCondition(-7787, str); } else if(dims[2] < getNumZVoxels() && !m_PreflightCheck) { @@ -143,8 +141,7 @@ void RequiredZThickness::dataCheck() ss << " Required Z Voxels: " << m_NumZVoxels << "\n"; ss << " Current Z Voxels: " << dims[2]; - setWarningCondition(-7788); - notifyWarningMessage(getHumanLabel(), str, getWarningCondition()); + setWarningCondition(-7788, str); } } @@ -166,16 +163,16 @@ void RequiredZThickness::preflight() // ----------------------------------------------------------------------------- void RequiredZThickness::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataContainer::Pointer dataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerSelection()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -193,8 +190,7 @@ void RequiredZThickness::execute() ss << " Required Z Voxels: " << m_NumZVoxels << "\n"; ss << " Current Z Voxels: " << dims[2]; - setErrorCondition(-7788); - notifyErrorMessage(getHumanLabel(), str, getErrorCondition()); + setErrorCondition(-7788, str); bool needMoreData = true; emit decisionMade(needMoreData); } diff --git a/Source/SIMPLib/CoreFilters/RequiredZThickness.h b/Source/SIMPLib/CoreFilters/RequiredZThickness.h index 9b2534cb6a..31f0048012 100755 --- a/Source/SIMPLib/CoreFilters/RequiredZThickness.h +++ b/Source/SIMPLib/CoreFilters/RequiredZThickness.h @@ -49,7 +49,7 @@ class SIMPLib_EXPORT RequiredZThickness : public AbstractDecisionFilter { Q_OBJECT PYB11_CREATE_BINDINGS(RequiredZThickness SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + PYB11_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) PYB11_PROPERTY(int NumZVoxels READ getNumZVoxels WRITE setNumZVoxels) PYB11_PROPERTY(bool PreflightCheck READ getPreflightCheck WRITE setPreflightCheck) @@ -60,8 +60,8 @@ class SIMPLib_EXPORT RequiredZThickness : public AbstractDecisionFilter ~RequiredZThickness() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerSelection) - Q_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerSelection) + Q_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) SIMPL_FILTER_PARAMETER(int, NumZVoxels) Q_PROPERTY(int NumZVoxels READ getNumZVoxels WRITE setNumZVoxels) diff --git a/Source/SIMPLib/CoreFilters/ScaleVolume.cpp b/Source/SIMPLib/CoreFilters/ScaleVolume.cpp index e5a92f27f1..40cc648246 100644 --- a/Source/SIMPLib/CoreFilters/ScaleVolume.cpp +++ b/Source/SIMPLib/CoreFilters/ScaleVolume.cpp @@ -60,10 +60,10 @@ class ScaleVolumeUpdateVerticesImpl { float* m_Nodes; float* m_Min; - FloatVec3_t m_ScaleFactor; + FloatVec3Type m_ScaleFactor; public: - ScaleVolumeUpdateVerticesImpl(float* nodes, float* min, FloatVec3_t scale) + ScaleVolumeUpdateVerticesImpl(float* nodes, float* min, FloatVec3Type scale) : m_Nodes(nodes) , m_Min(min) , m_ScaleFactor(scale) @@ -75,9 +75,9 @@ class ScaleVolumeUpdateVerticesImpl { for(size_t i = start; i < end; i++) { - m_Nodes[3 * i] = m_Min[0] + (m_Nodes[3 * i] - m_Min[0]) * m_ScaleFactor.x; - m_Nodes[3 * i + 1] = m_Min[1] + (m_Nodes[3 * i + 1] - m_Min[1]) * m_ScaleFactor.y; - m_Nodes[3 * i + 2] = m_Min[2] + (m_Nodes[3 * i + 2] - m_Min[2]) * m_ScaleFactor.z; + m_Nodes[3 * i] = m_Min[0] + (m_Nodes[3 * i] - m_Min[0]) * m_ScaleFactor[0]; + m_Nodes[3 * i + 1] = m_Min[1] + (m_Nodes[3 * i + 1] - m_Min[1]) * m_ScaleFactor[1]; + m_Nodes[3 * i + 2] = m_Min[2] + (m_Nodes[3 * i + 2] - m_Min[2]) * m_ScaleFactor[2]; } } @@ -98,10 +98,9 @@ ScaleVolume::ScaleVolume() , m_ApplyToVoxelVolume(true) , m_ApplyToSurfaceMesh(true) { - m_ScaleFactor.x = 1.0f; - m_ScaleFactor.y = 1.0f; - m_ScaleFactor.z = 1.0f; - + m_ScaleFactor[0] = 1.0f; + m_ScaleFactor[1] = 1.0f; + m_ScaleFactor[2] = 1.0f; } // ----------------------------------------------------------------------------- @@ -114,7 +113,7 @@ ScaleVolume::~ScaleVolume() = default; // ----------------------------------------------------------------------------- void ScaleVolume::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Scaling Factor", ScaleFactor, FilterParameter::Parameter, ScaleVolume)); @@ -149,8 +148,8 @@ void ScaleVolume::readFilterParameters(AbstractFilterParametersReader* reader, i setApplyToVoxelVolume(reader->readValue("ApplyToVoxelVolume", getApplyToVoxelVolume())); setApplyToSurfaceMesh(reader->readValue("ApplyToSurfaceMesh", getApplyToSurfaceMesh())); setScaleFactor(reader->readFloatVec3("ScaleFactor", getScaleFactor())); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); - setSurfaceDataContainerName(reader->readString("SurfaceDataContainerName", getSurfaceDataContainerName())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); + setSurfaceDataContainerName(reader->readDataArrayPath("SurfaceDataContainerName", getSurfaceDataContainerName())); reader->closeFilterGroup(); } @@ -166,8 +165,8 @@ void ScaleVolume::initialize() // ----------------------------------------------------------------------------- void ScaleVolume::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_ApplyToVoxelVolume) { @@ -198,8 +197,8 @@ void ScaleVolume::preflight() // ----------------------------------------------------------------------------- void ScaleVolume::updateSurfaceMesh() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); #ifdef SIMPL_USE_PARALLEL_ALGORITHMS tbb::task_scheduler_init init; @@ -262,10 +261,10 @@ void ScaleVolume::updateSurfaceMesh() // ----------------------------------------------------------------------------- void ScaleVolume::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -275,12 +274,12 @@ void ScaleVolume::execute() DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); ImageGeom::Pointer image = m->getGeometryAs(); - float resolution[3] = {0.0f, 0.0f, 0.0f}; - image->getResolution(resolution); - resolution[0] *= m_ScaleFactor.x; - resolution[1] *= m_ScaleFactor.y; - resolution[2] *= m_ScaleFactor.z; - image->setResolution(resolution); + FloatVec3Type spacing = {0.0f, 0.0f, 0.0f}; + image->getSpacing(spacing); + spacing[0] *= m_ScaleFactor[0]; + spacing[1] *= m_ScaleFactor[1]; + spacing[2] *= m_ScaleFactor[2]; + image->setSpacing(spacing); } if(m_ApplyToSurfaceMesh) diff --git a/Source/SIMPLib/CoreFilters/ScaleVolume.h b/Source/SIMPLib/CoreFilters/ScaleVolume.h index 4076ad3bc8..341e624f88 100755 --- a/Source/SIMPLib/CoreFilters/ScaleVolume.h +++ b/Source/SIMPLib/CoreFilters/ScaleVolume.h @@ -48,11 +48,11 @@ class SIMPLib_EXPORT ScaleVolume : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(ScaleVolume SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - PYB11_PROPERTY(QString SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) PYB11_PROPERTY(bool ApplyToVoxelVolume READ getApplyToVoxelVolume WRITE setApplyToVoxelVolume) PYB11_PROPERTY(bool ApplyToSurfaceMesh READ getApplyToSurfaceMesh WRITE setApplyToSurfaceMesh) - PYB11_PROPERTY(FloatVec3_t ScaleFactor READ getScaleFactor WRITE setScaleFactor) + PYB11_PROPERTY(FloatVec3Type ScaleFactor READ getScaleFactor WRITE setScaleFactor) public: SIMPL_SHARED_POINTERS(ScaleVolume) @@ -61,11 +61,11 @@ class SIMPLib_EXPORT ScaleVolume : public AbstractFilter ~ScaleVolume() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) - SIMPL_FILTER_PARAMETER(QString, SurfaceDataContainerName) - Q_PROPERTY(QString SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, SurfaceDataContainerName) + Q_PROPERTY(DataArrayPath SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) SIMPL_FILTER_PARAMETER(bool, ApplyToVoxelVolume) Q_PROPERTY(bool ApplyToVoxelVolume READ getApplyToVoxelVolume WRITE setApplyToVoxelVolume) @@ -73,8 +73,8 @@ class SIMPLib_EXPORT ScaleVolume : public AbstractFilter SIMPL_FILTER_PARAMETER(bool, ApplyToSurfaceMesh) Q_PROPERTY(bool ApplyToSurfaceMesh READ getApplyToSurfaceMesh WRITE setApplyToSurfaceMesh) - SIMPL_FILTER_PARAMETER(FloatVec3_t, ScaleFactor) - Q_PROPERTY(FloatVec3_t ScaleFactor READ getScaleFactor WRITE setScaleFactor) + SIMPL_FILTER_PARAMETER(FloatVec3Type, ScaleFactor) + Q_PROPERTY(FloatVec3Type ScaleFactor READ getScaleFactor WRITE setScaleFactor) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class diff --git a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp index f39d35375a..a70e0e29d6 100644 --- a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp +++ b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp @@ -96,14 +96,13 @@ SetOriginResolutionImageGeom::SetOriginResolutionImageGeom() , m_ChangeOrigin(false) , m_ChangeResolution(false) { - m_Origin.x = 0.0f; - m_Origin.y = 0.0f; - m_Origin.z = 0.0f; - - m_Resolution.x = 1.0f; - m_Resolution.y = 1.0f; - m_Resolution.z = 1.0f; + m_Origin[0] = 0.0f; + m_Origin[1] = 0.0f; + m_Origin[2] = 0.0f; + m_Spacing[0] = 1.0f; + m_Spacing[1] = 1.0f; + m_Spacing[2] = 1.0f; } // ----------------------------------------------------------------------------- @@ -116,7 +115,7 @@ SetOriginResolutionImageGeom::~SetOriginResolutionImageGeom() = default; // ----------------------------------------------------------------------------- void SetOriginResolutionImageGeom::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerSelectionFilterParameter::RequirementType req; req.dcGeometryTypes = IGeometry::Types(1, IGeometry::Type::Image); @@ -128,9 +127,9 @@ void SetOriginResolutionImageGeom::setupFilterParameters() parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, SetOriginResolutionImageGeom)); linkedProps.clear(); - linkedProps << "Resolution"; - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Change Resolution", ChangeResolution, FilterParameter::Parameter, SetOriginResolutionImageGeom, linkedProps)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resolution", Resolution, FilterParameter::Parameter, SetOriginResolutionImageGeom)); + linkedProps << "Spacing"; + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Change Spacing", ChangeResolution, FilterParameter::Parameter, SetOriginResolutionImageGeom, linkedProps)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Spacing", Spacing, FilterParameter::Parameter, SetOriginResolutionImageGeom)); setFilterParameters(parameters); } @@ -144,8 +143,8 @@ void SetOriginResolutionImageGeom::readFilterParameters(AbstractFilterParameters setChangeOrigin(reader->readValue("ChangeOrigin", getChangeOrigin())); setChangeResolution(reader->readValue("ChangeResolution", getChangeResolution())); setOrigin(reader->readFloatVec3("Origin", getOrigin())); - setResolution(reader->readFloatVec3("Resolution", getResolution())); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); + setSpacing(reader->readFloatVec3("Spacing", getSpacing())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); reader->closeFilterGroup(); } @@ -161,21 +160,21 @@ void SetOriginResolutionImageGeom::initialize() // ----------------------------------------------------------------------------- void SetOriginResolutionImageGeom::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(getChangeOrigin()) { - image->setOrigin(std::make_tuple(m_Origin.x, m_Origin.y, m_Origin.z)); + image->setOrigin(std::make_tuple(m_Origin[0], m_Origin[1], m_Origin[2])); } if(getChangeResolution()) { - image->setResolution(std::make_tuple(m_Resolution.x, m_Resolution.y, m_Resolution.z)); + image->setSpacing(std::make_tuple(m_Spacing[0], m_Spacing[1], m_Spacing[2])); } } @@ -197,10 +196,10 @@ void SetOriginResolutionImageGeom::preflight() // ----------------------------------------------------------------------------- void SetOriginResolutionImageGeom::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -276,5 +275,5 @@ const QString SetOriginResolutionImageGeom::getSubGroupName() const // ----------------------------------------------------------------------------- const QString SetOriginResolutionImageGeom::getHumanLabel() const { - return "Set Origin & Resolution (Image)"; + return "Set Origin & Spacing (Image)"; } diff --git a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h index 0f2514704a..9af2dc7a43 100755 --- a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h +++ b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h @@ -48,11 +48,11 @@ class SIMPLib_EXPORT SetOriginResolutionImageGeom : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(SetOriginResolutionImageGeom SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(bool ChangeOrigin READ getChangeOrigin WRITE setChangeOrigin) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) PYB11_PROPERTY(bool ChangeResolution READ getChangeResolution WRITE setChangeResolution) - PYB11_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + PYB11_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) public: SIMPL_SHARED_POINTERS(SetOriginResolutionImageGeom) @@ -61,20 +61,20 @@ class SIMPLib_EXPORT SetOriginResolutionImageGeom : public AbstractFilter ~SetOriginResolutionImageGeom() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) SIMPL_FILTER_PARAMETER(bool, ChangeOrigin) Q_PROPERTY(bool ChangeOrigin READ getChangeOrigin WRITE setChangeOrigin) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Origin) + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) SIMPL_FILTER_PARAMETER(bool, ChangeResolution) Q_PROPERTY(bool ChangeResolution READ getChangeResolution WRITE setChangeResolution) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Resolution) - Q_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Spacing) + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class diff --git a/Source/SIMPLib/CoreFilters/SourceList.cmake b/Source/SIMPLib/CoreFilters/SourceList.cmake index 8749c9c55a..a7719ebcde 100755 --- a/Source/SIMPLib/CoreFilters/SourceList.cmake +++ b/Source/SIMPLib/CoreFilters/SourceList.cmake @@ -97,10 +97,12 @@ endforeach() # This is the list of Private Filters. These filters are available from other filters but the user will not # be able to use them from the DREAM3D user interface. set(_PrivateFilters + ApplyImageTransforms Breakpoint EmptyFilter FileReader FileWriter + MassCreateData ) #----------------- diff --git a/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp b/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp index ec0ad90009..9c7fcc391f 100644 --- a/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp +++ b/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp @@ -42,6 +42,10 @@ #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/SIMPLibVersion.h" +enum createdPathID : RenameDataPath::DataID_t { + SplitArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -62,7 +66,7 @@ SplitAttributeArray::~SplitAttributeArray() = default; // ----------------------------------------------------------------------------- void SplitAttributeArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; DataArraySelectionFilterParameter::RequirementType dasReq = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", InputArrayPath, FilterParameter::RequiredArray, SplitAttributeArray, dasReq)); @@ -94,13 +98,13 @@ void SplitAttributeArray::initialize() // ----------------------------------------------------------------------------- void SplitAttributeArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); m_InputArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getInputArrayPath()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -111,8 +115,7 @@ void SplitAttributeArray::dataCheck() if(numComps <= 1) { QString ss = QObject::tr("Selected Attribute Array must have more than 1 component"); - setErrorCondition(-11000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11000, ss); return; } @@ -122,24 +125,22 @@ void SplitAttributeArray::dataCheck() { QString arrayName = getInputArrayPath().getDataArrayName() + getSplitArraysSuffix() + QString::number(i); DataArrayPath path(getInputArrayPath().getDataContainerName(), getInputArrayPath().getAttributeMatrixName(), arrayName); - IDataArray::WeakPointer ptr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, path, cDims, m_InputArrayPtr.lock()); - if(getErrorCondition() >= 0) + IDataArray::WeakPointer ptr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, path, cDims, m_InputArrayPtr.lock(), SplitArrayID + i); + if(getErrorCode() >= 0) { m_SplitArraysPtrVector.push_back(ptr.lock()); } else { QString ss = QObject::tr("Unable to create an Attribute Array for component %1 in the selected multicomponent Attribute Array").arg(i); - setErrorCondition(-11051); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11051, ss); } } if(numComps != m_SplitArraysPtrVector.size()) { QString ss = QObject::tr("The number of created arrays %1 does not match the number of components %2").arg(m_SplitArraysPtrVector.size()).arg(numComps); - setErrorCondition(-11001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } } } @@ -191,10 +192,10 @@ template void splitMulticomponentArray(IDataArray::Pointer inputArr // ----------------------------------------------------------------------------- void SplitAttributeArray::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ApplyImageTransformsTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ApplyImageTransformsTest.cpp new file mode 100644 index 0000000000..3aebf9cf51 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ApplyImageTransformsTest.cpp @@ -0,0 +1,69 @@ +// ----------------------------------------------------------------------------- +// Insert your license & copyright information here +// ----------------------------------------------------------------------------- +#pragma once + +#include +#include + +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/CoreFilters/ApplyImageTransforms.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class ApplyImageTransformsTest +{ + + public: + ApplyImageTransformsTest() = default; + ~ApplyImageTransformsTest() = default; + ApplyImageTransformsTest(const ApplyImageTransformsTest&) = delete; // Copy Constructor + ApplyImageTransformsTest(ApplyImageTransformsTest&&) = delete; // Move Constructor + ApplyImageTransformsTest& operator=(const ApplyImageTransformsTest&) = delete; // Copy Assignment + ApplyImageTransformsTest& operator=(ApplyImageTransformsTest&&) = delete; // Move Assignment + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestFilterAvailability() + { + ApplyImageTransforms::Pointer filter = ApplyImageTransforms::New(); + filter->preflight(); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestApplyImageTransformsTest() + { + int foo = 0; + DREAM3D_REQUIRE_EQUAL(foo, 0) + + return EXIT_SUCCESS; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST( TestFilterAvailability() ); + + DREAM3D_REGISTER_TEST( TestApplyImageTransformsTest() ) + } + + private: + + +}; + diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp index 2e55f42dae..338baf451e 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp @@ -58,21 +58,20 @@ class DummyObserver : public Observer { public: - DummyObserver() - : Observer() - { - } + DummyObserver() = default; ~DummyObserver() override = default; SIMPL_TYPE_MACRO(DummyObserver) - void processPipelineMessage(const PipelineMessage& pm) override + void processPipelineMessage(const AbstractMessage::Pointer& pm) override { // Don't do anything...this class only exists to stifle the messages being dumped to the console } -private: - DummyObserver(const DummyObserver&); // Copy Constructor Not Implemented - void operator=(const DummyObserver&); // Move assignment Not Implemented +public: + DummyObserver(const DummyObserver&) = delete; // Copy Constructor Not Implemented + DummyObserver(DummyObserver&&) = delete; // Move Constructor Not Implemented + DummyObserver& operator=(const DummyObserver&) = delete; // Copy Assignment Not Implemented + DummyObserver& operator=(DummyObserver&&) = delete; // Move Assignment Not Implemented }; class ArrayCalculatorTest @@ -92,11 +91,11 @@ class ArrayCalculatorTest AttributeMatrix::Pointer am1 = AttributeMatrix::New(QVector(1, 10), "AttributeMatrix", AttributeMatrix::Type::Cell); AttributeMatrix::Pointer am2 = AttributeMatrix::New(QVector(1, 1), "NumericMatrix", AttributeMatrix::Type::Cell); FloatArrayType::Pointer array1 = FloatArrayType::CreateArray(10, "InputArray1"); - array1->initializeWithValue(-12, 0); + array1->initializeWithValue(-12); UInt32ArrayType::Pointer array2 = UInt32ArrayType::CreateArray(10, "InputArray2"); - array2->initializeWithValue(10, 0); + array2->initializeWithValue(10); UInt32ArrayType::Pointer sArray = UInt32ArrayType::CreateArray(10, "Spaced Array"); - sArray->initializeWithValue(2, 0); + sArray->initializeWithValue(2); UInt32ArrayType::Pointer mcArray1 = UInt32ArrayType::CreateArray(QVector(1, 10), QVector(1, 3), "MultiComponent Array1"); int num = 0; @@ -120,16 +119,16 @@ class ArrayCalculatorTest IDataArray::Pointer signArray = mcArray1->deepCopy(); signArray->setName("*"); - am1->addAttributeArray("InputArray1", array1); - am1->addAttributeArray("InputArray2", array2); - am1->addAttributeArray("Spaced Array", sArray); - am1->addAttributeArray("MultiComponent Array1", mcArray1); - am1->addAttributeArray("MultiComponent Array2", mcArray2); - am1->addAttributeArray("4", numberArray); - am1->addAttributeArray("*", signArray); - dc->addAttributeMatrix("AttributeMatrix", am1); - dc->addAttributeMatrix("NumericMatrix", am2); - dca->addDataContainer(dc); + am1->insertOrAssign(array1); + am1->insertOrAssign(array2); + am1->insertOrAssign(sArray); + am1->insertOrAssign(mcArray1); + am1->insertOrAssign(mcArray2); + am1->insertOrAssign(numberArray); + am1->insertOrAssign(signArray); + dc->addOrReplaceAttributeMatrix(am1); + dc->addOrReplaceAttributeMatrix(am2); + dca->addOrReplaceDataContainer(dc); return dca; } @@ -137,7 +136,7 @@ class ArrayCalculatorTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - AbstractFilter::Pointer createArrayCalculatorFilter(DataArrayPath calculatedPath) + AbstractFilter::Pointer createArrayCalculatorFilter(const DataArrayPath& calculatedPath) { QString filtName = "ArrayCalculator"; FilterManager* fm = FilterManager::Instance(); @@ -170,9 +169,11 @@ class ArrayCalculatorTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void runTest(QString equation, DataArrayPath targetArrayPath, CalculatorItem::ErrorCode expectedErrorCondition, CalculatorItem::WarningCode expectedWarningCondition, - int* expectedNumberOfTuples = nullptr, double* expectedValue = nullptr, ArrayCalculator::AngleUnits units = ArrayCalculator::Radians) + void runTest(const QString& equation, const DataArrayPath& targetArrayPath, CalculatorItem::ErrorCode expectedErrorCondition, CalculatorItem::WarningCode expectedWarningCondition, + const int* expectedNumberOfTuples = nullptr, const double* expectedValue = nullptr, ArrayCalculator::AngleUnits units = ArrayCalculator::Radians) { + std::cout << " Testing equation: ==>" << equation.toStdString() << "<==" << std::endl; + bool propWasSet = false; AbstractFilter::Pointer filter = createArrayCalculatorFilter(targetArrayPath); @@ -182,10 +183,13 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("Units", units); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); + if(filter->getErrorCode() < 0 && expectedErrorCondition == CalculatorItem::ErrorCode::SUCCESS) + { + std::cout << " Error " << filter->getErrorCode() << " executing filter." << std::endl; + } - std::cout << "Testing equation: " << equation.toStdString() << std::endl; - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(expectedErrorCondition)); - DREAM3D_REQUIRE_EQUAL(filter->getWarningCondition(), static_cast(expectedWarningCondition)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(expectedErrorCondition)); + DREAM3D_REQUIRE_EQUAL(filter->getWarningCode(), static_cast(expectedWarningCondition)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), targetArrayPath); @@ -202,7 +206,7 @@ class ArrayCalculatorTest for(size_t i = 0; i < arrayPtr->getNumberOfTuples(); i++) { - DREAM3D_REQUIRE(SIMPLibMath::closeEnough(arrayPtr->getValue(i), value, 0.01) == true); + DREAM3D_REQUIRED(SIMPLibMath::closeEnough(arrayPtr->getValue(i), value, 0.01), ==, true); } } } @@ -215,7 +219,6 @@ class ArrayCalculatorTest DataArrayPath numericArrayPath("DataContainer", "NumericMatrix", "NewArray"); DataArrayPath arrayPath("DataContainer", "AttributeMatrix", "NewArray"); - QVariant var; bool propWasSet = false; // Multi-Component Array Tests @@ -231,7 +234,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "MultiComponent Array1 + MultiComponent Array2"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == mcArray1->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == mcArray1->getNumberOfComponents()); @@ -257,7 +260,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "MultiComponent Array1[1] + MultiComponent Array2[0]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == mcArray1->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == 1); @@ -282,7 +285,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "\"4\" + 2"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == nArray->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == nArray->getNumberOfComponents()); @@ -308,7 +311,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "\"4\" + \"*\""); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == nArray->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == nArray->getNumberOfComponents()); @@ -334,7 +337,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "\"4\"[0] + \"*\"[1]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == nArray->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == 1); @@ -359,7 +362,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "\"4\" + \"*\"[1]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS)); } // Out of bounds error @@ -375,7 +378,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "\"4\"[0] + \"*\"[3]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE)); } } @@ -387,7 +390,6 @@ class ArrayCalculatorTest DataArrayPath numericArrayPath("DataContainer", "NumericMatrix", "NewArray"); DataArrayPath arrayPath("DataContainer", "AttributeMatrix", "NewArray"); - QVariant var; bool propWasSet = false; // Empty Tests @@ -450,7 +452,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "-InputArray1"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == inputArray1->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) @@ -467,7 +469,7 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "InputArray2"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == inputArray2->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) @@ -489,8 +491,8 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "Spaced Array + InputArray1"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DREAM3D_REQUIRE_EQUAL(filter->getWarningCondition(), static_cast(CalculatorItem::WarningCode::NONE)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getWarningCode(), static_cast(CalculatorItem::WarningCode::NONE)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == spacedArray->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) @@ -510,8 +512,8 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("InfixEquation", "sqrt((InputArray1^2)+(InputArray2^2))"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DREAM3D_REQUIRE_EQUAL(filter->getWarningCondition(), static_cast(CalculatorItem::WarningCode::NONE)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getWarningCode(), static_cast(CalculatorItem::WarningCode::NONE)); DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == inputArray2->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp index 48438aa604..b7b595ccfd 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp @@ -54,11 +54,11 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDimsVec, cDimsScalar, vecName, scalarName, err) \ DataArray::Pointer _##type##VectorArray = DataArray::CreateArray(tDims, cDimsVec, #vecName, true); \ - err = attrMat->addAttributeArray(#vecName, _##type##VectorArray); \ + err = attrMat->insertOrAssign(_##type##VectorArray); \ _##type##VectorArray->initializeWithZeros(); \ DREAM3D_REQUIRE(err >= 0); \ DataArray::Pointer _##type##ScalarArray = DataArray::CreateArray(tDims, cDimsScalar, #scalarName, true); \ - err = attrMat->addAttributeArray(#scalarName, _##type##ScalarArray); \ + err = attrMat->insertOrAssign(_##type##ScalarArray); \ _##type##ScalarArray->initializeWithZeros(); \ DREAM3D_REQUIRE(err >= 0); @@ -120,8 +120,8 @@ class CombineAttributeArraysTest QVector tDims(1, 100); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "CombineAttributeArraysTest", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("CombineAttributeArraysTest", attrMat); - dca->addDataContainer(m); + m->addOrReplaceAttributeMatrix(attrMat); + dca->addOrReplaceDataContainer(m); QVector cDimsVec(1, 3); QVector cDimsScalar(1, 1); @@ -214,7 +214,7 @@ class CombineAttributeArraysTest } filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); auto outputArrayPtr = filter->getDataContainerArray()->getDataContainer("CombineAttributeArraysTest")->getAttributeMatrix("CombineAttributeArraysTest")->getAttributeArray("CombinedData"); @@ -242,7 +242,7 @@ class CombineAttributeArraysTest } filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); outputArrayPtr = filter->getDataContainerArray()->getDataContainer("CombineAttributeArraysTest")->getAttributeMatrix("CombineAttributeArraysTest")->getAttributeArray("CombinedData"); @@ -272,7 +272,7 @@ class CombineAttributeArraysTest } filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); outputArrayPtr = filter->getDataContainerArray()->getDataContainer("CombineAttributeArraysTest")->getAttributeMatrix("CombineAttributeArraysTest")->getAttributeArray("CombinedData"); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp index 902721d95d..8b5afc6cb0 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp @@ -54,7 +54,7 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDims, initVal, name, err) \ DataArray::Pointer name##Array = DataArray::CreateArray(tDims, cDims, name, true); \ - err = attrMat->addAttributeArray(name, name##Array); \ + err = attrMat->insertOrAssign(name##Array); \ name##Array->initializeWithValue(initVal); \ DREAM3D_REQUIRE(err >= 0); @@ -96,7 +96,7 @@ qDebug() << "Unable to set property CombinedAttributeMatrixName"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, errVal); #define CHECK_FOR_PASS1(filter, featureIds1, featureIds2, attrMat1, attrMat2, newIndex, newAttrMat) \ @@ -137,7 +137,7 @@ qDebug() << "Unable to set property CombinedAttributeMatrixName"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ validateCombinedEnsembleAMs(filter, featureIds1, featureIds2, attrMat1, attrMat2, newIndex, newAttrMat); @@ -179,7 +179,7 @@ qDebug() << "Unable to set property CombinedAttributeMatrixName"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ validateCombinedFeatureAMs(filter, featureIds1, featureIds2, attrMat1, attrMat2, newIndex, newAttrMat); @@ -230,7 +230,7 @@ class CombineAttributeMatricesTest // Make Cell AM AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::New(tDims, "cellAttrMat", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("cellAttrMat", cellAttrMat); + m->addOrReplaceAttributeMatrix(cellAttrMat); // Create 2 featureIds arrays in the Cell AM QString featureIds1 = "featureIds1"; @@ -258,14 +258,14 @@ class CombineAttributeMatricesTest tDims.resize(1); tDims[0] = 3; AttributeMatrix::Pointer featureAttrMat1 = AttributeMatrix::New(tDims, "featureAttrMat1", AttributeMatrix::Type::CellFeature); - m->addAttributeMatrix("featureAttrMat1", featureAttrMat1); + m->addOrReplaceAttributeMatrix(featureAttrMat1); QString fAM1AA1 = "ensembleIds"; QString fAM1AA2 = "sizes"; CREATE_DATA_ARRAY(int32_t, featureAttrMat1, tDims, cDims, initVal, fAM1AA1, err); CREATE_DATA_ARRAY(float, featureAttrMat1, tDims, cDims, initVal, fAM1AA2, err); tDims[0] = 2; AttributeMatrix::Pointer ensembleAttrMat1 = AttributeMatrix::New(tDims, "ensembleAttrMat1", AttributeMatrix::Type::CellEnsemble); - m->addAttributeMatrix("ensembleAttrMat1", ensembleAttrMat1); + m->addOrReplaceAttributeMatrix(ensembleAttrMat1); QString eAM1AA1 = "crystalStructures"; CREATE_DATA_ARRAY(int32_t, ensembleAttrMat1, tDims, cDims, initVal, eAM1AA1, err); @@ -288,14 +288,14 @@ class CombineAttributeMatricesTest // Make a feature and ensemble AM for the second featureIds array and add some arrays tDims[0] = 3; AttributeMatrix::Pointer featureAttrMat2 = AttributeMatrix::New(tDims, "featureAttrMat2", AttributeMatrix::Type::CellFeature); - m->addAttributeMatrix("featureAttrMat2", featureAttrMat2); + m->addOrReplaceAttributeMatrix(featureAttrMat2); QString fAM2AA1 = "ensembleIds"; QString fAM2AA2 = "surfaceFeatures"; CREATE_DATA_ARRAY(int32_t, featureAttrMat2, tDims, cDims, initVal, fAM2AA1, err); CREATE_DATA_ARRAY(bool, featureAttrMat2, tDims, cDims, initVal, fAM2AA2, err); tDims[0] = 2; AttributeMatrix::Pointer ensembleAttrMat2 = AttributeMatrix::New(tDims, "ensembleAttrMat2", AttributeMatrix::Type::CellEnsemble); - m->addAttributeMatrix("ensembleAttrMat2", ensembleAttrMat2); + m->addOrReplaceAttributeMatrix(ensembleAttrMat2); QString eAM2AA1 = "crystalStructures"; CREATE_DATA_ARRAY(int32_t, ensembleAttrMat2, tDims, cDims, initVal, eAM2AA1, err); @@ -315,11 +315,11 @@ class CombineAttributeMatricesTest crystStructs2[0] = 0; crystStructs2[1] = 1; - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // add a feature AM to the second DC to allow for check that AMs are in same DC - m2->addAttributeMatrix("featureAttrMat2", featureAttrMat2); - dca->addDataContainer(m2); + m2->addOrReplaceAttributeMatrix(featureAttrMat2->deepCopy()); + dca->addOrReplaceDataContainer(m2); return dca; } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp index ec53f6bc6a..5bfa627cc5 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp @@ -54,7 +54,7 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDims, initVal, comps, err) \ DataArray::Pointer _##type##_##comps##_##attrMat##Array = DataArray::CreateArray(tDims, cDims, #type #comps, true); \ - err = attrMat->addAttributeArray(#type #comps, _##type##_##comps##_##attrMat##Array); \ + err = attrMat->insertOrAssign(_##type##_##comps##_##attrMat##Array); \ _##type##_##comps##_##attrMat##Array->initializeWithValue(initVal); \ DREAM3D_REQUIRE(err >= 0); @@ -82,7 +82,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, errVal); #ifdef SET_PROPERTIES_AND_CHECK_EQ @@ -109,7 +109,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ dataArray = dc->getAttributeMatrix(selectedArray.getAttributeMatrixName())->getAttributeArray(selectedArray.getDataArrayName()); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ @@ -156,9 +156,9 @@ class ConditionalSetValueTest QVector tDims(1, 10); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "ConditionalSetValueAttrMat", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("ConditionalSetValueAttrMat", attrMat); + m->addOrReplaceAttributeMatrix(attrMat); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); QVector cDims(1, 3); int32_t initVal = 10; @@ -192,7 +192,7 @@ class ConditionalSetValueTest // this is the conditional array QString name = "ConditionalArray"; BoolArrayType::Pointer condArrayPtr = BoolArrayType::CreateArray(tDims, cDims, name); - attrMat->addAttributeArray(name, condArrayPtr); + attrMat->insertOrAssign(condArrayPtr); condArrayPtr->initializeWithValue(true); // Set some of the values to false int he conditional array bool* condArray = condArrayPtr->getPointer(0); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp index d6dc7940d6..d9e44d5fc6 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp @@ -40,7 +40,7 @@ #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/DataArray.hpp" -#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" @@ -60,7 +60,7 @@ class ConvertColorToGrayScaleTest { - const FloatVec3_t m_defaultWeights{0.2125f, 0.7154f, 0.0721f}; + const FloatVec3Type m_defaultWeights{0.2125f, 0.7154f, 0.0721f}; const bool m_createNewAM = false; const QString m_filtName = "ConvertColorToGrayScale"; const QString m_outputArrayPrefix = "grayTestImage"; @@ -299,18 +299,18 @@ class ConvertColorToGrayScaleTest static DataContainer::Pointer createVertexGeometryDataContainer(const DataArray::Pointer& aa, const QVector& tDims) { AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - am->addAttributeArray(aa->getName(), aa); + am->insertOrAssign(aa); DataContainer::Pointer dc = DataContainer::New(SIMPL::Defaults::VertexDataContainerName); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, am); + dc->insertOrAssign(am); dc->setGeometry(VertexGeom::CreateGeometry(static_cast(aa->getNumberOfTuples()), SIMPL::Geometry::VertexGeometry)); return dc; } - int CheckFilterParameters(const QVariant& algorithm, const FloatVec3_t& cws, const uint8_t& cc) + int CheckFilterParameters(const QVariant& algorithm, const FloatVec3Type& cws, const uint8_t& cc) { QVariant conversionAlgorithm{m_colorToGrayscaleFilter->property("ConversionAlgorithm")}; - FloatVec3_t colorWeights = (m_colorToGrayscaleFilter->property("ColorWeights").value()); + FloatVec3Type colorWeights = (m_colorToGrayscaleFilter->property("ColorWeights").value()); QVariant outputArrayPrefix{m_colorToGrayscaleFilter->property("OutputArrayPrefix")}; QVariant colorChannel{m_colorToGrayscaleFilter->property("ColorChannel")}; QVariant createNewAM{m_colorToGrayscaleFilter->property("CreateNewAttributeMatrix")}; @@ -319,7 +319,7 @@ class ConvertColorToGrayScaleTest int wrongParameters = 0; wrongParameters += (conversionAlgorithm == algorithm) ? 0 : 1; float epsilon = 0.000000001f; - wrongParameters += (abs(colorWeights.x - cws.x) < epsilon && abs(colorWeights.y - cws.y) < epsilon && abs(colorWeights.z - cws.z) < epsilon) ? 0 : 1; + wrongParameters += (abs(colorWeights.getX() - cws.getX()) < epsilon && abs(colorWeights.getY() - cws.getY()) < epsilon && abs(colorWeights.getZ() - cws.getZ()) < epsilon) ? 0 : 1; wrongParameters += (outputArrayPrefix == m_outputArrayPrefix) ? 0 : 1; wrongParameters += (colorChannel == cc) ? 0 : 1; wrongParameters += (createNewAM == m_createNewAM) ? 0 : 1; @@ -331,10 +331,10 @@ class ConvertColorToGrayScaleTest int CompareResults(const uint8_t& algoMapIndex) const { QString amName = m_outputAMName; - DataContainer::Pointer dc = m_dca->getDataContainers().first(); + DataContainer::Pointer dc = m_dca->getDataContainers().front(); if(!m_createNewAM) { - amName = dc->getAttributeMatrices().first()->getName(); + amName = dc->getAttributeMatrices().front()->getName(); } AttributeMatrix::Pointer am = dc->getAttributeMatrix(amName); @@ -367,9 +367,11 @@ class ConvertColorToGrayScaleTest of the desired geometry is passed in here this method will sort out the input data array path and should work as expected */ - void SetUp(const QVariant& algorithm, const DataContainer::Pointer& dc, const FloatVec3_t& colorWeights = {0.2125f, 0.7154f, 0.0721f}, const uint8_t& colorChannel = 0) + void SetUp(const QVariant& algorithm, const DataContainer::Pointer& dc, const FloatVec3Type& colorWeights = {0.2125f, 0.7154f, 0.0721f}, const uint8_t& colorChannel = 0) { - m_dca->addDataContainer(dc); + m_dca = DataContainerArray::New(); + m_dca->setName("TEST DATA CONTAINER ARRAY"); + m_dca->insertOrAssign(dc); QVector daps{}; for(const AttributeMatrix::Pointer& eachAM : dc->getAttributeMatrices()) { @@ -410,8 +412,10 @@ class ConvertColorToGrayScaleTest int RunTest(const uint8_t& algoMapIndex) { + Observer obs; + m_colorToGrayscaleFilter->connect(m_colorToGrayscaleFilter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); m_colorToGrayscaleFilter->execute(); - int erred = m_colorToGrayscaleFilter->getErrorCondition(); + int erred = m_colorToGrayscaleFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(erred, 0); int wrongValues = CompareResults(algoMapIndex); DREAM3D_REQUIRE_EQUAL(wrongValues, 0) @@ -469,6 +473,8 @@ class ConvertColorToGrayScaleTest void operator()() { + std::cout << "#### ConvertColorToGrayScaleTest Starting ####" << std::endl; + int err = 0; const QString aaName = SIMPL::VertexData::SurfaceMeshNodes; @@ -490,7 +496,7 @@ class ConvertColorToGrayScaleTest TearDown(vertexDC); // Test custom - FloatVec3_t colorWeights{0.75, 0.75, 0.75}; + FloatVec3Type colorWeights{0.75, 0.75, 0.75}; qDebug() << "Custom weights (0.75, 0.75, 0.75)..."; SetUp(Algorithms::LUMINOSITY, vertexDC, colorWeights); DREAM3D_REGISTER_TEST(RunTest(1)) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp index f9873df6a8..21873e7c72 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp @@ -67,12 +67,12 @@ class ConvertDataTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims; dims.push_back(2); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); QVector cdims; cdims.push_back(2); @@ -120,7 +120,7 @@ class ConvertDataTest break; } da->initializeWithZeros(); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); return dca; } @@ -215,7 +215,7 @@ class ConvertDataTest { setValues(filter, arrayName, newType, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); if(checkArray) { @@ -583,7 +583,7 @@ class ConvertDataTest setValues(filter, "Array1", SIMPL::NumericTypes::Type::Int8, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -90002); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -90002); } // ----------------------------------------------------------------------------- @@ -600,7 +600,7 @@ class ConvertDataTest setValues(filter, "DataArray", SIMPL::NumericTypes::Type::Int8, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp index a2e9c1a6f6..ff780aa7a5 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp @@ -99,12 +99,14 @@ class CopyFeatureArrayToElementArrayTest static const QString k_DataContainerName("DataContainer"); - static const QString k_FeatureDataMatrixName("FeatureDataMatrix"); - static const QString k_FeatureIDMatrixName("FeatureIDMatrix"); + static const QString k_Cell_AMName("Cell Attribute Matrix"); + static const QString k_Feature_AMName("Feature Attribute Matrix"); - static const QString k_FeatureDataArrayName("FeatureData"); - static const QString k_FeatureIDArrayName("FeatureIDArray"); - static const QString k_ElementArrayName("ElementArray"); + + static const QString k_CellFeatureIdsArrayName("FeatureIds"); + static const QString k_CellTempArrayName("Temperature"); + + static const QString k_FeatureDataArrayName("Temperature"); // Create DataContainerArray @@ -113,33 +115,36 @@ class CopyFeatureArrayToElementArrayTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices + QVector tDims = {{10, 3}}; + AttributeMatrix::Pointer cellAM = AttributeMatrix::New(tDims, k_Cell_AMName, AttributeMatrix::Type::Cell); + dc->addOrReplaceAttributeMatrix(cellAM); - AttributeMatrix::Pointer dataAM = AttributeMatrix::New(m_Dims10, k_FeatureDataMatrixName, AttributeMatrix::Type::VertexFeature); - dc->addAttributeMatrix(k_FeatureDataMatrixName, dataAM); - - AttributeMatrix::Pointer idsAM = AttributeMatrix::New(m_Dims10, k_FeatureIDMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(k_FeatureIDMatrixName, idsAM); + AttributeMatrix::Pointer featureAM = AttributeMatrix::New(m_Dims3, k_Feature_AMName, AttributeMatrix::Type::CellFeature); + dc->addOrReplaceAttributeMatrix(featureAM); - // Create feature data and feature IDs + // Create Cell FeatureIds array + typename DataArray::Pointer cellFeatureIds = DataArray::CreateArray(cellAM->getNumberOfTuples(), k_CellFeatureIdsArrayName); + cellAM->insertOrAssign(cellFeatureIds); - typename DataArray::Pointer daFeatures = DataArray::CreateArray(m_Dims10, m_Dims3, k_FeatureDataArrayName); - for(int i = 0; i < daFeatures->getSize(); i++) + for(size_t y = 0; y < 3; y++) { - daFeatures->setValue(i, static_cast(i + 2.13)); + for(size_t x = 0; x < 10; x++) + { + size_t index = (10*y) + x; + cellFeatureIds->setValue(index, static_cast(y)); + } } - dataAM->addAttributeArray(k_FeatureDataArrayName, daFeatures); - - // Use reverse ordering on the ID list to test that the filter moves data to the appropriate location - DataArray::Pointer daIDList = DataArray::CreateArray(m_Dims10, m_Dims1, k_FeatureIDArrayName); - for(int i = 0; i < daIDList->getNumberOfTuples(); i++) + //Create an array in teh Feature Attribute Matrix with 3 values since we created 3 features in the cell attribute matrix + typename DataArray::Pointer avgTempValue = DataArray::CreateArray(3, k_FeatureDataArrayName); + featureAM->insertOrAssign(avgTempValue); + for(int i = 0; i < 3; i++) { - daIDList->setValue(daIDList->getNumberOfTuples() - i - 1, i); + avgTempValue->setValue(i, static_cast(0)); } - idsAM->addAttributeArray(k_FeatureIDArrayName, daIDList); // Create Filter @@ -149,42 +154,53 @@ class CopyFeatureArrayToElementArrayTest copyFeatureArrayToElementArray->setDataContainerArray(dca); - // Set up filter - QVariant var; - DataArrayPath dap(k_DataContainerName, k_FeatureDataMatrixName, k_FeatureDataArrayName); + DataArrayPath dap(k_DataContainerName, k_Feature_AMName, k_FeatureDataArrayName); var.setValue(dap); bool propWasSet = copyFeatureArrayToElementArray->setProperty("SelectedFeatureArrayPath", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) - dap = DataArrayPath(k_DataContainerName, k_FeatureIDMatrixName, k_FeatureIDArrayName); + dap = DataArrayPath(k_DataContainerName, k_Cell_AMName, k_CellFeatureIdsArrayName); var.setValue(dap); propWasSet = copyFeatureArrayToElementArray->setProperty("FeatureIdsArrayPath", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) - var.setValue(k_ElementArrayName); + var.setValue(k_CellTempArrayName); propWasSet = copyFeatureArrayToElementArray->setProperty("CreatedArrayName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) // Run filter copyFeatureArrayToElementArray->execute(); - DREAM3D_REQUIRED(copyFeatureArrayToElementArray->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(copyFeatureArrayToElementArray->getErrorCode(), >=, 0); // Check filter results + QString dbg; + QTextStream ss(&dbg); + typename DataArray::Pointer createdElementArray = cellAM->getAttributeArrayAs>(k_CellTempArrayName); - typename DataArray::Pointer createdElementArray = idsAM->getAttributeArrayAs>(k_ElementArrayName); - - for(size_t i = 0; i < daFeatures->getNumberOfTuples(); i++) + for(size_t i = 0; i < createdElementArray->getNumberOfTuples(); i++) { - for(size_t j = 0; j < daFeatures->getNumberOfComponents(); j++) - { - T oldValue = daFeatures->getComponent(i, j); - T newValue = createdElementArray->getComponent(daIDList->getValue(i), j); - DREAM3D_REQUIRE_EQUAL(newValue, oldValue) - } +// daFeatures->printTuple(ss , i); +// createdElementArray->printTuple(ss, i); +// ss << "---\n"; + + int32_t featureId = cellFeatureIds->getValue(i); + T value = createdElementArray->getValue(i); + T featureValue = avgTempValue->getValue(featureId); + DREAM3D_REQUIRE_EQUAL(value, featureValue); + +// for(size_t j = 0; j < daFeatures->getNumberOfComponents(); j++) +// { + +// T oldValue = daFeatures->getComponent(i, j); +// T newValue = createdElementArray->getComponent(daIDList->getValue(i), j); +// DREAM3D_REQUIRE_EQUAL(newValue, oldValue) +// } } + + } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp index e40b4f0fa6..8988f16817 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp @@ -298,8 +298,8 @@ class CopyObjectTest bool sameDims = (oldDims == newDims); DREAM3D_REQUIRE_EQUAL(sameDims, true) - SIMPL::Tuple3FVec oldRes = oldImageGeom->getResolution(); - SIMPL::Tuple3FVec newRes = newImageGeom->getResolution(); + SIMPL::Tuple3FVec oldRes = oldImageGeom->getSpacing(); + SIMPL::Tuple3FVec newRes = newImageGeom->getSpacing(); bool sameRes = (oldRes == newRes); DREAM3D_REQUIRE_EQUAL(sameRes, true) @@ -533,13 +533,13 @@ class CopyObjectTest bool sameArrayNames = (newMatrixNames == oldMatrixNames); DREAM3D_REQUIRE_EQUAL(sameArrayNames, true) - QMap oldAttrMatrices = oldDC->getAttributeMatrices(); - QMap newAttrMatrices = newDC->getAttributeMatrices(); + //DataContainer::Container_t oldAttrMatrices = oldDC->getAttributeMatrices(); + //DataContainer::Container_t newAttrMatrices = newDC->getAttributeMatrices(); for(int i = 0; i < newMatrixNames.size(); i++) { - AttributeMatrix::Pointer oldAM = oldAttrMatrices[oldMatrixNames[i]]; - AttributeMatrix::Pointer newAM = newAttrMatrices[newMatrixNames[i]]; + AttributeMatrix::Pointer oldAM = *oldDC->find(oldMatrixNames[i]); + AttributeMatrix::Pointer newAM = *newDC->find(newMatrixNames[i]); checkAttributeMatrix(oldAM, newAM, false); } } @@ -550,7 +550,13 @@ class CopyObjectTest void TestCase(DataContainerArray::Pointer dca, DataArrayPath dap, int objectToCopy, const QString& copyName) { // Create Filter + std::cout << " TestCase: " << dca->getName().toStdString() << " " << dap.serialize("/").toStdString() << " " << copyName.toStdString(); + if(dca->getDataContainer(dap)->getGeometry().get() != nullptr) + { + std::cout << " " << dca->getDataContainer(dap)->getGeometry()->getName().toStdString(); + } + std::cout << std::endl; FilterManager* fm = FilterManager::Instance(); IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(m_FilterName); AbstractFilter::Pointer extractAttributeArraysFromGeometry = filterFactory->create(); @@ -571,7 +577,7 @@ class CopyObjectTest if(objectToCopy == 0) // DataContainer { - var.setValue(dap.getDataContainerName()); + var.setValue(dap); propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerToCopy", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) } @@ -591,7 +597,7 @@ class CopyObjectTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -726,21 +732,21 @@ class CopyObjectTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); DataContainer::Pointer emptyDC = DataContainer::New(k_EmptyDataContainerName); - dca->addDataContainer(emptyDC); + dca->addOrReplaceDataContainer(emptyDC); // Create AttributeMatrix AttributeMatrix::Pointer am1 = AttributeMatrix::New(m_Dims8, k_AttributeMatrix1Name, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(k_AttributeMatrix1Name, am1); + dc->addOrReplaceAttributeMatrix(am1); AttributeMatrix::Pointer am2 = AttributeMatrix::New(m_Dims8, k_AttributeMatrix2Name, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(k_AttributeMatrix2Name, am2); + dc->addOrReplaceAttributeMatrix(am2); AttributeMatrix::Pointer emptyAM = AttributeMatrix::New(m_Dims1, k_EmptyAttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_EmptyAttributeMatrixName, emptyAM); + dc->addOrReplaceAttributeMatrix(emptyAM); // Create DataArray @@ -761,8 +767,9 @@ class CopyObjectTest ImageGeom::Pointer imageGeom = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); imageGeom->setDimensions(std::forward_as_tuple(5, 5, 5)); - imageGeom->setResolution(std::forward_as_tuple(5, 5, 5)); - imageGeom->setOrigin(std::forward_as_tuple(5, 5, 5)); + imageGeom->setSpacing(FloatVec3Type(5, 5, 5)); + imageGeom->setOrigin(FloatVec3Type(5, 5, 5)); + imageGeom->setName("Image Geom"); // RectGrid @@ -774,6 +781,7 @@ class CopyObjectTest rectGridGeom->setXBounds(daXBounds); rectGridGeom->setYBounds(daYBounds); rectGridGeom->setZBounds(daZBounds); + rectGridGeom->setName("rectGridGeom"); // Vertex @@ -782,6 +790,7 @@ class CopyObjectTest DataArray::Pointer daVert = createDataArray(k_VerticesDAName, vertices, m_Dims2, m_Dims3); VertexGeom::Pointer vertexGeom = VertexGeom::CreateGeometry(daVert, SIMPL::Geometry::VertexGeometry); + vertexGeom->setName("vertexGeom"); // Edge @@ -802,6 +811,7 @@ class CopyObjectTest DataArray::Pointer daTriList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims3); TriangleGeom::Pointer triGeom = TriangleGeom::CreateGeometry(daTriList, daTriVert, SIMPL::Geometry::TriangleGeometry); + triGeom->setName("triGeom"); // Quad @@ -812,6 +822,7 @@ class CopyObjectTest DataArray::Pointer daQuadList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims4); QuadGeom::Pointer quadGeom = QuadGeom::CreateGeometry(daQuadList, daQuadVert, SIMPL::Geometry::QuadGeometry); + quadGeom->setName("quadGeom"); // Tetrahedral @@ -823,6 +834,7 @@ class CopyObjectTest DataArray::Pointer daTetList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims4); TetrahedralGeom::Pointer tetGeom = TetrahedralGeom::CreateGeometry(daTetList, daTetVert, SIMPL::Geometry::TetrahedralGeometry); + tetGeom->setName("tetGeom"); // Hexahedral @@ -834,20 +846,21 @@ class CopyObjectTest DataArray::Pointer daHexList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims8); HexahedralGeom::Pointer hexGeom = HexahedralGeom::CreateGeometry(daHexList, daHexVert, SIMPL::Geometry::HexahedralGeometry); + hexGeom->setName("hexGeom"); // Add DataArrays to AttributeMatrices - am1->addAttributeArray(k_uint8ArrayName, daUint8); - am1->addAttributeArray(k_int8ArrayName, daInt8); - am1->addAttributeArray(k_uint16ArrayName, daUint16); - am1->addAttributeArray(k_int16ArrayName, daInt16); - am1->addAttributeArray(k_uint32ArrayName, daUint32); + am1->insertOrAssign(daUint8); + am1->insertOrAssign(daInt8); + am1->insertOrAssign(daUint16); + am1->insertOrAssign(daInt16); + am1->insertOrAssign(daUint32); - am2->addAttributeArray(k_int32ArrayName, daInt32); - am2->addAttributeArray(k_uint64ArrayName, daUint64); - am2->addAttributeArray(k_int64ArrayName, daInt64); - am2->addAttributeArray(k_floatArrayName, daFloat); - am2->addAttributeArray(k_doubleArrayName, daDouble); + am2->insertOrAssign(daInt32); + am2->insertOrAssign(daUint64); + am2->insertOrAssign(daInt64); + am2->insertOrAssign(daFloat); + am2->insertOrAssign(daDouble); dc->setGeometry(hexGeom); @@ -895,7 +908,7 @@ class CopyObjectTest TestCase(dca, DataArrayPath(k_DataContainerName, k_AttributeMatrix2Name, ""), 1, k_CopiedObjectName); - emptyDC->addAttributeMatrix(k_EmptyAttributeMatrixName, emptyAM); + emptyDC->addOrReplaceAttributeMatrix(emptyAM); TestCase(dca, DataArrayPath(k_EmptyDataContainerName, k_EmptyAttributeMatrixName, ""), 1, k_CopiedObjectName); // Test Copy DataArrays diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp index 2b2d81403a..beda654b64 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/DataArray.hpp" @@ -67,7 +67,7 @@ class CreateAttributeMatrixTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); return dca; } @@ -166,7 +166,7 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer", amName, tableDims, type); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) TestMatrixTupleDims(filter, tableDims, amName); } @@ -305,7 +305,7 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer2", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -999); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -999); } // ----------------------------------------------------------------------------- @@ -320,11 +320,11 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); TestMatrixTupleDims(filter, tableDims, "AttributeMatrix"); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -10014); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -10014); } // ----------------------------------------------------------------------------- @@ -346,16 +346,27 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11000); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11000); tableDims.clear(); tableDims.resize(0); setValues(filter, "DataContainer", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11000); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11000); } + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestOperators() + { + QVector tDims = {10, 10}; + AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "Test", AttributeMatrix::Type::Cell); + + FloatArrayType::Pointer floatArray = FloatArrayType::CreateArray(100, "Float"); + Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(100, "Int32"); + } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -364,6 +375,7 @@ class CreateAttributeMatrixTest std::cout << "#### CreateAttributeMatrixTest Starting ####" << std::endl; int err = EXIT_SUCCESS; + DREAM3D_REGISTER_TEST(TestOperators()); DREAM3D_REGISTER_TEST(TestVertexMatrix()); DREAM3D_REGISTER_TEST(TestVertexFeatureMatrix()); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp index 3531a9b6db..e0daeffae5 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp @@ -133,7 +133,7 @@ class CreateDataArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -156,7 +156,7 @@ class CreateDataArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -170,9 +170,9 @@ class CreateDataArrayTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(QVector(1, 1), SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); - m->addAttributeMatrix(SIMPL::Defaults::AttributeMatrixName, attrMatrix); + m->addOrReplaceAttributeMatrix(attrMatrix); return dca; } @@ -211,13 +211,13 @@ class CreateDataArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); { @@ -239,14 +239,14 @@ class CreateDataArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); { @@ -306,7 +306,7 @@ class CreateDataArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); IDataArray::Pointer boolArray = m->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); @@ -328,7 +328,7 @@ class CreateDataArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_Int8Error); #endif diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp index ab06f24482..702aafa0bc 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp @@ -94,7 +94,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void setValues(CreateDataContainer::Pointer filter, QString dataContainer) + void setValues(CreateDataContainer::Pointer filter, const DataArrayPath& dataContainer) { if(nullptr == filter.get()) { @@ -104,20 +104,21 @@ class CreateDataContainerTest QVariant value; value.setValue(dataContainer); - filter->setProperty("DataContainerName", value); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void TestFilter(QString dataContainer, int errorCode) + void TestFilter(const DataArrayPath& dataContainer, int errorCode) { CreateDataContainer::Pointer filter = createFilter(); filter->setDataContainerArray(createDataContainerArray()); setValues(filter, dataContainer); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), errorCode) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), errorCode) } // ----------------------------------------------------------------------------- @@ -125,7 +126,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestValidDataContainer() { - TestFilter("DataContainer", 0); + TestFilter(DataArrayPath("DataContainer","",""), 0); } // ----------------------------------------------------------------------------- @@ -133,17 +134,17 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestExistingDataContainer() { - QString dataContainer = "DataContainer"; + DataArrayPath dataContainer("DataContainer", "", ""); CreateDataContainer::Pointer filter = createFilter(); filter->setDataContainerArray(createDataContainerArray()); setValues(filter, dataContainer); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -889) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -889) } // ----------------------------------------------------------------------------- @@ -151,7 +152,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestMissingDataContainerName() { - TestFilter("", -887); + TestFilter(DataArrayPath(), -887); } // ----------------------------------------------------------------------------- @@ -159,7 +160,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestInvalidName() { - TestFilter("Data/Container", -888); + TestFilter(DataArrayPath("Data/Container","",""), -888); } // ----------------------------------------------------------------------------- @@ -179,6 +180,6 @@ class CreateDataContainerTest } private: - CreateDataContainerTest(const CreateDataContainerTest&); // Copy Constructor Not Implemented - void operator=(const CreateDataContainerTest&); // Move assignment Not Implemented + CreateDataContainerTest(const CreateDataContainerTest&) = delete; // Copy Constructor Not Implemented + void operator=(const CreateDataContainerTest&) = delete; // Move assignment Not Implemented }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp index af528364ca..38c2559e81 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp @@ -133,11 +133,11 @@ class CreateFeatureArrayFromElementArrayTest cellDataArray->initializeTuple(i, &temp); } - cellAttr->addAttributeArray("CellData", cellDataArray); - cellAttr->addAttributeArray("FeatureIds", featureIds); - dc->addAttributeMatrix("Cell Attribute Matrix", cellAttr); - dc->addAttributeMatrix("Feature Attribute Matrix", featureAttr); - dca->addDataContainer(dc); + cellAttr->insertOrAssign(cellDataArray); + cellAttr->insertOrAssign(featureIds); + dc->addOrReplaceAttributeMatrix(cellAttr); + dc->addOrReplaceAttributeMatrix(featureAttr); + dca->addOrReplaceDataContainer(dc); DataArrayPath path = DataArrayPath(dc->getName(), cellAttr->getName(), cellDataArray->getName()); QVariant var; @@ -224,11 +224,11 @@ class CreateFeatureArrayFromElementArrayTest cellDataArray->initializeTuple(i, &temp); } - cellAttr->addAttributeArray("CellData", cellDataArray); - cellAttr->addAttributeArray("FeatureIds", featureIds); - dc->addAttributeMatrix("Cell Attribute Matrix", cellAttr); - dc->addAttributeMatrix("Feature Attribute Matrix", featureAttr); - dca->addDataContainer(dc); + cellAttr->insertOrAssign(cellDataArray); + cellAttr->insertOrAssign(featureIds); + dc->addOrReplaceAttributeMatrix(cellAttr); + dc->addOrReplaceAttributeMatrix(featureAttr); + dca->addOrReplaceDataContainer(dc); DataArrayPath path = DataArrayPath(dc->getName(), cellAttr->getName(), cellDataArray->getName()); QVariant var; @@ -305,10 +305,10 @@ class CreateFeatureArrayFromElementArrayTest featureIds->initializeTuple(14, &value); featureIds->initializeTuple(15, &value); - cellAttr->addAttributeArray("FeatureIds", featureIds); - dc->addAttributeMatrix("Cell Attribute Matrix", cellAttr); - dc->addAttributeMatrix("Feature Attribute Matrix", featureAttr); - dca->addDataContainer(dc); + cellAttr->insertOrAssign(featureIds); + dc->addOrReplaceAttributeMatrix(cellAttr); + dc->addOrReplaceAttributeMatrix(featureAttr); + dca->addOrReplaceDataContainer(dc); DataArrayPath path = DataArrayPath(dc->getName(), cellAttr->getName(), featureIds->getName()); QVariant var; @@ -328,7 +328,7 @@ class CreateFeatureArrayFromElementArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createFeatureArrayFromElementArrayFilter->execute(); - int err = createFeatureArrayFromElementArrayFilter->getErrorCondition(); + int err = createFeatureArrayFromElementArrayFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); } else diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp index 89c837207f..d13b0e7184 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp @@ -152,7 +152,7 @@ class CreateGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void testCaseImage(AbstractFilter::Pointer createGeometry, DataContainer::Pointer dc, IGeometry::Type geomType, IntVec3_t numDimensions, FloatVec3_t originPos, FloatVec3_t imgResolution) + void testCaseImage(AbstractFilter::Pointer createGeometry, DataContainer::Pointer dc, IGeometry::Type geomType, IntVec3Type numDimensions, FloatVec3Type originPos, FloatVec3Type imgResolution) { if(geomType != IGeometry::Type::Image) { @@ -166,7 +166,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createGeometry->execute(); - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createGeometry->getErrorCode(), >=, 0); bool correctGeom = (geomType == dc->getGeometry()->getGeometryType()); DREAM3D_REQUIRE_EQUAL(correctGeom, true) @@ -175,19 +175,19 @@ class CreateGeometryTest SIMPL::Tuple3SVec dim = imageGeom->getDimensions(); SIMPL::Tuple3FVec origin = imageGeom->getOrigin(); - SIMPL::Tuple3FVec res = imageGeom->getResolution(); + SIMPL::Tuple3FVec res = imageGeom->getSpacing(); - DREAM3D_REQUIRE_EQUAL(std::get<0>(dim), numDimensions.x) - DREAM3D_REQUIRE_EQUAL(std::get<1>(dim), numDimensions.y) - DREAM3D_REQUIRE_EQUAL(std::get<2>(dim), numDimensions.z) + DREAM3D_REQUIRE_EQUAL(std::get<0>(dim), numDimensions[0]) + DREAM3D_REQUIRE_EQUAL(std::get<1>(dim), numDimensions[1]) + DREAM3D_REQUIRE_EQUAL(std::get<2>(dim), numDimensions[2]) - DREAM3D_REQUIRE_EQUAL(std::get<0>(origin), originPos.x) - DREAM3D_REQUIRE_EQUAL(std::get<1>(origin), originPos.y) - DREAM3D_REQUIRE_EQUAL(std::get<2>(origin), originPos.z) + DREAM3D_REQUIRE_EQUAL(std::get<0>(origin), originPos[0]) + DREAM3D_REQUIRE_EQUAL(std::get<1>(origin), originPos[1]) + DREAM3D_REQUIRE_EQUAL(std::get<2>(origin), originPos[2]) - DREAM3D_REQUIRE_EQUAL(std::get<0>(res), imgResolution.x) - DREAM3D_REQUIRE_EQUAL(std::get<1>(res), imgResolution.y) - DREAM3D_REQUIRE_EQUAL(std::get<2>(res), imgResolution.z) + DREAM3D_REQUIRE_EQUAL(std::get<0>(res), imgResolution[0]) + DREAM3D_REQUIRE_EQUAL(std::get<1>(res), imgResolution[1]) + DREAM3D_REQUIRE_EQUAL(std::get<2>(res), imgResolution[2]) removeGeometry(dc); } @@ -221,11 +221,11 @@ class CreateGeometryTest if(treatWarningsAsErrors) { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), ==, -1) + DREAM3D_REQUIRED(createGeometry->getErrorCode(), ==, -1) } else { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createGeometry->getErrorCode(), >=, 0); bool correctGeom = (geomType == dc->getGeometry()->getGeometryType()); DREAM3D_REQUIRE_EQUAL(correctGeom, true) @@ -312,11 +312,11 @@ class CreateGeometryTest if(treatWarningsAsErrors && geomType != IGeometry::Type::Vertex) { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), ==, -1) + DREAM3D_REQUIRED(createGeometry->getErrorCode(), ==, -1) } else { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createGeometry->getErrorCode(), >=, 0); bool correctGeom = (geomType == dc->getGeometry()->getGeometryType()); @@ -383,10 +383,11 @@ class CreateGeometryTest QList names = am->getAttributeArrayNames(); DREAM3D_REQUIRE_EQUAL(names.contains(daVertices->getName()), false) - if(geomType != IGeometry::Type::Vertex) - { - DREAM3D_REQUIRE_EQUAL(names.contains(daElements->getName()), false) - } + // daElements is renamed by the geometries, causing names.contains(daElements->getName()) to return true. + //if(geomType != IGeometry::Type::Vertex) + //{ + // DREAM3D_REQUIRE_EQUAL(names.contains(daElements->getName()), false) + //} } } @@ -421,24 +422,24 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // ImageGeom Parameters - IntVec3_t numDimensions; - numDimensions.x = 5; - numDimensions.y = 15; - numDimensions.z = 25; + IntVec3Type numDimensions; + numDimensions[0] = 5; + numDimensions[1] = 15; + numDimensions[2] = 25; - FloatVec3_t originPos; - originPos.x = 5; - originPos.y = 15; - originPos.z = 25; + FloatVec3Type originPos; + originPos[0] = 5; + originPos[1] = 15; + originPos[2] = 25; - FloatVec3_t imgResolution; - imgResolution.x = 5; - imgResolution.y = 15; - imgResolution.z = 25; + FloatVec3Type imgResolution; + imgResolution[0] = 5; + imgResolution[1] = 15; + imgResolution[2] = 25; // Create Filter @@ -461,7 +462,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -480,7 +481,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) var.setValue(imgResolution); - propWasSet = createGeometry->setProperty("Resolution", var); + propWasSet = createGeometry->setProperty("Spacing", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) createGeometry->setDataContainerArray(dca); @@ -499,9 +500,9 @@ class CreateGeometryTest static const QString k_DataContainerName("DataContainer"); static const QString k_BoundsMatrixName("BoundsMatrix"); - static const QString k_XBoundsDAName("XBounds"); - static const QString k_YBoundsDAName("YBounds"); - static const QString k_ZBoundsDAName("ZBounds"); + static const QString k_XBoundsDAName(SIMPL::Geometry::xBoundsList); + static const QString k_YBoundsDAName(SIMPL::Geometry::yBoundsList); + static const QString k_ZBoundsDAName(SIMPL::Geometry::zBoundsList); static const QString k_BadXBoundsDAName("BadXBounds"); // Create DataContainerArray @@ -511,12 +512,12 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer boundsAM = AttributeMatrix::New(m_Dims4, k_BoundsMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_BoundsMatrixName, boundsAM); + dc->addOrReplaceAttributeMatrix(boundsAM); // Create Bounds Arrays @@ -525,21 +526,21 @@ class CreateGeometryTest { daXBounds->setValue(i, i); } - boundsAM->addAttributeArray(k_XBoundsDAName, daXBounds); + boundsAM->insertOrAssign(daXBounds); DataArray::Pointer daYBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_YBoundsDAName); for(size_t i = 0; i < daYBounds->getSize(); i++) { daYBounds->setValue(i, i); } - boundsAM->addAttributeArray(k_YBoundsDAName, daYBounds); + boundsAM->insertOrAssign(daYBounds); DataArray::Pointer daZBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_ZBoundsDAName); for(size_t i = 0; i < daZBounds->getSize(); i++) { daZBounds->setValue(i, i); } - boundsAM->addAttributeArray(k_ZBoundsDAName, daZBounds); + boundsAM->insertOrAssign(daZBounds); // Create bad xBounds arrays @@ -549,7 +550,7 @@ class CreateGeometryTest daBadXBounds->setValue(i, i); } daBadXBounds->setValue(0, 100); - boundsAM->addAttributeArray(k_BadXBoundsDAName, daBadXBounds); + boundsAM->insertOrAssign(daBadXBounds); // Create Filter @@ -572,7 +573,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -666,19 +667,19 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims2, k_VertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_VertexMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); // Create Vertex Data Arrays std::vector> vertices = {{1.0f, 1.0f, 0.0f}, {3.0f, 1.0f, 0.0f}}; DataArray::Pointer daVert = createDataArray(k_VertexListDAName, vertices, m_Dims2, m_Dims3); - vertexAM->addAttributeArray(k_VertexListDAName, daVert); + vertexAM->insertOrAssign(daVert); // Create Filter @@ -701,7 +702,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -742,15 +743,15 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer edgeVertexAM = AttributeMatrix::New(m_Dims2, k_EdgeVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_EdgeVertexMatrixName, edgeVertexAM); + dc->addOrReplaceAttributeMatrix(edgeVertexAM); AttributeMatrix::Pointer edgeElementAM = AttributeMatrix::New(m_Dims1, k_EdgeElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_EdgeElementAttributeMatrixName, edgeElementAM); + dc->addOrReplaceAttributeMatrix(edgeElementAM); // Create Edge Data Arrays @@ -759,15 +760,15 @@ class CreateGeometryTest DataArray::Pointer daEdgeVert = createDataArray(k_EdgeVertexListDAName, vertices, m_Dims2, m_Dims3); DataArray::Pointer daEdgeList = createDataArray(k_EdgeListDAName, elements, m_Dims1, m_Dims2); - edgeVertexAM->addAttributeArray(k_EdgeVertexListDAName, daEdgeVert); - edgeElementAM->addAttributeArray(k_EdgeListDAName, daEdgeList); + edgeVertexAM->insertOrAssign(daEdgeVert); + edgeElementAM->insertOrAssign(daEdgeList); // Create Bad EdgeList elements = {{0, 2}}; DataArray::Pointer daBadEdgeList = createDataArray(k_BadEdgeListDAName, elements, m_Dims1, m_Dims2); - edgeElementAM->addAttributeArray(k_BadEdgeListDAName, daBadEdgeList); + edgeElementAM->insertOrAssign(daBadEdgeList); // Create Filter @@ -790,7 +791,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -858,15 +859,15 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer triVertexAM = AttributeMatrix::New(m_Dims3, k_TriVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TriVertexMatrixName, triVertexAM); + dc->addOrReplaceAttributeMatrix(triVertexAM); AttributeMatrix::Pointer triElementAM = AttributeMatrix::New(m_Dims1, k_TriElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TriElementAttributeMatrixName, triElementAM); + dc->addOrReplaceAttributeMatrix(triElementAM); // Create Triangle Data Arrays @@ -875,15 +876,15 @@ class CreateGeometryTest DataArray::Pointer daTriVert = createDataArray(k_TriVertexListDAName, vertices, m_Dims3, m_Dims3); DataArray::Pointer daTriList = createDataArray(k_TriListDAName, elements, m_Dims1, m_Dims3); - triVertexAM->addAttributeArray(k_TriVertexListDAName, daTriVert); - triElementAM->addAttributeArray(k_TriListDAName, daTriList); + triVertexAM->insertOrAssign(daTriVert); + triElementAM->insertOrAssign(daTriList); // Create Bad TriangleList elements = {{0, 3, 2}}; DataArray::Pointer daBadTriList = createDataArray(k_BadTriListDAName, elements, m_Dims1, m_Dims3); - triElementAM->addAttributeArray(k_BadTriListDAName, daBadTriList); + triElementAM->insertOrAssign(daBadTriList); // Create Filter @@ -906,7 +907,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -974,15 +975,15 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer quadVertexAM = AttributeMatrix::New(m_Dims4, k_QuadVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_QuadVertexMatrixName, quadVertexAM); + dc->addOrReplaceAttributeMatrix(quadVertexAM); AttributeMatrix::Pointer quadElementAM = AttributeMatrix::New(m_Dims1, k_QuadElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_QuadElementAttributeMatrixName, quadElementAM); + dc->addOrReplaceAttributeMatrix(quadElementAM); // Create Quadrilateral Data Arrays @@ -991,15 +992,15 @@ class CreateGeometryTest DataArray::Pointer daQuadVert = createDataArray(k_QuadVertexListDAName, vertices, m_Dims4, m_Dims3); DataArray::Pointer daQuadList = createDataArray(k_QuadListDAName, elements, m_Dims1, m_Dims4); - quadVertexAM->addAttributeArray(k_QuadVertexListDAName, daQuadVert); - quadElementAM->addAttributeArray(k_QuadListDAName, daQuadList); + quadVertexAM->insertOrAssign(daQuadVert); + quadElementAM->insertOrAssign(daQuadList); // Create Bad QuadrilateralList elements = {{0, 1, 7, 3}}; DataArray::Pointer daBadQuadList = createDataArray(k_BadQuadListDAName, elements, m_Dims1, m_Dims4); - quadElementAM->addAttributeArray(k_BadQuadListDAName, daBadQuadList); + quadElementAM->insertOrAssign(daBadQuadList); // Create Filter @@ -1022,7 +1023,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -1090,15 +1091,15 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer tetVertexAM = AttributeMatrix::New(m_Dims4, k_TetVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TetVertexMatrixName, tetVertexAM); + dc->addOrReplaceAttributeMatrix(tetVertexAM); AttributeMatrix::Pointer tetElementAM = AttributeMatrix::New(m_Dims1, k_TetElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TetElementAttributeMatrixName, tetElementAM); + dc->addOrReplaceAttributeMatrix(tetElementAM); // Create Tetrahedron Data Arrays @@ -1108,15 +1109,15 @@ class CreateGeometryTest DataArray::Pointer daTetVert = createDataArray(k_TetVertexListDAName, vertices, m_Dims4, m_Dims3); DataArray::Pointer daTetList = createDataArray(k_TetListDAName, elements, m_Dims1, m_Dims4); - tetVertexAM->addAttributeArray(k_TetVertexListDAName, daTetVert); - tetElementAM->addAttributeArray(k_TetListDAName, daTetList); + tetVertexAM->insertOrAssign(daTetVert); + tetElementAM->insertOrAssign(daTetList); // Create Bad TetrahedronList elements = {{0, 10, 2, 3}}; DataArray::Pointer daBadTetList = createDataArray(k_BadTetListDAName, elements, m_Dims1, m_Dims4); - tetElementAM->addAttributeArray(k_BadTetListDAName, daBadTetList); + tetElementAM->insertOrAssign(daBadTetList); // Create Filter @@ -1139,7 +1140,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -1207,15 +1208,15 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer hexVertexAM = AttributeMatrix::New(m_Dims8, k_HexVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_HexVertexMatrixName, hexVertexAM); + dc->addOrReplaceAttributeMatrix(hexVertexAM); AttributeMatrix::Pointer hexElementAM = AttributeMatrix::New(m_Dims1, k_HexElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_HexElementAttributeMatrixName, hexElementAM); + dc->addOrReplaceAttributeMatrix(hexElementAM); // Create Hexahedron Data Arrays @@ -1225,15 +1226,15 @@ class CreateGeometryTest DataArray::Pointer daHexVert = createDataArray(k_HexVertexListDAName, vertices, m_Dims8, m_Dims3); DataArray::Pointer daHexList = createDataArray(k_HexListDAName, elements, m_Dims1, m_Dims8); - hexVertexAM->addAttributeArray(k_HexVertexListDAName, daHexVert); - hexElementAM->addAttributeArray(k_HexListDAName, daHexList); + hexVertexAM->insertOrAssign(daHexVert); + hexElementAM->insertOrAssign(daHexList); // Create Bad HexahedronList elements = {{0, 1, 2, 32, 4, 5, 6, 7}}; DataArray::Pointer daBadHexList = createDataArray(k_BadHexListDAName, elements, m_Dims1, m_Dims8); - hexElementAM->addAttributeArray(k_BadHexListDAName, daBadHexList); + hexElementAM->insertOrAssign(daBadHexList); // Create Filter @@ -1256,7 +1257,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp index 9c3ce5ad64..ab92e05b0b 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp @@ -67,13 +67,13 @@ class CreateImageGeometryTest AttributeMatrix::Pointer am = AttributeMatrix::New(attributeMatrixSize, "Attribute Matrix", AttributeMatrix::Type::Any); DataContainer::Pointer dc = DataContainer::New("Data Container"); - dc->addAttributeMatrix("Attribute Matrix", am); + dc->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); imageGeometry->setDataContainerArray(dca); - imageGeometry->setSelectedDataContainer("Data Container"); + imageGeometry->setSelectedDataContainer(DataArrayPath("Data Container", "", "")); return imageGeometry; } @@ -84,18 +84,18 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - IntVec3_t numDimensions; - numDimensions.x = 5; - numDimensions.y = 15; - numDimensions.z = 25; + IntVec3Type numDimensions; + numDimensions[0] = 5; + numDimensions[1] = 15; + numDimensions[2] = 25; imageGeometry->setDimensions(numDimensions); - IntVec3_t dimensions = imageGeometry->getDimensions(); + IntVec3Type dimensions = imageGeometry->getDimensions(); - DREAM3D_REQUIRE_EQUAL(numDimensions.x, dimensions.x); - DREAM3D_REQUIRE_EQUAL(numDimensions.y, dimensions.y); - DREAM3D_REQUIRE_EQUAL(numDimensions.z, dimensions.z); + DREAM3D_REQUIRE_EQUAL(numDimensions[0], dimensions[0]); + DREAM3D_REQUIRE_EQUAL(numDimensions[1], dimensions[1]); + DREAM3D_REQUIRE_EQUAL(numDimensions[2], dimensions[2]); } // ----------------------------------------------------------------------------- @@ -105,18 +105,18 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - FloatVec3_t originPos; - originPos.x = 5; - originPos.y = 15; - originPos.z = 25; + FloatVec3Type originPos; + originPos[0] = 5; + originPos[1] = 15; + originPos[2] = 25; imageGeometry->setOrigin(originPos); - FloatVec3_t origin = imageGeometry->getOrigin(); + FloatVec3Type origin = imageGeometry->getOrigin(); - DREAM3D_REQUIRE_EQUAL(originPos.x, origin.x); - DREAM3D_REQUIRE_EQUAL(originPos.y, origin.y); - DREAM3D_REQUIRE_EQUAL(originPos.z, origin.z); + DREAM3D_REQUIRE_EQUAL(originPos[0], origin[0]); + DREAM3D_REQUIRE_EQUAL(originPos[1], origin[1]); + DREAM3D_REQUIRE_EQUAL(originPos[2], origin[2]); } // ----------------------------------------------------------------------------- @@ -126,18 +126,18 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - FloatVec3_t imgResolution; - imgResolution.x = 5; - imgResolution.y = 15; - imgResolution.z = 25; + FloatVec3Type imgResolution; + imgResolution[0] = 5; + imgResolution[1] = 15; + imgResolution[2] = 25; - imageGeometry->setResolution(imgResolution); + imageGeometry->setSpacing(imgResolution); - FloatVec3_t resolution = imageGeometry->getResolution(); + FloatVec3Type resolution = imageGeometry->getSpacing(); - DREAM3D_REQUIRE_EQUAL(imgResolution.x, resolution.x); - DREAM3D_REQUIRE_EQUAL(imgResolution.y, resolution.y); - DREAM3D_REQUIRE_EQUAL(imgResolution.z, resolution.z); + DREAM3D_REQUIRE_EQUAL(imgResolution[0], resolution[0]); + DREAM3D_REQUIRE_EQUAL(imgResolution[1], resolution[1]); + DREAM3D_REQUIRE_EQUAL(imgResolution[2], resolution[2]); } // ----------------------------------------------------------------------------- @@ -147,23 +147,23 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - IntVec3_t numDimensions; - numDimensions.x = 5; - numDimensions.y = 15; - numDimensions.z = 25; + IntVec3Type numDimensions; + numDimensions[0] = 5; + numDimensions[1] = 15; + numDimensions[2] = 25; imageGeometry->setDimensions(numDimensions); - FloatVec3_t originPos; - originPos.x = 5; - originPos.y = 15; - originPos.z = 25; + FloatVec3Type originPos; + originPos[0] = 5; + originPos[1] = 15; + originPos[2] = 25; imageGeometry->setOrigin(originPos); - FloatVec3_t imgResolution; - imgResolution.x = 5; - imgResolution.y = 15; - imgResolution.z = 25; - imageGeometry->setResolution(imgResolution); + FloatVec3Type imgResolution; + imgResolution[0] = 5; + imgResolution[1] = 15; + imgResolution[2] = 25; + imageGeometry->setSpacing(imgResolution); imageGeometry->execute(); @@ -174,36 +174,30 @@ class CreateImageGeometryTest DREAM3D_REQUIRE(nullptr != geometry.get()); { - float* res = new float[3]; - geometry->getResolution(res); + FloatVec3Type res; + geometry->getSpacing(res); - DREAM3D_REQUIRE_EQUAL(res[0], imgResolution.x); - DREAM3D_REQUIRE_EQUAL(res[1], imgResolution.y); - DREAM3D_REQUIRE_EQUAL(res[2], imgResolution.z); - - delete[] res; + DREAM3D_REQUIRE_EQUAL(res[0], imgResolution[0]); + DREAM3D_REQUIRE_EQUAL(res[1], imgResolution[1]); + DREAM3D_REQUIRE_EQUAL(res[2], imgResolution[2]); } { - float* origin = new float[3]; + FloatVec3Type origin; geometry->getOrigin(origin); - DREAM3D_REQUIRE_EQUAL(origin[0], originPos.x); - DREAM3D_REQUIRE_EQUAL(origin[1], originPos.y); - DREAM3D_REQUIRE_EQUAL(origin[2], originPos.z); - - delete[] origin; + DREAM3D_REQUIRE_EQUAL(origin[0], originPos[0]); + DREAM3D_REQUIRE_EQUAL(origin[1], originPos[1]); + DREAM3D_REQUIRE_EQUAL(origin[2], originPos[2]); } { - size_t* dims = new size_t[3]; - std::tie(dims[0], dims[1], dims[2]) = geometry->getDimensions(); + SizeVec3Type dims; + geometry->getDimensions(dims); - DREAM3D_REQUIRE_EQUAL(dims[0], numDimensions.x); - DREAM3D_REQUIRE_EQUAL(dims[1], numDimensions.y); - DREAM3D_REQUIRE_EQUAL(dims[2], numDimensions.z); - - delete[] dims; + DREAM3D_REQUIRE_EQUAL(dims[0], numDimensions[0]); + DREAM3D_REQUIRE_EQUAL(dims[1], numDimensions[1]); + DREAM3D_REQUIRE_EQUAL(dims[2], numDimensions[2]); } } @@ -235,7 +229,9 @@ class CreateImageGeometryTest DREAM3D_REGISTER_TEST(testExecution()) } -private: - CreateImageGeometryTest(const CreateImageGeometryTest&); // Copy Constructor Not Implemented - void operator=(const CreateImageGeometryTest&); // Move assignment Not Implemented +public: + CreateImageGeometryTest(const CreateImageGeometryTest&) = delete; // Copy Constructor Not Implemented + CreateImageGeometryTest(CreateImageGeometryTest&&) = delete; // Move Constructor Not Implemented + CreateImageGeometryTest& operator=(const CreateImageGeometryTest&) = delete; // Copy Assignment Not Implemented + CreateImageGeometryTest& operator=(CreateImageGeometryTest&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp index 0d6ae301c3..79d993f7ef 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp @@ -104,12 +104,12 @@ class CreateStringArrayTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer am = AttributeMatrix::New(tupleDims, k_AttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixName, am); + dc->addOrReplaceAttributeMatrix(am); // Create Filter @@ -135,7 +135,7 @@ class CreateStringArrayTest // Run Filter createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), >=, 0); // Check Filter Results @@ -156,7 +156,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -5759); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -5759); // Test invalid array path; should yield error -8152 @@ -170,7 +170,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -8152); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -8152); // Test negative number of components; should yield error -8150 @@ -184,7 +184,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -8150); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -8150); // Test zero components; should yield error -8151 @@ -193,7 +193,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -8151); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -8151); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp index 3e7a0a7c9b..fbb2906cf2 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp @@ -129,22 +129,22 @@ class CropVertexGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix QVector dims(1, vertices.size()); AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(dims, k_VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(k_VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer nonVertexAM = AttributeMatrix::New(m_Dims4, k_AttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixName, nonVertexAM); + dc->addOrReplaceAttributeMatrix(nonVertexAM); // Create DataArray used for geometry creation FloatArrayType::Pointer daVert = createDataArray(k_VertexCoordinatesDAName, vertices, dims, m_Dims3); - vertexAM->addAttributeArray(k_VertexCoordinatesDAName, daVert); + vertexAM->insertOrAssign(daVert); // Manually create cropped DataArray for comparison @@ -159,7 +159,7 @@ class CropVertexGeometryTest { da->setValue(i, i + 0.5f); } - nonVertexAM->addAttributeArray(k_DataArray0Name, da); + nonVertexAM->insertOrAssign(da); // Create Geometry @@ -178,12 +178,13 @@ class CropVertexGeometryTest // Setup Filter QVariant var; - - var.setValue(k_DataContainerName); + DataArrayPath dap(k_DataContainerName); + var.setValue(dap); bool propWasSet = cropVertexGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) - var.setValue(k_CroppedDataContainerName); + dap = DataArrayPath(k_CroppedDataContainerName); + var.setValue(dap); propWasSet = cropVertexGeometry->setProperty("CroppedDataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -214,7 +215,7 @@ class CropVertexGeometryTest // Run Filter cropVertexGeometry->execute(); - DREAM3D_REQUIRED(cropVertexGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(cropVertexGeometry->getErrorCode(), >=, 0); // Check filter results @@ -230,7 +231,7 @@ class CropVertexGeometryTest DREAM3D_REQUIRE_EQUAL((daCroppedVert->getNumberOfTuples() == croppedVertexAM->getNumberOfTuples()), true) - FloatArrayType::Pointer croppedVerticesFromAM = croppedVertexAM->getAttributeArrayAs(k_VertexCoordinatesDAName); + FloatArrayType::Pointer croppedVerticesFromAM = croppedVertexAM->getAttributeArrayAs(SIMPL::Geometry::SharedVertexList); checkDataArray(daCroppedVert, croppedVerticesFromAM); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp index fa4eef24eb..2e47e1ff1f 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp @@ -47,7 +47,9 @@ #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataArrays/StructArray.hpp" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" @@ -123,6 +125,14 @@ QString H5File() class DataContainerTest { + + enum createdPathID : RenameDataPath::DataID_t + { + DataContainerID1 = 1, + DataContainerID2 = 2, + DataContainerID3 = 3 + }; + public: DataContainerTest() = default; virtual ~DataContainerTest() = default; @@ -186,7 +196,7 @@ class DataContainerTest typename DataArray::Pointer foo = DataArray::CreateArray(attrMat->getTupleDimensions(), compDims, "RENAME_ME"); foo->setName(foo->getFullNameOfClass() + name); foo->initializeWithValue(static_cast(1)); - attrMat->addAttributeArray(foo->getName(), foo); + attrMat->insertOrAssign(foo); QString autoName = foo->getName() + "_Auto"; attrMat->createNonPrereqArray, AbstractFilter, T>(nullptr, autoName, static_cast(10), compDims); @@ -204,13 +214,13 @@ class DataContainerTest QString value = QString("string_%1").arg(i); data->setValue(i, value); } - attrMat->addAttributeArray(data->getName(), data); + attrMat->insertOrAssign(data); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void FillAttributeMatrix(AttributeMatrix::Pointer attrMat, QVector compDims) + void FillAttributeMatrix(const AttributeMatrix::Pointer& attrMat, const QVector& compDims) { CreateDataArray(attrMat, compDims); CreateDataArray(attrMat, compDims); @@ -228,7 +238,7 @@ class DataContainerTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void PopulateVolumeDataContainer(DataContainer::Pointer dc, QVector tupleDims, const QString& name) + void PopulateVolumeDataContainer(const DataContainer::Pointer& dc, QVector tupleDims, const QString& name) { // Create the attribute matrix with the dimensions and name AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tupleDims, name, AttributeMatrix::Type::Cell); @@ -246,7 +256,7 @@ class DataContainerTest FillAttributeMatrix(attrMat, compDims); // Add the AttributeMatrix to the Data Container - dc->addAttributeMatrix(attrMat->getName(), attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); QString autoAddName = name + QString::fromLatin1("_Auto"); AttributeMatrix::Pointer autoAttrMat = dc->createNonPrereqAttributeMatrix(nullptr, autoAddName, tupleDims, AttributeMatrix::Type::Cell); @@ -284,31 +294,31 @@ class DataContainerTest // 1D VolumeDataContainer tupleDims.push_back(nx); { - DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "1D_VolumeDataContainer"); + DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "1D_VolumeDataContainer", DataContainerID1); PopulateVolumeDataContainer(dc, tupleDims, "1D_AttributeMatrix"); } // 2D VolumeDataContainer tupleDims.push_back(ny); { - DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "2D_VolumeDataContainer"); + DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "2D_VolumeDataContainer", DataContainerID2); PopulateVolumeDataContainer(dc, tupleDims, "2D_AttributeMatrix"); } // 3D VolumeDataContainer tupleDims.push_back(nz); { - DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "3D_VolumeDataContainer"); + DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "3D_VolumeDataContainer", DataContainerID3); PopulateVolumeDataContainer(dc, tupleDims, "3D_AttributeMatrix"); } // A DataContainer that mimics some real data DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); m->setGeometry(image); AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(tupleDims, getCellFeatureAttributeMatrixName(), AttributeMatrix::Type::CellFeature); - m->addAttributeMatrix(getCellFeatureAttributeMatrixName(), attrMatrix); + m->addOrReplaceAttributeMatrix(attrMatrix); int size = nx * ny * nz; Int32ArrayType::Pointer featureIds = Int32ArrayType::CreateArray(size, SIMPL::CellData::FeatureIds); @@ -316,14 +326,14 @@ class DataContainerTest { featureIds->setValue(i, i + DataContainerIOTest::Offset); } - attrMatrix->addAttributeArray(SIMPL::CellData::FeatureIds, featureIds); + attrMatrix->insertOrAssign(featureIds); BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray(size, SIMPL::CellData::BoundaryCells); for(int i = 0; i < size; ++i) { boolArray->setValue(i, i + DataContainerIOTest::Offset); } - attrMatrix->addAttributeArray(SIMPL::CellData::BoundaryCells, boolArray); + attrMatrix->insertOrAssign(boolArray); QVector dims(1, 3); FloatArrayType::Pointer avgEuler = FloatArrayType::CreateArray(size, dims, SIMPL::FeatureData::AxisEulerAngles); @@ -333,19 +343,19 @@ class DataContainerTest avgEuler->setComponent(i, 1, i * 0.325f); avgEuler->setComponent(i, 2, i * 0.165f); } - m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->addAttributeArray(SIMPL::FeatureData::AxisEulerAngles, avgEuler); + m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->insertOrAssign(avgEuler); tupleDims.resize(1); tupleDims[0] = 4; AttributeMatrix::Pointer ensemAttrMat = AttributeMatrix::New(tupleDims, getCellEnsembleAttributeMatrixName(), AttributeMatrix::Type::CellEnsemble); - m->addAttributeMatrix(getCellEnsembleAttributeMatrixName(), ensemAttrMat); + m->addOrReplaceAttributeMatrix(ensemAttrMat); FloatArrayType::Pointer surfArea = FloatArrayType::CreateArray(4, SIMPL::EnsembleData::TotalSurfaceAreas); for(int i = 0; i < 4; ++i) { surfArea->setValue(i, i + 41.2f); } - m->getAttributeMatrix(getCellEnsembleAttributeMatrixName())->addAttributeArray(SIMPL::EnsembleData::TotalSurfaceAreas, surfArea); + m->getAttributeMatrix(getCellEnsembleAttributeMatrixName())->insertOrAssign(surfArea); Observer obs; // Send progress messages from PipelineBuilder to this object for display @@ -359,10 +369,10 @@ class DataContainerTest // manually. Normally the Pipeline Object would do this for us. We are NOT using a Pipeline Object because using the // Pipeline Object would over write the DataContainer Array that we have created with a blank one thus defeating the // entire purpose of the test. - QObject::connect(writer.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); writer->execute(); - int err = writer->getErrorCondition(); + int err = writer->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); } @@ -384,7 +394,7 @@ class DataContainerTest DataContainerArrayProxy dcaProxy = reader->readDataContainerArrayStructure(DataContainerIOTest::TestFile()); reader->setInputFileDataContainerArrayProxy(dcaProxy); reader->execute(); - int err = reader->getErrorCondition(); + int err = reader->getErrorCode(); DREAM3D_REQUIRE(err >= 0) Observer obs; @@ -399,10 +409,10 @@ class DataContainerTest // manually. Normally the Pipeline Object would do this for us. We are NOT using a Pipeline Object because using the // Pipeline Object would over write the DataContainer Array that we have created with a blank one thus defeating the // entire purpose of the test. - QObject::connect(writer.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); QMap& dcsToRead = dcaProxy.getDataContainers(); @@ -447,16 +457,16 @@ class DataContainerTest reader2->setDataContainerArray(dca2); reader2->setInputFileDataContainerArrayProxy(dcaProxy); reader2->execute(); - err = reader2->getErrorCondition(); + err = reader2->getErrorCode(); DREAM3D_REQUIRE(err >= 0) DataContainerWriter::Pointer writer2 = DataContainerWriter::New(); writer2->setDataContainerArray(dca2); writer2->setOutputFile(DataContainerIOTest::TestFile3()); - QObject::connect(writer.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); writer2->execute(); - err = writer2->getErrorCondition(); + err = writer2->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); } @@ -479,7 +489,7 @@ class DataContainerTest tDims[0] = 5; attrMat->resizeAttributeArrays(tDims); - int err = attrMat->addAttributeArray("Test", p); + int err = attrMat->insertOrAssign(p); DREAM3D_REQUIRED(err, >=, 0) // Now get it back out as the specific type that we put it in as @@ -587,8 +597,6 @@ class DataContainerTest { DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - QList nameList; - insertDeleteArray(m); insertDeleteArray(m); insertDeleteArray(m); @@ -643,72 +651,72 @@ class DataContainerTest QVector dims(1, 2); T* ptr = m->createCellData("Test", 10, dims, absFilt.get()); - DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCode(), 0); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - absFilt->setErrorCondition(0); + absFilt->clearErrorCode(); // First try getting the array, but pass in a bad array name which should produce a null pointer // and negative error condition ptr = m->getCellDataSizeCheck("BAD_ARRAY_NAME", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad size name which should produce a null pointer // and negative error condition ptr = m->getCellDataSizeCheck("Test", 10, 1, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad cast type which should produce a null pointer // and negative error condition bool* bool_ptr = m->getCellDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(bool_ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next, pass in all the correct values which should produce a Non nullptr pointer value and // Zero Error Condition ptr = m->getCellDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); IDataArray::Pointer t = attrMat->removeAttributeArray( "Test" ); DREAM3D_TEST_POINTER(ptr, !=, nullptr); /********************************* Feature Data Tests *********************************************/ ptr = m->createCellFeatureData("Test", 10, dims, absFilt.get()); - DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCode(), 0); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - absFilt->setErrorCondition(0); + absFilt->clearErrorCode(); // First try getting the array, but pass in a bad array name which should produce a null pointer // and negative error condition ptr = m->getCellFeatureDataSizeCheck("BAD_ARRAY_NAME", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad size name which should produce a null pointer // and negative error condition ptr = m->getCellFeatureDataSizeCheck("Test", 10, 1, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad cast type which should produce a null pointer // and negative error condition bool_ptr = m->getCellFeatureDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(bool_ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next, pass in all the correct values which should produce a Non nullptr pointer value and // Zero Error Condition ptr = m->getCellFeatureDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); t = m->removeCellFeatureData( "Test" ); DREAM3D_TEST_POINTER(ptr, !=, nullptr); @@ -716,36 +724,36 @@ class DataContainerTest /********************************* Ensemble Data Tests *********************************************/ ptr = m->createCellEnsembleData("Test", 10, dims, absFilt.get()); - DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCode(), 0); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - absFilt->setErrorCondition(0); + absFilt->clearErrorCode(); // First try getting the array, but pass in a bad array name which should produce a null pointer // and negative error condition ptr = m->getCellEnsembleDataSizeCheck("BAD_ARRAY_NAME", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad size name which should produce a null pointer // and negative error condition ptr = m->getCellEnsembleDataSizeCheck("Test", 10, 1, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad cast type which should produce a null pointer // and negative error condition bool_ptr = m->getCellEnsembleDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(bool_ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next, pass in all the correct values which should produce a Non nullptr pointer value and // Zero Error Condition ptr = m->getCellEnsembleDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); t = m->removeCellEnsembleData( "Test" ); @@ -885,6 +893,284 @@ class DataContainerTest } #endif + // ----------------------------------------------------------------------------- + void TestDataContainerArray() + { + bool result = false; + DataContainerArray::Pointer dca = DataContainerArray::New(); + // addDataContainer + // insertOrAssign + // getDataContainer(QString | DataArrayPath) + + // try adding or assigning a null DataContainer + DataContainer::Pointer nullDc = DataContainer::NullPointer(); + result = dca->addOrReplaceDataContainer(nullDc); + DREAM3D_REQUIRED(false, ==, result) + result = dca->insertOrAssign(nullDc); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 0) + + const QString k_DC0("DCO"); + const QString k_DC1("DC1"); + DataContainer::Pointer dc0 = DataContainer::New(k_DC0); + DataContainer::Pointer dc1 = DataContainer::New(k_DC1); + + result = dca->addOrReplaceDataContainer(dc0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 1) + + // Add the same DataContainer a second time. Still returns true. Size stays at 1 + result = dca->insertOrAssign(dc0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->push_back(dc0); + DREAM3D_REQUIRED(false, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->addOrReplaceDataContainer(dc1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 2) + + dc0 = dca->removeDataContainer(k_DC0); + dc1 = dca->removeDataContainer(k_DC1); + DREAM3D_REQUIRED(dca->empty(), ==, true) + DREAM3D_REQUIRE_NULL_POINTER(dc0->getParentNode()) + + dca->clear(); + DREAM3D_REQUIRED(dca->empty(), ==, true) + + result = dca->addOrReplaceDataContainer(dc0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->push_back(dc0); + DREAM3D_REQUIRED(false, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->addOrReplaceDataContainer(dc1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 2) + + // getDataContainers + DataContainerArray::Container dcContainer = dca->getDataContainers(); + DREAM3D_REQUIRED(dcContainer.size(), ==, 2) + + dc0 = dca->getDataContainer(k_DC0); + DREAM3D_REQUIRE_VALID_POINTER(dc0.get()) + DataArrayPath dap(k_DC0); + dc0 = dca->getDataContainer(dap); + DREAM3D_REQUIRE_VALID_POINTER(dc0.get()) + + DREAM3D_REQUIRED(dca->size(), ==, 2) + dca->clear(); + DREAM3D_REQUIRED(dca->empty(), ==, true) + for(int i = 0; i < 10; i++) + { + DataContainer::Pointer dc = DataContainer::New("Foo" + QString::number(i)); + dca->addOrReplaceDataContainer(dc); + // std::cout << dca->size() << std::endl; + DREAM3D_REQUIRED(dca->size(), ==, i + 1) + } + + result = dca->insertOrAssign(dc0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 11) + + result = dca->insertOrAssign(dc0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 11) + result = dca->insertOrAssign(dc1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dca->size(), ==, 12) + } + + // ----------------------------------------------------------------------------- + void TestDataContainer() + { + bool result = false; + DataContainer::Pointer dc = DataContainer::New("DataContainer"); + // addDataContainer + // insertOrAssign + // getDataContainer(QString | DataArrayPath) + + // try adding or assigning a null DataContainer + AttributeMatrix::Pointer nullAttrMat = AttributeMatrix::NullPointer(); + result = dc->addOrReplaceAttributeMatrix(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + result = dc->insertOrAssign(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dc->empty(), ==, true) + + const QString k_DC0("DCO"); + const QString k_DC1("DC1"); + QVector tDims = {10, 10}; + AttributeMatrix::Pointer am0 = AttributeMatrix::New(tDims, k_DC0, AttributeMatrix::Type::Generic); + AttributeMatrix::Pointer am1 = AttributeMatrix::New(tDims, k_DC1, AttributeMatrix::Type::Generic); + + result = dc->addOrReplaceAttributeMatrix(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 1) + + // Add the same AttributeMatrix a second time. Still returns true. Size stays at 1 + result = dc->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->push_back(am0); + DREAM3D_REQUIRED(false, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->addOrReplaceAttributeMatrix(am1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 2) + + am0 = dc->removeAttributeMatrix(k_DC0); + am1 = dc->removeAttributeMatrix(k_DC1); + DREAM3D_REQUIRED(dc->empty(), ==, true) + DREAM3D_REQUIRE_NULL_POINTER(am0->getParentNode()) + + dc->clear(); + DREAM3D_REQUIRED(dc->empty(), ==, true) + + result = dc->addOrReplaceAttributeMatrix(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->push_back(am0); + DREAM3D_REQUIRED(false, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->addOrReplaceAttributeMatrix(am1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 2) + + // getDataContainers + DataContainer::Container_t dcContainer = dc->getAttributeMatrices(); + DREAM3D_REQUIRED(dcContainer.size(), ==, 2) + + am0 = dc->getAttributeMatrix(k_DC0); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + DataArrayPath dap("DataContainer", k_DC0, ""); + am0 = dc->getAttributeMatrix(dap); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + + DREAM3D_REQUIRED(dc->size(), ==, 2) + dc->clear(); + DREAM3D_REQUIRED(dc->empty(), ==, true) + for(int i = 0; i < 10; i++) + { + AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "Foo" + QString::number(i), AttributeMatrix::Type::Generic); + dc->addOrReplaceAttributeMatrix(am); + // std::cout << dca->size() << std::endl; + DREAM3D_REQUIRED(dc->size(), ==, i + 1) + } + + result = dc->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 11) + + result = dc->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 11) + result = dc->insertOrAssign(am1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(dc->size(), ==, 12) + } + + // ----------------------------------------------------------------------------- + void TestAttributeMatrix() + { + bool result = false; + QVector tDims = {10, 10}; + AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Generic); + // addDataContainer + // insertOrAssign + // getDataContainer(QString | DataArrayPath) + + // try adding or assigning a null DataContainer + Int32ArrayType::Pointer nullAttrMat = Int32ArrayType::NullPointer(); + result = am->addOrReplaceAttributeArray(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + result = am->insertOrAssign(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(am->empty(), ==, true) + + const QString k_DC0("DCO"); + const QString k_DC1("DC1"); + Int32ArrayType::Pointer am0 = Int32ArrayType::CreateArray(100, k_DC0); + Int32ArrayType::Pointer am1 = Int32ArrayType::CreateArray(100, k_DC1); + + result = am->addOrReplaceAttributeArray(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 1) + + // Add the same AttributeMatrix a second time. Still returns true. Size stays at 1 + result = am->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->push_back(am0); + DREAM3D_REQUIRED(false, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->addOrReplaceAttributeArray(am1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 2) + + IDataArray::Pointer da0 = am->removeAttributeArray(k_DC0); + IDataArray::Pointer da1 = am->removeAttributeArray(k_DC1); + DREAM3D_REQUIRED(am->empty(), ==, true) + DREAM3D_REQUIRE_NULL_POINTER(am0->getParentNode()) + + am->clear(); + DREAM3D_REQUIRED(am->empty(), ==, true) + + result = am->addOrReplaceAttributeArray(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->push_back(am0); + DREAM3D_REQUIRED(false, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->addOrReplaceAttributeArray(am1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 2) + + // getDataContainers + AttributeMatrix::Container_t dcContainer = am->getAttributeArrays(); + DREAM3D_REQUIRED(dcContainer.size(), ==, 2) + + da0 = am->getAttributeArray(k_DC0); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + DataArrayPath dap("DataContainer", "AttributeMatrix", k_DC0); + da0 = am->getAttributeArray(dap); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + + DREAM3D_REQUIRED(am->size(), ==, 2) + am->clear(); + DREAM3D_REQUIRED(am->empty(), ==, true) + for(int i = 0; i < 10; i++) + { + Int32ArrayType::Pointer aa = Int32ArrayType::CreateArray(100, "Foo" + QString::number(i)); + am->addOrReplaceAttributeArray(aa); + // std::cout << dca->size() << std::endl; + DREAM3D_REQUIRED(am->size(), ==, i + 1) + } + + result = am->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 11) + + result = am->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 11) + result = am->insertOrAssign(am1); + DREAM3D_REQUIRED(true, ==, result); + DREAM3D_REQUIRED(am->size(), ==, 12) + } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -899,6 +1185,11 @@ class DataContainerTest DREAM3D_REGISTER_TEST(RemoveTestFiles()) #endif int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST(TestDataContainerArray()) + DREAM3D_REGISTER_TEST(TestDataContainer()) + DREAM3D_REGISTER_TEST(TestAttributeMatrix()) + DREAM3D_REGISTER_TEST(TestInsertDelete()) DREAM3D_REGISTER_TEST(TestDataContainerWriter()) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp index eeaf1509f1..b2f44591a7 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp @@ -35,7 +35,10 @@ #include -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" @@ -60,26 +63,17 @@ class ErrorMessageTest // ----------------------------------------------------------------------------- void TestErrorMessage() { - PipelineMessage e0; - - QString a0("Some Class Name"); - QString a1("Description"); - int eCode = -10; - PipelineMessage e1; - - PipelineMessage e2(a0, a1, eCode); - AbstractFilter::Pointer f = AbstractFilter::New(); - f->notifyErrorMessage("Some Test", a1, eCode); - f->notifyErrorMessage("Another Test", "A description", -10); - - PipelineMessage pm("Joey's Test", "Testing Warning Message...", -23, PipelineMessage::MessageType::Warning); - PipelineMessage pm1("Joey's Test", "Testing Error Message...", -23, PipelineMessage::MessageType::Error); - PipelineMessage pm2("Joey's Test", "Testing Status Message...", -23, PipelineMessage::MessageType::StatusMessage); - PipelineMessage pm3("Joey's Test", "Testing Status Message...", -23, PipelineMessage::MessageType::ProgressValue, 23); - f->broadcastPipelineMessage(pm); - f->broadcastPipelineMessage(pm1); - f->broadcastPipelineMessage(pm2); + f->setErrorCondition(-10, "Description"); + + FilterProgressMessage::Pointer progressMessage = FilterProgressMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Warning Message...", -23); + FilterErrorMessage::Pointer errorMessage = FilterErrorMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Error Message...", -23); + FilterStatusMessage::Pointer statusMessage = FilterStatusMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Status Message..."); + FilterWarningMessage::Pointer warningMessage = FilterWarningMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Status Message...", 23); + emit f->messageGenerated(progressMessage); + emit f->messageGenerated(errorMessage); + emit f->messageGenerated(statusMessage); + emit f->messageGenerated(warningMessage); if(true) { diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp index 98598a05fb..2a6fd903b4 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp @@ -44,6 +44,10 @@ #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/PipelineStatusMessage.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" #include "SIMPLib/SIMPLib.h" @@ -53,8 +57,42 @@ #include "SIMPLib/CoreFilters/ExecuteProcess.h" /** -* @brief -*/ + * @brief This message handler is used by the ExecuteProcessTest to append filter and pipeline status messages + * to a standard output string. + */ +class ExecuteProcessMessageHandler : public AbstractMessageHandler +{ +public: + explicit ExecuteProcessMessageHandler(QString* stdOutput) + : m_StdOutput(stdOutput) + { + } + + /** + * @brief Appends incoming FilterStatusMessages to the standard output string + */ + void processMessage(const FilterStatusMessage* msg) const override + { + QString str = msg->generateMessageString(); + m_StdOutput->append(str); + } + + /** + * @brief Appends incoming PipelineStatusMessages to the standard output string + */ + void processMessage(const PipelineStatusMessage* msg) const override + { + QString str = msg->generateMessageString(); + m_StdOutput->append(str); + } + +private: + QString* m_StdOutput = nullptr; +}; + +/** + * @brief The ExecuteProcessObserver class + */ class ExecuteProcessObserver : public QObject, public IObserver { Q_OBJECT @@ -76,16 +114,10 @@ class ExecuteProcessObserver : public QObject, public IObserver } public slots: - void processPipelineMessage(const PipelineMessage& pm) override + void processPipelineMessage(const AbstractMessage::Pointer& pm) override { - if(pm.getType() == PipelineMessage::MessageType::StandardOutputMessage) - { - PipelineMessage msg = pm; - QString str; - QTextStream ss(&str); - ss << msg.generateStandardOutputString(); - m_StdOutput.append(str); - } + ExecuteProcessMessageHandler msgHandler(&m_StdOutput); + pm->visit(&msgHandler); } private: @@ -97,6 +129,9 @@ public slots: #include "ExecuteProcessTest.moc" +/** + * @brief The ExecuteProcessTest class + */ class ExecuteProcessTest { @@ -131,11 +166,11 @@ class ExecuteProcessTest ExecuteProcess::Pointer filter = ExecuteProcess::New(); ExecuteProcessObserver obs; - QObject::connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); filter->setArguments(QObject::tr("%1 -query QMAKE_VERSION").arg(UnitTest::ExecuteProcessTest::QMakeLocation)); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) QString stdOutput = obs.getStdOutput(); #ifdef Q_OS_WIN stdOutput.remove('\r'); @@ -153,14 +188,14 @@ class ExecuteProcessTest // ExecuteProcess::Pointer filter = ExecuteProcess::New(); // ExecuteProcessObserver obs; - // QObject::connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + // QObject::connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); // filter->setArguments(QObject::tr("%1 -version").arg(UnitTest::ExecuteProcessTest::CMakeLocation)); // filter->execute(); // QString stdOutput = obs.getStdOutput(); // stdOutput.remove('\r'); // stdOutput.remove('\n'); - // DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + // DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) // QString versionString = UnitTest::ExecuteProcessTest::CMakeVersionString; // versionString.remove('\r'); // versionString.remove('\n'); @@ -171,14 +206,14 @@ class ExecuteProcessTest ExecuteProcess::Pointer filter = ExecuteProcess::New(); ExecuteProcessObserver obs; - QObject::connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); filter->setArguments("sdhsdrtfn"); filter->execute(); QString stdOutput = obs.getStdOutput(); stdOutput.remove('\r'); stdOutput.remove('\n'); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -4005) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -4005) } return EXIT_SUCCESS; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp index 3fe8f496b0..b8dd7aa064 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp @@ -135,12 +135,12 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer boundsAM = AttributeMatrix::New(m_Dims4, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, boundsAM); + dc->addOrReplaceAttributeMatrix(boundsAM); // Create Geometry @@ -183,7 +183,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -205,7 +205,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -243,12 +243,12 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims2, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); // Create Geometry @@ -273,7 +273,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -285,7 +285,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -315,15 +315,15 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims2, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Edge); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry @@ -351,7 +351,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -368,7 +368,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -403,15 +403,15 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims3, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Face); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry @@ -439,7 +439,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -456,7 +456,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -491,15 +491,15 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims4, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Face); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry @@ -527,7 +527,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -544,7 +544,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -579,15 +579,15 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims4, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry @@ -615,7 +615,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -632,7 +632,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -667,15 +667,15 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims8, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry @@ -703,7 +703,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -720,7 +720,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp index 8a7f3a846e..667e0a6164 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp @@ -66,12 +66,12 @@ class ExtractComponentAsArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims; dims.push_back(2); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); QVector cdims; cdims.push_back(2); @@ -80,7 +80,7 @@ class ExtractComponentAsArrayTest da->setComponent(0, 1, 2); da->setComponent(1, 0, 3); da->setComponent(1, 1, 4); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); return dca; } @@ -158,7 +158,7 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray", 1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainerArray::Pointer dca = filter->getDataContainerArray(); DataContainer::Pointer dc = dca->getDataContainer("DataContainer"); @@ -179,11 +179,11 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray", 2, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11004); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11004); setValues(filter, "DataArray", -1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11005); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11005); } // ----------------------------------------------------------------------------- @@ -198,7 +198,7 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray1", 1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -90002); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -90002); } // ----------------------------------------------------------------------------- @@ -213,7 +213,7 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray", 1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -10002); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -10002); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp index 096bee7689..8648e8db5b 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp @@ -71,14 +71,14 @@ class ExtractVertexGeometryTest DataContainerArray::Pointer dca = DataContainerArray::New(); // Create the DataContainer for the ImageGeometry - DataContainer::Pointer imageGeomDC = DataContainer::New(k_ImageGeomDataContainerName); - dca->addDataContainer(imageGeomDC); + DataContainer::Pointer imageGeomDC = DataContainer::New(k_ImageGeomDataContainerPath); + dca->addOrReplaceDataContainer(imageGeomDC); DataContainer::Pointer badDataContainer = DataContainer::New(k_BadDataContainerName); - dca->addDataContainer(badDataContainer); + dca->addOrReplaceDataContainer(badDataContainer); DataContainer::Pointer wrongGeomDataContainer = DataContainer::New(k_WrongGeomDataContainerName); - dca->addDataContainer(wrongGeomDataContainer); + dca->addOrReplaceDataContainer(wrongGeomDataContainer); TriangleGeom::Pointer triangleGeom = TriangleGeom::New(); wrongGeomDataContainer->setGeometry(triangleGeom); @@ -91,25 +91,25 @@ class ExtractVertexGeometryTest // Create the Cell AttributeMatrix AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::Create(dims, k_CellAttrMatName, AttributeMatrix::Type::Cell); - imageGeomDC->addAttributeMatrix(cellAttrMat->getName(), cellAttrMat); + imageGeomDC->addOrReplaceAttributeMatrix(cellAttrMat); // Create a cell attribute array FloatArrayType::Pointer f32Data = FloatArrayType::CreateArray(cellCount, k_FloatArrayName, true); f32Data->initializeWithValue(45.243f); - cellAttrMat->addAttributeArray(f32Data->getName(), f32Data); + cellAttrMat->insertOrAssign(f32Data); // Create a Feature AttributeMatrix with different dimensions dims[0] = 1; dims[1] = 2; dims[2] = 3; AttributeMatrix::Pointer featureAttrMat = AttributeMatrix::Create(dims, k_FeatureAttrMatName, AttributeMatrix::Type::CellFeature); - imageGeomDC->addAttributeMatrix(featureAttrMat->getName(), featureAttrMat); + imageGeomDC->addOrReplaceAttributeMatrix(featureAttrMat); // Create a feature attribute array cellCount = std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies()); Int32ArrayType::Pointer i32Data = Int32ArrayType::CreateArray(cellCount, k_FeatureArrayName, true); i32Data->initializeWithValue(1); - featureAttrMat->addAttributeArray(i32Data->getName(), i32Data); + featureAttrMat->insertOrAssign(i32Data); return dca; } @@ -128,14 +128,14 @@ class ExtractVertexGeometryTest // extVertGeomFilter->setArrayHandling(-10); extVertGeomFilter->preflight(); - int32_t err = extVertGeomFilter->getErrorCondition(); + int32_t err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2002) dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->setArrayHandling(10); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2003) // Empty SelectedDataContainerName @@ -143,58 +143,58 @@ class ExtractVertexGeometryTest extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->setArrayHandling(k_MoveArrays); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2004) // Empty VertexDataContainerName dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerName); - extVertGeomFilter->setVertexDataContainerName(QString("")); + extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerPath); + extVertGeomFilter->setVertexDataContainerName(DataArrayPath("", "", "")); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2006) // Set the Vertex Data Container to an existing DataContainer dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_ImageGeomDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_ImageGeomDataContainerPath); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2007) // Set the Vertex Data Container to an existing DataContainer // Set a DataContainer that does not have a Geometry dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerPath); extVertGeomFilter->setSelectedDataContainerName(k_BadDataContainerName); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2008) // Set the Vertex Data Container to an existing DataContainer // Set a DataContainer that does not have the proper geometry dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerPath); extVertGeomFilter->setSelectedDataContainerName(k_WrongGeomDataContainerName); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2010) // Set the Vertex Data Container to an existing DataContainer dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerName); - extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerPath); + extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerPath); // Set an incorrect AttributeMatrix/DataArray Path QVector includePaths; DataArrayPath dap(k_ImageGeomDataContainerName, k_FeatureAttrMatName, k_FeatureArrayName); includePaths.push_back(dap); extVertGeomFilter->setIncludedDataArrayPaths(includePaths); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2009) // Set the correct paths. @@ -204,14 +204,14 @@ class ExtractVertexGeometryTest includePaths[0] = dap; extVertGeomFilter->setIncludedDataArrayPaths(includePaths); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) // The preflight should be passing at this point so execute the filter dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->execute(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) dap.update(k_ImageGeomDataContainerName, k_CellAttrMatName, k_FloatArrayName); @@ -227,7 +227,7 @@ class ExtractVertexGeometryTest extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->setArrayHandling(k_CopyArrays); extVertGeomFilter->execute(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) dap.update(k_ImageGeomDataContainerName, k_CellAttrMatName, k_FloatArrayName); @@ -253,12 +253,14 @@ class ExtractVertexGeometryTest } private: + const DataArrayPath k_ImageGeomDataContainerPath = DataArrayPath("ImageGeomDataContainer", "", ""); const QString k_ImageGeomDataContainerName = QString("ImageGeomDataContainer"); const QString k_CellAttrMatName = QString("CellData"); const QString k_FloatArrayName = QString("FloatArray"); const QString k_VertexDataContainerName = QString("VertexDataContainer"); - const QString k_BadDataContainerName = QString("BadDataContainer"); - const QString k_WrongGeomDataContainerName = QString("WrongGeomDataContainer"); + const DataArrayPath k_VertexDataContainerPath = DataArrayPath("VertexDataContainer", "", ""); + const DataArrayPath k_BadDataContainerName = DataArrayPath("BadDataContainer", "", ""); + const DataArrayPath k_WrongGeomDataContainerName = DataArrayPath("WrongGeomDataContainer", "", ""); const QString k_FeatureAttrMatName = QString("Feature Attr Mat"); const QString k_FeatureArrayName = QString("featureData"); }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp index f8cc2bbc0c..a4f2ebe230 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp @@ -43,12 +43,12 @@ #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -275,8 +275,8 @@ class FeatureDataCSVWriterTest // The data array added last in code will be the first printed and first in daList - checkDataList(am, daList[0]->getName(), tokens, i, 1); - checkDataList(am, daList[1]->getName(), tokens, i, 1 + daList[0]->getNumberOfComponents()); + checkDataList(am, daList[0]->getName(), tokens, i, 1); + checkDataList(am, daList[1]->getName(), tokens, i, 1 + daList[0]->getNumberOfComponents()); } if(writeNeighborListData) @@ -352,10 +352,10 @@ class FeatureDataCSVWriterTest // Run filter featureDataCSVWriter->preflight(); - DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCode(), >=, 0); featureDataCSVWriter->execute(); - DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCode(), >=, 0); checkFilter(am, delimiterChoice, writeNumFeaturesLine, writeNeighborListData); } @@ -391,18 +391,18 @@ class FeatureDataCSVWriterTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create Image Geometry ImageGeom::Pointer ig = ImageGeom::New(); - ig->setDimensions(xDim, yDim, zDim); + ig->setDimensions(SizeVec3Type(xDim, yDim, zDim)); dc->setGeometry(ig); // Create AttributeMatrix AttributeMatrix::Pointer am = AttributeMatrix::New(tupleDims, k_AttributeMatrixName, AttributeMatrix::Type::CellFeature); - dc->addAttributeMatrix(k_AttributeMatrixName, am); + dc->addOrReplaceAttributeMatrix(am); // Create DataArrayInt (add in under checkFilter) @@ -411,7 +411,7 @@ class FeatureDataCSVWriterTest { da->setValue(i, i); } - am->addAttributeArray(k_DataArrayIntName, da); + am->insertOrAssign(da); // Create DataArrayFloat @@ -427,7 +427,7 @@ class FeatureDataCSVWriterTest daFloat->setValue(i, static_cast(i) * -0.1); } } - am->addAttributeArray(k_DataArrayFloatName, daFloat); + am->insertOrAssign(daFloat); // Create NeighborLists (must be int32_t) @@ -437,7 +437,7 @@ class FeatureDataCSVWriterTest nl->addEntry(i, i); nl->addEntry(i, i * 2); } - am->addAttributeArray(k_NeighborListName, nl); + am->insertOrAssign(nl); NeighborList::Pointer nl2 = NeighborList::CreateArray(tupleDims, cDimsNeighbor, k_NeighborListName2); for(size_t i = 0; i < nl2->getNumberOfTuples(); i++) @@ -446,7 +446,7 @@ class FeatureDataCSVWriterTest nl2->addEntry(i, i); nl2->addEntry(i, i + 1); } - am->addAttributeArray(k_NeighborListName2, nl2); + am->insertOrAssign(nl2); // Create Filter diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp index d37a5c5073..6bcb1c44b6 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp @@ -63,7 +63,7 @@ #define FDTEST_CREATE_DATA_CONTAINER(name, geom, dca) \ DataContainer::Pointer _##geom##Container = DataContainer::New(#name); \ _##geom##Container->setGeometry(geom); \ - dca->addDataContainer(_##geom##Container); + dca->addOrReplaceDataContainer(_##geom##Container); #define FDTEST_SET_PROPERTIES_AND_CHECK_EQ(filter, dc, path, derivsName, data) \ var.setValue(path); \ @@ -79,7 +79,7 @@ qDebug() << "Unable to set property DerivativesArrayPath for" << #dc; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ data = dc->getAttributeMatrix(derivsName.getAttributeMatrixName())->getAttributeArray(derivsName.getDataArrayName()); \ if(nullptr == std::dynamic_pointer_cast(data)) \ @@ -108,7 +108,7 @@ qDebug() << "Unable to set property DerivativesArrayPath for" << #dc; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_NE(err, 0); class FindDerivativesFilterTest @@ -123,43 +123,41 @@ class FindDerivativesFilterTest // ----------------------------------------------------------------------------- void initializeDataArrays(DataContainer::Pointer m, QVector cDims) { - QMap attrMats = m->getAttributeMatrices(); - QMap::Iterator it; - for(it = attrMats.begin(); it != attrMats.end(); ++it) + for(auto& am : m->getChildren()) { - DoubleArrayType::Pointer dblArray = DoubleArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_D"); + DoubleArrayType::Pointer dblArray = DoubleArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_D"); dblArray->initializeWithValue(5); - (*it)->addAttributeArray("TEST_D", dblArray); - FloatArrayType::Pointer fltArray = FloatArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_F"); + am->insertOrAssign(dblArray); + FloatArrayType::Pointer fltArray = FloatArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_F"); fltArray->initializeWithValue(5); - (*it)->addAttributeArray("TEST_F", fltArray); - Int8ArrayType::Pointer int8Array = Int8ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I8"); + am->insertOrAssign(fltArray); + Int8ArrayType::Pointer int8Array = Int8ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I8"); int8Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I8", int8Array); - UInt8ArrayType::Pointer uint8Array = UInt8ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI8"); + am->insertOrAssign(int8Array); + UInt8ArrayType::Pointer uint8Array = UInt8ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI8"); uint8Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI8", uint8Array); - Int16ArrayType::Pointer int16Array = Int16ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I16"); + am->insertOrAssign(uint8Array); + Int16ArrayType::Pointer int16Array = Int16ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I16"); int16Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I16", int16Array); - UInt16ArrayType::Pointer uint16Array = UInt16ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI16"); + am->insertOrAssign(int16Array); + UInt16ArrayType::Pointer uint16Array = UInt16ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI16"); uint16Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI16", uint16Array); - Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I32"); + am->insertOrAssign(uint16Array); + Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I32"); int32Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I32", int32Array); - UInt32ArrayType::Pointer uint32Array = UInt32ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI32"); + am->insertOrAssign(int32Array); + UInt32ArrayType::Pointer uint32Array = UInt32ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI32"); uint32Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI32", uint32Array); - Int64ArrayType::Pointer int64Array = Int64ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I64"); + am->insertOrAssign(uint32Array); + Int64ArrayType::Pointer int64Array = Int64ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I64"); int64Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I64", int64Array); - UInt64ArrayType::Pointer uint64Array = UInt64ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI64"); + am->insertOrAssign(int64Array); + UInt64ArrayType::Pointer uint64Array = UInt64ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI64"); uint64Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI64", uint64Array); - BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_BOOL"); + am->insertOrAssign(uint64Array); + BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_BOOL"); boolArray->initializeWithZeros(); - (*it)->addAttributeArray("TEST_BOOL", boolArray); + am->insertOrAssign(boolArray); } } @@ -171,16 +169,16 @@ class FindDerivativesFilterTest AttributeMatrix::Pointer attrMat; QString ss = QObject::tr("AttrMatType%1").arg(0); attrMat = AttributeMatrix::New(tDimsVert, ss, AttributeMatrix::Type::Vertex); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); ss = QObject::tr("AttrMatType%1").arg(1); attrMat = AttributeMatrix::New(tDimsVert, ss, AttributeMatrix::Type::Edge); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); ss = QObject::tr("AttrMatType%1").arg(2); attrMat = AttributeMatrix::New(tDimsVert, ss, AttributeMatrix::Type::Face); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); ss = QObject::tr("AttrMatType%1").arg(3); attrMat = AttributeMatrix::New(tDimsCell, ss, AttributeMatrix::Type::Cell); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); } // ----------------------------------------------------------------------------- @@ -207,7 +205,7 @@ class FindDerivativesFilterTest image->setDimensions(std::make_tuple(10, 10, 10)); image->setOrigin(std::make_tuple(0.0f, 0.0f, 0.0f)); - image->setResolution(std::make_tuple(1.0f, 1.0f, 1.0f)); + image->setSpacing(std::make_tuple(1.0f, 1.0f, 1.0f)); rectGrid->setDimensions(std::make_tuple(10, 10, 10)); FloatArrayType::Pointer xBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::xBoundsList); FloatArrayType::Pointer yBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::yBoundsList); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp index 0c136ef658..4c51325a4b 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp @@ -161,7 +161,7 @@ class GenerateColorTableTest filter->setDataContainerArray(dca); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) } // Validate Results @@ -208,8 +208,8 @@ class GenerateColorTableTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New(SIMPL::Defaults::ImageDataContainerName); AttributeMatrix::Pointer am = AttributeMatrix::New(QVector(1, 37989), SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, am); - dca->addDataContainer(dc); + dc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(dc); // Read Image File { @@ -242,7 +242,7 @@ class GenerateColorTableTest filter->setDataContainerArray(dca); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) } CheckPreset("Black, Blue and White", UnitTest::GenerateColorTableTest::BlackBlueWhiteFile, dca); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp index 7ac14f387f..f2e8e0e187 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp @@ -61,15 +61,15 @@ class ImportAsciDataArrayTest DataContainer::Pointer dc = DataContainer::New("ImageDataContainer"); ImageGeom::Pointer imageGeom = ImageGeom::New(); - imageGeom->setDimensions(m_XDim, m_YDim, m_ZDim); + imageGeom->setDimensions(SizeVec3Type(m_XDim, m_YDim, m_ZDim)); dc->setGeometry(imageGeom); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector tDims = {m_XDim, m_YDim, m_ZDim}; AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(attrMat->getName(), attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); FilterManager* fm = FilterManager::Instance(); @@ -112,17 +112,17 @@ class ImportAsciDataArrayTest #if 0 Observer obs; - filter->connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), - &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + filter->connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), + &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); #endif filter->preflight(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); attrMat->removeAttributeArray("ImportedData"); filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); typename DataArray::Pointer dataPtr = attrMat->getAttributeArrayAs>("ImportedData"); T* ptr = dataPtr->getPointer(0); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp index aecf6c5f07..d299068964 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp @@ -260,30 +260,30 @@ class ImportHDF5DatasetTest // Check empty file path error filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20001); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20001); + filter->clearErrorCode(); // Check incorrect extension error filter->setHDF5FilePath("foo.txt"); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20002); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20002); + filter->clearErrorCode(); // Check non-existent file error filter->setHDF5FilePath("foo.h5"); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20003); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20003); + filter->clearErrorCode(); // Put in the correct file path filter->setHDF5FilePath(m_FilePath); // Check empty dataset path error filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20004); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20004); + filter->clearErrorCode(); // Check incorrect dataset path error QList importInfoList; @@ -293,8 +293,8 @@ class ImportHDF5DatasetTest filter->setDatasetImportInfoList(importInfoList); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20005); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20005); + filter->clearErrorCode(); // Fill in Dataset Path with a valid path so that we can continue our error checks importInfoList.clear(); @@ -306,8 +306,8 @@ class ImportHDF5DatasetTest // Check empty component dimensions filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20006); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20006); + filter->clearErrorCode(); // Check incorrect component dimensions importInfoList.clear(); @@ -316,8 +316,8 @@ class ImportHDF5DatasetTest filter->setDatasetImportInfoList(importInfoList); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20007); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20007); + filter->clearErrorCode(); return filter; } @@ -331,10 +331,10 @@ class ImportHDF5DatasetTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(attrMat->getName(), attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); return dca; } @@ -412,7 +412,7 @@ class ImportHDF5DatasetTest } filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), errCode); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), errCode); // If we got through without errors, validate the results if(errCode == 0) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp index 3ef6e55676..a9b6678648 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp @@ -240,7 +240,7 @@ class MoveDataTest if(whatToMove == 0) // Move AttributeMatrix { - var.setValue(dapDst.getDataContainerName()); + var.setValue(dapDst); propWasSet = moveData->setProperty("DataContainerDestination", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -269,11 +269,11 @@ class MoveDataTest if(err >= 0) { - DREAM3D_REQUIRED(moveData->getErrorCondition(), >=, err) + DREAM3D_REQUIRED(moveData->getErrorCode(), >=, err) } else { - DREAM3D_REQUIRED(moveData->getErrorCondition(), ==, err) + DREAM3D_REQUIRED(moveData->getErrorCode(), ==, err) } // Check filter results if filter successfully executed @@ -387,26 +387,26 @@ class MoveDataTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); DataContainer::Pointer dcDst = DataContainer::New(k_DataContainerDstName); - dca->addDataContainer(dcDst); + dca->addOrReplaceDataContainer(dcDst); // Create AttributeMatrix AttributeMatrix::Pointer amSrc = AttributeMatrix::New(tupleDims, k_AttributeMatrixSrcName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixSrcName, amSrc); + dc->addOrReplaceAttributeMatrix(amSrc); AttributeMatrix::Pointer amDst = AttributeMatrix::New(tupleDims, k_AttributeMatrixDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixDstName, amDst); + dc->addOrReplaceAttributeMatrix(amDst); AttributeMatrix::Pointer amBadDst = AttributeMatrix::New(badTupleDims, k_AttributeMatrixBadDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixBadDstName, amBadDst); + dc->addOrReplaceAttributeMatrix(amBadDst); // Create DataArray IDataArray::Pointer daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - amSrc->addAttributeArray(k_DataArraySrcName, daSrc); + amSrc->insertOrAssign(daSrc); // Run test cases @@ -425,7 +425,7 @@ class MoveDataTest dcaTest = dca->deepCopy(); - dcaTest->getDataContainer(k_DataContainerDstName)->addAttributeMatrix(k_AttributeMatrixDstName, dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); + dcaTest->getDataContainer(k_DataContainerDstName)->addOrReplaceAttributeMatrix(dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); src = DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_DataArraySrcName); dst = DataArrayPath(k_DataContainerDstName, k_AttributeMatrixDstName, ""); @@ -454,7 +454,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -464,7 +464,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -474,7 +474,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -484,7 +484,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -494,7 +494,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -504,7 +504,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -514,7 +514,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -524,7 +524,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -534,7 +534,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp index 7e5b76aacb..a8bdcf4931 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp @@ -241,7 +241,7 @@ class MoveMultiDataTest if(whatToMove == 0) // Move AttributeMatrix { - var.setValue(dapDst.getDataContainerName()); + var.setValue(dapDst); propWasSet = moveMultiData->setProperty("DataContainerDestination", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -277,11 +277,11 @@ class MoveMultiDataTest if(err >= 0) { - DREAM3D_REQUIRED(moveMultiData->getErrorCondition(), >=, err) + DREAM3D_REQUIRED(moveMultiData->getErrorCode(), >=, err) } else { - DREAM3D_REQUIRED(moveMultiData->getErrorCondition(), ==, err) + DREAM3D_REQUIRED(moveMultiData->getErrorCode(), ==, err) } // Check filter results if filter successfully executed @@ -411,53 +411,53 @@ class MoveMultiDataTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); DataContainer::Pointer dcDst = DataContainer::New(k_DataContainerDstName); - dca->addDataContainer(dcDst); + dca->addOrReplaceDataContainer(dcDst); // Create AttributeMatrix AttributeMatrix::Pointer amSrc = AttributeMatrix::New(tupleDims, k_AttributeMatrixSrcName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixSrcName, amSrc); + dc->addOrReplaceAttributeMatrix(amSrc); AttributeMatrix::Pointer amDst = AttributeMatrix::New(tupleDims, k_AttributeMatrixDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixDstName, amDst); + dc->addOrReplaceAttributeMatrix(amDst); AttributeMatrix::Pointer amBadDst = AttributeMatrix::New(badTupleDims, k_AttributeMatrixBadDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixBadDstName, amBadDst); + dc->addOrReplaceAttributeMatrix(amBadDst); // Create DataArray IDataArray::Pointer daSrc = createDataArray(k_uint8ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_uint8ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_int8ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_int8ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_uint16ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_uint16ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_int16ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_int16ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_uint32ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_uint32ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_int32ArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_int32ArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_uint64ArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_uint64ArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_int64ArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_int64ArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_floatArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_floatArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_doubleArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_doubleArrayName, daSrc); + amDst->insertOrAssign(daSrc); // Run test cases @@ -505,7 +505,7 @@ class MoveMultiDataTest dcaTest = dca->deepCopy(); - dcaTest->getDataContainer(k_DataContainerDstName)->addAttributeMatrix(k_AttributeMatrixDstName, dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); + dcaTest->getDataContainer(k_DataContainerDstName)->addOrReplaceAttributeMatrix(dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); sources = { DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint8ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_int8ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint16ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_int16ArrayName), diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp index f2f07db745..2a10ae8e58 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp @@ -109,10 +109,10 @@ class MultiThresholdObjects2Test datai->setValue(i, inum); // int array inum += 1; } - am->addAttributeArray(dataf->getName(), dataf); // float array - am->addAttributeArray(datai->getName(), datai); // int array - vdc->addAttributeMatrix(am->getName(), am); - dca->addDataContainer(vdc); + am->insertOrAssign(dataf); // float array + am->insertOrAssign(datai); // int array + vdc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(vdc); // Now instantiate the MultiThresholdObjects2Test Filter from the FilterManager QString filtName = "MultiThresholdObjects2"; @@ -165,7 +165,7 @@ class MultiThresholdObjects2Test DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path = DataArrayPath(dataContainerName, SIMPL::Defaults::CellAttributeMatrixName, outputName); IDataArray::Pointer thresholdArray = @@ -240,7 +240,7 @@ class MultiThresholdObjects2Test DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path = DataArrayPath(dataContainerName, SIMPL::Defaults::CellAttributeMatrixName, outputName); IDataArray::Pointer thresholdArray = diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp index 116cf43a5f..891b858911 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp @@ -107,10 +107,10 @@ class MultiThresholdObjectsTest data1->setValue(i, inum); // int array inum += 1; } - am->addAttributeArray(data->getName(), data); // float array - am->addAttributeArray(data1->getName(), data1); // int array - vdc->addAttributeMatrix(am->getName(), am); - dca->addDataContainer(vdc); + am->insertOrAssign(data); // float array + am->insertOrAssign(data1); // int array + vdc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(vdc); // Now instantiate the MultiThresholdObjectsTest Filter from the FilterManager QString filtName = "MultiThresholdObjects"; @@ -144,7 +144,7 @@ class MultiThresholdObjectsTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path = DataArrayPath("dc1", SIMPL::Defaults::CellAttributeMatrixName, SIMPL::GeneralData::ThresholdArray); IDataArray::Pointer thresholdArray = vdc->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); @@ -179,7 +179,7 @@ class MultiThresholdObjectsTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path1 = DataArrayPath("dc1", SIMPL::Defaults::CellAttributeMatrixName, "ThresholdArray1"); IDataArray::Pointer thresholdArray1 = vdc->getAttributeMatrix(path1.getAttributeMatrixName())->getAttributeArray(path1.getDataArrayName()); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp index 637a91216a..e07ef3c3c2 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp @@ -207,7 +207,7 @@ class RawBinaryReaderTest // filt->setOrigin(origin); // FloatVec3Widget_t spacing; // spacing.x = spacing.y = spacing.z = 0.55f; - // filt->setResolution(spacing); + // filt->setSpacing(spacing); filt->setCreatedAttributeArrayPath(DataArrayPath("DataContainer", "AttributeMatrix", "Test_Array")); return filt; @@ -250,9 +250,9 @@ class RawBinaryReaderTest // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -260,14 +260,14 @@ class RawBinaryReaderTest // Preflight, get the error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute the filter, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = am->getAttributeArray("Test_Array"); @@ -355,9 +355,9 @@ class RawBinaryReaderTest // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -365,14 +365,14 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that the "file is too small" error is returned filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) am->clearAttributeArrays(); // Execute, get error condition, and check that the "file is too small" error is returned filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) } @@ -455,9 +455,9 @@ class RawBinaryReaderTest // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -465,14 +465,14 @@ class RawBinaryReaderTest // Preflight, get the error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get the error condition, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = am->getAttributeArray("Test_Array"); @@ -565,9 +565,9 @@ class RawBinaryReaderTest // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -575,14 +575,14 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get error condition, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = m->getAttributeMatrix(SIMPL::Defaults::AttributeMatrixName)->getAttributeArray("Test_Array"); @@ -601,9 +601,9 @@ class RawBinaryReaderTest // Create another data container DataContainer::Pointer m2 = DataContainer::New(SIMPL::Defaults::DataContainerName); - m2->addAttributeMatrix("AttributeMatrix", am); + m2->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca2 = DataContainerArray::New(); - dca2->addDataContainer(m2); + dca2->addOrReplaceDataContainer(m2); // Create another filter, passing in the skipHeaderBytes + 1 RawBinaryReader::Pointer filt2 = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes + 1); @@ -613,14 +613,14 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that there are errors filt2->preflight(); - err = filt2->getErrorCondition(); + err = filt2->getErrorCode(); DREAM3D_REQUIRED(err, <, 0) am->clearAttributeArrays(); // Execute, get error condition, and check that the "file too small" error occurred filt2->execute(); - err = filt2->getErrorCondition(); + err = filt2->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) } @@ -703,9 +703,9 @@ class RawBinaryReaderTest // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -713,14 +713,14 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get error condition, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = m->getAttributeMatrix(SIMPL::Defaults::AttributeMatrixName)->getAttributeArray("Test_Array"); @@ -813,9 +813,9 @@ class RawBinaryReaderTest // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -823,12 +823,12 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that the "file too small" error has occurred filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) // Execute, get error condition, and check that there are errors filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, <, 0) } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp index 540ca7483f..8fd3640d4b 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp @@ -135,8 +135,8 @@ class ReadASCIIDataTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New(DataContainerName); AttributeMatrix::Pointer am = AttributeMatrix::New(QVector(1, data.numberOfLines), AttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(AttributeMatrixName, am); - dca->addDataContainer(dc); + dc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(dc); // Now instantiate the DxWriter Filter from the FilterManager QString filtName = "ReadASCIIData"; @@ -149,7 +149,7 @@ class ReadASCIIDataTest AbstractFilter::Pointer importASCIIData = filterFactory->create(); importASCIIData->preflight(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::EMPTY_FILE) QVariant var; @@ -158,7 +158,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) importASCIIData->preflight(); - err = importASCIIData->getErrorCondition(); + err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::EMPTY_ATTR_MATRIX) importASCIIData->setDataContainerArray(dca); @@ -199,7 +199,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -232,7 +232,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -264,7 +264,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::CONVERSION_FAILURE) } @@ -279,7 +279,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -313,7 +313,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -341,7 +341,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -369,7 +369,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::CONVERSION_FAILURE) } @@ -405,7 +405,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::CONVERSION_FAILURE) } } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp index 3ba1de82ea..3ea5d0f7e0 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp @@ -81,14 +81,14 @@ class RemoveArraysTest sizeList.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(sizeList, "AttributeMatrix", AttributeMatrix::Type::Any); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); FilterManager* fm = FilterManager::Instance(); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp index 93537fa767..b58231457b 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp @@ -134,7 +134,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -157,7 +157,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -171,9 +171,9 @@ class RemoveComponentFromArrayTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(QVector(1, numTuples), SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); - m->addAttributeMatrix(SIMPL::Defaults::AttributeMatrixName, attrMatrix); + m->addOrReplaceAttributeMatrix(attrMatrix); return dca; } // ----------------------------------------------------------------------------- @@ -214,7 +214,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); IDataArray::Pointer ReducedArrayPtr = dca->getDataContainer(SIMPL::Defaults::DataContainerName)->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(ReducedArrayArrayName); @@ -258,7 +258,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -11004); // Test to make sure sending in a single component array fails. @@ -283,7 +283,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -11003); } @@ -344,13 +344,13 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); { @@ -370,14 +370,14 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); IDataArray::Pointer testArrayPtr = dca->getDataContainer(SIMPL::Defaults::DataContainerName)->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp index cc8ec233ba..519997019f 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp @@ -91,12 +91,12 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -111,7 +111,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11016); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11016); } // ----------------------------------------------------------------------------- @@ -126,15 +126,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -149,7 +149,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11016); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11016); } // ----------------------------------------------------------------------------- @@ -164,15 +164,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -187,7 +187,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DREAM3D_REQUIRE_EQUAL(da->getName(), newAttributeArrayName); } @@ -204,15 +204,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -227,7 +227,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11009); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11009); } // ----------------------------------------------------------------------------- @@ -242,15 +242,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -264,7 +264,7 @@ class RenameAttributeArrayTest value.setValue(newAttributeArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11009); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11009); } // ----------------------------------------------------------------------------- @@ -279,17 +279,17 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); DataArray::Pointer da2 = DataArray::CreateArray(1, "DataArray_2"); - am->addAttributeArray("DataArray_2", da2); + am->insertOrAssign(da2); filter->setDataContainerArray(dca); @@ -304,7 +304,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11017); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11017); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp index 43195c0a70..758797f7dc 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp @@ -91,7 +91,7 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); @@ -106,7 +106,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -307020); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -307020); } // ----------------------------------------------------------------------------- @@ -121,12 +121,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -141,7 +141,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -301000); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -301000); } // ----------------------------------------------------------------------------- @@ -156,12 +156,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -176,7 +176,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DREAM3D_REQUIRE_EQUAL(am->getName(), newAttributeMatrixName); } @@ -193,12 +193,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -213,7 +213,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11004); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11004); } // ----------------------------------------------------------------------------- @@ -228,12 +228,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); QVector dims = QVector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -247,7 +247,7 @@ class RenameAttributeMatrixTest value.setValue(newAttributeMatrixName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11004); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11004); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp index 56528a46e7..8cbe9e7c12 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp @@ -93,16 +93,16 @@ class RenameDataContainerTest QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = "DataContainer_"; + DataArrayPath newDataContainerName("DataContainer_"); value.setValue(dataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -999); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -999); } // ----------------------------------------------------------------------------- @@ -117,22 +117,22 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = ""; + DataArrayPath dataContainerName; value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = "DataContainer_"; + DataArrayPath newDataContainerName("DataContainer_"); value.setValue(dataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11001); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11001); } // ----------------------------------------------------------------------------- @@ -147,24 +147,26 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName ("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = "Container_2"; + DataArrayPath newDataContainerName ("Container_2"); value.setValue(newDataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); - DREAM3D_REQUIRE_EQUAL(dc->getName(), newDataContainerName); + DataArrayPath dap(dc->getName()); + + DREAM3D_REQUIRE_EQUAL(dap, newDataContainerName); } // ----------------------------------------------------------------------------- @@ -179,22 +181,22 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName ( "DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = ""; + DataArrayPath newDataContainerName; value.setValue(newDataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11001); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11001); } // ----------------------------------------------------------------------------- @@ -209,21 +211,21 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = ""; + DataArrayPath newDataContainerName; value.setValue(newDataContainerName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11001); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11001); } // ----------------------------------------------------------------------------- @@ -245,4 +247,4 @@ class RenameDataContainerTest private: RenameDataContainerTest(const RenameDataContainerTest&); // Copy Constructor Not Implemented void operator=(const RenameDataContainerTest&); // Move assignment Not Implemented -}; \ No newline at end of file +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameTimingTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameTimingTest.cpp new file mode 100644 index 0000000000..d75a2c8f15 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameTimingTest.cpp @@ -0,0 +1,156 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include +#include + +#include +#include + +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +#include "SIMPLib/CoreFilters/RenameDataContainer.h" + +class RenameTimingTest +{ +public: + RenameTimingTest() = default; + virtual ~RenameTimingTest() = default; + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + AbstractFilter::Pointer createFilter() + { + // Now instantiate the RenameAttributeArray Filter from the FilterManager + QString filtName = "MassCreateData"; + FilterManager* fm = FilterManager::Instance(); + IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); + if(nullptr == filterFactory.get()) + { + std::stringstream ss; + ss << "The RenameTimingTest Requires the use of the " << filtName.toStdString() << " filter which is found in Core Filters"; + DREAM3D_TEST_THROW_EXCEPTION(ss.str()) + } + + AbstractFilter::Pointer filter = filterFactory->create(); + DREAM3D_REQUIRE(nullptr != filter.get()); + + return filter; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + FilterPipeline::Pointer createPipeline() + { + const int iterations = 2; + FilterPipeline::Pointer pipeline = FilterPipeline::New(); + for(int i = 0; i < iterations; i++) + { + AbstractFilter::Pointer filter = createFilter(); + + QVariant value; + QString dataContainerName = "DataContainer_" + QString::number(i); + value.setValue(dataContainerName); + filter->setProperty("DataContainerName", value); + pipeline->pushBack(filter); + } + return pipeline; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestPreflightTimes() + { + //const int iterations = 1; + FilterPipeline::Pointer pipeline = createPipeline(); + + { + auto start = std::chrono::steady_clock::now(); + pipeline->preflightPipeline(); + auto end = std::chrono::steady_clock::now(); + + auto elapsed = std::chrono::duration_cast(end - start); + std::cout << "\tFirst Preflight Duration: " << elapsed.count() << " milliseconds" << std::endl; + } + + QVariant value; + value.setValue(QString("NewName")); + AbstractFilter::Pointer filter = pipeline->getFilterContainer().front(); + filter->setProperty("DataContainerName", value); + + { + auto start = std::chrono::steady_clock::now(); + //for(int i = 0; i < iterations; i++) + { + pipeline->preflightPipeline(); + } + auto end = std::chrono::steady_clock::now(); + + auto elapsed = std::chrono::duration_cast(end - start); + std::cout << "\tSecond Preflight Duration: " << elapsed.count() << " milliseconds" << std::endl; + } + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + std::cout << "#### RenameTimingTest Starting ####" << std::endl; + + int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST(TestPreflightTimes()); + } + +private: + RenameTimingTest(const RenameTimingTest&); // Copy Constructor Not Implemented + void operator=(const RenameTimingTest&); // Move assignment Not Implemented +}; \ No newline at end of file diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp index 353d70988f..a832d55b5e 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp @@ -54,7 +54,7 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDims, initVal, comps, err) \ DataArray::Pointer _##type##_##comps##_##attrMat##Array = DataArray::CreateArray(tDims, cDims, #type #comps, true); \ - err = attrMat->addAttributeArray(#type #comps, _##type##_##comps##_##attrMat##Array); \ + err = attrMat->insertOrAssign(_##type##_##comps##_##attrMat##Array); \ _##type##_##comps##_##attrMat##Array->initializeWithValue(initVal); \ DREAM3D_REQUIRE(err >= 0); @@ -82,7 +82,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, errVal); #ifdef SET_PROPERTIES_AND_CHECK_EQ @@ -109,7 +109,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ dataArray = dc->getAttributeMatrix(selectedArray.getAttributeMatrixName())->getAttributeArray(selectedArray.getDataArrayName()); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ @@ -154,9 +154,9 @@ class ReplaceValueTest QVector tDims(1, 100); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "ReplaceValueAttrMat", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("ReplaceValueAttrMat", attrMat); + m->addOrReplaceAttributeMatrix(attrMat); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); QVector cDims(1, 3); int32_t initVal = 10; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp index 9bfd6668ac..ff2fce2bbf 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp @@ -67,10 +67,10 @@ class RequiredZThicknessTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc1 = DataContainer::New("DataContainer1"); - dca->addDataContainer(dc1); + dca->addOrReplaceDataContainer(dc1); DataContainer::Pointer dc2 = DataContainer::New("DataContainer2"); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc2); ImageGeom::Pointer imgGeom = ImageGeom::New(); imgGeom->setDimensions(2, 2, 2); @@ -143,7 +143,7 @@ class RequiredZThicknessTest QVariant value; - value.setValue(QString("DataContainer1")); + value.setValue(DataArrayPath("DataContainer1")); filter->setProperty("DataContainerSelection", value); value.setValue(numZVoxels); @@ -162,7 +162,7 @@ class RequiredZThicknessTest QVariant value; - value.setValue(QString("DataContainer2")); + value.setValue(DataArrayPath("DataContainer2")); filter->setProperty("DataContainerSelection", value); value.setValue(numZVoxels); @@ -181,7 +181,7 @@ class RequiredZThicknessTest QVariant value; - value.setValue(QString("DataContainer3")); + value.setValue(DataArrayPath("DataContainer3")); filter->setProperty("DataContainerSelection", value); value.setValue(0); @@ -198,12 +198,12 @@ class RequiredZThicknessTest setGeometryTest(filter, 1); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); // test Z equal to minimum Z setGeometryTest(filter, 2); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); } // ----------------------------------------------------------------------------- @@ -216,7 +216,7 @@ class RequiredZThicknessTest setGeometryTest(filter, 3); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -7788); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -7788); } // ----------------------------------------------------------------------------- @@ -229,7 +229,7 @@ class RequiredZThicknessTest setInvalidGeometry(filter, 3); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -7789); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -7789); } // ----------------------------------------------------------------------------- @@ -243,7 +243,7 @@ class RequiredZThicknessTest setNullDataContainer(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -999); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -999); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp index 4c9be1f05a..a9b9f36ee1 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp @@ -55,7 +55,7 @@ namespace ScaleVolumeTestConsts { -const FloatVec3_t SCALE = FloatVec3_t{3, 3, 3}; +const FloatVec3Type SCALE = FloatVec3Type{3, 3, 3}; } class ScaleVolumeTest @@ -72,16 +72,16 @@ class ScaleVolumeTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc1 = DataContainer::New("DataContainer1"); - dca->addDataContainer(dc1); + dca->addOrReplaceDataContainer(dc1); DataContainer::Pointer dc2 = DataContainer::New("DataContainer2"); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc2); DataContainer::Pointer dc3 = DataContainer::New("DataContainer3"); - dca->addDataContainer(dc3); + dca->addOrReplaceDataContainer(dc3); DataContainer::Pointer dc4 = DataContainer::New("DataContainer4"); - dca->addDataContainer(dc4); + dca->addOrReplaceDataContainer(dc4); ImageGeom::Pointer imgGeom = ImageGeom::New(); imgGeom->setDimensions(2, 2, 2); @@ -154,19 +154,24 @@ class ScaleVolumeTest QVariant value; value.setValue(imageGeometry); - filter->setProperty("ApplyToVoxelVolume", value); + bool propWasSet = filter->setProperty("ApplyToVoxelVolume", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(surfaceGeometry); - filter->setProperty("ApplyToSurfaceMesh", value); + propWasSet = filter->setProperty("ApplyToSurfaceMesh", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(ScaleVolumeTestConsts::SCALE); - filter->setProperty("ScaleFactor", value); + propWasSet = filter->setProperty("ScaleFactor", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer1")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer1")); + propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer2")); - filter->setProperty("SurfaceDataContainerName", value); + value.setValue(DataArrayPath("DataContainer2")); + propWasSet = filter->setProperty("SurfaceDataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -182,19 +187,24 @@ class ScaleVolumeTest QVariant value; value.setValue(imageGeometry); - filter->setProperty("ApplyToVoxelVolume", value); + bool propWasSet = filter->setProperty("ApplyToVoxelVolume", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(surfaceGeometry); - filter->setProperty("ApplyToSurfaceMesh", value); + propWasSet = filter->setProperty("ApplyToSurfaceMesh", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(ScaleVolumeTestConsts::SCALE); - filter->setProperty("ScaleFactor", value); + propWasSet = filter->setProperty("ScaleFactor", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer2")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer2")); + propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer1")); - filter->setProperty("SurfaceDataContainerName", value); + value.setValue(DataArrayPath("DataContainer1")); + propWasSet = filter->setProperty("SurfaceDataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -210,19 +220,24 @@ class ScaleVolumeTest QVariant value; value.setValue(imageGeometry); - filter->setProperty("ApplyToVoxelVolume", value); + bool propWasSet = filter->setProperty("ApplyToVoxelVolume", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(surfaceGeometry); - filter->setProperty("ApplyToSurfaceMesh", value); + propWasSet = filter->setProperty("ApplyToSurfaceMesh", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(ScaleVolumeTestConsts::SCALE); - filter->setProperty("ScaleFactor", value); + propWasSet = filter->setProperty("ScaleFactor", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer3")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer3")); + propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer4")); - filter->setProperty("SurfaceDataContainerName", value); + value.setValue(DataArrayPath("DataContainer4")); + propWasSet = filter->setProperty("SurfaceDataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -236,21 +251,19 @@ class ScaleVolumeTest setGeometryTest(filter, true, false); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer1"); ImageGeom::Pointer imgGeom = std::dynamic_pointer_cast(dc->getGeometry()); DREAM3D_REQUIRE(imgGeom != nullptr); - float xRes = 0.0f; - float yRes = 0.0f; - float zRes = 0.0f; - std::tie(xRes, yRes, zRes) = imgGeom->getResolution(); + FloatVec3Type spacing; + imgGeom->getSpacing(spacing); - DREAM3D_REQUIRE_EQUAL(xRes, ScaleVolumeTestConsts::SCALE.x); - DREAM3D_REQUIRE_EQUAL(yRes, ScaleVolumeTestConsts::SCALE.y); - DREAM3D_REQUIRE_EQUAL(zRes, ScaleVolumeTestConsts::SCALE.z); + DREAM3D_REQUIRE_EQUAL(spacing[0], ScaleVolumeTestConsts::SCALE[0]); + DREAM3D_REQUIRE_EQUAL(spacing[1], ScaleVolumeTestConsts::SCALE[1]); + DREAM3D_REQUIRE_EQUAL(spacing[2], ScaleVolumeTestConsts::SCALE[2]); } // ----------------------------------------------------------------------------- @@ -264,7 +277,7 @@ class ScaleVolumeTest setGeometryTest(filter, false, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer2"); TriangleGeom::Pointer triGeom = std::dynamic_pointer_cast(dc->getGeometry()); @@ -297,7 +310,7 @@ class ScaleVolumeTest setIncorrectGeometry(filter, true, false); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -384); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -384); } // ----------------------------------------------------------------------------- @@ -311,7 +324,7 @@ class ScaleVolumeTest setIncorrectGeometry(filter, false, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -384); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -384); } // ----------------------------------------------------------------------------- @@ -325,7 +338,7 @@ class ScaleVolumeTest setNullGeometry(filter, true, false); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -385); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -385); } // ----------------------------------------------------------------------------- @@ -339,7 +352,7 @@ class ScaleVolumeTest setNullGeometry(filter, false, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -385); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -385); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp index 54fa25797c..5dff07fe0f 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp @@ -55,8 +55,8 @@ namespace SetOriginResolutionImageGeometryTest { -const FloatVec3_t ORIGIN = FloatVec3_t{1, 2, 3}; -const FloatVec3_t RESOLUTION = FloatVec3_t{4, 5, 6}; +const FloatVec3Type ORIGIN = FloatVec3Type{1, 2, 3}; +const FloatVec3Type RESOLUTION = FloatVec3Type{4, 5, 6}; } class SetOriginResolutionImageGeomTest @@ -73,13 +73,13 @@ class SetOriginResolutionImageGeomTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc1 = DataContainer::New("DataContainer1"); - dca->addDataContainer(dc1); + dca->addOrReplaceDataContainer(dc1); DataContainer::Pointer dc2 = DataContainer::New("DataContainer2"); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc2); DataContainer::Pointer dc3 = DataContainer::New("DataContainer3"); - dca->addDataContainer(dc3); + dca->addOrReplaceDataContainer(dc3); ImageGeom::Pointer imgGeom = ImageGeom::New(); imgGeom->setDimensions(2, 2, 2); @@ -152,8 +152,9 @@ class SetOriginResolutionImageGeomTest QVariant value; - value.setValue(QString("DataContainer1")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer1")); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -168,8 +169,9 @@ class SetOriginResolutionImageGeomTest QVariant value; - value.setValue(QString("DataContainer2")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer2")); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -184,8 +186,9 @@ class SetOriginResolutionImageGeomTest QVariant value; - value.setValue(QString("DataContainer3")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer3")); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -201,10 +204,12 @@ class SetOriginResolutionImageGeomTest QVariant value; value.setValue(true); - filter->setProperty("ChangeOrigin", value); + bool propWasSet = filter->setProperty("ChangeOrigin", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(SetOriginResolutionImageGeometryTest::ORIGIN); - filter->setProperty("Origin", value); + propWasSet = filter->setProperty("Origin", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -220,10 +225,12 @@ class SetOriginResolutionImageGeomTest QVariant value; value.setValue(true); - filter->setProperty("ChangeResolution", value); + bool propWasSet = filter->setProperty("ChangeResolution", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(SetOriginResolutionImageGeometryTest::RESOLUTION); - filter->setProperty("Resolution", value); + propWasSet = filter->setProperty("Spacing", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -238,18 +245,18 @@ class SetOriginResolutionImageGeomTest changeOrigin(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer1"); ImageGeom::Pointer imgGeom = std::dynamic_pointer_cast(dc->getGeometry()); DREAM3D_REQUIRE(imgGeom != nullptr); - float origin[3]; + FloatVec3Type origin; imgGeom->getOrigin(origin); - DREAM3D_REQUIRE_EQUAL(origin[0], SetOriginResolutionImageGeometryTest::ORIGIN.x); - DREAM3D_REQUIRE_EQUAL(origin[1], SetOriginResolutionImageGeometryTest::ORIGIN.y); - DREAM3D_REQUIRE_EQUAL(origin[2], SetOriginResolutionImageGeometryTest::ORIGIN.z); + DREAM3D_REQUIRE_EQUAL(origin[0], SetOriginResolutionImageGeometryTest::ORIGIN[0]); + DREAM3D_REQUIRE_EQUAL(origin[1], SetOriginResolutionImageGeometryTest::ORIGIN[1]); + DREAM3D_REQUIRE_EQUAL(origin[2], SetOriginResolutionImageGeometryTest::ORIGIN[2]); } // ----------------------------------------------------------------------------- @@ -264,7 +271,7 @@ class SetOriginResolutionImageGeomTest changeResolution(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer1"); ImageGeom::Pointer imgGeom = std::dynamic_pointer_cast(dc->getGeometry()); @@ -274,11 +281,11 @@ class SetOriginResolutionImageGeomTest float xRes = 0.0f; float yRes = 0.0f; float zRes = 0.0f; - std::tie(xRes, yRes, zRes) = imgGeom->getResolution(); + std::tie(xRes, yRes, zRes) = imgGeom->getSpacing(); - DREAM3D_REQUIRE_EQUAL(xRes, SetOriginResolutionImageGeometryTest::RESOLUTION.x); - DREAM3D_REQUIRE_EQUAL(yRes, SetOriginResolutionImageGeometryTest::RESOLUTION.y); - DREAM3D_REQUIRE_EQUAL(zRes, SetOriginResolutionImageGeometryTest::RESOLUTION.z); + DREAM3D_REQUIRE_EQUAL(xRes, SetOriginResolutionImageGeometryTest::RESOLUTION[0]); + DREAM3D_REQUIRE_EQUAL(yRes, SetOriginResolutionImageGeometryTest::RESOLUTION[1]); + DREAM3D_REQUIRE_EQUAL(zRes, SetOriginResolutionImageGeometryTest::RESOLUTION[2]); } // ----------------------------------------------------------------------------- @@ -292,7 +299,7 @@ class SetOriginResolutionImageGeomTest setInvalidGeometry(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -384); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -384); } // ----------------------------------------------------------------------------- @@ -306,7 +313,7 @@ class SetOriginResolutionImageGeomTest setNullGeometry(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -385); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -385); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake b/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake index ff3ff7fc0b..16a27426fe 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake @@ -2,6 +2,7 @@ set(TEST_TESTFILES_DIR ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx/TestFiles) set(TEST_${SUBDIR_NAME}_NAMES + ApplyImageTransformsTest ArrayCalculatorTest CombineAttributeArraysTest CombineAttributeMatricesTest @@ -40,6 +41,7 @@ set(TEST_${SUBDIR_NAME}_NAMES RenameAttributeArrayTest RenameAttributeMatrixTest RenameDataContainerTest + # RenameTimingTest ReplaceValueTest RequiredZThicknessTest ScaleVolumeTest diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp index f3f8638d87..c01fcbb8a5 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp @@ -108,21 +108,21 @@ class SplitAttributeArrayTest SizeTArrayType::Pointer mcArray13 = SizeTArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array size_t"); fillDataArray(mcArray13); - am1->addAttributeArray("MultiComponent Array uint32_t", mcArray1); - am1->addAttributeArray("MultiComponent Array bool", mcArray2); - am1->addAttributeArray("MultiComponent Array unsigned char", mcArray3); - am1->addAttributeArray("MultiComponent Array int8_t", mcArray4); - am1->addAttributeArray("MultiComponent Array uint8_t", mcArray5); - am1->addAttributeArray("MultiComponent Array int16_t", mcArray6); - am1->addAttributeArray("MultiComponent Array uint16_t", mcArray7); - am1->addAttributeArray("MultiComponent Array int32_t", mcArray8); - am1->addAttributeArray("MultiComponent Array int64_t", mcArray9); - am1->addAttributeArray("MultiComponent Array uint64_t", mcArray10); - am1->addAttributeArray("MultiComponent Array float", mcArray11); - am1->addAttributeArray("MultiComponent Array double", mcArray12); - am1->addAttributeArray("MultiComponent Array size_t", mcArray13); - dc->addAttributeMatrix("AttributeMatrix", am1); - dca->addDataContainer(dc); + am1->insertOrAssign(mcArray1); + am1->insertOrAssign(mcArray2); + am1->insertOrAssign(mcArray3); + am1->insertOrAssign(mcArray4); + am1->insertOrAssign(mcArray5); + am1->insertOrAssign(mcArray6); + am1->insertOrAssign(mcArray7); + am1->insertOrAssign(mcArray8); + am1->insertOrAssign(mcArray9); + am1->insertOrAssign(mcArray10); + am1->insertOrAssign(mcArray11); + am1->insertOrAssign(mcArray12); + am1->insertOrAssign(mcArray13); + dc->addOrReplaceAttributeMatrix(am1); + dca->addOrReplaceDataContainer(dc); return dca; } @@ -224,7 +224,7 @@ class SplitAttributeArrayTest { // Observer obs; // QObject::connect( - // filter.get(), &AbstractFilter::filterGeneratedMessage, + // filter.get(), &AbstractFilter::messageGenerated, // &obs, &Observer::processPipelineMessage // ); @@ -240,13 +240,13 @@ class SplitAttributeArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) dca = createDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) using DataArrayPtrType = std::shared_ptr>; DataArrayPtrType mcArray_original = diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp index e8f0b98c19..2e081ca19f 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp @@ -104,9 +104,9 @@ class WriteASCIIDataTest strArray->setValue(8, QString("Weird words")); strArray->setValue(9, QString("Sierra")); - am->addAttributeArray(strArray->getName(), strArray); - dc->addAttributeMatrix(am->getName(), am); - dca->addDataContainer(dc); + am->insertOrAssign(strArray); + dc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(dc); QVector paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "ASCII_Data")}; WriteASCIIData::Pointer writer = WriteASCIIData::New(); @@ -119,62 +119,62 @@ class WriteASCIIDataTest writer->setOutputStyle(WriteASCIIData::MultiFile); writer->preflight(); - int err = writer->getErrorCondition(); + int err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) // Test Single File mode writer->setOutputStyle(WriteASCIIData::SingleFile); writer->setOutputFilePath(UnitTest::TestTempDir + "/" + "SingleFileMode.csv"); writer->preflight(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) // Back to MultiFile mode writer->setOutputStyle(WriteASCIIData::MultiFile); NeighborList::Pointer neighborList = NeighborList::CreateArray(k_ArraySize, "NeighborList", true); - am->addAttributeArray(neighborList->getName(), neighborList); + am->insertOrAssign(neighborList); paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "NeighborList")}; writer->setSelectedDataArrayPaths(paths); writer->preflight(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) StructArray::Pointer structArray = StructArray::CreateArray(k_ArraySize, "StructArray", true); - am->addAttributeArray(structArray->getName(), structArray); + am->insertOrAssign(structArray); paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "StructArray")}; writer->setSelectedDataArrayPaths(paths); writer->preflight(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) StatsDataArray::Pointer statsDataArray = StatsDataArray::CreateArray(k_ArraySize, "StatsDataArray", true); - am->addAttributeArray(statsDataArray->getName(), statsDataArray); + am->insertOrAssign(statsDataArray); paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "StatsDataArray")}; writer->setSelectedDataArrayPaths(paths); writer->preflight(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp index 50ce965479..1af2f35492 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp @@ -102,7 +102,7 @@ class WriteTriangleGeometryTest { // Names and Constants - static const QString k_DataContainerName("DataContainer"); + static const DataArrayPath k_DataContainerPath("DataContainer", "", ""); static const QString k_TriVertexListDAName("TriVertexList"); static const QString k_TriListDAName("TriangleList"); @@ -116,8 +116,8 @@ class WriteTriangleGeometryTest // Create DataContainer - DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + DataContainer::Pointer dc = DataContainer::New(k_DataContainerPath); + dca->addOrReplaceDataContainer(dc); // Create Triangle Data Arrays @@ -164,7 +164,7 @@ class WriteTriangleGeometryTest QVariant var; - var.setValue(k_DataContainerName); + var.setValue(k_DataContainerPath); bool propWasSet = writeTriangleGeometry->setProperty("DataContainerSelection", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -179,7 +179,7 @@ class WriteTriangleGeometryTest // Run filter writeTriangleGeometry->execute(); - DREAM3D_REQUIRED(writeTriangleGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(writeTriangleGeometry->getErrorCode(), >=, 0); // Test filter diff --git a/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp b/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp index d10bc582bd..a4e42f7e95 100644 --- a/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp +++ b/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp @@ -83,8 +83,7 @@ template class WriteASCIIDataPrivate if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("The output file could not be opened: '%1'").arg(outputFile); - filter->setErrorCondition(-11012); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-11012, ss); return; } @@ -143,7 +142,7 @@ WriteASCIIData::~WriteASCIIData() = default; // ----------------------------------------------------------------------------- void WriteASCIIData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); @@ -226,33 +225,30 @@ void WriteASCIIData::dataCheck() // Make sure the weak pointer vector is cleared before we begin... m_SelectedWeakPtrVector.clear(); - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); //**************** MultiFile Checks ****************** if(m_OutputStyle == MultiFile) { if(m_OutputPath.isEmpty()) { - setErrorCondition(-11002); QString ss = QObject::tr("The output path must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } if(m_MaxValPerLine <= 0) { - setErrorCondition(-11003); QString ss = QObject::tr("The Maximum Tuples Per Line (%1) must be positive").arg(m_MaxValPerLine); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); return; } if(m_FileExtension.isEmpty()) { - setErrorCondition(-11004); QString ss = QObject::tr("The file extension must be set."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } } @@ -261,33 +257,29 @@ void WriteASCIIData::dataCheck() { if(m_OutputFilePath.isEmpty()) { - setErrorCondition(-11005); QString ss = QObject::tr("The output file path must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11005, ss); } QFileInfo fi(m_OutputPath); QDir parentPath = fi.path(); if(!parentPath.exists()) { - setWarningCondition(-11006); QString ss = QObject::tr("The directory path for the output file does not exist. DREAM.3D will attempt to create this path during execution of the filter"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11006, ss); } } else { QString ss = QObject::tr("The type of output did not match either 0 (Multi-File) or 1 (Single File)"); - setErrorCondition(-11009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11009, ss); return; } if(m_SelectedDataArrayPaths.isEmpty()) { - setErrorCondition(-11007); QString ss = QObject::tr("At least one Attribute Array must be selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11007, ss); return; } @@ -295,9 +287,8 @@ void WriteASCIIData::dataCheck() if(!DataArrayPath::ValidateVector(paths)) { - setErrorCondition(-11008); QString ss = QObject::tr("There are Attribute Arrays selected that are not contained in the same Attribute Matrix. All selected Attribute Arrays must belong to the same Attribute Matrix"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11008, ss); return; } @@ -305,25 +296,22 @@ void WriteASCIIData::dataCheck() { IDataArray::WeakPointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if( ptr.lock()->getTypeAsString().compare("NeighborList") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "NeighborList is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "NeighborList is unsupported when writing ASCII Data."); } else if( ptr.lock()->getTypeAsString().compare("struct") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StructArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StructArray is unsupported when writing ASCII Data."); } else if( ptr.lock()->getTypeAsString().compare("StatsDataArray") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StatsDataArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StatsDataArray is unsupported when writing ASCII Data."); } else { @@ -351,11 +339,11 @@ void WriteASCIIData::preflight() // ----------------------------------------------------------------------------- void WriteASCIIData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -363,8 +351,7 @@ void WriteASCIIData::execute() if(m_SelectedDataArrayPaths.count() != m_SelectedWeakPtrVector.count()) { QString ss = QObject::tr("The number of selected Attribute Arrays does not equal the number of internal weak pointers"); - setErrorCondition(-11010); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11010, ss); return; } @@ -379,8 +366,7 @@ void WriteASCIIData::execute() else { QString ss = QObject::tr("The type of output did not match either 0 (Multi-File) or 1 (Single File)"); - setErrorCondition(-11009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11009, ss); return; } } @@ -393,8 +379,7 @@ void WriteASCIIData::writeMultiFileOutput() if(!dir.mkpath(m_OutputPath)) { ss = QObject::tr("Error creating output path '%1'").arg(m_OutputPath); - setErrorCondition(-11004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } @@ -408,7 +393,7 @@ void WriteASCIIData::writeMultiFileOutput() IDataArray::Pointer selectedArrayPtr = m_SelectedWeakPtrVector.at(i).lock(); QString message = QObject::tr("|| Exporting Dataset '%1'").arg(selectedArrayPtr->getName()); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), message); + notifyStatusMessage(message); QString exportArrayFile = m_OutputPath + QDir::separator() + selectedArrayPtr->getName() + m_FileExtension; // the complete output file path, name and extension @@ -421,24 +406,20 @@ void WriteASCIIData::writeMultiFileOutput() } else if( selectedArrayPtr->getTypeAsString().compare("NeighborList") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "NeighborList is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "NeighborList is unsupported when writing ASCII Data."); } else if( selectedArrayPtr->getTypeAsString().compare("struct") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StructArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StructArray is unsupported when writing ASCII Data."); } else if( selectedArrayPtr->getTypeAsString().compare("StatsDataArray") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StatsDataArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StatsDataArray is unsupported when writing ASCII Data."); } else EXECUTE_TEMPLATE(this, WriteASCIIDataPrivate, selectedArrayPtr, this, selectedArrayPtr, delimiter, exportArrayFile, m_MaxValPerLine) - - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { break; } @@ -456,8 +437,7 @@ void WriteASCIIData::writeSingleFileOutput() if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-11020); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11020, ss); return; } @@ -465,8 +445,7 @@ void WriteASCIIData::writeSingleFileOutput() if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getOutputFilePath()); - setErrorCondition(-11021); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11021, ss); return; } @@ -519,7 +498,7 @@ void WriteASCIIData::writeSingleFileOutput() if(percentIncrement > threshold) { QString ss = QObject::tr("Writing Output: %1%").arg(static_cast(percentIncrement)); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + notifyStatusMessage(ss); threshold = threshold + 5.0f; if(threshold < percentIncrement) { @@ -555,8 +534,7 @@ void WriteASCIIData::writeStringArray(const IDataArray::Pointer& inputData, cons if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("The output file could not be opened: '%1'").arg(outputFile); - setErrorCondition(-11011); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11011, ss); return; } diff --git a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp index 40308ae403..a2bce89829 100644 --- a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp @@ -70,7 +70,7 @@ WriteTriangleGeometry::~WriteTriangleGeometry() = default; // ----------------------------------------------------------------------------- void WriteTriangleGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output Nodes File", OutputNodesFile, FilterParameter::Parameter, WriteTriangleGeometry)); parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output Triangles File", OutputTrianglesFile, FilterParameter::Parameter, WriteTriangleGeometry)); @@ -89,7 +89,7 @@ void WriteTriangleGeometry::setupFilterParameters() void WriteTriangleGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerSelection(reader->readString("DataContainerSelection", getDataContainerSelection())); + setDataContainerSelection(reader->readDataArrayPath("DataContainerSelection", getDataContainerSelection())); setOutputNodesFile(reader->readString("OutputNodesFile", getOutputNodesFile())); setOutputTrianglesFile(reader->readString("OutputTrianglesFile", getOutputTrianglesFile())); reader->closeFilterGroup(); @@ -107,8 +107,8 @@ void WriteTriangleGeometry::initialize() // ----------------------------------------------------------------------------- void WriteTriangleGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QFileInfo fi(getOutputNodesFile()); @@ -126,13 +126,13 @@ void WriteTriangleGeometry::dataCheck() FileSystemPathHelper::CheckOutputFile(this, "Output Triangles File", getOutputTrianglesFile(), true); DataContainer::Pointer dataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerSelection()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } TriangleGeom::Pointer triangles = dataContainer->getPrereqGeometry(this); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -140,14 +140,12 @@ void WriteTriangleGeometry::dataCheck() // We MUST have Nodes if(nullptr == triangles->getVertices().get()) { - setErrorCondition(-386); - notifyErrorMessage(getHumanLabel(), "DataContainer Geometry missing Vertices", getErrorCondition()); + setErrorCondition(-386, "DataContainer Geometry missing Vertices"); } // We MUST have Triangles defined also. if(nullptr == triangles->getTriangles().get()) { - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), "DataContainer Geometry missing Triangles", getErrorCondition()); + setErrorCondition(-387, "DataContainer Geometry missing Triangles"); } } @@ -169,11 +167,11 @@ void WriteTriangleGeometry::preflight() // ----------------------------------------------------------------------------- void WriteTriangleGeometry::execute() { - int err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -192,15 +190,14 @@ void WriteTriangleGeometry::execute() // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path - notifyStatusMessage(getHumanLabel(), "Writing Nodes Text File"); + notifyStatusMessage("Writing Nodes Text File"); QFileInfo fi(getOutputNodesFile()); QDir parentPath = fi.path(); if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); return; } @@ -209,8 +206,7 @@ void WriteTriangleGeometry::execute() if (!fileNodes.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getOutputNodesFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-100, ss); return; } @@ -241,15 +237,14 @@ void WriteTriangleGeometry::execute() // ++++++++++++++ Write the Triangles File +++++++++++++++++++++++++++++++++++++++++++ - notifyStatusMessage(getHumanLabel(), "Writing Triangles Text File"); + notifyStatusMessage("Writing Triangles Text File"); QFileInfo triFI(getOutputTrianglesFile()); parentPath = triFI.path(); if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); return; } @@ -258,8 +253,7 @@ void WriteTriangleGeometry::execute() if (!fileTri.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getOutputTrianglesFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-100, ss); return; } diff --git a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h index d32ba83352..ef8f476226 100644 --- a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h +++ b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h @@ -57,7 +57,7 @@ class SIMPLib_EXPORT WriteTriangleGeometry : public AbstractFilter { Q_OBJECT PYB11_CREATE_BINDINGS(WriteTriangleGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + PYB11_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) PYB11_PROPERTY(QString OutputNodesFile READ getOutputNodesFile WRITE setOutputNodesFile) PYB11_PROPERTY(QString OutputTrianglesFile READ getOutputTrianglesFile WRITE setOutputTrianglesFile) @@ -68,8 +68,8 @@ class SIMPLib_EXPORT WriteTriangleGeometry : public AbstractFilter ~WriteTriangleGeometry() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerSelection) - Q_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerSelection) + Q_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) SIMPL_FILTER_PARAMETER(QString, OutputNodesFile) Q_PROPERTY(QString OutputNodesFile READ getOutputNodesFile WRITE setOutputNodesFile) diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorItem.h b/Source/SIMPLib/CoreFilters/util/CalculatorItem.h index 8c1b5b8d52..25fba1a526 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorItem.h +++ b/Source/SIMPLib/CoreFilters/util/CalculatorItem.h @@ -79,7 +79,8 @@ class SIMPLib_EXPORT CalculatorItem TOO_MANY_ARGUMENTS = -4034, INVALID_SYMBOL = -4035, NO_PRECEDING_UNARY_OPERATOR = -4036, - InvalidOutputArrayType = -4037 + InvalidOutputArrayType = -4037, + AttributeMatrixInsertionError = -4038 }; enum class WarningCode : EnumType diff --git a/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp b/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp index b4fab9972b..261d691c8e 100644 --- a/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp +++ b/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp @@ -51,7 +51,7 @@ class ParserFunctor struct ErrorObject { - bool ok; + bool ok = false; QString errorMessage; }; }; diff --git a/Source/SIMPLib/DataArrays/DataArray.hpp b/Source/SIMPLib/DataArrays/DataArray.hpp index 7edafb1532..2c7ff71901 100755 --- a/Source/SIMPLib/DataArrays/DataArray.hpp +++ b/Source/SIMPLib/DataArrays/DataArray.hpp @@ -36,7 +36,12 @@ #pragma once // STL Includes +#include #include +#include +#include +#include +#include #include #include "SIMPLib/Common/SIMPLibSetGetMacros.h" @@ -76,7 +81,7 @@ template class DataArray : public IDataArray SIMPL_TYPE_MACRO_SUPER(DataArray, IDataArray) SIMPL_CLASS_VERSION(2) - DataArray(const DataArray&) = delete; // Copy Constructor Not Implemented + DataArray(const DataArray&) = default; // Copy Constructor Not Implemented DataArray(DataArray&&) = delete; // Move Constructor Not Implemented DataArray& operator=(const DataArray&) = delete; // Copy Assignment Not Implemented DataArray& operator=(DataArray&&) = delete; // Move Assignment Not Implemented @@ -568,18 +573,6 @@ template class DataArray : public IDataArray return p; } - /** - * @brief Destructor - */ - ~DataArray() override - { - // qDebug() << "~DataArrayTemplate '" << m_Name << "'" ; - if((nullptr != m_Array) && (true == m_OwnsData)) - { - _deallocate(); - } - } - /** * @brief isAllocated * @return @@ -598,24 +591,6 @@ template class DataArray : public IDataArray m_InitValue = initValue; } - /** - * @brief Gives this array a human readable name - * @param name The name of this array - */ - void setName(const QString& name) override - { - m_Name = name; - } - - /** - * @brief Returns the human readable name of this array - * @return - */ - QString getName() override - { - return m_Name; - } - /** * @brief Makes this class responsible for freeing the memory */ @@ -642,7 +617,7 @@ template class DataArray : public IDataArray { if((nullptr != m_Array) && (true == m_OwnsData)) { - _deallocate(); + deallocate(); } m_Array = nullptr; m_OwnsData = true; @@ -670,23 +645,6 @@ template class DataArray : public IDataArray return 1; } - /** - * @brief Removes all elements from the array (which are destroyed), leaving the container with a size of 0. - */ - virtual void clear() - { - if(nullptr != m_Array && true == m_OwnsData) - { - _deallocate(); - } - m_Array = nullptr; - m_Size = 0; - m_OwnsData = true; - m_MaxId = 0; - m_IsAllocated = false; - m_NumTuples = 0; - } - /** * @brief Sets all the values to zero. */ @@ -709,10 +667,7 @@ template class DataArray : public IDataArray { return; } - for(size_t i = offset; i < m_Size; i++) - { - m_Array[i] = initValue; - } + std::for_each(begin() + offset, end(), [=](T& n) { n = initValue; }); } /** @@ -735,7 +690,7 @@ template class DataArray : public IDataArray auto idxs_size = static_cast(idxs.size()); if(idxs_size >= getNumberOfTuples()) { - resize(0); + resizeTuples(0); return 0; } @@ -779,7 +734,7 @@ template class DataArray : public IDataArray { T* currentSrc = m_Array + (j * m_NumComponents); std::memcpy(currentDest, currentSrc, (getNumberOfTuples() - idxs.size()) * m_NumComponents * sizeof(T)); - _deallocate(); // We are done copying - delete the current m_Array + deallocate(); // We are done copying - delete the current m_Array m_Size = newSize; m_Array = newArray; m_OwnsData = true; @@ -820,7 +775,7 @@ template class DataArray : public IDataArray } // We are done copying - delete the current m_Array - _deallocate(); + deallocate(); // Allocation was successful. Save it. m_Size = newSize; @@ -888,7 +843,7 @@ template class DataArray : public IDataArray */ QVector getComponentDimensions() override { - return m_CompDims; + return QVector::fromStdVector(m_CompDims); } /** @@ -1104,14 +1059,13 @@ template class DataArray : public IDataArray * @param numTuples * @return */ - int32_t resize(size_t numTuples) override + void resizeTuples(size_t numTuples) override { - int32_t check = resizeTotalElements(numTuples * m_NumComponents); - if(check > 0) + T* ptr = resizeAndExtend(numTuples * m_NumComponents); + if(nullptr != ptr) { m_NumTuples = numTuples; } - return check; } /** @@ -1426,19 +1380,28 @@ template class DataArray : public IDataArray QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + QString nameBgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + nameBgColor = "bgcolor=\"#E9E7D6\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; + ss << ""; - ss << R"("; + ss << ""; - ss << R"("; + ss << ""; QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << R"("; + ss << ""; QString compDimStr = "("; for(int i = 0; i < m_CompDims.size(); i++) @@ -1450,17 +1413,20 @@ template class DataArray : public IDataArray } } compDimStr = compDimStr + ")"; - ss << R"("; + ss << ""; numStr = usa.toString(static_cast(m_Size)); - ss << R"("; + ss << ""; numStr = usa.toString(static_cast(m_Size * sizeof(T))); - ss << R"("; + ss << ""; ss << "
Attribute Array Info
Attribute Array Info
Name:)" << getName() << "
Name:" << getName() << "
Type: DataArray<)" << getTypeAsString() << ">
Type: DataArray<" << getTypeAsString() << ">
Number of Tuples:)" << numStr << "
Number of Tuples:" << numStr << "
Component Dimensions:)" << compDimStr << "
Component Dimensions:" << compDimStr << "
Total Elements:)" << numStr << "
Total Elements:" << numStr << "
Total Memory Required:)" << numStr << "
Total Memory Required:" << numStr << "
\n"; ss << ""; + break; } - else - { + default: + ss << "Requested DataArray information string format is not supported. " << format; + break; } + return info; } @@ -1473,7 +1439,7 @@ template class DataArray : public IDataArray { int err = 0; - resize(0); + resizeTuples(0); IDataArray::Pointer p = H5DataArrayReader::ReadIDataArray(parentId, getName()); if(p.get() == nullptr) { @@ -1484,9 +1450,9 @@ template class DataArray : public IDataArray m_OwnsData = true; m_MaxId = (m_Size == 0) ? 0 : m_Size - 1; m_IsAllocated = true; - m_Name = p->getName(); + setName(p->getName()); m_NumTuples = p->getNumberOfTuples(); - m_CompDims = p->getComponentDimensions(); + m_CompDims = p->getComponentDimensions().toStdVector(); m_NumComponents = p->getNumberOfComponents(); // Tell the intermediate DataArray to release ownership of the data as we are going to be responsible @@ -1525,17 +1491,510 @@ template class DataArray : public IDataArray } } + //========================================= STL INTERFACE COMPATIBILITY ================================= + + using comp_dims_type = std::vector; + using size_type = size_t; + using value_type = T; + using reference = T&; + using iterator_category = std::input_iterator_tag; + using pointer = T*; + using difference_type = value_type; + + DataArray() = default; /** - * @brief operator [] - * @param i + * @brief DataArray + * @param ntuples + * @param name + * @param allocate + */ + DataArray(size_t ntuples, const std::string& name, bool allocate = true) + : IDataArray(QString::fromStdString(name)) + { + m_NumComponents = 1; + if(allocate) + { + resizeTuples(ntuples); + } + else + { + m_Size = ntuples; + m_MaxId = (ntuples == 0) ? 0 : ntuples - 1; + m_NumTuples = ntuples; + m_NumComponents = 1; + } + } + + /** + * @brief DataArray + * @param ntuples + * @param cdims + * @param name + * @param allocate + */ + DataArray(size_t ntuples, comp_dims_type cdims, const std::string& name, bool allocate = true) + : IDataArray(QString::fromStdString(name)) + , m_NumTuples(ntuples) + , m_CompDims(std::move(cdims)) + { + m_NumComponents = std::accumulate(m_CompDims.begin(), m_CompDims.end(), 1, std::multiplies()); + m_InitValue = static_cast(0); + if(allocate) + { + m_Array = resizeAndExtend(m_NumTuples * m_NumComponents); + } + else + { + m_Size = m_NumTuples * m_NumComponents; + m_MaxId = (m_Size == 0) ? 0 : m_Size - 1; + } + } + + ~DataArray() override + { + clear(); + } + + //========================================= STL INTERFACE COMPATIBILITY ================================= + + class tuple_iterator + { + public: + using self_type = tuple_iterator; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = value_type; + using iterator_category = std::forward_iterator_tag; + + tuple_iterator(pointer ptr, size_type numComps) + : ptr_(ptr) + , num_comps_(numComps) + { + } + self_type operator++() + { + ptr_ = ptr_ + num_comps_; + return *this; + } // PREFIX + self_type operator++(int junk) + { + self_type i = *this; + ptr_ = ptr_ + num_comps_; + return i; + } // POSTFIX + reference operator*() + { + return *ptr_; + } + pointer operator->() + { + return ptr_; + } + bool operator==(const self_type& rhs) + { + return ptr_ == rhs.ptr_; + } + bool operator!=(const self_type& rhs) + { + return ptr_ != rhs.ptr_; + } + reference comp_value(size_type comp) + { + return *(ptr_ + comp); + } + + private: + pointer ptr_; + size_t num_comps_; + }; + + class const_tuple_iterator + { + public: + using self_type = const_tuple_iterator; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = value_type; + using iterator_category = std::forward_iterator_tag; + + const_tuple_iterator(pointer ptr, size_type numComps) + : ptr_(ptr) + , num_comps_(numComps) + { + } + self_type operator++() + { + ptr_ = ptr_ + num_comps_; + return *this; + } // PREFIX + self_type operator++(int junk) + { + self_type i = *this; + ptr_ = ptr_ + num_comps_; + return i; + } // POSTFIX + const value_type& operator*() + { + return *ptr_; + } + const pointer operator->() + { + return ptr_; + } + bool operator==(const self_type& rhs) + { + return ptr_ == rhs.ptr_; + } + bool operator!=(const self_type& rhs) + { + return ptr_ != rhs.ptr_; + } + const value_type& comp_value(size_type comp) + { + return *(ptr_ + comp); + } + + private: + pointer ptr_; + size_t num_comps_; + }; + + class iterator + { + public: + using self_type = iterator; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = value_type; + using iterator_category = std::forward_iterator_tag; + + iterator(pointer ptr) + : ptr_(ptr) + { + } + iterator(pointer ptr, size_type ununsed) + : ptr_(ptr) + { + } + + self_type operator++() + { + ptr_++; + return *this; + } // PREFIX + self_type operator++(int junk) + { + self_type i = *this; + ptr_++; + return i; + } // POSTFIX + self_type operator+(int amt) + { + ptr_ += amt; + return *this; + } + reference operator*() + { + return *ptr_; + } + pointer operator->() + { + return ptr_; + } + bool operator==(const self_type& rhs) + { + return ptr_ == rhs.ptr_; + } + bool operator!=(const self_type& rhs) + { + return ptr_ != rhs.ptr_; + } + + private: + pointer ptr_; + }; + + class const_iterator + { + public: + using self_type = const_iterator; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = value_type; + using iterator_category = std::forward_iterator_tag; + const_iterator(pointer ptr) + : ptr_(ptr) + { + } + const_iterator(pointer ptr, size_type unused) + : ptr_(ptr) + { + } + + self_type operator++() + { + ptr_++; + return *this; + } // PREFIX + self_type operator++(int amt) + { + self_type i = *this; + ptr_ += amt; + return i; + } // POSTFIX + self_type operator+(int amt) + { + ptr_ += amt; + return *this; + } + const value_type& operator*() + { + return *ptr_; + } + const pointer operator->() + { + return ptr_; + } + bool operator==(const self_type& rhs) + { + return ptr_ == rhs.ptr_; + } + bool operator!=(const self_type& rhs) + { + return ptr_ != rhs.ptr_; + } + + private: + pointer ptr_; + }; + + // ######### Iterators ######### + + template IteratorType begin() + { + return IteratorType(m_Array, m_NumComponents); + } + iterator begin() + { + return iterator(m_Array); + } + + template IteratorType end() + { + return IteratorType(m_Array + m_Size, m_NumComponents); + } + iterator end() + { + return iterator(m_Array + m_Size); + } + + const_iterator begin() const + { + return const_iterator(m_Array); + } + + const_iterator end() const + { + return const_iterator(m_Array + m_Size); + } + + // rbegin + // rend + // cbegin + // cend + // crbegin + // crend + + // ######### Capacity ######### + + size_type size() const + { + return m_Size; + } + + size_type max_size() const + { + return m_Size; + } + // void resize(size_type n) override + // { + // resizeAndExtend(n); + // } + // void resize (size_type n, const value_type& val); + size_type capacity() const noexcept + { + return m_Size; + } + bool empty() const noexcept + { + return (m_Size == 0); + } + // reserve() + // shrink_to_fit() + + // ######### Element Access ######### + + inline reference operator[](size_type index) + { + // assert(index < m_Size); + return m_Array[index]; + } + + inline const T& operator[](size_type index) const + { + // assert(index < m_Size); + return m_Array[index]; + } + + inline reference at(size_type index) + { + assert(index < m_Size); + return m_Array[index]; + } + + inline const T& at(size_type index) const + { + assert(index < m_Size); + return m_Array[index]; + } + + inline reference front() + { + return m_Array[0]; + } + inline const T& front() const + { + return m_Array[0]; + } + + inline reference back() + { + return m_Array[m_MaxId]; + } + inline const T& back() const + { + return m_Array[m_MaxId]; + } + + inline T* data() noexcept + { + return m_Array; + } + inline const T* data() const noexcept + { + return m_Array; + } + + // ######### Modifiers ######### + + /** + * @brief In the range version (1), the new contents are elements constructed from each of the elements in the range + * between first and last, in the same order. + */ + template void assign(InputIterator first, InputIterator last) // range (1) + { + size_type size = last - first; + resizeAndExtend(size); + size_type idx = 0; + while(first != last) + { + m_Array[idx] = *first; + first++; + } + } + + /** + * @brief In the fill version (2), the new contents are n elements, each initialized to a copy of val. + * @param n + * @param val + */ + void assign(size_type n, const value_type& val) // fill (2) + { + resizeAndExtend(n); + std::for_each(begin(), end(), [=](T& n) { n = val; }); + } + + /** + * @brief In the initializer list version (3), the new contents are copies of the values passed as initializer list, in the same order. + * @param il + */ + void assign(std::initializer_list il) // initializer list (3) + { + assign(il.begin(), il.end()); + } + + /** + * @brief push_back + * @param val + */ + void push_back(const value_type& val) + { + resizeAndExtend(m_Size + 1); + m_Array[m_MaxId] = val; + } + /** + * @brief push_back + * @param val + */ + void push_back(value_type&& val) + { + resizeAndExtend(m_Size + 1); + m_Array[m_MaxId] = val; + } + + /** + * @brief pop_back + */ + void pop_back() + { + resizeAndExtend(m_Size - 1); + } + // insert + // iterator erase (const_iterator position) + // iterator erase (const_iterator first, const_iterator last); + // swap + + /** + * @brief Removes all elements from the array (which are destroyed), leaving the container with a size of 0. + */ + void clear() + { + if(nullptr != m_Array && m_OwnsData) + { + deallocate(); + } + m_Array = nullptr; + m_Size = 0; + m_OwnsData = true; + m_MaxId = 0; + m_IsAllocated = false; + m_NumTuples = 0; + } + // emplace + // emplace_back + + /** + * @brief equal + * @param range1 + * @param range2 * @return */ - inline T& operator[](size_t i) + template bool equal(Range1 const& range1, Range2 const& range2) { - Q_ASSERT(i < m_Size); - return m_Array[i]; + if(range1.size() != range2.size()) + { + return false; + } + + return std::equal(begin(range1), end(range1), begin(range2)); } + // =================================== END STL COMPATIBLE INTERFACe =================================================== + protected: /** * @brief Protected Constructor @@ -1544,15 +2003,13 @@ template class DataArray : public IDataArray * @param dims The actual dimensions the attribute on each Tuple has. * @param takeOwnership Will the class clean up the memory. Default=true */ - DataArray(size_t numTuples, QVector compDims, QString name, bool ownsData = true) - : m_Array(nullptr) - , m_OwnsData(ownsData) - , m_IsAllocated(false) - , m_Name(std::move(name)) + DataArray(size_t numTuples, const QVector& compDims, const QString& name, bool ownsData = true) + : IDataArray(name) , m_NumTuples(numTuples) + , m_OwnsData(ownsData) { // Set the Component Dimensions and compute the number of components at each tuple for caching - m_CompDims = compDims; + m_CompDims = std::vector(compDims.begin(), compDims.end()); m_NumComponents = m_CompDims[0]; for(int i = 1; i < m_CompDims.size(); i++) { @@ -1569,7 +2026,7 @@ template class DataArray : public IDataArray /** * @brief deallocates the memory block */ - void _deallocate() + void deallocate() { // We are going to splat 0xABABAB across the first value of the array as a debugging aid auto cptr = reinterpret_cast(m_Array); @@ -1713,7 +2170,7 @@ template class DataArray : public IDataArray std::memcpy(newArray, m_Array, (newSize < m_Size ? newSize : m_Size) * sizeof(T)); } // Free the old array - _deallocate(); + deallocate(); } // Allocation was successful. Save it. @@ -1736,26 +2193,15 @@ template class DataArray : public IDataArray } private: - // unsigned long long int MUD_FLAP_0; - T* m_Array; - // unsigned long long int MUD_FLAP_1; - size_t m_Size; - // unsigned long long int MUD_FLAP_4; - bool m_OwnsData; - // unsigned long long int MUD_FLAP_2; - size_t m_MaxId; - - bool m_IsAllocated; - // unsigned long long int MUD_FLAP_3; - QString m_Name; - // unsigned long long int MUD_FLAP_5; - - size_t m_NumTuples; - - QVector m_CompDims; - size_t m_NumComponents; - - T m_InitValue; + T* m_Array = nullptr; + size_t m_Size = 0; + size_t m_MaxId = 0; + size_t m_NumTuples = 0; + size_t m_NumComponents = 1; + T m_InitValue = static_cast(0); + std::vector m_CompDims = {1}; + bool m_IsAllocated = false; + bool m_OwnsData = true; }; // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/DataArrays/IDataArray.cpp b/Source/SIMPLib/DataArrays/IDataArray.cpp index 6c25becec1..ac0f629edd 100644 --- a/Source/SIMPLib/DataArrays/IDataArray.cpp +++ b/Source/SIMPLib/DataArrays/IDataArray.cpp @@ -14,7 +14,9 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::IDataArray() = default; +IDataArray::IDataArray(const QString& name) +: IDataStructureNode(name) +{} // ----------------------------------------------------------------------------- // @@ -28,3 +30,13 @@ bool IDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourc { return copyFromArray(destTupleOffset, sourceArray, 0, sourceArray->getNumberOfTuples()); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath IDataArray::getDataArrayPath() const +{ + DataArrayPath path = getParentPath(); + path.setDataArrayName(getName()); + return path; +} diff --git a/Source/SIMPLib/DataArrays/IDataArray.h b/Source/SIMPLib/DataArrays/IDataArray.h index 987b200f48..3b2ab1d1ee 100755 --- a/Source/SIMPLib/DataArrays/IDataArray.h +++ b/Source/SIMPLib/DataArrays/IDataArray.h @@ -24,6 +24,7 @@ #include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/IDataStructureNode.h" /** @@ -37,7 +38,7 @@ * @date Jan 3, 2008 * @version $Revision: 1.2 $ */ -class SIMPLib_EXPORT IDataArray +class SIMPLib_EXPORT IDataArray : public IDataStructureNode { PYB11_CREATE_BINDINGS(IDataArray) PYB11_PROPERTY(QString Name READ getName WRITE setName) @@ -58,7 +59,7 @@ class SIMPLib_EXPORT IDataArray * @code * typedef DataArray Int32ArrayType; * int32_t* iPtr = IDataArray::SafeReinterpretCast(ptr.get()); - * Q_ASSERT(nullptr != iPtr); + * Q_ASSERT(nullptr != iPtr); * @endcode * @param x The Pointer to IDataArray * @return @@ -74,16 +75,19 @@ class SIMPLib_EXPORT IDataArray } - IDataArray(); - virtual ~IDataArray(); - - virtual void setName(const QString& name) = 0; - virtual QString getName() = 0; + IDataArray(const QString& name = ""); + ~IDataArray() override; virtual Pointer createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate = true) = 0; virtual Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) = 0; virtual Pointer createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate = true) = 0; + /** + * @brief Creates and returns a DataArrayPath for the DataArray + * @return + */ + DataArrayPath getDataArrayPath() const override; + virtual int getClassVersion() = 0; /** @@ -223,11 +227,10 @@ class SIMPLib_EXPORT IDataArray virtual int32_t resizeTotalElements(size_t size) = 0; /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure + * @brief resize + * @param count */ - virtual int32_t resize(size_t numTuples) = 0; + virtual void resizeTuples(size_t count) = 0; /** * @brief printTuple diff --git a/Source/SIMPLib/DataArrays/NeighborList.hpp b/Source/SIMPLib/DataArrays/NeighborList.hpp index a7e4085d90..66ee4cdf6a 100755 --- a/Source/SIMPLib/DataArrays/NeighborList.hpp +++ b/Source/SIMPLib/DataArrays/NeighborList.hpp @@ -313,18 +313,6 @@ class NeighborList : public IDataArray */ QString getTypeAsString() override { return NeighborList::ClassName();} - /** - * @brief setName - * @param name - */ - void setName(const QString& name) override { m_Name = name; } - - /** - * @brief getName - * @return - */ - QString getName() override { return m_Name; } - /** * @brief takeOwnership */ @@ -608,20 +596,11 @@ class NeighborList : public IDataArray * @brief Resizes the internal array to accomondate numTuples * @param numTuples */ - void resizeTuples(size_t numTuples) + void resizeTuples(size_t numTuples) override { resizeTotalElements(numTuples); } - /** - * @brief Resizes the internal array to accomondate numTuples - * @param numTuples - */ - int32_t resize(size_t numTuples) override - { - return resizeTotalElements(numTuples); - } - //FIXME: These need to be implemented void printTuple(QTextStream& out, size_t i, char delimiter = ',') override { @@ -813,30 +792,41 @@ class NeighborList : public IDataArray { QString info; QTextStream ss (&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + QString nameBgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + nameBgColor = "bgcolor=\"#E9E7D6\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; + ss << ""; - ss << ""; + ss << ""; - ss << ""; + ss << ""; QLocale usa(QLocale::English, QLocale::UnitedStates); QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; - ss << ""; + ss << ""; + ss << ""; ss << "
Attribute Array Info
Attribute Array Info
Name:" << getName() << "
Name:" << getName() << "
Type:" << getTypeAsString() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
Number of Lists:" << getNumberOfLists() << "
Number of Tuples:" << numStr << "
Number of Lists:" << getNumberOfLists() << "
\n"; ss << "
"; ss << ""; + break; } - else - { - + default: + ss << "Requested NeighborList information string format is not supported. " << format; + break; } + return info; } /** @@ -1072,9 +1062,9 @@ class NeighborList : public IDataArray /** * @brief NeighborList */ - NeighborList(size_t numTuples, const QString& name) - : m_NumNeighborsArrayName() - , m_Name(name) + NeighborList(size_t numTuples, const QString name) + : IDataArray(name) + , m_NumNeighborsArrayName("") , m_NumTuples(numTuples) , m_IsAllocated(false) { @@ -1082,7 +1072,6 @@ class NeighborList : public IDataArray private: std::vector m_Array; - QString m_Name; size_t m_NumTuples; bool m_IsAllocated; T m_InitValue; diff --git a/Source/SIMPLib/DataArrays/StatsDataArray.cpp b/Source/SIMPLib/DataArrays/StatsDataArray.cpp index 6bf88203a3..8cc9cefd28 100644 --- a/Source/SIMPLib/DataArrays/StatsDataArray.cpp +++ b/Source/SIMPLib/DataArrays/StatsDataArray.cpp @@ -51,7 +51,7 @@ // // ----------------------------------------------------------------------------- StatsDataArray::StatsDataArray() -: m_Name(SIMPL::EnsembleData::Statistics) +: IDataArray(SIMPL::EnsembleData::Statistics) { m_IsAllocated = true; } @@ -186,21 +186,6 @@ IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, QVector& idxs) if(static_cast(idxs.size()) >= getNumberOfTuples()) { - resize(0); + resizeTuples(0); return 0; } @@ -417,7 +402,7 @@ IDataArray::Pointer StatsDataArray::deepCopy(bool forceNoAllocate) { StatsDataArray::Pointer daCopyPtr = StatsDataArray::CreateArray(getNumberOfTuples() * getNumberOfComponents(), getName()); - daCopyPtr->resize(getNumberOfTuples()); + daCopyPtr->resizeTuples(getNumberOfTuples()); for(size_t i = 0; i < getNumberOfTuples(); i++) { // This should be a Deep Copy of each of the StatsData subclasses instead of a reference copy @@ -446,9 +431,9 @@ int32_t StatsDataArray::resizeTotalElements(size_t size) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int32_t StatsDataArray::resize(size_t numTuples) +void StatsDataArray::resizeTuples(size_t numTuples) { - return resizeTotalElements(numTuples); + resizeTotalElements(numTuples); } // ----------------------------------------------------------------------------- @@ -472,7 +457,7 @@ void StatsDataArray::printComponent(QTextStream& out, size_t i, int j) int StatsDataArray::writeH5Data(hid_t parentId, QVector tDims) { herr_t err = 0; - hid_t gid = QH5Utilities::createGroup(parentId, m_Name); + hid_t gid = QH5Utilities::createGroup(parentId, getName()); if(gid < 0) { return -1; @@ -508,7 +493,7 @@ int StatsDataArray::readH5Data(hid_t parentId) bool ok = false; int err = 0; QString statsType; - hid_t gid = QH5Utilities::openHDF5Object(parentId, m_Name); + hid_t gid = QH5Utilities::openHDF5Object(parentId, getName()); if(gid < 0) { return err; @@ -689,28 +674,40 @@ QString StatsDataArray::getInfoString(SIMPL::InfoStringFormat format) { QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + QString nameBgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + nameBgColor = "bgcolor=\"#E9E7D6\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; + ss << ""; - ss << ""; + ss << ""; - ss << ""; + ss << ""; QLocale usa(QLocale::English, QLocale::UnitedStates); QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; + ss << ""; ss << "
Attribute Array Info
Attribute Array Info
Name:" << getName() << "
Name:" << getName() << "
Type:" << getTypeAsString() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
Number of Tuples:" << numStr << "
\n"; ss << "
"; ss << ""; + break; } - else - { + default: + ss << "Requested StatsDataArray information string format is not supported. " << format; + break; } + return info; } diff --git a/Source/SIMPLib/DataArrays/StatsDataArray.h b/Source/SIMPLib/DataArrays/StatsDataArray.h index d3d8896d56..6e1e18e369 100755 --- a/Source/SIMPLib/DataArrays/StatsDataArray.h +++ b/Source/SIMPLib/DataArrays/StatsDataArray.h @@ -178,9 +178,6 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray /* **************** This is the interface for the IDataArray Class which MUST * Be implemented. Most of it is useless and will simply ASSERT if called. */ - void setName(const QString& name) override; - QString getName() override; - /** * @brief getFullNameOfClass * @return @@ -310,11 +307,10 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray int32_t resizeTotalElements(size_t size) override; /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure + * @brief Resizes the internal array to accomondate numTuples + * @param numTuples */ - int32_t resize(size_t numTuples) override; + void resizeTuples(size_t numTuples) override; /** * @brief printTuple @@ -382,7 +378,6 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray StatsDataArray(); private: - QString m_Name; bool m_IsAllocated; public: diff --git a/Source/SIMPLib/DataArrays/StringDataArray.cpp b/Source/SIMPLib/DataArrays/StringDataArray.cpp index 6073182b14..baaec9d405 100644 --- a/Source/SIMPLib/DataArrays/StringDataArray.cpp +++ b/Source/SIMPLib/DataArrays/StringDataArray.cpp @@ -41,23 +41,20 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StringDataArray::StringDataArray() -: m_Name("") -, _ownsData(false) +StringDataArray::StringDataArray() +: _ownsData(false) { } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StringDataArray::StringDataArray(size_t numTuples, const QString name, bool allocate) -: m_Name(name) +StringDataArray::StringDataArray(size_t numTuples, const QString& name, bool allocate) +: IDataArray(name) , _ownsData(true) { - // if (allocate == true) - { - m_Array.resize(numTuples); - } + m_Array.resize(numTuples); + setName(name); } // ----------------------------------------------------------------------------- @@ -70,7 +67,6 @@ StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, const QS return NullPointer(); } StringDataArray* d = new StringDataArray(numTuples, name, allocate); - d->setName(name); Pointer ptr(d); return ptr; } @@ -85,7 +81,6 @@ StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, QVector< return NullPointer(); } StringDataArray* d = new StringDataArray(numTuples, name, allocate); - d->setName(name); Pointer ptr(d); return ptr; } @@ -160,22 +155,6 @@ QString StringDataArray::getTypeAsString() return "StringDataArray"; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void StringDataArray::setName(const QString& name) -{ - m_Name = name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString StringDataArray::getName() -{ - return m_Name; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -272,15 +251,16 @@ int StringDataArray::eraseTuples(QVector& idxs) size_t idxs_size = static_cast(idxs.size()); if(idxs_size >= getNumberOfTuples()) { - resize(0); + resizeTuples(0); return 0; } // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are // off the end of the array and return an error code. - for(QVector::size_type i = 0; i < idxs.size(); ++i) + // for(QVector::size_type i = 0; i < idxs.size(); ++i) + for(auto& value : idxs) { - if(idxs[i] >= static_cast(m_Array.size())) + if(value >= static_cast(m_Array.size())) { return -100; } @@ -378,7 +358,7 @@ void StringDataArray::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringDataArray::initializeWithValue(QString value) +void StringDataArray::initializeWithValue(const QString& value) { m_Array.assign(m_Array.size(), value); } @@ -419,10 +399,9 @@ int32_t StringDataArray::resizeTotalElements(size_t size) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int32_t StringDataArray::resize(size_t numTuples) +void StringDataArray::resizeTuples(size_t numTuples) { m_Array.resize(numTuples); - return 1; } // ----------------------------------------------------------------------------- @@ -485,25 +464,35 @@ QString StringDataArray::getInfoString(SIMPL::InfoStringFormat format) { QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; - ss << ""; - ss << ""; + ss << ""; + ss << ")"; + ss << ")"; QLocale usa(QLocale::English, QLocale::UnitedStates); QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; + ss << ")"; ss << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Attribute Array Info
Name:" << getName() << R"(
Type:" << getTypeAsString() << R"(
Number of Tuples:" << numStr << "
Number of Tuples:" << numStr << R"(
\n"; ss << "
"; ss << ""; + break; } - else - { + default: + ss << "Requested StringDataArray information string format is not supported. " << format; + break; } + return info; } @@ -513,7 +502,7 @@ QString StringDataArray::getInfoString(SIMPL::InfoStringFormat format) int StringDataArray::readH5Data(hid_t parentId) { int err = 0; - this->resize(0); + this->resizeTuples(0); std::vector strings; err = H5Lite::readVectorOfStringDataset(parentId, getName().toStdString(), strings); diff --git a/Source/SIMPLib/DataArrays/StringDataArray.h b/Source/SIMPLib/DataArrays/StringDataArray.h index 64c099182f..e56ce15ae9 100755 --- a/Source/SIMPLib/DataArrays/StringDataArray.h +++ b/Source/SIMPLib/DataArrays/StringDataArray.h @@ -154,18 +154,6 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray */ QString getTypeAsString() override; - /** - * @brief Gives this array a human readable name - * @param name The name of this array - */ - void setName(const QString& name) override; - - /** - * @brief Returns the human readable name of this array - * @return - */ - QString getName() override; - /** * @brief */ @@ -278,7 +266,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @brief initializeWithValue * @param value */ - virtual void initializeWithValue(QString value); + virtual void initializeWithValue(const QString& value); /** * @brief initializeWithValue @@ -301,11 +289,10 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray int32_t resizeTotalElements(size_t size) override; /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure + * @brief Resizes the internal array to accomondate numTuples + * @param numTuples */ - int32_t resize(size_t numTuples) override; + void resizeTuples(size_t numTuples) override; /** * @brief Initializes this class to zero bytes freeing any data that it currently owns @@ -385,12 +372,11 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param numElements The number of elements in the internal array. * @param takeOwnership Will the class clean up the memory. Default=true */ - StringDataArray(size_t numTuples, const QString name, bool allocate = true); + StringDataArray(size_t numTuples, const QString& name, bool allocate = true); StringDataArray(); private: - QString m_Name; QString m_InitValue; std::vector m_Array; bool _ownsData; diff --git a/Source/SIMPLib/DataArrays/StructArray.hpp b/Source/SIMPLib/DataArrays/StructArray.hpp index 317016884a..d4db2631b4 100755 --- a/Source/SIMPLib/DataArrays/StructArray.hpp +++ b/Source/SIMPLib/DataArrays/StructArray.hpp @@ -64,7 +64,7 @@ class StructArray : public IDataArray */ static Pointer CreateArray(size_t numElements, const QString& name, bool allocate = true) { - if (name.isEmpty() == true) + if(name.isEmpty()) { return NullPointer(); } @@ -160,25 +160,6 @@ class StructArray : public IDataArray return theType; } - - /** - * @brief Gives this array a human readable name - * @param name The name of this array - */ - void setName(const QString& name) override - { - m_Name = name; - } - - /** - * @brief Returns the human readable name of this array - * @return - */ - QString getName() override - { - return m_Name; - } - /** * @brief Makes this class responsible for freeing the memory */ @@ -292,7 +273,7 @@ class StructArray : public IDataArray size_t idxs_size = static_cast(idxs.size()); if (idxs_size >= getNumberOfTuples() ) { - resize(0); + resizeTuples(0); return 0; } @@ -611,20 +592,16 @@ class StructArray : public IDataArray { return 1; } - else - { - return 0; - } + return 0; } /** - * @brief Resize + * @brief Resizes the internal array to accomondate numTuples * @param numTuples - * @return */ - int32_t resize(size_t numTuples) override + void resizeTuples(size_t numTuples) override { - return resizeTotalElements(numTuples ); + resizeTotalElements(numTuples); } /** @@ -692,26 +669,37 @@ class StructArray : public IDataArray { QString info; QTextStream ss (&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + QString nameBgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + nameBgColor = "bgcolor=\"#E9E7D6\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; - ss << ""; - ss << ""; + ss << ""; + ss << ""; + ss << ""; QLocale usa(QLocale::English, QLocale::UnitedStates); QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; + ss << ""; ss << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
Number of Tuples:" << numStr << "
\n"; ss << "
"; ss << ""; + break; } - else - { - + default: + ss << "Requested StructArray information string format is not supported. " << format; + break; } + return info; } @@ -899,7 +887,6 @@ class StructArray : public IDataArray bool m_IsAllocated; // unsigned long long int MUD_FLAP_3; - QString m_Name; // unsigned long long int MUD_FLAP_5; StructArray(const StructArray&); //Not Implemented diff --git a/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp b/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp index f938c9aad9..6b1e73f55f 100644 --- a/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp +++ b/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include #include +#include #include #include @@ -75,6 +76,34 @@ #define DIM1 3 #define DIM2 4 +//============================= These are for testing the STL Interface ================================================ +std::map test; +std::map::value_type vt; + +bool mypredicate(int32_t i, int32_t j) +{ + return (i == j); +} + +struct Sum +{ + Sum() + : sum{0} + { + } + void operator()(int n) + { + sum += n; + } + int sum; +}; + +template void print(const T& v) +{ + std::cout << v << " "; +} +//====================================================================================================================== + class DataArrayTest { public: @@ -384,8 +413,8 @@ class DataArrayTest { \ DataArray::Pointer p_##type = DataArray::CreateArray(1, "Test", false); \ QString s_##type = p_##type->getTypeAsString(); \ - /* qDebug() << #type << s_##type; */ \ - type value = (type)(1); \ + s_##type = s_##type; /* qDebug() << #type << s_##type; */ \ + auto value = static_cast(1); \ value = value; \ /* qDebug() << TypeToString(value); */ \ } @@ -452,7 +481,7 @@ class DataArrayTest } // Resize Larger - int32Array->resize(NUM_TUPLES_2); + int32Array->resizeTuples(NUM_TUPLES_2); DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_2, int32Array->getNumberOfTuples()); DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_2, int32Array->getSize()); DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true); @@ -467,7 +496,7 @@ class DataArrayTest } // Resize Smaller - Which should have still saved some of our data - int32Array->resize(NUM_TUPLES_3); + int32Array->resizeTuples(NUM_TUPLES_3); DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_3, int32Array->getNumberOfTuples()); DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_3, int32Array->getSize()); DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true); @@ -672,13 +701,13 @@ class DataArrayTest } // Splat another value across the array starting at an offset into the array // and test those values made it into the array correctly - array->initializeWithValue(static_cast(1), numComp); - for(size_t i = numComp; i < numElements; i++) + array->initializeWithValue(static_cast(1)); + for(size_t i = 0; i < numElements; i++) { DREAM3D_REQUIRE_EQUAL(static_cast(1), ptr[i]); } // Initialize the entire array with a value (offset = 0); - array->initializeWithValue(static_cast(2), 0); + array->initializeWithValue(static_cast(2)); for(size_t i = 0; i < numElements; i++) { DREAM3D_REQUIRE_EQUAL(static_cast(2), ptr[i]); @@ -727,15 +756,15 @@ class DataArrayTest /// virtual QVector getComponentDimensions() // Test resizing the array based on a give number of tuples. The number of Components will stay the same at each tuple - array->resize(numTuples * 2); + array->resizeTuples(numTuples); array->initializeWithZeros(); // Init the grown array to all Zeros nt = array->getNumberOfTuples(); - DREAM3D_REQUIRED(nt, ==, (numTuples * 2)); + DREAM3D_REQUIRED(nt, ==, (numTuples)); nc = array->getNumberOfComponents(); DREAM3D_REQUIRED(nc, ==, numComp); // Test resizing the array to a smaller size - array->resize(numTuples); + array->resizeTuples(numTuples); array->initializeWithZeros(); // Init the grown array to all Zeros nt = array->getNumberOfTuples(); DREAM3D_REQUIRED(nt, ==, (numTuples)); @@ -757,7 +786,7 @@ class DataArrayTest DREAM3D_REQUIRED_PTR(ptr, ==, nullptr); // Test resizing the array to a any larger size - array->resize(numTuples); + array->resizeTuples(numTuples); array->initializeWithZeros(); // Init the grown array to all Zeros nt = array->getNumberOfTuples(); DREAM3D_REQUIRED(nt, ==, (numTuples)); @@ -1002,7 +1031,7 @@ class DataArrayTest DREAM3D_REQUIRE_EQUAL(didCopy, false); // Resize the DataArray to accomondate the true amount of data that we want (20 Tuples) - src->resize(numTuples * 2); + src->resizeTuples(numTuples * 2); didCopy = src->copyFromArray(numTuples, copy); DREAM3D_REQUIRE_EQUAL(didCopy, true); @@ -1167,10 +1196,10 @@ class DataArrayTest typename std::vector> data; - for (size_t i = 0; i < numTuples; i++) + for(size_t i = 0; i < numTuples; i++) { typename std::vector tempVector; - for (size_t j = 0; j < cDims[0]; j++) + for(size_t j = 0; j < cDims[0]; j++) { tempVector.push_back(static_cast(i + j)); } @@ -1181,16 +1210,16 @@ class DataArrayTest typename DataArray::Pointer src = DataArray::CreateArray(numTuples, cDims, name, true); - for (size_t i = 0; i < numTuples; i++) + for(size_t i = 0; i < numTuples; i++) { src->setTuple(i, data[i]); } // Check each element of the DataArray against the original vector - for (size_t i = 0; i < numTuples; i++) + for(size_t i = 0; i < numTuples; i++) { - for (size_t j = 0; j < cDims[0]; j++) + for(size_t j = 0; j < cDims[0]; j++) { T val = src->getComponent(i, j); DREAM3D_REQUIRE_EQUAL(data[i][j], val) @@ -1215,6 +1244,150 @@ class DataArrayTest TestSetTupleForType(); } + // ----------------------------------------------------------------------------- + void STLInterfaceTest() + { + std::cout << "STLInterfaceTest Test Starting...." << std::endl; + + DataArray i32Array(10, "Test Array"); + DataArray i32Array1(10, "Other Array"); + + // Initialize with a value + for(auto& value : i32Array) + { + value = 5; + } + // Initialize with a value + for(auto& value : i32Array1) + { + value = 5; + } + + std::cout << "before:"; + std::for_each(i32Array.begin(), i32Array.end(), print); + std::cout << '\n'; + + std::cout << "using default comparison:" << std::endl; + if(std::equal(i32Array.begin(), i32Array.end(), i32Array1.begin())) + { + std::cout << "The contents of both sequences are equal.\n"; + } + else + { + std::cout << "The contents of both sequences differ.\n"; + } + + std::for_each(i32Array1.begin(), i32Array1.end(), [](int32_t& n) { n++; }); + + std::cout << "using predicate comparison:" << std::endl; + if(std::equal(i32Array.begin(), i32Array.end(), i32Array1.begin(), mypredicate)) + { + std::cout << "The contents of both sequences are equal.\n"; + } + else + { + std::cout << "The contents of both sequences differ.\n"; + } + + std::cout << "Using another predicate to sum the values" << std::endl; + // calls Sum::operator() for each number + Sum s = std::for_each(i32Array1.begin(), i32Array1.end(), Sum()); + + std::cout << "after: "; + std::for_each(i32Array1.begin(), i32Array1.end(), print); + std::cout << '\n'; + std::cout << "sum: " << s.sum << '\n'; + + std::cout << "Modify Array using [] operator..." << std::endl; + for(DataArray::size_type i = 0; i < i32Array.size(); i++) + { + i32Array[i] = static_cast(i * 10); + } + + std::cout << "Print using range based loop..." << std::endl; + for(const auto& value : i32Array) + { + std::cout << value << std::endl; + } + + std::cout << "std::fill" << std::endl; + // std::fill the array with a set value + std::fill(i32Array.begin(), i32Array.end(), -1); + std::for_each(i32Array.begin(), i32Array.end(), print); + std::cout << "" << std::endl; + + std::cout << "std::transform from int32_t to float using a back_inserter" << std::endl; + DataArray f32Array(0, "Float Array"); + std::transform(i32Array.begin(), i32Array.end(), std::back_inserter(f32Array), [](int32_t i) -> float { return i * 2.5; }); + std::for_each(f32Array.begin(), f32Array.end(), print); + std::cout << std::endl; + + // Get the front and back + int32_t front = i32Array1.front(); + float back = f32Array.back(); + if(front != back) + { + // do nothing + } + + std::cout << "## Assign Content(1)" << std::endl; + std::vector foo(60, 33); + i32Array.assign(foo.begin(), foo.end()); + std::cout << "i32Array.size() after assign(1): " << i32Array.size() << std::endl; + + i32Array.assign(static_cast(22), 333); + std::cout << "i32Array.size() after assign(2): " << i32Array.size() << std::endl; + + i32Array.assign(std::initializer_list{ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + }); + std::cout << "i32Array.size() after assign(3): " << i32Array.size() << std::endl; + + int32_t* data = i32Array.data(); + if(data[0] != 3) + { + } + // Stick DataArray into a STL container + std::vector> vecOfFloatArrays; + + // ----------------------------------------------------------------------------- + // Let's try something that has components, like an ARGB array + using RgbaType = DataArray; + using CompDimsType = RgbaType::comp_dims_type; + using RgbaIterator = RgbaType::tuple_iterator; + + CompDimsType cDims = {4}; + RgbaType rgba(static_cast(10), cDims, "RGBA Array"); + + RgbaIterator begin = rgba.begin(); + rgba.initializeWithValue(0xFF); + rgba[0] = 0x65; + rgba[1] = 0x66; + rgba[2] = 0x67; + rgba[3] = 0x68; + + for(RgbaIterator rgbaIter = begin; rgbaIter != rgba.end(); rgbaIter++) + { + std::cout << "rgba: " << static_cast(*rgbaIter) << std::endl; + std::cout << " rgba[0] " << static_cast(rgbaIter.comp_value(0)) << " rgba[1] " << static_cast(rgbaIter.comp_value(1)) << " rgba[2] " << static_cast(rgbaIter.comp_value(2)) + << " rgba[3] " << static_cast(rgbaIter.comp_value(3)) << std::endl; + + for(size_t i = 0; i < 4; i++) + { + rgbaIter.comp_value(i) = 55 + i; + } + std::cout << "rgba: " << static_cast(*rgbaIter) << std::endl; + std::cout << " rgba[0] " << static_cast(rgbaIter.comp_value(0)) << " rgba[1] " << static_cast(rgbaIter.comp_value(1)) << " rgba[2] " << static_cast(rgbaIter.comp_value(2)) + << " rgba[3] " << static_cast(rgbaIter.comp_value(3)) << std::endl; + } + } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -1245,7 +1418,9 @@ class DataArrayTest #endif } -private: - DataArrayTest(const DataArrayTest&); // Copy Constructor Not Implemented - void operator=(const DataArrayTest&); // Move assignment Not Implemented +public: + DataArrayTest(const DataArrayTest&) = delete; // Copy Constructor Not Implemented + DataArrayTest(DataArrayTest&&) = delete; // Move Constructor Not Implemented + DataArrayTest& operator=(const DataArrayTest&) = delete; // Copy Assignment Not Implemented + DataArrayTest& operator=(DataArrayTest&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp b/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp index 011cd37382..7dd9faa5b3 100644 --- a/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp +++ b/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp @@ -190,7 +190,7 @@ class StringDataArrayTest StringDataArray::Pointer nodes = initializeStringDataArray(); // Resize to a smaller Array - nodes->resize(k_ResizeSmaller); + nodes->resizeTuples(k_ResizeSmaller); size_t nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeSmaller, nTuples) size_t size = nodes->getSize(); @@ -205,14 +205,14 @@ class StringDataArrayTest DREAM3D_REQUIRE_EQUAL(nodes->getValue(4), ::_4); // Resize to a larger Array - nodes->resize(k_ResizeLarger); + nodes->resizeTuples(k_ResizeLarger); nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeLarger, nTuples) size = nodes->getSize(); DREAM3D_REQUIRE_EQUAL(k_ResizeLarger, size) // Resize to a Zero Array - nodes->resize(k_InitSize); + nodes->resizeTuples(k_InitSize); nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_InitSize, nTuples) size = nodes->getSize(); @@ -276,7 +276,7 @@ class StringDataArrayTest StringDataArray::Pointer nodes = initializeStringDataArray(); StringDataArray::Pointer copy = initializeStringDataArray(); - nodes->resize(k_ArraySize * 2); + nodes->resizeTuples(k_ArraySize * 2); bool didCopy = nodes->copyFromArray(k_ArraySize, copy); DREAM3D_REQUIRE_EQUAL(didCopy, true) DREAM3D_REQUIRE_EQUAL(nodes->getNumberOfTuples(), k_ArraySize * 2); diff --git a/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp b/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp index e01e879975..d85782f984 100644 --- a/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp +++ b/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp @@ -239,7 +239,7 @@ class StructArrayTest Vec3IntListPointer_t nodes = initializeStructArray(); // Resize to a smaller Array - nodes->resize(k_ResizeSmaller); + nodes->resizeTuples(k_ResizeSmaller); size_t nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeSmaller, nTuples) size_t size = nodes->getSize(); @@ -256,7 +256,7 @@ class StructArrayTest } // Resize to a larger Array - nodes->resize(k_ResizeLarger); + nodes->resizeTuples(k_ResizeLarger); nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeLarger, nTuples) size = nodes->getSize(); @@ -279,7 +279,7 @@ class StructArrayTest } // Resize to a Zero Array - nodes->resize(k_InitSize); + nodes->resizeTuples(k_InitSize); Vec3Int_t* ptr = reinterpret_cast(nodes->getVoidPointer(0)); DREAM3D_REQUIRED_PTR(ptr, ==, nullptr); ptr = nodes->getPointer(0); @@ -365,7 +365,7 @@ class StructArrayTest Vec3IntListPointer_t nodes = initializeStructArray(); Vec3IntListPointer_t copy = initializeStructArray(); - nodes->resize(k_ArraySize * 2); + nodes->resizeTuples(k_ArraySize * 2); bool didCopy = nodes->copyFromArray(k_ArraySize, copy); DREAM3D_REQUIRE_EQUAL(didCopy, true) DREAM3D_REQUIRE_EQUAL(nodes->getNumberOfTuples(), k_ArraySize * 2); diff --git a/Source/SIMPLib/DataContainers/AttributeMatrix.cpp b/Source/SIMPLib/DataContainers/AttributeMatrix.cpp index a385e019d5..871c912ba8 100644 --- a/Source/SIMPLib/DataContainers/AttributeMatrix.cpp +++ b/Source/SIMPLib/DataContainers/AttributeMatrix.cpp @@ -59,9 +59,9 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::AttributeMatrix(QVector tDims, const QString& name, AttributeMatrix::Type attrType) -: m_Type(attrType) -, m_Name(name) +AttributeMatrix::AttributeMatrix(const QVector& tDims, const QString& name, AttributeMatrix::Type attrType) +: IDataStructureContainerNode(name) +, m_Type(attrType) , m_TupleDims(tDims) { } @@ -69,10 +69,7 @@ AttributeMatrix::AttributeMatrix(QVector tDims, const QString& name, Att // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::~AttributeMatrix() -{ - // std::cout << "~AttributeMatrix" << std::endl; -} +AttributeMatrix::~AttributeMatrix() = default; // ----------------------------------------------------------------------------- QString AttributeMatrix::TypeToString(AttributeMatrix::Type t) @@ -290,9 +287,11 @@ void AttributeMatrix::ReadAttributeMatrixStructure(hid_t containerId, DataContai // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool AttributeMatrix::doesAttributeArrayExist(const QString& name) const +DataArrayPath AttributeMatrix::getDataArrayPath() const { - return m_AttributeArrays.contains(name); + DataArrayPath path = getParentPath(); + path.setAttributeMatrixName(getName()); + return path; } // ----------------------------------------------------------------------------- @@ -302,10 +301,10 @@ bool AttributeMatrix::validateAttributeArraySizes() { int64_t arraySize = 0; int64_t matrixSize = getNumberOfTuples(); - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + const AttributeMatrix::Container_t& dataArrays = getChildren(); + for(const auto& dataArray : dataArrays) { - IDataArray::Pointer d = iter.value(); - arraySize = d->getNumberOfTuples(); + arraySize = dataArray->getNumberOfTuples(); if(arraySize != matrixSize) { return false; @@ -314,66 +313,19 @@ bool AttributeMatrix::validateAttributeArraySizes() return true; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int AttributeMatrix::addAttributeArray(const QString& name, const IDataArray::Pointer& data) -{ - if(data->getName().compare(name) != 0) - { - qDebug() << "Adding Attribute Array with different array name than key name" - << "\n"; - qDebug() << "Key name: " << name << "\n"; - qDebug() << "Array Name:" << data->getName() << "\n"; - data->setName(name); - } - if(getNumberOfTuples() != data->getNumberOfTuples()) - { - qDebug() << "AttributeMatrix::Name: " << getName() << " dataArray::name: " << data->getName() << " Type: " << data->getTypeAsString(); - qDebug() << "getNumberOfTuples(): " << getNumberOfTuples() << " data->getNumberOfTuples(): " << data->getNumberOfTuples(); - } - Q_ASSERT(getNumberOfTuples() == data->getNumberOfTuples()); - - m_AttributeArrays[name] = data; - return 0; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -IDataArray::Pointer AttributeMatrix::getAttributeArray(const QString& name) -{ - QMap::iterator it; - it = m_AttributeArrays.find(name); - if(it == m_AttributeArrays.end()) - { - return IDataArray::NullPointer(); - } - return it.value(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -IDataArray::Pointer AttributeMatrix::getAttributeArray(const DataArrayPath& path) -{ - return getAttributeArray(path.getDataArrayName()); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- IDataArray::Pointer AttributeMatrix::removeAttributeArray(const QString& name) { - QMap::iterator it; - it = m_AttributeArrays.find(name); - if(it == m_AttributeArrays.end()) + auto it = find(name); + if(it == end()) { // DO NOT return a NullPointer for any reason other than "Data Array was not found" return IDataArray::NullPointer(); } - IDataArray::Pointer p = it.value(); - m_AttributeArrays.erase(it); + IDataArray::Pointer p = (*it); + erase(it); return p; } @@ -382,25 +334,38 @@ IDataArray::Pointer AttributeMatrix::removeAttributeArray(const QString& name) // ----------------------------------------------------------------------------- RenameErrorCodes AttributeMatrix::renameAttributeArray(const QString& oldname, const QString& newname, bool overwrite) { - QMap::iterator itOld; - QMap::iterator itNew; + // Cannot rename a DataArray when the name does not change. + if(oldname == newname) + { + return SAME_PATH; + } - itNew = m_AttributeArrays.find(newname); - // If new name doesn't exist or we want to overwrite one that does exist... - if(itNew == m_AttributeArrays.end() || overwrite) + bool hasNewName = contains(newname); + if(hasNewName) { - itOld = m_AttributeArrays.find(oldname); - // If old name doesn't exist... - if(itOld == m_AttributeArrays.end()) + if(overwrite) { - return OLD_DOES_NOT_EXIST; + removeAttributeArray(newname); } - IDataArray::Pointer p = itOld.value(); - p->setName(newname); - removeAttributeArray(oldname); - addAttributeArray(newname, p); + else + { + return NEW_EXISTS; + } + } + + // If new name doesn't exist or we want to overwrite one that does exist... + auto oldArray = getChildByName(oldname); + // If old name doesn't exist... + if(nullptr == oldArray) + { + return OLD_DOES_NOT_EXIST; + } + if(oldArray->setName(newname)) + { return SUCCESS; } + + // Rename not successful return NEW_EXISTS; } @@ -522,10 +487,10 @@ void AttributeMatrix::resizeAttributeArrays(const QVector& tDims) numTuples *= m_TupleDims[i]; } - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + const AttributeMatrix::Container_t& dataArrays = getChildren(); + for(const auto& dataArray : dataArrays) { - IDataArray::Pointer d = iter.value(); - d->resize(numTuples); + dataArray->resizeTuples(numTuples); } } @@ -534,28 +499,15 @@ void AttributeMatrix::resizeAttributeArrays(const QVector& tDims) // ----------------------------------------------------------------------------- void AttributeMatrix::clearAttributeArrays() { - m_AttributeArrays.clear(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QList AttributeMatrix::getAttributeArrayNames() -{ - QList keys; - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) - { - keys.push_back(iter.key()); - } - return keys; + clear(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int AttributeMatrix::getNumAttributeArrays() const +AttributeMatrix::NameList AttributeMatrix::getAttributeArrayNames() { - return static_cast(m_AttributeArrays.size()); + return getNamesOfChildren(); } // ----------------------------------------------------------------------------- @@ -565,15 +517,15 @@ AttributeMatrix::Pointer AttributeMatrix::deepCopy(bool forceNoAllocate) { AttributeMatrix::Pointer newAttrMat = AttributeMatrix::New(getTupleDimensions(), getName(), getType()); - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + const auto& dataArrays = getChildren(); + for(const auto& d : dataArrays) { - IDataArray::Pointer d = iter.value(); IDataArray::Pointer new_d = d->deepCopy(forceNoAllocate); if(new_d.get() == nullptr) { return AttributeMatrix::NullPointer(); } - newAttrMat->addAttributeArray(new_d->getName(), new_d); + newAttrMat->insertOrAssign(new_d); } return newAttrMat; @@ -583,10 +535,11 @@ AttributeMatrix::Pointer AttributeMatrix::deepCopy(bool forceNoAllocate) // ----------------------------------------------------------------------------- int AttributeMatrix::writeAttributeArraysToHDF5(hid_t parentId) { - int err; - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + int err = 0; + + const auto& dataArrays = getChildren(); + for(const auto& d : dataArrays) { - IDataArray::Pointer d = iter.value(); err = d->writeH5Data(parentId, m_TupleDims); if(err < 0) { @@ -612,7 +565,7 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = H5DataArrayReader::ReadIDataArray(gid, name, preflight); if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } else if(classType.compare("StringDataArray") == 0) @@ -620,7 +573,7 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = H5DataArrayReader::ReadStringDataArray(gid, name, preflight); if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } else if(classType.compare("vector") == 0) @@ -631,7 +584,7 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = H5DataArrayReader::ReadNeighborListData(gid, name, preflight); if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } else if(name.compare(SIMPL::EnsembleData::Statistics) == 0) @@ -642,13 +595,13 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = statsData; if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } if(nullptr != dPtr.get()) { - addAttributeArray(dPtr->getName(), dPtr); + addOrReplaceAttributeArray(dPtr); } return err; @@ -697,7 +650,7 @@ int AttributeMatrix::readAttributeArraysFromHDF5(hid_t amGid, bool preflight, At if(nullptr != dPtr.get()) { - addAttributeArray(dPtr->getName(), dPtr); + addOrReplaceAttributeArray(dPtr); } } H5Gclose(amGid); // Close the Cell Group @@ -713,9 +666,9 @@ QString AttributeMatrix::generateXdmfText(const QString& centering, const QStrin QString block; QTextStream out(&xdmfText); - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + for(auto iter = begin(); iter != end(); ++iter) { - IDataArray::Pointer d = iter.value(); + IDataArray::Pointer d = (*iter); block = writeXdmfAttributeData(d, centering, dataContainerName, hdfFileName, gridType); out << block; } @@ -727,70 +680,78 @@ QString AttributeMatrix::generateXdmfText(const QString& centering, const QStrin // ----------------------------------------------------------------------------- QString AttributeMatrix::getInfoString(SIMPL::InfoStringFormat format) { + QString typeString; + switch(m_Type) + { + case AttributeMatrix::Type::Vertex: + typeString = "Vertex"; + break; + case AttributeMatrix::Type::Edge: + typeString = "Edge"; + break; + case AttributeMatrix::Type::Face: + typeString = "Face"; + break; + case AttributeMatrix::Type::Cell: + typeString = "Cell"; + break; + case AttributeMatrix::Type::VertexFeature: + typeString = "Vertex Feature"; + break; + case AttributeMatrix::Type::EdgeFeature: + typeString = "Edge Feature"; + break; + case AttributeMatrix::Type::FaceFeature: + typeString = "Face Feature"; + break; + case AttributeMatrix::Type::CellFeature: + typeString = "Cell Feature"; + break; + case AttributeMatrix::Type::VertexEnsemble: + typeString = "Vertex Ensemble"; + break; + case AttributeMatrix::Type::EdgeEnsemble: + typeString = "Edge Ensemble"; + break; + case AttributeMatrix::Type::FaceEnsemble: + typeString = "Face Ensemble"; + break; + case AttributeMatrix::Type::CellEnsemble: + typeString = "Cell Ensemble"; + break; + case AttributeMatrix::Type::MetaData: + typeString = "MetaData"; + break; + case AttributeMatrix::Type::Generic: + typeString = "Generic"; + break; + default: + typeString = "Unknown"; + break; + } + QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; + ss << ""; - ss << ""; + ss << ""; - QString typeString; - switch(m_Type) - { - case AttributeMatrix::Type::Vertex: - typeString = "Vertex"; - break; - case AttributeMatrix::Type::Edge: - typeString = "Edge"; - break; - case AttributeMatrix::Type::Face: - typeString = "Face"; - break; - case AttributeMatrix::Type::Cell: - typeString = "Cell"; - break; - case AttributeMatrix::Type::VertexFeature: - typeString = "Vertex Feature"; - break; - case AttributeMatrix::Type::EdgeFeature: - typeString = "Edge Feature"; - break; - case AttributeMatrix::Type::FaceFeature: - typeString = "Face Feature"; - break; - case AttributeMatrix::Type::CellFeature: - typeString = "Cell Feature"; - break; - case AttributeMatrix::Type::VertexEnsemble: - typeString = "Vertex Ensemble"; - break; - case AttributeMatrix::Type::EdgeEnsemble: - typeString = "Edge Ensemble"; - break; - case AttributeMatrix::Type::FaceEnsemble: - typeString = "Face Ensemble"; - break; - case AttributeMatrix::Type::CellEnsemble: - typeString = "Cell Ensemble"; - break; - case AttributeMatrix::Type::MetaData: - typeString = "MetaData"; - break; - case AttributeMatrix::Type::Generic: - typeString = "Generic"; - break; - default: - typeString = "Unknown"; - break; - } QLocale usa(QLocale::English, QLocale::UnitedStates); - ss << ""; + ss << ""; QString tupleStr = "("; for(int i = 0; i < m_TupleDims.size(); i++) { @@ -802,21 +763,24 @@ QString AttributeMatrix::getInfoString(SIMPL::InfoStringFormat format) } } tupleStr = tupleStr + ")"; - ss << ""; + ss << ""; - ss << ""; + ss << ""; ss << "
Attribute Matrix Info
Attribute Matrix Info
Name:" << getName() << "
Name:" << getName() << "
Type:" << typeString << "
Type:" << typeString << "
Tuple Dimensions:" << tupleStr << "
Tuple Dimensions:" << tupleStr << "
Attribute Array Count:" << getNumAttributeArrays() << "
Attribute Array Count:" << getNumAttributeArrays() << "
\n"; ss << ""; + break; } - else - { + default: + ss << "Requested AttributeMatrix information string format is not supported. " << format; + break; } + return info; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, IDataArray::Pointer array, const QString& centering, int precision, +QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, const IDataArray::Pointer& array, const QString& centering, int precision, const QString& xdmfTypeName, const QString& hdfFileName, uint8_t gridType) { QString buf; @@ -838,7 +802,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << "Center=\"" << centering << "\">" << "\n"; // Open the Tag - out << " " << "\n"; @@ -858,7 +822,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << "Center=\"" << centering << "\">" << "\n"; // Open the Tag - out << " getName() << " (Feature 0)\" >" << "\n"; @@ -872,7 +836,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << " " << dimStrHalf << " " << "\n"; out << "\n"; - out << " " << "\n"; @@ -893,7 +857,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << "Center=\"" << centering << "\">" << "\n"; // Open the Tag - out << " getName() << " (Feature 1)\" >" << "\n"; @@ -906,7 +870,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << " " << dimStrHalf << " " << "\n"; out << "\n"; - out << " " << "\n"; diff --git a/Source/SIMPLib/DataContainers/AttributeMatrix.h b/Source/SIMPLib/DataContainers/AttributeMatrix.h index a03ffc6588..5fc5da8412 100755 --- a/Source/SIMPLib/DataContainers/AttributeMatrix.h +++ b/Source/SIMPLib/DataContainers/AttributeMatrix.h @@ -57,6 +57,8 @@ #include "SIMPLib/Common/Observable.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/IDataStructureContainerNode.hpp" +#include "SIMPLib/DataContainers/RenameDataPath.h" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/SIMPLib.h" @@ -69,7 +71,8 @@ enum RenameErrorCodes { OLD_DOES_NOT_EXIST, SUCCESS, - NEW_EXISTS + NEW_EXISTS, + SAME_PATH }; /** @@ -81,7 +84,7 @@ enum RenameErrorCodes * @date * @version 1.0 */ -class SIMPLib_EXPORT AttributeMatrix : public Observable +class SIMPLib_EXPORT AttributeMatrix : public Observable, public IDataStructureContainerNode { // clang-format off PYB11_CREATE_BINDINGS(AttributeMatrix) @@ -93,8 +96,10 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_PROPERTY(QVector TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) - PYB11_METHOD(int addAttributeArray ARGS Name Array) PYB11_METHOD(bool doesAttributeArrayExist ARGS Name) + PYB11_METHOD(bool addOrReplaceAttributeArray OVERLOAD const.IDataArray::Pointer.&,Data) + PYB11_METHOD(bool insertOrAssign ARGS IDataArray::Pointer) + PYB11_METHOD(IDataArray removeAttributeArray ARGS Name) PYB11_METHOD(int renameAttributeArray ARGS OldName NewName OverWrite) PYB11_METHOD(IDataArray::Pointer getAttributeArray OVERLOAD const.QString.&,Name) @@ -108,6 +113,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable ~AttributeMatrix() override; using EnumType = unsigned int; + using Container_t = std::vector>; /** * @brief The Type is an enum that describes the type of data that the AttributeMatrix holds @@ -204,37 +210,56 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable static void ReadAttributeMatrixStructure(hid_t containerId, DataContainerProxy* dcProxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath); /** - * @brief Type - */ - SIMPL_INSTANCE_PROPERTY(AttributeMatrix::Type, Type) + * @brief Creates and returns a DataArrayPath for the AttributeMatrix + * @return + */ + DataArrayPath getDataArrayPath() const override; /** - * @brief Name + * @brief Type */ - SIMPL_INSTANCE_PROPERTY(QString, Name) - + SIMPL_INSTANCE_PROPERTY(AttributeMatrix::Type, Type) /** - * @brief Adds/overwrites the data for a named array - * @param name The name that the array will be known by - * @param data The IDataArray::Pointer that will hold the data - * @return error code if the addition did not work - */ - virtual int addAttributeArray(const QString& name, const IDataArray::Pointer& data); - + * @brief Adds the IDataArray to the AttributeMatrix. + * @param data The IDataArray::Pointer that will hold the data + * @return Bool: True if the addition happened, FALSE if an IDataArray with the same name already exists. + */ + bool addOrReplaceAttributeArray(const IDataArray::Pointer& data) + { + // Can not insert a null IDataArray object + if(data.get() == nullptr) + { + return false; + } + if(getNumberOfTuples() != data->getNumberOfTuples()) + { + qDebug() << "AttributeMatrix::Name: " << getName() << " dataArray::name: " << data->getName() << " Type: " << data->getTypeAsString(); + qDebug() << "getNumberOfTuples(): " << getNumberOfTuples() << " data->getNumberOfTuples(): " << data->getNumberOfTuples(); + } + Q_ASSERT(getNumberOfTuples() == data->getNumberOfTuples()); + return insertOrAssign(data); + } + /** * @brief Returns the array for a given named array or the equivelant to a * null pointer if the name does not exist. * @param name The name of the data array */ - virtual IDataArray::Pointer getAttributeArray(const QString& name); + IDataArray::Pointer getAttributeArray(const QString& name) + { + return getChildByName(name); + } /** * @brief getAttributeArray * @param path * @return */ - virtual IDataArray::Pointer getAttributeArray(const DataArrayPath& path); + IDataArray::Pointer getAttributeArray(const DataArrayPath& path) + { + return getAttributeArray(path.getDataArrayName()); + } /** * @brief returns a IDataArray based object that is stored in the attribute matrix by a @@ -253,7 +278,10 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable * @brief Returns bool of whether a named array exists * @param name The name of the data array */ - virtual bool doesAttributeArrayExist(const QString& name) const; + bool doesAttributeArrayExist(const QString& name) const + { + return contains(name); + } /** @@ -276,18 +304,30 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable */ virtual void clearAttributeArrays(); + /** + * @brief Returns the collection of contained DataArrays + * @return + */ + Container_t getAttributeArrays() const + { + return getChildren(); + } + /** * @brief Returns a list that contains the names of all the arrays currently stored in the * Cell (Formerly Cell) group * @return */ - virtual QList getAttributeArrayNames(); + virtual NameList getAttributeArrayNames(); /** * @brief Returns the total number of arrays that are stored in the Cell group * @return */ - virtual int getNumAttributeArrays() const; + int getNumAttributeArrays() const + { + return static_cast(size()); + } /** @@ -326,9 +366,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { if(filter) { - filter->setErrorCondition(err); ss = QObject::tr("AttributeMatrix:'%1' The name of a requested Attribute Array was empty. Please provide a name for this array").arg(getName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err, ss); } } // Now ask for the actual AttributeArray from the AttributeMatrix @@ -336,9 +375,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { if(filter) { - filter->setErrorCondition(err); ss = QObject::tr("The AttributeMatrix named '%1' does NOT have a DataArray with name '%2'. This filter requires this DataArray in order to execute.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err, ss); } return attributeArray; } @@ -356,9 +394,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable attributeArray = std::dynamic_pointer_cast< ArrayType >(iDataArray); if(nullptr == attributeArray.get() && filter) { - filter->setErrorCondition(err); ss = QObject::tr("The AttributeMatrix named '%1' contains an array with name '%2' but the DataArray could not be downcast using std::dynamic_pointer_cast.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err, ss); } return attributeArray; } @@ -381,9 +418,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { if(filter) { - filter->setErrorCondition(err); ss = QObject::tr("AttributeMatrix:'%1' The name of a requested Attribute Array was empty. Please provide a name for this array").arg(getName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err, ss); } } // Now ask for the actual AttributeArray from the AttributeMatrix @@ -391,9 +427,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { if(filter) { - filter->setErrorCondition(err); ss = QObject::tr("The AttributeMatrix named '%1' does NOT have a DataArray with name '%2'. This filter requires this DataArray in order to execute.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err, ss); } return attributeArray; } @@ -404,9 +439,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable return std::dynamic_pointer_cast(ptr); } - filter->setErrorCondition(err); ss = QObject::tr("Unable to cast input array %1 to the necessary type.").arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err, ss); return attributeArray; } @@ -425,7 +459,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable typename ArrayType::Pointer createNonPrereqArray(Filter* filter, const QString& attributeArrayName, T initValue, - QVector compDims) + QVector compDims, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) { typename ArrayType::Pointer attributeArray = ArrayType::NullPointer(); @@ -434,9 +469,8 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { if(filter) { - filter->setErrorCondition(-10001); ss = QObject::tr("The name of the array was empty. Please provide a name for this array."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10001, ss); } return attributeArray; } @@ -447,24 +481,28 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable } else if (filter) { - filter->setErrorCondition(-10002); ss = QObject::tr("AttributeMatrix:'%1' An Attribute Array already exists with the name %2.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10002, ss); return attributeArray; } iDataArray = getAttributeArray(attributeArrayName); if(nullptr == iDataArray && filter) { - filter->setErrorCondition(-10003); ss = QObject::tr("AttributeMatrix:'%1' An array with name '%2' could not be created.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10003, ss); } attributeArray = std::dynamic_pointer_cast< ArrayType >(iDataArray); if(nullptr == attributeArray.get() && filter) { - filter->setErrorCondition(-10004); ss = QObject::tr("AttributeMatrix:'%1' An array with name '%2' could not be downcast using std::dynamic_pointer_cast.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10004, ss); + } + else if(nullptr != attributeArray && filter) + { + // Check if path was renamed + // This will crash if no parent node is found + IDataStructureNode* parentPtr = getParentNode(); + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(parentPtr->getName(), getName(), attributeArrayName)); } return attributeArray; } @@ -475,7 +513,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable * @param dims The size the data on each tuple */ template - void createAndAddAttributeArray(Filter* filter, const QString& name, T initValue, QVector compDims) + void createAndAddAttributeArray(Filter* filter, const QString& name, T initValue, QVector compDims, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) { bool allocateData = false; if(nullptr == filter) { allocateData = true; } @@ -488,7 +526,11 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable attributeArray->initializeWithValue(initValue); } attributeArray->setInitValue(initValue); - addAttributeArray(name, attributeArray); + addOrReplaceAttributeArray(attributeArray); + // Check if path was renamed + DataArrayPath path = getDataArrayPath(); + path.setDataArrayName(name); + RenameDataPath::AlertFilterCreatedPath(filter, id, path); } } @@ -514,8 +556,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable QString srcDesc = srcArray->getTypeAsString(); QString desc = validTargetArray->getTypeAsString(); QString ss = QObject::tr("The Filter '%1' requires an array of type '%2' but the data array '%3' has a type of '%4'").arg(filter->getHumanLabel()).arg(desc).arg(srcArray->getName()).arg(srcDesc); - filter->setErrorCondition(-501); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-501, ss); } return false; } @@ -526,8 +567,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { QString ss = QObject::tr("Filter '%1' requires array with name '%2' to have Number of Tuples = %3. The currently selected array " " has %4").arg(filter->getHumanLabel()).arg(arrayName).arg((getNumberOfTuples())).arg(targetDestArray->getNumberOfTuples()); - filter->setErrorCondition(-502); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-502, ss); } return false; } @@ -538,8 +578,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable { QString ss = QObject::tr("Filter '%1' is trying to use array '%2' where the number of components is %3 but the filter requires that array " " to have %4.").arg(filter->getHumanLabel()).arg(targetDestArray->getName()).arg(targetDestArray->getNumberOfComponents()).arg(numComp); - filter->setErrorCondition(-503); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-503, ss); } return false; } @@ -553,8 +592,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable .arg(arrayName).arg(dat->getTypeAsString()).arg(getNameOfClass()).arg(arrayName).arg(getNameOfClass()).arg(targetDestArray->getTypeAsString()); if (nullptr != filter) { - filter->setErrorCondition(-504); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-504, ss); } return false; } @@ -638,7 +676,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable virtual QString getInfoString(SIMPL::InfoStringFormat format); protected: - AttributeMatrix(QVector tDims, const QString& name, AttributeMatrix::Type attrType); + AttributeMatrix(const QVector& tDims, const QString& name, AttributeMatrix::Type attrType); /** * @brief writeXdmfAttributeData @@ -664,12 +702,11 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable * @param gridType * @return */ - virtual QString writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, IDataArray::Pointer array, const QString& centering, int precision, + virtual QString writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, const IDataArray::Pointer& array, const QString& centering, int precision, const QString& xdmfTypeName, const QString& hdfFileName, uint8_t gridType = 0); private: QVector m_TupleDims; - QMap m_AttributeArrays; AttributeMatrix(const AttributeMatrix&); void operator =(const AttributeMatrix&); diff --git a/Source/SIMPLib/DataContainers/DataArrayPath.cpp b/Source/SIMPLib/DataContainers/DataArrayPath.cpp index dfa86ab80f..220f96a8fa 100644 --- a/Source/SIMPLib/DataContainers/DataArrayPath.cpp +++ b/Source/SIMPLib/DataContainers/DataArrayPath.cpp @@ -41,6 +41,15 @@ #include "SIMPLib/DataArrays/NeighborList.hpp" #include "SIMPLib/DataContainers/DataContainerArray.h" +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath::HashType DataArrayPath::GetHash(const QString& name) +{ + std::hash hashFn; + return hashFn(name.toStdString()); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -63,7 +72,11 @@ DataArrayPath::DataArrayPath(const QString& dcName, const QString& amName, const : m_DataContainerName(dcName) , m_AttributeMatrixName(amName) , m_DataArrayName(daName) +, m_DataContainerHash(GetHash(dcName)) +, m_AttributeMatrixHash(GetHash(amName)) +, m_DataArrayHash(GetHash(daName)) { + updateDataType(); } // ----------------------------------------------------------------------------- @@ -75,16 +88,18 @@ DataArrayPath::DataArrayPath(const QString& path) if(!tokens.empty()) { - m_DataContainerName = tokens.at(0); + setDataContainerName(tokens.at(0)); } if(tokens.size() > 1) { - m_AttributeMatrixName = tokens.at(1); + setAttributeMatrixName(tokens.at(1)); } if(tokens.size() > 2) { - m_DataArrayName = tokens.at(2); + setDataArrayName(tokens.at(2)); } + + updateDataType(); } // ----------------------------------------------------------------------------- @@ -92,9 +107,14 @@ DataArrayPath::DataArrayPath(const QString& path) // ----------------------------------------------------------------------------- DataArrayPath::DataArrayPath(const DataArrayPath& rhs) { - m_DataContainerName = rhs.getDataContainerName(); - m_AttributeMatrixName = rhs.getAttributeMatrixName(); - m_DataArrayName = rhs.getDataArrayName(); + m_DataContainerName = rhs.m_DataContainerName; + m_AttributeMatrixName = rhs.m_AttributeMatrixName; + m_DataArrayName = rhs.m_DataArrayName; + m_DataContainerHash = rhs.m_DataContainerHash; + m_AttributeMatrixHash = rhs.m_AttributeMatrixHash; + m_DataArrayHash = rhs.m_DataArrayHash; + + updateDataType(); } // ----------------------------------------------------------------------------- @@ -124,6 +144,11 @@ DataArrayPath& DataArrayPath::operator=(const DataArrayPath& rhs) m_DataContainerName = rhs.m_DataContainerName; m_AttributeMatrixName = rhs.m_AttributeMatrixName; m_DataArrayName = rhs.m_DataArrayName; + m_DataContainerHash = rhs.m_DataContainerHash; + m_AttributeMatrixHash = rhs.m_AttributeMatrixHash; + m_DataArrayHash = rhs.m_DataArrayHash; + + updateDataType(); return *this; } @@ -132,13 +157,30 @@ DataArrayPath& DataArrayPath::operator=(const DataArrayPath& rhs) // ----------------------------------------------------------------------------- bool DataArrayPath::operator==(const DataArrayPath& rhs) const { - return m_DataContainerName == rhs.m_DataContainerName && m_AttributeMatrixName == rhs.m_AttributeMatrixName && m_DataArrayName == rhs.m_DataArrayName; + return m_DataContainerHash == rhs.m_DataContainerHash && m_AttributeMatrixHash == rhs.m_AttributeMatrixHash && m_DataArrayHash == rhs.m_DataArrayHash; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPath::serialize(QString delimiter) const +bool DataArrayPath::operator!=(const DataArrayPath& rhs) const +{ + bool b = (*this == rhs); + return !b; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataArrayPath::operator<(const DataArrayPath& rhs) const +{ + return serialize() < rhs.serialize(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString DataArrayPath::serialize(const QString& delimiter) const { QString s = ""; if(!m_DataContainerName.isEmpty()) @@ -162,7 +204,7 @@ QString DataArrayPath::serialize(QString delimiter) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath DataArrayPath::Deserialize(QString str, QString delimiter) +DataArrayPath DataArrayPath::Deserialize(const QString& str, const QString& delimiter) { if(str.isEmpty()) { @@ -193,13 +235,44 @@ DataArrayPath DataArrayPath::Deserialize(QString str, QString delimiter) break; } + path.updateDataType(); return path; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPath::CheckRenamePath(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, DataArrayPath oldPath, DataArrayPath newPath) +void DataArrayPath::setDataContainerName(const QString& name) +{ + m_DataContainerName = name; + m_DataContainerHash = GetHash(m_DataContainerName); + updateDataType(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArrayPath::setAttributeMatrixName(const QString& name) +{ + m_AttributeMatrixName = name; + m_AttributeMatrixHash = GetHash(m_AttributeMatrixName); + updateDataType(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArrayPath::setDataArrayName(const QString& name) +{ + m_DataArrayName = name; + m_DataArrayHash = GetHash(m_DataArrayName); + updateDataType(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataArrayPath::CheckRenamePath(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const DataArrayPath& oldPath, const DataArrayPath& newPath) { // If the paths are not possible renames, return false if(!oldPath.possibleRename(newPath)) @@ -259,14 +332,14 @@ bool DataArrayPath::CheckRenamePath(DataContainerArrayShPtr oldDca, DataContaine // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, std::list oldPaths, std::list newPaths) +DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const std::list& oldPaths, const std::list& newPaths) { RenameContainer container; std::list duplicatedPaths; std::list usedNewPaths; // For each older path, check for any matching new paths. If only one new path matches, add it as a possibility - for(DataArrayPath oldPath : oldPaths) + for(const DataArrayPath& oldPath : oldPaths) { // If the same path exists in both oldPaths and newPaths, it was not renamed if(std::find(newPaths.begin(), newPaths.end(), oldPath) != newPaths.end()) @@ -276,7 +349,7 @@ DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainer // Find any potential renames in newPaths for the given oldPath std::list matches; - for(DataArrayPath newPath : newPaths) + for(const DataArrayPath& newPath : newPaths) { // If the same path exists in both oldPaths and newPaths, it was not renamed if(std::find(oldPaths.begin(), oldPaths.end(), newPath) != oldPaths.end()) @@ -293,7 +366,7 @@ DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainer // If this path was already used, mark it as duplicate and move on if(matches.size() == 1) { - DataArrayPath newPath = (*matches.begin()); + const DataArrayPath& newPath = matches.front(); if(usedNewPaths.end() != std::find(usedNewPaths.begin(), usedNewPaths.end(), newPath)) { duplicatedPaths.push_back(newPath); @@ -301,7 +374,7 @@ DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainer else { usedNewPaths.push_back(newPath); - container.push_back(RenameType(oldPath, newPath)); + container.push_back(std::make_pair(oldPath, newPath)); } } } @@ -309,7 +382,7 @@ DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainer // Remove items with duplicated paths for(auto iter = container.begin(); iter != container.end(); ) { - DataArrayPath checkPath = std::get<1>(*iter); + const DataArrayPath& checkPath = std::get<1>(*iter); if(duplicatedPaths.end() != std::find(duplicatedPaths.begin(), duplicatedPaths.end(), checkPath)) { iter = container.erase(iter); @@ -326,56 +399,54 @@ DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainer // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath::DataType DataArrayPath::getDataType() +void DataArrayPath::updateDataType() { - if(getDataContainerName().isEmpty()) - { - return DataType::None; - } - if(getAttributeMatrixName().isEmpty() && getDataArrayName().isEmpty()) + const bool dcEmpty = m_DataContainerName.isEmpty(); + const bool amEmpty = m_AttributeMatrixName.isEmpty(); + const bool daEmpty = m_DataArrayName.isEmpty(); + + if(dcEmpty) { - return DataType::DataContainer; + m_DataType = DataArrayPathHelper::DataType::None; + return; } - if(getDataArrayName().isEmpty()) + if(amEmpty) { - return DataType::AttributeMatrix; + if(daEmpty) + { + m_DataType = DataArrayPathHelper::DataType::DataContainer; + return; + } } - if(!getAttributeMatrixName().isEmpty()) + else { - return DataType::DataArray; + if(daEmpty) + { + m_DataType = DataArrayPathHelper::DataType::AttributeMatrix; + return; + } + if(!amEmpty) + { + m_DataType = DataArrayPathHelper::DataType::DataArray; + return; + } } - return DataType::None; + m_DataType = DataArrayPathHelper::DataType::None; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector DataArrayPath::toQVector() +QVector DataArrayPath::toQVector() const { QVector v(3); - v[0] = m_DataContainerName; - v[1] = m_AttributeMatrixName; - v[2] = m_DataArrayName; + v[0] = getDataContainerName(); + v[1] = getAttributeMatrixName(); + v[2] = getDataArrayName(); return v; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataArrayPath::isEmpty() const -{ - return m_DataContainerName.isEmpty() && m_AttributeMatrixName.isEmpty() && m_DataArrayName.isEmpty(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataArrayPath::isValid() const -{ - return !m_DataContainerName.isEmpty() && !m_AttributeMatrixName.isEmpty() && !m_DataArrayName.isEmpty(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -400,7 +471,7 @@ DataArrayPath DataArrayPath::GetAttributeMatrixPath(const QVector return DataArrayPath(); } - return DataArrayPath(paths.first().getDataContainerName(), paths.first().getAttributeMatrixName(), ""); + return DataArrayPath(paths.first().getDataContainerName(), paths.first().getAttributeMatrixName(), ""); } // ----------------------------------------------------------------------------- @@ -409,7 +480,7 @@ DataArrayPath DataArrayPath::GetAttributeMatrixPath(const QVector QStringList DataArrayPath::toQStringList() const { QStringList l; - l << m_DataContainerName << m_AttributeMatrixName << m_DataArrayName; + l << getDataContainerName() << getAttributeMatrixName() << getDataArrayName(); return l; } @@ -418,9 +489,10 @@ QStringList DataArrayPath::toQStringList() const // ----------------------------------------------------------------------------- void DataArrayPath::update(const QString& dcName, const QString& amName, const QString& daName) { - m_DataContainerName = dcName; - m_AttributeMatrixName = amName; - m_DataArrayName = daName; + setDataContainerName(dcName); + setAttributeMatrixName(amName); + setDataArrayName(daName); + updateDataType(); } // ----------------------------------------------------------------------------- @@ -428,7 +500,7 @@ void DataArrayPath::update(const QString& dcName, const QString& amName, const Q // ----------------------------------------------------------------------------- bool DataArrayPath::hasSameDataContainer(const DataArrayPath& other) const { - return (m_DataContainerName == other.m_DataContainerName); + return m_DataContainerHash == other.m_DataContainerHash; } // ----------------------------------------------------------------------------- @@ -436,7 +508,7 @@ bool DataArrayPath::hasSameDataContainer(const DataArrayPath& other) const // ----------------------------------------------------------------------------- bool DataArrayPath::hasSameAttributeMatrix(const DataArrayPath& other) const { - return (m_AttributeMatrixName == other.m_AttributeMatrixName); + return m_AttributeMatrixHash == other.m_AttributeMatrixHash; } // ----------------------------------------------------------------------------- @@ -444,7 +516,7 @@ bool DataArrayPath::hasSameAttributeMatrix(const DataArrayPath& other) const // ----------------------------------------------------------------------------- bool DataArrayPath::hasSameDataArray(const DataArrayPath& other) const { - return (m_DataArrayName == other.m_DataArrayName); + return m_DataArrayHash == other.m_DataArrayHash; } // ----------------------------------------------------------------------------- @@ -458,85 +530,58 @@ bool DataArrayPath::hasSameAttributeMatrixPath(const DataArrayPath& other) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPath::possibleRename(const DataArrayPath& updated) const +bool DataArrayPath::isSubset(const DataArrayPath& other) const { - // Empty DataArrayPaths are not considered renames - // Neither are DataArrayPaths of different lengths - if(updated.getDataContainerName().isEmpty() || getDataContainerName().isEmpty()) - { - return false; - } - if(updated.getAttributeMatrixName().isEmpty() != getAttributeMatrixName().isEmpty()) - { - return false; - } - if(updated.getDataArrayName().isEmpty() != getDataArrayName().isEmpty()) - { - return false; - } + // Check types + const DataArrayPathHelper::DataType type = getDataType(); + const DataArrayPathHelper::DataType otherType = other.getDataType(); - // Check number of differences - int differences = 0; - if(!hasSameDataArray(updated)) - { - differences++; - } - if(!hasSameAttributeMatrix(updated)) + // If both are of the same DataType, require identical paths + if(type == otherType) { - differences++; + return (*this) == other; } - if(!hasSameDataContainer(updated)) - { - differences++; - } - - return 1 == differences; -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataArrayPath::updatePath(const DataArrayPath::RenameType& renamePath) -{ - DataArrayPath oldPath; - DataArrayPath newPath; - std::tie(oldPath, newPath) = renamePath; - - // Check for differences with original path - if(!hasSameDataArray(oldPath) && !oldPath.getDataArrayName().isEmpty()) - { - return false; - } - if(!hasSameAttributeMatrix(oldPath) && !oldPath.getAttributeMatrixName().isEmpty()) - { - return false; - } - if(!hasSameDataContainer(oldPath) && !oldPath.getDataContainerName().isEmpty()) - { - return false; - } - if(oldPath.getDataContainerName().isEmpty() || newPath.getDataContainerName().isEmpty()) + switch(otherType) { - return false; + case DataArrayPathHelper::DataType::DataArray: + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + if(type == DataArrayPathHelper::DataType::DataArray) + { + return false; + } + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + if(type == DataArrayPathHelper::DataType::AttributeMatrix || type == DataArrayPathHelper::DataType::DataArray) + { + return false; + } + break; + case DataArrayPathHelper::DataType::None: + if(type != DataArrayPathHelper::DataType::None) + { + return false; + } } - // Substitude in the new DataArrayPath - if(hasSameDataContainer(oldPath)) + bool valid = true; + switch(type) { - setDataContainerName(newPath.getDataContainerName()); - - if(hasSameAttributeMatrix(oldPath)) - { - setAttributeMatrixName(newPath.getAttributeMatrixName()); - - if(hasSameDataArray(oldPath)) - { - setDataArrayName(newPath.getDataArrayName()); - } - } + case DataArrayPathHelper::DataType::DataArray: + valid &= m_DataArrayHash == other.m_DataArrayHash; + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + valid &= m_AttributeMatrixHash == other.m_AttributeMatrixHash; + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + valid &= m_DataContainerHash == other.m_DataContainerHash; + break; + case DataArrayPathHelper::DataType::None: + break; } - - return true; + + return valid; } // ----------------------------------------------------------------------------- @@ -595,9 +640,9 @@ bool DataArrayPath::readJson(QJsonObject& json) { if(json["Data Container Name"].isString() && json["Attribute Matrix Name"].isString() && json["Data Array Name"].isString()) { - m_DataContainerName = json["Data Container Name"].toString(); - m_AttributeMatrixName = json["Attribute Matrix Name"].toString(); - m_DataArrayName = json["Data Array Name"].toString(); + setDataContainerName(json["Data Container Name"].toString()); + setAttributeMatrixName(json["Attribute Matrix Name"].toString()); + setDataArrayName(json["Data Array Name"].toString()); return true; } return false; diff --git a/Source/SIMPLib/DataContainers/DataArrayPath.h b/Source/SIMPLib/DataContainers/DataArrayPath.h index e383a00e56..4c3840e16d 100755 --- a/Source/SIMPLib/DataContainers/DataArrayPath.h +++ b/Source/SIMPLib/DataContainers/DataArrayPath.h @@ -42,7 +42,7 @@ #include #include -#include +#include #include "SIMPLib/Common/SIMPLibDLLExport.h" // for SIMPLib_EXPORT #include "SIMPLib/Common/SIMPLibSetGetMacros.h" // for SIMPL_PIMPL_PROPERTY_DECL @@ -50,17 +50,40 @@ class DataContainerArray; using DataContainerArrayShPtr = std::shared_ptr; +/** + * @brief The DataArrayPathHelper namespace is used to contain the QMetaType + * and enum DataType without requiring DataArrayPath to be a QObject. + */ +class SIMPLib_EXPORT DataArrayPathHelper final : public QObject +{ + Q_OBJECT + +public: + enum class DataType + { + DataContainer, + AttributeMatrix, + DataArray, + None + }; + Q_ENUM(DataType) + + ~DataArrayPathHelper() = default; + +private: + DataArrayPathHelper() = default; +}; + /** * @brief The DataArrayPath class holds a complete or partial path to a data array starting at the DataContainer * level. The class is implemented using the PIMPL design pattern. */ -class SIMPLib_EXPORT DataArrayPath : public QObject +class SIMPLib_EXPORT DataArrayPath { - Q_OBJECT - + PYB11_CREATE_BINDINGS(DataArrayPath) PYB11_CREATION(ARGS QString QString QString) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(QString AttributeMatrixName READ getAttributeMatrixName WRITE setAttributeMatrixName) PYB11_PROPERTY(QString DataArrayName READ getDataArrayName WRITE setDataArrayName) @@ -68,20 +91,23 @@ class SIMPLib_EXPORT DataArrayPath : public QObject PYB11_METHOD(bool isValid) PYB11_METHOD(void update ARGS dcName amName daName) + using HashType = size_t; + +private: + QString m_DataContainerName; + QString m_AttributeMatrixName; + QString m_DataArrayName; + HashType m_DataContainerHash = 0; + HashType m_AttributeMatrixHash = 0; + HashType m_DataArrayHash = 0; + + static HashType GetHash(const QString& name); + public: // tuple - using RenameType = std::tuple; + using RenameType = std::pair; using RenameContainer = std::list; - enum class DataType - { - DataContainer, - AttributeMatrix, - DataArray, - None - }; - Q_ENUM(DataType) - DataArrayPath(); /** @@ -106,7 +132,7 @@ class SIMPLib_EXPORT DataArrayPath : public QObject /** * @brief ~DataArrayPath */ - ~DataArrayPath() override; + virtual ~DataArrayPath(); /** * @brief checks that a vector of paths have the same data container and attribute matrix @@ -139,7 +165,7 @@ class SIMPLib_EXPORT DataArrayPath : public QObject * @param delimiter * @return */ - static DataArrayPath Deserialize(QString str, QString delimiter); + static DataArrayPath Deserialize(const QString& str, const QString& delimiter); /** * @brief checks for and returns any updated DataArrayPaths between two sets @@ -147,7 +173,7 @@ class SIMPLib_EXPORT DataArrayPath : public QObject * @param newPaths * @return */ - static RenameContainer CheckForRenamedPaths(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, std::list oldPaths, std::list newPaths); + static RenameContainer CheckForRenamedPaths(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const std::list& oldPaths, const std::list& newPaths); /** * @brief checks if the targets of the old DataArrayPath and new DataArrayPath are compatible in their given DataContainerArrays @@ -156,18 +182,37 @@ class SIMPLib_EXPORT DataArrayPath : public QObject * @param oldPath * @param newPath */ - static bool CheckRenamePath(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, DataArrayPath oldPath, DataArrayPath newPath); + static bool CheckRenamePath(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const DataArrayPath& oldPath, const DataArrayPath& newPath); /** - * @brief Returns the DataType matching the current path - * @return - */ - DataType getDataType(); + * @brief Returns the DataType matching the current path. + * @return + */ + DataArrayPathHelper::DataType getDataType() const + { + return m_DataType; + } - SIMPL_INSTANCE_STRING_PROPERTY(DataContainerName) - SIMPL_INSTANCE_STRING_PROPERTY(AttributeMatrixName) - SIMPL_INSTANCE_STRING_PROPERTY(DataArrayName) + QString getDataContainerName() const + { + return m_DataContainerName; + } + QString getAttributeMatrixName() const + { + return m_AttributeMatrixName; + } + + QString getDataArrayName() const + { + return m_DataArrayName; + } + + void setDataContainerName(const QString& name); + + void setAttributeMatrixName(const QString& name); + + void setDataArrayName(const QString& name); /** * @brief operator = @@ -181,26 +226,43 @@ class SIMPLib_EXPORT DataArrayPath : public QObject */ bool operator==(const DataArrayPath& rhs) const; + /** + * @brief operator != + * @param rhs + * @return + */ + bool operator!=(const DataArrayPath& rhs) const; + + /** + * @brief operator < is required for std::set + * @param rhs + * @return + */ + bool operator<(const DataArrayPath& rhs) const; + /** * @brief serialize Returns the path using the '|' charater by default. This can be over ridden by the programmer * @param delimiter * @return */ - QString serialize(QString delimiter = "|") const; + QString serialize(const QString& delimiter = "|") const; /** * @brief getAsVector Returns the DataArrayPath represented as a QVector where index[0] = DataContainer Name, * index[1] = AttributeMatrix Name and index[2] = DataArray Name * @return */ - QVector toQVector(); + QVector toQVector() const; /** * @brief isEmpty Returns if ALL of the string elements are empty. Note that a class could return FALSE for this * function and FALSE for isValid() also so this function is not a true indication of a valid path. * @return */ - bool isEmpty() const; + bool isEmpty() const + { + return m_DataType == DataArrayPathHelper::DataType::None; + } /** * @brief isValid Returns if ALL of the string components have some value stored in them so 'valid' in this sense just @@ -208,7 +270,10 @@ class SIMPLib_EXPORT DataArrayPath : public QObject * serialized into a path actually refer to something in your DataContainer. * @return */ - bool isValid() const; + bool isValid() const + { + return m_DataType == DataArrayPathHelper::DataType::DataArray; + } /** * @brief toQStringList Converts the DataArrayPath to a QStringList @@ -252,6 +317,13 @@ class SIMPLib_EXPORT DataArrayPath : public QObject */ bool hasSameDataArray(const DataArrayPath& other) const; + /** + * @brief Returns true if this DataArrayPath is a subset of the given path. Returns false otherwise. + * @param other + * @return + */ + bool isSubset(const DataArrayPath& other) const; + /** * @brief checks if the given DataArrayPath could indicate a possible renamed path. * This requires that the given path be no longer than the current path and only one value is changed. @@ -259,14 +331,133 @@ class SIMPLib_EXPORT DataArrayPath : public QObject * @param updated * @return */ - bool possibleRename(const DataArrayPath& updated) const; + bool possibleRename(const DataArrayPath& updated) const + { + // Empty DataArrayPaths are not considered renames + // Neither are DataArrayPaths of different lengths + if(getDataType() != updated.getDataType()) + { + return false; + } + + // Check number of differences + int differences = 0; + if(!hasSameDataArray(updated)) + { + differences++; + } + if(!hasSameAttributeMatrix(updated)) + { + differences++; + } + if(!hasSameDataContainer(updated)) + { + differences++; + } + + return 1 == differences; + } /** * @brief updates the current path based on the newPath if it matches the given previous value * @param renamePath * return */ - bool updatePath(const DataArrayPath::RenameType& renamePath); + bool updatePath(const DataArrayPath::RenameType& renamePath) + { + const DataArrayPath& oldPath = std::get<0>(renamePath); + const DataArrayPath& newPath = std::get<1>(renamePath); + + bool valid = true; + // Check for differences with original path + switch(oldPath.getDataType()) + { + case DataArrayPathHelper::DataType::DataArray: + valid &= hasSameDataArray(oldPath); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + valid &= hasSameAttributeMatrix(oldPath); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + valid &= hasSameDataContainer(oldPath); + break; + default: + valid = false; + break; + } + + if(!valid) + { + return false; + } + + // Substitude in the new DataArrayPath + switch(oldPath.getDataType()) + { + case DataArrayPathHelper::DataType::DataArray: + setDataArrayName(newPath.getDataArrayName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + setAttributeMatrixName(newPath.getAttributeMatrixName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + setDataContainerName(newPath.getDataContainerName()); + break; + case DataArrayPathHelper::DataType::None: + break; + } + + return true; + } + + /** + * @brief Creates the missing RenameType resulting from two other RenameTypes. + * This can fail if the previous and new RenameTypes are not adequately related. + * This returns a pair of a bool signifying the success of the operation and the + * resulting RenameType. + * @param oldRename + * @param newRename + * @return std::pair + */ + static std::pair CreateLinkingRename(const RenameType& oldRename, const RenameType& newRename) + { + const DataArrayPath& oldOldPath = std::get<0>(oldRename); + const DataArrayPath& oldNewPath = std::get<1>(oldRename); + + const DataArrayPath& newOldPath = std::get<0>(newRename); + const DataArrayPath& newNewPath = std::get<1>(newRename); + + // Require newOldPath to be a subset of oldNewPath + // Require newOldPath != oldNewPath + const bool isSubset = newOldPath.isSubset(oldNewPath); + if(!isSubset || (newOldPath == oldNewPath)) + { + return std::make_pair(false, RenameType{}); + } + + // Create output rename + DataArrayPath replacementOldPath = oldOldPath; + replacementOldPath.updatePath(newRename); + DataArrayPath replacementNewPath = oldNewPath; + + DataArrayPathHelper::DataType newOldType = newOldPath.getDataType(); + switch(newOldType) + { + case DataArrayPathHelper::DataType::DataArray: + replacementNewPath.setDataArrayName(newNewPath.getDataArrayName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + replacementNewPath.setAttributeMatrixName(newNewPath.getAttributeMatrixName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + replacementNewPath.setDataContainerName(newNewPath.getDataContainerName()); + break; + case DataArrayPathHelper::DataType::None: + break; + } + + return std::make_pair(true, std::make_pair(replacementOldPath, replacementNewPath)); + } /** * @brief Writes the contents of the proxy to the json object 'json' @@ -288,19 +479,12 @@ class SIMPLib_EXPORT DataArrayPath : public QObject */ QJsonObject toJsonObject() const; - protected: - - + void updateDataType(); private: - - + DataArrayPathHelper::DataType m_DataType = DataArrayPathHelper::DataType::None; }; - Q_DECLARE_METATYPE(DataArrayPath) -Q_DECLARE_METATYPE(DataArrayPath::DataType) - - - +Q_DECLARE_METATYPE(DataArrayPathHelper::DataType) diff --git a/Source/SIMPLib/DataContainers/DataContainer.cpp b/Source/SIMPLib/DataContainers/DataContainer.cpp index d397df6434..3646f11233 100644 --- a/Source/SIMPLib/DataContainers/DataContainer.cpp +++ b/Source/SIMPLib/DataContainers/DataContainer.cpp @@ -65,7 +65,7 @@ DataContainer::DataContainer() = default; // // ----------------------------------------------------------------------------- DataContainer::DataContainer(const QString &name) - : m_Name(name) + : IDataStructureContainerNode(name) { } @@ -87,6 +87,19 @@ DataContainer::Pointer DataContainer::New(const QString& name) return sharedPtr; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainer::Pointer DataContainer::New(const DataArrayPath& path) +{ + if(path.isEmpty()) + { + return DataContainer::NullPointer(); + } + DataContainer::Pointer sharedPtr(new DataContainer(path.getDataContainerName())); + return sharedPtr; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -148,17 +161,9 @@ void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContain // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainer::setName(const QString& name) +DataArrayPath DataContainer::getDataArrayPath() const { - m_Name = name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString DataContainer::getName() -{ - return m_Name; + return DataArrayPath(getName(), "", ""); } // ----------------------------------------------------------------------------- @@ -177,90 +182,29 @@ IGeometry::Pointer DataContainer::getGeometry() return m_Geometry; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -DataContainer::AttributeMatrixMap_t& DataContainer::getAttributeMatrices() -{ - return m_AttributeMatrices; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataContainer::doesAttributeMatrixExist(const QString& name) -{ - return m_AttributeMatrices.contains(name); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AttributeMatrix::Pointer DataContainer::createAndAddAttributeMatrix(const QVector& tDims, const QString& attrMatName, AttributeMatrix::Type attrType) { AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, attrMatName, attrType); - addAttributeMatrix(attrMatName, attrMat); + addOrReplaceAttributeMatrix(attrMat); return attrMat; // Return the shared pointer } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void DataContainer::addAttributeMatrix(const QString& name, const AttributeMatrix::Pointer& data) -{ - if(data->getName().compare(name) != 0) - { - qDebug() << "Adding Attribute Matrix with a different name than key name"; - qDebug() << "Key name: " << name; - qDebug() << "AttributeMatrix Name: " << data->getName(); - qDebug() << "This action is NOT typical of DREAM3D Usage. Are you sure you want to be doing this? We are forcing the name of the AttributeMatrix to be the same as the key"; - data->setName(name); - } - m_AttributeMatrices[name] = data; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -AttributeMatrix::Pointer DataContainer::getAttributeMatrix(const QString& name) -{ - QMap::iterator it; - it = m_AttributeMatrices.find(name); - if(it == m_AttributeMatrices.end()) - { - return AttributeMatrix::NullPointer(); - } - return it.value(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -AttributeMatrix::Pointer DataContainer::getAttributeMatrix(const DataArrayPath& path) -{ - QMap::iterator it; - it = m_AttributeMatrices.find(path.getAttributeMatrixName()); - if(it == m_AttributeMatrices.end()) - { - return AttributeMatrix::NullPointer(); - } - return it.value(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AttributeMatrix::Pointer DataContainer::removeAttributeMatrix(const QString& name) { - QMap::iterator it; - it = m_AttributeMatrices.find(name); - if(it == m_AttributeMatrices.end()) + auto it = find(name); + if(it == end()) { - // DO NOT return a NullPointer for any reason other than "Attribute Matrix was not found" + // DO NOT return a NullPointer for any reason other than "AttributeMatrix was not found" return AttributeMatrix::NullPointer(); } - AttributeMatrix::Pointer p = it.value(); - m_AttributeMatrices.erase(it); + AttributeMatrix::Pointer p = (*it); + erase(it); return p; } @@ -269,32 +213,8 @@ AttributeMatrix::Pointer DataContainer::removeAttributeMatrix(const QString& nam // ----------------------------------------------------------------------------- bool DataContainer::renameAttributeMatrix(const QString& oldname, const QString& newname, bool overwrite) { - QMap::iterator it; - it = m_AttributeMatrices.find(oldname); - if(it == m_AttributeMatrices.end()) - { - return false; - } - AttributeMatrix::Pointer p = it.value(); - p->setName(newname); - removeAttributeMatrix(oldname); - - // Now check to make sure there isn't one with the same name - it = m_AttributeMatrices.find(newname); - if(it == m_AttributeMatrices.end()) // Didn't find another AttributeMatrix with the new name - { - addAttributeMatrix(newname, p); - } - else if(overwrite) // We are here because we found another attribute matrix with the new name - { - AttributeMatrix::Pointer removedAttributeMatrix = removeAttributeMatrix(newname); // Remove the existing one - addAttributeMatrix(newname, p); - } - else - { - return false; - } - return true; + auto am = getChildByName(oldname); + return am && am->setName(newname); } // ----------------------------------------------------------------------------- @@ -302,28 +222,15 @@ bool DataContainer::renameAttributeMatrix(const QString& oldname, const QString& // ----------------------------------------------------------------------------- void DataContainer::clearAttributeMatrices() { - m_AttributeMatrices.clear(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QList DataContainer::getAttributeMatrixNames() -{ - QList keys; - for(QMap::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) - { - keys.push_back(iter.key()); - } - return keys; + clear(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int DataContainer::getNumAttributeMatrices() +DataContainer::NameList DataContainer::getAttributeMatrixNames() { - return static_cast(m_AttributeMatrices.size()); + return getNamesOfChildren(); } // ----------------------------------------------------------------------------- @@ -333,31 +240,32 @@ int DataContainer::writeAttributeMatricesToHDF5(hid_t parentId) { int err; hid_t attributeMatrixId; - for(QMap::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) + for(auto iter = begin(); iter != end(); ++iter) { - AttributeMatrix::Pointer attrMat = iter.value(); + auto attrMat = (*iter); + const QString amName = attrMat->getName(); - err = QH5Utilities::createGroupsFromPath(iter.key(), parentId); + err = QH5Utilities::createGroupsFromPath(amName, parentId); if(err < 0) { return err; } - attributeMatrixId = H5Gopen(parentId, iter.key().toLatin1().data(), H5P_DEFAULT); + attributeMatrixId = H5Gopen(parentId, attrMat->getName().toLatin1().data(), H5P_DEFAULT); H5ScopedGroupSentinel gSentinel(&attributeMatrixId, false); AttributeMatrix::EnumType attrMatType = static_cast(attrMat->getType()); - err = QH5Lite::writeScalarAttribute(parentId, iter.key(), SIMPL::StringConstants::AttributeMatrixType, attrMatType); + err = QH5Lite::writeScalarAttribute(parentId, amName, SIMPL::StringConstants::AttributeMatrixType, attrMatType); if(err < 0) { return err; } - hsize_t size = (*iter)->getTupleDimensions().size(); - err = QH5Lite::writePointerAttribute(parentId, iter.key(), SIMPL::HDF5::TupleDimensions, 1, &size, (*iter)->getTupleDimensions().data()); + hsize_t size = attrMat->getTupleDimensions().size(); + err = QH5Lite::writePointerAttribute(parentId, amName, SIMPL::HDF5::TupleDimensions, 1, &size, attrMat->getTupleDimensions().data()); if(err < 0) { return err; } - err = (*iter)->writeAttributeArraysToHDF5(attributeMatrixId); + err = attrMat->writeAttributeArraysToHDF5(attributeMatrixId); if(err < 0) { return err; @@ -408,7 +316,7 @@ int DataContainer::readAttributeMatricesFromHDF5(bool preflight, hid_t dcGid, Da { amType = static_cast(amTypeTmp); AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, amName, amType); - addAttributeMatrix(amName, am); + addOrReplaceAttributeMatrix(am); } AttributeMatrixProxy amProxy = iter.value(); @@ -439,10 +347,11 @@ DataContainer::Pointer DataContainer::deepCopy(bool forceNoAllocate) dcCopy->setGeometry(geomCopy); } - for(auto & iter : getAttributeMatrices()) + const auto attrMatrices = getChildren(); + for(const auto& am : attrMatrices) { - AttributeMatrix::Pointer attrMat = iter->deepCopy(forceNoAllocate); - dcCopy->addAttributeMatrix(attrMat->getName(), attrMat); + AttributeMatrix::Pointer attrMat = am->deepCopy(forceNoAllocate); + dcCopy->addOrReplaceAttributeMatrix(attrMat); } return dcCopy; @@ -535,14 +444,12 @@ int DataContainer::writeXdmf(QTextStream& out, const QString& hdfFileName) m_Geometry->writeXdmf(out, getName(), hdfFileName); IGeometry::Type geomType = m_Geometry->getGeometryType(); - // Get all of our AttributeMatrices - AttributeMatrixMap_t amMap = getAttributeMatrices(); // Loop over each AttributeMatrix and write the meta data to the Xdmf file QString xdmfCenter = ""; - for(QMap::iterator iter = amMap.begin(); iter != amMap.end(); ++iter) + for(auto iter = begin(); iter != end(); ++iter) { xdmfCenter = ""; - AttributeMatrix::Pointer attrMat = iter.value(); + AttributeMatrix::Pointer attrMat = (*iter); AttributeMatrix::Type amType = attrMat->getType(); switch(geomType) { @@ -824,15 +731,14 @@ int DataContainer::readMeshDataFromHDF5(hid_t dcGid, bool preflight) // ----------------------------------------------------------------------------- QVector DataContainer::getAllDataArrayPaths() { - QVector paths; - for(QMap::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) + const auto attributeMatrices = getChildren(); + for(const auto& am : attributeMatrices) { - AttributeMatrix::Pointer am = iter.value(); QString amName = am->getName(); - QList aaNames = am->getAttributeArrayNames(); + NameList aaNames = am->getAttributeArrayNames(); - foreach(QString aaName, aaNames) + for(QString aaName : aaNames) { DataArrayPath dap(getName(), amName, aaName); paths.push_back(dap); @@ -849,29 +755,38 @@ QString DataContainer::getInfoString(SIMPL::InfoStringFormat format) { QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + + QString bgColor = ""; + + switch(format) + { + case SIMPL::ToolTipFormat: + bgColor = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: { ss << "\n"; ss << "\n"; ss << "\n"; ss << "\n"; - ss << ""; + ss << ""; - ss << R"("; - ss << R"("; + ss << ""; + ss << ""; ss << ""; if(getGeometry().get() != nullptr) { - ss << getGeometry()->getInfoString(SIMPL::HtmlFormat); + ss << getGeometry()->getInfoString(SIMPL::ToolTipFormat); } ss << "
Data Container Info
Data Container Info
Name:)" << getName() << "
Attribute Matrix Count:)" << getNumAttributeMatrices() << "
Name:" << getName() << "
Attribute Matrix Count:" << getNumAttributeMatrices() << "
\n"; ss << ""; + break; } - else - { - ss << "Requested InfoStringFormat is not supported. " << format; + default: + ss << "Requested DataContainer information string format is not supported. " << format; + break; } + return info; } @@ -889,9 +804,8 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil { if(filter != nullptr) { - filter->setErrorCondition(err * 1000); ss = QObject::tr("DataContainer:'%1' The name of the AttributeMatrix was empty. Please provide a name for this AttributeMatrix").arg(getName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err * 1000, ss); } return attributeMatrix; } @@ -901,9 +815,8 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil { if(filter != nullptr) { - filter->setErrorCondition(err * 1020); ss = QObject::tr("DataContainer:'%1' An AttributeMatrix with name '%2' does not exist and is required for this filter to execute.").arg(getName()).arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err * 1020, ss); } return attributeMatrix; } @@ -911,9 +824,8 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil { if(filter != nullptr) { - filter->setErrorCondition(err * 1030); ss = QObject::tr("DataContainer:'%1' AttributeMatrix: '%2' Attribute Matrix has Attribute Arrays with mismatched number of objects.").arg(getName()).arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err * 1030, ss); } return attributeMatrix; } @@ -923,63 +835,72 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const QVector& tDims, AttributeMatrix::Type amType) +AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const QVector& tDims, AttributeMatrix::Type amType, RenameDataPath::DataID_t id) { - return createNonPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), tDims, amType); + return createNonPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), tDims, amType, id); } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const QVector &tDims, AttributeMatrix::Type amType) +AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const SizeVec3Type& tDims, AttributeMatrix::Type amType, + RenameDataPath::DataID_t id) { - AttributeMatrixShPtr attributeMatrix(nullptr); + QVector tupleDims; + for(const auto& value : tDims) + { + tupleDims.push_back(value); + } + return createNonPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), tupleDims, amType, id); +} +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const QVector &tDims, AttributeMatrix::Type amType, RenameDataPath::DataID_t id) +{ QString ss; if(attributeMatrixName.isEmpty()) { if(filter != nullptr) { - filter->setErrorCondition(-10011); ss = QObject::tr("The name of the Attribute Matrix was empty. Please provide a name for this Attribute Matrix."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10011, ss); } - return attributeMatrix; + return nullptr; } if(attributeMatrixName.contains('/')) { if(filter != nullptr) { - filter->setErrorCondition(-10012); ss = QObject::tr("The AttributeMatrix '%1' has forward slashes in its name").arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10012, ss); } - return attributeMatrix; + return nullptr; } if(attributeMatrixName.compare(SIMPL::Geometry::Geometry) == 0) { if(filter != nullptr) { - filter->setErrorCondition(-10013); ss = QObject::tr("%1 is a protected name. Please provide a different name for this Attribute Matrix.").arg(SIMPL::Geometry::Geometry); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10013, ss); } - return attributeMatrix; + return nullptr; } - attributeMatrix = getAttributeMatrix(attributeMatrixName); + AttributeMatrixShPtr attributeMatrix = getAttributeMatrix(attributeMatrixName); if(nullptr == attributeMatrix.get()) { attributeMatrix = createAndAddAttributeMatrix(tDims, attributeMatrixName, amType); + // Check if path was renamed + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(getName(), attributeMatrixName, "")); return attributeMatrix; } if(filter != nullptr) // If the filter object is NOT null (is valid) then set the error condition and send an error message { - filter->setErrorCondition(-10014); ss = QObject::tr("An Attribute Matrix already exists with the name %1.").arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10014, ss); } return attributeMatrix; } diff --git a/Source/SIMPLib/DataContainers/DataContainer.h b/Source/SIMPLib/DataContainers/DataContainer.h index bafc1fd8b9..5125cab554 100755 --- a/Source/SIMPLib/DataContainers/DataContainer.h +++ b/Source/SIMPLib/DataContainers/DataContainer.h @@ -42,8 +42,11 @@ #include #include "SIMPLib/Common/Observable.h" +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/IDataStructureContainerNode.hpp" +#include "SIMPLib/DataContainers/RenameDataPath.h" #include "SIMPLib/Geometry/IGeometry.h" #include "SIMPLib/SIMPLib.h" @@ -60,19 +63,21 @@ using AttributeMatrixShPtr = std::shared_ptr; /** * @brief The DataContainer class */ -class SIMPLib_EXPORT DataContainer : public Observable +class SIMPLib_EXPORT DataContainer : public Observable, public IDataStructureContainerNode { // This line MUST be first when exposing a class and properties to Python // clang-format off PYB11_CREATE_BINDINGS(DataContainer) - PYB11_STATIC_CREATION(New ARGS QString) + PYB11_STATIC_CREATION(New OVERLOAD QString) + PYB11_STATIC_CREATION(New OVERLOAD DataArrayPath) PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_PROPERTY(IGeometry Geometry READ getGeometry WRITE setGeometry) PYB11_METHOD(QString getInfoString ARGS InfoStringFormat) - PYB11_METHOD(void addAttributeMatrix ARGS Name AttributeMatrix) + PYB11_METHOD(bool addOrReplaceAttributeMatrix ARGS AttributeMatrix) + PYB11_METHOD(bool insertOrAssign ARGS AttributeMatrix) PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix OVERLOAD const.QString.&,Name) PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix OVERLOAD const.DataArrayPath.&,Path) @@ -108,10 +113,12 @@ class SIMPLib_EXPORT DataContainer : public Observable using Types = QVector; + using Container_t = std::vector; + /** * @brief AttributeMatrixMap_t */ - using AttributeMatrixMap_t = QMap; + //using AttributeMatrixMap_t = QMap; /** * @brief Creates a new shared pointer instance of this class @@ -120,6 +127,13 @@ class SIMPLib_EXPORT DataContainer : public Observable */ static Pointer New(const QString& name); + /** + * @brief Creates a new shared pointer instance of this class + * @param name The name to give to the DataContainer and must NOT be empty. + * @return Shared Pointer to a DataContainer instance. + */ + static Pointer New(const DataArrayPath& name); + /** * @brief Creates a new data container */ @@ -134,14 +148,10 @@ class SIMPLib_EXPORT DataContainer : public Observable static void ReadDataContainerStructure(hid_t dcArrayGroupId, DataContainerArrayProxy& proxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath); /** - * @brief Sets the name of the data container - */ - virtual void setName(const QString& name); - - /** - * @brief Gets the name of the data container + * @brief Creates and returns a DataArrayPath for the DataContainer + * @return */ - virtual QString getName(); + DataArrayPath getDataArrayPath() const override; /** * @brief Sets the geometry of the data container @@ -161,37 +171,49 @@ class SIMPLib_EXPORT DataContainer : public Observable virtual QString getInfoString(SIMPL::InfoStringFormat format); /** - * @brief Adds/overwrites the data for a named array - * @param name The name that the array will be known by - * @param data The IDataArray::Pointer that will hold the data + * @brief Adds the data for a named array. If an AttributeMatrix with the same + * name already exists in the DataContainer then the add will fail. + * @param matrix The IDataArray::Pointer that will hold the data + * @return Bool TRUE if the addition was successful, FALSE Otherwise. */ - virtual void addAttributeMatrix(const QString& name, const AttributeMatrixShPtr& matrix); - + bool addOrReplaceAttributeMatrix(const AttributeMatrixShPtr& matrix) + { + return insertOrAssign(matrix); + } + /** * @brief Returns the array for a given named array or the equivelant to a * null pointer if the name does not exist. * @param name The name of the data array */ - virtual AttributeMatrixShPtr getAttributeMatrix(const QString& name); + AttributeMatrixShPtr getAttributeMatrix(const QString& name) + { + return getChildByName(name); + } /** * @brief Returns the array for a given named array or the equivelant to a * null pointer if the name does not exist. * @param name The Name of the AttributeMatrix will be extracted from the DataArratPath object */ - virtual AttributeMatrixShPtr getAttributeMatrix(const DataArrayPath& path); - - /** - * @brief getAttributeMatrices - * @return - */ - AttributeMatrixMap_t& getAttributeMatrices(); + AttributeMatrixShPtr getAttributeMatrix(const DataArrayPath& path) + { + // Could this be sped-up if we hashed DataArrayPath as well? + if(path.getDataContainerName() != getName()) + { + return nullptr; + } + return getChildByName(path.getAttributeMatrixName()); + } /** * @brief Returns bool of whether a named array exists * @param name The name of the data array */ - virtual bool doesAttributeMatrixExist(const QString& name); + bool doesAttributeMatrixExist(const QString& name) + { + return contains(name); + } /** * @brief Removes the named data array from the Data Container and returns it to the calling @@ -212,18 +234,26 @@ class SIMPLib_EXPORT DataContainer : public Observable */ virtual void clearAttributeMatrices(); + Container_t getAttributeMatrices() + { + return getChildren(); + } + /** * @brief Returns a list that contains the names of all the arrays currently stored in the * Cell (Formerly Cell) group * @return */ - virtual QList getAttributeMatrixNames(); + virtual NameList getAttributeMatrixNames(); /** * @brief Returns the total number of arrays that are stored in the Cell group * @return */ - virtual int getNumAttributeMatrices(); + int getNumAttributeMatrices() + { + return static_cast(size()); + } /** * @brief getAllDataArrayPaths @@ -253,7 +283,18 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param amType The Type of AttributeMatrix * @return A Shared Pointer to the AttributeMatrix */ - AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const QVector& tDims, AttributeMatrix::Type amType); + AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const QVector& tDims, AttributeMatrix::Type amType, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); + + /** + * @brief createNonPrereqAttributeMatrix + * @param filter + * @param path + * @param tDims + * @param amType + * @param id + * @return + */ + AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const SizeVec3Type& tDims, AttributeMatrix::Type amType, RenameDataPath::DataID_t id); /** * @brief createNonPrereqAttributeMatrix This method will create a new AttributeMatrix with the given tuple dimensions @@ -265,7 +306,7 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param amType The Type of AttributeMatrix * @return A Shared Pointer to the AttributeMatrix */ - AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const QVector& tDims, AttributeMatrix::Type amType); + AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const QVector& tDims, AttributeMatrix::Type amType, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); /** * @brief Returns the geometry as the templated type @@ -290,9 +331,8 @@ class SIMPLib_EXPORT DataContainer : public Observable { if(filter) { - filter->setErrorCondition(-385); QString ss = QObject::tr("Data Container Geometry is missing."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-385, ss); } return geom; } @@ -301,9 +341,8 @@ class SIMPLib_EXPORT DataContainer : public Observable { if(filter) { - filter->setErrorCondition(-384); QString ss = QObject::tr("Data Container Geometry is not compatible. The selected Geometry type is %1").arg(igeom->getGeometryTypeAsString()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-384, ss); } return geom; } @@ -369,7 +408,5 @@ class SIMPLib_EXPORT DataContainer : public Observable explicit DataContainer(const QString& name); private: - AttributeMatrixMap_t m_AttributeMatrices; IGeometry::Pointer m_Geometry; - QString m_Name; }; diff --git a/Source/SIMPLib/DataContainers/DataContainerArray.cpp b/Source/SIMPLib/DataContainers/DataContainerArray.cpp index 30293b1e2c..c9461d359c 100644 --- a/Source/SIMPLib/DataContainers/DataContainerArray.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerArray.cpp @@ -50,9 +50,9 @@ DataContainerArray::~DataContainerArray() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArray::addDataContainer(DataContainer::Pointer f) +DataArrayPath DataContainerArray::getDataArrayPath() const { - m_Array.push_back(f); + return DataArrayPath(); } // ----------------------------------------------------------------------------- @@ -60,7 +60,7 @@ void DataContainerArray::addDataContainer(DataContainer::Pointer f) // ----------------------------------------------------------------------------- int DataContainerArray::getNumDataContainers() { - return m_Array.size(); + return static_cast(size()); } // ----------------------------------------------------------------------------- @@ -68,7 +68,7 @@ int DataContainerArray::getNumDataContainers() // ----------------------------------------------------------------------------- void DataContainerArray::clearDataContainers() { - m_Array.clear(); + clear(); } #if 0 @@ -122,19 +122,15 @@ bool DataContainerArray::empty() DataContainer::Pointer DataContainerArray::removeDataContainer(const QString& name) { removeDataContainerFromBundles(name); - DataContainer::Pointer f = DataContainer::NullPointer(); - for(QList::iterator it = m_Array.begin(); it != m_Array.end(); ++it) + auto it = find(name); + if(it == end()) { - if((*it)->getName().compare(name) == 0) - { - f = *it; - m_Array.erase(it); - return f; - } + // DO NOT return a NullPointer for any reason other than "DataContainer was not found" + return DataContainer::NullPointer(); } - - // DO NOT return a NullPointer for any reason other than "DataContainer was not found" - return f; + DataContainer::Pointer p = (*it); + erase(it); + return p; } // ----------------------------------------------------------------------------- @@ -142,41 +138,17 @@ DataContainer::Pointer DataContainerArray::removeDataContainer(const QString& na // ----------------------------------------------------------------------------- bool DataContainerArray::renameDataContainer(const QString& oldName, const QString& newName) { - DataContainer::Pointer dc = DataContainer::NullPointer(); - - // Make sure we do not already have a DataContainer with the newname - for(const auto& iter : m_Array) - { - if(iter->getName().compare(newName) == 0) - { - dc = iter; - break; - } - } - - if(nullptr == dc) - { - // We did not find any data container that matches the new name so we can rename if we find one that matches - // the 'oldname' argument - // Now find the data container we want to rename - for(const auto& iter : m_Array) - { - if(iter->getName() == oldName) - { - // we have an existing DataContainer that matches our "oldname" that we want to rename so all is good. - dc = iter; - dc->setName(newName); - return true; - } - } - } - else if(nullptr != dc) - { - // We found an existing Data Container with the 'newname' but we do NOT want to over write it so just bail out now - return false; - } + DataContainer::Pointer dc = getChildByName(oldName); + return dc && dc->setName(newName); +} - return false; // default (but we should just NEVER make it here) +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataContainerArray::renameDataContainer(const DataArrayPath& oldName, const DataArrayPath& newName) +{ + DataContainer::Pointer dc = getChildByName(oldName.getDataContainerName()); + return dc && dc->setName(newName.getDataContainerName()); } // ----------------------------------------------------------------------------- @@ -184,17 +156,7 @@ bool DataContainerArray::renameDataContainer(const QString& oldName, const QStri // ----------------------------------------------------------------------------- DataContainer::Pointer DataContainerArray::getDataContainer(const QString& name) { - DataContainer::Pointer f = DataContainer::NullPointer(); - for(const auto& dc : m_Array) - { - if(dc->getName().compare(name) == 0) - { - f = dc; - break; - } - } - - return f; + return getChildByName(name); } // ----------------------------------------------------------------------------- @@ -225,16 +187,7 @@ AttributeMatrix::Pointer DataContainerArray::getAttributeMatrix(const DataArrayP // ----------------------------------------------------------------------------- void DataContainerArray::duplicateDataContainer(const QString& name, const QString& newName) { - DataContainer::Pointer f = DataContainer::NullPointer(); - for(const auto& dc : m_Array) - { - if(dc->getName().compare(name) == 0) - { - f = dc; - break; - } - } - + DataContainer::Pointer f = getDataContainer(name); if(f == nullptr) { return; @@ -242,28 +195,23 @@ void DataContainerArray::duplicateDataContainer(const QString& name, const QStri DataContainer::Pointer new_f = f->deepCopy(false); new_f->setName(newName); - addDataContainer(new_f); + addOrReplaceDataContainer(new_f); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QList DataContainerArray::getDataContainerNames() +DataContainerArray::NameList DataContainerArray::getDataContainerNames() { - QList names; - for(const auto& dc : m_Array) - { - names.push_back(dc->getName()); - } - return names; + return getNamesOfChildren(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QList& DataContainerArray::getDataContainers() +DataContainerArray::Container DataContainerArray::getDataContainers() { - return m_Array; + return getChildren(); } // ----------------------------------------------------------------------------- @@ -272,7 +220,8 @@ QList& DataContainerArray::getDataContainers() void DataContainerArray::printDataContainerNames(QTextStream& out) { out << "---------------------------------------------------------------------"; - for(const auto& dc : m_Array) + Container dcArray = getDataContainers(); + for(DataContainer::Pointer dc : dcArray) { out << dc->getNameOfClass(); } @@ -301,12 +250,12 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, QString ss = QObject::tr("A Data Container with name %1 already exists in Memory. Reading a Data Container with the same name would over write the one in memory. Currently this is not allowed.") .arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745600); + obs->setErrorCondition(-198745600, ss); } return -198745600; } DataContainer::Pointer dc = DataContainer::New(dcProxy.getName()); - this->addDataContainer(dc); + this->addOrReplaceDataContainer(dc); // Now open the DataContainer Group in the HDF5 file hid_t dcGid = H5Gopen(dcaGid, dcProxy.getName().toLatin1().data(), H5P_DEFAULT); @@ -315,7 +264,7 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, if(nullptr != obs) { QString ss = QObject::tr("Error opening Group '%1'").arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745602); + obs->setErrorCondition(-198745602, ss); } return -198745602; } @@ -326,7 +275,7 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, if(nullptr != obs) { QString ss = QObject::tr("Error reading Mesh Data from '%1'").arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745603); + obs->setErrorCondition(-198745603, ss); } return -198745603; } @@ -336,7 +285,7 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, if(nullptr != obs) { QString ss = QObject::tr("Error reading AttributeMatrix Data from '%1'").arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745604); + obs->setErrorCondition(-198745604, ss); } return -198745604; } @@ -347,16 +296,17 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataContainerArray::doesDataContainerExist(const QString& name) +bool DataContainerArray::doesDataContainerExist(const DataArrayPath& dap) const { - for(const auto& dc : m_Array) - { - if(dc->getName() == name) - { - return true; - } - } - return false; + return contains(dap.getDataContainerName()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataContainerArray::doesDataContainerExist(const QString& name) const +{ + return contains(name); } // ----------------------------------------------------------------------------- @@ -415,7 +365,7 @@ IDataContainerBundle::Pointer DataContainerArray::getDataContainerBundle(const Q IDataContainerBundle::Pointer f = IDataContainerBundle::NullPointer(); for(QMap::iterator it = m_DataContainerBundles.begin(); it != m_DataContainerBundles.end(); ++it) { - if((*it)->getName().compare(name) == 0) + if((*it)->getName() == name) { f = *it; break; @@ -480,9 +430,9 @@ bool DataContainerArray::renameDataContainerBundle(const QString& oldName, const return false; } - m_DataContainerBundles.insert(newName, iter.value()); - iter.value()->setName(newName); - m_DataContainerBundles.remove(oldName); + m_DataContainerBundles.insert(newName, iter.value()); + iter.value()->setName(newName); + m_DataContainerBundles.remove(oldName); } return false; } @@ -493,40 +443,13 @@ bool DataContainerArray::renameDataContainerBundle(const QString& oldName, const DataContainerArray::Pointer DataContainerArray::deepCopy(bool forceNoAllocate) { DataContainerArray::Pointer dcaCopy = DataContainerArray::New(); - QList dcs = getDataContainers(); - for(int i = 0; i < dcs.size(); i++) + const Container dcs = getDataContainers(); + for(const auto& dc : dcs) { - DataContainer::Pointer dcCopy = dcs[i]->deepCopy(forceNoAllocate); -#if 0 - - // Deep copy geometry if applicable - if(nullptr != dcs[i]->getGeometry().get()) - { - dcCopy->setGeometry(dcs[i]->getGeometry()->deepCopy()); - } - - // Add AttributeMatrix copies - QMap ams = dcs[i]->getAttributeMatrices(); - for(QMap::Iterator iter = ams.begin(); iter != ams.end(); iter++) - { - QVector dims = (*iter)->getTupleDimensions(); - AttributeMatrix::Pointer amCopy = AttributeMatrix::New(dims, (*iter)->getName(), (*iter)->getType()); - - // Add DataArray copies without allocating memory - QList daNames = (*iter)->getAttributeArrayNames(); - for(int i = 0; i < daNames.size(); i++) - { - // Copy and add DataArray to AttributeMatrix copy without allocating memory - IDataArray::Pointer daCopy = (*iter)->getAttributeArray(daNames[i])->deepCopy(true); - amCopy->addAttributeArray(daNames[i], daCopy); - } + DataContainer::Pointer dcCopy = dc->deepCopy(forceNoAllocate); - // End add AttributeMatrix - dcCopy->addAttributeMatrix(amCopy->getName(), amCopy); - } -#endif // End add DataContainer - dcaCopy->addDataContainer(dcCopy); + dcaCopy->push_back(dcCopy); } return dcaCopy; diff --git a/Source/SIMPLib/DataContainers/DataContainerArray.h b/Source/SIMPLib/DataContainers/DataContainerArray.h index e3554dc618..8b751b3737 100755 --- a/Source/SIMPLib/DataContainers/DataContainerArray.h +++ b/Source/SIMPLib/DataContainers/DataContainerArray.h @@ -46,6 +46,8 @@ #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/IDataContainerBundle.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/IDataStructureContainerNode.hpp" +#include "SIMPLib/DataContainers/RenameDataPath.h" class DataContainer; @@ -60,26 +62,30 @@ using DataContainerShPtr = std::shared_ptr; * @date Sep 28, 2011 * @version 1.0 */ -class SIMPLib_EXPORT DataContainerArray : public QObject +class SIMPLib_EXPORT DataContainerArray : public QObject, public IDataStructureContainerNode { Q_OBJECT // clang-format off PYB11_CREATE_BINDINGS(DataContainerArray) - PYB11_METHOD(void addDataContainer ARGS data_container) - //PYB11_METHOD(DataContainer::Pointer getDataContainer ARGS name) - PYB11_METHOD(bool doesDataContainerExist ARGS name) - PYB11_METHOD(DataContainer::Pointer removeDataContainer ARGS name) - PYB11_METHOD(bool renameDataContainer ARGS oldName newName) + PYB11_METHOD(bool addOrReplaceDataContainer ARGS DataContainer) + PYB11_METHOD(bool insertOrAssign ARGS DataContainer) + PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.QString.&,Name CONST_METHOD) + PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) + + PYB11_METHOD(DataContainer::Pointer removeDataContainer ARGS Name) + PYB11_METHOD(bool renameDataContainer OVERLOAD const.QString.&,OldName const.QString.&,NewName) + PYB11_METHOD(bool renameDataContainer OVERLOAD const.DataArrayPath.&,OldPath const.DataArrayPath.&,NewPath ) + PYB11_METHOD(void clearDataContainers) //PYB11_METHOD(XXXX getDataContainerNames) PYB11_METHOD(int getNumDataContainers) - PYB11_METHOD(void duplicateDataContainer ARGS oldName, newName) + PYB11_METHOD(void duplicateDataContainer ARGS OldName, NewName) - PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix ARGS dataArrayPath) - PYB11_METHOD(bool doesAttributeMatrixExist ARGS dataArrayPath) + PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix ARGS DataArrayPath) + PYB11_METHOD(bool doesAttributeMatrixExist ARGS DataArrayPath) - PYB11_METHOD(bool doesAttributeArrayExist ARGS dataArrayPath) + PYB11_METHOD(bool doesAttributeArrayExist ARGS DataArrayPath) // clang-format on public: @@ -87,12 +93,23 @@ class SIMPLib_EXPORT DataContainerArray : public QObject SIMPL_STATIC_NEW_MACRO(DataContainerArray) SIMPL_TYPE_MACRO(DataContainerArray) + using Container = ChildCollection; + ~DataContainerArray() override; + /** + * @brief Creates and returns an empty DataArrayPath + * @return + */ + DataArrayPath getDataArrayPath() const override; + /** * @brief */ - virtual void addDataContainer(DataContainerShPtr f); + bool addOrReplaceDataContainer(const DataContainerShPtr& f) + { + return insertOrAssign(f); + } /** * @brief getDataContainer @@ -112,14 +129,21 @@ class SIMPLib_EXPORT DataContainerArray : public QObject * @brief getDataContainers * @return */ - QList& getDataContainers(); + Container getDataContainers(); /** * @brief Returns if a DataContainer with the give name is in the array * @param name The name of the DataContiner to find * @return */ - virtual bool doesDataContainerExist(const QString& name); + virtual bool doesDataContainerExist(const QString& name) const; + + /** + * @brief doesDataContainerExist + * @param dap + * @return + */ + virtual bool doesDataContainerExist(const DataArrayPath& dap) const; /** * @brief DataContainerArray::doesAttributeMatrixExist @@ -148,6 +172,14 @@ class SIMPLib_EXPORT DataContainerArray : public QObject */ bool renameDataContainer(const QString& oldName, const QString& newName); + /** + * @brief renameDataContainer + * @param oldName + * @param newName + * @return + */ + bool renameDataContainer(const DataArrayPath& oldName, const DataArrayPath& newName); + /** * @brief Removes all DataContainers from this DataContainerArray */ @@ -157,7 +189,7 @@ class SIMPLib_EXPORT DataContainerArray : public QObject * @brief getDataContainerNames * @return */ - QList getDataContainerNames(); + NameList getDataContainerNames(); /** * @brief Returns the number of DataContainers @@ -253,6 +285,11 @@ class SIMPLib_EXPORT DataContainerArray : public QObject */ void renameDataArrayPaths(DataArrayPath::RenameContainer renamePaths); + template DataContainerShPtr getPrereqDataContainer(Filter* filter, const DataArrayPath& dap, bool createIfNotExists = false) + { + return getPrereqDataContainer(filter, dap.getDataContainerName(), createIfNotExists); + } + /** * @brief getPrereqDataContainer * @param name @@ -267,9 +304,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (filter) { - filter->setErrorCondition(-999); QString ss = "The DataContainer Object with the specific name '" + name + "' was not available."; - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-999, ss); } return dc; } @@ -277,13 +313,25 @@ class SIMPLib_EXPORT DataContainerArray : public QObject if(nullptr != dc && createIfNotExists) { DataContainerShPtr dataContainer = DataContainer::New(name); // Create a new Data Container - addDataContainer(dataContainer); // Put the new DataContainer into the array + addOrReplaceDataContainer(dataContainer); // Put the new DataContainer into the array return dataContainer; // Return the wrapped pointer } // The DataContainer we asked for was present and NON Null so return that. return dc; } + /** + * @brief createNonPrereqDataContainer + * @param filter + * @param dap + * @param id + * @return + */ + template DataContainerShPtr createNonPrereqDataContainer(Filter* filter, const DataArrayPath& dap, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) + { + return createNonPrereqDataContainer(filter, dap.getDataContainerName(), id); + } + /** * @brief This function will create a new DataContainer of type * @param dataContainerName The name of the DataContainer. Must not be empty or this method will ASSERT() @@ -291,15 +339,14 @@ class SIMPLib_EXPORT DataContainerArray : public QObject * dataContainerName is empty in which case a Null DataContainer will be returned. */ template - DataContainerShPtr createNonPrereqDataContainer(Filter* filter, const QString& dataContainerName) + DataContainerShPtr createNonPrereqDataContainer(Filter* filter, const QString& dataContainerName, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) { if(dataContainerName.isEmpty()) { if (filter) { - filter->setErrorCondition(-887); QString ss = QObject::tr("The DataContainer Object must have a name to be created."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-887, ss); return DataContainer::NullPointer(); } } @@ -308,25 +355,26 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (filter) { - filter->setErrorCondition(-888); QString ss = QObject::tr("The DataContainer Object has forward slashes in its name."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-888, ss); return DataContainer::NullPointer(); } } - if(doesDataContainerExist(dataContainerName)) + + DataContainerShPtr dataContainer = DataContainer::New(dataContainerName); + bool dcExists = !push_back(dataContainer); + if(dcExists) { - if (filter) + if(filter) { - filter->setErrorCondition(-889); QString ss = QObject::tr("The DataContainer Object with the specific name '%1' already exists.").arg(dataContainerName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-889, ss); return DataContainer::NullPointer(); } } - DataContainerShPtr dataContainer = DataContainer::New(dataContainerName); - addDataContainer(dataContainer); + + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(dataContainerName, "", "")); return dataContainer; } @@ -348,6 +396,24 @@ class SIMPLib_EXPORT DataContainerArray : public QObject return dc->getPrereqGeometry(filter); } + /** + * @brief getPrereqGeometryFromDataContainer Returns an IGeometry object of the templated type + * if it is available for the given DataContainer + * @param filter + * @param path + * @return + */ + template typename GeometryType::Pointer getPrereqGeometryFromDataContainer(Filter* filter, const DataArrayPath& path) + { + typename GeometryType::Pointer geom = GeometryType::NullPointer(); + DataContainerShPtr dc = getPrereqDataContainer(filter, path.getDataContainerName(), false); + if(nullptr == dc) + { + return geom; + } + + return dc->getPrereqGeometry(filter); + } /** * @brief getPrereqAttributeMatrixFromPath This function will return an AttributeMatrix if it is availabe @@ -388,9 +454,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80000); ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80000, ss); } return dataArray; } @@ -399,9 +464,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80001); ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(path.serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80001, ss); } return dataArray; } @@ -416,9 +480,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80002); ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80002, ss); } return dataArray; } @@ -428,9 +491,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80003); ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80003, ss); } return dataArray; } @@ -456,9 +518,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-90000); ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-90000, ss); } return dataArray; } @@ -467,9 +528,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-90001); ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(path.serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-90001, ss); } return dataArray; } @@ -484,9 +544,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-999); ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-999, ss); } return dataArray; } @@ -496,9 +555,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-307020); ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-307020, ss); } return dataArray; } @@ -523,7 +581,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject const DataArrayPath& path, T initValue, QVector compDims, - const QString& property = "") + const QString& property = "", + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) { typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); QString ss; @@ -531,9 +590,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80010); ss = QObject::tr("Property '%1': The DataArrayPath is invalid because one of the elements was empty.\n DataContainer: %2\n AttributeMatrix: %3\n DataArray: %4").arg(property).arg(path.getDataContainerName()).arg(path.getAttributeMatrixName()).arg(path.getDataArrayName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80010, ss); } return dataArray; } @@ -542,9 +600,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (filter) { - filter->setErrorCondition(-80005); ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80005, ss); } return dataArray; } @@ -553,9 +610,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (filter) { - filter->setErrorCondition(-80006); ss = QObject::tr("The AttributeMatrix '%1' has forward slashes in its name").arg(path.getAttributeMatrixName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80006, ss); } return dataArray; } @@ -564,9 +620,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (filter) { - filter->setErrorCondition(-80007); ss = QObject::tr("The DataArray '%1' has forward slashes in its name").arg(path.getDataArrayName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80007, ss); } return dataArray; } @@ -575,9 +630,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (filter) { - filter->setErrorCondition(-80004); ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80004, ss); } return dataArray; } @@ -587,9 +641,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80002); ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80002, ss); } return dataArray; } @@ -599,16 +652,15 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if(filter) { - filter->setErrorCondition(-80003); ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(path.getAttributeMatrixName()).arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-80003, ss); } return dataArray; } // If something goes wrong at this point the error message will be directly set in the 'filter' object so we just // simply return what ever is given to us. - dataArray = attrMat->createNonPrereqArray(filter, path.getDataArrayName(), initValue, compDims); + dataArray = attrMat->createNonPrereqArray(filter, path.getDataArrayName(), initValue, compDims, id); return dataArray; } @@ -630,18 +682,16 @@ class SIMPLib_EXPORT DataContainerArray : public QObject QString ss; if (!paths.at(0).isValid() && nullptr != filter) { - filter->setErrorCondition(-10000); ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(paths.at(0).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10000, ss); valid = false; return valid; } IDataArray::Pointer array0 = getPrereqIDataArrayFromPath(filter, paths.at(0)); if (nullptr == array0.get() && nullptr != filter) { - filter->setErrorCondition(-10100); ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(0).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10100, ss); valid = false; return valid; } @@ -651,18 +701,16 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (!paths.at(i).isValid() && nullptr != filter) { - filter->setErrorCondition(-10000); ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(paths.at(i).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10000, ss); valid = false; return valid; } IDataArray::Pointer nextArray = getPrereqIDataArrayFromPath(filter, paths.at(i)); if (nullptr == nextArray.get() && nullptr != filter) { - filter->setErrorCondition(-10100); ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(i).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10100, ss); valid = false; return valid; } @@ -674,10 +722,9 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) { - filter->setErrorCondition(-10200); ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") .arg(dataArrays[0]->getName()).arg(dataArrays[0]->getNumberOfTuples()).arg(dataArrays[i]->getName()).arg(dataArrays[i]->getNumberOfTuples()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10200, ss); valid = false; } } @@ -703,9 +750,8 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (nullptr == dataArray && nullptr != filter) { - filter->setErrorCondition(-10100); ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available").arg(__LINE__); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10100, ss); valid = false; } } @@ -714,10 +760,9 @@ class SIMPLib_EXPORT DataContainerArray : public QObject { if (numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) { - filter->setErrorCondition(-10200); ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") .arg(dataArrays[i - 1]->getName()).arg(dataArrays[i - 1]->getNumberOfTuples()).arg(dataArrays[i]->getName()).arg(dataArrays[i]->getNumberOfTuples()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10200, ss); valid = false; } } @@ -735,7 +780,6 @@ class SIMPLib_EXPORT DataContainerArray : public QObject DataContainerArray(); private: - QList m_Array; QMap m_DataContainerBundles; public: diff --git a/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp b/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp index 0af84df38b..25cccfaf55 100644 --- a/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp @@ -69,10 +69,10 @@ DataContainerArrayProxy::DataContainerArrayProxy(DataContainerArray* dca) return; } - QList containers = dca->getDataContainers(); - for(const auto& container : containers) + DataContainerArray::Container containers = dca->getDataContainers(); + for(DataContainer::Pointer dataContainer : containers) // Loop on each Data Container { - IGeometry::Pointer geo = container->getGeometry(); + IGeometry::Pointer geo = dataContainer->getGeometry(); IGeometry::Type dcType; if(geo != IGeometry::NullPointer()) { @@ -82,25 +82,21 @@ DataContainerArrayProxy::DataContainerArrayProxy(DataContainerArray* dca) { dcType = IGeometry::Type::Unknown; } - DataContainerProxy dcProxy(container->getName(), Qt::Checked, dcType); // Create a new DataContainerProxy + DataContainerProxy dcProxy(dataContainer->getName(), Qt::Checked, dcType); // Create a new DataContainerProxy // Now loop over each AttributeMatrix in the data container that was selected - DataContainer::AttributeMatrixMap_t attrMats = container->getAttributeMatrices(); - QMapIterator iter(attrMats); - while(iter.hasNext()) + DataContainer::Container_t attrMats = dataContainer->getAttributeMatrices(); + for(auto iter = attrMats.begin(); iter != attrMats.end(); ++iter) { - iter.next(); - QString amName = iter.key(); - AttributeMatrix::Pointer attrMat = iter.value(); + AttributeMatrix::Pointer attrMat = *iter; + QString amName = attrMat->getName(); AttributeMatrixProxy amProxy(amName, Qt::Checked, attrMat->getType()); - QList attrArrayNames = attrMat->getAttributeArrayNames(); - QListIterator attrArrayNamesIter(attrArrayNames); - while(attrArrayNamesIter.hasNext()) + for(IDataArray::Pointer attrArray : attrMat->getAttributeArrays()) { - QString aaName = attrArrayNamesIter.next(); - QString daPath = container->getName() + "/" + amName + "/"; - IDataArray::Pointer attrArray = attrMat->getAttributeArray(aaName); + QString aaName = attrArray->getName(); + QString daPath = dataContainer->getName() + "/" + amName + "/"; + DataArrayProxy daProxy(daPath, aaName, Qt::Checked, attrArray->getTypeAsString(), attrArray->getClassVersion()); daProxy.setCompDims(attrArray->getComponentDimensions()); daProxy.setTupleDims(attrMat->getTupleDimensions()); diff --git a/Source/SIMPLib/DataContainers/DataContainerBundle.cpp b/Source/SIMPLib/DataContainers/DataContainerBundle.cpp index b30b0715b4..d850ceca08 100644 --- a/Source/SIMPLib/DataContainers/DataContainerBundle.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerBundle.cpp @@ -86,7 +86,7 @@ QVector DataContainerBundle::getDataContainerNames() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerBundle::addDataContainer(DataContainer::Pointer dc) +void DataContainerBundle::addOrReplaceDataContainer(DataContainer::Pointer dc) { m_DataContainers.append(dc); } diff --git a/Source/SIMPLib/DataContainers/DataContainerBundle.h b/Source/SIMPLib/DataContainers/DataContainerBundle.h index 7ee508cda5..150983a36f 100755 --- a/Source/SIMPLib/DataContainers/DataContainerBundle.h +++ b/Source/SIMPLib/DataContainers/DataContainerBundle.h @@ -99,7 +99,7 @@ class SIMPLib_EXPORT DataContainerBundle : public IDataContainerBundle * @brief addDataContainer Adds a Data Container to the bundle * @param dc */ - void addDataContainer(DataContainer::Pointer dc) override; + void addOrReplaceDataContainer(DataContainer::Pointer dc) override; /** * @brief removeDataContainer Removes a Data Container from the bundle by pointer diff --git a/Source/SIMPLib/DataContainers/DsnIterators.h b/Source/SIMPLib/DataContainers/DsnIterators.h new file mode 100644 index 0000000000..c33bf168a4 --- /dev/null +++ b/Source/SIMPLib/DataContainers/DsnIterators.h @@ -0,0 +1,471 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include + +class IDataStructureNode; + +/** + * @brief The DsnIterator is a bidirectional iterator over data structure types + * belonging to the same level. DataContainerArray iterators only iterate over + * DataContainers. DataContainer iterators only iterate over their AttributeMatrices. + * AttributeMatrix iterators only iterate over their DataArrays. + * This was made constexpr for the sake of creating faster runtime operations. + */ +class DsnIterator : public std::iterator, size_t> //std::iterator_traits> +{ + using self_type = DsnIterator; + using difference_type = size_t; + using value_type = std::shared_ptr; + using pointer = IDataStructureNode*; + using reference = value_type&; + using collection_type = std::vector; + using iterator_category = std::random_access_iterator_tag; + +public: + /** + * @brief Default constructor creates an invalid iterator + */ + DsnIterator() = default; + + /** + * @brief Creates an iterator for the given collection and index + * @param collection + * @param index + */ + DsnIterator(const collection_type& collection, size_t index) + : m_Collection(collection) + , m_Index(index) + {} + + /** + * @brief Copy iterator + * @param other + */ + DsnIterator(const self_type& other) + : m_Collection(other.m_Collection) + , m_Index(other.m_Index) + {} + + /** + * @brief Destructor + */ + ~DsnIterator() = default; + + /** + * @brief Returns the iterator's index. + * @return + */ + constexpr difference_type position() const + { + return m_Index; + } + + /** + * @brief Returns the next iterator in the collection. + * @return + */ + constexpr self_type& operator++(int) + { + m_Index++; + return *this; + } + + /** + * @brief Returns the previous iterator in the collection. + * @return + */ + constexpr self_type& operator--(int) + { + m_Index--; + return *this; + } + + /** + * @brief Proceeds n positions. + * @param n + * @return + */ + constexpr self_type& operator+(difference_type n) + { + m_Index += n; + return *this; + } + + /** + * @brief Regresses n positions. + * @param n + * @return + */ + constexpr self_type& operator-(difference_type n) + { + if(n > m_Index) + { + throw std::out_of_range("Iterator out of range"); + } + m_Index -= n; + return *this; + } + + /** + * @brief Returns the difference in position with the given iterator. + * @param other + * @return + */ + constexpr difference_type operator-(const self_type& other) + { + return m_Index - other.m_Index; + } + + /** + * @brief Returns the stored value. + * @return + */ + constexpr reference operator*() + { + return m_Collection[m_Index]; + } + + /** + * @brief Returns the stored value. + * @return + */ + constexpr pointer operator->() + { + return m_Collection[m_Index].get(); + } + + /** + * @brief Returns true if the given iterator comes later in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<(const self_type& other) const + { + return m_Index < other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes later or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<=(const self_type& other) const + { + return m_Index <= other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>(const self_type& other) const + { + return m_Index > other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>=(const self_type& other) const + { + return m_Index >= other.m_Index; + } + + /** + * @brief Returns true if other iterator points to the same index in same collection. + * @param rhs right hand side + * @return + */ + constexpr bool operator==(const self_type& rhs) const + { + return (m_Index == rhs.m_Index) && (m_Collection == rhs.m_Collection); + } + + /** + * @brief Returns true if the other iterator does not point to the same index and collection. + * @param rhs right hand side + * @return + */ + bool operator!=(const self_type& rhs) const + { + return !operator==(rhs); + } + + /** + * @brief Swaps values with the given iterator. + * @param other + */ + inline void swap(self_type& other) noexcept + { + const collection_type tempCollection = m_Collection; + m_Collection = other.m_Collection; + other.m_Collection = tempCollection; + + const difference_type tempIndex = m_Index; + m_Index = other.m_Index; + other.m_Index = tempIndex; + } + +private: + collection_type m_Collection; + difference_type m_Index; +}; + + +/** + * @brief The DsnConstIterator is a bidirectional const iterator over data structure types + * belonging to the same level. DataContainerArray iterators only iterate over + * DataContainers. DataContainer iterators only iterate over their AttributeMatrices. + * AttributeMatrix iterators only iterate over their DataArrays. + * This was made constexpr for the sake of creating faster runtime operations. + */ +class DsnConstIterator : public std::iterator, size_t> //std::iterator_traits> +{ + using self_type = DsnConstIterator; + using difference_type = size_t; + using value_type = const std::shared_ptr; + using pointer = const IDataStructureNode*; + using reference = value_type&; + using collection_type = std::vector>; + using iterator_category = std::random_access_iterator_tag; + +public: + /** + * @brief Calling the default constructor will return an invalid iterator. + */ + DsnConstIterator() = default; + + /** + * @brief Constructor for the given collection and index + * @param collection + * @param index + */ + DsnConstIterator(const collection_type& collection, size_t index) + : m_Collection(collection) + , m_Index(index) + {} + + /** + * @brief Copy constructor + * @param other + */ + DsnConstIterator(const self_type& other) + : m_Collection(other.m_Collection) + , m_Index(other.m_Index) + {} + + /** + * @brief Destructor + */ + ~DsnConstIterator() = default; + + /** + * @brief Returns the iterator's index. + * @return + */ + constexpr difference_type position() const + { + return m_Index; + } + + /** + * @brief Returns the next iterator in the collection + * @return + */ + constexpr self_type& operator++() + { + m_Index++; + return *this; + } + + /** + * @brief Returns the previous iterator in the collection + * @return + */ + constexpr self_type& operator--(int) + { + m_Index--; + return *this; + } + + /** + * @brief Proceeds n positions. + * @param n + * @return + */ + constexpr self_type& operator+(difference_type n) + { + m_Index += n; + return *this; + } + + /** + * @brief Regresses n positions + * @param n + * @return + */ + constexpr self_type& operator-(difference_type n) + { + if(n > m_Index) + { + throw std::out_of_range("Iterator out of range"); + } + m_Index -= n; + return *this; + } + + /** + * @brief Returns the difference in position with the given iterator. + * @param other + * @return + */ + constexpr difference_type operator-(const self_type& other) + { + return m_Index - other.m_Index; + } + + /** + * @brief Returns a the stored value as const. + * @return + */ + constexpr reference operator*() const + { + return m_Collection[m_Index]; + } + + /** + * @brief Returns the value as const. + * @return + */ + constexpr pointer operator->() const + { + return m_Collection[m_Index].get(); + } + + /** + * @brief Returns true if the given iterator comes later in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<(const self_type& other) const + { + return m_Index < other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes later or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<=(const self_type& other) const + { + return m_Index <= other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>(const self_type& other) const + { + return m_Index > other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>=(const self_type& other) const + { + return m_Index >= other.m_Index; + } + + /** + * @brief Returns true if the other iterator points to the same index and collection. + * Returns false otherwise. + * @param rhs right hand side + * @return + */ + constexpr bool operator==(const self_type& rhs) const + { + return (m_Index == rhs.m_Index) && (m_Collection == rhs.m_Collection); + } + + /** + * @brief Returns true if the other iterator does not point to the same index and collection. + * Returns false otherwise. + * @param rhs right hand side + * @return + */ + bool operator!=(const self_type& rhs) const + { + return !operator==(rhs); + } + + /** + * @brief Swaps values with the given iterator. + * @param other + */ + inline void swap(self_type& other) noexcept + { + const collection_type tempCollection = m_Collection; + m_Collection = other.m_Collection; + other.m_Collection = tempCollection; + + const difference_type tempIndex = m_Index; + m_Index = other.m_Index; + other.m_Index = tempIndex; + } + +private: + collection_type m_Collection; + size_t m_Index; +}; diff --git a/Source/SIMPLib/DataContainers/IDataContainerBundle.h b/Source/SIMPLib/DataContainers/IDataContainerBundle.h index 9b1673a6fd..c4f81fc845 100755 --- a/Source/SIMPLib/DataContainers/IDataContainerBundle.h +++ b/Source/SIMPLib/DataContainers/IDataContainerBundle.h @@ -58,7 +58,7 @@ class SIMPLib_EXPORT IDataContainerBundle : public QObject virtual QVector getDataContainerNames() = 0; - virtual void addDataContainer(DataContainer::Pointer dc) = 0; + virtual void addOrReplaceDataContainer(DataContainer::Pointer dc) = 0; virtual void removeDataContainer(DataContainer::Pointer dc) = 0; virtual void removeDataContainer(const QString& name) = 0; diff --git a/Source/SIMPLib/DataContainers/IDataStructureContainerNode.hpp b/Source/SIMPLib/DataContainers/IDataStructureContainerNode.hpp new file mode 100644 index 0000000000..6c81f94558 --- /dev/null +++ b/Source/SIMPLib/DataContainers/IDataStructureContainerNode.hpp @@ -0,0 +1,471 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "IDataStructureNode.h" + +template class IDataStructureContainerNode : public AbstractDataStructureContainer +{ +public: + SIMPL_SHARED_POINTERS(IDataStructureContainerNode) + + using ChildShPtr = std::shared_ptr; + using ChildCollection = std::vector; + using iterator = typename ChildCollection::iterator; + using const_iterator = typename ChildCollection::const_iterator; + using NameList = QList; + +private: + ChildCollection m_ChildrenNodes; + +protected: + + + // void setParent(const ParentType& parent) override + //{ + // // Remove from parent's children + // Pointer tempPtr; + // Pointer parentPtr = m_Parent.lock(); + // if(nullptr != parentPtr) + // { + // tempPtr = parentPtr->removeChild(this); + // } + + // m_Parent = parent; + //} + +public: + IDataStructureContainerNode(const QString& name = "") + : AbstractDataStructureContainer(name) + { + } + IDataStructureContainerNode(ParentType* parent, const QString& name = "") + : AbstractDataStructureContainer(parent, name) + { + } + ~IDataStructureContainerNode() override + { + clear(); + } + + /** + * @brief Returns a copy of the children collection. + * @return + */ + constexpr const ChildCollection& getChildren() const + { + return m_ChildrenNodes; + } + + /** + * @brief Returns the names of all children nodes. + * @return + */ + NameList getNamesOfChildren() const + { + NameList names; + for(const auto& child : m_ChildrenNodes) + { + names.push_back(child->getName()); + } + return names; + } + + /** + * @brief Returns the DataArrayPaths of all descendants. + * @return + */ + DataArrayPathList getDescendantPaths() const + { + DataArrayPathList paths; + + for(const auto& child : m_ChildrenNodes) + { + paths.push_back(child->getDataArrayPath()); + // Check if child is a container node + auto childContainer = std::dynamic_pointer_cast(child); + if(nullptr != childContainer) + { + paths.merge(childContainer->getDescendantPaths()); + } + } + + return paths; + } + + /** + * @brief Returns a list of DataArrayPaths from both itself and all its descendants. + * @return + */ + DataArrayPathList getAllPaths() const + { + DataArrayPathList list = getDescendantPaths(); + list.push_front(getDataArrayPath()); + return list; + } + + /** + * @brief Returns an iterator pointing to the start of the children collection. + * @return + */ + constexpr iterator begin() noexcept + { + return m_ChildrenNodes.begin(); + } + + /** + * @brief Returns a const iterator pointing to the start of the children collection. + * @return + */ + constexpr const_iterator begin() const noexcept + { + return m_ChildrenNodes.begin(); + } + + /** + * @brief Returns a const iterator pointing to the start of the children collection. + * @return + */ + constexpr const_iterator cbegin() const noexcept + { + return m_ChildrenNodes.cbegin(); + } + + /** + * @brief Returns an iterator pointing past the end of the children collection. + * @return + */ + constexpr iterator end() noexcept + { + return m_ChildrenNodes.end(); + } + + /** + * @brief Returns a const iterator pointing past the end of the children collection. + * @return + */ + constexpr const_iterator end() const noexcept + { + return m_ChildrenNodes.end(); + } + + /** + * @brief Returns a const iterator pointing past the end of the children collection. + * @return + */ + constexpr const_iterator cend() const noexcept + { + return m_ChildrenNodes.cend(); + } + + /** + * @brief Returns true if the child collection is empty. Returns false otherwise. + * @return + */ + constexpr bool empty() const + { + return m_ChildrenNodes.empty(); + } + + /** + * @brief Returns the size of the children collection. + * @return + */ + constexpr size_t size() const + { + return m_ChildrenNodes.size(); + } + + /** + * @brief Clears the children collection. Items are not deleted unless this + * was the last shared_ptr referencing them. + */ + constexpr void clear() noexcept + { + auto children = getChildren(); + for(auto& child : children) + { + if(child != nullptr) + { + destroyParentConnection(child.get()); + } + } + m_ChildrenNodes.clear(); + } + + /** + * @brief Returns the child node with the given name. If no children nodes + * are found with the given name, return nullptr. + * @param name + * @return + */ + constexpr iterator find(const QString& name) + { + const auto hash = CreateStringHash(name); + for(auto iter = begin(); iter != end(); iter++) + { + if((*iter)->checkNameHash(hash)) + { + return iter; + } + } + + return end(); + } + + /** + * @brief Returns the child node with the given name. If no children nodes + * are found with the given name, return nullptr. + * @param name + * @return + */ + constexpr const_iterator find(const QString& name) const + { + const auto hash = CreateStringHash(name); + for(auto iter = begin(); iter != end(); iter++) + { + if((*iter)->checkNameHash(hash)) + { + return iter; + } + } + + return cend(); + } + + /** + * @brief Returns the child with the given name as a shared_ptr. + * If no child is found, return nullptr. + * @param name + * @return + */ + constexpr ChildShPtr getChildByName(const QString& name) const + { + HashType nameHash = CreateStringHash(name); + + const auto& children = getChildren(); + for(const auto& child : children) + { + if(child->checkNameHash(nameHash)) + { + return child; + } + } + return nullptr; + } + + /** + * @brief Returns true if the container has a child node with the given name. + * Returns false otherwise. + * @param name + * @return + */ + constexpr bool contains(const QString& name) const + { + return getChildByName(name) != nullptr; + } + + /** + * @brief Returns true if the given object is one of the container's children. + * Returns false otherwise. + * @param obj + * @return + */ + constexpr bool contains(const ChildShPtr& obj) const + { + const auto& children = getChildren(); + for(const auto& child : children) + { + if(child == obj) + { + return true; + } + } + return false; + } + + /** + * @brief Returns the index for the child with the given name. + * Returns -1 if there is no child with the given name. + * @param name + * @return + */ + constexpr int64_t getIndex(const QString& name) const + { + auto iter = find(name); + if(iter == cend()) + { + return -1; + } + return iter - begin(); + } + + /** + * @brief Returns the child node at the given index. If index is greater than + * the specified index, throw out_of_range exception. + * @param index + * @return + */ + constexpr ChildShPtr& operator[](size_t index) + { + if(index < 0 || index > m_ChildrenNodes.size()) + { + const char msg[] = "Index is out of range for the IDataStructureContainerNode's children collection."; + throw std::out_of_range(msg); + } + + return m_ChildrenNodes[index]; + } + + /** + * @brief Returns the child node with the given name. If no children nodes + * are found with the given name, return nullptr. + * @param name + * @return + */ + constexpr ChildShPtr& operator[](const QString& name) + { + return operator[](getIndex(name)); + } + + /** + * @brief Returns true if the container has a child by the given name. + * Returns false otherwise. + * @param name + * @return + */ + bool hasChildWithName(const QString& name) const override + { + return contains(name); + } + + /** + * @brief Attempts to append the given IDataStructureNode as a child. + * Returns true if the process succeeded. Returns false otherwise. + * @param value + * @return success + */ + bool push_back(const ChildShPtr& node) + { + if(node.get() == nullptr) + { + return false; + } + if(contains(node->getName())) + { + return false; + } + typename ChildCollection::size_type size = m_ChildrenNodes.size(); + m_ChildrenNodes.push_back(node); + + createParentConnection(node.get(), this); + return (size != m_ChildrenNodes.size()); + } + + /** + * @brief Sets the given IDataStructureNode as a child. If a child already + * exists with the given name, it is removed. + * @param node + * @return success + */ + bool insertOrAssign(const ChildShPtr& node) + { + // Can not insert a null IDataArray + if(node.get() == nullptr) + { + return false; + } + + auto iter = find(node->getName()); + if(iter != end()) + { + if((*iter) != node) + { + erase(iter); + } + else + { + return true; + } + } + + m_ChildrenNodes.push_back(node); + createParentConnection(node.get(), this); + return true; + } + + /** + * @brief Erases the child at the given iterator + * @param iter + */ + void erase(iterator iter) + { + ChildShPtr child = (*iter); + m_ChildrenNodes.erase(iter); + destroyParentConnection(child.get()); + } + + /** + * @brief Removes the given child from the children collection and returns its shared_ptr. + * @param child + * @return + */ + IDataStructureNode::Pointer removeChildNode(const IDataStructureNode* rmChild) override + { + if(rmChild == nullptr) + { + return NullPointer(); + } + + for(auto iter = m_ChildrenNodes.begin(); iter != m_ChildrenNodes.end(); ++iter) + { + if((*iter).get() == rmChild) + { + ChildShPtr ptr = *iter; + m_ChildrenNodes.erase(iter); + return ptr; + } + } + + return NullPointer(); + } + +}; diff --git a/Source/SIMPLib/DataContainers/IDataStructureNode.cpp b/Source/SIMPLib/DataContainers/IDataStructureNode.cpp new file mode 100644 index 0000000000..e08076a22f --- /dev/null +++ b/Source/SIMPLib/DataContainers/IDataStructureNode.cpp @@ -0,0 +1,174 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "IDataStructureNode.h" + +#include +#include +#include + +//#include "SIMPLib/DataContainers/DsnIterators.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::HashType IDataStructureNode::CreateStringHash(const QString& string) +{ + std::hash hashFn; + return hashFn(string.toStdString()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::IDataStructureNode(const QString& name) +: m_Name(name) +, m_Parent(nullptr) +{ + updateNameHash(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::IDataStructureNode(ParentType* parent, const QString& name) +: m_Name(name) +, m_Parent(parent) +{ + updateNameHash(); + + // Add to parent's children +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::~IDataStructureNode() +{ + if(m_Parent != nullptr) + { + m_Parent->removeChildNode(this); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IDataStructureNode::updateNameHash() +{ + m_NameHash = CreateStringHash(getName()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString IDataStructureNode::getName() const +{ + return m_Name; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool IDataStructureNode::setName(const QString& newName) +{ + if(nullptr == m_Parent) + { + m_Name = newName; + updateNameHash(); + return true; + } + else if(!m_Parent->hasChildWithName(newName)) + { + m_Name = newName; + updateNameHash(); + return true; + } + + return false; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::ParentType* IDataStructureNode::getParentNode() const +{ + return m_Parent; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IDataStructureNode::setParentNode(ParentType* const parent) +{ + if(parent == m_Parent) + { + return; + } + + // Remove from parent's children + if(nullptr != m_Parent) + { + m_Parent->removeChildNode(this); + } + + m_Parent = parent; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath IDataStructureNode::getParentPath() const +{ + if(!hasParent()) + { + return DataArrayPath(); + } + return getParentNode()->getDataArrayPath(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractDataStructureContainer::createParentConnection(IDataStructureNode* child, AbstractDataStructureContainer* parent) const +{ + child->setParentNode(parent); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractDataStructureContainer::destroyParentConnection(IDataStructureNode* child) const +{ + child->clearParentNode(); +} diff --git a/Source/SIMPLib/DataContainers/IDataStructureNode.h b/Source/SIMPLib/DataContainers/IDataStructureNode.h new file mode 100644 index 0000000000..51f7419b72 --- /dev/null +++ b/Source/SIMPLib/DataContainers/IDataStructureNode.h @@ -0,0 +1,214 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include +#include +#include + +#include + +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/SIMPLib.h" + +class AbstractDataStructureContainer; + +/** + * @class IDataStructureNode IDataStructureNode.h SIMPLib/DataContainers/IDataStructureNode.h + * @brief the IDataStructureNode class serves as the base class for data + * structure classes from DataContainer to DataArray + */ +class SIMPLib_EXPORT IDataStructureNode +{ +public: + SIMPL_SHARED_POINTERS(IDataStructureNode) + + using ParentType = AbstractDataStructureContainer; + // using ParentWkPtr = std::weak_ptr; + // using parent_collection = std::vector; + using DataArrayPathList = std::list; + using HashType = size_t; + + friend AbstractDataStructureContainer; + +private: + QString m_Name; + ParentType* m_Parent = nullptr; + HashType m_NameHash = 0; + + /** + * @brief Updates the name hash variable based on the current name. + */ + void updateNameHash(); + + /** + * @brief Sets the raw parent pointer. As additional graph support is added, + * this will instead be replaced with addParentNode(const ParentType&) and + * removeParentNode(const ParentType&). This should only be called from + * IDataStructureContainerNode::push_back, insertOrAssign, or + * IDataStructureNode::clearParentNode. THIS DOES NOT ADD THE NODE TO THE TARGET PARENT! + * @param parent + */ + void setParentNode(ParentType* const parent); + + /** + * @brief Clears the parent pointer and removes this from its parent constainer. + */ + void clearParentNode() + { + setParentNode(nullptr); + } + + // void addParentNode(const ParentType& newParent); + // bool removeParentNode(const ParentType& removedParent); + +protected: + /** + * @brief Method for creating hashes from QString values. + * @param string + * @return + */ + static HashType CreateStringHash(const QString& string); + +public: + IDataStructureNode(const QString& name = ""); + IDataStructureNode(ParentType* parent, const QString& name = ""); + + virtual ~IDataStructureNode(); + + /** + * @brief Checks the name hash for equality. Returns true if they are equal. + * Returns false otherwise. + * @param nameHash + * @return + */ + bool checkNameHash(size_t nameHash) const + { + return m_NameHash == nameHash; + } + + /** + * @brief Returns the node's name. + * @return + */ + QString getName() const; + + /** + * @brief Attempts to rename the container. Returns true if the operation succeeded. + * Returns false otherwise. + * @param newName + * @return + */ + bool setName(const QString& newName); + + /** + * @brief Returns the parent node. This currently only returns a single pointer, + * but as additional graph support is added, this will instead return a parent_collection. + * @return + */ + ParentType* getParentNode() const; + + /** + * @brief Returns the data structure node's DataArrayPath. + * @return + */ + virtual DataArrayPath getDataArrayPath() const = 0; + + /** + * @brief Returns the parent node's DataArrayPath. If no parent node exists, return an empty path; + * @return + */ + DataArrayPath getParentPath() const; + + /** + * @brief Returns true if a parent node exists. Returns false otherwise. + * @return + */ + bool hasParent() const + { + return m_Parent != nullptr; + } +}; + +/** + * @class AbstractDataStructureContainer IDataStructureNode.h SIMPLib/DataContainers/IDataStructureNode.h + * @brief The AbstractDataStructureContainer is an interface created so that IDataStructureNode can call required methods in IDataStructureContainerNode. + */ +class SIMPLib_EXPORT AbstractDataStructureContainer : public IDataStructureNode +{ +public: + AbstractDataStructureContainer(const QString& name = "") + : IDataStructureNode(name) + { + } + AbstractDataStructureContainer(ParentType* parent, const QString& name = "") + : IDataStructureNode(parent, name) + { + } + ~AbstractDataStructureContainer() override = default; + + /** + * @brief Returns true if the container has a child node with the given name. + * @param name + * @return + */ + virtual bool hasChildWithName(const QString& name) const = 0; + + /** + * @brief Removes the target node from the container's list of children. + * Returns the removed node as a shared pointer. + * @param rmChild + * @return + */ + virtual IDataStructureNode::Pointer removeChildNode(const IDataStructureNode* rmChild) = 0; + +protected: + /** + * @brief Sets the child's parent container. This does not add the child to the parent's collection. + * THIS METHOD IS ONLY USED BY IDataStructureNode AND SHOULD NOT BE USED BY ANY CLASS THAT DERIVES FROM IT. + * @param child + * @param parent + */ + void createParentConnection(IDataStructureNode* child, AbstractDataStructureContainer* parent) const; + + /** + * @brief Clears the child's parent pointer. This does not remove the child from the parent's collection. + * THIS METHOD IS ONLY USED BY IDataStructureNode AND SHOULD NOT BE USED BY ANY CLASS THAT DERIVES FROM IT. + * @param child + */ + void destroyParentConnection(IDataStructureNode* child) const; +}; diff --git a/Source/SIMPLib/FilterParameters/FloatVec2.h b/Source/SIMPLib/DataContainers/RenameDataPath.cpp similarity index 74% rename from Source/SIMPLib/FilterParameters/FloatVec2.h rename to Source/SIMPLib/DataContainers/RenameDataPath.cpp index 36fb54b44b..6ec872e03a 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec2.h +++ b/Source/SIMPLib/DataContainers/RenameDataPath.cpp @@ -26,37 +26,23 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once -#include +#include "RenameDataPath.h" -typedef struct -{ - float x; - float y; - float z; - void FloatVec2(const float& xx, const float& yy) - { - x = xx; - y = yy; - } - void writeJson(QJsonObject& json) - { - json["x"] = static_cast(x); - json["y"] = static_cast(y); - } +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" - bool readJson(QJsonObject& json) +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RenameDataPath::AlertFilterCreatedPath(AbstractFilter* filter, DataID_t id, const DataArrayPath& path) +{ + if(filter != nullptr) { - if(json["x"].isDouble() && json["y"].isDouble()) - { - x = static_cast(json["x"].toDouble()); - y = static_cast(json["y"].toDouble()); - return true; - } - return false; + filter->checkIfPathRenamed(id, path); } -} FloatVec2_t; - -Q_DECLARE_METATYPE(FloatVec2_t) +} diff --git a/Source/SIMPLib/DataContainers/RenameDataPath.h b/Source/SIMPLib/DataContainers/RenameDataPath.h new file mode 100644 index 0000000000..c043fa4f5e --- /dev/null +++ b/Source/SIMPLib/DataContainers/RenameDataPath.h @@ -0,0 +1,74 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" + +class AbstractFilter; +class DataArrayPath; + +/** + * @brief RenameDataPath is used by DataContainerArray, DataContainer, and AttributeMatrix + * to alert the specified AbstractFilter that a DataArrayPath has been created + * with the given DataID_t. This also serves as the declaration of the type alias, + * DataID_t so that all classes that require it have access to it without causing + * dependency issues. + */ +namespace RenameDataPath +{ + /** + * @brief DataID_t is used as the ID type when creating DataArrayPaths through + * createNonPrereq* methods inside AbstractFilter::dataCheck(). This ID is + * used for mapping created paths and performing quick lookups to detect rename + * operations far more quickly than previous implementations for rename + * operations. This forces filters to opt-in to rename functionality rather than + * provide it across all filters automatically. + */ + using DataID_t = size_t; + const DataID_t k_Invalid_ID = 0; + + /** + * @brief This function serves as the main hub for alerting the specified + * AbstractFilter that a DataArrayPath has been created with the given ID. + * The plus side of this is that AbstractFilter has a single friend function + * instead of having to declare DataContainerArray, DataContainer, and AttributeMatrix + * all as friend classes in order to achieve the same result. + * @param filter The filter creating the path + * @param id The local ID for the filter to perform rename checks on + * @param path The new DataArrayPath + */ + void SIMPLib_EXPORT AlertFilterCreatedPath(AbstractFilter* filter, DataID_t id, const DataArrayPath& path); +} diff --git a/Source/SIMPLib/DataContainers/SourceList.cmake b/Source/SIMPLib/DataContainers/SourceList.cmake index 1ef9dcf942..8275df4b7f 100755 --- a/Source/SIMPLib/DataContainers/SourceList.cmake +++ b/Source/SIMPLib/DataContainers/SourceList.cmake @@ -57,6 +57,10 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainer.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerArrayProxy.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerProxy.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DsnIterators.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataStructureContainerNode.hpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataStructureNode.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/RenameDataPath.h ) set(SIMPLib_${SUBDIR_NAME}_SRCS @@ -70,6 +74,8 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerProxy.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerBundle.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataContainerBundle.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataStructureNode.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/RenameDataPath.cpp ) cmp_IDE_SOURCE_PROPERTIES( "${SUBDIR_NAME}" "${SIMPLib_${SUBDIR_NAME}_HDRS};${SIMPLib_${SUBDIR_NAME}_Moc_HDRS}" "${SIMPLib_${SUBDIR_NAME}_SRCS}" "${PROJECT_INSTALL_HEADERS}") diff --git a/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp b/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp index cfab4dfe84..f79a8be563 100644 --- a/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp +++ b/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp @@ -72,7 +72,7 @@ class DataContainerBundleTest typename DataArray::Pointer data = DataArray::CreateArray(tDims, cDims, name); - am->addAttributeArray(data->getName(), data); + am->insertOrAssign(data); } // ----------------------------------------------------------------------------- @@ -94,11 +94,11 @@ class DataContainerBundleTest AddDataArray(am, "Uint8 Array", tDims, cDims); AddDataArray(am, "Float Array", tDims, cDims); AddDataArray(am, "int32 Array", tDims, cDims); - dc0->addAttributeMatrix(am->getName(), am); + dc0->addOrReplaceAttributeMatrix(am); QVector tupleDims(1, 1); AttributeMatrix::Pointer metaAm = AttributeMatrix::New(tupleDims, DataContainerBundle::GetMetaDataName(), AttributeMatrix::Type::MetaData); - dc0->addAttributeMatrix(metaAm->getName(), metaAm); + dc0->addOrReplaceAttributeMatrix(metaAm); DataContainer::Pointer dc1 = dc0->deepCopy(false); dc1->setName("DC 1"); @@ -109,14 +109,14 @@ class DataContainerBundleTest dc2->getAttributeMatrix("CellAttributeMatrix")->removeAttributeArray("Uint8 Array"); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(dc0); - dca->addDataContainer(dc1); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc0); + dca->addOrReplaceDataContainer(dc1); + dca->addOrReplaceDataContainer(dc2); DataContainerBundle::Pointer bundle = DataContainerBundle::New("Bundle 1"); - bundle->addDataContainer(dc0); - bundle->addDataContainer(dc1); - bundle->addDataContainer(dc2); + bundle->addOrReplaceDataContainer(dc0); + bundle->addOrReplaceDataContainer(dc1); + bundle->addOrReplaceDataContainer(dc2); QVector paths = bundle->findCommonDataArrayPaths(); diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ApplyImageTransforms.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ApplyImageTransforms.md new file mode 100644 index 0000000000..42cef1823a --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ApplyImageTransforms.md @@ -0,0 +1,36 @@ +# Apply Image Transforms # + +## Group (Subgroup) ## + +CoreFilters (Image) + +## Description ## + +This **Filter** updates the geometry of selected data containers by applying the transforms stored in each data container to the data container's origin. This is an experimental filter and is not yet ready for release to the public. It is only currently meant to be used to apply Affine 3x3 transforms from each data container's transform container to the data container's origin. + +## Parameters ## + +None. + +## Required Geometry ## + +Image + +## Required Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|-----| +| **Image Data Containers** | N/A | Any | Any | The data containers whose stored transforms will be applied to the origin. | + +## Created Objects ## + +None. + +## License & Copyright ## + +Please see the description file distributed with this plugin. + +## DREAM3D Mailing Lists ## + +If you need more help with a filter, please consider asking your question on the DREAM3D Users mailing list: +https://groups.google.com/forum/?hl=en#!forum/dream3d-users \ No newline at end of file diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MassCreateData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MassCreateData.md new file mode 100644 index 0000000000..d5ff428e4e --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MassCreateData.md @@ -0,0 +1,41 @@ +Mass Create Data Containers +============= + +## Group (Subgroup) ## + +Core (Generation) + + +## Description ## + +This **Filter** creates 4,000 **Data Containers** starting with a given name with an index number tacked on at the end. This filter was created for testing rename operation timings. + +## Parameters ## + +| Name | Type | Description | +|------------------|------|-------------| +| Data Container Name | string | Base DataContainer name | + +## Required Geometry ## + +Not Applicable + +## Required Objects ## + +None + +## Created Objects ## + +| Kind | Default Name | Description | +|------|--------------|-------------|---------|----------------| +| **Data Container** | None | Created **Data Container** location and name | + + +## Example Pipelines ## + + + +## License & Copyright ## + +Please see the description file distributed with this **Plugin** + diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp index 173a1ed079..85d2e40c18 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp @@ -348,25 +348,25 @@ QVector AbstractFilterParametersReader::readArray(const QString name, QV // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntVec3_t AbstractFilterParametersReader::readIntVec3(const QString name, IntVec3_t defaultValue) +IntVec3Type AbstractFilterParametersReader::readIntVec3(const QString name, IntVec3Type defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return IntVec3_t(); + return IntVec3Type(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec3_t AbstractFilterParametersReader::readFloatVec3(const QString name, FloatVec3_t defaultValue) +FloatVec3Type AbstractFilterParametersReader::readFloatVec3(const QString name, FloatVec3Type defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return FloatVec3_t(); + return FloatVec3Type(); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h index e945de0d6d..933db09602 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h @@ -109,8 +109,8 @@ class SIMPLib_EXPORT AbstractFilterParametersReader virtual QVector readArray(const QString name, QVector value); virtual QVector readArray(const QString name, QVector value); - virtual IntVec3_t readIntVec3(const QString name, IntVec3_t v); - virtual FloatVec3_t readFloatVec3(const QString name, FloatVec3_t v); + virtual IntVec3Type readIntVec3(const QString name, IntVec3Type v); + virtual FloatVec3Type readFloatVec3(const QString name, FloatVec3Type v); virtual Float2ndOrderPoly_t readFloat2ndOrderPoly(const QString name, Float2ndOrderPoly_t v); virtual Float3rdOrderPoly_t readFloat3rdOrderPoly(const QString name, Float3rdOrderPoly_t v); virtual Float4thOrderPoly_t readFloat4thOrderPoly(const QString name, Float4thOrderPoly_t v); diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp b/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp index 9f4f3a11b7..f0bc57d087 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp @@ -324,7 +324,7 @@ int AbstractFilterParametersWriter::writeValue(const QString& name, QVector value); virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, IntVec3_t v); - virtual int writeValue(const QString& name, FloatVec3_t v); + virtual int writeValue(const QString& name, IntVec3Type v); + virtual int writeValue(const QString& name, FloatVec3Type v); virtual int writeValue(const QString& name, Float2ndOrderPoly_t v); virtual int writeValue(const QString& name, Float3rdOrderPoly_t v); virtual int writeValue(const QString& name, Float4thOrderPoly_t v); diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp index bf917932e4..f58ef62787 100644 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp @@ -34,6 +34,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AttributeMatrixCreationFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -49,8 +50,8 @@ AttributeMatrixCreationFilterParameter::~AttributeMatrixCreationFilterParameter( // // ----------------------------------------------------------------------------- AttributeMatrixCreationFilterParameter::Pointer AttributeMatrixCreationFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex) + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const RequirementType& req, int groupIndex) { AttributeMatrixCreationFilterParameter::Pointer ptr = AttributeMatrixCreationFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -103,3 +104,23 @@ void AttributeMatrixCreationFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AttributeMatrixCreationFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h index 3761d5940e..623f5f5910 100755 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h @@ -42,6 +42,8 @@ #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + /** * @brief SIMPL_NEW_AM_CREATION_FP This macro is a short-form way of instantiating an instance of * AttributeMatrixCreationFilterParameter. There are 5 required parameters and 1 optional parameter @@ -75,10 +77,10 @@ class SIMPLib_EXPORT AttributeMatrixCreationFilterParameter : public FilterParam using SetterCallbackType = std::function; using GetterCallbackType = std::function; - typedef struct + using RequirementType = struct { IGeometry::Types dcGeometryTypes; - } RequirementType; + }; /** * @brief New This function instantiates an instance of the AttributeMatrixCreationFilterParameter. Specifying a RequirementType will @@ -100,10 +102,8 @@ class SIMPLib_EXPORT AttributeMatrixCreationFilterParameter : public FilterParam * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); + static Pointer New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); ~AttributeMatrixCreationFilterParameter() override; @@ -146,6 +146,11 @@ class SIMPLib_EXPORT AttributeMatrixCreationFilterParameter : public FilterParam */ SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + protected: /** * @brief AttributeMatrixCreationFilterParameter The default constructor. It is protected because this diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp index 2bd7f205b8..50a052c5e4 100644 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp @@ -53,8 +53,8 @@ AttributeMatrixSelectionFilterParameter::~AttributeMatrixSelectionFilterParamete // // ----------------------------------------------------------------------------- AttributeMatrixSelectionFilterParameter::Pointer AttributeMatrixSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex) + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const RequirementType& req, int groupIndex) { AttributeMatrixSelectionFilterParameter::Pointer ptr = AttributeMatrixSelectionFilterParameter::New(); @@ -171,3 +171,23 @@ AttributeMatrixSelectionFilterParameter::RequirementType AttributeMatrixSelectio return reqs; } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h index 8457a752af..da6d0c8182 100755 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h @@ -74,11 +74,11 @@ class SIMPLib_EXPORT AttributeMatrixSelectionFilterParameter : public FilterPara using SetterCallbackType = std::function; using GetterCallbackType = std::function; - typedef struct + using RequirementType = struct { IGeometry::Types dcGeometryTypes; AttributeMatrix::Types amTypes; - } RequirementType; + }; /** * @brief New This function instantiates an instance of the AttributeMatrixSelectionFilterParameter. Specifying a RequirementType will @@ -100,10 +100,8 @@ class SIMPLib_EXPORT AttributeMatrixSelectionFilterParameter : public FilterPara * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); + static Pointer New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); ~AttributeMatrixSelectionFilterParameter() override; @@ -174,6 +172,11 @@ class SIMPLib_EXPORT AttributeMatrixSelectionFilterParameter : public FilterPara */ SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + protected: /** * @brief AttributeMatrixSelectionFilterParameter The default constructor. It is protected because this diff --git a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp index ceced77422..f5727ce1d3 100644 --- a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp @@ -101,7 +101,7 @@ void CalculatorFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CalculatorFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void CalculatorFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h index 3988a8ecde..d1bbae933c 100644 --- a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h @@ -130,7 +130,7 @@ class SIMPLib_EXPORT CalculatorFilterParameter : public FilterParameter * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp index 219d79bc9d..918fd88175 100644 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp @@ -120,7 +120,7 @@ void ComparisonSelectionAdvancedFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionAdvancedFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void ComparisonSelectionAdvancedFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h index 37a838cc21..67d2a1766a 100644 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h @@ -143,7 +143,7 @@ class SIMPLib_EXPORT ComparisonSelectionAdvancedFilterParameter : public FilterP * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp index 53a098dc14..a4c065fb33 100644 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp @@ -131,7 +131,7 @@ void ComparisonSelectionFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void ComparisonSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h index a51894b632..e0292e5935 100755 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h @@ -142,7 +142,7 @@ class SIMPLib_EXPORT ComparisonSelectionFilterParameter : public FilterParameter * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp index 22941d8c5a..6cc79c8a17 100644 --- a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp @@ -36,7 +36,7 @@ #include "DataArrayCreationFilterParameter.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" - +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -157,3 +157,23 @@ void DataArrayCreationFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArrayCreationFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} diff --git a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h index 8b0c690b58..3c11039c28 100755 --- a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h @@ -42,6 +42,8 @@ #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + /** * @brief SIMPL_NEW_DA_CREATION_FP This macro is a short-form way of instantiating an instance of * DataArrayCreationFilterParameter. There are 5 required parameters and 1 optional parameter @@ -168,6 +170,11 @@ class SIMPLib_EXPORT DataArrayCreationFilterParameter : public FilterParameter */ SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + protected: /** * @brief DataArrayCreationFilterParameter The default constructor. It is protected because this diff --git a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp index 824f244c9b..28dfb09c74 100644 --- a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp @@ -205,3 +205,23 @@ DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParam return reqs; } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} diff --git a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h index 208c144fc5..79b5a48f59 100755 --- a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h @@ -42,6 +42,8 @@ #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + /** * @brief SIMPL_NEW_DA_SELECTION_FP This macro is a short-form way of instantiating an instance of * DataArraySelectionFilterParameter. There are 5 required parameters and 1 optional parameter @@ -197,6 +199,11 @@ class SIMPLib_EXPORT DataArraySelectionFilterParameter : public FilterParameter */ SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + protected: /** * @brief DataArraySelectionFilterParameter The default constructor. It is protected because this diff --git a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp index 90d1c98404..1521554ca3 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp @@ -113,12 +113,15 @@ void DataContainerArrayProxyFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArrayProxyFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void DataContainerArrayProxyFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { QVariant var = filter->property(qPrintable(getPropertyName())); DataContainerArrayProxy dcaProxy = var.value(); dcaProxy.updatePath(renamePath); var.setValue(dcaProxy); - filter->setProperty(qPrintable(getPropertyName()), var); + if(m_SetterCallback) + { + m_SetterCallback(dcaProxy); + } emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } diff --git a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h index 9203534486..629c9de96f 100755 --- a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h @@ -136,7 +136,7 @@ class SIMPLib_EXPORT DataContainerArrayProxyFilterParameter : public FilterParam /** * @brief Handle DataArrayPath changes if necessary */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp index aee34d78c5..da08211bdc 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp @@ -35,6 +35,8 @@ #include "DataContainerCreationFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -48,14 +50,16 @@ DataContainerCreationFilterParameter::~DataContainerCreationFilterParameter() = // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerCreationFilterParameter::Pointer DataContainerCreationFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, +DataContainerCreationFilterParameter::Pointer DataContainerCreationFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) { DataContainerCreationFilterParameter::Pointer ptr = DataContainerCreationFilterParameter::New(); ptr->setHumanLabel(humanLabel); ptr->setPropertyName(propertyName); - ptr->setDefaultValue(defaultValue); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); ptr->setCategory(category); ptr->setGroupIndex(groupIndex); ptr->setSetterCallback(setterCallback); @@ -80,7 +84,18 @@ void DataContainerCreationFilterParameter::readJson(const QJsonObject& json) QJsonValue jsonValue = json[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) { - m_SetterCallback(jsonValue.toString("")); + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + m_SetterCallback(dap); + } } } @@ -91,6 +106,25 @@ void DataContainerCreationFilterParameter::writeJson(QJsonObject& json) { if(m_GetterCallback) { - json[getPropertyName()] = m_GetterCallback(); + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerCreationFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + { + m_SetterCallback(newPath); + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } diff --git a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h index 0e36ec16e7..adc7e4bd18 100755 --- a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h @@ -37,6 +37,7 @@ #include +#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/FilterParameters/FilterParameter.h" /** @@ -64,33 +65,32 @@ class SIMPLib_EXPORT DataContainerCreationFilterParameter : public FilterParamet { public: SIMPL_SHARED_POINTERS(DataContainerCreationFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataContainerCreationFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerCreationFilterParameter, FilterParameter) + SIMPL_STATIC_NEW_MACRO(DataContainerCreationFilterParameter) + SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerCreationFilterParameter, FilterParameter) - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; - /** - * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DC_CREATION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); + /** + * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DC_CREATION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, + int groupIndex = -1); - ~DataContainerCreationFilterParameter() override; + ~DataContainerCreationFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls @@ -125,6 +125,13 @@ class SIMPLib_EXPORT DataContainerCreationFilterParameter : public FilterParamet */ SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Handles changes to the DataArrayPath + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + protected: /** * @brief DataContainerCreationFilterParameter The default constructor. It is protected because this diff --git a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp index 0230d9b5b9..b36abbd753 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp @@ -50,8 +50,8 @@ DataContainerSelectionFilterParameter::~DataContainerSelectionFilterParameter() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerSelectionFilterParameter::Pointer DataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const RequirementType req, +DataContainerSelectionFilterParameter::Pointer DataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, + SetterCallbackType setterCallback, GetterCallbackType getterCallback, const RequirementType& req, int groupIndex) { DataContainerSelectionFilterParameter::Pointer ptr = DataContainerSelectionFilterParameter::New(); @@ -85,7 +85,18 @@ void DataContainerSelectionFilterParameter::readJson(const QJsonObject& json) QJsonValue jsonValue = json[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) { - m_SetterCallback(jsonValue.toString("")); + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + m_SetterCallback(dap); + } } } @@ -96,22 +107,25 @@ void DataContainerSelectionFilterParameter::writeJson(QJsonObject& json) { if(m_GetterCallback) { - json[getPropertyName()] = m_GetterCallback(); + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void DataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; std::tie(oldPath, newPath) = renamePath; - if(oldPath.getDataContainerName() == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) { - m_SetterCallback(newPath.getDataContainerName()); + m_SetterCallback(newPath); emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } diff --git a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h index 37310785cf..43f6b5b940 100755 --- a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h @@ -37,6 +37,7 @@ #include +#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" @@ -69,13 +70,13 @@ class SIMPLib_EXPORT DataContainerSelectionFilterParameter : public FilterParame SIMPL_STATIC_NEW_MACRO(DataContainerSelectionFilterParameter) SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerSelectionFilterParameter, FilterParameter) - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; - typedef struct + using RequirementType = struct { IGeometry::Types dcGeometryTypes; - } RequirementType; + }; /** * @brief New This function instantiates an instance of the DataContainerSelectionFilterParameter. Specifying a RequirementType will @@ -97,10 +98,8 @@ class SIMPLib_EXPORT DataContainerSelectionFilterParameter : public FilterParame * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); + static Pointer New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, SetterCallbackType setterCallback, + GetterCallbackType getterCallback, const RequirementType& req, int groupIndex = -1); ~DataContainerSelectionFilterParameter() override; @@ -150,7 +149,7 @@ class SIMPLib_EXPORT DataContainerSelectionFilterParameter : public FilterParame * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/DynamicTableData.cpp b/Source/SIMPLib/FilterParameters/DynamicTableData.cpp index eccfc9e828..3121e15ed0 100644 --- a/Source/SIMPLib/FilterParameters/DynamicTableData.cpp +++ b/Source/SIMPLib/FilterParameters/DynamicTableData.cpp @@ -339,7 +339,7 @@ QVector DynamicTableData::flattenData() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector> DynamicTableData::ExpandData(std::vector orig, int nRows, int nCols) +std::vector> DynamicTableData::ExpandData(std::vector orig, size_t nRows, size_t nCols) { std::vector> expand(nRows, std::vector(nCols)); @@ -349,9 +349,9 @@ std::vector> DynamicTableData::ExpandData(std::vector > ExpandData(std::vector orig, int nRows, int nCols); + static std::vector > ExpandData(std::vector orig, size_t nRows, size_t nCols); /** * @brief This deserializes a string of headers and returns the original QStringList. diff --git a/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp index 316278559c..185412839d 100644 --- a/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp @@ -80,7 +80,6 @@ DynamicTableFilterParameter::Pointer DynamicTableFilterParameter::New(const QStr } } - ptr->setErrorCondition(0); ptr->setErrorMessage("There is no error."); return ptr; } diff --git a/Source/SIMPLib/FilterParameters/FilterParameter.cpp b/Source/SIMPLib/FilterParameters/FilterParameter.cpp index 868823d7f0..76acbb4616 100644 --- a/Source/SIMPLib/FilterParameters/FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FilterParameter.cpp @@ -76,10 +76,15 @@ void FilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { QVariant var = filter->property(qPrintable(getPropertyName())); - if(var.isValid() && var.canConvert()) + if(!var.isValid()) + { + return; + } + + if(var.canConvert()) { DataArrayPath path = var.value(); if(path.updatePath(renamePath)) @@ -89,7 +94,7 @@ void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { DataContainerArrayProxy proxy = var.value(); proxy.updatePath(renamePath); @@ -97,7 +102,7 @@ void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath filter->setProperty(qPrintable(getPropertyName()), var); emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { DataContainerProxy proxy = var.value(); proxy.updatePath(renamePath); @@ -105,7 +110,7 @@ void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath filter->setProperty(qPrintable(getPropertyName()), var); emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { AttributeMatrixProxy proxy = var.value(); proxy.updatePath(renamePath); @@ -113,7 +118,7 @@ void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath filter->setProperty(qPrintable(getPropertyName()), var); emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { DataArrayProxy proxy = var.value(); proxy.updatePath(renamePath); diff --git a/Source/SIMPLib/FilterParameters/FilterParameter.h b/Source/SIMPLib/FilterParameters/FilterParameter.h index e965aa7bf7..12377f1b19 100755 --- a/Source/SIMPLib/FilterParameters/FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FilterParameter.h @@ -105,7 +105,7 @@ class SIMPLib_EXPORT FilterParameter * @param filter * @param renamePath */ - virtual void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath); + virtual void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath); protected: FilterParameter(); @@ -117,7 +117,7 @@ class SIMPLib_EXPORT FilterParameter FilterParameter& operator=(FilterParameter&&) = delete; // Move Assignment Not Implemented }; -typedef QVector FilterParameterVector; +using FilterParameterVectorType = std::vector; // ----------------------------------------------------------------------------- // This section of Macros allows each FilterParameter subclass to create a macro diff --git a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp index 6c258d32d3..33a33d90aa 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp @@ -46,7 +46,7 @@ FloatVec2FilterParameter::~FloatVec2FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec2FilterParameter::Pointer FloatVec2FilterParameter::New(const QString& humanLabel, const QString& propertyName, const FloatVec2_t& defaultValue, Category category, +FloatVec2FilterParameter::Pointer FloatVec2FilterParameter::New(const QString& humanLabel, const QString& propertyName, const FloatVec2Type& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) { @@ -75,14 +75,18 @@ QString FloatVec2FilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatVec2FilterParameter::readJson(const QJsonObject& json) +void FloatVec2FilterParameter::readJson(const QJsonObject& obj) { - QJsonValue jsonValue = json[getPropertyName()]; + QJsonValue jsonValue = obj[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) { - QJsonObject obj = jsonValue.toObject(); - FloatVec2_t floatVec2; - floatVec2.readJson(obj); + QJsonObject json = jsonValue.toObject(); + FloatVec2Type floatVec2; + if(json["x"].isDouble() && json["y"].isDouble()) + { + floatVec2[0] = static_cast(json["x"].toDouble()); + floatVec2[1] = static_cast(json["y"].toDouble()); + } m_SetterCallback(floatVec2); } } @@ -90,13 +94,14 @@ void FloatVec2FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatVec2FilterParameter::writeJson(QJsonObject& json) +void FloatVec2FilterParameter::writeJson(QJsonObject& obj) { if (m_GetterCallback) { - FloatVec2_t floatVec2 = m_GetterCallback(); - QJsonObject obj; - floatVec2.writeJson(obj); - json[getPropertyName()] = obj; + FloatVec2Type floatVec2 = m_GetterCallback(); + QJsonObject json; + json["x"] = static_cast(floatVec2.getX()); + json["y"] = static_cast(floatVec2.getY()); + obj[getPropertyName()] = json; } } diff --git a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h index 3e1898b168..f2bdac3c14 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h @@ -36,14 +36,15 @@ #pragma once #include +#include #include #include #include +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/FilterParameters/FloatVec2.h" #include "SIMPLib/SIMPLib.h" /** @@ -74,8 +75,8 @@ class SIMPLib_EXPORT FloatVec2FilterParameter : public FilterParameter SIMPL_STATIC_NEW_MACRO(FloatVec2FilterParameter) SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FloatVec2FilterParameter, FilterParameter) - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; /** * @brief New This function instantiates an instance of the FloatVec2FilterParameter. Although this function is available to be used, @@ -93,9 +94,8 @@ class SIMPLib_EXPORT FloatVec2FilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const FloatVec2_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); + static Pointer New(const QString& humanLabel, const QString& propertyName, const FloatVec2Type& defaultValue, Category category, SetterCallbackType setterCallback, + GetterCallbackType getterCallback, int groupIndex = -1); ~FloatVec2FilterParameter() override; @@ -146,3 +146,4 @@ class SIMPLib_EXPORT FloatVec2FilterParameter : public FilterParameter FloatVec2FilterParameter& operator=(FloatVec2FilterParameter&&) = delete; // Move Assignment Not Implemented }; +Q_DECLARE_METATYPE(FloatVec2Type) diff --git a/Source/SIMPLib/FilterParameters/FloatVec3.h b/Source/SIMPLib/FilterParameters/FloatVec3.h index 2121e9e2f7..e69de29bb2 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec3.h +++ b/Source/SIMPLib/FilterParameters/FloatVec3.h @@ -1,74 +0,0 @@ -/* ============================================================================ - * Copyright (c) 2019 BlueQuartz Software, LLC - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its - * contributors may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once - -#include - -typedef struct -{ - float x; - float y; - float z; - void FloatVec3(const float& xx, const float& yy, const float& zz) - { - x = xx; - y = yy; - z = zz; - } - - void writeJson(QJsonObject& json) - { - json["x"] = static_cast(x); - json["y"] = static_cast(y); - json["z"] = static_cast(z); - } - - bool readJson(QJsonObject& json) - { - if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) - { - x = static_cast(json["x"].toDouble()); - y = static_cast(json["y"].toDouble()); - z = static_cast(json["z"].toDouble()); - return true; - } - return false; - } - - void normalize() - { - float denom = std::sqrt(x * x + y * y + z * z); - x = x / denom; - y = y / denom; - z = z / denom; - } -} FloatVec3_t; - -Q_DECLARE_METATYPE(FloatVec3_t) \ No newline at end of file diff --git a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp index fb1e71e225..92a4a6ccc8 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp @@ -48,7 +48,7 @@ FloatVec3FilterParameter::~FloatVec3FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec3FilterParameter::Pointer FloatVec3FilterParameter::New(const QString& humanLabel, const QString& propertyName, const FloatVec3_t& defaultValue, Category category, +FloatVec3FilterParameter::Pointer FloatVec3FilterParameter::New(const QString& humanLabel, const QString& propertyName, const FloatVec3Type& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) { @@ -77,14 +77,19 @@ QString FloatVec3FilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatVec3FilterParameter::readJson(const QJsonObject& json) +void FloatVec3FilterParameter::readJson(const QJsonObject& obj) { - QJsonValue jsonValue = json[getPropertyName()]; + QJsonValue jsonValue = obj[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) { - QJsonObject obj = jsonValue.toObject(); - FloatVec3_t floatVec3; - floatVec3.readJson(obj); + QJsonObject json = jsonValue.toObject(); + FloatVec3Type floatVec3; + if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) + { + floatVec3[0] = static_cast(json["x"].toDouble()); + floatVec3[1] = static_cast(json["y"].toDouble()); + floatVec3[2] = static_cast(json["z"].toDouble()); + } m_SetterCallback(floatVec3); } } @@ -92,13 +97,15 @@ void FloatVec3FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatVec3FilterParameter::writeJson(QJsonObject& json) +void FloatVec3FilterParameter::writeJson(QJsonObject& obj) { if (m_GetterCallback) { - FloatVec3_t floatVec3 = m_GetterCallback(); - QJsonObject obj; - floatVec3.writeJson(obj); - json[getPropertyName()] = obj; + FloatVec3Type floatVec3 = m_GetterCallback(); + QJsonObject json; + json["x"] = static_cast(floatVec3.getX()); + json["y"] = static_cast(floatVec3.getY()); + json["z"] = static_cast(floatVec3.getZ()); + obj[getPropertyName()] = json; } } diff --git a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h index 5615c31635..0f3d0f7d40 100755 --- a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h @@ -36,14 +36,16 @@ #pragma once #include +#include #include #include #include +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/FilterParameters/FloatVec3.h" + #include "SIMPLib/SIMPLib.h" /** @@ -74,8 +76,8 @@ class SIMPLib_EXPORT FloatVec3FilterParameter : public FilterParameter SIMPL_STATIC_NEW_MACRO(FloatVec3FilterParameter) SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FloatVec3FilterParameter, FilterParameter) - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; /** * @brief New This function instantiates an instance of the FloatVec3FilterParameter. Although this function is available to be used, @@ -93,9 +95,8 @@ class SIMPLib_EXPORT FloatVec3FilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const FloatVec3_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); + static Pointer New(const QString& humanLabel, const QString& propertyName, const FloatVec3Type& defaultValue, Category category, SetterCallbackType setterCallback, + GetterCallbackType getterCallback, int groupIndex = -1); ~FloatVec3FilterParameter() override; @@ -146,3 +147,4 @@ class SIMPLib_EXPORT FloatVec3FilterParameter : public FilterParameter FloatVec3FilterParameter& operator=(FloatVec3FilterParameter&&) = delete; // Move Assignment Not Implemented }; +Q_DECLARE_METATYPE(FloatVec3Type) diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp index 9c69adf303..a648ec8499 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp @@ -52,6 +52,7 @@ #include "SIMPLib/FilterParameters/H5FilterParametersConstants.h" #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" #include "SIMPLib/FilterParameters/JsonFilterParametersWriter.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" // ----------------------------------------------------------------------------- // @@ -145,8 +146,7 @@ FilterPipeline::Pointer H5FilterParametersReader::readPipelineFromFile(hid_t fid else if(nullptr != obs) { QString ss = QObject::tr("The input file contains an unrecognizable pipeline version number, and is therefore incompatible and cannot be read."); - PipelineMessage pm("", ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("H5FilterParametersReader::ReadPipelineFromFile(...)"); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg("H5FilterParametersReader::ReadPipelineFromFile(...)").arg(ss), -66066); obs->processPipelineMessage(pm); return FilterPipeline::NullPointer(); } @@ -254,8 +254,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o else if(nullptr != obs) { QString ss = QObject::tr("The input file contains an unrecognizable pipeline version number, and is therefore incompatible and cannot be read."); - PipelineMessage pm("", ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("H5FilterParametersReader::ReadPipelineFromFile(...)"); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg("H5FilterParametersReader::ReadPipelineFromFile(...)").arg(ss), -66066); obs->processPipelineMessage(pm); return QString(); } @@ -782,10 +781,10 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector< // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntVec3_t H5FilterParametersReader::readIntVec3(const QString name, IntVec3_t defaultValue) +IntVec3Type H5FilterParametersReader::readIntVec3(const QString name, IntVec3Type defaultValue) { int err = 0; - IntVec3_t v; + IntVec3Type v; err = QH5Lite::readPointerDataset(m_CurrentGroupId, name, reinterpret_cast(&v)); if(err < 0) { @@ -798,10 +797,10 @@ IntVec3_t H5FilterParametersReader::readIntVec3(const QString name, IntVec3_t de // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec3_t H5FilterParametersReader::readFloatVec3(const QString name, FloatVec3_t defaultValue) +FloatVec3Type H5FilterParametersReader::readFloatVec3(const QString name, FloatVec3Type defaultValue) { int err = 0; - FloatVec3_t v; + FloatVec3Type v; err = QH5Lite::readPointerDataset(m_CurrentGroupId, name, reinterpret_cast(&v)); if(err < 0) { diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h index e312379281..a435a389a0 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h @@ -127,8 +127,8 @@ class SIMPLib_EXPORT H5FilterParametersReader : public AbstractFilterParametersR QVector readArray(const QString name, QVector value) override; QVector readArray(const QString name, QVector value) override; - IntVec3_t readIntVec3(const QString name, IntVec3_t v) override; - FloatVec3_t readFloatVec3(const QString name, FloatVec3_t v) override; + IntVec3Type readIntVec3(const QString name, IntVec3Type v) override; + FloatVec3Type readFloatVec3(const QString name, FloatVec3Type v) override; Float2ndOrderPoly_t readFloat2ndOrderPoly(const QString name, Float2ndOrderPoly_t v) override; Float3rdOrderPoly_t readFloat3rdOrderPoly(const QString name, Float3rdOrderPoly_t v) override; diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp index ff813536f2..943ec7b6d1 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp @@ -47,6 +47,8 @@ #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/H5FilterParametersConstants.h" #include "SIMPLib/FilterParameters/JsonFilterParametersWriter.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" +#include "SIMPLib/Messages/GenericErrorMessage.h" #include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- @@ -76,7 +78,7 @@ int H5FilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeli { if(!obs.empty()) { - PipelineMessage pm(JsonFilterParametersWriter::ClassName(), "FilterPipeline Object was nullptr for writing", -1, PipelineMessage::MessageType::Error); + GenericErrorMessage::Pointer pm = GenericErrorMessage::New(QObject::tr("%1: %2").arg(JsonFilterParametersWriter::ClassName()).arg("FilterPipeline Object was nullptr for writing"), -1); for (int i = 0; i < obs.size(); i++) { @@ -106,7 +108,8 @@ int H5FilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeli { if(!obs.empty()) { - PipelineMessage pm(JsonFilterParametersWriter::ClassName(), "Output .dream3d file could not be created.", -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = + PipelineErrorMessage::New(pipeline->getName(), QObject::tr("%1: %2").arg(JsonFilterParametersWriter::ClassName()).arg("Output .dream3d file could not be created."), -1); for (int i = 0; i < obs.size(); i++) { @@ -474,7 +477,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, QVector va // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, IntVec3_t v) +int H5FilterParametersWriter::writeValue(const QString& name, IntVec3Type v) { int err = 0; int32_t rank = 1; @@ -486,7 +489,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, IntVec3_t v) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, FloatVec3_t v) +int H5FilterParametersWriter::writeValue(const QString& name, FloatVec3Type v) { int err = 0; int32_t rank = 1; diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h index d0e8926691..580e11fd33 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h @@ -104,8 +104,8 @@ class SIMPLib_EXPORT H5FilterParametersWriter : public AbstractFilterParametersW int writeValue(const QString& name, QVector value) override; int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, IntVec3_t v) override; - int writeValue(const QString& name, FloatVec3_t v) override; + int writeValue(const QString& name, IntVec3Type v) override; + int writeValue(const QString& name, FloatVec3Type v) override; int writeValue(const QString& name, Float2ndOrderPoly_t v) override; int writeValue(const QString& name, Float3rdOrderPoly_t v) override; @@ -133,7 +133,7 @@ class SIMPLib_EXPORT H5FilterParametersWriter : public AbstractFilterParametersW int writeValue(const QString& name, AxisAngleInput_t v, int notUsed) override; private: - hid_t m_CurrentGroupId; + hid_t m_CurrentGroupId = -1; public: H5FilterParametersWriter(const H5FilterParametersWriter&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp index 8bbda60e11..7246caffe7 100644 --- a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp @@ -48,8 +48,8 @@ IntVec3FilterParameter::~IntVec3FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntVec3FilterParameter::Pointer IntVec3FilterParameter::New(const QString& humanLabel, const QString& propertyName, const IntVec3_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +IntVec3FilterParameter::Pointer IntVec3FilterParameter::New(const QString& humanLabel, const QString& propertyName, const IntVec3Type& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { IntVec3FilterParameter::Pointer ptr = IntVec3FilterParameter::New(); @@ -77,14 +77,19 @@ QString IntVec3FilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IntVec3FilterParameter::readJson(const QJsonObject& json) +void IntVec3FilterParameter::readJson(const QJsonObject& obj) { - QJsonValue jsonValue = json[getPropertyName()]; + QJsonValue jsonValue = obj[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) { - QJsonObject obj = jsonValue.toObject(); - IntVec3_t intVec3; - intVec3.readJson(obj); + QJsonObject json = jsonValue.toObject(); + IntVec3Type intVec3; + if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) + { + intVec3[0] = json["x"].toInt(); + intVec3[1] = json["y"].toInt(); + intVec3[2] = json["z"].toInt(); + } m_SetterCallback(intVec3); } } @@ -92,13 +97,15 @@ void IntVec3FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IntVec3FilterParameter::writeJson(QJsonObject& json) +void IntVec3FilterParameter::writeJson(QJsonObject& obj) { if (m_GetterCallback) { - IntVec3_t intVec3 = m_GetterCallback(); - QJsonObject obj; - intVec3.writeJson(obj); - json[getPropertyName()] = obj; + IntVec3Type intVec3 = m_GetterCallback(); + QJsonObject json; + json["x"] = intVec3.getX(); + json["y"] = intVec3.getY(); + json["z"] = intVec3.getZ(); + obj[getPropertyName()] = json; } } diff --git a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h index b73828c2cc..3b82413057 100755 --- a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h @@ -35,10 +35,12 @@ #pragma once +#include + #include +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/FilterParameters/IntVec3.h" /** * @brief SIMPL_NEW_INT_VEC3_FP This macro is a short-form way of instantiating an instance of @@ -68,8 +70,8 @@ class SIMPLib_EXPORT IntVec3FilterParameter : public FilterParameter SIMPL_STATIC_NEW_MACRO(IntVec3FilterParameter) SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IntVec3FilterParameter, FilterParameter) - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; /** * @brief New This function instantiates an instance of the IntVec3FilterParameter. Although this function is available to be used, @@ -87,9 +89,8 @@ class SIMPLib_EXPORT IntVec3FilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const IntVec3_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); + static Pointer New(const QString& humanLabel, const QString& propertyName, const IntVec3Type& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); ~IntVec3FilterParameter() override; @@ -140,3 +141,4 @@ class SIMPLib_EXPORT IntVec3FilterParameter : public FilterParameter IntVec3FilterParameter& operator=(IntVec3FilterParameter&&) = delete; // Move Assignment Not Implemented }; +Q_DECLARE_METATYPE(IntVec3Type) diff --git a/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp b/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp index 21a485610c..a9f4678cd9 100644 --- a/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp +++ b/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "JsonFilterParametersReader.h" #include @@ -45,6 +45,7 @@ #include "SIMPLib/CoreFilters/EmptyFilter.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" #include "SIMPLib/Utilities/StringOperations.h" // ----------------------------------------------------------------------------- @@ -176,7 +177,7 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipelineFromFile(QString currentLine++; } - PipelineMessage pm(JsonFilterParametersReader::ClassName(), msg, -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg(JsonFilterParametersReader::ClassName()).arg(msg), -1); obs->processPipelineMessage(pm); } return FilterPipeline::NullPointer(); @@ -223,7 +224,7 @@ QString JsonFilterParametersReader::getJsonFromFile(QString filePath, IObserver* { QString msg = createErrorMessageFromJsonParseError(parseError); msg = QString("File '%1' had errors while parsing the json data.%2").arg(filePath) + msg; - PipelineMessage pm(JsonFilterParametersReader::ClassName(), msg, -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg(JsonFilterParametersReader::ClassName()).arg(msg), -1); obs->processPipelineMessage(pm); } return QString(); @@ -402,13 +403,13 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) { return FilterPipeline::NullPointer(); } - + QJsonObject builderObj = m_Root[SIMPL::Settings::PipelineBuilderGroup].toObject(); int filterCount = builderObj[SIMPL::Settings::NumFilters].toInt(); m_MaxFilterIndex = filterCount - 1; // Zero based indexing - + FilterPipeline::Pointer pipeline; - + if(filterCount >= 0) { pipeline = FilterPipeline::New(); @@ -419,11 +420,11 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) { pipeline = FilterPipeline::NullPointer(); } - + for(int i = 0; i < filterCount; ++i) { openFilterGroup(nullptr, i); - + IFilterFactory::Pointer factory = IFilterFactory::NullPointer(); QString filterName = m_CurrentFilterIndex[SIMPL::Settings::FilterName].toString(); bool filterEnabled = m_CurrentFilterIndex[SIMPL::Settings::FilterEnabled].toBool(true); @@ -443,11 +444,11 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) factory = filtManager->getFactoryFromClassName(filterName); } } - + if(nullptr != factory.get()) { AbstractFilter::Pointer filter = factory->create(); - + if(nullptr != filter.get()) { filter->setEnabled(filterEnabled); @@ -456,7 +457,7 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) } } else // Could not find the filter because the specific name has not been registered. This could - // be due to a name change for the filter. + // be due to a name change for the filter. { EmptyFilter::Pointer filter = EmptyFilter::New(); QString humanLabel = QString("UNKNOWN FILTER: ") + filterName; @@ -464,15 +465,16 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) filter->setOriginalFilterName(filterName); filter->setEnabled(filterEnabled); pipeline->pushBack(filter); - + if(nullptr != obs) { QString ss = QObject::tr("An attempt to instantiate a filter from the pipeline file resulted in an error.\ Possible reasons include a name change of the filter, plugin not loading or a simple spelling mistake? A \ blank filter has been inserted in its place. Possible error message is: %1") - .arg(filterName); - PipelineMessage pm(filterName, ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("JsonFilterParametersReader::ReadPipelineFromFile()"); + .arg(filterName); + + QString prefix = "JsonFilterParametersReader::ReadPipelineFromFile()"; + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New(pipeline->getName(), QObject::tr("%1: %2").arg(prefix).arg(ss), -66066); obs->processPipelineMessage(pm); } } @@ -510,7 +512,7 @@ void JsonFilterParametersReader::readNameOfPipelineFromFile(QString filePath, QS { QString msg = createErrorMessageFromJsonParseError(parseError); msg = QString("File '%1' had errors while parsing the json data.%2").arg(fInfo.absoluteFilePath()) + msg; - PipelineMessage pm(JsonFilterParametersReader::ClassName(), msg, -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg(JsonFilterParametersReader::ClassName()).arg(msg), -1); obs->processPipelineMessage(pm); } name = QString("ERROR: Could not open file specified."); @@ -605,7 +607,7 @@ int JsonFilterParametersReader::openFilterGroup(AbstractFilter* unused, int inde Q_ASSERT(m_Root.isEmpty() == false); int err = 0; QString numStr = QString::number(index); - if(m_Root.find(numStr) != m_Root.end() ) + if(m_Root.find(numStr) != m_Root.end()) { m_CurrentFilterIndex = m_Root[numStr].toObject(); } diff --git a/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp b/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp index fd027f0187..7bc1a99409 100644 --- a/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp +++ b/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp @@ -42,6 +42,7 @@ #include "JsonFilterParametersWriter.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" // ----------------------------------------------------------------------------- // @@ -113,7 +114,8 @@ int JsonFilterParametersWriter::populateWriter(FilterPipeline::Pointer pipeline, { if(!obs.empty()) { - PipelineMessage pm(JsonFilterParametersWriter::ClassName(), "FilterPipeline Object was nullptr for writing", -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = + PipelineErrorMessage::New(pipeline->getName(), QObject::tr("%1: FilterPipeline Object was nullptr for writing").arg(JsonFilterParametersWriter::ClassName()), -1); for (int i = 0; i < obs.size(); i++) { diff --git a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp index dc749c9594..f6dfc0d500 100644 --- a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp @@ -34,6 +34,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LinkedDataContainerSelectionFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -48,9 +49,10 @@ LinkedDataContainerSelectionFilterParameter::~LinkedDataContainerSelectionFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -LinkedDataContainerSelectionFilterParameter::Pointer LinkedDataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const RequirementType req, QStringList linkedProperties, - int groupIndex) +LinkedDataContainerSelectionFilterParameter::Pointer LinkedDataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, + Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, + const QStringList& linkedProperties, int groupIndex) { LinkedDataContainerSelectionFilterParameter::Pointer ptr = LinkedDataContainerSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -84,7 +86,18 @@ void LinkedDataContainerSelectionFilterParameter::readJson(const QJsonObject& js QJsonValue jsonValue = json[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) { - m_SetterCallback(jsonValue.toString("")); + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + m_SetterCallback(dap); + } } } @@ -95,6 +108,25 @@ void LinkedDataContainerSelectionFilterParameter::writeJson(QJsonObject& json) { if(m_GetterCallback) { - json[getPropertyName()] = m_GetterCallback(); + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void LinkedDataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + { + m_SetterCallback(newPath); + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } diff --git a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h index 566619b303..9a96e89c6e 100644 --- a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h @@ -40,6 +40,8 @@ #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + // FP: Documentation incomplete because there isn't currently a way to instantiate this filter parameter // in one line. /** @@ -64,13 +66,13 @@ class SIMPLib_EXPORT LinkedDataContainerSelectionFilterParameter : public Filter SIMPL_STATIC_NEW_MACRO(LinkedDataContainerSelectionFilterParameter) SIMPL_TYPE_MACRO_SUPER_OVERRIDE(LinkedDataContainerSelectionFilterParameter, FilterParameter) - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - } RequirementType; + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + using RequirementType = struct + { + IGeometry::Types dcGeometryTypes; + }; /** * @brief New This function instantiates an instance of the LinkedDataContainerSelectionFilterParameter. This function must be used to instantiate the class; the @@ -90,62 +92,63 @@ class SIMPLib_EXPORT LinkedDataContainerSelectionFilterParameter : public Filter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, QStringList linkedProperties, - int groupIndex = -1); - - ~LinkedDataContainerSelectionFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QStringList, LinkedProperties) - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief LinkedDataContainerSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - LinkedDataContainerSelectionFilterParameter(); - - public: - LinkedDataContainerSelectionFilterParameter(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - LinkedDataContainerSelectionFilterParameter(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - LinkedDataContainerSelectionFilterParameter& operator=(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - LinkedDataContainerSelectionFilterParameter& operator=(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + static Pointer New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, const QStringList& linkedProperties, int groupIndex = -1); + + ~LinkedDataContainerSelectionFilterParameter() override; + + SIMPL_INSTANCE_PROPERTY(QStringList, LinkedProperties) + SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + + protected: + /** + * @brief LinkedDataContainerSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + LinkedDataContainerSelectionFilterParameter(); + + public: + LinkedDataContainerSelectionFilterParameter(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + LinkedDataContainerSelectionFilterParameter(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + LinkedDataContainerSelectionFilterParameter& operator=(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + LinkedDataContainerSelectionFilterParameter& operator=(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp index 4054b0dfb8..8b8b06ba62 100644 --- a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp @@ -208,7 +208,7 @@ void MultiAttributeMatrixSelectionFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiAttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void MultiAttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h index 37e35c041d..b65b0199b7 100644 --- a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h @@ -178,7 +178,7 @@ class SIMPLib_EXPORT MultiAttributeMatrixSelectionFilterParameter : public Filte * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp index d49ee0700e..6ab318a2dd 100644 --- a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp @@ -208,7 +208,7 @@ void MultiDataArraySelectionFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiDataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void MultiDataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h index 25f26dbeba..8d7aa921d0 100755 --- a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h @@ -178,7 +178,7 @@ class SIMPLib_EXPORT MultiDataArraySelectionFilterParameter : public FilterParam * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** diff --git a/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.cpp new file mode 100644 index 0000000000..44f386706b --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.cpp @@ -0,0 +1,229 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "MultiDataContainerSelectionFilterParameter.h" + +#include + +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::MultiDataContainerSelectionFilterParameter() +: m_DefaultNames(QStringList()) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::~MultiDataContainerSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::Pointer MultiDataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QStringList& defaultValue, + Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex) +{ + + MultiDataContainerSelectionFilterParameter::Pointer ptr = MultiDataContainerSelectionFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); + ptr->setCategory(category); + ptr->setDefaultGeometryTypes(req.dcGeometryTypes); + ptr->setDefaultAttributeMatrixTypes(req.amTypes); + ptr->setDefaultAttributeArrayTypes(req.daTypes); + ptr->setDefaultComponentDimensions(req.componentDimensions); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MultiDataContainerSelectionFilterParameter::getWidgetType() const +{ + return QString("MultiDataContainerSelectionWidget"); +} + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::RequirementType MultiDataContainerSelectionFilterParameter::CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, + AttributeMatrix::Category attributeMatrixCategory) +{ + using QVectorOfSizeType = QVector; + MultiDataContainerSelectionFilterParameter::RequirementType req; + AttributeMatrix::Types amTypes; + if (attributeMatrixCategory == AttributeMatrix::Category::Element) + { + amTypes.push_back(AttributeMatrix::Type::Cell); + amTypes.push_back(AttributeMatrix::Type::Face); + amTypes.push_back(AttributeMatrix::Type::Edge); + amTypes.push_back(AttributeMatrix::Type::Vertex); + } + else if (attributeMatrixCategory == AttributeMatrix::Category::Feature) + { + amTypes.push_back(AttributeMatrix::Type::CellFeature); + amTypes.push_back(AttributeMatrix::Type::FaceFeature); + amTypes.push_back(AttributeMatrix::Type::EdgeFeature); + amTypes.push_back(AttributeMatrix::Type::VertexFeature); + } + else if (attributeMatrixCategory == AttributeMatrix::Category::Ensemble) + { + amTypes.push_back(AttributeMatrix::Type::CellEnsemble); + amTypes.push_back(AttributeMatrix::Type::FaceEnsemble); + amTypes.push_back(AttributeMatrix::Type::EdgeEnsemble); + amTypes.push_back(AttributeMatrix::Type::VertexEnsemble); + } + req.amTypes = amTypes; + if (primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) + { + req.daTypes = QVector(1, primitiveType); + } + if (SIMPL::Defaults::AnyComponentSize != allowedCompDim) + { + req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + } + // if(IGeometry::Type::Unknown != geometryType) + // { + // req.dcGeometryTypes = IGeometry::Types(1, geometryType); + // } + return req; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::RequirementType MultiDataContainerSelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, + IGeometry::Type geometryType) +{ + using QVectorOfSizeType = QVector; + MultiDataContainerSelectionFilterParameter::RequirementType req; + if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) + { + req.daTypes = QVector(1, primitiveType); + } + if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) + { + req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + } + if (AttributeMatrix::Type::Any != attributeMatrixType) + { + QVector amTypes(1, attributeMatrixType); + req.amTypes = amTypes; + } + if (IGeometry::Type::Any != geometryType) + { + req.dcGeometryTypes = IGeometry::Types(1, geometryType); + } + return req; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(!jsonValue.isUndefined() && m_SetterCallback) + { + QJsonArray arrayObj = jsonValue.toArray(); + QStringList dcList; + for(const auto& obj : arrayObj) + { + QString dcName = obj.toString(); + dcList.push_back(dcName); + } + + m_SetterCallback(dcList); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::writeJson(QJsonObject& json) +{ + if (m_GetterCallback) + { + QStringList dcList = m_GetterCallback(); + QJsonArray arrayObj; + + for(int i = 0; i < dcList.size(); i++) + { + QString dcName = dcList[i]; + arrayObj.push_back(dcName); + } + + json[getPropertyName()] = arrayObj; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + QStringList dcList = m_GetterCallback(); + int count = dcList.size(); + bool updated = false; + + for(int i = 0; i < count; i++) + { + if(dcList[i] == oldPath.getDataContainerName()) + { + dcList[i] = newPath.getDataContainerName(); + updated = true; + } + } + + m_SetterCallback(dcList); + emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); +} diff --git a/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h new file mode 100644 index 0000000000..09eba5edee --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h @@ -0,0 +1,194 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/Geometry/IGeometry.h" + +/** + * @brief SIMPL_NEW_MCA_SELECTION_FP This macro is a short-form way of instantiating an instance of + * MultiDataContainerSelectionFilterParameter. There are 5 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), RequirementType, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_MCA_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, RequirementType, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): + * MultiDataContainerSelectionFilterParameter::RequirementType req; + * SIMPL_NEW_MCA_SELECTION_FP("Multi Data Container Test", SelectedMultiDataContainers, FilterParameter::Parameter, GenericExample, req, 0); + */ +#define SIMPL_NEW_MDC_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ + SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ + (MultiDataContainerSelectionFilterParameter, __VA_ARGS__)) + +/** + * @brief The MultiDataContainerSelectionFilterParameter class is used by filters to instantiate an MultiDataContainerSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a MultiDataContainerSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT MultiDataContainerSelectionFilterParameter : public FilterParameter +{ + public: + SIMPL_SHARED_POINTERS(MultiDataContainerSelectionFilterParameter) + SIMPL_STATIC_NEW_MACRO(MultiDataContainerSelectionFilterParameter) + SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MultiDataContainerSelectionFilterParameter, FilterParameter) + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + typedef struct + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + QVector daTypes; + QVector> componentDimensions; + } RequirementType; + + /** + * @brief New This function instantiates an instance of the MultiDataContainerSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_MCA_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer New(const QString& humanLabel, const QString& propertyName, const QStringList& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); + + ~MultiDataContainerSelectionFilterParameter() override; + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixCategory + * @return + */ + static RequirementType CreateCategoryRequirement(const QString& primitiveType, + size_t allowedCompDim, + AttributeMatrix::Category attributeMatrixCategory); + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(const QString& primitiveType, + size_t allowedCompDim, + AttributeMatrix::Type attributeMatrixType, + IGeometry::Type geometryType); + + SIMPL_INSTANCE_PROPERTY(QStringList, DefaultNames) + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) override; + + SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) + SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeMatrixTypes) + SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeArrayTypes) + SIMPL_INSTANCE_PROPERTY(QVector< QVector >, DefaultComponentDimensions) + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + + protected: + /** + * @brief MultiDataContainerSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MultiDataContainerSelectionFilterParameter(); + + public: + MultiDataContainerSelectionFilterParameter(const MultiDataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + MultiDataContainerSelectionFilterParameter(MultiDataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + MultiDataContainerSelectionFilterParameter& operator=(const MultiDataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + MultiDataContainerSelectionFilterParameter& operator=(MultiDataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented +}; + diff --git a/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h b/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h index aa93a2263d..d8039debb5 100644 --- a/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h @@ -41,18 +41,18 @@ #include "SIMPLib/Common/Constants.h" /** -* @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of -* NumericTypeFilterParameter. There are 6 required parameters and 1 optional parameter -* that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, -* FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). -* -* Therefore, the macro should be written like this (this is a concrete example): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, -* PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) -* -* Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); -*/ + * @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * NumericTypeFilterParameter. There are 6 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_NUMERICTYPE_FP("HumanLabel", PropertyName, Category, FilterName, + * PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_NUMERICTYPE_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); + */ #define SIMPL_NEW_NUMERICTYPE_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(NumericTypeFilterParameter, __VA_ARGS__)) @@ -72,7 +72,7 @@ class SIMPLib_EXPORT NumericTypeFilterParameter : public FilterParameter /** * @brief New This function instantiates an instance of the NumericTypeFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SHAPETYPE_SELECTION_FP(...) macro at the top of this file. + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_NUMERICTYPE_FP(...) macro at the top of this file. * @param humanLabel The name that the users of DREAM.3D see for this filter parameter * @param propertyName The internal property name for this filter parameter. diff --git a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp index d55da38992..09def6082e 100644 --- a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp @@ -37,6 +37,8 @@ #include +#include "SIMPLib/Filtering/AbstractFilter.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -50,10 +52,10 @@ PhaseTypeSelectionFilterParameter::~PhaseTypeSelectionFilterParameter() = defaul // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PhaseTypeSelectionFilterParameter::Pointer PhaseTypeSelectionFilterParameter::New(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath attributeMatrixDefault, +PhaseTypeSelectionFilterParameter::Pointer PhaseTypeSelectionFilterParameter::New(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath& attributeMatrixDefault, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& PhaseTypesArrayName, const QString& phaseTypeCountProperty, const QString& attributeMatrixProperty, - const QStringList phaseListChoices, int groupIndex) + const QStringList& phaseListChoices, int groupIndex) { PhaseTypeSelectionFilterParameter::Pointer ptr = PhaseTypeSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -115,3 +117,21 @@ void PhaseTypeSelectionFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = jsonArray; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getAttributeMatrixPathProperty())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + var.setValue(path); + filter->setProperty(qPrintable(getAttributeMatrixPathProperty()), var); + emit filter->dataArrayPathUpdated(getAttributeMatrixPathProperty(), renamePath); + } + } +} diff --git a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h index 50f037641f..f768211c8e 100755 --- a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h @@ -88,9 +88,9 @@ class SIMPLib_EXPORT PhaseTypeSelectionFilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath attributeMatrixDefault, Category category, SetterCallbackType setterCallback, + static Pointer New(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath& attributeMatrixDefault, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& PhaseTypesArrayName, const QString& phaseTypeCountProperty, const QString& attributeMatrixProperty, - const QStringList phaseListChoices, int groupIndex = -1); + const QStringList& phaseListChoices, int groupIndex = -1); ~PhaseTypeSelectionFilterParameter() override; @@ -136,6 +136,11 @@ class SIMPLib_EXPORT PhaseTypeSelectionFilterParameter : public FilterParameter */ SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + protected: /** * @brief PhaseTypeSelectionFilterParameter The default constructor. It is protected because this diff --git a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp index e0fdc82174..630dd8c062 100644 --- a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp @@ -74,7 +74,7 @@ QString ReadASCIIDataFilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ReadASCIIDataFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void ReadASCIIDataFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h index 05d63b825d..0609b7c381 100644 --- a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h @@ -57,7 +57,7 @@ class SIMPLib_EXPORT ReadASCIIDataFilterParameter : public FilterParameter * @param filter * @param renamePath */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: ReadASCIIDataFilterParameter(); diff --git a/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h b/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h index b921732f63..319a4c6d26 100644 --- a/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h @@ -41,18 +41,18 @@ #include "SIMPLib/Common/Constants.h" /** -* @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of -* ScalarTypeFilterParameter. There are 6 required parameters and 1 optional parameter -* that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, -* FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). -* -* Therefore, the macro should be written like this (this is a concrete example): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, -* PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) -* -* Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); -*/ + * @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * ScalarTypeFilterParameter. There are 6 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_SCALARTYPE_FP("HumanLabel", PropertyName, Category, FilterName, + * PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_SCALARTYPE_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); + */ #define SIMPL_NEW_SCALARTYPE_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ScalarTypeFilterParameter, __VA_ARGS__)) @@ -72,7 +72,7 @@ class SIMPLib_EXPORT ScalarTypeFilterParameter : public FilterParameter /** * @brief New This function instantiates an instance of the ScalarTypeFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SHAPETYPE_SELECTION_FP(...) macro at the top of this file. + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SCALARTYPE_FP(...) macro at the top of this file. * @param humanLabel The name that the users of DREAM.3D see for this filter parameter * @param propertyName The internal property name for this filter parameter. diff --git a/Source/SIMPLib/FilterParameters/SourceList.cmake b/Source/SIMPLib/FilterParameters/SourceList.cmake index bb43bb5e4d..967a68e7df 100755 --- a/Source/SIMPLib/FilterParameters/SourceList.cmake +++ b/Source/SIMPLib/FilterParameters/SourceList.cmake @@ -39,9 +39,7 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FileListInfoFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatFilterParameter.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec2.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec2FilterParameter.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec3.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec3FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FourthOrderPolynomialFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenerateColorTableFilterParameter.h @@ -52,7 +50,6 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/InputFileFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/InputPathFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntFilterParameter.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec3.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec3FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/JsonFilterParametersReader.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/JsonFilterParametersWriter.h @@ -60,6 +57,7 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedChoicesFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedDataContainerSelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiAttributeMatrixSelectionFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataContainerSelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataArraySelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/NumericTypeFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/OutputFileFilterParameter.h @@ -122,6 +120,7 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedChoicesFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedDataContainerSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiAttributeMatrixSelectionFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataContainerSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataArraySelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/NumericTypeFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/OutputFileFilterParameter.cpp diff --git a/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp b/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp index e10472f37f..0976c91658 100644 --- a/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp +++ b/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp @@ -93,6 +93,7 @@ #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" + class FilterParametersRWTest { public: @@ -104,6 +105,8 @@ class FilterParametersRWTest m_String1 = "This is the FilterParametersRWTest"; m_ArrayPath1 = DataArrayPath("DataContainer", "AttributeMatrix", "DataArray"); + m_Path1 = DataArrayPath("DataContainer Name", "", ""); + m_AxisAngle1.angle = 2.2f; m_AxisAngle1.h = 3.4f; m_AxisAngle1.k = 6.4f; @@ -152,15 +155,15 @@ class FilterParametersRWTest } { - m_FloatVec3_1.x = 3.0f; - m_FloatVec3_1.y = 6.7f; - m_FloatVec3_1.z = 32.42f; + m_FloatVec3_1[0] = 3.0f; + m_FloatVec3_1[1] = 6.7f; + m_FloatVec3_1[2] = 32.42f; } { - m_IntVec3_1.x = 3; - m_IntVec3_1.y = 6; - m_IntVec3_1.z = 32; + m_IntVec3_1[0] = 3; + m_IntVec3_1[1] = 6; + m_IntVec3_1[2] = 32; } { @@ -250,6 +253,11 @@ class FilterParametersRWTest SIMPL_INSTANCE_PROPERTY(QString, String2) Q_PROPERTY(QString String2 READ getString2 WRITE setString2) + SIMPL_INSTANCE_PROPERTY(DataArrayPath, Path1) + Q_PROPERTY(DataArrayPath Path1 READ getPath1 WRITE setPath1) + SIMPL_INSTANCE_PROPERTY(DataArrayPath, Path2) + Q_PROPERTY(DataArrayPath Path2 READ getPath2 WRITE setPath2) + SIMPL_INSTANCE_PROPERTY(DataArrayPath, ArrayPath1) Q_PROPERTY(DataArrayPath ArrayPath1 READ getArrayPath1 WRITE setArrayPath1) SIMPL_INSTANCE_PROPERTY(DataArrayPath, ArrayPath2) @@ -280,15 +288,15 @@ class FilterParametersRWTest SIMPL_INSTANCE_PROPERTY(FileListInfo_t, FileListInfo2) Q_PROPERTY(FileListInfo_t FileListInfo2 READ getFileListInfo2 WRITE setFileListInfo2) - SIMPL_INSTANCE_PROPERTY(IntVec3_t, IntVec3_1) - Q_PROPERTY(IntVec3_t IntVec3_1 READ getIntVec3_1 WRITE setIntVec3_1) - SIMPL_INSTANCE_PROPERTY(IntVec3_t, IntVec3_2) - Q_PROPERTY(IntVec3_t IntVec3_2 READ getIntVec3_2 WRITE setIntVec3_2) + SIMPL_INSTANCE_PROPERTY(IntVec3Type, IntVec3_1) + Q_PROPERTY(IntVec3Type IntVec3_1 READ getIntVec3_1 WRITE setIntVec3_1) + SIMPL_INSTANCE_PROPERTY(IntVec3Type, IntVec3_2) + Q_PROPERTY(IntVec3Type IntVec3_2 READ getIntVec3_2 WRITE setIntVec3_2) - SIMPL_INSTANCE_PROPERTY(FloatVec3_t, FloatVec3_1) - Q_PROPERTY(FloatVec3_t FloatVec3_1 READ getFloatVec3_1 WRITE setFloatVec3_1) - SIMPL_INSTANCE_PROPERTY(FloatVec3_t, FloatVec3_2) - Q_PROPERTY(FloatVec3_t FloatVec3_2 READ getFloatVec3_2 WRITE setFloatVec3_2) + SIMPL_INSTANCE_PROPERTY(FloatVec3Type, FloatVec3_1) + Q_PROPERTY(FloatVec3Type FloatVec3_1 READ getFloatVec3_1 WRITE setFloatVec3_1) + SIMPL_INSTANCE_PROPERTY(FloatVec3Type, FloatVec3_2) + Q_PROPERTY(FloatVec3Type FloatVec3_2 READ getFloatVec3_2 WRITE setFloatVec3_2) SIMPL_INSTANCE_PROPERTY(Float2ndOrderPoly_t, Float2ndOrderPoly_1) Q_PROPERTY(Float2ndOrderPoly_t Float2ndOrderPoly_1 READ getFloat2ndOrderPoly_1 WRITE setFloat2ndOrderPoly_1) @@ -513,13 +521,13 @@ class FilterParametersRWTest { DataContainerCreationFilterParameter::Pointer fp = DataContainerCreationFilterParameter::New( - "Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + "Test", "Path1", getPath1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Path2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Path1)); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_String1, m_String2) + DREAM3D_REQUIRE_EQUAL(m_Path1, m_Path2) m_String2.clear(); } @@ -527,13 +535,13 @@ class FilterParametersRWTest { DataContainerSelectionFilterParameter::RequirementType req; DataContainerSelectionFilterParameter::Pointer fp = DataContainerSelectionFilterParameter::New( - "Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1), req); + "Test", "Path1", getPath1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Path2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Path1), req); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_String1, m_String2) + DREAM3D_REQUIRE_EQUAL(m_Path1, m_Path2) m_String2.clear(); } @@ -603,18 +611,18 @@ class FilterParametersRWTest } { - FloatVec3FilterParameter::Pointer fp = FloatVec3FilterParameter::New("Test", "FloatVec3_1", FloatVec3_t(), FilterParameter::Parameter, + FloatVec3FilterParameter::Pointer fp = FloatVec3FilterParameter::New("Test", "FloatVec3_1", FloatVec3Type(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, FloatVec3_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, FloatVec3_1)); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1.x, m_FloatVec3_2.x) - DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1.y, m_FloatVec3_2.y) - DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1.z, m_FloatVec3_2.z) + DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1[0], m_FloatVec3_2[0]) + DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1[1], m_FloatVec3_2[1]) + DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1[2], m_FloatVec3_2[2]) - m_FloatVec3_2 = FloatVec3_t(); + m_FloatVec3_2 = FloatVec3Type(); } { @@ -685,18 +693,18 @@ class FilterParametersRWTest } { - IntVec3FilterParameter::Pointer fp = IntVec3FilterParameter::New("Test", "IntVec3_1", IntVec3_t(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, IntVec3_2), + IntVec3FilterParameter::Pointer fp = IntVec3FilterParameter::New("Test", "IntVec3_1", IntVec3Type(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, IntVec3_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, IntVec3_1)); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_IntVec3_1.x, m_IntVec3_2.x) - DREAM3D_REQUIRE_EQUAL(m_IntVec3_1.y, m_IntVec3_2.y) - DREAM3D_REQUIRE_EQUAL(m_IntVec3_1.z, m_IntVec3_2.z) + DREAM3D_REQUIRE_EQUAL(m_IntVec3_1[0], m_IntVec3_2[0]) + DREAM3D_REQUIRE_EQUAL(m_IntVec3_1[1], m_IntVec3_2[1]) + DREAM3D_REQUIRE_EQUAL(m_IntVec3_1[2], m_IntVec3_2[2]) - m_IntVec3_2 = IntVec3_t(); + m_IntVec3_2 = IntVec3Type(); } { @@ -848,8 +856,6 @@ class FilterParametersRWTest ShapeTypeSelectionFilterParameter::New("Test", "String1", shapeData, FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ShapeType::Types), SIMPL_BIND_GETTER(FilterParametersRWTest, this, ShapeType::Types), "String1", ""); - //SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); - QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); diff --git a/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp b/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp index 69669a46e0..a08d2d1338 100644 --- a/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp +++ b/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp @@ -52,7 +52,7 @@ AbstractDecisionFilter::~AbstractDecisionFilter() = default; // ----------------------------------------------------------------------------- void AbstractDecisionFilter::setupFilterParameters() { - // FilterParameterVector parameters; + // FilterParameterVectorType parameters; // setFilterParameters(parameters); } @@ -79,8 +79,8 @@ void AbstractDecisionFilter::initialize() // ----------------------------------------------------------------------------- void AbstractDecisionFilter::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -101,10 +101,10 @@ void AbstractDecisionFilter::preflight() // ----------------------------------------------------------------------------- void AbstractDecisionFilter::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/Filtering/AbstractFilter.cpp b/Source/SIMPLib/Filtering/AbstractFilter.cpp index 862d4de774..eb331a7a67 100644 --- a/Source/SIMPLib/Filtering/AbstractFilter.cpp +++ b/Source/SIMPLib/Filtering/AbstractFilter.cpp @@ -37,24 +37,26 @@ #include -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/IFilterFactory.hpp" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Plugin/PluginManager.h" + + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AbstractFilter::AbstractFilter() -: m_ErrorCondition(0) -, m_WarningCondition(0) -, m_InPreflight(false) +: m_InPreflight(false) , m_Enabled(true) , m_Removing(false) , m_PipelineIndex(0) , m_Cancel(false) - { m_DataContainerArray = DataContainerArray::New(); m_PreviousFilter = NullPointer(); @@ -100,91 +102,27 @@ void AbstractFilter::setCancel(bool value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::renameDataArrayPath(DataArrayPath::RenameType renamePath) +void AbstractFilter::renameDataArrayPath(const DataArrayPath::RenameType& renamePath) { - // Updates any DataArrayPath or proxy property assigned to this filter. - // A signal is emitted if a change was required stating the property name, old path, and new path. - // No additional methods are required aside from a connecting slot in filter parameter widgets to update their UI. - // If all filters stored their data paths as DataArrayPaths instead of QString without delimiters, - // this would handle all required updates. This was moved to FilterParameter::dataArrayRenamed. - // However, moving this to FilterParameter does not update any private properties that do not - // have a FilterParameter assigned. -#if 0 - const QMetaObject* metaobject = metaObject(); - int count = metaobject->propertyCount(); - for(int i = 0; i < count; i++) - { - QMetaProperty metaproperty = metaobject->property(i); - const char* name = metaproperty.name(); - QVariant var = property(name); - if(var.isValid() && var.canConvert()) - { - DataArrayPath path = var.value(); - if(path.updatePath(oldPath, newPath)) - { - //QString ss = QString("Updated property '%1' in %2").arg(name).arg(getHumanLabel()); - //notifyStandardOutputMessage(getHumanLabel(), getPipelineIndex(), ss); - //notifyStatusMessage(getHumanLabel(), ss); - var.setValue(path); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - } - else if(var.isValid() && var.canConvert()) - { - DataContainerArrayProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - else if(var.isValid() && var.canConvert()) - { - DataContainerProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - else if(var.isValid() && var.canConvert()) - { - AttributeMatrixProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - else if(var.isValid() && var.canConvert()) - { - DataArrayProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - } -#endif - // Some filter parameters handle paths as nothing but a QString (i.e. DataContainerSelectionFilterParameter) // This does not store data in a way that represents what is stored or in a consistent manner with anything else. // Because this format cannot be quieried nicely like the above code, filter parameters have to be able to update // their own paths in these cases. In cases where private properties need to be updated but do not have // assigned filter parameters, although this should not be the case, this code, unlike the above snippet, will not update them. - FilterParameterVector filterParams = getFilterParameters(); - for(FilterParameter::Pointer filterParam : filterParams) + FilterParameterVectorType filterParams = getFilterParameters(); + for(FilterParameter::Pointer& filterParam : filterParams) { filterParam->dataArrayPathRenamed(this, renamePath); } -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void AbstractFilter::renameDataArrayPaths(DataArrayPath::RenameContainer renamedPaths) -{ - for(DataArrayPath::RenameType rename : renamedPaths) + // Update created paths + for(const auto& createdPathItem : m_CreatedPaths) { - renameDataArrayPath(rename); + DataArrayPath createdPath = createdPathItem.second; + if(createdPath.updatePath(renamePath)) + { + m_CreatedPaths[createdPathItem.first] = createdPath; + } } } @@ -200,8 +138,7 @@ void AbstractFilter::setupFilterParameters() // ----------------------------------------------------------------------------- void AbstractFilter::execute() { - setErrorCondition(-3015); - notifyErrorMessage(getNameOfClass(), "QAbstractFilter does not implement an execute method. Please use a subclass instead.", getErrorCondition()); + setErrorCondition(-3015, "QAbstractFilter does not implement an execute method. Please use a subclass instead."); } // ----------------------------------------------------------------------------- @@ -210,8 +147,7 @@ void AbstractFilter::execute() void AbstractFilter::preflight() { setInPreflight(true); - setErrorCondition(-3016); - notifyErrorMessage(getNameOfClass(), "AbstractFilter does not implement a preflight method. Please use a subclass instead.", getErrorCondition()); + setErrorCondition(-3016, "AbstractFilter does not implement a preflight method. Please use a subclass instead."); } // ----------------------------------------------------------------------------- @@ -261,7 +197,7 @@ void insertAttributeMatrixPaths(DataContainer::Pointer dc, AttributeMatrix::Poin { paths.push_back(DataArrayPath(dc->getName(), am->getName(), "")); // Insert all DataArrayPaths - for(QString daName : am->getAttributeArrayNames()) + for(const QString& daName : am->getAttributeArrayNames()) { DataArrayPath daPath(dc->getName(), am->getName(), daName); paths.push_back(daPath); @@ -271,11 +207,11 @@ void insertAttributeMatrixPaths(DataContainer::Pointer dc, AttributeMatrix::Poin // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void insertDataContainerPaths(DataContainer::Pointer dc, std::list& paths) +void insertDataContainerPaths(const DataContainer::Pointer& dc, std::list& paths) { - paths.push_back(DataArrayPath(dc->getName(), "", "")); + paths.emplace_back(DataArrayPath(dc->getName(), "", "")); // Insert all AttributeMatrix paths - for(AttributeMatrix::Pointer am : dc->getAttributeMatrices()) + for(const AttributeMatrix::Pointer& am : dc->getAttributeMatrices()) { insertAttributeMatrixPaths(dc, am, paths); } @@ -300,7 +236,7 @@ std::list AbstractFilter::getCreatedPaths() DataContainerArray::Pointer dca = getDataContainerArray(); // Check DataContainers - for(DataContainer::Pointer dc : dca->getDataContainers()) + for(const DataContainer::Pointer& dc : dca->getDataContainers()) { if(!prevDca->doesDataContainerExist(dc->getName())) { @@ -309,7 +245,7 @@ std::list AbstractFilter::getCreatedPaths() else { // Check AttributeMatrices - for(AttributeMatrix::Pointer am : dc->getAttributeMatrices()) + for(const AttributeMatrix::Pointer& am : dc->getAttributeMatrices()) { DataArrayPath amPath(dc->getName(), am->getName(), ""); if(!prevDca->doesAttributeMatrixExist(amPath)) @@ -319,7 +255,7 @@ std::list AbstractFilter::getCreatedPaths() else { // Check DataArrays - for(QString daName : am->getAttributeArrayNames()) + for(const QString& daName : am->getAttributeArrayNames()) { DataArrayPath daPath(dc->getName(), am->getName(), daName); if(!prevDca->doesAttributeArrayExist(daPath)) @@ -340,7 +276,7 @@ std::list AbstractFilter::getCreatedPaths() if(dca) { // Add all paths if there is no previous filter to compare to - for(DataContainer::Pointer dc : dca->getDataContainers()) + for(const DataContainer::Pointer& dc : dca->getDataContainers()) { insertDataContainerPaths(dc, createdPaths); } @@ -350,14 +286,21 @@ std::list AbstractFilter::getCreatedPaths() return createdPaths; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list AbstractFilter::getDeletedPaths() +{ + return std::list(); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- DataArrayPath::RenameContainer AbstractFilter::getRenamedPaths() { // Implemented in filters that rename existing paths - DataArrayPath::RenameContainer container; - return container; + return m_RenamedPaths; } // ----------------------------------------------------------------------------- @@ -375,10 +318,9 @@ void AbstractFilter::readFilterParameters(AbstractFilterParametersReader* reader // ----------------------------------------------------------------------------- void AbstractFilter::readFilterParameters(QJsonObject& obj) { - QVector filterParameters = getFilterParameters(); - for(int i = 0; i < filterParameters.size(); i++) + FilterParameterVectorType filterParameters = getFilterParameters(); + for(auto const& fp : filterParameters) { - FilterParameter::Pointer fp = filterParameters[i]; fp->readJson(obj); } } @@ -397,8 +339,8 @@ void AbstractFilter::preWriteFilterParameters(QJsonObject& obj, QJsonObject& roo // ----------------------------------------------------------------------------- void AbstractFilter::writeFilterParameters(QJsonObject& obj) const { - QVector filterParameters = getFilterParameters(); - for(auto const fp : filterParameters) + FilterParameterVectorType filterParameters = getFilterParameters(); + for(auto const& fp : filterParameters) { fp->writeJson(obj); } @@ -590,65 +532,55 @@ void AbstractFilter::cleanupFilter() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyErrorMessage(const QString& humanLabel, const QString& str, int code) +void AbstractFilter::setErrorCondition(int code, const QString &messageText) { - PipelineMessage pm = PipelineMessage::CreateErrorMessage(getNameOfClass(), humanLabel, str, code); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_ErrorCode = code; + FilterErrorMessage::Pointer pm = FilterErrorMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText, code); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyStatusMessage(const QString& humanLabel, const QString& str) +void AbstractFilter::notifyStatusMessage(const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + FilterStatusMessage::Pointer pm = FilterStatusMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& str) +void AbstractFilter::setWarningCondition(int code, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_WarningCode = code; + FilterWarningMessage::Pointer pm = FilterWarningMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText, code); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& str) +void AbstractFilter::notifyProgressMessage(int progress, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStandardOutputMessage(humanLabel, pipelineIndex, str); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + FilterProgressMessage::Pointer pm = FilterProgressMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText, progress); + emit messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyWarningMessage(const QString& humanLabel, const QString& str, int code) +void AbstractFilter::clearErrorCode() { - PipelineMessage pm = PipelineMessage::CreateWarningMessage(getNameOfClass(), humanLabel, str, code); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_ErrorCode = 0; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress) +void AbstractFilter::clearWarningCode() { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - pm.setProgressValue(progress); - pm.setType(PipelineMessage::MessageType::StatusMessageAndProgressValue); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_WarningCode = 0; } // ----------------------------------------------------------------------------- @@ -662,6 +594,45 @@ void AbstractFilter::notifyMissingProperty(FilterParameter* filterParameter) .arg(filterParameter->getPropertyName()) .arg(getHumanLabel()); - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool AbstractFilter::checkIfPathRenamed(const RenameDataPath::DataID_t id, const DataArrayPath& path) +{ + if(id == RenameDataPath::k_Invalid_ID) + { + return false; + } + else if(m_CreatedPaths.find(id) == m_CreatedPaths.end()) + { + m_CreatedPaths[id] = path; + return false; + } + else if(m_CreatedPaths[id] == path) + { + return false; + } + + m_RenamedPaths.push_back(std::make_pair(m_CreatedPaths[id], path)); + m_CreatedPaths[id] = path; + return true; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractFilter::clearRenamedPaths() +{ + m_RenamedPaths.clear(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractFilter::addPathRename(const DataArrayPath& oldPath, const DataArrayPath& newPath) +{ + m_RenamedPaths.push_back(std::make_pair(oldPath, newPath)); } diff --git a/Source/SIMPLib/Filtering/AbstractFilter.h b/Source/SIMPLib/Filtering/AbstractFilter.h index 72470ca614..1b842350f0 100755 --- a/Source/SIMPLib/Filtering/AbstractFilter.h +++ b/Source/SIMPLib/Filtering/AbstractFilter.h @@ -35,6 +35,8 @@ #pragma once +#include + #include #include #include @@ -43,6 +45,7 @@ #include "SIMPLib/Common/Observable.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/DataContainers/RenameDataPath.h" #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/SIMPLib.h" @@ -84,9 +87,8 @@ class SIMPLib_EXPORT AbstractFilter : public Observable PYB11_PROPERTY(QString CompiledLibraryName READ getCompiledLibraryName) PYB11_PROPERTY(bool Cancel READ getCancel WRITE setCancel) PYB11_PROPERTY(bool Enabled READ getEnabled WRITE setEnabled) - PYB11_PROPERTY(QString MessagePrefix READ getMessagePrefix WRITE setMessagePrefix) - PYB11_PROPERTY(int ErrorCondition READ getErrorCondition WRITE setErrorCondition) - PYB11_PROPERTY(int WarningCondition READ getWarningCondition WRITE setWarningCondition) + PYB11_PROPERTY(int ErrorCode READ getErrorCode) + PYB11_PROPERTY(int WarningCode READ getWarningCode) PYB11_PROPERTY(bool InPreflight READ getInPreflight WRITE setInPreflight) PYB11_PROPERTY(int PipelineIndex READ getPipelineIndex WRITE setPipelineIndex) @@ -94,12 +96,21 @@ class SIMPLib_EXPORT AbstractFilter : public Observable PYB11_METHOD(void execute) PYB11_METHOD(void preflight) PYB11_METHOD(void setDataContainerArray) + PYB11_METHOD(void setErrorCondition ARGS code messageText) + PYB11_METHOD(void setWarningCondition ARGS code messageText) + PYB11_METHOD(void notifyStatusMessage ARGS messageText) + PYB11_METHOD(void notifyProgressMessage ARGS progress messageText) + PYB11_METHOD(void clearErrorCode) + PYB11_METHOD(void clearWarningCode) + // Friend declarations for RenameDataPath so that it can set and check the instance's created data by ID. + friend void RenameDataPath::AlertFilterCreatedPath(AbstractFilter*, RenameDataPath::DataID_t, const DataArrayPath&); + public: SIMPL_SHARED_POINTERS(AbstractFilter) SIMPL_TYPE_MACRO_SUPER_OVERRIDE(AbstractFilter, Observable) SIMPL_STATIC_NEW_MACRO(AbstractFilter) - + ~AbstractFilter() override; /** @@ -237,13 +248,11 @@ class SIMPLib_EXPORT AbstractFilter : public Observable SIMPL_INSTANCE_PROPERTY(DataContainerArray::Pointer, DataContainerArray) - SIMPL_INSTANCE_PROPERTY(QVector, FilterParameters) + SIMPL_INSTANCE_PROPERTY(FilterParameterVectorType, FilterParameters) - SIMPL_INSTANCE_PROPERTY(QString, MessagePrefix) + SIMPL_GET_PROPERTY(int, ErrorCode) - SIMPL_INSTANCE_PROPERTY(int, ErrorCondition) - - SIMPL_INSTANCE_PROPERTY(int, WarningCondition) + SIMPL_GET_PROPERTY(int, WarningCode) SIMPL_INSTANCE_PROPERTY(bool, InPreflight) @@ -269,6 +278,16 @@ class SIMPLib_EXPORT AbstractFilter : public Observable */ SIMPL_INSTANCE_PROPERTY(AbstractFilter::WeakPointer, NextFilter) + /** + * @brief clearErrorCondition + */ + void clearErrorCode(); + + /** + * @brief clearWarningCondition + */ + void clearWarningCode(); + /** * @brief doesPipelineContainFilterBeforeThis * @param name @@ -295,63 +314,43 @@ class SIMPLib_EXPORT AbstractFilter : public Observable std::list getCreatedPaths(); /** - * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @brief Returns the list of deleted data paths. * @return */ - virtual DataArrayPath::RenameContainer getRenamedPaths(); - - // ------------------------------ - // These methods are over ridden from the superclass in order to add the - // pipeline index to the PipelineMessage Object. - // ------------------------------ + virtual std::list getDeletedPaths(); /** - * @brief notifyErrorMessage - * @param humanLabel - * @param ss - * @param code + * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @return */ - void notifyErrorMessage(const QString& humanLabel, const QString& ss, int code) override; + virtual DataArrayPath::RenameContainer getRenamedPaths(); /** - * @brief notifyWarningMessage - * @param humanLabel - * @param ss + * @brief setErrorCondition * @param code + * @param messageText */ - void notifyWarningMessage(const QString& humanLabel, const QString& ss, int code) override; + void setErrorCondition(int code, const QString& messageText) override; /** - * @brief notifyStatusMessage - * @param humanLabel - * @param ss - */ - void notifyStatusMessage(const QString& humanLabel, const QString& ss) override; - - /** - * @brief notifyStandardOutputMessage - * @param humanLabel - * @param pipelineIndex - * @param ss + * @brief setWarningCondition + * @param code + * @param messageText */ - void notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& ss) override; + void setWarningCondition(int code, const QString& messageText) override; /** * @brief notifyStatusMessage - * @param prefix - * @param humanLabel - * @param ss + * @param messageText */ - void notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& ss) override; + void notifyStatusMessage(const QString& messageText) override; /** * @brief notifyProgressMessage - * @param prefix - * @param humanLabel - * @param str * @param progress + * @param messageText */ - void notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress) override; + void notifyProgressMessage(int progress, const QString& messageText); /** * @brief notifyMissingProperty @@ -380,6 +379,11 @@ class SIMPLib_EXPORT AbstractFilter : public Observable */ virtual void copyFilterParameterInstanceVariables(AbstractFilter* filter) const; + /** + * @brief Clears the renamed paths for the filter instance. + */ + void clearRenamedPaths(); + signals: /** * @brief Signal is emitted when filter has completed the execute() method @@ -396,7 +400,7 @@ class SIMPLib_EXPORT AbstractFilter : public Observable * @param propertyName * @param renamePath */ - void dataArrayPathUpdated(QString propertyName, DataArrayPath::RenameType renamePath); + void dataArrayPathUpdated(const QString& propertyName, const DataArrayPath::RenameType& renamePath); public slots: @@ -410,18 +414,40 @@ public slots: * For DataArrayPaths longer than the given path, only the specified values are modified * @param renamePath */ - virtual void renameDataArrayPath(DataArrayPath::RenameType renamePath); + virtual void renameDataArrayPath(const DataArrayPath::RenameType& renamePath); /** * @brief Updates any DataArrayPath properties from the old paths to their corresponding new paths. * For DataArrayPaths longer than the new path, only the values provided by the new path are modified * @param renamedPaths */ - virtual void renameDataArrayPaths(DataArrayPath::RenameContainer renamedPaths); + inline void renameDataArrayPaths(const DataArrayPath::RenameContainer& renamedPaths) + { + for(const DataArrayPath::RenameType& rename : renamedPaths) + { + renameDataArrayPath(rename); + } + } protected: AbstractFilter(); + /** + * @brief Checks if the path matches the one saved with the specified ID. Index 0 is used for + * non-renamable DataArrayPaths, and any DataID 0 value will bypass the check and return false. + * If the path does not match and the ID is already used, return true and update the path. If + * the ID is used and the paths match, return false. If the ID has not been used, add the path + * to the createdPaths map. + */ + bool checkIfPathRenamed(const RenameDataPath::DataID_t id, const DataArrayPath& path); + + /** + * @brief Adds the specified change to the list of renamed DataArrayPaths. + * @param oldPath + * @param newPath + */ + void addPathRename(const DataArrayPath& oldPath, const DataArrayPath& newPath); + protected slots: /** * @brief This function will be called after the pipeline is completely done executing. This can be reimplemented @@ -432,6 +458,11 @@ protected slots: private: bool m_Cancel; QUuid m_Uuid; + int m_ErrorCode = 0; + int m_WarningCode = 0; + + std::map m_CreatedPaths; + DataArrayPath::RenameContainer m_RenamedPaths; public: AbstractFilter(const AbstractFilter&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h b/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h index f77c8ea6e9..2dda50ee42 100644 --- a/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h +++ b/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h @@ -65,7 +65,7 @@ class SIMPLib_EXPORT ComparisonInputsAdvanced : public QObject PYB11_CREATION() PYB11_PROPERTY(QVector Inputs READ getInputs) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(QString AttributeMatrixName READ getAttributeMatrixName WRITE setAttributeMatrixName) PYB11_METHOD(void addInput OVERLOAD int,unionOperator const.QString,arrayName int,compOperator double,compValue) diff --git a/Source/SIMPLib/Filtering/FilterFactory.hpp b/Source/SIMPLib/Filtering/FilterFactory.hpp index 7ebce8bcfe..12be5acc3d 100755 --- a/Source/SIMPLib/Filtering/FilterFactory.hpp +++ b/Source/SIMPLib/Filtering/FilterFactory.hpp @@ -87,7 +87,12 @@ template class FilterFactory : public IFilterFactory { return m_CompiledLibraryName; } - + + QString getFilterHtmlSummary() const override + { + return m_HtmlSummary; + } + QUuid getUuid() const override { return m_Uuid; @@ -104,6 +109,7 @@ template class FilterFactory : public IFilterFactory m_BrandingString = w->getBrandingString(); m_CompiledLibraryName = w->getCompiledLibraryName(); m_Uuid = w->getUuid(); + m_HtmlSummary = w->generateHtmlSummary(); } private: @@ -113,8 +119,12 @@ template class FilterFactory : public IFilterFactory QString m_HumanName; QString m_BrandingString; QString m_CompiledLibraryName; + QString m_HtmlSummary; QUuid m_Uuid; - FilterFactory(const FilterFactory&); // Copy Constructor Not Implemented - void operator=(const FilterFactory&); // Move assignment Not Implemented +public: + FilterFactory(const FilterFactory&) = delete; // Copy Constructor Not Implemented + FilterFactory(FilterFactory&&) = delete; // Move Constructor Not Implemented + FilterFactory& operator=(const FilterFactory&) = delete; // Copy Assignment Not Implemented + FilterFactory& operator=(FilterFactory&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/Filtering/FilterPipeline.cpp b/Source/SIMPLib/Filtering/FilterPipeline.cpp index cd7655a6cf..704e83fae2 100644 --- a/Source/SIMPLib/Filtering/FilterPipeline.cpp +++ b/Source/SIMPLib/Filtering/FilterPipeline.cpp @@ -35,6 +35,15 @@ #include "FilterPipeline.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" +#include "SIMPLib/Messages/PipelineProgressMessage.h" +#include "SIMPLib/Messages/PipelineStatusMessage.h" +#include "SIMPLib/Messages/PipelineWarningMessage.h" #include "SIMPLib/CoreFilters/EmptyFilter.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" @@ -43,12 +52,45 @@ #include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Utilities/StringOperations.h" +#define RENAME_ENABLED 1 + +/** + * @brief This message handler is used by FilterPipeline to re-emit filter progress messages as pipeline progress messages + */ +class FilterPipelineMessageHandler : public AbstractMessageHandler +{ + public: + explicit FilterPipelineMessageHandler(FilterPipeline* pipeline) : m_Pipeline(pipeline) {} + + /** + * @brief Converts filter progress messages into pipeline progress messages. This enables the overall pipeline + * progress to update along with the filter's progress updates + */ + void processMessage(const FilterProgressMessage* msg) const override + { + int filterProgress = msg->getProgressValue(); + float filterProgressStep = (1.0f / m_Pipeline->size()) * filterProgress / 100.0f; + int pipelineProgress = static_cast((static_cast(msg->getPipelineIndex()) / (m_Pipeline->size()) + filterProgressStep) * 100.0f); + m_Pipeline->notifyProgressMessage(pipelineProgress, ""); + } + + private: + FilterPipeline* m_Pipeline = nullptr; +}; + +class PipelineIdleException : public std::exception +{ + const char* what () const noexcept + { + return "A pipeline that was finishing execution was marked as in the idle state."; + } +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- FilterPipeline::FilterPipeline() -: m_ErrorCondition(0) -, m_PipelineName("") +: m_PipelineName("") , m_Dca(nullptr) { } @@ -271,8 +313,8 @@ void FilterPipeline::fromJson(const QJsonObject& json, IObserver* obs) Possible reasons include a name change of the filter, plugin not loading or a simple spelling mistake? A \ blank filter has been inserted in its place. Possible error message is: %1") .arg(filterName); - PipelineMessage pm(filterName, ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("JsonFilterParametersReader::ReadPipelineFromFile()"); + QString prefix = "JsonFilterParametersReader::ReadPipelineFromFile()"; + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New(getName(), ss, -66066); obs->processPipelineMessage(pm); } } @@ -287,10 +329,6 @@ void FilterPipeline::cancel() if(m_State != FilterPipeline::State::Executing) { // We cannot cancel a pipeline that is not executing - setErrorCondition(-201); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss; if(m_State == FilterPipeline::State::Idle) { @@ -304,9 +342,7 @@ void FilterPipeline::cancel() { ss = QObject::tr("Pipeline '%1' could not be canceled.").arg(getName()); } - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-201, ss); return; } @@ -337,14 +373,8 @@ bool FilterPipeline::pushFront(const AbstractFilter::Pointer& f) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to add filters to a pipeline that is not idle - setErrorCondition(-202); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be added to pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-202, ss); return false; } @@ -361,16 +391,10 @@ bool FilterPipeline::popFront() if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-203); - AbstractFilter::Pointer f = m_Pipeline.front(); - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-203, ss); return false; } @@ -387,14 +411,8 @@ bool FilterPipeline::pushBack(const AbstractFilter::Pointer& f) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to add filters to a pipeline that is not idle - setErrorCondition(-204); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be added to pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-204, ss); return false; } @@ -411,16 +429,10 @@ bool FilterPipeline::popBack() if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-205); - AbstractFilter::Pointer f = m_Pipeline.back(); - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-205, ss); return false; } @@ -437,14 +449,8 @@ bool FilterPipeline::insert(size_t index, const AbstractFilter::Pointer& f) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to add filters to a pipeline that is not idle - setErrorCondition(-206); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be added to pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-206, ss); return false; } @@ -466,16 +472,10 @@ bool FilterPipeline::erase(size_t index) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-207); - AbstractFilter::Pointer f = m_Pipeline[index]; - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-207, ss); return false; } @@ -497,14 +497,8 @@ bool FilterPipeline::clear() if(m_State != FilterPipeline::State::Idle) { // We cannot clear a pipeline that is not idle - setErrorCondition(-208); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Pipeline '%1' could not be cleared because it is executing.").arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-208, ss); return false; } @@ -540,14 +534,8 @@ AbstractFilter::Pointer FilterPipeline::removeFirstFilterByName(const QString& n if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-209); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(name).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-209, ss); return AbstractFilter::NullPointer(); } @@ -621,12 +609,66 @@ void FilterPipeline::updatePrevNextFilters() } } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::setErrorCondition(int code, const QString &messageText) +{ + m_ErrorCode = code; + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New(getName(), messageText, code); + emit messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::notifyStatusMessage(const QString& messageText) +{ + PipelineStatusMessage::Pointer pm = PipelineStatusMessage::New(getName(), messageText); + emit messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::setWarningCondition(int code, const QString& messageText) +{ + m_WarningCode = code; + PipelineWarningMessage::Pointer pm = PipelineWarningMessage::New(getName(), messageText, code); + emit messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::notifyProgressMessage(int progress, const QString& messageText) +{ + PipelineProgressMessage::Pointer pm = PipelineProgressMessage::New(getName(), messageText, progress); + emit messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::clearErrorCode() +{ + m_ErrorCode = 0; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::clearWarningCode() +{ + m_WarningCode = 0; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FilterPipeline::addMessageReceiver(QObject* obj) { - connect(this, SIGNAL(pipelineGeneratedMessage(const PipelineMessage&)), obj, SLOT(processPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), obj, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); m_MessageReceivers.push_back(obj); } @@ -635,30 +677,37 @@ void FilterPipeline::addMessageReceiver(QObject* obj) // ----------------------------------------------------------------------------- void FilterPipeline::removeMessageReceiver(QObject* obj) { - disconnect(this, SIGNAL(pipelineGeneratedMessage(const PipelineMessage&)), obj, SLOT(processPipelineMessage(const PipelineMessage&))); + disconnect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), obj, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); m_MessageReceivers.removeAll(obj); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterPipeline::connectFilterNotifications(QObject* filter) +void FilterPipeline::connectFilterNotifications(AbstractFilter* filter) { for(const auto& messageReceiver : m_MessageReceivers) { - connect(filter, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), messageReceiver, SLOT(processPipelineMessage(const PipelineMessage&))); + connect(filter, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), messageReceiver, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); } + + connect(filter, &AbstractFilter::messageGenerated, [=] (AbstractMessage::Pointer msg) { + FilterPipelineMessageHandler msgHandler(this); + msg->visit(&msgHandler); + }); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterPipeline::disconnectFilterNotifications(QObject* filter) +void FilterPipeline::disconnectFilterNotifications(AbstractFilter* filter) { for(const auto& messageReceiver : m_MessageReceivers) { - disconnect(filter, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), messageReceiver, SLOT(processPipelineMessage(const PipelineMessage&))); + disconnect(filter, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), messageReceiver, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); } + + disconnect(filter, &AbstractFilter::messageGenerated, 0, 0); } // ----------------------------------------------------------------------------- @@ -669,96 +718,78 @@ int FilterPipeline::preflightPipeline() if(m_State != FilterPipeline::State::Idle) { // We cannot preflight a pipeline that is not idle - setErrorCondition(-203); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Pipeline '%1' could not be preflighted because it is already executing.").arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); - return getErrorCondition(); + int err = -203; + setErrorCondition(err, ss); + return err; } // Create the DataContainer object DataContainerArray::Pointer dca = DataContainerArray::New(); - setErrorCondition(0); + clearErrorCode(); int preflightError = 0; DataArrayPath::RenameContainer renamedPaths; - DataArrayPath::RenameContainer filterRenamedPaths; // Start looping through each filter in the Pipeline and preflight everything - // for(FilterContainerType::iterator filter = m_Pipeline.begin(); filter != m_Pipeline.end(); ++filter) for(const auto& filter : m_Pipeline) { // Do not preflight disabled filters if(filter->getEnabled()) { - // Update renamed paths before getting old created paths - DataContainerArray::Pointer oldDca = filter->getDataContainerArray(); - oldDca->renameDataArrayPaths(filterRenamedPaths); - filter->setDataContainerArray(oldDca); - filter->renameDataArrayPaths(filterRenamedPaths); - - std::list oldCreatedPaths = filter->getCreatedPaths(); - filter->setDataContainerArray(dca); +#if RENAME_ENABLED filter->renameDataArrayPaths(renamedPaths); +#endif setCurrentFilter(filter); connectFilterNotifications(filter.get()); + filter->clearRenamedPaths(); filter->preflight(); disconnectFilterNotifications(filter.get()); filter->setCancel(false); // Reset the cancel flag - preflightError |= filter->getErrorCondition(); + preflightError |= filter->getErrorCode(); filter->setDataContainerArray(dca->deepCopy(false)); - std::list currentCreatedPaths = filter->getCreatedPaths(); +#if RENAME_ENABLED + const std::list deletedPaths = filter->getDeletedPaths(); - // Check if an existing renamed path was created by this filter - for(const DataArrayPath& createdPath : currentCreatedPaths) + // Check if an existing renamed path was deleted by this filter + for(const DataArrayPath& deletedPath : deletedPaths) { - // Filter Parameter changes for(const DataArrayPath::RenameType& rename : renamedPaths) { - DataArrayPath originalPath; - DataArrayPath renamePath; - std::tie(originalPath, renamePath) = rename; - if(originalPath == createdPath) + const DataArrayPath& originalPath = std::get<0>(rename); + // const DataArrayPath& renamePath = std::get<1>(rename); + if(originalPath == deletedPath) { - renamedPaths.remove(rename); + const auto iter = std::find(renamedPaths.begin(), renamedPaths.end(), rename); + renamedPaths.erase(iter); break; } } - // Rename Filters - for(const DataArrayPath::RenameType& rename : filterRenamedPaths) + } + // Filter renamed existing DataArrayPaths + const DataArrayPath::RenameContainer newRenamePaths = filter->getRenamedPaths(); + for(const DataArrayPath::RenameType& newRename : newRenamePaths) + { + // Loop through all existing rename paths and update as appropriate + for(auto iter = renamedPaths.cbegin(); iter != renamedPaths.cend(); ++iter) { - DataArrayPath originalPath; - DataArrayPath renamePath; - std::tie(originalPath, renamePath) = rename; - if(originalPath == createdPath) + const auto& existingRename = (*iter); + const auto updatedRenameOpt = DataArrayPath::CreateLinkingRename(existingRename, newRename); + if(true == updatedRenameOpt.first) { - filterRenamedPaths.remove(rename); - break; + // Remove the old rename, insert the updated one, and update the iterator + renamedPaths.insert(iter, updatedRenameOpt.second); } } + // Add the new rename path + renamedPaths.push_back(newRename); } - - DataArrayPath::RenameContainer newRenamedPaths = DataArrayPath::CheckForRenamedPaths(oldDca, dca, oldCreatedPaths, currentCreatedPaths); - for(const DataArrayPath::RenameType& renameType : newRenamedPaths) - { - renamedPaths.push_back(renameType); - } - - // Filter renamed existing DataArrayPaths - DataArrayPath::RenameContainer hardRenamePaths = filter->getRenamedPaths(); - for(const DataArrayPath::RenameType& renameType : hardRenamePaths) - { - renamedPaths.push_back(renameType); - filterRenamedPaths.push_back(renameType); - } +#endif } +#if RENAME_ENABLED else { // Some widgets require the updated path to be valid before it can be set in the widget @@ -766,17 +797,16 @@ int FilterPipeline::preflightPipeline() filter->renameDataArrayPaths(renamedPaths); // Undo filter renaming - DataArrayPath::RenameContainer filterRenamedPaths = filter->getRenamedPaths(); - for(DataArrayPath::RenameType renameType : filterRenamedPaths) + const DataArrayPath::RenameContainer filterRenamedPaths = filter->getRenamedPaths(); + for(const DataArrayPath::RenameType& renameType : filterRenamedPaths) { - DataArrayPath oldPath; - DataArrayPath newPath; - std::tie(oldPath, newPath) = renameType; - renameType = std::make_pair(newPath, oldPath); + const DataArrayPath& oldPath = std::get<0>(renameType); + const DataArrayPath& newPath = std::get<1>(renameType); - renamedPaths.push_back(renameType); + renamedPaths.push_back(std::make_pair(newPath, oldPath)); } } +#endif } setCurrentFilter(AbstractFilter::NullPointer()); @@ -787,18 +817,20 @@ int FilterPipeline::preflightPipeline() // // ----------------------------------------------------------------------------- DataContainerArray::Pointer FilterPipeline::execute() +{ + return execute(DataContainerArray::New()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerArray::Pointer FilterPipeline::execute(DataContainerArray::Pointer dca) { if(m_State != FilterPipeline::State::Idle) { // We cannot execute a pipeline that is not idle - setErrorCondition(-200); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Pipeline '%1' could not be executed because it is already executing.").arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-200, ss); disconnectSignalsSlots(); return DataContainerArray::NullPointer(); @@ -812,49 +844,35 @@ DataContainerArray::Pointer FilterPipeline::execute() m_State = FilterPipeline::State::Executing; - m_Dca = DataContainerArray::New(); + m_Dca = dca; // Start looping through the Pipeline - float progress = 0.0f; - - PipelineMessage progValue("", "", 0, PipelineMessage::MessageType::ProgressValue, -1); for(const auto& filt : m_Pipeline) { - progress = progress + 1.0f; - progValue.setType(PipelineMessage::MessageType::ProgressValue); - progValue.setProgressValue(static_cast(progress / (m_Pipeline.size() + 1) * 100.0f)); - emit pipelineGeneratedMessage(progValue); + int filtIndex = filt->getPipelineIndex(); + QString ss = QObject::tr("[%1/%2] %3").arg(filtIndex+1).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); + notifyStatusMessage(ss); - QString ss = QObject::tr("[%1/%2] %3 ").arg(progress).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); - - progValue.setType(PipelineMessage::MessageType::StatusMessage); - progValue.setText(ss); - emit pipelineGeneratedMessage(progValue); emit filt->filterInProgress(filt.get()); // Do not execute disabled filters if(filt->getEnabled()) { - filt->setMessagePrefix(ss); +// filt->setMessagePrefix(ss); connectFilterNotifications(filt.get()); filt->setDataContainerArray(m_Dca); setCurrentFilter(filt); filt->execute(); disconnectFilterNotifications(filt.get()); filt->setDataContainerArray(DataContainerArray::NullPointer()); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); if(err < 0) { - setErrorCondition(err); - progValue.setFilterClassName(filt->getNameOfClass()); - progValue.setFilterHumanLabel(filt->getHumanLabel()); - progValue.setType(PipelineMessage::MessageType::Error); - progValue.setProgressValue(100); - ss = QObject::tr("[%1/%2] %3 caused an error during execution.").arg(progress).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); - progValue.setText(ss); - progValue.setPipelineIndex(filt->getPipelineIndex()); - progValue.setCode(filt->getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + ss = QObject::tr("[%1/%2] %3 caused an error during execution.").arg(filtIndex+1).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); + setErrorCondition(err, ss); + + notifyProgressMessage(100, ""); + emit filt->filterCompleted(filt.get()); emit pipelineFinished(); disconnectSignalsSlots(); @@ -873,33 +891,26 @@ DataContainerArray::Pointer FilterPipeline::execute() // Emit that the filter is completed for those objects that care, even the disabled ones. emit filt->filterCompleted(filt.get()); + + notifyProgressMessage(static_cast(static_cast(filtIndex + 1) / (m_Pipeline.size()) * 100.0f), ""); } disconnectSignalsSlots(); - PipelineMessage completeMessage("", "", 0, PipelineMessage::MessageType::StatusMessage, -1); - if(m_State == FilterPipeline::State::Canceling) + switch(m_State) { - completeMessage.setText("Pipeline Canceled"); + case FilterPipeline::State::Canceling: m_ExecutionResult = FilterPipeline::ExecutionResult::Canceled; - } - else if(m_State == FilterPipeline::State::Executing) - { - completeMessage.setText("Pipeline Complete"); + notifyStatusMessage("Pipeline Canceled"); + break; + case FilterPipeline::State::Executing: m_ExecutionResult = FilterPipeline::ExecutionResult::Completed; + notifyStatusMessage("Pipeline Complete"); + break; + case FilterPipeline::State::Idle: + throw PipelineIdleException(); + break; } - else - { - // This should never get here - completeMessage.setText("Unsupported Pipeline Execution Result"); - emit pipelineGeneratedMessage(completeMessage); - - setErrorCondition(-210); - completeMessage.setType(PipelineMessage::MessageType::Error); - completeMessage.setCode(getErrorCondition()); - } - - emit pipelineGeneratedMessage(completeMessage); m_State = FilterPipeline::State::Idle; diff --git a/Source/SIMPLib/Filtering/FilterPipeline.h b/Source/SIMPLib/Filtering/FilterPipeline.h index 9fb402a346..ee5ec97802 100755 --- a/Source/SIMPLib/Filtering/FilterPipeline.h +++ b/Source/SIMPLib/Filtering/FilterPipeline.h @@ -47,6 +47,7 @@ #include "SIMPLib/SIMPLib.h" class IObserver; +class FilterPipelineMessageHandler; /** * @class FilterPipeline FilterPipeline.h DREAM3DLib/Common/FilterPipeline.h @@ -57,12 +58,13 @@ class IObserver; * @date Sep 28, 2011 * @version 1.0 */ -class SIMPLib_EXPORT FilterPipeline : public QObject +class SIMPLib_EXPORT FilterPipeline : public Observable { Q_OBJECT PYB11_CREATE_BINDINGS(FilterPipeline) - PYB11_PROPERTY(int ErrorCondition READ getErrorCondition WRITE setErrorCondition) + PYB11_PROPERTY(int ErrorCode READ getErrorCode) + PYB11_PROPERTY(int WarningCode READ getWarningCode) PYB11_PROPERTY(AbstractFilter CurrentFilter READ getCurrentFilter WRITE setCurrentFilter) PYB11_PROPERTY(State State READ getState) PYB11_PROPERTY(ExecutionResult ExecutionResult READ getExecutionResult) @@ -77,6 +79,8 @@ class SIMPLib_EXPORT FilterPipeline : public QObject PYB11_METHOD(bool clear) PYB11_METHOD(size_t size) PYB11_METHOD(bool empty) + PYB11_METHOD(void clearErrorCode) + PYB11_METHOD(void clearWarningCode) public: SIMPL_SHARED_POINTERS(FilterPipeline) @@ -85,6 +89,8 @@ class SIMPLib_EXPORT FilterPipeline : public QObject ~FilterPipeline() override; + friend FilterPipelineMessageHandler; + enum class State : unsigned int { Idle, @@ -104,7 +110,8 @@ class SIMPLib_EXPORT FilterPipeline : public QObject SIMPL_GET_PROPERTY(FilterPipeline::ExecutionResult, ExecutionResult) SIMPL_GET_PROPERTY(FilterPipeline::State, State) - SIMPL_INSTANCE_PROPERTY(int, ErrorCondition) + SIMPL_GET_PROPERTY(int, ErrorCode) + SIMPL_GET_PROPERTY(int, WarningCode) SIMPL_INSTANCE_PROPERTY(AbstractFilter::Pointer, CurrentFilter) /** @@ -131,6 +138,11 @@ class SIMPLib_EXPORT FilterPipeline : public QObject */ virtual DataContainerArray::Pointer execute(); + /** + * @brief An execute method using an existing data container array + */ + DataContainerArray::Pointer execute(DataContainerArray::Pointer dca); + /** * @brief This will preflight the pipeline and report any errors that would occur during * execution of the pipeline @@ -164,18 +176,55 @@ class SIMPLib_EXPORT FilterPipeline : public QObject /** * @brief This method adds a QObject based class that is capable of being connected with the following signals from * AbstractFilter: - * @li processPipelineMessage(PipelineMessage&) - * @param obj Class that implements needed processPipelineMessage(PipelineMessage&) method + * @li processPipelineMessage(const AbstractMessage::Pointer &) + * @param obj Class that implements needed processPipelineMessage(const AbstractMessage::Pointer &) method */ void addMessageReceiver(QObject* obj); void removeMessageReceiver(QObject* obj); - void connectFilterNotifications(QObject* filter); - void disconnectFilterNotifications(QObject* filter); + void connectFilterNotifications(AbstractFilter* filter); + void disconnectFilterNotifications(AbstractFilter* filter); QString getName(); + /** + * @brief setErrorCondition + * @param code + * @param messageText + */ + void setErrorCondition(int code, const QString& messageText) override; + + /** + * @brief setWarningCondition + * @param code + * @param messageText + */ + void setWarningCondition(int code, const QString& messageText) override; + + /** + * @brief notifyStatusMessage + * @param messageText + */ + void notifyStatusMessage(const QString& messageText) override; + + /** + * @brief notifyProgressMessage + * @param progress + * @param messageText + */ + void notifyProgressMessage(int progress, const QString& messageText); + + /** + * @brief clearErrorCondition + */ + void clearErrorCode(); + + /** + * @brief clearWarningCondition + */ + void clearWarningCode(); + /** * @brief This method returns a deep copy of the FilterPipeline and all its filters * @return @@ -220,7 +269,7 @@ public slots: void updatePrevNextFilters(); signals: - void pipelineGeneratedMessage(const PipelineMessage& message); + void messageGenerated(AbstractMessage::Pointer message); /** * @brief This method is emitted from the pipeline and signals a pipeline pause @@ -261,6 +310,9 @@ public slots: DataContainerArray::Pointer m_Dca; + int m_ErrorCode = 0; + int m_WarningCode = 0; + void connectSignalsSlots(); void disconnectSignalsSlots(); @@ -270,3 +322,4 @@ public slots: FilterPipeline& operator=(const FilterPipeline&) = delete; // Copy Assignment Not Implemented FilterPipeline& operator=(FilterPipeline&&) = delete; // Move Assignment Not Implemented }; +Q_DECLARE_METATYPE(FilterPipeline::Pointer); diff --git a/Source/SIMPLib/Filtering/IFilterFactory.hpp b/Source/SIMPLib/Filtering/IFilterFactory.hpp index 48a073c0ce..601f16d942 100755 --- a/Source/SIMPLib/Filtering/IFilterFactory.hpp +++ b/Source/SIMPLib/Filtering/IFilterFactory.hpp @@ -121,10 +121,20 @@ class IFilterFactory Q_ASSERT(false); return ""; } - + + /** + * @brief getFilterHtmlSummary + * @return + */ + virtual QString getFilterHtmlSummary() const + { + Q_ASSERT(false); + return ""; + } + /** * @brief getUuid - * @return + * @return */ virtual QUuid getUuid() const { @@ -135,8 +145,10 @@ class IFilterFactory protected: IFilterFactory() = default; -private: - IFilterFactory(const IFilterFactory&); // Copy Constructor Not Implemented - void operator=(const IFilterFactory&); // Move assignment Not Implemented +public: + IFilterFactory(const IFilterFactory&) = delete; // Copy Constructor Not Implemented + IFilterFactory(IFilterFactory&&) = delete; // Move Constructor Not Implemented + IFilterFactory& operator=(const IFilterFactory&) = delete; // Copy Assignment Not Implemented + IFilterFactory& operator=(IFilterFactory&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp b/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp index 9f80d454cc..c112de77f5 100644 --- a/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp +++ b/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp @@ -41,10 +41,10 @@ #include #include "SIMPLib/Common/EnsembleInfo.h" -#include "SIMPLib/Common/PipelineMessage.h" #include "SIMPLib/CoreFilters/CreateDataArray.h" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" +#include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/FilterParameters/AxisAngleFilterParameter.h" #include "SIMPLib/FilterParameters/DynamicTableData.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" @@ -55,25 +55,25 @@ #include "SIMPLib/Filtering/ComparisonInputsAdvanced.h" // These Streams need to be implemented so that our 3 Element Vectors can be read/write to disk/prefs files -QDataStream& operator<<(QDataStream& out, const IntVec3_t& v) +QDataStream& operator<<(QDataStream& out, const IntVec3Type& v) { - out << v.x << v.y << v.z; + out << v[0] << v[1] << v[2]; return out; } -QDataStream& operator>>(QDataStream& in, IntVec3_t& v) +QDataStream& operator>>(QDataStream& in, IntVec3Type& v) { - in >> v.x >> v.y >> v.z; + in >> v[0] >> v[1] >> v[2]; return in; } -QDataStream& operator<<(QDataStream& out, const FloatVec3_t& v) +QDataStream& operator<<(QDataStream& out, const FloatVec3Type& v) { - out << v.x << v.y << v.z; + out << v[0] << v[1] << v[2]; return out; } -QDataStream& operator>>(QDataStream& in, FloatVec3_t& v) +QDataStream& operator>>(QDataStream& in, FloatVec3Type& v) { - in >> v.x >> v.y >> v.z; + in >> v[0] >> v[1] >> v[2]; return in; } @@ -145,6 +145,7 @@ QMetaObjectUtilities::~QMetaObjectUtilities() = default; // ----------------------------------------------------------------------------- void QMetaObjectUtilities::RegisterMetaTypes() { + qRegisterMetaType("AbstractMessage::Pointer"); qRegisterMetaType("DataContainerArrayProxy"); qRegisterMetaType("DataArrayPath"); qRegisterMetaType("AxisAngleInput_t"); @@ -152,14 +153,13 @@ void QMetaObjectUtilities::RegisterMetaTypes() qRegisterMetaType("ComparisonInputs"); qRegisterMetaType("ComparisonInputsAdvanced"); qRegisterMetaType("DataContainerArrayProxy"); - qRegisterMetaType("IntVec3_t"); - qRegisterMetaType("FloatVec3_t"); - qRegisterMetaType("PipelineMessage"); + qRegisterMetaType("IntVec3Type"); + qRegisterMetaType("FloatVec3Type"); qRegisterMetaType("FPRangePair"); qRegisterMetaType("DynamicTableData"); qRegisterMetaType("PhaseType::Types"); - qRegisterMetaTypeStreamOperators("IntVec3_t"); - qRegisterMetaTypeStreamOperators("FloatVec3_t"); + qRegisterMetaTypeStreamOperators("IntVec3Type"); + qRegisterMetaTypeStreamOperators("FloatVec3Type"); qRegisterMetaTypeStreamOperators("PhaseType::Types"); qRegisterMetaTypeStreamOperators("EnsembleInfo"); } diff --git a/Source/SIMPLib/Geometry/EdgeGeom.cpp b/Source/SIMPLib/Geometry/EdgeGeom.cpp index e3abe98160..557326a0ca 100644 --- a/Source/SIMPLib/Geometry/EdgeGeom.cpp +++ b/Source/SIMPLib/Geometry/EdgeGeom.cpp @@ -87,7 +87,7 @@ class FindEdgeDerivativesImpl for(int64_t i = start; i < end; i++) { m_Edges->getVertsAtEdge(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 2; k++) { @@ -128,9 +128,6 @@ EdgeGeom::EdgeGeom() m_GeometryTypeName = SIMPL::Geometry::EdgeGeometry; m_GeometryType = IGeometry::Type::Edge; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 1; m_SpatialDimensionality = 3; m_VertexList = EdgeGeom::CreateSharedVertexList(0); @@ -202,9 +199,9 @@ void EdgeGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void EdgeGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void EdgeGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { - if(data->getType() != AttributeMatrix::Type::Vertex || data->getType() != AttributeMatrix::Type::Edge) + if(data->getType() != AttributeMatrix::Type::Vertex && data->getType() != AttributeMatrix::Type::Edge) { // EdgeGeom can only accept vertex or edge Attribute Matrices return; @@ -217,11 +214,11 @@ void EdgeGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } - m_AttributeMatrices[name] = data; + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} + m_AttributeMatrices[data->getName()] = data; } // ----------------------------------------------------------------------------- @@ -436,7 +433,7 @@ void EdgeGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType:: if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -584,18 +581,25 @@ QString EdgeGeom::getInfoString(SIMPL::InfoStringFormat format) QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + QString bgColorLabel = ""; + + switch(format) { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Edges" << getNumberOfEdges() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Number of Edges" << getNumberOfEdges() << ""; + ss << "Number of Vertices" << getNumberOfVertices() << ""; ss << ""; + break; + default: + ss << "Requested Edge Geometry information string format is not supported. " << format; + break; } - else - { - } + return info; } diff --git a/Source/SIMPLib/Geometry/EdgeGeom.h b/Source/SIMPLib/Geometry/EdgeGeom.h index 96c3998acd..a53d285508 100644 --- a/Source/SIMPLib/Geometry/EdgeGeom.h +++ b/Source/SIMPLib/Geometry/EdgeGeom.h @@ -350,9 +350,9 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; protected: EdgeGeom(); diff --git a/Source/SIMPLib/Geometry/GeometryHelpers.h b/Source/SIMPLib/Geometry/GeometryHelpers.h index 9c4c68db74..9650181fd1 100755 --- a/Source/SIMPLib/Geometry/GeometryHelpers.h +++ b/Source/SIMPLib/Geometry/GeometryHelpers.h @@ -466,7 +466,7 @@ class Connectivity } typename std::set>::iterator setIter; - edgeList->resize(edgeSet.size()); + edgeList->resizeTuples(edgeSet.size()); T* uEdges = edgeList->getPointer(0); T index = 0; @@ -511,7 +511,7 @@ class Connectivity } typename std::set>::iterator setIter; - edgeList->resize(edgeSet.size()); + edgeList->resizeTuples(edgeSet.size()); T* uEdges = edgeList->getPointer(0); T index = 0; @@ -528,7 +528,7 @@ class Connectivity * @param hexList * @param edgeList */ - template static void FindHexEdges(typename DataArray::Pointer hexList, typename DataArray::Pointer edgeList) + template static void FindHexEdges(typename DataArray::Pointer hexList, typename DataArray::Pointer edge_List) { size_t numElems = hexList->getNumberOfTuples(); @@ -566,8 +566,8 @@ class Connectivity } typename std::set>::iterator setIter; - edgeList->resize(edgeSet.size()); - T* uEdges = edgeList->getPointer(0); + edge_List->resizeTuples(edgeSet.size()); + T* uEdges = edge_List->getPointer(0); T index = 0; for(setIter = edgeSet.begin(); setIter != edgeSet.end(); ++setIter) @@ -609,7 +609,7 @@ class Connectivity } typename std::set>::iterator setIter; - faceList->resize(faceSet.size()); + faceList->resizeTuples(faceSet.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -656,7 +656,7 @@ class Connectivity } typename std::set>::iterator setIter; - faceList->resize(faceSet.size()); + faceList->resizeTuples(faceSet.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -736,7 +736,7 @@ class Connectivity } } - edgeList->resize(edgeMap.size()); + edgeList->resizeTuples(edgeMap.size()); T* bEdges = edgeList->getPointer(0); T index = 0; @@ -794,7 +794,7 @@ class Connectivity } } - edgeList->resize(edgeMap.size()); + edgeList->resizeTuples(edgeMap.size()); T* bEdges = edgeList->getPointer(0); T index = 0; @@ -811,7 +811,7 @@ class Connectivity * @param hexList * @param edgeList */ - template static void FindUnsharedHexEdges(typename DataArray::Pointer hexList, typename DataArray::Pointer edgeList) + template static void FindUnsharedHexEdges(typename DataArray::Pointer& hexList, typename DataArray::Pointer& edge_List) { size_t numElems = hexList->getNumberOfTuples(); @@ -837,8 +837,7 @@ class Connectivity std::vector edge10 = {verts[6], verts[7]}; std::vector edge11 = {verts[7], verts[4]}; - std::list> edgeList = {edge0, edge1, edge2, edge3, edge4, edge5, - edge6, edge7, edge8, edge9, edge10, edge11}; + std::list> edgeList = {edge0, edge1, edge2, edge3, edge4, edge5, edge6, edge7, edge8, edge9, edge10, edge11}; for(auto&& uEdge : edgeList) { @@ -862,8 +861,8 @@ class Connectivity } } - edgeList->resize(edgeMap.size()); - T* bEdges = edgeList->getPointer(0); + edge_List->resizeTuples(edgeMap.size()); + T* bEdges = edge_List->getPointer(0); T index = 0; for(mapIter = edgeMap.begin(); mapIter != edgeMap.end(); ++mapIter) @@ -918,7 +917,7 @@ class Connectivity } } - faceList->resize(faceMap.size()); + faceList->resizeTuples(faceMap.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -978,7 +977,7 @@ class Connectivity } } - faceList->resize(faceMap.size()); + faceList->resizeTuples(faceMap.size()); T* uFaces = faceList->getPointer(0); T index = 0; diff --git a/Source/SIMPLib/Geometry/HexahedralGeom.cpp b/Source/SIMPLib/Geometry/HexahedralGeom.cpp index b36d8766a5..9abdf8f530 100644 --- a/Source/SIMPLib/Geometry/HexahedralGeom.cpp +++ b/Source/SIMPLib/Geometry/HexahedralGeom.cpp @@ -52,7 +52,7 @@ class FindHexDerivativesImpl for(int64_t i = start; i < end; i++) { m_Hexas->getVertsAtHex(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 8; k++) { @@ -93,9 +93,6 @@ HexahedralGeom::HexahedralGeom() m_GeometryTypeName = SIMPL::Geometry::HexahedralGeometry; m_GeometryType = IGeometry::Type::Hexahedral; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 3; m_SpatialDimensionality = 3; m_VertexList = HexahedralGeom::CreateSharedVertexList(0); @@ -171,11 +168,11 @@ void HexahedralGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void HexahedralGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void HexahedralGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if(data->getType() != AttributeMatrix::Type::Vertex - || data->getType() != AttributeMatrix::Type::Edge - || data->getType() != AttributeMatrix::Type::Face || data->getType() != AttributeMatrix::Type::Cell) + && data->getType() != AttributeMatrix::Type::Edge + && data->getType() != AttributeMatrix::Type::Face || data->getType() != AttributeMatrix::Type::Cell) { // HexahedralGeom can only accept vertex, edge, face or cell Attribute Matrices return; @@ -196,11 +193,11 @@ void HexahedralGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Po { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } - m_AttributeMatrices[name] = data; + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} + m_AttributeMatrices[data->getName()] = data; } // ----------------------------------------------------------------------------- @@ -216,7 +213,7 @@ size_t HexahedralGeom::getNumberOfElements() // ----------------------------------------------------------------------------- int HexahedralGeom::findEdges() { - m_EdgeList = CreateSharedEdgeList(0); + m_EdgeList = CreateSharedEdgeList(0, false); GeometryHelpers::Connectivity::FindHexEdges(m_HexList, m_EdgeList); if(m_EdgeList.get() == nullptr) { @@ -238,7 +235,7 @@ void HexahedralGeom::deleteEdges() // ----------------------------------------------------------------------------- int HexahedralGeom::findFaces() { - m_QuadList = CreateSharedQuadList(0); + m_QuadList = CreateSharedQuadList(0, false); GeometryHelpers::Connectivity::FindHexFaces(m_HexList, m_QuadList); if(m_QuadList.get() == nullptr) { @@ -386,7 +383,8 @@ void HexahedralGeom::deleteElementCentroids() int HexahedralGeom::findElementSizes() { QVector cDims(1, 1); - m_HexSizes = FloatArrayType::CreateArray(getNumberOfHexas(), cDims, SIMPL::StringConstants::HexVolumes); + int64_t numHexs = getNumberOfHexas(); + m_HexSizes = FloatArrayType::CreateArray(numHexs, cDims, SIMPL::StringConstants::HexVolumes, (numHexs != 0)); GeometryHelpers::Topology::FindHexVolumes(m_HexList, m_VertexList, m_HexSizes); if(m_HexSizes.get() == nullptr) { @@ -425,7 +423,7 @@ void HexahedralGeom::deleteElementSizes() int HexahedralGeom::findUnsharedEdges() { QVector cDims(1, 2); - m_UnsharedEdgeList = SharedEdgeList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedEdgeList); + m_UnsharedEdgeList = SharedEdgeList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedEdgeList, false); GeometryHelpers::Connectivity::FindUnsharedHexEdges(m_HexList, m_UnsharedEdgeList); if(m_UnsharedEdgeList.get() == nullptr) { @@ -464,7 +462,7 @@ void HexahedralGeom::deleteUnsharedEdges() int HexahedralGeom::findUnsharedFaces() { QVector cDims(1, 4); - m_UnsharedQuadList = SharedQuadList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedFaceList); + m_UnsharedQuadList = SharedQuadList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedFaceList, false); GeometryHelpers::Connectivity::FindUnsharedHexFaces(m_HexList, m_UnsharedQuadList); if(m_UnsharedQuadList.get() == nullptr) { @@ -561,7 +559,7 @@ void HexahedralGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArray if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -745,17 +743,24 @@ QString HexahedralGeom::getInfoString(SIMPL::InfoStringFormat format) QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) - { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Hexahedra" << getNumberOfHexas() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; - } - else + QString bgColorLabel = ""; + + switch(format) { + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Number of Hexahedra" << getNumberOfHexas() << ""; + ss << "Number of Vertices" << getNumberOfVertices() << ""; + break; + default: + ss << "Requested Hexahedral Geometry information string format is not supported. " << format; + break; } + return info; } diff --git a/Source/SIMPLib/Geometry/HexahedralGeom.h b/Source/SIMPLib/Geometry/HexahedralGeom.h index 048f40bde5..6e48a088fe 100644 --- a/Source/SIMPLib/Geometry/HexahedralGeom.h +++ b/Source/SIMPLib/Geometry/HexahedralGeom.h @@ -333,9 +333,9 @@ class SIMPLib_EXPORT HexahedralGeom : public IGeometry3D IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; // ----------------------------------------------------------------------------- // Inherited from IGeometry3D diff --git a/Source/SIMPLib/Geometry/IGeometry.cpp b/Source/SIMPLib/Geometry/IGeometry.cpp index ee93a1227e..ce01f91dde 100644 --- a/Source/SIMPLib/Geometry/IGeometry.cpp +++ b/Source/SIMPLib/Geometry/IGeometry.cpp @@ -46,6 +46,7 @@ IGeometry::IGeometry() : m_TimeValue(0.0f) , m_EnableTimeSeries(false) , m_Units(LengthUnit::Unspecified) +, m_ProgressCounter(0) { } @@ -422,63 +423,15 @@ void IGeometry::sendThreadSafeProgressMessage(int64_t counter, int64_t max) if(m_ProgressCounter > prog) { - int64_t progressInt = static_cast((static_cast(m_ProgressCounter) / max) * 100.0f); - QString ss = m_MessageTitle + QObject::tr(" || %1% Complete").arg(progressInt); - notifyStatusMessage(m_MessagePrefix, m_MessageLabel, ss); + int64_t progressInt = static_cast((static_cast(m_ProgressCounter) / max) * 100.0); + QString ss = QObject::tr("%1% Complete").arg(progressInt); + notifyStatusMessage(ss); prog += progIncrement; } m_Mutex.unlock(); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void IGeometry::setMessagePrefix(const QString& name) -{ - m_MessagePrefix = name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString IGeometry::getMessagePrefix() -{ - return m_MessagePrefix; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void IGeometry::setMessageTitle(const QString& title) -{ - m_MessageTitle = title; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString IGeometry::getMessageTitle() -{ - return m_MessageTitle; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void IGeometry::setMessageLabel(const QString& label) -{ - m_MessageLabel = label; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString IGeometry::getMessageLabel() -{ - return m_MessageLabel; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -562,7 +515,7 @@ int IGeometry::readGeometryFromHDF5(hid_t parentId, bool preflight) herr_t err = 0; std::string transformTypeName = SIMPL::Geometry::UnknownTransformContainer.toStdString(); - QString transformName = QString::number(0).toLatin1().data(); + QString transformName = SIMPL::Geometry::TransformContainerGroup.toLatin1().data(); err = H5Lite::readStringAttribute(parentId, transformName.toLatin1().data(), SIMPL::Geometry::TransformContainerTypeName.toLatin1().data(), transformTypeName); // No transform information found. if(err < 0) diff --git a/Source/SIMPLib/Geometry/IGeometry.h b/Source/SIMPLib/Geometry/IGeometry.h index 233e5a8eb6..4d7f5b960e 100644 --- a/Source/SIMPLib/Geometry/IGeometry.h +++ b/Source/SIMPLib/Geometry/IGeometry.h @@ -76,15 +76,12 @@ class SIMPLib_EXPORT IGeometry : public Observable PYB11_METHOD(Type getGeometryType) PYB11_METHOD(QString getGeometryTypeAsString) PYB11_METHOD(QString getInfoString ARGS formatType) - PYB11_PROPERTY(QString MessagePrefix READ getMessagePrefix WRITE setMessagePrefix) - PYB11_PROPERTY(QString MessageTitle READ getMessageTitle WRITE setMessageTitle) - PYB11_PROPERTY(QString MessageLabel READ getMessageLabel WRITE setMessageLabel) PYB11_METHOD(uint32_t getXdmfGridType) PYB11_METHOD(uint32_t getUnitDimensionality) PYB11_PROPERTY(uint32_t SpatialDimensionality READ getSpatialDimensionality WRITE setSpatialDimensionality) PYB11_METHOD(Pointer deepCopy ARGS forceNoAllocate) PYB11_METHOD(void initializeWithZeros) - PYB11_METHOD(void addAttributeMatrix ARGS Name AttributeMatrix) + PYB11_METHOD(void addOrReplaceAttributeMatrix ARGS Name AttributeMatrix) PYB11_METHOD(AttributeMatrix getAttributeMatrix ARGS Name) PYB11_METHOD(AttributeMatrix removeAttributeMatrix ARGS Name) @@ -342,42 +339,6 @@ class SIMPLib_EXPORT IGeometry : public Observable */ virtual QString getInfoString(SIMPL::InfoStringFormat) = 0; - /** - * @brief setMessagePrefix - * @param prefix - */ - virtual void setMessagePrefix(const QString& prefix) final; - - /** - * @brief getMessagePrefix - * @return - */ - virtual QString getMessagePrefix() final; - - /** - * @brief setMessageTitle - * @param title - */ - virtual void setMessageTitle(const QString& title) final; - - /** - * @brief getMessageTitle - * @return - */ - virtual QString getMessageTitle() final; - - /** - * @brief setMessageLabel - * @param label - */ - virtual void setMessageLabel(const QString& label) final; - - /** - * @brief getMessageLabel - * @return - */ - virtual QString getMessageLabel() final; - /** * @brief getXdmfGridType * @return @@ -439,9 +400,9 @@ class SIMPLib_EXPORT IGeometry : public Observable virtual void initializeWithZeros() = 0; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - virtual void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) = 0; + virtual void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) = 0; /** * @brief getAttributeMatrix @@ -460,9 +421,6 @@ class SIMPLib_EXPORT IGeometry : public Observable protected: QString m_Name; QString m_GeometryTypeName; - QString m_MessagePrefix; - QString m_MessageTitle; - QString m_MessageLabel; Type m_GeometryType = Type::Unknown; unsigned int m_XdmfGridType = SIMPL::XdmfGridType::UnknownGrid; unsigned int m_UnitDimensionality = 0; diff --git a/Source/SIMPLib/Geometry/IGeometryGrid.h b/Source/SIMPLib/Geometry/IGeometryGrid.h index 3cf0c95cb9..e038d25c68 100644 --- a/Source/SIMPLib/Geometry/IGeometryGrid.h +++ b/Source/SIMPLib/Geometry/IGeometryGrid.h @@ -37,6 +37,7 @@ #include +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Geometry/IGeometry.h" @@ -61,10 +62,10 @@ class SIMPLib_EXPORT IGeometryGrid : public IGeometry IGeometryGrid(); ~IGeometryGrid() override; - - virtual void setDimensions(size_t dims[3]) = 0; - virtual void setDimensions(size_t a, size_t b, size_t c) = 0; - virtual void setDimensions(const SIMPL::Tuple3SVec& dims) = 0; + + virtual void setDimensions(const SizeVec3Type& dims) = 0; + virtual void setDimensions(SizeVec3Type& dims) = 0; + virtual void setDimensions(const SIMPL::Tuple3SVec& dims) = 0; // Needed for Python Interface virtual SIMPL::Tuple3SVec getDimensions() const = 0; diff --git a/Source/SIMPLib/Geometry/ImageGeom.cpp b/Source/SIMPLib/Geometry/ImageGeom.cpp index af99e4a6c3..453618c810 100644 --- a/Source/SIMPLib/Geometry/ImageGeom.cpp +++ b/Source/SIMPLib/Geometry/ImageGeom.cpp @@ -208,7 +208,7 @@ class FindImageDerivativesImpl // Compute the actual derivatives index = (z * dims[1] * dims[0]) + (y * dims[0]) + x; - for(int32_t i = 0; i < numComps; i++) + for(size_t i = 0; i < numComps; i++) { derivsPtr[index * numComps * 3 + i * 3] = xix * dValuesdXi[i] + etax * dValuesdEta[i] + zetax * dValuesdZeta[i]; @@ -398,24 +398,17 @@ class FindImageDerivativesImpl // // ----------------------------------------------------------------------------- ImageGeom::ImageGeom() +: m_Spacing(1.0f, 1.0f, 1.0f) +, m_Origin(0.0f, 0.0f, 0.0f) { m_GeometryTypeName = SIMPL::Geometry::ImageGeometry; m_GeometryType = IGeometry::Type::Image; m_XdmfGridType = SIMPL::XdmfGridType::RectilinearGrid; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 3; m_SpatialDimensionality = 3; m_Dimensions[0] = 0; m_Dimensions[1] = 0; m_Dimensions[2] = 0; - m_Resolution[0] = 1.0f; - m_Resolution[1] = 1.0f; - m_Resolution[2] = 1.0f; - m_Origin[0] = 0.0f; - m_Origin[1] = 0.0f; - m_Origin[2] = 0.0f; m_VoxelSizes = FloatArrayType::NullPointer(); m_ProgressCounter = 0; } @@ -443,15 +436,118 @@ ImageGeom::Pointer ImageGeom::CreateGeometry(const QString& name) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -//void ImageGeom::getBoundingBox(float &xMin, float &xMax, float &yMin, float &yMax, float &zMin, float &zMax) -//{ -// xMin = m_Origin[0]; -// xMax = m_Origin[0] + (m_Dimensions[0] * m_Resolution[0]); -// yMin = m_Origin[1]; -// yMax = m_Origin[1] + (m_Dimensions[1] * m_Resolution[1]); -// zMin = m_Origin[2]; -// zMax = m_Origin[2] + (m_Dimensions[2] * m_Resolution[2]); -//} +SIMPL::Tuple3FVec ImageGeom::getSpacing() const +{ + return m_Spacing.toTuple(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::getSpacing(FloatVec3Type& spacing) const +{ + spacing[0] = m_Spacing[0]; + spacing[1] = m_Spacing[1]; + spacing[2] = m_Spacing[2]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setSpacing(const FloatVec3Type& spacing) +{ + m_Spacing = spacing; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setSpacing(FloatVec3Type& spacing) +{ + m_Spacing = spacing; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setSpacing(float x, float y, float z) +{ + m_Spacing[0] = x; + m_Spacing[1] = y; + m_Spacing[2] = z; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPL::Tuple3FVec ImageGeom::getOrigin() const +{ + return m_Origin.toTuple(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::getOrigin(FloatVec3Type& origin) const +{ + origin[0] = m_Origin[0]; + origin[1] = m_Origin[1]; + origin[2] = m_Origin[2]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setOrigin(const FloatVec3Type& origin) +{ + m_Origin = origin; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setOrigin(FloatVec3Type& origin) +{ + m_Origin = origin; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setOrigin(float x, float y, float z) +{ + m_Origin[0] = x; + m_Origin[1] = y; + m_Origin[2] = z; +} + +SIMPL::Tuple3SVec ImageGeom::getDimensions() const +{ + return m_Dimensions.toTuple(); +} +void ImageGeom::getDimensions(SizeVec3Type& dims) const +{ + dims = m_Dimensions; +} + +void ImageGeom::setDimensions(const SizeVec3Type& dims) +{ + m_Dimensions = dims; +} +void ImageGeom::setDimensions(SizeVec3Type& dims) +{ + m_Dimensions = dims; +} +void ImageGeom::setDimensions(const SIMPL::Tuple3SVec& dims) +{ + m_Dimensions = dims; +} +void ImageGeom::setDimensions(size_t x, size_t y, size_t z) +{ + m_Dimensions[0] = x; + m_Dimensions[1] = y; + m_Dimensions[2] = z; +} // ----------------------------------------------------------------------------- // @@ -459,11 +555,11 @@ ImageGeom::Pointer ImageGeom::CreateGeometry(const QString& name) void ImageGeom::getBoundingBox(float* boundingBox) { boundingBox[0] = m_Origin[0]; - boundingBox[1] = m_Origin[0] + (m_Dimensions[0] * m_Resolution[0]); + boundingBox[1] = m_Origin[0] + (m_Dimensions[0] * m_Spacing[0]); boundingBox[2] = m_Origin[1]; - boundingBox[3] = m_Origin[1] + (m_Dimensions[1] * m_Resolution[1]); + boundingBox[3] = m_Origin[1] + (m_Dimensions[1] * m_Spacing[1]); boundingBox[4] = m_Origin[2]; - boundingBox[5] = m_Origin[2] + (m_Dimensions[2] * m_Resolution[2]); + boundingBox[5] = m_Origin[2] + (m_Dimensions[2] * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -471,13 +567,8 @@ void ImageGeom::getBoundingBox(float* boundingBox) // ----------------------------------------------------------------------------- SIMPL::Tuple6FVec ImageGeom::getBoundingBox() { - return std::make_tuple(m_Origin[0], - m_Origin[0] + (m_Dimensions[0] * m_Resolution[0]), - m_Origin[1], - m_Origin[1] + (m_Dimensions[1] * m_Resolution[1]), - m_Origin[2], - m_Origin[2] + (m_Dimensions[2] * m_Resolution[2]) - ); + return std::make_tuple(m_Origin[0], m_Origin[0] + (m_Dimensions[0] * m_Spacing[0]), m_Origin[1], m_Origin[1] + (m_Dimensions[1] * m_Spacing[1]), m_Origin[2], + m_Origin[2] + (m_Dimensions[2] * m_Spacing[2])); } // ----------------------------------------------------------------------------- @@ -509,9 +600,9 @@ size_t ImageGeom::getZPoints() // ----------------------------------------------------------------------------- void ImageGeom::getPlaneCoords(size_t idx[3], float coords[3]) { - coords[0] = idx[0] * m_Resolution[0] + m_Origin[0]; - coords[1] = idx[1] * m_Resolution[1] + m_Origin[1]; - coords[2] = idx[2] * m_Resolution[2] + m_Origin[2]; + coords[0] = idx[0] * m_Spacing[0] + m_Origin[0]; + coords[1] = idx[1] * m_Spacing[1] + m_Origin[1]; + coords[2] = idx[2] * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- @@ -519,9 +610,9 @@ void ImageGeom::getPlaneCoords(size_t idx[3], float coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getPlaneCoords(size_t x, size_t y, size_t z, float coords[3]) { - coords[0] = x * m_Resolution[0] + m_Origin[0]; - coords[1] = y * m_Resolution[1] + m_Origin[1]; - coords[2] = z * m_Resolution[2] + m_Origin[2]; + coords[0] = x * m_Spacing[0] + m_Origin[0]; + coords[1] = y * m_Spacing[1] + m_Origin[1]; + coords[2] = z * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- @@ -533,9 +624,9 @@ void ImageGeom::getPlaneCoords(size_t idx, float coords[3]) size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = column * m_Resolution[0] + m_Origin[0]; - coords[1] = row * m_Resolution[1] + m_Origin[1]; - coords[2] = plane * m_Resolution[2] + m_Origin[2]; + coords[0] = column * m_Spacing[0] + m_Origin[0]; + coords[1] = row * m_Spacing[1] + m_Origin[1]; + coords[2] = plane * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- @@ -543,9 +634,9 @@ void ImageGeom::getPlaneCoords(size_t idx, float coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getPlaneCoords(size_t idx[3], double coords[3]) { - coords[0] = static_cast(idx[0] * m_Resolution[0] + m_Origin[0]); - coords[1] = static_cast(idx[1] * m_Resolution[1] + m_Origin[1]); - coords[2] = static_cast(idx[2] * m_Resolution[2] + m_Origin[2]); + coords[0] = static_cast(idx[0]) * m_Spacing[0] + m_Origin[0]; + coords[1] = static_cast(idx[1]) * m_Spacing[1] + m_Origin[1]; + coords[2] = static_cast(idx[2]) * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- @@ -553,9 +644,9 @@ void ImageGeom::getPlaneCoords(size_t idx[3], double coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getPlaneCoords(size_t x, size_t y, size_t z, double coords[3]) { - coords[0] = static_cast(x * m_Resolution[0] + m_Origin[0]); - coords[1] = static_cast(y * m_Resolution[1] + m_Origin[1]); - coords[2] = static_cast(z * m_Resolution[2] + m_Origin[2]); + coords[0] = static_cast(x) * m_Spacing[0] + m_Origin[0]; + coords[1] = static_cast(y) * m_Spacing[1] + m_Origin[1]; + coords[2] = static_cast(z) * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- @@ -567,9 +658,9 @@ void ImageGeom::getPlaneCoords(size_t idx, double coords[3]) size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = static_cast(column * m_Resolution[0] + m_Origin[0]); - coords[1] = static_cast(row * m_Resolution[1] + m_Origin[1]); - coords[2] = static_cast(plane * m_Resolution[2] + m_Origin[2]); + coords[0] = static_cast(column) * m_Spacing[0] + m_Origin[0]; + coords[1] = static_cast(row) * m_Spacing[1] + m_Origin[1]; + coords[2] = static_cast(plane) * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- @@ -577,9 +668,9 @@ void ImageGeom::getPlaneCoords(size_t idx, double coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getCoords(size_t idx[3], float coords[3]) { - coords[0] = idx[0] * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0]); - coords[1] = idx[1] * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1]); - coords[2] = idx[2] * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2]); + coords[0] = idx[0] * m_Spacing[0] + m_Origin[0] + (0.5f * m_Spacing[0]); + coords[1] = idx[1] * m_Spacing[1] + m_Origin[1] + (0.5f * m_Spacing[1]); + coords[2] = idx[2] * m_Spacing[2] + m_Origin[2] + (0.5f * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -587,9 +678,9 @@ void ImageGeom::getCoords(size_t idx[3], float coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getCoords(size_t x, size_t y, size_t z, float coords[3]) { - coords[0] = x * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0]); - coords[1] = y * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1]); - coords[2] = z * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2]); + coords[0] = x * m_Spacing[0] + m_Origin[0] + (0.5f * m_Spacing[0]); + coords[1] = y * m_Spacing[1] + m_Origin[1] + (0.5f * m_Spacing[1]); + coords[2] = z * m_Spacing[2] + m_Origin[2] + (0.5f * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -601,9 +692,9 @@ void ImageGeom::getCoords(size_t idx, float coords[3]) size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = column * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0]); - coords[1] = row * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1]); - coords[2] = plane * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2]); + coords[0] = column * m_Spacing[0] + m_Origin[0] + (0.5f * m_Spacing[0]); + coords[1] = row * m_Spacing[1] + m_Origin[1] + (0.5f * m_Spacing[1]); + coords[2] = plane * m_Spacing[2] + m_Origin[2] + (0.5f * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -611,9 +702,9 @@ void ImageGeom::getCoords(size_t idx, float coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getCoords(size_t idx[3], double coords[3]) { - coords[0] = static_cast(idx[0] * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0])); - coords[1] = static_cast(idx[1] * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1])); - coords[2] = static_cast(idx[2] * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2])); + coords[0] = static_cast(idx[0]) * m_Spacing[0] + m_Origin[0] + (0.5 * m_Spacing[0]); + coords[1] = static_cast(idx[1]) * m_Spacing[1] + m_Origin[1] + (0.5 * m_Spacing[1]); + coords[2] = static_cast(idx[2]) * m_Spacing[2] + m_Origin[2] + (0.5 * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -621,9 +712,9 @@ void ImageGeom::getCoords(size_t idx[3], double coords[3]) // ----------------------------------------------------------------------------- void ImageGeom::getCoords(size_t x, size_t y, size_t z, double coords[3]) { - coords[0] = static_cast(x * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0])); - coords[1] = static_cast(y * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1])); - coords[2] = static_cast(z * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2])); + coords[0] = static_cast(x) * m_Spacing[0] + m_Origin[0] + (0.5 * m_Spacing[0]); + coords[1] = static_cast(y) * m_Spacing[1] + m_Origin[1] + (0.5 * m_Spacing[1]); + coords[2] = static_cast(z) * m_Spacing[2] + m_Origin[2] + (0.5 * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -635,9 +726,9 @@ void ImageGeom::getCoords(size_t idx, double coords[3]) size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = static_cast(column * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0])); - coords[1] = static_cast(row * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1])); - coords[2] = static_cast(plane * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2])); + coords[0] = static_cast(column) * m_Spacing[0] + m_Origin[0] + (0.5 * m_Spacing[0]); + coords[1] = static_cast(row) * m_Spacing[1] + m_Origin[1] + (0.5 * m_Spacing[1]); + coords[2] = static_cast(plane) * m_Spacing[2] + m_Origin[2] + (0.5 * m_Spacing[2]); } // ----------------------------------------------------------------------------- @@ -648,7 +739,7 @@ void ImageGeom::initializeWithZeros() for(size_t i = 0; i < 3; i++) { m_Dimensions[i] = 0; - m_Resolution[i] = 1.0f; + m_Spacing[i] = 1.0f; m_Origin[i] = 0.0f; } } @@ -656,7 +747,7 @@ void ImageGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void ImageGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if(data->getType() != AttributeMatrix::Type::Cell) { @@ -667,10 +758,10 @@ void ImageGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } @@ -777,8 +868,8 @@ void ImageGeom::deleteElementCentroids() // ----------------------------------------------------------------------------- int ImageGeom::findElementSizes() { - float res[3] = {0.0f, 0.0f, 0.0f}; - std::tie(res[0], res[1], res[2]) = getResolution(); + FloatVec3Type res = {0.0f, 0.0f, 0.0f}; + std::tie(res[0], res[1], res[2]) = getSpacing(); if(res[0] <= 0.0f || res[1] <= 0.0f || res[2] <= 0.0f) { @@ -878,7 +969,7 @@ void ImageGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType: if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -915,9 +1006,9 @@ int ImageGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf { herr_t err = 0; int64_t volDims[3] = {static_cast(getXPoints()), static_cast(getYPoints()), static_cast(getZPoints())}; - float spacing[3] = {0.0f, 0.0f, 0.0f}; - std::tie(spacing[0], spacing[1], spacing[2]) = getResolution(); - float origin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type spacing = {0.0f, 0.0f, 0.0f}; + std::tie(spacing[0], spacing[1], spacing[2]) = getSpacing(); + FloatVec3Type origin = {0.0f, 0.0f, 0.0f}; std::tie(origin[0], origin[1], origin[2]) = getOrigin(); int32_t rank = 1; @@ -928,12 +1019,12 @@ int ImageGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf { return err; } - err = H5Lite::writePointerDataset(parentId, H5_ORIGIN, rank, dims, origin); + err = H5Lite::writePointerDataset(parentId, H5_ORIGIN, rank, dims, origin.data()); if(err < 0) { return err; } - err = H5Lite::writePointerDataset(parentId, H5_SPACING, rank, dims, spacing); + err = H5Lite::writePointerDataset(parentId, H5_SPACING, rank, dims, spacing.data()); if(err < 0) { return err; @@ -960,9 +1051,9 @@ int ImageGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) herr_t err = 0; int64_t volDims[3] = {static_cast(getXPoints()), static_cast(getYPoints()), static_cast(getZPoints())}; - float spacing[3] = {0.0f, 0.0f, 0.0f}; - std::tie(spacing[0], spacing[1], spacing[2]) = getResolution(); - float origin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type spacing = {0.0f, 0.0f, 0.0f}; + std::tie(spacing[0], spacing[1], spacing[2]) = getSpacing(); + FloatVec3Type origin = {0.0f, 0.0f, 0.0f}; std::tie(origin[0], origin[1], origin[2]) = getOrigin(); out << " " @@ -981,7 +1072,7 @@ int ImageGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) << "\n"; out << R"( )" << origin[2] << " " << origin[1] << " " << origin[0] << "" << "\n"; - out << " " + out << " " << "\n"; out << R"( )" << spacing[2] << " " << spacing[1] << " " << spacing[0] << "" << "\n"; @@ -1000,37 +1091,53 @@ QString ImageGeom::getInfoString(SIMPL::InfoStringFormat format) QTextStream ss(&info); int64_t volDims[3] = {static_cast(getXPoints()), static_cast(getYPoints()), static_cast(getZPoints())}; - float spacing[3] = {0.0f, 0.0f, 0.0f}; - std::tie(spacing[0], spacing[1], spacing[2]) = getResolution(); - std::tie(spacing[0], spacing[1], spacing[2]) = getResolution(); - float origin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type spacing = {0.0f, 0.0f, 0.0f}; + std::tie(spacing[0], spacing[1], spacing[2]) = getSpacing(); + std::tie(spacing[0], spacing[1], spacing[2]) = getSpacing(); + FloatVec3Type origin = {0.0f, 0.0f, 0.0f}; std::tie(origin[0], origin[1], origin[2]) = getOrigin(); float halfRes[3] = {spacing[0] / 2.0f, spacing[1] / 2.0f, spacing[2] / 2.0f}; - if(format == SIMPL::HtmlFormat) + QString geomTypeString = TypeToString(getGeometryType()); + QString lengthUnitString = LengthUnitToString(getUnits()); + QString xExtentString = tr("X Extent: 0 to %1 (dimension: %2)").arg(volDims[0] - 1).arg(volDims[0]); + QString yExtentString = tr("Y Extent: 0 to %1 (dimension: %2)").arg(volDims[1] - 1).arg(volDims[1]); + QString zExtentString = tr("Z Extent: 0 to %1 (dimension: %2)").arg(volDims[2] - 1).arg(volDims[2]); + QString xRangeString = tr("X Range: %1 to %2 (delta: %3)").arg(origin[0] - halfRes[0]).arg(origin[0] - halfRes[0] + volDims[0] * spacing[0]).arg(volDims[0] * spacing[0]); + QString yRangeString = tr("Y Range: %1 to %2 (delta: %3)").arg(origin[1] - halfRes[1]).arg(origin[1] - halfRes[1] + volDims[1] * spacing[1]).arg(volDims[1] * spacing[1]); + QString zRangeString = tr("Z Range: %1 to %2 (delta: %3)").arg(origin[2] - halfRes[2]).arg(origin[2] - halfRes[2] + volDims[2] * spacing[2]).arg(volDims[2] * spacing[2]); + QString originString = tr("(%1, %2, %3)").arg(origin[0]).arg(origin[1]).arg(origin[2]); + QString spacingString = tr("(%1, %2, %3)").arg(spacing[0]).arg(spacing[1]).arg(spacing[2]); + QString bgColorLabel = ""; + + switch(format) { - ss << "Geometry Info"; - ss << R"(Type)" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << R"(Extents:)" - << "

X Extent: 0 to " << volDims[0] - 1 << " (dimension: " << volDims[0] << ")

" - << "

Y Extent: 0 to " << volDims[1] - 1 << " (dimension: " << volDims[1] << ")

" - << "

Z Extent: 0 to " << volDims[2] - 1 << " (dimension: " << volDims[2] << ")

" + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type: " << geomTypeString << ""; + ss << "Units: " << lengthUnitString << ""; + ss << "Extents: " + << "

" << xExtentString << "

" + << "

" << yExtentString << "

" + << "

" << zExtentString << "

" << ""; - ss << R"(Origin:)" << origin[0] << ", " << origin[1] << ", " << origin[2] << ""; - ss << R"(Spacing/Resolution:)" << spacing[0] << ", " << spacing[1] << ", " << spacing[2] << ""; + ss << "Origin: " << originString << ""; + ss << "Spacing: " << spacingString << ""; - ss << R"(Bounds:)" - << "

X Range: " << (origin[0] - halfRes[0]) << " to " << (origin[0] - halfRes[0] + volDims[0] * spacing[0]) << " (delta: " << (volDims[0] * spacing[0]) << ")

" - << "

Y Range: " << (origin[1] - halfRes[1]) << " to " << (origin[1] - halfRes[1] + volDims[1] * spacing[1]) << " (delta: " << (volDims[1] * spacing[1]) << ")

" - << "

Z Range: " << (origin[2] - halfRes[2]) << " to " << (origin[2] - halfRes[2] + volDims[2] * spacing[2]) << " (delta: " << (volDims[2] * spacing[2]) << ")

" + ss << "Bounds: " + << "

" << xRangeString << "

" + << "

" << yRangeString << "

" + << "

" << zRangeString << "

" << ""; + break; + default: + ss << "Requested Image Geometry information string format is not supported. " << format; + break; } - else - { - ss << "Requested InfoStringFormat is not supported. " << format; - } + return info; } @@ -1041,11 +1148,11 @@ int ImageGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { int err = 0; size_t volDims[3] = {0, 0, 0}; - float spacing[3] = {1.0f, 1.0f, 1.0f}; - float origin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type spacing = {1.0f, 1.0f, 1.0f}; + FloatVec3Type origin = {0.0f, 0.0f, 0.0f}; unsigned int spatialDims = 0; QString geomName = ""; - err = gatherMetaData(parentId, volDims, spacing, origin, spatialDims, geomName, preflight); + err = gatherMetaData(parentId, volDims, spacing.data(), origin.data(), spatialDims, geomName, preflight); if(err < 0) { return err; @@ -1065,10 +1172,10 @@ IGeometry::Pointer ImageGeom::deepCopy(bool forceNoAllocate) std::tuple spacing = std::make_tuple(1.0f, 1.0f, 1.0f); std::tuple origin = std::make_tuple(0.0f, 0.0f, 0.0f); volDims = getDimensions(); - spacing = getResolution(); + spacing = getSpacing(); origin = getOrigin(); imageCopy->setDimensions(volDims); - imageCopy->setResolution(spacing); + imageCopy->setSpacing(spacing); imageCopy->setOrigin(origin); FloatArrayType::Pointer elementSizes = std::dynamic_pointer_cast((getElementSizes().get() == nullptr) ? nullptr : getElementSizes()->deepCopy(forceNoAllocate)); imageCopy->setElementSizes(elementSizes); @@ -1104,7 +1211,7 @@ int ImageGeom::gatherMetaData(hid_t parentId, size_t volDims[3], float spacing[3 return -1; } setDimensions(volDims); - setResolution(spacing); + setSpacing(spacing); setOrigin(origin); setElementSizes(voxelSizes); @@ -1123,11 +1230,11 @@ ImageGeom::ErrorType ImageGeom::computeCellIndex(float coords[3], size_t index[3 { return static_cast(i * 2); } - if(coords[i] > (m_Origin[i] + m_Dimensions[i] * m_Resolution[i])) + if(coords[i] > (m_Origin[i] + m_Dimensions[i] * m_Spacing[i])) { return static_cast(i * 2 + 1); } - index[i] = static_cast((coords[i] - m_Origin[i]) / m_Resolution[i]); + index[i] = static_cast((coords[i] - m_Origin[i]) / m_Spacing[i]); if(index[i] > m_Dimensions[i]) { return static_cast(i * 2 + 1); @@ -1149,7 +1256,7 @@ ImageGeom::ErrorType ImageGeom::computeCellIndex(float coords[3], size_t& index) { return static_cast(i * 2); } - cell[i] = static_cast((coords[i] - m_Origin[i]) / m_Resolution[i]); + cell[i] = static_cast((coords[i] - m_Origin[i]) / m_Spacing[i]); if(cell[i] > m_Dimensions[i]) { return static_cast(i * 2 + 1); diff --git a/Source/SIMPLib/Geometry/ImageGeom.h b/Source/SIMPLib/Geometry/ImageGeom.h index eec804842b..4430279ea3 100644 --- a/Source/SIMPLib/Geometry/ImageGeom.h +++ b/Source/SIMPLib/Geometry/ImageGeom.h @@ -35,6 +35,7 @@ #pragma once +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Geometry/IGeometryGrid.h" @@ -53,19 +54,19 @@ class SIMPLib_EXPORT ImageGeom : public IGeometryGrid PYB11_CREATE_BINDINGS(ImageGeom SUPERCLASS IGeometryGrid) PYB11_STATIC_CREATION(CreateGeometry ARGS QString) - + PYB11_ENUMERATION(ErrorType) PYB11_METHOD(void setDimensions OVERLOAD size_t,x size_t,y size_t,z) - PYB11_METHOD(SIMPL::Tuple3SVec getDimensions) + PYB11_METHOD(SIMPL::Tuple3SVec getDimensions OVERLOAD CONST_METHOD) - PYB11_METHOD(void setResolution OVERLOAD float,x float,y float,z) - PYB11_METHOD(SIMPL::Tuple3FVec getResolution OVERLOAD CONST_METHOD) + PYB11_METHOD(void setSpacing OVERLOAD float,x float,y float,z) + PYB11_METHOD(SIMPL::Tuple3FVec getSpacing OVERLOAD CONST_METHOD) PYB11_METHOD(size_t getXPoints) PYB11_METHOD(size_t getYPoints) PYB11_METHOD(size_t getZPoints) - + PYB11_METHOD(void setOrigin OVERLOAD float,x float,y float,z) PYB11_METHOD(SIMPL::Tuple3FVec getOrigin OVERLOAD CONST_METHOD) @@ -100,14 +101,24 @@ class SIMPLib_EXPORT ImageGeom : public IGeometryGrid static Pointer CreateGeometry(const QString& name); /** - * @brief Sets/Gets the Resolution property + * @brief Sets/Gets the Spacing property */ - SIMPL_INSTANCE_VEC3_PROPERTY(float, Resolution) + // SIMPL_INSTANCE_VEC3_PROPERTY(float, Spacing) + SIMPL::Tuple3FVec getSpacing() const; + void getSpacing(FloatVec3Type& spacing) const; + void setSpacing(const FloatVec3Type& spacing); + void setSpacing(FloatVec3Type& spacing); + void setSpacing(float x, float y, float z); /** * @brief Sets/Gets the Origin property */ - SIMPL_INSTANCE_VEC3_PROPERTY(float, Origin) + // SIMPL_INSTANCE_VEC3_PROPERTY(float, Origin) + SIMPL::Tuple3FVec getOrigin() const; + void getOrigin(FloatVec3Type& origin) const; + void setOrigin(const FloatVec3Type& origin); + void setOrigin(FloatVec3Type& origin); + void setOrigin(float x, float y, float z); /** * @brief getBoundingBox @@ -265,15 +276,20 @@ class SIMPLib_EXPORT ImageGeom : public IGeometryGrid IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; // ----------------------------------------------------------------------------- // Inherited from IGeometryGrid // ----------------------------------------------------------------------------- + SIMPL::Tuple3SVec getDimensions() const override; + void getDimensions(SizeVec3Type& dims) const; - SIMPL_INSTANCE_VEC3_PROPERTY_VO(size_t, Dimensions) + void setDimensions(const SizeVec3Type& dims) override; + void setDimensions(SizeVec3Type& dims) override; + void setDimensions(const SIMPL::Tuple3SVec& dims) override; + void setDimensions(size_t x, size_t y, size_t z); size_t getXPoints() override; size_t getYPoints() override; @@ -389,6 +405,10 @@ class SIMPLib_EXPORT ImageGeom : public IGeometryGrid private: FloatArrayType::Pointer m_VoxelSizes; + FloatVec3Type m_Spacing; + FloatVec3Type m_Origin; + SizeVec3Type m_Dimensions; + friend class FindImageDerivativesImpl; public: diff --git a/Source/SIMPLib/Geometry/QuadGeom.cpp b/Source/SIMPLib/Geometry/QuadGeom.cpp index e3097bd63b..75176bb5fc 100644 --- a/Source/SIMPLib/Geometry/QuadGeom.cpp +++ b/Source/SIMPLib/Geometry/QuadGeom.cpp @@ -88,7 +88,7 @@ class FindQuadDerivativesImpl for(int64_t i = start; i < end; i++) { m_Quads->getVertsAtQuad(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 4; k++) { @@ -129,9 +129,6 @@ QuadGeom::QuadGeom() m_GeometryTypeName = SIMPL::Geometry::QuadGeometry; m_GeometryType = IGeometry::Type::Quad; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 2; m_SpatialDimensionality = 3; m_VertexList = QuadGeom::CreateSharedVertexList(0); @@ -205,9 +202,9 @@ void QuadGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void QuadGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void QuadGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { - if(data->getType() != AttributeMatrix::Type::Vertex || data->getType() != AttributeMatrix::Type::Edge || data->getType() != AttributeMatrix::Type::Face) + if(data->getType() != AttributeMatrix::Type::Vertex && data->getType() != AttributeMatrix::Type::Edge && data->getType() != AttributeMatrix::Type::Face) { // QuadGeom can only accept vertex, edge, or face Attribute Matrices return; @@ -224,10 +221,10 @@ void QuadGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } @@ -504,7 +501,7 @@ void QuadGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType:: if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -669,18 +666,25 @@ QString QuadGeom::getInfoString(SIMPL::InfoStringFormat format) QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + QString bgColorLabel = ""; + + switch(format) { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Quads" << getNumberOfQuads() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Number of Quads" << getNumberOfQuads() << ""; + ss << "Number of Vertices" << getNumberOfVertices() << ""; ss << ""; + break; + default: + ss << "Requested Quad Geometry information string format is not supported. " << format; + break; } - else - { - } + return info; } diff --git a/Source/SIMPLib/Geometry/QuadGeom.h b/Source/SIMPLib/Geometry/QuadGeom.h index f2f3fd9d6a..b020262c7a 100644 --- a/Source/SIMPLib/Geometry/QuadGeom.h +++ b/Source/SIMPLib/Geometry/QuadGeom.h @@ -322,9 +322,9 @@ class SIMPLib_EXPORT QuadGeom : public IGeometry2D IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; // ----------------------------------------------------------------------------- // Inherited from IGeometry2D diff --git a/Source/SIMPLib/Geometry/RectGridGeom.cpp b/Source/SIMPLib/Geometry/RectGridGeom.cpp index 72aa3e731c..cf52ca4f59 100644 --- a/Source/SIMPLib/Geometry/RectGridGeom.cpp +++ b/Source/SIMPLib/Geometry/RectGridGeom.cpp @@ -208,7 +208,7 @@ class FindRectGridDerivativesImpl // Compute the actual derivatives index = (z * dims[1] * dims[0]) + (y * dims[0]) + x; - for(int32_t i = 0; i < numComps; i++) + for(size_t i = 0; i < numComps; i++) { derivsPtr[index * numComps * 3 + i * 3] = xix * dValuesdXi[i] + etax * dValuesdEta[i] + zetax * dValuesdZeta[i]; @@ -402,9 +402,6 @@ RectGridGeom::RectGridGeom() m_GeometryTypeName = SIMPL::Geometry::RectGridGeometry; m_GeometryType = IGeometry::Type::RectGrid; m_XdmfGridType = SIMPL::XdmfGridType::RectilinearGrid; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 3; m_SpatialDimensionality = 3; m_Dimensions[0] = 0; @@ -440,7 +437,47 @@ RectGridGeom::Pointer RectGridGeom::CreateGeometry(const QString& name) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RectGridGeom::setXBounds(FloatArrayType::Pointer xBnds) +SIMPL::Tuple3SVec RectGridGeom::getDimensions() const +{ + return m_Dimensions.toTuple(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RectGridGeom::getDimensions(SizeVec3Type& dims) const +{ + dims = m_Dimensions; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RectGridGeom::setDimensions(const SizeVec3Type& dims) +{ + m_Dimensions = dims; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RectGridGeom::setDimensions(SizeVec3Type& dims) +{ + m_Dimensions = dims; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RectGridGeom::setDimensions(const SIMPL::Tuple3SVec& dims) +{ + m_Dimensions = dims; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RectGridGeom::setXBounds(const FloatArrayType::Pointer& xBnds) { if(xBnds.get() != nullptr) { @@ -455,7 +492,7 @@ void RectGridGeom::setXBounds(FloatArrayType::Pointer xBnds) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RectGridGeom::setYBounds(FloatArrayType::Pointer yBnds) +void RectGridGeom::setYBounds(const FloatArrayType::Pointer& yBnds) { if(yBnds.get() != nullptr) { @@ -470,7 +507,7 @@ void RectGridGeom::setYBounds(FloatArrayType::Pointer yBnds) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RectGridGeom::setZBounds(FloatArrayType::Pointer zBnds) +void RectGridGeom::setZBounds(const FloatArrayType::Pointer& zBnds) { if(zBnds.get() != nullptr) { @@ -482,6 +519,46 @@ void RectGridGeom::setZBounds(FloatArrayType::Pointer zBnds) m_zBounds = zBnds; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FloatArrayType::Pointer RectGridGeom::getXBounds() const +{ + return m_xBounds; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FloatArrayType::Pointer RectGridGeom::getYBounds() const +{ + return m_yBounds; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FloatArrayType::Pointer RectGridGeom::getZBounds() const +{ + return m_zBounds; +} + +// ----------------------------------------------------------------------------- +size_t RectGridGeom::getXPoints() +{ + return m_Dimensions[0]; +} +// ----------------------------------------------------------------------------- +size_t RectGridGeom::getYPoints() +{ + return m_Dimensions[1]; +} +// ----------------------------------------------------------------------------- +size_t RectGridGeom::getZPoints() +{ + return m_Dimensions[2]; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -629,9 +706,9 @@ void RectGridGeom::getCoords(size_t idx[3], double coords[3]) float* yBnds = m_yBounds->getPointer(0); float* zBnds = m_zBounds->getPointer(0); - coords[0] = static_cast(0.5 * (xBnds[idx[0]] + xBnds[idx[0] + 1])); - coords[1] = static_cast(0.5 * (yBnds[idx[1]] + yBnds[idx[1] + 1])); - coords[2] = static_cast(0.5 * (zBnds[idx[2]] + zBnds[idx[2] + 1])); + coords[0] = 0.5 * (static_cast(xBnds[idx[0]]) + xBnds[idx[0] + 1]); + coords[1] = 0.5 * (static_cast(yBnds[idx[1]]) + yBnds[idx[1] + 1]); + coords[2] = 0.5 * (static_cast(zBnds[idx[2]]) + zBnds[idx[2] + 1]); } // ----------------------------------------------------------------------------- @@ -643,9 +720,9 @@ void RectGridGeom::getCoords(size_t x, size_t y, size_t z, double coords[3]) float* yBnds = m_yBounds->getPointer(0); float* zBnds = m_zBounds->getPointer(0); - coords[0] = static_cast(0.5 * (xBnds[x] + xBnds[x + 1])); - coords[1] = static_cast(0.5 * (yBnds[y] + yBnds[y + 1])); - coords[2] = static_cast(0.5 * (zBnds[z] + zBnds[z + 1])); + coords[0] = 0.5 * (static_cast(xBnds[x]) + xBnds[x + 1]); + coords[1] = 0.5 * (static_cast(yBnds[y]) + yBnds[y + 1]); + coords[2] = 0.5 * (static_cast(zBnds[z]) + zBnds[z + 1]); } // ----------------------------------------------------------------------------- @@ -661,9 +738,9 @@ void RectGridGeom::getCoords(size_t idx, double coords[3]) float* yBnds = m_yBounds->getPointer(0); float* zBnds = m_zBounds->getPointer(0); - coords[0] = static_cast(0.5f * (xBnds[column] + xBnds[column + 1])); - coords[1] = static_cast(0.5f * (yBnds[row] + yBnds[row + 1])); - coords[2] = static_cast(0.5f * (zBnds[plane] + zBnds[plane + 1])); + coords[0] = 0.5 * (static_cast(xBnds[column]) + xBnds[column + 1]); + coords[1] = 0.5 * (static_cast(yBnds[row]) + yBnds[row + 1]); + coords[2] = 0.5 * (static_cast(zBnds[plane]) + zBnds[plane + 1]); } // ----------------------------------------------------------------------------- @@ -683,7 +760,7 @@ void RectGridGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RectGridGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void RectGridGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if(data->getType() != AttributeMatrix::Type::Cell) { @@ -694,10 +771,10 @@ void RectGridGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Poin { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } @@ -925,7 +1002,7 @@ void RectGridGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayTy if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -1058,19 +1135,26 @@ QString RectGridGeom::getInfoString(SIMPL::InfoStringFormat format) int64_t volDims[3] = {static_cast(getXPoints()), static_cast(getYPoints()), static_cast(getZPoints())}; - if(format == SIMPL::HtmlFormat) + QString bgColorLabel = ""; + + switch(format) { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Dimensions:" << volDims[0] << " x " << volDims[1] << " x " << volDims[2] << ""; - ss << "Resolution:" + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Dimensions:" << volDims[0] << " x " << volDims[1] << " x " << volDims[2] << ""; + ss << "Spacing:" << "Variable" << ""; + break; + default: + ss << "Requested Rectilinear Grid Geometry information string format is not supported. " << format; + break; } - else - { - } + return info; } diff --git a/Source/SIMPLib/Geometry/RectGridGeom.h b/Source/SIMPLib/Geometry/RectGridGeom.h index a323b9d9c4..5b7eb14f5c 100644 --- a/Source/SIMPLib/Geometry/RectGridGeom.h +++ b/Source/SIMPLib/Geometry/RectGridGeom.h @@ -56,18 +56,18 @@ class SIMPLib_EXPORT RectGridGeom : public IGeometryGrid * @return */ static Pointer CreateGeometry(const QString& name); - - void setXBounds(FloatArrayType::Pointer xBounds); - void setYBounds(FloatArrayType::Pointer yBounds); - void setZBounds(FloatArrayType::Pointer zBounds); - inline FloatArrayType::Pointer getXBounds() { return m_xBounds; } - inline FloatArrayType::Pointer getYBounds() { return m_yBounds; } - inline FloatArrayType::Pointer getZBounds() { return m_zBounds; } + void setXBounds(const FloatArrayType::Pointer& xBounds); + void setYBounds(const FloatArrayType::Pointer& yBounds); + void setZBounds(const FloatArrayType::Pointer& zBounds); -// ----------------------------------------------------------------------------- -// Inherited from IGeometry -// ----------------------------------------------------------------------------- + FloatArrayType::Pointer getXBounds() const; + FloatArrayType::Pointer getYBounds() const; + FloatArrayType::Pointer getZBounds() const; + + // ----------------------------------------------------------------------------- + // Inherited from IGeometry + // ----------------------------------------------------------------------------- /** * @brief initializeWithZeros @@ -207,20 +207,23 @@ class SIMPLib_EXPORT RectGridGeom : public IGeometryGrid IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; // ----------------------------------------------------------------------------- // Inherited from IGeometryGrid // ----------------------------------------------------------------------------- + SIMPL::Tuple3SVec getDimensions() const override; + void getDimensions(SizeVec3Type& dims) const; - SIMPL_INSTANCE_VEC3_PROPERTY_VO(size_t, Dimensions) + void setDimensions(const SizeVec3Type& dims) override; + void setDimensions(SizeVec3Type& dims) override; + void setDimensions(const SIMPL::Tuple3SVec& dims) override; - - size_t getXPoints() override { return m_Dimensions[0]; } - size_t getYPoints() override { return m_Dimensions[1]; } - size_t getZPoints() override { return m_Dimensions[2]; } + size_t getXPoints() override; + size_t getYPoints() override; + size_t getZPoints() override; void getPlaneCoords(size_t idx[3], float coords[3]) override; void getPlaneCoords(size_t x, size_t y, size_t z, float coords[3]) override; @@ -279,6 +282,7 @@ class SIMPLib_EXPORT RectGridGeom : public IGeometryGrid FloatArrayType::Pointer m_yBounds; FloatArrayType::Pointer m_zBounds; FloatArrayType::Pointer m_VoxelSizes; + SizeVec3Type m_Dimensions; friend class FindRectGridDerivativesImpl; diff --git a/Source/SIMPLib/Geometry/ShapeOps/CubeOctohedronOps.cpp b/Source/SIMPLib/Geometry/ShapeOps/CubeOctohedronOps.cpp index 6ae6e8c8d8..eecdddf8a3 100644 --- a/Source/SIMPLib/Geometry/ShapeOps/CubeOctohedronOps.cpp +++ b/Source/SIMPLib/Geometry/ShapeOps/CubeOctohedronOps.cpp @@ -120,7 +120,7 @@ float CubeOctohedronOps::inside(float axis1comp, float axis2comp, float axis3com float plane3comp = ((axis1comp) + (axis2comp) + (axis3comp) - ((2.0f - (0.5f * Gvalue)) + (2.0f - (0.5f * Gvalue)) + 2.0f)); plane3comp = plane3comp / ((1) + (1) + (1) - ((2.0f - (0.5f * Gvalue)) + (2.0f - (0.5f * Gvalue)) + 2.0f)); - float plane4comp = static_cast(((-axis1comp) + (axis2comp) + (axis3comp) - ((-0.5f * Gvalue) + (2.0f - (0.5 * Gvalue)) + 2.0f))); + float plane4comp = ((-axis1comp) + (axis2comp) + (axis3comp) - ((-0.5f * Gvalue) + (2.0f - (0.5f * Gvalue)) + 2.0f)); plane4comp = plane4comp / ((-1) + (1) + (1) - ((-0.5f * Gvalue) + (2.0f - (0.5f * Gvalue)) + 2.0f)); float plane5comp = ((-axis1comp) + (-axis2comp) + (-axis3comp) - ((-0.5f * Gvalue) + (-0.5f * Gvalue))); @@ -130,7 +130,7 @@ float CubeOctohedronOps::inside(float axis1comp, float axis2comp, float axis3com plane6comp = plane6comp / ((1) + (-1) + (-1) - ((2.0f - (0.5f * Gvalue)) + (-0.5f * Gvalue))); float plane7comp = ((axis1comp) + (axis2comp) + (-axis3comp) - ((2.0f - (0.5f * Gvalue)) + (2.0f - (0.5f * Gvalue)))); - plane7comp = static_cast(plane7comp / ((1) + (1) + (-1) - ((2.0f - (0.5f * Gvalue)) + (2.0f - (0.5 * Gvalue))))); + plane7comp = plane7comp / ((1) + (1) + (-1) - ((2.0f - (0.5f * Gvalue)) + (2.0f - (0.5f * Gvalue)))); float plane8comp = ((-axis1comp) + (axis2comp) + (-axis3comp) - ((-0.5f * Gvalue) + (2.0f - (0.5f * Gvalue)))); plane8comp = plane8comp / ((-1) + (1) + (-1) - ((-0.5f * Gvalue) + (2 - (0.5f * Gvalue)))); diff --git a/Source/SIMPLib/Geometry/SharedEdgeOps.cpp b/Source/SIMPLib/Geometry/SharedEdgeOps.cpp index 740077844e..a4d18b8b3e 100644 --- a/Source/SIMPLib/Geometry/SharedEdgeOps.cpp +++ b/Source/SIMPLib/Geometry/SharedEdgeOps.cpp @@ -49,7 +49,7 @@ SharedEdgeList::Pointer GEOM_CLASS_NAME::CreateSharedEdgeList(int64_t numEdges, // ----------------------------------------------------------------------------- void GEOM_CLASS_NAME::resizeEdgeList(int64_t newNumEdges) { - m_EdgeList->resize(newNumEdges); + m_EdgeList->resizeTuples(newNumEdges); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Geometry/SharedHexOps.cpp b/Source/SIMPLib/Geometry/SharedHexOps.cpp index 7ac11aedcf..bb103f97c2 100644 --- a/Source/SIMPLib/Geometry/SharedHexOps.cpp +++ b/Source/SIMPLib/Geometry/SharedHexOps.cpp @@ -14,7 +14,7 @@ SharedHexList::Pointer GEOM_CLASS_NAME::CreateSharedHexList(int64_t numHexas, bo // ----------------------------------------------------------------------------- void GEOM_CLASS_NAME::resizeHexList(int64_t newNumHexas) { - m_HexList->resize(newNumHexas); + m_HexList->resizeTuples(newNumHexas); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Geometry/SharedQuadOps.cpp b/Source/SIMPLib/Geometry/SharedQuadOps.cpp index 6413ec690a..6cea373bad 100644 --- a/Source/SIMPLib/Geometry/SharedQuadOps.cpp +++ b/Source/SIMPLib/Geometry/SharedQuadOps.cpp @@ -49,7 +49,7 @@ SharedQuadList::Pointer GEOM_CLASS_NAME::CreateSharedQuadList(int64_t numQuads, // ----------------------------------------------------------------------------- void GEOM_CLASS_NAME::resizeQuadList(int64_t newNumQuads) { - m_QuadList->resize(newNumQuads); + m_QuadList->resizeTuples(newNumQuads); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Geometry/SharedTetOps.cpp b/Source/SIMPLib/Geometry/SharedTetOps.cpp index 649bd099cb..298f77fd31 100644 --- a/Source/SIMPLib/Geometry/SharedTetOps.cpp +++ b/Source/SIMPLib/Geometry/SharedTetOps.cpp @@ -49,7 +49,7 @@ SharedTetList::Pointer GEOM_CLASS_NAME::CreateSharedTetList(int64_t numTets, boo // ----------------------------------------------------------------------------- void GEOM_CLASS_NAME::resizeTetList(int64_t newNumTets) { - m_TetList->resize(newNumTets); + m_TetList->resizeTuples(newNumTets); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Geometry/SharedTriOps.cpp b/Source/SIMPLib/Geometry/SharedTriOps.cpp index fac7ef6506..e7da99830a 100644 --- a/Source/SIMPLib/Geometry/SharedTriOps.cpp +++ b/Source/SIMPLib/Geometry/SharedTriOps.cpp @@ -49,7 +49,7 @@ SharedTriList::Pointer GEOM_CLASS_NAME::CreateSharedTriList(int64_t numTris, boo // ----------------------------------------------------------------------------- void GEOM_CLASS_NAME::resizeTriList(int64_t newNumTris) { - m_TriList->resize(newNumTris); + m_TriList->resizeTuples(newNumTris); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Geometry/SharedVertexOps.cpp b/Source/SIMPLib/Geometry/SharedVertexOps.cpp index 83580756c1..a5b2aad299 100644 --- a/Source/SIMPLib/Geometry/SharedVertexOps.cpp +++ b/Source/SIMPLib/Geometry/SharedVertexOps.cpp @@ -49,7 +49,7 @@ SharedVertexList::Pointer GEOM_CLASS_NAME::CreateSharedVertexList(int64_t numVer // ----------------------------------------------------------------------------- void GEOM_CLASS_NAME::resizeVertexList(int64_t newNumVertices) { - m_VertexList->resize(newNumVertices); + m_VertexList->resizeTuples(newNumVertices); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Geometry/Testing/Cxx/ImageGeomTest.cpp b/Source/SIMPLib/Geometry/Testing/Cxx/ImageGeomTest.cpp index cff2dbe087..b90200a3df 100644 --- a/Source/SIMPLib/Geometry/Testing/Cxx/ImageGeomTest.cpp +++ b/Source/SIMPLib/Geometry/Testing/Cxx/ImageGeomTest.cpp @@ -34,13 +34,13 @@ class ImageGeomTest void TestIndexCalculation() { ImageGeom::Pointer geom = ImageGeom::CreateGeometry("Test Geometry"); - size_t dims[3] = {10, 20, 30}; - float res[3] = {0.4f, 2.3f, 5.0f}; - float origin[3] = {-1.0f, 6.0f, 10.0f}; + SizeVec3Type dims(10, 20, 30); + FloatVec3Type res = {0.4f, 2.3f, 5.0f}; + FloatVec3Type origin = {-1.0f, 6.0f, 10.0f}; geom->setDimensions(dims); geom->setOrigin(origin); - geom->getResolution(res); + geom->getSpacing(res); float coords[3] = {3.5f, 9.23f, 12.78f}; size_t indices[3] = {0, 0, 0}; diff --git a/Source/SIMPLib/Geometry/TetrahedralGeom.cpp b/Source/SIMPLib/Geometry/TetrahedralGeom.cpp index 431e95e2cd..7e248f4859 100644 --- a/Source/SIMPLib/Geometry/TetrahedralGeom.cpp +++ b/Source/SIMPLib/Geometry/TetrahedralGeom.cpp @@ -87,7 +87,7 @@ class FindTetDerivativesImpl for(int64_t i = start; i < end; i++) { m_Tets->getVertsAtTet(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 4; k++) { @@ -128,9 +128,6 @@ TetrahedralGeom::TetrahedralGeom() m_GeometryTypeName = SIMPL::Geometry::TetrahedralGeometry; m_GeometryType = IGeometry::Type::Tetrahedral; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 3; m_SpatialDimensionality = 3; m_VertexList = TetrahedralGeom::CreateSharedVertexList(0); @@ -206,11 +203,11 @@ void TetrahedralGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TetrahedralGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void TetrahedralGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if(data->getType() != AttributeMatrix::Type::Vertex - || data->getType() != AttributeMatrix::Type::Edge - || data->getType() != AttributeMatrix::Type::Face || data->getType() != AttributeMatrix::Type::Cell) + && data->getType() != AttributeMatrix::Type::Edge + && data->getType() != AttributeMatrix::Type::Face || data->getType() != AttributeMatrix::Type::Cell) { // TetrahedralGeom can only accept vertex, edge, face or cell Attribute Matrices return; @@ -231,10 +228,10 @@ void TetrahedralGeom::addAttributeMatrix(const QString& name, AttributeMatrix::P { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } @@ -578,7 +575,7 @@ void TetrahedralGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArra if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -762,17 +759,24 @@ QString TetrahedralGeom::getInfoString(SIMPL::InfoStringFormat format) QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) - { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Tetrahedra" << getNumberOfTets() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; - } - else + QString bgColorLabel = ""; + + switch(format) { + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Number of Tetrahedra" << getNumberOfTets() << ""; + ss << "Number of Vertices" << getNumberOfVertices() << ""; + break; + default: + ss << "Requested Tetrahedral Geometry information string format is not supported. " << format; + break; } + return info; } diff --git a/Source/SIMPLib/Geometry/TetrahedralGeom.h b/Source/SIMPLib/Geometry/TetrahedralGeom.h index 4d2d72abea..43e0f72cc3 100644 --- a/Source/SIMPLib/Geometry/TetrahedralGeom.h +++ b/Source/SIMPLib/Geometry/TetrahedralGeom.h @@ -363,9 +363,9 @@ class SIMPLib_EXPORT TetrahedralGeom : public IGeometry3D IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; // ----------------------------------------------------------------------------- // Inherited from IGeometry3D diff --git a/Source/SIMPLib/Geometry/TriangleGeom.cpp b/Source/SIMPLib/Geometry/TriangleGeom.cpp index 4fc6591192..d8079682c5 100644 --- a/Source/SIMPLib/Geometry/TriangleGeom.cpp +++ b/Source/SIMPLib/Geometry/TriangleGeom.cpp @@ -87,7 +87,7 @@ class FindTriangleDerivativesImpl for(int64_t i = start; i < end; i++) { m_Tris->getVertsAtTri(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 3; k++) { @@ -128,9 +128,6 @@ TriangleGeom::TriangleGeom() m_GeometryTypeName = SIMPL::Geometry::TriangleGeometry; m_GeometryType = IGeometry::Type::Triangle; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 2; m_SpatialDimensionality = 3; m_VertexList = TriangleGeom::CreateSharedVertexList(0); @@ -204,9 +201,9 @@ void TriangleGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TriangleGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void TriangleGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { - if(data->getType() != AttributeMatrix::Type::Vertex || data->getType() != AttributeMatrix::Type::Edge || data->getType() != AttributeMatrix::Type::Face) + if(data->getType() != AttributeMatrix::Type::Vertex && data->getType() != AttributeMatrix::Type::Edge && data->getType() != AttributeMatrix::Type::Face) { // TriangleGeom can only accept vertex, edge, or face Attribute Matrices return; @@ -223,10 +220,10 @@ void TriangleGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Poin { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } @@ -500,7 +497,7 @@ void TriangleGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayTy if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } #ifdef SIMPL_USE_PARALLEL_ALGORITHMS @@ -667,17 +664,24 @@ QString TriangleGeom::getInfoString(SIMPL::InfoStringFormat format) QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) - { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Triangles" << getNumberOfTris() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; - } - else + QString bgColorLabel = ""; + + switch(format) { + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Number of Triangles" << getNumberOfTris() << ""; + ss << "Number of Vertices" << getNumberOfVertices() << ""; + break; + default: + ss << "Requested Triangle Geometry information string format is not supported. " << format; + break; } + return info; } diff --git a/Source/SIMPLib/Geometry/TriangleGeom.h b/Source/SIMPLib/Geometry/TriangleGeom.h index 9bd26a4850..eec4095b86 100644 --- a/Source/SIMPLib/Geometry/TriangleGeom.h +++ b/Source/SIMPLib/Geometry/TriangleGeom.h @@ -316,9 +316,9 @@ class SIMPLib_EXPORT TriangleGeom : public IGeometry2D IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; // ----------------------------------------------------------------------------- // Inherited from IGeometry2D diff --git a/Source/SIMPLib/Geometry/VertexGeom.cpp b/Source/SIMPLib/Geometry/VertexGeom.cpp index 5422cb09f8..9080140e68 100644 --- a/Source/SIMPLib/Geometry/VertexGeom.cpp +++ b/Source/SIMPLib/Geometry/VertexGeom.cpp @@ -52,9 +52,6 @@ VertexGeom::VertexGeom() m_GeometryTypeName = SIMPL::Geometry::VertexGeometry; m_GeometryType = IGeometry::Type::Vertex; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 0; m_SpatialDimensionality = 3; m_VertexList = VertexGeom::CreateSharedVertexList(0); @@ -115,7 +112,7 @@ void VertexGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void VertexGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void VertexGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if(data->getType() != AttributeMatrix::Type::Vertex) { @@ -126,10 +123,10 @@ void VertexGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointe { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + //if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } @@ -411,17 +408,24 @@ QString VertexGeom::getInfoString(SIMPL::InfoStringFormat format) QString info; QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) + QString bgColorLabel = ""; + + switch(format) { - ss << "Geometry Info"; - ss << R"(Type)" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << R"(Number of Vertices)" << getNumberOfVertices() << ""; + case SIMPL::ToolTipFormat: + bgColorLabel = "bgcolor=\"#FFFCEA\""; + case SIMPL::HtmlFormat: + ss << "Geometry Info"; + ss << "Type" << TypeToString(getGeometryType()) << ""; + ss << "Units" << LengthUnitToString(getUnits()) << ""; + ss << "Number of Vertices" << getNumberOfVertices() << ""; ss << ""; + break; + default: + ss << "Requested Vertex Geometry information string format is not supported. " << format; + break; } - else - { - } + return info; } diff --git a/Source/SIMPLib/Geometry/VertexGeom.h b/Source/SIMPLib/Geometry/VertexGeom.h index 020aec2524..c8f149bc2d 100644 --- a/Source/SIMPLib/Geometry/VertexGeom.h +++ b/Source/SIMPLib/Geometry/VertexGeom.h @@ -284,9 +284,9 @@ class SIMPLib_EXPORT VertexGeom : public IGeometry IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; protected: VertexGeom(); diff --git a/Source/SIMPLib/HDF5/H5DataArrayWriter.hpp b/Source/SIMPLib/HDF5/H5DataArrayWriter.hpp index 5a94fa31aa..c5f113f129 100755 --- a/Source/SIMPLib/HDF5/H5DataArrayWriter.hpp +++ b/Source/SIMPLib/HDF5/H5DataArrayWriter.hpp @@ -121,7 +121,7 @@ class H5DataArrayWriter int err = 0; QVector cDims = dataArray->getComponentDimensions(); - hsize_t h5Rank = tDims.size() + cDims.size(); + hsize_t h5Rank = static_cast(tDims.size()) + cDims.size(); QVector h5Dims(tDims.size() + cDims.size()); diff --git a/Source/SIMPLib/ITK/Dream3DTemplateAliasMacro.h b/Source/SIMPLib/ITK/Dream3DTemplateAliasMacro.h index 2d15122ac6..7bb474eaed 100644 --- a/Source/SIMPLib/ITK/Dream3DTemplateAliasMacro.h +++ b/Source/SIMPLib/ITK/Dream3DTemplateAliasMacro.h @@ -157,12 +157,11 @@ Dream3DTemplateAliasMacroCase_##value(typeIN, typeOUT, call, var_type, tDims, errorCondition, QUOTE(typeIN), isTypeOUT, typeOUTTypename) // Type is not accepted, throw an error message. -#define Dream3DTemplateAliasMacroCase_0(typeIN, typeOUT, call, var_type, tDims, errorCondition, quotedType, isTypeOUT, typeOUTTypename) \ - if(var_type.compare(quotedType) == 0) \ - { \ - setErrorCondition(errorCondition); \ - QString errorMessage = QString("Unsupported pixel type: %1.").arg(quotedType); \ - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); \ +#define Dream3DTemplateAliasMacroCase_0(typeIN, typeOUT, call, var_type, tDims, errorCondition, quotedType, isTypeOUT, typeOUTTypename) \ + if(var_type.compare(quotedType) == 0) \ + { \ + QString errorMessage = QString("Unsupported pixel type: %1.").arg(quotedType); \ + setErrorCondition(errorCondition, errorMessage); \ } // Type is accepted, select the dimension of the input and output images @@ -182,27 +181,26 @@ } // Select vector, RGB/RGBA, or scalar images -#define Dream3DTemplateAliasMacroPixelType(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ - QVector cDims = ptr->getComponentDimensions(); \ - if(cDims.size() > 1) \ - { \ - Dream3DTemplateAliasMacroCaseVectorImage0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, DREAM3D_USE_Vector); \ - } \ - else \ - { \ - if(cDims[0] == 1) \ - { \ - Dream3DTemplateAliasMacroCaseScalarImage0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, DREAM3D_USE_Scalar); \ - } \ - else if(cDims[0] == 3 || cDims[0] == 4) \ - { \ - Dream3DTemplateAliasMacroCaseRGBRGBAImage0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, DREAM3D_USE_RGB_RGBA, cDims[0]); \ - } \ - else \ - { \ - setErrorCondition(errorCondition); \ - notifyErrorMessage(getHumanLabel(), QString("Size of tuple not handled:%1").arg(cDims[0]), getErrorCondition()); \ - } \ +#define Dream3DTemplateAliasMacroPixelType(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ + QVector cDims = ptr->getComponentDimensions(); \ + if(cDims.size() > 1) \ + { \ + Dream3DTemplateAliasMacroCaseVectorImage0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, DREAM3D_USE_Vector); \ + } \ + else \ + { \ + if(cDims[0] == 1) \ + { \ + Dream3DTemplateAliasMacroCaseScalarImage0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, DREAM3D_USE_Scalar); \ + } \ + else if(cDims[0] == 3 || cDims[0] == 4) \ + { \ + Dream3DTemplateAliasMacroCaseRGBRGBAImage0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, DREAM3D_USE_RGB_RGBA, cDims[0]); \ + } \ + else \ + { \ + setErrorCondition(errorCondition, QString("Size of tuple not handled:%1").arg(cDims[0])); \ + } \ } // Replaces typeOUT by typeIN if no typeOUT is given @@ -228,9 +226,8 @@ #define Dream3DTemplateAliasMacroCaseScalarImage1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, Scalar) \ Dream3DTemplateAliasMacroCaseScalarImage1_##Scalar(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) // Scalar images not accepted, throw an error message if a scalar image is given. -#define Dream3DTemplateAliasMacroCaseScalarImage1_0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ - setErrorCondition(errorCondition); \ - notifyErrorMessage(getHumanLabel(), "Scalar images not supported. Try RGB/RGBA or vector images", getErrorCondition()); +#define Dream3DTemplateAliasMacroCaseScalarImage1_0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ + setErrorCondition(errorCondition, "Scalar images not supported. Try RGB/RGBA or vector images"); // Scalar images accepted #define Dream3DTemplateAliasMacroCaseScalarImage1_1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ Dream3DTemplateAliasMacroCase_1_##isTypeOUT(typeIN, typeOUT, call, typeOUTTypename, dimension) @@ -252,36 +249,32 @@ #define Dream3DTemplateAliasMacroCaseVectorImage1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, Vector) \ Dream3DTemplateAliasMacroCaseVectorImage1_##Vector(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) // Vector images not accepted, throw an error message if a vector image is given. -#define Dream3DTemplateAliasMacroCaseVectorImage1_0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ - setErrorCondition(errorCondition); \ - notifyErrorMessage( \ - getHumanLabel(), \ - "Vector not supported. Try converting the selected input image to an image with scalar components using 'ITK::RGB to Luminance ImageFilter' or 'Convert Rgb To GrayScale' filters", \ - getErrorCondition()); +#define Dream3DTemplateAliasMacroCaseVectorImage1_0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ + setErrorCondition( \ + errorCondition, \ + "Vector not supported. Try converting the selected input image to an image with scalar components using 'ITK::RGB to Luminance ImageFilter' or 'Convert Rgb To GrayScale' filters"); \ // Vector images: Call the given function with the correct dimension after defining the input and output vector types. -#define Dream3DTemplateAliasMacroCaseVectorImage1_1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ - if(cDims.size() == 2) \ - { \ - DefineVectorPixelTypes_##isTypeOUT(typeIN, typeOUT, 2); \ - Dream3DTemplateAliasMacroCaseIf(InputPixelType, OutputPixelType, call, typeOUTTypename, dimension); \ - } \ - else if(cDims.size() == 3) \ - { \ - DefineVectorPixelTypes_##isTypeOUT(typeIN, typeOUT, 3); \ - Dream3DTemplateAliasMacroCaseIf(InputPixelType, OutputPixelType, call, typeOUTTypename, dimension); \ - } \ - else if(cDims.size() == 36) \ - { \ - DefineVectorPixelTypes_##isTypeOUT(typeIN, typeOUT, 36); \ - Dream3DTemplateAliasMacroCaseIf(InputPixelType, OutputPixelType, call, typeOUTTypename, dimension); \ - } \ - else \ - { \ - setErrorCondition(errorCondition); \ - notifyErrorMessage( \ - getHumanLabel(), \ - "Vector dimension not supported. Try converting the selected input image to an image with scalar components using 'ITK::RGB to Luminance ImageFilter' or 'Convert Rgb To GrayScale' filters", \ - getErrorCondition()); \ +#define Dream3DTemplateAliasMacroCaseVectorImage1_1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension) \ + if(cDims.size() == 2) \ + { \ + DefineVectorPixelTypes_##isTypeOUT(typeIN, typeOUT, 2); \ + Dream3DTemplateAliasMacroCaseIf(InputPixelType, OutputPixelType, call, typeOUTTypename, dimension); \ + } \ + else if(cDims.size() == 3) \ + { \ + DefineVectorPixelTypes_##isTypeOUT(typeIN, typeOUT, 3); \ + Dream3DTemplateAliasMacroCaseIf(InputPixelType, OutputPixelType, call, typeOUTTypename, dimension); \ + } \ + else if(cDims.size() == 36) \ + { \ + DefineVectorPixelTypes_##isTypeOUT(typeIN, typeOUT, 36); \ + Dream3DTemplateAliasMacroCaseIf(InputPixelType, OutputPixelType, call, typeOUTTypename, dimension); \ + } \ + else \ + { \ + setErrorCondition( \ + errorCondition, \ + "Vector dimension not supported. Try converting the selected input image to an image with scalar components using 'ITK::RGB to Luminance ImageFilter' or 'Convert Rgb To GrayScale' filters"); \ } ////////////////////////////////////////////////////////////////////////////// @@ -293,12 +286,10 @@ #define Dream3DTemplateAliasMacroCaseRGBRGBAImage1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, RGBRGBA, nbComponents) \ Dream3DTemplateAliasMacroCaseRGBRGBAImage1_##RGBRGBA(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, nbComponents) // If RGB/RGBA not accepted by the current filter, prints an error message -#define Dream3DTemplateAliasMacroCaseRGBRGBAImage1_0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, nbComponents) \ - setErrorCondition(errorCondition); \ - notifyErrorMessage( \ - getHumanLabel(), \ - "RGB/RGBA not supported. Try converting the selected input image to an image with scalar components using 'ITK::RGB to Luminance ImageFilter' or 'Convert Rgb To GrayScale' filters", \ - getErrorCondition()); +#define Dream3DTemplateAliasMacroCaseRGBRGBAImage1_0(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, nbComponents) \ + setErrorCondition( \ + errorCondition, \ + "RGB/RGBA not supported. Try converting the selected input image to an image with scalar components using 'ITK::RGB to Luminance ImageFilter' or 'Convert Rgb To GrayScale' filters"); \ // If RGB/RGBA accepted by current filter, call the macro that will call the given function #define Dream3DTemplateAliasMacroCaseRGBRGBAImage1_1(typeIN, typeOUT, call, errorCondition, isTypeOUT, typeOUTTypename, dimension, nbComponents) \ if(nbComponents == 3) \ @@ -330,33 +321,31 @@ // Define a macro that is specific to Dream3D and dispatches calls to a template // instantiated over the aliased scalar type based on the type of a data array // which is saved in the filter's data container array. -#define Dream3DArraySwitchMacroLongOutputType(call, path, errorCondition, typeOUT, isTypeOUT, typeOUTTypename) \ - { \ - IDataArray::Pointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); \ - if(nullptr != ptr) \ - { \ - ImageGeom::Pointer imageGeometry = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, path.getDataContainerName()); \ - if(nullptr != imageGeometry) \ - { \ - QVector tDims(3, 0); \ - std::tie(tDims[0], tDims[1], tDims[2]) = imageGeometry->getDimensions(); \ - if(getErrorCondition() >= 0) \ - { \ - QString type = ptr->getTypeAsString(); \ - Dream3DTemplateAliasMacro(call, type, typeOUT, tDims, errorCondition, isTypeOUT, typeOUTTypename); \ - } \ - } \ - else \ - { \ - setErrorCondition(errorCondition); \ - notifyErrorMessage(getHumanLabel(), "Geometry not found", getErrorCondition()); \ - } \ - } \ - else \ - { \ - setErrorCondition(errorCondition); \ - notifyErrorMessage(getHumanLabel(), "Array not found", getErrorCondition()); \ - } \ +#define Dream3DArraySwitchMacroLongOutputType(call, path, errorCondition, typeOUT, isTypeOUT, typeOUTTypename) \ + { \ + IDataArray::Pointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); \ + if(nullptr != ptr) \ + { \ + ImageGeom::Pointer imageGeometry = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, path.getDataContainerName()); \ + if(nullptr != imageGeometry) \ + { \ + QVector tDims(3, 0); \ + std::tie(tDims[0], tDims[1], tDims[2]) = imageGeometry->getDimensions(); \ + if(getErrorCode() >= 0) \ + { \ + QString type = ptr->getTypeAsString(); \ + Dream3DTemplateAliasMacro(call, type, typeOUT, tDims, errorCondition, isTypeOUT, typeOUTTypename); \ + } \ + } \ + else \ + { \ + setErrorCondition(errorCondition, "Geometry not found"); \ + } \ + } \ + else \ + { \ + setErrorCondition(errorCondition, "Array not found"); \ + } \ } ////////////////////////////////////////////////////////////////////////////// @@ -384,43 +373,42 @@ // itk::ImageIOBase::IOComponentType '0' value is UNKNOWNCOMPONENTTYPE and therefore // should be skipped. // -#define Dream3DArraySwitchOutputComponentMacro(call, type, path, errorCondition) \ - switch(type) \ - { \ - case itk::ImageIOBase::IOComponentType::UCHAR - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, uint8_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::CHAR - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, int8_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::USHORT - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, uint16_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::SHORT - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, int16_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::UINT - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, uint32_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::INT - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, int32_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::ULONG - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, uint64_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::LONG - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, int64_t, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::FLOAT - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, float, 0); \ - break; \ - case itk::ImageIOBase::IOComponentType::DOUBLE - 1: \ - Dream3DArraySwitchMacroOutputType(call, path, -4, double, 0); \ - break; \ - default: \ - setErrorCondition(-4); \ - notifyErrorMessage(getHumanLabel(), "Unsupported pixel component", errorCondition); \ - break; \ +#define Dream3DArraySwitchOutputComponentMacro(call, type, path, errorCondition) \ + switch(type) \ + { \ + case itk::ImageIOBase::IOComponentType::UCHAR - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, uint8_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::CHAR - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, int8_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::USHORT - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, uint16_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::SHORT - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, int16_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::UINT - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, uint32_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::INT - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, int32_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::ULONG - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, uint64_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::LONG - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, int64_t, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::FLOAT - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, float, 0); \ + break; \ + case itk::ImageIOBase::IOComponentType::DOUBLE - 1: \ + Dream3DArraySwitchMacroOutputType(call, path, errorCondition, double, 0); \ + break; \ + default: \ + setErrorCondition(errorCondition, "Unsupported pixel component"); \ + break; \ } //////////////////////////////////////////////////////////////////////////////////////// @@ -441,7 +429,7 @@ { \ QVector tDims(3, 0); \ std::tie(tDims[0], tDims[1], tDims[2]) = imageGeometry->getDimensions(); \ - if(getErrorCondition() >= 0) \ + if(getErrorCode() >= 0) \ { \ QString str_type = ptr->getTypeAsString(); \ itk::ImageIOBase::IOComponentType type = itk::ImageIOBase::GetComponentTypeFromString(str_type.toStdString()); \ @@ -450,14 +438,11 @@ } \ else \ { \ - setErrorCondition(errorCondition); \ - notifyErrorMessage(getHumanLabel(), "Geometry not found", getErrorCondition()); \ + setErrorCondition(errorCondition, "Geometry not found"); \ } \ } \ else \ { \ - setErrorCondition(errorCondition); \ - notifyErrorMessage(getHumanLabel(), "Array not found", getErrorCondition()); \ + setErrorCondition(errorCondition, "Array not found"); \ } \ } - diff --git a/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DITransformContainerToTransformTest.cpp b/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DITransformContainerToTransformTest.cpp index 9f4144c11b..e62337a2b7 100644 --- a/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DITransformContainerToTransformTest.cpp +++ b/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DITransformContainerToTransformTest.cpp @@ -41,7 +41,7 @@ class itkDream3DITransformContainerToTransformTest public: itkDream3DITransformContainerToTransformTest() = default; - virtual ~itkDream3DITransformContainerToTransformTest() = default; + ~itkDream3DITransformContainerToTransformTest() = default; int TestitkDream3DITransformContainerToTransformTest() { diff --git a/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DTransformContainerToTransformTest.cpp b/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DTransformContainerToTransformTest.cpp index 1084ccf111..06bd2ac930 100644 --- a/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DTransformContainerToTransformTest.cpp +++ b/Source/SIMPLib/ITK/Testing/Cxx/itkDream3DTransformContainerToTransformTest.cpp @@ -40,7 +40,7 @@ class itkDream3DTransformContainerToTransformTest public: itkDream3DTransformContainerToTransformTest() = default; - virtual ~itkDream3DTransformContainerToTransformTest() = default; + ~itkDream3DTransformContainerToTransformTest() = default; int TestitkDream3DTransformContainerToTransformTest() { diff --git a/Source/SIMPLib/ITK/itkBridge.h b/Source/SIMPLib/ITK/itkBridge.h index 42ed025305..02ebb9a580 100644 --- a/Source/SIMPLib/ITK/itkBridge.h +++ b/Source/SIMPLib/ITK/itkBridge.h @@ -108,7 +108,7 @@ template class Dream3DToItkIm region.SetSize(size); importFilter->SetRegion(region); - float sampleOrigin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type sampleOrigin(0.0f, 0.0f, 0.0f); m->getGeometryAs()->getOrigin(sampleOrigin); double origin[ImageProcessingConstants::ImageDimension]; origin[0] = sampleOrigin[0]; // X coordinate @@ -116,8 +116,8 @@ template class Dream3DToItkIm origin[2] = sampleOrigin[2]; // Z coordinate importFilter->SetOrigin(origin); - float voxelResolution[3] = {0.0f, 0.0f, 0.0f}; - m->getGeometryAs()->getResolution(voxelResolution); + FloatVec3Type voxelResolution(0.0f, 0.0f, 0.0f); + m->getGeometryAs()->getSpacing(voxelResolution); double spacing[ImageProcessingConstants::ImageDimension]; spacing[0] = voxelResolution[0]; // along X direction spacing[1] = voxelResolution[1]; // along Y direction @@ -188,7 +188,7 @@ class ItkBridge2 importFilter->getGeometryAs()->setOrigin( origin ); float voxelResolution[3] = {0.0f, 0.0f, 0.0f}; - m->getGeometryAs()->getResolution(voxelResolution); + m->getGeometryAs()->getSpacing(voxelResolution); double spacing[ ImageProcessingConstants::ImageDimension ]; spacing[0] = voxelResolution[0]; // along X direction spacing[1] = voxelResolution[1]; // along Y direction @@ -212,19 +212,15 @@ class ItkBridge2 template class CreateItkWrapperForDataPointer { public: - CreateItkWrapperForDataPointer() - { - } - virtual ~CreateItkWrapperForDataPointer() - { - } + CreateItkWrapperForDataPointer() = default; + virtual ~CreateItkWrapperForDataPointer() = default; - typedef typename itk::Image ScalarImageType; // 3D Scalar Image - typedef typename ScalarImageType::Pointer ScalarImagePointerType; - typedef itk::ImportImageFilter ImportImageFilterType; - typedef typename ImportImageFilterType::Pointer ImportImageFilterPointerType; + using ScalarImageType = typename itk::Image; // 3D Scalar Image + using ScalarImagePointerType = typename ScalarImageType::Pointer; + using ImportImageFilterType = itk::ImportImageFilter; + using ImportImageFilterPointerType = typename ImportImageFilterType::Pointer; - ScalarImagePointerType operator()(DataContainer::Pointer m, QString attrMatName, ComponentType* data) + ScalarImagePointerType operator()(DataContainer::Pointer m, const QString& attrMatName, ComponentType* data) { AttributeMatrix::Pointer attrMat = m->getAttributeMatrix(attrMatName); @@ -233,7 +229,7 @@ template class CreateItkWrapperForDataPointer size_t totalPoints = attrMat->getNumberOfTuples(); // create and setup import filter - typedef itk::ImportImageFilter ImportImageFilterType; + using ImportImageFilterType = itk::ImportImageFilter; typename ImportImageFilterType::Pointer importFilter = ImportImageFilterType::New(); typename ImportImageFilterType::SizeType size; @@ -257,7 +253,7 @@ template class CreateItkWrapperForDataPointer region.SetSize(size); importFilter->SetRegion(region); - float sampleOrigin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type sampleOrigin = {0.0f, 0.0f, 0.0f}; m->getGeometryAs()->getOrigin(sampleOrigin); double origin[ImageProcessingConstants::ImageDimension]; origin[0] = sampleOrigin[0]; // X coordinate @@ -265,8 +261,8 @@ template class CreateItkWrapperForDataPointer origin[2] = sampleOrigin[2]; // Z coordinate importFilter->SetOrigin(origin); - float voxelResolution[3] = {0.0f, 0.0f, 0.0f}; - m->getGeometryAs()->getResolution(voxelResolution); + FloatVec3Type voxelResolution = {0.0f, 0.0f, 0.0f}; + m->getGeometryAs()->getSpacing(voxelResolution); double spacing[ImageProcessingConstants::ImageDimension]; spacing[0] = voxelResolution[0]; // along X direction spacing[1] = voxelResolution[1]; // along Y direction @@ -284,9 +280,11 @@ template class CreateItkWrapperForDataPointer return image; } -private: +public: CreateItkWrapperForDataPointer(const CreateItkWrapperForDataPointer&) = delete; // Copy Constructor Not Implemented - void operator=(const CreateItkWrapperForDataPointer&) = delete; // Move assignment Not Implemented + CreateItkWrapperForDataPointer(CreateItkWrapperForDataPointer&&) = delete; // Move Constructor Not Implemented + CreateItkWrapperForDataPointer& operator=(const CreateItkWrapperForDataPointer&) = delete; // Copy Assignment Not Implemented + CreateItkWrapperForDataPointer& operator=(CreateItkWrapperForDataPointer&&) = delete; // Move Assignment Not Implemented }; /* @@ -302,24 +300,21 @@ template class ItkBridge SIMPL_SHARED_POINTERS(ItkBridge) SIMPL_TYPE_MACRO(ItkBridge) - virtual ~ItkBridge() - { - } - + virtual ~ItkBridge() = default; //*! Define all the Typedefs for this class - typedef DataArray DataArrayType; - typedef typename DataArrayType::Pointer DataArrayPointerType; + using DataArrayType = DataArray; + using DataArrayPointerType = typename DataArrayType::Pointer; - typedef typename itk::Image ScalarImageType; // 3D Scalar Image - typedef typename itk::Image, ImageProcessingConstants::ImageDimension> RGBImageType; // 3D RGB Image - typedef typename itk::Image, ImageProcessingConstants::ImageDimension> RGBAImageType; // 3D RGBA Image + using ScalarImageType = typename itk::Image; // 3D Scalar Image + using RGBImageType = typename itk::Image, ImageProcessingConstants::ImageDimension>; // 3D RGB Image + using RGBAImageType = typename itk::Image, ImageProcessingConstants::ImageDimension>; // 3D RGBA Image - typedef typename itk::Image ScalarSliceImageType; // 2D Scalar Image - typedef typename itk::Image, ImageProcessingConstants::SliceDimension> RGBSliceImageType; // 2D RGB Image - typedef typename itk::Image, ImageProcessingConstants::SliceDimension> RGBASliceImageType; // 2D RGBA Image + using ScalarSliceImageType = typename itk::Image; // 2D Scalar Image + using RGBSliceImageType = typename itk::Image, ImageProcessingConstants::SliceDimension>; // 2D RGB Image + using RGBASliceImageType = typename itk::Image, ImageProcessingConstants::SliceDimension>; // 2D RGBA Image - typedef itk::ImportImageFilter ImportImageFilterType; - typedef typename ImportImageFilterType::Pointer ImportImageFilterPointerType; + using ImportImageFilterType = itk::ImportImageFilter; + using ImportImageFilterPointerType = typename ImportImageFilterType::Pointer; /** * @brief Dream3DtoITKImportFilter Grayscale conversion / copying & conversion from dream3d arrays to importfilter @@ -338,7 +333,7 @@ template class ItkBridge size_t totalPoints = attrMat->getNumberOfTuples(); // create and setup import filter - typedef itk::ImportImageFilter ImportImageFilterType; + using ImportImageFilterType = itk::ImportImageFilter; typename ImportImageFilterType::Pointer importFilter = ImportImageFilterType::New(); typename ImportImageFilterType::SizeType size; @@ -362,7 +357,7 @@ template class ItkBridge region.SetSize(size); importFilter->SetRegion(region); - float sampleOrigin[3] = {0.0f, 0.0f, 0.0f}; + FloatVec3Type sampleOrigin = {0.0f, 0.0f, 0.0f}; m->getGeometryAs()->getOrigin(sampleOrigin); double origin[ImageProcessingConstants::ImageDimension]; origin[0] = sampleOrigin[0]; // X coordinate @@ -370,8 +365,8 @@ template class ItkBridge origin[2] = sampleOrigin[2]; // Z coordinate importFilter->SetOrigin(origin); - float voxelResolution[3] = {0.0f, 0.0f, 0.0f}; - m->getGeometryAs()->getResolution(voxelResolution); + FloatVec3Type voxelResolution = {0.0f, 0.0f, 0.0f}; + m->getGeometryAs()->getSpacing(voxelResolution); double spacing[ImageProcessingConstants::ImageDimension]; spacing[0] = voxelResolution[0]; // along X direction spacing[1] = voxelResolution[1]; // along Y direction @@ -395,7 +390,7 @@ template class ItkBridge // size_t totalPoints = attrMat->getNumberOfTuples(); // create and setup import filter - typedef itk::ImportImageFilter ImportImageFilterType; + using ImportImageFilterType = itk::ImportImageFilter; typename ImportImageFilterType::Pointer importFilter = ImportImageFilterType::New(); typename ImportImageFilterType::SizeType size; @@ -428,7 +423,7 @@ template class ItkBridge importFilter->SetOrigin(origin); // float voxelResolution[3] = {0.0f, 0.0f, 0.0f}; - // m->getResolution(voxelResolution); + // m->getSpacing(voxelResolution); double spacing[ImageProcessingConstants::ImageDimension]; spacing[0] = voxelResolution[0]; // along X direction spacing[1] = voxelResolution[1]; // along Y direction @@ -512,7 +507,7 @@ template class ItkBridge */ static typename ScalarSliceImageType::Pointer ExtractSlice(typename ScalarImageType::Pointer image, int sliceType, int sliceNum) { - typedef typename itk::ExtractImageFilter SliceExtractFilter; + using SliceExtractFilter = typename itk::ExtractImageFilter; typename SliceExtractFilter::Pointer extractSlice = SliceExtractFilter::New(); typename ScalarImageType::RegionType inputRegion = image->GetLargestPossibleRegion(); typename ScalarImageType::SizeType size = inputRegion.GetSize(); @@ -566,13 +561,13 @@ template class ItkBridge } protected: - ItkBridge() - { - } + ItkBridge() = default; -private: - ItkBridge(const ItkBridge&) = delete; // Copy Constructor Not Implemented - void operator=(const ItkBridge&) = delete; // Move assignment Not Implemented +public: + ItkBridge(const ItkBridge&) = delete; // Copy Constructor Not Implemented + ItkBridge(ItkBridge&&) = delete; // Move Constructor Not Implemented + ItkBridge& operator=(const ItkBridge&) = delete; // Copy Assignment Not Implemented + ItkBridge& operator=(ItkBridge&&) = delete; // Move Assignment Not Implemented }; //// Create some typedefs for our convenience diff --git a/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.h b/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.h index 17ee9980e6..75c4185c79 100644 --- a/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.h +++ b/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.h @@ -38,7 +38,9 @@ #include "itkSimpleDataObjectDecorator.h" #include "itkTransformBase.h" +// SIMPL / ITK #include "SIMPLib/Geometry/ITransformContainer.h" +#include "SIMPLib/ITK/itkSupportConstants.h" namespace itk { @@ -66,7 +68,7 @@ class Dream3DITransformContainerToTransform : public ProcessObject Dream3DITransformContainerToTransform(); ~Dream3DITransformContainerToTransform() override; - void VerifyPreconditions() override; + void VerifyPreconditions() ITKv5_CONST; void GenerateData() override; ProcessObject::DataObjectPointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType) override; diff --git a/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.hxx b/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.hxx index 03eac2875e..191ddb8a4a 100644 --- a/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.hxx +++ b/Source/SIMPLib/ITK/itkDream3DITransformContainerToTransform.hxx @@ -87,7 +87,7 @@ Dream3DITransformContainerToTransform void Dream3DITransformContainerToTransform -::VerifyPreconditions() +::VerifyPreconditions() ITKv5_CONST { if(!m_ITransformContainer) { diff --git a/Source/SIMPLib/ITK/itkDream3DImage.h b/Source/SIMPLib/ITK/itkDream3DImage.h index 98b40f3440..0f36355f51 100644 --- a/Source/SIMPLib/ITK/itkDream3DImage.h +++ b/Source/SIMPLib/ITK/itkDream3DImage.h @@ -17,6 +17,7 @@ *=========================================================================*/ #pragma once +// ITK Includes #include "itkDefaultPixelAccessor.h" #include "itkDefaultPixelAccessorFunctor.h" #include "itkFixedArray.h" @@ -27,6 +28,9 @@ #include "itkPoint.h" #include "itkWeakPointer.h" +// SIMPLib/ITK includes +#include "SIMPLib/ITK/itkSupportConstants.h" + namespace itk { /** \class Dream3DImage diff --git a/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.h b/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.h index 2dd8ad1a42..5d21b636cd 100644 --- a/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.h +++ b/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.h @@ -57,12 +57,13 @@ template class Dream3DTransformContainerToTransform using Superclass::SetInput; virtual void SetInput(::TransformContainer::Pointer transformContainer); DecoratorType* GetOutput(); + const DecoratorType* GetOutput() const; protected: Dream3DTransformContainerToTransform(); ~Dream3DTransformContainerToTransform() override; - void VerifyPreconditions() override; + void VerifyPreconditions() ITKv5_CONST override; void GenerateData() override; ::TransformContainer::Pointer m_TransformContainer; diff --git a/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.hxx b/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.hxx index 95cf96a373..69f8e0185e 100644 --- a/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.hxx +++ b/Source/SIMPLib/ITK/itkDream3DTransformContainerToTransform.hxx @@ -33,6 +33,7 @@ #pragma once +#include "SIMPLib/ITK/itkSupportConstants.h" #include "itkDream3DTransformContainerToTransform.h" namespace itk @@ -83,14 +84,19 @@ Dream3DTransformContainerToTransform template void Dream3DTransformContainerToTransform -::VerifyPreconditions() +::VerifyPreconditions() ITKv5_CONST { if(!m_TransformContainer) { itkExceptionMacro("Input transform container is empty"); } - DecoratorType* outputPtr = this->GetOutput(); - typename ITKTransformType::Pointer transform = outputPtr->Get(); + const DecoratorType* outputPtr = this->GetOutput(); +#if defined(ITK_VERSION_MAJOR) && ITK_VERSION_MAJOR == 5 + typename ITKTransformType::ConstPointer transform = outputPtr->Get(); +#elif defined(ITK_VERSION_MAJOR) && ITK_VERSION_MAJOR == 4 + typename ITKTransformType::Pointer transform = outputPtr->Get(); +#endif + // Verifies that the number of Parameters and Fixed Parameters in the transform // match the expected number based on the transform type. if(transform->GetNumberOfParameters() != m_TransformContainer->getParameters().size()) @@ -144,4 +150,14 @@ Dream3DTransformContainerToTransform return itkDynamicCastInDebugMode(this->GetPrimaryOutput()); } + +template +const typename Dream3DTransformContainerToTransform::DecoratorType* +Dream3DTransformContainerToTransform +::GetOutput() const +{ + return itkDynamicCastInDebugMode(this->GetPrimaryOutput()); +} + + } // end of itk namespace diff --git a/Source/SIMPLib/ITK/itkFijiConfigurationFileReader.hpp b/Source/SIMPLib/ITK/itkFijiConfigurationFileReader.hpp new file mode 100644 index 0000000000..c2f02b1f80 --- /dev/null +++ b/Source/SIMPLib/ITK/itkFijiConfigurationFileReader.hpp @@ -0,0 +1,131 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#if defined(ITK_VERSION_MAJOR) && ITK_VERSION_MAJOR == 4 +#error This file can ONLY be used if ITK Version 5 with the Montage module is being used. +#endif + +#include +#include +#include +#include +#include + +#include "itkParseTileConfiguration.h" + +namespace itk +{ +struct FijiImageTileData +{ + QString filePath; + QPointF coords; + int row; + int col; +}; + +typedef std::vector FijiRowData; +typedef std::vector FijiFileData; + +class FijiConfigurationFileReader : public QObject +{ + public: + FijiFileData parseFijiConfigFile(const QString &configFilePath) + { + m_ErrorCondition = 0; + itk::FijiFileData fileData; + + itk::TileLayout2D stageTiles = itk::ParseTileConfiguration2D(configFilePath.toStdString()); + for (int i = 0; i < stageTiles.size(); i++) + { + auto tile2D = stageTiles[i]; + FijiRowData rowData; + for (int j = 0; j < tile2D.size(); j++) + { + auto tile = tile2D[j]; + + QString imageFilePath = QString::fromStdString(tile.FileName); + QFileInfo fi(imageFilePath); + if (fi.isRelative()) + { + QFileInfo configFi(configFilePath); + imageFilePath = configFi.path() + QDir::separator() + imageFilePath; + } + + itk::FijiImageTileData imageTileData; + + imageTileData.filePath = imageFilePath; + + uint32_t coordsSize = tile.Position.GetPointDimension(); + if (coordsSize != 2) + { + m_ErrorMessage = QObject::tr("The dimension size of all tiles in the fiji config file must be equal to 2."); + m_ErrorCondition = -2004; + return itk::FijiFileData(); + } + + imageTileData.coords = QPointF(tile.Position[0], tile.Position[1]); + imageTileData.row = i; + imageTileData.col = j; + + rowData.push_back(imageTileData); + } + + fileData.push_back(rowData); + } + + return fileData; + } + + int getErrorCode() + { + return m_ErrorCondition; + } + + QString getErrorMessage() + { + return m_ErrorMessage; + } + + private: + int m_ErrorCondition; + QString m_ErrorMessage; +}; +} + +//#ifndef ITK_MANUAL_INSTANTIATION +//#include "itkFijiConfigurationFileReader.cpp" +//#endif diff --git a/Source/SIMPLib/ITK/itkImageReaderHelper.cpp b/Source/SIMPLib/ITK/itkImageReaderHelper.cpp index 8e6df1a192..8f2a50117d 100644 --- a/Source/SIMPLib/ITK/itkImageReaderHelper.cpp +++ b/Source/SIMPLib/ITK/itkImageReaderHelper.cpp @@ -111,9 +111,8 @@ ::readImage(const DataArrayPath& dataArrayPath, const itk::ImageIOBase::Pointer& } else { - setErrorCondition(-4); QString errorMessage = QString("Unsupported number of components: %1.").arg(nbComponents); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); + setErrorCondition(-4, errorMessage); break; } break; @@ -126,9 +125,8 @@ ::readImage(const DataArrayPath& dataArrayPath, const itk::ImageIOBase::Pointer& case itk::ImageIOBase::FIXEDARRAY: case itk::ImageIOBase::MATRIX: default: - setErrorCondition(-4); QString errorMessage = QString("Unsupported pixel type: %1.").arg(itk::ImageIOBase::GetPixelTypeAsString(pixel).c_str()); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); + setErrorCondition(-4, errorMessage); break; } } @@ -144,8 +142,7 @@ ::readImage(const DataArrayPath& dataArrayPath, const QString& filename, bool da DataContainer::Pointer container = getDataContainerArray()->getDataContainer(dataArrayPath.getDataContainerName()); if(nullptr == container.get()) { - setErrorCondition(-4); - notifyErrorMessage(getHumanLabel(), "Container not found.", getErrorCondition()); + setErrorCondition(-4, "Container not found."); return; } @@ -185,9 +182,8 @@ ::readImage(const DataArrayPath& dataArrayPath, bool dataCheck) itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(filename.toLatin1(), itk::ImageIOFactory::ReadMode); if(nullptr == imageIO) { - setErrorCondition(-5); QString errorMessage = "ITK could not read the given file \"%1\". Format is likely unsupported."; - notifyErrorMessage(getHumanLabel(), errorMessage.arg(filename), getErrorCondition()); + setErrorCondition(-5, errorMessage.arg(filename)); return; } imageIO->SetFileName(filename.toLatin1()); @@ -228,16 +224,14 @@ ::readImage(const DataArrayPath& dataArrayPath, bool dataCheck) readImage(dataArrayPath, imageIO, filename, dataCheck); break; default: - setErrorCondition(-4); QString errorMessage = QString("Unsupported pixel component: %1.").arg(imageIO->GetComponentTypeAsString(component).c_str()); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); + setErrorCondition(-4, errorMessage); break; } } catch(itk::ExceptionObject& err) { - setErrorCondition(-55557); QString errorMessage = "ITK exception was thrown while processing input file: %1"; - notifyErrorMessage(getHumanLabel(), errorMessage.arg(err.what()), getErrorCondition()); + setErrorCondition(-55557, errorMessage.arg(err.what())); return; } } @@ -256,10 +250,10 @@ ::readImageOutputInformation(const DataArrayPath& dataArrayPath, typename itk::I const typename ImageType::PointType origin = reader->GetOutput()->GetOrigin(); const typename ImageType::SizeType size = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); const typename ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing(); - QVector torigin(3, 0); - QVector tspacing(3, 0); - QVector tDims(3, 1); // Initialize torigin/tspacing/tDims since arrays are always of size 3 and ITK image may have a different size. + FloatVec3Type torigin = {0.0f, 0.0f, 0.0f}; + FloatVec3Type tspacing = {1.0f, 1.0f, 1.0f}; + SizeVec3Type tDims = {1, 1, 1}; for(size_t i = 0; i < dimensions; i++) { torigin[i] = origin[i]; @@ -267,14 +261,15 @@ ::readImageOutputInformation(const DataArrayPath& dataArrayPath, typename itk::I tDims[i] = size[i]; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); - image->setDimensions(tDims[0], tDims[1], tDims[2]); - image->setOrigin(torigin[0], torigin[1], torigin[2]); - image->setResolution(tspacing[0], tspacing[1], tspacing[2]); + image->setDimensions(tDims); + image->setOrigin(torigin); + image->setSpacing(tspacing); container->setGeometry(image); QVector cDims = ITKDream3DHelper::GetComponentsDimensions(); - AttributeMatrix::Pointer cellAttrMat = container->createNonPrereqAttributeMatrix(this, dataArrayPath.getAttributeMatrixName(), tDims, AttributeMatrix::Type::Cell); - if(getErrorCondition() < 0) + QVector qTdims = {tDims[0], tDims[1], tDims[2]}; + AttributeMatrix::Pointer cellAttrMat = container->createNonPrereqAttributeMatrix(this, dataArrayPath.getAttributeMatrixName(), qTdims, AttributeMatrix::Type::Cell); + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/ITK/itkInPlaceDream3DDataToImageFilter.h b/Source/SIMPLib/ITK/itkInPlaceDream3DDataToImageFilter.h index 98d0acf1e9..b9a2b7aac8 100644 --- a/Source/SIMPLib/ITK/itkInPlaceDream3DDataToImageFilter.h +++ b/Source/SIMPLib/ITK/itkInPlaceDream3DDataToImageFilter.h @@ -49,7 +49,7 @@ class InPlaceDream3DDataToImageFilter : public ImageSource template< typename PixelType, unsigned int VDimension> void InPlaceDream3DDataToImageFilter< PixelType, VDimension > -::VerifyPreconditions() +::VerifyPreconditions() ITKv5_CONST { if (m_DataContainer == DataContainer::NullPointer() ) { @@ -66,9 +66,7 @@ InPlaceDream3DDataToImageFilter< PixelType, VDimension > template< typename PixelType, unsigned int VDimension> -void -InPlaceDream3DDataToImageFilter< PixelType, VDimension > -::GenerateOutputInformation() +void InPlaceDream3DDataToImageFilter< PixelType, VDimension >::GenerateOutputInformation() { // call the superclass' implementation of this method Superclass::GenerateOutputInformation(); @@ -82,13 +80,13 @@ InPlaceDream3DDataToImageFilter< PixelType, VDimension > itkExceptionMacro("Error casting geometry!!!"); } // Get data container properties - QVector torigin(3, 0); + FloatVec3Type torigin; // Setting spacing to 0 means dimension is not used. Used to know if // image is 2D or 3D. Setting dimensions to 0 leads to crashes - QVector tspacing(3, 0); - QVector tDims(3, 1); - imageGeom->getOrigin(torigin[0], torigin[1], torigin[2]); - imageGeom->getResolution(tspacing[0], tspacing[1], tspacing[2]); + FloatVec3Type tspacing; + SizeVec3Type tDims; + imageGeom->getOrigin(torigin); + imageGeom->getSpacing(tspacing); std::tie(tDims[0], tDims[1], tDims[2]) = imageGeom->getDimensions(); typename ImageType::PointType origin; typename ImageType::SizeType size; @@ -114,9 +112,7 @@ InPlaceDream3DDataToImageFilter< PixelType, VDimension > template< typename PixelType, unsigned int VDimension> -void -InPlaceDream3DDataToImageFilter< PixelType, VDimension > -::GenerateData() +void InPlaceDream3DDataToImageFilter< PixelType, VDimension >::GenerateData() { // Get data pointer AttributeMatrix::Pointer ma = m_DataContainer->getAttributeMatrix(m_AttributeMatrixArrayName.c_str()); diff --git a/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.h b/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.h index 0c3a09ec57..c7697808b8 100644 --- a/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.h +++ b/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.h @@ -15,7 +15,8 @@ namespace itk { -template class InPlaceImageToDream3DDataFilter : public ProcessObject +template +class InPlaceImageToDream3DDataFilter : public ProcessObject { public: /** Standard class typedefs. */ @@ -36,6 +37,7 @@ template class InPlaceImageToDream virtual void SetInput(const ImageType* image); DecoratorType* GetOutput(); + const DecoratorType* GetOutput() const; void SetDataContainer(DataContainer::Pointer dc); @@ -54,13 +56,13 @@ template class InPlaceImageToDream InPlaceImageToDream3DDataFilter(); virtual ~InPlaceImageToDream3DDataFilter(); - virtual void VerifyPreconditions() override; + virtual void VerifyPreconditions() ITKv5_CONST override; ProcessObject::DataObjectPointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType) override; - virtual void GenerateData() override; - virtual void GenerateOutputInformation() override; + void GenerateData() override; + void GenerateOutputInformation() override; - void CheckValidArrayPathComponentName(std::string var); + void CheckValidArrayPathComponentName(std::string var) const; private: using Superclass::SetInput; @@ -75,4 +77,3 @@ template class InPlaceImageToDream #ifndef ITK_MANUAL_INSTANTIATION #include "itkInPlaceImageToDream3DDataFilter.hxx" #endif - diff --git a/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.hxx b/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.hxx index c48ae76c9c..06aecb070b 100644 --- a/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.hxx +++ b/Source/SIMPLib/ITK/itkInPlaceImageToDream3DDataFilter.hxx @@ -104,9 +104,9 @@ InPlaceImageToDream3DDataFilter tspacing[i] = spacing[i]; tDims[i] = size[i]; } - imageGeom->setOrigin(torigin[0], torigin[1], torigin[2]); - imageGeom->setResolution(tspacing[0], tspacing[1], tspacing[2]); - imageGeom->setDimensions(tDims[0], tDims[1], tDims[2]); + imageGeom->setOrigin(FloatVec3Type(torigin[0], torigin[1], torigin[2])); + imageGeom->setSpacing(FloatVec3Type(tspacing[0], tspacing[1], tspacing[2])); + imageGeom->setDimensions(SizeVec3Type(tDims[0], tDims[1], tDims[2])); dataContainer->setGeometry(imageGeom); } @@ -177,7 +177,7 @@ InPlaceImageToDream3DDataFilter ::memcpy(data->getPointer(0), reinterpret_cast(inputPtr->GetBufferPointer()), imageGeom->getNumberOfElements() * sizeof(ValueType)); } } - attrMat->addAttributeArray(m_DataArrayName.c_str(), data); + attrMat->insertOrAssign(data); outputPtr->Set(dataContainer); } @@ -185,7 +185,7 @@ InPlaceImageToDream3DDataFilter template void InPlaceImageToDream3DDataFilter -::CheckValidArrayPathComponentName(std::string var) +::CheckValidArrayPathComponentName(std::string var) const { if (var.find('/') != std::string::npos) { @@ -202,7 +202,7 @@ InPlaceImageToDream3DDataFilter template void InPlaceImageToDream3DDataFilter -::VerifyPreconditions() +::VerifyPreconditions() ITKv5_CONST { //Test only works if image if of dimension 2 or 3 if (VDimension != 2 && VDimension != 3) @@ -212,7 +212,7 @@ InPlaceImageToDream3DDataFilter CheckValidArrayPathComponentName(m_AttributeMatrixArrayName); CheckValidArrayPathComponentName(m_DataArrayName); // Verify data container - DecoratorType *outputPtr = this->GetOutput(); + const DecoratorType *outputPtr = this->GetOutput(); if (!outputPtr->Get()) { itkExceptionMacro("Data container not set"); @@ -232,5 +232,13 @@ InPlaceImageToDream3DDataFilter return itkDynamicCastInDebugMode< DecoratorType * >(this->GetPrimaryOutput()); } +template +const typename InPlaceImageToDream3DDataFilter::DecoratorType* +InPlaceImageToDream3DDataFilter +::GetOutput() const +{ + return itkDynamicCastInDebugMode< const DecoratorType * >(this->GetPrimaryOutput()); +} + } // end of itk namespace diff --git a/Source/SIMPLib/ITK/itkProgressObserver.hpp b/Source/SIMPLib/ITK/itkProgressObserver.hpp new file mode 100644 index 0000000000..3ebecd9ee0 --- /dev/null +++ b/Source/SIMPLib/ITK/itkProgressObserver.hpp @@ -0,0 +1,111 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include "SIMPLib/Filtering/AbstractFilter.h" + +#include "itkProcessObject.h" +#include "itkCommand.h" + +namespace itk +{ +class ProgressObserver : public itk::Command +{ + public: + SIMPL_SHARED_POINTERS(ProgressObserver) + SIMPL_STATIC_NEW_MACRO(ProgressObserver) + + void Execute(itk::Object* caller, const itk::EventObject& event) override + { + Execute((const itk::Object*)caller, event); + } + + void Execute(const itk::Object* caller, const itk::EventObject& event) override + { + if(!itk::ProgressEvent().CheckEvent(&event)) + { + return; + } + const auto* processObject = dynamic_cast(caller); + if(!processObject) + { + return; + } + + QString progressStr = QString::number(processObject->GetProgress() * 100); + + QString ss; + if (m_MessagePrefix.isEmpty()) + { + ss = QObject::tr("%1%").arg(progressStr); + } + else + { + ss = QObject::tr("%1: %2%").arg(m_MessagePrefix).arg(progressStr); + } + + if (m_Filter) + { + m_Filter->notifyStatusMessage(ss); + } + } + + void setMessagePrefix(const QString &prefix) + { + m_MessagePrefix = prefix; + } + + void setFilter(AbstractFilter* filter) + { + m_Filter = filter; + } + + protected: + ProgressObserver() {} + + private: + AbstractFilter* m_Filter = nullptr; + QString m_MessagePrefix; + + ProgressObserver(const ProgressObserver&) = delete; // Copy Constructor Not Implemented + ProgressObserver(ProgressObserver&&) = delete; // Move Constructor Not Implemented + ProgressObserver& operator=(const ProgressObserver&) = delete; // Copy Assignment Not Implemented + ProgressObserver& operator=(ProgressObserver&&) = delete; // Move Assignment Not Implemented +}; +} // end of itk namespace diff --git a/Source/SIMPLib/ITK/itkReadImageImpl.hpp b/Source/SIMPLib/ITK/itkReadImageImpl.hpp index 530e95eb67..3134ee2167 100644 --- a/Source/SIMPLib/ITK/itkReadImageImpl.hpp +++ b/Source/SIMPLib/ITK/itkReadImageImpl.hpp @@ -147,10 +147,9 @@ template class ItkReadImagePrivate case itk::ImageIOBase::MATRIX: break; default: - filter->setErrorCondition(-2); QString message = QObject::tr("Unable to read image '%1'").arg(inputFile); - filter->notifyErrorMessage(filter->getHumanLabel(), message, filter->getErrorCondition()); - outputIDataArray->resize(0); + filter->setErrorCondition(-2, message); + outputIDataArray->resizeTuples(0); } try @@ -158,9 +157,8 @@ template class ItkReadImagePrivate readerObject->Update(); } catch(itk::ExceptionObject& err) { - filter->setErrorCondition(-5); QString ss = QObject::tr("Failed to read image '%1': %2").arg(inputFile).arg(err.GetDescription()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-5, ss); } } diff --git a/Source/SIMPLib/ITK/itkSupportConstants.h b/Source/SIMPLib/ITK/itkSupportConstants.h index aba3b47204..0b988bef88 100644 --- a/Source/SIMPLib/ITK/itkSupportConstants.h +++ b/Source/SIMPLib/ITK/itkSupportConstants.h @@ -45,6 +45,10 @@ #include "SIMPLib/DataArrays/DataArray.hpp" +#if defined(ITK_VERSION_MAJOR) && ITK_VERSION_MAJOR == 4 +#define ITKv5_CONST +#endif + /** * @brief This namespace is used to define some Constants for the plugin itself. */ diff --git a/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.h b/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.h index 0eca16afac..ff73f6c34c 100644 --- a/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.h +++ b/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.h @@ -37,6 +37,7 @@ #include "itkSimpleDataObjectDecorator.h" #include "SIMPLib/Geometry/ITransformContainer.h" +#include "SIMPLib/ITK/itkSupportConstants.h" namespace itk { @@ -62,7 +63,7 @@ template clas TransformToDream3DITransformContainer(); ~TransformToDream3DITransformContainer() override; - void VerifyPreconditions() override; + void VerifyPreconditions() ITKv5_CONST; void GenerateData() override; ProcessObject::DataObjectPointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType) override; diff --git a/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.hxx b/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.hxx index f5ef1578ec..172a58f10b 100644 --- a/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.hxx +++ b/Source/SIMPLib/ITK/itkTransformToDream3DITransformContainer.hxx @@ -84,7 +84,7 @@ TransformToDream3DITransformContainer void TransformToDream3DITransformContainer -::VerifyPreconditions() +::VerifyPreconditions() ITKv5_CONST { if(!m_Transform) { diff --git a/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.h b/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.h index d453c26c14..5eb71b9b45 100644 --- a/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.h +++ b/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.h @@ -37,6 +37,7 @@ #include "itkSimpleDataObjectDecorator.h" #include "SIMPLib/Geometry/TransformContainer.h" +#include "SIMPLib/ITK/itkSupportConstants.h" namespace itk { @@ -61,7 +62,7 @@ template class TransformToDream3DTransformContainer TransformToDream3DTransformContainer(); ~TransformToDream3DTransformContainer() override; - void VerifyPreconditions() override; + void VerifyPreconditions() ITKv5_CONST; void GenerateData() override; ProcessObject::DataObjectPointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType) override; diff --git a/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.hxx b/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.hxx index 63b14c58ce..1b3c40f3d8 100644 --- a/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.hxx +++ b/Source/SIMPLib/ITK/itkTransformToDream3DTransformContainer.hxx @@ -83,7 +83,7 @@ TransformToDream3DTransformContainer template void TransformToDream3DTransformContainer -::VerifyPreconditions() +::VerifyPreconditions() ITKv5_CONST { if(!m_Transform) { diff --git a/Source/SIMPLib/Math/GeometryMath.cpp b/Source/SIMPLib/Math/GeometryMath.cpp index 25006d57b1..98f9058c16 100644 --- a/Source/SIMPLib/Math/GeometryMath.cpp +++ b/Source/SIMPLib/Math/GeometryMath.cpp @@ -1020,7 +1020,7 @@ char GeometryMath::PointInPolyhedron(TriangleGeom* faces, const Int32Int32Dynami for(f = 0; f < numFaces; f++) { /* Begin check each face */ - int32_t idx = 2 * faceId[f]; + int64_t idx = 2 * static_cast(faceId[f]); float* v0 = faceBBs->getVertexPointer(idx); float* v1 = faceBBs->getVertexPointer(idx + 1); if(!RayIntersectsBox(q, r, v0, v1)) @@ -1113,7 +1113,7 @@ char GeometryMath::PointInPolyhedron(TriangleGeom* faces, const Int32Int32Dynami for(f = 0; f < numFaces; f++) { /* Begin check each face */ - int32_t idx = 2 * faceId[f]; + int64_t idx = 2 * static_cast(faceId[f]); float* v0 = faceBBs->getVertexPointer(idx); float* v1 = faceBBs->getVertexPointer(idx + 1); faces->getVertCoordsAtTri(faceId[f], a, b, c); diff --git a/Source/SIMPLib/Math/QuaternionMath.hpp b/Source/SIMPLib/Math/QuaternionMath.hpp index a6065e0633..8dc255c7b5 100755 --- a/Source/SIMPLib/Math/QuaternionMath.hpp +++ b/Source/SIMPLib/Math/QuaternionMath.hpp @@ -35,7 +35,8 @@ #pragma once -#include +#include +#include #include "SIMPLib/Math/SIMPLibMath.h" #include "SIMPLib/Math/MatrixMath.h" @@ -60,16 +61,54 @@ template class QuaternionMath { public: + using size_type = size_t; + using value_type = T; + using reference = T&; + /** * @brief */ - typedef struct + using Quaternion = struct { T x; T y; T z; T w; - } Quaternion; + + inline reference operator[](size_type index) + { + switch(index) + { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw std::range_error("Invalid Quaternion index"); + } + } + + inline const T& operator[](size_type index) const + { + switch(index) + { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw std::range_error("Invalid Quaternion index"); + } + } + }; enum Order { @@ -465,23 +504,19 @@ class QuaternionMath /** * @brief QuaternionMathF Typedef for 32 bit floats for convenience */ -typedef QuaternionMath QuaternionMathF; +using QuaternionMathF = QuaternionMath; /** * @brief QuaternionMathD Typedef for 64 bit floats for convenience */ -typedef QuaternionMath QuaternionMathD; +using QuaternionMathD = QuaternionMath; /** * @brief QuatF 32 Bit Floating point Quaternion for convenience. */ -typedef QuaternionMath::Quaternion QuatF; +using QuatF = QuaternionMath::Quaternion; /** * @brief QuatD 64 Bit Floating point Quaternion for convenience. */ -typedef QuaternionMath::Quaternion QuatD; - - - - +using QuatD = QuaternionMath::Quaternion; diff --git a/Source/SIMPLib/Math/SIMPLibMath.cpp b/Source/SIMPLib/Math/SIMPLibMath.cpp index 4a499a4872..8f47c54020 100644 --- a/Source/SIMPLib/Math/SIMPLibMath.cpp +++ b/Source/SIMPLib/Math/SIMPLibMath.cpp @@ -360,8 +360,8 @@ float SIMPLibMath::erfc(float x) } float SIMPLibMath::incompletebeta(float a, float b, float x) { - float maxrealnumber = std::numeric_limits::max(); - float minrealnumber = std::numeric_limits::min(); + constexpr float maxrealnumber = std::numeric_limits::max(); + constexpr float minrealnumber = std::numeric_limits::min(); float result; float t; float xc; @@ -696,8 +696,8 @@ float SIMPLibMath::incompletebetaps(float a, float b, float x, float maxgam) float z; float ai; float sg; - float maxrealnumber = std::numeric_limits::max(); - float minrealnumber = std::numeric_limits::min(); + constexpr float maxrealnumber = std::numeric_limits::max(); + constexpr float minrealnumber = std::numeric_limits::min(); ai = 1.0f / a; u = (1.0f - b) * x; v = u / (a + 1.0f); diff --git a/Source/SIMPLib/Math/SIMPLibRandom.cpp b/Source/SIMPLib/Math/SIMPLibRandom.cpp index cba26cf9a1..355f14270b 100644 --- a/Source/SIMPLib/Math/SIMPLibRandom.cpp +++ b/Source/SIMPLib/Math/SIMPLibRandom.cpp @@ -299,7 +299,7 @@ double SIMPLibRandom::genrand_beta(double aa, double bb) S50: w = a * exp(v); S60: - z = powf(static_cast(u1), 2.0f) * static_cast(u2); + z = powf(static_cast(u1), 2.0f) * u2; r = gamma * v - 1.3862944; s = a + r - w; if(s + 2.609438 >= 5.0 * z) @@ -360,7 +360,7 @@ double SIMPLibRandom::genrand_beta(double aa, double bb) } goto S170; S130: - z = powf(static_cast(u1), 2.0f) * static_cast(u2); + z = powf(static_cast(u1), 2.0f) * u2; if(!(z <= 0.25)) { goto S160; diff --git a/Source/SIMPLib/Messages/AbstractErrorMessage.h b/Source/SIMPLib/Messages/AbstractErrorMessage.h new file mode 100755 index 0000000000..56162cc2a7 --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractErrorMessage.h @@ -0,0 +1,85 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractMessage.h" + +/** + * @class AbstractErrorMessage AbstractErrorMessage.h SIMPLib/Messages/AbstractErrorMessage.h + * @brief This class is an abstract error message superclass. + */ +class SIMPLib_EXPORT AbstractErrorMessage : public AbstractMessage +{ +public: + SIMPL_SHARED_POINTERS(AbstractErrorMessage) + SIMPL_TYPE_MACRO(AbstractErrorMessage) + + virtual ~AbstractErrorMessage() + { + } + + SIMPL_INSTANCE_PROPERTY(int, Code) + + /** + * @brief This method creates and returns a string for error messages + */ + virtual QString generateMessageString() const = 0; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const = 0; + +protected: + AbstractErrorMessage() + : AbstractMessage() + , m_Code(0) + { + } + + AbstractErrorMessage(const QString& msgText, int code) + : AbstractMessage(msgText) + , m_Code(code) + { + } + +private: +}; +Q_DECLARE_METATYPE(AbstractErrorMessage::Pointer) diff --git a/Source/SIMPLib/FilterParameters/IntVec3.h b/Source/SIMPLib/Messages/AbstractMessage.cpp similarity index 61% rename from Source/SIMPLib/FilterParameters/IntVec3.h rename to Source/SIMPLib/Messages/AbstractMessage.cpp index d7ee634fdb..f81d56bf0d 100644 --- a/Source/SIMPLib/FilterParameters/IntVec3.h +++ b/Source/SIMPLib/Messages/AbstractMessage.cpp @@ -1,5 +1,5 @@ /* ============================================================================ - * Copyright (c) 2019 BlueQuartz Software, LLC + * Copyright (c) 2009-2019 BlueQuartz Software, LLC * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -26,40 +26,32 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once -#include +#include "AbstractMessage.h" -typedef struct +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractMessage::AbstractMessage() { - int x; - int y; - int z; - void IntVec3(const int& x_, const int& y_, const int& z_) - { - x = x_; - y = y_; - z = z_; - } - void writeJson(QJsonObject& json) - { - json["x"] = x; - json["y"] = y; - json["z"] = z; - } +} - bool readJson(QJsonObject& json) - { - if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) - { - x = json["x"].toInt(); - y = json["y"].toInt(); - z = json["z"].toInt(); - return true; - } - return false; - } -} IntVec3_t; +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractMessage::AbstractMessage(const QString &msgText) +: m_MessageText(msgText) +{ +} -Q_DECLARE_METATYPE(IntVec3_t) +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractMessage::~AbstractMessage() = default; diff --git a/Source/SIMPLib/Messages/AbstractMessage.h b/Source/SIMPLib/Messages/AbstractMessage.h new file mode 100755 index 0000000000..46928af625 --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractMessage.h @@ -0,0 +1,83 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + +class AbstractMessageHandler; + +/** + * @class AbstractMessage AbstractMessage.h SIMPLib/Messages/AbstractMessage.h + * @brief This class is the superclass for all messages that can be sent using SIMPL. + */ +class SIMPLib_EXPORT AbstractMessage +{ + public: + SIMPL_SHARED_POINTERS(AbstractMessage) + SIMPL_TYPE_MACRO(AbstractMessage) + + virtual ~AbstractMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(MessageText) + + /** + * @brief This method creates and returns a message string + */ + virtual QString generateMessageString() const = 0; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const = 0; + + protected: + AbstractMessage(); + AbstractMessage(const QString& msgText); + + private: + +}; +Q_DECLARE_METATYPE(AbstractMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/AbstractMessageHandler.cpp b/Source/SIMPLib/Messages/AbstractMessageHandler.cpp new file mode 100644 index 0000000000..6a4dd61d6b --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractMessageHandler.cpp @@ -0,0 +1,159 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "AbstractMessageHandler.h" + +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/GenericProgressMessage.h" +#include "SIMPLib/Messages/GenericStatusMessage.h" +#include "SIMPLib/Messages/GenericWarningMessage.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractMessageHandler::AbstractMessageHandler() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const GenericErrorMessage *msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing generic error messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const GenericProgressMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing generic progress messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const GenericStatusMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing generic status messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const GenericWarningMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing generic warning messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const PipelineErrorMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing pipeline error messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const PipelineProgressMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing pipeline progress messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const PipelineStatusMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing pipeline status messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const PipelineWarningMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing pipeline warning messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const FilterErrorMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing filter error messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const FilterProgressMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing filter progress messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const FilterStatusMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing filter status messages. */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractMessageHandler::processMessage(const FilterWarningMessage* msg) const +{ + /* This is a default method that can be reimplemented in a subclass. Subclassed message handlers + * should reimplement this method if they care about processing filter warning messages. */ +} diff --git a/Source/SIMPLib/Messages/AbstractMessageHandler.h b/Source/SIMPLib/Messages/AbstractMessageHandler.h new file mode 100755 index 0000000000..01393f7ec2 --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractMessageHandler.h @@ -0,0 +1,81 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/SIMPLib.h" + +class GenericErrorMessage; +class GenericProgressMessage; +class GenericStatusMessage; +class GenericWarningMessage; +class PipelineErrorMessage; +class PipelineProgressMessage; +class PipelineStatusMessage; +class PipelineWarningMessage; +class FilterErrorMessage; +class FilterProgressMessage; +class FilterStatusMessage; +class FilterWarningMessage; + +/** + * @class AbstractMessageHandler AbstractMessageHandler.h SIMPLib/Messages/AbstractMessageHandler.h + * @brief This is the message handler superclass that is part of the double-dispatch API and enables + * observers to process messages that they receive from observable objects + */ +class SIMPLib_EXPORT AbstractMessageHandler +{ + public: + virtual void processMessage(const GenericErrorMessage* msg) const; + virtual void processMessage(const GenericProgressMessage* msg) const; + virtual void processMessage(const GenericStatusMessage* msg) const; + virtual void processMessage(const GenericWarningMessage* msg) const; + + virtual void processMessage(const PipelineErrorMessage* msg) const; + virtual void processMessage(const PipelineProgressMessage* msg) const; + virtual void processMessage(const PipelineStatusMessage* msg) const; + virtual void processMessage(const PipelineWarningMessage* msg) const; + + virtual void processMessage(const FilterErrorMessage* msg) const; + virtual void processMessage(const FilterProgressMessage* msg) const; + virtual void processMessage(const FilterStatusMessage* msg) const; + virtual void processMessage(const FilterWarningMessage* msg) const; + + protected: + AbstractMessageHandler(); +}; + + diff --git a/Source/SIMPLib/Messages/AbstractProgressMessage.h b/Source/SIMPLib/Messages/AbstractProgressMessage.h new file mode 100755 index 0000000000..5acbc580ae --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractProgressMessage.h @@ -0,0 +1,87 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractMessage.h" + +class AbstractMessageHandler; + +/** + * @class AbstractProgressMessage AbstractProgressMessage.h SIMPLib/Messages/AbstractProgressMessage.h + * @brief This class is an abstract progress message superclass. + */ +class SIMPLib_EXPORT AbstractProgressMessage : public AbstractMessage +{ +public: + SIMPL_SHARED_POINTERS(AbstractProgressMessage) + SIMPL_TYPE_MACRO(AbstractProgressMessage) + + virtual ~AbstractProgressMessage() + { + } + + SIMPL_INSTANCE_PROPERTY(int, ProgressValue) + + /** + * @brief This method creates and returns a string for progress messages + */ + virtual QString generateMessageString() const = 0; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const = 0; + +protected: + AbstractProgressMessage() + : AbstractMessage() + , m_ProgressValue(0) + { + } + + AbstractProgressMessage(const QString& msgText, int progress) + : AbstractMessage(msgText) + , m_ProgressValue(progress) + { + } + +private: +}; +Q_DECLARE_METATYPE(AbstractProgressMessage::Pointer) diff --git a/Source/SIMPLib/Messages/AbstractStatusMessage.h b/Source/SIMPLib/Messages/AbstractStatusMessage.h new file mode 100755 index 0000000000..a558056362 --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractStatusMessage.h @@ -0,0 +1,83 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractMessage.h" + +class AbstractMessageHandler; + +/** + * @class AbstractStatusMessage AbstractStatusMessage.h SIMPLib/Messages/AbstractStatusMessage.h + * @brief This class is an abstract status message superclass. + */ +class SIMPLib_EXPORT AbstractStatusMessage : public AbstractMessage +{ +public: + SIMPL_SHARED_POINTERS(AbstractStatusMessage) + SIMPL_TYPE_MACRO(AbstractStatusMessage) + + virtual ~AbstractStatusMessage() + { + } + + /** + * @brief This method creates and returns a string for status messages + */ + virtual QString generateMessageString() const = 0; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const = 0; + +protected: + AbstractStatusMessage() + : AbstractMessage() + { + } + + AbstractStatusMessage(const QString& msgText) + : AbstractMessage(msgText) + { + } + +private: +}; +Q_DECLARE_METATYPE(AbstractStatusMessage::Pointer) diff --git a/Source/SIMPLib/Messages/AbstractWarningMessage.h b/Source/SIMPLib/Messages/AbstractWarningMessage.h new file mode 100755 index 0000000000..e304314ee4 --- /dev/null +++ b/Source/SIMPLib/Messages/AbstractWarningMessage.h @@ -0,0 +1,87 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractMessage.h" + +class AbstractMessageHandler; + +/** + * @class AbstractWarningMessage AbstractWarningMessage.h SIMPLib/Messages/AbstractWarningMessage.h + * @brief This class is an abstract warning message superclass. + */ +class SIMPLib_EXPORT AbstractWarningMessage : public AbstractMessage +{ +public: + SIMPL_SHARED_POINTERS(AbstractWarningMessage) + SIMPL_TYPE_MACRO(AbstractWarningMessage) + + virtual ~AbstractWarningMessage() + { + } + + SIMPL_INSTANCE_PROPERTY(int, Code) + + /** + * @brief This method creates and returns a string for warning messages + */ + virtual QString generateMessageString() const = 0; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const = 0; + +protected: + AbstractWarningMessage() + : AbstractMessage() + , m_Code(0) + { + } + + AbstractWarningMessage(const QString& msgText, int code) + : AbstractMessage(msgText) + , m_Code(code) + { + } + +private: +}; +Q_DECLARE_METATYPE(AbstractWarningMessage::Pointer) diff --git a/Source/SIMPLib/Messages/FilterErrorMessage.cpp b/Source/SIMPLib/Messages/FilterErrorMessage.cpp new file mode 100644 index 0000000000..d05e72c024 --- /dev/null +++ b/Source/SIMPLib/Messages/FilterErrorMessage.cpp @@ -0,0 +1,89 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "FilterErrorMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterErrorMessage::FilterErrorMessage() +: AbstractErrorMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterErrorMessage::FilterErrorMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code) +: AbstractErrorMessage(msgText, code) +, m_ClassName(className) +, m_HumanLabel(humanLabel) +, m_PipelineIndex(pipelineIndex) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterErrorMessage::~FilterErrorMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterErrorMessage::Pointer FilterErrorMessage::New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code) +{ + FilterErrorMessage::Pointer shared_ptr (new FilterErrorMessage(className, humanLabel, pipelineIndex, msgText, code)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString FilterErrorMessage::generateMessageString() const +{ + QString ss = QObject::tr("'%1' Error (%2): %3").arg(getClassName()).arg(getCode()).arg(getMessageText()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterErrorMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/FilterErrorMessage.h b/Source/SIMPLib/Messages/FilterErrorMessage.h new file mode 100755 index 0000000000..5f8e63f745 --- /dev/null +++ b/Source/SIMPLib/Messages/FilterErrorMessage.h @@ -0,0 +1,94 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractErrorMessage.h" + +/** + * @class FilterErrorMessage FilterErrorMessage.h SIMPLib/Messages/FilterErrorMessage.h + * @brief This class is a filter error message class that is responsible for holding all the details + * of an error message emitted by an AbstractFilter + */ +class SIMPLib_EXPORT FilterErrorMessage : public AbstractErrorMessage +{ + public: + SIMPL_SHARED_POINTERS(FilterErrorMessage) + SIMPL_STATIC_NEW_MACRO(FilterErrorMessage) + SIMPL_TYPE_MACRO(FilterErrorMessage) + + SIMPL_INSTANCE_STRING_PROPERTY(ClassName) + + SIMPL_INSTANCE_STRING_PROPERTY(HumanLabel) + + SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) + + virtual ~FilterErrorMessage(); + + /** + * @brief New + * @param className + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param code + * @return + */ + static Pointer New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for filter error messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + FilterErrorMessage(); + FilterErrorMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code); + + private: + +}; +Q_DECLARE_METATYPE(FilterErrorMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/FilterProgressMessage.cpp b/Source/SIMPLib/Messages/FilterProgressMessage.cpp new file mode 100644 index 0000000000..25084c8dfe --- /dev/null +++ b/Source/SIMPLib/Messages/FilterProgressMessage.cpp @@ -0,0 +1,89 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "FilterProgressMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterProgressMessage::FilterProgressMessage() +: AbstractProgressMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterProgressMessage::FilterProgressMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int progress) +: AbstractProgressMessage(msgText, progress) +, m_ClassName(className) +, m_HumanLabel(humanLabel) +, m_PipelineIndex(pipelineIndex) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterProgressMessage::~FilterProgressMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterProgressMessage::Pointer FilterProgressMessage::New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int progress) +{ + FilterProgressMessage::Pointer shared_ptr (new FilterProgressMessage(className, humanLabel, pipelineIndex, msgText, progress)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString FilterProgressMessage::generateMessageString() const +{ + QString ss = QObject::tr("%1 %2%%").arg(getMessageText()).arg(getProgressValue()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterProgressMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/FilterProgressMessage.h b/Source/SIMPLib/Messages/FilterProgressMessage.h new file mode 100755 index 0000000000..2e7ae820c8 --- /dev/null +++ b/Source/SIMPLib/Messages/FilterProgressMessage.h @@ -0,0 +1,94 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractProgressMessage.h" + +/** + * @class FilterProgressMessage FilterProgressMessage.h SIMPLib/Messages/FilterProgressMessage.h + * @brief This class is a filter progress message class that is responsible for holding all the details + * of a progress message emitted by an AbstractFilter + */ +class SIMPLib_EXPORT FilterProgressMessage : public AbstractProgressMessage +{ + public: + SIMPL_SHARED_POINTERS(FilterProgressMessage) + SIMPL_STATIC_NEW_MACRO(FilterProgressMessage) + SIMPL_TYPE_MACRO(FilterProgressMessage) + + virtual ~FilterProgressMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(ClassName) + + SIMPL_INSTANCE_STRING_PROPERTY(HumanLabel) + + SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) + + /** + * @brief New + * @param className + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param code + * @return + */ + static Pointer New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for filter progress messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + FilterProgressMessage(); + FilterProgressMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int progress); + + private: + +}; +Q_DECLARE_METATYPE(FilterProgressMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/FilterStatusMessage.cpp b/Source/SIMPLib/Messages/FilterStatusMessage.cpp new file mode 100644 index 0000000000..8e39526491 --- /dev/null +++ b/Source/SIMPLib/Messages/FilterStatusMessage.cpp @@ -0,0 +1,88 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "FilterStatusMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterStatusMessage::FilterStatusMessage() +: AbstractStatusMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterStatusMessage::FilterStatusMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText) +: AbstractStatusMessage(msgText) +, m_ClassName(className) +, m_HumanLabel(humanLabel) +, m_PipelineIndex(pipelineIndex) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterStatusMessage::~FilterStatusMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterStatusMessage::Pointer FilterStatusMessage::New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText) +{ + FilterStatusMessage::Pointer shared_ptr (new FilterStatusMessage(className, humanLabel, pipelineIndex, msgText)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString FilterStatusMessage::generateMessageString() const +{ + return getMessageText(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterStatusMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/FilterStatusMessage.h b/Source/SIMPLib/Messages/FilterStatusMessage.h new file mode 100755 index 0000000000..442117fe96 --- /dev/null +++ b/Source/SIMPLib/Messages/FilterStatusMessage.h @@ -0,0 +1,93 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractStatusMessage.h" + +/** + * @class FilterStatusMessage FilterStatusMessage.h SIMPLib/Messages/FilterStatusMessage.h + * @brief This class is a filter status message class that is responsible for holding all the details + * of a status message emitted by an AbstractFilter + */ +class SIMPLib_EXPORT FilterStatusMessage : public AbstractStatusMessage +{ + public: + SIMPL_SHARED_POINTERS(FilterStatusMessage) + SIMPL_STATIC_NEW_MACRO(FilterStatusMessage) + SIMPL_TYPE_MACRO(FilterStatusMessage) + + virtual ~FilterStatusMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(ClassName) + + SIMPL_INSTANCE_STRING_PROPERTY(HumanLabel) + + SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) + + /** + * @brief New + * @param className + * @param humanLabel + * @param pipelineIndex + * @param msg + * @return + */ + static Pointer New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText); + + /** + * @brief This method creates and returns a string for filter status messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + FilterStatusMessage(); + FilterStatusMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText); + + private: + +}; +Q_DECLARE_METATYPE(FilterStatusMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/FilterWarningMessage.cpp b/Source/SIMPLib/Messages/FilterWarningMessage.cpp new file mode 100644 index 0000000000..785461466d --- /dev/null +++ b/Source/SIMPLib/Messages/FilterWarningMessage.cpp @@ -0,0 +1,89 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "FilterWarningMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterWarningMessage::FilterWarningMessage() +: AbstractWarningMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterWarningMessage::FilterWarningMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code) +: AbstractWarningMessage(msgText, code) +, m_ClassName(className) +, m_HumanLabel(humanLabel) +, m_PipelineIndex(pipelineIndex) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterWarningMessage::~FilterWarningMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FilterWarningMessage::Pointer FilterWarningMessage::New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code) +{ + FilterWarningMessage::Pointer shared_ptr (new FilterWarningMessage(className, humanLabel, pipelineIndex, msgText, code)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString FilterWarningMessage::generateMessageString() const +{ + QString ss = QObject::tr("'%1' Warning (%2): %4").arg(getClassName()).arg(getCode()).arg(getMessageText()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterWarningMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/FilterWarningMessage.h b/Source/SIMPLib/Messages/FilterWarningMessage.h new file mode 100755 index 0000000000..c72b0e4454 --- /dev/null +++ b/Source/SIMPLib/Messages/FilterWarningMessage.h @@ -0,0 +1,94 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractWarningMessage.h" + +/** + * @class FilterWarningMessage FilterWarningMessage.h SIMPLib/Messages/FilterWarningMessage.h + * @brief This class is a filter warning message class that is responsible for holding all the details + * of a warning message emitted by an AbstractFilter + */ +class SIMPLib_EXPORT FilterWarningMessage : public AbstractWarningMessage +{ + public: + SIMPL_SHARED_POINTERS(FilterWarningMessage) + SIMPL_STATIC_NEW_MACRO(FilterWarningMessage) + SIMPL_TYPE_MACRO(FilterWarningMessage) + + virtual ~FilterWarningMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(ClassName) + + SIMPL_INSTANCE_STRING_PROPERTY(HumanLabel) + + SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) + + /** + * @brief New + * @param className + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param code + * @return + */ + static Pointer New(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for filter warning messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + FilterWarningMessage(); + FilterWarningMessage(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msgText, int code); + + private: + +}; +Q_DECLARE_METATYPE(FilterWarningMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/GenericErrorMessage.cpp b/Source/SIMPLib/Messages/GenericErrorMessage.cpp new file mode 100644 index 0000000000..5f304d0fee --- /dev/null +++ b/Source/SIMPLib/Messages/GenericErrorMessage.cpp @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "GenericErrorMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericErrorMessage::GenericErrorMessage() +: AbstractErrorMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericErrorMessage::GenericErrorMessage(const QString& msgText, int code) +: AbstractErrorMessage(msgText, code) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericErrorMessage::~GenericErrorMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericErrorMessage::Pointer GenericErrorMessage::New(const QString& msgText, int code) +{ + GenericErrorMessage::Pointer shared_ptr (new GenericErrorMessage(msgText, code)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenericErrorMessage::generateMessageString() const +{ + QString ss = QObject::tr("Error (%1): %2").arg(getCode()).arg(getMessageText()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenericErrorMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/GenericErrorMessage.h b/Source/SIMPLib/Messages/GenericErrorMessage.h new file mode 100755 index 0000000000..5721f10867 --- /dev/null +++ b/Source/SIMPLib/Messages/GenericErrorMessage.h @@ -0,0 +1,85 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractErrorMessage.h" + +/** + * @class GenericErrorMessage GenericErrorMessage.h SIMPLib/Messages/GenericErrorMessage.h + * @brief This class is a generic error message class that is responsible for holding all the details + * of a generic error message emitted by any observable object + */ +class SIMPLib_EXPORT GenericErrorMessage : public AbstractErrorMessage +{ + public: + SIMPL_SHARED_POINTERS(GenericErrorMessage) + SIMPL_STATIC_NEW_MACRO(GenericErrorMessage) + SIMPL_TYPE_MACRO(GenericErrorMessage) + + virtual ~GenericErrorMessage(); + + /** + * @brief New + * @param msgText + * @param code + * @return + */ + static Pointer New(const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for generic error messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + GenericErrorMessage(); + GenericErrorMessage(const QString& msgText, int code); + + private: + +}; +Q_DECLARE_METATYPE(GenericErrorMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/GenericProgressMessage.cpp b/Source/SIMPLib/Messages/GenericProgressMessage.cpp new file mode 100644 index 0000000000..c9ca9deee3 --- /dev/null +++ b/Source/SIMPLib/Messages/GenericProgressMessage.cpp @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "GenericProgressMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericProgressMessage::GenericProgressMessage() +: AbstractProgressMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericProgressMessage::GenericProgressMessage(const QString& msgText, int progress) +: AbstractProgressMessage(msgText, progress) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericProgressMessage::~GenericProgressMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericProgressMessage::Pointer GenericProgressMessage::New(const QString& msgText, int progress) +{ + GenericProgressMessage::Pointer shared_ptr (new GenericProgressMessage(msgText, progress)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenericProgressMessage::generateMessageString() const +{ + QString ss = QObject::tr("%1 %2%%").arg(getMessageText()).arg(getProgressValue()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenericProgressMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/GenericProgressMessage.h b/Source/SIMPLib/Messages/GenericProgressMessage.h new file mode 100755 index 0000000000..7f79663708 --- /dev/null +++ b/Source/SIMPLib/Messages/GenericProgressMessage.h @@ -0,0 +1,85 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractProgressMessage.h" + +/** + * @class GenericProgressMessage GenericProgressMessage.h SIMPLib/Messages/GenericProgressMessage.h + * @brief This class is a generic progress message class that is responsible for holding all the details + * of a generic progress message emitted by any observable object + */ +class SIMPLib_EXPORT GenericProgressMessage : public AbstractProgressMessage +{ + public: + SIMPL_SHARED_POINTERS(GenericProgressMessage) + SIMPL_STATIC_NEW_MACRO(GenericProgressMessage) + SIMPL_TYPE_MACRO(GenericProgressMessage) + + virtual ~GenericProgressMessage(); + + /** + * @brief New + * @param msgText + * @param progress + * @return + */ + static Pointer New(const QString& msgText, int progress); + + /** + * @brief This method creates and returns a string for generic progress messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + GenericProgressMessage(); + GenericProgressMessage(const QString& msgText, int progress); + + private: + +}; +Q_DECLARE_METATYPE(GenericProgressMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/GenericStatusMessage.cpp b/Source/SIMPLib/Messages/GenericStatusMessage.cpp new file mode 100644 index 0000000000..6bde8f89f4 --- /dev/null +++ b/Source/SIMPLib/Messages/GenericStatusMessage.cpp @@ -0,0 +1,85 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "GenericStatusMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericStatusMessage::GenericStatusMessage() +: AbstractStatusMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericStatusMessage::GenericStatusMessage(const QString& msgText) +: AbstractStatusMessage(msgText) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericStatusMessage::~GenericStatusMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericStatusMessage::Pointer GenericStatusMessage::New(const QString& msgText) +{ + GenericStatusMessage::Pointer shared_ptr (new GenericStatusMessage(msgText)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenericStatusMessage::generateMessageString() const +{ + return getMessageText(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenericStatusMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/GenericStatusMessage.h b/Source/SIMPLib/Messages/GenericStatusMessage.h new file mode 100755 index 0000000000..d8b53bfc1b --- /dev/null +++ b/Source/SIMPLib/Messages/GenericStatusMessage.h @@ -0,0 +1,85 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractStatusMessage.h" + +/** + * @class GenericStatusMessage GenericStatusMessage.h SIMPLib/Messages/GenericStatusMessage.h + * @brief This class is a generic status message class that is responsible for holding all the details + * of a generic status message emitted by any observable object + */ +class SIMPLib_EXPORT GenericStatusMessage : public AbstractStatusMessage +{ + public: + SIMPL_SHARED_POINTERS(GenericStatusMessage) + SIMPL_STATIC_NEW_MACRO(GenericStatusMessage) + SIMPL_TYPE_MACRO(GenericStatusMessage) + + virtual ~GenericStatusMessage(); + + /** + * @brief New + * @param humanLabel + * @param msg + * @return + */ + static Pointer New(const QString& msgText); + + /** + * @brief This method creates and returns a string for generic status messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + GenericStatusMessage(); + GenericStatusMessage(const QString& msgText); + + private: + +}; +Q_DECLARE_METATYPE(GenericStatusMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/GenericWarningMessage.cpp b/Source/SIMPLib/Messages/GenericWarningMessage.cpp new file mode 100644 index 0000000000..f57cfe8b74 --- /dev/null +++ b/Source/SIMPLib/Messages/GenericWarningMessage.cpp @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "GenericWarningMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericWarningMessage::GenericWarningMessage() +: AbstractWarningMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericWarningMessage::GenericWarningMessage(const QString& msgText, int code) +: AbstractWarningMessage(msgText, code) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericWarningMessage::~GenericWarningMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenericWarningMessage::Pointer GenericWarningMessage::New(const QString& msgText, int code) +{ + GenericWarningMessage::Pointer shared_ptr (new GenericWarningMessage(msgText, code)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenericWarningMessage::generateMessageString() const +{ + QString ss = QObject::tr("Error (%1): %2").arg(getCode()).arg(getMessageText()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenericWarningMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/GenericWarningMessage.h b/Source/SIMPLib/Messages/GenericWarningMessage.h new file mode 100755 index 0000000000..eb7cd73c42 --- /dev/null +++ b/Source/SIMPLib/Messages/GenericWarningMessage.h @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractWarningMessage.h" + +/** + * @class GenericWarningMessage GenericWarningMessage.h SIMPLib/Messages/GenericWarningMessage.h + * @brief This class is a generic warning message class that is responsible for holding all the details + * of a generic warning message emitted by any observable object + */ +class SIMPLib_EXPORT GenericWarningMessage : public AbstractWarningMessage +{ + public: + SIMPL_SHARED_POINTERS(GenericWarningMessage) + SIMPL_STATIC_NEW_MACRO(GenericWarningMessage) + SIMPL_TYPE_MACRO(GenericWarningMessage) + + virtual ~GenericWarningMessage(); + + /** + * @brief New + * @param humanLabel + * @param msg + * @param code + * @return + */ + static Pointer New(const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for generic warning messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + GenericWarningMessage(); + GenericWarningMessage(const QString& msgText, int code); + + private: + +}; +Q_DECLARE_METATYPE(GenericWarningMessage::Pointer) + + diff --git a/Source/SVWidgetsLib/QtSupport/QtSDisclosableGroupBox.cpp b/Source/SIMPLib/Messages/PipelineErrorMessage.cpp similarity index 59% rename from Source/SVWidgetsLib/QtSupport/QtSDisclosableGroupBox.cpp rename to Source/SIMPLib/Messages/PipelineErrorMessage.cpp index 20f2336345..a007331989 100644 --- a/Source/SVWidgetsLib/QtSupport/QtSDisclosableGroupBox.cpp +++ b/Source/SIMPLib/Messages/PipelineErrorMessage.cpp @@ -1,7 +1,5 @@ /* ============================================================================ - * Copyright (c) 2012 Michael A. Jackson (BlueQuartz Software) - * Copyright (c) 2012 Dr. Michael A. Groeber (US Air Force Research Laboratories) - * All rights reserved. + * Copyright (c) 2009-2019 BlueQuartz Software, LLC * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -13,10 +11,9 @@ * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * - * Neither the name of Michael A. Groeber, Michael A. Jackson, the US Air Force, - * BlueQuartz Software nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior written - * permission. + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -29,91 +26,63 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * This code was written under United States Air Force Contract number - * FA8650-07-D-5800 + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "QtSDisclosableGroupBox.h" +#include "PipelineErrorMessage.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include "AbstractMessageHandler.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QtSDisclosableGroupBox::QtSDisclosableGroupBox(QWidget* parent) -: QGroupBox(parent) +PipelineErrorMessage::PipelineErrorMessage() +: AbstractErrorMessage() { - connect(this, SIGNAL(toggled(bool)), this, SLOT(disclose(bool))); } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QtSDisclosableGroupBox::~QtSDisclosableGroupBox() = default; +PipelineErrorMessage::PipelineErrorMessage(const QString &pipelineName, const QString& msgText, int code) +: AbstractErrorMessage(msgText, code) +, m_PipelineName(pipelineName) +{ +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void QtSDisclosableGroupBox::changeStyle() -{ -} +PipelineErrorMessage::~PipelineErrorMessage() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void QtSDisclosableGroupBox::updateWidgetStyle() +PipelineErrorMessage::Pointer PipelineErrorMessage::New(const QString &pipelineName, const QString& msgText, int code) { + PipelineErrorMessage::Pointer shared_ptr (new PipelineErrorMessage(pipelineName, msgText, code)); + return shared_ptr; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void QtSDisclosableGroupBox::setupGui() +QString PipelineErrorMessage::generateMessageString() const { - setCheckable(true); + QString ss = QObject::tr("Error (%1): %2").arg(getCode()).arg(getMessageText()); + return ss; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void QtSDisclosableGroupBox::disclose(bool on) +void PipelineErrorMessage::visit(AbstractMessageHandler* msgHandler) const { - if(on) - { - this->setMaximumHeight(260000); - } - else - { - this->setMaximumHeight(26); - } - - QObjectList objs = children(); - foreach(QObject* obj, objs) - { - QWidget* w = qobject_cast(obj); - if(nullptr != w) - { - if(on) - { - w->show(); - } - else - { - w->hide(); - } - } - } + msgHandler->processMessage(this); } diff --git a/Source/SIMPLib/Messages/PipelineErrorMessage.h b/Source/SIMPLib/Messages/PipelineErrorMessage.h new file mode 100755 index 0000000000..0f45094a9d --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineErrorMessage.h @@ -0,0 +1,89 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractErrorMessage.h" + +/** + * @class PipelineErrorMessage PipelineErrorMessage.h SIMPLib/Messages/PipelineErrorMessage.h + * @brief This class is a pipeline error message class that is responsible for holding all the details + * of a pipeline error message emitted by a FilterPipeline instance. + */ +class SIMPLib_EXPORT PipelineErrorMessage : public AbstractErrorMessage +{ + public: + SIMPL_SHARED_POINTERS(PipelineErrorMessage) + SIMPL_STATIC_NEW_MACRO(PipelineErrorMessage) + SIMPL_TYPE_MACRO(PipelineErrorMessage) + + virtual ~PipelineErrorMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(PipelineName) + + /** + * @brief New + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param code + * @return + */ + static Pointer New(const QString &pipelineName, const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for pipeline error messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + PipelineErrorMessage(); + PipelineErrorMessage(const QString &pipelineName, const QString& msgText, int code); + + private: + +}; +Q_DECLARE_METATYPE(PipelineErrorMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/PipelineProgressMessage.cpp b/Source/SIMPLib/Messages/PipelineProgressMessage.cpp new file mode 100644 index 0000000000..0495ef1351 --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineProgressMessage.cpp @@ -0,0 +1,87 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "PipelineProgressMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineProgressMessage::PipelineProgressMessage() +: AbstractProgressMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineProgressMessage::PipelineProgressMessage(const QString &pipelineName, const QString& msgText, int progress) +: AbstractProgressMessage(msgText, progress) +, m_PipelineName(pipelineName) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineProgressMessage::~PipelineProgressMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineProgressMessage::Pointer PipelineProgressMessage::New(const QString &pipelineName, const QString& msgText, int progress) +{ + PipelineProgressMessage::Pointer shared_ptr (new PipelineProgressMessage(pipelineName, msgText, progress)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString PipelineProgressMessage::generateMessageString() const +{ + QString ss = QObject::tr("%1 %2%%").arg(getMessageText()).arg(getProgressValue()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineProgressMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/PipelineProgressMessage.h b/Source/SIMPLib/Messages/PipelineProgressMessage.h new file mode 100755 index 0000000000..f6d92cf799 --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineProgressMessage.h @@ -0,0 +1,89 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractProgressMessage.h" + +/** + * @class PipelineProgressMessage PipelineProgressMessage.h SIMPLib/Messages/PipelineProgressMessage.h + * @brief This class is a pipeline progress message class that is responsible for holding all the details + * of a pipeline progress message emitted by a FilterPipeline instance. + */ +class SIMPLib_EXPORT PipelineProgressMessage : public AbstractProgressMessage +{ + public: + SIMPL_SHARED_POINTERS(PipelineProgressMessage) + SIMPL_STATIC_NEW_MACRO(PipelineProgressMessage) + SIMPL_TYPE_MACRO(PipelineProgressMessage) + + virtual ~PipelineProgressMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(PipelineName) + + /** + * @brief New + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param progress + * @return + */ + static Pointer New(const QString &pipelineName, const QString& msgText, int progress); + + /** + * @brief This method creates and returns a string for pipeline progress messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + PipelineProgressMessage(); + PipelineProgressMessage(const QString &pipelineName, const QString& msgText, int progress); + + private: + +}; +Q_DECLARE_METATYPE(PipelineProgressMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/PipelineStatusMessage.cpp b/Source/SIMPLib/Messages/PipelineStatusMessage.cpp new file mode 100644 index 0000000000..046cc033c6 --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineStatusMessage.cpp @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "PipelineStatusMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineStatusMessage::PipelineStatusMessage() +: AbstractStatusMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineStatusMessage::PipelineStatusMessage(const QString &pipelineName, const QString& msgText) +: AbstractStatusMessage(msgText) +, m_PipelineName(pipelineName) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineStatusMessage::~PipelineStatusMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineStatusMessage::Pointer PipelineStatusMessage::New(const QString &pipelineName, const QString& msgText) +{ + PipelineStatusMessage::Pointer shared_ptr (new PipelineStatusMessage(pipelineName, msgText)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString PipelineStatusMessage::generateMessageString() const +{ + return getMessageText(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineStatusMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/PipelineStatusMessage.h b/Source/SIMPLib/Messages/PipelineStatusMessage.h new file mode 100755 index 0000000000..cea626353e --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineStatusMessage.h @@ -0,0 +1,88 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractStatusMessage.h" + +/** + * @class PipelineStatusMessage PipelineStatusMessage.h SIMPLib/Messages/PipelineStatusMessage.h + * @brief This class is a pipeline status message class that is responsible for holding all the details + * of a pipeline status message emitted by a FilterPipeline instance. + */ +class SIMPLib_EXPORT PipelineStatusMessage : public AbstractStatusMessage +{ + public: + SIMPL_SHARED_POINTERS(PipelineStatusMessage) + SIMPL_STATIC_NEW_MACRO(PipelineStatusMessage) + SIMPL_TYPE_MACRO(PipelineStatusMessage) + + virtual ~PipelineStatusMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(PipelineName) + + /** + * @brief New + * @param humanLabel + * @param pipelineIndex + * @param msg + * @return + */ + static Pointer New(const QString &pipelineName, const QString& msgText); + + /** + * @brief This method creates and returns a string for pipeline status messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + PipelineStatusMessage(); + PipelineStatusMessage(const QString &pipelineName, const QString& msgText); + + private: + +}; +Q_DECLARE_METATYPE(PipelineStatusMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/PipelineWarningMessage.cpp b/Source/SIMPLib/Messages/PipelineWarningMessage.cpp new file mode 100644 index 0000000000..45412526ee --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineWarningMessage.cpp @@ -0,0 +1,87 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "PipelineWarningMessage.h" + +#include "AbstractMessageHandler.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineWarningMessage::PipelineWarningMessage() +: AbstractWarningMessage() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineWarningMessage::PipelineWarningMessage(const QString& pipelineName, const QString& msgText, int code) +: AbstractWarningMessage(msgText, code) +, m_PipelineName(pipelineName) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineWarningMessage::~PipelineWarningMessage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineWarningMessage::Pointer PipelineWarningMessage::New(const QString &pipelineName, const QString& msgText, int code) +{ + PipelineWarningMessage::Pointer shared_ptr (new PipelineWarningMessage(pipelineName, msgText, code)); + return shared_ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString PipelineWarningMessage::generateMessageString() const +{ + QString ss = QObject::tr("Warning (%1): %2").arg(getCode()).arg(getMessageText()); + return ss; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineWarningMessage::visit(AbstractMessageHandler* msgHandler) const +{ + msgHandler->processMessage(this); +} diff --git a/Source/SIMPLib/Messages/PipelineWarningMessage.h b/Source/SIMPLib/Messages/PipelineWarningMessage.h new file mode 100755 index 0000000000..e02a86d636 --- /dev/null +++ b/Source/SIMPLib/Messages/PipelineWarningMessage.h @@ -0,0 +1,89 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractWarningMessage.h" + +/** + * @class PipelineWarningMessage PipelineWarningMessage.h SIMPLib/Messages/PipelineWarningMessage.h + * @brief This class is a pipeline warning message class that is responsible for holding all the details + * of a pipeline warning message emitted by a FilterPipeline instance. + */ +class SIMPLib_EXPORT PipelineWarningMessage : public AbstractWarningMessage +{ + public: + SIMPL_SHARED_POINTERS(PipelineWarningMessage) + SIMPL_STATIC_NEW_MACRO(PipelineWarningMessage) + SIMPL_TYPE_MACRO(PipelineWarningMessage) + + virtual ~PipelineWarningMessage(); + + SIMPL_INSTANCE_STRING_PROPERTY(PipelineName) + + /** + * @brief New + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param code + * @return + */ + static Pointer New(const QString &pipelineName, const QString& msgText, int code); + + /** + * @brief This method creates and returns a string for pipeline warning messages + */ + virtual QString generateMessageString() const override; + + /** + * @brief Method that allows the visitation of a message by a message handler. This + * is part of the double-dispatch API that allows observers to be able to perform + * subclass specific operations on messages that they receive. + * @param msgHandler The observer's message handler + */ + virtual void visit(AbstractMessageHandler* msgHandler) const override final; + + protected: + PipelineWarningMessage(); + PipelineWarningMessage(const QString &pipelineName, const QString& msgText, int code); + + private: + +}; +Q_DECLARE_METATYPE(PipelineWarningMessage::Pointer) + + diff --git a/Source/SIMPLib/Messages/SourceList.cmake b/Source/SIMPLib/Messages/SourceList.cmake new file mode 100755 index 0000000000..cde173b105 --- /dev/null +++ b/Source/SIMPLib/Messages/SourceList.cmake @@ -0,0 +1,68 @@ + +set(SUBDIR_NAME Messages) + +# -------------------------------------------------------------------- +# Any Class that inherits from QObject, either directly or through the heirarchy needs to have its header listed here +set(SIMPLib_${SUBDIR_NAME}_Moc_HDRS + # ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DocRequestManager.h +) + +# -------------------------------------------------------------------- +# Run Qts automoc program to generate some source files that get compiled +# QT5_WRAP_CPP( SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS ${SIMPLib_${SUBDIR_NAME}_Moc_HDRS}) +set_source_files_properties( ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} PROPERTIES GENERATED TRUE) +set_source_files_properties( ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} PROPERTIES HEADER_FILE_ONLY TRUE) + +set(SIMPLib_${SUBDIR_NAME}_HDRS + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractMessageHandler.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractErrorMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractProgressMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractStatusMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractWarningMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterErrorMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterProgressMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterStatusMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterWarningMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericErrorMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericProgressMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericStatusMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericWarningMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineErrorMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineProgressMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineStatusMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineWarningMessage.h +) + + +set(SIMPLib_${SUBDIR_NAME}_SRCS + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractMessageHandler.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterErrorMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterProgressMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterStatusMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterWarningMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericErrorMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericProgressMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericStatusMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenericWarningMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineErrorMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineProgressMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineStatusMessage.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineWarningMessage.cpp +) + +cmp_IDE_SOURCE_PROPERTIES( "${SUBDIR_NAME}" "${SIMPLib_${SUBDIR_NAME}_HDRS};${SIMPLib_${SUBDIR_NAME}_Moc_HDRS}" "${SIMPLib_${SUBDIR_NAME}_SRCS}" "${PROJECT_INSTALL_HEADERS}") +cmp_IDE_SOURCE_PROPERTIES( "Generated/${SUBDIR_NAME}" "" "${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS}" "0") + +set(SIMPLib_${SUBDIR_NAME}_HDRS + ${SIMPLib_${SUBDIR_NAME}_HDRS} + ${SIMPLib_${SUBDIR_NAME}_Moc_HDRS} # Add the headers that get Moc'ed here so they show up in solutions/IDEs/Project files +) + +set(SIMPLib_${SUBDIR_NAME}_SRCS + ${SIMPLib_${SUBDIR_NAME}_SRCS} + ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} +) + + diff --git a/Source/SIMPLib/REST/PipelineListener.cpp b/Source/SIMPLib/REST/PipelineListener.cpp index 98334e8011..59f3baff28 100644 --- a/Source/SIMPLib/REST/PipelineListener.cpp +++ b/Source/SIMPLib/REST/PipelineListener.cpp @@ -1,5 +1,11 @@ #include "PipelineListener.h" +#include "REST/PipelineListenerMessageHandler.h" + +#include "SIMPLib/Messages/AbstractErrorMessage.h" +#include "SIMPLib/Messages/AbstractWarningMessage.h" +#include "SIMPLib/Messages/AbstractStatusMessage.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -23,142 +29,53 @@ PipelineListener::~PipelineListener() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector PipelineListener::getMessages() +std::vector PipelineListener::getAllMessages() { - return m_Messages; + return m_AllMessages; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector PipelineListener::getErrorMessages() +std::vector PipelineListener::getErrorMessages() { - std::vector errorMessages; - - size_t numMessages = m_Messages.size(); - for(size_t i = 0; i < numMessages; i++) - { - if(m_Messages[i].getType() == PipelineMessage::MessageType::Error) - { - errorMessages.push_back(m_Messages[i]); - } - } - - return errorMessages; + return m_ErrorMessages; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector PipelineListener::getWarningMessages() +std::vector PipelineListener::getWarningMessages() { - std::vector warningMessages; - - size_t numMessages = m_Messages.size(); - for(size_t i = 0; i < numMessages; i++) - { - if(m_Messages[i].getType() == PipelineMessage::MessageType::Warning) - { - warningMessages.push_back(m_Messages[i]); - } - } - - return warningMessages; + return m_WarningMessages; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector PipelineListener::getStatusMessages() +std::vector PipelineListener::getStatusMessages() { - std::vector statusMessages; - - size_t numMessages = m_Messages.size(); - for(size_t i = 0; i < numMessages; i++) - { - if(m_Messages[i].getType() == PipelineMessage::MessageType::StatusMessage) - { - statusMessages.push_back(m_Messages[i]); - } - } - - return statusMessages; + return m_StatusMessages; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector PipelineListener::getStandardOutputMessages() +std::vector PipelineListener::getProgressMessages() { - std::vector stdOutMessages; - - size_t numMessages = m_Messages.size(); - for(size_t i = 0; i < numMessages; i++) - { - if(m_Messages[i].getType() == PipelineMessage::MessageType::StandardOutputMessage) - { - stdOutMessages.push_back(m_Messages[i]); - } - } - - return stdOutMessages; + return m_ProgressMessages; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PipelineListener::processPipelineMessage(const PipelineMessage& pm) +void PipelineListener::processPipelineMessage(const AbstractMessage::Pointer& pm) { - m_Messages.push_back(pm); - - switch(pm.getType()) - { - case PipelineMessage::MessageType::Error: - if(m_ErrorLog && m_ErrorLog->open(QIODevice::ReadWrite)) - { - QTextStream stream(m_ErrorLog); - stream.readAll(); - stream << pm.generateErrorString() << endl; - m_ErrorLog->close(); - } - break; - case PipelineMessage::MessageType::Warning: - if(m_WarningLog && m_WarningLog->open(QIODevice::ReadWrite)) - { - QTextStream stream(m_WarningLog); - stream.readAll(); - stream << pm.generateWarningString() << endl; - m_WarningLog->close(); - } - break; - case PipelineMessage::MessageType::StatusMessage: - if(m_StatusLog && m_StatusLog->open(QIODevice::ReadWrite)) - { - QTextStream stream(m_StatusLog); - stream.readAll(); - stream << pm.generateStatusString() << endl; - m_StatusLog->close(); - } - - qDebug() << pm.getText(); - break; - case PipelineMessage::MessageType::StandardOutputMessage: - if(m_StandardOutputLog && m_StandardOutputLog->open(QIODevice::ReadWrite)) - { - QTextStream stream(m_StandardOutputLog); - stream.readAll(); - stream << pm.generateStandardOutputString() << endl; - m_StandardOutputLog->close(); - } - break; - default: - break; - } + PipelineListenerMessageHandler msgHandler(this); + pm->visit(&msgHandler); - if(pm.getType() == PipelineMessage::MessageType::StandardOutputMessage) - { - qDebug() << pm.getText(); - } + m_SharedMessages.push_back(pm); + m_AllMessages.push_back(pm.get()); } // ----------------------------------------------------------------------------- @@ -166,13 +83,13 @@ void PipelineListener::processPipelineMessage(const PipelineMessage& pm) // ----------------------------------------------------------------------------- QString PipelineListener::getErrorLog() { - std::vector messages = getErrorMessages(); + std::vector messages = getErrorMessages(); int count = messages.size(); QString log; for(int i = 0; i < count; i++) { - log += messages[i].generateErrorString() + "\n"; + log += messages[i]->generateMessageString() + "\n"; } return log; @@ -183,13 +100,13 @@ QString PipelineListener::getErrorLog() // ----------------------------------------------------------------------------- QString PipelineListener::getWarningLog() { - std::vector messages = getWarningMessages(); + std::vector messages = getWarningMessages(); int count = messages.size(); QString log; for(int i = 0; i < count; i++) { - log += messages[i].generateWarningString() + "\n"; + log += messages[i]->generateMessageString() + "\n"; } return log; @@ -200,30 +117,13 @@ QString PipelineListener::getWarningLog() // ----------------------------------------------------------------------------- QString PipelineListener::getStatusLog() { - std::vector messages = getStatusMessages(); + std::vector messages = getStatusMessages(); int count = messages.size(); QString log; for(int i = 0; i < count; i++) { - log += messages[i].generateStatusString() + "\n"; - } - - return log; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString PipelineListener::getStandardOutputLog() -{ - std::vector messages = getStandardOutputMessages(); - int count = messages.size(); - QString log; - - for(int i = 0; i < count; i++) - { - log += messages[i].generateStandardOutputString() + "\n"; + log += messages[i]->generateMessageString() + "\n"; } return log; @@ -271,20 +171,6 @@ void PipelineListener::createStatusLogFile(QString path) m_StatusLog = new QFile(path); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void PipelineListener::createStandardOutputLogFile(QString path) -{ - if(m_StandardOutputLog) - { - m_StandardOutputLog->close(); - delete m_StandardOutputLog; - } - - m_StandardOutputLog = new QFile(path); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/REST/PipelineListener.h b/Source/SIMPLib/REST/PipelineListener.h index 0d1ad034ea..8287bb64ad 100644 --- a/Source/SIMPLib/REST/PipelineListener.h +++ b/Source/SIMPLib/REST/PipelineListener.h @@ -5,10 +5,17 @@ #include #include "SIMPLib/Common/IObserver.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/SIMPLib.h" +class PipelineListenerMessageHandler; + +class AbstractErrorMessage; +class AbstractProgressMessage; +class AbstractStatusMessage; +class AbstractWarningMessage; + class SIMPLib_EXPORT PipelineListener : public QObject, public IObserver { Q_OBJECT @@ -18,28 +25,33 @@ class SIMPLib_EXPORT PipelineListener : public QObject, public IObserver PipelineListener(QObject* parent); virtual ~PipelineListener(); + friend PipelineListenerMessageHandler; + void createErrorLogFile(QString path); void createWarningLogFile(QString path); void createStatusLogFile(QString path); - void createStandardOutputLogFile(QString path); void closeFiles(); - std::vector getMessages(); - std::vector getErrorMessages(); - std::vector getWarningMessages(); - std::vector getStatusMessages(); - std::vector getStandardOutputMessages(); + std::vector getAllMessages(); + std::vector getErrorMessages(); + std::vector getWarningMessages(); + std::vector getStatusMessages(); + std::vector getProgressMessages(); QString getErrorLog(); QString getWarningLog(); QString getStatusLog(); - QString getStandardOutputLog(); public slots: - void processPipelineMessage(const PipelineMessage& pm); + void processPipelineMessage(const AbstractMessage::Pointer& pm); private: - std::vector m_Messages; + std::vector m_SharedMessages; + std::vector m_AllMessages; + std::vector m_ErrorMessages; + std::vector m_StatusMessages; + std::vector m_ProgressMessages; + std::vector m_WarningMessages; QFile* m_ErrorLog; QFile* m_WarningLog; diff --git a/Source/SIMPLib/REST/PipelineListenerMessageHandler.cpp b/Source/SIMPLib/REST/PipelineListenerMessageHandler.cpp new file mode 100644 index 0000000000..5c9398ca30 --- /dev/null +++ b/Source/SIMPLib/REST/PipelineListenerMessageHandler.cpp @@ -0,0 +1,163 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "PipelineListenerMessageHandler.h" + +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/GenericWarningMessage.h" +#include "SIMPLib/Messages/GenericStatusMessage.h" +#include "SIMPLib/Messages/GenericProgressMessage.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" +#include "SIMPLib/Messages/PipelineWarningMessage.h" +#include "SIMPLib/Messages/PipelineStatusMessage.h" +#include "SIMPLib/Messages/PipelineProgressMessage.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" + +#include "REST/PipelineListener.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PipelineListenerMessageHandler::PipelineListenerMessageHandler(PipelineListener* listener) +: m_Listener(listener) +{ + +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const PipelineErrorMessage* msg) const +{ + QFile* log = m_Listener->m_ErrorLog; + QString msgString = msg->generateMessageString(); + streamToLog(msgString, log); + + m_Listener->m_ErrorMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const PipelineWarningMessage* msg) const +{ + QFile* log = m_Listener->m_WarningLog; + QString msgString = msg->generateMessageString(); + streamToLog(msgString, log); + + m_Listener->m_WarningMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const PipelineStatusMessage* msg) const +{ + QFile* log = m_Listener->m_StatusLog; + QString msgString = msg->generateMessageString(); + streamToLog(msgString, log); + + m_Listener->m_StatusMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const PipelineProgressMessage* msg) const +{ + m_Listener->m_ProgressMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const FilterErrorMessage* msg) const +{ + QFile* log = m_Listener->m_ErrorLog; + QString msgString = msg->generateMessageString(); + streamToLog(msgString, log); + + m_Listener->m_ErrorMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const FilterWarningMessage* msg) const +{ + QFile* log = m_Listener->m_WarningLog; + QString msgString = msg->generateMessageString(); + streamToLog(msgString, log); + + m_Listener->m_WarningMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const FilterStatusMessage* msg) const +{ + QFile* log = m_Listener->m_StatusLog; + QString msgString = msg->generateMessageString(); + streamToLog(msgString, log); + + m_Listener->m_StatusMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::processMessage(const FilterProgressMessage* msg) const +{ + m_Listener->m_ProgressMessages.push_back(msg); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PipelineListenerMessageHandler::streamToLog(const QString &msgString, QFile* log) const +{ + if(log && log->open(QIODevice::ReadWrite)) + { + QTextStream stream(log); + stream.readAll(); + stream << msgString << endl; + log->close(); + } +} diff --git a/Source/SIMPLib/REST/PipelineListenerMessageHandler.h b/Source/SIMPLib/REST/PipelineListenerMessageHandler.h new file mode 100644 index 0000000000..db1642c542 --- /dev/null +++ b/Source/SIMPLib/REST/PipelineListenerMessageHandler.h @@ -0,0 +1,104 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/SIMPLib.h" + +class QFile; +class PipelineListener; + +/** + * @brief This message handler is used by the PipelineListener class to stream incoming error, warning, + * and status messages to the correct logs. It also stores the incoming messages for later use. + */ +class SIMPLib_EXPORT PipelineListenerMessageHandler : public AbstractMessageHandler +{ +public: + PipelineListenerMessageHandler(PipelineListener* listener); + + /** + * @brief Streams incoming PipelineErrorMessages to the error log and stores the message + * for later use. + */ + virtual void processMessage(const PipelineErrorMessage* msg) const override; + + /** + * @brief Stores the incoming PipelineProgressMessages for later use. + */ + virtual void processMessage(const PipelineProgressMessage* msg) const override; + + /** + * @brief Streams incoming PipelineStatusMessages to the status log and stores the message + * for later use. + */ + virtual void processMessage(const PipelineStatusMessage* msg) const override; + + /** + * @brief Streams incoming PipelineWarningMessages to the warning log and stores the message + * for later use. + */ + virtual void processMessage(const PipelineWarningMessage* msg) const override; + + /** + * @brief Streams incoming FilterErrorMessages to the error log and stores the message + * for later use. + */ + virtual void processMessage(const FilterErrorMessage* msg) const override; + + /** + * @brief Stores the incoming FilterProgressMessages for later use. + */ + virtual void processMessage(const FilterProgressMessage* msg) const override; + + /** + * @brief Streams incoming FilterStatusMessages to the status log and stores the message + * for later use. + */ + virtual void processMessage(const FilterStatusMessage* msg) const override; + + /** + * @brief Streams incoming FilterWarningMessages to the warning log and stores the message + * for later use. + */ + virtual void processMessage(const FilterWarningMessage* msg) const override; + +private: + PipelineListener* m_Listener = nullptr; + + void streamToLog(const QString& msgString, QFile* log) const; +}; diff --git a/Source/SIMPLib/REST/SourceList.cmake b/Source/SIMPLib/REST/SourceList.cmake index 25310c44ee..efcc8f1f27 100755 --- a/Source/SIMPLib/REST/SourceList.cmake +++ b/Source/SIMPLib/REST/SourceList.cmake @@ -29,23 +29,29 @@ set_source_files_properties( ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} PROPER set_source_files_properties( ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} PROPERTIES HEADER_FILE_ONLY TRUE) set(SIMPLib_${SUBDIR_NAME}_HDRS + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineListenerMessageHandler.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/ExecutePipelineMessageHandler.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/PreflightPipelineMessageHandler.h ) set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRequestMapper.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineListener.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineListenerMessageHandler.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLDirectoryListing.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/NumFiltersController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/V1RequestMapper.cpp - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/ExecutePipelineController.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/ExecutePipelineController.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/ExecutePipelineMessageHandler.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/NumFiltersController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/ListFilterParametersController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/PluginInfoController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/LoadedPluginsController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/PreflightPipelineController.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/PreflightPipelineMessageHandler.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/NamesOfFiltersController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/ApiNotFoundController.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/V1Controllers/SIMPLStaticFileController.cpp diff --git a/Source/SIMPLib/REST/Testing/Cxx/RESTUnitTest.cpp b/Source/SIMPLib/REST/Testing/Cxx/RESTUnitTest.cpp index d567d61718..427c9230fb 100755 --- a/Source/SIMPLib/REST/Testing/Cxx/RESTUnitTest.cpp +++ b/Source/SIMPLib/REST/Testing/Cxx/RESTUnitTest.cpp @@ -59,6 +59,8 @@ #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Messages/AbstractErrorMessage.h" +#include "SIMPLib/Messages/AbstractWarningMessage.h" #include "SIMPLib/Plugin/PluginManager.h" #include "SIMPLib/Plugin/SIMPLPluginConstants.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" @@ -333,10 +335,10 @@ class RESTUnitTest pipeline->execute(); - std::vector warningMessages = listener.getWarningMessages(); + std::vector warningMessages = listener.getWarningMessages(); DREAM3D_REQUIRE_EQUAL(warningMessages.size(), 0); - std::vector errorMessages = listener.getErrorMessages(); + std::vector errorMessages = listener.getErrorMessages(); DREAM3D_REQUIRE_EQUAL(errorMessages.size(), 0); } } @@ -527,10 +529,10 @@ class RESTUnitTest pipeline->execute(); - std::vector warningMessages = listener.getWarningMessages(); + std::vector warningMessages = listener.getWarningMessages(); DREAM3D_REQUIRE_EQUAL(warningMessages.size(), 0); - std::vector errorMessages = listener.getErrorMessages(); + std::vector errorMessages = listener.getErrorMessages(); DREAM3D_REQUIRE_EQUAL(errorMessages.size(), 0); } else @@ -564,7 +566,7 @@ class RESTUnitTest FilterPipeline::Pointer pipeline = FilterPipeline::New(); CreateDataContainer::Pointer createDataContainer = CreateDataContainer::New(); - createDataContainer->setDataContainerName("DataContainer"); + createDataContainer->setDataContainerName(DataArrayPath("DataContainer", "", "")); pipeline->pushBack(createDataContainer); CreateAttributeMatrix::Pointer createAttrMat = CreateAttributeMatrix::New(); @@ -591,7 +593,7 @@ class RESTUnitTest pipeline->pushBack(writer); DataContainerArray::Pointer dca = pipeline->execute(); - int32_t err = pipeline->getErrorCondition(); + int32_t err = pipeline->getErrorCode(); DREAM3D_REQUIRE(err >= 0); } // ----------------------------------------------------------------------------- @@ -798,10 +800,10 @@ class RESTUnitTest pipeline->execute(); - std::vector warningMessages = listener.getWarningMessages(); + std::vector warningMessages = listener.getWarningMessages(); DREAM3D_REQUIRE_EQUAL(warningMessages.size(), 0); - std::vector errorMessages = listener.getErrorMessages(); + std::vector errorMessages = listener.getErrorMessages(); DREAM3D_REQUIRE_EQUAL(errorMessages.size(), 0); } else @@ -977,7 +979,7 @@ class RESTUnitTest QJsonArray responseFPArray = responseObject[SIMPL::JSON::FilterParameters].toArray(); CreateAttributeMatrix::Pointer filter = CreateAttributeMatrix::New(); - QVector parameters = filter->getFilterParameters(); + FilterParameterVectorType parameters = filter->getFilterParameters(); DREAM3D_REQUIRE_EQUAL(responseFPArray.size(), parameters.size()); @@ -1523,10 +1525,10 @@ class RESTUnitTest pipeline->preflightPipeline(); - std::vector warningMessages = listener.getWarningMessages(); + std::vector warningMessages = listener.getWarningMessages(); DREAM3D_REQUIRE_EQUAL(warningMessages.size(), 0); - std::vector errorMessages = listener.getErrorMessages(); + std::vector errorMessages = listener.getErrorMessages(); DREAM3D_REQUIRED(errorMessages.size(), >, 0); for(int i = 0; i < responseErrorsArray.size(); i++) @@ -1540,8 +1542,8 @@ class RESTUnitTest DREAM3D_REQUIRE_EQUAL(responseErrorObject[SIMPL::JSON::FilterIndex].isDouble(), true); int responseErrorCode = responseErrorObject[SIMPL::JSON::Code].toInt(); - PipelineMessage errorMessage = errorMessages[i]; - DREAM3D_REQUIRE_EQUAL(responseErrorCode, errorMessage.getCode()); + const AbstractErrorMessage* errorMessage = errorMessages[i]; + DREAM3D_REQUIRE_EQUAL(responseErrorCode, errorMessage->getCode()); } } @@ -1593,10 +1595,10 @@ class RESTUnitTest pipeline->preflightPipeline(); - std::vector warningMessages = listener.getWarningMessages(); + std::vector warningMessages = listener.getWarningMessages(); DREAM3D_REQUIRE_EQUAL(warningMessages.size(), 0); - std::vector errorMessages = listener.getErrorMessages(); + std::vector errorMessages = listener.getErrorMessages(); DREAM3D_REQUIRE_EQUAL(errorMessages.size(), 0); } } diff --git a/Source/SIMPLib/REST/Testing/Cxx/SourceList.cmake b/Source/SIMPLib/REST/Testing/Cxx/SourceList.cmake index 5ea743814c..d19151bd69 100644 --- a/Source/SIMPLib/REST/Testing/Cxx/SourceList.cmake +++ b/Source/SIMPLib/REST/Testing/Cxx/SourceList.cmake @@ -6,4 +6,4 @@ set(TEST_${SUBDIR_NAME}_NAMES ) SIMPL_ADD_UNIT_TEST("${TEST_${SUBDIR_NAME}_NAMES}" "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") -SIMPL_ADD_UNIT_TEST_MOC_FILE(RESTUnitTest "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") \ No newline at end of file +SIMPL_ADD_UNIT_TEST_MOC_FILE(RESTUnitTest "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") diff --git a/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.cpp b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.cpp index ee2841aa95..935edc3061 100644 --- a/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.cpp +++ b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.cpp @@ -56,6 +56,7 @@ #include "QtWebApp/httpserver/httpsessionstore.h" #include "SIMPLStaticFileController.h" #include "SIMPLib/REST/PipelineListener.h" +#include "SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.h" // ----------------------------------------------------------------------------- // @@ -86,17 +87,17 @@ void ExecutePipelineController::serviceJSON(QJsonObject pipelineObj) // SIMPLStaticFileController* staticFileController = SIMPLStaticFileController::Instance(); // QString docRoot = staticFileController->getDocRoot(); -// QString newFilePath = docRoot + QDir::separator() + QString(sessionId) + QDir::separator(); -// QJsonArray outputLinks; + // QString newFilePath = docRoot + QDir::separator() + QString(sessionId) + QDir::separator(); + // QJsonArray outputLinks; // // Look through the pipeline to find any input or output filter parameters. Replace // // the file paths in these filter parameters with session-id specific paths. // QList filters = pipeline->getFilterContainer(); // for(int i = 0; i < filters.size(); i++) // { // AbstractFilter::Pointer filter = filters[i]; - // QVector filterParams = filter->getFilterParameters(); + // FilterParameterVectorType filterParams = filter->getFilterParameters(); - // for(QVector::iterator iter = filterParams.begin(); iter != filterParams.end(); ++iter) + // for(FilterParameterVectorType::iterator iter = filterParams.begin(); iter != filterParams.end(); ++iter) // { // FilterParameter* parameter = (*iter).get(); // OutputFileFilterParameter* outFileParam = dynamic_cast(parameter); @@ -186,53 +187,29 @@ void ExecutePipelineController::serviceJSON(QJsonObject pipelineObj) qDebug() << "Pipeline About to Execute...."; pipeline->execute(); - qDebug() << "Pipeline Done Executing...." << pipeline->getErrorCondition(); + qDebug() << "Pipeline Done Executing...." << pipeline->getErrorCode(); } - // Return messages - std::vector errorMessages = listener.getErrorMessages(); - bool completed = (errorMessages.size() == 0); + // Return messages QJsonArray errors; - size_t numErrors = errorMessages.size(); - for(size_t i = 0; i < numErrors; i++) - { - QJsonObject error; - error[SIMPL::JSON::Code] = errorMessages[i].generateErrorString(); - error[SIMPL::JSON::Message] = errorMessages[i].getText(); - error[SIMPL::JSON::FilterHumanLabel] = errorMessages[i].getFilterHumanLabel(); - error[SIMPL::JSON::FilterIndex] = errorMessages[i].getPipelineIndex(); - - errors.push_back(error); - } - m_ResponseObj[SIMPL::JSON::PipelineErrors] = errors; - - std::vector warningMessages = listener.getWarningMessages(); QJsonArray warnings; - size_t numWarnings = warningMessages.size(); - for(size_t i = 0; i < numWarnings; i++) - { - QJsonObject warning; - warning[SIMPL::JSON::Code] = warningMessages[i].generateWarningString(); - warning[SIMPL::JSON::Message] = warningMessages[i].getText(); - warning[SIMPL::JSON::FilterHumanLabel] = warningMessages[i].getFilterHumanLabel(); - warning[SIMPL::JSON::FilterIndex] = warningMessages[i].getPipelineIndex(); + QJsonArray statusMsgs; - warnings.push_back(warning); - } + std::vector errorMessages = listener.getErrorMessages(); + bool completed = (errorMessages.size() == 0); + m_ResponseObj[SIMPL::JSON::Completed] = completed; - std::vector statusMessages = listener.getStatusMessages(); - QJsonArray statusMsgs; - size_t numStatusMsgs = statusMessages.size(); - for(size_t i = 0; i < numStatusMsgs; i++) + std::vector allMessages = listener.getAllMessages(); + for(const AbstractMessage* msg : allMessages) { - QJsonObject msg; - msg[SIMPL::JSON::Message] = statusMessages[i].generateStatusString(); - statusMsgs.push_back(msg); + ExecutePipelineMessageHandler msgHandler(&errors, &warnings); + msg->visit(&msgHandler); } - // responseObj["StatusMessages"] = statusMsgs; + + m_ResponseObj[SIMPL::JSON::PipelineErrors] = errors; m_ResponseObj[SIMPL::JSON::PipelineWarnings] = warnings; - m_ResponseObj[SIMPL::JSON::Completed] = completed; + // m_ResponseObj["StatusMessages"] = statusMsgs; // // ************************************************************************** // // This section archives the working directory for this session diff --git a/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.h b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.h index b6af8ea523..8fb7e7ef7c 100644 --- a/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.h +++ b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineController.h @@ -41,6 +41,8 @@ #include "QtWebApp/httpserver/httpresponse.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Plugin/SIMPLPluginConstants.h" /** @brief This class responds to REST API endpoint diff --git a/Source/SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.cpp b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.cpp new file mode 100644 index 0000000000..d3d1cfbce6 --- /dev/null +++ b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.cpp @@ -0,0 +1,102 @@ +/* ============================================================================ + * Copyright (c) 2017-2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "ExecutePipelineMessageHandler.h" + +#include "QtCore/QJsonArray" + +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" +#include "SIMPLib/Messages/PipelineWarningMessage.h" + +#include "REST/V1Controllers/ExecutePipelineController.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ExecutePipelineMessageHandler::ExecutePipelineMessageHandler(QJsonArray* errors, QJsonArray* warnings) +: m_Errors(errors) +, m_Warnings(warnings) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ExecutePipelineMessageHandler::processMessage(const FilterErrorMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + obj.insert(SIMPL::JSON::FilterIndex, msg->getPipelineIndex()); + obj.insert(SIMPL::JSON::FilterHumanLabel, msg->getHumanLabel()); + m_Errors->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ExecutePipelineMessageHandler::processMessage(const FilterWarningMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + obj.insert(SIMPL::JSON::FilterIndex, msg->getPipelineIndex()); + obj.insert(SIMPL::JSON::FilterHumanLabel, msg->getHumanLabel()); + m_Warnings->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ExecutePipelineMessageHandler::processMessage(const PipelineErrorMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + m_Errors->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ExecutePipelineMessageHandler::processMessage(const PipelineWarningMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + m_Warnings->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QJsonObject ExecutePipelineMessageHandler::writeToJson(int code, const QString& msg) const +{ + QJsonObject obj; + obj.insert(SIMPL::JSON::Code, code); + obj.insert(SIMPL::JSON::Message, msg); + return obj; +} diff --git a/Source/SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.h b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.h new file mode 100644 index 0000000000..a925d2b93a --- /dev/null +++ b/Source/SIMPLib/REST/V1Controllers/ExecutePipelineMessageHandler.h @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2017-2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" + +/** + * @brief This message handler is used by the ExecutePipeline class to store values from error and warning + * messages in json objects. These json objects are stored in an error json array and a warning json array. + */ +class SIMPLib_EXPORT ExecutePipelineMessageHandler : public AbstractMessageHandler +{ + public: + ExecutePipelineMessageHandler(QJsonArray* errors, QJsonArray* warnings); + + /** + * @brief Stores pipeline index, human label, message text, and error code + * of incoming FilterErrorMessages into a json object and stores the json + * object in the errors json array. + */ + void processMessage(const FilterErrorMessage* msg) const override; + + /** + * @brief Stores pipeline index, human label, message text, and warning code + * of incoming FilterWarningMessages into a json object and stores the json + * object in the warnings json array. + */ + void processMessage(const FilterWarningMessage* msg) const override; + + /** + * @brief Stores message text and warning code of incoming PipelineErrorMessages + * into a json object and stores the json object in the errors json array. + */ + void processMessage(const PipelineErrorMessage* msg) const override; + + /** + * @brief Stores message text and warning code of incoming PipelineWarningMessages + * into a json object and stores the json object in the warnings json array. + */ + void processMessage(const PipelineWarningMessage* msg) const override; + + private: + QJsonArray* m_Errors = nullptr; + QJsonArray* m_Warnings = nullptr; + + /** + * @brief writeToJson + * @param code + * @param msg + */ + QJsonObject writeToJson(int code, const QString &msg) const; +}; + diff --git a/Source/SIMPLib/REST/V1Controllers/ListFilterParametersController.cpp b/Source/SIMPLib/REST/V1Controllers/ListFilterParametersController.cpp index 54cd6ed3c5..87d3135fac 100644 --- a/Source/SIMPLib/REST/V1Controllers/ListFilterParametersController.cpp +++ b/Source/SIMPLib/REST/V1Controllers/ListFilterParametersController.cpp @@ -74,7 +74,7 @@ void ListFilterParametersController::createFilterParametersJson(const QString& f return; } - QVector parameters = filter->getFilterParameters(); + FilterParameterVectorType parameters = filter->getFilterParameters(); QJsonArray jsonParameters; for(int i = 0; i < parameters.size(); i++) diff --git a/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.cpp b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.cpp index 8c7e7d8d16..6927456c6b 100644 --- a/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.cpp +++ b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.cpp @@ -29,6 +29,7 @@ * * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include "PreflightPipelineController.h" #include @@ -48,6 +49,7 @@ #include "QtWebApp/httpserver/httpsessionstore.h" #include "SIMPLib/REST/PipelineListener.h" #include "SIMPLib/REST/V1Controllers/SIMPLStaticFileController.h" +#include "SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.h" // ----------------------------------------------------------------------------- // @@ -171,40 +173,23 @@ void PreflightPipelineController::service(HttpRequest& request, HttpResponse& re // response.setCookie(HttpCookie("firstCookie","hello",600,QByteArray(),QByteArray(),QByteArray(),false,true)); // response.setCookie(HttpCookie("secondCookie","world",600)); - // Return messages - std::vector errorMessages = listener.getErrorMessages(); - bool completed = (errorMessages.size() == 0); - QJsonArray errors; - int numErrors = errorMessages.size(); - for(int i = 0; i < numErrors; i++) - { - QJsonObject error; - error[SIMPL::JSON::Code] = errorMessages[i].getCode(); - error[SIMPL::JSON::Message] = errorMessages[i].getText(); - error[SIMPL::JSON::FilterHumanLabel] = errorMessages[i].getFilterHumanLabel(); - error[SIMPL::JSON::FilterIndex] = errorMessages[i].getPipelineIndex(); + QJsonArray warnings; - errors.push_back(error); - } - rootObj[SIMPL::JSON::PipelineErrors] = errors; + std::vector errorMessages = listener.getErrorMessages(); + bool completed = (errorMessages.size() == 0); + rootObj[SIMPL::JSON::Completed] = completed; - std::vector warningMessages = listener.getWarningMessages(); - QJsonArray warnings; - int numWarnings = warningMessages.size(); - for(int i = 0; i < numWarnings; i++) + std::vector allMessages = listener.getAllMessages(); + for(const AbstractMessage* msg : allMessages) { - QJsonObject warning; - warning[SIMPL::JSON::Code] = warningMessages[i].getCode(); - warning[SIMPL::JSON::Message] = warningMessages[i].getText(); - warning[SIMPL::JSON::FilterHumanLabel] = warningMessages[i].getFilterHumanLabel(); - warning[SIMPL::JSON::FilterIndex] = warningMessages[i].getPipelineIndex(); - - warnings.push_back(warning); + PreflightPipelineMessageHandler msgHandler(&errors, &warnings); + msg->visit(&msgHandler); } + + rootObj[SIMPL::JSON::PipelineErrors] = errors; rootObj[SIMPL::JSON::PipelineWarnings] = warnings; - rootObj[SIMPL::JSON::Completed] = completed; QJsonDocument jdoc(rootObj); response.write(jdoc.toJson(), true); diff --git a/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.h b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.h index 32d8145560..ee947a50f3 100644 --- a/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.h +++ b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineController.h @@ -31,11 +31,16 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "QtWebApp/httpserver/httprequest.h" #include "QtWebApp/httpserver/httprequesthandler.h" #include "QtWebApp/httpserver/httpresponse.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Plugin/SIMPLPluginConstants.h" + +class PreflightPipelineMessageHandler; /** @brief This class responds to REST API endpoint @@ -46,6 +51,8 @@ class SIMPLib_EXPORT PreflightPipelineController : public HttpRequestHandler Q_OBJECT Q_DISABLE_COPY(PreflightPipelineController) public: + friend PreflightPipelineMessageHandler; + /** Constructor */ PreflightPipelineController(const QHostAddress& hostAddress, const int hostPort); diff --git a/Source/SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.cpp b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.cpp new file mode 100644 index 0000000000..ba91fb77d8 --- /dev/null +++ b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.cpp @@ -0,0 +1,102 @@ +/* ============================================================================ + * Copyright (c) 2017-2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "PreflightPipelineMessageHandler.h" + +#include "QtCore/QJsonArray" + +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" +#include "SIMPLib/Messages/PipelineWarningMessage.h" + +#include "REST/V1Controllers/PreflightPipelineController.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +PreflightPipelineMessageHandler::PreflightPipelineMessageHandler(QJsonArray* errors, QJsonArray* warnings) +: m_Errors(errors) +, m_Warnings(warnings) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PreflightPipelineMessageHandler::processMessage(const FilterErrorMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + obj.insert(SIMPL::JSON::FilterIndex, msg->getPipelineIndex()); + obj.insert(SIMPL::JSON::FilterHumanLabel, msg->getHumanLabel()); + m_Errors->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PreflightPipelineMessageHandler::processMessage(const FilterWarningMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + obj.insert(SIMPL::JSON::FilterIndex, msg->getPipelineIndex()); + obj.insert(SIMPL::JSON::FilterHumanLabel, msg->getHumanLabel()); + m_Warnings->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PreflightPipelineMessageHandler::processMessage(const PipelineErrorMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + m_Errors->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PreflightPipelineMessageHandler::processMessage(const PipelineWarningMessage* msg) const +{ + QJsonObject obj = writeToJson(msg->getCode(), msg->getMessageText()); + m_Warnings->push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QJsonObject PreflightPipelineMessageHandler::writeToJson(int code, const QString& text) const +{ + QJsonObject obj; + obj.insert(SIMPL::JSON::Code, code); + obj.insert(SIMPL::JSON::Message, text); + return obj; +} diff --git a/Source/SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.h b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.h new file mode 100644 index 0000000000..3030c1ef6c --- /dev/null +++ b/Source/SIMPLib/REST/V1Controllers/PreflightPipelineMessageHandler.h @@ -0,0 +1,87 @@ +/* ============================================================================ + * Copyright (c) 2017-2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" + +/** + * @brief This message handler is used by the PreflightPipeline class to store values from error and warning + * messages in json objects. These json objects are stored in an error json array and a warning json array. + */ +class SIMPLib_EXPORT PreflightPipelineMessageHandler : public AbstractMessageHandler +{ + public: + PreflightPipelineMessageHandler(QJsonArray* errors, QJsonArray* warnings); + + /** + * @brief Stores pipeline index, human label, message text, and error code + * of incoming FilterErrorMessages into a json object and stores the json + * object in the errors json array. + */ + void processMessage(const FilterErrorMessage* msg) const override; + + /** + * @brief Stores pipeline index, human label, message text, and warning code + * of incoming FilterWarningMessages into a json object and stores the json + * object in the warnings json array. + */ + void processMessage(const FilterWarningMessage* msg) const override; + + /** + * @brief Stores message text and warning code of incoming PipelineErrorMessages + * into a json object and stores the json object in the errors json array. + */ + void processMessage(const PipelineErrorMessage* msg) const override; + + /** + * @brief Stores message text and warning code of incoming PipelineWarningMessages + * into a json object and stores the json object in the warnings json array. + */ + void processMessage(const PipelineWarningMessage* msg) const override; + + private: + QJsonArray* m_Errors = nullptr; + QJsonArray* m_Warnings = nullptr; + + /** + * @brief writeToJson + * @param code + * @param text + * @param humanLabel + */ + QJsonObject writeToJson(int code, const QString &text) const; +}; + diff --git a/Source/SIMPLib/SIMPLibMacros.cmake b/Source/SIMPLib/SIMPLibMacros.cmake index 93ce2b374e..05828d7073 100755 --- a/Source/SIMPLib/SIMPLibMacros.cmake +++ b/Source/SIMPLib/SIMPLibMacros.cmake @@ -170,6 +170,8 @@ function(SIMPL_START_FILTER_GROUP) STRING(REPLACE "Filters" "" P_FILTER_GROUP ${P_FILTER_GROUP}) set_property(GLOBAL APPEND PROPERTY DREAM3DDoc_GROUPS ${P_FILTER_GROUP}) + + file(WRITE ${SIMPLProj_BINARY_DIR}/${P_FILTER_GROUP}PublicFilters.txt "# ${P_FILTER_GROUP} Public Filters\n") endfunction() #------------------------------------------------------------------------------- @@ -271,6 +273,9 @@ macro(ADD_SIMPL_FILTER FilterLib WidgetLib filterGroup filterName filterDocPath get_property(DREAM3DDocRoot GLOBAL PROPERTY DREAM3DDocRoot) set_property(GLOBAL APPEND PROPERTY DREAM3DDoc_${filterGroup} ${filterDocPath}) endif() + + file(APPEND ${SIMPLProj_BINARY_DIR}/${FilterLib}PublicFilters.txt "${filterName}.h\n") + endmacro() #------------------------------------------------------------------------------- diff --git a/Source/SIMPLib/StatsData/Testing/Cxx/StatsDataJsonRWTest.cpp b/Source/SIMPLib/StatsData/Testing/Cxx/StatsDataJsonRWTest.cpp index 5949e9fc66..4a979050c7 100644 --- a/Source/SIMPLib/StatsData/Testing/Cxx/StatsDataJsonRWTest.cpp +++ b/Source/SIMPLib/StatsData/Testing/Cxx/StatsDataJsonRWTest.cpp @@ -207,13 +207,13 @@ class StatsDataJsonRWTest // Write the Misorientation Weights { FloatArrayType::Pointer angles = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Angle); - angles->initializeWithValue(45.0f, 0); + angles->initializeWithValue(45.0f); std::vector vec; vec.push_back(3); FloatArrayType::Pointer axis = FloatArrayType::CreateArray(1, vec, SIMPL::StringConstants::Axis); - axis->initializeWithValue(1.0, 0); + axis->initializeWithValue(1.0); FloatArrayType::Pointer weight = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Weight); - weight->initializeWithValue(1000.0f, 0); + weight->initializeWithValue(1000.0f); arrays.clear(); arrays.push_back(angles); arrays.push_back(axis); @@ -224,15 +224,15 @@ class StatsDataJsonRWTest // Write the ODF { FloatArrayType::Pointer e1 = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Euler1); - e1->initializeWithValue(45.0f, 0); + e1->initializeWithValue(45.0f); FloatArrayType::Pointer e2 = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Euler2); - e2->initializeWithValue(30.0f, 0); + e2->initializeWithValue(30.0f); FloatArrayType::Pointer e3 = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Euler3); - e3->initializeWithValue(60.0f, 0); + e3->initializeWithValue(60.0f); FloatArrayType::Pointer sigma = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Sigma); - sigma->initializeWithValue(2.0, 0); + sigma->initializeWithValue(2.0); FloatArrayType::Pointer weight = FloatArrayType::CreateArray(1, SIMPL::StringConstants::Weight); - weight->initializeWithValue(100000.0f, 0); + weight->initializeWithValue(100000.0f); arrays.clear(); arrays.push_back(e1); arrays.push_back(e2); diff --git a/Source/SIMPLib/TestFilters/ArraySelectionExample.cpp b/Source/SIMPLib/TestFilters/ArraySelectionExample.cpp index ededb91206..d2f8483a44 100644 --- a/Source/SIMPLib/TestFilters/ArraySelectionExample.cpp +++ b/Source/SIMPLib/TestFilters/ArraySelectionExample.cpp @@ -49,7 +49,7 @@ ArraySelectionExample::~ArraySelectionExample() = default; // ----------------------------------------------------------------------------- void ArraySelectionExample::setupFilterParameters() { - QVector parameters; + FilterParameterVectorType parameters; DataContainerArrayProxy proxy; /* To select arrays */ // parameters.push_back(DataContainerArrayProxyFilterParameter::New("Array to Select", "DataContainerArrayProxy", "", FilterParameter::Parameter, SIMPL_BIND_SETTER(ArraySelectionExample, this, @@ -89,8 +89,8 @@ void ArraySelectionExample::initialize() void ArraySelectionExample::dataCheck() { // std::cout << " ArraySelectionExample Preflighting " << std::endl; - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -114,10 +114,10 @@ void ArraySelectionExample::preflight() // ----------------------------------------------------------------------------- void ArraySelectionExample::execute() { - int err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/TestFilters/DynamicTableExample.cpp b/Source/SIMPLib/TestFilters/DynamicTableExample.cpp index 8745d03b93..4eb4b191f1 100644 --- a/Source/SIMPLib/TestFilters/DynamicTableExample.cpp +++ b/Source/SIMPLib/TestFilters/DynamicTableExample.cpp @@ -52,7 +52,7 @@ DynamicTableExample::~DynamicTableExample() = default; // ----------------------------------------------------------------------------- void DynamicTableExample::setupFilterParameters() { - QVector parameters; + FilterParameterVectorType parameters; /* Place all your option initialization code here */ // Table 1 - Fixed rows and columns, no default data passed in diff --git a/Source/SIMPLib/TestFilters/ErrorWarningFilter.cpp b/Source/SIMPLib/TestFilters/ErrorWarningFilter.cpp index 273bf12011..45e3907fa9 100644 --- a/Source/SIMPLib/TestFilters/ErrorWarningFilter.cpp +++ b/Source/SIMPLib/TestFilters/ErrorWarningFilter.cpp @@ -58,8 +58,8 @@ ErrorWarningFilter::~ErrorWarningFilter() = default; // ----------------------------------------------------------------------------- void ErrorWarningFilter::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -68,7 +68,7 @@ void ErrorWarningFilter::initialize() // ----------------------------------------------------------------------------- void ErrorWarningFilter::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_BOOL_FP("Preflight Warning", PreflightWarning, FilterParameter::Parameter, ErrorWarningFilter)); parameters.push_back(SIMPL_NEW_BOOL_FP("Preflight Error", PreflightError, FilterParameter::Parameter, ErrorWarningFilter)); @@ -88,14 +88,12 @@ void ErrorWarningFilter::dataCheck() if(getPreflightWarning()) { QString ss = QObject::tr("Intentional preflight warning generated"); - setWarningCondition(-666000); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-666000, ss); } if(getPreflightError()) { QString ss = QObject::tr("Intentional preflight error generated"); - setErrorCondition(-666001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-666001, ss); } if(getPropertyError()) { @@ -124,7 +122,7 @@ void ErrorWarningFilter::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -137,14 +135,12 @@ void ErrorWarningFilter::execute() if(getExecuteWarning()) { QString ss = QObject::tr("Intentional execute warning generated"); - setWarningCondition(-666000); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-666000, ss); } if(getExecuteError()) { QString ss = QObject::tr("Intentional execute error generated"); - setErrorCondition(-666001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-666001, ss); } } diff --git a/Source/SIMPLib/TestFilters/FilterGroup00.cpp b/Source/SIMPLib/TestFilters/FilterGroup00.cpp index 1a2e39a1d7..a1d9b6e5e0 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup00.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup00.cpp @@ -52,8 +52,8 @@ TESTCLASSNAME::~TESTCLASSNAME() = default; // ----------------------------------------------------------------------------- void TESTCLASSNAME::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void TESTCLASSNAME::initialize() // ----------------------------------------------------------------------------- void TESTCLASSNAME::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void TESTCLASSNAME::setupFilterParameters() // ----------------------------------------------------------------------------- void TESTCLASSNAME::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -110,8 +110,7 @@ void TESTCLASSNAME::execute() if(getErrorCondition() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup01.cpp b/Source/SIMPLib/TestFilters/FilterGroup01.cpp index ebed9b58a4..e42f083ef2 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup01.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup01.cpp @@ -52,8 +52,8 @@ FilterGroup01::~FilterGroup01() = default; // ----------------------------------------------------------------------------- void FilterGroup01::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup01::initialize() // ----------------------------------------------------------------------------- void FilterGroup01::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup01::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup01::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup01::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup01::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup02.cpp b/Source/SIMPLib/TestFilters/FilterGroup02.cpp index 13f54fbb4a..de668a0bc9 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup02.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup02.cpp @@ -52,8 +52,8 @@ FilterGroup02::~FilterGroup02() = default; // ----------------------------------------------------------------------------- void FilterGroup02::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup02::initialize() // ----------------------------------------------------------------------------- void FilterGroup02::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup02::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup02::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup02::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup02::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup03.cpp b/Source/SIMPLib/TestFilters/FilterGroup03.cpp index 3ec05702d2..b683c0a174 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup03.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup03.cpp @@ -52,8 +52,8 @@ FilterGroup03::~FilterGroup03() = default; // ----------------------------------------------------------------------------- void FilterGroup03::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup03::initialize() // ----------------------------------------------------------------------------- void FilterGroup03::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup03::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup03::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup03::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup03::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup04.cpp b/Source/SIMPLib/TestFilters/FilterGroup04.cpp index 027f0e7d1b..f00e7e17bf 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup04.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup04.cpp @@ -52,8 +52,8 @@ FilterGroup04::~FilterGroup04() = default; // ----------------------------------------------------------------------------- void FilterGroup04::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup04::initialize() // ----------------------------------------------------------------------------- void FilterGroup04::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup04::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup04::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup04::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup04::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup05.cpp b/Source/SIMPLib/TestFilters/FilterGroup05.cpp index 043ab539f3..a152c12dd7 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup05.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup05.cpp @@ -52,8 +52,8 @@ FilterGroup05::~FilterGroup05() = default; // ----------------------------------------------------------------------------- void FilterGroup05::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup05::initialize() // ----------------------------------------------------------------------------- void FilterGroup05::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup05::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup05::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup05::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup05::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup06.cpp b/Source/SIMPLib/TestFilters/FilterGroup06.cpp index a95d31a322..d687616ffb 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup06.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup06.cpp @@ -52,8 +52,8 @@ FilterGroup06::~FilterGroup06() = default; // ----------------------------------------------------------------------------- void FilterGroup06::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup06::initialize() // ----------------------------------------------------------------------------- void FilterGroup06::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup06::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup06::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup06::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup06::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup07.cpp b/Source/SIMPLib/TestFilters/FilterGroup07.cpp index 158b0a6e4b..e2896d23f1 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup07.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup07.cpp @@ -52,8 +52,8 @@ FilterGroup07::~FilterGroup07() = default; // ----------------------------------------------------------------------------- void FilterGroup07::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup07::initialize() // ----------------------------------------------------------------------------- void FilterGroup07::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup07::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup07::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup07::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup07::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup08.cpp b/Source/SIMPLib/TestFilters/FilterGroup08.cpp index 64425fde88..6eb0ef2766 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup08.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup08.cpp @@ -52,8 +52,8 @@ FilterGroup08::~FilterGroup08() = default; // ----------------------------------------------------------------------------- void FilterGroup08::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup08::initialize() // ----------------------------------------------------------------------------- void FilterGroup08::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup08::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup08::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup08::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup08::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup09.cpp b/Source/SIMPLib/TestFilters/FilterGroup09.cpp index 200664b883..dd82f0f9ef 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup09.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup09.cpp @@ -52,8 +52,8 @@ FilterGroup09::~FilterGroup09() = default; // ----------------------------------------------------------------------------- void FilterGroup09::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup09::initialize() // ----------------------------------------------------------------------------- void FilterGroup09::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup09::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup09::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup09::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup09::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup10.cpp b/Source/SIMPLib/TestFilters/FilterGroup10.cpp index 4bbb7f1c66..c89e755291 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup10.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup10.cpp @@ -52,8 +52,8 @@ FilterGroup10::~FilterGroup10() = default; // ----------------------------------------------------------------------------- void FilterGroup10::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup10::initialize() // ----------------------------------------------------------------------------- void FilterGroup10::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup10::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup10::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup10::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup10::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup12.cpp b/Source/SIMPLib/TestFilters/FilterGroup12.cpp index 77a05bc1d5..cfc51da8bf 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup12.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup12.cpp @@ -52,8 +52,8 @@ FilterGroup12::~FilterGroup12() = default; // ----------------------------------------------------------------------------- void FilterGroup12::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup12::initialize() // ----------------------------------------------------------------------------- void FilterGroup12::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup12::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup12::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup12::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup12::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/FilterGroup13.cpp b/Source/SIMPLib/TestFilters/FilterGroup13.cpp index 2d60e1330b..950d6be12d 100644 --- a/Source/SIMPLib/TestFilters/FilterGroup13.cpp +++ b/Source/SIMPLib/TestFilters/FilterGroup13.cpp @@ -52,8 +52,8 @@ FilterGroup13::~FilterGroup13() = default; // ----------------------------------------------------------------------------- void FilterGroup13::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -62,7 +62,7 @@ void FilterGroup13::initialize() // ----------------------------------------------------------------------------- void FilterGroup13::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -72,8 +72,8 @@ void FilterGroup13::setupFilterParameters() // ----------------------------------------------------------------------------- void FilterGroup13::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -97,7 +97,7 @@ void FilterGroup13::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -107,11 +107,10 @@ void FilterGroup13::execute() return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { QString ss = QObject::tr("Some error message"); - setErrorCondition(-99999999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-99999999, ss); return; } diff --git a/Source/SIMPLib/TestFilters/GenericExample.cpp b/Source/SIMPLib/TestFilters/GenericExample.cpp index 54a2f0d6e5..d9e59eedc9 100644 --- a/Source/SIMPLib/TestFilters/GenericExample.cpp +++ b/Source/SIMPLib/TestFilters/GenericExample.cpp @@ -92,13 +92,13 @@ GenericExample::GenericExample() , m_AlgorithmSelection(0) , m_DistanceMetric(1) { - m_Dimensions.x = 0; - m_Dimensions.y = 0; - m_Dimensions.z = 0; + m_Dimensions[0] = 0; + m_Dimensions[1] = 0; + m_Dimensions[2] = 0; - m_Origin.x = 0.0; - m_Origin.y = 0.0; - m_Origin.z = 0.0; + m_Origin[0] = 0.0; + m_Origin[1] = 0.0; + m_Origin[2] = 0.0; FileListInfo_t flInfo; flInfo.PaddingDigits = 2; @@ -123,7 +123,7 @@ GenericExample::~GenericExample() = default; // ----------------------------------------------------------------------------- void GenericExample::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; /* Place all your option initialization code here */ /* For String input use this code */ parameters.push_back(SIMPL_NEW_STRING_FP("STL Output Prefix", StlFilePrefix, FilterParameter::Parameter, GenericExample)); @@ -375,8 +375,8 @@ void GenericExample::initialize() void GenericExample::dataCheck() { DataArrayPath tempPath; - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); FileSystemPathHelper::CheckOutputFile(this, "Output File Name", getOutputFile(), true); @@ -407,12 +407,12 @@ void computeEulerAngle(float pq, float* eulerAngle) // ----------------------------------------------------------------------------- void GenericExample::execute() { - int err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); // Run the data check to get references to all of our data arrays initialized to the values stored in memory dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/TestFilters/GenericExample.h b/Source/SIMPLib/TestFilters/GenericExample.h index 7ca7655a71..f46edce029 100644 --- a/Source/SIMPLib/TestFilters/GenericExample.h +++ b/Source/SIMPLib/TestFilters/GenericExample.h @@ -80,7 +80,7 @@ class SIMPLib_EXPORT GenericExample : public AbstractFilter PYB11_PROPERTY(FileListInfo_t InputFileListInfo READ getInputFileListInfo WRITE setInputFileListInfo) PYB11_PROPERTY(QString SelectedXCoordArrayName READ getSelectedXCoordArrayName WRITE setSelectedXCoordArrayName) PYB11_PROPERTY(QStringList DataArrayList READ getDataArrayList WRITE setDataArrayList) - PYB11_PROPERTY(QString CreatedDataContainer READ getCreatedDataContainer WRITE setCreatedDataContainer) + PYB11_PROPERTY(DataArrayPath CreatedDataContainer READ getCreatedDataContainer WRITE setCreatedDataContainer) PYB11_PROPERTY(DataContainerArrayProxy DcaProxy READ getDcaProxy WRITE setDcaProxy) PYB11_PROPERTY(QString InputPath READ getInputPath WRITE setInputPath) PYB11_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) @@ -88,13 +88,13 @@ class SIMPLib_EXPORT GenericExample : public AbstractFilter PYB11_PROPERTY(QVector SelectedMultiArrayPaths READ getSelectedMultiArrayPaths WRITE setSelectedMultiArrayPaths) PYB11_PROPERTY(bool WriteAlignmentShifts READ getWriteAlignmentShifts WRITE setWriteAlignmentShifts) PYB11_PROPERTY(int ConversionType READ getConversionType WRITE setConversionType) - PYB11_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) PYB11_PROPERTY(AxisAngleInput_t CrystalSymmetryRotations READ getCrystalSymmetryRotations WRITE setCrystalSymmetryRotations) PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) PYB11_PROPERTY(DataArrayPath AttributeMatrixPath READ getAttributeMatrixPath WRITE setAttributeMatrixPath) PYB11_PROPERTY(DataArrayPath CreatedAttributeMatrix READ getCreatedAttributeMatrix WRITE setCreatedAttributeMatrix) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(int SizeDistributionFitType READ getSizeDistributionFitType WRITE setSizeDistributionFitType) PYB11_PROPERTY(ComparisonInputs SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) PYB11_PROPERTY(QString CalcExpression READ getCalcExpression WRITE setCalcExpression) @@ -162,8 +162,8 @@ class SIMPLib_EXPORT GenericExample : public AbstractFilter SIMPL_FILTER_PARAMETER(QStringList, DataArrayList) Q_PROPERTY(QStringList DataArrayList READ getDataArrayList WRITE setDataArrayList) - SIMPL_FILTER_PARAMETER(QString, CreatedDataContainer) - Q_PROPERTY(QString CreatedDataContainer READ getCreatedDataContainer WRITE setCreatedDataContainer) + SIMPL_FILTER_PARAMETER(DataArrayPath, CreatedDataContainer) + Q_PROPERTY(DataArrayPath CreatedDataContainer READ getCreatedDataContainer WRITE setCreatedDataContainer) SIMPL_FILTER_PARAMETER(DataContainerArrayProxy, DcaProxy) Q_PROPERTY(DataContainerArrayProxy DcaProxy READ getDcaProxy WRITE setDcaProxy) @@ -186,11 +186,11 @@ class SIMPLib_EXPORT GenericExample : public AbstractFilter SIMPL_FILTER_PARAMETER(int, ConversionType) Q_PROPERTY(int ConversionType READ getConversionType WRITE setConversionType) - SIMPL_FILTER_PARAMETER(IntVec3_t, Dimensions) - Q_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) + SIMPL_FILTER_PARAMETER(IntVec3Type, Dimensions) + Q_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + SIMPL_FILTER_PARAMETER(FloatVec3Type, Origin) + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) SIMPL_FILTER_PARAMETER(AxisAngleInput_t, CrystalSymmetryRotations) Q_PROPERTY(AxisAngleInput_t CrystalSymmetryRotations READ getCrystalSymmetryRotations WRITE setCrystalSymmetryRotations) @@ -204,8 +204,8 @@ class SIMPLib_EXPORT GenericExample : public AbstractFilter SIMPL_FILTER_PARAMETER(DataArrayPath, CreatedAttributeMatrix) Q_PROPERTY(DataArrayPath CreatedAttributeMatrix READ getCreatedAttributeMatrix WRITE setCreatedAttributeMatrix) - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + SIMPL_FILTER_PARAMETER(DataArrayPath, DataContainerName) + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) SIMPL_FILTER_PARAMETER(int, SizeDistributionFitType) Q_PROPERTY(int SizeDistributionFitType READ getSizeDistributionFitType WRITE setSizeDistributionFitType) diff --git a/Source/SIMPLib/TestFilters/MakeDataContainer.cpp b/Source/SIMPLib/TestFilters/MakeDataContainer.cpp index b99af699ef..152d34ad70 100644 --- a/Source/SIMPLib/TestFilters/MakeDataContainer.cpp +++ b/Source/SIMPLib/TestFilters/MakeDataContainer.cpp @@ -43,6 +43,11 @@ #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -69,7 +74,7 @@ MakeDataContainer::~MakeDataContainer() = default; // ----------------------------------------------------------------------------- void MakeDataContainer::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; parameters.push_back(SIMPL_NEW_STRING_FP("FeatureIds", FeatureIdsArrayName, FilterParameter::CreatedArray, MakeDataContainer)); parameters.push_back(SIMPL_NEW_STRING_FP("Cell Euler Angles", CellEulerAnglesArrayName, FilterParameter::CreatedArray, MakeDataContainer)); @@ -99,24 +104,24 @@ void MakeDataContainer::initialize() // ----------------------------------------------------------------------------- void MakeDataContainer::dataCheck() { - DataArrayPath tempPath; - setErrorCondition(0); - setWarningCondition(0); - DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + clearErrorCode(); + clearWarningCode(); + + DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName(), DataContainerID); + if(getErrorCode() < 0) { return; } QVector tDims(3, 64); AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix(this, getCellAttributeMatrixName(), tDims, AttributeMatrix::Type::Cell); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } // tDims.resize(1); // tDims[0] = 0; // AttributeMatrix::Pointer cellEnsembleAttrMat = m->createNonPrereqAttributeMatrix(this, getCellEnsembleAttributeMatrixName(), tDims, AttributeMatrix::Type::CellEnsemble); - // if(getErrorCondition() < 0) + // if(getErrorCode() < 0) // { // return; // } @@ -130,7 +135,7 @@ void MakeDataContainer::dataCheck() } // ImageGeom::Pointer image = ImageGeom::CreateGeometry("TestImageGeom"); - // image->setResolution(0.1f, 0.2f, 0.3f); + // image->setSpacing(0.1f, 0.2f, 0.3f); // image->setOrigin(100.3f, 987.234f, 0.0f); // image->setDimensions(64, 64, 64); // m->setGeometry(image); @@ -168,12 +173,12 @@ void MakeDataContainer::preflight() // ----------------------------------------------------------------------------- void MakeDataContainer::execute() { - int err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); // Run the data check to get references to all of our data arrays initialized to the values stored in memory dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } diff --git a/Source/SIMPLib/TestFilters/TestFilters.cpp b/Source/SIMPLib/TestFilters/TestFilters.cpp index e716cc39c3..d67127e9e3 100644 --- a/Source/SIMPLib/TestFilters/TestFilters.cpp +++ b/Source/SIMPLib/TestFilters/TestFilters.cpp @@ -28,7 +28,7 @@ Filt0::~Filt0() = default; // ----------------------------------------------------------------------------- void Filt0::setupFilterParameters() { - QVector parameters; + FilterParameterVectorType parameters; /* Place all your option initialization code here */ /* For an Integer use this code*/ @@ -68,8 +68,8 @@ void Filt0::initialize() // ----------------------------------------------------------------------------- void Filt0::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -86,19 +86,17 @@ void Filt0::preflight() // ----------------------------------------------------------------------------- void Filt0::execute() { - int err = 0; - setErrorCondition(err); - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); if(nullptr == m) { - setErrorCondition(-1); QString ss = QObject::tr(" DataContainer was nullptr"); - notifyErrorMessage(getHumanLabel(), QObject::tr("VolumeDataContainer was nullptr. Returning from Execute Method for filter %1").arg(getHumanLabel()), -1); + setErrorCondition(-1, QObject::tr("VolumeDataContainer was nullptr. Returning from Execute Method for filter %1").arg(getHumanLabel())); return; } - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); /* Place all your code to execute your filter here. */ } @@ -124,7 +122,7 @@ Filt1::~Filt1() = default; // ----------------------------------------------------------------------------- void Filt1::setupFilterParameters() { - QVector parameters; + FilterParameterVectorType parameters; /* Place all your option initialization code here */ /* For an Integer use this code*/ @@ -164,8 +162,8 @@ void Filt1::initialize() // ----------------------------------------------------------------------------- void Filt1::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -182,18 +180,17 @@ void Filt1::preflight() // ----------------------------------------------------------------------------- void Filt1::execute() { - int err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); if(nullptr == m.get()) { - setErrorCondition(-1); QString ss = QObject::tr(" DataContainer was nullptr"); - notifyErrorMessage(getHumanLabel(), QObject::tr("VolumeDataContainer was nullptr. Returning from Execute Method for filter %1").arg(getHumanLabel()), -1); + setErrorCondition(-1, QObject::tr("VolumeDataContainer was nullptr. Returning from Execute Method for filter %1").arg(getHumanLabel())); return; } - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); /* Place all your code to execute your filter here. */ } diff --git a/Source/SIMPLib/TestFilters/ThresholdExample.cpp b/Source/SIMPLib/TestFilters/ThresholdExample.cpp index 01f4e6c423..eba289ac98 100644 --- a/Source/SIMPLib/TestFilters/ThresholdExample.cpp +++ b/Source/SIMPLib/TestFilters/ThresholdExample.cpp @@ -56,7 +56,7 @@ ThresholdExample::~ThresholdExample() = default; // ----------------------------------------------------------------------------- void ThresholdExample::setupFilterParameters() { - QVector parameters; + FilterParameterVectorType parameters; /* To Compare Arrays like a threshold filter */ { @@ -141,11 +141,11 @@ void ThresholdExample::initialize() // ----------------------------------------------------------------------------- void ThresholdExample::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m) + if(getErrorCode() < 0 || nullptr == m) { return; } @@ -156,8 +156,7 @@ void ThresholdExample::dataCheck() if (m_OutputFile.isEmpty() == true) { ss << "The output file must be set before executing this filter."; - setErrorCondition(-1); - notifyErrorMessage(getNameOfClass(), ss.str(), -1); + setErrorCondition(-1, ss.str()); } */ } diff --git a/Source/SIMPLib/Testing/Unused/NewDataContainerStructureTest.cpp b/Source/SIMPLib/Testing/Unused/NewDataContainerStructureTest.cpp index a73464fa56..474781964e 100644 --- a/Source/SIMPLib/Testing/Unused/NewDataContainerStructureTest.cpp +++ b/Source/SIMPLib/Testing/Unused/NewDataContainerStructureTest.cpp @@ -96,7 +96,7 @@ void BuildNewDream3dFile() tDims[1] = 128; tDims[2] = 128; AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::New(tDims, "CellData", SIMPL::AttributeMatrixType::Cell); - vdc->addAttributeMatrix("CellData", cellAttrMat); + vdc->addAttributeMatrix(cellAttrMat); QVector dims(1, 1); cellAttrMat->createAndAddAttributeArray, int64_t>("Ids", 1, dims); @@ -114,11 +114,11 @@ void BuildNewDream3dFile() m_FeatureIds[i] = i; } AttributeMatrix::Pointer cellFeatureAttrMat = AttributeMatrix::New(tDims, "CellFeatureData", SIMPL::AttributeMatrixType::CellFeature); - vdc->addAttributeMatrix("CellFeatureData", cellFeatureAttrMat); + vdc->addAttributeMatrix(cellFeatureAttrMat); tDims.resize(1); tDims[0] = 2; AttributeMatrix::Pointer cellEnsembleAttrMat = AttributeMatrix::New(tDims, "CellEnsembleData", SIMPL::AttributeMatrixType::CellEnsemble); - vdc->addAttributeMatrix("CellEnsembleData", cellEnsembleAttrMat); + vdc->addAttributeMatrix(cellEnsembleAttrMat); cellEnsembleAttrMat->createAndAddAttributeArray, unsigned int>("PhaseTypes", SIMPL::PhaseType::PrimaryPhase, dims); DataArray::WeakPointer m_PhaseTypesPtr; @@ -159,7 +159,7 @@ void BuildNewDream3dFile() StatsDataArray::Pointer p = StatsDataArray::New(); m_StatsDataArray = p.get(); m_StatsDataArray->fillArrayWithNewStatsData(cellEnsembleAttrMat->getNumberOfTuples(), m_PhaseTypes); - cellEnsembleAttrMat->addAttributeArray(SIMPL::EnsembleData::Statistics, p); + cellEnsembleAttrMat->insertOrAssign(p); } StatsDataArray& statsDataArray = *m_StatsDataArray; diff --git a/Source/SIMPLib/Testing/Unused/VtkGrainIdIOTest.cpp b/Source/SIMPLib/Testing/Unused/VtkGrainIdIOTest.cpp index 4536c12c28..0d120648b4 100644 --- a/Source/SIMPLib/Testing/Unused/VtkGrainIdIOTest.cpp +++ b/Source/SIMPLib/Testing/Unused/VtkGrainIdIOTest.cpp @@ -71,14 +71,13 @@ class GenerateGrainIds : public AbstractFilter } virtual void execute() { - setErrorCondition(0); + clearErrorCode(); VoxelDataContainer* m = getVoxelDataContainer(); if(nullptr == m) { - setErrorCondition(-1); QStringstream ss; ss << " DataContainer was nullptr"; - setErrorMessage(ss.str()); + setErrorCondition(-1, ss.str()); return; } int size = UnitTest::VtkGrainIdIOTest::XSize * UnitTest::VtkGrainIdIOTest::YSize * UnitTest::VtkGrainIdIOTest::ZSize; @@ -115,7 +114,7 @@ class GenerateGrainIds : public AbstractFilter void dataCheck() { - setErrorCondition(0); + clearErrorCode(); QStringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); m_GrainIdsPtr = attrMat->createNonPrereqArray, AbstractFilter, int32_t>(this, m_CellAttributeMatrixName, m_GrainIdsArrayName, 0, voxels, diff --git a/Source/SIMPLib/Utilities/ColorTable.cpp b/Source/SIMPLib/Utilities/ColorTable.cpp index afa37d34d5..e458c075c6 100644 --- a/Source/SIMPLib/Utilities/ColorTable.cpp +++ b/Source/SIMPLib/Utilities/ColorTable.cpp @@ -1,40 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the followig contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ColorTable.h" +#include #include #include @@ -54,7 +55,7 @@ SIMPLColorTable::~SIMPLColorTable() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SIMPLColorTable::GetColorTable(int numColors, QVector& colors) +void SIMPLColorTable::GetColorTable(int numColors, QVector& colorsOut) { static const int numColorNodes = 8; float color[numColorNodes][3] = { @@ -68,44 +69,55 @@ void SIMPLColorTable::GetColorTable(int numColors, QVector& colors) {255.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f} // red }; - float val = 0.0f, r = 0.0f, g = 0.0f, b = 0.0f; - float step = 1.0 / float(numColors); - float nodeStep = 1.0f / float(numColorNodes - 1); - for(int i = 0; i < (numColors); i++) + static const int maxNodeIndex = numColorNodes - 1; + const float stepSize = 1.0f / numColors; + const float nodeStepSize = 1.0f / (maxNodeIndex); + for(int i = 0; i < numColors; i++) { - val = float(i) * step; - int currColorBin = int(val / nodeStep); - float currFraction = (val / nodeStep) - currColorBin; - if(currColorBin > numColorNodes - 1) + float pos = i * stepSize; // [0, 1] range + int currColorBin = static_cast(pos / nodeStepSize); + float currFraction = (pos / nodeStepSize) - currColorBin; + + float r; + float g; + float b; + currColorBin = std::min(currColorBin, maxNodeIndex); + // currColorBin + 1 causes this to step out of color[] bounds when currColorBin == (numColorNodes - 1) + if(i < numColors - 1) + { + r = color[currColorBin][0] * (1.0f - currFraction) + color[currColorBin + 1][0] * currFraction; + g = color[currColorBin][1] * (1.0f - currFraction) + color[currColorBin + 1][1] * currFraction; + b = color[currColorBin][2] * (1.0f - currFraction) + color[currColorBin + 1][2] * currFraction; + } + else { - currColorBin = numColorNodes - 1; + r = color[currColorBin][0]; + g = color[currColorBin][1]; + b = color[currColorBin][2]; } - r = color[currColorBin][0] * (1.0 - currFraction) + color[currColorBin + 1][0] * currFraction; - g = color[currColorBin][1] * (1.0 - currFraction) + color[currColorBin + 1][1] * currFraction; - b = color[currColorBin][2] * (1.0 - currFraction) + color[currColorBin + 1][2] * currFraction; - colors[3 * i] = r; - colors[3 * i + 1] = g; - colors[3 * i + 2] = b; + colorsOut[3 * i] = r; + colorsOut[3 * i + 1] = g; + colorsOut[3 * i + 2] = b; } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector SIMPLColorTable::GetColorTable(int numColors, QJsonArray colorControlPoints) +std::vector SIMPLColorTable::GetColorTable(size_t numColors, QJsonArray colorControlPoints) { - int numControlColors = colorControlPoints.count() / 4; - int numComponents = 4; - std::vector > controlPoints(numControlColors, std::vector(numComponents)); + const size_t controlColorsCount = colorControlPoints.count() / 4; + const size_t numComponents = 4; + std::vector> controlPoints(controlColorsCount, std::vector(numComponents)); // Migrate colorControlPoints values from QJsonArray to 2D array. Store A-values in binPoints vector. - QVector binPoints; - for (int i=0; i binPoints; + for(size_t i = 0; i < controlColorsCount; i++) { - for (int j=0; j(colorControlPoints[numComponents*i + j].toDouble()); - if (j == 0) + controlPoints[i][j] = static_cast(colorControlPoints[numComponents * i + j].toDouble()); + if(j == 0) { binPoints.push_back(controlPoints[i][j]); } @@ -113,35 +125,33 @@ std::vector SIMPLColorTable::GetColorTable(int numColors, QJsonAr } // Normalize binPoints values - float min = binPoints[0]; - float max = binPoints[binPoints.size() - 1]; - for (int i=0; i generatedColors(numColors * 3); - int currentBinIndex = 0; - float currFraction = 0.0f; - float allColorVal = 0.0f; - unsigned char r = 0, g = 0, b = 0; - float colorStep = 1.0 / float(numColors); - for(int i = 0; i < numColors; i++) + size_t currentBinIndex = 0; + const float colorStepSize = 1.0f / numColors; + for(size_t i = 0; i < numColors; i++) { // Calculate what point we are at in the entire color range - allColorVal = float(i) * colorStep; + const float allColorVal = static_cast(i) * colorStepSize; // If we have crossed into the next color bin, increment the currentBinIndex variable. - if (currentBinIndex+1 < binPoints.size() && allColorVal > binPoints[currentBinIndex+1]) + if(currentBinIndex + 1 < binPoints.size() && allColorVal > binPoints[currentBinIndex + 1]) { // We have crossed into the next bin currentBinIndex++; } // Find the fractional distance traveled between the beginning and end of the current color bin - if (currentBinIndex + 1 < binPoints.size()) + float currFraction = 0.0f; + if(currentBinIndex + 1 < binPoints.size()) { - currFraction = (allColorVal - binPoints[currentBinIndex]) / (binPoints[currentBinIndex+1] - binPoints[currentBinIndex]); + currFraction = (allColorVal - binPoints[currentBinIndex]) / (binPoints[currentBinIndex + 1] - binPoints[currentBinIndex]); } else { @@ -150,15 +160,24 @@ std::vector SIMPLColorTable::GetColorTable(int numColors, QJsonAr // If the current color bin index is larger than the total number of control colors, automatically set the currentBinIndex // to the last control color. - if(currentBinIndex > numControlColors - 1) - { - currentBinIndex = numControlColors - 1; - } + currentBinIndex = std::min(currentBinIndex, controlColorsCount - 1); // Calculate the RGB values - r = (controlPoints[currentBinIndex][1] * (1.0 - currFraction) + controlPoints[currentBinIndex + 1][1] * currFraction) * 255; - g = (controlPoints[currentBinIndex][2] * (1.0 - currFraction) + controlPoints[currentBinIndex + 1][2] * currFraction) * 255; - b = (controlPoints[currentBinIndex][3] * (1.0 - currFraction) + controlPoints[currentBinIndex + 1][3] * currFraction) * 255; + unsigned char r = 0; + unsigned char g = 0; + unsigned char b = 0; + if(currentBinIndex < controlColorsCount - 2) + { + r = (controlPoints[currentBinIndex][1] * (1.0 - currFraction) + controlPoints[currentBinIndex + 1][1] * currFraction) * 255; + g = (controlPoints[currentBinIndex][2] * (1.0 - currFraction) + controlPoints[currentBinIndex + 1][2] * currFraction) * 255; + b = (controlPoints[currentBinIndex][3] * (1.0 - currFraction) + controlPoints[currentBinIndex + 1][3] * currFraction) * 255; + } + else + { + r = controlPoints[currentBinIndex][1] * 255; + g = controlPoints[currentBinIndex][2] * 255; + b = controlPoints[currentBinIndex][3] * 255; + } // Store the RGB values in the RGB generatedColors vector generatedColors[3 * i] = r; @@ -168,7 +187,3 @@ std::vector SIMPLColorTable::GetColorTable(int numColors, QJsonAr return generatedColors; } - - - - diff --git a/Source/SIMPLib/Utilities/ColorTable.h b/Source/SIMPLib/Utilities/ColorTable.h index 0429cc1e64..61f08ab8bd 100755 --- a/Source/SIMPLib/Utilities/ColorTable.h +++ b/Source/SIMPLib/Utilities/ColorTable.h @@ -127,7 +127,7 @@ class SIMPLib_EXPORT SIMPLColorTable */ static void GetColorTable(int numColors, QVector& colors); - static std::vector GetColorTable(int numColors, QJsonArray colorNodeArray); + static std::vector GetColorTable(size_t numColors, QJsonArray colorNodeArray); private: SIMPLColorTable(const SIMPLColorTable&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/Utilities/FileSystemPathHelper.cpp b/Source/SIMPLib/Utilities/FileSystemPathHelper.cpp index ffa095aa83..e12e9fdc9b 100644 --- a/Source/SIMPLib/Utilities/FileSystemPathHelper.cpp +++ b/Source/SIMPLib/Utilities/FileSystemPathHelper.cpp @@ -53,33 +53,29 @@ void FileSystemPathHelper::CheckOutputFile(AbstractFilter* filter, { if(filePath.isEmpty()) { - filter->setErrorCondition(-900); QString ss = QObject::tr("The output file for input parameter '%1' is empty. Please set a path to an output file.").arg(parameterName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-900, ss); } QFileInfo fi(filePath); if(fi.isDir() && fi.suffix().isEmpty()) { - filter->setErrorCondition(-901); QString ss = QObject::tr("The output file for input parameter '%1' is a directory. Please set a path to an output file.").arg(parameterName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-901, ss); } QDir parentPath = fi.path(); if(!parentPath.exists()) { - filter->setWarningCondition(902); QString ss = QObject::tr("The directory path for input parameter '%1' does not exist. DREAM.3D will attempt to create this path during execution of the filter").arg(parameterName); - filter->notifyWarningMessage(filter->getHumanLabel(), ss, filter->getWarningCondition()); + filter->setWarningCondition(902, ss); } if(requireExtension) { if(fi.suffix().isEmpty()) { - filter->setErrorCondition(-903); QString ss = QObject::tr("The file path for input parameter '%1' does not have a file extension. Please use a file extension to denote the type of file being written.").arg(parameterName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getWarningCondition()); + filter->setErrorCondition(-903, ss); } } @@ -94,9 +90,8 @@ void FileSystemPathHelper::CheckOutputFile(AbstractFilter* filter, QFileInfo dirInfo(fi.path()); if(!dirInfo.isWritable() && parentPath.exists()) { - filter->setErrorCondition(-10002); QString ss = QObject::tr("The user does not have the proper permissions to write to the output file"); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10002, ss); } #ifdef _WIN32 diff --git a/Source/SIMPLib/Utilities/SIMPLH5DataReader.cpp b/Source/SIMPLib/Utilities/SIMPLH5DataReader.cpp index 5d1938f633..2cb78fb29e 100644 --- a/Source/SIMPLib/Utilities/SIMPLH5DataReader.cpp +++ b/Source/SIMPLib/Utilities/SIMPLH5DataReader.cpp @@ -332,7 +332,7 @@ bool SIMPLH5DataReader::readDataContainerBundles(hid_t fileId, const DataContain qDebug() << "Data Container '" << dcName << "' was nullptr" << " " << __FILE__ << "(" << __LINE__ << ")"; } - bundle->addDataContainer(dc); + bundle->addOrReplaceDataContainer(dc); } QString metaArrays; @@ -357,9 +357,7 @@ bool SIMPLH5DataReader::readDataContainerBundles(hid_t fileId, const DataContain // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SIMPLH5DataReader::notifyErrorMessage(const QString& humanLabel, const QString& str, int code) +void SIMPLH5DataReader::setErrorCondition(int code, const QString& str) { - Q_UNUSED(humanLabel) - emit errorGenerated(Title, str, code); } diff --git a/Source/SIMPLib/Utilities/SIMPLH5DataReader.h b/Source/SIMPLib/Utilities/SIMPLH5DataReader.h index 79ebce925d..e5ce3ef46b 100644 --- a/Source/SIMPLib/Utilities/SIMPLH5DataReader.h +++ b/Source/SIMPLib/Utilities/SIMPLH5DataReader.h @@ -102,12 +102,11 @@ class SIMPLib_EXPORT SIMPLH5DataReader : public Observable bool readPipelineJson(QString &json); /** - * @brief notifyErrorMessage - * @param humanLabel - * @param str + * @brief setErrorCondition * @param code + * @param str */ - void notifyErrorMessage(const QString& humanLabel, const QString& str, int code) override; + void setErrorCondition(int code, const QString& str) override; signals: void errorGenerated(const QString &title, const QString &msg, const int &code); diff --git a/Source/SIMPLib/Utilities/TestObserver.cpp b/Source/SIMPLib/Utilities/TestObserver.cpp index 0a1a94683f..0597bf6490 100644 --- a/Source/SIMPLib/Utilities/TestObserver.cpp +++ b/Source/SIMPLib/Utilities/TestObserver.cpp @@ -46,27 +46,7 @@ TestObserver::~TestObserver() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TestObserver::processPipelineMessage(const PipelineMessage& pm) +void TestObserver::processPipelineMessage(const AbstractMessage::Pointer& pm) { - PipelineMessage msg = pm; - if(msg.getType() == PipelineMessage::MessageType::Error) - { - std::cout << msg.getFilterHumanLabel().toStdString() << ": " << msg.generateErrorString().toStdString() << std::endl; - } - else if(msg.getType() == PipelineMessage::MessageType::Warning) - { - std::cout << msg.getFilterHumanLabel().toStdString() << ": " << msg.generateWarningString().toStdString() << std::endl; - } - else if(msg.getType() == PipelineMessage::MessageType::StatusMessage) - { - // std::cout << msg.getFilterHumanLabel().toStdString() << ": " << msg.generateStatusString().toStdString() << std::endl; - } - else if(msg.getType() == PipelineMessage::MessageType::ProgressValue) - { - // std::cout << msg.getFilterHumanLabel().toStdString() << ": " << msg.getProgressValue() << "%" << std::endl; - } - else if(msg.getType() == PipelineMessage::MessageType::StatusMessageAndProgressValue) - { - // std::cout << msg.getFilterHumanLabel().toStdString() << ": " << msg.getProgressValue() << "% " << msg.generateStatusString().toStdString() << std::endl; - } + std::cout << pm->generateMessageString().toStdString() << std::endl; } diff --git a/Source/SIMPLib/Utilities/TestObserver.h b/Source/SIMPLib/Utilities/TestObserver.h index d927aa3035..abf6fe8102 100755 --- a/Source/SIMPLib/Utilities/TestObserver.h +++ b/Source/SIMPLib/Utilities/TestObserver.h @@ -38,7 +38,7 @@ #include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Common/IObserver.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" class SIMPLib_EXPORT TestObserver : public QObject, public IObserver { @@ -50,13 +50,13 @@ class SIMPLib_EXPORT TestObserver : public QObject, public IObserver ~TestObserver() override; public slots: - void processPipelineMessage(const PipelineMessage& pm) override; + void processPipelineMessage(const AbstractMessage::Pointer& pm) override; - public: - TestObserver(const TestObserver&) = delete; // Copy Constructor Not Implemented - TestObserver(TestObserver&&) = delete; // Move Constructor Not Implemented - TestObserver& operator=(const TestObserver&) = delete; // Copy Assignment Not Implemented - TestObserver& operator=(TestObserver&&) = delete; // Move Assignment Not Implemented + public: + TestObserver(const TestObserver&) = delete; // Copy Constructor Not Implemented + TestObserver(TestObserver&&) = delete; // Move Constructor Not Implemented + TestObserver& operator=(const TestObserver&) = delete; // Copy Assignment Not Implemented + TestObserver& operator=(TestObserver&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/VTKUtils/VTKFileReader.cpp b/Source/SIMPLib/VTKUtils/VTKFileReader.cpp index 4e445a8276..fcd1b411fe 100644 --- a/Source/SIMPLib/VTKUtils/VTKFileReader.cpp +++ b/Source/SIMPLib/VTKUtils/VTKFileReader.cpp @@ -189,15 +189,13 @@ int VTKFileReader::readHeader() int err = 0; if(getInputFile().isEmpty()) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileName was not set and must be valid", -1); + setErrorCondition(-1, "FileName was not set and must be valid"); return -1; } if(nullptr == getDataContainerArray()->getDataContainer(getDataContainerName()).get()) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "DataContainer Pointer was nullptr and must be valid", -1); + setErrorCondition(-1, "DataContainer Pointer was nullptr and must be valid"); return -1; } @@ -205,8 +203,7 @@ int VTKFileReader::readHeader() if(!in.open(QIODevice::ReadOnly | QIODevice::Text)) { QString msg = QObject::tr("VTF file could not be opened: %1").arg(getInputFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), msg, getErrorCondition()); + setErrorCondition(-100, msg); return -100; } @@ -248,16 +245,15 @@ int VTKFileReader::readHeader() dims[1] = tokens[2].toLongLong(&ok, 10); dims[2] = tokens[3].toLongLong(&ok, 10); #if(CMP_SIZEOF_SSIZE_T == 4) - int64_t max = std::numeric_limits::max(); + constexpr int64_t max = std::numeric_limits::max(); #else - int64_t max = std::numeric_limits::max(); + constexpr int64_t max = std::numeric_limits::max(); #endif if(dims[0] * dims[1] * dims[2] > max) { err = -1; QString ss = QObject::tr("The total number of elements '%1' is greater than this program can hold. Try the 64 bit version.").arg(dims[0] * dims[1] * dims[2]); - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return err; } @@ -265,8 +261,7 @@ int VTKFileReader::readHeader() { err = -1; QString ss = QObject::tr("One of the dimensions is greater than the max index for this sysem. Try the 64 bit version. dim[0]=%1 dim[1]=%2im[2]=%3").arg(dims[0]).arg(dims[1]).arg(dims[2]); - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return err; } @@ -297,7 +292,7 @@ int VTKFileReader::readHeader() resolution[0] = tokens[1].toFloat(&ok); resolution[1] = tokens[2].toFloat(&ok); resolution[2] = tokens[3].toFloat(&ok); - image->setResolution(resolution); + image->setSpacing(resolution); return err; } diff --git a/Source/SIMPLib/VTKUtils/VTKFileReader.h b/Source/SIMPLib/VTKUtils/VTKFileReader.h index 8677e344e0..db82fc2446 100755 --- a/Source/SIMPLib/VTKUtils/VTKFileReader.h +++ b/Source/SIMPLib/VTKUtils/VTKFileReader.h @@ -176,7 +176,7 @@ class SIMPLib_EXPORT VTKFileReader : public FileReader } template - int skipVolume(std::ifstream& inStream, int byteSize, int xDim, int yDim, int zDim) + int skipVolume(std::ifstream& inStream, int byteSize, size_t xDim, size_t yDim, size_t zDim) { int err = 0; if(getFileIsBinary() == true) @@ -195,11 +195,11 @@ class SIMPLib_EXPORT VTKFileReader : public FileReader else { T tmp; - for (int z = 0; z < zDim; ++z) + for(size_t z = 0; z < zDim; ++z) { - for (int y = 0; y < yDim; ++y) + for(size_t y = 0; y < yDim; ++y) { - for (int x = 0; x < xDim; ++x) + for(size_t x = 0; x < xDim; ++x) { inStream >> tmp; } diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/AbstractIOFileWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/AbstractIOFileWidget.cpp index 3d3f2f692a..81e5ab063f 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/AbstractIOFileWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/AbstractIOFileWidget.cpp @@ -72,10 +72,12 @@ AbstractIOFileWidget::AbstractIOFileWidget(FilterParameter* parameter, AbstractF // Store the last used directory into the private instance variable QFileInfo fi(currentPath); m_LineEdit->setText(fi.filePath()); + setValidFilePath(m_LineEdit->text()); } else { m_LineEdit->setText(QDir::homePath()); + setValidFilePath(m_LineEdit->text()); } } } @@ -143,6 +145,7 @@ void AbstractIOFileWidget::setupGui() QString currentPath = getFilter()->property(PROPERTY_NAME_AS_CHAR).toString(); m_LineEdit->setText(currentPath); + setValidFilePath(m_LineEdit->text()); on_m_LineEdit_fileDropped(currentPath); on_m_LineEdit_returnPressed(); } @@ -159,6 +162,7 @@ void AbstractIOFileWidget::keyPressEvent(QKeyEvent* event) { SVStyle* style = SVStyle::Instance(); m_LineEdit->setText(m_CurrentText); + setValidFilePath(m_LineEdit->text()); style->LineEditClearStyle(m_LineEdit); m_LineEdit->setToolTip(""); } @@ -284,6 +288,7 @@ void AbstractIOFileWidget::on_m_LineEdit_fileDropped(const QString& text) QString inputPath = validator->convertToAbsolutePath(text); m_LineEdit->setText(text); + setValidFilePath(m_LineEdit->text()); // Set/Remove the red outline if the file does exist QtSFileUtils::VerifyPathExists(inputPath, m_LineEdit); @@ -327,6 +332,7 @@ void AbstractIOFileWidget::afterPreflight() void AbstractIOFileWidget::setValue(const QString& val) { m_LineEdit->setText(val); + setValidFilePath(m_LineEdit->text()); } // ----------------------------------------------------------------------------- diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.cpp index 92fe49dc48..a7a0094341 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.cpp @@ -194,7 +194,7 @@ bool AttributeMatrixCreationWidget::eventFilter(QObject* obj, QEvent* event) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrixCreationWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void AttributeMatrixCreationWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(PROPERTY_NAME_AS_CHAR) == 0) { diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.h index 9f27aa8d0a..d02ea19e03 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixCreationWidget.h @@ -123,9 +123,9 @@ public slots: void setSelectedPath(QString dcName, QString attrMatName, QString attrArrName); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); - private slots: +private slots: private: bool m_DidCausePreflight; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.cpp index cfc808eac0..acd103196e 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.cpp @@ -111,8 +111,7 @@ void AttributeMatrixSelectionWidget::setupGui() this, SLOT(filterNeedsInputParameters(AbstractFilter*))); // If the DataArrayPath is updated in the filter, update the widget - connect(getFilter(), SIGNAL(dataArrayPathUpdated(QString, DataArrayPath::RenameType)), - this, SLOT(updateDataArrayPath(QString, DataArrayPath::RenameType))); + connect(getFilter(), &AbstractFilter::dataArrayPathUpdated, this, &AttributeMatrixSelectionWidget::updateDataArrayPath); connect(this, SIGNAL(filterPathInput(DataArrayPath)), m_SelectedAttributeMatrixPath, SLOT(checkDragPath(DataArrayPath))); connect(this, SIGNAL(endViewPathRequirements()), m_SelectedAttributeMatrixPath, SLOT(clearPathFiltering())); @@ -175,7 +174,7 @@ bool AttributeMatrixSelectionWidget::eventFilter(QObject* obj, QEvent* event) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrixSelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void AttributeMatrixSelectionWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(PROPERTY_NAME_AS_CHAR) == 0) { diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.h index 243507d9ef..437a77461a 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/AttributeMatrixSelectionWidget.h @@ -102,7 +102,7 @@ class SVWidgetsLib_EXPORT AttributeMatrixSelectionWidget : public FilterParamete void attributeMatrixSelected(QString path); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.cpp index 041bb871ed..176ba9b40f 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.cpp @@ -451,7 +451,7 @@ void CalculatorWidget::on_applyChangesBtn_clicked() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CalculatorWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void CalculatorWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.h index 7908d38926..110f4a8ec6 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/CalculatorWidget.h @@ -108,7 +108,7 @@ class SVWidgetsLib_EXPORT CalculatorWidget : public FilterParameterWidget, priva void on_vectorsBtn_clicked(); void on_piBtn_clicked(); - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: bool m_DidCausePreflight; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.cpp index 86d8a88af0..159b6c9ccc 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.cpp @@ -360,7 +360,7 @@ void ComparisonSelectionAdvancedWidget::populateButtonText() } // Check to see if we have any DataContainers to actually populate drop downs with. - if (dca->getDataContainers().isEmpty()) + if (dca->getDataContainers().empty()) { return; } @@ -465,7 +465,7 @@ void ComparisonSelectionAdvancedWidget::presetAttributeMatrix(DataArrayPath amPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionAdvancedWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void ComparisonSelectionAdvancedWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(getFilterParameter()->getPropertyName()) == 0) { diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.h index 187da1bcbe..0279fc5001 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/ComparisonSelectionAdvancedWidget.h @@ -166,7 +166,7 @@ class ComparisonSelectionAdvancedWidget : public FilterParameterWidget, private * @param propertyName * @param renamePath */ - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); /** * @brief Handles AttributeMatrix path changes through DataArrayPathSelectionWidget diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.cpp index 0cf2f44420..5db84f127f 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.cpp @@ -192,7 +192,7 @@ bool DataArrayCreationWidget::eventFilter(QObject* obj, QEvent* event) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayCreationWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void DataArrayCreationWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(getFilterParameter()->getPropertyName()) == 0) { diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.h index 07927168de..504a929784 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataArrayCreationWidget.h @@ -109,7 +109,7 @@ class SVWidgetsLib_EXPORT DataArrayCreationWidget : public FilterParameterWidget void attributeMatrixSelected(QString path); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.cpp index 97c609acf3..6338d45f13 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.cpp @@ -173,7 +173,7 @@ bool DataArraySelectionWidget::eventFilter(QObject* obj, QEvent* event) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArraySelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void DataArraySelectionWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(PROPERTY_NAME_AS_CHAR) == 0) { diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.h index bfc3c7b015..40b678e039 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataArraySelectionWidget.h @@ -110,7 +110,7 @@ class SVWidgetsLib_EXPORT DataArraySelectionWidget : public FilterParameterWidge void dataArraySelected(QString path); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: bool m_DidCausePreflight; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.cpp index 22c4995828..5c0fca3825 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.cpp @@ -378,7 +378,7 @@ void DataContainerArrayProxyWidget::toggleStrikeOutFont(QListWidgetItem* item, Q // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArrayProxyWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void DataContainerArrayProxyWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { blockSignals(true); diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.h index 3b8e35238e..5064af9b59 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerArrayProxyWidget.h @@ -126,7 +126,7 @@ class SVWidgetsLib_EXPORT DataContainerArrayProxyWidget : public FilterParameter void selectAllDataContainersClicked(bool checked); void selectAllAttributeMatricesClicked(bool checked); void selectAllDataArraysClicked(bool checked); - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.cpp index 13cea27d58..97b4ae821e 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.cpp @@ -72,8 +72,13 @@ void DataContainerCreationWidget::setupGui() { label->setText(getFilterParameter()->getHumanLabel()); - QString str = getFilter()->property(PROPERTY_NAME_AS_CHAR).toString(); - stringEdit->setText(str, true); + DataContainerCreationFilterParameter::GetterCallbackType getter = m_FilterParameter->getGetterCallback(); + DataArrayPath dap; + if(getter) + { + dap = getter(); + } + stringEdit->setText(dap.getDataContainerName(), true); } blockSignals(false); @@ -119,17 +124,18 @@ void DataContainerCreationWidget::afterPreflight() // ----------------------------------------------------------------------------- void DataContainerCreationWidget::filterNeedsInputParameters(AbstractFilter* filter) { - bool ok = filter->setProperty(PROPERTY_NAME_AS_CHAR, stringEdit->getText()); - if(!ok) + DataArrayPath dap(stringEdit->getText()); + DataContainerCreationFilterParameter::SetterCallbackType setter = m_FilterParameter->getSetterCallback(); + if(setter) { - getFilter()->notifyMissingProperty(getFilterParameter()); + setter(dap); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerCreationWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void DataContainerCreationWidget::updateDataArrayPath(const QString& propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(PROPERTY_NAME_AS_CHAR) == 0) { diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.h index e35e1f454d..325b781930 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerCreationWidget.h @@ -86,7 +86,7 @@ class SVWidgetsLib_EXPORT DataContainerCreationWidget : public FilterParameterWi void filterNeedsInputParameters(AbstractFilter* filter); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(const QString& propertyName, const DataArrayPath::RenameType& renamePath); private: DataContainerCreationFilterParameter* m_FilterParameter; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.cpp index af8e2ba9b0..40da0bd142 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.cpp @@ -360,7 +360,8 @@ void DataContainerReaderWidget::setupGui() QString path = m_Filter->getInputFile(); m_LineEdit->setText(path); - + setValidFilePath(m_LineEdit->text()); + checkFilePath(path); updateStylingForPath(path); @@ -608,24 +609,6 @@ void DataContainerReaderWidget::afterPreflight() updateModelFromProxy(p); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void DataContainerReaderWidget::showFileInFileSystem() -{ - QFileInfo fi(m_CurrentlyValidPath); - QString path; - if (fi.isFile()) - { - path = fi.absoluteFilePath(); - } - else - { - path = fi.absolutePath(); - } - - QtSFileUtils::ShowPathInGui(this, path); -} // ----------------------------------------------------------------------------- // @@ -783,6 +766,7 @@ void DataContainerReaderWidget::on_selectBtn_clicked() QFileInfo fi(filePath); m_OpenDialogLastFilePath = fi.filePath(); m_LineEdit->setText(filePath); + setValidFilePath(m_LineEdit->text()); updateDCAProxy(filePath); } diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.h index 01d17e890c..838b6f5343 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerReaderWidget.h @@ -131,16 +131,10 @@ class SVWidgetsLib_EXPORT DataContainerReaderWidget : public FilterParameterWidg protected slots: - /** - * @brief showFileInFileSystem - */ - void showFileInFileSystem() override; - private: static QString m_OpenDialogLastFilePath; DataContainerReader* m_Filter = nullptr; - QString m_CurrentlyValidPath = ""; QString m_CurrentText = ""; DataContainerReaderFilterParameter* m_FilterParameter; DataContainerArrayProxy m_DcaProxy; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.cpp index 137f3576ce..475640888a 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.cpp @@ -140,19 +140,20 @@ void DataContainerSelectionWidget::setupGui() m_SelectedDataContainerPath->setStyleSheet(SVStyle::Instance()->QToolSelectionButtonStyle(false)); - QString dcName = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); - m_SelectedDataContainerPath->setText(dcName); + DataContainerSelectionFilterParameter::GetterCallbackType getter = m_FilterParameter->getGetterCallback(); + if(getter) + { + m_SelectedDataContainerPath->setText(getter().getDataContainerName()); + } m_SelectedDataContainerPath->setPropertyName(getFilterParameter()->getHumanLabel()); - changeStyleSheet(Style::FS_STANDARD_STYLE); - } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataContainerSelectionWidget::checkStringValues(QString curDcName, QString filtDcName) +QString DataContainerSelectionWidget::checkStringValues(const QString& curDcName, const QString& filtDcName) { if(curDcName.isEmpty() && !filtDcName.isEmpty()) { @@ -187,15 +188,13 @@ bool DataContainerSelectionWidget::eventFilter(QObject* obj, QEvent* event) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerSelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void DataContainerSelectionWidget::updateDataArrayPath(const QString& propertyName, const DataArrayPath::RenameType& renamePath) { - if(propertyName.compare(PROPERTY_NAME_AS_CHAR) == 0) + DataContainerSelectionFilterParameter::GetterCallbackType getter = m_FilterParameter->getGetterCallback(); + if(getter) { - QVariant var = getFilter()->property(PROPERTY_NAME_AS_CHAR); - QString updatedPath = var.value(); - blockSignals(true); - setSelectedPath(updatedPath); + setSelectedPath(getter()); blockSignals(false); } } @@ -215,7 +214,7 @@ void DataContainerSelectionWidget::dataContainerSelected(QString path) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerSelectionWidget::setSelectedPath(QString path) +void DataContainerSelectionWidget::setSelectedPath(const QString& path) { DataArrayPath dcPath = DataArrayPath::Deserialize(path, Detail::Delimiter); setSelectedPath(dcPath); @@ -224,7 +223,7 @@ void DataContainerSelectionWidget::setSelectedPath(QString path) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerSelectionWidget::setSelectedPath(DataArrayPath dcPath) +void DataContainerSelectionWidget::setSelectedPath(const DataArrayPath& dcPath) { if (dcPath.isEmpty()) { return; } @@ -268,15 +267,10 @@ void DataContainerSelectionWidget::afterPreflight() // ----------------------------------------------------------------------------- void DataContainerSelectionWidget::filterNeedsInputParameters(AbstractFilter* filter) { - // Generate the path to the AttributeArray - // DataArrayPath path(dataContainerList->currentText(), attributeMatrixList->currentText(), attributeArrayList->currentText()); - QVariant var(m_SelectedDataContainerPath->text()); - // var.setValue(path); - bool ok = false; - // Set the value into the Filter - ok = filter->setProperty(PROPERTY_NAME_AS_CHAR, var); - if(!ok) + DataArrayPath dap(m_SelectedDataContainerPath->text()); + DataContainerSelectionFilterParameter::SetterCallbackType setter = m_FilterParameter->getSetterCallback(); + if(setter) { - getFilter()->notifyMissingProperty(getFilterParameter()); + setter(dap); } } diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.h index 934d02868d..5f815813c1 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/DataContainerSelectionWidget.h @@ -86,7 +86,7 @@ class SVWidgetsLib_EXPORT DataContainerSelectionWidget : public FilterParameterW * @param filt * @return */ - QString checkStringValues(QString current, QString filtDcName); + QString checkStringValues(const QString& current, const QString& filtDcName); /** * @brief initializeWidget @@ -111,7 +111,7 @@ class SVWidgetsLib_EXPORT DataContainerSelectionWidget : public FilterParameterW void dataContainerSelected(QString path); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(const QString &propertyName, const DataArrayPath::RenameType& renamePath); private: @@ -119,9 +119,9 @@ class SVWidgetsLib_EXPORT DataContainerSelectionWidget : public FilterParameterW DataContainerSelectionFilterParameter* m_FilterParameter; - void setSelectedPath(QString path); + void setSelectedPath(const QString& path); - void setSelectedPath(DataArrayPath dcPath); + void setSelectedPath(const DataArrayPath& dcPath); public: DataContainerSelectionWidget(const DataContainerSelectionWidget&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.cpp index f4735ac2ca..85cef7ed06 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.cpp @@ -422,6 +422,14 @@ void FilterParameterWidget::hideBorder() setStyleSheet(""); } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterParameterWidget::setValidFilePath(const QString& filePath) +{ + m_CurrentlyValidPath = filePath; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.h index 7bbfcf3cdc..204312abcc 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.h @@ -93,6 +93,7 @@ class SVWidgetsLib_EXPORT FilterParameterWidget : public QFrame SIMPL_POINTER_PROPERTY(FilterParameter, FilterParameter) SIMPL_VIRTUAL_INSTANCE_PROPERTY(bool, WidgetIsExpanding) + void setValidFilePath(const QString& filePath); void fadeInWidget(QWidget* widget); diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec2Widget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec2Widget.cpp index dd9e2bd224..aa82b47229 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec2Widget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec2Widget.cpp @@ -95,10 +95,10 @@ void FloatVec2Widget::setupGui() { label->setText(getFilterParameter()->getHumanLabel()); - FloatVec2_t data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); + FloatVec2Type data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); - xData->setText(loc.toString(data.x)); - yData->setText(loc.toString(data.y)); + xData->setText(loc.toString(data[0])); + yData->setText(loc.toString(data[1])); } errorLabel->hide(); @@ -137,27 +137,27 @@ void FloatVec2Widget::widgetChanged(const QString& text) void FloatVec2Widget::filterNeedsInputParameters(AbstractFilter* filter) { bool ok = false; - FloatVec2_t defValue = m_FilterParameter->getDefaultValue().value(); - FloatVec2_t data; + FloatVec2Type defValue = m_FilterParameter->getDefaultValue().value(); + FloatVec2Type data; QLocale loc; - data.x = loc.toFloat(xData->text(), &ok); + data[0] = loc.toFloat(xData->text(), &ok); if(!ok) { SVStyle::Instance()->LineEditBackgroundErrorStyle(xData); SVStyle::Instance()->SetErrorColor("QLabel", errorLabel); errorLabel->setText("X Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); - data.x = defValue.x; + data[0] = defValue[0]; } - data.y = loc.toFloat(yData->text(), &ok); + data[1] = loc.toFloat(yData->text(), &ok); if(!ok) { SVStyle::Instance()->LineEditBackgroundErrorStyle(yData); SVStyle::Instance()->SetErrorColor("QLabel", errorLabel); errorLabel->setText("Y Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); - data.y = defValue.y; + data[1] = defValue[1]; } QVariant v; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec3Widget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec3Widget.cpp index f33a31a830..a59fc00325 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec3Widget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/FloatVec3Widget.cpp @@ -98,11 +98,11 @@ void FloatVec3Widget::setupGui() { label->setText(getFilterParameter()->getHumanLabel()); - FloatVec3_t data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); + FloatVec3Type data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); - xData->setText(loc.toString(data.x)); - yData->setText(loc.toString(data.y)); - zData->setText(loc.toString(data.z)); + xData->setText(loc.toString(data[0])); + yData->setText(loc.toString(data[1])); + zData->setText(loc.toString(data[2])); } errorLabel->hide(); @@ -142,39 +142,39 @@ void FloatVec3Widget::widgetChanged(const QString& text) void FloatVec3Widget::filterNeedsInputParameters(AbstractFilter* filter) { bool ok = false; - FloatVec3_t defValue = m_FilterParameter->getDefaultValue().value(); - FloatVec3_t data; + FloatVec3Type defValue = m_FilterParameter->getDefaultValue().value(); + FloatVec3Type data; QLocale loc; - data.x = loc.toFloat(xData->text(), &ok); + data[0] = loc.toFloat(xData->text(), &ok); if(!ok) { SVStyle::Instance()->LineEditBackgroundErrorStyle(xData); SVStyle::Instance()->SetErrorColor("QLabel", errorLabel); errorLabel->setText("X Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); - data.x = defValue.x; + data[0] = defValue[0]; } - - data.y = loc.toFloat(yData->text(), &ok); + + data[1] = loc.toFloat(yData->text(), &ok); if(!ok) { SVStyle::Instance()->LineEditBackgroundErrorStyle(yData); SVStyle::Instance()->SetErrorColor("QLabel", errorLabel); errorLabel->setText("Y Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); - data.y = defValue.y; + data[1] = defValue[1]; } - - data.z = loc.toFloat(zData->text(), &ok); + + data[2] = loc.toFloat(zData->text(), &ok); if(!ok) { SVStyle::Instance()->LineEditBackgroundErrorStyle(zData); SVStyle::Instance()->SetErrorColor("QLabel", errorLabel); errorLabel->setText("Z Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); - data.z = defValue.z; + data[2] = defValue[2]; } QVariant v; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/IntVec3Widget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/IntVec3Widget.cpp index 41fd965963..c8ac5b6ea9 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/IntVec3Widget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/IntVec3Widget.cpp @@ -90,10 +90,10 @@ void IntVec3Widget::setupGui() { IntVec3WidgetLabel->setText(getFilterParameter()->getHumanLabel()); - IntVec3_t data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); - xData->setText(QString::number(data.x)); - yData->setText(QString::number(data.y)); - zData->setText(QString::number(data.z)); + IntVec3Type data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); + xData->setText(QString::number(data[0])); + yData->setText(QString::number(data[1])); + zData->setText(QString::number(data[2])); } } @@ -111,10 +111,10 @@ void IntVec3Widget::widgetChanged(const QString& text) void IntVec3Widget::filterNeedsInputParameters(AbstractFilter* filter) { bool ok = false; - IntVec3_t data; - data.x = xData->text().toInt(&ok); - data.y = yData->text().toInt(&ok); - data.z = zData->text().toInt(&ok); + IntVec3Type data; + data[0] = xData->text().toInt(&ok); + data[1] = yData->text().toInt(&ok); + data[2] = zData->text().toInt(&ok); QVariant v; v.setValue(data); diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/LinkedDataContainerSelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/LinkedDataContainerSelectionWidget.cpp index 79d5f8690f..cc060251b5 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/LinkedDataContainerSelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/LinkedDataContainerSelectionWidget.cpp @@ -193,14 +193,11 @@ void LinkedDataContainerSelectionWidget::createSelectionMenu() // Get the DataContainerArray object // Loop over the data containers until we find the proper data container - QList containers = dca->getDataContainers(); + DataContainerArray::Container containers = dca->getDataContainers(); IGeometry::Types geomTypes = m_FilterParameter->getDefaultGeometryTypes(); - QListIterator containerIter(containers); - while(containerIter.hasNext()) + for(DataContainer::Pointer dc : containers) { - DataContainer::Pointer dc = containerIter.next(); - IGeometry::Pointer geom = IGeometry::NullPointer(); IGeometry::Type geomType = IGeometry::Type::Unknown; if(nullptr != dc.get()) @@ -284,7 +281,7 @@ void LinkedDataContainerSelectionWidget::setSelectedPath(DataArrayPath dcPath) if (dca->doesDataContainerExist(dcPath.getDataContainerName())) { DataContainer::Pointer dc = dca->getDataContainer(dcPath.getDataContainerName()); - QString html = dc->getInfoString(SIMPL::HtmlFormat); + QString html = dc->getInfoString(SIMPL::ToolTipFormat); m_SelectedDataContainerPath->setToolTip(html); m_SelectedDataContainerPath->setText(dcPath.getDataContainerName()); } @@ -323,7 +320,7 @@ void LinkedDataContainerSelectionWidget::afterPreflight() { DataContainer::Pointer dc = dca->getDataContainer(m_SelectedDataContainerPath->text()); if (nullptr != dc.get()) { - QString html = dc->getInfoString(SIMPL::HtmlFormat); + QString html = dc->getInfoString(SIMPL::ToolTipFormat); m_SelectedDataContainerPath->setToolTip(html); m_SelectedDataContainerPath->setStyleSheet(SVStyle::Instance()->QToolSelectionButtonStyle(true)); } diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.cpp index f40087c69a..743347c2f8 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.cpp @@ -574,7 +574,7 @@ void MultiAttributeMatrixSelectionWidget::filterNeedsInputParameters(AbstractFil // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiAttributeMatrixSelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void MultiAttributeMatrixSelectionWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.h index 720b332a27..e1baf71843 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/MultiAttributeMatrixSelectionWidget.h @@ -124,7 +124,7 @@ class SVWidgetsLib_EXPORT MultiAttributeMatrixSelectionWidget : public FilterPar void on_attributeMatricesSelectWidget_itemSelectionChanged(); void on_attributeMatricesOrderWidget_itemSelectionChanged(); - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: bool m_DidCausePreflight; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.cpp index 5b41c2ce26..b01d190def 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.cpp @@ -579,7 +579,7 @@ void MultiDataArraySelectionWidget::filterNeedsInputParameters(AbstractFilter* f // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiDataArraySelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void MultiDataArraySelectionWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.h index 1391f5f878..2bb7aa4dc8 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataArraySelectionWidget.h @@ -127,7 +127,7 @@ class SVWidgetsLib_EXPORT MultiDataArraySelectionWidget : public FilterParameter void on_availableArraysListWidget_itemDoubleClicked(QListWidgetItem* item); void on_selectedArraysListWidget_itemDoubleClicked(QListWidgetItem* item); - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: bool m_DidCausePreflight; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataContainerSelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataContainerSelectionWidget.cpp new file mode 100644 index 0000000000..fd4cd98b10 --- /dev/null +++ b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataContainerSelectionWidget.cpp @@ -0,0 +1,494 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "MultiDataContainerSelectionWidget.h" + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SVWidgetsLib/Core/SVWidgetsLibConstants.h" +#include "SVWidgetsLib/Widgets/SVStyle.h" + +#include "FilterParameterWidgetUtils.hpp" +#include "FilterParameterWidgetsDialogs.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionWidget::MultiDataContainerSelectionWidget(FilterParameter* parameter, AbstractFilter* filter, QWidget* parent) +: FilterParameterWidget(parameter, filter, parent) +, m_DidCausePreflight(false) +{ + m_FilterParameter = dynamic_cast(parameter); + Q_ASSERT_X(m_FilterParameter != nullptr, "NULL Pointer", "MultiDataContainerSelectionWidget can ONLY be used with a MultiDataContainerSelectionFilterParameter object"); + + setupUi(this); + setupGui(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionWidget::MultiDataContainerSelectionWidget(QWidget* parent) +: FilterParameterWidget(nullptr, nullptr, parent) +, m_DidCausePreflight(false) +{ + setupUi(this); + setupGui(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionWidget::~MultiDataContainerSelectionWidget() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::initializeWidget(FilterParameter* parameter, AbstractFilter* filter) +{ + setFilter(filter); + setFilterParameter(parameter); + setupGui(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::setupGui() +{ + // Sanity Check the filter and the filter parameter + if(getFilter() == nullptr) + { + return; + } + if(getFilterParameter() == nullptr) + { + return; + } + + selectedDataContainersListWidget->installEventFilter(this); + availableDataContainersListWidget->installEventFilter(this); + + // Generate the text for the QLabel + //label->setText(getFilterParameter()->getHumanLabel()); + + // Lastly, hook up the filter's signals and slots to our own signals and slots + // Catch when the filter is about to execute the preflight + connect(getFilter(), SIGNAL(preflightAboutToExecute()), this, SLOT(beforePreflight())); + + // Catch when the filter is finished running the preflight + connect(getFilter(), SIGNAL(preflightExecuted()), this, SLOT(afterPreflight())); + + // Catch when the filter wants its values updated + connect(getFilter(), SIGNAL(updateFilterParameters(AbstractFilter*)), this, SLOT(filterNeedsInputParameters(AbstractFilter*))); + + // If the DataArrayPath is updated in the filter, update the widget + connect(getFilter(), SIGNAL(dataArrayPathUpdated(QString, DataArrayPath::RenameType)), + this, SLOT(updateDataArrayPath(QString, DataArrayPath::RenameType))); + + QStringList dcNames = getFilter()->property(PROPERTY_NAME_AS_CHAR).value(); + for (int i=0; iaddItem(item); + } + selectBtn->setDisabled(true); + deselectBtn->setDisabled(true); + removeBtn->hide(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MultiDataContainerSelectionWidget::checkStringValues(QString curDcName, QString filtDcName) +{ + if(curDcName.isEmpty() && !filtDcName.isEmpty()) + { + return filtDcName; + } + if(!curDcName.isEmpty() && filtDcName.isEmpty()) + { + return curDcName; + } + if(!curDcName.isEmpty() && !filtDcName.isEmpty() && m_DidCausePreflight) + { + return curDcName; + } + + return filtDcName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool MultiDataContainerSelectionWidget::eventFilter(QObject* obj, QEvent* event) +{ + if(event->type() == QEvent::FocusIn && obj == selectedDataContainersListWidget) + { + on_selectedDataContainersListWidget_itemSelectionChanged(); + } + else if(event->type() == QEvent::FocusIn && obj == availableDataContainersListWidget) + { + on_availableDataContainersListWidget_itemSelectionChanged(); + } + return false; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_availableDataContainersListWidget_itemDoubleClicked(QListWidgetItem* item) +{ + on_selectBtn_clicked(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_selectedDataContainersListWidget_itemDoubleClicked(QListWidgetItem* item) +{ + on_deselectBtn_clicked(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_selectBtn_clicked() +{ + QModelIndexList indexList = availableDataContainersListWidget->selectionModel()->selectedRows(); + if(!indexList.empty()) + { + int offset = 0; + for (int i=0; itakeItem(row); + offset++; + if(item != nullptr) + { + selectedDataContainersListWidget->addItem(item); + } + } + + m_DidCausePreflight = true; + emit parametersChanged(); + m_DidCausePreflight = false; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_deselectBtn_clicked() +{ + // QModelIndexList indexList = selectedDataContainersListWidget->selectionModel()->selectedRows(); + QList items = selectedDataContainersListWidget->selectedItems(); + foreach(QListWidgetItem* item, items) + { + int row = selectedDataContainersListWidget->row(item); + selectedDataContainersListWidget->takeItem(row); + availableDataContainersListWidget->addItem(item); + } + m_DidCausePreflight = true; + emit parametersChanged(); + m_DidCausePreflight = false; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_upBtn_clicked() +{ + int currentIndex = selectedDataContainersListWidget->currentRow(); + + if(currentIndex > 0) + { + QListWidgetItem* item = selectedDataContainersListWidget->takeItem(currentIndex); + selectedDataContainersListWidget->insertItem(currentIndex - 1, item); + selectedDataContainersListWidget->setCurrentRow(currentIndex - 1); + + m_DidCausePreflight = true; + emit parametersChanged(); + m_DidCausePreflight = false; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_downBtn_clicked() +{ + int currentIndex = selectedDataContainersListWidget->currentRow(); + + if(currentIndex < selectedDataContainersListWidget->count() - 1) + { + QListWidgetItem* item = selectedDataContainersListWidget->takeItem(currentIndex); + selectedDataContainersListWidget->insertItem(currentIndex + 1, item); + selectedDataContainersListWidget->setCurrentRow(currentIndex + 1); + + m_DidCausePreflight = true; + emit parametersChanged(); + m_DidCausePreflight = false; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_removeBtn_clicked() +{ + QModelIndexList indexList = selectedDataContainersListWidget->selectionModel()->selectedRows(); + if(!indexList.empty()) + { + int offset = 0; + for (int i=0; iitem(row); + selectedDataContainersListWidget->removeItemWidget(item); + delete item; + offset++; + } + + m_DidCausePreflight = true; + emit parametersChanged(); + m_DidCausePreflight = false; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::selectionChanged() +{ + upBtn->setDisabled(true); + downBtn->setDisabled(true); + selectBtn->setDisabled(true); + deselectBtn->setDisabled(true); + removeBtn->hide(); + + int selectSize = availableDataContainersListWidget->selectionModel()->selectedRows().size(); + int orderSize = selectedDataContainersListWidget->selectionModel()->selectedRows().size(); + + if (selectSize > 0) + { + selectBtn->setEnabled(true); + } + + if (orderSize > 0) + { + deselectBtn->setEnabled(true); + + if (orderSize == 1) + { + upBtn->setEnabled(true); + downBtn->setEnabled(true); + } + + bool allErrorRows = true; + for (int i=0; iselectionModel()->selectedRows()[i].row(); + if(selectedDataContainersListWidget->item(row)->backgroundColor() != QColor(235, 110, 110)) + { + allErrorRows = false; + } + } + + if(allErrorRows) + { + removeBtn->show(); + } + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_availableDataContainersListWidget_itemSelectionChanged() +{ + selectionChanged(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::on_selectedDataContainersListWidget_itemSelectionChanged() +{ + selectionChanged(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::clearNonexistantDataContainers() +{ + DataContainerArray::Pointer dca = getFilter()->getDataContainerArray(); + if(nullptr == dca.get()) + { + return; + } + + QList dcNames = dca->getDataContainerNames(); + + for (int i = 0; i < availableDataContainersListWidget->count(); i++) + { + if (!dcNames.contains(availableDataContainersListWidget->item(i)->text())) + { + QListWidgetItem* item = availableDataContainersListWidget->takeItem(i); + delete item; + i--; + } + } + + for (int i = 0; i < selectedDataContainersListWidget->count(); i++) + { + if (!dcNames.contains(selectedDataContainersListWidget->item(i)->text())) + { + QListWidgetItem* item = selectedDataContainersListWidget->takeItem(i); + delete item; + i--; + } + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::beforePreflight() +{ + if(nullptr == getFilter()) + { + return; + } + + clearNonexistantDataContainers(); + + // Previously in afterPreflight() + DataContainerArray::Pointer dca = getFilter()->getDataContainerArray(); + if(nullptr == dca.get()) + { + return; + } + + QList dcNames = dca->getDataContainerNames(); + + QList selectListNames; + for (int i = 0; i < availableDataContainersListWidget->count(); i++) + { + selectListNames.append(availableDataContainersListWidget->item(i)->text()); + } + + QList orderListNames; + for (int i = 0; i < selectedDataContainersListWidget->count(); i++) + { + QListWidgetItem* item = selectedDataContainersListWidget->item(i); + QString name = item->text(); + orderListNames.append(name); + if (!dcNames.contains(name)) + { + //item->setFlags(item->flags() & ~Qt::ItemIsEnabled); + // item->setBackgroundColor(QColor(235, 110, 110)); + item->setIcon(QIcon(":/SIMPL/icons/images/bullet_ball_red.png")); + } + else + { + // item->setBackgroundColor(QColor(255, 255, 255)); + item->setIcon(QIcon(":/SIMPL/icons/images/bullet_ball_green.png")); + } + } + + for (int i = 0; i < dcNames.size(); i++) + { + if (!selectListNames.contains(dcNames[i]) && !orderListNames.contains(dcNames[i])) + { + QListWidgetItem* item = new QListWidgetItem(QIcon(":/SIMPL/icons/images/bullet_ball_green.png"), dcNames[i]); + availableDataContainersListWidget->addItem(item); + } + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::afterPreflight() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::filterNeedsInputParameters(AbstractFilter* filter) +{ + QStringList dcNames; + for (int i = 0; i < selectedDataContainersListWidget->count(); i++) + { + dcNames.push_back(selectedDataContainersListWidget->item(i)->text()); + } + + // Generate the path to the AttributeArray + QVariant var; + var.setValue(dcNames); + bool ok = false; + // Set the value into the Filter + ok = filter->setProperty(PROPERTY_NAME_AS_CHAR, var); + if (!ok) + { + getFilter()->notifyMissingProperty(getFilterParameter()); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; +} diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataContainerSelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataContainerSelectionWidget.h new file mode 100644 index 0000000000..6393c39f1d --- /dev/null +++ b/Source/SVWidgetsLib/FilterParameterWidgets/MultiDataContainerSelectionWidget.h @@ -0,0 +1,150 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + + +#include +#include +#include + +#include "SVWidgetsLib/QtSupport/QtSFaderWidget.h" + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/DataContainerArrayProxy.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" + + +#include "SVWidgetsLib/SVWidgetsLib.h" +#include "SVWidgetsLib/FilterParameterWidgets/FilterParameterWidget.h" + + +#include "SVWidgetsLib/ui_MultiDataContainerSelectionWidget.h" + +class FilterParameter; +class AbstractFilter; +class MultiDataContainerSelectionFilterParameter; +class QSignalMapper; + +/** +* @brief +* @author +* @version +*/ +class SVWidgetsLib_EXPORT MultiDataContainerSelectionWidget : public FilterParameterWidget, private Ui::MultiDataContainerSelectionWidget +{ + Q_OBJECT + + public: + /** + * @brief Constructor + * @param parameter The FilterParameter object that this widget represents + * @param filter The instance of the filter that this parameter is a part of + * @param parent The parent QWidget for this Widget + */ + MultiDataContainerSelectionWidget(FilterParameter* parameter, AbstractFilter* filter = nullptr, QWidget* parent = nullptr); + + MultiDataContainerSelectionWidget(QWidget* parent = nullptr); + + ~MultiDataContainerSelectionWidget() override; + + /** + * @brief This method does additional GUI widget connections + */ + void setupGui() override; + + /** + * @brief checkStringValues + * @param current + * @param filt + * @return + */ + QString checkStringValues(QString current, QString filtDcName); + + /** + * @brief initializeWidget + * @param parameter + * @param filter + */ + void initializeWidget(FilterParameter* parameter, AbstractFilter* filter); + + /** + * @brief eventFilter + * @param obj + * @param event + * @return + */ + bool eventFilter(QObject* obj, QEvent* event) override; + + public slots: + void beforePreflight(); + void afterPreflight(); + void filterNeedsInputParameters(AbstractFilter* filter); + + protected slots: + void on_upBtn_clicked(); + void on_downBtn_clicked(); + void on_selectBtn_clicked(); + void on_deselectBtn_clicked(); + void on_removeBtn_clicked(); + + void on_availableDataContainersListWidget_itemSelectionChanged(); + void on_selectedDataContainersListWidget_itemSelectionChanged(); + + void on_availableDataContainersListWidget_itemDoubleClicked(QListWidgetItem* item); + void on_selectedDataContainersListWidget_itemDoubleClicked(QListWidgetItem* item); + + void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + + private: + bool m_DidCausePreflight; + + MultiDataContainerSelectionFilterParameter* m_FilterParameter; + + void selectionChanged(); + + /** + * @brief clearNonexistantDataContainers + */ + void clearNonexistantDataContainers(); + + public: + MultiDataContainerSelectionWidget(const MultiDataContainerSelectionWidget&) = delete; // Copy Constructor Not Implemented + MultiDataContainerSelectionWidget(MultiDataContainerSelectionWidget&&) = delete; // Move Constructor Not Implemented + MultiDataContainerSelectionWidget& operator=(const MultiDataContainerSelectionWidget&) = delete; // Copy Assignment Not Implemented + MultiDataContainerSelectionWidget& operator=(MultiDataContainerSelectionWidget&&) = delete; // Move Assignment Not Implemented +}; + + + diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.cpp index 1967f46dc0..7c840ac588 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.cpp @@ -188,7 +188,7 @@ bool PhaseTypeSelectionWidget::eventFilter(QObject* obj, QEvent* event) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PhaseTypeSelectionWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void PhaseTypeSelectionWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { if(propertyName.compare(PROPERTY_NAME_AS_CHAR) == 0) { @@ -239,7 +239,7 @@ void PhaseTypeSelectionWidget::setSelectedPath(DataArrayPath amPath) if (dca->doesAttributeMatrixExist(amPath)) { AttributeMatrix::Pointer am = dca->getAttributeMatrix(amPath); - QString html = am->getInfoString(SIMPL::HtmlFormat); + QString html = am->getInfoString(SIMPL::ToolTipFormat); m_SelectedAttributeMatrixPath->setToolTip(html); m_SelectedAttributeMatrixPath->setText(amPath.serialize(Detail::Delimiter)); } diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.h index 75174bdc6b..5a3c71f430 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/PhaseTypeSelectionWidget.h @@ -109,7 +109,7 @@ class SVWidgetsLib_EXPORT PhaseTypeSelectionWidget : public FilterParameterWidge void resetPhaseComboBoxes(); protected slots: - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: bool m_DidCausePreflight; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.cpp b/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.cpp index 8752daf0f1..acdd1eff22 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.cpp +++ b/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.cpp @@ -509,7 +509,7 @@ void ReadASCIIDataWidget::afterPreflight() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ReadASCIIDataWidget::updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath) +void ReadASCIIDataWidget::updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.h b/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.h index d32445f00e..a58dbf4656 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.h +++ b/Source/SVWidgetsLib/FilterParameterWidgets/ReadASCIIDataWidget.h @@ -85,7 +85,7 @@ class SVWidgetsLib_EXPORT ReadASCIIDataWidget : public FilterParameterWidget, pr void lineCountDidFinish(); void updateProgress(double percentage); - void updateDataArrayPath(QString propertyName, DataArrayPath::RenameType renamePath); + void updateDataArrayPath(QString propertyName, const DataArrayPath::RenameType& renamePath); private: ReadASCIIDataFilterParameter* m_FilterParameter; diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/SourceList.cmake b/Source/SVWidgetsLib/FilterParameterWidgets/SourceList.cmake index f6ebed59fd..cf86c46a74 100644 --- a/Source/SVWidgetsLib/FilterParameterWidgets/SourceList.cmake +++ b/Source/SVWidgetsLib/FilterParameterWidgets/SourceList.cmake @@ -33,6 +33,7 @@ set(SIMPLView_PARAMETER_WIDGETS IntWidget LinkedBooleanWidget MultiAttributeMatrixSelectionWidget + MultiDataContainerSelectionWidget MultiDataArraySelectionWidget NumericTypeWidget ParagraphWidget diff --git a/Source/SVWidgetsLib/FilterParameterWidgets/UI_Files/MultiDataContainerSelectionWidget.ui b/Source/SVWidgetsLib/FilterParameterWidgets/UI_Files/MultiDataContainerSelectionWidget.ui new file mode 100644 index 0000000000..3bd5245239 --- /dev/null +++ b/Source/SVWidgetsLib/FilterParameterWidgets/UI_Files/MultiDataContainerSelectionWidget.ui @@ -0,0 +1,396 @@ + + + MultiDataContainerSelectionWidget + + + + 0 + 0 + 583 + 247 + + + + + 2 + + + 2 + + + 2 + + + 2 + + + 4 + + + + + 0 + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Use this button to move an array up in the "Selected Data Arrays" column + + + + + + + :/SIMPL/icons/images/arrow_up.png:/SIMPL/icons/images/arrow_up.png + + + + 24 + 24 + + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Use this button to move an array down in the "Selected Data Arrays" column + + + + + + + :/SIMPL/icons/images/arrow_down.png:/SIMPL/icons/images/arrow_down.png + + + + 24 + 24 + + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Use this button to remove non-existant arrays out of the "Selected Data Arrays" column + + + + + + + :/SIMPL/icons/images/delete.png:/SIMPL/icons/images/delete.png + + + + 24 + 24 + + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 75 + true + + + + Selected Data Containers + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + Available Data Containers + + + Qt::AlignCenter + + + + + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Use this button to move arrays into the "Selected Data Arrays" column + + + + + + + :/SIMPL/icons/images/arrow_right.png:/SIMPL/icons/images/arrow_right.png + + + + 24 + 24 + + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Use this button to move arrays out of the "Selected Data Arrays" column + + + + + + + :/SIMPL/icons/images/arrow_left.png:/SIMPL/icons/images/arrow_left.png + + + + 24 + 24 + + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + + + 1 + 0 + + + + QAbstractScrollArea::AdjustIgnored + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + false + + + QAbstractItemView::NoDragDrop + + + Qt::CopyAction + + + false + + + QAbstractItemView::ExtendedSelection + + + QListView::ListMode + + + true + + + + + + + + 1 + 0 + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + false + + + QAbstractItemView::NoDragDrop + + + Qt::CopyAction + + + false + + + QAbstractItemView::ExtendedSelection + + + QListView::ListMode + + + true + + + false + + + + + + + + SVIconPushButton + QPushButton +
SVControlWidgets.h
+
+ + SVListWidget + QListWidget +
SVControlWidgets.h
+
+
+ + + + +
diff --git a/Source/SVWidgetsLib/QtSupport/QtSDisclosableWidget.cpp b/Source/SVWidgetsLib/QtSupport/QtSDisclosableWidget.cpp new file mode 100644 index 0000000000..32508aa974 --- /dev/null +++ b/Source/SVWidgetsLib/QtSupport/QtSDisclosableWidget.cpp @@ -0,0 +1,183 @@ +/* ============================================================================ + * Copyright (c) 2012 Michael A. Jackson (BlueQuartz Software) + * Copyright (c) 2012 Dr. Michael A. Groeber (US Air Force Research Laboratories) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of Michael A. Groeber, Michael A. Jackson, the US Air Force, + * BlueQuartz Software nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This code was written under United States Air Force Contract number + * FA8650-07-D-5800 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "QtSDisclosableWidget.h" + +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QtSDisclosableWidget::QtSDisclosableWidget(QWidget* parent) +: QWidget(parent) +{ +// connect(this, SIGNAL(toggled(bool)), this, SLOT(disclose(bool))); + + toggleButton.setStyleSheet("QToolButton { border: none; }"); + toggleButton.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + toggleButton.setArrowType(Qt::ArrowType::RightArrow); + toggleButton.setCheckable(true); + toggleButton.setChecked(false); + + headerLine.setFrameShape(QFrame::HLine); + headerLine.setFrameShadow(QFrame::Sunken); + headerLine.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + +// contentArea.setStyleSheet("QScrollArea { border: none; }"); + contentArea.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + contentArea.setMaximumHeight(0); + contentArea.setMinimumHeight(0); + toggleAnimation.addAnimation(new QPropertyAnimation(this, "minimumHeight")); + toggleAnimation.addAnimation(new QPropertyAnimation(this, "maximumHeight")); + toggleAnimation.addAnimation(new QPropertyAnimation(&contentArea, "maximumHeight")); + mainLayout.setVerticalSpacing(0); + mainLayout.setContentsMargins(0, 0, 0, 0); + int row = 0; + mainLayout.addWidget(&toggleButton, row, 0, 1, 1, Qt::AlignLeft); + mainLayout.addWidget(&headerLine, row++, 2, 1, 1); + mainLayout.addWidget(&contentArea, row, 0, 1, 3); + setLayout(&mainLayout); + QObject::connect(&toggleButton, &QToolButton::clicked, [this](const bool checked) { + toggleButton.setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow); + toggleAnimation.setDirection(checked ? QAbstractAnimation::Forward : QAbstractAnimation::Backward); + toggleAnimation.start(); + }); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QtSDisclosableWidget::~QtSDisclosableWidget() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void QtSDisclosableWidget::changeStyle() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void QtSDisclosableWidget::updateWidgetStyle() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void QtSDisclosableWidget::setupGui() +{ + +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void QtSDisclosableWidget::setTitle(const QString &title) +{ + toggleButton.setText(title); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void QtSDisclosableWidget::setContentLayout(QLayout* contentLayout) +{ + delete contentArea.layout(); + contentArea.setLayout(contentLayout); + const auto collapsedHeight = sizeHint().height() - contentArea.maximumHeight(); + auto contentHeight = contentLayout->sizeHint().height(); + for (int i = 0; i < toggleAnimation.animationCount() - 1; ++i) { + QPropertyAnimation * spoilerAnimation = static_cast(toggleAnimation.animationAt(i)); + spoilerAnimation->setDuration(animationDuration); + spoilerAnimation->setStartValue(collapsedHeight); + spoilerAnimation->setEndValue(collapsedHeight + contentHeight); + } + QPropertyAnimation * contentAnimation = static_cast(toggleAnimation.animationAt(toggleAnimation.animationCount() - 1)); + contentAnimation->setDuration(animationDuration); + contentAnimation->setStartValue(0); + contentAnimation->setEndValue(contentHeight); +} + +#if 0 +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void QtSDisclosableWidget::disclose(bool on) +{ + if(on) + { + this->setMaximumHeight(260000); + } + else + { + this->setMaximumHeight(26); + } + + QObjectList objs = children(); + foreach(QObject* obj, objs) + { + QWidget* w = qobject_cast(obj); + if(nullptr != w) + { + if(on) + { + w->show(); + } + else + { + w->hide(); + } + } + } +} +#endif diff --git a/Source/SVWidgetsLib/QtSupport/QtSDisclosableGroupBox.h b/Source/SVWidgetsLib/QtSupport/QtSDisclosableWidget.h similarity index 69% rename from Source/SVWidgetsLib/QtSupport/QtSDisclosableGroupBox.h rename to Source/SVWidgetsLib/QtSupport/QtSDisclosableWidget.h index aef9e79370..38a469b93f 100644 --- a/Source/SVWidgetsLib/QtSupport/QtSDisclosableGroupBox.h +++ b/Source/SVWidgetsLib/QtSupport/QtSDisclosableWidget.h @@ -33,7 +33,13 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + +#include +#include +#include +#include +#include #include "SVWidgetsLib/SVWidgetsLib.h" @@ -41,7 +47,7 @@ class QLayout; class QRect; /** - * @class QtSDisclosableGroupBox QtSDisclosableGroupBox.h FilterWidgets/QtSDisclosableGroupBox.h + * @class QtSDisclosableWidget QtSDisclosableWidget.h FilterWidgets/QtSDisclosableWidget.h * @brief This class is a subclass of the QGroupBox class and is used to display * Filter Options that the user can set. This class is capable of constructing a * default GUI widget set for each type of Filter Option that is available. If @@ -51,21 +57,24 @@ class QRect; * @date Jan 6, 2012 * @version 1.0 */ -class SVWidgetsLib_EXPORT QtSDisclosableGroupBox : public QGroupBox +class SVWidgetsLib_EXPORT QtSDisclosableWidget : public QWidget { Q_OBJECT public: - QtSDisclosableGroupBox(QWidget* parent = nullptr); - ~QtSDisclosableGroupBox() override; + QtSDisclosableWidget(QWidget* parent = nullptr); + ~QtSDisclosableWidget() override; virtual void setupGui(); + void setContentLayout(QLayout* contentLayout); + + void setTitle(const QString &title); signals: - void dragStarted(QtSDisclosableGroupBox* widget); + void dragStarted(QtSDisclosableWidget* widget); public slots: - void disclose(bool on); +// void disclose(bool on); /** * @brief Sets the style of the Widget to indicate a selected or non-selected @@ -79,11 +88,18 @@ public slots: */ void updateWidgetStyle(); +private: + QGridLayout mainLayout; + QToolButton toggleButton; + QFrame headerLine; + QParallelAnimationGroup toggleAnimation; + QScrollArea contentArea; + int animationDuration = 300; public: - QtSDisclosableGroupBox(const QtSDisclosableGroupBox&) = delete; // Copy Constructor Not Implemented - QtSDisclosableGroupBox(QtSDisclosableGroupBox&&) = delete; // Move Constructor Not Implemented - QtSDisclosableGroupBox& operator=(const QtSDisclosableGroupBox&) = delete; // Copy Assignment Not Implemented - QtSDisclosableGroupBox& operator=(QtSDisclosableGroupBox&&) = delete; // Move Assignment Not Implemented + QtSDisclosableWidget(const QtSDisclosableWidget&) = delete; // Copy Constructor Not Implemented + QtSDisclosableWidget(QtSDisclosableWidget&&) = delete; // Move Constructor Not Implemented + QtSDisclosableWidget& operator=(const QtSDisclosableWidget&) = delete; // Copy Assignment Not Implemented + QtSDisclosableWidget& operator=(QtSDisclosableWidget&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SVWidgetsLib/QtSupport/QtSPluginFrame.h b/Source/SVWidgetsLib/QtSupport/QtSPluginFrame.h index f6b1c7050e..2d20dc8935 100755 --- a/Source/SVWidgetsLib/QtSupport/QtSPluginFrame.h +++ b/Source/SVWidgetsLib/QtSupport/QtSPluginFrame.h @@ -44,7 +44,7 @@ #include #include -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" #include "SVWidgetsLib/SVWidgetsLib.h" @@ -162,7 +162,7 @@ class SVWidgetsLib_EXPORT QtSPluginFrame : public QFrame * @brief Slot to add a message to display to the user * @param message */ - virtual void addMessage(PipelineMessage msg) = 0; + virtual void addMessage(AbstractMessage::Pointer msg) = 0; /** * @brief Slot to add a Progress message to display to the user diff --git a/Source/SVWidgetsLib/QtSupport/SourceList.cmake b/Source/SVWidgetsLib/QtSupport/SourceList.cmake index ee514ae9b0..d55ad0da52 100755 --- a/Source/SVWidgetsLib/QtSupport/SourceList.cmake +++ b/Source/SVWidgetsLib/QtSupport/SourceList.cmake @@ -15,7 +15,7 @@ set(SVWidgetsLib_QtSupport_MOC_HDRS ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSCheckboxDialog.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QRoundProgressBar.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSColorComboPicker.h - ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDisclosableGroupBox.h + ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDisclosableWidget.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDistributionTypeWidget.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDroppableScrollArea.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDocServer.h @@ -33,7 +33,6 @@ set(SVWidgetsLib_QtSupport_MOC_HDRS ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSSettings.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSSplitter.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSSplitterHandle.h - ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDisclosableGroupBox.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSStringEdit.h ${SVWidgetsLib_SOURCE_DIR}/QtSupport/httpserver/QtSStaticFileController.h @@ -46,7 +45,7 @@ set(SVWidgetsLib_QtSupport_SRCS ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSCheckboxDialog.cpp ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QRoundProgressBar.cpp ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSColorComboPicker.cpp - ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDisclosableGroupBox.cpp + ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDisclosableWidget.cpp ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDistributionTypeWidget.cpp ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDroppableScrollArea.cpp ${SVWidgetsLib_SOURCE_DIR}/QtSupport/QtSDocServer.cpp diff --git a/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.cpp b/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.cpp index c024aa3fb1..2454658b84 100644 --- a/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.cpp @@ -48,7 +48,7 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(DataArrayPath path) +const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(const DataArrayPath& path) { return CreateDragIcon(path.serialize(Detail::Delimiter), path.getDataType()); } @@ -56,7 +56,7 @@ const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(DataArrayPath path) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(QString text, DataArrayPath::DataType dataType) +const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(const QString& text, DataArrayPathHelper::DataType dataType) { return CreateDragIcon(text, GetActiveColor(dataType)); } @@ -64,7 +64,7 @@ const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(QString text, DataArr // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(QString text, QColor backgroundColor) +const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(const QString& text, const QColor& backgroundColor) { int minHeight = 26; @@ -113,23 +113,23 @@ const QPixmap DataArrayPathSelectionWidget::CreateDragIcon(QString text, QColor // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QColor DataArrayPathSelectionWidget::GetActiveColor(DataArrayPath::DataType type) +const QColor DataArrayPathSelectionWidget::GetActiveColor(DataArrayPathHelper::DataType type) { QColor color; SVStyle* style = SVStyle::Instance(); switch(type) { - case DataArrayPath::DataType::DataContainer: + case DataArrayPathHelper::DataType::DataContainer: color = style->getDataArrayPath_DataContainer_color(); break; - case DataArrayPath::DataType::AttributeMatrix: + case DataArrayPathHelper::DataType::AttributeMatrix: color = style->getDataArrayPath_AttributeMatrix_color(); break; - case DataArrayPath::DataType::DataArray: + case DataArrayPathHelper::DataType::DataArray: color = style->getDataArrayPath_DataArray_color(); break; - case DataArrayPath::DataType::None: + case DataArrayPathHelper::DataType::None: break; } @@ -139,23 +139,23 @@ const QColor DataArrayPathSelectionWidget::GetActiveColor(DataArrayPath::DataTyp // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QColor DataArrayPathSelectionWidget::GetCheckedColor(DataArrayPath::DataType type) +const QColor DataArrayPathSelectionWidget::GetCheckedColor(DataArrayPathHelper::DataType type) { QColor color; SVStyle* style = SVStyle::Instance(); switch(type) { - case DataArrayPath::DataType::DataContainer: + case DataArrayPathHelper::DataType::DataContainer: color = style->getDataArrayPath_DataContainer_background_color(); break; - case DataArrayPath::DataType::AttributeMatrix: + case DataArrayPathHelper::DataType::AttributeMatrix: color = style->getDataArrayPath_AttributeMatrix_background_color(); break; - case DataArrayPath::DataType::DataArray: + case DataArrayPathHelper::DataType::DataArray: color = style->getDataArrayPath_DataArray_background_color(); break; - case DataArrayPath::DataType::None: + case DataArrayPathHelper::DataType::None: break; } @@ -165,9 +165,9 @@ const QColor DataArrayPathSelectionWidget::GetCheckedColor(DataArrayPath::DataTy // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, DataArrayPath path, DataContainerSelectionFilterParameter::RequirementType reqs) +bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, const DataArrayPath& path, const DataContainerSelectionFilterParameter::RequirementType& reqs) { - if(DataArrayPath::DataType::DataContainer != path.getDataType()) + if(DataArrayPathHelper::DataType::DataContainer != path.getDataType()) { return false; } @@ -211,9 +211,9 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, DataArrayPath path, AttributeMatrixSelectionFilterParameter::RequirementType reqs) +bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, const DataArrayPath& path, const AttributeMatrixSelectionFilterParameter::RequirementType& reqs) { - if(DataArrayPath::DataType::AttributeMatrix != path.getDataType()) + if(DataArrayPathHelper::DataType::AttributeMatrix != path.getDataType()) { return false; } @@ -272,9 +272,9 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, DataArrayPath path, DataArraySelectionFilterParameter::RequirementType reqs) +bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter, const DataArrayPath& path, const DataArraySelectionFilterParameter::RequirementType& reqs) { - if(DataArrayPath::DataType::DataArray != path.getDataType()) + if(DataArrayPathHelper::DataType::DataArray != path.getDataType()) { return false; } @@ -372,7 +372,7 @@ void DataArrayPathSelectionWidget::setupGui() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath::DataType DataArrayPathSelectionWidget::getDataType() +DataArrayPathHelper::DataType DataArrayPathSelectionWidget::getDataType() const { return m_DataType; } @@ -380,9 +380,9 @@ DataArrayPath::DataType DataArrayPathSelectionWidget::getDataType() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayPathSelectionWidget::setDataContainerRequirements(DataContainerSelectionFilterParameter::RequirementType dcReqs) +void DataArrayPathSelectionWidget::setDataContainerRequirements(const DataContainerSelectionFilterParameter::RequirementType& dcReqs) { - m_DataType = DataArrayPath::DataType::DataContainer; + m_DataType = DataArrayPathHelper::DataType::DataContainer; m_DataContainerReqs = dcReqs; QString html; @@ -397,9 +397,9 @@ void DataArrayPathSelectionWidget::setDataContainerRequirements(DataContainerSel // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayPathSelectionWidget::setAttrMatrixRequirements(AttributeMatrixSelectionFilterParameter::RequirementType amReqs) +void DataArrayPathSelectionWidget::setAttrMatrixRequirements(const AttributeMatrixSelectionFilterParameter::RequirementType& amReqs) { - m_DataType = DataArrayPath::DataType::AttributeMatrix; + m_DataType = DataArrayPathHelper::DataType::AttributeMatrix; m_AttrMatrixReqs = amReqs; QString html; @@ -415,9 +415,9 @@ void DataArrayPathSelectionWidget::setAttrMatrixRequirements(AttributeMatrixSele // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayPathSelectionWidget::setDataArrayRequirements(DataArraySelectionFilterParameter::RequirementType daReqs) +void DataArrayPathSelectionWidget::setDataArrayRequirements(const DataArraySelectionFilterParameter::RequirementType& daReqs) { - m_DataType = DataArrayPath::DataType::DataArray; + m_DataType = DataArrayPathHelper::DataType::DataArray; m_DataArrayReqs = daReqs; QString html; @@ -435,7 +435,7 @@ void DataArrayPathSelectionWidget::setDataArrayRequirements(DataArraySelectionFi // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPathSelectionWidget::createTooltipHeader() +QString DataArrayPathSelectionWidget::createTooltipHeader() const { QString html; QTextStream ss(&html); @@ -451,7 +451,7 @@ QString DataArrayPathSelectionWidget::createTooltipHeader() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPathSelectionWidget::createTooltipFooter() +QString DataArrayPathSelectionWidget::createTooltipFooter() const { QString html; QTextStream ss(&html); @@ -464,7 +464,7 @@ QString DataArrayPathSelectionWidget::createTooltipFooter() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPathSelectionWidget::createGeomReqString(QVector geomTypes) +QString DataArrayPathSelectionWidget::createGeomReqString(QVector geomTypes) const { QString reqStr = "Required Geometries:"; if(geomTypes.empty()) @@ -518,7 +518,7 @@ QString DataArrayPathSelectionWidget::createGeomReqString(QVector amTypes) +QString DataArrayPathSelectionWidget::createAttrMatrixReqString(QVector amTypes) const { QString reqStr = "Required Matrix Type:"; if(amTypes.empty()) @@ -590,7 +590,7 @@ QString DataArrayPathSelectionWidget::createAttrMatrixReqString(QVector daTypes) +QString DataArrayPathSelectionWidget::createDataArrayTypeString(QVector daTypes) const { QString reqStr = "Required Array Type:"; if(daTypes.empty()) @@ -612,7 +612,7 @@ QString DataArrayPathSelectionWidget::createDataArrayTypeString(QVector // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPathSelectionWidget::createComponentReqString(QVector> comps) +QString DataArrayPathSelectionWidget::createComponentReqString(QVector> comps) const { QString reqStr = "Required Component Size:"; if(comps.empty()) @@ -647,7 +647,7 @@ QString DataArrayPathSelectionWidget::createComponentReqString(QVectorgetDataContainer(getDataArrayPath())) { found = true; } break; - case DataArrayPath::DataType::AttributeMatrix: + case DataArrayPathHelper::DataType::AttributeMatrix: if(dca->getAttributeMatrix(getDataArrayPath())) { found = true; } break; - case DataArrayPath::DataType::DataArray: + case DataArrayPathHelper::DataType::DataArray: { AttributeMatrix::Pointer am = dca->getAttributeMatrix(getDataArrayPath()); if(am && am->getAttributeArray(getDataArrayPath().getDataArrayName())) @@ -1096,7 +1096,7 @@ void DataArrayPathSelectionWidget::afterPreflight() } } break; - case DataArrayPath::DataType::None: + case DataArrayPathHelper::DataType::None: break; } @@ -1172,7 +1172,7 @@ void DataArrayPathSelectionWidget::resetStyle() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QColor DataArrayPathSelectionWidget::getBorderColor(State state) +const QColor DataArrayPathSelectionWidget::getBorderColor(State state) const { SVStyle* style = SVStyle::Instance(); QColor color = "#000000"; @@ -1202,7 +1202,7 @@ const QColor DataArrayPathSelectionWidget::getBorderColor(State state) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPathSelectionWidget::State DataArrayPathSelectionWidget::getState() +DataArrayPathSelectionWidget::State DataArrayPathSelectionWidget::getState() const { return m_State; } @@ -1404,7 +1404,7 @@ QSize DataArrayPathSelectionWidget::sizeHint() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPathSelectionWidget::getPropertyName() +QString DataArrayPathSelectionWidget::getPropertyName() const { return m_PropName; } @@ -1420,7 +1420,7 @@ void DataArrayPathSelectionWidget::setPropertyName(QString propName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPathSelectionWidget::isCreatedPath(DataArrayPath path) +bool DataArrayPathSelectionWidget::isCreatedPath(const DataArrayPath& path) const { if(nullptr == m_Filter) { @@ -1455,7 +1455,7 @@ void DataArrayPathSelectionWidget::showContextMenu(const QPoint& pos) // ----------------------------------------------------------------------------- QMenu* DataArrayPathSelectionWidget::createSelectionMenu() { - if(nullptr == m_Filter || DataArrayPath::DataType::None == m_DataType) + if(nullptr == m_Filter || DataArrayPathHelper::DataType::None == m_DataType) { return nullptr; } @@ -1470,8 +1470,8 @@ QMenu* DataArrayPathSelectionWidget::createSelectionMenu() DataArrayPath path; // Populate Menu with DataContainers - QList containers = dca->getDataContainers(); - for(DataContainer::Pointer dc : containers) + DataContainerArray::Container containers = dca->getDataContainers(); + for(const auto& dc : containers) { path.setDataContainerName(dc->getName()); if(isCreatedPath(path)) @@ -1479,7 +1479,7 @@ QMenu* DataArrayPathSelectionWidget::createSelectionMenu() continue; } - if(DataArrayPath::DataType::DataContainer == m_DataType) + if(DataArrayPathHelper::DataType::DataContainer == m_DataType) { QAction* action = menu->addAction(dc->getName()); action->setEnabled(checkPathReqs(path)); @@ -1491,8 +1491,7 @@ QMenu* DataArrayPathSelectionWidget::createSelectionMenu() menu->addMenu(dcMenu); bool dcMenuEnabled = false; - DataContainer::AttributeMatrixMap_t attrMats = dc->getAttributeMatrices(); - for(AttributeMatrix::Pointer am : attrMats) + for(const AttributeMatrix::Pointer& am : dc->getChildren()) { path.setAttributeMatrixName(am->getName()); if(isCreatedPath(path)) @@ -1501,7 +1500,7 @@ QMenu* DataArrayPathSelectionWidget::createSelectionMenu() } // Populate DataContainer menu - if(DataArrayPath::DataType::AttributeMatrix == m_DataType) + if(DataArrayPathHelper::DataType::AttributeMatrix == m_DataType) { QAction* action = dcMenu->addAction(am->getName()); action->setEnabled(checkPathReqs(path)); @@ -1520,7 +1519,7 @@ QMenu* DataArrayPathSelectionWidget::createSelectionMenu() // Populate AttributeMatrix menu QList attrArrayNames = am->getAttributeArrayNames(); - for(QString daName : attrArrayNames) + for(const auto& daName : attrArrayNames) { path.setDataArrayName(daName); if(isCreatedPath(path)) diff --git a/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.h b/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.h index 38eb0982f9..2214da89ec 100644 --- a/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.h +++ b/Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.h @@ -70,101 +70,101 @@ class DataArrayPathSelectionWidget : public QToolButton }; Q_ENUM(State) - static const QPixmap CreateDragIcon(DataArrayPath path); - static const QPixmap CreateDragIcon(QString text, DataArrayPath::DataType dataType); - static const QPixmap CreateDragIcon(QString text, QColor backgroundColor); - static const QColor GetActiveColor(DataArrayPath::DataType type); - static const QColor GetCheckedColor(DataArrayPath::DataType type); - static bool CheckPathRequirements(AbstractFilter* filter, DataArrayPath path, DataContainerSelectionFilterParameter::RequirementType reqs); - static bool CheckPathRequirements(AbstractFilter* filter, DataArrayPath path, AttributeMatrixSelectionFilterParameter::RequirementType reqs); - static bool CheckPathRequirements(AbstractFilter* filter, DataArrayPath path, DataArraySelectionFilterParameter::RequirementType reqs); + static const QPixmap CreateDragIcon(const DataArrayPath& path); + static const QPixmap CreateDragIcon(const QString& text, DataArrayPathHelper::DataType dataType); + static const QPixmap CreateDragIcon(const QString& text, const QColor& backgroundColor); + static const QColor GetActiveColor(DataArrayPathHelper::DataType type); + static const QColor GetCheckedColor(DataArrayPathHelper::DataType type); + static bool CheckPathRequirements(AbstractFilter* filter, const DataArrayPath& path, const DataContainerSelectionFilterParameter::RequirementType& reqs); + static bool CheckPathRequirements(AbstractFilter* filter, const DataArrayPath& path, const AttributeMatrixSelectionFilterParameter::RequirementType& reqs); + static bool CheckPathRequirements(AbstractFilter* filter, const DataArrayPath& path, const DataArraySelectionFilterParameter::RequirementType& reqs); DataArrayPathSelectionWidget(QWidget* parent = nullptr); ~DataArrayPathSelectionWidget() override = default; - Q_PROPERTY(DataArrayPath::DataType PathType READ getDataType) + Q_PROPERTY(DataArrayPathHelper::DataType PathType READ getDataType) Q_PROPERTY(State State READ getState) /** * @brief Returns the type of DataArrayPath this widget can handle * @return */ - DataArrayPath::DataType getDataType(); + DataArrayPathHelper::DataType getDataType() const; /** * @brief Sets the DataContainer requirements and sets the DataType to DataContainer * @param dcReqs */ - void setDataContainerRequirements(DataContainerSelectionFilterParameter::RequirementType dcReqs); + void setDataContainerRequirements(const DataContainerSelectionFilterParameter::RequirementType& dcReqs); /** * @brief Sets the AttributeMatrix requirements and sets the DataType to AttributeMatrix * @param amReqs */ - void setAttrMatrixRequirements(AttributeMatrixSelectionFilterParameter::RequirementType amReqs); + void setAttrMatrixRequirements(const AttributeMatrixSelectionFilterParameter::RequirementType& amReqs); /** * @brief Sets the DataArray requirements and sets the DataType to DataArray * @param daReqs */ - void setDataArrayRequirements(DataArraySelectionFilterParameter::RequirementType daReqs); + void setDataArrayRequirements(const DataArraySelectionFilterParameter::RequirementType& daReqs); /** * @brief Returns the DataContainer requirements * @return */ - DataContainerSelectionFilterParameter::RequirementType getDataContainerRequirements(); + DataContainerSelectionFilterParameter::RequirementType getDataContainerRequirements() const; /** * @brief Returns the AttributeMatrix requirements * @return */ - AttributeMatrixSelectionFilterParameter::RequirementType getAttrMatrixRequirements(); + AttributeMatrixSelectionFilterParameter::RequirementType getAttrMatrixRequirements() const; /** * @brief Returns the DataArray requirements * @return */ - DataArraySelectionFilterParameter::RequirementType getDataArrayRequirements(); + DataArraySelectionFilterParameter::RequirementType getDataArrayRequirements() const; /** * @brief Checks the requirements for the current path * @return */ - bool checkCurrentPath(); + bool checkCurrentPath() const; /** * @brief Checks requirements against the given DataArrayPath * @param path * @return */ - bool checkPathReqs(DataArrayPath path); + bool checkPathReqs(const DataArrayPath& path) const; /** * @brief Checks DataContainer requirements against the given DataArrayPath * @param path * @return */ - bool checkDataContainerReqs(DataArrayPath path); + bool checkDataContainerReqs(const DataArrayPath& path) const; /** * @brief Checks AttributeMatrix requirements against the given DataArrayPath * @param path * @return */ - bool checkAttributeMatrixReqs(DataArrayPath path); + bool checkAttributeMatrixReqs(const DataArrayPath& path) const; /** * @brief Sets the DataArrayPath without checking requirements * @param dap */ - void setDataArrayPath(DataArrayPath dap); + void setDataArrayPath(const DataArrayPath& dap); /** * @brief Returns the DataArrayPath * @return */ - DataArrayPath getDataArrayPath(); + DataArrayPath getDataArrayPath() const; /** * @brief Sets the filter the selection widget operates on @@ -196,7 +196,7 @@ class DataArrayPathSelectionWidget : public QToolButton * @brief Returns the property name set for this widget * @return */ - QString getPropertyName(); + QString getPropertyName() const; /** * @brief Sets the property name @@ -270,7 +270,7 @@ public slots: * @brief Returns the current State * @return */ - State getState(); + State getState() const; /** * @brief Change the stylesheet based on the widget state @@ -329,7 +329,7 @@ public slots: * @param path * @return */ - bool checkDataArrayReqs(DataArrayPath path); + bool checkDataArrayReqs(const DataArrayPath& path) const; /** * @brief dragEnterEvent @@ -353,41 +353,41 @@ public slots: * @brief Creates and returns the header part of the tooltip HTML * @return */ - QString createTooltipHeader(); + QString createTooltipHeader() const; /** * @brief Creates and returns the closing part of the tooltip HTML * @return */ - QString createTooltipFooter(); + QString createTooltipFooter() const; /** * @brief Create the IGeometry::Type requirements part of the tooltip * @param geomTypes * @return */ - QString createGeomReqString(QVector geomTypes); + QString createGeomReqString(QVector geomTypes) const; /** * @brief Create the AttributeMatrix::Type requirements part of the tooltip * @param amTypes * @return */ - QString createAttrMatrixReqString(QVector amTypes); + QString createAttrMatrixReqString(QVector amTypes) const; /** * @brief Create the DataArray type requirements part of the tooltip * @param daTypes * @return */ - QString createDataArrayTypeString(QVector daTypes); + QString createDataArrayTypeString(QVector daTypes) const; /** * @brief Create the component requirements part of the tooltip * @param compDims * @return */ - QString createComponentReqString(QVector> compDims); + QString createComponentReqString(QVector> compDims) const; /** * @brief mouseMoveEvent @@ -399,7 +399,7 @@ public slots: * @brief Returns the color code for the given State * @param state */ - const QColor getBorderColor(State state); + const QColor getBorderColor(State state) const; /** * @brief Override the paint event to mark the DataType required @@ -418,7 +418,7 @@ public slots: * @param path * @return */ - bool isCreatedPath(DataArrayPath path); + bool isCreatedPath(const DataArrayPath& path) const; protected slots: /** @@ -441,7 +441,7 @@ private slots: void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE; private: - DataArrayPath::DataType m_DataType = DataArrayPath::DataType::None; + DataArrayPathHelper::DataType m_DataType = DataArrayPathHelper::DataType::None; State m_State = State::Normal; AbstractFilter* m_Filter = nullptr; DataContainerSelectionFilterParameter::RequirementType m_DataContainerReqs; diff --git a/Source/SVWidgetsLib/Widgets/DataContainerArrayWidget.cpp b/Source/SVWidgetsLib/Widgets/DataContainerArrayWidget.cpp index 0ed415617b..a9dd99b4e7 100644 --- a/Source/SVWidgetsLib/Widgets/DataContainerArrayWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/DataContainerArrayWidget.cpp @@ -156,19 +156,16 @@ void DataContainerArrayWidget::updateView() QStandardItem* rootItem = model->invisibleRootItem(); // Loop over the data containers until we find the proper data container - QList containers = dca->getDataContainers(); + DataContainerArray::Container containers = dca->getDataContainers(); - QListIterator containerIter(containers); // QStringList dcList; int row0 = 0; - while(containerIter.hasNext()) + for(DataContainer::Pointer dc : containers) { - DataContainer::Pointer dc = containerIter.next(); - QStandardItem* dcItem = new QStandardItem(dc->getName()); rootItem->appendRow(dcItem); - dcItem->setData(dc->getInfoString(SIMPL::HtmlFormat), Qt::UserRole + 1); + dcItem->setData(dc->getInfoString(SIMPL::ToolTipFormat), Qt::UserRole + 1); if(!path.empty() && dc->getName().compare(path[0]) == 0) { @@ -176,18 +173,14 @@ void DataContainerArrayWidget::updateView() } // We found the proper Data Container, now populate the AttributeMatrix List - DataContainer::AttributeMatrixMap_t attrMats = dc->getAttributeMatrices(); - QMapIterator attrMatsIter(attrMats); int row1 = 0; - while(attrMatsIter.hasNext()) + for(const auto& am : dc->getChildren()) { - attrMatsIter.next(); - QString amName = attrMatsIter.key(); - AttributeMatrix::Pointer am = attrMatsIter.value(); + QString amName = am->getName(); QStandardItem* amItem = new QStandardItem(am->getName()); dcItem->appendRow(amItem); - amItem->setData(am->getInfoString(SIMPL::HtmlFormat), Qt::UserRole + 1); + amItem->setData(am->getInfoString(SIMPL::ToolTipFormat), Qt::UserRole + 1); if(path.size() > 1 && am->getName().compare(path[1]) == 0) { @@ -205,7 +198,7 @@ void DataContainerArrayWidget::updateView() QStandardItem* aaItem = new QStandardItem(attrArrayName); amItem->appendRow(aaItem); - aaItem->setData(attrArray->getInfoString(SIMPL::HtmlFormat), Qt::UserRole + 1); + aaItem->setData(attrArray->getInfoString(SIMPL::ToolTipFormat), Qt::UserRole + 1); if(path.size() > 2 && attrArrayName.compare(path[2]) == 0) { diff --git a/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.cpp b/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.cpp index d47081798c..7a3c8d3793 100644 --- a/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.cpp +++ b/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.cpp @@ -85,10 +85,10 @@ void DataStructureItemDelegate::createNewPathIcons() QImage daImage = baseImage.copy(); QImage invalidImage = baseImage.copy(); - QColor invalidColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPath::DataType::None); - QColor dcColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPath::DataType::DataContainer); - QColor amColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPath::DataType::AttributeMatrix); - QColor daColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPath::DataType::DataArray); + QColor invalidColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPathHelper::DataType::None); + QColor dcColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPathHelper::DataType::DataContainer); + QColor amColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPathHelper::DataType::AttributeMatrix); + QColor daColor = DataArrayPathSelectionWidget::GetActiveColor(DataArrayPathHelper::DataType::DataArray); int height = baseImage.height(); int width = baseImage.width(); @@ -160,7 +160,7 @@ void DataStructureItemDelegate::setActiveFilter(AbstractFilter::Pointer filter) void DataStructureItemDelegate::setViewRequirements(DataContainerSelectionFilterParameter::RequirementType reqs) { m_DcReqs = reqs; - m_ReqType = DataArrayPath::DataType::DataContainer; + m_ReqType = DataArrayPathHelper::DataType::DataContainer; } // ----------------------------------------------------------------------------- @@ -169,7 +169,7 @@ void DataStructureItemDelegate::setViewRequirements(DataContainerSelectionFilter void DataStructureItemDelegate::setViewRequirements(AttributeMatrixSelectionFilterParameter::RequirementType reqs) { m_AmReqs = reqs; - m_ReqType = DataArrayPath::DataType::AttributeMatrix; + m_ReqType = DataArrayPathHelper::DataType::AttributeMatrix; } // ----------------------------------------------------------------------------- @@ -178,7 +178,7 @@ void DataStructureItemDelegate::setViewRequirements(AttributeMatrixSelectionFilt void DataStructureItemDelegate::setViewRequirements(DataArraySelectionFilterParameter::RequirementType reqs) { m_DaReqs = reqs; - m_ReqType = DataArrayPath::DataType::DataArray; + m_ReqType = DataArrayPathHelper::DataType::DataArray; } // ----------------------------------------------------------------------------- @@ -186,7 +186,7 @@ void DataStructureItemDelegate::setViewRequirements(DataArraySelectionFilterPara // ----------------------------------------------------------------------------- void DataStructureItemDelegate::clearRequirements() { - m_ReqType = DataArrayPath::DataType::None; + m_ReqType = DataArrayPathHelper::DataType::None; } // ----------------------------------------------------------------------------- @@ -194,7 +194,7 @@ void DataStructureItemDelegate::clearRequirements() // ----------------------------------------------------------------------------- bool DataStructureItemDelegate::isFiltered() { - return m_ReqType != DataArrayPath::DataType::None; + return m_ReqType != DataArrayPathHelper::DataType::None; } // ----------------------------------------------------------------------------- @@ -305,7 +305,7 @@ void DataStructureItemDelegate::paint(QPainter* painter, const QStyleOptionViewI mousePos = dynamic_cast(parent())->mapFromGlobal(mousePos); } - bool filterData = (m_ReqType != DataArrayPath::DataType::None); + bool filterData = (m_ReqType != DataArrayPathHelper::DataType::None); bool isCreatedPath = std::find(m_CreatedPaths.begin(), m_CreatedPaths.end(), path) != m_CreatedPaths.end(); // Check for a corresponding icon @@ -423,13 +423,13 @@ void DataStructureItemDelegate::paint(QPainter* painter, const QStyleOptionViewI switch(path.getDataType()) { - case DataArrayPath::DataType::DataContainer: + case DataArrayPathHelper::DataType::DataContainer: m_CreatedDcIcon.paint(painter, imgRect); break; - case DataArrayPath::DataType::AttributeMatrix: + case DataArrayPathHelper::DataType::AttributeMatrix: m_CreatedAmIcon.paint(painter, imgRect); break; - case DataArrayPath::DataType::DataArray: + case DataArrayPathHelper::DataType::DataArray: m_CreatedDaIcon.paint(painter, imgRect); break; default: @@ -492,11 +492,11 @@ bool DataStructureItemDelegate::pathMatchesReqs(DataArrayPath path) const { switch(m_ReqType) { - case DataArrayPath::DataType::DataContainer: + case DataArrayPathHelper::DataType::DataContainer: return DataArrayPathSelectionWidget::CheckPathRequirements(m_Filter.get(), path, m_DcReqs); - case DataArrayPath::DataType::AttributeMatrix: + case DataArrayPathHelper::DataType::AttributeMatrix: return DataArrayPathSelectionWidget::CheckPathRequirements(m_Filter.get(), path, m_AmReqs); - case DataArrayPath::DataType::DataArray: + case DataArrayPathHelper::DataType::DataArray: return DataArrayPathSelectionWidget::CheckPathRequirements(m_Filter.get(), path, m_DaReqs); default: return false; diff --git a/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.h b/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.h index 4c07303a48..c40430e94e 100755 --- a/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.h +++ b/Source/SVWidgetsLib/Widgets/DataStructureItemDelegate.h @@ -131,7 +131,7 @@ class DataStructureItemDelegate : public QStyledItemDelegate AbstractFilter::Pointer m_Filter = nullptr; std::list m_CreatedPaths; - DataArrayPath::DataType m_ReqType = DataArrayPath::DataType::None; + DataArrayPathHelper::DataType m_ReqType = DataArrayPathHelper::DataType::None; DataContainerSelectionFilterParameter::RequirementType m_DcReqs; AttributeMatrixSelectionFilterParameter::RequirementType m_AmReqs; DataArraySelectionFilterParameter::RequirementType m_DaReqs; diff --git a/Source/SVWidgetsLib/Widgets/DataStructureWidget.cpp b/Source/SVWidgetsLib/Widgets/DataStructureWidget.cpp index a17f7e25d4..6d47b3ba5e 100644 --- a/Source/SVWidgetsLib/Widgets/DataStructureWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/DataStructureWidget.cpp @@ -270,14 +270,11 @@ void DataStructureWidget::refreshData() } // Loop over the data containers - QList containers = m_Dca->getDataContainers(); + DataContainerArray::Container containers = m_Dca->getDataContainers(); QStandardItem* rootItem = model->invisibleRootItem(); - QListIterator containerIter(containers); - while(containerIter.hasNext()) + for(DataContainer::Pointer dc : containers) { - DataContainer::Pointer dc = containerIter.next(); - QStandardItem* dcItem = findChildByName(rootItem, dc->getName(), 0); if(dcItem == nullptr) { @@ -286,8 +283,8 @@ void DataStructureWidget::refreshData() // dcItem->setBackground(QBrush(QColor(154, 136, 255))); m_Ui->dataBrowserTreeView->expand(dcItem->index()); } - dcItem->setData(dc->getInfoString(SIMPL::HtmlFormat), Qt::UserRole + 1); - dcItem->setToolTip(dc->getInfoString(SIMPL::HtmlFormat)); + dcItem->setData(dc->getInfoString(SIMPL::ToolTipFormat), Qt::UserRole + 1); + dcItem->setToolTip(dc->getInfoString(SIMPL::ToolTipFormat)); if(dc->getGeometry()) { switch(dc->getGeometry()->getGeometryType()) @@ -332,14 +329,8 @@ void DataStructureWidget::refreshData() } // We found the proper Data Container, now populate the AttributeMatrix List - DataContainer::AttributeMatrixMap_t attrMats = dc->getAttributeMatrices(); - QMapIterator attrMatsIter(attrMats); - while(attrMatsIter.hasNext()) + for(const auto& am : dc->getChildren()) { - attrMatsIter.next(); - // QString amName = attrMatsIter.key(); - AttributeMatrix::Pointer am = attrMatsIter.value(); - QStandardItem* amItem = findChildByName(dcItem, am->getName(), 0); if(amItem == nullptr) { @@ -348,8 +339,8 @@ void DataStructureWidget::refreshData() dcItem->appendRow(amItem); m_Ui->dataBrowserTreeView->expand(amItem->index()); } - amItem->setData(am->getInfoString(SIMPL::HtmlFormat), Qt::UserRole + 1); - amItem->setToolTip(am->getInfoString(SIMPL::HtmlFormat)); + amItem->setData(am->getInfoString(SIMPL::ToolTipFormat), Qt::UserRole + 1); + amItem->setToolTip(am->getInfoString(SIMPL::ToolTipFormat)); amItem->setIcon(QIcon()); if(path.size() > 1 && am->getName().compare(path[1]) == 0) @@ -376,8 +367,8 @@ void DataStructureWidget::refreshData() // { // aaItem->setBackground(QColor(255, 255, 255)); // } - aaItem->setData(attrArray->getInfoString(SIMPL::HtmlFormat), Qt::UserRole + 1); - aaItem->setToolTip(attrArray->getInfoString(SIMPL::HtmlFormat)); + aaItem->setData(attrArray->getInfoString(SIMPL::ToolTipFormat), Qt::UserRole + 1); + aaItem->setToolTip(attrArray->getInfoString(SIMPL::ToolTipFormat)); aaItem->setIcon(QIcon()); if(path.size() > 2 && attrArrayName.compare(path[2]) == 0) @@ -454,8 +445,8 @@ QStandardItem* DataStructureWidget::findChildByName(QStandardItem* rootItem, con // ----------------------------------------------------------------------------- QStandardItem* DataStructureWidget::findItemByPath(DataArrayPath path) { - DataArrayPath::DataType dataType = path.getDataType(); - if(dataType == DataArrayPath::DataType::None) + DataArrayPathHelper::DataType dataType = path.getDataType(); + if(dataType == DataArrayPathHelper::DataType::None) { return nullptr; } @@ -470,14 +461,14 @@ QStandardItem* DataStructureWidget::findItemByPath(DataArrayPath path) QStandardItem* rootItem = model->invisibleRootItem(); QStandardItem* targetItem = nullptr; QStandardItem* dcItem = findChildByName(rootItem, path.getDataContainerName(), 0); - if(dataType == DataArrayPath::DataType::DataContainer) + if(dataType == DataArrayPathHelper::DataType::DataContainer) { targetItem = dcItem; } else { QStandardItem* amItem = findChildByName(dcItem, path.getAttributeMatrixName(), 0); - if(dataType == DataArrayPath::DataType::AttributeMatrix) + if(dataType == DataArrayPathHelper::DataType::AttributeMatrix) { targetItem = amItem; } diff --git a/Source/SVWidgetsLib/Widgets/DataStructureWidget.h b/Source/SVWidgetsLib/Widgets/DataStructureWidget.h index a8d0a736dd..a366f8677e 100755 --- a/Source/SVWidgetsLib/Widgets/DataStructureWidget.h +++ b/Source/SVWidgetsLib/Widgets/DataStructureWidget.h @@ -42,7 +42,6 @@ #include #include "SIMPLib/Common/IObserver.h" -#include "SIMPLib/Common/PipelineMessage.h" #include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" diff --git a/Source/SVWidgetsLib/Widgets/FilterInputWidget.cpp b/Source/SVWidgetsLib/Widgets/FilterInputWidget.cpp index 99feeae5a4..2d96b6c647 100644 --- a/Source/SVWidgetsLib/Widgets/FilterInputWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/FilterInputWidget.cpp @@ -289,12 +289,12 @@ void FilterInputWidget::layoutWidgets(AbstractFilter* filter) // Get the FilterWidgetManagere instance so we can instantiate new FilterParameterWidgets FilterWidgetManager* fwm = FilterWidgetManager::Instance(); // Get a list of all the filterParameters from the filter. - QVector filterParameters = filter->getFilterParameters(); + FilterParameterVectorType filterParameters = filter->getFilterParameters(); // Create all the FilterParameterWidget objects that can be displayed where ever the developer needs bool addSpacer = true; int pCount = 0, rCount = 0, cCount = 0; - for(QVector::iterator iter = filterParameters.begin(); iter != filterParameters.end(); ++iter) + for(FilterParameterVectorType::iterator iter = filterParameters.begin(); iter != filterParameters.end(); ++iter) { FilterParameter* parameter = (*iter).get(); @@ -504,10 +504,10 @@ void FilterInputWidget::validateFileSystemFilterParameter(FilterParameter* param // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterInputWidget::linkConditionalWidgets(QVector& filterParameters) +void FilterInputWidget::linkConditionalWidgets(FilterParameterVectorType& filterParameters) { // Figure out if we have any "Linked Boolean Widgets" to hook up to other widgets - for(QVector::iterator iter = filterParameters.begin(); iter != filterParameters.end(); ++iter) + for(FilterParameterVectorType::iterator iter = filterParameters.begin(); iter != filterParameters.end(); ++iter) { FilterParameter::Pointer filterParameter = (*iter); LinkedBooleanFilterParameter::Pointer filterParameterPtr = std::dynamic_pointer_cast(filterParameter); diff --git a/Source/SVWidgetsLib/Widgets/FilterInputWidget.h b/Source/SVWidgetsLib/Widgets/FilterInputWidget.h index f155993e7b..ed28d07789 100755 --- a/Source/SVWidgetsLib/Widgets/FilterInputWidget.h +++ b/Source/SVWidgetsLib/Widgets/FilterInputWidget.h @@ -131,7 +131,7 @@ class SVWidgetsLib_EXPORT FilterInputWidget : public QWidget * @brief linkConditionalWidgets * @param filterParameters */ - void linkConditionalWidgets(QVector& filterParameters); + void linkConditionalWidgets(FilterParameterVectorType& filterParameters); public: FilterInputWidget(const FilterInputWidget&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SVWidgetsLib/Widgets/FilterLibraryToolboxWidget.cpp b/Source/SVWidgetsLib/Widgets/FilterLibraryToolboxWidget.cpp index 8d8e242c05..71df7ba071 100644 --- a/Source/SVWidgetsLib/Widgets/FilterLibraryToolboxWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/FilterLibraryToolboxWidget.cpp @@ -141,9 +141,8 @@ void FilterLibraryToolboxWidget::refreshFilterGroups() { iter.next(); IFilterFactory::Pointer factory = iter.value(); - AbstractFilter::Pointer filter = factory->create(); QTreeWidgetItem* filterTreeItem = new QTreeWidgetItem(filterSubGroup); - filterTreeItem->setText(0, filter->getHumanLabel()); + filterTreeItem->setText(0, factory->getFilterHumanLabel()); #if 0 if(groupName.compare(SIMPL::FilterGroups::Unsupported) == 0) @@ -170,8 +169,8 @@ void FilterLibraryToolboxWidget::refreshFilterGroups() filterTreeItem->setIcon(0, icon); #endif filterTreeItem->setData(0, Qt::UserRole, QVariant(FILTER_NODE_TYPE)); - filterTreeItem->setData(0, Qt::UserRole + 1, QVariant(filter->getNameOfClass())); - filterTreeItem->setToolTip(0, filter->generateHtmlSummary()); + filterTreeItem->setData(0, Qt::UserRole + 1, QVariant(factory->getFilterClassName())); + filterTreeItem->setToolTip(0, factory->getFilterHtmlSummary()); } } } diff --git a/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.cpp b/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.cpp index 7785b3dcc0..957f2f8081 100644 --- a/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.cpp @@ -168,14 +168,7 @@ void FilterListToolboxWidget::loadFilterList() { continue; } - - AbstractFilter::Pointer filter = factory->create(); - if(nullptr == filter.get()) - { - continue; - } - - filterListView->addFilter(filter); + filterListView->addFilter(factory); } filterListView->setSortingEnabled(true); @@ -202,7 +195,7 @@ void FilterListToolboxWidget::searchFilters(QString text) // The user is typing something in the search box so lets search the filter class name and human label // int listWidgetSize = m_LoadedFilters.size(); QMapIterator iter(m_LoadedFilters); - std::vector filters; + std::vector filters; while(iter.hasNext()) { iter.next(); @@ -211,18 +204,11 @@ void FilterListToolboxWidget::searchFilters(QString text) { continue; } - - AbstractFilter::Pointer filter = factory->create(); - if (filter == nullptr) - { - continue; - } - - filters.push_back(filter); + filters.push_back(factory); } QStringList searchTokens = text.split(' '); - QSet addedFiltersSet; + QSet addedFiltersSet; matchFiltersToSearchGroup(filters, addedFiltersSet, searchTokens, FilterListView::SearchGroup::HumanLabel); matchFiltersToSearchGroup(filters, addedFiltersSet, searchTokens, FilterListView::SearchGroup::GroupName); @@ -238,73 +224,69 @@ void FilterListToolboxWidget::searchFilters(QString text) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterListToolboxWidget::matchFiltersToSearchGroup(std::vector filters, QSet &addedFiltersSet, QStringList searchTokens, FilterListView::SearchGroup searchGroup) +void FilterListToolboxWidget::matchFiltersToSearchGroup(std::vector factories, QSet& addedFiltersSet, const QStringList& searchTokens, + FilterListView::SearchGroup searchGroup) { - QMap wordCountMap; - QMultiMap relevanceMap; + QMap wordCountMap; + QMultiMap relevanceMap; - for (size_t i = 0; i < filters.size(); i++) + for(const auto& factory : factories) { - AbstractFilter::Pointer filter = filters[i]; + int wordCount = getMatchingWordCountForFilter(searchTokens, factory, searchGroup); + int relevance = getMatchingRelevanceForFilter(searchTokens, factory, searchGroup); - int wordCount = getMatchingWordCountForFilter(searchTokens, filter, searchGroup); - int relevance = getMatchingRelevanceForFilter(searchTokens, filter, searchGroup); - - if(!wordCountMap.contains(filter) && wordCount > 0) + if(!wordCountMap.contains(factory) && wordCount > 0) { - wordCountMap.insert(filter, wordCount); - relevanceMap.insert(relevance, filter); + wordCountMap.insert(factory, wordCount); + relevanceMap.insert(relevance, factory); } } // Match according to "Exact Phrase" if(m_ActionExactPhrase->isChecked()) { - QList filterList = relevanceMap.values(searchTokens.size()); - for(QList::iterator iter = filterList.begin(); iter != filterList.end(); ++iter) + QList filterList = relevanceMap.values(searchTokens.size()); + for(const auto& factory : filterList) { - AbstractFilter::Pointer filter = *iter; - // Do not display results that have the exact phrase in the middle or end of the search phrase QString searchPhrase = searchTokens.join(' '); - if(filter->getHumanLabel().startsWith(searchPhrase)) + if(factory->getFilterHumanLabel().startsWith(searchPhrase)) { - filterListView->addFilter(filter, searchGroup); - addedFiltersSet.insert(filter.get()); + filterListView->addFilter(factory, searchGroup); + addedFiltersSet.insert(factory.get()); } } } // Match according to "All Words" else if(m_ActionAllWords->isChecked()) { - QList filterList = wordCountMap.keys(searchTokens.size()); - QMapIterator iter(relevanceMap); + QList factoryList = wordCountMap.keys(searchTokens.size()); + QMapIterator iter(relevanceMap); iter.toBack(); while(iter.hasPrevious()) { iter.previous(); - AbstractFilter::Pointer filter = iter.value(); + IFilterFactory::Pointer factory = iter.value(); - if(filterList.contains(filter)) + if(factoryList.contains(factory)) { - filterListView->addFilter(filter, searchGroup); - addedFiltersSet.insert(filter.get()); + filterListView->addFilter(factory, searchGroup); + addedFiltersSet.insert(factory.get()); } } } // Match according to "Any Words" else { - // QList filterListView = wordCountMap.keys(); - QMapIterator iter(relevanceMap); + QMapIterator iter(relevanceMap); iter.toBack(); while(iter.hasPrevious()) { iter.previous(); - AbstractFilter::Pointer filter = iter.value(); + IFilterFactory::Pointer factory = iter.value(); - filterListView->addFilter(filter, searchGroup); - addedFiltersSet.insert(filter.get()); + filterListView->addFilter(factory, searchGroup); + addedFiltersSet.insert(factory.get()); } } } @@ -312,34 +294,34 @@ void FilterListToolboxWidget::matchFiltersToSearchGroup(std::vectorgetHumanLabel(); + searchGroupTerm = factory->getFilterHumanLabel(); break; } case FilterListView::SearchGroup::GroupName: { - searchGroupTerm = filter->getGroupName(); + searchGroupTerm = factory->getFilterGroup(); break; } case FilterListView::SearchGroup::SubgroupName: { - searchGroupTerm = filter->getSubGroupName(); + searchGroupTerm = factory->getFilterSubGroup(); break; } case FilterListView::SearchGroup::BrandingName: { - searchGroupTerm = filter->getBrandingString(); + searchGroupTerm = factory->getBrandingString(); break; } case FilterListView::SearchGroup::CompiledLibraryName: { - searchGroupTerm = filter->getCompiledLibraryName(); + searchGroupTerm = factory->getCompiledLibraryName(); break; } case FilterListView::SearchGroup::Keywords: @@ -367,34 +349,34 @@ int FilterListToolboxWidget::getMatchingWordCountForFilter(QStringList searchTok // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int FilterListToolboxWidget::getMatchingRelevanceForFilter(QStringList searchTokens, AbstractFilter::Pointer filter, FilterListView::SearchGroup searchGroup) +int FilterListToolboxWidget::getMatchingRelevanceForFilter(QStringList searchTokens, IFilterFactory::Pointer factory, FilterListView::SearchGroup searchGroup) { QString searchGroupTerm = ""; switch(searchGroup) { case FilterListView::SearchGroup::HumanLabel: { - searchGroupTerm = filter->getHumanLabel(); + searchGroupTerm = factory->getFilterHumanLabel(); break; } case FilterListView::SearchGroup::GroupName: { - searchGroupTerm = filter->getGroupName(); + searchGroupTerm = factory->getFilterGroup(); break; } case FilterListView::SearchGroup::SubgroupName: { - searchGroupTerm = filter->getSubGroupName(); + searchGroupTerm = factory->getFilterSubGroup(); break; } case FilterListView::SearchGroup::BrandingName: { - searchGroupTerm = filter->getBrandingString(); + searchGroupTerm = factory->getBrandingString(); break; } case FilterListView::SearchGroup::CompiledLibraryName: { - searchGroupTerm = filter->getCompiledLibraryName(); + searchGroupTerm = factory->getCompiledLibraryName(); break; } case FilterListView::SearchGroup::Keywords: @@ -529,12 +511,12 @@ QList FilterListToolboxWidget::getSearchActionList() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QMap FilterListToolboxWidget::getHumanNameMap(QList list) +QMap FilterListToolboxWidget::getHumanNameMap(const QList& list) { - QMap map; - for(int i = 0; i < list.size(); i++) + QMap map; + for(const auto& factory : list) { - map.insert(list[i]->getHumanLabel(), list[i]); + map.insert(factory->getFilterHumanLabel(), factory); } return map; diff --git a/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.h b/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.h index a5e81feec3..89f59562f4 100755 --- a/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.h +++ b/Source/SVWidgetsLib/Widgets/FilterListToolboxWidget.h @@ -44,8 +44,9 @@ #include #include "SIMPLib/Filtering/FilterManager.h" -#include "SVWidgetsLib/SVWidgetsLib.h" +#include "SIMPLib/Filtering/IFilterFactory.hpp" +#include "SVWidgetsLib/SVWidgetsLib.h" #include "SVWidgetsLib/QtSupport/QtSSettings.h" #include "ui_FilterListToolboxWidget.h" @@ -132,13 +133,13 @@ class SVWidgetsLib_EXPORT FilterListToolboxWidget : public QWidget, private Ui:: FilterManager::Collection m_LoadedFilters; - QMap getHumanNameMap(QList list); + QMap getHumanNameMap(const QList& list); - void matchFiltersToSearchGroup(std::vector filters, QSet &addedFiltersSet, QStringList searchTokens, FilterListView::SearchGroup searchGroup); + void matchFiltersToSearchGroup(std::vector filters, QSet& addedFiltersSet, const QStringList& searchTokens, FilterListView::SearchGroup searchGroup); - int getMatchingWordCountForFilter(QStringList searchTokens, AbstractFilter::Pointer filter, FilterListView::SearchGroup searchGroup); + int getMatchingWordCountForFilter(QStringList searchTokens, IFilterFactory::Pointer filter, FilterListView::SearchGroup searchGroup); - int getMatchingRelevanceForFilter(QStringList searchTokens, AbstractFilter::Pointer filter, FilterListView::SearchGroup searchGroup); + int getMatchingRelevanceForFilter(QStringList searchTokens, IFilterFactory::Pointer filter, FilterListView::SearchGroup searchGroup); public: FilterListToolboxWidget(const FilterListToolboxWidget&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SVWidgetsLib/Widgets/FilterListView.cpp b/Source/SVWidgetsLib/Widgets/FilterListView.cpp index 78df7c597b..430839583b 100644 --- a/Source/SVWidgetsLib/Widgets/FilterListView.cpp +++ b/Source/SVWidgetsLib/Widgets/FilterListView.cpp @@ -93,15 +93,15 @@ void FilterListView::connectSignalsSlots() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterListView::addFilter(AbstractFilter::Pointer filter) +void FilterListView::addFilter(const IFilterFactory::Pointer& factory) { - addFilter(filter, QModelIndex()); + addFilter(factory, QModelIndex()); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterListView::addFilter(AbstractFilter::Pointer filter, SearchGroup group) +void FilterListView::addFilter(const IFilterFactory::Pointer& factory, SearchGroup group) { if(!m_SearchGroupIndexMap.contains(group)) { @@ -109,19 +109,19 @@ void FilterListView::addFilter(AbstractFilter::Pointer filter, SearchGroup group } QModelIndex groupIndex = m_SearchGroupIndexMap[group]; - addFilter(filter, groupIndex); + addFilter(factory, groupIndex); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterListView::addFilter(AbstractFilter::Pointer filter, const QModelIndex &parent) +void FilterListView::addFilter(const IFilterFactory::Pointer& factory, const QModelIndex& parent) { - QString humanName = filter->getHumanLabel(); + QString humanName = factory->getFilterHumanLabel(); QString iconName(":/Groups/"); - iconName.append(filter->getGroupName()); + iconName.append(factory->getFilterGroup()); - QIcon icon = SVStyle::Instance()->IconForGroup(filter->getGroupName()); + QIcon icon = SVStyle::Instance()->IconForGroup(factory->getFilterGroup()); // Create the QListWidgetItem and add it to the filterListView FilterListModel* model = getFilterListModel(); @@ -137,10 +137,10 @@ void FilterListView::addFilter(AbstractFilter::Pointer filter, const QModelIndex // Set an "internal" QString that is the name of the filter. We need this value // when the item is clicked in order to retreive the Filter Widget from the // filter widget manager. - model->setData(index, filter->getNameOfClass(), FilterListModel::Roles::ClassNameRole); + model->setData(index, factory->getFilterClassName(), FilterListModel::Roles::ClassNameRole); // Allow a basic mouse hover tool tip that gives some summary information on the filter. - model->setData(index, filter->generateHtmlSummary(), Qt::ToolTipRole); + model->setData(index, factory->getFilterHtmlSummary(), Qt::ToolTipRole); } // ----------------------------------------------------------------------------- @@ -213,7 +213,7 @@ QModelIndex FilterListView::findIndexByName(const QString &name) } } - return QModelIndex(); + return {}; } // ----------------------------------------------------------------------------- @@ -327,9 +327,9 @@ QModelIndex FilterListView::findNextSelectableIndex() return selectedIndexes[0]; } - return model->index(selectedIndexes[0].row() + 1, FilterListModel::Column::Contents, parent); + return model->index(selectedIndexes[0].row() + 1, FilterListModel::Column::Contents, parent); - return QModelIndex(); + return {}; } // ----------------------------------------------------------------------------- @@ -365,7 +365,7 @@ QModelIndex FilterListView::findPreviousSelectableIndex() return model->index(selectedIndexes[0].row() - 1, FilterListModel::Column::Contents, parent); } - return QModelIndex(); + return {}; } // ----------------------------------------------------------------------------- @@ -386,7 +386,7 @@ void FilterListView::mousePressEvent(QMouseEvent* event) // ----------------------------------------------------------------------------- void FilterListView::mouseMoveEvent(QMouseEvent* event) { - if(event->buttons() & Qt::LeftButton) + if((event->buttons() & Qt::LeftButton) != 0) { int distance = (event->pos() - m_StartPos).manhattanLength(); if(distance >= QApplication::startDragDistance()) diff --git a/Source/SVWidgetsLib/Widgets/FilterListView.h b/Source/SVWidgetsLib/Widgets/FilterListView.h index 45821f7def..043bc36efc 100755 --- a/Source/SVWidgetsLib/Widgets/FilterListView.h +++ b/Source/SVWidgetsLib/Widgets/FilterListView.h @@ -40,7 +40,7 @@ #include #include "SIMPLib/Filtering/AbstractFilter.h" - +#include "SIMPLib/Filtering/IFilterFactory.hpp" #include "SVWidgetsLib/SVWidgetsLib.h" class FilterListModel; @@ -78,14 +78,14 @@ class SVWidgetsLib_EXPORT FilterListView : public QTreeView * @brief addFilter * @param filter */ - void addFilter(AbstractFilter::Pointer filter); + void addFilter(const IFilterFactory::Pointer& factory); /** * @brief addFilter * @param filter * @param group */ - void addFilter(AbstractFilter::Pointer filter, SearchGroup group); + void addFilter(const IFilterFactory::Pointer& factory, SearchGroup group); /** * @brief addGroup @@ -150,7 +150,7 @@ class SVWidgetsLib_EXPORT FilterListView : public QTreeView * @param filter * @param parent */ - void addFilter(AbstractFilter::Pointer filter, const QModelIndex &parent); + void addFilter(const IFilterFactory::Pointer &factory, const QModelIndex &parent); /** * @brief connectSignalsSlots diff --git a/Source/SVWidgetsLib/Widgets/ImportASCIIDataWizard/DataFormatPage.cpp b/Source/SVWidgetsLib/Widgets/ImportASCIIDataWizard/DataFormatPage.cpp index 86de250191..8782b91b21 100644 --- a/Source/SVWidgetsLib/Widgets/ImportASCIIDataWizard/DataFormatPage.cpp +++ b/Source/SVWidgetsLib/Widgets/ImportASCIIDataWizard/DataFormatPage.cpp @@ -450,17 +450,14 @@ void DataFormatPage::createAMSelectionMenu() // Get the DataContainerArray object // Loop over the data containers until we find the proper data container - QList containers = dca->getDataContainers(); + DataContainerArray::Container containers = dca->getDataContainers(); QVector daTypes;// = m_FilterParameter->getDefaultAttributeArrayTypes(); QVector> cDims;// = m_FilterParameter->getDefaultComponentDimensions(); QVector amTypes;// = m_FilterParameter->getDefaultAttributeMatrixTypes(); IGeometry::Types geomTypes;// = m_FilterParameter->getDefaultGeometryTypes(); - QListIterator containerIter(containers); - while(containerIter.hasNext()) + for(DataContainer::Pointer dc : containers) { - DataContainer::Pointer dc = containerIter.next(); - IGeometry::Pointer geom = IGeometry::NullPointer(); IGeometry::Type geomType = IGeometry::Type::Unknown; if(nullptr != dc.get()) @@ -481,13 +478,9 @@ void DataFormatPage::createAMSelectionMenu() } // We found the proper Data Container, now populate the AttributeMatrix List - DataContainer::AttributeMatrixMap_t attrMats = dc->getAttributeMatrices(); - QMapIterator attrMatsIter(attrMats); - while(attrMatsIter.hasNext()) + for(const auto& am : dc->getChildren()) { - attrMatsIter.next(); - QString amName = attrMatsIter.key(); - AttributeMatrix::Pointer am = attrMatsIter.value(); + QString amName = am->getName(); QAction* amAction = dcMenu->addAction(amName); // dcMenu owns the created action // QAction* action = new QAction(amName, dcMenu); @@ -539,14 +532,11 @@ void DataFormatPage::createDCSelectionMenu() // Get the DataContainerArray object // Loop over the data containers until we find the proper data container - QList containers = dca->getDataContainers(); + DataContainerArray::Container containers = dca->getDataContainers(); IGeometry::Types geomTypes; - QListIterator containerIter(containers); - while(containerIter.hasNext()) + for(DataContainer::Pointer dc : containers) { - DataContainer::Pointer dc = containerIter.next(); - IGeometry::Pointer geom = IGeometry::NullPointer(); IGeometry::Type geomType = IGeometry::Type::Unknown; if(nullptr != dc.get()) diff --git a/Source/SVWidgetsLib/Widgets/IssuesWidget.cpp b/Source/SVWidgetsLib/Widgets/IssuesWidget.cpp index 66c82c3cf0..1d2f7617e6 100644 --- a/Source/SVWidgetsLib/Widgets/IssuesWidget.cpp +++ b/Source/SVWidgetsLib/Widgets/IssuesWidget.cpp @@ -46,14 +46,7 @@ #include "SVWidgetsLib/QtSupport/QtSSettings.h" #include "SVWidgetsLib/SVWidgetsLib.h" #include "SVWidgetsLib/Widgets/SVStyle.h" - -#ifdef SIMPL_USE_MKDOCS -#define URL_GENERATOR QtSDocServer -#include "SVWidgetsLib/QtSupport/QtSDocServer.h" -#else -#define URL_GENERATOR QtSHelpUrlGenerator -#include "SVWidgetsLib/QtSupport/QtSHelpUrlGenerator.h" -#endif +#include "SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.h" #include "ui_IssuesWidget.h" @@ -151,7 +144,7 @@ void IssuesWidget::clearIssues() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IssuesWidget::processPipelineMessage(const PipelineMessage& msg) +void IssuesWidget::processPipelineMessage(const AbstractMessage::Pointer& msg) { m_CachedMessages.push_back(msg); } @@ -161,110 +154,19 @@ void IssuesWidget::processPipelineMessage(const PipelineMessage& msg) // ----------------------------------------------------------------------------- void IssuesWidget::displayCachedMessages() { - // Figure out how many error and warning messages that we have. We ignore the rest int count = 0; int warnCount = 0; int errCount = 0; - for(int i = 0; i < m_CachedMessages.size(); i++) - { - PipelineMessage msg = m_CachedMessages[i]; - switch(msg.getType()) - { - case PipelineMessage::MessageType::Error: - count++; - errCount++; - break; - case PipelineMessage::MessageType::Warning: - count++; - warnCount++; - break; - case PipelineMessage::MessageType::StatusMessage: - case PipelineMessage::MessageType::StandardOutputMessage: - case PipelineMessage::MessageType::ProgressValue: - case PipelineMessage::MessageType::StatusMessageAndProgressValue: - case PipelineMessage::MessageType::UnknownMessageType: - break; - } - } - - emit tableHasErrors(errCount > 0, errCount, warnCount); - - // Now create the correct number of table rows. - ui->errorTableWidget->setRowCount(count); - int row = 0; - bool updateRow = false; - QBrush msgBrush; - QColor msgColor; - QString msgDesc; - QString msgPrefix; - int msgCode = -1; - QTableWidgetItem* filterNameWidgetItem = nullptr; - QTableWidgetItem* descriptionWidgetItem = nullptr; - QTableWidgetItem* codeWidgetItem = nullptr; - QTableWidgetItem* indexWidgetItem = nullptr; - QLabel* hyperlinkLabel = nullptr; // Add in the content for the cells of the table. for(int j = 0; j < m_CachedMessages.size(); j++) { - PipelineMessage msg = m_CachedMessages[j]; - // Create error hyperlink - updateRow = false; - switch(msg.getType()) - { - case PipelineMessage::MessageType::Error: - msgColor = QColor(255, 191, 193); - updateRow = true; - break; - case PipelineMessage::MessageType::Warning: - msgColor = QColor(251, 254, 137); - updateRow = true; - break; - case PipelineMessage::MessageType::StatusMessage: - case PipelineMessage::MessageType::StandardOutputMessage: - case PipelineMessage::MessageType::ProgressValue: - case PipelineMessage::MessageType::StatusMessageAndProgressValue: - case PipelineMessage::MessageType::UnknownMessageType: - break; - } - - if(updateRow) - { - msgBrush = QBrush(msgColor); - - msgDesc = msg.getText(); - msgCode = msg.getCode(); - msgPrefix = msg.getPrefix(); - - filterNameWidgetItem = new QTableWidgetItem(msgPrefix); - filterNameWidgetItem->setTextAlignment(Qt::AlignCenter); - descriptionWidgetItem = new QTableWidgetItem(msgDesc); - codeWidgetItem = new QTableWidgetItem(QString::number(msgCode)); - indexWidgetItem = new QTableWidgetItem(QString::number(msg.getPipelineIndex() + 1)); - - codeWidgetItem->setTextAlignment(Qt::AlignCenter); - - filterNameWidgetItem->setBackground(msgBrush); - descriptionWidgetItem->setBackground(msgBrush); - codeWidgetItem->setBackground(msgBrush); - - hyperlinkLabel = createHyperlinkLabel(msg); - if(hyperlinkLabel == nullptr) - { - ui->errorTableWidget->setItem(row, FilterName, filterNameWidgetItem); - } - else - { - ui->errorTableWidget->setCellWidget(row, FilterName, hyperlinkLabel); - } - ui->errorTableWidget->setItem(row, FilterIndex, indexWidgetItem); - ui->errorTableWidget->setItem(row, Description, descriptionWidgetItem); - ui->errorTableWidget->setItem(row, ErrorCode, codeWidgetItem); - - row++; - } + IssuesWidgetMessageHandler messageHandler(this, &count, &errCount, &warnCount); + m_CachedMessages[j]->visit(&messageHandler); } + emit tableHasErrors(errCount > 0, errCount, warnCount); + if (ui->errorTableWidget->rowCount() > 0) { ui->errorTableWidget->horizontalHeader()->setSectionResizeMode(FilterIndex, QHeaderView::ResizeToContents); @@ -285,47 +187,18 @@ void IssuesWidget::displayCachedMessages() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QLabel* IssuesWidget::createHyperlinkLabel(const PipelineMessage& msg) +void IssuesWidget::showFilterHelp(const QString& urlString) { - QString filterClassName = (msg.getFilterClassName()); - QString filterHumanLabel = (msg.getFilterHumanLabel()); - - if(filterClassName.isEmpty() || filterHumanLabel.isEmpty()) - { - if(!filterClassName.isEmpty()) - { - return new QLabel(filterClassName); - } - if(!filterHumanLabel.isEmpty()) - { - return new QLabel(filterHumanLabel); - } - - return new QLabel("Unknown Filter Class"); - } - - QUrl filterURL = URL_GENERATOR::GenerateHTMLUrl(filterClassName); - QString filterHTMLText; - QTextStream ts(&filterHTMLText); - ts << "getText_Error_color().name(QColor::HexRgb) << ";\" href=\""; - ts << filterURL.toString() << "\">" << filterHumanLabel << ""; - - QLabel* hyperlinkLabel = new QLabel(filterHTMLText); - hyperlinkLabel->setTextFormat(Qt::RichText); - hyperlinkLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - hyperlinkLabel->setOpenExternalLinks(false); - connect(hyperlinkLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showFilterHelp(const QString&))); + QUrl helpURL(urlString); - return hyperlinkLabel; + DocRequestManager* docRequester = DocRequestManager::Instance(); + docRequester->requestFilterDocUrl(helpURL); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IssuesWidget::showFilterHelp(const QString& urlString) +QTableWidget* IssuesWidget::getIssuesTable() { - QUrl helpURL(urlString); - - DocRequestManager* docRequester = DocRequestManager::Instance(); - docRequester->requestFilterDocUrl(helpURL); + return ui->errorTableWidget; } diff --git a/Source/SVWidgetsLib/Widgets/IssuesWidget.h b/Source/SVWidgetsLib/Widgets/IssuesWidget.h index 8ae8c47107..cb224a886e 100755 --- a/Source/SVWidgetsLib/Widgets/IssuesWidget.h +++ b/Source/SVWidgetsLib/Widgets/IssuesWidget.h @@ -40,7 +40,8 @@ #include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/IObserver.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/AbstractMessage.h" #include "SVWidgetsLib/Core/SVWidgetsLibConstants.h" @@ -50,17 +51,19 @@ class FilterListToolboxWidget; class QLabel; class QTableWidgetItem; class QtSSettings; +class QTableWidget; namespace Ui { class IssuesWidget; } +class IssuesWidgetMessageHandler; + /** * @brief The IssuesWidget class */ class SVWidgetsLib_EXPORT IssuesWidget : public QWidget, public IObserver { - Q_OBJECT public: static SIMPLView::DockWidgetSettings::HideDockSetting GetHideDockSetting(); @@ -69,15 +72,21 @@ class SVWidgetsLib_EXPORT IssuesWidget : public QWidget, public IObserver IssuesWidget(QWidget* parent = nullptr); ~IssuesWidget() override; - QLabel* createHyperlinkLabel(const PipelineMessage& msg); + friend IssuesWidgetMessageHandler; static const int FilterIndex = 0; static const int FilterName = 1; static const int Description = 2; static const int ErrorCode = 3; + /** + * @brief getIssuesTable + * @return + */ + QTableWidget* getIssuesTable(); + public slots: - void processPipelineMessage(const PipelineMessage& msg) override; + void processPipelineMessage(const AbstractMessage::Pointer& msg) override; void clearIssues(); void on_errorTableWidget_itemClicked( QTableWidgetItem* item ); void displayCachedMessages(); @@ -97,7 +106,7 @@ class SVWidgetsLib_EXPORT IssuesWidget : public QWidget, public IObserver private: QSharedPointer ui = nullptr; - QVector m_CachedMessages; + std::vector m_CachedMessages; public: IssuesWidget(const IssuesWidget&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.cpp b/Source/SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.cpp new file mode 100755 index 0000000000..5d70e7025e --- /dev/null +++ b/Source/SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.cpp @@ -0,0 +1,169 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "IssuesWidgetMessageHandler.h" + +#include + +#include +#include + +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" + +#ifdef SIMPL_USE_MKDOCS +#define URL_GENERATOR QtSDocServer +#include "SVWidgetsLib/QtSupport/QtSDocServer.h" +#else +#define URL_GENERATOR QtSHelpUrlGenerator +#include "SVWidgetsLib/QtSupport/QtSHelpUrlGenerator.h" +#endif + +#include "SVWidgetsLib/Widgets/IssuesWidget.h" +#include "SVWidgetsLib/Widgets/SVStyle.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IssuesWidgetMessageHandler::IssuesWidgetMessageHandler(IssuesWidget* issuesWidget, int* count, int* errCount, int* warningCount) +: m_IssuesWidget(issuesWidget) +, m_Count(count) +, m_ErrCount(errCount) +, m_WarningCount(warningCount) +{ + +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IssuesWidgetMessageHandler::processMessage(const FilterErrorMessage* msg) const +{ + QColor msgColor = QColor(255, 191, 193); + addItemToIssuesTable(msg->getClassName(), msg->getHumanLabel(), msg->getPipelineIndex(), msg->getMessageText(), msg->getCode(), msgColor); + + m_ErrCount[0]++; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IssuesWidgetMessageHandler::processMessage(const FilterWarningMessage* msg) const +{ + QColor msgColor = QColor(251, 254, 137); + addItemToIssuesTable(msg->getClassName(), msg->getHumanLabel(), msg->getPipelineIndex(), msg->getMessageText(), msg->getCode(), msgColor); + + m_WarningCount[0]++; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IssuesWidgetMessageHandler::addItemToIssuesTable(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msg, int code, QColor msgColor) const +{ + QBrush msgBrush = QBrush(msgColor); + + // Create error hyperlink + QTableWidgetItem* codeWidgetItem = nullptr; + QTableWidgetItem* indexWidgetItem = nullptr; + + QTableWidgetItem* filterNameWidgetItem = new QTableWidgetItem(humanLabel); + filterNameWidgetItem->setTextAlignment(Qt::AlignCenter); + QTableWidgetItem* descriptionWidgetItem = new QTableWidgetItem(msg); + codeWidgetItem = new QTableWidgetItem(QString::number(code)); + indexWidgetItem = new QTableWidgetItem(QString::number(pipelineIndex + 1)); + + codeWidgetItem->setTextAlignment(Qt::AlignCenter); + + filterNameWidgetItem->setBackground(msgBrush); + descriptionWidgetItem->setBackground(msgBrush); + codeWidgetItem->setBackground(msgBrush); + + QTableWidget* issuesTable = m_IssuesWidget->getIssuesTable(); + int row = issuesTable->rowCount(); + + issuesTable->insertRow(row); + + QLabel* hyperlinkLabel = createHyperlinkLabel(className, humanLabel); + if(hyperlinkLabel == nullptr) + { + issuesTable->setItem(row, IssuesWidget::FilterName, filterNameWidgetItem); + } + else + { + issuesTable->setCellWidget(row, IssuesWidget::FilterName, hyperlinkLabel); + } + issuesTable->setItem(row, IssuesWidget::FilterIndex, indexWidgetItem); + issuesTable->setItem(row, IssuesWidget::Description, descriptionWidgetItem); + issuesTable->setItem(row, IssuesWidget::ErrorCode, codeWidgetItem); + + m_Count[0]++; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QLabel* IssuesWidgetMessageHandler::createHyperlinkLabel(const QString &filterClassName, const QString &filterHumanLabel) const +{ + if(filterClassName.isEmpty() || filterHumanLabel.isEmpty()) + { + if(!filterClassName.isEmpty()) + { + return new QLabel(filterClassName); + } + if(!filterHumanLabel.isEmpty()) + { + return new QLabel(filterHumanLabel); + } + + return new QLabel("Unknown Filter Class"); + } + + QUrl filterURL = URL_GENERATOR::GenerateHTMLUrl(filterClassName); + QString filterHTMLText; + QTextStream ts(&filterHTMLText); + ts << "getText_Error_color().name(QColor::HexRgb) << ";\" href=\""; + ts << filterURL.toString() << "\">" << filterHumanLabel << ""; + + QLabel* hyperlinkLabel = new QLabel(filterHTMLText); + hyperlinkLabel->setTextFormat(Qt::RichText); + hyperlinkLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + hyperlinkLabel->setOpenExternalLinks(false); + QObject::connect(hyperlinkLabel, SIGNAL(linkActivated(const QString&)), m_IssuesWidget, SLOT(showFilterHelp(const QString&))); + + return hyperlinkLabel; +} + + diff --git a/Source/SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.h b/Source/SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.h new file mode 100755 index 0000000000..1784e46b00 --- /dev/null +++ b/Source/SVWidgetsLib/Widgets/IssuesWidgetMessageHandler.h @@ -0,0 +1,90 @@ +/* ============================================================================ +* Copyright (c) 2009-2016 BlueQuartz Software, LLC +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* Redistributions in binary form must reproduce the above copyright notice, this +* list of conditions and the following disclaimer in the documentation and/or +* other materials provided with the distribution. +* +* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its +* contributors may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The code contained herein was partially funded by the followig contracts: +* United States Air Force Prime Contract FA8650-07-D-5800 +* United States Air Force Prime Contract FA8650-10-D-5210 +* United States Prime Contract Navy N00173-07-C-2068 +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SVWidgetsLib/SVWidgetsLib.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" + +class IssuesWidget; +class QLabel; + +/** + * @brief This message handler is used by the Issues Widget to load the issues table + * with filter error and warning messages. + */ +class SVWidgetsLib_EXPORT IssuesWidgetMessageHandler : public AbstractMessageHandler +{ + public: + explicit IssuesWidgetMessageHandler(IssuesWidget* issuesWidget, int* count, int* errCount, int* warningCount); + + /** + * @brief Adds incoming FilterErrorMessages to the issues table. + * @param msg + */ + void processMessage(const FilterErrorMessage* msg) const override; + + /** + * @brief Adds incoming FilterWarningMessages to the issues table. + * @param msg + */ + void processMessage(const FilterWarningMessage* msg) const override; + + private: + IssuesWidget* m_IssuesWidget = nullptr; + int* m_Count = nullptr; + int* m_ErrCount = nullptr; + int* m_WarningCount = nullptr; + + /** + * @brief addItemToIssuesTable + * @param className + * @param humanLabel + * @param pipelineIndex + * @param msg + * @param code + * @param msgColor + */ + void addItemToIssuesTable(const QString& className, const QString& humanLabel, int pipelineIndex, const QString& msg, int code, QColor msgColor) const; + + /** + * @brief createHyperlinkLabel + * @param msg + * @return + */ + QLabel* createHyperlinkLabel(const QString &filterClassName, const QString &filterHumanLabel) const; +}; + + diff --git a/Source/SVWidgetsLib/Widgets/PopUpWidget.h b/Source/SVWidgetsLib/Widgets/PopUpWidget.h index 63005a9f5e..c06f7e0393 100644 --- a/Source/SVWidgetsLib/Widgets/PopUpWidget.h +++ b/Source/SVWidgetsLib/Widgets/PopUpWidget.h @@ -31,10 +31,10 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/PipelineMessage.h" - #include +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + #include "SVWidgetsLib/SVWidgetsLib.h" #include "SVWidgetsLib/ui_PopUpWidget.h" diff --git a/Source/SVWidgetsLib/Widgets/ProgressDialog.cpp b/Source/SVWidgetsLib/Widgets/ProgressDialog.cpp index b628bc5850..a0a0e5da7a 100644 --- a/Source/SVWidgetsLib/Widgets/ProgressDialog.cpp +++ b/Source/SVWidgetsLib/Widgets/ProgressDialog.cpp @@ -33,14 +33,43 @@ #include +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" + #include "ui_ProgressDialog.h" +/** + * @brief This class is the message handler for the Progress Dialog class. It is responsible + * for receiving any incoming messages that the progress dialog would like to know about. + */ +class ProgressDialogMessageHandler : public AbstractMessageHandler +{ +public: + explicit ProgressDialogMessageHandler(ProgressDialog* progressDialog) + : m_ProgressDialog(progressDialog) + { + } + + /** + * @brief Sets the text of the progress dialog's label to the human label of incoming + * FilterErrorMessages. + * @param msg + */ + void processMessage(const FilterErrorMessage* msg) const override + { + m_ProgressDialog->m_Ui->label->setText(msg->getHumanLabel()); + } + +private: + ProgressDialog* m_ProgressDialog = nullptr; +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) - : QDialog (parent, f) - , m_Ui(new Ui::ProgressDialog) +ProgressDialog::ProgressDialog(QWidget* parent, Qt::WindowFlags f) +: QDialog(parent, f) +, m_Ui(new Ui::ProgressDialog) { m_Ui->setupUi(this); } @@ -61,7 +90,8 @@ void ProgressDialog::setLabelText(const QString& text) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ProgressDialog::processPipelineMessage(const PipelineMessage& msg) +void ProgressDialog::processPipelineMessage(const AbstractMessage::Pointer& msg) { - m_Ui->label->setText(msg.getFilterHumanLabel()); + ProgressDialogMessageHandler msgHandler(this); + msg->visit(&msgHandler); } diff --git a/Source/SVWidgetsLib/Widgets/ProgressDialog.h b/Source/SVWidgetsLib/Widgets/ProgressDialog.h index fdb1bfbfb8..72b62d4fba 100644 --- a/Source/SVWidgetsLib/Widgets/ProgressDialog.h +++ b/Source/SVWidgetsLib/Widgets/ProgressDialog.h @@ -32,7 +32,7 @@ #pragma once -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" #include @@ -43,6 +43,8 @@ namespace Ui { class ProgressDialog; } +class ProgressDialogMessageHandler; + /** * @brief The ProgressDialog class */ @@ -54,10 +56,12 @@ class SVWidgetsLib_EXPORT ProgressDialog : public QDialog ProgressDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); ~ProgressDialog() override; + friend ProgressDialogMessageHandler; + public slots: void setLabelText(const QString& text); - void processPipelineMessage(const PipelineMessage& msg); + void processPipelineMessage(const AbstractMessage::Pointer& msg); protected: diff --git a/Source/SVWidgetsLib/Widgets/SVPipelineView.cpp b/Source/SVWidgetsLib/Widgets/SVPipelineView.cpp index 0900008a43..453ead155c 100644 --- a/Source/SVWidgetsLib/Widgets/SVPipelineView.cpp +++ b/Source/SVWidgetsLib/Widgets/SVPipelineView.cpp @@ -67,7 +67,6 @@ #include #include "SIMPLib/Common/DocRequestManager.h" -#include "SIMPLib/Common/PipelineMessage.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/CoreFilters/Breakpoint.h" #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" @@ -100,40 +99,14 @@ #include "SVWidgetsLib/Widgets/SVStyle.h" #include "SVWidgetsLib/QtSupport/QtSRecentFileList.h" -namespace +class ExecutionResultInvalidException : public std::exception { - -class JsonObserver : public IObserver -{ -public: - JsonObserver() = default; - ~JsonObserver() override = default; - - JsonObserver(const JsonObserver&) = delete; // Copy Constructor Not Implemented - JsonObserver(JsonObserver&&) = delete; // Move Constructor Not Implemented - JsonObserver& operator=(const JsonObserver&) = delete; // Copy Assignment Not Implemented - JsonObserver& operator=(JsonObserver&&) = delete; // Move Assignment Not Implemented - - void processPipelineMessage(const PipelineMessage& pm) override - { - m_ErrorCode = pm.getCode(); - m_ErrorMessage = pm.getText(); - } - - QString getErrorMessage() - { - return m_ErrorMessage; - } - int32_t getErrorCode() - { - return m_ErrorCode; - } - -private: - QString m_ErrorMessage; - int32_t m_ErrorCode = 0; + const char* what () const noexcept + { + return "The execution result of a pipeline was invalid."; + } }; -} // namespace + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -298,11 +271,11 @@ void SVPipelineView::listenFilterCompleted(AbstractFilter* filter) { model->setData(index, static_cast(PipelineItem::WidgetState::Completed), PipelineModel::WidgetStateRole); } - if(filter->getWarningCondition() < 0) + if(filter->getWarningCode() < 0) { model->setData(index, static_cast(PipelineItem::ErrorState::Warning), PipelineModel::ErrorStateRole); } - if(filter->getErrorCondition() < 0) + if(filter->getErrorCode() < 0) { model->setData(index, static_cast(PipelineItem::ErrorState::Error), PipelineModel::ErrorStateRole); } @@ -373,7 +346,7 @@ void SVPipelineView::preflightPipeline() FilterPipeline::FilterContainerType filters = pipeline->getFilterContainer(); for(int i = 0; i < filters.size(); i++) { - filters.at(i)->setErrorCondition(0); + filters.at(i)->clearErrorCode(); filters.at(i)->setCancel(false); QModelIndex childIndex = model->index(i, PipelineItem::Contents); @@ -404,11 +377,11 @@ void SVPipelineView::preflightPipeline() AbstractFilter::Pointer filter = model->filter(childIndex); if(filter.get() != nullptr) { - if (filter->getWarningCondition() < 0) + if(filter->getWarningCode() < 0) { model->setData(childIndex, static_cast(PipelineItem::ErrorState::Warning), PipelineModel::ErrorStateRole); } - if(filter->getErrorCondition() < 0) + if(filter->getErrorCode() < 0) { model->setData(childIndex, static_cast(PipelineItem::ErrorState::Error), PipelineModel::ErrorStateRole); } @@ -503,7 +476,7 @@ void SVPipelineView::executePipeline() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SVPipelineView::processPipelineMessage(const PipelineMessage& msg) +void SVPipelineView::processPipelineMessage(const AbstractMessage::Pointer& msg) { emit pipelineHasMessage(msg); } @@ -564,8 +537,10 @@ void SVPipelineView::finishPipeline() emit stdOutMessage(SVStyle::Instance()->WrapTextWithHtmlStyle("*************** PIPELINE FAILED ***************", true)); break; case FilterPipeline::ExecutionResult::Invalid: + throw ExecutionResultInvalidException(); break; } + emit stdOutMessage(SVStyle::Instance()->WrapTextWithHtmlStyle("", false)); // Put back the DataContainerArray for each filter at the conclusion of running @@ -1629,24 +1604,16 @@ FilterPipeline::Pointer SVPipelineView::readPipelineFromFile(const QString& file QFileInfo fi(filePath); QString ext = fi.suffix(); - ::JsonObserver jsonObs; - FilterPipeline::Pointer pipeline = FilterPipeline::NullPointer(); if(ext == "dream3d") { H5FilterParametersReader::Pointer dream3dReader = H5FilterParametersReader::New(); - pipeline = dream3dReader->readPipelineFromFile(filePath, &jsonObs); + pipeline = dream3dReader->readPipelineFromFile(filePath, this); } else if(ext == "json") { JsonFilterParametersReader::Pointer jsonReader = JsonFilterParametersReader::New(); - pipeline = jsonReader->readPipelineFromFile(filePath, &jsonObs); - } - - if(jsonObs.getErrorCode() != 0) - { - emit statusMessage(jsonObs.getErrorMessage()); - emit stdOutMessage(SVStyle::Instance()->WrapTextWithHtmlStyle(jsonObs.getErrorMessage(), true)); + pipeline = jsonReader->readPipelineFromFile(filePath, this); } return pipeline; diff --git a/Source/SVWidgetsLib/Widgets/SVPipelineView.h b/Source/SVWidgetsLib/Widgets/SVPipelineView.h index e1aa8a2f32..b32878fdf9 100755 --- a/Source/SVWidgetsLib/Widgets/SVPipelineView.h +++ b/Source/SVWidgetsLib/Widgets/SVPipelineView.h @@ -49,7 +49,7 @@ #include #include "SIMPLib/Common/Observer.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" #include "SIMPLib/CoreFilters/DataContainerReader.h" #include "SIMPLib/FilterParameters/H5FilterParametersReader.h" #include "SIMPLib/FilterParameters/H5FilterParametersWriter.h" @@ -327,7 +327,7 @@ public slots: * @brief processPipelineMessage * @param pm */ - void processPipelineMessage(const PipelineMessage& pm) override; + void processPipelineMessage(const AbstractMessage::Pointer& pm) override; signals: void displayIssuesTriggered(); @@ -346,7 +346,7 @@ public slots: void pipelineStarted(); void pipelineFinished(); - void pipelineHasMessage(const PipelineMessage& msg); + void pipelineHasMessage(AbstractMessage::Pointer msg); void pipelineFilePathUpdated(const QString& name); void pipelineChanged(); void filePathOpened(const QString& filePath); diff --git a/Source/SVWidgetsLib/Widgets/SourceList.cmake b/Source/SVWidgetsLib/Widgets/SourceList.cmake index 52901d0161..28510fd20c 100755 --- a/Source/SVWidgetsLib/Widgets/SourceList.cmake +++ b/Source/SVWidgetsLib/Widgets/SourceList.cmake @@ -50,6 +50,7 @@ set(SVWidgetsLib_Widgets_HDRS ${SVWidgetsLib_SOURCE_DIR}/Widgets/BookmarksItem.h ${SVWidgetsLib_SOURCE_DIR}/Widgets/DataStructureItem.h ${SVWidgetsLib_SOURCE_DIR}/Widgets/ImportHDF5TreeModelItem.h + ${SVWidgetsLib_SOURCE_DIR}/Widgets/IssuesWidgetMessageHandler.h ${SVWidgetsLib_SOURCE_DIR}/Widgets/PipelineFilterMimeData.h ${SVWidgetsLib_SOURCE_DIR}/Widgets/PipelineItem.h ${SVWidgetsLib_SOURCE_DIR}/Widgets/PipelineView.h @@ -78,6 +79,7 @@ set(SVWidgetsLib_Widgets_SRCS ${SVWidgetsLib_SOURCE_DIR}/Widgets/FilterListModel.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/FilterListView.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/IssuesWidget.cpp + ${SVWidgetsLib_SOURCE_DIR}/Widgets/IssuesWidgetMessageHandler.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/StandardOutputWidget.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/FilterInputWidget.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/ImportHDF5TreeModel.cpp @@ -94,7 +96,6 @@ set(SVWidgetsLib_Widgets_SRCS ${SVWidgetsLib_SOURCE_DIR}/Widgets/StatusBarIssuesButton.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/PopUpWidget.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/ProgressDialog.cpp - ${SVWidgetsLib_SOURCE_DIR}/Widgets/SVControlWidgets.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/SVOverlayWidgetButton.cpp ${SVWidgetsLib_SOURCE_DIR}/Widgets/SVStyle.cpp diff --git a/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.cpp b/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.cpp index 438e7baf6c..b15a578862 100644 --- a/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.cpp +++ b/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.cpp @@ -35,9 +35,53 @@ const QString& genDir, const QString& moduleTemplatePath, const QString& isSIMPL //----------------------------------------------------------------------------- PyBind11Generator::~PyBind11Generator() = default; +//----------------------------------------------------------------------------- +void PyBind11Generator::readFilterList() +{ + QString libName = m_LibNameUpper; + if(m_IsSIMPLib =="TRUE") + { + libName = QString("SIMPLib"); + } + QString listFilePath = SIMPL::PyBind11::SIMPLProjBinaryDir + "/" + libName + "PublicFilters.txt"; + QFileInfo listFileInfo(listFilePath); + if(!listFileInfo.exists()) + { + qDebug() << "Needed Input file to generate Python Bindings was not found for Plugin '" << libName + << "'. The file should have been generated at " + << listFileInfo.absoluteFilePath(); + } + + m_FilterList.clear(); + + // Read the Source File + QFile source(listFilePath); + source.open(QFile::ReadOnly); + QString contents = source.readAll(); + source.close(); + + QStringList list = contents.split(QRegExp("\\n")); + QStringListIterator sourceLines(list); + while(sourceLines.hasNext()) + { + QString line = sourceLines.next(); + QString tLine = line.trimmed(); + if(tLine.startsWith("#")) // Skip the comment line + { + } + else if(!tLine.isEmpty()) + { + m_FilterList << tLine; + } + } + qDebug() << "[PyBind11Generator] " << libName << ": Generating " << m_FilterList.size() << " Pybind11 Headers "; +} + //----------------------------------------------------------------------------- void PyBind11Generator::execute() { + readFilterList(); + recursiveSearch(m_TopLevelDir); // If these extensions are changed be sure the WrappingFunctions.cmake file is updated @@ -56,7 +100,7 @@ void PyBind11Generator::execute() genHeaderPath = QString(""); QString libName = m_LibNameUpper; - if(m_IsSIMPLib.compare("TRUE") == 0) + if(m_IsSIMPLib =="TRUE") { libName = QString("simpl"); } @@ -66,7 +110,7 @@ void PyBind11Generator::execute() genHeaderPath = QString(""); libName = m_LibNameUpper; - if(m_IsSIMPLib.compare("TRUE") == 0) + if(m_IsSIMPLib =="TRUE") { libName = QString("simpl"); } @@ -198,29 +242,44 @@ void PyBind11Generator::copyPyInitFiles() //----------------------------------------------------------------------------- void PyBind11Generator::recursiveSearch(QDir currentDir) { - QStringList filters; - filters.append("*.h"); - if(currentDir.dirName().compare("zRel") == 0 || currentDir.dirName().compare("Build") == 0 || currentDir.dirName().compare("pybind11") == 0) { return; } - // Get a list of all the directories - QFileInfoList dirList = currentDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); - if(dirList.size() > 0) + // If the currently generated library is SIMPLib itself then ignore the list of + // files and do a recursive search for the PYBIND macros since everything in + // SIMPL is going to need to be wrapped. + if(m_IsSIMPLib =="TRUE") { - foreach(QFileInfo fi, dirList) + // Get a list of all the directories + QFileInfoList dirList = currentDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + if(dirList.size() > 0) { - recursiveSearch(QDir(fi.absoluteFilePath())); // Recursive call + foreach(QFileInfo fi, dirList) + { + recursiveSearch(QDir(fi.absoluteFilePath())); // Recursive call + } + } + QStringList filters; + filters.append("*.h"); + QFileInfoList itemList = currentDir.entryInfoList(filters); + foreach(QFileInfo itemInfo, itemList) + { + QString headerFilePath = itemInfo.absoluteFilePath(); + generatePybind11Header(headerFilePath); + } + } else { + for(const auto& item : m_FilterList) + { + QString filePath = currentDir.absolutePath() + QDir::separator() + item; + QFileInfo fi(filePath); + if(fi.exists()) + { + generatePybind11Header(fi.absoluteFilePath()); + } } } - QFileInfoList itemList = currentDir.entryInfoList(filters); - foreach(QFileInfo itemInfo, itemList) - { - QString headerFilePath = itemInfo.absoluteFilePath(); - generatePybind11Header(headerFilePath); - } } //----------------------------------------------------------------------------- void PyBind11Generator::generatePybind11Header(const QString& hFile) diff --git a/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.h b/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.h index 4389e1c002..552ebfe29c 100644 --- a/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.h +++ b/Wrapping/Python/Pybind11/CodeScraper/PyBind11Generator.h @@ -2,6 +2,7 @@ #include #include +#include #include "SIMPLib/Common/SIMPLibSetGetMacros.h" @@ -52,7 +53,11 @@ class PyBind11Generator */ void generateModuleInitPy(); - + /** + * + */ + void readFilterList(); + private: QDir m_TopLevelDir; QDir m_SourceDir; @@ -64,6 +69,7 @@ class PyBind11Generator PythonBindingsModule m_ModuleCode; QString m_IsSIMPLib; QString m_CfgIntDir; + QStringList m_FilterList; PyBind11Generator(const PyBind11Generator&) = delete; // Copy Constructor Not Implemented void operator=(const PyBind11Generator&) = delete; // Operator '=' Not Implemented diff --git a/Wrapping/Python/Pybind11/Templates/SIMPLModuleCodeTemplate.in.cpp b/Wrapping/Python/Pybind11/Templates/SIMPLModuleCodeTemplate.in.cpp index ae052fbd4e..e2dd2b4306 100644 --- a/Wrapping/Python/Pybind11/Templates/SIMPLModuleCodeTemplate.in.cpp +++ b/Wrapping/Python/Pybind11/Templates/SIMPLModuleCodeTemplate.in.cpp @@ -31,20 +31,17 @@ PYBIND11_MAKE_OPAQUE(std::vector); #include +#include +#include + #include "SIMPLib/Common/PhaseType.h" +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Common/ShapeType.h" #include "SIMPLib/CoreFilters/ArrayCalculator.h" #include "SIMPLib/CoreFilters/ImportHDF5Dataset.h" #include "SIMPLib/FilterParameters/AxisAngleInput.h" #include "SIMPLib/FilterParameters/FileListInfo.h" -#include "SIMPLib/FilterParameters/FloatVec2.h" -#include "SIMPLib/FilterParameters/FloatVec3.h" -#include "SIMPLib/FilterParameters/IntVec3.h" #include "SIMPLib/FilterParameters/ThirdOrderPolynomial.h" -#include -#include - -//#include "OrientationLib/OrientationMath/OrientationConverter.hpp" namespace py = pybind11; @@ -143,15 +140,11 @@ PYBIND11_MODULE(dream3d, m) // // // - py::class_(mod, "FloatVec3") - .def(py::init()) - ; - py::class_(mod, "FloatVec2") - .def(py::init()) - ; - py::class_(mod, "IntVec3") - .def(py::init()) - ; + py::class_(mod, "FloatVec3Type").def(py::init()); + py::class_(mod, "FloatVec2Type").def(py::init()); + py::class_(mod, "IntVec3Type").def(py::init()); + + py::class_(mod, "SizeVec3Type").def(py::init()); py::class_(mod, "AxisAngleInput") .def(py::init< const float &, const float &, const float &, const float &>())