Commit 430c8802 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'master' of cgogn.u-strasbg.fr:CGoGN

parents 2dd3f2a4 895926cd
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<width>207</width>
<height>545</height>
</rect>
</property>
......@@ -14,35 +14,8 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Locked selector :</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QComboBox" name="combo_lockedSelector">
<item row="6" column="0" colspan="2">
<widget class="QComboBox" name="combo_freeSelector">
<item>
<property name="text">
<string>- select selector -</string>
......@@ -50,20 +23,18 @@
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Handle selector :</string>
<string>Position :</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QComboBox" name="combo_handleSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Free vertices selector :</string>
</property>
</widget>
</item>
<item row="0" column="1">
......@@ -81,20 +52,49 @@
</item>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QPushButton" name="button_start_stop">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QComboBox" name="combo_handleSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
</widget>
</item>
<item row="11" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Handle vertices selector :</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
......
......@@ -30,8 +30,8 @@ struct MapParameters
VertexAttribute<PFP2::VEC3> positionAttribute;
CellSelector<VERTEX>* lockedSelector;
CellSelector<VERTEX>* handleSelector;
CellSelector<VERTEX>* freeSelector;
bool initialized;
......@@ -88,13 +88,13 @@ private slots:
void attributeAdded(unsigned int orbit, const QString& name);
void cellSelectorAdded(unsigned int orbit, const QString& name);
void cellSelectorRemoved(unsigned int orbit, const QString& name);
void selectedCellsChanged();
void selectedCellsChanged(CellSelectorGen *cs);
public slots:
// slots for Python calls
void changePositionAttribute(const QString& map, const QString& name);
void changeLockedSelector(const QString& map, const QString& name);
void changeHandleSelector(const QString& map, const QString& name);
void changeFreeSelector(const QString& map, const QString& name);
protected:
void toggleMapDeformation(MapHandlerGen* map);
......
......@@ -29,8 +29,8 @@ private:
private slots:
void positionAttributeChanged(int index);
void lockedSelectorChanged(int index);
void handleSelectorChanged(int index);
void freeSelectorChanged(int index);
void startStopButtonClicked();
private:
......
......@@ -13,8 +13,8 @@ namespace SCHNApps
{
MapParameters::MapParameters() :
lockedSelector(NULL),
handleSelector(NULL),
freeSelector(NULL),
initialized(false),
nlContext(NULL)
{}
......@@ -29,7 +29,7 @@ void MapParameters::start(MapHandlerGen* mh)
{
if(!initialized)
{
if(positionAttribute.isValid() && lockedSelector && handleSelector)
if(positionAttribute.isValid() && handleSelector && freeSelector)
{
positionInit = mh->getAttribute<PFP2::VEC3, VERTEX>("positionInit", false);
if(!positionInit.isValid())
......@@ -232,6 +232,7 @@ void Surface_Deformation_Plugin::mapAdded(MapHandlerGen* map)
connect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(attributeAdded(unsigned int, const QString&)));
connect(map, SIGNAL(cellSelectorAdded(unsigned int, const QString&)), this, SLOT(cellSelectorAdded(unsigned int, const QString&)));
connect(map, SIGNAL(cellSelectorRemoved(unsigned int, const QString&)), this, SLOT(cellSelectorRemoved(unsigned int, const QString&)));
connect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(selectedCellsChanged(CellSelectorGen*)));
}
void Surface_Deformation_Plugin::mapRemoved(MapHandlerGen* map)
......@@ -239,6 +240,7 @@ void Surface_Deformation_Plugin::mapRemoved(MapHandlerGen* map)
disconnect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(attributeAdded(unsigned int, const QString&)));
disconnect(map, SIGNAL(cellSelectorAdded(unsigned int, const QString&)), this, SLOT(cellSelectorAdded(unsigned int, const QString&)));
disconnect(map, SIGNAL(cellSelectorRemoved(unsigned int, const QString&)), this, SLOT(cellSelectorRemoved(unsigned int, const QString&)));
disconnect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(selectedCellsChanged(CellSelectorGen*)));
}
......@@ -268,26 +270,31 @@ void Surface_Deformation_Plugin::cellSelectorRemoved(unsigned int orbit, const Q
m_dockTab->removeVertexSelector(name);
MapParameters& p = h_parameterSet[map];
if(p.lockedSelector->getName() == name)
if(p.handleSelector->getName() == name)
{
p.stop(map);
if(!p.initialized && map->isSelectedMap())
m_dockTab->mapParametersInitialized(false);
p.lockedSelector = NULL;
p.handleSelector = NULL;
}
if(p.handleSelector->getName() == name)
if(p.freeSelector->getName() == name)
{
p.stop(map);
if(!p.initialized && map->isSelectedMap())
m_dockTab->mapParametersInitialized(false);
p.handleSelector = NULL;
p.freeSelector = NULL;
}
}
void Surface_Deformation_Plugin::selectedCellsChanged()
void Surface_Deformation_Plugin::selectedCellsChanged(CellSelectorGen* cs)
{
// nlMakeCurrent(perMap->nlContext) ;
// nlReset(NL_FALSE) ;
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
MapParameters& p = h_parameterSet[map];
if(p.initialized && (p.handleSelector == cs || p.freeSelector == cs))
{
nlMakeCurrent(p.nlContext) ;
nlReset(NL_FALSE) ;
}
}
......@@ -309,7 +316,7 @@ void Surface_Deformation_Plugin::changePositionAttribute(const QString& map, con
}
}
void Surface_Deformation_Plugin::changeLockedSelector(const QString& map, const QString& name)
void Surface_Deformation_Plugin::changeHandleSelector(const QString& map, const QString& name)
{
MapHandlerGen* m = m_schnapps->getMap(map);
if(m)
......@@ -317,14 +324,14 @@ void Surface_Deformation_Plugin::changeLockedSelector(const QString& map, const
MapParameters& p = h_parameterSet[m];
if(!p.initialized)
{
p.lockedSelector = m->getCellSelector<VERTEX>(name);
p.handleSelector = m->getCellSelector<VERTEX>(name);
if(m->isSelectedMap())
m_dockTab->updateMapParameters();
}
}
}
void Surface_Deformation_Plugin::changeHandleSelector(const QString& map, const QString& name)
void Surface_Deformation_Plugin::changeFreeSelector(const QString& map, const QString& name)
{
MapHandlerGen* m = m_schnapps->getMap(map);
if(m)
......@@ -332,7 +339,7 @@ void Surface_Deformation_Plugin::changeHandleSelector(const QString& map, const
MapParameters& p = h_parameterSet[m];
if(!p.initialized)
{
p.handleSelector = m->getCellSelector<VERTEX>(name);
p.freeSelector = m->getCellSelector<VERTEX>(name);
if(m->isSelectedMap())
m_dockTab->updateMapParameters();
}
......@@ -373,7 +380,7 @@ void Surface_Deformation_Plugin::matchDiffCoord(MapHandlerGen* mh)
nlBegin(NL_SYSTEM) ;
for(int coord = 0; coord < 3; ++coord)
{
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.lockedSelector->getMarker(), p.positionAttribute, coord);
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord);
nlBegin(NL_MATRIX);
LinearSolving::addRowsRHS_Laplacian_Topo<PFP2>(*map, p.vIndex, p.diffCoord, coord);
nlEnd(NL_MATRIX);
......@@ -503,7 +510,7 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
nlBegin(NL_SYSTEM);
for(int coord = 0; coord < 3; ++coord)
{
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.lockedSelector->getMarker(), p.positionAttribute, coord);
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord);
nlBegin(NL_MATRIX);
// LinearSolving::addRowsRHS_Laplacian_Cotan<PFP2>(*map, p.vIndex, p.edgeWeight, p.vertexArea, p.rotatedDiffCoord, coord);
LinearSolving::addRowsRHS_Laplacian_Topo<PFP2>(*map, p.vIndex, p.rotatedDiffCoord, coord);
......
......@@ -18,8 +18,8 @@ Surface_Deformation_DockTab::Surface_Deformation_DockTab(SCHNApps* s, Surface_De
setupUi(this);
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(combo_lockedSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(lockedSelectorChanged(int)));
connect(combo_handleSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectorChanged(int)));
connect(combo_freeSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(freeSelectorChanged(int)));
connect(button_start_stop, SIGNAL(clicked()), this, SLOT(startStopButtonClicked()));
}
......@@ -42,23 +42,23 @@ void Surface_Deformation_DockTab::positionAttributeChanged(int index)
}
}
void Surface_Deformation_DockTab::lockedSelectorChanged(int index)
void Surface_Deformation_DockTab::handleSelectorChanged(int index)
{
if(!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(map)
m_plugin->h_parameterSet[map].lockedSelector = map->getCellSelector<VERTEX>(combo_lockedSelector->currentText());
m_plugin->h_parameterSet[map].handleSelector = map->getCellSelector<VERTEX>(combo_handleSelector->currentText());
}
}
void Surface_Deformation_DockTab::handleSelectorChanged(int index)
void Surface_Deformation_DockTab::freeSelectorChanged(int index)
{
if(!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(map)
m_plugin->h_parameterSet[map].handleSelector = map->getCellSelector<VERTEX>(combo_handleSelector->currentText());
m_plugin->h_parameterSet[map].freeSelector = map->getCellSelector<VERTEX>(combo_freeSelector->currentText());
}
}
......@@ -89,25 +89,25 @@ void Surface_Deformation_DockTab::addVertexAttribute(const QString& name)
void Surface_Deformation_DockTab::addVertexSelector(const QString& name)
{
b_updatingUI = true;
combo_lockedSelector->addItem(name);
combo_handleSelector->addItem(name);
combo_freeSelector->addItem(name);
b_updatingUI = false;
}
void Surface_Deformation_DockTab::removeVertexSelector(const QString& name)
{
b_updatingUI = true;
int curIndex = combo_lockedSelector->currentIndex();
int index = combo_lockedSelector->findText(name, Qt::MatchExactly);
if(curIndex == index)
combo_lockedSelector->setCurrentIndex(0);
combo_lockedSelector->removeItem(index);
curIndex = combo_handleSelector->currentIndex();
index = combo_handleSelector->findText(name, Qt::MatchExactly);
int curIndex = combo_handleSelector->currentIndex();
int index = combo_handleSelector->findText(name, Qt::MatchExactly);
if(curIndex == index)
combo_handleSelector->setCurrentIndex(0);
combo_handleSelector->removeItem(index);
curIndex = combo_freeSelector->currentIndex();
index = combo_freeSelector->findText(name, Qt::MatchExactly);
if(curIndex == index)
combo_freeSelector->setCurrentIndex(0);
combo_freeSelector->removeItem(index);
b_updatingUI = false;
}
......@@ -115,8 +115,8 @@ void Surface_Deformation_DockTab::mapParametersInitialized(bool b)
{
b_updatingUI = true;
combo_positionAttribute->setEnabled(!b);
combo_lockedSelector->setEnabled(!b);
combo_handleSelector->setEnabled(!b);
combo_freeSelector->setEnabled(!b);
if(b) button_start_stop->setText("Stop");
else button_start_stop->setText("Start");
b_updatingUI = false;
......@@ -128,10 +128,10 @@ void Surface_Deformation_DockTab::updateMapParameters()
combo_positionAttribute->clear();
combo_positionAttribute->addItem("- select attribute -");
combo_lockedSelector->clear();
combo_lockedSelector->addItem("- select selector -");
combo_handleSelector->clear();
combo_handleSelector->addItem("- select selector -");
combo_freeSelector->clear();
combo_freeSelector->addItem("- select selector -");
MapHandlerGen* map = m_schnapps->getSelectedMap();
......@@ -159,14 +159,14 @@ void Surface_Deformation_DockTab::updateMapParameters()
const CellSelectorSet& selectors = map->getCellSelectorSet(VERTEX);
for(CellSelectorSet::const_iterator it = selectors.constBegin(); it != selectors.constEnd(); ++it)
{
combo_lockedSelector->addItem(it.key());
if(p.lockedSelector && it.key() == p.lockedSelector->getName())
combo_lockedSelector->setCurrentIndex(i);
combo_handleSelector->addItem(it.key());
if(p.handleSelector && it.key() == p.handleSelector->getName())
combo_handleSelector->setCurrentIndex(i);
combo_freeSelector->addItem(it.key());
if(p.freeSelector && it.key() == p.freeSelector->getName())
combo_freeSelector->setCurrentIndex(i);
++i;
}
......
......@@ -34,6 +34,9 @@ bool Surface_DifferentialProperties_Plugin::enable()
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
mapAdded(map);
return true;
}
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<width>207</width>
<height>600</height>
</rect>
</property>
......@@ -131,6 +131,17 @@
<header>colorComboBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>combo_positionAttribute</tabstop>
<tabstop>check_drawDarts</tabstop>
<tabstop>combo_dartsColor</tabstop>
<tabstop>check_drawPhi1</tabstop>
<tabstop>combo_phi1Color</tabstop>
<tabstop>check_drawPhi2</tabstop>
<tabstop>combo_phi2Color</tabstop>
<tabstop>slider_edgesScaleFactor</tabstop>
<tabstop>slider_facesScaleFactor</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<width>207</width>
<height>600</height>
</rect>
</property>
......@@ -36,7 +36,7 @@
</item>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
......@@ -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<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();
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();
}
}
}
}
}
......@@ -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();
}
}
......
#ifndef _CELL_SELECTOR_H_
#define _CELL_SELECTOR_H_
#include <QObject>
#include <QString>
#include <QList>
#include "Topology/generic/dart.h"
#include "Topology/generic/genericmap.h"
#include "Topology/generic/cellmarker.h"
#include <QObject>
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<Dart>& d) = 0;
virtual void unselect(const std::vector<Dart>& d) = 0;
inline void select(const std::vector<Dart>& 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<Dart>& 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<CellSelectorGen*>& 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<Dart> m_cells;
bool m_selectionChanged;
bool m_isMutuallyExclusive;
QList<CellSelectorGen*> m_mutuallyExclusive;
};
template <unsigned int ORBIT>
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: