OpenLexocad  27.1
PropertyColor.h
Go to the documentation of this file.
1 #pragma once
2 #include <Base/Color.h>
3 #include <Core/Property.h>
4 #include <Core/Variant.h>
5 
6 namespace Core
7 {
8 class LX_CORE_EXPORT PropertyColor : public Core::Property
9 {
11 
12 public:
13  PropertyColor(void);
14  virtual ~PropertyColor(void);
15 
16 
17  void setValue(const Base::Color& c);
18  void setValue(int r, int g, int b);
19  bool setValueFromVariant(const Core::Variant& value);
20 
22  virtual bool setKeyValue(const std::string& name, const Core::Variant& value);
24  virtual std::map<std::string, Core::Variant> getKeyValueMap() const;
25 
26  void copyValue(Core::Property* p);
27 
28  const Base::Color& getValue() const;
29  Core::Variant getVariant(void) const;
30 
31  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
32  virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
33  virtual bool isEqual(const Property*) const;
34  virtual Core::Property* copy(void) const override;
35  virtual void paste(const Core::Property& from) override;
36 
37 protected:
39 };
40 
41 class LX_CORE_EXPORT PropertyColorList : public Core::Property
42 {
44 
45 public:
47  virtual ~PropertyColorList();
48 
49  void setValue(const std::vector<Base::MColor>& clist);
50  void setValue(const std::vector<Base::Color>& clist);
51  bool setValueFromVariant(const Core::Variant& value);
52  void copyValue(Core::Property* p);
53 
54  void addColor(const Base::MColor& c);
55  void setEmpty();
56  bool isEmpty() const;
57 
58  const std::vector<Base::MColor>& getValue() const;
59 
60  Core::Variant getVariant(void) const { return Core::Variant(_colorList); }
61 
62  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
63  virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
64  virtual bool isEqual(const Property*) const;
65  virtual Core::Property* copy(void) const override;
66  virtual void paste(const Core::Property& from) override;
67 
68 protected:
69  std::vector<Base::MColor> _colorList;
70 };
71 
73 DECLARE_PROPERTY_FACTORY(PropertyColor_Factory, Core::PropertyColor);
74 DECLARE_PROPERTY_FACTORY(PropertyColorOpt_Factory, Core::PropertyColorOpt);
75 DECLARE_PROPERTY_FACTORY(PropertyColorList_Factory, Core::PropertyColorList);
76 
77 } // namespace Core
DECLARE_OPTIONAL_PROPERTY_HEADER(PropertyColorOpt, Core::PropertyColor)
Base::Color _cValue
Definition: PropertyColor.h:38
Definition: Color.h:45
Definition: Persistence.h:14
Core::PropertyText name
Definition: CoreDocument.h:167
Definition: PropertyColor.h:8
LX_CORE_EXPORT Version & version
Definition: Variant.h:87
Definition: AbstractXMLReader.h:7
Definition: Base.h:12
Definition: Writer.h:16
Core::Variant getVariant(void) const
Definition: PropertyColor.h:60
Definition: Color.h:21
Definition: PropertyColor.h:41
std::vector< Base::MColor > _colorList
Definition: PropertyColor.h:69
Definition: Property.h:77
TYPESYSTEM_HEADER()
DECLARE_PROPERTY_FACTORY(PropertyAxis1_Factory, Core::PropertyAxis1)