From a9073ab59bbdfc104171dd7f6f3dae4675d941f0 Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Mon, 1 Feb 2016 14:12:00 -0600 Subject: [PATCH] glnetwork is under stim/visualization/ --- stim/visualization/glnetwork.h | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+), 0 deletions(-) create mode 100644 stim/visualization/glnetwork.h diff --git a/stim/visualization/glnetwork.h b/stim/visualization/glnetwork.h new file mode 100644 index 0000000..5f5d8eb --- /dev/null +++ b/stim/visualization/glnetwork.h @@ -0,0 +1,106 @@ +#ifndef STIM_GLNETWORK_H +#define STIM_GLNETWORK_H + +#include +#include +#include "network.h" +#include +#include +#include +#include "fiber.h" + + +namespace stim +{ +template +class glnetwork : public virtual network +{ +private: + using stim::network::E; + + GLuint dList; + + void init() + { + if(glIsList(dList)) + glDeleteLists(dList, 1); + dList = glGenLists(1); + glListBase(dList); + glMatrixMode(GL_PROJECTION); + glLoadIdentity; + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; + } + + void + Create(GLenum mode) + { + glNewList(dList, GL_COMPILE); + glLineWidth(3.5); + for(int i = 0; i < E.size(); i++) + { + if(mode == GL_SELECT) + { +// glLineWidth(3.5); + glLoadName(i); + } + else{ +// glLineWidth(1.0+1.0*i); + } + glColor3f(0.0, 1.0-0.05*i, i*0.05); + std::vector > line = getEdgeCenterLine(i); + glBegin(GL_LINE_STRIP); + for(int j = 0; j < line.size(); j++) + { + glVertex3f(line[j][0], + line[j][1], + line[j][2]); + } + glEnd(); + } + glEndList(); +// CHECK_OPENGL_ERROR + } + +public: + using stim::network::sizeE; + using stim::network::getEdgeCenterLine; + glnetwork() + { + + } + + void + createFromSelf(GLenum mode = GL_RENDER) + { + init(); + Create(mode); + } + + void + Render() + { + glCallList(dList); +// CHECK_OPENGL_ERROR + } + + void + RenderLine(std::vector > l) + { + glColor3f(0.5, 1.0, 0.5); + glLineWidth(3.0); + glBegin(GL_LINE_STRIP); + for(int j = 0; j < l.size(); j++){ + glVertex3f( + l[j][0], + l[j][1], + l[j][2] + ); + } + glEnd(); + } + +}; +} + +#endif -- libgit2 0.21.4