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,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
......@@ -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)
......@@ -92,56 +100,53 @@ public:
*
* \param menuPath the menu path (see details below) to specify a location for the action in the menu.
* \param act a pointer to the allocated action to add in the menu. All the details ont that action (such as
* QObject::connect() calls) are not dealt in this function.
* QObject::connect() calls) are not dealt in this function.
*
* The menu path is a string used to specify the location of the new action in the menu bar.
* In such path every menu step of the path should be separate by ';'. The action is the last substring after
* the last ';', and will be added in the menu with that name. All non-existing menu specified in the path
* shall be created.
* The menu path is a string used to specify the location of the new action in the menu bar.
* In such path every menu step of the path should be separate by ';'. The action is the last substring after
* the last ';', and will be added in the menu with that name. All non-existing menu specified in the path
* shall be created.
*
* <b>Example 1:</b> if you want to add an entry <em>"action"</em> to the existing menu <em>"Plugins"</em> the
* menu path shall be: <em>Plugins;action</em>
* <b>Example 1:</b> if you want to add an entry <em>"action"</em> to the existing menu <em>"Plugins"</em> the
* menu path shall be: <em>Plugins;action</em>
*
* <b>Example 2:</b> if you want to add an entry <em>"action"</em> in a new menu <em>"config"</em> that is also a
* submenu of a new menu <em>"Settings"</em>, the menu path
* shall be: <em>Settings;config;action</em>
* <b>Example 2:</b> if you want to add an entry <em>"action"</em> in a new menu <em>"config"</em> that is also a
* submenu of a new menu <em>"Settings"</em>, the menu path
* shall be: <em>Settings;config;action</em>
*
*
* A new action should at least belong to one menu (already existing or not). Otherwise the method will fail.
* A new action should at least belong to one menu (already existing or not). Otherwise the method will fail.
*
* This method is already called by reimplemented Plugin methods, there's apparently no reason for calling it.
* This method is already called by reimplemented Plugin methods, there's apparently no reason for calling it.
*
* \return a boolean whether the method succeeded or not.
* \return a boolean whether the method succeeded or not.
*
* If the function failed, the error code ( Error::code ) is affected with a value
depending on the error. This error can be shown with Error::showError
depending on the error. This error can be shown with Error::showError
*
* \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
*
* \param act pointer to the allocated action to delete.
*
* If this action was the only action remaining in a menu, this menu will also be deleted.
* If this action was the only action remaining in a menu, this menu will also be deleted.
*
* \warning DO NOT use this method with an action that hasn't been added with addMenuAction()
* \warning DO NOT use this method with an action that hasn't been added with addMenuAction()
*
* This method is already called by reimplemented Plugin methods, there's apparently no reason for calling it.
* This method is already called by reimplemented Plugin methods, there's apparently no reason for calling it.
*
* \see addMenuAction()
* \see VisualPlugin::deleteMenuActions()
* \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)
......@@ -150,9 +155,9 @@ public:
* \param pluginPath the absolute path of the Plugin location
*
* The Plugin is loaded and referenced under a name that is the Plugin file name
where the extension '.so' and the prefix 'lib' were removed.
where the extension '.so' and the prefix 'lib' were removed.
*
* <b>Example:</b> <em>/path/libExample.so</em> will be referenced as <em>Example</em>
* <b>Example:</b> <em>/path/libExample.so</em> will be referenced as <em>Example</em>
*
* You have to make sure that a Plugin file with a similar name hasn't been loaded yet, otherwise
* the loading will fail.
......@@ -162,16 +167,16 @@ public:
*
*  \warning In the program this method is called under specific and controlled circumstances, you should probably not call it.
*
* \return a boolean whether the loading succeeded or not.
* \return a boolean whether the loading succeeded or not.
*
* If the function failed, the error code ( Error::code ) is affected with a value
depending on the error. This error can be shown with Error::showError
depending on the error. This error can be shown with Error::showError
*
* \see unloadPlugin()
* \see getPlugin()
* \see Plugin::activate()
*/
Plugin* loadPlugin(QString pluginPath);
Plugin *loadPlugin(QString pluginPath);
/**
* \fn void unloadPlugin(QString pluginName)
......@@ -192,35 +197,39 @@ 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
*
* \param name the name of the Plugin you have to check the existence in order to make a dependencie
* \param dependantPlugin a reference to the Plugin that asks for the dependencie that will be set as a
* dependant Plugin for the found Plugin
* dependant Plugin for the found Plugin
*
* \warning In the program this method is called under specific and controlled circumstances
* by the Plugins you should probably not call it.
* by the Plugins you should probably not call it.
*
* \return a pointer to the found dependencie Plugin, NULL if this Plugin wasn't referenced
*
* If the function failed, the error code ( Error::code ) is affected with a value
depending on the error. This error can be shown with Error::showError
depending on the error. This error can be shown with Error::showError
*
* \see loadPlugin()
* \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,38 +239,42 @@ 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.
* map type, that is to say an instance of a class that inherits CGoGN::GenericMap.
*
* \param[in] map_name The name under which will be referenced the map
* \param[out] map A pointer to a type T map, which will be set to the adress of the newly created map, or
* to the already existing map refererence by the same name
* to the already existing map refererence by the same name
*
* \return true if the map is created, false if creation fails (returns false if a same named map already exists)
*
* \see getReferencedMap()
*/
template<typename T>
MapHandler* addNewReferencedMap(QString map_name, T* &map){
MapHandler *addNewReferencedMap(QString map_name, T *&map)