 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
16 #include <QSharedPointer>
74 typedef QSharedPointer<ccColorScale>
Shared;
99 static const unsigned MIN_STEPS = 2;
104 static const unsigned DEFAULT_STEPS = 256;
109 static const unsigned MAX_STEPS = 1024;
112 inline const QString&
getName()
const {
return m_name; }
121 void generateNewUuid();
132 void setAbsolute(
double minVal,
double maxVal);
137 void getAbsoluteBoundaries(
double& minVal,
double& maxVal)
const;
149 Label(
double v,
const QString& t) : value(v), text(t) {}
155 return value < otherLabel.
value;
171 m_customLabels = labels;
184 return m_steps[index];
196 void remove(
int index,
bool autoUpdate =
true);
216 assert(m_updated && !m_relative);
217 return (value - m_absoluteMinValue) / m_absoluteRange;
229 assert(m_updated && !m_relative);
230 double relativePos = getRelativePosition(value);
231 return (relativePos >= 0.0 && relativePos <= 1.0
232 ? getColorByRelativePos(relativePos)
245 if (relativePos >= 0.0 && relativePos <= 1.0)
246 return &getColorByIndex(
247 static_cast<unsigned>(relativePos * (MAX_STEPS - 1)));
249 return outOfRangeColor;
263 if (relativePos >= 0.0 && relativePos <= 1.0) {
266 (
static_cast<unsigned>((relativePos * steps) * 65535.0)) >>
268 return &getColorByIndex((index * (MAX_STEPS - 1)) / steps);
270 return outOfRangeColor;
279 assert(m_updated && index < MAX_STEPS);
280 return m_rgbaScale[index];
284 bool saveAsXML(QString
filename)
const;
286 static Shared LoadFromXML(QString
filename);
290 bool toFile(QFile& out,
short dataVersion)
const override;
295 LoadedIDMap& oldToNewIDMap)
override;
ccColorScaleElement(double relativePos, QColor color)
Constructor from a (relative) position and a color.
Definition: ecvColorScale.h:28
std::string filename
Definition: PointCloudIO.cpp:47
QColor m_color
Color.
Definition: ecvColorScale.h:57
constexpr Rgb black(0, 0, 0)
bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvColorScale.h:289
QString m_name
Name.
Definition: ecvColorScale.h:302
bool copy
Definition: VtkUtils.cpp:74
Color scale element: one value + one color.
Definition: ecvColorScale.h:22
QSharedPointer< ccColorScale > Shared
Shared pointer type.
Definition: ecvColorScale.h:74
double m_absoluteRange
'Absolute' range
Definition: ecvColorScale.h:332
std::set< Label > LabelSet
Type of a list of custom labels.
Definition: ecvColorScale.h:160
QString text
Definition: ecvColorScale.h:152
double m_relativePos
Step (relative) position.
Definition: ecvColorScale.h:55
virtual bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Loads data from binary stream.
Definition: ecvSerializableObject.h:75
const ecvColor::Rgb * getColorByRelativePos(double relativePos, const ecvColor::Rgb *outOfRangeColor=nullptr) const
Returns color by relative position in scale.
Definition: ecvColorScale.h:241
math::float4 color
Definition: LineSetBuffers.cpp:46
const QColor & getColor() const
Returns color.
Definition: ecvColorScale.h:43
ccColorScaleElement & step(int index)
Access to a given step.
Definition: ecvColorScale.h:180
void setRelative()
Sets scale as relative.
Definition: ecvColorScale.h:129
void setColor(QColor color)
Sets color.
Definition: ecvColorScale.h:41
Label(double v)
Definition: ecvColorScale.h:147
double m_absoluteMinValue
'Absolute' minimum value
Definition: ecvColorScale.h:326
int stepCount() const
Returns the current number of steps.
Definition: ecvColorScale.h:177
double value
Definition: ecvColorScale.h:151
static bool IsSmaller(const ccColorScaleElement &e1, const ccColorScaleElement &e2)
Comparison operator between two color scale elements.
Definition: ecvColorScale.h:46
const ecvColor::Rgb & getColorByIndex(unsigned index) const
Returns color by index.
Definition: ecvColorScale.h:278
bool m_relative
Whether scale is relative or not.
Definition: ecvColorScale.h:317
QList< ccColorScaleElement > m_steps
Elements.
Definition: ecvColorScale.h:308
virtual bool toFile(QFile &out, short dataVersion) const
Saves data to binary stream.
Definition: ecvSerializableObject.h:38
QString getUuid() const
Returns unique ID.
Definition: ecvColorScale.h:117
const ccColorScaleElement & step(int index) const
Access to a given step (const)
Definition: ecvColorScale.h:183
virtual short minimumFileVersion() const =0
Returns the minimum file version required to save this instance.
void setLocked(bool state)
Sets whether scale is locked or not.
Definition: ecvColorScale.h:143
const LabelSet & customLabels() const
Returns the list of custom labels (if any - const version)
Definition: ecvColorScale.h:165
Color scale.
Definition: ecvColorScale.h:71
bool m_updated
Internal representation validity.
Definition: ecvColorScale.h:314
Serializable object interface.
Definition: ecvSerializableObject.h:25
bool isLocked() const
Returns whether scale is locked or not.
Definition: ecvColorScale.h:140
double e2[36]
Definition: essential_matrix_poly.h:12
double getRelativePos() const
Returns step position (relative to scale boundaries)
Definition: ecvColorScale.h:38
RGB color structure.
Definition: ecvColorTypes.h:49
LabelSet & customLabels()
Returns the list of custom labels (if any)
Definition: ecvColorScale.h:163
bool operator<(const Label &otherLabel) const
Definition: ecvColorScale.h:154
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'.
Definition: ecvColorScale.h:258
const QString & getName() const
Returns name.
Definition: ecvColorScale.h:112
#define CV_DB_LIB_API
Definition: CV_db.h:15
ccColorScaleElement()
Default constructor.
Definition: ecvColorScale.h:25
void setCustomLabels(const LabelSet &labels)
Sets the list of custom labels (only if the scale is absolute)
Definition: ecvColorScale.h:170
Color scale label (value + optional text)
Definition: ecvColorScale.h:146
void setName(const QString &name)
Sets name.
Definition: ecvColorScale.h:114
QString m_uuid
Unique ID.
Definition: ecvColorScale.h:305
LabelSet m_customLabels
List of custom labels.
Definition: ecvColorScale.h:335
const ecvColor::Rgb * getColorByValue(double value, const ecvColor::Rgb *outOfRangeColor=nullptr) const
Returns color by value.
Definition: ecvColorScale.h:226
bool m_locked
Whether scale is locked or not.
Definition: ecvColorScale.h:320
void setRelativePos(double pos)
Sets associated value (relative to scale boundaries)
Definition: ecvColorScale.h:34
Label(double v, const QString &t)
Definition: ecvColorScale.h:149
bool isRelative() const
Returns whether scale is relative or absoute.
Definition: ecvColorScale.h:126
void setUuid(QString uuid)
Sets unique ID.
Definition: ecvColorScale.h:119
double getRelativePosition(double value) const
Definition: ecvColorScale.h:215
std::string name
Definition: FileIOFactory.cpp:129