diff --git a/SCHNApps/Plugins/surface_deformation/forms/surface_deformation.ui b/SCHNApps/Plugins/surface_deformation/forms/surface_deformation.ui
index 7430c2405b69100d7183390315b5754efb4d3cf0..e6be71d8c948b50c16828d9bfc3f9f0010d33385 100644
--- a/SCHNApps/Plugins/surface_deformation/forms/surface_deformation.ui
+++ b/SCHNApps/Plugins/surface_deformation/forms/surface_deformation.ui
@@ -33,7 +33,7 @@
-
- Free selector :
+ Free vertices selector :
@@ -59,6 +59,22 @@
+ -
+
+
+ Start
+
+
+
+ -
+
+
-
+
+ - select selector -
+
+
+
+
-
@@ -72,29 +88,13 @@
- -
-
-
- Start
-
-
-
- -
+
-
- Handle selector :
+ Handle vertices selector :
- -
-
-
-
-
- - select selector -
-
-
-
-
diff --git a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp
index 077f3aa4d99d7112980ba2a9fea56dc3a3ba263a..808aecabc31dd792026cd3fad31c1a4c84c7b630 100644
--- a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp
+++ b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp
@@ -81,26 +81,26 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_drawer->vertex(p.positionAttribute[*it]);
m_drawer->end();
m_drawer->endList();
- }
- }
- if(m_selecting)
- {
- std::vector 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();
+ if(m_selecting)
+ {
+ std::vector 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();
+ }
+ }
}
}
}
@@ -111,7 +111,7 @@ void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event)
{
view->setMouseTracking(true);
m_selecting = true;
-// view->updateGL();
+ view->updateGL();
}
}
@@ -121,7 +121,7 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event)
{
view->setMouseTracking(false);
m_selecting = false;
-// view->updateGL();
+ view->updateGL();
}
}
diff --git a/SCHNApps/include/cellSelector.h b/SCHNApps/include/cellSelector.h
index ff85c1d10e0d0169c46eddaf4ee3fd29587e4e89..54556348d7ef5002f6079187d738553c2d84f57d 100644
--- a/SCHNApps/include/cellSelector.h
+++ b/SCHNApps/include/cellSelector.h
@@ -1,14 +1,14 @@
#ifndef _CELL_SELECTOR_H_
#define _CELL_SELECTOR_H_
+#include
#include
+#include
#include "Topology/generic/dart.h"
#include "Topology/generic/genericmap.h"
#include "Topology/generic/cellmarker.h"
-#include
-
namespace CGoGN
{
@@ -35,27 +35,69 @@ public:
virtual void select(Dart d, bool emitSignal) = 0;
virtual void unselect(Dart d, bool emitSignal) = 0;
- virtual void select(const std::vector& d) = 0;
- virtual void unselect(const std::vector& d) = 0;
+ inline void select(const std::vector& d)
+ {
+ for(unsigned int i = 0; i < d.size(); ++i)
+ select(d[i], false);
+ checkChange();
+ if(m_isMutuallyExclusive && !m_mutuallyExclusive.empty())
+ {
+ foreach(CellSelectorGen* cs, m_mutuallyExclusive)
+ cs->checkChange();
+ }
+ }
+
+ inline void unselect(const std::vector& d)
+ {
+ for(unsigned int i = 0; i < d.size(); ++i)
+ unselect(d[i], false);
+ checkChange();
+ }
virtual bool isSelected(Dart d) = 0;
+ inline void setMutuallyExclusive(bool b) { m_isMutuallyExclusive = b; }
+ inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; }
+ inline void setMutuallyExclusiveSet(const QList& mex)
+ {
+ m_mutuallyExclusive.clear();
+ foreach(CellSelectorGen* cs, mex)
+ {
+ if(cs != this)
+ m_mutuallyExclusive.append(cs);
+ }
+ }
+
+ inline void checkChange()
+ {
+ if(m_selectionChanged)
+ {
+ emit(selectedCellsChanged());
+ m_selectionChanged = false;
+ }
+ }
+
signals:
void selectedCellsChanged();
protected:
QString m_name;
std::vector m_cells;
+
+ bool m_selectionChanged;
+
+ bool m_isMutuallyExclusive;
+ QList m_mutuallyExclusive;
};
template
class CellSelector : public CellSelectorGen
{
public:
- CellSelector(GenericMap& m, const QString& name, unsigned int thread = 0) :
+ CellSelector(GenericMap& map, const QString& name, unsigned int thread = 0) :
CellSelectorGen(name),
- m_map(m),
- m_cm(m, thread)
+ m_map(map),
+ m_cm(map, thread)
{}
~CellSelector()
@@ -72,8 +114,15 @@ public:
{
m_cells.push_back(d);
m_cm.mark(v);
+ if(m_isMutuallyExclusive && !m_mutuallyExclusive.empty())
+ {
+ foreach(CellSelectorGen* cs, m_mutuallyExclusive)
+ cs->unselect(d, emitSignal);
+ }
if(emitSignal)
emit(selectedCellsChanged());
+ else
+ m_selectionChanged = true;
}
}
@@ -96,24 +145,12 @@ public:
m_cells.pop_back();
if(emitSignal)
emit(selectedCellsChanged());
+ else
+ m_selectionChanged = true;
}
}
}
- inline void select(const std::vector& d)
- {
- for(unsigned int i = 0; i < d.size(); ++i)
- select(d[i], false);
- emit(selectedCellsChanged());
- }
-
- inline void unselect(const std::vector& d)
- {
- for(unsigned int i = 0; i < d.size(); ++i)
- unselect(d[i], false);
- emit(selectedCellsChanged());
- }
-
inline bool isSelected(Dart d)
{
return m_cm.isMarked(d);
diff --git a/SCHNApps/include/controlDock_mapTab.h b/SCHNApps/include/controlDock_mapTab.h
index 0d097f015a4eecad5e11673975815ba2565cd47f..2ba43f3ae4adc695e5a7d55973b522529a038b3b 100644
--- a/SCHNApps/include/controlDock_mapTab.h
+++ b/SCHNApps/include/controlDock_mapTab.h
@@ -38,6 +38,7 @@ private slots:
void vertexAttributeCheckStateChanged(QListWidgetItem* item);
void selectedSelectorChanged();
+ void selectorCheckStateChanged(QListWidgetItem* item);
void addSelector();
void removeSelector();
diff --git a/SCHNApps/include/mapHandler.h b/SCHNApps/include/mapHandler.h
index ac1e9e12a1b6c80b59615d2d5a18b941cbcd383e..69cca09ec3545d84ddc2ff6a10c8df5fb6f74292 100644
--- a/SCHNApps/include/mapHandler.h
+++ b/SCHNApps/include/mapHandler.h
@@ -152,6 +152,8 @@ public:
template
CellSelector* getCellSelector(const QString& name) const;
+ void updateMutuallyExclusiveSelectors(unsigned int orbit);
+
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
diff --git a/SCHNApps/src/cellSelector.cpp b/SCHNApps/src/cellSelector.cpp
index 58c4bc94d723ed344fa026f6b9d2e117da7d7f4f..b74f8450c08484a694541269377c1c3140c79d0d 100644
--- a/SCHNApps/src/cellSelector.cpp
+++ b/SCHNApps/src/cellSelector.cpp
@@ -9,7 +9,9 @@ namespace SCHNApps
unsigned int CellSelectorGen::selectorCount = 0;
CellSelectorGen::CellSelectorGen(const QString& name) :
- m_name(name)
+ m_name(name),
+ m_selectionChanged(false),
+ m_isMutuallyExclusive(false)
{
++selectorCount;
}
diff --git a/SCHNApps/src/controlDock_mapTab.cpp b/SCHNApps/src/controlDock_mapTab.cpp
index 2251921eecc9cc7f659a72ec83686ed378da501d..02e13e4921b8c0539eae2f175ef1da62dbaf5187 100644
--- a/SCHNApps/src/controlDock_mapTab.cpp
+++ b/SCHNApps/src/controlDock_mapTab.cpp
@@ -28,22 +28,27 @@ ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) :
connect(m_schnapps, SIGNAL(selectedViewChanged(View*,View*)), this, SLOT(selectedViewChanged(View*,View*)));
connect(list_dartSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
+ connect(list_dartSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(selectorCheckStateChanged(QListWidgetItem*)));
connect(button_dartAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_dartRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_vertexSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
+ connect(list_vertexSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(selectorCheckStateChanged(QListWidgetItem*)));
connect(button_vertexAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_vertexRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_edgeSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
+ connect(list_edgeSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(selectorCheckStateChanged(QListWidgetItem*)));
connect(button_edgeAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_edgeRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_faceSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
+ connect(list_faceSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(selectorCheckStateChanged(QListWidgetItem*)));
connect(button_faceAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_faceRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
connect(list_volumeSelectors, SIGNAL(itemSelectionChanged()), this, SLOT(selectedSelectorChanged()));
+ connect(list_volumeSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(selectorCheckStateChanged(QListWidgetItem*)));
connect(button_volumeAddSelector, SIGNAL(clicked()), this, SLOT(addSelector()));
connect(button_volumeRemoveSelector, SIGNAL(clicked()), this, SLOT(removeSelector()));
}
@@ -157,6 +162,20 @@ void ControlDock_MapTab::selectedSelectorChanged()
}
}
+void ControlDock_MapTab::selectorCheckStateChanged(QListWidgetItem* item)
+{
+ if(!b_updatingUI)
+ {
+ if(m_selectedMap)
+ {
+ unsigned int orbit = getCurrentOrbit();
+ CellSelectorGen* cs = m_selectedMap->getCellSelector(orbit, item->text());
+ cs->setMutuallyExclusive(item->checkState() == Qt::Checked);
+ m_selectedMap->updateMutuallyExclusiveSelectors(orbit);
+ }
+ }
+}
+
void ControlDock_MapTab::addSelector()
{
if(!b_updatingUI)
@@ -327,75 +346,60 @@ void ControlDock_MapTab::updateSelectedMapInfo()
for(unsigned int orbit = DART; orbit <= VOLUME; ++orbit)
{
unsigned int nbc = m->getNbCells(orbit);
+
+ QListWidget* selectorList = NULL;
+
switch(orbit)
{
case DART : {
unsigned int nb = m->getNbDarts();
label_dartNbOrbits->setText(QString::number(nb));
label_dartNbCells->setText(QString::number(nbc));
- foreach(CellSelectorGen* cs, m_selectedMap->getCellSelectorSet(orbit).values())
- {
- QListWidgetItem* item = new QListWidgetItem(cs->getName(), list_dartSelectors);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- if(m_selectedSelector[orbit] == cs)
- item->setSelected(true);
- }
+ selectorList = list_dartSelectors;
break;
}
case VERTEX : {
unsigned int nb = m->getNbOrbits();
label_vertexNbOrbits->setText(QString::number(nb));
label_vertexNbCells->setText(QString::number(nbc));
- foreach(CellSelectorGen* cs, m_selectedMap->getCellSelectorSet(orbit).values())
- {
- QListWidgetItem* item = new QListWidgetItem(cs->getName(), list_vertexSelectors);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- if(m_selectedSelector[orbit] == cs)
- item->setSelected(true);
- }
+ selectorList = list_vertexSelectors;
break;
}
case EDGE : {
unsigned int nb = m->getNbOrbits();
label_edgeNbOrbits->setText(QString::number(nb));
label_edgeNbCells->setText(QString::number(nbc));
- foreach(CellSelectorGen* cs, m_selectedMap->getCellSelectorSet(orbit).values())
- {
- QListWidgetItem* item = new QListWidgetItem(cs->getName(), list_edgeSelectors);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- if(m_selectedSelector[orbit] == cs)
- item->setSelected(true);
- }
+ selectorList = list_edgeSelectors;
break;
}
case FACE : {
unsigned int nb = m->getNbOrbits();
label_faceNbOrbits->setText(QString::number(nb));
label_faceNbCells->setText(QString::number(nbc));
- foreach(CellSelectorGen* cs, m_selectedMap->getCellSelectorSet(orbit).values())
- {
- QListWidgetItem* item = new QListWidgetItem(cs->getName(), list_faceSelectors);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- if(m_selectedSelector[orbit] == cs)
- item->setSelected(true);
- }
+ selectorList = list_faceSelectors;
break;
}
case VOLUME : {
unsigned int nb = m->getNbOrbits();
label_volumeNbOrbits->setText(QString::number(nb));
label_volumeNbCells->setText(QString::number(nbc));
- foreach(CellSelectorGen* cs, m_selectedMap->getCellSelectorSet(orbit).values())
- {
- QListWidgetItem* item = new QListWidgetItem(cs->getName(), list_volumeSelectors);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- if(m_selectedSelector[orbit] == cs)
- item->setSelected(true);
- }
+ selectorList = list_volumeSelectors;
break;
}
}
+ foreach(CellSelectorGen* cs, m_selectedMap->getCellSelectorSet(orbit).values())
+ {
+ QListWidgetItem* item = new QListWidgetItem(cs->getName(), selectorList);
+ item->setFlags(item->flags() | Qt::ItemIsEditable);
+ if(m_selectedSelector[orbit] == cs)
+ item->setSelected(true);
+ if(cs->isMutuallyExclusive())
+ item->setCheckState(Qt::Checked);
+ else
+ item->setCheckState(Qt::Unchecked);
+ }
+
if(m->isOrbitEmbedded(orbit))
{
AttributeContainer& cont = m->getAttributeContainer(orbit);
diff --git a/SCHNApps/src/mapHandler.cpp b/SCHNApps/src/mapHandler.cpp
index d8c0fc791896664f8b634ab7c7ff6efad548135a..5443bbba38d73fd427364a128f670ef2cfbf541e 100644
--- a/SCHNApps/src/mapHandler.cpp
+++ b/SCHNApps/src/mapHandler.cpp
@@ -47,9 +47,7 @@ Utils::VBO* MapHandlerGen::createVBO(const AttributeMultiVectorGen* attr)
emit(vboAdded(vbo));
}
else
- {
vbo->updateData(attr);
- }
return vbo;
}
else
@@ -158,6 +156,18 @@ CellSelectorGen* MapHandlerGen::getCellSelector(unsigned int orbit, const QStrin
return NULL;
}
+void MapHandlerGen::updateMutuallyExclusiveSelectors(unsigned int orbit)
+{
+ QList mex;
+ foreach(CellSelectorGen* cs, m_cellSelectors[orbit])
+ {
+ if(cs->isMutuallyExclusive())
+ mex.append(cs);
+ }
+ foreach(CellSelectorGen* cs, m_cellSelectors[orbit])
+ cs->setMutuallyExclusiveSet(mex);
+}
+
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp
index a3103c76d95c126207a44defff5d7ef0b1261610..c11e646c5f7f3a04f06f921138e65cdb53194516 100644
--- a/SCHNApps/src/view.cpp
+++ b/SCHNApps/src/view.cpp
@@ -139,7 +139,7 @@ void View::linkMap(MapHandlerGen* map)
connect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
connect(map, SIGNAL(selectedCellsChanged()), this, SLOT(updateGL()));
- if(map == m_schnapps->getSelectedMap())
+ if(map->isSelectedMap())
setManipulatedFrame(map->getFrame());
}
}