Commit 3cd5f660 authored by Pierre Kraemer's avatar Pierre Kraemer

little improvements & bug fixes

parent 03178203
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual void mouseMove(View* view, QMouseEvent* event); virtual void mouseMove(View* view, QMouseEvent* event);
virtual void wheelEvent(View* view, QWheelEvent* event); virtual void wheelEvent(View* view, QWheelEvent* event);
virtual void viewLinked(View *view) {} virtual void viewLinked(View *view);
virtual void viewUnlinked(View *view) {} virtual void viewUnlinked(View *view) {}
private slots: private slots:
......
...@@ -53,24 +53,6 @@ void Surface_Selection_Plugin::disable() ...@@ -53,24 +53,6 @@ void Surface_Selection_Plugin::disable()
void Surface_Selection_Plugin::draw(View *view) void Surface_Selection_Plugin::draw(View *view)
{ {
if(m_selecting)
{
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(m_selectionCenter);
m_selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setAttributePosition(m_selectionSphereVBO);
m_pointSprite->setSize(m_selectionRadius);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->enableVertexAttribs();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_POINTS, 0, 1);
glDisable(GL_BLEND);
m_pointSprite->disableVertexAttribs();
}
} }
void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
...@@ -96,6 +78,25 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -96,6 +78,25 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_drawer->endList(); m_drawer->endList();
} }
} }
if(m_selecting)
{
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(m_selectionCenter);
m_selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setAttributePosition(m_selectionSphereVBO);
m_pointSprite->setSize(m_selectionRadius);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->enableVertexAttribs();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_POINTS, 0, 1);
glDisable(GL_BLEND);
m_pointSprite->disableVertexAttribs();
}
} }
} }
...@@ -121,7 +122,7 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event) ...@@ -121,7 +122,7 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event)
void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
{ {
if(event->button() == Qt::LeftButton && m_selecting) if(m_selecting && (event->button() == Qt::LeftButton || event->button() == Qt::RightButton))
{ {
MapHandlerGen* mh = m_schnapps->getSelectedMap(); MapHandlerGen* mh = m_schnapps->getSelectedMap();
const MapParameters& p = h_viewParameterSet[view][mh]; const MapParameters& p = h_viewParameterSet[view][mh];
...@@ -152,16 +153,27 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -152,16 +153,27 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
if(selector) if(selector)
{ {
switch(orbit) if(event->button() == Qt::LeftButton)
{ {
case DART: break; switch(orbit)
case VERTEX: selector->select(neigh.getInsideVertices()); break; {
case EDGE: selector->select(neigh.getInsideEdges()); break; case DART: break;
case FACE: selector->select(neigh.getInsideFaces()); break; case VERTEX: selector->select(neigh.getInsideVertices()); break;
case EDGE: selector->select(neigh.getInsideEdges()); break;
case FACE: selector->select(neigh.getInsideFaces()); break;
}
}
else if(event->button() == Qt::RightButton)
{
switch(orbit)
{
case DART: break;
case VERTEX: selector->unselect(neigh.getInsideVertices()); break;
case EDGE: selector->unselect(neigh.getInsideEdges()); break;
case FACE: selector->unselect(neigh.getInsideFaces()); break;
}
} }
} }
view->updateGL() ;
} }
} }
} }
...@@ -208,13 +220,20 @@ void Surface_Selection_Plugin::wheelEvent(View* view, QWheelEvent* event) ...@@ -208,13 +220,20 @@ void Surface_Selection_Plugin::wheelEvent(View* view, QWheelEvent* event)
if(m_selecting) if(m_selecting)
{ {
if(event->delta() > 0) if(event->delta() > 0)
m_selectionRadius *= 0.9f ; m_selectionRadius *= 0.9f;
else else
m_selectionRadius *= 1.1f ; m_selectionRadius *= 1.1f;
view->updateGL() ; view->updateGL();
} }
} }
void Surface_Selection_Plugin::viewLinked(View *view)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(map)
m_selectionRadius = map->getBBdiagSize() / 50.0f;
}
......
...@@ -102,12 +102,14 @@ public: ...@@ -102,12 +102,14 @@ public:
{ {
for(unsigned int i = 0; i < d.size(); ++i) for(unsigned int i = 0; i < d.size(); ++i)
select(d[i], false); select(d[i], false);
emit(selectedCellsChanged());
} }
inline void unselect(const std::vector<Dart>& d) inline void unselect(const std::vector<Dart>& d)
{ {
for(unsigned int i = 0; i < d.size(); ++i) for(unsigned int i = 0; i < d.size(); ++i)
unselect(d[i], false); unselect(d[i], false);
emit(selectedCellsChanged());
} }
inline bool isSelected(Dart d) inline bool isSelected(Dart d)
......
...@@ -74,13 +74,6 @@ public slots: ...@@ -74,13 +74,6 @@ public slots:
return matrix; return matrix;
} }
private slots:
void frameModified()
{
foreach(View* view, l_views)
view->updateGL();
}
public: public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0; virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
virtual void drawBB() = 0; virtual void drawBB() = 0;
...@@ -178,6 +171,7 @@ signals: ...@@ -178,6 +171,7 @@ signals:
void cellSelectorAdded(unsigned int orbit, const QString& name); void cellSelectorAdded(unsigned int orbit, const QString& name);
void cellSelectorRemoved(unsigned int orbit, const QString& name); void cellSelectorRemoved(unsigned int orbit, const QString& name);
void selectedCellsChanged();
protected: protected:
QString m_name; QString m_name;
......
...@@ -15,16 +15,12 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map) ...@@ -15,16 +15,12 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map)
m_render(NULL) m_render(NULL)
{ {
m_frame = new qglviewer::ManipulatedFrame(); m_frame = new qglviewer::ManipulatedFrame();
connect(m_frame, SIGNAL(modified()), this, SLOT(frameModified()));
} }
MapHandlerGen::~MapHandlerGen() MapHandlerGen::~MapHandlerGen()
{ {
if(m_frame) if(m_frame)
{
disconnect(m_frame, SIGNAL(modified()), this, SLOT(frameModified()));
delete m_frame; delete m_frame;
}
if(m_bbDrawer) if(m_bbDrawer)
delete m_bbDrawer; delete m_bbDrawer;
if(m_render) if(m_render)
...@@ -134,6 +130,9 @@ CellSelectorGen* MapHandlerGen::addCellSelector(unsigned int orbit, const QStrin ...@@ -134,6 +130,9 @@ CellSelectorGen* MapHandlerGen::addCellSelector(unsigned int orbit, const QStrin
m_cellSelectors[orbit].insert(name, cs); m_cellSelectors[orbit].insert(name, cs);
emit(cellSelectorAdded(orbit, name)); emit(cellSelectorAdded(orbit, name));
connect(cs, SIGNAL(selectedCellsChanged()), this, SIGNAL(selectedCellsChanged()));
return cs; return cs;
} }
...@@ -144,6 +143,9 @@ void MapHandlerGen::removeCellSelector(unsigned int orbit, const QString& name) ...@@ -144,6 +143,9 @@ void MapHandlerGen::removeCellSelector(unsigned int orbit, const QString& name)
{ {
m_cellSelectors[orbit].remove(name); m_cellSelectors[orbit].remove(name);
emit(cellSelectorRemoved(orbit, name)); emit(cellSelectorRemoved(orbit, name));
disconnect(cs, SIGNAL(selectedCellsChanged()), this, SIGNAL(selectedCellsChanged()));
delete cs; delete cs;
} }
} }
......
...@@ -132,9 +132,15 @@ void View::linkMap(MapHandlerGen* map) ...@@ -132,9 +132,15 @@ void View::linkMap(MapHandlerGen* map)
l_maps.push_back(map); l_maps.push_back(map);
map->linkView(this); map->linkView(this);
emit(mapLinked(map)); emit(mapLinked(map));
updateCurrentCameraBB(); updateCurrentCameraBB();
updateGL(); updateGL();
connect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL())); connect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
connect(map, SIGNAL(selectedCellsChanged()), this, SLOT(updateGL()));
if(map == m_schnapps->getSelectedMap())
setManipulatedFrame(map->getFrame());
} }
} }
...@@ -151,9 +157,15 @@ void View::unlinkMap(MapHandlerGen* map) ...@@ -151,9 +157,15 @@ void View::unlinkMap(MapHandlerGen* map)
{ {
map->unlinkView(this); map->unlinkView(this);
emit(mapUnlinked(map)); emit(mapUnlinked(map));
updateCurrentCameraBB(); updateCurrentCameraBB();
updateGL(); updateGL();
disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL())); disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
disconnect(map, SIGNAL(selectedCellsChanged()), this, SLOT(updateGL()));
if(map == m_schnapps->getSelectedMap())
setManipulatedFrame(NULL);
} }
} }
......
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