Inviwo  0.9.10.1
Inviwo documentation
inviwo::TFPrimitiveSet Class Reference

data structure managing multiple TFPrimitives More...

#include <tfprimitiveset.h>

+ Inheritance diagram for inviwo::TFPrimitiveSet:

Public Types

using transform_t = TFPrimitive &(*)(TFPrimitive *)
 
using const_transform_t = const TFPrimitive &(*)(const TFPrimitive *)
 
using iterator = util::TransformIterator< transform_t, typename std::vector< TFPrimitive * >::iterator >
 
using const_iterator = util::TransformIterator< const_transform_t, typename std::vector< TFPrimitive * >::const_iterator >
 

Public Member Functions

 TFPrimitiveSet (const std::vector< TFPrimitiveData > &values={}, TFPrimitiveSetType type=TFPrimitiveSetType::Relative)
 
 TFPrimitiveSet (const TFPrimitiveSet &rhs)
 
 TFPrimitiveSet (TFPrimitiveSet &&rhs)=default
 
TFPrimitiveSetoperator= (const TFPrimitiveSet &rhs)
 
void setType (TFPrimitiveSetType type)
 
TFPrimitiveSetType getType () const
 
virtual std::string getTitle () const
 
dvec2 getRange () const
 
size_t size () const
 
bool empty () const
 
TFPrimitiveoperator[] (size_t i)
 
const TFPrimitiveoperator[] (size_t i) const
 
TFPrimitiveget (size_t i)
 
const TFPrimitiveget (size_t i) const
 
TFPrimitivefront ()
 
const TFPrimitivefront () const
 
TFPrimitiveback ()
 
const TFPrimitiveback () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
std::vector< TFPrimitiveDataget () const
 
std::vector< TFPrimitiveDatagetUnsorted () const
 
void set (const_iterator begin, const_iterator end)
 
std::pair< std::vector< double >, std::vector< vec4 > > getVectors () const
 
std::pair< std::vector< float >, std::vector< vec4 > > getVectorsf () const
 
void add (const TFPrimitive &primitive)
 
void add (double pos, const vec4 &color)
 
void add (const dvec2 &pos)
 
void add (const TFPrimitiveData &data)
 
void add (const std::vector< TFPrimitiveData > &primitives)
 
bool remove (const TFPrimitive &primitive)
 
void clear ()
 
void setPosition (const std::vector< TFPrimitive * > primitives, double pos)
 
void setAlpha (const std::vector< TFPrimitive * > primitives, double alpha)
 
void setColor (const std::vector< TFPrimitive * > primitives, const vec3 &color)
 
virtual void onTFPrimitiveChange (const TFPrimitive &p) override
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
virtual void invalidate ()
 
virtual std::vector< FileExtensiongetSupportedExtensions () const
 
virtual void save (const std::string &filename, const FileExtension &ext=FileExtension()) const
 
virtual void load (const std::string &filename, const FileExtension &ext=FileExtension())
 
void interpolateAndStoreColors (vec4 *dataArray, const size_t size) const
 
void flipPositions (const std::vector< TFPrimitive * > &primitives={})
 
void interpolateAlpha (const std::vector< TFPrimitive * > &primitives={})
 
void equalizeAlpha (const std::vector< TFPrimitive * > &primitives={})
 
- Public Member Functions inherited from inviwo::Observable< TFPrimitiveSetObserver >
 Observable (const Observable< TFPrimitiveSetObserver > &other)
 
 Observable (Observable< TFPrimitiveSetObserver > &&other)
 
Observable< TFPrimitiveSetObserver > & operator= (const Observable< TFPrimitiveSetObserver > &other)
 
Observable< TFPrimitiveSetObserver > & operator= (Observable< TFPrimitiveSetObserver > &&other)
 
void addObserver (TFPrimitiveSetObserver *observer)
 
