Commit 7297ee8a authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

SCHNApps: update renderExplod plugin

parent 986a72a3
...@@ -34,7 +34,7 @@ bool RenderExplodPlugin::enable() ...@@ -34,7 +34,7 @@ bool RenderExplodPlugin::enable()
m_dockTab = new RenderExplodDockTab(this); m_dockTab = new RenderExplodDockTab(this);
addTabInDock(m_dockTab, "RenderExplod"); addTabInDock(m_dockTab, "RenderExplod");
// m_renderExplod = new Algo::Render::GL2::ExplodeVolumeRender(true); // m_renderExplod = new Algo::Render::GL2::ExplodeVolumeRender(true);
// //
// m_renderExplod->setNoClippingPlane(); // m_renderExplod->setNoClippingPlane();
// m_renderExplod->setExplodeVolumes(0.9f); // m_renderExplod->setExplodeVolumes(0.9f);
...@@ -54,12 +54,15 @@ bool RenderExplodPlugin::enable() ...@@ -54,12 +54,15 @@ bool RenderExplodPlugin::enable()
connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged())); connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
connect(m_dockTab->combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_positionVBOChanged(int))); connect(m_dockTab->combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_positionVBOChanged(int)));
connect(m_dockTab->combo_colorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_colorVBOChanged(int))); connect(m_dockTab->combo_colorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_colorVBOChanged(int)));
connect(m_dockTab->button_refreshVBOs, SIGNAL(clicked()), this, SLOT(cb_refreshVBOs()));
connect(m_dockTab->check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(cb_renderEdgesChanged(bool))); connect(m_dockTab->check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(cb_renderEdgesChanged(bool)));
connect(m_dockTab->check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(cb_renderFacesChanged(bool))); connect(m_dockTab->check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(cb_renderFacesChanged(bool)));
connect(m_dockTab->slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_facesScaleFactorChanged(int))); connect(m_dockTab->slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_facesScaleFactorChanged(int)));
connect(m_dockTab->slider_volumesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_volumesScaleFactorChanged(int))); connect(m_dockTab->slider_volumesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_volumesScaleFactorChanged(int)));
connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*)));
connect(m_window, SIGNAL(viewAndPluginUnlinked(View*, Plugin*)), this, SLOT(viewUnlinked(View*, Plugin*)));
connect(m_window, SIGNAL(currentViewChanged(View*)), this, SLOT(currentViewChanged(View*)));
return true; return true;
} }
...@@ -95,62 +98,185 @@ void RenderExplodPlugin::redraw(View* view) ...@@ -95,62 +98,185 @@ void RenderExplodPlugin::redraw(View* view)
} }
} }
void RenderExplodPlugin::viewLinked(View* view) void RenderExplodPlugin::viewLinked(View* view, Plugin* plugin)
{ {
ParameterSet* params = new ParameterSet(); if(plugin == this)
h_viewParams.insert(view, params);
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* map, maps)
{ {
PerMapParameterSet p(map); ParameterSet* params = new ParameterSet();
params->perMap.insert(map->getName(), p); h_viewParams.insert(view, params);
} const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
if (!maps.empty()) foreach(MapHandlerGen* map, maps)
params->selectedMap = maps[0]; {
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
if (!maps.empty())
changeSelectedMap(view, maps[0]);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*)));
m_dockTab->refreshUI(params); m_dockTab->refreshUI(params);
}
} }
void RenderExplodPlugin::viewUnlinked(View* view) void RenderExplodPlugin::viewUnlinked(View* view, Plugin* plugin)
{ {
h_viewParams.remove(view); if(plugin == this)
{
h_viewParams.remove(view);
View* current = m_window->getCurrentView(); disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
if(isLinkedToView(current)) disconnect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*)));
m_dockTab->refreshUI(h_viewParams[current]); }
} }
void RenderExplodPlugin::currentViewChanged(View* view) void RenderExplodPlugin::currentViewChanged(View* view)
{ {
assert(isLinkedToView(view)); if(isLinkedToView(view))
m_dockTab->refreshUI(h_viewParams[view]); m_dockTab->refreshUI(h_viewParams[view]);
} }
void RenderExplodPlugin::mapLinked(View* view, MapHandlerGen* m) void RenderExplodPlugin::mapLinked(MapHandlerGen* m)
{ {
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view)); assert(isLinkedToView(view));
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
PerMapParameterSet p(m); PerMapParameterSet p(m);
params->perMap.insert(m->getName(), p); params->perMap.insert(m->getName(), p);
if(params->perMap.count() == 1) if(params->selectedMap == NULL || params->perMap.count() == 1)
params->selectedMap = m; changeSelectedMap(view, m);
else
m_dockTab->refreshUI(params); m_dockTab->refreshUI(params);
} }
void RenderExplodPlugin::mapUnlinked(View* view, MapHandlerGen* m) void RenderExplodPlugin::mapUnlinked(MapHandlerGen* m)
{ {
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view)); assert(isLinkedToView(view));
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
params->perMap.remove(m->getName()); params->perMap.remove(m->getName());
if(params->selectedMap == m) if(params->selectedMap == m)
{ {
if(!params->perMap.empty()) if(!params->perMap.empty())
params->selectedMap = m_window->getMap(params->perMap.begin().key()); changeSelectedMap(view, m_window->getMap(params->perMap.begin().key()));
else else
params->selectedMap = NULL; changeSelectedMap(view, NULL);
}
else
m_dockTab->refreshUI(params);
}
void RenderExplodPlugin::vboAdded(Utils::VBO* vbo)
{
m_dockTab->refreshUI(h_viewParams[m_window->getCurrentView()]);
}
void RenderExplodPlugin::vboRemoved(Utils::VBO* vbo)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[view];
if(params->perMap[map->getName()].positionVBO == vbo)
changePositionVBO(view, map, NULL);
if(params->perMap[map->getName()].colorVBO == vbo)
changeColorVBO(view, map, NULL);
m_dockTab->refreshUI(h_viewParams[view]);
}
void RenderExplodPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
{
ParameterSet* params = h_viewParams[view];
MapHandlerGen* prev = params->selectedMap;
params->selectedMap = map;
if(view->isCurrentView())
{
if(prev)
disconnect(map, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
if(map)
connect(map, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderExplodPlugin::changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].positionVBO = vbo;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderExplodPlugin::changeColorVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].colorVBO = vbo;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderExplodPlugin::changeRenderEdges(View* view, MapHandlerGen* map, bool b)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderEdges = b;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderExplodPlugin::changeRenderFaces(View* view, MapHandlerGen* map, bool b)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderFaces = b;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderExplodPlugin::changeFacesScaleFactor(View* view, MapHandlerGen* map, int i)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].facesScaleFactor = i / 50.0;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderExplodPlugin::changeVolumesScaleFactor(View* view, MapHandlerGen* map, int i)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].volumesScaleFactor = i / 50.0;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params); m_dockTab->refreshUI(params);
view->updateGL();
} }
} }
...@@ -158,16 +284,9 @@ void RenderExplodPlugin::cb_selectedMapChanged() ...@@ -158,16 +284,9 @@ void RenderExplodPlugin::cb_selectedMapChanged()
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[view];
QList<QListWidgetItem*> currentItems = m_dockTab->mapList->selectedItems(); QList<QListWidgetItem*> currentItems = m_dockTab->mapList->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
const QString& mapname = currentItems[0]->text();
params->selectedMap = m_window->getMap(mapname);
m_dockTab->refreshUI(params);
view->updateGL();
}
} }
} }
...@@ -175,11 +294,9 @@ void RenderExplodPlugin::cb_positionVBOChanged(int index) ...@@ -175,11 +294,9 @@ void RenderExplodPlugin::cb_positionVBOChanged(int index)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* current = m_window->getCurrentView(); View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[current]; MapHandlerGen* map = h_viewParams[view]->selectedMap;
MapHandlerGen* map = params->selectedMap; changePositionVBO(view, map, map->getVBO(m_dockTab->combo_positionVBO->currentText()));
params->perMap[map->getName()].positionVBO = map->getVBO(m_dockTab->combo_positionVBO->currentText());
current->updateGL();
} }
} }
...@@ -187,26 +304,19 @@ void RenderExplodPlugin::cb_colorVBOChanged(int index) ...@@ -187,26 +304,19 @@ void RenderExplodPlugin::cb_colorVBOChanged(int index)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* view = m_window->getCurrentView();
MapHandlerGen* map = h_viewParams[view]->selectedMap;
changeColorVBO(view, map, map->getVBO(m_dockTab->combo_positionVBO->currentText()));
} }
} }
void RenderExplodPlugin::cb_refreshVBOs()
{
View* current = m_window->getCurrentView();
if(isLinkedToView(current))
m_dockTab->refreshUI(h_viewParams[current]);
}
void RenderExplodPlugin::cb_renderEdgesChanged(bool b) void RenderExplodPlugin::cb_renderEdgesChanged(bool b)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* current = m_window->getCurrentView(); View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[current]; MapHandlerGen* map = h_viewParams[view]->selectedMap;
MapHandlerGen* m = params->selectedMap; changeRenderEdges(view, map, b);
params->perMap[m->getName()].renderEdges = b;
current->updateGL();
} }
} }
...@@ -214,11 +324,9 @@ void RenderExplodPlugin::cb_renderFacesChanged(bool b) ...@@ -214,11 +324,9 @@ void RenderExplodPlugin::cb_renderFacesChanged(bool b)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* current = m_window->getCurrentView(); View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[current]; MapHandlerGen* map = h_viewParams[view]->selectedMap;
MapHandlerGen* m = params->selectedMap; changeRenderFaces(view, map, b);
params->perMap[m->getName()].renderFaces = b;
current->updateGL();
} }
} }
...@@ -226,11 +334,9 @@ void RenderExplodPlugin::cb_facesScaleFactorChanged(int i) ...@@ -226,11 +334,9 @@ void RenderExplodPlugin::cb_facesScaleFactorChanged(int i)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* current = m_window->getCurrentView(); View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[current]; MapHandlerGen* map = h_viewParams[view]->selectedMap;
MapHandlerGen* m = params->selectedMap; changeFacesScaleFactor(view, map, i);
params->perMap[m->getName()].facesScaleFactor = i / 50.0;
current->updateGL();
} }
} }
...@@ -238,11 +344,9 @@ void RenderExplodPlugin::cb_volumesScaleFactorChanged(int i) ...@@ -238,11 +344,9 @@ void RenderExplodPlugin::cb_volumesScaleFactorChanged(int i)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
{ {
View* current = m_window->getCurrentView(); View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[current]; MapHandlerGen* map = h_viewParams[view]->selectedMap;
MapHandlerGen* m = params->selectedMap; changeVolumesScaleFactor(view, map, i);
params->perMap[m->getName()].volumesScaleFactor = i / 50.0;
current->updateGL();
} }
} }
...@@ -267,45 +371,71 @@ void RenderExplodDockTab::refreshUI(ParameterSet* params) ...@@ -267,45 +371,71 @@ void RenderExplodDockTab::refreshUI(ParameterSet* params)
item[0]->setSelected(true); item[0]->setSelected(true);
PerMapParameterSet& p = params->perMap[map->getName()]; PerMapParameterSet& p = params->perMap[map->getName()];
//
// QList<Utils::VBO*> vbos = map->getVBOList(); QList<Utils::VBO*> vbos = map->getVBOList();
// for(int i = 0; i < vbos.count(); ++i) unsigned int j = 0;
// { for(int i = 0; i < vbos.count(); ++i)
// combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name())); {
// if(p.positionVBO == NULL) if(vbos[i]->dataSize() == 3)
// { // if nothing is specified in the parameter set {
// if(vbos[i]->name() == "position") // try to select a VBO named "position" combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name()));
// { if(p.positionVBO == NULL)
// p.positionVBO = vbos[i]; { // if nothing is specified in the parameter set
// combo_positionVBO->setCurrentIndex(i); if(vbos[i]->name() == "position") // try to select a VBO named "position"
// } {
// } p.positionVBO = vbos[i];
// else if(vbos[i] == p.positionVBO) combo_positionVBO->setCurrentIndex(j);
// combo_positionVBO->setCurrentIndex(i); }
// }
// combo_normalVBO->addItem(QString::fromStdString(vbos[i]->name())); else if(vbos[i] == p.positionVBO)
// if(p.normalVBO == NULL) combo_positionVBO->setCurrentIndex(j);
// { // if nothing is specified in the parameter set
// if(vbos[i]->name() == "normal") // try to select a VBO named "normal" combo_colorVBO->addItem(QString::fromStdString(vbos[i]->name()));
// { if(p.colorVBO == NULL)
// p.normalVBO = vbos[i]; { // if nothing is specified in the parameter set
// combo_normalVBO->setCurrentIndex(i); if(vbos[i]->name() == "color") // try to select a VBO named "color"
// } {
// } p.colorVBO = vbos[i];
// else if(vbos[i] == p.normalVBO) combo_colorVBO->setCurrentIndex(j);
// combo_normalVBO->setCurrentIndex(i); }
// } }
// else if(vbos[i] == p.colorVBO)
// if(p.positionVBO == NULL && vbos.count() > 0) combo_colorVBO->setCurrentIndex(j);
// {
// p.positionVBO = vbos[0]; ++j;
// combo_positionVBO->setCurrentIndex(0); }
// } }
// if(p.normalVBO == NULL && vbos.count() > 0)
// { if(p.positionVBO == NULL && vbos.count() > 0)
// p.normalVBO = vbos[0]; {
// combo_normalVBO->setCurrentIndex(0); int i = 0;
// } bool found = false;
while(i < vbos.count() && !found)
{
if(vbos[i]->dataSize() == 3)
{
p.positionVBO = vbos[i];
combo_positionVBO->setCurrentIndex(i);
found = true;
}
++i;
}
}
if(p.colorVBO == NULL && vbos.count() > 0)
{
int i = 0;
bool found = false;
while(i < vbos.count() && !found)
{
if(vbos[i]->dataSize() == 3)
{
p.colorVBO = vbos[i];
combo_colorVBO->setCurrentIndex(i);
found = true;
}
++i;
}
}
check_renderEdges->setChecked(p.renderEdges); check_renderEdges->setChecked(p.renderEdges);
check_renderFaces->setChecked(p.renderFaces); check_renderFaces->setChecked(p.renderFaces);
......
...@@ -84,13 +84,6 @@ public: ...@@ -84,13 +84,6 @@ public:
virtual void mouseMove(View* view, int buttons, int x, int y) {} virtual void mouseMove(View* view, int buttons, int x, int y) {}
virtual void wheelEvent(View* view, int delta, int x, int y) {} virtual void wheelEvent(View* view, int delta, int x, int y) {}
virtual void viewLinked(View* view);
virtual void viewUnlinked(View* view);
virtual void currentViewChanged(View* view);
virtual void mapLinked(View* view, MapHandlerGen* m);
virtual void mapUnlinked(View* view, MapHandlerGen* m);
void setRefreshingUI(bool b) { b_refreshingUI = b; } void setRefreshingUI(bool b) { b_refreshingUI = b; }
protected: protected:
...@@ -100,10 +93,27 @@ protected: ...@@ -100,10 +93,27 @@ protected:
bool b_refreshingUI; bool b_refreshingUI;
public slots: public slots:
void viewLinked(View* view, Plugin* plugin);
void viewUnlinked(View* view, Plugin* plugin);
void currentViewChanged(View* view);
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo);
void changeColorVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo);
void changeRenderEdges(View* view, MapHandlerGen* map, bool b);
void changeRenderFaces(View* view, MapHandlerGen* map, bool b);
void changeFacesScaleFactor(View* view, MapHandlerGen* map, int i);
void changeVolumesScaleFactor(View* view, MapHandlerGen* map, int i);
void cb_selectedMapChanged(); void cb_selectedMapChanged();
void cb_positionVBOChanged(int index); void cb_positionVBOChanged(int index);
void cb_colorVBOChanged(int index); void cb_colorVBOChanged(int index);
void cb_refreshVBOs();
void cb_renderEdgesChanged(bool b); void cb_renderEdgesChanged(bool b);
void cb_renderFacesChanged(bool b); void cb_renderFacesChanged(bool b);
void cb_facesScaleFactorChanged(int i); void cb_facesScaleFactorChanged(int i);
......
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