Commit 3cae3e11 authored by Sylvain Thery's avatar Sylvain Thery

schnapps interface modifs

parent c12a2401
......@@ -150,6 +150,7 @@ SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_mapTab.h
${SCHNApps_ROOT_DIR}/include/colorComboBox.h
${SCHNApps_ROOT_DIR}/include/dialogList.h
)
......
......@@ -38,6 +38,8 @@ private slots:
void computeNormalFromDialog();
void computeCurvatureFromDialog();
void appsFinished();
public slots:
void computeNormal(const QString& mapName,
const QString& positionAttributeName = "position",
......
......@@ -37,6 +37,9 @@ bool Surface_DifferentialProperties_Plugin::enable()
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
mapAdded(map);
......@@ -56,6 +59,8 @@ void Surface_DifferentialProperties_Plugin::disable()
disconnect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
}
void Surface_DifferentialProperties_Plugin::mapAdded(MapHandlerGen *map)
......@@ -213,6 +218,7 @@ void Surface_DifferentialProperties_Plugin::computeNormal(
mh->notifyAttributeModification(normal);
}
void Surface_DifferentialProperties_Plugin::computeCurvature(
const QString& mapName,
const QString& positionAttributeName,
......@@ -303,6 +309,13 @@ void Surface_DifferentialProperties_Plugin::computeCurvature(
}
}
void Surface_DifferentialProperties_Plugin::appsFinished()
{
m_computeNormalDialog->close();
m_computeCurvatureDialog->close();
}
Q_EXPORT_PLUGIN2(Surface_DifferentialProperties_Plugin, Surface_DifferentialProperties_Plugin)
} // namespace SCHNApps
......
......@@ -67,6 +67,8 @@ public:
~Surface_Render_Plugin()
{}
private:
virtual bool enable();
virtual void disable();
......@@ -95,6 +97,8 @@ private slots:
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
void appsFinished();
public slots:
// slots for Python calls
......
......@@ -41,6 +41,7 @@ bool Surface_Render_Plugin::enable()
connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
mapAdded(map);
......@@ -61,6 +62,7 @@ void Surface_Render_Plugin::disable()
disconnect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(appsFinished()), this, SLOT(appsFinished()));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
mapRemoved(map);
......@@ -397,6 +399,12 @@ void Surface_Render_Plugin::changeVertexColor(const QString& view, const QString
}
void Surface_Render_Plugin::appsFinished()
{
m_dockTab->m_colorDial->close();
}
Q_EXPORT_PLUGIN2(Surface_Render_Plugin, Surface_Render_Plugin)
} // namespace SCHNApps
......
......@@ -29,6 +29,7 @@ public:
private slots:
void openSubdivisionDialog();
void subdivideFromDialog();
void appsFinished();
public slots:
void loopSubdivision(
......
......@@ -125,6 +125,12 @@ void Surface_Subdivision_Plugin::trianguleFaces(
view->updateGL();
}
void Surface_Subdivision_Plugin::appsFinished()
{
m_subdivisionDialog->close();
}
Q_EXPORT_PLUGIN2(Surface_Subdivision_Plugin, Surface_Subdivision_Plugin)
} // namespace SCHNApps
......
......@@ -26,6 +26,12 @@ public:
~Camera();
const QString& getName() const { return m_name; }
void updateParams();
void drawBBCam();
bool m_drawBB;
public slots:
QString getName() { return m_name; }
SCHNApps* getSCHNApps() const { return m_schnapps; }
......@@ -40,24 +46,34 @@ public slots:
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
bool isLinkedToMap(MapHandlerGen* mhg) const;
private:
void linkView(View* view);
void unlinkView(View* view);
private slots:
void frameModified();
void mapAdded(MapHandlerGen* mhg);
void mapRemoved(MapHandlerGen* mhg);
void BBModified();
public slots:
void setProjectionType(int t);
void setDraw(bool b);
void setDrawPath(bool b);
signals:
void projectionTypeChanged(int);
void drawChanged(bool);
void drawPathChanged(bool);
protected:
qglviewer::Vec m_bbMin;
qglviewer::Vec m_bbMax;
QString m_name;
SCHNApps* m_schnapps;
......
......@@ -28,22 +28,25 @@ private slots:
void cameraProjectionChanged(QAbstractButton* b);
void cameraDrawClicked(bool b);
void cameraDrawPathClicked(bool b);
void cameraSelectionChanged();
// slots called from SCHNApps signals
void cameraAdded(Camera* c);
void cameraRemoved(Camera* c);
void selectedViewChanged(View* prev, View* cur);
// void selectedViewChanged(View* prev, View* cur);
// slots called from selected View signals
void selectedViewCurrentCameraChanged(Camera* prev, Camera* cur);
// void selectedViewCurrentCameraChanged(Camera* prev, Camera* cur);
// slots called from current Camera signals
void currentCameraProjectionTypeChanged(int t);
void currentCameraDrawChanged(bool b);
void currentCameraDrawPathChanged(bool b);
// void currentCameraProjectionTypeChanged(int t);
// void currentCameraDrawChanged(bool b);
// void currentCameraDrawPathChanged(bool b);
private:
void updateCurrentCameraInfo();
Camera* currentCam();
SCHNApps* m_schnapps;
bool b_updatingUI;
......
......@@ -36,7 +36,7 @@ public:
private slots:
// slots called from UI actions
void selectedMapChanged();
void mapCheckStateChanged(QListWidgetItem* item);
// void mapCheckStateChanged(QListWidgetItem* item);
void vertexAttributeCheckStateChanged(QListWidgetItem* item);
void selectedSelectorChanged();
......@@ -47,11 +47,11 @@ private slots:
// slots called from SCHNApps signals
void mapAdded(MapHandlerGen* m);
void mapRemoved(MapHandlerGen* m);
void selectedViewChanged(View* prev, View* cur);
// void selectedViewChanged(View* prev, View* cur);
// slots called from selected View signals
void selectedViewMapLinked(MapHandlerGen* plugin);
void selectedViewMapUnlinked(MapHandlerGen* plugin);
// void selectedViewMapLinked(MapHandlerGen* plugin);
// void selectedViewMapUnlinked(MapHandlerGen* plugin);
// slots called from selected MapHandler signals
void selectedMapAttributeAdded(unsigned int orbit, const QString& name);
......
......@@ -27,17 +27,17 @@ private slots:
void addPluginDirectoryClicked();
void enableSelectedPluginsClicked();
void disableSelectedPluginsClicked();
void pluginCheckStateChanged(QListWidgetItem* item);
// void pluginCheckStateChanged(QListWidgetItem* item);
// slots called from SCHNApps signals
void pluginAvailableAdded(QString name);
void pluginEnabled(Plugin* plugin);
void pluginDisabled(Plugin* plugin);
void selectedViewChanged(View* prev, View* cur);
// void selectedViewChanged(View* prev, View* cur);
// slots called from selected View signals
void selectedViewPluginLinked(PluginInteraction* plugin);
void selectedViewPluginUnlinked(PluginInteraction* plugin);
// void selectedViewPluginLinked(PluginInteraction* plugin);
// void selectedViewPluginUnlinked(PluginInteraction* plugin);
private:
SCHNApps* m_schnapps;
......
#ifndef _DIALOG_LIST_H_
#define _DIALOG_LIST_H_
#include <QDialog>
#include <QVBoxLayout>
#include <QListWidget>
#include <QListWidgetItem>
namespace CGoGN
{
namespace SCHNApps
{
class ListPopUp : public QDialog
{
Q_OBJECT
QVBoxLayout* m_layout;
QListWidget* m_list_items;
public:
ListPopUp(const QString& name, QWidget* parent = NULL);
virtual ~ListPopUp();
QListWidget* list();
QListWidgetItem* addItem(const QString& str, Qt::CheckState checked = Qt::Unchecked);
QListWidgetItem* getItem(unsigned int row);
unsigned int nbItems();
QListWidgetItem* findItem(const QString& str);
bool removeItem(const QString& str);
void check(const QString& str, Qt::CheckState ck);
bool isChecked(const QString& str);
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
......@@ -51,8 +51,8 @@ public slots:
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
const qglviewer::Vec& getBBmin() const { return m_bbMin; }
const qglviewer::Vec& getBBmax() const { return m_bbMax; }
// const qglviewer::Vec& getBBmin() const { return m_bbMin; }
// const qglviewer::Vec& getBBmax() const { return m_bbMax; }
float getBBdiagSize() const { return m_bbDiagSize; }
Utils::GLSLShader* getBBDrawerShader() const
......@@ -77,9 +77,12 @@ public slots:
return matrix;
}
void frameModified() { DEBUG_EMIT("frameModified");emit(BBisModified());}
public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
virtual void drawBB() = 0;
virtual void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
void setPrimitiveDirty(int primitive) { m_render->setPrimitiveDirty(primitive); }
......@@ -181,6 +184,8 @@ signals:
void cellSelectorRemoved(unsigned int orbit, const QString& name);
void selectedCellsChanged(CellSelectorGen* cs);
void BBisModified();
protected:
QString m_name;
SCHNApps* m_schnapps;
......@@ -253,6 +258,9 @@ public:
void updateBB(const VertexAttribute<VEC3, MAP>& position);
void updateBBDrawer();
void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax);
/*********************************************************
* MANAGE TOPO DRAWING
*********************************************************/
......
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Geometry/bounding_box.h"
namespace CGoGN
{
......@@ -73,10 +75,8 @@ void MapHandler<PFP>::draw(Utils::GLSLShader* shader, int primitive)
if(!m_render->isPrimitiveUpToDate(primitive))
m_render->initPrimitives<PFP>(*(static_cast<MAP*>(m_map)), primitive) ;
glPushMatrix();
glMultMatrixd(m_frame->matrix());
m_render->draw(shader, primitive);
glPopMatrix();
}
template <typename PFP>
......@@ -88,32 +88,30 @@ void MapHandler<PFP>::drawBB()
updateBBDrawer();
}
glPushMatrix();
glMultMatrixd(m_frame->matrix());
// QGLViewer::drawAxis();
m_bbDrawer->callList();
glPopMatrix();
}
template <typename PFP>
void MapHandler<PFP>::updateBB(const VertexAttribute<VEC3, MAP>& position)
{
m_bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*(static_cast<MAP*>(m_map)), position);
m_bbMin = qglviewer::Vec(m_bb.min()[0], m_bb.min()[1], m_bb.min()[2]);
m_bbMax = qglviewer::Vec(m_bb.max()[0], m_bb.max()[1], m_bb.max()[2]);
m_bbDiagSize = (m_bbMax - m_bbMin).norm();
m_bbDiagSize = m_bb.diagSize();
updateBBDrawer();
}
template <typename PFP>
void MapHandler<PFP>::updateBBDrawer()
{
if(!m_bbDrawer)
m_bbDrawer = new Utils::Drawer();
const Geom::Vec3f& bbmin = m_bb.min();
const Geom::Vec3f& bbmax = m_bb.max();
Geom::Vec3f bbmin = m_bb.min();
Geom::Vec3f bbmax = m_bb.max();
float shift = 0.005f*(bbmax - bbmin).norm();
bbmin -= Geom::Vec3f(shift,shift,shift);
bbmax += Geom::Vec3f(shift,shift,shift);
m_bbDrawer->newList(GL_COMPILE);
m_bbDrawer->color3f(0.0f,1.0f,0.0f);
......@@ -229,6 +227,52 @@ void MapHandler<PFP>::drawTopoRender(int code)
template <typename PFP>
void MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax)
{
const Geom::Vec3f& BBmin = m_bb.min();
const Geom::Vec3f& BBMax = m_bb.max();
CGoGN::Geom::BoundingBox<typename PFP::VEC3> bb;
qglviewer::Vec v = qglviewer::Vec(BBmin[0], BBmin[1], BBmin[2]);
qglviewer::Vec vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBMax[0], BBmin[1], BBmin[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBmin[0], BBMax[1], BBmin[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBmin[0], BBmin[1], BBMax[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBMax[0], BBMax[1], BBmin[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBMax[0], BBmin[1], BBMax[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBmin[0], BBMax[1], BBMax[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
v = qglviewer::Vec(BBMax[0], BBMax[1], BBMax[2]);
vt = m_frame->inverseCoordinatesOf(v);
bb.addPoint(Geom::Vec3f(vt[0], vt[1], vt[2]));
bbMin = qglviewer::Vec(bb.min()[0], bb.min()[1], bb.min()[2]);
bbMax = qglviewer::Vec(bb.max()[0], bb.max()[1], bb.max()[2]);
}
} // namespace SCHNApps
......
......@@ -47,6 +47,8 @@ public slots:
/*********************************************************
* MANAGE VIEWS
*********************************************************/
public:
void redrawAllViews();
public slots:
View* addView(const QString& name);
......@@ -151,6 +153,8 @@ signals:
void pluginEnabled(Plugin* plugin);
void pluginDisabled(Plugin* plugin);
void appsFinished();
protected:
QString m_appPath;
PythonQtObjectPtr& m_pythonContext;
......@@ -186,6 +190,8 @@ protected:
TextureSet m_textures;
StaticPointers m_sp;
void closeEvent(QCloseEvent *event);
};
} // namespace SCHNApps
......
......@@ -5,6 +5,8 @@
#include <QGLViewer/qglviewer.h>
#include <QGLViewer/manipulatedFrame.h>
#include "dialogList.h"
#include "schnapps.h"
#include "Utils/gl_matrices.h"
......@@ -19,6 +21,7 @@ class ViewButtonArea;
class ViewButton;
class PluginInteraction;
class View : public QGLViewer
{
Q_OBJECT
......@@ -34,7 +37,9 @@ public:
const QString& getName() const { return m_name; }
MapHandlerGen* lastSelectedMap() { return m_lastSelectedMap;}
void setLastSelectedMap(MapHandlerGen* m) { m_lastSelectedMap=m; }
// void setLastSelectedMap(MapHandlerGen* m) { m_lastSelectedMap=m; }
void closeDialogs();
public slots:
QString getName() { return m_name; }
......@@ -67,6 +72,8 @@ public slots:
bool isLinkedToMap(const QString& name) const;
private:
bool b_updatingUI;
virtual void init();
virtual void preDraw();
virtual void draw();
......@@ -87,7 +94,7 @@ private:
glm::mat4 getCurrentProjectionMatrix() const;
glm::mat4 getCurrentModelViewProjectionMatrix() const;
void updateCurrentCameraBB();
// void updateCurrentCameraBB();
private slots:
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
......@@ -96,6 +103,22 @@ private slots:
void ui_horizontalSplitView(int x, int y, int globalX, int globalY);
void ui_closeView(int x, int y, int globalX, int globalY);
void ui_mapsListView(int x, int y, int globalX, int globalY);
void ui_pluginsListView(int x, int y, int globalX, int globalY);
void ui_camerasListView(int x, int y, int globalX, int globalY);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
void pluginEnabled(Plugin *plugin);
void pluginDisabled(Plugin *plugin);
void cameraAdded(Camera* camera);
void cameraRemoved(Camera* camera);
void mapCheckStateChanged(QListWidgetItem* item);
void pluginCheckStateChanged(QListWidgetItem* item);
void cameraCheckStateChanged(QListWidgetItem* item);
signals:
void currentCameraChanged(Camera*, Camera*);
......@@ -120,7 +143,17 @@ protected:
ViewButton* m_VsplitButton;
ViewButton* m_HsplitButton;
ViewButtonArea* m_buttonAreaLeft;
ViewButton* m_mapsButton;
ViewButton* m_pluginsButton;
ViewButton* m_camerasButton;
QString m_textInfo;
ListPopUp* m_dialogMaps;
ListPopUp* m_dialogPlugins;
ListPopUp* m_dialogCameras;
};
} // namespace SCHNApps
......
......@@ -69,6 +69,8 @@ public:
void setTopRightPosition(int x, int y);
void setTopLeftPosition(int x, int y);
void draw();
protected:
......
#include "camera.h"
#include "mapHandler.h"
namespace CGoGN
{
......@@ -9,6 +10,7 @@ namespace SCHNApps
unsigned int Camera::cameraCount = 0;
Camera::Camera(const QString& name, SCHNApps* s) :
m_drawBB(false),
m_name(name),
m_schnapps(s),
m_draw(false),
......@@ -16,6 +18,22 @@ Camera::Camera(const QString& name, SCHNApps* s) :
{
++cameraCount;
connect(this->frame(), SIGNAL(modified()), this, SLOT(frameModified()));
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
{
// do the code of BBModified for each linked map
if (isLinkedToMap(map))
updateParams();
foreach(View* v, l_views)
{
v->updateGL();
}
// and do the connection for map added
mapAdded(map);
}
}
Camera::~Camera()
......@@ -73,6 +91,122 @@ void Camera::frameModified()
}
}
void Camera::updateParams()
{
// get all maps viewed by camera
QSet<MapHandlerGen*> q_maps;
foreach(View* view, l_views)
{
QList<MapHandlerGen*> l_maps = view->getLinkedMaps();
foreach(MapHandlerGen* mhg, l_maps)
q_maps.insert(mhg);
}
if (!q_maps.empty())
{
// to help debug I store bb min/max in camera for camera bb drawing
// qglviewer::Vec m_bbMin;
// qglviewer::Vec m_bbMax;
(*q_maps.begin())->transformedBB(m_bbMin,m_bbMax);
foreach(MapHandlerGen* mhg, q_maps)
{
qglviewer::Vec minbb;
qglviewer::Vec maxbb;
mhg->transformedBB(minbb,maxbb);
for(unsigned int dim = 0; dim < 3; ++dim)
{
if(minbb[dim] < m_bbMin[dim])
m_bbMin[dim] = minbb[dim];
if(maxbb[dim] > m_bbMax[dim])
m_bbMax[dim] = maxbb[dim];
}
}
this->setSceneBoundingBox(m_bbMin, m_bbMax);
this->showEntireScene();
}
}
bool Camera::isLinkedToMap(MapHandlerGen* mhg) const
{
const QString& mapName = mhg->getName();
foreach(View* v, l_views)
{
if (v->isLinkedToMap(mapName))
return true;
}
return false;
}
void Camera::mapAdded(MapHandlerGen* mhg)
{
// all maps signals to camera its existence
// selection if done by BBModified
connect(mhg, SIGNAL(BBisModified()), this, SLOT(BBModified()));
}
void Camera::mapRemoved(MapHandlerGen* mhg)
{
disconnect(mhg, SIGNAL(BBisModified()), this, SLOT(BBModified()));
}
void Camera::BBModified()
{
DEBUG_SLOT();
MapHandlerGen* mhg = static_cast<MapHandlerGen*>(QObject::sender());
if (isLinkedToMap(mhg))
updateParams();
foreach(View* v, l_views)
{
v->updateGL();
}
}
void Camera::drawBBCam()
{
if (!m_drawBB)
return;
float shift = 0.01f*(m_bbMax - m_bbMin).norm();
glDisable(GL_LIGHTING);
glColor3f(0.5f,1.0f,0.0f);
glLineWidth(1.0f);
glBegin(GL_LINE_LOOP);
glVertex3f(m_bbMin[0]-shift, m_bbMin[1]-shift, m_bbMin[2]-shift);
glVertex3f(m_bbMin[0]-shift, m_bbMax[1]+shift, m_bbMin[2]-shift);
glVertex3f(m_bbMax[0]+shift, m_bbMax[1]+shift, m_bbMin[2]-shift);
glVertex3f(m_bbMax[0]+shift, m_bbMin[1]-shift, m_bbMin[2]-shift);
glVertex3f(m_bbMin[0]-shift, m_bbMin[1]-shift, m_bbMin[2]-shift);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(m_bbMax[0]+shift, m_bbMax[1]+shift, m_bbMax[2]+shift);
glVertex3f(m_bbMax[0]+shift, m_bbMin[1]-shift, m_bbMax[2]+shift);
glVertex3f