Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::CompositeProcessor Class Reference

A processor containing a network of processors, i.e. it will act as a sub network within a processor network. A CompositeProcessor can be used to reduce cluttering in the network. Also makes it easy to reuse groups of processors inside of a network, and across network since they can be saved in the processor list. A CompositeProcessor is usually created by selecting a group of processors that are closely related in the network editor and then clicking "create composite" in the context menu. Use InviwoModule::registerCompositeProcessor to register a saved composite in your module. More...

#include <compositeprocessor.h>

+ Inheritance diagram for inviwo::CompositeProcessor:

Public Member Functions

 CompositeProcessor (std::string_view identifier, std::string_view displayName, InviwoApplication *app, const std::filesystem::path &filename="")
 
virtual void process () override
 
virtual void propagateEvent (Event *event, Outport *source) override
 
void saveSubNetwork (const std::filesystem::path &file)
 
ProcessorNetworkgetSubNetwork ()
 
PropertyaddSuperProperty (Property *subProperty)
 
PropertygetSuperProperty (Property *subProperty)
 
void removeSuperProperty (Property *subProperty)
 
PropertygetSubProperty (Property *superProperty)
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
virtual const ProcessorInfogetProcessorInfo () const override
 
- Public Member Functions inherited from inviwo::Processor
 Processor (std::string_view identifier="", std::string_view displayName="")
 
const std::string & getClassIdentifier () const
 
const std::string & getCategory () const
 
CodeState getCodeState () const
 
const TagsgetTags () const
 
void setIdentifier (std::string_view identifier)
 
virtual const std::string & getIdentifier () const override
 
NameDispatcherHandle onIdentifierChange (std::function< void(std::string_view, std::string_view)> callback)
 
void setDisplayName (std::string_view displayName)
 
const std::string & getDisplayName () const
 
NameDispatcherHandle onDisplayNameChange (std::function< void(std::string_view, std::string_view)> callback)
 
virtual void setProcessorWidget (std::unique_ptr< ProcessorWidget > processorWidget)
 
ProcessorWidgetgetProcessorWidget () const
 
bool hasProcessorWidget () const
 
virtual void setNetwork (ProcessorNetwork *network)
 
ProcessorNetworkgetNetwork () const
 
virtual void initializeResources ()
 
PortgetPort (std::string_view identifier) const
 
InportgetInport (std::string_view identifier) const
 
OutportgetOutport (std::string_view identifier) const
 
const std::vector< Inport * > & getInports () const
 
const std::vector< Outport * > & getOutports () const
 
const std::string & getPortGroup (Port *port) const
 
std::vector< std::string > getPortGroups () const
 
const std::vector< Port * > & getPortsInGroup (std::string_view portGroup) const
 
const std::vector< Port * > & getPortsInSameGroup (Port *port) const
 
bool allInportsConnected () const
 
bool allInportsAreReady () const
 
bool isSource () const
 
bool isSink () const
 
bool isReady () const
 
const ProcessorStatusstatus () const
 
virtual void doIfNotReady ()
 
virtual void setValid () override
 
virtual void invalidate (InvalidationLevel invalidationLevel, Property *modifiedProperty=nullptr) override
 
void addInteractionHandler (InteractionHandler *interactionHandler)
 
void removeInteractionHandler (InteractionHandler *interactionHandler)
 
bool hasInteractionHandler () const
 
const std::vector< InteractionHandler * > & getInteractionHandlers () const
 
virtual void invokeEvent (Event *event) override
 
virtual ProcessorgetProcessor () override
 
virtual const ProcessorgetProcessor () const override
 
virtual const PropertyOwnergetOwner () const override
 
virtual PropertyOwnergetOwner () override
 
virtual InviwoApplicationgetInviwoApplication () override
 
template<typename T , typename std::enable_if_t< std::is_base_of< Inport, T >::value, int > = 0>
T & addPort (std::unique_ptr< T > port, std::string_view portGroup="default")
 
template<typename T , typename std::enable_if_t< std::is_base_of< Outport, T >::value, int > = 0>
T & addPort (std::unique_ptr< T > port, std::string_view portGroup="default")
 
