/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#pragma once

#include <QObject>
#include <QDockWidget>
#include "QPulse.h"
#include "engine/SEAction.h"
#include "engine/SEDataRequest.h"
#include "scenario/SEScenario.h"

namespace Ui {
  class DynamicControlsWidget;
}

enum class ScenarioInput { None = 0, State, Patient };
class QDynamicControlsWidget : public QDockWidget, public PulseListener
{
  Q_OBJECT
public:
  QDynamicControlsWidget(QPulse& qp, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
  virtual ~QDynamicControlsWidget();

  void Clear();
  void Reset();
  bool ValidPatient();

  bool SetupShowcase(QString name);
  void SetupPulseEditor();
  void UpateAction(SEAction const&, SEScalarTime const&);
  void LoadScenario(SEScenario& scenario);
  void SaveScenario(SEScenario& scenario);
  void StartEngine();

  void AddTabWidgets(QTabWidget& tabWidget, int tabIdx);

  void AtSteadyState(PhysiologyEngine& pulse) override;
  void AtSteadyStateUpdateUI() override; // Main Window will call this to update UI Components
  void ProcessPhysiology(PhysiologyEngine& pulse) override;
  void PhysiologyUpdateUI() override;// Main Window will call this to update UI Components
  void EngineErrorUI() override {};
  public slots:
    void LoadState();
    void ClearPatient();
    void OpenAction(SEAction const& action, SEScalarTime const& pTime);

protected:
  void LoadState(std::string const& engineStateFile);

private:
  class Controls;
  Controls* m_Controls;
  
};