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

SCHNApps, on continue..

parent 2d79bd26
......@@ -25,14 +25,14 @@ public:
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()
{
......@@ -40,8 +40,8 @@ public:
}
protected:
CGoGN::GenericMap *m_map;
QList<VBOHandler *> l_vbo;
CGoGN::GenericMap* m_map;
QList<VBOHandler*> l_vbo;
};
#endif
......@@ -8,11 +8,11 @@
#include "window.h"
#include "system.h"
#include "scene.h"
#include "view.h"
#include "camera.h"
#include "mapHandler.h"
#include "vboHandler.h"
#include "scene.h"
class Plugin
{
......@@ -20,15 +20,28 @@ public:
enum { UNLIMITED_NUMBER_OF_MAPS = -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_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_keyRelease(Scene* scene, int event) = 0;
......@@ -38,34 +51,66 @@ public:
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 void cb_recievedMap(MapHandler* map) = 0;
virtual void cb_removingMap(MapHandler* map) = 0;
virtual bool isWaitingForScene() = 0;
virtual void recieveScene(Scene* scene) = 0;
virtual void deleteLinkWithScene(Scene* scene) = 0;
virtual bool hasManualLinkWithScene(Scene* scene) = 0;
const QString& getName() { return m_name; }
void setName(QString name) { m_name = name; }
const QString& getPluginFilePath() { return m_pluginPathFile; }
void setPluginFilePath(QString path) { m_pluginPathFile = path; }
virtual void cb_mapAdded(MapHandler* map) = 0;
virtual void cb_mapRemoved(MapHandler* map) = 0;
virtual void cb_sceneAdded(Scene* s) = 0;
virtual void cb_sceneRemoved(Scene* s) = 0;
/*********************************************************
* MANAGE MAPS
*********************************************************/
bool addMap(MapHandler* map);
void removeMap(MapHandler* map);
bool hasMap(MapHandler* map);
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; }
void setWindow(Window* window) { m_window = window; }
protected:
QString m_name;
QString m_filePath;
Window* m_window;
virtual bool activate(bool initializing)
{
m_windowInitializing = initializing;
bool r = activate();
m_windowInitializing = false;
return r;
}
int m_maxNumberOfMaps;
QList<MapHandler*> l_maps;
QList<Scene*> l_scenes;
QList<QWidget*> l_tabWidgets;
QList<QAction*> l_menuActions;
QList<QAction*> l_toolbarActions;
// QList<ViewButton*> l_viewButtons;
virtual void activate() = 0;
virtual void disable() = 0;
// QList<Plugin*> l_dependencies;
// QList<Plugin*> l_dependantPlugins;
/*
void addDependantPlugin(Plugin* p) { l_dependantPlugins.push_back(p); }
void removeDependantPlugin(Plugin* p) { l_dependantPlugins.removeAll(p); }
void removeAllDependantPlugins() { l_dependantPlugins.clear(); }
......@@ -127,49 +172,7 @@ public:
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")
......
......@@ -14,42 +14,41 @@
class Plugin;
class Window;
class PluginDialog : public QDialog, public Ui::Dialog{
class PluginDialog : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
PluginDialog(Window* parent=0, PluginHash* activePlugins=NULL);
PluginDialog(Window* parent = 0, PluginHash* activePlugins = NULL);
~PluginDialog();
protected:
// QDomDocument doc;
// QFile xmlFile;
// QTextStream out;
PluginHash* activePlugins;
Window* parentWindow;
PluginHash* activePlugins;
bool loadInfoPlugins();
// void showPlugins();
bool restoreState();
private:
bool init;
enum EntryType{DIR=1,FILE, FILE_DIR};
void showPluginsDir(QDir directory);
enum EntryType
{
DIR = 1,
FILE,
FILE_DIR
};
protected slots:
void cb_addPlugins();
void cb_removePlugins();
void cb_addPluginDirectory();
void cb_activePlugin(QTreeWidgetItem* item, int column);
void cb_addPluginsDirectory();
void cb_acceptDialog();
void cb_togglePlugin(QTreeWidgetItem* item, int column);
void customContextMenu(const QPoint & pos);
void cb_acceptDialog();
void showPluginInfo();
};
......
......@@ -25,14 +25,21 @@ class Scene : public QObject
Q_OBJECT
public:
Scene(QString name, Window* window, Camera* sharedCamera = NULL);
Scene(QString name, Plugin* plugin, Window* window);
Scene(const QString& name, Window* window);
~Scene();
void initializeGL();
void updateGL(View* view = NULL);
void draw(View* view);
void init();
const QString& getName() { return m_name; }
void setName(const QString& name) { m_name = name; }
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 keyReleaseEvent(QKeyEvent *e);
......@@ -41,29 +48,33 @@ public:
bool mouseMoveEvent(QMouseEvent* 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);
QList<View*> views() { return l_view; }
int countViews() { return l_view.size(); }
View* addNewView(Camera* c);
void deleteView(View* view);
QList<View*> getViews() { return l_views; }
int getNbViews() { return l_views.size(); }
void viewClickedButton(View* view, ViewButton* viewButton);
void associateNewPlugin(Plugin* plugin, bool callBackInitGL = true);
void suppressLinkWith(Plugin* plugin);
void linkWithPlugin();
void unlinkPlugin();
bool isManual() { return (m_creator == NULL); }
Plugin* creator() { return m_creator; }
QList<Plugin*> linkedPlugins() { return l_plugin; }
bool isLinked() { return !l_plugin.isEmpty(); }
bool isLinkedWith(Plugin* plugin) { return l_plugin.contains(plugin); }
/*********************************************************
* MANAGE PLUGINS
*********************************************************/
void addPlugin(Plugin* plugin, bool callBackInitGL = true);
void removePlugin(Plugin* plugin);
QList<Plugin*> getPlugins() { return l_plugins; }
bool hasPlugins() { return !l_plugins.isEmpty(); }
bool hasPlugin(Plugin* plugin) { return l_plugins.contains(plugin); }
// void linkWithPlugin();
// void unlinkPlugin();
/*********************************************************
* MANAGE VIEW BUTTONS
*********************************************************/
bool addViewButton(ViewButton* viewButton);
ViewButton* removeViewButton(ViewButton* viewButton);
// VBOHandler* addNewVBO(QString name);
// void addVBO(VBOHandler* vbo);
......@@ -74,25 +85,15 @@ public:
void firstViewFitSphere(float x, float y, float z, float radius);
bool addCustomViewButton(ViewButton* viewButton);
ViewButton* takeCustomViewButton(ViewButton* viewButton);
protected:
Window* m_window;
QList<View*> l_view;
QString m_name;
QList<Plugin*> l_plugin;
Plugin* m_creator;
// QList<VBOHandler*> l_vbo;
Window* m_window;
Context* m_context;
QList<ViewButton*> l_viewButton;
QList<View*> l_views;
QList<Plugin*> l_plugins;
// QList<VBOHandler*> l_vbo;
QList<ViewButton*> l_viewButtons;
signals:
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:
bool setContent(QUrl urlHTMLFile);
};
}
} // namespace Dialog
class Error
{
......@@ -119,13 +119,14 @@ public:
typedef enum
{
GLVIEWER_IN_DOCK, SIMPLE_GLVIEWER
GLVIEWER_IN_DOCK,
SIMPLE_GLVIEWER
} QGLV_CREATE_SETTINGS;
extern QString app_path;
extern QSplashScreen *splash;
}
} // namespace System
#endif
......@@ -9,38 +9,24 @@
class Plugin;
class Scene;
namespace CGoGN { class GenericMap; }
#define PluginHash QHash<QString, Plugin*>
#define SceneHash QHash<QString, Scene*>
/**
* \def MapHash
*
* 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*>
class MapHandler;
namespace CGoGN
{
namespace Utils
{
class VBO;
class GLSLShader;
}
}
#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;
}
......
......@@ -22,11 +22,10 @@ class View : public QGLViewer
Q_OBJECT
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();
virtual void updateGL();
void simpleUpdate();
virtual void draw();
virtual void init();
......@@ -50,8 +49,8 @@ public:
Scene* getScene() { return m_scene; }
void setName(QString name) { m_name = name; }
QString getName() { return m_name; }
void setName(const QString& name) { m_name = name; }
const QString& getName() { return m_name; }
void enableLinking(bool b = true);
void enableUnlinking(bool b = true);
......@@ -88,9 +87,8 @@ public:
void setShowButtons(bool b) { b_showButtons = b; }
protected:
Scene* m_scene;
QString m_name;
Scene* m_scene;
QList<Camera*> l_camera;
Camera* m_currentCamera;
......
#ifndef _VISUALPLUGIN_H_
#define _VISUALPLUGIN_H_
#include "plugin.h"
class VisualPlugin : public QObject, public Plugin
{
Q_OBJECT
public:
VisualPlugin();
~VisualPlugin();
virtual void cb_updateMatrix(View* view);
virtual void cb_redraw(Scene* scene) = 0;
virtual void cb_initGL(Scene* scene) = 0;
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; }
virtual void cb_recievedMap(MapHandler* map) {}
virtual void cb_removingMap(MapHandler* map) {}
bool isWaitingForScene() { return (m_waitedScene > 0 || m_waitedScene == UNLIMITED_NUMBER_OF_SCENES); }
void recieveScene(Scene* scene);
void deleteLinkWithScene(Scene* scene);
bool hasManualLinkWithScene(Scene* scene) { return l_recievedScene.contains(scene); }
protected:
std::list<Scene*> l_scene;
bool associateScene(QString glv_name, Scene* &scene, bool cb_initGL=false);
bool addNewScene(QString glv_name, Scene* &scene);
bool addNewSceneDialog(QString name, Scene* &scene);
bool addWidgetInDockTab(QWidget* newTabWidget, QString tabText);
void removeTabInDock(QWidget* tabWidget);
bool addReferencedMap(QString map_name, MapHandler* map);
template<typename T>
MapHandler* addNewReferencedMap(QString map_name, T* &map){
if(m_window){
MapHandler* vh= m_window->addNewReferencedMap<T>(map_name, map);
if(vh) l_map.push_back(vh);
return vh;
}
else{
System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name);
return NULL;
}
}
MapHandler* getReferencedMap(QString map_name);
QList<QAction*> l_action;
QList<QWidget*> l_customWidget;
QAction* addMenuAction(QString menuPath, const char* method);
bool addMenuAction(QString menuPath, QAction* action);
void deleteActions();
QAction* addToolbarAction(const char* method, QIcon icon= QIcon());
bool addToolbarAction(QAction* action);
int m_waitedScene;
QList<Scene*> l_recievedScene;
bool m_allowSameViewSeveralTime;
void allowSamerViewSeveralTime(bool b){m_allowSameViewSeveralTime=b;};
void waitingForScene(int nb=UNLIMITED_NUMBER_OF_SCENES);
ViewButton* addSceneNewViewButton(Scene* scene, QString imagePath);
bool addSceneViewButton(Scene* scene, ViewButton* viewButton);
void takeSceneViewButton(Scene* scene, ViewButton* viewButton);
QList<ViewButton*> l_viewButtons;
signals:
void recievedScene(Scene*);
};