Commit 71054826 authored by Pierre Kraemer's avatar Pierre Kraemer

create empty map in modelisation plugin

parent 430c8802
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>259</width>
<width>345</width>
<height>600</height>
</rect>
</property>
......@@ -14,21 +14,52 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="3">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vertex selector :</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="3">
<widget class="QComboBox" name="combo_vertexSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Edge selector :</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="3">
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="combo_edgeSelector">
<item>
<property name="text">
......@@ -37,14 +68,14 @@
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Face selector :</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="3">
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="combo_faceSelector">
<item>
<property name="text">
......@@ -53,37 +84,35 @@
</item>
</widget>
</item>
<item row="4" column="0" colspan="5">
<item row="4" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="combo_vertexSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
<item row="5" column="0" colspan="4">
<widget class="QPushButton" name="button_createEmptyMap">
<property name="text">
<string>Create empty map</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="5">
<widget class="QPushButton" name="button_createCube">
<item row="6" column="0" colspan="4">
<widget class="QPushButton" name="button_addCube">
<property name="text">
<string>Create cube</string>
<string>Add cube</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="5">
<item row="7" column="0" colspan="4">
<widget class="QPushButton" name="button_flipEdge">
<property name="text">
<string>Flip edge</string>
</property>
</widget>
</item>
<item row="7" column="2">
<item row="8" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -96,28 +125,6 @@
</property>
</spacer>
</item>
<item row="0" column="2" colspan="3">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -75,7 +75,8 @@ public slots:
void changeFaceSelector(const QString& map, const QString& name);
protected:
void createCube(MapHandlerGen* mhg);
void createEmptyMap();
void addCube(MapHandlerGen* mhg);
void flipEdge(MapHandlerGen* mhg);
protected:
......
......@@ -33,11 +33,18 @@ private slots:
void edgeSelectorChanged(int index);
void faceSelectorChanged(int index);
void createCubeButtonClicked();
void createEmptyMapButtonClicked();
void addCubeButtonClicked();
void flipEdgeButtonClicked();
private:
void addVertexAttribute(const QString& name);
void addVertexSelector(const QString& name);
void removeVertexSelector(const QString& name);
void addEdgeSelector(const QString& name);
void removeEdgeSelector(const QString& name);
void addFaceSelector(const QString& name);
void removeFaceSelector(const QString& name);
void updateMapParameters();
};
......
......@@ -49,6 +49,8 @@ void Surface_Modelisation_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHan
void Surface_Modelisation_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&)));
}
void Surface_Modelisation_Plugin::mapRemoved(MapHandlerGen* map)
......@@ -67,6 +69,48 @@ void Surface_Modelisation_Plugin::attributeAdded(unsigned int orbit, const QStri
m_dockTab->addVertexAttribute(name);
}
void Surface_Modelisation_Plugin::cellSelectorAdded(unsigned int orbit, const QString& name)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
if(map->isSelectedMap())
{
switch(orbit)
{
case VERTEX :
m_dockTab->addVertexSelector(name);
break;
case EDGE :
m_dockTab->addEdgeSelector(name);
break;
case FACE :
m_dockTab->addFaceSelector(name);
break;
}
}
}
void Surface_Modelisation_Plugin::cellSelectorRemoved(unsigned int orbit, const QString& name)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
if(map->isSelectedMap())
{
switch(orbit)
{
case VERTEX :
m_dockTab->removeVertexSelector(name);
break;
case EDGE :
m_dockTab->removeEdgeSelector(name);
break;
case FACE :
m_dockTab->removeFaceSelector(name);
break;
}
}
}
......@@ -122,7 +166,22 @@ void Surface_Modelisation_Plugin::changeFaceSelector(const QString& map, const Q
void Surface_Modelisation_Plugin::createCube(MapHandlerGen *mhg)
void Surface_Modelisation_Plugin::createEmptyMap()
{
MapHandlerGen* mhg = m_schnapps->addMap("map", 2);
if(mhg)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
// add vertex position attribute
VertexAttribute<PFP2::VEC3> position = mh->addAttribute<PFP2::VEC3, VERTEX>("position");
// update corresponding VBO & emit attribute update signal
mh->notifyAttributeModification(position);
}
}
void Surface_Modelisation_Plugin::addCube(MapHandlerGen *mhg)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
PFP2::MAP* map = mh->getMap();
......@@ -133,6 +192,9 @@ void Surface_Modelisation_Plugin::createCube(MapHandlerGen *mhg)
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
// compute map bounding box
mh->updateBB(position);
}
void Surface_Modelisation_Plugin::flipEdge(MapHandlerGen *mhg)
......
......@@ -17,7 +17,11 @@ Surface_Modelisation_DockTab::Surface_Modelisation_DockTab(SCHNApps* s, Surface_
setupUi(this);
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(button_createCube, SIGNAL(clicked()), this, SLOT(createCubeButtonClicked()));
connect(combo_vertexSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(vertexSelectorChanged(int)));
connect(combo_edgeSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(edgeSelectorChanged(int)));
connect(combo_faceSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(faceSelectorChanged(int)));
connect(button_createEmptyMap, SIGNAL(clicked()), this, SLOT(createEmptyMapButtonClicked()));
connect(button_addCube, SIGNAL(clicked()), this, SLOT(addCubeButtonClicked()));
connect(button_flipEdge, SIGNAL(clicked()), this, SLOT(flipEdgeButtonClicked()));
}
......@@ -65,13 +69,21 @@ void Surface_Modelisation_DockTab::faceSelectorChanged(int index)
}
}
void Surface_Modelisation_DockTab::createCubeButtonClicked()
void Surface_Modelisation_DockTab::createEmptyMapButtonClicked()
{
if(!b_updatingUI)
{
m_plugin->createEmptyMap();
}
}
void Surface_Modelisation_DockTab::addCubeButtonClicked()
{
if(!b_updatingUI)
{
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(map)
m_plugin->createCube(map);
m_plugin->addCube(map);
}
}
......@@ -99,12 +111,72 @@ void Surface_Modelisation_DockTab::addVertexAttribute(const QString& nameAttr)
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::addVertexSelector(const QString& name)
{
b_updatingUI = true;
combo_vertexSelector->addItem(name);
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::removeVertexSelector(const QString& name)
{
b_updatingUI = true;
int curIndex = combo_vertexSelector->currentIndex();
int index = combo_vertexSelector->findText(name, Qt::MatchExactly);
if(curIndex == index)
combo_vertexSelector->setCurrentIndex(0);
combo_vertexSelector->removeItem(index);
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::addEdgeSelector(const QString& name)
{
b_updatingUI = true;
combo_edgeSelector->addItem(name);
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::removeEdgeSelector(const QString& name)
{
b_updatingUI = true;
int curIndex = combo_edgeSelector->currentIndex();
int index = combo_edgeSelector->findText(name, Qt::MatchExactly);
if(curIndex == index)
combo_edgeSelector->setCurrentIndex(0);
combo_edgeSelector->removeItem(index);
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::addFaceSelector(const QString& name)
{
b_updatingUI = true;
combo_faceSelector->addItem(name);
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::removeFaceSelector(const QString& name)
{
b_updatingUI = true;
int curIndex = combo_faceSelector->currentIndex();
int index = combo_faceSelector->findText(name, Qt::MatchExactly);
if(curIndex == index)
combo_faceSelector->setCurrentIndex(0);
combo_faceSelector->removeItem(index);
b_updatingUI = false;
}
void Surface_Modelisation_DockTab::updateMapParameters()
{
b_updatingUI = true;
combo_positionAttribute->clear();
combo_positionAttribute->addItem("- select attribute -");
combo_vertexSelector->clear();
combo_vertexSelector->addItem("- select selector -");
combo_edgeSelector->clear();
combo_edgeSelector->addItem("- select selector -");
combo_faceSelector->clear();
combo_faceSelector->addItem("- select selector -");
MapHandlerGen* map = m_schnapps->getSelectedMap();
......@@ -127,6 +199,34 @@ void Surface_Modelisation_DockTab::updateMapParameters()
++i;
}
}
i = 1;
const CellSelectorSet& vertexSelectors = map->getCellSelectorSet(VERTEX);
for(CellSelectorSet::const_iterator it = vertexSelectors.constBegin(); it != vertexSelectors.constEnd(); ++it)
{
combo_vertexSelector->addItem(it.key());
if(p.vertexSelector && it.key() == p.vertexSelector->getName())
combo_vertexSelector->setCurrentIndex(i);
++i;
}
i = 1;
const CellSelectorSet& edgeSelectors = map->getCellSelectorSet(EDGE);
for(CellSelectorSet::const_iterator it = edgeSelectors.constBegin(); it != edgeSelectors.constEnd(); ++it)
{
combo_edgeSelector->addItem(it.key());
if(p.edgeSelector && it.key() == p.edgeSelector->getName())
combo_edgeSelector->setCurrentIndex(i);
++i;
}
i = 1;
const CellSelectorSet& faceSelectors = map->getCellSelectorSet(FACE);
for(CellSelectorSet::const_iterator it = faceSelectors.constBegin(); it != faceSelectors.constEnd(); ++it)
{
combo_faceSelector->addItem(it.key());
if(p.faceSelector && it.key() == p.faceSelector->getName())
combo_faceSelector->setCurrentIndex(i);
++i;
}
}
b_updatingUI = false;
......
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