12namespace Json{
class Value; }
32 [[nodiscard]] MRVIEWER_API
static const std::vector<Color> &
GreenRedColors();
34 MRVIEWER_API
Palette(
const std::vector<Color>& colors );
63 MRVIEWER_API
void draw(
const std::string& windowName,
const ImVec2& pose,
const ImVec2&
size,
bool onlyTopHalf =
false );
72 MRVIEWER_API
Label(
float val, std::string text );
108 valid ? 0.25f : 0.75f
115 MRVIEWER_API VertUVCoords
getUVcoords(
const VertScalars & values,
const VertBitSet & region,
const VertPredicate & valids = {} )
const;
116 MRVIEWER_API VertUVCoords
getUVcoords(
const VertScalars & values,
const VertBitSet & region,
const VertBitSet * valids )
const;
121 std::vector<float>
ranges = { 0.f, 1.f };
145 void setRangeLimits_(
const std::vector<float>& ranges );
147 void updateDiscretizatedColors_();
148 Color getBaseColor_(
float val );
152 void setUniformLabels_();
155 void setZeroCentredLabels_();
157 void updateCustomLabels_();
161 std::vector<Label> customLabels_;
162 std::vector<Label> labels_;
163 bool showLabels_ =
false;
169 float texStart_ = 0, texEnd_ = 1;
173 bool isWindowOpen_ =
false;
175 bool useCustomLabels_ =
false;
177 int maxLabelCount_ = 0;
179 float prevMaxLabelWidth_ = 0.0f;
181 static void resizeCallback_( ImGuiSizeCallbackData* data );
201 std::vector<std::string> names_;
Class to save and load user palette presets.
Definition MRPalette.h:186
static MRVIEWER_API Expected< void > savePreset(const std::string &name, const Palette &palette)
saves given palette to preset with given name
static MRVIEWER_API std::filesystem::path getPalettePresetsFolder()
returns path to presets folder
static MRVIEWER_API bool loadPreset(const std::string &name, Palette &palette)
static MRVIEWER_API const std::vector< std::string > & getPresetNames()
gets names of existing presets
Class to hold one dimension texture with value to UV mapping.
Definition MRPalette.h:25
MRVIEWER_API float getRelativePos(float val) const
MRVIEWER_API void draw(const std::string &windowName, const ImVec2 &pose, const ImVec2 &size, bool onlyTopHalf=false)
float getRangeSq() const
returns minimum squared value, not smaller than all squared values of palette's range
Definition MRPalette.h:135
MRVIEWER_API int getMaxLabelCount()
const MeshTexture & getTexture() const
Definition MRPalette.h:94
MRVIEWER_API Palette(const std::vector< Color > &colors)
MRVIEWER_API bool loadFromJson(const Json::Value &root)
MRVIEWER_API void setFilterType(FilterType type)
const Parameters & getParameters() const
Definition MRPalette.h:126
MRVIEWER_API std::string getStringValue(float value)
MRVIEWER_API Color getColor(float val)
static MRVIEWER_API const std::vector< Color > & GreenRedColors()
simpler palette colors: from green to red
MRVIEWER_API void setCustomLabels(const std::vector< Label > &labels)
float getRangeMin() const
returns minimum value in the palette's range
Definition MRPalette.h:129
MRVIEWER_API void setMaxLabelCount(int val)
MRVIEWER_API VertUVCoords getUVcoords(const VertScalars &values, const VertBitSet ®ion, const VertBitSet *valids) const
MRVIEWER_API void saveCurrentToJson(Json::Value &root) const
MRVIEWER_API void setRangeMinMax(float min, float max)
set range limits for palette (need for find color by value) all palette colors are evenly distributed...
MRVIEWER_API VertUVCoords getUVcoords(const VertScalars &values, const VertBitSet ®ion, const VertPredicate &valids={}) const
MRVIEWER_API void setDiscretizationNumber(int discretization)
MRVIEWER_API void setRangeMinMaxNegPos(float minNeg, float maxNeg, float minPos, float maxPos)
set range limits for palette (need for find color by value) two half palette colors are evenly distri...
static MRVIEWER_API const std::vector< Color > DefaultColors
preset palette colors: from blue via green to red
Definition MRPalette.h:28
MRVIEWER_API void resetLabels()
float getRangeMax() const
returns maximum value in the palette's range
Definition MRPalette.h:132
static const std::vector< Color > & BlueGreenRedColors()
Definition MRPalette.h:29
UVCoord getUVcoord(float val, bool valid=true) const
Definition MRPalette.h:104
MRVIEWER_API void setLabelsVisible(bool visible)
MRVIEWER_API void setBaseColors(const std::vector< Color > &colors)
Set base palette colors colors.size() should be more or equal 2 for discrete palette using vector of ...
Definition MRCameraOrientationPlugin.h:8
constexpr T sqr(T x) noexcept
Definition MRMesh/MRMeshFwd.h:600
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
FilterType
Definition MRMesh/MRMeshFwd.h:579
tl::expected< T, E > Expected
Definition MRExpected.h:58
Vector2f UVCoord
Definition MRMesh/MRMeshFwd.h:380
Definition MRMeshTexture.h:13
Definition MRPalette.h:67
MRVIEWER_API Label(float val, std::string text)
std::string text
Definition MRPalette.h:69
Definition MRPalette.h:120
std::vector< Color > baseColors
Definition MRPalette.h:122
int discretization
Definition MRPalette.h:123
std::vector< float > ranges
Definition MRPalette.h:121