Commit 13852a54 authored by Sylvain Thery's avatar Sylvain Thery

remove/duplicate maps in schnapps

parent b5f3f45d
...@@ -442,7 +442,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs) ...@@ -442,7 +442,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
typedef typename PFP::MAP MAP; typedef typename PFP::MAP MAP;
typedef typename EMBV::DATA_TYPE EMB; typedef typename EMBV::DATA_TYPE EMB;
VertexAutoAttribute<EMB, PFP::MAP> facesAverage(map); VertexAutoAttribute<EMB, typename PFP::MAP> facesAverage(map);
std::vector<Dart> l_vertices; std::vector<Dart> l_vertices;
std::vector<Dart> l_edges; std::vector<Dart> l_edges;
......
...@@ -6,25 +6,18 @@ ...@@ -6,25 +6,18 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>327</width> <width>282</width>
<height>230</height> <height>334</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Subdivide surface</string> <string>Subdivide surface</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5"> <item row="0" column="7" colspan="4">
<widget class="QListWidget" name="list_maps"/> <widget class="QListWidget" name="list_maps"/>
</item> </item>
<item row="1" column="0" colspan="3"> <item row="2" column="10">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="combo_positionAttribute"> <widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
...@@ -34,45 +27,66 @@ ...@@ -34,45 +27,66 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="10">
<widget class="QRadioButton" name="radio_Loop"> <widget class="QRadioButton" name="radio_trianguleFaces">
<property name="text"> <property name="text">
<string>Loop</string> <string>Triangule</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="3"> <item row="3" column="7" colspan="2">
<widget class="QRadioButton" name="radio_CC"> <widget class="QRadioButton" name="radio_Loop">
<property name="text"> <property name="text">
<string>Catmull-Clark</string> <string>Loop</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="4"> <item row="4" column="10">
<widget class="QRadioButton" name="radio_trianguleFaces"> <widget class="QRadioButton" name="radio_quadranguleFaces">
<property name="text"> <property name="text">
<string>Triangule faces</string> <string>Quadrangule</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="2" column="7">
<widget class="QPushButton" name="button_cancel"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Cancel</string> <string>Position attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2" colspan="2"> <item row="6" column="10">
<widget class="QPushButton" name="button_apply"> <widget class="QPushButton" name="button_apply">
<property name="text"> <property name="text">
<string>Apply</string> <string>Apply</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="4"> <item row="6" column="7">
<widget class="QPushButton" name="button_ok"> <widget class="QPushButton" name="button_ok">
<property name="text"> <property name="text">
<string>OK</string> <string>Close</string>
</property>
</widget>
</item>
<item row="5" column="7">
<widget class="QRadioButton" name="radio_DoSabin">
<property name="text">
<string>Do-Sabin</string>
</property>
</widget>
</item>
<item row="4" column="7">
<widget class="QRadioButton" name="radio_CC">
<property name="text">
<string>Catmull-Clark</string>
</property>
</widget>
</item>
<item row="4" column="8">
<widget class="QCheckBox" name="check_interp">
<property name="text">
<string>Interp</string>
</property> </property>
</widget> </widget>
</item> </item>
......
...@@ -36,16 +36,24 @@ private slots: ...@@ -36,16 +36,24 @@ private slots:
public slots: public slots:
void loopSubdivision( void loopSubdivision(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName = "position" const QString& positionAttributeName = "position");
);
void CCSubdivision( void CCSubdivision(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName = "position" const QString& positionAttributeName = "position",
); bool interp = false );
void DoSabinSubdivision(
const QString& mapName,
const QString& positionAttributeName = "position");
void trianguleFaces( void trianguleFaces(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName = "position" const QString& positionAttributeName = "position");
);
void quadranguleFaces(
const QString& mapName,
const QString& positionAttributeName = "position");
private: private:
Dialog_Surface_Subdivision* m_subdivisionDialog; Dialog_Surface_Subdivision* m_subdivisionDialog;
......
...@@ -26,6 +26,7 @@ bool Surface_Subdivision_Plugin::enable() ...@@ -26,6 +26,7 @@ bool Surface_Subdivision_Plugin::enable()
connect(m_subdivisionDialog, SIGNAL(accepted()), this, SLOT(subdivideFromDialog())); connect(m_subdivisionDialog, SIGNAL(accepted()), this, SLOT(subdivideFromDialog()));
connect(m_subdivisionDialog->button_apply, SIGNAL(clicked()), this, SLOT(subdivideFromDialog())); connect(m_subdivisionDialog->button_apply, SIGNAL(clicked()), this, SLOT(subdivideFromDialog()));
connect(m_subdivisionDialog->button_ok, SIGNAL(clicked()), this, SLOT(schnappsClosing()));
connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(schnappsClosing())); connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(schnappsClosing()));
return true; return true;
...@@ -56,10 +57,20 @@ void Surface_Subdivision_Plugin::subdivideFromDialog() ...@@ -56,10 +57,20 @@ void Surface_Subdivision_Plugin::subdivideFromDialog()
if(m_subdivisionDialog->radio_Loop->isChecked()) if(m_subdivisionDialog->radio_Loop->isChecked())
loopSubdivision(mapName, positionName); loopSubdivision(mapName, positionName);
else if(m_subdivisionDialog->radio_CC->isChecked()) else if (m_subdivisionDialog->radio_CC->isChecked())
CCSubdivision(mapName, positionName); {
if (m_subdivisionDialog->check_interp->isChecked())
CCSubdivision(mapName, positionName, true);
else
CCSubdivision(mapName, positionName, false);
}
else if (m_subdivisionDialog->radio_DoSabin->isChecked())
DoSabinSubdivision(mapName, positionName);
else if(m_subdivisionDialog->radio_trianguleFaces->isChecked()) else if(m_subdivisionDialog->radio_trianguleFaces->isChecked())
trianguleFaces(mapName, positionName); trianguleFaces(mapName, positionName);
else if (m_subdivisionDialog->radio_quadranguleFaces->isChecked())
quadranguleFaces(mapName, positionName);
} }
} }
...@@ -89,7 +100,7 @@ void Surface_Subdivision_Plugin::loopSubdivision( ...@@ -89,7 +100,7 @@ void Surface_Subdivision_Plugin::loopSubdivision(
void Surface_Subdivision_Plugin::CCSubdivision( void Surface_Subdivision_Plugin::CCSubdivision(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName) const QString& positionAttributeName, bool interp)
{ {
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName)); MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if(mh == NULL) if(mh == NULL)
...@@ -99,10 +110,38 @@ void Surface_Subdivision_Plugin::CCSubdivision( ...@@ -99,10 +110,38 @@ void Surface_Subdivision_Plugin::CCSubdivision(
if(!position.isValid()) if(!position.isValid())
return; return;
pythonRecording("CCSubdivision", "", mapName, positionAttributeName); pythonRecording("CCSubdivision", "", mapName, positionAttributeName,interp);
PFP2::MAP* map = mh->getMap();
if (interp)
Algo::Surface::Modelisation::CatmullClarkInterpolSubdivision<PFP2>(*map, position);
else
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP2>(*map, position);
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
foreach(View* view, mh->getLinkedViews())
view->updateGL();
}
void Surface_Subdivision_Plugin::DoSabinSubdivision(
const QString& mapName,
const QString& positionAttributeName)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if (mh == NULL)
return;
VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
if (!position.isValid())
return;
pythonRecording("DoSabinSubdivision", "", mapName, positionAttributeName);
PFP2::MAP* map = mh->getMap(); PFP2::MAP* map = mh->getMap();
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP2>(*map, position); Algo::Surface::Modelisation::DooSabin<PFP2>(*map, position);
mh->notifyAttributeModification(position); mh->notifyAttributeModification(position);
mh->notifyConnectivityModification(); mh->notifyConnectivityModification();
...@@ -111,6 +150,7 @@ void Surface_Subdivision_Plugin::CCSubdivision( ...@@ -111,6 +150,7 @@ void Surface_Subdivision_Plugin::CCSubdivision(
view->updateGL(); view->updateGL();
} }
void Surface_Subdivision_Plugin::trianguleFaces( void Surface_Subdivision_Plugin::trianguleFaces(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName) const QString& positionAttributeName)
...@@ -135,6 +175,32 @@ void Surface_Subdivision_Plugin::trianguleFaces( ...@@ -135,6 +175,32 @@ void Surface_Subdivision_Plugin::trianguleFaces(
view->updateGL(); view->updateGL();
} }
void Surface_Subdivision_Plugin::quadranguleFaces(
const QString& mapName,
const QString& positionAttributeName)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if (mh == NULL)
return;
VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
if (!position.isValid())
return;
pythonRecording("quadranguleFaces", "", mapName, positionAttributeName);
PFP2::MAP* map = mh->getMap();
Algo::Surface::Modelisation::quadranguleFaces<PFP2>(*map, position);
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
foreach(View* view, mh->getLinkedViews())
view->updateGL();
}
void Surface_Subdivision_Plugin::schnappsClosing() void Surface_Subdivision_Plugin::schnappsClosing()
{ {
m_subdivisionDialog->close(); m_subdivisionDialog->close();
......
...@@ -44,6 +44,16 @@ ...@@ -44,6 +44,16 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="check_drawBB">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
...@@ -63,6 +73,24 @@ ...@@ -63,6 +73,24 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="button_remove">
<property name="text">
<string>remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_duplicate">
<property name="text">
<string>duplicate</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QTabWidget" name="tabWidget_mapInfo"> <widget class="QTabWidget" name="tabWidget_mapInfo">
<property name="sizePolicy"> <property name="sizePolicy">
......
...@@ -40,6 +40,10 @@ private slots: ...@@ -40,6 +40,10 @@ private slots:
// slots called from UI actions // slots called from UI actions
void selectedMapChanged(); void selectedMapChanged();
void duplicateCurrentMap();
void removeCurrentMap();
void showBBChanged(bool b);
void bbVertexAttributeChanged(int index); void bbVertexAttributeChanged(int index);
void vertexAttributeCheckStateChanged(QListWidgetItem* item); void vertexAttributeCheckStateChanged(QListWidgetItem* item);
......
...@@ -82,6 +82,19 @@ private slots: ...@@ -82,6 +82,19 @@ private slots:
*********************************************************/ *********************************************************/
public slots: public slots:
void showBB(bool b)
{
m_showBB = b;
foreach(View* view, l_views)
view->updateGL();
}
bool isBBshown() const
{
return m_showBB;
}
void setBBVertexAttribute(const QString& name) void setBBVertexAttribute(const QString& name)
{ {
m_bbVertexAttribute = m_map->getAttributeVectorGen(VERTEX, name.toStdString()); m_bbVertexAttribute = m_map->getAttributeVectorGen(VERTEX, name.toStdString());
...@@ -118,6 +131,7 @@ public slots: ...@@ -118,6 +131,7 @@ public slots:
virtual bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0; virtual bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
protected: protected:
bool m_showBB;
virtual void updateBB() = 0; virtual void updateBB() = 0;
/********************************************************* /*********************************************************
......
...@@ -87,7 +87,7 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive) ...@@ -87,7 +87,7 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive)
template <typename PFP> template <typename PFP>
void MapHandler<PFP>::drawBB() void MapHandler<PFP>::drawBB()
{ {
if (m_bbDrawer) if (m_showBB && m_bbDrawer)
m_bbDrawer->callList(); m_bbDrawer->callList();
} }
......
...@@ -99,6 +99,9 @@ private slots: ...@@ -99,6 +99,9 @@ private slots:
public slots: public slots:
MapHandlerGen* addMap(const QString& name, unsigned int dim); MapHandlerGen* addMap(const QString& name, unsigned int dim);
void removeMap(const QString& name); void removeMap(const QString& name);
MapHandlerGen* duplicateMap(const QString& name, bool properties);
void setSelectedMap(const QString& mapName); void setSelectedMap(const QString& mapName);
MapHandlerGen* getMap(const QString& name) const; MapHandlerGen* getMap(const QString& name) const;
......
...@@ -21,6 +21,10 @@ ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) : ...@@ -21,6 +21,10 @@ ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) :
connect(list_maps, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged())); connect(list_maps, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(button_duplicate, SIGNAL(clicked()), this, SLOT(duplicateCurrentMap()));
connect(button_remove, SIGNAL(clicked()), this, SLOT(removeCurrentMap()));
connect(check_drawBB, SIGNAL(toggled(bool)), this, SLOT(showBBChanged(bool)));
connect(combo_bbVertexAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(bbVertexAttributeChanged(int))); connect(combo_bbVertexAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(bbVertexAttributeChanged(int)));
connect(list_vertexAttributes, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(vertexAttributeCheckStateChanged(QListWidgetItem*))); connect(list_vertexAttributes, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(vertexAttributeCheckStateChanged(QListWidgetItem*)));
...@@ -79,6 +83,7 @@ void ControlDock_MapTab::setSelectedMap(const QString& mapName) ...@@ -79,6 +83,7 @@ void ControlDock_MapTab::setSelectedMap(const QString& mapName)
items[0]->setSelected(false); items[0]->setSelected(false);
m_selectedMap = NULL; m_selectedMap = NULL;
} }
updateSelectedMapInfo();
return; return;
} }
...@@ -133,6 +138,57 @@ void ControlDock_MapTab::selectedMapChanged() ...@@ -133,6 +138,57 @@ void ControlDock_MapTab::selectedMapChanged()
} }
} }
void ControlDock_MapTab::showBBChanged(bool b)
{
if (!b_updatingUI)
{
if (m_selectedMap)
{
m_selectedMap->showBB(b);
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << m_selectedMap->getName() << ".showBB(\"" << b << "\");" << endl;
}
}
}
void ControlDock_MapTab::duplicateCurrentMap()
{
if (!b_updatingUI)
{
if (m_selectedMap)
{
m_schnapps->duplicateMap(m_selectedMap->getName(),true);
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << "schnapps.duplicateMap(" << m_selectedMap->getName() << ".getName(),1);" << endl;
}
}
}
void ControlDock_MapTab::removeCurrentMap()
{
if (!b_updatingUI)
{
if (m_selectedMap)
{
m_schnapps->removeMap(m_selectedMap->getName());
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << "schnapps.removeMap(" << m_selectedMap->getName() << ".getName());" << endl;
setSelectedMap("NONE");
}
}
}
void ControlDock_MapTab::bbVertexAttributeChanged(int index) void ControlDock_MapTab::bbVertexAttributeChanged(int index)
{ {
if (!b_updatingUI) if (!b_updatingUI)
...@@ -319,6 +375,8 @@ void ControlDock_MapTab::updateSelectedMapInfo() ...@@ -319,6 +375,8 @@ void ControlDock_MapTab::updateSelectedMapInfo()
for (unsigned int orbit = DART; orbit <= VOLUME; ++orbit) for (unsigned int orbit = DART; orbit <= VOLUME; ++orbit)
{ {
check_drawBB->setChecked(m_selectedMap->isBBshown());
unsigned int nbc = m->getNbCells(orbit); unsigned int nbc = m->getNbCells(orbit);
QListWidget* selectorList = NULL; QListWidget* selectorList = NULL;
......
...@@ -7,6 +7,7 @@ namespace SCHNApps ...@@ -7,6 +7,7 @@ namespace SCHNApps
{ {
MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map) : MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map) :
m_showBB(true),
m_name(name), m_name(name),
m_schnapps(s), m_schnapps(s),
m_map(map), m_map(map),
......
...@@ -543,6 +543,60 @@ void SCHNApps::disablePluginTabWidgets(PluginInteraction* plugin) ...@@ -543,6 +543,60 @@ void SCHNApps::disablePluginTabWidgets(PluginInteraction* plugin)
* MANAGE MAPS * MANAGE MAPS
*********************************************************/ *********************************************************/
MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties)
{
if (! m_maps.contains(name))
return NULL;
QString newName = name + "_copy";
if (m_maps.contains(newName))
return NULL;
MapHandlerGen* maph = m_maps[name];