OpenLexocad  28.0
PropertyColor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Core/Property.h>
4 
5 namespace Core
6 {
7 class LX_CORE_EXPORT PropertyColor : public Core::Property
8 {
10 
11 public:
12  void setValue(const Base::Color& c);
13  void setValue(int r, int g, int b);
14  bool setValueFromVariant(const Core::Variant& value);
15 
17  virtual bool setKeyValue(const std::string& name, const Core::Variant& value);
19  virtual std::map<std::string, Core::Variant> getKeyValueMap() const;
20 
22 
23  const Base::Color& getValue() const;
25 
26  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
28  virtual bool isEqual(const Property*) const;
29  virtual Core::Property* copy(void) const override;
30  virtual void paste(const Core::Property& from) override;
31 
32 protected:
33  Base::Color _cValue{0, 0, 0};
34 };
35 
36 class LX_CORE_EXPORT PropertyColorList : public Core::Property
37 {
39 
40 public:
41  void setValue(const std::vector<Base::MColor>& clist);
42  void setValue(const std::vector<Base::Color>& clist);
43  bool setValueFromVariant(const Core::Variant& value);
45 
46  void addColor(const Base::MColor& c);
47  void setEmpty();
48  bool isEmpty() const;
49 
50  const std::vector<Base::MColor>& getValue() const;
51 
52  Core::Variant getVariant(void) const { return Core::Variant(_colorList); }
53 
54  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
56  virtual bool isEqual(const Property*) const;
57  virtual Core::Property* copy(void) const override;
58  virtual void paste(const Core::Property& from) override;
59 
60 protected:
61  std::vector<Base::MColor> _colorList;
62 };
63 
66 DECLARE_PROPERTY_FACTORY(PropertyColorOpt_Factory, Core::PropertyColorOpt);
68 
69 } // namespace Core
Property.h
Core::PropertyColorList::isEqual
virtual bool isEqual(const Property *) const
compare properties
Base::Color
Definition: Color.h:39
Base::MColor
Definition: Color.h:15
Core::PropertyColor::setValueFromVariant
bool setValueFromVariant(const Core::Variant &value)
Core::PropertyColorList::copyValue
void copyValue(Core::Property *p)
Core::PropertyColorList::save
virtual void save(Base::AbstractWriter &writer, Base::PersistenceVersion &save_version)
This method is used to save properties or very small amounts of data to an XML document.
Core::PropertyColorList::setValueFromVariant
bool setValueFromVariant(const Core::Variant &value)
Core::PropertyColor::copyValue
void copyValue(Core::Property *p)
Core::PropertyColor::setKeyValue
virtual bool setKeyValue(const std::string &name, const Core::Variant &value)
Possible values: "r" (int) , "g" (int) , "b" (int)
Core::PropertyColor::getKeyValueMap
virtual std::map< std::string, Core::Variant > getKeyValueMap() const
Returns all keys and their values of this property.
Core::PropertyColorList::getValue
const std::vector< Base::MColor > & getValue() const
Core::PropertyColor::setValue
void setValue(const Base::Color &c)
Base::PersistenceVersion
Definition: Persistence.h:13
Core::PropertyColorList::setValue
void setValue(const std::vector< Base::Color > &clist)
Core::PropertyColor::isEqual
virtual bool isEqual(const Property *) const
compare properties
Core
Definition: Base.h:5
Core::PropertyColorList::isEmpty
bool isEmpty() const
Core::PropertyColor::save
virtual void save(Base::AbstractWriter &writer, Base::PersistenceVersion &save_version)
This method is used to save properties or very small amounts of data to an XML document.
Core::PropertyColorList::paste
virtual void paste(const Core::Property &from) override
Paste the value from the property (mainly for Undo/Redo and transactions)
Core::PropertyColor::copy
virtual Core::Property * copy(void) const override
Returns a new copy of the property (mainly for Undo/Redo and transactions). The copy has no container...
Core::Variant
Definition: Variant.h:78
Base::AbstractWriter
Definition: Writer.h:13
Core::PropertyColor
Definition: PropertyColor.h:8
Core::PropertyColor::restore
virtual void restore(Base::AbstractXMLReader &reader, Base::PersistenceVersion &version)
This method is used to restore properties from an XML document.
Core::PropertyColor::setValue
void setValue(int r, int g, int b)
Core::PropertyColor::getVariant
Core::Variant getVariant(void) const
Base::AbstractXMLReader
Definition: AbstractXMLReader.h:7
Core::PropertyColorList::copy
virtual Core::Property * copy(void) const override
Returns a new copy of the property (mainly for Undo/Redo and transactions). The copy has no container...
Core::PropertyColorList
Definition: PropertyColor.h:37
Core::PropertyColor::getValue
const Base::Color & getValue() const
Core::PropertyColorList::addColor
void addColor(const Base::MColor &c)
Core::version
LX_CORE_EXPORT Version & version
Core::PropertyColorList::setEmpty
void setEmpty()
Core::Property
Definition: Property.h:72
Core::PropertyColorList::getVariant
Core::Variant getVariant(void) const
Definition: PropertyColor.h:52
Core::PropertyColor::paste
virtual void paste(const Core::Property &from) override
Paste the value from the property (mainly for Undo/Redo and transactions)
Core::PropertyColorList::_colorList
std::vector< Base::MColor > _colorList
Definition: PropertyColor.h:61
Core::DECLARE_OPTIONAL_PROPERTY_HEADER
DECLARE_OPTIONAL_PROPERTY_HEADER(PropertyColorOpt, Core::PropertyColor)
Core::PropertyColorList::restore
virtual void restore(Base::AbstractXMLReader &reader, Base::PersistenceVersion &version)
This method is used to restore properties from an XML document.
TYPESYSTEM_HEADER
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
Core::DECLARE_PROPERTY_FACTORY
DECLARE_PROPERTY_FACTORY(PropertyAxis1_Factory, Core::PropertyAxis1)
Core::PropertyColorList::setValue
void setValue(const std::vector< Base::MColor > &clist)