//#####################################################################
// Copyright 2011.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class QT_DEBUG_PARTICLES
//#####################################################################
#ifndef __QT_DEBUG_PARTICLES__
#define __QT_DEBUG_PARTICLES__

#include <Core/Arrays/ARRAY.h>
#include "QT_COMPONENT.h"
#include <memory>

namespace PhysBAM
{
template<class TV> class DEBUG_PARTICLES;
template<class OBJ> class QT_OBJECT;
struct DEBUG_PARTICLES_OPTIONS;

template<class TV>
class QT_DEBUG_PARTICLES:public QT_COMPONENT
{
public:
    typedef typename TV::SCALAR T;
    typedef DEBUG_PARTICLES<TV> TYPE;

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

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

public:
    typedef DEBUG_PARTICLES<TV> OBJ_TYPE;

    QT_DEBUG_PARTICLES(QT_WORLD& world,const std::string& name,const std::string& file);
    QT_DEBUG_PARTICLES(QT_WORLD& world,const std::string& name,const std::shared_ptr<QT_OBJECT<TYPE>>& obj);
    virtual ~QT_DEBUG_PARTICLES();

    void Render(QT_RENDER_UTILS& ru) override;
    void Read() override;
    void Invalidate(bool invalidate_common) override;
    RANGE<FV> Bounding_Box() override;
    void Set_Selection(ARRAY_VIEW<int> selection) override;
    void Clear_Selection() override;
    FV Selection_Point() 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;
private:
    void Render_Triangles(QT_RENDER_UTILS& ru,bool filled) const;
    void Render_Segments(QT_RENDER_UTILS& ru) const;
};

}

#endif
