Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
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
 
using const_iterator
 

Public Member Functions

 TFPrimitiveSet (const std::vector< TFPrimitiveData > &values={}, TFPrimitiveSetType type=TFPrimitiveSetType::Relative)
 
 TFPrimitiveSet (const TFPrimitiveSet &rhs)
 
 TFPrimitiveSet (TFPrimitiveSet &&rhs) noexcept=default
 
TFPrimitiveSetoperator= (const TFPrimitiveSet &rhs)
 
TFPrimitiveSetoperator= (TFPrimitiveSet &&rhs) noexcept
 
void setType (TFPrimitiveSetType type)
 
TFPrimitiveSetType getType () 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 (std::span< const TFPrimitiveData >)
 
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
 
std::vector< double > getPositions () const
 
std::vector< float > getPositionsf () const
 
std::vector< vec4 > getColors () const
 
TFPrimitiveadd (const TFPrimitive &primitive)
 
TFPrimitiveadd (double pos, const vec4 &color)
 
TFPrimitiveadd (double pos, double alpha)
 
TFPrimitiveadd (const dvec2 &pos)
 
TFPrimitiveadd (const TFPrimitiveData &data)
 
void add (const std::vector< TFPrimitiveData > &primitives)
 
bool remove (const TFPrimitive &primitive)
 
void clear ()
 
void setPosition (std::span< TFPrimitive * > primitives, double pos)
 
virtual void onTFPrimitiveChange (const TFPrimitive &p) override
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
virtual void interpolateAndStoreColors (std::span< vec4 > data) const
 
bool operator== (const std::vector< TFPrimitiveData > &rhs) const
 
bool contains (const TFPrimitive *primitive) const
 
- Public Member Functions inherited from inviwo::Serializable
- Public Member Functions inherited from inviwo::Observable< TFPrimitiveSetObserver >
 Observable (const Observable< TFPrimitiveSetObserver > &other)
 
 Observable (Observable< TFPrimitiveSetObserver > &&other) noexcept
 
Observable< TFPrimitiveSetObserver > & operator= (const Observable< TFPrimitiveSetObserver > &other)
 
Observable< TFPrimitiveSetObserver > & operator= (Observable< TFPrimitiveSetObserver > &&other) noexcept
 
void addObserver (TFPrimitiveSetObserver *observer)
 
void removeObserver (TFPrimitiveSetObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::ObservableInterface
- Public Member Functions inherited from inviwo::TFPrimitiveObserver
- 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

TFPrimitiveadd (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_view serializationKey () const
 
virtual std::string_view serializationItemKey () const
 
- Protected Member Functions inherited from inviwo::TFPrimitiveSetObservable
void notifyTFPrimitiveAdded (const TFPrimitiveSet &set, TFPrimitive &p)
 
void notifyTFPrimitiveRemoved (const TFPrimitiveSet &set, TFPrimitive &p)
 
void notifyTFPrimitiveChanged (const TFPrimitiveSet &set, const TFPrimitive &p)
 
void notifyTFTypeChanged (const TFPrimitiveSet &set, TFPrimitiveSetType type)
 
void notifyTFMaskChanged (const TFPrimitiveSet &set, dvec2 mask)
 
- 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
std::unordered_set< ObservableInterface * > observables_
 

Friends

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

Detailed Description

data structure managing multiple TFPrimitives

See also
TFPrimitive

Member Typedef Documentation

◆ const_iterator

Initial value:
util::TransformIterator<const_transform_t,
typename std::vector<TFPrimitive*>::const_iterator>

◆ iterator

Initial value:
util::TransformIterator<transform_t, typename std::vector<TFPrimitive*>::iterator>

Member Function Documentation

◆ add() [1/6]

TFPrimitive & 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() [2/6]

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]

◆ add() [3/6]

TFPrimitive & 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() [4/6]

TFPrimitive & 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/6]

TFPrimitive & 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() [6/6]

TFPrimitive & inviwo::TFPrimitiveSet::add ( double pos,
double alpha )

Add a TFPrimitive at pos with alpha. The color is interpolated from existing TFPrimitives before and after the given position

Parameters
posposition of the TFPrimitive,
alphaalpha value of the TFPrimitive
Exceptions
RangeExceptionif TF type is relative and pos is outside [0,1]

◆ deserialize()

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

Implements inviwo::Serializable.

◆ getColors()

std::vector< vec4 > inviwo::TFPrimitiveSet::getColors ( ) const

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

Returns
vector of TFPrimitives' colors sorted increasingly regarding position

◆ getPositions()

std::vector< double > inviwo::TFPrimitiveSet::getPositions ( ) const

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

Returns
vector of TFPrimitives' positions sorted increasingly regarding position

◆ getPositionsf()

std::vector< float > inviwo::TFPrimitiveSet::getPositionsf ( ) const

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

Returns
vector of TFPrimitives' positions sorted increasingly regarding position

◆ 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

◆ getVectorsf()

std::pair< std::vector< float >, std::vector< vec4 > > inviwo::TFPrimitiveSet::getVectorsf ( ) 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

◆ interpolateAndStoreColors()

virtual void inviwo::TFPrimitiveSet::interpolateAndStoreColors ( std::span< vec4 > data) const
virtual

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
datawrite interpolated colors into data

Reimplemented in inviwo::TransferFunction.

◆ 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

◆ onTFPrimitiveChange()

virtual void inviwo::TFPrimitiveSet::onTFPrimitiveChange ( const TFPrimitive & p)
overridevirtual

Reimplemented from inviwo::TFPrimitiveObserver.

◆ remove()

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

Removes a primitive from the set

Returns
if a primitive was found and removed

◆ serialize()

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

Implements inviwo::Serializable.

◆ 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 file: