Commit 2d79bd26 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps : suite de la remise a plat.. (attention ne pas compiler..)

parent 0c4a8f15
#ifndef _CAMERA_H_
#define _CAMERA_H_
#include "view.h"
//forward declaration
class Camera : public qglviewer::Camera
{
public:
Camera(View* v);
Camera(View* v, Camera c);
~Camera();
bool isShared() { return l_views.size() > 1; }
QString getName() { return m_name; }
void setName(QString name) { m_name = name; }
void 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 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 saveSnapshot(QString snapPathName);
void updateGL();
void viewShowButton(bool b);
protected:
QList<View*> l_views;
QString m_name;
bool m_draw;
bool m_drawFarPlane;
double m_drawScale;
bool m_drawPath;
bool m_drawPathAxis;
double m_drawPathScale;
View* m_lastWorkingView;
int m_snapCount;
};
#endif
#ifndef _CAMERAOPTIONDIALOG_H_
#define _CAMERAOPTIONDIALOG_H_
#include "ui_cameraOptionDialog.h"
class Camera;
class CameraOptionDialog: public QDialog, Ui::CODialog{
Q_OBJECT
public:
CameraOptionDialog(Camera* camera, QWidget* parent);
~CameraOptionDialog(){}
public slots:
void drawChecked(bool b);
void drawPathChecked(bool b);
void accept();
protected:
Camera* m_camera;
};
#endif
#ifndef _SEPARATECAMERADIALOG_H_
#define _SEPARATECAMERADIALOG_H_
#include "ui_cameraSceneDialog.h"
#include <QTreeWidget>
#include <QVariant>
class Scene;
class View;
namespace Qt{
extern int UserRoleType;
}
namespace myTreeWidget{
enum type {view, camera};
}
class MyTreeWidget : public QTreeWidget{
Q_OBJECT
public:
MyTreeWidget(Scene* originalScene, QWidget* parent=0);
protected:
virtual bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
QStringList mimeTypes() const;
Qt::DropActions supportedDropActions () const;
QMimeData* mimeData(const QList<QTreeWidgetItem *> items) const;
Scene* m_scene;
};
class CameraSceneDialog : public QDialog, Ui::CSDialog{
Q_OBJECT
public:
CameraSceneDialog(Scene* scene, QWidget* parent=0);
~CameraSceneDialog(){}
MyTreeWidget* treeWidget;
Scene* m_scene;
protected slots:
void newDuplicatedView();
void removeView();
void currentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev);
};
#endif
#ifndef _CAMERAVIEWDIALOG_H_
#define _CAMERAVIEWDIALOG_H_
#include "ui_cameraViewDialog.h"
class View;
class Camera;
class CameraViewDialog : public QDialog, Ui::CVDialog{
Q_OBJECT
public:
CameraViewDialog(View* view, QWidget* parent=0);
~CameraViewDialog();
protected:
View* view;
protected slots:
void addCamera();
void removeCamera();
void changeCurrentCamera(QListWidgetItem * current, QListWidgetItem * previous);
void cameraNameChange(QListWidgetItem * item);
void settingsCamera();
private:
bool autoText;
};
#endif
#ifndef _CONTEXT_H_
#define _CONTEXT_H_
#include "types.h"
#include <QGLContext>
class Context : public QGLContext
{
public:
Context(QWidget* w, const QGLFormat & format);
void setDevice(QWidget* w);
};
#endif
#ifndef _GLOBALCAMERADIALOG_H_
#define _GLOBALCAMERADIALOG_H_
#include "ui_globalCameraDialog.h"
#include <QListWidget>
#include <QTreeWidget>
#include <QVariant>
#include <QMenu>
#include "visualization/camera.h"
#include "visualization/view.h"
class Window;
struct CarryCamera{
Camera* camera;
View* view;
CarryCamera(Camera* camera=NULL, View* view=NULL) : camera(camera), view(view){}
};
namespace Qt{
extern int UserRole2;
}
namespace myDragDropWidgets{
enum type {view, camera,scene};
}
class MyCameraMenu : public QMenu{
Q_OBJECT
public:
enum ResultType{none,move,share};
enum Mode{moving=1, sharing=2};
MyCameraMenu(const QString & title, QWidget * parent = 0, int mode=(moving | sharing));
ResultType result(){return m_result;}
protected:
QAction* m_moveAction;
QAction* m_shareAction;
ResultType m_result;
protected slots:
void moveCamera(){m_result=move;}
void shareCamera(){m_result=share;}
};
class MyDragListWidget : public QListWidget{
Q_OBJECT
public:
MyDragListWidget(QWidget* parent=0);
~MyDragListWidget(){}
protected:
QMimeData* mimeData(const QList<QListWidgetItem *> items) const;
};
class MyDropTreeWidget : public QTreeWidget{
Q_OBJECT
public:
MyDropTreeWidget(QWidget* parent=0);
~MyDropTreeWidget(){}
protected:
virtual bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action);
QStringList mimeTypes() const;
Qt::DropActions supportedDropActions () const;
};
class GlobalCameraDialog : public QDialog, Ui::GCDialog{
Q_OBJECT
public:
GlobalCameraDialog(Window* window);
~GlobalCameraDialog(){}
MyDropTreeWidget* treeWidget;
MyDragListWidget* listWidget;
public slots:
void treeCurrentItemChanged(QTreeWidgetItem* cur,QTreeWidgetItem* prev);
};
#endif
#ifndef _LINKVIEWDIALOG_H_
#define _LINKVIEWDIALOG_H_
#include "ui_linkViewDialog.h"
#include "types.h"
class Window;
class Scene;
class LinkViewDialog : public QDialog, Ui::LVDialog{
Q_OBJECT
public:
LinkViewDialog(Window* parent, PluginHash* activePlugins, Scene* scene);
LinkViewDialog(Window* parent, QList<Plugin*> dependingPlugin, Scene* scene);
~LinkViewDialog(){}
protected:
enum Mode{LINK, UNLINK};
QList<Plugin*> l_waitingPlugins;
Scene* m_scene;
Mode m_mode;
public slots:
void button_OK();
void customContextMenu(const QPoint & pos);
void showPluginInfo();
};
#endif
#ifndef _VIZUHANDLER_H_
#define _VIZUHANDLER_H_
#include <QHash>
namespace CGoGN
{
class GenericMap;
namespace Utils
{
class VBO;
}
}
class VBOHandler;
class MapHandler
{
public:
MapHandler(CGoGN::GenericMap *map);
~MapHandler();
CGoGN::GenericMap *map()
{
return m_map;
}
VBOHandler *findVBO(QString name);
VBOHandler *findFirstVBOMatching(QRegExp regexp);
QList<VBOHandler *> findVBOsMatching(QRegExp regexp);
bool addVBO(VBOHandler *vboH);
VBOHandler *addNewVBO(QString vboName);
VBOHandler *takeVBO(VBOHandler *vbo);
int countVBO()
{
return l_vbo.count();
}
protected:
CGoGN::GenericMap *m_map;
QList<VBOHandler *> l_vbo;
};
#endif
#ifndef _MAPPLUGINDIALOG_H_
#define _MAPPLUGINDIALOG_H_
#include "ui_mapPluginDialog.h"
#include "types.h"
class Window;
class Plugin;
class MapHandler;
namespace CGoGN { class GenericMap; }
class MapPluginDialog : public QDialog, Ui::MPDialog{
Q_OBJECT
public:
MapPluginDialog(Window* w, MapHash* maps);
protected:
QList<Plugin*> l_plugin;
public slots:
void pluginSelection();
void actionMap(QListWidgetItem* item);
void customPluginContextMenu(const QPoint & pos);
void showPluginInfo();
};
#endif
#ifndef _NEWSCENEDIALOG_H_
#define _NEWSCENEDIALOG_H_
#include "ui_newSceneDialog.h"
#include <QListWidget>
namespace myListCameraTypes{
enum type {view, camera,scene};
}
class Window;
class NewSceneDialog : public QDialog, Ui::NSDialog{
Q_OBJECT
public:
NewSceneDialog(Window* parent);
~NewSceneDialog();
protected:
Window* m_window;
QListWidget* m_listWidget;
QListWidget* m_listWidget2;
public slots:
void button_OK();
void new_camera();
void share_camera();
void cameraListSelectionChange(QListWidgetItem* cur, QListWidgetItem* prev);
void linkPlugin(bool b);
void customContextMenu(const QPoint & pos);
void showPluginInfo();
};
#endif
#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 _PLUGINDIALOG_H_
#define _PLUGINDIALOG_H_
#include "ui_pluginDialog.h"
#include <QDir>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QTextStream>
#include "types.h"
class Plugin;
class Window;
class PluginDialog : public QDialog, public Ui::Dialog{
Q_OBJECT
public:
PluginDialog(Window* parent=0, PluginHash* activePlugins=NULL);
~PluginDialog();
protected:
// QDomDocument doc;
// QFile xmlFile;
// QTextStream out;
PluginHash* activePlugins;
Window* parentWindow;
bool loadInfoPlugins();
// void showPlugins();
private:
bool init;
enum EntryType{DIR=1,FILE, FILE_DIR};
void showPluginsDir(QDir directory);
protected slots:
void cb_addPlugins();
void cb_removePlugins();
void cb_addPluginDirectory();
void cb_activePlugin(QTreeWidgetItem* item, int column);
void cb_acceptDialog();
void customContextMenu(const QPoint & pos);
void showPluginInfo();
};