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)
typedef typename PFP::MAP MAP;
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_edges;
......
......@@ -6,25 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>230</height>
<width>282</width>
<height>334</height>
</rect>
</property>
<property name="windowTitle">
<string>Subdivide surface</string>
</property>
<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"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<item row="2" column="10">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
......@@ -34,45 +27,66 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radio_Loop">
<item row="3" column="10">
<widget class="QRadioButton" name="radio_trianguleFaces">
<property name="text">
<string>Loop</string>
<string>Triangule</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QRadioButton" name="radio_CC">
<item row="3" column="7" colspan="2">
<widget class="QRadioButton" name="radio_Loop">
<property name="text">
<string>Catmull-Clark</string>
<string>Loop</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QRadioButton" name="radio_trianguleFaces">
<item row="4" column="10">
<widget class="QRadioButton" name="radio_quadranguleFaces">
<property name="text">
<string>Triangule faces</string>
<string>Quadrangule</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="button_cancel">
<item row="2" column="7">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cancel</string>
<string>Position attribute :</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<item row="6" column="10">
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="3" column="4">
<item row="6" column="7">
<widget class="QPushButton" name="button_ok">
<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>
</widget>
</item>
......
......@@ -36,16 +36,24 @@ private slots:
public slots:
void loopSubdivision(
const QString& mapName,
const QString& positionAttributeName = "position"
);
const QString& positionAttributeName = "position");
void CCSubdivision(
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(
const QString& mapName,
const QString& positionAttributeName = "position"
);
const QString& positionAttributeName = "position");
void quadranguleFaces(
const QString& mapName,
const QString& positionAttributeName = "position");
private:
Dialog_Surface_Subdivision* m_subdivisionDialog;
......
......@@ -26,6 +26,7 @@ bool Surface_Subdivision_Plugin::enable()
connect(m_subdivisionDialog, SIGNAL(accepted()), 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()));
return true;
......@@ -56,10 +57,20 @@ void Surface_Subdivision_Plugin::subdivideFromDialog()
if(m_subdivisionDialog->radio_Loop->isChecked())
loopSubdivision(mapName, positionName);
else if(m_subdivisionDialog->radio_CC->isChecked())
CCSubdivision(mapName, positionName);
else if (m_subdivisionDialog->radio_CC->isChecked())
{
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())
trianguleFaces(mapName, positionName);
else if (m_subdivisionDialog->radio_quadranguleFaces->isChecked())
quadranguleFaces(mapName, positionName);
}
}
......@@ -89,7 +100,7 @@ void Surface_Subdivision_Plugin::loopSubdivision(
void Surface_Subdivision_Plugin::CCSubdivision(
const QString& mapName,
const QString& positionAttributeName)
const QString& positionAttributeName, bool interp)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if(mh == NULL)
......@@ -99,10 +110,38 @@ void Surface_Subdivision_Plugin::CCSubdivision(
if(!position.isValid())
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();
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP2>(*map, position);
Algo::Surface::Modelisation::DooSabin<PFP2>(*map, position);
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
......@@ -111,6 +150,7 @@ void Surface_Subdivision_Plugin::CCSubdivision(
view->updateGL();
}
void Surface_Subdivision_Plugin::trianguleFaces(
const QString& mapName,
const QString& positionAttributeName)
......@@ -135,6 +175,32 @@ void Surface_Subdivision_Plugin::trianguleFaces(
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()
{
m_subdivisionDialog->close();
......
......@@ -44,6 +44,16 @@
</item>
<item>
<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>
<widget class="QLabel" name="label">
<property name="text">
......@@ -63,6 +73,24 @@
</item>
</layout>
</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>
<widget class="QTabWidget" name="tabWidget_mapInfo">
<property name="sizePolicy">
......
......@@ -40,6 +40,10 @@ private slots:
// slots called from UI actions
void selectedMapChanged();
void duplicateCurrentMap();
void removeCurrentMap();
void showBBChanged(bool b);
void bbVertexAttributeChanged(int index);
void vertexAttributeCheckStateChanged(QListWidgetItem* item);
......
......@@ -82,6 +82,19 @@ private 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)
{
m_bbVertexAttribute = m_map->getAttributeVectorGen(VERTEX, name.toStdString());
......@@ -118,6 +131,7 @@ public slots:
virtual bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
protected:
bool m_showBB;
virtual void updateBB() = 0;
/*********************************************************
......
......@@ -87,7 +87,7 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive)
template <typename PFP>
void MapHandler<PFP>::drawBB()
{
if (m_bbDrawer)
if (m_showBB && m_bbDrawer)
m_bbDrawer->callList();
}
......
......@@ -99,6 +99,9 @@ private slots:
public slots:
MapHandlerGen* addMap(const QString& name, unsigned int dim);
void removeMap(const QString& name);
MapHandlerGen* duplicateMap(const QString& name, bool properties);
void setSelectedMap(const QString& mapName);
MapHandlerGen* getMap(const QString& name) const;
......
......@@ -21,6 +21,10 @@ ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) :
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(list_vertexAttributes, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(vertexAttributeCheckStateChanged(QListWidgetItem*)));
......@@ -79,6 +83,7 @@ void ControlDock_MapTab::setSelectedMap(const QString& mapName)
items[0]->setSelected(false);
m_selectedMap = NULL;
}
updateSelectedMapInfo();
return;
}
......@@ -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)
{
if (!b_updatingUI)
......@@ -319,6 +375,8 @@ void ControlDock_MapTab::updateSelectedMapInfo()
for (unsigned int orbit = DART; orbit <= VOLUME; ++orbit)
{
check_drawBB->setChecked(m_selectedMap->isBBshown());
unsigned int nbc = m->getNbCells(orbit);
QListWidget* selectorList = NULL;
......
......@@ -7,6 +7,7 @@ namespace SCHNApps
{
MapHandlerGen::MapHandlerGen(const QString& name, SCHNApps* s, GenericMap* map) :
m_showBB(true),
m_name(name),
m_schnapps(s),
m_map(map),
......
......@@ -543,6 +543,60 @@ void SCHNApps::disablePluginTabWidgets(PluginInteraction* plugin)
* 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];
MapHandlerGen* new_mh;
unsigned int dim = maph->getGenericMap()->dimension();
switch (dim)
{
case 2: {
PFP2::MAP* map = new PFP2::MAP();
map->copyFrom(*(maph->getGenericMap()));
new_mh = new MapHandler<PFP2>(newName, this, map);
break;
}
case 3: {
PFP3::MAP* map = new PFP3::MAP();
map->copyFrom(*(maph->getGenericMap()));
new_mh = new MapHandler<PFP3>(newName, this, map);
break;
}
}
m_maps.insert(newName, new_mh);
DEBUG_EMIT("mapAdded");
emit(mapAdded(new_mh));
if (properties)
{
// BB
new_mh->setBBVertexAttribute(maph->getBBVertexAttributeName());
//VBOs
const VBOSet& vbos = maph->getVBOSet();
foreach(QString s, vbos.keys())
{
new_mh->createVBO(s);
}
}
return new_mh;
}
MapHandlerGen* SCHNApps::addMap(const QString& name, unsigned int dim)
{
if (m_maps.contains(name))
......
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