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
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
......
......@@ -13,11 +13,11 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="mapList"/>
</item>
<item row="1" column="0">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
......@@ -41,10 +41,40 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item>
<widget class="Line" name="line"/>
</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">
<item row="0" column="0">
<widget class="QLabel" name="label">
......@@ -82,7 +112,7 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
......@@ -19,10 +19,13 @@ struct PerMapParameterSet
void updateRender();
Algo::Render::GL2::TopoRender* m_renderTopo;
MapHandlerGen* mh;
Algo::Render::GL2::TopoRender* m_renderTopo;
VertexAttribute<PFP2::VEC3> positionAttribute;
bool drawDarts;
bool drawPhi1;
bool drawPhi2;
float edgesScaleFactor;
float facesScaleFactor;
};
......@@ -63,7 +66,6 @@ public:
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
protected:
RenderTopoSurfaceDockTab* m_dockTab;
QHash<View*, ParameterSet*> h_viewParams;
......@@ -77,9 +79,10 @@ public slots:
void mapUnlinked(MapHandlerGen* m);
void changeSelectedMap(View* view, MapHandlerGen* map, 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 changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
......
#ifndef _RENDER_TOPO_DOCK_TAB_H_
#define _RENDER_TOPO_DOCK_TAB_H_
#ifndef _RENDER_TOPO_SURFACE_DOCK_TAB_H_
#define _RENDER_TOPO_SURFACE_DOCK_TAB_H_
#include "ui_renderTopoSurface.h"
......@@ -31,8 +31,12 @@ public slots:
void selectedMapChanged();
void positionAttributeChanged(int index);
void drawDartsChanged(bool b);
void drawPhi1Changed(bool b);
void drawPhi2Changed(bool b);
void edgesScaleFactorChanged(int i);
void facesScaleFactorChanged(int i);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
......
......@@ -10,13 +10,14 @@ namespace SCHNApps
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
mh(m),
drawDarts(true),
drawPhi1(true),
drawPhi2(true),
edgesScaleFactor(1.0f),
facesScaleFactor(1.0f)
{
m_renderTopo = new Algo::Render::GL2::TopoRender();
std::cout << "plop" << std::endl;
QString positionName;
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
......@@ -35,7 +36,6 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
updateRender();
}
PerMapParameterSet::~PerMapParameterSet()
{
delete m_renderTopo;
......@@ -43,17 +43,11 @@ PerMapParameterSet::~PerMapParameterSet()
void PerMapParameterSet::updateRender()
{
MapHandler<PFP2>* mh2 = static_cast<MapHandler<PFP2>*>(mh);
if(mh2 == NULL)
return;
PFP2::MAP* m = mh2->getMap();
m_renderTopo->updateData<PFP2>(*m,positionAttribute,edgesScaleFactor,facesScaleFactor);
std::cout << "update render " << std::endl;
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(mh)->getMap();
m_renderTopo->updateData<PFP2>(*m, positionAttribute, edgesScaleFactor, facesScaleFactor);
}
bool RenderTopoSurfacePlugin::enable()
{
m_dockTab = new RenderTopoSurfaceDockTab(m_window, this);
......@@ -80,12 +74,12 @@ void RenderTopoSurfacePlugin::redraw(View* view)
{
PerMapParameterSet* p = params->perMap[m->getName()];
if(p != NULL)
p->m_renderTopo->drawTopo();
// if (p->m_selectedDart != NIL)
// p->m_renderTopo->overdrawDart(m_selectedDart, 4.0f, 1.0f, 0.0f, 0.0f) ;
if(p->drawDarts)
p->m_renderTopo->drawDarts();
if(p->drawPhi1)
p->m_renderTopo->drawRelation1();
if(p->drawPhi2)
p->m_renderTopo->drawRelation2();
}
}
......@@ -103,7 +97,7 @@ void RenderTopoSurfacePlugin::viewLinked(View* view, Plugin* plugin)
registerShader(p->m_renderTopo->shader2());
params->perMap.insert(mh->getName(), p);
}
if (!maps.empty())
if(!maps.empty())
changeSelectedMap(view, maps[0]);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
......@@ -118,6 +112,15 @@ void RenderTopoSurfacePlugin::viewUnlinked(View* view, Plugin* plugin)
{
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);
disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
......@@ -128,11 +131,7 @@ void RenderTopoSurfacePlugin::viewUnlinked(View* view, Plugin* plugin)
void RenderTopoSurfacePlugin::currentViewChanged(View* view)
{
if(isLinkedToView(view))
{
// ParameterSet* params = h_viewParams[view];
// changeSelectedMap(view, params->selectedMap);
m_dockTab->refreshUI(h_viewParams[view]);
}
}
void RenderTopoSurfacePlugin::mapLinked(MapHandlerGen* m)
......@@ -144,14 +143,10 @@ void RenderTopoSurfacePlugin::mapLinked(MapHandlerGen* m)
connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[view];
PerMapParameterSet* p = new PerMapParameterSet(m);
registerShader(p->m_renderTopo->shader1());
registerShader(p->m_renderTopo->shader2());
params->perMap.insert(m->getName(), p);
if(params->selectedMap == NULL || params->perMap.count() == 1)
changeSelectedMap(view, m);
else
......@@ -167,6 +162,7 @@ void RenderTopoSurfacePlugin::mapUnlinked(MapHandlerGen* m)
disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[view];
delete params->perMap[m->getName()];
params->perMap.remove(m->getName());
if(params->selectedMap == m)
......@@ -189,9 +185,13 @@ void RenderTopoSurfacePlugin::changeSelectedMap(View* view, MapHandlerGen* map,
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)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
......@@ -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)
{
......@@ -243,7 +281,20 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen*
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()
......
......@@ -11,16 +11,17 @@ namespace SCHNApps
{
RenderTopoSurfaceDockTab::RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p) :
m_window(w),
m_plugin(p),
b_refreshingUI(false)
m_window(w),
m_plugin(p),
b_refreshingUI(false)
{
setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
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_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int)));
}
......@@ -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_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0);
}
......@@ -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)
{
if(!b_refreshingUI)
......@@ -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 CGoGN
......@@ -86,7 +86,7 @@ void RenderVectorPlugin::viewLinked(View* view, Plugin* plugin)
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
if (!maps.empty())
if(!maps.empty())
changeSelectedMap(view, maps[0]);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
......@@ -182,7 +182,6 @@ void RenderVectorPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
......
......@@ -70,6 +70,13 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
initParameters();
}
PerMapParameterSet::~PerMapParameterSet()
{
delete lockingMarker;
delete handleMarker;
nlDeleteContext(nlContext);
}
void PerMapParameterSet::initParameters()
{
if(positionAttribute.isValid())
......@@ -97,13 +104,6 @@ void PerMapParameterSet::initParameters()
}
}
PerMapParameterSet::~PerMapParameterSet()
{
delete lockingMarker;
delete handleMarker;
nlDeleteContext(nlContext);
}
bool SurfaceDeformationPlugin::enable()
{
......@@ -459,7 +459,6 @@ void SurfaceDeformationPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
}
m_dockTab->refreshUI(params);
view->updateGL();
}
}
......
importPlugin = schnapps.loadPlugin("ImportSurface");
renderPlugin = schnapps.loadPlugin("RenderD");
renderVectorPlugin = schnapps.loadPlugin("RenderVectorD");
renderPlugin = schnapps.loadPlugin("Render");
renderVectorPlugin = schnapps.loadPlugin("RenderVector");
renderTopoSurfacePlugin = schnapps.loadPlugin("RenderTopoSurfaceD");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface");
surfaceDeformationPlugin = schnapps.loadPlugin("SurfaceDeformation");
......@@ -11,6 +12,7 @@ v = schnapps.getView("view_0");
schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderTopoSurfacePlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), surfaceDeformationPlugin.getName());
schnapps.linkViewAndMap(v.getName(), obj.getName());
......
......@@ -196,6 +196,12 @@ public:
*/
void drawTopo();
/**
* get shader objects
*/
Utils::GLSLShader* shader1() { return static_cast<Utils::GLSLShader*>(m_shader1); }
Utils::GLSLShader* shader2() { return static_cast<Utils::GLSLShader*>(m_shader2); }
/**
* change dart drawing color
* @param d the dart
......@@ -286,9 +292,6 @@ public:
* @param ns distance shift
*/
void setBoundaryShift(float bs);
Utils::GLSLShader* shader1() { return static_cast<Utils::GLSLShader*>(m_shader1); }
Utils::GLSLShader* shader2() { return static_cast<Utils::GLSLShader*>(m_shader2); }
};
// just for compatibility with old code
......
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