Commit cfe6d910 authored by Sylvain Thery's avatar Sylvain Thery

Ajout CGoGNStream

Amelioration msg compil Shader
parent f22dfb72
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "Utils/shaderSimpleColor.h" #include "Utils/shaderSimpleColor.h"
#include "Utils/shaderFlat.h" #include "Utils/shaderFlat.h"
#include "Utils/cgognStream.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -241,7 +242,6 @@ int main(int argc, char **argv) ...@@ -241,7 +242,6 @@ int main(int argc, char **argv)
dock.vertexEdit->setPlainText(QString(sqt.m_shader2->getVertexShaderSrc())); dock.vertexEdit->setPlainText(QString(sqt.m_shader2->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(sqt.m_shader2->getFragmentShaderSrc())); dock.fragmentEdit->setPlainText(QString(sqt.m_shader2->getFragmentShaderSrc()));
dock.geometryEdit->setPlainText(QString(sqt.m_shader2->getGeometryShaderSrc())); dock.geometryEdit->setPlainText(QString(sqt.m_shader2->getGeometryShaderSrc()));
// show final pour premier redraw // show final pour premier redraw
sqt.show(); sqt.show();
......
...@@ -81,10 +81,10 @@ ...@@ -81,10 +81,10 @@
<number>100</number> <number>100</number>
</property> </property>
<property name="value"> <property name="value">
<number>90</number> <number>100</number>
</property> </property>
<property name="sliderPosition"> <property name="sliderPosition">
<number>90</number> <number>100</number>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -116,7 +116,17 @@ ...@@ -116,7 +116,17 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTextEdit" name="vertexEdit"/> <widget class="QTextEdit" name="vertexEdit">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="tabStopWidth">
<number>20</number>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
...@@ -126,7 +136,17 @@ ...@@ -126,7 +136,17 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTextEdit" name="fragmentEdit"/> <widget class="QTextEdit" name="fragmentEdit">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="tabStopWidth">
<number>20</number>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
...@@ -143,6 +163,24 @@ ...@@ -143,6 +163,24 @@
<verstretch>1</verstretch> <verstretch>1</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="overwriteMode">
<bool>false</bool>
</property>
<property name="tabStopWidth">
<number>20</number>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
#include "Utils/pointSprite.h" #include "Utils/pointSprite.h"
#include "Utils/pointLine.h" #include "Utils/pointLine.h"
#include "Utils/cgognStream.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -81,7 +83,6 @@ void MyQT::vectors_onoff(bool x) ...@@ -81,7 +83,6 @@ void MyQT::vectors_onoff(bool x)
void MyQT::text_onoff(bool x) void MyQT::text_onoff(bool x)
{ {
statusMsg(NULL);
render_text = !render_text; render_text = !render_text;
updateGL(); updateGL();
} }
...@@ -231,12 +232,35 @@ void MyQT::cb_redraw() ...@@ -231,12 +232,35 @@ void MyQT::cb_redraw()
} }
void MyQT::cb_mousePress(int button, int x, int y)
{
if (Shift())
{
Dart d = m_render_topo->picking<PFP>(myMap,allDarts,x,getHeight()-y);
if (d != Dart::nil())
{
// std::stringstream ss;
// ss << "Dart "<< d << " clicked"<< std::endl;
// statusMsg(ss.str().c_str());
CGoGNout << "Dart "<< d << " clicked"<< CGoGNendl;
}
else
{
statusMsg("");
}
}
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT,"position"); position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT,"position");
CGoGNout << 5.34 << " toto "<< Geom::Vec3f(2.5, 2.2, 4.3) << CGoGNendl;
CGoGNout << 3 << " tutu "<< 4 <<CGoGNendl;
Algo::Modelisation::Primitive3D<PFP> prim(myMap,position); Algo::Modelisation::Primitive3D<PFP> prim(myMap,position);
int nb=3; int nb=3;
...@@ -258,7 +282,17 @@ int main(int argc, char **argv) ...@@ -258,7 +282,17 @@ int main(int argc, char **argv)
// message d'aide // message d'aide
sqt.setHelpMsg(""); sqt.setHelpMsg("");
sqt.statusMsg("3Map with topo rendering & attribute shader utilization"); CGoGNout.out2StatuBar(&sqt);
CGoGNout <<"CGoGNOut StatusBar"<< Geom::Vec3f(2.5, 2.2, 4.3) << CGoGNendl;
CGoGNout.out2Console(&sqt);
CGoGNout <<"CGoGNOut dans la console"<< Geom::Vec3f(2.5, 2.2, 4.3) << CGoGNendl;
CGoGNout.out2StatuBar(NULL);
CGoGNout <<"tirelipinpon .."<< CGoGNendl;
CGoGNout <<"ah aha ah"<< CGoGNendl;
// bounding box // bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position); Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
...@@ -283,7 +317,12 @@ int main(int argc, char **argv) ...@@ -283,7 +317,12 @@ int main(int argc, char **argv)
sqt.slider_vectors(50); sqt.slider_vectors(50);
sqt.slider_text(50); sqt.slider_text(50);
GLint texSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
CGoGNdbg2.out2Console(&sqt);
CGoGNerr.out2Console(&sqt);
CGoGNdbg2 << " TextureSize " << texSize << CGoGNendl;
CGoGNerr << " ERROR " << 5*7 << CGoGNendl;
// et on attend la fin. // et on attend la fin.
return app.exec(); return app.exec();
......
...@@ -91,6 +91,8 @@ protected: ...@@ -91,6 +91,8 @@ protected:
void cb_initGL(); void cb_initGL();
void cb_mousePress(int button, int x, int y);
// slots locaux // slots locaux
public slots: public slots:
void balls_onoff(bool x); void balls_onoff(bool x);
......
...@@ -77,6 +77,7 @@ add_library( ...@@ -77,6 +77,7 @@ add_library(
#) #)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/") add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
add_definitions(-DDBG_MAX_LEVEL=5)
file( file(
GLOB_RECURSE GLOB_RECURSE
......
...@@ -77,7 +77,7 @@ add_library( ...@@ -77,7 +77,7 @@ add_library(
#) #)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/") add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
add_definitions(-DDBG_MAX_LEVEL=0)
file( file(
GLOB_RECURSE GLOB_RECURSE
......
...@@ -63,6 +63,7 @@ protected: ...@@ -63,6 +63,7 @@ protected:
* 1: vertices phi1 * 1: vertices phi1
* 2: vertices phi2 * 2: vertices phi2
* 3: vertices phi3 * 3: vertices phi3
* 4: colors
*/ */
Utils::VBO* m_vbo0; Utils::VBO* m_vbo0;
Utils::VBO* m_vbo1; Utils::VBO* m_vbo1;
...@@ -132,6 +133,24 @@ protected: ...@@ -132,6 +133,24 @@ protected:
void updateGMap3(typename PFP::MAP& map, const FunctorSelect& good, const typename PFP::TVEC3& positions, float ke, float kf, float kv); void updateGMap3(typename PFP::MAP& map, const FunctorSelect& good, const typename PFP::TVEC3& positions, float ke, float kf, float kv);
/**
* save colors
*/
void pushColors();
/**
* restore colors
*/
void popColors();
/**
* pick dart with color set bey setDartsIdColor
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
Dart pickColor(unsigned int x, unsigned int y);
public: public:
...@@ -234,16 +253,6 @@ public: ...@@ -234,16 +253,6 @@ public:
void overdrawDart(Dart d, float width, float r, float g, float b); void overdrawDart(Dart d, float width, float r, float g, float b);
/**
* save colors
*/
void pushColors();
/**
* restore colors
*/
void popColors();
/* /*
* store darts in color for picking * store darts in color for picking
...@@ -254,14 +263,19 @@ public: ...@@ -254,14 +263,19 @@ public:
void setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good); void setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good);
/** /**
* pick dart with color set bey setDartsIdColor * pick dart with color set bey setDartsIdColor
* Do not forget to apply same transformation to scene before picking than before drawing ! * Do not forget to apply same transformation to scene before picking than before drawing !
* @param map the map
* @param good a dart selector
* @param x position of mouse (x) * @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin) * @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL * @return the dart or NIL
*/ */
Dart picking(unsigned int x, unsigned int y); template<typename PFP>
Dart picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y);
}; };
//template<typename MAP> //template<typename MAP>
......
...@@ -674,6 +674,10 @@ void Topo3RenderMapD::updateData(typename PFP::MAP& map, const FunctorSelect& go ...@@ -674,6 +674,10 @@ void Topo3RenderMapD::updateData(typename PFP::MAP& map, const FunctorSelect& go
m_vbo4->bind(); m_vbo4->bind();
glUnmapBuffer(GL_ARRAY_BUFFER); glUnmapBuffer(GL_ARRAY_BUFFER);
} }
// //
// //
// //
...@@ -927,6 +931,18 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g ...@@ -927,6 +931,18 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g
glUnmapBuffer(GL_ARRAY_BUFFER); glUnmapBuffer(GL_ARRAY_BUFFER);
} }
template<typename PFP>
Dart Topo3Render::picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y)
{
pushColors();
setDartsIdColor<PFP>(map,good);
Dart d = pickColor(x,y);
popColors();
return d;
}
}//end namespace VBO }//end namespace VBO
......
...@@ -88,6 +88,9 @@ protected: ...@@ -88,6 +88,9 @@ protected:
*/ */
float m_topo_relation_width; float m_topo_relation_width;
float *m_color_save;
/** /**
* attribut d'index dans le VBO * attribut d'index dans le VBO
*/ */
...@@ -101,6 +104,15 @@ protected: ...@@ -101,6 +104,15 @@ protected:
void dartToCol(Dart d, float& r, float& g, float& b); void dartToCol(Dart d, float& r, float& g, float& b);
Dart pickColor(unsigned int x, unsigned int y);
template<typename PFP>
void setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good);
void pushColors();
void popColors();
public: public:
/** /**
* Constructor * Constructor
...@@ -179,11 +191,14 @@ public: ...@@ -179,11 +191,14 @@ public:
/** /**
* pick dart with color set bey setDartsIdColor * pick dart with color set bey setDartsIdColor
* Do not forget to apply same transformation to scene before picking than before drawing ! * Do not forget to apply same transformation to scene before picking than before drawing !
* @param map the map in which we pick (same as drawn !)
* @param good the selector (same as used during drawing)
* @param x position of mouse (x) * @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin) * @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL * @return the dart or NIL
*/ */
Dart picking(unsigned int x, unsigned int y); template<typename PFP>
Dart picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y);
}; };
class TopoRenderMapD : public TopoRender class TopoRenderMapD : public TopoRender
......
...@@ -338,6 +338,55 @@ void TopoRenderGMap::updateData(typename PFP::MAP& map, const typename PFP::TVEC ...@@ -338,6 +338,55 @@ void TopoRenderGMap::updateData(typename PFP::MAP& map, const typename PFP::TVEC
*/ */
} }
template<typename PFP>
void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good)
{
m_vbo3->bind();
float* colorBuffer = reinterpret_cast<float*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE));
unsigned int nb=0;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (nb < m_nbDarts)
{
if (good(d))
{
float r,g,b;
dartToCol(d, r,g,b);
float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO
*local++ = r;
*local++ = g;
*local++ = b;
*local++ = r;
*local++ = g;
*local++ = b;
nb++;
}
}
else
{
std::cerr << "Error buffer too small for color picking (change the good parameter ?)" << std::endl;
d = map.end();
}
}
glUnmapBuffer(GL_ARRAY_BUFFER);
}
template<typename PFP>
Dart TopoRender::picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y)
{
pushColors();
setDartsIdColor<PFP>(map,good);
Dart d = pickColor(x,y);
popColors();
return d;
}
}//end namespace GL2 }//end namespace GL2
}//end namespace Algo }//end namespace Algo
......
...@@ -97,6 +97,10 @@ protected: ...@@ -97,6 +97,10 @@ protected:
*/ */
GLhandleARB m_geom_shader_object; GLhandleARB m_geom_shader_object;
std::string m_nameVS;
std::string m_nameFS;
std::string m_nameGS;
/** /**
* handle of program * handle of program
*/ */
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _CGOGNSTREAM_H_
#define _CGOGNSTREAM_H_
#ifndef DBG_MAX_LEVEL
#define DBG_MAX_LEVEL 5
#endif
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
//forward defs
namespace CGoGN { namespace Utils { namespace QT {class SimpleQT; } } }
class QTextEdit;
namespace CGoGN
{
namespace CGoGNStream
{
enum drawingType { STDOUT = 1,
STDERR = 2,
FILEOUT = 4,
QTSTATUSBAR = 8,
QTCONSOLE = 16,
SSBUFFER = 32};
class Special
{};
template<int LEVEL>
class Out
{
protected:
int m_out_mode;
std::stringstream m_buffer;
Utils::QT::SimpleQT* m_sqt_bar;
Utils::QT::SimpleQT* m_sqt_console;
QTextEdit* m_qte;
std::ofstream* m_ofs;
std::stringstream* m_oss;
int m_code;
public:
/**
* constructor
*/
Out();
/**
* destructor
*/
~Out();
/**
* set output to standard
*/
void out2std(bool yes = true);
/**
* set output to file
*/
void out2File(const std::string& filename );
/**
* set output to status bar of Qt interface