OpenLexocad  27.0
Selection.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <OpenLxApp/Element.h>
5 #include <OpenLxUI/SelectionCB.h>
6 #include <OpenLxUI/UIElement.h>
8 
9 #include <QObject>
10 
11 
12 namespace OpenLxUI
13 {
14 class SelectionP;
15 
23 
24 #ifndef SWIG
25  : public QObject
26 #endif
27 
28 {
29  Q_OBJECT
30 
31 public:
32  std::shared_ptr<OpenLxApp::Document> getDocument() const;
33 
34  void selectAll() const;
35  void select(std::shared_ptr<OpenLxApp::Element> aElem) const;
36  void select(const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElems) const;
37  void deselectAll() const;
38  void deselect(std::shared_ptr<OpenLxApp::Element> aElem) const;
39  void deselect(const std::vector<std::shared_ptr<OpenLxApp::Element>>& aElems) const;
40 
41  std::vector<std::shared_ptr<OpenLxApp::DocObject>> getDocObjects() const;
42  std::vector<std::shared_ptr<OpenLxApp::Element>> getAsElements() const;
43  std::vector<std::shared_ptr<OpenLxUI::UIElement>> getUIElements() const;
44 
45 
46 #ifndef SWIG
47 
48 signals:
49  // Is emitted when one or more UIElements get selected.
50  void selectedSignal(const std::vector<std::shared_ptr<OpenLxUI::UIElement>>&);
51  // Is emitted when one or more UIElements get deselected.
52  void deselectedSignal(const std::vector<std::shared_ptr<OpenLxUI::UIElement>>&);
53  // Is emitted when the selection is cleared.
54  void clearedSelectionSignal();
55 
56 private slots:
57  void _onSelected(const std::vector<Core::DocObject*>&);
58  void _onDeselected(const std::vector<Core::DocObject*>&);
59  void _onClearedSelection();
60 #endif
61 public:
62  void addCallback(OpenLxUI::SelectionCB* aCB);
63  void addCallback(OpenLxUI::SelectionCB* aCB, OpenLxUI::UIElementFilter* aFilter);
64  void removeCallback(OpenLxUI::SelectionCB* aCB);
65  void removeCallbacks();
66  std::vector<OpenLxUI::SelectionCB*> getCallbacks() const;
67  std::vector<OpenLxUI::SelectionCB*> getCallbacks(OpenLxUI::UIElementFilter* aFilter) const;
68 
69  // Testing
70  void testCB();
71 
72  Selection(std::shared_ptr<OpenLxApp::Document> aDoc);
73 
74  ~Selection();
75  Selection() = delete;
76 
77 private:
78  std::shared_ptr<OpenLxUI::SelectionP> _pimpl;
79 };
80 } // namespace OpenLxUI
Definition: Selection.h:22
Definition: SelectionCB.h:38
Definition: UIElementFilter.h:17
#define slots
Definition: PyExport.h:22
#define signals
Definition: pythonize.h:34
Definition: ActiveEdge.h:25
#define OPENLXUI_EXPORT
Definition: OpenLxUI_defines.h:12