Commit b308066d authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: encore un petit souci d'affichage GL1 / GL2..

parent 95db7eb4
...@@ -146,6 +146,7 @@ IF(WIN32) ...@@ -146,6 +146,7 @@ IF(WIN32)
# set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE) # set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32) ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
add_subdirectory(Release) add_subdirectory(Release)
add_subdirectory(Debug) add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps) add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
......
...@@ -8,6 +8,7 @@ SET( QT_USE_QTDESIGNER TRUE ) ...@@ -8,6 +8,7 @@ SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE ) SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE ) SET( QT_USE_QTPLUGIN TRUE )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
#========CGoGN========# #========CGoGN========#
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir") SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir")
......
...@@ -39,9 +39,12 @@ file( ...@@ -39,9 +39,12 @@ file(
) )
SET(SCHNApps_H_OBJECT_FILES SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/camera.h
${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/mapHandler.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h ${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h ${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h ${SCHNApps_ROOT_DIR}/include/cameraDialog.h
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
/**---CGoGN includes **/ /**---CGoGN includes **/
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h" #include "Topology/map/embeddedMap2.h"
#include "Algo/Render/GL2/topoRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
/**---CGoGN includes **/ /**---CGoGN includes **/
/**---Definitions specific to CGoGN ---*/ /**---Definitions specific to CGoGN ---*/
...@@ -50,7 +51,6 @@ public: ...@@ -50,7 +51,6 @@ public:
FirstPlugin() FirstPlugin()
{ {
setProvidesRendering(true); setProvidesRendering(true);
glewInit();
} }
~FirstPlugin() ~FirstPlugin()
...@@ -87,34 +87,11 @@ public: ...@@ -87,34 +87,11 @@ public:
virtual void viewRemoved(View* view) {} virtual void viewRemoved(View* view) {}
protected: protected:
/** Attributes that are specific to this plugin **/
MAP myMap; MAP myMap;
// attribute for vertices positions
VertexAttribute<VEC3> position; VertexAttribute<VEC3> position;
Algo::Render::GL2::MapRender* m_render ;
// render (for the topo) Utils::VBO* m_positionVBO ;
Algo::Render::GL2::TopoRender *m_render_topo; Utils::ShaderFlat* m_flatShader ;
// just for more compact writing
inline Dart PHI1(Dart d)
{
return myMap.phi1(d);
}
inline Dart PHI_1(Dart d)
{
return myMap.phi_1(d);
}
inline Dart PHI2(Dart d)
{
return myMap.phi2(d);
}
template<int X>
Dart PHI(Dart d)
{
return myMap.phi<X>(d);
}
/** Attributes that are specific to this plugin **/
}; };
#endif // _FIRSTPLUGIN_H_ #endif // _FIRSTPLUGIN_H_
#include "firstPlugin.h" #include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/Import/import.h"
bool FirstPlugin::enable() bool FirstPlugin::enable()
{ {
// creation of 2 new faces: 1 triangle and 1 square m_render = new Algo::Render::GL2::MapRender() ;
Dart d1 = myMap.newFace(3); m_positionVBO = new Utils::VBO() ;
Dart d2 = myMap.newFace(4); m_flatShader = new Utils::ShaderFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)) ;
m_flatShader->setDiffuse(Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)) ;
m_flatShader->setExplode(1.0f) ;
CGoGN::Utils::GLSLShader::registerShader(NULL, m_flatShader) ;
// sew these faces along one of their edge std::vector<std::string> attrNames ;
myMap.sewFaces(d1, d2); CGoGN::Algo::Import::importMesh<PFP>(myMap, "/home/kraemer/Media/Data/surface/lowRes/duck_163.ply", attrNames);
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
// creation of a new attribute on vertices of type 3D vector for position. m_render->initPrimitives<PFP>(myMap, allDarts, CGoGN::Algo::Render::GL2::POINTS) ;
// a handler to this attribute is returned m_render->initPrimitives<PFP>(myMap, allDarts, CGoGN::Algo::Render::GL2::LINES) ;
position = myMap.addAttribute<VEC3, VERTEX>("position"); m_render->initPrimitives<PFP>(myMap, allDarts, CGoGN::Algo::Render::GL2::TRIANGLES) ;
// affect position by moving in the map m_positionVBO->updateData(position) ;
position[d1] = VEC3(0, 0, 0);
position[PHI1(d1)] = VEC3(2, 0, 0);
position[PHI_1(d1)] = VEC3(1, 2, 0);
position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -2, 0);
m_render_topo = new Algo::Render::GL2::TopoRender() ;
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
return true; return true;
} }
void FirstPlugin::disable() void FirstPlugin::disable()
{ {
if (m_render_topo)
{
delete m_render_topo;
}
} }
void FirstPlugin::redraw(View* view) void FirstPlugin::redraw(View* view)
{ {
m_render_topo->drawTopo(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
glEnable(GL_LIGHTING) ;
// const float nbSteps = 200.0; m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
// glBegin(GL_QUAD_STRIP);
// for (float i = 0; i < nbSteps; ++i)
// {
// float ratio = i/nbSteps;
// float angle = 21.0*ratio;
// float c = cos(angle);
// float s = sin(angle);
// float r1 = 1.0 - 0.8f*ratio;
// float r2 = 0.8f - 0.8f*ratio;
// float alt = ratio - 0.5f;
// const float nor = 0.5f;
// const float up = sqrt(1.0-nor*nor);
// glColor3f(1.0-ratio, 0.2f , ratio);
// glNormal3f(nor*c, up, nor*s);
// glVertex3f(r1*c, alt, r1*s);
// glVertex3f(r2*c, alt+0.05f, r2*s);
// }
// glEnd();
} }
void FirstPlugin::viewAdded(View* view) void FirstPlugin::viewAdded(View* view)
{ {
// bounding box of scene CGoGN::Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position); qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]);
qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]);
PFP::VEC3& min = bb.min(); view->setSceneBoundingBox(min, max);
PFP::VEC3& max = bb.max();
qglviewer::Vec minV(min[0], min[1], min[2]);
qglviewer::Vec maxV(max[0], max[1], max[2]);
view->setSceneBoundingBox(minV, maxV);
} }
/** /**
......
...@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.8) ...@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.8)
SET(CMAKE_BUILD_TYPE Release) SET(CMAKE_BUILD_TYPE Release)
ADD_DEFINITIONS(-fPIC)
IF(WIN32) IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32) ELSE (WIN32)
...@@ -41,9 +39,12 @@ file( ...@@ -41,9 +39,12 @@ file(
) )
SET(SCHNApps_H_OBJECT_FILES SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/camera.h
${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/mapHandler.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h ${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h ${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h ${SCHNApps_ROOT_DIR}/include/cameraDialog.h
......
...@@ -8,6 +8,8 @@ class Window; ...@@ -8,6 +8,8 @@ class Window;
class Camera : public qglviewer::Camera class Camera : public qglviewer::Camera
{ {
Q_OBJECT
public: public:
static unsigned int cameraCount; static unsigned int cameraCount;
...@@ -79,6 +81,9 @@ protected: ...@@ -79,6 +81,9 @@ protected:
double m_drawPathScale; double m_drawPathScale;
int m_snapCount; int m_snapCount;
public slots:
void cb_viewRemoved(View* view);
}; };
#endif #endif
...@@ -15,15 +15,20 @@ namespace CGoGN ...@@ -15,15 +15,20 @@ namespace CGoGN
} }
} }
class MapHandler class MapHandler : public QObject
{ {
Q_OBJECT
public: public:
MapHandler(const QString& name, CGoGN::GenericMap* map); MapHandler(const QString& name, Window* window, CGoGN::GenericMap* map);
~MapHandler(); ~MapHandler();
const QString& getName() { return m_name; } const QString& getName() { return m_name; }
void setName(const QString& name) { m_name = name; } void setName(const QString& name) { m_name = name; }
Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; }
CGoGN::GenericMap* getMap() { return m_map; } CGoGN::GenericMap* getMap() { return m_map; }
CGoGN::Utils::VBO* addVBO(const QString& name); CGoGN::Utils::VBO* addVBO(const QString& name);
...@@ -45,11 +50,15 @@ public: ...@@ -45,11 +50,15 @@ public:
protected: protected:
QString m_name; QString m_name;
Window* m_window;
CGoGN::GenericMap* m_map; CGoGN::GenericMap* m_map;
QList<View*> l_views; QList<View*> l_views;
VBOHash h_vbo; VBOHash h_vbo;
public slots:
void cb_viewRemoved(View* view);
}; };
#endif #endif
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
class Plugin : public QObject class Plugin : public QObject
{ {
public: Q_OBJECT
enum { UNLIMITED_NUMBER_OF_MAPS = -1 };
enum { UNLIMITED_NUMBER_OF_SCENES = -1 };
public:
Plugin(); Plugin();
virtual ~Plugin(); virtual ~Plugin();
...@@ -35,7 +34,12 @@ public: ...@@ -35,7 +34,12 @@ public:
void setWindow(Window* w) { m_window = w; } void setWindow(Window* w) { m_window = w; }
bool getProvidesRendering() { return b_providesRendering; } bool getProvidesRendering() { return b_providesRendering; }
void setProvidesRendering(bool b) { b_providesRendering = b; } void setProvidesRendering(bool b)
{
b_providesRendering = b;
if(b_providesRendering)
glewInit();
}
virtual void redraw(View* view) = 0; virtual void redraw(View* view) = 0;
...@@ -92,6 +96,9 @@ protected: ...@@ -92,6 +96,9 @@ protected:
QList<QAction*> l_menuActions; QList<QAction*> l_menuActions;
QList<QAction*> l_toolbarActions; QList<QAction*> l_toolbarActions;
public slots:
void cb_viewRemoved(View* view);
// QList<Plugin*> l_dependencies; // QList<Plugin*> l_dependencies;
// QList<Plugin*> l_dependantPlugins; // QList<Plugin*> l_dependantPlugins;
......
...@@ -143,11 +143,11 @@ public: ...@@ -143,11 +143,11 @@ public:
// static bool savePluginsInfo(Window *window, PluginHash *pluginHash, QStringList paths); // static bool savePluginsInfo(Window *window, PluginHash *pluginHash, QStringList paths);
//}; //};
typedef enum //typedef enum
{ //{
GLVIEWER_IN_DOCK, // GLVIEWER_IN_DOCK,
SIMPLE_GLVIEWER // SIMPLE_GLVIEWER
} QGLV_CREATE_SETTINGS; //} QGLV_CREATE_SETTINGS;
extern QString app_path; extern QString app_path;
......
...@@ -8,6 +8,7 @@ class Window; ...@@ -8,6 +8,7 @@ class Window;
class Plugin; class Plugin;
class View; class View;
class Camera; class Camera;
class Texture;
class MapHandler; class MapHandler;
...@@ -28,6 +29,8 @@ typedef QHash<QString, MapHandler*> MapHash; ...@@ -28,6 +29,8 @@ typedef QHash<QString, MapHandler*> MapHash;
typedef QHash<QString, CGoGN::Utils::VBO*> VBOHash; typedef QHash<QString, CGoGN::Utils::VBO*> VBOHash;
typedef QHash<QString, CGoGN::Utils::GLSLShader*> ShaderHash; typedef QHash<QString, CGoGN::Utils::GLSLShader*> ShaderHash;
typedef QHash<QString, Texture*> TextureHash;
namespace Qt namespace Qt
{ {
extern int UserRoleType; extern int UserRoleType;
......
...@@ -105,15 +105,18 @@ protected: ...@@ -105,15 +105,18 @@ protected:
QString m_textInfo; QString m_textInfo;
qglviewer::Vec bbmin;
qglviewer::Vec bbmax;
CameraViewDialog* m_cameraViewDialog; CameraViewDialog* m_cameraViewDialog;
PluginsViewDialog* m_pluginsViewDialog; PluginsViewDialog* m_pluginsViewDialog;
MapsViewDialog* m_mapsViewDialog; MapsViewDialog* m_mapsViewDialog;
public slots: public slots:
void cb_cameraView(int x, int y); void cb_cameraView(int x, int y, int globalX, int globalY);
void cb_pluginsView(int x, int y); void cb_pluginsView(int x, int y, int globalX, int globalY);
void cb_mapsView(int x, int y); void cb_mapsView(int x, int y, int globalX, int globalY);
void cb_closeView(int x, int y); void cb_closeView(int x, int y, int globalX, int globalY);
//signals: //signals:
// void currentCameraChanged(Camera* camera); // void currentCameraChanged(Camera* camera);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <iostream> #include <iostream>
class View; class View;
class Texture;
class ViewButton : public QObject class ViewButton : public QObject
{ {
...@@ -19,20 +20,18 @@ public: ...@@ -19,20 +20,18 @@ public:
ViewButton(const QString& image, View* view); ViewButton(const QString& image, View* view);
~ViewButton(); ~ViewButton();
QSize getSize() { return m_GLimg.size(); } QSize getSize();
void click(int x, int y); void click(int x, int y, int globalX, int globalY);
void drawAt(int x, int y); void drawAt(int x, int y);
protected: protected:
QString m_img;
View* m_view; View* m_view;
Texture* m_tex;
QSize m_size;
QImage m_GLimg;
int m_texID;
signals: signals:
void clicked(int x, int y); void clicked(int x, int y, int globalX, int globalY);
}; };
class ViewButtonArea : public QObject class ViewButtonArea : public QObject
...@@ -49,7 +48,7 @@ public: ...@@ -49,7 +48,7 @@ public:
void removeButton(ViewButton* button); void removeButton(ViewButton* button);
bool isClicked(int x, int y); bool isClicked(int x, int y);
void clickButton(int x, int y); void clickButton(int x, int y, int globalX, int globalY);
const QRect& getForm() { return m_form; } const QRect& getForm() { return m_form; }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
class SplitArea; class SplitArea;
class PluginDialog; class PluginDialog;
class CameraDialog; class CameraDialog;
class Texture;
class Window : public QMainWindow, Ui::Window class Window : public QMainWindow, Ui::Window
{ {
...@@ -238,17 +239,12 @@ public: ...@@ -238,17 +239,12 @@ public:
QList<MapHandler*> getMapsList() { return h_maps.values(); } QList<MapHandler*> getMapsList() { return h_maps.values(); }
const MapHash& getMapsHash() { return h_maps; } const MapHash& getMapsHash() { return h_maps; }
// template<typename T> /*********************************************************
// T* getReferencedMap(QString map_name){ * MANAGE TEXTURES
// MapHash::iterator it; *********************************************************/
// if((it=h_map.find(map_name))!=h_map.end()){
// return ((T*)(*it)); Texture* getTexture(const QString& image);
// } void releaseTexture(const QString& image);
// else{
// System::Error::code= System::Error::MAP_UNREFERENCED_f(map_name);
// return NULL;
// }
// }
protected: protected:
bool m_initialization; bool m_initialization;
...@@ -266,6 +262,8 @@ protected: ...@@ -266,6 +262,8 @@ protected:
CameraHash h_cameras; CameraHash h_cameras;
MapHash h_maps; MapHash h_maps;
TextureHash h_textures;
PluginDialog* m_pluginDialog; PluginDialog* m_pluginDialog;
CameraDialog* m_cameraDialog; CameraDialog* m_cameraDialog;
...@@ -330,7 +328,7 @@ signals: ...@@ -330,7 +328,7 @@ signals:
void viewAdded(View* view); void viewAdded(View* view);
void viewRemoved(View* view); void viewRemoved(View* view);
void mapAdded(MapHandler* camera); void mapAdded(MapHandler* map);
void mapRemoved(MapHandler* map); void mapRemoved(MapHandler* map);
void pluginAdded(Plugin* plugin); void pluginAdded(Plugin* plugin);
......
...@@ -15,6 +15,8 @@ Camera::Camera(const QString& name, Window* window) : ...@@ -15,6 +15,8 @@ Camera::Camera(const QString& name, Window* window) :
{ {
++cameraCount; ++cameraCount;
this->setZClippingCoefficient(100); this->setZClippingCoefficient(100);
// connect(m_window, SIGNAL(viewRemoved(View*)), this, SLOT(cb_viewRemoved(View*)));
} }
Camera::~Camera() Camera::~Camera()
...@@ -63,3 +65,8 @@ void Camera::saveSnapshot(QString snapPathName) ...@@ -63,3 +65,8 @@ void Camera::saveSnapshot(QString snapPathName)
view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpg", true); view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpg", true);
++m_snapCount; ++m_snapCount;
} }