OpenLexocad  27.1
Selection.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <OpenLxApp/Element.h>
4 
5 #include <OpenLxUI/SelectionCB.h>
6 #include <OpenLxUI/UIElement.h>
8 
9 #include <QObject>
10 
11 
12 namespace OpenLxUI
13 {
14 class SelectionP;
15 
22 class LX_OPENLXUI_EXPORT Selection
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  void forceUpdate() const;
41 
42  std::vector<std::shared_ptr<OpenLxApp::DocObject>> getDocObjects() const;
43  std::vector<std::shared_ptr<OpenLxApp::Element>> getAsElements() const;
44  std::vector<std::shared_ptr<OpenLxUI::UIElement>> getUIElements() const;
45 
46 
47 #ifndef SWIG
48 
49 signals:
50  // Is emitted when one or more UIElements get selected.
51  void selectedSignal(const std::vector<std::shared_ptr<OpenLxUI::UIElement>>&);
52  // Is emitted when one or more UIElements get deselected.
53  void deselectedSignal(const std::vector<std::shared_ptr<OpenLxUI::UIElement>>&);
54  // Is emitted when the selection is cleared.
55  void clearedSelectionSignal();
56 
57 private slots:
58  void _onSelected(const std::vector<Core::DocObject*>&);
59  void _onDeselected(const std::vector<Core::DocObject*>&);
60  void _onClearedSelection();
61 #endif
62 public:
63  void addCallback(OpenLxUI::SelectionCB* aCB);
64  void addCallback(OpenLxUI::SelectionCB* aCB, OpenLxUI::UIElementFilter* aFilter);
65  void removeCallback(OpenLxUI::SelectionCB* aCB);
66  void removeCallbacks();
67  std::vector<OpenLxUI::SelectionCB*> getCallbacks() const;
68  std::vector<OpenLxUI::SelectionCB*> getCallbacks(OpenLxUI::UIElementFilter* aFilter) const;
69 
70  // Testing
71  void testCB();
72 
73  Selection(std::shared_ptr<OpenLxApp::Document> aDoc);
74 
75  ~Selection();
76  Selection() = delete;
77 
78 private:
79  std::shared_ptr<OpenLxUI::SelectionP> _pimpl;
80 };
81 } // 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:40
Definition: ActiveEdge.h:25