VPTissue Reference Manual
ProjectController.h
Go to the documentation of this file.
1 #ifndef GUI_PROJECTCONTROLLER_H_INCLUDED
2 #define GUI_PROJECTCONTROLLER_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "SessionController.h"
25 #include "gui/EnabledActions.h"
27 #include "gui/IHasPTreeState.h"
28 #include "workspace/IProject.h"
29 
30 #include <memory>
31 #include <QWidget>
32 
33 class QDockWidget;
34 
35 namespace SimShell {
36 namespace Gui {
37 
38 class PTreeContainer;
39 class PTreeContainerPreferencesObserver;
40 
41 namespace Controller {
42 
43 class AppController;
44 
52 class ProjectController : public QWidget,
53  public IHasPTreeState,
56 {
57  Q_OBJECT
58 public:
60 
61  QAction* GetActionClose() const;
62 
63  QMenu* GetExportMenu() const;
64 
65  const std::string& GetOpenedFileName() const;
66 
67  const std::string& GetOpenedProjectName() const;
68 
69  QDockWidget* GetParametersDock() const;
70 
71  QMenu* GetParametersMenu() const;
72 
73  QDockWidget* GetPreferencesDock() const;
74 
75  QMenu* GetPreferencesMenu() const;
76 
78  boost::property_tree::ptree GetPTreeState() const;
79 
80  QMenu* GetSimulationMenu() const;
81 
82  virtual Timings GetTimings() const;
83 
84  QMenu* GetViewersMenu() const;
85 
87  virtual bool IsOpened() const;
88 
90  bool IsRunning() const;
91 
92  bool Set(const std::string& project_name, const std::shared_ptr<Ws::IProject>& project);
93 
95  void SetPTreeState(const boost::property_tree::ptree&);
96 
98  void SetRunning(bool);
99 
101  operator bool() const;
102 
103 protected:
105  virtual void InternalForceClose();
106 
108  virtual bool InternalIsClean() const;
109 
111  virtual void InternalPreForceClose();
112 
114  virtual bool InternalSave();
115 
116 private slots:
117  void SLOT_ApplyParameters(const boost::property_tree::ptree&);
118  void SLOT_ApplyPreferences(const boost::property_tree::ptree&);
119  void SLOT_Close();
120 
121 private:
122  void InitActions();
123  void InitBaseClasses();
124  void InitWidgets();
125 
126 private:
127  AppController* m_main_controller;
128 
129  // Timings of all simulations
130  Timings m_timings;
131 
132  // These shared ptrs will only contain objects if we are in opened state.
133  std::string m_project_name;
134  std::string m_file_name;
135  std::shared_ptr<Ws::IProject> m_project;
136  std::shared_ptr<Viewer::IViewerNode> m_root_viewer;
137  std::shared_ptr<ProjectActions::ExportActions> m_export_actions;
138  std::shared_ptr<ProjectActions::ViewerActions> m_viewer_actions;
139 
140  // Widgets
141  std::shared_ptr<PTreeContainer> m_container_parameters;
142  std::shared_ptr<PTreeContainerPreferencesObserver> m_container_preferences;
143 
144  // Actions and menus
145  QAction* m_a_close_project;
146  QMenu* m_m_export;
147  QMenu* m_m_viewers;
148  QMenu* m_m_simulation;
149 
150  // Sub-state
151  SessionController m_running_controller;
152 
153  EnabledActions m_enabled_actions;
154 };
155 
156 } // namespace
157 } // namespace
158 } // namespace
159 
160 #endif // end_of_inclde_guard
Helper class to enable or disable a collection of QAction and QMenu objects at once.
HasUnsavedChanges with the ability of displaying a "save-discard-cancel" dialog to the user before cl...
EnabledActions interface.
void SetPTreeState(const boost::property_tree::ptree &)
Interface for IProject.
see the online Qt documentation
Interface for objects that have non-critical state (metadata) information representable as a ptree...
boost::property_tree::ptree GetPTreeState() const
SessionController header.
see the online Qt documentation
ExportActions header.
virtual Timings GetTimings() const
Timings in duration units specified above.
Simple state machine with 3 states: "disabled", "enabled-not-running" and "enabled-running".
void SetRunning(bool)
Set simulation running.
ViewerActions header.
see the online Qt documentation
HasPtreeState interface.
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
Utility class to for timing.
Definition: Timeable.h:38
HasUnsavedChangesPrompt interface.