8 #include <pybind11/pybind11.h>
9 #include <pybind11/stl.h>
10 #include <pybind11/stl_bind.h>
16 #include "../casters.h"
19 using namespace pybind11::literals;
23 py::class_<ccColorScaleElement>(m,
"ccColorScaleElement")
25 .def(py::init<double, const QColor &>(),
"relativePos"_a,
"color"_a)
32 py::class_<ccColorScale> pyColorScale(m,
"ccColorScale");
33 pyColorScale.def(py::init<const QString &, const QString &>(),
"name"_a,
"uuid"_a = QString())
46 .def(
"getAbsoluteBoundaries",
49 double minVal, maxVal;
50 self.getAbsoluteBoundaries(minVal, maxVal);
51 return py::make_tuple(minVal, maxVal);
65 .def(
"getColorByValue",
68 "outOfRangeColor"_a =
nullptr)
69 .def(
"getColorByRelativePos",
73 "outOfRangeColor"_a =
nullptr)
74 .def(
"getColorByRelativePos",
80 "outOfRangeColor"_a =
nullptr)
85 py::class_<ccColorScale::Label>(pyColorScale,
"Label")
88 .def(py::init<double>(),
"value"_a)
89 .def(py::init<double, const QString &>(),
"value"_a,
"text"_a);
93 static_cast<const std::set<ccColorScale::Label> &(
ccColorScale::*)() const
>(
96 static_cast<std::set<ccColorScale::Label> &(
ccColorScale::*)()
>(
100 py::class_<ccColorScale::Shared>(pyColorScale,
"Shared");
void define_ccColorScale(py::module &m)
Color scale element: one value + one color.
const QColor & getColor() const
Returns color.
double getRelativePos() const
Returns step position (relative to scale boundaries)
static bool IsSmaller(const ccColorScaleElement &e1, const ccColorScaleElement &e2)
Comparison operator between two color scale elements.
void setRelativePos(double pos)
Sets associated value (relative to scale boundaries)
void setColor(QColor color)
Sets color.
bool saveAsXML(QString filename) const
Saves this color scale as an XML file.
static const unsigned DEFAULT_STEPS
Default number of steps for display.
ccColorScaleElement & step(int index)
Access to a given step.
static Shared LoadFromXML(QString filename)
Loads a color scale from an XML file.
QString getUuid() const
Returns unique ID.
void setRelative()
Sets scale as relative.
LabelSet & customLabels()
Returns the list of custom labels (if any)
void setAbsolute(double minVal, double maxVal)
Sets scale as absolute.
void update()
Updates internal representation.
static const unsigned MIN_STEPS
Minimum number of steps.
void setLocked(bool state)
Sets whether scale is locked or not.
const QString & getName() const
Returns name.
const ecvColor::Rgb & getColorByIndex(unsigned index) const
Returns color by index.
bool isRelative() const
Returns whether scale is relative or absoute.
void remove(int index, bool autoUpdate=true)
Deletes a given step.
double getRelativePosition(double value) const
void insert(const ccColorScaleElement &step, bool autoUpdate=true)
Adds a step.
const ecvColor::Rgb * getColorByRelativePos(double relativePos, const ecvColor::Rgb *outOfRangeColor=nullptr) const
Returns color by relative position in scale.
void generateNewUuid()
Generates a new unique ID.
int stepCount() const
Returns the current number of steps.
void clear()
Clears all steps.
const ecvColor::Rgb * getColorByValue(double value, const ecvColor::Rgb *outOfRangeColor=nullptr) const
Returns color by value.
void setUuid(QString uuid)
Sets unique ID.
void setName(const QString &name)
Sets name.
bool isLocked() const
Returns whether scale is locked or not.
void setCustomLabels(const LabelSet &labels)
Sets the list of custom labels (only if the scale is absolute)
static const unsigned MAX_STEPS
Maximum number of steps (internal representation)