Commit cb23b33c authored by Pierre Kraemer's avatar Pierre Kraemer

update selection in surface deformation plugin

parent bba8d132
......@@ -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 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="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="10" column="0" colspan="2">
<widget class="QPushButton" name="button_start_stop">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Handle selector :</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>
</layout>
</widget>
<tabstops>
......
......@@ -30,8 +30,8 @@ struct MapParameters
VertexAttribute<PFP2::VEC3> positionAttribute;
CellSelector<VERTEX>* lockedSelector;
CellSelector<VERTEX>* handleSelector;
CellSelector<VERTEX>* freeSelector;
bool initialized;
......@@ -93,8 +93,8 @@ private slots:
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())
......@@ -268,19 +268,19 @@ 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;
}
}
......@@ -309,7 +309,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 +317,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 +332,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 +373,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 +503,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;
}
......
......@@ -43,10 +43,10 @@ template <typename PFP, typename ATTR_TYPE>
void setupVariables(
typename PFP::MAP& m,
const VertexAttribute<unsigned int>& index,
const CellMarker<VERTEX>& lm,
const CellMarker<VERTEX>& fm,
const VertexAttribute<ATTR_TYPE>& attr)
{
FunctorMeshToSolver_Scalar<PFP, ATTR_TYPE> fmts(index, lm, attr) ;
FunctorMeshToSolver_Scalar<PFP, ATTR_TYPE> fmts(index, fm, attr) ;
m.template foreach_orbit<VERTEX>(fmts) ;
}
......@@ -54,11 +54,11 @@ template <typename PFP, typename ATTR_TYPE>
void setupVariables(
typename PFP::MAP& m,
const VertexAttribute<unsigned int>& index,
const CellMarker<VERTEX>& lm,
const CellMarker<VERTEX>& fm,
const VertexAttribute<ATTR_TYPE>& attr,
unsigned int coord)
{
FunctorMeshToSolver_Vector<PFP, ATTR_TYPE> fmts(index, lm, attr, coord) ;
FunctorMeshToSolver_Vector<PFP, ATTR_TYPE> fmts(index, fm, attr, coord) ;
m.template foreach_orbit<VERTEX>(fmts) ;
}
......
......@@ -36,22 +36,22 @@ class FunctorMeshToSolver_Scalar : public FunctorType
{
protected:
const VertexAttribute<unsigned int>& indexTable ;
const CellMarker<VERTEX>& lockingMarker ;
const CellMarker<VERTEX>& freeMarker ;
const VertexAttribute<ATTR_TYPE>& attrTable ;
bool lockedVertices ;
public:
FunctorMeshToSolver_Scalar(
const VertexAttribute<unsigned int>& index,
const CellMarker<VERTEX>& lm,
const CellMarker<VERTEX>& fm,
const VertexAttribute<ATTR_TYPE>& attr
) : indexTable(index), lockingMarker(lm), attrTable(attr), lockedVertices(false)
) : indexTable(index), freeMarker(fm), attrTable(attr), lockedVertices(false)
{}
bool operator()(Dart d)
{
nlSetVariable(indexTable[d], attrTable[d]);
if(lockingMarker.isMarked(d))
if(!freeMarker.isMarked(d))
{
nlLockVariable(indexTable[d]);
lockedVertices = true ;
......@@ -67,7 +67,7 @@ class FunctorMeshToSolver_Vector : public FunctorType
{
protected:
const VertexAttribute<unsigned int>& indexTable ;
const CellMarker<VERTEX>& lockingMarker ;
const CellMarker<VERTEX>& freeMarker ;
const VertexAttribute<ATTR_TYPE>& attrTable ;
unsigned int coord ;
bool lockedVertices ;
......@@ -75,16 +75,16 @@ protected:
public:
FunctorMeshToSolver_Vector(
const VertexAttribute<unsigned int>& index,
const CellMarker<VERTEX>& lm,
const CellMarker<VERTEX>& fm,
const VertexAttribute<ATTR_TYPE>& attr,
unsigned int c
) : indexTable(index), lockingMarker(lm), attrTable(attr), coord(c), lockedVertices(false)
) : indexTable(index), freeMarker(fm), attrTable(attr), coord(c), lockedVertices(false)
{}
bool operator()(Dart d)
{
nlSetVariable(indexTable[d], (attrTable[d])[coord]);
if(lockingMarker.isMarked(d))
if(!freeMarker.isMarked(d))
{
nlLockVariable(indexTable[d]);
lockedVertices = true ;
......
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