Commit 90c61bbf authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps : suite du ménage

parent b78c9abb
...@@ -8,34 +8,43 @@ ...@@ -8,34 +8,43 @@
class Camera : public qglviewer::Camera class Camera : public qglviewer::Camera
{ {
public: public:
Camera(View* v); Camera(Window* window, View* v);
Camera(View* v, Camera c); Camera(Window* window, View* v, const qglviewer::Camera& c);
~Camera(); ~Camera();
bool isShared() { return l_views.size() > 1; }
QString getName() { return m_name; }
void setName(QString name) { m_name = name; } void setName(QString name) { m_name = name; }
QString getName() { return m_name; }
Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; }
bool isShared() { return l_views.size() > 1; }
void draw(); void draw();
bool getDraw() { return m_draw; } 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 setDraw(bool b = true) { m_draw = b; }
bool getDrawFarPlane() { return m_drawFarPlane; }
void setDrawFarPlane(bool b = true) { m_drawFarPlane = b; } void setDrawFarPlane(bool b = true) { m_drawFarPlane = b; }
double getDrawScale() { return m_drawScale; }
void setDrawScale(double s) { m_drawScale = s; } void setDrawScale(double s) { m_drawScale = s; }
bool getDrawPath() { return m_drawPath; }
void setDrawPath(bool b = true) { m_drawPath = b; } void setDrawPath(bool b = true) { m_drawPath = b; }
bool getDrawPathAxis() { return m_drawPathAxis; }
void setDrawPathAxis(bool b = true) { m_drawPathAxis = b; } void setDrawPathAxis(bool b = true) { m_drawPathAxis = b; }
double getDrawPathScale() { return m_drawPathScale; }
void setDrawPathScale(double s) { m_drawPathScale = s;} void setDrawPathScale(double s) { m_drawPathScale = s;}
void takenFrom(View* v); void linkView(View* view);
void sharedWith(View* v); void unlinkView(View* view);
void fitParamWith(View* v); bool isLinkedWithView(View* view);
void fitParamWith(View* view);
void resetSnapCount() { m_snapCount = 0; } void resetSnapCount() { m_snapCount = 0; }
void saveSnapshot(QString snapPathName); void saveSnapshot(QString snapPathName);
...@@ -45,9 +54,11 @@ public: ...@@ -45,9 +54,11 @@ public:
void viewShowButton(bool b); void viewShowButton(bool b);
protected: protected:
QList<View*> l_views; static unsigned int cameraCount;
QString m_name; QString m_name;
Window* m_window;
QList<View*> l_views;
bool m_draw; bool m_draw;
bool m_drawFarPlane; bool m_drawFarPlane;
...@@ -57,8 +68,6 @@ protected: ...@@ -57,8 +68,6 @@ protected:
bool m_drawPathAxis; bool m_drawPathAxis;
double m_drawPathScale; double m_drawPathScale;
View* m_lastWorkingView;
int m_snapCount; int m_snapCount;
}; };
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
class Context : public QGLContext class Context : public QGLContext
{ {
public: public:
Context(QWidget* w, const QGLFormat & format); Context(const QGLFormat& format, QWidget* w);
void setDevice(QWidget* w); void setDevice(QWidget* w);
}; };
......
...@@ -20,8 +20,7 @@ public: ...@@ -20,8 +20,7 @@ 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 };
Plugin(const QString& name, const QString& filePath); Plugin(const QString& name, const QString& filePath, Window* window);
virtual ~Plugin(); virtual ~Plugin();
virtual bool enable() = 0; virtual bool enable() = 0;
...@@ -43,13 +42,13 @@ public: ...@@ -43,13 +42,13 @@ public:
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 bool cb_keyPress(Scene* scene, int event) = 0; virtual void cb_keyPress(Scene* scene, int key) = 0;
virtual bool cb_keyRelease(Scene* scene, int event) = 0; virtual void cb_keyRelease(Scene* scene, int key) = 0;
virtual bool cb_mousePress(Scene* scene, int button, int x, int y) = 0; virtual void 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 void 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 void 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 void 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_wheelEvent(Scene* scene, int delta, int x, int y) = 0;
virtual void cb_mapAdded(MapHandler* map) = 0; virtual void cb_mapAdded(MapHandler* map) = 0;
virtual void cb_mapRemoved(MapHandler* map) = 0; virtual void cb_mapRemoved(MapHandler* map) = 0;
...@@ -60,21 +59,21 @@ public: ...@@ -60,21 +59,21 @@ public:
/********************************************************* /*********************************************************
* MANAGE MAPS * MANAGE MAPS
*********************************************************/ *********************************************************/
bool addMap(MapHandler* map); bool linkMap(MapHandler* map);
void removeMap(MapHandler* map); void unlinkMap(MapHandler* map);
bool hasMap(MapHandler* map); bool isLinkedToMap(MapHandler* map);
QList<MapHandler*> getMaps(); QList<MapHandler*> getLinkedMaps();
void setMaxNumberOfMaps(int n); void setMaxNumberOfLinkedMaps(int n);
int getCurrentNumberOfMaps(); int getCurrentNumberOfLinkedMaps();
int getRemainingNumberOfMaps(); int getRemainingNumberOfLinkedMaps();
/********************************************************* /*********************************************************
* MANAGE SCENES * MANAGE SCENES
*********************************************************/ *********************************************************/
bool addScene(Scene* scene); bool linkScene(Scene* scene);
void removeScene(Scene* scene); void unlinkScene(Scene* scene);
bool hasScene(Scene* scene); bool isLinkedToScene(Scene* scene);
QList<Scene*> getScenes(); QList<Scene*> getLinkedScenes();
/********************************************************* /*********************************************************
* MANAGE DOCK TABS * MANAGE DOCK TABS
......
...@@ -41,41 +41,33 @@ public: ...@@ -41,41 +41,33 @@ public:
void updateGL(); void updateGL();
void draw(View *v); void draw(View *v);
bool keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent* event);
bool keyReleaseEvent(QKeyEvent *e); void keyReleaseEvent(QKeyEvent *e);
bool mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
bool mouseReleaseEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event);
bool mouseMoveEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event);
bool wheelEvent(QWheelEvent* event); void wheelEvent(QWheelEvent* event);
/********************************************************* /*********************************************************
* MANAGE VIEWS * MANAGE VIEWS
*********************************************************/ *********************************************************/
View* addView(Camera* c = NULL); void linkView(View* view);
void removeView(View* view); void unlinkView(View* view);
View* getView(int num); View* getLinkedView(unsigned int num);
QList<View*> getViews() { return l_views; } QList<View*> getLinkedViews() { return l_views; }
int getNbViews() { return l_views.size(); } int getNbLinkedViews() { return l_views.size(); }
void viewClickedButton(View* view, ViewButton* viewButton);
/********************************************************* /*********************************************************
* MANAGE PLUGINS * MANAGE PLUGINS
*********************************************************/ *********************************************************/
void addPlugin(Plugin* plugin, bool callBackInitGL = true); void linkPlugin(Plugin* plugin, bool callInitGL = true);
void removePlugin(Plugin* plugin); void unlinkPlugin(Plugin* plugin);
QList<Plugin*> getPlugins() { return l_plugins; } QList<Plugin*> getLinkedPlugins() { return l_plugins; }
bool hasPlugins() { return !l_plugins.isEmpty(); } bool isLinkedToPlugins() { return !l_plugins.isEmpty(); }
bool hasPlugin(Plugin* plugin) { return l_plugins.contains(plugin); } bool isLinkedToPlugin(Plugin* plugin) { return l_plugins.contains(plugin); }
// void linkWithPlugin(); // void linkWithPlugin();
// void unlinkPlugin(); // void unlinkPlugin();
/*********************************************************
* 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);
// VBOHandler* findVBO(QString name); // VBOHandler* findVBO(QString name);
...@@ -93,10 +85,7 @@ protected: ...@@ -93,10 +85,7 @@ protected:
QList<View*> l_views; QList<View*> l_views;
QList<Plugin*> l_plugins; QList<Plugin*> l_plugins;
// QList<VBOHandler*> l_vbo; // QList<VBOHandler*> l_vbo;
QList<ViewButton*> l_viewButtons; // QList<ViewButton*> l_viewButtons;
signals:
void viewButtonClicked(View*, ViewButton*);
}; };
#endif #endif
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
class Plugin; class Plugin;
class Scene; class Scene;
class View;
class Camera;
class MapHandler; class MapHandler;
namespace CGoGN namespace CGoGN
{ {
namespace Utils namespace Utils
...@@ -21,6 +25,9 @@ namespace CGoGN ...@@ -21,6 +25,9 @@ namespace CGoGN
typedef QHash<QString, Plugin*> PluginHash; typedef QHash<QString, Plugin*> PluginHash;
typedef QHash<QString, Scene*> SceneHash; typedef QHash<QString, Scene*> SceneHash;
typedef QHash<QString, View*> ViewHash;
typedef QHash<QString, Camera*> CameraHash;
typedef QHash<QString, MapHandler*> MapHash; typedef QHash<QString, MapHandler*> MapHash;
typedef QHash<QString, CGoGN::Utils::VBO*> VBOHash; typedef QHash<QString, CGoGN::Utils::VBO*> VBOHash;
typedef QHash<QString, CGoGN::Utils::GLSLShader*> ShaderHash; typedef QHash<QString, CGoGN::Utils::GLSLShader*> ShaderHash;
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
# include <QKeyEvent> # include <QKeyEvent>
#include <QList> #include <QList>
#include <QWidget> #include <QWidget>
#include <QGLContext>
#include "Utils/gl_matrices.h" #include "Utils/gl_matrices.h"
//forward declaration
class Scene; class Scene;
class Camera; class Camera;
class Context; class Context;
...@@ -22,14 +22,32 @@ class View : public QGLViewer ...@@ -22,14 +22,32 @@ class View : public QGLViewer
Q_OBJECT Q_OBJECT
public: public:
View(Scene* s, const QString& name, Camera* c, QGLWidget* shareWidget = NULL, Context* context = NULL, QWidget* parent = NULL); View(const QString& name, Window* w, Scene* s, Camera* c, QWidget* parent, const QGLWidget* shareWidget = NULL);
~View(); ~View();
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; }
Scene* getScene() { return m_scene; }
void setScene(Scene* s) { m_scene = s; }
Camera* getCurrentCamera() { return m_currentCamera; }
void setCurrentCamera(Camera* c)
{
m_currentCamera = c;
updateTextInfo();
updateGL();
}
QGLContext* getContext() { return m_context; }
void setContext(QGLContext* c) { m_context = c; }
virtual void initGL();
virtual void updateGL(); virtual void updateGL();
virtual void draw(); virtual void draw();
virtual void init();
void drawCameras(View* view);
void drawText(); void drawText();
void drawButtons(); void drawButtons();
...@@ -47,28 +65,12 @@ public: ...@@ -47,28 +65,12 @@ public:
// virtual void paintGL() { update(); } // virtual void paintGL() { update(); }
// virtual void paintEvent(QPaintEvent *event); // virtual void paintEvent(QPaintEvent *event);
Scene* getScene() { return m_scene; }
void setName(const QString& name) { m_name = 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);
void enableCameraGesture(bool b = true); void enableCameraGesture(bool b = true);
void enableSceneCameraGesture(bool b = true); void enableSceneCameraGesture(bool b = true);
void enableViewClose(bool b = true); void enableViewClose(bool b = true);
Camera* currentCamera() { return m_currentCamera; }
void setCurrentCamera(Camera* c);
QList<Camera*> cameras() { return l_camera; }
int countCameras() { return l_camera.size(); }
void removeCamera(Camera* c);
Camera* takeCamera(Camera* c);
Camera* addCamera();
void insertCamera(int index, Camera* c);
void shareCamera(Camera* c, int index = 0);
// void addUnlinkButton(); // void addUnlinkButton();
// void removeUnlinkButton(); // void removeUnlinkButton();
...@@ -78,55 +80,48 @@ public: ...@@ -78,55 +80,48 @@ public:
glm::mat4 getCurrentProjectionMatrix(); glm::mat4 getCurrentProjectionMatrix();
glm::mat4 getCurrentModelViewProjectionMatrix(); glm::mat4 getCurrentModelViewProjectionMatrix();
void setCurrentModelViewMatrix(glm::mat4 mvm); void setCurrentModelViewMatrix(const glm::mat4& mvm);
void setCurrentProjectionMatrix(glm::mat4 pm); void setCurrentProjectionMatrix(const glm::mat4& pm);
void addCustomViewButton(ViewButton* viewButton); // void addViewButton(ViewButton* viewButton);
void removeCustomViewButton(ViewButton* viewButton); // void removeViewButton(ViewButton* viewButton);
void setShowButtons(bool b) { b_showButtons = b; } // void setShowButtons(bool b) { b_showButtons = b; }
protected: protected:
QString m_name; QString m_name;
Window* m_window;
Scene* m_scene; Scene* m_scene;
QGLContext* m_context;
QList<Camera*> l_camera;
Camera* m_currentCamera; Camera* m_currentCamera;
ViewButtonArea* m_buttonArea; // ViewButtonArea* m_buttonArea;
ViewButton* m_linkButton; // ViewButton* m_linkButton;
bool m_linkViewEnabled; // bool m_linkViewEnabled;
ViewButton* m_unlinkButton; // ViewButton* m_unlinkButton;
bool m_unlinkViewEnabled; // bool m_unlinkViewEnabled;
ViewButton* m_cameraButton; // ViewButton* m_cameraButton;
bool m_cameraEnabled; // bool m_cameraEnabled;
ViewButton* m_cameraSceneButton; // ViewButton* m_cameraSceneButton;
bool m_cameraSceneEnabled; // bool m_cameraSceneEnabled;
ViewButton* m_closeViewButton; // ViewButton* m_closeViewButton;
bool m_closeViewEnabled; // bool m_closeViewEnabled;
QString m_textInfo; // bool b_showButtons;
Context* m_context;
bool b_showButtons;
public slots: QString m_textInfo;
void linkView(); bool b_drawText;
void unlinkView();
void cameraGesture();
void cameraSceneGesture();
void closeView();
void clickButton(ViewButton* viewButton);
private: //public slots:
bool b_destroyView; // void linkView();
// void unlinkView();
// void cameraGesture();
// void cameraSceneGesture();
// void closeView();
signals: //signals:
void currentCameraChanged(Camera* camera); // void currentCameraChanged(Camera* camera);
void viewButtonClicked(ViewButton* viewButton);
}; };
#endif #endif
...@@ -17,26 +17,23 @@ class ViewButton : public QObject ...@@ -17,26 +17,23 @@ class ViewButton : public QObject
Q_OBJECT Q_OBJECT
public: public:
ViewButton(QString image, View* view); ViewButton(const QString& image, View* view);
~ViewButton();
void click(View* view) void click();
{
emit clicked();
emit viewClicked(view);
}
void drawAt(int x, int y); void drawAt(int x, int y);
QSize getSize() { return m_GLimg.size(); } QSize getSize() { return m_GLimg.size(); }
protected: protected:
View* m_view;
QSize m_size; QSize m_size;
QImage m_GLimg; QImage m_GLimg;
int m_texID; int m_texID;
signals: signals:
void clicked(); void clicked();
void viewClicked(View* view);
}; };
class ViewButtonArea : public QObject class ViewButtonArea : public QObject
...@@ -46,33 +43,25 @@ class ViewButtonArea : public QObject ...@@ -46,33 +43,25 @@ class ViewButtonArea : public QObject
public: public:
ViewButtonArea(View* view) : m_view(view) ViewButtonArea(View* view) : m_view(view)
{} {}
~ViewButtonArea(); ~ViewButtonArea()
{}
void addButton(ViewButton* button); void addButton(ViewButton* button);
ViewButton* takeButton(ViewButton* button); void removeButton(ViewButton* button);
bool isIn(int x, int y);
ViewButton* clickAt(int x, int y); bool isClicked(int x, int y);
ViewButton* clickButton(int x, int y);
QRect form() { return m_form; } const QRect& getForm() { return m_form; }
void setTopRightPosition(int x, int y); void setTopRightPosition(int x, int y);
void draw(); void draw();
protected: protected:
QRect m_form;
QList<ViewButton*> l_button;
View* m_view; View* m_view;
QRect m_form;
public slots: QList<ViewButton*> l_buttons;
void buttonDestroyed(QObject* button);
signals:
void buttonClicked(ViewButton* button);
}; };
#endif #endif
...@@ -243,6 +243,11 @@ public: ...@@ -243,6 +243,11 @@ public:
* MANAGE MAPS * MANAGE MAPS
*********************************************************/ *********************************************************/
/*********************************************************
* MANAGE CAMERAS
*********************************************************/
QList<Camera*> getCameras() { return h_cameras.values(); }
...@@ -353,6 +358,7 @@ protected: ...@@ -353,6 +358,7 @@ protected:
SceneHash h_scenes; SceneHash h_scenes;
PluginHash h_plugins; PluginHash h_plugins;
MapHash h_maps; MapHash h_maps;
CameraHash h_cameras;
/** /**