//#####################################################################
// Copyright 2022, 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_COLOR_MAP__
#define __QT_COLOR_MAP__

#include <Core/Data_Structures/HASHTABLE.h>
#include "QT_WINDOW.h"
#include <functional>
#include <QDialog>
#include <QKeyEvent>
#include <QMainWindow>
#include <QWindow>

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

namespace PhysBAM{
class QT_CAMERA;
class QT_WORLD;
class QT_RENDER_UTILS;
class QT_COMPONENT;
class PARSE_ARGS;
template<class T> class INTERPOLATED_COLOR_MAP;

class QT_COLOR_MAP : public QDialog
{
    Q_OBJECT
public:
    typedef VECTOR<float,3> C;
    typedef INTERPOLATED_COLOR_MAP<float> CM;
    QT_COLOR_MAP(QT_WINDOW& window,QT_COMPONENT& comp,CM& cm,bool& changed);
    virtual ~QT_COLOR_MAP();

    QGridLayout *layout;
    std::function<void()> apply_cmd;
    CM &cm;
    bool& changed;

public slots:
//    void Quit();
private:
    void Action_Cancel();
    void Action_Apply();
    void Action_Accept();
    void Action_Sort();
    void Action_Push();
    void Action_Pop();
    void Action_Rescale();
    void Action_Reverse();
    void Action_Rainbow();
    void Action_Jet();
    void Action_Hot();
    void Rebuild_Colors();
    int num_colors=0;

    ARRAY<std::pair<QLineEdit*,QPushButton*>> color_widgets;
    
    QT_WINDOW& window;
    QT_COMPONENT& comp;
};
}
#endif