void removeObserver (TFPrimitiveSetObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- 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 ()
 

Protected Member Functions

void add (std::unique_ptr< TFPrimitive > primitive)
 
bool remove (std::vector< std::unique_ptr< TFPrimitive >>::iterator it)
 
void sort ()
 
vec4 interpolateColor (double t) const
 
virtual std::string serializationKey () const
 
virtual std::string serializationItemKey () const
 
- Protected Member Functions inherited from inviwo::TFPrimitiveSetObservable
void notifyTFPrimitiveAdded (TFPrimitive &p)
 
void notifyTFPrimitiveRemoved (TFPrimitive &p)
 
void notifyTFPrimitiveChanged (const TFPrimitive &p)
 
void notifyTFTypeChanged (const TFPrimitiveSet &primitiveSet)
 
- Protected Member Functions inherited from inviwo::Observable< TFPrimitiveSetObserver >
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::Observer
void addObservation (ObservableInterface *observable)
 

Protected Attributes

std::vector< std::unique_ptr< TFPrimitive > > values_
 
std::vector< TFPrimitive * > sorted_
 
- Protected Attributes inherited from inviwo::Observer
ObservableSet observables_
 

Friends

bool operator== (const TFPrimitiveSet &lhs, const TFPrimitiveSet &rhs)
 

Additional Inherited Members

- Protected Types inherited from inviwo::Observer
using ObservableSet = std::unordered_set< ObservableInterface * >
 

Detailed Description

data structure managing multiple TFPrimitives

See also
TFPrimitive

Member Function Documentation

◆ add() [1/5]

void inviwo::TFPrimitiveSet::add ( const TFPrimitive primitive)

Add a TFPrimitive

Parameters
primitiveTFPrimitive to be added
Exceptions
RangeExceptionif TF type is relative and the primitive position is outside [0,1]

◆ add() [2/5]

void inviwo::TFPrimitiveSet::add ( double  pos,
const vec4 &  color 
)

Add a TFPrimitive

Parameters
posrefers to the position of the TFPrimitive
colorcolor of the TFPrimitive including alpha
Exceptions
RangeExceptionif TF type is relative and pos is outside [0,1]

◆ add() [3/5]

void inviwo::TFPrimitiveSet::add ( const dvec2 &  pos)

Add a TFPrimitive at pos.x where pos.y is used as alpha and the color is interpolated from existing TFPrimitives before and after the given position

Parameters
pospos.x refers to the position of the TFPrimitive, pos.y will be mapped to alpha
Exceptions
RangeExceptionif TF type is relative and pos.x is outside [0,1]

◆ add() [4/5]

void inviwo::TFPrimitiveSet::add ( const TFPrimitiveData data)

Add a TFPrimitive

Parameters
dataPrimitive to be added
Exceptions
RangeExceptionif TF type is relative and position of point is outside [0,1]

◆ add() [5/5]

void inviwo::TFPrimitiveSet::add ( const std::vector< TFPrimitiveData > &  primitives)

Add multiple TFPrimitives

Parameters
primitivesvector of primitives to be added
Exceptions
RangeExceptionif TF type is relative and any of the given points is outside [0,1]

◆ equalizeAlpha()

void inviwo::TFPrimitiveSet::equalizeAlpha ( const std::vector< TFPrimitive * > &  primitives = {})

set the alphas value of all primitives to the average alpha value. If primitives is empty, the entire TFPrimitiveSet is equalized.

◆ flipPositions()

void inviwo::TFPrimitiveSet::flipPositions ( const std::vector< TFPrimitive * > &  primitives = {})

flip the positions of the primitives with respect to the respective range, i.e. p' = range.max - (p - range.min) with range.min/max corresponding to the lowest/highest position in primitives. If primitives is empty, the entire TFPrimitiveSet is flipped using TFPrimitiveSet::getRange().

Parameters
primitiveslist of primitives to be flipped. If empty, the entire primitive set is flipped.

◆ getRange()

dvec2 inviwo::TFPrimitiveSet::getRange ( ) const

returns the range of the TF. For a relative TF this will return [0,1]. In case of an absolute TF the range between first and last TF primitive is returned. If there are no primitives in the TF [0,1] will be returned.

Returns
range of TF

◆ getVectors()

std::pair< std::vector< double >, std::vector< vec4 > > inviwo::TFPrimitiveSet::getVectors ( ) const

Access TFPrimitives as pair of vectors which can be used, e.g., for setting uniforms of a shader.

Returns
vectors of TFPrimitives' position and color sorted increasingly regarding position

◆ interpolateAlpha()

void inviwo::TFPrimitiveSet::interpolateAlpha ( const std::vector< TFPrimitive * > &  primitives = {})

interpolate the alpha values of all primitives in between the first and the last primitive based on their relative position. If primitives is empty, the alpha of the entire TFPrimitiveSet will be adjusted.

◆ interpolateAndStoreColors()

void inviwo::TFPrimitiveSet::interpolateAndStoreColors ( vec4 *  dataArray,
const size_t  size 
) const

Interpolate the color between all neighboring pairs of TFPrimitives and write the result to dataArray. The range of all TFPrimitives is [0,1] when TF type is relative

Parameters
dataArraywrite location for interpolated colors
sizesize of dataArray

◆ interpolateColor()

vec4 inviwo::TFPrimitiveSet::interpolateColor ( double  t) const
protected

Interpolate the color between TFPrimitives at position t and return the respective color and opacity (rgba). The range of all TFPrimitives is [0,1] when TF type is relative

Parameters
tsampling position, if TF type is relative and t is outside the range [0,1] it is clamped to [0,1]
Returns
color and opacity at position t

◆ invalidate()

virtual void inviwo::TFPrimitiveSet::invalidate ( )
inlinevirtual

gets called every time when a primitive is added, removed, or changed before notifying the observers. Can be used to invalidate the internal state of derived classes.

Reimplemented in inviwo::TransferFunction.

◆ remove()

bool inviwo::TFPrimitiveSet::remove ( const TFPrimitive primitive)

Removes a primitive from the set

Returns
if a primitive was found and removed

◆ set()

void inviwo::TFPrimitiveSet::set ( const_iterator  begin,
const_iterator  end 
)

Set/update the list of TFPrimitives from given range


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