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

little improvements & bug fixes

parent 03178203
......@@ -47,7 +47,7 @@ public:
virtual void mouseMove(View* view, QMouseEvent* event);
virtual void wheelEvent(View* view, QWheelEvent* event);
virtual void viewLinked(View *view) {}
virtual void viewLinked(View *view);
virtual void viewUnlinked(View *view) {}
private slots:
......
......@@ -53,24 +53,6 @@ void Surface_Selection_Plugin::disable()
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)
......@@ -96,6 +78,25 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
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)
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();
const MapParameters& p = h_viewParameterSet[view][mh];
......@@ -152,16 +153,27 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
if(selector)
{
switch(orbit)
if(event->button() == Qt::LeftButton)
{
case DART: break;
case VERTEX: selector->select(neigh.getInsideVertices()); break;
case EDGE: selector->select(neigh.getInsideEdges()); break;
case FACE: selector->select(neigh.getInsideFaces()); break;
switch(orbit)
{
case DART: 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)
if(m_selecting)
{
if(event->delta() > 0)
m_selectionRadius *= 0.9f ;
m_selectionRadius *= 0.9f;
else
m_selectionRadius *= 1.1f ;
view->updateGL() ;
m_selectionRadius *= 1.1f;
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:
{
for(unsigned int i = 0; i < d.size(); ++i)
select(d[i], false);
emit(selectedCellsChanged());
}
inline void unselect(const std::vector<Dart>& d)
{
for(unsigned int i = 0; i < d.size(); ++i)
unselect(d[i], false);
emit(selectedCellsChanged());
}
inline bool isSelected(Dart d)
......
......@@ -74,13 +74,6 @@ public slots:
return matrix;
}
private slots:
void frameModified()
{
foreach(View* view, l_views)
view->updateGL();
}
public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
virtual void drawBB() = 0;
......@@ -178,6 +171,7 @@ signals:
void cellSelectorAdded(unsigned int orbit, const QString& name);
void cellSelectorRemoved(unsigned int orbit, const QString& name);
void selectedCellsChanged();
protected:
QString m_name;
......
......@@ -15,16 +15,12 @@ MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map)
m_render(NULL)
{
m_frame = new qglviewer::ManipulatedFrame();
connect(m_frame, SIGNAL(modified()), this, SLOT(frameModified()));
}
MapHandlerGen::~MapHandlerGen()
{
if(m_frame)
{
disconnect(m_frame, SIGNAL(modified()), this, SLOT(frameModified()));
delete m_frame;
}
if(m_bbDrawer)
delete m_bbDrawer;
if(m_render)
......@@ -134,6 +130,9 @@ CellSelectorGen* MapHandlerGen::addCellSelector(unsigned int orbit, const QStrin
m_cellSelectors[orbit].insert(name, cs);
emit(cellSelectorAdded(orbit, name));
connect(cs, SIGNAL(selectedCellsChanged()), this, SIGNAL(selectedCellsChanged()));
return cs;
}
......@@ -144,6 +143,9 @@ void MapHandlerGen::removeCellSelector(unsigned int orbit, const QString& name)
{
m_cellSelectors[orbit].remove(name);
emit(cellSelectorRemoved(orbit, name));
disconnect(cs, SIGNAL(selectedCellsChanged()), this, SIGNAL(selectedCellsChanged()));
delete cs;
}
}
......
......@@ -132,9 +132,15 @@ void View::linkMap(MapHandlerGen* map)
l_maps.push_back(map);
map->linkView(this);
emit(mapLinked(map));
updateCurrentCameraBB();
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)
{
map->unlinkView(this);
emit(mapUnlinked(map));
updateCurrentCameraBB();
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