diff --git a/src/Mod/Sketcher/Gui/CMakeLists.txt b/src/Mod/Sketcher/Gui/CMakeLists.txt index 43616f91db..08d0d155af 100644 --- a/src/Mod/Sketcher/Gui/CMakeLists.txt +++ b/src/Mod/Sketcher/Gui/CMakeLists.txt @@ -152,6 +152,8 @@ SET(SketcherGui_SRCS ViewProviderPython.h ViewProviderSketchGeometryExtension.h ViewProviderSketchGeometryExtension.cpp + VisualLayer.cpp + VisualLayer.h ) SET(Python_SRCS diff --git a/src/Mod/Sketcher/Gui/VisualLayer.cpp b/src/Mod/Sketcher/Gui/VisualLayer.cpp new file mode 100644 index 0000000000..075a49f715 --- /dev/null +++ b/src/Mod/Sketcher/Gui/VisualLayer.cpp @@ -0,0 +1,86 @@ +/*************************************************************************** + * Copyright (c) 2023 Abdullah Tahiri +#include + +#include "VisualLayer.h" + +using namespace SketcherGui; + +//**************** VisualClassConfig **************************************// + +VisualLayer::VisualLayer(unsigned int linePattern, float lineWidth, bool visible): linePattern(linePattern), lineWidth(lineWidth), visible(visible) +{} + +unsigned int VisualLayer::getLinePattern() const +{ + return linePattern; +} + +float VisualLayer::getLineWidth() const +{ + return lineWidth; +} + +void VisualLayer::setLinePattern(unsigned int linepattern) +{ + linePattern = linepattern; +} + +void VisualLayer::setLineWidth(float linewidth) +{ + lineWidth = linewidth; +} + +bool VisualLayer::isVisible() const +{ + return visible; +} + +void VisualLayer::setVisible(bool show) +{ + visible = show; +} + +void VisualLayer::Save(Base::Writer &writer) const +{ + writer.Stream() << writer.ind() + << "" << std::endl; +} + +void VisualLayer::Restore(Base::XMLReader &reader) +{ + reader.readElement("VisualLayer"); + + std::string str = reader.getAttribute("visible"); + visible = ( str == "true"); + + linePattern = reader.getAttributeAsUnsigned("linePattern"); + lineWidth = reader.getAttributeAsFloat("lineWidth"); +} + diff --git a/src/Mod/Sketcher/Gui/VisualLayer.h b/src/Mod/Sketcher/Gui/VisualLayer.h new file mode 100644 index 0000000000..53e5b686e3 --- /dev/null +++ b/src/Mod/Sketcher/Gui/VisualLayer.h @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (c) 2023 Abdullah Tahiri +#include + +namespace SketcherGui +{ + +/** Provides the visual layer configuration for a class of geometry. + * A class of geometry can be any grouping of geometry, for + * which the user wants to provide a per coin layer specific + * configuration. + */ +class VisualLayer { +public: + explicit VisualLayer(unsigned int linePattern = 0xFFFF, float lineWidth = 3.0, bool visible = true); + + unsigned int getLinePattern() const; + float getLineWidth() const; + + void setLinePattern(unsigned int linepattern); + void setLineWidth(float linewidth); + + bool isVisible() const; + void setVisible(bool show); + + void Save(Base::Writer &/*writer*/) const; + void Restore(Base::XMLReader &/*reader*/); + +private: + unsigned int linePattern; + float lineWidth; + bool visible; + + friend inline bool operator==(VisualLayer const& lhs, VisualLayer const& rhs); +}; + +bool operator==(VisualLayer const& lhs, VisualLayer const& rhs) +{ + return ( lhs.linePattern == rhs.linePattern ) && + ( lhs.lineWidth == rhs.lineWidth ) && + ( lhs.visible == rhs.visible ); +} + +} // namespace SketcherGui + + +#endif // SKETCHERGUI_VisualLayer_H