Commit 986a72a3 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: update some signals connections

parent 42e522b2
......@@ -21,9 +21,10 @@ public:
private:
Window* m_window;
MapHandlerGen* m_selectedMap;
public slots:
void selectedMapChanged();
void refreshUI();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
};
......
......@@ -21,9 +21,10 @@ public:
private:
Window* m_window;
MapHandlerGen* m_selectedMap;
public slots:
void selectedMapChanged();
void refreshUI();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
};
......
......@@ -10,7 +10,9 @@ namespace CGoGN
namespace SCHNApps
{
ComputeCurvatureDialog::ComputeCurvatureDialog(Window* w) : m_window(w)
ComputeCurvatureDialog::ComputeCurvatureDialog(Window* w) :
m_window(w),
m_selectedMap(NULL)
{
setupUi(this);
......@@ -23,15 +25,18 @@ ComputeCurvatureDialog::ComputeCurvatureDialog(Window* w) : m_window(w)
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(refreshUI()));
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
}
void ComputeCurvatureDialog::selectedMapChanged()
void ComputeCurvatureDialog::refreshUI()
{
if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
{
......@@ -94,7 +99,12 @@ void ComputeCurvatureDialog::selectedMapChanged()
++k;
}
}
m_selectedMap = mh;
connect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
}
else
m_selectedMap = NULL;
}
void ComputeCurvatureDialog::addMapToList(MapHandlerGen* m)
......@@ -104,13 +114,14 @@ void ComputeCurvatureDialog::addMapToList(MapHandlerGen* m)
void ComputeCurvatureDialog::removeMapFromList(MapHandlerGen* m)
{
for(int i = 0; i < mapList->count(); ++i)
QList<QListWidgetItem*> items = mapList->findItems(m->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
if(m_selectedMap == m)
{
if(mapList->item(i)->text() == m->getName())
{
delete mapList->item(i);
return;
}
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
m_selectedMap = NULL;
}
}
......
......@@ -10,7 +10,9 @@ namespace CGoGN
namespace SCHNApps
{
ComputeNormalDialog::ComputeNormalDialog(Window* w) : m_window(w)
ComputeNormalDialog::ComputeNormalDialog(Window* w) :
m_window(w),
m_selectedMap(NULL)
{
setupUi(this);
......@@ -19,15 +21,18 @@ ComputeNormalDialog::ComputeNormalDialog(Window* w) : m_window(w)
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(refreshUI()));
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
}
void ComputeNormalDialog::selectedMapChanged()
void ComputeNormalDialog::refreshUI()
{
if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
{
......@@ -59,7 +64,12 @@ void ComputeNormalDialog::selectedMapChanged()
++j;
}
}
m_selectedMap = mh;
connect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
}
else
m_selectedMap = NULL;
}
void ComputeNormalDialog::addMapToList(MapHandlerGen* m)
......@@ -69,13 +79,14 @@ void ComputeNormalDialog::addMapToList(MapHandlerGen* m)
void ComputeNormalDialog::removeMapFromList(MapHandlerGen* m)
{
for(int i = 0; i < mapList->count(); ++i)
QList<QListWidgetItem*> items = mapList->findItems(m->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
if(m_selectedMap == m)
{
if(mapList->item(i)->text() == m->getName())
{
delete mapList->item(i);
return;
}
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
m_selectedMap = NULL;
}
}
......
......@@ -45,20 +45,20 @@ void DifferentialPropertiesPlugin::computeNormal()
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
PFP2::MAP* map = mh->getMap();
std::string positionName = m_computeNormalDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName;
QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText();
QString normalName;
if(m_computeNormalDialog->normalAttributeName->text().isEmpty())
normalName = m_computeNormalDialog->combo_normalAttribute->currentText().toUtf8().constData();
normalName = m_computeNormalDialog->combo_normalAttribute->currentText();
else
normalName = m_computeNormalDialog->normalAttributeName->text().toUtf8().constData();
normalName = m_computeNormalDialog->normalAttributeName->text();
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(positionName);
VertexAttribute<PFP2::VEC3> normal = map->getAttribute<PFP2::VEC3, VERTEX>(normalName);
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionName);
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalName);
if(!normal.isValid())
normal = map->addAttribute<PFP2::VEC3, VERTEX>(normalName);
normal = mh->addAttribute<PFP2::VEC3, VERTEX>(normalName);
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);
if(m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked)
......@@ -77,64 +77,64 @@ void DifferentialPropertiesPlugin::computeCurvature()
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
PFP2::MAP* map = mh->getMap();
std::string positionName = m_computeCurvatureDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeCurvatureDialog->combo_normalAttribute->currentText().toUtf8().constData();
QString positionName = m_computeCurvatureDialog->combo_positionAttribute->currentText();
QString normalName = m_computeCurvatureDialog->combo_normalAttribute->currentText();
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(positionName);
VertexAttribute<PFP2::VEC3> normal = map->getAttribute<PFP2::VEC3, VERTEX>(normalName);
VertexAttribute<PFP2::VEC3> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionName);
VertexAttribute<PFP2::VEC3> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalName);
std::string KmaxName;
QString KmaxName;
if(m_computeCurvatureDialog->KmaxAttributeName->text().isEmpty())
KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText().toUtf8().constData();
KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText();
else
KmaxName = m_computeCurvatureDialog->KmaxAttributeName->text().toUtf8().constData();
VertexAttribute<PFP2::VEC3> Kmax = map->getAttribute<PFP2::VEC3, VERTEX>(KmaxName);
KmaxName = m_computeCurvatureDialog->KmaxAttributeName->text();
VertexAttribute<PFP2::VEC3> Kmax = mh->getAttribute<PFP2::VEC3, VERTEX>(KmaxName);
if(!Kmax.isValid())
Kmax = map->addAttribute<PFP2::VEC3, VERTEX>(KmaxName);
Kmax = mh->addAttribute<PFP2::VEC3, VERTEX>(KmaxName);
std::string kmaxName;
QString kmaxName;
if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty())
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText().toUtf8().constData();
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText();
else
kmaxName = m_computeCurvatureDialog->kmaxAttributeName->text().toUtf8().constData();
VertexAttribute<PFP2::REAL> kmax = map->getAttribute<PFP2::REAL, VERTEX>(kmaxName);
kmaxName = m_computeCurvatureDialog->kmaxAttributeName->text();
VertexAttribute<PFP2::REAL> kmax = mh->getAttribute<PFP2::REAL, VERTEX>(kmaxName);
if(!kmax.isValid())
kmax = map->addAttribute<PFP2::REAL, VERTEX>(kmaxName);
kmax = mh->addAttribute<PFP2::REAL, VERTEX>(kmaxName);
std::string KminName;
QString KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText().toUtf8().constData();
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText();
else
KminName = m_computeCurvatureDialog->KminAttributeName->text().toUtf8().constData();
VertexAttribute<PFP2::VEC3> Kmin = map->getAttribute<PFP2::VEC3, VERTEX>(KminName);
KminName = m_computeCurvatureDialog->KminAttributeName->text();
VertexAttribute<PFP2::VEC3> Kmin = mh->getAttribute<PFP2::VEC3, VERTEX>(KminName);
if(!Kmin.isValid())
Kmin = map->addAttribute<PFP2::VEC3, VERTEX>(KminName);
Kmin = mh->addAttribute<PFP2::VEC3, VERTEX>(KminName);
std::string kminName;
QString kminName;
if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty())
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText().toUtf8().constData();
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText();
else
kminName = m_computeCurvatureDialog->kminAttributeName->text().toUtf8().constData();
VertexAttribute<PFP2::REAL> kmin = map->getAttribute<PFP2::REAL, VERTEX>(kminName);
kminName = m_computeCurvatureDialog->kminAttributeName->text();
VertexAttribute<PFP2::REAL> kmin = mh->getAttribute<PFP2::REAL, VERTEX>(kminName);
if(!kmin.isValid())
kmin = map->addAttribute<PFP2::REAL, VERTEX>(kminName);
kmin = mh->addAttribute<PFP2::REAL, VERTEX>(kminName);
std::string KnormalName;
QString KnormalName;
if(m_computeCurvatureDialog->KnormalAttributeName->text().isEmpty())
KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText().toUtf8().constData();
KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText();
else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text().toUtf8().constData();
VertexAttribute<PFP2::VEC3> Knormal = map->getAttribute<PFP2::VEC3, VERTEX>(KnormalName);
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text();
VertexAttribute<PFP2::VEC3> Knormal = mh->getAttribute<PFP2::VEC3, VERTEX>(KnormalName);
if(!Knormal.isValid())
Knormal = map->addAttribute<PFP2::VEC3, VERTEX>(KnormalName);
Knormal = mh->addAttribute<PFP2::VEC3, VERTEX>(KnormalName);
EdgeAttribute<PFP2::REAL> edgeAngle = map->getAttribute<PFP2::REAL, EDGE>("edgeAngle");
EdgeAttribute<PFP2::REAL> edgeAngle = mh->getAttribute<PFP2::REAL, EDGE>("edgeAngle");
if(!edgeAngle.isValid())
edgeAngle = map->addAttribute<PFP2::REAL, EDGE>("edgeAngle");
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
edgeAngle = mh->addAttribute<PFP2::REAL, EDGE>("edgeAngle");
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, 0.01f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
if(m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked)
......
......@@ -45,6 +45,8 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
}
return mhg;
}
else
return NULL;
}
void ImportSurfacePlugin::importFromFileDialog()
......
......@@ -45,6 +45,8 @@ MapHandlerGen* ImportVolumePlugin::importFromFile(const QString& fileName)
}
return mhg;
}
else
return NULL;
}
void ImportVolumePlugin::importFromFileDialog()
......
......@@ -21,9 +21,10 @@ public:
private:
Window* m_window;
MapHandlerGen* m_selectedMap;
public slots:
void selectedMapChanged();
void refreshUI();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
};
......
......@@ -10,7 +10,9 @@ namespace CGoGN
namespace SCHNApps
{
SubdivideSurfaceDialog::SubdivideSurfaceDialog(Window* w) : m_window(w)
SubdivideSurfaceDialog::SubdivideSurfaceDialog(Window* w) :
m_window(w),
m_selectedMap(NULL)
{
setupUi(this);
......@@ -24,8 +26,11 @@ SubdivideSurfaceDialog::SubdivideSurfaceDialog(Window* w) : m_window(w)
mapList->addItem(map->getName());
}
void SubdivideSurfaceDialog::selectedMapChanged()
void SubdivideSurfaceDialog::refreshUI()
{
if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
{
......@@ -52,7 +57,12 @@ void SubdivideSurfaceDialog::selectedMapChanged()
++j;
}
}
m_selectedMap = mh;
connect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
}
else
m_selectedMap = NULL;
}
void SubdivideSurfaceDialog::addMapToList(MapHandlerGen* m)
......@@ -62,13 +72,14 @@ void SubdivideSurfaceDialog::addMapToList(MapHandlerGen* m)
void SubdivideSurfaceDialog::removeMapFromList(MapHandlerGen* m)
{
for(int i = 0; i < mapList->count(); ++i)
QList<QListWidgetItem*> items = mapList->findItems(m->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
if(m_selectedMap == m)
{
if(mapList->item(i)->text() == m->getName())
{
delete mapList->item(i);
return;
}
disconnect(m_selectedMap, SIGNAL(attributeAdded()), this, SLOT(refreshUI()));
m_selectedMap = NULL;
}
}
......
......@@ -8,6 +8,7 @@
#include "plugin.h"
#include "Topology/generic/genericmap.h"
#include "Topology/generic/attribmap.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/attributeHandler.h"
#include "Utils/vbo.h"
......@@ -48,6 +49,25 @@ public slots:
public:
void draw(Utils::GLSLShader* shader, int primitive) { m_render->draw(shader, primitive); }
/*********************************************************
* MANAGE ATTRIBUTES
*********************************************************/
template <typename T, unsigned int ORBIT>
AttributeHandler<T, ORBIT> getAttribute(const QString& nameAttr)
{
AttributeHandler<T,ORBIT> ah = static_cast<AttribMap*>(m_map)->getAttribute<T,ORBIT>(nameAttr.toUtf8().constData());
return ah;
}
template <typename T, unsigned int ORBIT>
AttributeHandler<T, ORBIT> addAttribute(const QString& nameAttr)
{
AttributeHandler<T,ORBIT> ah = static_cast<AttribMap*>(m_map)->addAttribute<T,ORBIT>(nameAttr.toUtf8().constData());
emit(attributeAdded());
return ah;
}
/*********************************************************
* MANAGE VBOs
*********************************************************/
......@@ -105,6 +125,7 @@ protected:
VBOHash h_vbo;
signals:
void attributeAdded();
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
};
......
......@@ -54,7 +54,7 @@ void CameraViewDialog::selectCurrentCamera()
void CameraViewDialog::selectedCameraChanged()
{
if(b_refreshingUI)
if(!b_refreshingUI)
{
QList<QListWidgetItem*> currentItems = cameraList->selectedItems();
if(currentItems.empty())
......@@ -77,7 +77,6 @@ void CameraViewDialog::selectCamera(View* view, Camera* camera)
{
b_refreshingUI = true;
items[0]->setSelected(true);
m_view->updateGL();
b_refreshingUI = false;
}
}
......@@ -92,7 +91,6 @@ void CameraViewDialog::deselectCamera(View* view, Camera* camera)
{
b_refreshingUI = true;
items[0]->setSelected(false);
m_view->updateGL();
b_refreshingUI = false;
}
}
......@@ -105,14 +103,9 @@ void CameraViewDialog::addCameraToList(Camera* c)
void CameraViewDialog::removeCameraFromList(Camera* c)
{
for(int i = 0; i < cameraList->count(); ++i)
{
if(cameraList->item(i)->text() == c->getName())
{
delete cameraList->item(i);
return;
}
}
QList<QListWidgetItem*> items = cameraList->findItems(c->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
}
} // namespace SCHNApps
......
......@@ -54,7 +54,6 @@ void MapsViewDialog::selectedMapsChanged()
else if(!mapList->item(i)->isSelected() && m_view->isLinkedToMap(map))
m_window->unlinkViewAndMap(m_view, map);
}
m_view->updateGL();
}
}
......@@ -67,7 +66,6 @@ void MapsViewDialog::selectMap(View* view, MapHandlerGen* plugin)
{
b_refreshingUI = true;
items[0]->setSelected(true);
m_view->updateGL();
b_refreshingUI = false;
}
}
......@@ -82,7 +80,6 @@ void MapsViewDialog::deselectMap(View* view, MapHandlerGen* plugin)
{
b_refreshingUI = true;
items[0]->setSelected(false);
m_view->updateGL();
b_refreshingUI = false;
}
}
......@@ -95,14 +92,9 @@ void MapsViewDialog::addMapToList(MapHandlerGen* m)
void MapsViewDialog::removeMapFromList(MapHandlerGen* m)
{
for(int i = 0; i < mapList->count(); ++i)
{
if(mapList->item(i)->text() == m->getName())
{
delete mapList->item(i);
return;
}
}
QList<QListWidgetItem*> items = mapList->findItems(m->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
}
} // namespace SCHNApps
......
......@@ -55,7 +55,6 @@ void PluginsViewDialog::selectedPluginsChanged()
else if(!pluginList->item(i)->isSelected() && m_view->isLinkedToPlugin(plugin))
m_window->unlinkViewAndPlugin(m_view, plugin);
}
m_view->updateGL();
}
}
......@@ -68,7 +67,6 @@ void PluginsViewDialog::selectPlugin(View* view, Plugin* plugin)
{
b_refreshingUI = true;
items[0]->setSelected(true);
m_view->updateGL();
b_refreshingUI = false;
}
}
......@@ -83,7 +81,6 @@ void PluginsViewDialog::deselectPlugin(View* view, Plugin* plugin)
{
b_refreshingUI = true;
items[0]->setSelected(false);
m_view->updateGL();
b_refreshingUI = false;
}
}
......@@ -99,14 +96,9 @@ void PluginsViewDialog::removePluginFromList(Plugin* p)
{
if(p->getProvidesRendering())
{
for(int i = 0; i < pluginList->count(); ++i)
{
if(pluginList->item(i)->text() == p->getName())
{
delete pluginList->item(i);
return;
}
}
QList<QListWidgetItem*> items = pluginList->findItems(p->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
}
}
......
......@@ -292,8 +292,8 @@ void View::updateViewBB()
}
}
}
setSceneBoundingBox(bbMin, bbMax);
showEntireScene();
camera()->setSceneBoundingBox(bbMin, bbMax);
camera()->showEntireScene();
}
/*********************************************************
......
......@@ -607,6 +607,8 @@ void Window::linkViewAndMap(View* v, MapHandlerGen* m)
m->linkView(v);
emit(viewAndMapLinked(v, m));
v->updateGL();
}
void Window::linkViewAndMap(const QString& viewName, const QString& mapName)
......@@ -623,6 +625,8 @@ void Window::unlinkViewAndMap(View* v, MapHandlerGen* m)
m->unlinkView(v);
emit(viewAndMapUnlinked(v, m));
v->updateGL();
}
void Window::unlinkViewAndMap(const QString& viewName, const QString& mapName)
......@@ -639,6 +643,8 @@ void Window::linkViewAndPlugin(View* v, Plugin* p)
p->linkView(v);
emit(viewAndPluginLinked(v, p));
v->updateGL();
}
void Window::linkViewAndPlugin(const QString& viewName, const QString& pluginName)
......@@ -655,6 +661,8 @@ void Window::unlinkViewAndPlugin(View* v, Plugin* p)
p->unlinkView(v);
emit(viewAndPluginUnlinked(v, p));
v->updateGL();
}
void Window::unlinkViewAndPlugin(const QString& viewName, const QString& pluginName)
......
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