diff --git a/Grinder/Version.h b/Grinder/Version.h index 141ea40a8e186f4e9c4a893c9c51d1bd51e2504e..4d22235b771fe226d617a62955f459092107d332 100644 --- a/Grinder/Version.h +++ b/Grinder/Version.h @@ -10,7 +10,7 @@ #define GRNDR_INFO_TITLE "Grinder" #define GRNDR_INFO_COPYRIGHT "Copyright (c) WWU Muenster" -#define GRNDR_INFO_DATE "13.04.2018" +#define GRNDR_INFO_DATE "15.04.2018" #define GRNDR_INFO_COMPANY "WWU Muenster" #define GRNDR_INFO_WEBSITE "http://www.uni-muenster.de" diff --git a/Grinder/common/properties/PropertyBase.cpp b/Grinder/common/properties/PropertyBase.cpp index 14c4103b59035d11b738a2a8f01499759fe9e5e4..2797c922b3359be782f993875bcda9a46c2be776 100644 --- a/Grinder/common/properties/PropertyBase.cpp +++ b/Grinder/common/properties/PropertyBase.cpp @@ -25,9 +25,5 @@ void PropertyBase::serialize(SerializationContext& ctx) const void PropertyBase::deserialize(DeserializationContext& ctx) { - // Deserialize values - if (ctx.getMode() != DeserializationContext::Mode::ProjectSerialization) // Already set when the object was created during deserialization - _id = ctx.settings()[Serialization_Value_ID].toString(); - _name = ctx.settings()[Serialization_Value_Name].toString(); } diff --git a/Grinder/engine/processors/InputProcessor.cpp b/Grinder/engine/processors/InputProcessor.cpp index a05804ab35f69e1680b142164c2379f863057494..a09328722c259ad53619a59b744f74cea569e2f8 100644 --- a/Grinder/engine/processors/InputProcessor.cpp +++ b/Grinder/engine/processors/InputProcessor.cpp @@ -18,20 +18,7 @@ void InputProcessor::execute(EngineExecutionContext& ctx) { Processor::execute(ctx); - ImageReference* imageReference = *_block->imageReference(); - - // Make sure that the image reference really exists (just in case) - if (imageReference) - { - if (!std::any_of(grinder()->project().imageReferences().cbegin(), grinder()->project().imageReferences().cend(), [imageReference](const auto& imageRef) { return imageRef.get() == imageReference; })) - imageReference = nullptr; - } - - // If no image reference has been set, use the currently active one - if (!imageReference) - imageReference = grinder()->projectController().activeImageReference(); - - if (imageReference) + if (auto imageReference = _block->resolveImageReference()) ctx.setContextEntry(_block->outPort(), DataBlob{getPortDataDescriptor(_block->outPort()), imageReference->loadImage()}); else throwProcessorException("There currently is no active image"); diff --git a/Grinder/engine/processors/OutputProcessor.cpp b/Grinder/engine/processors/OutputProcessor.cpp index 25cfb26e9499153b1ebaa8fe502ff00e5cf29cb0..928984f462de3a9bf561512841bb709ebd18575c 100644 --- a/Grinder/engine/processors/OutputProcessor.cpp +++ b/Grinder/engine/processors/OutputProcessor.cpp @@ -39,12 +39,8 @@ void OutputProcessor::execute(EngineExecutionContext& ctx) for (auto inputBlock : inputBlocks) { - const ImageReference* imageReference = *inputBlock->imageReference(); - - if (!imageReference) - imageReference = ctx.activeImageReference(); - - imageReferences.insert(imageReference); + if (auto imageReference = inputBlock->resolveImageReference(ctx.activeImageReference())) + imageReferences.insert(imageReference); } // Finally, get the image build for this block and the used images and set its image data diff --git a/Grinder/image/DraftItem.cpp b/Grinder/image/DraftItem.cpp index f31b66d3a21df1150cddbfab53b3d7d6b1a8caee..aaded77c016674e3e94beaef0c45657cfb5711f0 100644 --- a/Grinder/image/DraftItem.cpp +++ b/Grinder/image/DraftItem.cpp @@ -37,10 +37,6 @@ void DraftItem::serialize(SerializationContext& ctx) const void DraftItem::deserialize(DeserializationContext& ctx) { PropertyObject::deserialize(ctx); - - // Deserialize values - if (ctx.getMode() != DeserializationContext::Mode::ProjectSerialization) // Already set when the object was created during deserialization - _type = ctx.settings()[Serialization_Value_Type].toString(); } void DraftItem::createProperties() diff --git a/Grinder/image/ImageBuild.cpp b/Grinder/image/ImageBuild.cpp index 6f8b5aa55f9acedb4103924b088d1fddb767f390..ca0f987d50e49fa07d516f0016a8ae7f7e41576d 100644 --- a/Grinder/image/ImageBuild.cpp +++ b/Grinder/image/ImageBuild.cpp @@ -106,25 +106,6 @@ void ImageBuild::serialize(SerializationContext& ctx) const void ImageBuild::deserialize(DeserializationContext& ctx) { - // Deserialize image references - if (ctx.getMode() == SerializationContext::Mode::ProjectSerialization) - { - std::vector<const ImageReference*> imageReferences; - - for (auto imageRef : ctx.settings()[Serialization_Value_ImageReferences].toString().split(",")) - { - auto imageRefIndex = imageRef.toInt(); - - if (imageRefIndex != -1) - { - if (auto imageRef = ctx.getImageReference(imageRefIndex)) - imageReferences.push_back(imageRef); - } - } - - _imageReferences = std::move(imageReferences); - } - // Deserialize all layers if (ctx.beginGroup(LayerVector::Serialization_Group)) { diff --git a/Grinder/pipeline/Block.cpp b/Grinder/pipeline/Block.cpp index 922feede9945e4d53f0176824100166411a8dc03..afa154bc1dd7a7562a124e84175cbb023dbfde00 100644 --- a/Grinder/pipeline/Block.cpp +++ b/Grinder/pipeline/Block.cpp @@ -80,10 +80,6 @@ void Block::deserialize(DeserializationContext& ctx) { PipelineItem::deserialize(ctx); - // Deserialize values - if (ctx.getMode() != DeserializationContext::Mode::ProjectSerialization) // Already set when the object was created during deserialization - _type = ctx.settings()[Serialization_Value_Type].toString(); - ctx.addBlock(ctx.settings()[Serialization_Value_Index].toInt(), this); // Deserialize all ports diff --git a/Grinder/pipeline/Port.cpp b/Grinder/pipeline/Port.cpp index e82964a175e79d4ec89e7c94ea3fce10a31c7d0e..3a9530ec524c4d75493d89d16cca09f245307ac1 100644 --- a/Grinder/pipeline/Port.cpp +++ b/Grinder/pipeline/Port.cpp @@ -227,9 +227,5 @@ void Port::deserialize(DeserializationContext& ctx) { PipelineItem::deserialize(ctx); - // Deserialize values - if (ctx.getMode() != DeserializationContext::Mode::ProjectSerialization) // Already set when the object was created during deserialization - _type = ctx.settings()[Serialization_Value_Type].toString(); - ctx.addPort(ctx.settings()[Serialization_Value_Index].toInt(), this); } diff --git a/Grinder/pipeline/blocks/InputBlock.cpp b/Grinder/pipeline/blocks/InputBlock.cpp index e4a5095e2c3388423f002d139526149da39f8c0f..5d3191c13c0068375ff7e27b46109526d168af7a 100644 --- a/Grinder/pipeline/blocks/InputBlock.cpp +++ b/Grinder/pipeline/blocks/InputBlock.cpp @@ -5,6 +5,7 @@ #include "Grinder.h" #include "InputBlock.h" +#include "core/GrinderApplication.h" #include "engine/processors/InputProcessor.h" const BlockType InputBlock::type_value = BlockType::Input; @@ -20,6 +21,24 @@ std::unique_ptr<ProcessorBase> InputBlock::createProcessor() const return std::make_unique<InputProcessor>(this); } +const ImageReference* InputBlock::resolveImageReference(const ImageReference* activeImageReference) const +{ + const ImageReference* currentImageRef = *imageReference(); + + // Make sure that the image reference really exists (just in case) + if (currentImageRef) + { + if (!std::any_of(grinder()->project().imageReferences().cbegin(), grinder()->project().imageReferences().cend(), [currentImageRef](const auto& imageRef) { return imageRef.get() == currentImageRef; })) + currentImageRef = nullptr; + } + + // If no image reference has been set, use the currently active one + if (!currentImageRef) + currentImageRef = activeImageReference ? activeImageReference : grinder()->projectController().activeImageReference(); + + return currentImageRef; +} + void InputBlock::createProperties() { Block::createProperties(); diff --git a/Grinder/pipeline/blocks/InputBlock.h b/Grinder/pipeline/blocks/InputBlock.h index 5af8a97fc5902d6e8ef8fab181be398ada6ca1fd..9fbcab802585fa0a2b5b367f48b1d3967012d661 100644 --- a/Grinder/pipeline/blocks/InputBlock.h +++ b/Grinder/pipeline/blocks/InputBlock.h @@ -25,6 +25,8 @@ namespace grndr public: virtual std::unique_ptr<ProcessorBase> createProcessor() const override; + const ImageReference* resolveImageReference(const ImageReference* activeImageReference = nullptr) const; + public: auto imageReference() { return dynamic_cast<ImageReferenceProperty*>(_imageReference.get()); } auto imageReference() const { return dynamic_cast<ImageReferenceProperty*>(_imageReference.get()); } diff --git a/Grinder/project/ImageReference.cpp b/Grinder/project/ImageReference.cpp index 806c9c0aa0bf47cdccc656c74d75261b772e6334..02b644d349a35a0d380103e456653c6eefeb77f5 100644 --- a/Grinder/project/ImageReference.cpp +++ b/Grinder/project/ImageReference.cpp @@ -84,10 +84,6 @@ void ImageReference::serialize(SerializationContext& ctx) const void ImageReference::deserialize(DeserializationContext& ctx) { - // Deserialize values - if (ctx.getMode() != DeserializationContext::Mode::ProjectSerialization) // Already set when the object was created during deserialization - _imageFilePath = ctx.settings()[Serialization_Value_File].toString(); - ctx.addImageReference(ctx.settings()[Serialization_Value_Index].toInt(), this); }