Commit 046c3ab1 authored by Pierre Kraemer's avatar Pierre Kraemer

update surface selection plugin

parent 573668ba
...@@ -36,7 +36,41 @@ ...@@ -36,7 +36,41 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Method :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="combo_selectionMethod">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>SingleCell</string>
</property>
</item>
<item>
<property name="text">
<string>WithinSphere</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
......
...@@ -13,12 +13,20 @@ namespace CGoGN ...@@ -13,12 +13,20 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
enum SelectionMethod
{
SingleCell = 0,
WithinSphere = 1
};
struct MapParameters struct MapParameters
{ {
MapParameters() MapParameters() :
selectionMethod(SingleCell)
{} {}
VertexAttribute<PFP2::VEC3> positionAttribute; VertexAttribute<PFP2::VEC3> positionAttribute;
SelectionMethod selectionMethod;
}; };
class Surface_Selection_Plugin : public PluginInteraction class Surface_Selection_Plugin : public PluginInteraction
...@@ -52,7 +60,6 @@ public: ...@@ -52,7 +60,6 @@ public:
private slots: private slots:
// slots called from SCHNApps signals // slots called from SCHNApps signals
void selectedViewChanged(View* prev, View* cur);
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur); void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map); void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map); void mapRemoved(MapHandlerGen* map);
...@@ -63,18 +70,22 @@ private slots: ...@@ -63,18 +70,22 @@ private slots:
public slots: public slots:
// slots for Python calls // slots for Python calls
void changePositionAttribute(const QString& view, const QString& map, const QString& name); void changePositionAttribute(const QString& view, const QString& map, const QString& name);
void changeSelectionMethod(const QString& view, const QString& map, unsigned int method);
protected: protected:
Surface_Selection_DockTab* m_dockTab; Surface_Selection_DockTab* m_dockTab;
QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet; QHash<MapHandlerGen*, MapParameters> h_parameterSet;
Utils::Drawer* m_drawer; bool m_selecting;
Utils::VBO* m_selectionSphereVBO;
Utils::PointSprite* m_pointSprite; Utils::PointSprite* m_pointSprite;
Utils::Drawer* m_drawer;
bool m_selecting; // selected cells drawing
Utils::VBO* m_selectedVerticesVBO;
// WithinSphere parameters
Utils::VBO* m_selectionSphereVBO;
PFP2::VEC3 m_selectionCenter; PFP2::VEC3 m_selectionCenter;
PFP2::REAL m_selectionRadius; PFP2::REAL m_selectionRadius;
}; };
......
...@@ -29,6 +29,7 @@ private: ...@@ -29,6 +29,7 @@ private:
private slots: private slots:
void positionAttributeChanged(int index); void positionAttributeChanged(int index);
void selectionMethodChanged(int index);
private: private:
void addVertexAttribute(const QString& name); void addVertexAttribute(const QString& name);
......
...@@ -17,6 +17,7 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select ...@@ -17,6 +17,7 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select
setupUi(this); setupUi(this);
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int))); connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(combo_selectionMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(selectionMethodChanged(int)));
} }
...@@ -27,13 +28,19 @@ void Surface_Selection_DockTab::positionAttributeChanged(int index) ...@@ -27,13 +28,19 @@ void Surface_Selection_DockTab::positionAttributeChanged(int index)
{ {
if(!b_updatingUI) if(!b_updatingUI)
{ {
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap(); MapHandlerGen* map = m_schnapps->getSelectedMap();
if(view && map) if(map)
{ m_plugin->h_parameterSet[map].positionAttribute = map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText());
m_plugin->h_viewParameterSet[view][map].positionAttribute = map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText()); }
view->updateGL(); }
}
void Surface_Selection_DockTab::selectionMethodChanged(int index)
{
if(!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(map)
m_plugin->h_parameterSet[map].selectionMethod = SelectionMethod(index);
} }
} }
...@@ -58,12 +65,11 @@ void Surface_Selection_DockTab::updateMapParameters() ...@@ -58,12 +65,11 @@ void Surface_Selection_DockTab::updateMapParameters()
combo_positionAttribute->clear(); combo_positionAttribute->clear();
combo_positionAttribute->addItem("- select attribute -"); combo_positionAttribute->addItem("- select attribute -");
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap(); MapHandlerGen* map = m_schnapps->getSelectedMap();
if(view && map) if(map)
{ {
const MapParameters& p = m_plugin->h_viewParameterSet[view][map]; const MapParameters& p = m_plugin->h_parameterSet[map];
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3())); QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
...@@ -80,6 +86,8 @@ void Surface_Selection_DockTab::updateMapParameters() ...@@ -80,6 +86,8 @@ void Surface_Selection_DockTab::updateMapParameters()
++i; ++i;
} }
} }
combo_selectionMethod->setCurrentIndex(p.selectionMethod);
} }
b_updatingUI = false; b_updatingUI = false;
......
...@@ -32,8 +32,8 @@ public: ...@@ -32,8 +32,8 @@ public:
virtual unsigned int getOrbit() = 0; virtual unsigned int getOrbit() = 0;
virtual void select(Dart d, bool emitSignal) = 0; virtual void select(Dart d, bool emitSignal = true) = 0;
virtual void unselect(Dart d, bool emitSignal) = 0; virtual void unselect(Dart d, bool emitSignal = true) = 0;
inline void select(const std::vector<Dart>& d) inline void select(const std::vector<Dart>& d)
{ {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "Topology/generic/functor.h" #include "Topology/generic/functor.h"
#include "Topology/generic/attributeHandler.h" #include "Topology/generic/attributeHandler.h"
//#include "Utils/drawer.h" #include "Utils/drawer.h"
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
...@@ -55,9 +55,9 @@ public slots: ...@@ -55,9 +55,9 @@ public slots:
Utils::GLSLShader* getBBDrawerShader() const Utils::GLSLShader* getBBDrawerShader() const
{ {
// if(m_bbDrawer) if(m_bbDrawer)
// return m_bbDrawer->getShader(); return m_bbDrawer->getShader();
// else else
return NULL; return NULL;
} }
...@@ -197,7 +197,7 @@ protected: ...@@ -197,7 +197,7 @@ protected:
qglviewer::Vec m_bbMin; qglviewer::Vec m_bbMin;
qglviewer::Vec m_bbMax; qglviewer::Vec m_bbMax;
float m_bbDiagSize; float m_bbDiagSize;
// Utils::Drawer* m_bbDrawer; Utils::Drawer* m_bbDrawer;
Algo::Render::GL2::MapRender* m_render; Algo::Render::GL2::MapRender* m_render;
......
...@@ -75,17 +75,17 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive) ...@@ -75,17 +75,17 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive)
template <typename PFP> template <typename PFP>
void MapHandler<PFP>::drawBB() void MapHandler<PFP>::drawBB()
{ {
// if(!m_bbDrawer) if(!m_bbDrawer)
// { {
// m_bbDrawer = new Utils::Drawer(); m_bbDrawer = new Utils::Drawer();
// updateBBDrawer(); updateBBDrawer();
// } }
// glPushMatrix(); glPushMatrix();
// glMultMatrixd(m_frame->matrix()); glMultMatrixd(m_frame->matrix());
//// QGLViewer::drawAxis(); // QGLViewer::drawAxis();
// m_bbDrawer->callList(); m_bbDrawer->callList();
// glPopMatrix(); glPopMatrix();
} }
template <typename PFP> template <typename PFP>
...@@ -96,46 +96,46 @@ void MapHandler<PFP>::updateBB(const VertexAttribute<typename PFP::VEC3>& positi ...@@ -96,46 +96,46 @@ void MapHandler<PFP>::updateBB(const VertexAttribute<typename PFP::VEC3>& positi
m_bbMax = qglviewer::Vec(m_bb.max()[0], m_bb.max()[1], m_bb.max()[2]); m_bbMax = qglviewer::Vec(m_bb.max()[0], m_bb.max()[1], m_bb.max()[2]);
m_bbDiagSize = (m_bbMax - m_bbMin).norm(); m_bbDiagSize = (m_bbMax - m_bbMin).norm();
// updateBBDrawer(); updateBBDrawer();
} }
template <typename PFP> template <typename PFP>
void MapHandler<PFP>::updateBBDrawer() void MapHandler<PFP>::updateBBDrawer()
{ {
// if(!m_bbDrawer) if(!m_bbDrawer)
// m_bbDrawer = new Utils::Drawer(); m_bbDrawer = new Utils::Drawer();
// const Geom::Vec3f& bbmin = m_bb.min(); const Geom::Vec3f& bbmin = m_bb.min();
// const Geom::Vec3f& bbmax = m_bb.max(); const Geom::Vec3f& bbmax = m_bb.max();
// m_bbDrawer->newList(GL_COMPILE); m_bbDrawer->newList(GL_COMPILE);
// m_bbDrawer->color3f(0.0f,1.0f,0.0f); m_bbDrawer->color3f(0.0f,1.0f,0.0f);
// m_bbDrawer->lineWidth(1.0f); m_bbDrawer->lineWidth(1.0f);
// m_bbDrawer->begin(GL_LINE_LOOP); m_bbDrawer->begin(GL_LINE_LOOP);
// m_bbDrawer->vertex(bbmin); m_bbDrawer->vertex(bbmin);
// m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmin[2]); m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmin[2]);
// m_bbDrawer->vertex3f(bbmax[0], bbmax[1], bbmin[2]); m_bbDrawer->vertex3f(bbmax[0], bbmax[1], bbmin[2]);
// m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmin[2]); m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmin[2]);
// m_bbDrawer->vertex(bbmin); m_bbDrawer->vertex(bbmin);
// m_bbDrawer->end(); m_bbDrawer->end();
// m_bbDrawer->begin(GL_LINE_LOOP); m_bbDrawer->begin(GL_LINE_LOOP);
// m_bbDrawer->vertex(bbmax); m_bbDrawer->vertex(bbmax);
// m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmax[2]); m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmax[2]);
// m_bbDrawer->vertex3f(bbmin[0], bbmin[1], bbmax[2]); m_bbDrawer->vertex3f(bbmin[0], bbmin[1], bbmax[2]);
// m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmax[2]); m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmax[2]);
// m_bbDrawer->vertex(bbmax); m_bbDrawer->vertex(bbmax);
// m_bbDrawer->end(); m_bbDrawer->end();
// m_bbDrawer->begin(GL_LINES); m_bbDrawer->begin(GL_LINES);
// m_bbDrawer->vertex(bbmin); m_bbDrawer->vertex(bbmin);
// m_bbDrawer->vertex3f(bbmin[0], bbmin[1], bbmax[2]); m_bbDrawer->vertex3f(bbmin[0], bbmin[1], bbmax[2]);
// m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmin[2]); m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmin[2]);
// m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmax[2]); m_bbDrawer->vertex3f(bbmin[0], bbmax[1], bbmax[2]);
// m_bbDrawer->vertex3f(bbmax[0], bbmax[1], bbmin[2]); m_bbDrawer->vertex3f(bbmax[0], bbmax[1], bbmin[2]);
// m_bbDrawer->vertex(bbmax); m_bbDrawer->vertex(bbmax);
// m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmin[2]); m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmin[2]);
// m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmax[2]); m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmax[2]);
// m_bbDrawer->end(); m_bbDrawer->end();
// m_bbDrawer->endList(); m_bbDrawer->endList();
} }
} // namespace SCHNApps } // namespace SCHNApps
......
...@@ -11,7 +11,7 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map) ...@@ -11,7 +11,7 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map)
m_schnapps(s), m_schnapps(s),
m_map(map), m_map(map),
m_frame(NULL), m_frame(NULL),
// m_bbDrawer(NULL), m_bbDrawer(NULL),
m_render(NULL) m_render(NULL)
{ {
m_frame = new qglviewer::ManipulatedFrame(); m_frame = new qglviewer::ManipulatedFrame();
...@@ -21,8 +21,8 @@ MapHandlerGen::~MapHandlerGen() ...@@ -21,8 +21,8 @@ MapHandlerGen::~MapHandlerGen()
{ {
if(m_frame) if(m_frame)
delete m_frame; delete m_frame;
// if(m_bbDrawer) if(m_bbDrawer)
// delete m_bbDrawer; delete m_bbDrawer;
if(m_render) if(m_render)
delete m_render; delete m_render;
foreach(CGoGN::Utils::VBO* vbo, m_vbo) foreach(CGoGN::Utils::VBO* vbo, m_vbo)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment