//#####################################################################
// 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_COMPONENT__
#define __QT_COMPONENT__

#include <Core/Data_Structures/HASHTABLE.h>
#include <Core/Vectors/VECTOR.h>
#include <Core/Viewer/VIEWER_OPTIONS.h>
#include <map>
#include <string>

class QMenu;
class QAction;

namespace PhysBAM{

struct VIEWER_DIR;
class QT_RENDER_UTILS;
struct QT_COMPONENT_OPTION;
struct VIEWER_OPTIONS;
class QT_WORLD;
class QT_WINDOW;
class QT_MAIN_WINDOW;
class PARSE_ARGS;

class QT_COMPONENT;
class QT_WORLD;

class QT_COMPONENT
{
public:
    typedef float F;
    typedef VECTOR<F,3> FV;
    typedef FV COLOR;
protected:

    bool selectable=true;
    std::string name="";
    QT_WORLD& world;
    QAction* action=nullptr;
public:
    std::shared_ptr<QT_COMPONENT> parent;

    QT_COMPONENT(QT_WORLD& world,const std::string& name);
    virtual ~QT_COMPONENT();

    virtual void Read()=0;
    virtual void Invalidate(bool invalidate_common=false)=0;
    virtual RANGE<FV> Bounding_Box() = 0;
    virtual void Render(QT_RENDER_UTILS& ru) = 0;
    virtual void Clear_Selection() = 0;
    virtual void Set_Selection(ARRAY_VIEW<int> selection) = 0;
    virtual FV Selection_Point() = 0;

    virtual void Read_Option(std::istream& in,int level) = 0;
    virtual void Make_Dialog(QT_WINDOW& window) = 0;
    virtual void Add_To_Menu(QT_MAIN_WINDOW& main,QMenu* menu);
    const std::string& Name() const {return name;}
    virtual void Set_Draw(bool draw) = 0;
    virtual bool Draw() const = 0;
    virtual void Save_Settings(std::ostream& out) = 0;
    virtual void Clear_Settings() = 0;
};
}
#endif
