Commit e0664504 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps : premiere version presque fonctionnelle..

parent cb9f0df4
......@@ -34,18 +34,21 @@ file(
${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp
${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp
)
SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h
${SCHNApps_ROOT_DIR}/include/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h
)
file(
......@@ -55,6 +58,8 @@ file(
${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui
)
QT4_WRAP_UI( UI_H_FILES
......
......@@ -48,7 +48,10 @@ class FirstPlugin : public Plugin
public:
FirstPlugin()
{}
{
setProvidesRendering(true);
glewInit();
}
~FirstPlugin()
{}
......@@ -70,20 +73,18 @@ public:
*/
void disable();
void cb_initGL(View *scene);
virtual void cb_updateMatrix(View* view) {}
void cb_redraw(View *scene);
virtual void redraw(View *view);
virtual void cb_keyPress(View* scene, int key) {}
virtual void cb_keyRelease(View* scene, int key) {}
virtual void cb_mousePress(View* scene, int button, int x, int y) {}
virtual void cb_mouseRelease(View* scene, int button, int x, int y) {}
// virtual void cb_mouseClick(View* scene, int button, int x, int y) {}
virtual void cb_mouseMove(View* scene, int buttons, int x, int y) {}
virtual void cb_wheelEvent(View* scene, int delta, int x, int y) {}
virtual void keyPress(View* view, int key) {}
virtual void keyRelease(View* view, int key) {}
virtual void mousePress(View* view, int button, int x, int y) {}
virtual void mouseRelease(View* view, int button, int x, int y) {}
// virtual void mouseClick(View* view, int button, int x, int y) {}
virtual void mouseMove(View* view, int buttons, int x, int y) {}
virtual void wheelEvent(View* view, int delta, int x, int y) {}
virtual void cb_viewAdded(View* s) {}
virtual void cb_viewRemoved(View* s) {}
virtual void viewAdded(View* view);
virtual void viewRemoved(View* view) {}
protected:
/** Attributes that are specific to this plugin **/
......
#include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.h"
void FirstPlugin::cb_initGL(View *view)
{
if (view)
{
// bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
// scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize());
m_render_topo = new Algo::Render::GL2::TopoRender() ;
// render the topo of the map without boundary darts
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
}
}
void FirstPlugin::cb_redraw(View* view)
{
m_render_topo->drawTopo();
}
bool FirstPlugin::enable()
{
// creation of 2 new faces: 1 triangle and 1 square
......@@ -43,7 +21,10 @@ bool FirstPlugin::enable()
position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -2, 0);
m_render_topo = NULL;
m_render_topo = new Algo::Render::GL2::TopoRender() ;
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
return true;
}
......@@ -56,6 +37,44 @@ void FirstPlugin::disable()
}
}
void FirstPlugin::redraw(View* view)
{
m_render_topo->drawTopo();
// const float nbSteps = 200.0;
// glBegin(GL_QUAD_STRIP);
// for (float i = 0; i < nbSteps; ++i)
// {
// float ratio = i/nbSteps;
// float angle = 21.0*ratio;
// float c = cos(angle);
// float s = sin(angle);
// float r1 = 1.0 - 0.8f*ratio;
// float r2 = 0.8f - 0.8f*ratio;
// float alt = ratio - 0.5f;
// const float nor = 0.5f;
// const float up = sqrt(1.0-nor*nor);
// glColor3f(1.0-ratio, 0.2f , ratio);
// glNormal3f(nor*c, up, nor*s);
// glVertex3f(r1*c, alt, r1*s);
// glVertex3f(r2*c, alt+0.05f, r2*s);
// }
// glEnd();
}
void FirstPlugin::viewAdded(View* view)
{
// bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
PFP::VEC3& min = bb.min();
PFP::VEC3& max = bb.max();
qglviewer::Vec minV(min[0], min[1], min[2]);
qglviewer::Vec maxV(max[0], max[1], max[2]);
view->setSceneBoundingBox(minV, maxV);
}
/**
* If we want to compile this plugin in debug mode,
* we also define a DEBUG macro at the compilation
......
......@@ -36,18 +36,21 @@ file(
${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp
${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp
)
SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h
${SCHNApps_ROOT_DIR}/include/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h
)
file(
......@@ -57,6 +60,8 @@ file(
${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui
)
QT4_WRAP_UI( UI_H_FILES
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>232</width>
<height>430</height>
<width>198</width>
<height>318</height>
</rect>
</property>
<property name="windowTitle">
......@@ -40,7 +40,7 @@
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="OKButton">
<property name="text">
<string>OK</string>
</property>
......@@ -49,5 +49,22 @@
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>OKButton</sender>
<signal>clicked()</signal>
<receiver>CameraDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>115</x>
<y>407</y>
</hint>
<hint type="destinationlabel">
<x>115</x>
<y>214</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>232</width>
<height>430</height>
<width>168</width>
<height>331</height>
</rect>
</property>
<property name="windowTitle">
......@@ -15,10 +15,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="cameraList"/>
<widget class="QListWidget" name="cameraList">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="OKButton">
<property name="text">
<string>OK</string>
</property>
......@@ -27,5 +31,22 @@
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>OKButton</sender>
<signal>clicked()</signal>
<receiver>CameraViewDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>115</x>
<y>407</y>
</hint>
<hint type="destinationlabel">
<x>115</x>
<y>214</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -64,10 +64,6 @@ public:
void resetSnapCount() { m_snapCount = 0; }
void saveSnapshot(QString snapPathName);
void updateGL();
// void viewShowButton(bool b);
protected:
QString m_name;
Window* m_window;
......
......@@ -4,6 +4,7 @@
#include "ui_cameraDialog.h"
class Window;
class Camera;
class CameraDialog : public QDialog, Ui::CameraDialog
{
......@@ -13,15 +14,14 @@ public:
CameraDialog(Window* window);
~CameraDialog();
void addCameraToList(const QString& name);
void addViewToList(const QString& name);
private:
Window* m_window;
public slots:
void cb_addCamera();
void cb_removeCamera();
void cb_addCameraToList(Camera* c);
void cb_removeCameraFromList(Camera* c);
};
#endif
......@@ -4,6 +4,7 @@
#include "ui_cameraViewDialog.h"
class Window;
class Camera;
class View;
class CameraViewDialog : public QDialog, Ui::CameraViewDialog
......@@ -18,8 +19,12 @@ private:
Window* m_window;
View* m_view;
void selectCurrentCamera();
public slots:
void cb_selectedCameraChanged(QListWidgetItem* current, QListWidgetItem* previous);
void cb_selectedCameraChanged();
void cb_addCameraToList(Camera* c);
void cb_removeCameraFromList(Camera* c);
};
#endif
#ifndef _CONTEXT_H_
#define _CONTEXT_H_
#include <QGLContext>
class Context : public QGLContext
{
public:
Context(const QGLFormat& format);
void setDevice(QWidget* w);
};
#endif
......@@ -4,6 +4,8 @@
#include <QString>
#include "types.h"
#include "view.h"
namespace CGoGN
{
class GenericMap;
......@@ -32,10 +34,21 @@ public:
int getNbVBO() { return h_vbo.count(); }
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
bool linkView(View* view);
void unlinkView(View* view);
bool isLinkedToView(View* view) { return l_views.contains(view); }
QList<View*> getLinkedViews() { return l_views; }
protected:
QString m_name;
CGoGN::GenericMap* m_map;
QList<View*> l_views;
VBOHash h_vbo;
};
......
......@@ -20,7 +20,6 @@ public:
enum { UNLIMITED_NUMBER_OF_SCENES = -1 };
Plugin();
Plugin(const QString& name, const QString& filePath, Window* window);
virtual ~Plugin();
virtual bool enable() = 0;
......@@ -35,20 +34,21 @@ public:
Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; }
virtual void cb_initGL(View* scene) = 0;
virtual void cb_updateMatrix(View* view) = 0;
virtual void cb_redraw(View* scene) = 0;
bool getProvidesRendering() { return b_providesRendering; }
void setProvidesRendering(bool b) { b_providesRendering = b; }
virtual void cb_keyPress(View* scene, int key) = 0;
virtual void cb_keyRelease(View* scene, int key) = 0;
virtual void cb_mousePress(View* scene, int button, int x, int y) = 0;
virtual void cb_mouseRelease(View* scene, int button, int x, int y) = 0;
// virtual void cb_mouseClick(View* scene, int button, int x, int y) = 0;
virtual void cb_mouseMove(View* scene, int buttons, int x, int y) = 0;
virtual void cb_wheelEvent(View* scene, int delta, int x, int y) = 0;
virtual void redraw(View* view) = 0;
virtual void cb_viewAdded(View* s) = 0;
virtual void cb_viewRemoved(View* s) = 0;
virtual void keyPress(View* view, int key) = 0;
virtual void keyRelease(View* view, int key) = 0;
virtual void mousePress(View* view, int button, int x, int y) = 0;
virtual void mouseRelease(View* view, int button, int x, int y) = 0;
// virtual void mouseClick(View* view, int button, int x, int y) = 0;
virtual void mouseMove(View* view, int buttons, int x, int y) = 0;
virtual void wheelEvent(View* view, int delta, int x, int y) = 0;
virtual void viewAdded(View* view) = 0;
virtual void viewRemoved(View* view) = 0;
/*********************************************************
* MANAGE LINKED VIEWS
......@@ -85,6 +85,8 @@ protected:
QString m_filePath;
Window* m_window;
bool b_providesRendering;
QList<View*> l_views;
QList<QWidget*> l_tabWidgets;
QList<QAction*> l_menuActions;
......
......@@ -10,6 +10,10 @@
class ViewButtonArea;
class ViewButton;
class CameraViewDialog;
class PluginsViewDialog;
class MapsViewDialog;
class View : public QGLViewer
{
Q_OBJECT
......@@ -26,9 +30,12 @@ public:
Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; }
virtual void initGL();
virtual void updateGL();
virtual void init();
virtual void preDraw();
virtual void draw();
virtual void postDraw();
virtual void resizeGL(int width, int height);
void drawText();
void drawButtons();
......@@ -39,8 +46,6 @@ public:
void mouseMoveEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
virtual void resizeGL(int width, int height);
void drawOverpaint(QPainter *painter);
// virtual void paintGL() { update(); }
......@@ -100,8 +105,15 @@ protected:
QString m_textInfo;
CameraViewDialog* m_cameraViewDialog;
PluginsViewDialog* m_pluginsViewDialog;
MapsViewDialog* m_mapsViewDialog;
public slots:
void cb_cameraView();
void cb_cameraView(int x, int y);
void cb_pluginsView(int x, int y);
void cb_mapsView(int x, int y);
void cb_closeView(int x, int y);
//signals:
// void currentCameraChanged(Camera* camera);
......
......@@ -19,20 +19,20 @@ public:
ViewButton(const QString& image, View* view);
~ViewButton();
void click();
QSize getSize() { return m_GLimg.size(); }
void click(int x, int y);
void drawAt(int x, int y);
QSize getSize() { return m_GLimg.size(); }
protected:
View* m_view;
QSize m_size;
QImage m_GLimg;
int m_texID;
signals:
void clicked();
void clicked(int x, int y);
};
class ViewButtonArea : public QObject
......@@ -49,7 +49,7 @@ public:
void removeButton(ViewButton* button);
bool isClicked(int x, int y);
ViewButton* clickButton(int x, int y);
void clickButton(int x, int y);
const QRect& getForm() { return m_form; }
......
......@@ -127,6 +127,28 @@ public:
void removeToolbarAction(QAction* action);
/*********************************************************
* MANAGE CAMERAS
*********************************************************/
Camera* addCamera(const QString& name);
Camera* addCamera();
void removeCamera(const QString& name);
Camera* getCamera(const QString& name);
QList<Camera*> getCamerasList() { return h_cameras.values(); }
const CameraHash& getCamerasHash() { return h_cameras; }
/*********************************************************
* MANAGE VIEWS
*********************************************************/
View* addView(const QString& name);
View* addView();
void removeView(const QString& name);
View* getView(const QString& name);
QList<View*> getViewsList() { return h_views.values(); }
const ViewHash& getViewsHash() { return h_views; }
/*********************************************************
* MANAGE PLUGINS
*********************************************************/
......@@ -206,28 +228,6 @@ public:
QList<Plugin*> getPluginsList() { return h_plugins.values(); }
const PluginHash& getPluginsHash() { return h_plugins; }
/*********************************************************
* MANAGE VIEWS
*********************************************************/
View* addView(const QString& name);
View* addView();
void removeView(const QString& name);
View* getView(const QString& name);
QList<View*> getViewsList() { return h_views.values(); }
const ViewHash& getViewsHash() { return h_views; }
/*********************************************************
* MANAGE CAMERAS
*********************************************************/
Camera* addCamera(const QString& name);
Camera* addCamera();
void removeCamera(const QString& name);
Camera* getCamera(const QString& name);
QList<Camera*> getCamerasList() { return h_cameras.values(); }
const CameraHash& getCamerasHash() { return h_cameras; }
/*********************************************************
* MANAGE MAPS
*********************************************************/
......@@ -303,11 +303,11 @@ public slots:
void cb_aboutCGoGN();
/**
* \fn void cb_managePlugins()
* \brief method called when the "Plugins" action is triggered.
* Show the plugins management dialog
* \fn void cb_manageCameras()
* \brief method called when the "Cameras" action is triggered.
* Show the cameras management dialog:
*/
void cb_managePlugins();
void cb_manageCameras();
/**
* \fn void cb_manageViews()
......@@ -317,11 +317,24 @@ public slots:
void cb_manageViews();
/**
* \fn void cb_manageCameras()
* \brief method called when the "Cameras" action is triggered.
* Show the cameras management dialog:
* \fn void cb_managePlugins()
* \brief method called when the "Plugins" action is triggered.
* Show the plugins management dialog
*/
void cb_manageCameras();
void cb_managePlugins();
signals:
void cameraAdded(Camera* camera);
void cameraRemoved(Camera* camera);
void viewAdded(View* view);
void viewRemoved(View* view);
void mapAdded(MapHandler* camera);
void mapRemoved(MapHandler* map);
void pluginAdded(Plugin* plugin);
void pluginRemoved(Plugin* plugin);
};
#endif
......@@ -63,15 +63,3 @@ void Camera::saveSnapshot(QString snapPathName)
view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpg", true);
++m_snapCount;
}
void Camera::updateGL()
{
foreach(View* view, l_views)
view->updateGL();
}
//void Camera::viewShowButton(bool b)