//#####################################################################
// Copyright 2004, Eran Guendelman.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class QT_VECTOR_FIELD
//#####################################################################
#ifndef __QT_VECTOR_FIELD__
#define __QT_VECTOR_FIELD__

#include <Core/Viewer/VIEWER_OPTIONS.h>
#include "QT_GRID_COMPONENT.h"
#include <memory>

namespace PhysBAM
{
template<class OBJ> class QT_OBJECT;

template<class TV>
class QT_VECTOR_FIELD:public QT_GRID_COMPONENT<TV::m>
{
public:
    typedef typename TV::SCALAR T;typedef VECTOR<int,TV::m> IV;
    typedef ARRAY<TV,IV> TYPE;

    typedef VECTOR_FIELD_OPTIONS OPT;
private:
    OPT opt,raw_opt[4];
    std::shared_ptr<QT_OBJECT<TYPE>> obj;

    int selected_index=-1;
    static const QT_COMPONENT_OPTION options[];
    static const int num_options;
    typedef QT_VECTOR_FIELD SELF;

public:
    typedef TV T_VECTOR;
    typedef QT_GRID_COMPONENT<TV::m> BASE;
    using typename BASE::COLOR;using typename BASE::FV;
    using BASE::grid;using BASE::name;using BASE::action;

    QT_VECTOR_FIELD(QT_WORLD& world,const std::string& name,
        const std::string& file,const std::string& grid_file);
    QT_VECTOR_FIELD(QT_WORLD& world,const std::string& name,
        const std::string& grid_file,const std::shared_ptr<QT_OBJECT<TYPE>>& obj);

    virtual ~QT_VECTOR_FIELD();

    void Render(QT_RENDER_UTILS& ru) override;
    void Read() override;
    void Invalidate(bool invalidate_common) override;
    RANGE<FV> Bounding_Box() override;

    void Print_Selection_Info(std::ostream& o,const IV& index,bool cell) const override;
    void Make_Dialog(QT_WINDOW& window) override;
    void Read_Option(std::istream& in,int level) override;
    void Set_Draw(bool draw) override;
    bool Draw() const override;
    void Save_Settings(std::ostream& out) override;
    void Clear_Settings() override;
};
}
#endif
