Commit 4a3261fe authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps, on continue..

parent 2d79bd26
...@@ -25,14 +25,14 @@ public: ...@@ -25,14 +25,14 @@ public:
return m_map; return m_map;
} }
VBOHandler *findVBO(QString name); VBOHandler* findVBO(QString name);
VBOHandler *findFirstVBOMatching(QRegExp regexp); VBOHandler* findFirstVBOMatching(QRegExp regexp);
QList<VBOHandler *> findVBOsMatching(QRegExp regexp); QList<VBOHandler*> findVBOsMatching(QRegExp regexp);
bool addVBO(VBOHandler *vboH); bool addVBO(VBOHandler* vboH);
VBOHandler *addNewVBO(QString vboName); VBOHandler* addNewVBO(QString vboName);
VBOHandler *takeVBO(VBOHandler *vbo); VBOHandler* takeVBO(VBOHandler* vbo);
int countVBO() int countVBO()
{ {
...@@ -40,8 +40,8 @@ public: ...@@ -40,8 +40,8 @@ public:
} }
protected: protected:
CGoGN::GenericMap *m_map; CGoGN::GenericMap* m_map;
QList<VBOHandler *> l_vbo; QList<VBOHandler*> l_vbo;
}; };
#endif #endif
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include "window.h" #include "window.h"
#include "system.h" #include "system.h"
#include "scene.h"
#include "view.h" #include "view.h"
#include "camera.h" #include "camera.h"
#include "mapHandler.h" #include "mapHandler.h"
#include "vboHandler.h" #include "vboHandler.h"
#include "scene.h"
class Plugin class Plugin
{ {
...@@ -20,15 +20,28 @@ public: ...@@ -20,15 +20,28 @@ public:
enum { UNLIMITED_NUMBER_OF_MAPS = -1 }; enum { UNLIMITED_NUMBER_OF_MAPS = -1 };
enum { UNLIMITED_NUMBER_OF_SCENES = -1 }; enum { UNLIMITED_NUMBER_OF_SCENES = -1 };
virtual ~Plugin() 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(View* view) = 0; virtual void cb_updateMatrix(View* view) = 0;
virtual void cb_redraw(Scene* scene) = 0; virtual void cb_redraw(Scene* scene) = 0;
virtual void cb_initGL(Scene* scene) = 0;
void updateGL() = 0;
void updateGL(Scene* scene) = 0;
virtual bool cb_keyPress(Scene* scene, int event) = 0; virtual bool cb_keyPress(Scene* scene, int event) = 0;
virtual bool cb_keyRelease(Scene* scene, int event) = 0; virtual bool cb_keyRelease(Scene* scene, int event) = 0;
...@@ -38,34 +51,66 @@ public: ...@@ -38,34 +51,66 @@ public:
virtual bool cb_mouseMove(Scene* scene, int buttons, int x, int y) = 0; virtual bool cb_mouseMove(Scene* scene, int buttons, int x, int y) = 0;
virtual bool cb_wheelEvent(Scene* scene, int delta, int x, int y) = 0; virtual bool cb_wheelEvent(Scene* scene, int delta, int x, int y) = 0;
virtual void cb_recievedMap(MapHandler* map) = 0; virtual void cb_mapAdded(MapHandler* map) = 0;
virtual void cb_removingMap(MapHandler* map) = 0; virtual void cb_mapRemoved(MapHandler* map) = 0;
virtual bool isWaitingForScene() = 0; virtual void cb_sceneAdded(Scene* s) = 0;
virtual void recieveScene(Scene* scene) = 0; virtual void cb_sceneRemoved(Scene* s) = 0;
virtual void deleteLinkWithScene(Scene* scene) = 0;
virtual bool hasManualLinkWithScene(Scene* scene) = 0; /*********************************************************
* MANAGE MAPS
const QString& getName() { return m_name; } *********************************************************/
void setName(QString name) { m_name = name; } bool addMap(MapHandler* map);
void removeMap(MapHandler* map);
const QString& getPluginFilePath() { return m_pluginPathFile; } bool hasMap(MapHandler* map);
void setPluginFilePath(QString path) { m_pluginPathFile = path; } QList<MapHandler*> getMaps();
void setMaxNumberOfMaps(int n);
int getCurrentNumberOfMaps();
int getRemainingNumberOfMaps();
/*********************************************************
* MANAGE SCENES
*********************************************************/
bool addScene(Scene* scene);
void removeScene(Scene* scene);
bool hasScene(Scene* scene);
QList<Scene*> getScenes();
/*********************************************************
* MANAGE DOCK TABS
*********************************************************/
bool addTabInDock(QWidget* tabWidget, const QString& tabText);
void removeTabInDock(QWidget* tabWidget);
/*********************************************************
* MANAGE MENU ACTIONS
*********************************************************/
bool addMenuAction(const QString& menuPath, QAction* action);
void removeMenuAction(QAction* action);
/*********************************************************
* MANAGE TOOLBAR ACTIONS
*********************************************************/
bool addToolbarAction(QAction* action);
void removeToolbarAction(QAction* action);
Window* getWindow() { return m_window; } protected:
void setWindow(Window* window) { m_window = window; } QString m_name;
QString m_filePath;
Window* m_window;
virtual bool activate(bool initializing) int m_maxNumberOfMaps;
{ QList<MapHandler*> l_maps;
m_windowInitializing = initializing; QList<Scene*> l_scenes;
bool r = activate(); QList<QWidget*> l_tabWidgets;
m_windowInitializing = false; QList<QAction*> l_menuActions;
return r; QList<QAction*> l_toolbarActions;
} // QList<ViewButton*> l_viewButtons;
virtual void activate() = 0; // QList<Plugin*> l_dependencies;
virtual void disable() = 0; // QList<Plugin*> l_dependantPlugins;
/*
void addDependantPlugin(Plugin* p) { l_dependantPlugins.push_back(p); } void addDependantPlugin(Plugin* p) { l_dependantPlugins.push_back(p); }
void removeDependantPlugin(Plugin* p) { l_dependantPlugins.removeAll(p); } void removeDependantPlugin(Plugin* p) { l_dependantPlugins.removeAll(p); }
void removeAllDependantPlugins() { l_dependantPlugins.clear(); } void removeAllDependantPlugins() { l_dependantPlugins.clear(); }
...@@ -127,49 +172,7 @@ public: ...@@ -127,49 +172,7 @@ public:
m_window->unloadPlugin(l_dependantPlugins.back()->getName()); m_window->unloadPlugin(l_dependantPlugins.back()->getName());
} }
} }
*/
bool addMap(MapHandler* map)
{
if((m_mapNumber == UNLIMITED_NUMBER_OF_MAPS || l_map.size() < m_mapNumber) && map && !l_map.contains(map))
{
l_map.push_back(map);
cb_recievedMap(map);
return true;
}
else
return false;
}
MapHandler* takeMap(MapHandler* map)
{
int i = l_map.indexOf(map);
if(i >= 0)
{
cb_removingMap(map);
return l_map.takeAt(i);
}
else
return NULL;
}
QList<MapHandler*> workingMaps() { return l_map; }
void setMapNumber(int n)
{
if(n >= l_map.size() || n == UNLIMITED_NUMBER_OF_MAPS)
m_mapNumber = n;
}
virtual int remainingMapNumber()
{
return m_mapNumber != UNLIMITED_NUMBER_OF_MAPS ? m_mapNumber - l_map.size() : m_mapNumber;
}
protected:
Window* m_window;
QString m_name;
QString m_pluginPathFile;
QList<Plugin*> l_dependencies;
QList<Plugin*> l_dependantPlugins;
bool m_windowInitializing;
int m_mapNumber;
QList<MapHandler*> l_map;
}; };
Q_DECLARE_INTERFACE(Plugin, "Window.Plugin") Q_DECLARE_INTERFACE(Plugin, "Window.Plugin")
......
...@@ -14,42 +14,41 @@ ...@@ -14,42 +14,41 @@
class Plugin; class Plugin;
class Window; class Window;
class PluginDialog : public QDialog, public Ui::Dialog{ class PluginDialog : public QDialog, public Ui::Dialog
{
Q_OBJECT Q_OBJECT
public: public:
PluginDialog(Window* parent=0, PluginHash* activePlugins=NULL); PluginDialog(Window* parent = 0, PluginHash* activePlugins = NULL);
~PluginDialog(); ~PluginDialog();
protected: protected:
// QDomDocument doc;
// QFile xmlFile;
// QTextStream out;
PluginHash* activePlugins;
Window* parentWindow; Window* parentWindow;
PluginHash* activePlugins;
bool loadInfoPlugins(); bool restoreState();
// void showPlugins();
private: private:
bool init; bool init;
enum EntryType{DIR=1,FILE, FILE_DIR}; enum EntryType
{
DIR = 1,
void showPluginsDir(QDir directory); FILE,
FILE_DIR
};
protected slots: protected slots:
void cb_addPlugins(); void cb_addPlugins();
void cb_removePlugins(); void cb_removePlugins();
void cb_addPluginDirectory(); void cb_addPluginsDirectory();
void cb_activePlugin(QTreeWidgetItem* item, int column);
void cb_acceptDialog(); void cb_togglePlugin(QTreeWidgetItem* item, int column);
void customContextMenu(const QPoint & pos); void customContextMenu(const QPoint & pos);
void cb_acceptDialog();
void showPluginInfo(); void showPluginInfo();
}; };
......
...@@ -25,14 +25,21 @@ class Scene : public QObject ...@@ -25,14 +25,21 @@ class Scene : public QObject
Q_OBJECT Q_OBJECT
public: public:
Scene(QString name, Window* window, Camera* sharedCamera = NULL); Scene(const QString& name, Window* window);
Scene(QString name, Plugin* plugin, Window* window);
~Scene(); ~Scene();
void initializeGL(); const QString& getName() { return m_name; }
void updateGL(View* view = NULL); void setName(const QString& name) { m_name = name; }
void draw(View* view);
void init(); Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; }
Context* getContext() { return m_context; }
void setContext(Context* c) { m_context = c; }
void initGL();
void updateGL();
void draw(View *v);
bool keyPressEvent(QKeyEvent* event); bool keyPressEvent(QKeyEvent* event);
bool keyReleaseEvent(QKeyEvent *e); bool keyReleaseEvent(QKeyEvent *e);
...@@ -41,29 +48,33 @@ public: ...@@ -41,29 +48,33 @@ public:
bool mouseMoveEvent(QMouseEvent* event); bool mouseMoveEvent(QMouseEvent* event);
bool wheelEvent(QWheelEvent* event); bool wheelEvent(QWheelEvent* event);
QString getName() { return m_name; } /*********************************************************
void setName(QString name) { m_name = name; } * MANAGE VIEWS
*********************************************************/
View* addView(Camera* c = NULL);
void removeView(View* view);
View* getView(int num); View* getView(int num);
QList<View*> views() { return l_view; } QList<View*> getViews() { return l_views; }
int countViews() { return l_view.size(); } int getNbViews() { return l_views.size(); }
View* addNewView(Camera* c);
void deleteView(View* view);
void viewClickedButton(View* view, ViewButton* viewButton); void viewClickedButton(View* view, ViewButton* viewButton);
void associateNewPlugin(Plugin* plugin, bool callBackInitGL = true); /*********************************************************
void suppressLinkWith(Plugin* plugin); * MANAGE PLUGINS
void linkWithPlugin(); *********************************************************/
void unlinkPlugin(); void addPlugin(Plugin* plugin, bool callBackInitGL = true);
void removePlugin(Plugin* plugin);
bool isManual() { return (m_creator == NULL); } QList<Plugin*> getPlugins() { return l_plugins; }
Plugin* creator() { return m_creator; } bool hasPlugins() { return !l_plugins.isEmpty(); }
bool hasPlugin(Plugin* plugin) { return l_plugins.contains(plugin); }
QList<Plugin*> linkedPlugins() { return l_plugin; } // void linkWithPlugin();
// void unlinkPlugin();
bool isLinked() { return !l_plugin.isEmpty(); }
bool isLinkedWith(Plugin* plugin) { return l_plugin.contains(plugin); } /*********************************************************
* MANAGE VIEW BUTTONS
*********************************************************/
bool addViewButton(ViewButton* viewButton);
ViewButton* removeViewButton(ViewButton* viewButton);
// VBOHandler* addNewVBO(QString name); // VBOHandler* addNewVBO(QString name);
// void addVBO(VBOHandler* vbo); // void addVBO(VBOHandler* vbo);
...@@ -74,25 +85,15 @@ public: ...@@ -74,25 +85,15 @@ public:
void firstViewFitSphere(float x, float y, float z, float radius); void firstViewFitSphere(float x, float y, float z, float radius);
bool addCustomViewButton(ViewButton* viewButton);
ViewButton* takeCustomViewButton(ViewButton* viewButton);
protected: protected:
Window* m_window;
QList<View*> l_view;
QString m_name; QString m_name;
Window* m_window;
QList<Plugin*> l_plugin;
Plugin* m_creator;
// QList<VBOHandler*> l_vbo;
Context* m_context; Context* m_context;
QList<ViewButton*> l_viewButton; QList<View*> l_views;
QList<Plugin*> l_plugins;
// QList<VBOHandler*> l_vbo;
QList<ViewButton*> l_viewButtons;
signals: signals:
void viewButtonClicked(View*, ViewButton*); void viewButtonClicked(View*, ViewButton*);
......
#ifndef _SIMPLEPLUGIN_H_
#define _SIMPLEPLUGIN_H_
#include "plugin.h"
class SimplePlugin : public QObject, public Plugin
{
Q_OBJECT
public:
SimplePlugin();
~SimplePlugin();
void cb_updateMatrix(View* view) {}
void cb_redraw(Scene* scene) {}
void cb_initGL(Scene* scene) {}
void updateGL() {}
void updateGL(Scene* scene) {}
bool cb_keyPress(Scene* scene, int event) { return false; }
bool cb_keyRelease(Scene* scene, int event) { return false; }
bool cb_mousePress(Scene* scene, int button, int x, int y) { return false; }
bool cb_mouseRelease(Scene* scene, int button, int x, int y) { return false; }
bool cb_mouseClick(Scene* scene, int button, int x, int y) { return false; }
bool cb_mouseMove(Scene* scene, int buttons, int x, int y) { return false; }
bool cb_wheelEvent(Scene* scene, int delta, int x, int y) { return false; }
void cb_recievedMap(MapHandler* map) {}
void cb_removingMap(MapHandler* map) {}
bool isWaitingForScene() { return false; }
void recieveScene(Scene* scene) {}
void deleteLinkWithScene(Scene* scene);
bool hasManualLinkWithScene(Scene* scene) { return false; }
protected:
template<typename T>
T* getDependencie(QString dependencie){ return( (T*)(this->addDependencie(dependencie)) ); }
bool addWidgetInDockTab(QWidget* newTabWidget, QString tabText);
void removeTabInDock(QWidget* tabWidget);
bool addReferencedMap(QString map_name, CGoGN::GenericMap* map);
template<typename T>
bool addNewReferencedMap(QString map_name, T* &map){
if(m_window){
bool r= m_window->addNewReferencedMap<T>(map_name, map);
if(r) l_map.push_back(map);
return r;
}
else{
System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name);
return false;
}
}
template<typename T>
T* getReferencedMap(QString map_name){
if(m_window){
return m_window->getReferencedMap<T>(map_name);
}
else{
System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name);
return NULL;
}
}
QList<QAction*> l_action;
QAction* addMenuAction(QString menuPath, const char* method);
void deleteMenuActions();
};
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
bool setContent(QUrl urlHTMLFile); bool setContent(QUrl urlHTMLFile);
}; };
} } // namespace Dialog
class Error class Error
{ {
...@@ -119,13 +119,14 @@ public: ...@@ -119,13 +119,14 @@ public:
typedef enum typedef enum
{ {
GLVIEWER_IN_DOCK, SIMPLE_GLVIEWER GLVIEWER_IN_DOCK,
SIMPLE_GLVIEWER
} QGLV_CREATE_SETTINGS; } QGLV_CREATE_SETTINGS;
extern QString app_path; extern QString app_path;
extern QSplashScreen *splash; extern QSplashScreen *splash;
} } // namespace System
#endif #endif
...@@ -9,38 +9,24 @@ ...@@ -9,38 +9,24 @@
class Plugin; class Plugin;
class Scene; class Scene;
namespace CGoGN { class GenericMap; } class MapHandler;
namespace CGoGN
#define PluginHash QHash<QString, Plugin*> {
#define SceneHash QHash<QString, Scene*> namespace Utils
{
/** class VBO;
* \def MapHash class GLSLShader;
* }
* Preprocessor macro for simplifying the type "QHash<QString, GenericMap*>" into GLViewerHash, within the code }
*
*/
//#define MapHash QHash<QString,CGoGN::GenericMap*>
/**
* \def VBOHash
* \brief Preprocessor macro for simplifying the type "QHash<QString, Utils::VBO*>" into GLViewerHash, within the code
*/
#define VBOHash QHash<QString, CGoGN::Utils::VBO*>
/**
* \def ShaderHash
* \brief Preprocessor macro for simplifying the type "QHash<QString, Utils::GLSLShader*>" into GLViewerHash, within the code
*/
#define ShaderHash QHash<QString, CGoGN::Utils::GLSLShader*>
/**
* \def ShaderHash
* \brief Preprocessor macro for simplifying the type "QHash<QString, Algo::Render::GL2::Topo3Render*>" into GLViewerHash, within the code
*/
#define Topo3RenderHash QHash<QString, Algo::Render::GL2::Topo3Render*>
#define MapHash QHash<QString, MapHandler*> typedef QHash<QString, Plugin*> PluginHash;
typedef QHash<QString, Scene*> SceneHash;
typedef QHash<QString, MapHandler*> MapHash;
typedef QHash<QString, CGoGN::Utils::VBO*> VBOHash;
typedef QHash<QString, CGoGN::Utils::GLSLShader*> ShaderHash;
namespace Qt{ namespace Qt
{
extern int UserRoleType; extern int UserRoleType;
} }
......
...@@ -22,11 +22,10 @@ class View : public QGLViewer ...@@ -22,11 +22,10 @@ class View : public QGLViewer
Q_OBJECT Q_OBJECT
public: public:
View(Scene* s, QString name, Camera* c, QGLWidget* shareWidget = NULL, Context* context = NULL, QWidget* parent = NULL); View(Scene* s, const QString& name, Camera* c, QGLWidget* shareWidget = NULL, Context* context = NULL, QWidget* parent = NULL);
~View(); ~View();
virtual void updateGL(); virtual void updateGL();
void simpleUpdate();
virtual void draw(); virtual void draw();
virtual void init(); virtual void init();
...@@ -50,8 +49,8 @@ public: ...@@ -50,8 +49,8 @@ public:
Scene* getScene() { return m_scene; } Scene* getScene() { return m_scene; }
void setName(QString name) { m_name = name; } void setName(const QString& name) { m_name = name; }
QString getName() { return m_name; } const QString& getName() { return m_name; }
void enableLinking(bool b = true); void enableLinking(bool b = true);
void enableUnlinking(bool b = true); void enableUnlinking(bool b = true);
...@@ -88,9 +87,8 @@ public: ...@@ -88,9 +87,8 @@ public:
void setShowButtons(bool b) { b_showButtons = b; } void setShowButtons(bool b) { b_showButtons = b; }
protected: protected:
Scene* m_scene;
QString m_name; QString m_name;
Scene* m_scene;
QList<Camera*> l_camera; QList<Camera*> l_camera;
Camera* m_currentCamera; Camera* m_currentCamera;
......