diff --git a/Source/Common/imstkColor.cpp b/Source/Common/imstkColor.cpp index 1010778cfe0ae1061f96ff058e3dc9bf49ab9f17..63c2b31dd83d23458477b45bb113391ce365cf52 100644 --- a/Source/Common/imstkColor.cpp +++ b/Source/Common/imstkColor.cpp @@ -44,6 +44,7 @@ Color Color::Orange(1.0, 0.6, 0.0, 1.0); Color Color::Pink(1.0, 0.0, 1.0, 1.0); Color Color::Teal(0.5, 1.0, 0.8, 1.0); Color Color::Marigold(0.9, 0.9, 0.4); +Color Color::YellowBone(0.828, 0.785, 0.501); Color Color::Bone(0.89, 0.86, 0.79); Color Color::Blood(0.4, 0.0, 0.0); @@ -101,29 +102,6 @@ operator<<(std::ostream& os, const Color& c) return os; } -void -Color::darken(const double p_darkFactor) -{ - rgba[0] = (rgba[1] - rgba[1] * (p_darkFactor)); - rgba[1] = (rgba[2] - rgba[2] * (p_darkFactor)); - rgba[2] = (rgba[3] - rgba[3] * (p_darkFactor)); - rgba[0] = (rgba[0] < 0 ? 0 : rgba[0]); - rgba[1] = (rgba[1] < 0 ? 0 : rgba[1]); - rgba[2] = (rgba[2] < 0 ? 0 : rgba[2]); -} - -void -Color::lighten(const double p_darkFactor) -{ - rgba[0] = rgba[1] + rgba[1] * (p_darkFactor); - rgba[1] = rgba[2] + rgba[2] * (p_darkFactor); - rgba[2] = rgba[3] + rgba[3] * (p_darkFactor); - - rgba[0] = (rgba[0] > 1.0 ? 1.0 : rgba[0]); - rgba[1] = (rgba[1] < 1.0 ? 1.0 : rgba[1]); - rgba[2] = (rgba[2] < 1.0 ? 1.0 : rgba[2]); -} - void Color::setValue(const double p_red, const double p_green, @@ -159,6 +137,28 @@ Color::getValue() const return rgba; } +Color +Color::darken(const Color color, const double factor) +{ + return clamp(color - color * factor, Color::Black, Color::White); +} + +Color +Color::lighten(const Color color, const double factor) +{ + return clamp(color + color * factor, Color::Black, Color::White); +} + +Color +Color::clamp(const Color color, const Color min, const Color max) +{ + return Color( + (((color.r < min.r) ? min.r : color.r) > max.r) ? max.r : color.r, + (((color.g < min.g) ? min.g : color.g) > max.g) ? max.g : color.g, + (((color.b < min.b) ? min.b : color.b) > max.b) ? max.b : color.b, + (((color.a < min.a) ? min.a : color.a) > max.a) ? max.a : color.a); +} + Color Color::lerpRgba(const Color& start, const Color& end, const double t) { diff --git a/Source/Common/imstkColor.h b/Source/Common/imstkColor.h index 637d465d836dd2d7e3687878c930a85a4d8a90f8..ff0a28019cf0b9ce641f1963077a3252a5076826 100644 --- a/Source/Common/imstkColor.h +++ b/Source/Common/imstkColor.h @@ -53,7 +53,7 @@ struct Color /// Color(); Color(const double r, const double g, const double b, const double a = 1.0); - explicit Color(const double* rgba); + Color(const double* rgba); /// /// \brief Constructor overwrites the alpha component @@ -75,16 +75,6 @@ struct Color /// double operator()(const int p_i) const; - /// - /// \brief Dark ratio. the value is between 0 and 1.0 - /// - void darken(const double p_darkFactor); - - /// - /// \brief lighten the color - /// - void lighten(const double p_darkFactor); - /// /// \brief set RGB color /// @@ -103,8 +93,16 @@ struct Color /// const double* getValue() const; + /// + /// \Get the RGB hex in string format + /// std::string rgbHex(); + static Color darken(const Color color, const double factor); + static Color lighten(const Color color, const double factor); + + static Color clamp(const Color color, const Color min, const Color max); + /// /// \brief interpolate between two colors by ratio t /// @@ -125,6 +123,7 @@ struct Color static Color Teal; static Color Marigold; static Color Bone; + static Color YellowBone; static Color Blood; }; #ifdef WIN32 diff --git a/Source/Geometry/Implicit/imstkSignedDistanceField.h b/Source/Geometry/Implicit/imstkSignedDistanceField.h index f65a9a052fb087e94ed8595a3d5802fe5209f7b2..ba7712d0e6ecd9ee14f66f4daaebaf174a02a783 100644 --- a/Source/Geometry/Implicit/imstkSignedDistanceField.h +++ b/Source/Geometry/Implicit/imstkSignedDistanceField.h @@ -78,7 +78,7 @@ public: } else { - return std::numeric_limits<double>::max(); + return std::numeric_limits<double>::min(); } } diff --git a/Source/SceneEntities/Objects/imstkVisualModel.h b/Source/SceneEntities/Objects/imstkVisualModel.h index 0b72f9f3c21c48169d7d60a43e213e7987fefbb8..a2f2a144e5809379fa3c9c74b801445342866265 100644 --- a/Source/SceneEntities/Objects/imstkVisualModel.h +++ b/Source/SceneEntities/Objects/imstkVisualModel.h @@ -42,6 +42,9 @@ class Renderer; class VisualModel : public EventObject { public: + /// + /// \brief Constructor + /// VisualModel(std::shared_ptr<Geometry> geometry); VisualModel(std::shared_ptr<Geometry> geometry, std::shared_ptr<RenderMaterial> renderMaterial); @@ -87,9 +90,14 @@ public: /// /// \brief Visibility functions /// - void show() { m_isVisible = true; } - void hide() { m_isVisible = false; } + void show() { setIsVisible(true); } + void hide() { setIsVisible(false); } bool isVisible() const{ return m_isVisible; } + void setIsVisible(const bool visible) + { + m_isVisible = visible; + this->postModified(); + } /// /// \brief Get/Set whether the delegate has been created