Commit a30b1e96 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey
Browse files

Merge cgogn:~kraemer/CGoGN

parents 7f1cdd21 b78c9abb
...@@ -46,6 +46,10 @@ int main(int argc, char **argv) ...@@ -46,6 +46,10 @@ int main(int argc, char **argv)
void MyQT::createMap() void MyQT::createMap()
{ {
// creation of a new attribute on vertices of type 3D vector for position.
// a handler to this attribute is returned
position = myMap.addAttribute<VEC3, VERTEX>("position");
// creation of 2 new faces: 1 triangle and 1 square // creation of 2 new faces: 1 triangle and 1 square
Dart d1 = myMap.newFace(3); Dart d1 = myMap.newFace(3);
Dart d2 = myMap.newFace(4); Dart d2 = myMap.newFace(4);
...@@ -53,10 +57,6 @@ void MyQT::createMap() ...@@ -53,10 +57,6 @@ void MyQT::createMap()
// sew these faces along one of their edge // sew these faces along one of their edge
myMap.sewFaces(d1, d2); myMap.sewFaces(d1, d2);
// creation of a new attribute on vertices of type 3D vector for position.
// a handler to this attribute is returned
position = myMap.addAttribute<VEC3, VERTEX>("position");
// affect position by moving in the map // affect position by moving in the map
position[d1] = VEC3(0, 0, 0); position[d1] = VEC3(0, 0, 0);
position[PHI1(d1)] = VEC3(2, 0, 0); position[PHI1(d1)] = VEC3(2, 0, 0);
......
...@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8) ...@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(SCHNApps) project(SCHNApps)
SET( QT_USE_QTOPENGL TRUE )
SET( QT_USE_QTXML TRUE ) SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTDESIGNER TRUE ) SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE ) SET( QT_USE_QTGUI TRUE )
...@@ -11,6 +12,7 @@ SET( QT_USE_QTPLUGIN TRUE ) ...@@ -11,6 +12,7 @@ SET( QT_USE_QTPLUGIN TRUE )
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir") SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir")
INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt) INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt)
find_package(Qt4 REQUIRED)
#=======QGLViewer=========# #=======QGLViewer=========#
find_package(QGLViewer REQUIRED) find_package(QGLViewer REQUIRED)
...@@ -19,7 +21,7 @@ find_package(QGLViewer REQUIRED) ...@@ -19,7 +21,7 @@ find_package(QGLViewer REQUIRED)
#======SCHNApps=======# #======SCHNApps=======#
SET(SCHNApps_ROOT_DIR ${CGoGN_ROOT_DIR}/SCHNApps) SET(SCHNApps_ROOT_DIR ${CGoGN_ROOT_DIR}/SCHNApps)
SET(EXECUTABLE_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/bin) SET(EXECUTABLE_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/plugins/lib) SET(LIBRARY_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/Plugins)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release) ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release)
IF (NOT WIN32) IF (NOT WIN32)
......
...@@ -34,7 +34,7 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -34,7 +34,7 @@ IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
TARGET_LINK_LIBRARIES( FirstPluginD TARGET_LINK_LIBRARIES( FirstPluginD
${CGoGN_LIBS_D} ${CGoGN_LIBS_D}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_INCLUDE_LIBRARY} ${QGLVIEWER_LIBRARIES}
) )
ADD_DEPENDENCIES( FirstPluginD SCHNAppsD ) ADD_DEPENDENCIES( FirstPluginD SCHNAppsD )
...@@ -59,7 +59,7 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) ...@@ -59,7 +59,7 @@ ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
TARGET_LINK_LIBRARIES( FirstPlugin TARGET_LINK_LIBRARIES( FirstPlugin
${CGoGN_LIBS_R} ${CGoGN_LIBS_R}
${COMMON_LIBS} ${COMMON_LIBS}
${QGLVIEWER_INCLUDE_LIBRARY} ${QGLVIEWER_LIBRARIES}
) )
ADD_DEPENDENCIES( FirstPlugin SCHNApps ) ADD_DEPENDENCIES( FirstPlugin SCHNApps )
......
#ifndef FIRSTPLUGIN_H_ #ifndef _FIRSTPLUGIN_H_
#define FIRSTPLUGIN_H_ #define _FIRSTPLUGIN_H_
#include "plugins/visualPlugin.h" #include "plugins/visualPlugin.h"
/**---CGoGN includes **/ /**---CGoGN includes **/
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#ifdef USE_GMAP
#include "Topology/gmap/embeddedGMap2.h"
#else
#include "Topology/map/embeddedMap2.h"
#endif
#include "Algo/Render/GL2/topoRender.h" #include "Algo/Render/GL2/topoRender.h"
/**---CGoGN includes **/ /**---CGoGN includes **/
...@@ -27,17 +18,13 @@ using namespace CGoGN ; ...@@ -27,17 +18,13 @@ using namespace CGoGN ;
*/ */
struct PFP: public PFP_STANDARD struct PFP: public PFP_STANDARD
{ {
// definition of the type of the map // definition of the map
#ifdef USE_GMAP
typedef EmbeddedGMap2 MAP;
#else
typedef EmbeddedMap2 MAP; typedef EmbeddedMap2 MAP;
#endif
}; };
typedef PFP::MAP MAP; typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3; typedef PFP::VEC3 VEC3;
/**---Definitions specific to CGoGN ---*/ /**---Definitions specific to CGoGN ---*/
/** /**
* This class is a basic minimal plugin. * This class is a basic minimal plugin.
...@@ -71,7 +58,7 @@ public: ...@@ -71,7 +58,7 @@ public:
* When a scene will be link to this plugin, it will call * When a scene will be link to this plugin, it will call
* back this method with itself as a parameter. * back this method with itself as a parameter.
*/ */
void cb_initGL(Scene* scene); void cb_initGL(Scene *scene);
/** /**
* The drawing method that needs to be overloaded. * The drawing method that needs to be overloaded.
...@@ -79,7 +66,7 @@ public: ...@@ -79,7 +66,7 @@ public:
* views that is contains) needs to be refresh, it calls back * views that is contains) needs to be refresh, it calls back
* this method with itself as a parameter * this method with itself as a parameter
*/ */
void cb_redraw(Scene* scene); void cb_redraw(Scene *scene);
/** /**
* The plugin's activation method * The plugin's activation method
...@@ -106,15 +93,27 @@ protected: ...@@ -106,15 +93,27 @@ protected:
VertexAttribute<VEC3> position; VertexAttribute<VEC3> position;
// render (for the topo) // render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo; Algo::Render::GL2::TopoRender *m_render_topo;
// just for more compact writing // just for more compact writing
inline Dart PHI1(Dart d) { return myMap.phi1(d); } inline Dart PHI1(Dart d)
inline Dart PHI_1(Dart d) { return myMap.phi_1(d); } {
inline Dart PHI2(Dart d) { return myMap.phi2(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> template<int X>
Dart PHI(Dart d) { return myMap.phi<X>(d); } Dart PHI(Dart d)
{
return myMap.phi<X>(d);
}
/** Attributes that are specific to this plugin **/ /** 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"
void FirstPlugin::cb_initGL(Scene* scene) void FirstPlugin::cb_initGL(Scene *scene)
{ {
if(scene) if (scene)
{ {
// we fit the first (possibly the only) view of the newly liked // we fit the first (possibly the only) view of the newly liked
// scene to the content of our map // scene to the content of our map
...@@ -21,7 +21,7 @@ void FirstPlugin::cb_initGL(Scene* scene) ...@@ -21,7 +21,7 @@ void FirstPlugin::cb_initGL(Scene* scene)
} }
} }
void FirstPlugin::cb_redraw(Scene* scene) void FirstPlugin::cb_redraw(Scene *scene)
{ {
m_render_topo->drawTopo(); m_render_topo->drawTopo();
} }
...@@ -46,14 +46,14 @@ bool FirstPlugin::activate() ...@@ -46,14 +46,14 @@ bool FirstPlugin::activate()
position[PHI<11>(d2)] = VEC3(0, -2, 0); position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -2, 0); position[PHI_1(d2)] = VEC3(2, -2, 0);
m_render_topo=NULL; m_render_topo = NULL;
return true; return true;
} }
void FirstPlugin::disable() void FirstPlugin::disable()
{ {
if(m_render_topo) if (m_render_topo)
{ {
delete m_render_topo; delete m_render_topo;
} }
...@@ -64,11 +64,11 @@ void FirstPlugin::disable() ...@@ -64,11 +64,11 @@ void FirstPlugin::disable()
* we also define a DEBUG macro at the compilation * we also define a DEBUG macro at the compilation
*/ */
#ifndef DEBUG #ifndef DEBUG
// essential Qt function: // essential Qt function:
// arguments are // arguments are
// - the complied name of the plugin // - the complied name of the plugin
// - the main class of our plugin (that extends VisualPlugin) // - the main class of our plugin (that extends VisualPlugin)
Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin) Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin)
#else #else
Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin) Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin)
#endif #endif
#ifndef _CAMERA_H_ #ifndef _CAMERA_H_
#define _CAMERA_H_ #define _CAMERA_H_
#include "visualization/view.h" #include "view.h"
//forward declaration //forward declaration
...@@ -12,32 +12,32 @@ public: ...@@ -12,32 +12,32 @@ public:
Camera(View* v, Camera c); Camera(View* v, Camera c);
~Camera(); ~Camera();
bool isShared(){return (l_views.size()>1);} bool isShared() { return l_views.size() > 1; }
QString getName(){return m_name;} QString getName() { return m_name; }
void setName(QString name){m_name= name;} void setName(QString name) { m_name = name; }
void draw(); void draw();
void enableDraw(bool b=true){m_draw=b;}
bool isDrawn(){return m_draw;} bool getDraw() { return m_draw; }
void enableDrawFarPlan(bool b=true){m_drawFarPlane=b;} bool getDrawFarPlane() { return m_drawFarPlane; }
bool isFarPlaneDrawn(){return m_drawFarPlane;} double getDrawScale() { return m_drawScale; }
void setDrawScale(double s){m_drawScale=s;} bool getDrawPath() { return m_drawPath; }
double getDrawScale(){return m_drawScale;} bool getDrawPathAxis() { return m_drawPathAxis; }
double getDrawPathScale() { return m_drawPathScale; }
bool isPathDrawn(){return m_drawUserPath;}
void enablePathDraw(bool b=true){m_drawUserPath=b;} void setDraw(bool b = true) { m_draw = b; }
bool isPathAxisDrawn(){return m_drawUserPathAxis;} void setDrawFarPlane(bool b = true) { m_drawFarPlane = b; }
void enablePathAxisDrawn(bool b=true){m_drawUserPathAxis=b;} void setDrawScale(double s) { m_drawScale = s; }
void setPathDrawScale(double s){m_drawUserPathScale= s;} void setDrawPath(bool b = true) { m_drawPath = b; }
double getPathDrawScale(){return m_drawUserPathScale;} void setDrawPathAxis(bool b = true) { m_drawPathAxis = b; }
void setDrawPathScale(double s) { m_drawPathScale = s;}
void takenFrom(View* v); void takenFrom(View* v);
void sharedWith(View* v); void sharedWith(View* v);
void fitParamWith(View* v); void fitParamWith(View* v);
void resetSnapCount(){m_snapCount=0;} void resetSnapCount() { m_snapCount = 0; }
void saveSnapshot(QString snapPathName); void saveSnapshot(QString snapPathName);
void updateGL(); void updateGL();
...@@ -53,9 +53,9 @@ protected: ...@@ -53,9 +53,9 @@ protected:
bool m_drawFarPlane; bool m_drawFarPlane;
double m_drawScale; double m_drawScale;
bool m_drawUserPath; bool m_drawPath;
bool m_drawUserPathAxis; bool m_drawPathAxis;
double m_drawUserPathScale; double m_drawPathScale;
View* m_lastWorkingView; View* m_lastWorkingView;
......
#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#include <QWidget>
#include <QSplashScreen>
#include <unistd.h>
#include <stdarg.h>
#include <iostream>
#include "types.h"
#include "ui_questionSessionDialog.h"
#include "ui_infoDialog.h"
class Window;
class SplitArea;
namespace System{
namespace Dialog{
class QuestionSessionDialog : public QDialog, public Ui::QSDialog{
Q_OBJECT
public:
QuestionSessionDialog(QWidget* parent=0) : QDialog(parent){ this->setupUi(this);}
};
class InfoDialog : public QDialog, public Ui::InfoDialog{
Q_OBJECT
public:
InfoDialog(QWidget* parent=0) : QDialog(parent){ this->setupUi(this);}
bool setContent(QUrl urlHTMLFile);
};
}
class Error{
public:
virtual ~Error() =0;
typedef enum{SUCCESS, NO_SCENE, SCENE_UNREFERENCED, SCENE_EXISTS, NO_DOCK, NO_PLUGIN_PATH_FILE,
ERROR_OPEN_PLUGIN_FILE ,BAD_PLUGIN_PATH_FILE, BAD_PLUGIN_PATH_IN_FILE, NO_PLUGIN_IN_DIR,
PLUGIN_EXISTS, ERROR_PLUGIN_LOAD, BAD_LINK_PLUGIN_WINDOW, UNSATSIFIED_PLUGIN_DEPENDENCIE,
BAD_ACTION_MENU_PATH, MAP_UNREFERENCED, MAP_EXISTS, SHADER_EXISTS, SHADER_NOT_FOUND,
VBO_EXISTS, VBO_NOT_FOUND, TOPO3RENDER_EXISTS, TOPO3RENDER_NOT_FOUND, OPEN_FILE_ERROR,
BAD_XML_FILE} ERROR_CODE;
static QString parameter;
static ERROR_CODE code;
static ERROR_CODE BAD_PLUGIN_PATH_IN_FILE_f(QString file);
static ERROR_CODE NO_PLUGIN_IN_DIR_f(QString dir);
static ERROR_CODE PLUGIN_EXISTS_f(QString plugin);
static ERROR_CODE ERROR_PLUGIN_LOAD_f(QString plugin);
static ERROR_CODE BAD_LINK_PLUGIN_WINDOW_f(QString plugin);
static ERROR_CODE UNSATSIFIED_PLUGIN_DEPENDENCIE_f(QString dependencie, QString from=QString());
static ERROR_CODE BAD_ACTION_MENU_PATH_f(QString actionPath);
static ERROR_CODE MAP_UNREFERENCED_f(QString map_name);
static ERROR_CODE MAP_EXISTS_f(QString map_name);
static ERROR_CODE SHADER_EXISTS_f(QString shader_name, QString glv_name=QString());
static ERROR_CODE SHADER_NOT_FOUND_f(QString shader_name, QString glv_name=QString());
static ERROR_CODE VBO_EXISTS_f(QString vbo_name, QString glv_name=QString());
static ERROR_CODE VBO_NOT_FOUND_f(QString vbo_name, QString glv_name=QString());
static ERROR_CODE TOPO3RENDER_EXISTS_f(QString name, QString glv_name=QString());
static ERROR_CODE TOPO3RENDER_NOT_FOUND_f(QString name, QString glv_name=QString());
static ERROR_CODE OPEN_FILE_ERROR_f(QString filepath);
static ERROR_CODE BAD_XML_FILE_f(QString filepath);
static void showError(QWidget* parent=0);
};
class Events{
public:
virtual ~Events() =0;
static bool movieDialogOpened;
};
class Info{
public:
virtual ~Info() =0;
static void showPluginInfo(QString pluginAbsolutePath, QWidget* parent=0);
static void showPluginInfo(QString locationPath, QString pluginName, QWidget* parent=0);
};
class StateHandler{
public:
virtual ~StateHandler() =0;
static bool saveState(Window* window, PluginHash* pluginHash, SceneHash* sceneHash, SplitArea* splitArea);
static bool loadState(Window* window, PluginHash* pluginHash, SceneHash* sceneHash, SplitArea* splitArea);
static void unsaveState();
static bool savePluginsInfo(Window* window, PluginHash* pluginHash, QStringList paths);
};
typedef enum{GLVIEWER_IN_DOCK, SIMPLE_GLVIEWER} QGLV_CREATE_SETTINGS;
extern QString app_path;
extern QSplashScreen* splash;
}
#endif
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
#include <QHash> #include <QHash>
namespace CGoGN { namespace CGoGN
{
class GenericMap; class GenericMap;
namespace Utils{ namespace Utils
{
class VBO; class VBO;
} }
} }
...@@ -15,10 +17,13 @@ class VBOHandler; ...@@ -15,10 +17,13 @@ class VBOHandler;
class MapHandler class MapHandler
{ {
public: public:
MapHandler(CGoGN::GenericMap* map); MapHandler(CGoGN::GenericMap *map);
~MapHandler(); ~MapHandler();
CGoGN::GenericMap* map(){ return m_map;} CGoGN::GenericMap *map()
{
return m_map;
}
VBOHandler* findVBO(QString name); VBOHandler* findVBO(QString name);
VBOHandler* findFirstVBOMatching(QRegExp regexp); VBOHandler* findFirstVBOMatching(QRegExp regexp);
...@@ -29,7 +34,10 @@ public: ...@@ -29,7 +34,10 @@ public:
VBOHandler* takeVBO(VBOHandler* vbo); VBOHandler* takeVBO(VBOHandler* vbo);
int countVBO(){ return l_vbo.count();} int countVBO()
{
return l_vbo.count();
}
protected: protected:
CGoGN::GenericMap* m_map; CGoGN::GenericMap* m_map;
......
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
#include <QtPlugin>
#include <iostream>
#include <list>
#include "window.h"
#include "system.h"
#include "scene.h"
#include "view.h"
#include "camera.h"
#include "mapHandler.h"
#include "vboHandler.h"
class Plugin
{
public:
enum { UNLIMITED_NUMBER_OF_MAPS = -1 };
enum { UNLIMITED_NUMBER_OF_SCENES = -1 };
Plugin(const QString& name, const QString& filePath);
virtual ~Plugin();
virtual bool enable() = 0;
virtual void disable() = 0;
const QString& getName() { return m_name; }
void setName(const QString& name) { m_name = name; }
const QString& getFilePath() { return m_filePath; }
void setFilePath(const QString& f) { m_filePath = f; }
Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; }
void updateGL();
void updateGL(Scene* scene);
virtual void cb_initGL(Scene* scene) = 0;
virtual void cb_updateMatrix