Commit e0664504 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps : premiere version presque fonctionnelle..

parent cb9f0df4
...@@ -34,18 +34,21 @@ file( ...@@ -34,18 +34,21 @@ file(
${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp ${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp ${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp
${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp
) )
SET(SCHNApps_H_OBJECT_FILES SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h ${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h ${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h ${SCHNApps_ROOT_DIR}/include/cameraDialog.h
${SCHNApps_ROOT_DIR}/include/pluginDialog.h ${SCHNApps_ROOT_DIR}/include/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h
) )
file( file(
...@@ -55,6 +58,8 @@ file( ...@@ -55,6 +58,8 @@ file(
${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui ${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui ${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.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 QT4_WRAP_UI( UI_H_FILES
......
...@@ -48,7 +48,10 @@ class FirstPlugin : public Plugin ...@@ -48,7 +48,10 @@ class FirstPlugin : public Plugin
public: public:
FirstPlugin() FirstPlugin()
{} {
setProvidesRendering(true);
glewInit();
}
~FirstPlugin() ~FirstPlugin()
{} {}
...@@ -70,20 +73,18 @@ public: ...@@ -70,20 +73,18 @@ public:
*/ */
void disable(); void disable();
void cb_initGL(View *scene); virtual void redraw(View *view);
virtual void cb_updateMatrix(View* view) {}
void cb_redraw(View *scene);
virtual void cb_keyPress(View* scene, int key) {} virtual void keyPress(View* view, int key) {}
virtual void cb_keyRelease(View* scene, int key) {} virtual void keyRelease(View* view, int key) {}
virtual void cb_mousePress(View* scene, int button, int x, int y) {} virtual void mousePress(View* view, int button, int x, int y) {}
virtual void cb_mouseRelease(View* scene, int button, int x, int y) {} virtual void mouseRelease(View* view, int button, int x, int y) {}
// virtual void cb_mouseClick(View* scene, int button, int x, int y) {} // virtual void mouseClick(View* view, int button, int x, int y) {}
virtual void cb_mouseMove(View* scene, int buttons, int x, int y) {} virtual void mouseMove(View* view, int buttons, int x, int y) {}
virtual void cb_wheelEvent(View* scene, int delta, int x, int y) {} virtual void wheelEvent(View* view, int delta, int x, int y) {}
virtual void cb_viewAdded(View* s) {} virtual void viewAdded(View* view);
virtual void cb_viewRemoved(View* s) {} virtual void viewRemoved(View* view) {}
protected: protected:
/** Attributes that are specific to this plugin **/ /** Attributes that are specific to this plugin **/
......
#include "firstPlugin.h" #include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.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() bool FirstPlugin::enable()
{ {
// creation of 2 new faces: 1 triangle and 1 square // creation of 2 new faces: 1 triangle and 1 square
...@@ -43,7 +21,10 @@ bool FirstPlugin::enable() ...@@ -43,7 +21,10 @@ bool FirstPlugin::enable()
position[PHI<11>(d2)] = VEC3(0, -2, 0); position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -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; return true;
} }
...@@ -56,6 +37,44 @@ void FirstPlugin::disable() ...@@ -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, * If we want to compile this plugin in debug mode,
* we also define a DEBUG macro at the compilation * we also define a DEBUG macro at the compilation
......
...@@ -36,18 +36,21 @@ file( ...@@ -36,18 +36,21 @@ file(
${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp ${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp ${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp
${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp
) )
SET(SCHNApps_H_OBJECT_FILES SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h ${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h ${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h ${SCHNApps_ROOT_DIR}/include/cameraDialog.h
${SCHNApps_ROOT_DIR}/include/pluginDialog.h ${SCHNApps_ROOT_DIR}/include/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h
) )
file( file(
...@@ -57,6 +60,8 @@ file( ...@@ -57,6 +60,8 @@ file(
${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui ${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui ${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.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 QT4_WRAP_UI( UI_H_FILES
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>232</width> <width>198</width>
<height>430</height> <height>318</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="OKButton">
<property name="text"> <property name="text">
<string>OK</string> <string>OK</string>
</property> </property>
...@@ -49,5 +49,22 @@ ...@@ -49,5 +49,22 @@
</layout> </layout>
</widget> </widget>
<resources/> <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> </ui>
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>232</width> <width>168</width>
<height>430</height> <height>331</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -15,10 +15,14 @@ ...@@ -15,10 +15,14 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QListWidget" name="cameraList"/> <widget class="QListWidget" name="cameraList">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="OKButton">
<property name="text"> <property name="text">
<string>OK</string> <string>OK</string>
</property> </property>
...@@ -27,5 +31,22 @@ ...@@ -27,5 +31,22 @@
</layout> </layout>
</widget> </widget>
<resources/> <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> </ui>
...@@ -64,10 +64,6 @@ public: ...@@ -64,10 +64,6 @@ public:
void resetSnapCount() { m_snapCount = 0; } void resetSnapCount() { m_snapCount = 0; }
void saveSnapshot(QString snapPathName); void saveSnapshot(QString snapPathName);
void updateGL();
// void viewShowButton(bool b);
protected: protected:
QString m_name; QString m_name;
Window* m_window; Window* m_window;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui_cameraDialog.h" #include "ui_cameraDialog.h"
class Window; class Window;
class Camera;
class CameraDialog : public QDialog, Ui::CameraDialog class CameraDialog : public QDialog, Ui::CameraDialog
{ {
...@@ -13,15 +14,14 @@ public: ...@@ -13,15 +14,14 @@ public:
CameraDialog(Window* window); CameraDialog(Window* window);
~CameraDialog(); ~CameraDialog();
void addCameraToList(const QString& name);
void addViewToList(const QString& name);
private: private:
Window* m_window; Window* m_window;
public slots: public slots:
void cb_addCamera(); void cb_addCamera();
void cb_removeCamera(); void cb_removeCamera();
void cb_addCameraToList(Camera* c);
void cb_removeCameraFromList(Camera* c);
}; };
#endif #endif
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui_cameraViewDialog.h" #include "ui_cameraViewDialog.h"
class Window; class Window;
class Camera;
class View; class View;
class CameraViewDialog : public QDialog, Ui::CameraViewDialog class CameraViewDialog : public QDialog, Ui::CameraViewDialog
...@@ -18,8 +19,12 @@ private: ...@@ -18,8 +19,12 @@ private:
Window* m_window; Window* m_window;
View* m_view; View* m_view;
void selectCurrentCamera();
public slots: public slots:
void cb_selectedCameraChanged(QListWidgetItem* current, QListWidgetItem* previous); void cb_selectedCameraChanged();
void cb_addCameraToList(Camera* c);
void cb_removeCameraFromList(Camera* c);
}; };
#endif #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 @@ ...@@ -4,6 +4,8 @@
#include <QString> #include <QString>
#include "types.h" #include "types.h"
#include "view.h"
namespace CGoGN namespace CGoGN
{ {
class GenericMap; class GenericMap;
...@@ -32,10 +34,21 @@ public: ...@@ -32,10 +34,21 @@ public:
int getNbVBO() { return h_vbo.count(); } 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: protected:
QString m_name; QString m_name;
CGoGN::GenericMap* m_map; CGoGN::GenericMap* m_map;
QList<View*> l_views;
VBOHash h_vbo; VBOHash h_vbo;
}; };
......
...@@ -20,7 +20,6 @@ public: ...@@ -20,7 +20,6 @@ public:
enum { UNLIMITED_NUMBER_OF_SCENES = -1 }; enum { UNLIMITED_NUMBER_OF_SCENES = -1 };
Plugin(); Plugin();
Plugin(const QString& name, const QString& filePath, Window* window);
virtual ~Plugin(); virtual ~Plugin();
virtual bool enable() = 0; virtual bool enable() = 0;
...@@ -35,20 +34,21 @@ public: ...@@ -35,20 +34,21 @@ public:
Window* getWindow() { return m_window; } Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; } void setWindow(Window* w) { m_window = w; }
virtual void cb_initGL(View* scene) = 0; bool getProvidesRendering() { return b_providesRendering; }
virtual void cb_updateMatrix(View* view) = 0; void setProvidesRendering(bool b) { b_providesRendering = b; }
virtual void cb_redraw(View* scene) = 0;
virtual void cb_keyPress(View* scene, int key) = 0; virtual void redraw(View* view) = 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 cb_viewAdded(View* s) = 0; virtual void keyPress(View* view, int key) = 0;
virtual void cb_viewRemoved(View* s) = 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 * MANAGE LINKED VIEWS
...@@ -85,6 +85,8 @@ protected: ...@@ -85,6 +85,8 @@ protected:
QString m_filePath; QString m_filePath;
Window* m_window; Window* m_window;
bool b_providesRendering;
QList<View*> l_views; QList<View*> l_views;
QList<QWidget*> l_tabWidgets; QList<QWidget*> l_tabWidgets;
QList<QAction*> l_menuActions; QList<QAction*> l_menuActions;
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
class ViewButtonArea; class ViewButtonArea;
class ViewButton; class ViewButton;
class CameraViewDialog;
class PluginsViewDialog;
class MapsViewDialog;
class View : public QGLViewer class View : public QGLViewer
{ {
Q_OBJECT Q_OBJECT
...@@ -26,9 +30,12 @@ public: ...@@ -26,9 +30,12 @@ public:
Window* getWindow() { return m_window; } Window* getWindow() { return m_window; }
void setWindow(Window* w) { m_window = w; } void setWindow(Window* w) { m_window = w; }
virtual void initGL(); virtual void init();
virtual void updateGL(); virtual void preDraw();
virtual void draw(); virtual void draw();
virtual void postDraw();
virtual void resizeGL(int width, int height);
void drawText(); void drawText();
void drawButtons(); void drawButtons();
...@@ -39,8 +46,6 @@ public: ...@@ -39,8 +46,6 @@ public:
void mouseMoveEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event); void wheelEvent(QWheelEvent* event);
virtual void resizeGL(int width, int height);
void drawOverpaint(QPainter *painter); void drawOverpaint(QPainter *painter);
// virtual void paintGL() { update(); } // virtual void paintGL() { update(); }
...@@ -100,8 +105,15 @@ protected: ...@@ -100,8 +105,15 @@ protected:
QString m_textInfo; QString m_textInfo;