Commit e739fd2a authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps : la suite..

parent 51b765cb
#ifndef FIRSTPLUGIN_H_
#define FIRSTPLUGIN_H_
#ifndef _FIRSTPLUGIN_H_
#define _FIRSTPLUGIN_H_
#include "plugins/visualPlugin.h"
/**---CGoGN includes **/
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
#include "Topology/generic/parameters.h"
#ifdef USE_GMAP
#include "Topology/gmap/embeddedGMap2.h"
#else
#include "Topology/map/embeddedMap2.h"
#endif
#include "Topology/map/embeddedMap2.h"
#include "Algo/Render/GL2/topoRender.h"
/**---CGoGN includes **/
......@@ -27,17 +18,13 @@ using namespace CGoGN ;
*/
struct PFP: public PFP_STANDARD
{
// definition of the type of the map
#ifdef USE_GMAP
typedef EmbeddedGMap2 MAP;
#else
// definition of the map
typedef EmbeddedMap2 MAP;
#endif
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
/**---Definitions specific to CGoGN ---*/
/**---Definitions specific to CGoGN ---*/
/**
* This class is a basic minimal plugin.
......@@ -71,7 +58,7 @@ public:
* When a scene will be link to this plugin, it will call
* 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.
......@@ -79,7 +66,7 @@ public:
* views that is contains) needs to be refresh, it calls back
* this method with itself as a parameter
*/
void cb_redraw(Scene* scene);
void cb_redraw(Scene *scene);
/**
* The plugin's activation method
......@@ -106,15 +93,27 @@ protected:
VertexAttribute<VEC3> position;
// render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo;
Algo::Render::GL2::TopoRender *m_render_topo;
// 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); }
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); }
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 "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
// scene to the content of our map
......@@ -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();
}
......@@ -46,14 +46,14 @@ bool FirstPlugin::activate()
position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -2, 0);
m_render_topo=NULL;
m_render_topo = NULL;
return true;
}
void FirstPlugin::disable()
{
if(m_render_topo)
if (m_render_topo)
{
delete m_render_topo;
}
......@@ -64,11 +64,11 @@ void FirstPlugin::disable()
* we also define a DEBUG macro at the compilation
*/
#ifndef DEBUG
// essential Qt function:
// arguments are
// - the complied name of the plugin
// - the main class of our plugin (that extends VisualPlugin)
Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin)
// essential Qt function:
// arguments are
// - the complied name of the plugin
// - the main class of our plugin (that extends VisualPlugin)
Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin)
#else
Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin)
Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin)
#endif
......@@ -16,92 +16,116 @@
class Window;
class SplitArea;
namespace System{
namespace System
{
namespace Dialog{
class QuestionSessionDialog : public QDialog, public Ui::QSDialog{
Q_OBJECT
public:
QuestionSessionDialog(QWidget* parent=0) : QDialog(parent){ this->setupUi(this);}
};
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 InfoDialog : public QDialog, public Ui::InfoDialog
{
Q_OBJECT
public:
InfoDialog(QWidget *parent = 0) : QDialog(parent)
{
this->setupUi(this);
}
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;
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
This diff is collapsed.
......@@ -3,9 +3,11 @@
#include <QHash>
namespace CGoGN {
namespace CGoGN
{
class GenericMap;
namespace Utils{
namespace Utils
{
class VBO;
}
}
......@@ -15,25 +17,31 @@ class VBOHandler;
class MapHandler
{
public:
MapHandler(CGoGN::GenericMap* map);
MapHandler(CGoGN::GenericMap *map);
~MapHandler();
CGoGN::GenericMap* map(){ return m_map;}
CGoGN::GenericMap *map()
{
return m_map;
}
VBOHandler* findVBO(QString name);
VBOHandler* findFirstVBOMatching(QRegExp regexp);
QList<VBOHandler*> findVBOsMatching(QRegExp regexp);
VBOHandler *findVBO(QString name);
VBOHandler *findFirstVBOMatching(QRegExp regexp);
QList<VBOHandler *> findVBOsMatching(QRegExp regexp);
bool addVBO(VBOHandler* vboH);
VBOHandler* addNewVBO(QString vboName);
bool addVBO(VBOHandler *vboH);
VBOHandler *addNewVBO(QString vboName);
VBOHandler* takeVBO(VBOHandler* vbo);
VBOHandler *takeVBO(VBOHandler *vbo);
int countVBO(){ return l_vbo.count();}
int countVBO()
{
return l_vbo.count();
}
protected:
CGoGN::GenericMap* m_map;
QList<VBOHandler*> l_vbo;
CGoGN::GenericMap *m_map;
QList<VBOHandler *> l_vbo;
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,92 +4,103 @@
#include "Topology/generic/genericmap.h"
MapHandler::MapHandler(CGoGN::GenericMap* map) :
MapHandler::MapHandler(CGoGN::GenericMap *map) :
m_map(map)
{}
MapHandler::~MapHandler(){
while(!l_vbo.isEmpty()){
VBOHandler* vboH= l_vbo.first();
bool destroy= !vboH->isShared();
MapHandler::~MapHandler()
{
while (!l_vbo.isEmpty())
{
VBOHandler *vboH = l_vbo.first();
bool destroy = !vboH->isShared();
takeVBO(vboH);
if(destroy)
if (destroy)
delete vboH;
}
if(m_map){
if (m_map)
delete m_map;
}
}
VBOHandler* MapHandler::addNewVBO(QString name){
foreach(VBOHandler* vbo, l_vbo){
if((*vbo)==name){
System::Error::code= System::Error::VBO_EXISTS_f(name);
VBOHandler *MapHandler::addNewVBO(QString name)
{
foreach(VBOHandler * vbo, l_vbo)
{
if ((*vbo) == name)
{
System::Error::code = System::Error::VBO_EXISTS_f(name);
return NULL;
}
}
VBOHandler* newVBO= new VBOHandler(name);
VBOHandler *newVBO = new VBOHandler(name);
newVBO->shareWith(this);
return newVBO;
}
bool MapHandler::addVBO(VBOHandler* vbo){
if(vbo){
foreach(VBOHandler* vboH, l_vbo){
if(vbo==vboH || vbo->getName()==vboH->getName()){
System::Error::code= System::Error::VBO_EXISTS_f(vbo->getName());
bool MapHandler::addVBO(VBOHandler *vbo)
{
if (vbo)
{
foreach(VBOHandler * vboH, l_vbo)
{
if (vbo == vboH || vbo->getName() == vboH->getName())
{
System::Error::code = System::Error::VBO_EXISTS_f(vbo->getName());
return false;
}
}
l_vbo.push_back(vbo);
return true;
}
else{
else
return false;
}
}
VBOHandler* MapHandler::findVBO(QString name){
foreach(VBOHandler* vbo, l_vbo){
if(vbo->getName()==name){
VBOHandler *MapHandler::findVBO(QString name)
{
foreach(VBOHandler * vbo, l_vbo)
{
if (vbo->getName() == name)
return vbo;
}
}
return NULL;
}
VBOHandler* MapHandler::findFirstVBOMatching(QRegExp regexp){
foreach(VBOHandler* vbo, l_vbo){
if(vbo->getName().contains(regexp)){
VBOHandler *MapHandler::findFirstVBOMatching(QRegExp regexp)
{
foreach(VBOHandler * vbo, l_vbo)
{
if (vbo->getName().contains(regexp))
return vbo;
}
}
return NULL;
}
QList<VBOHandler*> MapHandler::findVBOsMatching(QRegExp regexp){
QList<VBOHandler*> rlist;
foreach(VBOHandler* vbo, l_vbo){
if(vbo->getName().contains(regexp)){
QList<VBOHandler *> MapHandler::findVBOsMatching(QRegExp regexp)
{
QList<VBOHandler *> rlist;
foreach(VBOHandler * vbo, l_vbo)
{
if (vbo->getName().contains(regexp))
rlist.push_back(vbo);
}
}
return rlist;
}
VBOHandler* MapHandler::takeVBO(VBOHandler* vbo){
int i= l_vbo.indexOf(vbo);
if(i>=0){
VBOHandler* vboh= l_vbo.takeAt(i);
VBOHandler *MapHandler::takeVBO(VBOHandler *vbo)
{
int i = l_vbo.indexOf(vbo);
if (i >= 0)
{
VBOHandler *vboh = l_vbo.takeAt(i);
vboh->unshareWith(this);
return vboh;
}
else{
else
return NULL;
}
}
......@@ -83,7 +83,6 @@ protected:
AttributeContainer m_attribs[NB_ORBITS] ;
static std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map ;
static int m_nbInstances;
/**
......
......@@ -33,16 +33,16 @@
namespace CGoGN
{
std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL ;
std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL;
int GenericMap::m_nbInstances = 0;
GenericMap::GenericMap() : m_nbThreads(1)
{
if(m_attributes_registry_map == NULL)
m_attributes_registry_map = new std::map<std::string, RegisteredBaseAttribute*> ;
m_attributes_registry_map = new std::map<std::string, RegisteredBaseAttribute*>;
m_nbInstances++;
// register all known types
registerAttribute<Dart>("Dart");
registerAttribute<Mark>("Mark");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment