Commit 921efcb1 authored by untereiner's avatar untereiner

some changes

parent 71e149b3
......@@ -29,6 +29,8 @@
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Import/import.h"
#include "Algo/Render/GL2/topo3Render.h"
#include "Algo/Render/SVG/mapSVGRender.h"
......@@ -43,552 +45,562 @@ Dart dglobal;
void MyQT::cb_checkTopo(bool b)
{
m_showTopo = b;
updateGL();
m_showTopo = b;
updateGL();
}
void MyQT::cb_combo1(int x)
{
m_first3 = x;
if (m_first3!=m_second3)
traverse3();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
m_first3 = x;
if (m_first3!=m_second3)
traverse3();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
}
void MyQT::cb_combo2(int x)
{
m_ajd_or_inci3 = x;
if (m_first3!=m_second3)
traverse3();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
m_ajd_or_inci3 = x;
if (m_first3!=m_second3)
traverse3();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
}
void MyQT::cb_combo3(int x)
{
m_second3 = x;
if (m_first3!=m_second3)
traverse3();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
m_second3 = x;
if (m_first3!=m_second3)
traverse3();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
}
void MyQT::cb_combo4(int x)
{
m_first2 = x;
if (m_first2!=m_second2)
traverse2();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
m_first2 = x;
if (m_first2!=m_second2)
traverse2();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
}
void MyQT::cb_combo5(int x)
{
m_ajd_or_inci2 = x;
if (m_first2!=m_second2)
traverse2();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
m_ajd_or_inci2 = x;
if (m_first2!=m_second2)
traverse2();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
}
void MyQT::cb_combo6(int x)
{
m_second2 = x;
if (m_first2!=m_second2)
traverse2();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
m_second2 = x;
if (m_first2!=m_second2)
traverse2();
else
CGoGNerr <<"undefined traversor" << CGoGNendl;
}
void MyQT::cb_explode(int x)
{
m_expl = float (x) /100.0f;
if (m_last==2)
traverse2();
if (m_last==3)
traverse3();
m_expl = float (x) /100.0f;
if (m_last==2)
traverse2();
if (m_last==3)
traverse3();
}
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
m_render_topo = new Algo::Render::GL2::Topo3Render();
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f);
m_dm_topo = new DartMarker(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f);
m_dm_topo = new DartMarker(myMap);
}
void MyQT::cb_redraw()
{
if (m_showTopo)
{
m_render_topo->drawTopo();
if (m_showTopo)
{
m_render_topo->drawTopo();
if (m_selected != NIL)
m_render_topo->overdrawDart(m_selected, 7, 1.0f, 0.0f, 1.0f);
if (m_selected != NIL)
m_render_topo->overdrawDart(m_selected, 7, 1.0f, 0.0f, 1.0f);
for (std::vector<Dart>::iterator it=m_affDarts.begin(); it!=m_affDarts.end(); ++it)
{
m_render_topo->overdrawDart(*it, 6, 1.0f, 1.0f, 1.0f);
}
}
for (std::vector<Dart>::iterator it=m_affDarts.begin(); it!=m_affDarts.end(); ++it)
{
m_render_topo->overdrawDart(*it, 6, 1.0f, 1.0f, 1.0f);
}
}
m_drawer.callList();
m_drawer.callList();
}
void MyQT::cb_mousePress(int /*button*/, int x, int y)
{
if (Shift())
{
Dart d = m_render_topo->picking<PFP>(myMap, x, y);
if (d != Dart::nil())
{
CGoGNout << "Dart " << d << " clicked" << CGoGNendl;
m_selected = d;
}
updateGL();
}
if (Shift())
{
Dart d = m_render_topo->picking<PFP>(myMap, x, y);
if (d != Dart::nil())
{
CGoGNout << "Dart " << d << " clicked" << CGoGNendl;
m_selected = d;
}
updateGL();
}
}
void MyQT::cb_Save()
{
// std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
// Utils::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
// m_drawer.toSVG(svg);
// m_render_topo->toSVG(svg);
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
std::string filename1 = filename + std::string("Drawer") + std::string(".svg");
std::string filename2 = filename + std::string("Topo") + std::string(".svg");
// std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
// Utils::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
// m_drawer.toSVG(svg);
// m_render_topo->toSVG(svg);
Utils::SVG::SVGOut svg1(filename1, modelViewMatrix(), projectionMatrix());
m_drawer.toSVG(svg1);
svg1.write();
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(0.0f);
Utils::SVG::SVGOut svg1(modelViewMatrix(), projectionMatrix());
m_drawer.toSVG(svg1);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(0.0f);
Utils::SVG::SVGOut svg2(filename2, modelViewMatrix(), projectionMatrix());
m_render_topo->toSVG(svg2);
svg2.write();
// svg2.addOpacityAnimation(1.0f);
// svg2.addOpacityAnimation(0.0f);
// svg2.addOpacityAnimation(1.0f);
Utils::SVG::SVGOut svg2(modelViewMatrix(), projectionMatrix());
m_render_topo->toSVG(svg2);
// svg2.addOpacityAnimation(1.0f);
// svg2.addOpacityAnimation(0.0f);
// svg2.addOpacityAnimation(1.0f);
// Utils::SVG::AnimatedSVGOut anim;
Utils::SVG::AnimatedSVGOut anim;
// anim.add(&svg1);
// anim.add(&svg2);
// anim.write(filename, 2.0f);
anim.add(&svg1);
anim.add(&svg2);
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
anim.write(filename, 2.0f);
}
template <unsigned int ORBIT>
void MyQT::colorizeCell(Dart d, float r,float g, float b)
{
TraversorDartsOfOrbit<PFP::MAP, ORBIT>doo (myMap, d);
for (Dart e = doo.begin(); e != doo.end(); e = doo.next())
m_render_topo->setDartColor(e, r, g, b);
TraversorDartsOfOrbit<PFP::MAP, ORBIT>doo (myMap, d);
for (Dart e = doo.begin(); e != doo.end(); e = doo.next())
m_render_topo->setDartColor(e, r, g, b);
}
void MyQT::traverse2()
{
if (m_selected == NIL)
return;
m_last=2;
// int code = (m_ajd_or_inci2)*100+m_first2*10+m_second2;
m_drawer.newList(GL_COMPILE);
m_drawer.lineWidth(7.0f);
m_drawer.pointSize(9.0f);
m_drawer.color3f(0.0f,0.7f,0.0f);
m_affDarts.clear();
if (m_ajd_or_inci2 == 0) // incident
{
Algo::Render::drawerCell<PFP>(VERTEX+m_second2, m_drawer, myMap, m_selected, position, m_expl);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createIncident(myMap, m_selected, 2, VERTEX+m_second2, VERTEX+m_first2);
for (Dart d=tra->begin(); d != tra->end(); d= tra->next())
m_affDarts.push_back(d);
Algo::Render::drawerCells<PFP>(VERTEX+m_first2, m_drawer, myMap, m_affDarts, position, m_expl);
}
else // adjacent
{
Algo::Render::drawerCell<PFP>(VERTEX+m_first2, m_drawer, myMap, m_selected, position, m_expl);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createAdjacent(myMap, m_selected, 2, VERTEX+m_first2, VERTEX+m_second2);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
m_affDarts.push_back(d);
Algo::Render::drawerCells<PFP>(VERTEX+m_first2, m_drawer, myMap, m_affDarts, position, m_expl);
}
m_drawer.endList();
// SelectorMarked sm(*m_dm_topo);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f);
updateGL();
if (m_selected == NIL)
return;
m_last=2;
// int code = (m_ajd_or_inci2)*100+m_first2*10+m_second2;
m_drawer.newList(GL_COMPILE);
m_drawer.lineWidth(7.0f);
m_drawer.pointSize(9.0f);
m_drawer.color3f(0.0f,0.7f,0.0f);
m_affDarts.clear();
if (m_ajd_or_inci2 == 0) // incident
{
Algo::Render::drawerCell<PFP>(VERTEX+m_second2, m_drawer, myMap, m_selected, position, m_expl);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createIncident(myMap, m_selected, 2, VERTEX+m_second2, VERTEX+m_first2);
for (Dart d=tra->begin(); d != tra->end(); d= tra->next())
m_affDarts.push_back(d);
Algo::Render::drawerCells<PFP>(VERTEX+m_first2, m_drawer, myMap, m_affDarts, position, m_expl);
}
else // adjacent
{
Algo::Render::drawerCell<PFP>(VERTEX+m_first2, m_drawer, myMap, m_selected, position, m_expl);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createAdjacent(myMap, m_selected, 2, VERTEX+m_first2, VERTEX+m_second2);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
m_affDarts.push_back(d);
Algo::Render::drawerCells<PFP>(VERTEX+m_first2, m_drawer, myMap, m_affDarts, position, m_expl);
}
m_drawer.endList();
// SelectorMarked sm(*m_dm_topo);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f);
updateGL();
}
void MyQT::dynamicMarkOrbit(unsigned int orb)
{
switch(orb)
{
case VERTEX:
m_dm_topo->markOrbit<VERTEX>(m_selected);
break;
case EDGE:
m_dm_topo->markOrbit<EDGE>(m_selected);
break;
case FACE:
m_dm_topo->markOrbit<FACE>(m_selected);
break;
case VOLUME:
m_dm_topo->markOrbit<VOLUME>(m_selected);
break;
default:
break;
}
switch(orb)
{
case VERTEX:
m_dm_topo->markOrbit<VERTEX>(m_selected);
break;
case EDGE:
m_dm_topo->markOrbit<EDGE>(m_selected);
break;
case FACE:
m_dm_topo->markOrbit<FACE>(m_selected);
break;
case VOLUME:
m_dm_topo->markOrbit<VOLUME>(m_selected);
break;
default:
break;
}
}
void MyQT::traverse3()
{
if (m_selected == NIL)
return;
m_last=3;
m_affDarts.clear();
m_drawer.newList(GL_COMPILE);
m_drawer.lineWidth(7.0f);
m_drawer.pointSize(9.0f);
m_drawer.color3f(0.0f,0.7f,0.0f);
m_dm_topo->unmarkAll();
SelectorMarked sm(*m_dm_topo);
if (m_ajd_or_inci3 == 0) // incident
{
Algo::Render::drawerCell<PFP>(VERTEX+m_second3, m_drawer,myMap,m_selected,position,m_expl);
dynamicMarkOrbit(VERTEX+m_second3);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createIncident(myMap,m_selected, 3, VERTEX+m_second3, VERTEX+m_first3);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
{
m_affDarts.push_back(d);
dynamicMarkOrbit(VERTEX+m_first3);
}
Algo::Render::drawerCells<PFP>(VERTEX+m_first3, m_drawer, myMap, m_affDarts, position, m_expl);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f); //sm
for (std::vector<Dart>::iterator id = m_affDarts.begin(); id != m_affDarts.end(); ++id)
m_render_topo->setDartColor(*id,0.7f,0.0f,0.0f);
m_render_topo->setDartColor(m_selected,0.0f,0.7f,0.0f);
}
else // adjacent
{
Algo::Render::drawerCell<PFP>(VERTEX+m_first3, m_drawer, myMap, m_selected, position, m_expl);
dynamicMarkOrbit(VERTEX+m_first3);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createAdjacent(myMap,m_selected, 3, VERTEX+m_first3, VERTEX+m_second3);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
{
m_affDarts.push_back(d);
dynamicMarkOrbit(VERTEX+m_first3);
}
Algo::Render::drawerCells<PFP>(VERTEX+m_first3, m_drawer, myMap,m_affDarts,position,m_expl);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f); //sm
for (std::vector<Dart>::iterator id=m_affDarts.begin(); id != m_affDarts.end(); ++id)
m_render_topo->setDartColor(*id,0.7f,0.0f,0.0f);
m_render_topo->setDartColor(m_selected,0.0f,0.7f,0.0f);
}
m_drawer.endList();
updateGL();
if (m_selected == NIL)
return;
m_last=3;
m_affDarts.clear();
m_drawer.newList(GL_COMPILE);
m_drawer.lineWidth(7.0f);
m_drawer.pointSize(9.0f);
m_drawer.color3f(0.0f,0.7f,0.0f);
m_dm_topo->unmarkAll();
//SelectorMarked sm(*m_dm_topo);
if (m_ajd_or_inci3 == 0) // incident
{
Algo::Render::drawerCell<PFP>(VERTEX+m_second3, m_drawer,myMap,m_selected,position,m_expl);
dynamicMarkOrbit(VERTEX+m_second3);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createIncident(myMap,m_selected, 3, VERTEX+m_second3, VERTEX+m_first3);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
{
m_affDarts.push_back(d);
dynamicMarkOrbit(VERTEX+m_first3);
}
Algo::Render::drawerCells<PFP>(VERTEX+m_first3, m_drawer, myMap, m_affDarts, position, m_expl);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f); //sm
for (std::vector<Dart>::iterator id = m_affDarts.begin(); id != m_affDarts.end(); ++id)
m_render_topo->setDartColor(*id,0.7f,0.0f,0.0f);
m_render_topo->setDartColor(m_selected,0.0f,0.7f,0.0f);
}
else // adjacent
{
Algo::Render::drawerCell<PFP>(VERTEX+m_first3, m_drawer, myMap, m_selected, position, m_expl);
dynamicMarkOrbit(VERTEX+m_first3);
m_drawer.color3f(1.0f,0.0f,0.0f);
Traversor<PFP::MAP>* tra = TraversorFactory<PFP::MAP>::createAdjacent(myMap,m_selected, 3, VERTEX+m_first3, VERTEX+m_second3);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
{
m_affDarts.push_back(d);
dynamicMarkOrbit(VERTEX+m_first3);
}
Algo::Render::drawerCells<PFP>(VERTEX+m_first3, m_drawer, myMap,m_affDarts,position,m_expl);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f); //sm
for (std::vector<Dart>::iterator id=m_affDarts.begin(); id != m_affDarts.end(); ++id)
m_render_topo->setDartColor(*id,0.7f,0.0f,0.0f);
m_render_topo->setDartColor(m_selected,0.0f,0.7f,0.0f);
}
m_drawer.endList();
updateGL();
}
/*
void MyQT::dyn_trav3XXaY(unsigned int first, unsigned int second)
{
unsigned int val = first *16 + second;
switch(val)
{
case 0x00:
break;
case 0x10:
{
Traversor3XXaY<PFP::MAP, VERTEX+1, VERTEX+0> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+1>(d);
}
}
break;
case 0x20:
{
Traversor3XXaY<PFP::MAP, VERTEX+2, VERTEX+0> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+2>(d);
}
}
break;
case 0x30:
{
Traversor3XXaY<PFP::MAP, VERTEX+3, VERTEX+0> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+3>(d);
}
}
break;
case 0x01:
{
Traversor3XXaY<PFP::MAP, VERTEX, VERTEX+1> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX>(d);
}
}
break;
case 0x21:
{
Traversor3XXaY<PFP::MAP, VERTEX+2, VERTEX+1> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+2>(d);
}
}
break;
case 0x31:
{
Traversor3XXaY<PFP::MAP, VERTEX+3, VERTEX+1> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+3>(d);
}
}
break;
case 0x02:
{
Traversor3XXaY<PFP::MAP, VERTEX, VERTEX+2> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX>(d);
}
}
break;
case 0x12:
{
Traversor3XXaY<PFP::MAP, VERTEX+1, VERTEX+2> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+1>(d);
}
}
break;
case 0x32:
{
Traversor3XXaY<PFP::MAP, VERTEX+3, VERTEX+2> tra(myMap,m_selected);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
m_affDarts.push_back(d);
m_dm_topo->markOrbit<VERTEX+3>(d);
}