Commit 7192da78 authored by Pierre Kraemer's avatar Pierre Kraemer

renderTopo plugin + PrimitiveSelector (not finished)

parent 1346483a
...@@ -137,7 +137,7 @@ SET(SCHNApps_QOBJECT_FILES ...@@ -137,7 +137,7 @@ SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/controlDock_cameraTab.h ${SCHNApps_ROOT_DIR}/include/controlDock_cameraTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.h ${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_mapTab.h ${SCHNApps_ROOT_DIR}/include/controlDock_mapTab.h
# ${SCHNApps_ROOT_DIR}/include/colorComboBox.h ${SCHNApps_ROOT_DIR}/include/colorComboBox.h
) )
......
...@@ -4,5 +4,6 @@ ADD_SUBDIRECTORY(surface_import) ...@@ -4,5 +4,6 @@ ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_render) ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector) ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_renderScalar) ADD_SUBDIRECTORY(surface_renderScalar)
ADD_SUBDIRECTORY(surface_renderTopo)
ADD_SUBDIRECTORY(surface_differentialProperties) ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision) ADD_SUBDIRECTORY(surface_subdivision)
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>200</width> <width>200</width>
<height>621</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME RenderTopoSurface ) SET( PLUGIN_NAME Surface_RenderTopo )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/renderTopoSurface ) SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_renderTopo )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include ${PLUGIN_ROOT_DIR}/include
...@@ -25,8 +25,8 @@ file( ...@@ -25,8 +25,8 @@ file(
SET( SET(
PLUGIN_QOBJECT_FILES PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/renderTopoSurface.h ${PLUGIN_ROOT_DIR}/include/surface_renderTopo.h
${PLUGIN_ROOT_DIR}/include/renderTopoSurfaceDockTab.h ${PLUGIN_ROOT_DIR}/include/surface_renderTopo_dockTab.h
) )
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt ) include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>RenderTopoSurfaceDockWidget</class> <class>Surface_RenderTopo_TabWidget</class>
<widget class="QWidget" name="RenderTopoSurfaceDockWidget"> <widget class="QWidget" name="Surface_RenderTopo_TabWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>190</width> <width>200</width>
<height>547</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4"> <item row="2" column="3">
<widget class="QListWidget" name="mapList"/> <widget class="ColorComboBox" name="combo_phi1Color"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawDarts"> <widget class="QCheckBox" name="check_drawPhi2">
<property name="text"> <property name="text">
<string>draw darts</string> <string>draw phi2</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3"> <item row="2" column="0" colspan="3">
<widget class="ColorComboBox" name="combo_dartsColor"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawPhi1"> <widget class="QCheckBox" name="check_drawPhi1">
<property name="text"> <property name="text">
<string>draw phi1</string> <string>draw phi1</string>
...@@ -57,30 +37,35 @@ ...@@ -57,30 +37,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="3"> <item row="1" column="3">
<widget class="ColorComboBox" name="combo_phi1Color"/> <widget class="ColorComboBox" name="combo_dartsColor"/>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="0" column="1" colspan="3">
<widget class="QCheckBox" name="check_drawPhi2"> <widget class="QComboBox" name="combo_positionAttribute">
<property name="text"> <property name="sizePolicy">
<string>draw phi2</string> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
</property> <horstretch>0</horstretch>
<property name="checked"> <verstretch>0</verstretch>
<bool>true</bool> </sizepolicy>
</property> </property>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="4" column="0" colspan="2">
<widget class="ColorComboBox" name="combo_phi2Color"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>explod edges</string> <string>explod edges</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2" colspan="2"> <item row="3" column="3">
<widget class="ColorComboBox" name="combo_phi2Color"/>
</item>
<item row="4" column="2" colspan="2">
<widget class="QSlider" name="slider_edgesScaleFactor"> <widget class="QSlider" name="slider_edgesScaleFactor">
<property name="value"> <property name="value">
<number>50</number> <number>50</number>
...@@ -90,14 +75,7 @@ ...@@ -90,14 +75,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="5" column="2" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>explod faces</string>
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<widget class="QSlider" name="slider_facesScaleFactor"> <widget class="QSlider" name="slider_facesScaleFactor">
<property name="value"> <property name="value">
<number>50</number> <number>50</number>
...@@ -107,7 +85,7 @@ ...@@ -107,7 +85,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="4"> <item row="6" column="0" colspan="4">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -120,6 +98,30 @@ ...@@ -120,6 +98,30 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>explod faces</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawDarts">
<property name="text">
<string>draw darts</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
......
#ifndef _RENDERTOPO_SURFACE_PLUGIN_H_
#define _RENDERTOPO_SURFACE_PLUGIN_H_
#include "plugin.h"
#include "renderTopoSurfaceDockTab.h"
#include "Algo/Render/GL2/topoRender.h"
namespace CGoGN
{
namespace SCHNApps
{
struct PerMapParameterSet
{
PerMapParameterSet(MapHandlerGen* mh);
~PerMapParameterSet();
void updateRender();
MapHandlerGen* mh;
Algo::Render::GL2::TopoRender* m_renderTopo;
VertexAttribute<PFP2::VEC3> positionAttribute;
bool drawDarts;
QColor dartsColor;
bool drawPhi1;
QColor phi1Color;
bool drawPhi2;
QColor phi2Color;
float edgesScaleFactor;
float facesScaleFactor;
};
struct ParameterSet
{
ParameterSet() : selectedMap(NULL)
{}
QHash<QString, PerMapParameterSet*> perMap;
MapHandlerGen* selectedMap;
};
class RenderTopoSurfacePlugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
RenderTopoSurfacePlugin()
{
setProvidesRendering(true);
}
~RenderTopoSurfacePlugin()
{}
virtual bool enable();
virtual void disable();
virtual void redraw(View *view);
virtual void keyPress(View* view, QKeyEvent* event) {}
virtual void keyRelease(View* view, QKeyEvent* event) {}
virtual void mousePress(View* view, QMouseEvent* event);
virtual void mouseRelease(View* view, QMouseEvent* event) {}
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
protected:
RenderTopoSurfaceDockTab* m_dockTab;
QHash<View*, ParameterSet*> h_viewParams;
public slots:
void viewLinked(View* view, Plugin* plugin);
void viewUnlinked(View* view, Plugin* plugin);
void currentViewChanged(View* view);
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
protected:
void addManagedMap(View *v, MapHandlerGen* m);
void removeManagedMap(View *v, MapHandlerGen* m);
public slots:
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP2::VEC3> attribute, bool fromUI = false);
void changeDrawDarts(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeDartsColor(View* view, MapHandlerGen* map, QColor c, bool fromUI = false);
void changeDrawPhi1(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changePhi1Color(View* view, MapHandlerGen* map, QColor c, bool fromUI = false);
void changeDrawPhi2(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changePhi2Color(View* view, MapHandlerGen* map, QColor c, bool fromUI = false);
void changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void attributeModified(unsigned int orbit, QString nameAttr);
void connectivityModified();
signals:
void dartSelected(Dart d);
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _SURFACE_RENDERTOPO_PLUGIN_H_
#define _SURFACE_RENDERTOPO_PLUGIN_H_
#include "plugin_interaction.h"
#include "surface_renderTopo_dockTab.h"
#include "Algo/Render/GL2/topoRender.h"
namespace CGoGN
{
namespace SCHNApps
{
struct MapParameters
{
MapParameters() :
drawDarts(true),
dartsColor("white"),
drawPhi1(true),
phi1Color("cyan"),
drawPhi2(true),
phi2Color("red"),
edgesScaleFactor(1.0f),
facesScaleFactor(1.0f)
{}
VertexAttribute<PFP2::VEC3> positionAttribute;
bool drawDarts;
QColor dartsColor;
bool drawPhi1;
QColor phi1Color;
bool drawPhi2;
QColor phi2Color;
float edgesScaleFactor;
float facesScaleFactor;
};
class Surface_RenderTopo_Plugin : public PluginInteraction
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class Surface_RenderTopo_DockTab;
public:
Surface_RenderTopo_Plugin()
{}
~Surface_RenderTopo_Plugin()
{}
virtual bool enable();
virtual void disable();
virtual void draw(View *view) {}
virtual void drawMap(View* view, MapHandlerGen* map);
virtual void keyPress(View* view, QKeyEvent* event) {}
virtual void keyRelease(View* view, QKeyEvent* event) {}
virtual void mousePress(View* view, QMouseEvent* event) {}
virtual void mouseRelease(View* view, QMouseEvent* event) {}
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
virtual void viewLinked(View *view) {}
virtual void viewUnlinked(View *view) {}
private slots:
// slots called from SCHNApps signals
void selectedViewChanged(View* prev, View* cur);
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
// slots called from MapHandler signals
void attributeAdded(unsigned int orbit, const QString& nameAttr);
public slots:
// slots for Python calls
// void changePositionAttribute(const QString& view, const QString& map, const QString& attrName);
// void changeDrawDarts(const QString& view, const QString& map, bool b);
// void changeDartsColor(const QString& view, const QString& map, QColor c);
// void changeDrawPhi1(const QString& view, const QString& map, bool b);
// void changePhi1Color(const QString& view, const QString& map, QColor c);
// void changeDrawPhi2(const QString& view, const QString& map, bool b);
// void changePhi2Color(const QString& view, const QString& map, QColor c);
// void changeEdgesScaleFactor(const QString& view, const QString& map, int i);
// void changeFacesScaleFactor(const QString& view, const QString& map, int i);
//signals:
// void dartSelected(Dart d);
protected:
Surface_RenderTopo_DockTab* m_dockTab;
QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _RENDER_TOPO_SURFACE_DOCK_TAB_H_ #ifndef _SURFACE_RENDERTOPO_DOCK_TAB_H_
#define _RENDER_TOPO_SURFACE_DOCK_TAB_H_ #define _SURFACE_RENDERTOPO_DOCK_TAB_H_
#include "ui_renderTopoSurface.h" #include "ui_surface_renderTopo.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -9,27 +9,25 @@ namespace CGoGN ...@@ -9,27 +9,25 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
class Window; class SCHNApps;
class RenderTopoSurfacePlugin; class Surface_RenderTopo_Plugin;
struct ParameterSet; struct MapParameters;
class RenderTopoSurfaceDockTab : public QWidget, public Ui::RenderTopoSurfaceDockWidget class Surface_RenderTopo_DockTab : public QWidget, public Ui::Surface_RenderTopo_TabWidget
{ {
Q_OBJECT Q_OBJECT
friend class Surface_RenderTopo_Plugin;
public: public:
RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p); Surface_RenderTopo_DockTab(SCHNApps* s, Surface_RenderTopo_Plugin* p);
private: private:
Window* m_window; SCHNApps* m_schnapps;
RenderTopoSurfacePlugin* m_plugin; Surface_RenderTopo_Plugin* m_plugin;
ParameterSet* m_currentParams; bool b_updatingUI;
bool b_refreshingUI;
public slots:
void refreshUI(ParameterSet* params);
void selectedMapChanged(); private slots:
void positionAttributeChanged(int index); void positionAttributeChanged(int index);
void drawDartsChanged(bool b); void drawDartsChanged(bool b);
void dartsColorChanged(int); void dartsColorChanged(int);
...@@ -40,7 +38,10 @@ public slots: ...@@ -40,7 +38,10 @@ public slots:
void edgesScaleFactorChanged(int i); void edgesScaleFactorChanged(int i);
void facesScaleFactorChanged(int i); void facesScaleFactorChanged(int i);
private:
void addAttributeToList(unsigned int orbit, const QString& nameAttr); void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void updateMapParameters();
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
#include "renderTopoSurfaceDockTab.h"
#include "renderTopoSurface.h"
#include "window.h"
#include "mapHandler.h"
namespace CGoGN
{
namespace SCHNApps
{
RenderTopoSurfaceDockTab::RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p) :
m_window(w),
m_plugin(p),
b_refreshingUI(false)
{
setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(check_drawDarts, SIGNAL(toggled(bool)), this, SLOT(drawDartsChanged(bool)));
connect(combo_dartsColor, SIGNAL(currentIndexChanged(int)), this, SLOT(dartsColorChanged(int)));
connect(check_drawPhi1, SIGNAL(toggled(bool)), this, SLOT(drawPhi1Changed(bool)));
connect(combo_phi1Color, SIGNAL(currentIndexChanged(int)), this, SLOT(phi1ColorChanged(int)));
connect(check_drawPhi2, SIGNAL(toggled(bool)), this, SLOT(drawPhi2Changed(bool)));
connect(combo_phi2Color, SIGNAL(currentIndexChanged(int)), this, SLOT(phi2ColorChanged(int)));
connect(slider_edgesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(edgesScaleFactorChanged(int)));
connect(slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int)));
}
void RenderTopoSurfaceDockTab::refreshUI(ParameterSet* params)
{
m_currentParams = params;
b_refreshingUI = true;
mapList->clear();
combo_positionAttribute->clear();