Commit 66f66943 authored by Thery Sylvain's avatar Thery Sylvain

Merge branch 'master' of cgogn.u-strasbg.fr:~kraemer/CGoGN

parents b73847af 2d79bd26
#ifndef _CAMERA_H_
#define _CAMERA_H_
#include "visualization/view.h"
#include "view.h"
//forward declaration
......@@ -12,32 +12,32 @@ public:
Camera(View* v, Camera c);
~Camera();
bool isShared(){return (l_views.size()>1);}
bool isShared() { return l_views.size() > 1; }
QString getName(){return m_name;}
void setName(QString name){m_name= name;}
QString getName() { return m_name; }
void setName(QString name) { m_name = name; }
void draw();
void enableDraw(bool b=true){m_draw=b;}
bool isDrawn(){return m_draw;}
void enableDrawFarPlan(bool b=true){m_drawFarPlane=b;}
bool isFarPlaneDrawn(){return m_drawFarPlane;}
void setDrawScale(double s){m_drawScale=s;}
double getDrawScale(){return m_drawScale;}
bool isPathDrawn(){return m_drawUserPath;}
void enablePathDraw(bool b=true){m_drawUserPath=b;}
bool isPathAxisDrawn(){return m_drawUserPathAxis;}
void enablePathAxisDrawn(bool b=true){m_drawUserPathAxis=b;}
void setPathDrawScale(double s){m_drawUserPathScale= s;}
double getPathDrawScale(){return m_drawUserPathScale;}
bool getDraw() { return m_draw; }
bool getDrawFarPlane() { return m_drawFarPlane; }
double getDrawScale() { return m_drawScale; }
bool getDrawPath() { return m_drawPath; }
bool getDrawPathAxis() { return m_drawPathAxis; }
double getDrawPathScale() { return m_drawPathScale; }
void setDraw(bool b = true) { m_draw = b; }
void setDrawFarPlane(bool b = true) { m_drawFarPlane = b; }
void setDrawScale(double s) { m_drawScale = s; }
void setDrawPath(bool b = true) { m_drawPath = b; }
void setDrawPathAxis(bool b = true) { m_drawPathAxis = b; }
void setDrawPathScale(double s) { m_drawPathScale = s;}
void takenFrom(View* v);
void sharedWith(View* v);
void fitParamWith(View* v);
void resetSnapCount(){m_snapCount=0;}
void resetSnapCount() { m_snapCount = 0; }
void saveSnapshot(QString snapPathName);
void updateGL();
......@@ -53,9 +53,9 @@ protected:
bool m_drawFarPlane;
double m_drawScale;
bool m_drawUserPath;
bool m_drawUserPathAxis;
double m_drawUserPathScale;
bool m_drawPath;
bool m_drawPathAxis;
double m_drawPathScale;
View* m_lastWorkingView;
......
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
#include <QtPlugin>
#include <iostream>
#include <list>
#include "window.h"
#include "system.h"
#include "view.h"
#include "camera.h"
#include "mapHandler.h"
#include "vboHandler.h"
#include "scene.h"
class Plugin
{
public:
enum { UNLIMITED_NUMBER_OF_MAPS = -1 };
enum { UNLIMITED_NUMBER_OF_SCENES = -1 };
virtual ~Plugin()
{}
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;
virtual bool cb_mousePress(Scene* scene, int button, int x, int y) = 0;
virtual bool cb_mouseRelease(Scene* scene, int button, int x, int y) = 0;
virtual bool cb_mouseClick(Scene* scene, int button, 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 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; }
Window* getWindow() { return m_window; }
void setWindow(Window* window) { m_window = window; }
virtual bool activate(bool initializing)
{
m_windowInitializing = initializing;
bool r = activate();
m_windowInitializing = false;
return r;
}
virtual void activate() = 0;
virtual void disable() = 0;
void addDependantPlugin(Plugin* p) { l_dependantPlugins.push_back(p); }
void removeDependantPlugin(Plugin* p) { l_dependantPlugins.removeAll(p); }
void removeAllDependantPlugins() { l_dependantPlugins.clear(); }
bool hasDependantPlugins() { return !l_dependantPlugins.isEmpty(); }
QStringList getDependantPluginNames()
{
QStringList l;
for(QList<Plugin*>::iterator it = l_dependantPlugins.begin(); it != l_dependantPlugins.end(); ++it)
l.push_back((*it)->getName());
return l;
}
Plugin* addDependency(QString dependency)
{
Plugin* plugin;
if((plugin = m_window->checkPluginDependency(dependency, this)))
{
l_dependencies.push_back(plugin);
return plugin;
}
else
return NULL;
}
template<typename T>
T* getDependency(QString dependency)
{
return (T*)(this->addDependency(dependency));
}
virtual void removeDependencyLink(Plugin* p)
{
p->removeDependantPlugin(this);
l_dependencies.removeAll(p);
}
virtual void removeAllDependencyLinks()
{
foreach(Plugin* p, l_dependencies)
p->removeDependantPlugin(this);
l_dependencies.clear();
}
void removeDependantLink(Plugin* p)
{
int i = l_dependantPlugins.indexOf(p);
if(i >= 0)
p->removeDependencyLink(this);
}
void removeAllDependantLinks()
{
foreach(Plugin* p, l_dependantPlugins)
p->removeDependencyLink(this);
}
virtual void unloadDependantPlugins()
{
while(!l_dependantPlugins.empty())
{
if(l_dependantPlugins.back())
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")
#endif
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
#include <QtPlugin>
#include <iostream>
#include <list>
#include "interface/window.h"
#include "interface/system.h"
#include "visualization/view.h"
#include "visualization/camera.h"
#include "visualization/mapHandler.h"
#include "visualization/vboHandler.h"
#include "visualization/scene.h"
class Plugin
{
public:
enum {UNLIMITED_MAP_NUMBER=-1};
virtual ~Plugin(){}
virtual void cb_updateMatrix(View* view) =0;
virtual void cb_redraw(Scene* scene) =0;
virtual void cb_initGL(Scene* scene) =0;
virtual bool cb_keyPress(Scene* scene, int event) =0;
virtual bool cb_keyRelease(Scene* scene, int event) =0;
virtual bool cb_mousePress(Scene* scene, int button, int x, int y) =0;
virtual bool cb_mouseRelease(Scene* scene, int button, int x, int y) =0;
virtual bool cb_mouseClick(Scene* scene, int button, 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 void cb_recievedMap(MapHandler* map)=0;
virtual void cb_removingMap(MapHandler* map)=0;
virtual QString getName() =0;
virtual QString getPluginFilePath() =0;
virtual bool hasDependantPlugins() =0;
virtual QStringList getDependantPluginNames() =0;
virtual bool isWaitingForScene() =0;
virtual void recieveScene(Scene* scene) =0;
virtual void setWindow(Window* window) =0;
virtual void setName(QString name) =0;
virtual void setPluginFilePath(QString path)= 0;
virtual bool activate(bool initializing= false) =0;
virtual void disable() =0;
virtual void deleteLinkWith(Scene* scene) =0;
virtual void addDependantPlugin(Plugin* dependant) =0;
virtual void deleteDependantLink(Plugin* dependantPlugin) =0;
virtual Plugin* addDependencie(QString dependencie) =0;
virtual void suppressDependencieLink(Plugin* dependencie) =0;
virtual void suppressAllDependencieLinks() =0;
virtual void suppressDependantLink(Plugin* dependant) =0;
virtual void suppressAllDependantLinks() =0;
virtual void unloadDependantPlugins() =0;
virtual bool hasManualLinkWith(Scene* scene)=0;
virtual bool addMap(MapHandler* map)=0;
virtual MapHandler* takeMap(MapHandler* map)=0;
virtual QList<MapHandler*> workingMaps()=0;
virtual void setMapNumber(int n)=0;
virtual int remainingMapNumber()=0;
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")
#endif
......@@ -23,13 +23,14 @@ class ViewButton;
class Scene : public QObject
{
Q_OBJECT
public:
Scene(QString name, Window* window, Camera* sharedCamera=NULL);
Scene(QString name, Window* window, Camera* sharedCamera = NULL);
Scene(QString name, Plugin* plugin, Window* window);
~Scene();
void initializeGL();
void updateGL(View* view=NULL);
void updateGL(View* view = NULL);
void draw(View* view);
void init();
......@@ -40,29 +41,29 @@ public:
bool mouseMoveEvent(QMouseEvent* event);
bool wheelEvent(QWheelEvent* event);
void setName(QString name){m_name=name;}
QString getName(){return m_name;}
QString getName() { return m_name; }
void setName(QString name) { m_name = name; }
View* getView(int num);
QList<View*> views(){return l_view;}
int countViews(){return l_view.size();}
QList<View*> views() { return l_view; }
int countViews() { return l_view.size(); }
View* addNewView(Camera* c);
void deleteView(View* view);
void viewClickedButton(View* view, ViewButton* viewButton);
void associateNewPlugin(Plugin* plugin,bool callBackInitGL=true);
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;}
bool isManual() { return (m_creator == NULL); }
Plugin* creator() { return m_creator; }
QList<Plugin*> linkedPlugins(){return l_plugin;}
QList<Plugin*> linkedPlugins() { return l_plugin; }
bool isLinked(){return !l_plugin.isEmpty();}
bool isLinkedWith(Plugin* plugin){return l_plugin.contains(plugin);}
bool isLinked() { return !l_plugin.isEmpty(); }
bool isLinkedWith(Plugin* plugin) { return l_plugin.contains(plugin); }
// VBOHandler* addNewVBO(QString name);
// void addVBO(VBOHandler* vbo);
......
#ifndef _SIMPLEPLUGIN_H_
#define _SIMPLEPLUGIN_H_
#include "plugins/plugin.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(CGoGN::GenericMap* map){}
void cb_removingMap(CGoGN::GenericMap* map){}
void cb_updateMatrix(View* view) {}
void cb_redraw(Scene* scene) {}
void cb_initGL(Scene* scene) {}
QString getName() {return m_name;}
void updateGL() {}
void updateGL(Scene* scene) {}
QString getPluginFilePath() {return m_pluginPathFile;}
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 addDependantPlugin(Plugin* dependant);
void deleteDependantLink(Plugin* dependantPlugin);
void cb_recievedMap(MapHandler* map) {}
void cb_removingMap(MapHandler* map) {}
bool hasDependantPlugins(){ return !l_dependantPlugins.isEmpty(); }
bool isWaitingForScene() { return false; }
void recieveScene(Scene* scene) {}
void deleteLinkWithScene(Scene* scene);
bool hasManualLinkWithScene(Scene* scene) { return false; }
QStringList getDependantPluginNames();
bool isWaitingForScene(){return false;}
void recieveScene(Scene* scene){}
void setWindow(Window* window);
void setName(QString name);
void setPluginFilePath(QString path);
bool activate(bool initializing);
virtual bool activate() =0;
virtual void disable() =0;
void deleteLinkWith(Scene* scene);
Plugin* addDependencie(QString dependencie);
void suppressDependencieLink(Plugin* dependencie);
void suppressAllDependencieLinks();
void suppressDependantLink(Plugin* dependant);
void suppressAllDependantLinks();
void unloadDependantPlugins();
bool hasManualLinkWith(Scene* scene){return false;}
bool addMap(CGoGN::GenericMap* map);
CGoGN::GenericMap* takeMap(CGoGN::GenericMap* map);
QList<CGoGN::GenericMap*> workingMaps(){return l_map;}
void setMapNumber(int n){if(n>=l_map.size() || n==UNLIMITED_MAP_NUMBER) m_mapNumber=n;}
int remainingMapNumber(){return (m_mapNumber!=UNLIMITED_MAP_NUMBER)?(m_mapNumber-l_map.size()):(m_mapNumber);}
enum {UNLIMITED_NUMBER_OF_SCENES=-1};
protected:
template<typename T>
T* getDependencie(QString dependencie){ return( (T*)(this->addDependencie(dependencie)) ); }
bool addWidgetInDockTab(QWidget* newTabWidget, QString tabText);
void removeTabInDock(QWidget* tabWidget);
......
......@@ -4,7 +4,7 @@
#include <iostream>
#include "types.h"
#include "interface/viewButtonArea.h"
#include "viewButtonArea.h"
# include <QKeyEvent>
#include <QList>
......@@ -17,15 +17,14 @@ class Scene;
class Camera;
class Context;
class View : public QGLViewer{
class View : public QGLViewer
{
Q_OBJECT
// friend class Scene;
public:
View(Scene* s, QString name, Camera* c, QGLWidget * shareWidget=0, Context* context=0 ,QWidget* parent=0);
View(Scene* s, QString name, Camera* c, QGLWidget* shareWidget = NULL, Context* context = NULL, QWidget* parent = NULL);
~View();
virtual void updateGL();
void simpleUpdate();
virtual void draw();
......@@ -49,44 +48,44 @@ public:
// virtual void paintGL() { update(); }
// virtual void paintEvent(QPaintEvent *event);
Scene* getScene(){return m_scene;}
Scene* getScene() { return m_scene; }
void setName(QString name){m_name= name;}
QString getName(){return m_name;}
void setName(QString name) { m_name = name; }
QString getName() { return m_name; }
void enableLinking(bool b=true);
void enableUnlinking(bool b=true);
void enableCameraGesture(bool b=true);
void enableSceneCameraGesture(bool b=true);
void enableViewClose(bool b=true);
void enableLinking(bool b = true);
void enableUnlinking(bool b = true);