OpenLexocad  27.1
CmdSetPropertySetDefinition.h
Go to the documentation of this file.
1 #pragma once
2 #include <Core/Command.h>
3 
4 #include <App/Properties/PropertySetInfo.h>
5 #include <Gui/CA_Command_5.h>
6 #include <OpenLxApp/Element.h>
7 
8 namespace OpenLxCmd
9 {
31 class LX_OPENLXCMD_EXPORT CmdSetPropertySetDefinition : public Core::Command
32 {
33 public:
34  CmdSetPropertySetDefinition() = default;
35  ~CmdSetPropertySetDefinition() = default;
36 
37  /*
38  * Signatures to DELETE a Property (only working for "PropertySets" not for "PredefinedPropertySets")
39  */
40  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName);
41  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, std::shared_ptr<OpenLxApp::Element> aElement);
42  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElements);
43 
44  /*
45  * Signatures to ADD/MODIFY a PropertyBoolDescriptor
46  */
47  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const bool& propertyValue);
48  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const bool& propertyValue, std::shared_ptr<OpenLxApp::Element> aElement);
49  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const bool& propertyValue, const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElements);
50 
51  /*
52  * Signatures to ADD/MODIFY a PropertyDoubleDescriptor
53  */
54  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const double& propertyValue);
55  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const double& propertyValue, std::shared_ptr<OpenLxApp::Element> aElement);
56  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const double& propertyValue, const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElements);
57 
58  /*
59  * Signatures to ADD/MODIFY a PropertyStringDescriptor
60  */
61  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::string& propertyValue);
62  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::string& propertyValue, std::shared_ptr<OpenLxApp::Element> aElement);
63  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::string& propertyValue, const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElements);
64 
65  /*
66  * Signatures to ADD/MODIFY a PropertyEnumDescriptor
67  */
68  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::vector<std::string>& propertyValue, const int& index);
69  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::vector<std::string>& propertyValue, const int& index, std::shared_ptr<OpenLxApp::Element> aElement);
70  CmdSetPropertySetDefinition(const std::string& propertySetName, const std::string& propertyName, const std::vector<std::string>& propertyValue, const int& index, const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElements);
71 
72  bool redo() override;
73  bool undo() override;
74 
75 private:
76  App::Document* _document = nullptr;
77  App::PropertySetInfo* _propertySetInfo = nullptr;
78  Core::PropertyDescriptor* _propertyDescriptor = nullptr;
79  std::map<App::Element*, App::PropertySet*> _propertySets = {};
80  std::pair<Core::PropertyGroupDescriptor*, Core::PropertyDescriptor*> _propertyGroupDescriptor;
81  std::unique_ptr<CmdRunCommands> _docCommands;
82 
83  void execute(const std::string& propertySetName, const std::string& propertyName, const Core::Variant& propertyValue, const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElements = {}, const int& index = 0);
84  bool handleDeletedProperties(const std::string& propertySetName, const std::string& propertyName, const Core::Variant& propertyValue, const std::vector<App::Element*>& elements) const;
85  bool handlePredefinedPropertySets(const std::string& propertySetName, const std::string& propertyName, const Core::Variant& propertyValue, const std::vector<App::Element*>& elements);
86 
87  App::PropertySetDefinition* getPropertySetDefinition(const Base::String& propertySetName, App::Element* element) const;
88  Core::PropertyDescriptor* getPropertyDescriptor(const Base::String& propertyName) const;
89 };
90 }
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
Generic command to add/delete/modify the value of a "Property" inside a "PropertySet" of an Element....
Definition: CmdSetPropertySetDefinition.h:31
Definition: Variant.h:87
Definition: PropertyDescriptor.h:15
bool undo(int id=0)
Will UNDO one step, returns False if no undo was done (Undos == 0).
bool redo(int id=0)
Will REDO one step, returns False if no redo was done (Redos == 0).
Definition: CmdAddBolt.h:7
Definition: Command.h:34