Inviwo
0.9.10.1
Inviwo documentation
|
data structure managing multiple TFPrimitives More...
#include <tfprimitiveset.h>
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 | |
TFPrimitiveSet & | operator= (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 |
TFPrimitive & | operator[] (size_t i) |
const TFPrimitive & | operator[] (size_t i) const |
TFPrimitive & | get (size_t i) |
const TFPrimitive & | get (size_t i) const |
TFPrimitive & | front () |
const TFPrimitive & | front () const |
TFPrimitive & | back () |
const TFPrimitive & | back () const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
std::vector< TFPrimitiveData > | get () const |
std::vector< TFPrimitiveData > | getUnsorted () 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< FileExtension > | getSupportedExtensions () 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) | |
Observer & | operator= (Observer &&other) |
Observer & | operator= (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 * > |
data structure managing multiple TFPrimitives
void inviwo::TFPrimitiveSet::add | ( | const TFPrimitive & | primitive | ) |
Add a TFPrimitive
primitive | TFPrimitive to be added |
RangeException | if TF type is relative and the primitive position is outside [0,1] |
void inviwo::TFPrimitiveSet::add | ( | double | pos, |
const vec4 & | color | ||
) |
Add a TFPrimitive
pos | refers to the position of the TFPrimitive |
color | color of the TFPrimitive including alpha |
RangeException | if TF type is relative and pos is outside [0,1] |
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
pos | pos.x refers to the position of the TFPrimitive, pos.y will be mapped to alpha |
RangeException | if TF type is relative and pos.x is outside [0,1] |
void inviwo::TFPrimitiveSet::add | ( | const TFPrimitiveData & | data | ) |
Add a TFPrimitive
data | Primitive to be added |
RangeException | if TF type is relative and position of point is outside [0,1] |
void inviwo::TFPrimitiveSet::add | ( | const std::vector< TFPrimitiveData > & | primitives | ) |
Add multiple TFPrimitives
primitives | vector of primitives to be added |
RangeException | if TF type is relative and any of the given points is outside [0,1] |
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.
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().
primitives | list of primitives to be flipped. If empty, the entire primitive set is flipped. |
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.
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.
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.
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
dataArray | write location for interpolated colors |
size | size of dataArray |
|
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
t | sampling position, if TF type is relative and t is outside the range [0,1] it is clamped to [0,1] |
|
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.
bool inviwo::TFPrimitiveSet::remove | ( | const TFPrimitive & | primitive | ) |
Removes a primitive from the set
void inviwo::TFPrimitiveSet::set | ( | const_iterator | begin, |
const_iterator | end | ||
) |
Set/update the list of TFPrimitives from given range