#ifndef QT_INPUT_VIEW_HPP
#define QT_INPUT_VIEW_HPP

#include "initial_state.hpp"
#include "input_geometry.hpp"
#include "view.hpp"
#include "math/point.hpp"
#include "math/spline.hpp"
#include "geometry.hpp"
#include "time.hpp"
#include "source.hpp"

using namespace std;

class QtInputView:public QtView{
  Q_OBJECT
public:
  enum Status{Geom,Init,Sources,Other};
private:
  QtInputGeometry* input_geometry;
  InitialState* initial_state;
  Source* source;
  Status status;
  static constexpr size_t const np=10;
  static constexpr int const pointSize=6;
  static constexpr double const min_d=0.01;
  size_t selected;
  Point point[3*np];
  Spline hsoil;
  Spline hbot;
  Spline hsat;
  double time;
  void initPoints();
  size_t findPoint(int x,int y);
  void drawSpline(Spline& S);
  void moveSelected(double x,double y);
public:
  QtInputView(QtInputGeometry* input_geometry,Geometry* geometry,InitialState* initial_state,Source* source);
  ~QtInputView();
  void paintGL() override;
  void mousePressEvent(QMouseEvent* event);
  void mouseMoveEvent(QMouseEvent* event);
  void mouseReleaseEvent(QMouseEvent* event);
  void setStatus(Status status);
  double getP(size_t ix,size_t iz);
  void paintTank(Tank*);
  void paintPump(Pump*);
  void paintCloud(Cloud*);
public slots:
  void updateGeometry();
  void updateInitialState();
  void updateSource();
  void setTime(int v);
};


inline void
QtInputView::setStatus(Status _status){
  status=_status;
}

inline double
QtInputView::getP(size_t ix,size_t iz){
  return initial_state->Pinit[ix][iz];

}

inline
QtInputView::~QtInputView(){
}

inline void
QtInputView::setTime(int v){
  time=double(v)/99;
  updateSource();
}
#endif
