#ifndef CONTROLS_H
#define CONTROLS_H

#include <QDockWidget>

class RTMSimulator;
class QDoubleValidator;

namespace Ui {
    class Controls;
}

class Controls : public QDockWidget {
    Q_OBJECT
public:
    Controls(RTMSimulator* pSimulator);
    ~Controls();
    void init();
    void selectionChanged();
    void updateInjectionDiameter(double injectionDiameter);
    void updateInjectionPointCheckBox(Qt::CheckState state);
    void updateInjectionPressure(int injectionPressure);
    void updateCavityHeight(double cavityHeight);
    void updatePermeability(double permeability);
    void updatePorosity(double porosity);
    void saveNodeSettings();

    void setShowSweptNodes(Qt::CheckState state);
    void setShowNeighbors(Qt::CheckState state);
    void setShowDirectNeighbors(Qt::CheckState state);
    void setShowPermeabilityGradient(Qt::CheckState state);
    void setQRS(double q, double r, double s);
    void setViscosity(double viscosity);
    void setQ(double q);
    void setR(double r);
    void setS(double s);
    void setVacuumPressure(double pressure);
    void setCycleNumber(int nCycle);
    void setPictureTimeInterval(double pictureTimeInterval);
    void setRelevantNeighbors(int n);
    void displayCycleNr(int cycleNr);
    void displayTime(double time);
    void setTakePictures(bool takePictures);

    int getNumberOfCycles();
    int numRelevantNeighbors();
    double getPictureTimeInterval();
    double getVacuumPressure();
    double getQ();
    double getR();
    double getS();
    double getViscosity();
    bool isSetTakePictures();


    void updateTotalCells(int);
    void updateCellsFull(int);
    void updateNumberOfInjectionCells(int);
    void updatePivotNodeId(int);
    void updateMedianCellDistance(double);
    void updateCurrentPressure(int);
    void updateNumberOfSelectedNodes(int);
    void updateCellDistance(double);
    void updateCellXYZ(double x, double y, double z);



protected:
    void changeEvent(QEvent *e);

private:
    RTMSimulator* m_pSimulator;
    Ui::Controls *ui;
    QDoubleValidator* m_pMinDistanceValidator;
    int m_totalCells;
    int m_fullCells;
    int m_injectionCells;
    QWidget* advancedTab;

private slots:
    void on_lineEditS_editingFinished();
    void on_lineEditR_editingFinished();
    void on_lineEditQ_editingFinished();
    void on_lineEditSeconds_editingFinished();
    void on_lineEditViscosity_editingFinished();
    void on_pushButtonCheckUnlinkedNodes_clicked();
    void on_checkBoxTakePictures_stateChanged(int );
    void on_buttonStep_clicked();
    void on_buttonStop_clicked();
    void on_buttonPause_clicked();
    void on_buttonStart_clicked();
    void on_buttonSaveCellSettings_clicked();
    void on_buttonRefresh_clicked();
    void on_checkBoxPermeabilityGradient_stateChanged(int );
    void on_checkBoxMarkDirectNeighbors_stateChanged(int );
    void on_checkBoxMarkNeighbors_stateChanged(int );
    void on_checkBoxShowSweptNodes_stateChanged(int );
    void on_buttonDeleteSwept_clicked();
    void on_buttonSweepOnce_clicked();
    void on_buttonSweep_clicked();

public slots:
    void showAdvancedTab(bool show);

signals:
    void start();
    void stop();
    void pause();
    void step(int);
    void state();
    void showProgress(bool);
    void takePictures(bool);
    void updatePictureTimeInterval(double);
    void startLonesomeNodesTest();
    void updateViscosity(double);
    void updateQ(double);
    void updateR(double);
    void updateS(double);
};

#endif // CONTROLS_H