template<typename T >
T & addPort (T &port, std::string_view portGroup="default")
 
template<typename... Ts>
void addPorts (Ts &... ports)
 
PortremovePort (std::string_view identifier)
 
InportremovePort (Inport *port)
 
OutportremovePort (Outport *port)
 
virtual bool isConnectionActive (Inport *inport, Outport *outport) const
 
virtual void accept (NetworkVisitor &visitor)
 Accept a NetworkVisitor, the visitor will visit this and then each Property of the Processor in an undefined order. The Visitor will then visit each Properties's properties and so on.
 
- Public Member Functions inherited from inviwo::PropertyOwner
virtual ~PropertyOwner ()
 Removes all properties and notifies its observers of the removal.
 
virtual void addProperty (Property *property, bool owner=true)
 
virtual void addProperty (Property &property)
 
virtual PropertyaddProperty (std::unique_ptr< Property > property)
 
template<typename... Ts>
void addProperties (Ts &... properties)
 
virtual void insertProperty (size_t index, Property *property, bool owner=true)
 insert property property at position index If index is not valid, the property is appended.
 
virtual void insertProperty (size_t index, Property &property)
 insert property property at position index If index is not valid, the property is appended.
 
virtual PropertyinsertProperty (size_t index, std::unique_ptr< Property > property)
 insert property property at position index If index is not valid, the property is appended.
 
virtual PropertyremoveProperty (std::string_view identifier)
 
virtual PropertyremoveProperty (Property *property)
 
virtual PropertyremoveProperty (Property &property)
 
virtual PropertyremoveProperty (size_t index)
 remove property referred to by index
 
virtual bool move (Property *property, size_t newIndex)
 
virtual void clear ()
 Remove all properties; Owned properties will be deleted.
 
const std::vector< Property * > & getProperties () const
 
const std::vector< CompositeProperty * > & getCompositeProperties () const
 
std::vector< Property * > getPropertiesRecursive () const
 
std::vector< Property * > & getPropertiesRecursive (std::vector< Property * > &destination) const
 
PropertygetPropertyByIdentifier (std::string_view identifier, bool recursiveSearch=false) const
 
PropertygetPropertyByPath (std::string_view path) const
 
template<class T >
std::vector< T * > getPropertiesByType (bool recursiveSearch=false) const
 
bool empty () const
 
size_t size () const
 
Propertyoperator[] (size_t)
 
const Propertyoperator[] (size_t) const
 
const_iterator find (Property *property) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
virtual bool isValid () const
 
InvalidationLevel getInvalidationLevel () const
 
virtual void setAllPropertiesCurrentStateAsDefault ()
 
virtual void resetAllProperties ()
 
- Public Member Functions inherited from inviwo::PropertyOwnerObservable
void notifyObserversWillAddProperty (PropertyOwner *owner, Property *property, size_t index)
 
void notifyObserversDidAddProperty (Property *property, size_t index)
 
void notifyObserversWillRemoveProperty (Property *property, size_t index)
 
void notifyObserversDidRemoveProperty (PropertyOwner *owner, Property *property, size_t index)
 
- Public Member Functions inherited from inviwo::Observable< PropertyOwnerObserver >
 Observable (const Observable< PropertyOwnerObserver > &other)
 
 Observable (Observable< PropertyOwnerObserver > &&other) noexcept
 
Observable< PropertyOwnerObserver > & operator= (const Observable< PropertyOwnerObserver > &other)
 
Observable< PropertyOwnerObserver > & operator= (Observable< PropertyOwnerObserver > &&other) noexcept
 
void addObserver (PropertyOwnerObserver *observer)
 
