Commit 687dea0d authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: renderTopoSurface debug & update

parent a547866f
...@@ -250,7 +250,6 @@ void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI ...@@ -250,7 +250,6 @@ void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI
if(!fromUI) if(!fromUI)
m_dockTab->refreshUI(params); m_dockTab->refreshUI(params);
view->updateGL();
} }
} }
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="0"> <item>
<widget class="QListWidget" name="mapList"/> <widget class="QListWidget" name="mapList"/>
</item> </item>
<item row="1" column="0"> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
...@@ -41,10 +41,40 @@ ...@@ -41,10 +41,40 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item>
<widget class="Line" name="line"/> <widget class="Line" name="line"/>
</item> </item>
<item row="3" column="0"> <item>
<widget class="QCheckBox" name="check_drawDarts">
<property name="text">
<string>draw darts</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_drawPhi1">
<property name="text">
<string>draw phi1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_drawPhi2">
<property name="text">
<string>draw phi2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
...@@ -82,7 +112,7 @@ ...@@ -82,7 +112,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
......
...@@ -19,10 +19,13 @@ struct PerMapParameterSet ...@@ -19,10 +19,13 @@ struct PerMapParameterSet
void updateRender(); void updateRender();
Algo::Render::GL2::TopoRender* m_renderTopo;
MapHandlerGen* mh; MapHandlerGen* mh;
Algo::Render::GL2::TopoRender* m_renderTopo;
VertexAttribute<PFP2::VEC3> positionAttribute; VertexAttribute<PFP2::VEC3> positionAttribute;
bool drawDarts;
bool drawPhi1;
bool drawPhi2;
float edgesScaleFactor; float edgesScaleFactor;
float facesScaleFactor; float facesScaleFactor;
}; };
...@@ -63,7 +66,6 @@ public: ...@@ -63,7 +66,6 @@ public:
virtual void mouseMove(View* view, QMouseEvent* event) {} virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {} virtual void wheelEvent(View* view, QWheelEvent* event) {}
protected: protected:
RenderTopoSurfaceDockTab* m_dockTab; RenderTopoSurfaceDockTab* m_dockTab;
QHash<View*, ParameterSet*> h_viewParams; QHash<View*, ParameterSet*> h_viewParams;
...@@ -77,9 +79,10 @@ public slots: ...@@ -77,9 +79,10 @@ public slots:
void mapUnlinked(MapHandlerGen* m); void mapUnlinked(MapHandlerGen* m);
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false); void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP2::VEC3> attribute, bool fromUI = false); void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP2::VEC3> attribute, bool fromUI = false);
void changeDrawDarts(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeDrawPhi1(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeDrawPhi2(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false); void changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false); void changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
......
#ifndef _RENDER_TOPO_DOCK_TAB_H_ #ifndef _RENDER_TOPO_SURFACE_DOCK_TAB_H_
#define _RENDER_TOPO_DOCK_TAB_H_ #define _RENDER_TOPO_SURFACE_DOCK_TAB_H_
#include "ui_renderTopoSurface.h" #include "ui_renderTopoSurface.h"
...@@ -31,8 +31,12 @@ public slots: ...@@ -31,8 +31,12 @@ public slots:
void selectedMapChanged(); void selectedMapChanged();
void positionAttributeChanged(int index); void positionAttributeChanged(int index);
void drawDartsChanged(bool b);
void drawPhi1Changed(bool b);
void drawPhi2Changed(bool b);
void edgesScaleFactorChanged(int i); void edgesScaleFactorChanged(int i);
void facesScaleFactorChanged(int i); void facesScaleFactorChanged(int i);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
...@@ -10,13 +10,14 @@ namespace SCHNApps ...@@ -10,13 +10,14 @@ namespace SCHNApps
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) : PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
mh(m), mh(m),
drawDarts(true),
drawPhi1(true),
drawPhi2(true),
edgesScaleFactor(1.0f), edgesScaleFactor(1.0f),
facesScaleFactor(1.0f) facesScaleFactor(1.0f)
{ {
m_renderTopo = new Algo::Render::GL2::TopoRender(); m_renderTopo = new Algo::Render::GL2::TopoRender();
std::cout << "plop" << std::endl;
QString positionName; QString positionName;
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3())); QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
...@@ -35,7 +36,6 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) : ...@@ -35,7 +36,6 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
updateRender(); updateRender();
} }
PerMapParameterSet::~PerMapParameterSet() PerMapParameterSet::~PerMapParameterSet()
{ {
delete m_renderTopo; delete m_renderTopo;
...@@ -43,17 +43,11 @@ PerMapParameterSet::~PerMapParameterSet() ...@@ -43,17 +43,11 @@ PerMapParameterSet::~PerMapParameterSet()
void PerMapParameterSet::updateRender() void PerMapParameterSet::updateRender()
{ {
MapHandler<PFP2>* mh2 = static_cast<MapHandler<PFP2>*>(mh); PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(mh)->getMap();
if(mh2 == NULL) m_renderTopo->updateData<PFP2>(*m, positionAttribute, edgesScaleFactor, facesScaleFactor);
return;
PFP2::MAP* m = mh2->getMap();
m_renderTopo->updateData<PFP2>(*m,positionAttribute,edgesScaleFactor,facesScaleFactor);
std::cout << "update render " << std::endl;
} }
bool RenderTopoSurfacePlugin::enable() bool RenderTopoSurfacePlugin::enable()
{ {
m_dockTab = new RenderTopoSurfaceDockTab(m_window, this); m_dockTab = new RenderTopoSurfaceDockTab(m_window, this);
...@@ -80,12 +74,12 @@ void RenderTopoSurfacePlugin::redraw(View* view) ...@@ -80,12 +74,12 @@ void RenderTopoSurfacePlugin::redraw(View* view)
{ {
PerMapParameterSet* p = params->perMap[m->getName()]; PerMapParameterSet* p = params->perMap[m->getName()];
if(p != NULL) if(p->drawDarts)
p->m_renderTopo->drawTopo(); p->m_renderTopo->drawDarts();
if(p->drawPhi1)
// if (p->m_selectedDart != NIL) p->m_renderTopo->drawRelation1();
// p->m_renderTopo->overdrawDart(m_selectedDart, 4.0f, 1.0f, 0.0f, 0.0f) ; if(p->drawPhi2)
p->m_renderTopo->drawRelation2();
} }
} }
...@@ -103,7 +97,7 @@ void RenderTopoSurfacePlugin::viewLinked(View* view, Plugin* plugin) ...@@ -103,7 +97,7 @@ void RenderTopoSurfacePlugin::viewLinked(View* view, Plugin* plugin)
registerShader(p->m_renderTopo->shader2()); registerShader(p->m_renderTopo->shader2());
params->perMap.insert(mh->getName(), p); params->perMap.insert(mh->getName(), p);
} }
if (!maps.empty()) if(!maps.empty())
changeSelectedMap(view, maps[0]); changeSelectedMap(view, maps[0]);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
...@@ -118,6 +112,15 @@ void RenderTopoSurfacePlugin::viewUnlinked(View* view, Plugin* plugin) ...@@ -118,6 +112,15 @@ void RenderTopoSurfacePlugin::viewUnlinked(View* view, Plugin* plugin)
{ {
if(plugin == this) if(plugin == this)
{ {
ParameterSet* params = h_viewParams[view];
QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
while (i != params->perMap.constEnd())
{
unregisterShader(i.value()->m_renderTopo->shader1());
unregisterShader(i.value()->m_renderTopo->shader2());
delete i.value();
++i;
}
h_viewParams.remove(view); h_viewParams.remove(view);
disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
...@@ -128,11 +131,7 @@ void RenderTopoSurfacePlugin::viewUnlinked(View* view, Plugin* plugin) ...@@ -128,11 +131,7 @@ void RenderTopoSurfacePlugin::viewUnlinked(View* view, Plugin* plugin)
void RenderTopoSurfacePlugin::currentViewChanged(View* view) void RenderTopoSurfacePlugin::currentViewChanged(View* view)
{ {
if(isLinkedToView(view)) if(isLinkedToView(view))
{
// ParameterSet* params = h_viewParams[view];
// changeSelectedMap(view, params->selectedMap);
m_dockTab->refreshUI(h_viewParams[view]); m_dockTab->refreshUI(h_viewParams[view]);
}
} }
void RenderTopoSurfacePlugin::mapLinked(MapHandlerGen* m) void RenderTopoSurfacePlugin::mapLinked(MapHandlerGen* m)
...@@ -144,14 +143,10 @@ void RenderTopoSurfacePlugin::mapLinked(MapHandlerGen* m) ...@@ -144,14 +143,10 @@ void RenderTopoSurfacePlugin::mapLinked(MapHandlerGen* m)
connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified())); connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
PerMapParameterSet* p = new PerMapParameterSet(m); PerMapParameterSet* p = new PerMapParameterSet(m);
registerShader(p->m_renderTopo->shader1()); registerShader(p->m_renderTopo->shader1());
registerShader(p->m_renderTopo->shader2()); registerShader(p->m_renderTopo->shader2());
params->perMap.insert(m->getName(), p); params->perMap.insert(m->getName(), p);
if(params->selectedMap == NULL || params->perMap.count() == 1) if(params->selectedMap == NULL || params->perMap.count() == 1)
changeSelectedMap(view, m); changeSelectedMap(view, m);
else else
...@@ -167,6 +162,7 @@ void RenderTopoSurfacePlugin::mapUnlinked(MapHandlerGen* m) ...@@ -167,6 +162,7 @@ void RenderTopoSurfacePlugin::mapUnlinked(MapHandlerGen* m)
disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified())); disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
delete params->perMap[m->getName()];
params->perMap.remove(m->getName()); params->perMap.remove(m->getName());
if(params->selectedMap == m) if(params->selectedMap == m)
...@@ -189,9 +185,13 @@ void RenderTopoSurfacePlugin::changeSelectedMap(View* view, MapHandlerGen* map, ...@@ -189,9 +185,13 @@ void RenderTopoSurfacePlugin::changeSelectedMap(View* view, MapHandlerGen* map,
if(view->isCurrentView()) if(view->isCurrentView())
{ {
if(prev)
disconnect(prev, SIGNAL(attributeAdded(unsigned int, const QString&)), m_dockTab, SLOT(addAttributeToList(unsigned int, const QString&)));
if(map)
connect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), m_dockTab, SLOT(addAttributeToList(unsigned int, const QString&)));
if(!fromUI) if(!fromUI)
m_dockTab->refreshUI(params); m_dockTab->refreshUI(params);
view->updateGL();
} }
} }
...@@ -210,6 +210,44 @@ void RenderTopoSurfacePlugin::changePositionAttribute(View* view, MapHandlerGen* ...@@ -210,6 +210,44 @@ void RenderTopoSurfacePlugin::changePositionAttribute(View* view, MapHandlerGen*
} }
} }
void RenderTopoSurfacePlugin::changeDrawDarts(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->drawDarts = b;
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderTopoSurfacePlugin::changeDrawPhi1(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->drawPhi1 = b;
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderTopoSurfacePlugin::changeDrawPhi2(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->drawPhi2 = b;
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderTopoSurfacePlugin::changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI) void RenderTopoSurfacePlugin::changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
{ {
...@@ -243,7 +281,20 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen* ...@@ -243,7 +281,20 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen*
void RenderTopoSurfacePlugin::attributeModified(unsigned int orbit, QString nameAttr) void RenderTopoSurfacePlugin::attributeModified(unsigned int orbit, QString nameAttr)
{ {
if(orbit == VERTEX)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
foreach(View* view, l_views)
{
ParameterSet* params = h_viewParams[view];
if(params->perMap.contains(map->getName()))
{
PerMapParameterSet* perMap = params->perMap[map->getName()];
if(nameAttr == QString::fromStdString(perMap->positionAttribute.name()))
perMap->updateRender();
}
}
}
} }
void RenderTopoSurfacePlugin::connectivityModified() void RenderTopoSurfacePlugin::connectivityModified()
......
...@@ -11,16 +11,17 @@ namespace SCHNApps ...@@ -11,16 +11,17 @@ namespace SCHNApps
{ {
RenderTopoSurfaceDockTab::RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p) : RenderTopoSurfaceDockTab::RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p) :
m_window(w), m_window(w),
m_plugin(p), m_plugin(p),
b_refreshingUI(false) b_refreshingUI(false)
{ {
setupUi(this); setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged())); connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int))); connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(check_drawDarts, SIGNAL(toggled(bool)), this, SLOT(drawDartsChanged(bool)));
connect(check_drawPhi1, SIGNAL(toggled(bool)), this, SLOT(drawPhi1Changed(bool)));
connect(check_drawPhi2, SIGNAL(toggled(bool)), this, SLOT(drawPhi2Changed(bool)));
connect(slider_edgesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(edgesScaleFactorChanged(int))); connect(slider_edgesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(edgesScaleFactorChanged(int)));
connect(slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int))); connect(slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int)));
} }
...@@ -63,6 +64,9 @@ void RenderTopoSurfaceDockTab::refreshUI(ParameterSet* params) ...@@ -63,6 +64,9 @@ void RenderTopoSurfaceDockTab::refreshUI(ParameterSet* params)
} }
} }
check_drawDarts->setChecked(p->drawDarts);
check_drawPhi1->setChecked(p->drawPhi1);
check_drawPhi2->setChecked(p->drawPhi2);
slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 50.0); slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 50.0);
slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0); slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0);
} }
...@@ -92,6 +96,36 @@ void RenderTopoSurfaceDockTab::positionAttributeChanged(int index) ...@@ -92,6 +96,36 @@ void RenderTopoSurfaceDockTab::positionAttributeChanged(int index)
} }
} }
void RenderTopoSurfaceDockTab::drawDartsChanged(bool b)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changeDrawDarts(view, map, b, true);
}
}
void RenderTopoSurfaceDockTab::drawPhi1Changed(bool b)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changeDrawPhi1(view, map, b, true);
}
}
void RenderTopoSurfaceDockTab::drawPhi2Changed(bool b)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changeDrawPhi2(view, map, b, true);
}
}
void RenderTopoSurfaceDockTab::facesScaleFactorChanged(int i) void RenderTopoSurfaceDockTab::facesScaleFactorChanged(int i)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
...@@ -112,6 +146,18 @@ void RenderTopoSurfaceDockTab::edgesScaleFactorChanged(int i) ...@@ -112,6 +146,18 @@ void RenderTopoSurfaceDockTab::edgesScaleFactorChanged(int i)
} }
} }
void RenderTopoSurfaceDockTab::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
const QString& typeAttr = m_currentParams->selectedMap->getAttributeTypeName(orbit, nameAttr);
if(typeAttr == vec3TypeName)
{
combo_positionAttribute->addItem(nameAttr);
}
}
} // namespace SCHNApps } // namespace SCHNApps
} // namespace CGoGN } // namespace CGoGN
...@@ -86,7 +86,7 @@ void RenderVectorPlugin::viewLinked(View* view, Plugin* plugin) ...@@ -86,7 +86,7 @@ void RenderVectorPlugin::viewLinked(View* view, Plugin* plugin)
PerMapParameterSet p(map); PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p); params->perMap.insert(map->getName(), p);
} }
if (!maps.empty()) if(!maps.empty())
changeSelectedMap(view, maps[0]); changeSelectedMap(view, maps[0]);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
...@@ -182,7 +182,6 @@ void RenderVectorPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool ...@@ -182,7 +182,6 @@ void RenderVectorPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool
if(!fromUI) if(!fromUI)
m_dockTab->refreshUI(params); m_dockTab->refreshUI(params);
view->updateGL();
} }
} }
......
...@@ -70,6 +70,13 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) : ...@@ -70,6 +70,13 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
initParameters(); initParameters();
} }
PerMapParameterSet::~PerMapParameterSet()
{
delete lockingMarker;
delete handleMarker;
nlDeleteContext(nlContext);
}
void PerMapParameterSet::initParameters() void PerMapParameterSet::initParameters()
{ {
if(positionAttribute.isValid()) if(positionAttribute.isValid())
...@@ -97,13 +104,6 @@ void PerMapParameterSet::initParameters() ...@@ -97,13 +104,6 @@ void PerMapParameterSet::initParameters()
} }
} }
PerMapParameterSet::~PerMapParameterSet()