VPTissue Reference Manual
LogWindowViewer.h
Go to the documentation of this file.
1 #ifndef LOGWINDOWVIEWER_H_INCLUDED
2 #define LOGWINDOWVIEWER_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  */
23 #include "gui/ViewerDockWidget.h"
24 #include "sim/CoupledSim.h"
26 #include "sim/event/SimEvent.h"
27 
28 #include <functional>
29 #include <string>
30 
31 class QPlainTextEdit;
32 class QWidget;
33 
34 namespace SimPT_Shell {
35 
40 {
41 public:
42  LogWindowViewer(const std::shared_ptr<SimShell::Ws::MergedPreferences>&,
43  SimShell::Gui::Controller::AppController*, std::function<void()> on_close);
44 
45  virtual ~LogWindowViewer();
46 
47  template <typename EventType>
48  void Update(const EventType&);
49 
50 private:
51  std::shared_ptr<SimShell::Ws::MergedPreferences> m_preferences;
53 };
54 
55 template<typename EventType>
56 inline void LogWindowViewer::Update(const EventType& e)
57 {
58  switch (e.GetType()) {
59  case SimPT_Sim::Event::SimEventType::Initialized:
60  {
61  m_app->Log("Initialized> path = " + m_preferences->GetPath());
62  break;
63  }
64  case SimPT_Sim::Event::SimEventType::Stepped:
65  {
66  m_app->Log("Stepped> " + e.GetSource()->GetStatusMessage());
67  break;
68  }
69  case SimPT_Sim::Event::SimEventType::Done:
70  {
71  m_app->Log("Done> path = " + m_preferences->GetPath());
72  break;
73  }
74  case SimPT_Sim::Event::SimEventType::Forced:
75  {
76  m_app->Log("Forced> " + e.GetSource()->GetStatusMessage());
77  break;
78  }
79  }
80 }
81 
82 template<>
83 inline void LogWindowViewer::Update(const SimPT_Sim::Event::CoupledSimEvent& e)
84 {
85  switch (e.GetType()) {
86  case SimPT_Sim::Event::SimEventType::Initialized:
87  {
88  m_app->Log("Initialized> path = " + m_preferences->GetPath());
89  break;
90  }
91  case SimPT_Sim::Event::SimEventType::Stepped:
92  {
93  m_app->Log("Stepped> " + std::to_string(e.GetSource()->GetSimStep()));
94  break;
95  }
96  case SimPT_Sim::Event::SimEventType::Done:
97  {
98  m_app->Log("Done> path = " + m_preferences->GetPath());
99  break;
100  }
101  case SimPT_Sim::Event::SimEventType::Forced:
102  {
103  m_app->Log("Forced> " + std::to_string(e.GetSource()->GetSimStep()));
104  break;
105  }
106  }
107 }
108 
109 } // namespace
110 
111 #endif // end_of_include_guard
Definition for SimEvent.
AppController header.
Type GetType() const
Get Event type.
Interface for ViewerDockWidget.
Source GetSource() const
Get the data member value.
Namespace for SimPT shell package.
Definition: Client.cpp:50
A viewer that displays sim events in a log in a dock window.
An event transmitted by a Coupled Simulator.
Definition for CoupledSimEvent.
see the online Qt documentation
Interface for CoupledSim.