void removeObserver (PropertyOwnerObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::ObservableInterface
- Public Member Functions inherited from inviwo::Serializable
- Public Member Functions inherited from inviwo::EventListener
- Public Member Functions inherited from inviwo::MetaDataOwner
 MetaDataOwner (const MetaDataOwner &rhs)=default
 
 MetaDataOwner (MetaDataOwner &rhs)=default
 
MetaDataOwneroperator= (const MetaDataOwner &rhs)=default
 
MetaDataOwneroperator= (MetaDataOwner &)=default
 
void copyMetaDataFrom (const MetaDataOwner &src)
 
void copyMetaDataTo (MetaDataOwner &dst)
 
template<typename T >
requires std::derived_from<T, MetaData>
T * createMetaData (std::string_view key)
 
template<typename T , typename U >
requires std::derived_from<T, MetaData> && Settable<T, U>
void setMetaData (std::string_view key, U value)
 
template<typename T >
requires std::derived_from<T, MetaData>
bool unsetMetaData (std::string_view key)
 unset, i.e. remove the metadata entry matching the given key and type
 
template<typename T , typename U >
requires std::derived_from<T, MetaData> && Gettable<T, U>
getMetaData (std::string_view key, U val) const
 
template<typename T >
requires std::derived_from<T, MetaData>
T * getMetaData (std::string_view key)
 
template<typename T >
requires std::derived_from<T, MetaData>
const T * getMetaData (std::string_view key) const
 
MetaDataMapgetMetaDataMap ()
 
const MetaDataMapgetMetaDataMap () const
 
bool hasMetaData (std::string_view key) const
 
template<typename T >
requires std::derived_from<T, MetaData>
bool hasMetaData (std::string_view key) const
 
void serialize (Serializer &s) const
 
void deserialize (Deserializer &d)
 
- Public Member Functions inherited from inviwo::Observable< ProcessorObserver >
 Observable (const Observable< ProcessorObserver > &other)
 
 Observable (Observable< ProcessorObserver > &&other) noexcept
 
Observable< ProcessorObserver > & operator= (const Observable< ProcessorObserver > &other)
 
Observable< ProcessorObserver > & operator= (Observable< ProcessorObserver > &&other) noexcept
 
void addObserver (ProcessorObserver *observer)
 
void removeObserver (ProcessorObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::EventPropagator
- Public Member Functions inherited from inviwo::ProcessorNetworkObserver
virtual void onProcessorNetworkChange ()
 
virtual void onProcessorNetworkUnlocked ()
 
virtual void onProcessorNetworkWillAddProcessor (Processor *)
 
virtual void onProcessorNetworkDidRemoveProcessor (Processor *)
 
virtual void onProcessorNetworkWillAddConnection (const PortConnection &)
 
virtual void onProcessorNetworkDidAddConnection (const PortConnection &)
 
virtual void onProcessorNetworkWillRemoveConnection (const PortConnection &)
 
virtual void onProcessorNetworkDidRemoveConnection (const PortConnection &)
 
virtual void onProcessorNetworkWillAddLink (const PropertyLink &)
 
virtual void onProcessorNetworkDidAddLink (const PropertyLink &)
 
virtual void onProcessorNetworkWillRemoveLink (const PropertyLink &)
 
virtual void onProcessorNetworkDidRemoveLink (const PropertyLink &)
 
- Public Member Functions inherited from inviwo::Observer
 Observer (const Observer &other)
 
 Observer (Observer &&other)
 
Observeroperator= (Observer &&other)
 
Observeroperator= (const Observer &other)
 
virtual ~Observer ()
 
void removeObservation (ObservableInterface *observable)
 
void removeObservations ()
 
- Public Member Functions inherited from inviwo::PropertyOwnerObserver
virtual void onWillAddProperty (PropertyOwner *owner, Property *property, size_t index)
 
virtual void onDidRemoveProperty (PropertyOwner *owner, Property *property, size_t index)
 
- Public Member Functions inherited from inviwo::PropertyObserver
- Public Member Functions inherited from inviwo::ProgressBarOwner
ProgressBargetProgressBar ()
 
const ProgressBargetProgressBar () const
 
void updateProgress (float progress)
 

Static Public Attributes

static const ProcessorInfo processorInfo_
 

Additional Inherited Members

- Public Types inherited from inviwo::Processor
using NameDispatcher = Dispatcher<void(std::string_view, std::string_view)>
 
using NameDispatcherHandle = typename NameDispatcher::Handle
 
- Public Types inherited from inviwo::PropertyOwner
using iterator = std::vector<Property*>::iterator
 
using const_iterator = std::vector<Property*>::const_iterator
 
- Public Attributes inherited from inviwo::ProcessorNetworkObserver
friend ProcessorNetworkObservable
 
- Public Attributes inherited from inviwo::PropertyOwnerObserver
friend PropertyOwnerObservable
 
- Protected Member Functions inherited from inviwo::Processor
void addPortToGroup (Port *port, std::string_view portGroup)
 
void removePortFromGroups (Port *port)
 
void setInportsChanged (bool changed)
 
- Protected Member Functions inherited from inviwo::PropertyOwner
 PropertyOwner (const PropertyOwner &rhs)
 
PropertyOwneroperator= (const PropertyOwner &that)=delete
 
void forEachProperty (std::function< void(Property &)> callback, bool recursiveSearch=false) const
 
- Protected Member Functions inherited from inviwo::Observable< PropertyOwnerObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::ObservableInterface
void addObservationHelper (Observer *observer)
 
void removeObservationHelper (Observer *observer)
 
- Protected Member Functions inherited from inviwo::ProcessorObservable
void notifyObserversAboutPropertyChange (Property *p)
 
void notifyObserversInvalidationBegin (Processor *p)
 
void notifyObserversInvalidationEnd (Processor *p)
 
void notifyObserversProcessorPortAdded (Processor *p, Port *port)
 
void notifyObserversProcessorPortRemoved (Processor *p, Port *port)
 
void notifyObserversAboutToProcess (Processor *p)
 
void notifyObserversFinishedProcess (Processor *p)
 
void notifyObserversSourceChange (Processor *p)
 
void notifyObserversSinkChange (Processor *p)
 
void notifyObserversReadyChange (Processor *p)
 
void notifyObserversActiveConnectionsChange (Processor *p)
 
void notifyObserversStartBackgroundWork (Processor *p, size_t jobs=1)
 
void notifyObserversFinishBackgroundWork (Processor *p, size_t jobs=1)
 
- Protected Member Functions inherited from inviwo::Observable< ProcessorObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::Observer
void addObservation (ObservableInterface *observable)
 
- Static Protected Member Functions inherited from inviwo::Processor
static std::function< ProcessorStatus()> getDefaultIsReadyUpdater (Processor *)
 
- Protected Attributes inherited from inviwo::Processor
std::unique_ptr< ProcessorWidgetprocessorWidget_
 
StateCoordinator< ProcessorStatusisReady_
 
StateCoordinator< bool > isSink_
 
StateCoordinator< bool > isSource_
 
- Protected Attributes inherited from inviwo::PropertyOwner
std::vector< Property * > properties_
 
std::vector< EventProperty * > eventProperties_
 
std::vector< CompositeProperty * > compositeProperties_
 
std::vector< std::unique_ptr< Property > > ownedProperties_
 
- Protected Attributes inherited from inviwo::MetaDataOwner
MetaDataMap metaData_
 
- Protected Attributes inherited from inviwo::ProcessorObservable
friend ProcessorNetworkEvaluator
 
friend Property
 
- Protected Attributes inherited from inviwo::Observer
std::unordered_set< ObservableInterface * > observables_
 
- Protected Attributes inherited from inviwo::ProgressBarOwner
ProgressBar progressBar_
 

Detailed Description

A processor containing a network of processors, i.e. it will act as a sub network within a processor network. A CompositeProcessor can be used to reduce cluttering in the network. Also makes it easy to reuse groups of processors inside of a network, and across network since they can be saved in the processor list. A CompositeProcessor is usually created by selecting a group of processors that are closely related in the network editor and then clicking "create composite" in the context menu. Use InviwoModule::registerCompositeProcessor to register a saved composite in your module.

The network inside of the CompositeProcessors is called the sub network and the network of the CompositeProcessor the super network. The CompositeProcessor will only evaluate its sub network when its process function is called, and otherwise keep it locked.

How it works The CompositeProcessor will observe its sub network and when a processor gets added to the sub network the CompositeProcessor will check if it's a CompositeSource or a CompositeSink. In the case it's a CompositeSource, which acts as data inputs in the sub network, in will get the special "super" inport and add it to it self. If it's a CompositeSink, which acts as data outputs, it will get the "super" outport and add it to it self.

When the CompositeSource gets evaluated in the sub network it will take the data from its super inport and put in its outport, moving the data from the super network to the sub network. At the end of the sub network evaluation the SinkProcessors will be evaluated and take the data on its inport and put on its super outport, moving the data from the sub network into the super network.

Properties in the sub network that are marked with application usage mode, or added by calling addSuperProperty, will be cloned and added to the composite processor with mutual onChange callbacks to keep them in sync, exposing the sub property's state to the super network.

Events are propagated through the sub network using the super inport and outports in the Source and Sink Processors.

Design considerations Many designs for composite processors were considered, including implementing it as a pure GUI feature having all the processors in the same network. The current design of completely encapsulating the sub network was chosen since it minimizes the amount of logic in the GUI. Hence keeping the simple mapping from processor network to GUI. It also completely hides the sub network from the super network making it possible to compose sub network in several layers out of the box.

See also
CompositeSource
CompositeSink

Constructor & Destructor Documentation

◆ CompositeProcessor()

inviwo::CompositeProcessor::CompositeProcessor ( std::string_view identifier,
std::string_view displayName,
InviwoApplication * app,
const std::filesystem::path & filename = "" )

Construct a CompositeProcessor, an optional workspace file can be supplied in which case it is deserialized as the CompositeProcessors sub network. otherwise the network is left empty. getSubNetwork can then be use to add processors etc.

Member Function Documentation

◆ addSuperProperty()

Property * inviwo::CompositeProcessor::addSuperProperty ( Property * subProperty)

Add a corresponding property in the CompositeProcessor for the sub property 'subProperty' in the sub network. Changes in the subProperty will be reflected in the superProperty and vice versa.

◆ deserialize()

virtual void inviwo::CompositeProcessor::deserialize ( Deserializer & d)
overridevirtual

Reimplemented from inviwo::Processor.

◆ getProcessorInfo()

virtual const ProcessorInfo & inviwo::CompositeProcessor::getProcessorInfo ( ) const
overridevirtual

Implements inviwo::Processor.

◆ getSubNetwork()

ProcessorNetwork & inviwo::CompositeProcessor::getSubNetwork ( )

Get access to the sub network to add or remove processors etc

◆ getSubProperty()

Property * inviwo::CompositeProcessor::getSubProperty ( Property * superProperty)

Get the sub property for super property 'superProperty'.

◆ getSuperProperty()

Property * inviwo::CompositeProcessor::getSuperProperty ( Property * subProperty)

Get the super property for sub property 'subProperty' given there is one, nullptr otherwise.

◆ process()

virtual void inviwo::CompositeProcessor::process ( )
overridevirtual

Evaluates the sub network

Reimplemented from inviwo::Processor.

◆ propagateEvent()

virtual void inviwo::CompositeProcessor::propagateEvent ( Event * event,
Outport * source )
overridevirtual

Propagates events through the sub network using the sink and source processors

Reimplemented from inviwo::Processor.

◆ removeSuperProperty()

void inviwo::CompositeProcessor::removeSuperProperty ( Property * subProperty)

Remove the super property for sub property 'subProperty'.

◆ saveSubNetwork()

void inviwo::CompositeProcessor::saveSubNetwork ( const std::filesystem::path & file)

Save the current network into the composites folder of the user settings dir. The current display name will be used as filename. Saved networks will automatically appear as Processors in the processor list, with the same display name.

◆ serialize()

virtual void inviwo::CompositeProcessor::serialize ( Serializer & s) const
overridevirtual

Reimplemented from inviwo::Processor.


The documentation for this class was generated from the following file: