1 #ifndef VIEW_QT_VIEWER_H_INCLUDED
2 #define VIEW_QT_VIEWER_H_INCLUDED
27 #include "../mesh_drawer/MeshDrawer.h"
29 #include <QGraphicsScene>
44 QtViewer(
const std::shared_ptr<SimShell::Ws::MergedPreferences>& p,
45 QWidget*, std::function<
void()> on_close);
49 template <
typename EventType>
50 void Update(
const EventType&);
56 std::shared_ptr<prefs_type> m_preferences;
57 std::shared_ptr<QGraphicsScene> m_canvas;
61 template <
typename EventType>
62 void QtViewer::Update(
const EventType& e)
64 auto et = e.GetType();
65 auto step = e.GetStep();
67 const bool check = (et == SimPT_Sim::Event::SimEventType::Forced)
68 || (et == SimPT_Sim::Event::SimEventType::Initialized)
69 || (et == SimPT_Sim::Event::SimEventType::Stepped && (m_preferences->m_stride != 0 && (step % m_preferences->m_stride == 0)))
70 || (et == SimPT_Sim::Event::SimEventType::Done && m_preferences->m_stride == 0);
73 std::string s = std::string(
"background-color:") + m_preferences->m_background_color +
";";
74 setStyleSheet(s.c_str());
76 m_drawer.
Draw(e.GetSource(), m_canvas.get());
82 #endif // end_of_include_guard
Graphical viewer showing the mesh at a certain simulation step.
Class drawing a simulator/mesh onto a QGraphicsScene.
Namespace for SimPT shell package.
Definition for SimEventType.
A window containing visual output of a viewer.
Interface/Implementation for QtPreferences.
void Draw(std::shared_ptr< SimPT_Sim::SimInterface > sim, QGraphicsScene *scene)
Draws the mesh to QGraphicsScene.
Interface for ViewerWindow.
see the online Qt documentation
Listener for SimShell::Event::MergedPreferencesChanged events.