#include "qt/view_solution.hpp"

QtViewSolution::QtViewSolution(Kernel* _kernel):QWidget(){
  kernel=_kernel;
  main_layout=new QVBoxLayout;
  time_bar=new QScrollBar(Qt::Horizontal);
  solution_geometry=new QtViewSolutionGeometry(_kernel);
  info_widget=new QWidget;
  info_layout=new QGridLayout;
  time_label=new QLabel;
  
  time_bar->setMinimum(0);
  time_bar->setMaximum(Time::nT);
  info_layout->addWidget(time_label);
  info_widget->setLayout(info_layout);
  main_layout->addWidget(solution_geometry,1);
  main_layout->addWidget(time_bar);
  main_layout->addWidget(info_widget);
  setLayout(main_layout);
  step=0;
  update();
  connect(time_bar,&QScrollBar::valueChanged,this,&QtViewSolution::time_change);
}


QtViewSolution::~QtViewSolution(){
}

void
QtViewSolution::update(){
  update_infos();
  solution_geometry->draw(step);
}

void
QtViewSolution::update_infos(){
  time_label->setText("Time : "+QString::number(step*Time::dT));
}

void
QtViewSolution::time_change(int val){
  step=val;
  update();
}
