Commit e739fd2a authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

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,12 +18,8 @@ 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;
......@@ -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,36 +16,53 @@
class Window;
class SplitArea;
namespace System{
namespace System
{
namespace Dialog{
class QuestionSessionDialog : public QDialog, public Ui::QSDialog{
namespace Dialog
{
class QuestionSessionDialog : public QDialog, public Ui::QSDialog
{
Q_OBJECT
public:
QuestionSessionDialog(QWidget* parent=0) : QDialog(parent){ this->setupUi(this);}
};
public:
QuestionSessionDialog(QWidget *parent = 0) : QDialog(parent)
{
this->setupUi(this);
}
};
class InfoDialog : public QDialog, public Ui::InfoDialog{
class InfoDialog : public QDialog, public Ui::InfoDialog
{
Q_OBJECT
public:
InfoDialog(QWidget* parent=0) : QDialog(parent){ this->setupUi(this);}
bool setContent(QUrl urlHTMLFile);
};
public:
InfoDialog(QWidget *parent = 0) : QDialog(parent)
{
this->setupUi(this);
}
class Error{
public:
virtual ~Error() =0;
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,
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;
BAD_XML_FILE
} ERROR_CODE;
static QString parameter;
......@@ -56,52 +73,59 @@ namespace System{
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 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 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);
};
static void showError(QWidget *parent = 0);
};
class Events{
public:
virtual ~Events() =0;
class Events
{
public:
virtual ~Events() = 0;
static bool movieDialogOpened;
};
};
class Info{
public:
virtual ~Info() =0;
class Info
{
public:
virtual ~Info() = 0;
static void showPluginInfo(QString pluginAbsolutePath, QWidget* parent=0);
static void showPluginInfo(QString locationPath, QString pluginName, QWidget* parent=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;
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 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);
};
static bool savePluginsInfo(Window *window, PluginHash *pluginHash, QStringList paths);
};
typedef enum
{
GLVIEWER_IN_DOCK, SIMPLE_GLVIEWER
} QGLV_CREATE_SETTINGS;
typedef enum{GLVIEWER_IN_DOCK, SIMPLE_GLVIEWER} QGLV_CREATE_SETTINGS;
extern QString app_path;
extern QString app_path;
extern QSplashScreen *splash;
extern QSplashScreen* splash;
}
#endif
......@@ -6,6 +6,7 @@
#include <QVBoxLayout>
#include "Topology/generic/genericmap.h"
#include "types.h"
#include "visualization/mapHandler.h"
#include "interface/splitArea.h"
......@@ -18,8 +19,10 @@ class Plugin;
class Context;
class MapHandler;
class Window : public QMainWindow, Ui::Window{
class Window : public QMainWindow, Ui::Window
{
Q_OBJECT
public:
/**
* \fn Window(QWidget* parent=0)
......@@ -27,26 +30,28 @@ public:
*
* \param parent the parent of the window
*/
Window(QWidget* parent=0);
Window(QWidget *parent = 0);
/**
* \fn ~Window()
* \brief the class destructor
*/
~Window();
bool addNewEmptyScene(QString name, Scene* &scene, bool dialog, Camera* sharedCamera=NULL);
bool addNewSceneView(Scene* scene, View* view);
bool addNewEmptyScene(QString name, Scene *&scene, bool dialog, Camera *sharedCamera = NULL);
bool addNewSceneView(Scene *scene, View *view);
QList<Scene*> scenes(){return h_scene.values();}
QList<Scene *> scenes()
{
return h_scene.values();
}
bool associateSceneWithPlugin(QString glviewer, Plugin* plugin, Scene* &scene, bool cb_initGL=false);
bool associateSceneWithPlugin(QString glviewer, Plugin *plugin, Scene *&scene, bool cb_initGL = false);
bool addNewSceneFromPlugin(QString name, Plugin* plugin, Scene* &scene);
bool addNewSceneFromPluginDialog(QString name, Plugin* plugin, Scene* &scene);
bool addNewSceneFromPlugin(QString name, Plugin *plugin, Scene *&scene);
bool addNewSceneFromPluginDialog(QString name, Plugin *plugin, Scene *&scene);
void removeScene(QString name);
/**
* \fn void addEmptyDock()
* \brief add an empty dock to the window, if one doesn't already exists
......@@ -55,6 +60,7 @@ public:
* \see VisualPlugin::addWidgetInDockTab()
*/
void addEmptyDock();
/**
* \fn QTabWidget* getDockTabWidget()
* \brief Accessor to the QTabWidget of this interface
......@@ -63,7 +69,8 @@ public:
*
* \return a pointer to the TabWidget, NULL if not allocated yet
*/
QTabWidget* getDockTabWidget();
QTabWidget *getDockTabWidget();
/**
* \fn void addWidgetInDockTab(QWidget* newTabWidget, QString tabText)
* \brief Adds the widget as a new tab in the interface's dock
......@@ -73,7 +80,8 @@ public:
*
* \see removeTabInDock()
*/
void addWidgetInDockTab(QWidget* newTabWidget, QString tabText);
void addWidgetInDockTab(QWidget *newTabWidget, QString tabText);
/**
* \fn void removeTabInDock(QWidget* tabWidget)
* \brief removes a given widget from the tab
......@@ -84,7 +92,7 @@ public:
*
* \see addWidgetInDockTab()
*/
void removeTabInDock(QWidget* tabWidget);
void removeTabInDock(QWidget *tabWidget);
/**
* \fn bool addMenuAction(QString menuPath, QAction* act)
......@@ -119,7 +127,8 @@ public:
* \see deleteMenuAction()
* \see VisualPlugin::addMenuAction()
*/
bool addMenuAction(QString menuPath, QAction* act);
bool addMenuAction(QString menuPath, QAction *act);
/**
* \fn void deleteMenuAction(QAction* act)
* \brief delete an action from the menu bar
......@@ -135,13 +144,9 @@ public:
* \see addMenuAction()
* \see VisualPlugin::deleteMenuActions()
*/
void deleteMenuAction(QAction* act);
bool addToolbarAction(QAction* act);
void deleteMenuAction(QAction *act);
bool addToolbarAction(QAction *act);
/**
* \fn bool loadPlugin(QString pluginPath)
......@@ -171,7 +176,7 @@ public:
* \see getPlugin()
* \see Plugin::activate()
*/
Plugin* loadPlugin(QString pluginPath);
Plugin *loadPlugin(QString pluginPath);
/**
* \fn void unloadPlugin(QString pluginName)
......@@ -192,6 +197,7 @@ public:
* \see Plugin::disable()
*/
void unloadPlugin(QString pluginName);
/**
* \fn Plugin* checkPluginDependencie(QString name, Plugin* dependantPlugin)
* \brief checks for a dependencie Plugin, and set the dependencie link for the found Plugin
......@@ -212,15 +218,18 @@ public:
* \see VisualPlugin::addDependencie()
**/
Plugin* checkPluginDependencie(QString name, Plugin* dependantPlugin);
Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin);
QList<Plugin*> activePlugins(){return h_plugin.values();}
QList<Plugin *> activePlugins()
{
return h_plugin.values();
}
void linkDialog(Scene* scene);
void unlinkDialog(Scene* scene, QList<Plugin*> dependingPlugins);
void linkDialog(Scene *scene);
void unlinkDialog(Scene *scene, QList<Plugin *> dependingPlugins);
bool addReferencedMap(QString map_name, MapHandler *map);
bool addReferencedMap(QString map_name, MapHandler* map);
/**
* \fn bool addNewReferencedMap(QString map_name, T* &map)
* \brief adds and reference a new map
......@@ -230,7 +239,6 @@ public:
*
* \warning This function was meant to be used by the plugins and GLViewers, you should probably not call it.
*
*
* \tparam T the template parameter which the type of the map you want to add. T must be a CGoGN
* map type, that is to say an instance of a class that inherits CGoGN::GenericMap.
*
......@@ -243,25 +251,30 @@ public:
* \see getReferencedMap()
*/
template<typename T>
MapHandler* addNewReferencedMap(QString map_name, T* &map){
MapHandler *addNewReferencedMap(QString map_name, T *&map)
{
//if a map isn't already referenced under that name
MapHash::iterator it;
if((it=h_vizu.find(map_name))==h_vizu.end()){
if ((it = h_vizu.find(map_name)) == h_vizu.end())
{
//the map is created, inserted, and reference under the given name
map= new T();
MapHandler* vh= new MapHandler((CGoGN::GenericMap*)map);
h_vizu.insert(map_name,vh);
map = new T();
MapHandler *vh = new MapHandler((CGoGN::GenericMap *)map);
h_vizu.insert(map_name, vh);
return vh;
}
//if a map already has that name
else{
else
{
//failure + map affected with the address of the already existing map
map= ((T*)((*it)->map()));
System::Error::code= System::Error::MAP_EXISTS_f(map_name);
map = ((T *)((*it)->map()));
System::Error::code = System::Error::MAP_EXISTS_f(map_name);
return NULL;
}
}
/**
* \fn T* getReferencedMap(QString map_name)
* \brief return the map referenced under the given name
......@@ -290,28 +303,37 @@ public:
// return NULL;
// }
// }
MapHandler* getReferencedMap(QString map_name);
MapHandler *getReferencedMap(QString map_name);
Context* context(){return m_context;}
Context *context()
{
return m_context;
}
QList<Plugin*> plugins(){return h_plugin.values();}
QList<MapHandler*> maps(){return h_vizu.values();}
QList<Plugin *> plugins()
{
return h_plugin.values();
}
QList<MapHandler *> maps()
{
return h_vizu.values();
}
protected:
QVBoxLayout* verticalLayout;
SplitArea* m_splitArea;
QVBoxLayout *verticalLayout;
SplitArea *m_splitArea;
/**
* \var QDockWidget* m_dock
* \brief The dock of the application
*/
QDockWidget* m_dock;
QDockWidget *m_dock;
/**
* \var QTabWidget* m_dockTabWidget
* \brief the tab widget that contains widgets provided by referenced Plugin
*/
QTabWidget* m_dockTabWidget;
QTabWidget *m_dockTabWidget;
SceneHash h_scene;
......@@ -340,8 +362,7 @@ protected:
*/
bool keys[3];
Context* m_context;
Context *m_context;
/**
* \fn void keyPressEvent( QKeyEvent * event )
......@@ -351,7 +372,7 @@ protected:
* button pressure. See the Qt documentation for more details
* ( http://qt-project.org/doc/qt-4.8/qwidget.html#mousePressEvent ).
*/
void keyPressEvent( QKeyEvent * event );
void keyPressEvent(QKeyEvent *event);
/**
* \fn void keyReleaseEvent( QKeyEvent * event )
......@@ -361,7 +382,7 @@ protected:
* button release. See the Qt documentation for more details
* ( http://qt-project.org/doc/qt-4.8/qwidget.html#mouseReleaseEvent ).
*/
void keyReleaseEvent( QKeyEvent * event );
void keyReleaseEvent(QKeyEvent *event);
/**
* \fn void moveView()
......@@ -375,8 +396,6 @@ protected:
*/
void moveView();
public slots:
/**
* \fn void cb_about_CGoGN();
......
......@@ -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);