mirror of https://github.com/CGAL/cgal
79 lines
2.8 KiB
C++
79 lines
2.8 KiB
C++
#ifndef SCENE_SPHERES_ITEM_H
|
|
#define SCENE_SPHERES_ITEM_H
|
|
#include "Scene_basic_objects_config.h"
|
|
#include "create_sphere.h"
|
|
#include "Color_map.h"
|
|
|
|
#include <CGAL/Three/Scene_group_item.h>
|
|
#include <CGAL/Three/Scene_item_rendering_helper.h>
|
|
#include <CGAL/Three/Scene_interface.h>
|
|
#include <CGAL/Three/Viewer_interface.h>
|
|
#include <CGAL/Sphere_3.h>
|
|
#include <CGAL/Plane_3.h>
|
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
|
#include <QOpenGLShaderProgram>
|
|
|
|
#include <QList>
|
|
#include <vector>
|
|
struct Scene_spheres_item_priv;
|
|
|
|
/* This item contains spheres and associated colors. They are kept in a Spheres_container,
|
|
* sorted by the value of their "index". This item also has an internal picking mechanism that
|
|
* colorizes all the spheres that has the same index as the one that has been picked.
|
|
* The picking is only usable if several indices exist.
|
|
* If all the spheres have the index 0, they can have independent colors (generally used by the items that
|
|
* have a Scene_spheres_item child).
|
|
*/
|
|
class SCENE_BASIC_OBJECTS_EXPORT Scene_spheres_item
|
|
: public CGAL::Three::Scene_group_item
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
|
typedef CGAL::Sphere_3<Kernel> Sphere;
|
|
typedef std::pair<Sphere, CGAL::IO::Color> Sphere_pair;
|
|
typedef std::vector<std::vector<Sphere_pair> > Spheres_container;
|
|
|
|
Scene_spheres_item(Scene_group_item* parent, std::size_t max_index = 0, bool planed = false, bool pickable = true);
|
|
|
|
~Scene_spheres_item();
|
|
|
|
Bbox bbox() const override { return _bbox; }
|
|
bool isFinite() const override{ return true; }
|
|
bool isEmpty() const override{ return false; }
|
|
Scene_item* clone() const override{return nullptr;}
|
|
QString toolTip() const override;
|
|
bool supportsRenderingMode(RenderingMode m) const override{
|
|
return (m == Gouraud || m == Wireframe);
|
|
}
|
|
void compute_bbox() const override;
|
|
void add_sphere(const Sphere &sphere, std::size_t index = 0, CGAL::IO::Color = CGAL::IO::Color(120,120,120));
|
|
void clear_spheres();
|
|
void setPrecision(int prec);
|
|
void gl_initialization(CGAL::Three::Viewer_interface* viewer);
|
|
void draw(CGAL::Three::Viewer_interface* viewer) const override;
|
|
void drawEdges(CGAL::Three::Viewer_interface* viewer) const override;
|
|
void invalidateOpenGLBuffers() override;
|
|
void setPlane(Kernel::Plane_3 p_plane);
|
|
void setToolTip(QString s);
|
|
void setColor(QColor c) override;
|
|
bool save(const std::string &file_name) const;
|
|
|
|
QMenu *contextMenu() override;
|
|
|
|
void initializeBuffers(Viewer_interface *) const override;
|
|
void computeElements() const override;
|
|
bool eventFilter(QObject *watched, QEvent *event)override;
|
|
|
|
Q_SIGNALS:
|
|
void on_color_changed();
|
|
void picked(std::size_t id) const;
|
|
void destroyMe();
|
|
protected:
|
|
friend struct Scene_spheres_item_priv;
|
|
Scene_spheres_item_priv* d;
|
|
bool connected_alpha_slider;
|
|
};
|
|
|
|
#endif // SCENE_SPHERES_ITEM_H
|