![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Color scale. More...
#include <ecvColorScale.h>


Classes | |
| struct | Label |
| Color scale label (value + optional text) More... | |
Public Types | |
| typedef QSharedPointer< ccColorScale > | Shared |
| Shared pointer type. More... | |
| using | LabelSet = std::set< Label > |
| Type of a list of custom labels. More... | |
Public Types inherited from ccSerializableObject | |
| enum | DeserializationFlags { DF_POINT_COORDS_64_BITS , DF_SCALAR_VAL_32_BITS = 2 } |
| Deserialization flags (bit-field) More... | |
| typedef QMultiMap< unsigned, unsigned > | LoadedIDMap |
| Map of loaded unique IDs (old ID --> new ID) More... | |
Public Member Functions | |
| ccColorScale (const QString &name, const QString &uuid=QString()) | |
| Default constructor. More... | |
| virtual | ~ccColorScale () |
| Destructor. More... | |
| ccColorScale::Shared | copy (const QString &uuid=QString()) const |
| Creates a copy of this color scale (with a specified unique id) More... | |
| const QString & | getName () const |
| Returns name. More... | |
| void | setName (const QString &name) |
| Sets name. More... | |
| QString | getUuid () const |
| Returns unique ID. More... | |
| void | setUuid (QString uuid) |
| Sets unique ID. More... | |
| void | generateNewUuid () |
| Generates a new unique ID. More... | |
| bool | isRelative () const |
| Returns whether scale is relative or absoute. More... | |
| void | setRelative () |
| Sets scale as relative. More... | |
| void | setAbsolute (double minVal, double maxVal) |
| Sets scale as absolute. More... | |
| void | getAbsoluteBoundaries (double &minVal, double &maxVal) const |
| Get absolute scale boundaries. More... | |
| bool | isLocked () const |
| Returns whether scale is locked or not. More... | |
| void | setLocked (bool state) |
| Sets whether scale is locked or not. More... | |
| LabelSet & | customLabels () |
| Returns the list of custom labels (if any) More... | |
| const LabelSet & | customLabels () const |
| Returns the list of custom labels (if any - const version) More... | |
| void | setCustomLabels (const LabelSet &labels) |
| Sets the list of custom labels (only if the scale is absolute) More... | |
| int | stepCount () const |
| Returns the current number of steps. More... | |
| ccColorScaleElement & | step (int index) |
| Access to a given step. More... | |
| const ccColorScaleElement & | step (int index) const |
| Access to a given step (const) More... | |
| void | insert (const ccColorScaleElement &step, bool autoUpdate=true) |
| Adds a step. More... | |
| void | remove (int index, bool autoUpdate=true) |
| Deletes a given step. More... | |
| void | clear () |
| Clears all steps. More... | |
| void | update () |
| Updates internal representation. More... | |
| double | getRelativePosition (double value) const |
| const ecvColor::Rgb * | getColorByValue (double value, const ecvColor::Rgb *outOfRangeColor=nullptr) const |
| Returns color by value. More... | |
| const ecvColor::Rgb * | getColorByRelativePos (double relativePos, const ecvColor::Rgb *outOfRangeColor=nullptr) const |
| Returns color by relative position in scale. More... | |
| const ecvColor::Rgb * | getColorByRelativePos (double relativePos, unsigned steps, const ecvColor::Rgb *outOfRangeColor=nullptr) const |
| Returns color by relative position in scale with a given 'resolution'. More... | |
| const ecvColor::Rgb & | getColorByIndex (unsigned index) const |
| Returns color by index. More... | |
| bool | saveAsXML (QString filename) const |
| Saves this color scale as an XML file. More... | |
| bool | isSerializable () const override |
| Returns whether object is serializable of not. More... | |
| bool | toFile (QFile &out, short dataVersion) const override |
| Saves data to binary stream. More... | |
| short | minimumFileVersion () const override |
| Returns the minimum file version required to save this instance. More... | |
| bool | fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override |
| Loads data from binary stream. More... | |
Public Member Functions inherited from ccSerializableObject | |
| virtual | ~ccSerializableObject ()=default |
| Destructor. More... | |
Static Public Member Functions | |
| static ccColorScale::Shared | Create (const QString &name) |
| Creates a new color scale (with auto-generated unique id) More... | |
| static Shared | LoadFromXML (QString filename) |
| Loads a color scale from an XML file. More... | |
Static Public Member Functions inherited from ccSerializableObject | |
| static bool | WriteError () |
| Sends a custom error message (write error) and returns 'false'. More... | |
| static bool | ReadError () |
| Sends a custom error message (read error) and returns 'false'. More... | |
| static bool | MemoryError () |
| Sends a custom error message (not enough memory) and returns 'false'. More... | |
| static bool | CorruptError () |
| Sends a custom error message (corrupted file) and returns 'false'. More... | |
Static Public Attributes | |
| static const unsigned | MIN_STEPS = 2 |
| Minimum number of steps. More... | |
| static const unsigned | DEFAULT_STEPS = 256 |
| Default number of steps for display. More... | |
| static const unsigned | MAX_STEPS = 1024 |
| Maximum number of steps (internal representation) More... | |
Protected Member Functions | |
| void | sort () |
| Sort elements. More... | |
Protected Attributes | |
| QString | m_name |
| Name. More... | |
| QString | m_uuid |
| Unique ID. More... | |
| QList< ccColorScaleElement > | m_steps |
| Elements. More... | |
| ecvColor::Rgb | m_rgbaScale [MAX_STEPS] |
| Internal representation (RGB) More... | |
| bool | m_updated |
| Internal representation validity. More... | |
| bool | m_relative |
| Whether scale is relative or not. More... | |
| bool | m_locked |
| Whether scale is locked or not. More... | |
| double | m_absoluteMinValue |
| 'Absolute' minimum value More... | |
| double | m_absoluteRange |
| 'Absolute' range More... | |
| LabelSet | m_customLabels |
| List of custom labels. More... | |
Color scale.
A color scale is defined by several 'steps' corresponding to given colors. The color between each step is linearly interpolated. A valid color scale must have at least 2 steps, one at relative position 0.0 (scale start) and one at relative position 1.0 (scale end). Steps can't be defined outside this interval.
For faster access, a array of interpolated colors is maintained internally. Be sure that the 'refresh' method has been called after any modification(s) of the scale steps (position or color).
Definition at line 71 of file ecvColorScale.h.
| using ccColorScale::LabelSet = std::set<Label> |
Type of a list of custom labels.
Definition at line 160 of file ecvColorScale.h.
| typedef QSharedPointer<ccColorScale> ccColorScale::Shared |
Shared pointer type.
Definition at line 74 of file ecvColorScale.h.
| ccColorScale::ccColorScale | ( | const QString & | name, |
| const QString & | uuid = QString() |
||
| ) |
Default constructor.
| name | scale name |
| uuid | UUID (automatically generated if none is provided) Scale are 'relative' by default (can be changed afterwards, see setAbsolute). On construction they already have the two extreme steps defined (at position 0.0 and 1.0). |
|
virtual |
Destructor.
| void ccColorScale::clear | ( | ) |
Clears all steps.
There should be at least 2 steps for the scale to be valid! Scale must not be locked.
Referenced by define_ccColorScale().
| ccColorScale::Shared ccColorScale::copy | ( | const QString & | uuid = QString() | ) | const |
Creates a copy of this color scale (with a specified unique id)
|
static |
Creates a new color scale (with auto-generated unique id)
Warning: color scale is relative by default.
Referenced by ccColorScaleEditorDialog::copyCurrentScale(), ccColorScaleEditorDialog::createNewScale(), and ccEntityAction::setColorGradient().
|
inline |
Returns the list of custom labels (if any)
Definition at line 163 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Returns the list of custom labels (if any - const version)
Definition at line 165 of file ecvColorScale.h.
|
overridevirtual |
Loads data from binary stream.
| in | input file (already opened) |
| dataVersion | file version (for version-specific deserialization) |
| flags | deserialization flags (see ccSerializableObject::DeserializationFlags) |
| oldToNewIDMap | map to link old IDs with new IDs |
Note: When implementing, use dataVersion checks to handle differentversions:
Reimplemented from ccSerializableObject.
| void ccColorScale::generateNewUuid | ( | ) |
Generates a new unique ID.
Referenced by define_ccColorScale().
| void ccColorScale::getAbsoluteBoundaries | ( | double & | minVal, |
| double & | maxVal | ||
| ) | const |
Get absolute scale boundaries.
Warning: only valid with absolute scales!
|
inline |
Returns color by index.
| index | color index in m_rgbaScale array (must be below MAX_STEPS) |
Definition at line 278 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Returns color by relative position in scale.
| relativePos | relative position (should be in [0;1]) |
| outOfRangeColor | default color to return if relativePos if out of [0;1] |
Definition at line 241 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Returns color by relative position in scale with a given 'resolution'.
| relativePos | relative position (must be between 0 and 1!) |
| steps | desired resolution (must be greater than 1 and smaller than MAX_STEPS) |
| outOfRangeColor | default color to return if relativePos if out of [0;1] |
Definition at line 258 of file ecvColorScale.h.
|
inline |
Returns color by value.
Warning: only valid with absolute scales!
| value | value |
| outOfRangeColor | default color to return if relativePos if out of [0;1] |
Definition at line 226 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
|
inline |
Returns relative position of a given value (wrt to scale absolute min and max) Warning: only valid with absolute scales! Use 'getColorByRelativePos' otherwise.
Definition at line 215 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Returns unique ID.
Definition at line 117 of file ecvColorScale.h.
Referenced by define_ccColorScale().
| void ccColorScale::insert | ( | const ccColorScaleElement & | step, |
| bool | autoUpdate = true |
||
| ) |
|
inline |
Returns whether scale is locked or not.
Definition at line 140 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Returns whether scale is relative or absoute.
Relative means that internal 'values' are percentage.
Definition at line 126 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inlineoverridevirtual |
Returns whether object is serializable of not.
Reimplemented from ccSerializableObject.
Definition at line 289 of file ecvColorScale.h.
|
static |
Loads a color scale from an XML file.
Referenced by define_ccColorScale(), ccColorScaleEditorDialog::importScale(), and CommandSFColorScale::process().
|
overridevirtual |
Returns the minimum file version required to save this instance.
To be overridden by subclasses to indicate their minimum required version. This enables the system to determine:
Implements ccSerializableObject.
| void ccColorScale::remove | ( | int | index, |
| bool | autoUpdate = true |
||
| ) |
Deletes a given step.
The first and last index shouldn't be deleted! Scale must not be locked.
Referenced by define_ccColorScale().
| bool ccColorScale::saveAsXML | ( | QString | filename | ) | const |
Saves this color scale as an XML file.
Referenced by define_ccColorScale().
| void ccColorScale::setAbsolute | ( | double | minVal, |
| double | maxVal | ||
| ) |
Sets scale as absolute.
Referenced by define_ccColorScale().
|
inline |
Sets the list of custom labels (only if the scale is absolute)
Definition at line 170 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Sets whether scale is locked or not.
Definition at line 143 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Sets name.
Definition at line 114 of file ecvColorScale.h.
References name.
Referenced by define_ccColorScale().
|
inline |
Sets scale as relative.
Definition at line 129 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Sets unique ID.
Definition at line 119 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
protected |
Sort elements.
|
inline |
Access to a given step.
Definition at line 180 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
inline |
Access to a given step (const)
Definition at line 183 of file ecvColorScale.h.
|
inline |
Returns the current number of steps.
A valid scale should always have at least 2 steps!
Definition at line 177 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
overridevirtual |
Saves data to binary stream.
| out | output file (already opened) |
| dataVersion | target file version (for forward/backward compatibility) |
Reimplemented from ccSerializableObject.
| void ccColorScale::update | ( | ) |
Updates internal representation.
Must be called at least once after any modification (before using this scale).
Referenced by define_ccColorScale().
|
static |
Default number of steps for display.
Definition at line 104 of file ecvColorScale.h.
Referenced by define_ccColorScale().
|
protected |
'Absolute' minimum value
Only used if scale is 'absolute' (i.e. not relative). 'Absolute' should not be taken in its mathematical meaning!
Definition at line 326 of file ecvColorScale.h.
|
protected |
'Absolute' range
Only used if scale is 'absolute' (i.e. not relative). 'Absolute' should not be taken in its mathematical meaning!
Definition at line 332 of file ecvColorScale.h.
|
protected |
List of custom labels.
Definition at line 335 of file ecvColorScale.h.
|
protected |
Whether scale is locked or not.
Definition at line 320 of file ecvColorScale.h.
|
protected |
Name.
Definition at line 302 of file ecvColorScale.h.
|
protected |
Whether scale is relative or not.
Definition at line 317 of file ecvColorScale.h.
|
protected |
Internal representation (RGB)
Definition at line 311 of file ecvColorScale.h.
|
protected |
Elements.
Definition at line 308 of file ecvColorScale.h.
|
protected |
Internal representation validity.
Definition at line 314 of file ecvColorScale.h.
|
protected |
Unique ID.
Definition at line 305 of file ecvColorScale.h.
|
static |
Maximum number of steps (internal representation)
Definition at line 109 of file ecvColorScale.h.
Referenced by ccPropertiesTreeDelegate::createEditor(), define_ccColorScale(), DistanceMapGenerationDlg::DistanceMapGenerationDlg(), and StereogramDialog::StereogramDialog().
|
static |
Minimum number of steps.
Definition at line 99 of file ecvColorScale.h.
Referenced by ccPropertiesTreeDelegate::createEditor(), define_ccColorScale(), DistanceMapGenerationDlg::DistanceMapGenerationDlg(), StereogramDialog::onDensityColorStepsChanged(), and StereogramDialog::StereogramDialog().