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

update surface selection plugin

parent 573668ba
......@@ -36,7 +36,41 @@
</item>
</widget>
</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">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
......@@ -13,12 +13,20 @@ namespace CGoGN
namespace SCHNApps
{
enum SelectionMethod
{
SingleCell = 0,
WithinSphere = 1
};
struct MapParameters
{
MapParameters()
MapParameters() :
selectionMethod(SingleCell)
{}
VertexAttribute<PFP2::VEC3> positionAttribute;
SelectionMethod selectionMethod;
};
class Surface_Selection_Plugin : public PluginInteraction
......@@ -52,7 +60,6 @@ public:
private slots:
// slots called from SCHNApps signals
void selectedViewChanged(View* prev, View* cur);
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
......@@ -63,18 +70,22 @@ private slots:
public slots:
// slots for Python calls
void changePositionAttribute(const QString& view, const QString& map, const QString& name);
void changeSelectionMethod(const QString& view, const QString& map, unsigned int method);
protected:
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::Drawer* m_drawer;
bool m_selecting;
// selected cells drawing
Utils::VBO* m_selectedVerticesVBO;
// WithinSphere parameters
Utils::VBO* m_selectionSphereVBO;
PFP2::VEC3 m_selectionCenter;
PFP2::REAL m_selectionRadius;
};
......
......@@ -29,6 +29,7 @@ private:
private slots:
void positionAttributeChanged(int index);
void selectionMethodChanged(int index);
private:
void addVertexAttribute(const QString& name);
......
......@@ -17,6 +17,7 @@ Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Select
setupUi(this);
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)
{
if(!b_updatingUI)
{
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(view && map)
{
m_plugin->h_viewParameterSet[view][map].positionAttribute = map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText());
view->updateGL();
}
if(map)
m_plugin->h_parameterSet[map].positionAttribute = map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText());
}
}
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()
combo_positionAttribute->clear();
combo_positionAttribute->addItem("- select attribute -");
View* view = m_schnapps->getSelectedView();
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()));
......@@ -80,6 +86,8 @@ void Surface_Selection_DockTab::updateMapParameters()
++i;
}
}
combo_selectionMethod->setCurrentIndex(p.selectionMethod);
}
b_updatingUI = false;
......
......@@ -32,8 +32,8 @@ public:
virtual unsigned int getOrbit() = 0;
virtual void select(Dart d, bool emitSignal) = 0;
virtual void unselect(Dart d, bool emitSignal) = 0;
virtual void select(Dart d, bool emitSignal = true) = 0;
virtual void unselect(Dart d, bool emitSignal = true) = 0;
inline void select(const std::vector<Dart>& d)
{
......
......@@ -13,7 +13,7 @@
#include "Topology/generic/functor.h"
#include "Topology/generic/attributeHandler.h"
//#include "Utils/drawer.h"
#include "Utils/drawer.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Geometry/boundingbox.h"
......@@ -55,9 +55,9 @@ public slots:
Utils::GLSLShader* getBBDrawerShader() const
{
// if(m_bbDrawer)
// return m_bbDrawer->getShader();
// else
if(m_bbDrawer)
return m_bbDrawer->getShader();
else
return NULL;
}
......@@ -197,7 +197,7 @@ protected:
qglviewer::Vec m_bbMin;
qglviewer::Vec m_bbMax;
float m_bbDiagSize;
// Utils::Drawer* m_bbDrawer;
Utils::Drawer* m_bbDrawer;
Algo::Render::GL2::MapRender* m_render;
......
......@@ -75,17 +75,17 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive)
template <typename PFP>
void MapHandler<PFP>::drawBB()
{
// if(!m_bbDrawer)
// {
// m_bbDrawer = new Utils::Drawer();
// updateBBDrawer();
// }
// glPushMatrix();
// glMultMatrixd(m_frame->matrix());
//// QGLViewer::drawAxis();
// m_bbDrawer->callList();
// glPopMatrix();
if(!m_bbDrawer)
{
m_bbDrawer = new Utils::Drawer();
updateBBDrawer();
}
glPushMatrix();
glMultMatrixd(m_frame->matrix());
// QGLViewer::drawAxis();
m_bbDrawer->callList();
glPopMatrix();
}
template <typename PFP>
......@@ -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_bbDiagSize = (m_bbMax - m_bbMin).norm();
// updateBBDrawer();
updateBBDrawer();
}
template <typename PFP>
void MapHandler<PFP>::updateBBDrawer()
{
// if(!m_bbDrawer)
// m_bbDrawer = new Utils::Drawer();
// const Geom::Vec3f& bbmin = m_bb.min();
// const Geom::Vec3f& bbmax = m_bb.max();
// m_bbDrawer->newList(GL_COMPILE);
// m_bbDrawer->color3f(0.0f,1.0f,0.0f);
// m_bbDrawer->lineWidth(1.0f);
// m_bbDrawer->begin(GL_LINE_LOOP);
// m_bbDrawer->vertex(bbmin);
// m_bbDrawer->vertex3f(bbmin[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->vertex(bbmin);
// m_bbDrawer->end();
// m_bbDrawer->begin(GL_LINE_LOOP);
// m_bbDrawer->vertex(bbmax);
// m_bbDrawer->vertex3f(bbmax[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->vertex(bbmax);
// m_bbDrawer->end();
// m_bbDrawer->begin(GL_LINES);
// m_bbDrawer->vertex(bbmin);
// 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], bbmax[2]);
// m_bbDrawer->vertex3f(bbmax[0], bbmax[1], bbmin[2]);
// m_bbDrawer->vertex(bbmax);
// m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmin[2]);
// m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmax[2]);
// m_bbDrawer->end();
// m_bbDrawer->endList();
if(!m_bbDrawer)
m_bbDrawer = new Utils::Drawer();
const Geom::Vec3f& bbmin = m_bb.min();
const Geom::Vec3f& bbmax = m_bb.max();
m_bbDrawer->newList(GL_COMPILE);
m_bbDrawer->color3f(0.0f,1.0f,0.0f);
m_bbDrawer->lineWidth(1.0f);
m_bbDrawer->begin(GL_LINE_LOOP);
m_bbDrawer->vertex(bbmin);
m_bbDrawer->vertex3f(bbmin[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->vertex(bbmin);
m_bbDrawer->end();
m_bbDrawer->begin(GL_LINE_LOOP);
m_bbDrawer->vertex(bbmax);
m_bbDrawer->vertex3f(bbmax[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->vertex(bbmax);
m_bbDrawer->end();
m_bbDrawer->begin(GL_LINES);
m_bbDrawer->vertex(bbmin);
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], bbmax[2]);
m_bbDrawer->vertex3f(bbmax[0], bbmax[1], bbmin[2]);
m_bbDrawer->vertex(bbmax);
m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmin[2]);
m_bbDrawer->vertex3f(bbmax[0], bbmin[1], bbmax[2]);
m_bbDrawer->end();
m_bbDrawer->endList();
}
} // namespace SCHNApps
......
......@@ -11,7 +11,7 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map)
m_schnapps(s),
m_map(map),
m_frame(NULL),
// m_bbDrawer(NULL),
m_bbDrawer(NULL),
m_render(NULL)
{
m_frame = new qglviewer::ManipulatedFrame();
......@@ -21,8 +21,8 @@ MapHandlerGen::~MapHandlerGen()
{
if(m_frame)
delete m_frame;
// if(m_bbDrawer)
// delete m_bbDrawer;
if(m_bbDrawer)
delete m_bbDrawer;
if(m_render)
delete m_render;
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