Commit 44d02608 authored by untereiner's avatar untereiner

plugin renderExplod v0.01

parent 3908de25
......@@ -37,7 +37,7 @@
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="combo_colorVBO">
<widget class="QComboBox" name="combo_colorAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -47,7 +47,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="combo_positionVBO">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......
......@@ -12,25 +12,28 @@ namespace CGoGN
namespace SCHNApps
{
enum FaceShadingStyle
{
FLAT = 0,
SMOOTH = 1
};
struct PerMapParameterSet
{
PerMapParameterSet() :
positionVBO(NULL),
colorVBO(NULL),
facesScaleFactor(1.0f),
volumesScaleFactor(1.0f),
renderEdges(false),
renderFaces(true)
{}
PerMapParameterSet(MapHandlerGen* mh);
~PerMapParameterSet();
PerMapParameterSet(MapHandlerGen* map);
void updateRender();
Utils::VBO* positionVBO;
Utils::VBO* colorVBO;
Algo::Render::GL2::ExplodeVolumeRender* m_renderExplod;
MapHandlerGen* mh;
VertexAttribute<PFP3::VEC3> positionAttribute;
VolumeAttribute<PFP3::VEC3> colorAttribute;
float facesScaleFactor;
float volumesScaleFactor;
bool renderEdges;
bool renderFaces;
FaceShadingStyle faceStyle;
};
struct ParameterSet
......@@ -38,7 +41,7 @@ struct ParameterSet
ParameterSet() : selectedMap(NULL)
{}
QHash<QString, PerMapParameterSet> perMap;
QHash<QString, PerMapParameterSet*> perMap;
MapHandlerGen* selectedMap;
};
......@@ -81,16 +84,20 @@ public slots:
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
//void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeColorVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP3::VEC3> attribute, bool fromUI = false);
void changeColorAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP3::VEC3> attribute, bool fromUI = false);
void changeRenderEdges(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeRenderFaces(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void changeVolumesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void attributeModified(unsigned int orbit, QString nameAttr);
void connectivityModified();
};
} // namespace SCHNApps
......
#ifndef _RENDEREXPLOD_DOCK_TAB_H_
#define _RENDEREXPLOD_DOCK_TAB_H_
#ifndef _RENDER_EXPLOD_DOCK_TAB_H_
#define _RENDER_EXPLOD_DOCK_TAB_H_
#include "ui_renderExplod.h"
......@@ -30,12 +30,14 @@ public slots:
void refreshUI(ParameterSet* params);
void selectedMapChanged();
void positionVBOChanged(int index);
void colorVBOChanged(int index);
void positionAttributeChanged(int index);
void colorAttributeChanged(int index);
void renderEdgesChanged(bool b);
void renderFacesChanged(bool b);
void facesScaleFactorChanged(int i);
void volumesScaleFactorChanged(int i);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
......
......@@ -18,10 +18,13 @@ RenderExplodDockTab::RenderExplodDockTab(Window* w, RenderExplodPlugin* p) :
setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
connect(combo_colorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(colorVBOChanged(int)));
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(combo_colorAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(colorAttributeChanged(int)));
connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool)));
connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool)));
connect(slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int)));
connect(slider_volumesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(volumesScaleFactorChanged(int)));
}
......@@ -33,44 +36,46 @@ void RenderExplodDockTab::refreshUI(ParameterSet* params)
b_refreshingUI = true;
mapList->clear();
combo_positionVBO->clear();
combo_colorVBO->clear();
combo_positionAttribute->clear();
combo_colorAttribute->clear();
MapHandlerGen* map = params->selectedMap;
MapHandlerGen* mh = params->selectedMap;
QHash<QString, PerMapParameterSet>::const_iterator i = params->perMap.constBegin();
QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
while (i != params->perMap.constEnd())
{
mapList->addItem(i.key());
if(map != NULL && i.key() == map->getName())
if(mh != NULL && i.key() == mh->getName())
{
QList<QListWidgetItem*> item = mapList->findItems(map->getName(), Qt::MatchExactly);
QList<QListWidgetItem*> item = mapList->findItems(mh->getName(), Qt::MatchExactly);
item[0]->setSelected(true);
PerMapParameterSet& p = params->perMap[map->getName()];
PerMapParameterSet* p = params->perMap[mh->getName()];
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
QList<Utils::VBO*> vbos = map->getVBOList();
unsigned int j = 0;
for(int i = 0; i < vbos.count(); ++i)
const AttributeHash& attribs = mh->getAttributesList(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(vbos[i]->dataSize() == 3)
if(i.value() == vec3TypeName)
{
combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.positionVBO)
combo_positionVBO->setCurrentIndex(j);
combo_positionAttribute->addItem(i.key());
if(i.key() == QString::fromStdString(p->positionAttribute.name()))
combo_positionAttribute->setCurrentIndex(j);
combo_colorVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.colorVBO)
combo_colorVBO->setCurrentIndex(j);
// combo_colorAttribute->addItem(i.key());
// if(i.key() == QString::fromStdString(p.colorAttribute.name()))
// combo_colorAttribute->setCurrentIndex(j);
++j;
}
}
check_renderEdges->setChecked(p.renderEdges);
check_renderFaces->setChecked(p.renderFaces);
slider_facesScaleFactor->setSliderPosition(p.facesScaleFactor * 50.0);
slider_volumesScaleFactor->setSliderPosition(p.volumesScaleFactor * 50.0);
check_renderEdges->setChecked(p->renderEdges);
check_renderFaces->setChecked(p->renderFaces);
slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0);
slider_volumesScaleFactor->setSliderPosition(p->volumesScaleFactor * 50.0);
}
++i;
}
......@@ -88,23 +93,23 @@ void RenderExplodDockTab::selectedMapChanged()
}
}
void RenderExplodDockTab::positionVBOChanged(int index)
void RenderExplodDockTab::positionAttributeChanged(int index)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changePositionVBO(view, map, map->getVBO(combo_positionVBO->currentText()), true);
m_plugin->changePositionAttribute(view, map, map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText()), true);
}
}
void RenderExplodDockTab::colorVBOChanged(int index)
void RenderExplodDockTab::colorAttributeChanged(int index)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changeColorVBO(view, map, map->getVBO(combo_colorVBO->currentText()), true);
m_plugin->changeColorAttribute(view, map, map->getAttribute<PFP2::VEC3, VERTEX>(combo_colorAttribute->currentText()), true);
}
}
......
importPlugin = schnapps.loadPlugin("ImportSurface");
renderPlugin = schnapps.loadPlugin("RenderD");
renderVectorPlugin = schnapps.loadPlugin("RenderVectorD");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface");
surfaceDeformationPlugin = schnapps.loadPlugin("SurfaceDeformation");
#importPlugin = schnapps.loadPlugin("ImportSurface");
#renderPlugin = schnapps.loadPlugin("RenderD");
#renderVectorPlugin = schnapps.loadPlugin("RenderVectorD");
#differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
#subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface");
#surfaceDeformationPlugin = schnapps.loadPlugin("SurfaceDeformation");
obj = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/lowRes/iphi_good_9k.off");
#obj = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/lowRes/iphi_good_9k.off");
v = schnapps.getView("view_0");
#v = schnapps.getView("view_0");
schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), surfaceDeformationPlugin.getName());
#schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
#schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
#schnapps.linkViewAndPlugin(v.getName(), surfaceDeformationPlugin.getName());
schnapps.linkViewAndMap(v.getName(), obj.getName());
#schnapps.linkViewAndMap(v.getName(), obj.getName());
#differentialPropertiesPlugin.computeNormal(obj.getName());
#differentialPropertiesPlugin.computeCurvature(obj.getName());
......@@ -74,7 +74,7 @@ template <typename PFP>
void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive)
{
if(!m_render->isPrimitiveUpToDate(primitive))
m_render->initPrimitives<PFP>(*(static_cast<typename PFP::MAP*>(m_map)), allDarts, primitive) ;
m_render->initPrimitives<PFP>(*(static_cast<typename PFP::MAP*>(m_map)), primitive) ;
m_render->draw(shader, primitive);
}
......
......@@ -728,24 +728,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
}
}
//
// edge-removal on all old boundary edges
//
TraversorE<typename PFP::MAP> tE(map);
for(Dart dit = tE.begin() ; dit != tE.end() ; dit = tE.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<EDGE>(dit);
Dart d = map.phi2(map.phi3(map.findBoundaryFaceOfEdge(dit)));
Volume::Modelisation::Tetrahedralization::swapGen3To2<PFP>(map, d);
}
}
TraversorV<typename PFP::MAP> tVg(map);
>>>>>>> 498aabac71c2d803003f86eb62a8466f894c2271
for(Dart dit = tVg.begin() ; dit != tVg.end() ; dit = tVg.next())
{
if(map.isBoundaryVertex(dit) && !newBoundaryV.isMarked(dit))
......@@ -774,7 +757,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
//
// edge-removal on all old boundary edges
//
TraversorE<typename PFP::MAP> tE(map,selected);
TraversorE<typename PFP::MAP> tE(map);
for(Dart dit = tE.begin() ; dit != tE.end() ; dit = tE.next())
{
if(m.isMarked(dit))
......
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