surface_selection.h 2.25 KB
Newer Older
1 2 3 4 5 6 7
#ifndef _SURFACE_SELECTION_PLUGIN_H_
#define _SURFACE_SELECTION_PLUGIN_H_

#include "plugin_interaction.h"
#include "surface_selection_dockTab.h"

#include "Utils/pointSprite.h"
8
#include "Utils/drawer.h"
9 10 11 12 13 14 15

namespace CGoGN
{

namespace SCHNApps
{

16 17 18 19 20 21
enum SelectionMethod
{
	SingleCell = 0,
	WithinSphere = 1
};

22 23
struct MapParameters
{
24 25
	MapParameters() :
		selectionMethod(SingleCell)
26 27 28
	{}

	VertexAttribute<PFP2::VEC3> positionAttribute;
29
	SelectionMethod selectionMethod;
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
};

class Surface_Selection_Plugin : public PluginInteraction
{
	Q_OBJECT
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)

	friend class Surface_Selection_DockTab;

public:
	Surface_Selection_Plugin();

	~Surface_Selection_Plugin()
	{}

	virtual bool enable();
	virtual void disable();

48
	virtual void draw(View *view);
49 50 51 52 53 54 55 56 57
	virtual void drawMap(View* view, MapHandlerGen* map);

	virtual void keyPress(View* view, QKeyEvent* event);
	virtual void keyRelease(View* view, QKeyEvent* event);
	virtual void mousePress(View* view, QMouseEvent* event);
	virtual void mouseRelease(View* view, QMouseEvent* event);
	virtual void mouseMove(View* view, QMouseEvent* event);
	virtual void wheelEvent(View* view, QWheelEvent* event);

58
	virtual void viewLinked(View *view);
59 60 61 62 63 64 65 66 67
	virtual void viewUnlinked(View *view) {}

private slots:
	// slots called from SCHNApps signals
	void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
	void mapAdded(MapHandlerGen* map);
	void mapRemoved(MapHandlerGen* map);

	// slots called from MapHandler signals
68
	void attributeAdded(unsigned int orbit, const QString& name);
69 70 71

public slots:
	// slots for Python calls
72
	void changePositionAttribute(const QString& view, const QString& map, const QString& name);
73
	void changeSelectionMethod(const QString& view, const QString& map, unsigned int method);
74 75 76

protected:
	Surface_Selection_DockTab* m_dockTab;
77
	QHash<MapHandlerGen*, MapParameters> h_parameterSet;
78

79
	bool m_selecting;
80 81

	Utils::PointSprite* m_pointSprite;
82
	Utils::Drawer* m_drawer;
83

Pierre Kraemer's avatar
Pierre Kraemer committed
84 85 86 87 88
	// cell under the mouse when selecting
	Dart m_selectingVertex;
	Dart m_selectingEdge;
	Dart m_selectingFace;

89 90
	// selected cells drawing
	Utils::VBO* m_selectedVerticesVBO;
91

92 93
	// WithinSphere parameters
	Utils::VBO* m_selectionSphereVBO;
94 95 96 97 98 99 100 101
	PFP2::REAL m_selectionRadius;
};

} // namespace SCHNApps

} // namespace CGoGN

#endif