Skip to content
Snippets Groups Projects
Commit 87a5ab4a authored by Daniel Müller's avatar Daniel Müller
Browse files

* Did some cleanup

parent a107d87d
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
......@@ -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();
}
......@@ -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");
......
......@@ -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
......
......@@ -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()
......
......@@ -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))
{
......
......@@ -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
......
......@@ -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);
}
......@@ -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();
......
......@@ -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()); }
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment