SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
qtBaseView.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 
11 #ifndef smtk_extension_qtBaseView_h
12 #define smtk_extension_qtBaseView_h
13 
14 #include <QtCore/QList>
15 #include <QtCore/QObject>
16 #include <QtCore/QPointer>
17 #include <QtWidgets/QLayout>
18 
19 #include "smtk/PublicPointerDefs.h"
20 #include "smtk/SharedFromThis.h"
21 #include "smtk/common/Deprecation.h"
22 #include "smtk/extension/qt/Exports.h"
23 #include "smtk/extension/qt/qtViewInfoDialog.h"
24 #include "smtk/view/BaseView.h"
25 #include "smtk/view/Information.h"
26 
27 class QScrollArea;
28 
29 // VTK's wrapper parser does not properly handle Qt macros on macos.
30 #if defined(__VTK_WRAP__) && !defined(Q_SLOTS)
31 #define Q_DISABLE_COPY(x)
32 #define Q_SLOTS
33 #define Q_SIGNALS protected
34 #define Q_OBJECT
35 #endif
36 
37 namespace smtk
38 {
39 namespace extension
40 {
41 class qtUIManager;
42 class qtItem;
43 class qtViewInfoDialog;
44 
46 class SMTKQTEXT_EXPORT qtBaseView
47  : public QObject
48  , public smtk::view::BaseView
49 {
50  Q_OBJECT
51 
52 public:
53  // Views do not follow RAII. They require a call to the protected virtual
54  // method buildUI() to be initialized. Since objects that inherit from
55  // qtBaseView are only ever called by qtUIManager, we can code around this
56  // issue by making qtBaseView a friend of qtUIManager and by calling buildUI()
57  // immediately upon construction in qtUIManager.
58  friend class qtUIManager;
59 
61 
63 
64  ~qtBaseView() override;
65 
66  const smtk::view::ConfigurationPtr& configuration() const
67  {
68  return m_viewInfo.get<smtk::view::ConfigurationPtr>();
69  }
70 
71  QWidget* widget() const { return this->Widget; }
72 
73  QWidget* parentWidget() const { return m_viewInfo.get<QWidget*>(); }
74 
75  qtUIManager* uiManager() const { return m_viewInfo.get<qtUIManager*>(); }
76 
77  virtual int advanceLevel() const { return 0; }
78  virtual bool categoryEnabled() const { return false; }
79  virtual std::string currentCategory() const { return ""; }
84  virtual void setInitialCategory() { ; }
85 
86  bool isTopLevel() const { return m_isTopLevel; }
87 
91  virtual bool isEmpty() const { return true; }
92 
94  virtual bool isValid() const { return true; }
95 
96  // Validates the view information to see if it is suitable for creating a qtBaseView instance
97  static bool validateInformation(const smtk::view::Information& info);
98 
99 Q_SIGNALS:
100  void aboutToDestroy();
101  void modified();
102 
103 public Q_SLOTS:
108  virtual void updateUI() { ; }
109  virtual void childrenResized() { ; }
110  virtual void showAdvanceLevelOverlay(bool val) { m_advOverlayVisible = val; }
112  virtual void showAdvanceLevel(int /* level */) { ; }
113  virtual void enableShowBy(int /* enable */) { ; }
115  virtual void onInfo();
116 
117  virtual void onShowCategory() {}
118 
119 protected:
122  virtual void buildUI() { ; }
125  virtual void createWidget() { ; }
126 
128  virtual void makeTopLevel();
129 
131  virtual void setInfoToBeDisplayed();
132 
133  QWidget* Widget;
134  bool m_isTopLevel;
135  bool m_useSelectionManager;
136  smtk::view::Information m_viewInfo;
137  QPointer<qtViewInfoDialog> m_infoDialog;
138  bool m_advOverlayVisible;
139 }; // class
140 
141 } // namespace extension
142 } // namespace smtk
143 
144 #endif
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::extension::qtItem
an abstract UI class for attribute item
Definition: qtItem.h:61
PublicPointerDefs.h
smtk::extension::qtUIManager
Container for managers whose content is presented via Qt widgets.
Definition: qtUIManager.h:57
smtk::extension::qtBaseView::showAdvanceLevel
virtual void showAdvanceLevel(int)
Have the view update its contents based on a new advance level.
Definition: qtBaseView.h:112
smtk::extension::qtBaseView
A base class for all view types implemented using Qt.
Definition: qtBaseView.h:46
smtk::view::Information
A class for information passed to views during initialization.
Definition: Information.h:32
smtk::extension::qtBaseView::createWidget
virtual void createWidget()
Creates the main QT Widget that is associated with a View.
Definition: qtBaseView.h:125
smtk::extension::qtBaseView::updateUI
virtual void updateUI()
Have the view update its contents.
Definition: qtBaseView.h:108
smtk::extension::qtBaseView::buildUI
virtual void buildUI()
Creates the UI related to the view and properly assigns it to the parent widget.
Definition: qtBaseView.h:122
smtk::view::BaseView
Definition: BaseView.h:24
smtk::extension::qtBaseView::setInitialCategory
virtual void setInitialCategory()
When category filtering is requested to be either on by default or is requested to be on permanently,...
Definition: qtBaseView.h:84
smtk::view::ConfigurationPtr
smtk::shared_ptr< smtk::view::Configuration > ConfigurationPtr
Definition: PublicPointerDefs.h:642
smtk::extension::qtBaseView::isValid
virtual bool isValid() const
Return true if the view's contents are valid.
Definition: qtBaseView.h:94
smtk::extension::qtBaseView::isEmpty
virtual bool isEmpty() const
Return true if the view does not contain any information to display.
Definition: qtBaseView.h:91
SharedFromThis.h
Macros for dealing with shared-pointer classes.
smtkTypenameMacro
#define smtkTypenameMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:68