/*
    QGLViewWindow
    Ivan Pelipenko peri4ko@yandex.ru

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef QGLVIEWWINDOW_H
#define QGLVIEWWINDOW_H

#include "formats/loader_assimp.h"
#include "formats/loader_qgl.h"
#include "session_manager.h"
#include "ui_qglview_window.h"

#include <QClipboard>
#include <QCloseEvent>
#include <QColorDialog>
#include <QFileDialog>
#include <QInputDialog>
#include <QRadioButton>
#include <QSplitter>
#include <QThread>
#include <QTime>
#include <QTranslator>
#include <QUrl>
// #include "renderer_rt.h"
#include "qglview.h"
#include "ui_qglview_window.h"


class QGLViewWindow
	: public QMainWindow
	, public Ui::QGLViewWindow {
	Q_OBJECT

public:
	QGLViewWindow(QWidget * parent = 0);
	~QGLViewWindow();

	void loadFile(const QString & path, bool import = false);

private:
	// Qt`s overloaded
	void changeEvent(QEvent * e);
	void timerEvent(QTimerEvent *);

	QString extensions;
	QTranslator translator;
	QString prev_path;
	// GLPrimitiveCube * box;
	Material m;
	SessionManager session;
	bool isChanged;

private slots:
	/*	void on_groupShadows_clicked(bool val) { view->view()->setFeature(QGLView::qglShadowsEnabled, val); }
		void on_groupEyeAccomodation_clicked(bool val) { view->view()->setFeature(QGLView::qglEyeAccomodationEnabled, val); }
		void on_groupBloom_clicked(bool val) { view->view()->setFeature(QGLView::qglBloomEnabled, val); }
		void on_groupMotionBlur_clicked(bool val) { view->view()->setFeature(QGLView::qglMotionBlurEnabled, val); }
		void on_groupReflections_clicked(bool val) { view->view()->setFeature(QGLView::qglReflectionsEnabled, val); }
		void on_checkSoftShadows_clicked(bool val) { view->view()->setFeature(QGLView::qglShadowsSoftEnabled, val); }
		void on_groupSSAO_clicked(bool val) { view->view()->setFeature(QGLView::qglSSAOEnabled, val); }
		void on_groupDOF_clicked(bool val) { view->view()->setFeature(QGLView::qglDepthOfFieldEnabled, val); }
		void on_checkDOFAutoFocus_clicked(bool val) { view->view()->setFeature(QGLView::qglDepthOfFieldAutoFocusEnabled, val); }
		void on_spinDOFFocus_valueChanged(double val) { view->view()->setFeature(QGLView::qglDepthOfFieldFocus, val); }
		void on_spinDOFDiaphragm_valueChanged(double val) { view->view()->setFeature(QGLView::qglDepthOfFieldDiaphragm, val); }
		void on_spinDOFSpeed_valueChanged(double val) { view->view()->setFeature(QGLView::qglDepthOfFieldAutoFocusSpeed, val); }
		void on_spinAccom_valueChanged(double val) { view->view()->setFeature(QGLView::qglEyeAccomodationTime, val); }
		void on_spinAccomMS_valueChanged(double val) { view->view()->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val); }
		void on_checkReflectionsBlur_clicked(bool val) { view->view()->setFeature(QGLView::qglReflectionsBlur, val); }
		void on_spinShadowmapSize_valueChanged(double val) { view->view()->setFeature(QGLView::qglShadowsMapSize, val); }
		void on_spinMotionBlurFactor_valueChanged(double val) { view->view()->setFeature(QGLView::qglMotionBlurFactor, val); }
		void on_spinMotionBlurSteps_valueChanged(int val) { view->view()->setFeature(QGLView::qglMotionBlurSteps, val); }
		void on_spinBloomFactor_valueChanged(double val) { view->view()->setFeature(QGLView::qglBloomFactor, val); }
		void on_spinBloomRadius_valueChanged(int val) { view->view()->setFeature(QGLView::qglBloomRadius, val); }
		void on_spinBloomThreshold_valueChanged(double val) { view->view()->setFeature(QGLView::qglBloomThreshold, val); }
		void on_spinSSAORadius_valueChanged(int val) { view->view()->setFeature(QGLView::qglSSAORadius, val); }
	*/
	void on_actionExit_triggered() { close(); }
	void on_actionReset_triggered();
	void on_actionImport_triggered();
	void on_actionSave_triggered();
	void on_actionSaveSelected_triggered();
	void on_actionOpen_triggered();

	void view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m);

	void on_pushButton_2_clicked() { view->view()->reloadShaders(); }
	void on_buttonParamsApply_clicked();

	void on_actionArrow_triggered(bool on);
	void on_actionMove_triggered(bool on);
	void on_actionRotate_triggered(bool on);
	void on_actionScale_triggered(bool on);

	void on_pushButton_3_clicked();

public slots:

signals:

private:
	QMatrix4x4 cam_mat;
};

#endif // QGLVIEWWINDOW_H
