//#####################################################################
// Copyright 2020, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
#ifndef __QT_WINDOW__
#define __QT_WINDOW__

#include <Core/Data_Structures/HASHTABLE.h>
#include <functional>
#include <QOpenGLWidget>
#include <QWindow>

QT_BEGIN_NAMESPACE
class QPainter;
class QOpenGLContext;
class QOpenGLPaintDevice;
class QOpenGLShaderProgram;
class QOpenGLFunctions;
class QMenu;
QT_END_NAMESPACE

namespace PhysBAM{
class QT_CAMERA;
class QT_WORLD;
class QT_RENDER_UTILS;
class QT_COMPONENT;
class PARSE_ARGS;
class QT_MAIN_WINDOW;

class QT_WINDOW : public QOpenGLWidget
{
    Q_OBJECT
public:
    QT_WINDOW(QT_MAIN_WINDOW& main_window);
    ~QT_WINDOW();

    void paintGL() override;
    void Select(int x,int y);
    void Render(bool dump_selection_info=false);
    void Capture(const std::string& pattern,int first_frame,int last_frame);

    QT_RENDER_UTILS* ru=nullptr;
    bool save_select=false;
    bool render_pick_buffer=false;
public slots:
    void Resize();
    void Dump_Selection_Info();
protected:
    bool event(QEvent *event) override;
    void initializeGL() override;
private:
    QT_MAIN_WINDOW& main_window;

    QOpenGLContext *gl_context = nullptr;
    QOpenGLPaintDevice *device = nullptr;
    QOpenGLFunctions& gl;
};
}
#endif
