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
${SCHNApps_ROOT_DIR}/include/controlDock_cameraTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.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)
ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_renderScalar)
ADD_SUBDIRECTORY(surface_renderTopo)
ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision)
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>200</width>
<height>621</height>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
......
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(
${PLUGIN_ROOT_DIR}/include
......@@ -25,8 +25,8 @@ file(
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/renderTopoSurface.h
${PLUGIN_ROOT_DIR}/include/renderTopoSurfaceDockTab.h
${PLUGIN_ROOT_DIR}/include/surface_renderTopo.h
${PLUGIN_ROOT_DIR}/include/surface_renderTopo_dockTab.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RenderTopoSurfaceDockWidget</class>
<widget class="QWidget" name="RenderTopoSurfaceDockWidget">
<class>Surface_RenderTopo_TabWidget</class>
<widget class="QWidget" name="Surface_RenderTopo_TabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>547</height>
<width>200</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mapList"/>
</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 row="2" column="3">
<widget class="ColorComboBox" name="combo_phi1Color"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawDarts">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawPhi2">
<property name="text">
<string>draw darts</string>
<string>draw phi2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="ColorComboBox" name="combo_dartsColor"/>
</item>
<item row="3" column="0" colspan="3">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawPhi1">
<property name="text">
<string>draw phi1</string>
......@@ -57,30 +37,35 @@
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="ColorComboBox" name="combo_phi1Color"/>
<item row="1" column="3">
<widget class="ColorComboBox" name="combo_dartsColor"/>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawPhi2">
<property name="text">
<string>draw phi2</string>
</property>
<property name="checked">
<bool>true</bool>
<item row="0" 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>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="4" column="3">
<widget class="ColorComboBox" name="combo_phi2Color"/>
</item>
<item row="5" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>explod edges</string>
</property>
</widget>
</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">
<property name="value">
<number>50</number>
......@@ -90,14 +75,7 @@
</property>
</widget>
</item>
<item row="6" column="0" 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">
<item row="5" column="2" colspan="2">
<widget class="QSlider" name="slider_facesScaleFactor">
<property name="value">
<number>50</number>
......@@ -107,7 +85,7 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<item row="6" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -120,6 +98,30 @@
</property>
</spacer>
</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>
</widget>
<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_
#define _RENDER_TOPO_SURFACE_DOCK_TAB_H_
#ifndef _SURFACE_RENDERTOPO_DOCK_TAB_H_
#define _SURFACE_RENDERTOPO_DOCK_TAB_H_
#include "ui_renderTopoSurface.h"
#include "ui_surface_renderTopo.h"
namespace CGoGN
{
......@@ -9,27 +9,25 @@ namespace CGoGN
namespace SCHNApps
{
class Window;
class RenderTopoSurfacePlugin;
struct ParameterSet;
class SCHNApps;
class Surface_RenderTopo_Plugin;
struct MapParameters;
class RenderTopoSurfaceDockTab : public QWidget, public Ui::RenderTopoSurfaceDockWidget
class Surface_RenderTopo_DockTab : public QWidget, public Ui::Surface_RenderTopo_TabWidget
{
Q_OBJECT
friend class Surface_RenderTopo_Plugin;
public:
RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p);
Surface_RenderTopo_DockTab(SCHNApps* s, Surface_RenderTopo_Plugin* p);
private:
Window* m_window;
RenderTopoSurfacePlugin* m_plugin;
ParameterSet* m_currentParams;
bool b_refreshingUI;
public slots:
void refreshUI(ParameterSet* params);
SCHNApps* m_schnapps;
Surface_RenderTopo_Plugin* m_plugin;
bool b_updatingUI;
void selectedMapChanged();
private slots:
void positionAttributeChanged(int index);
void drawDartsChanged(bool b);
void dartsColorChanged(int);
......@@ -40,7 +38,10 @@ public slots:
void edgesScaleFactorChanged(int i);
void facesScaleFactorChanged(int i);
private:
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void updateMapParameters();
};
} // 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();
MapHandlerGen* mh = params->selectedMap;
QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
while (i != params->perMap.constEnd())
{
mapList->addItem(i.key());
if(mh != NULL && i.key() == mh->getName())
{
QList<QListWidgetItem*> item = mapList->findItems(mh->getName(), Qt::MatchExactly);
item[0]->setSelected(true);
PerMapParameterSet* p = params->perMap[mh->getName()];
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
unsigned int j = 0;
const AttributeHash& attribs = mh->getAttributesList(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(i.value() == vec3TypeName)
{
combo_positionAttribute->addItem(i.key());
if(i.key() == QString::fromStdString(p->positionAttribute.name()))
combo_positionAttribute->setCurrentIndex(j);
++j;
}
}
check_drawDarts->setChecked(p->drawDarts);
combo_dartsColor->setColor(p->dartsColor);
check_drawPhi1->setChecked(p->drawPhi1);
combo_phi1Color->setColor(p->phi1Color);
check_drawPhi2->setChecked(p->drawPhi2);
combo_phi2Color->setColor(p->phi2Color);
slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 100.0);
slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 100.0);
}
++i;
}
b_refreshingUI = false;
}
void RenderTopoSurfaceDockTab::selectedMapChanged()
{
if(!b_refreshingUI)
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
}
}
void RenderTopoSurfaceDockTab::positionAttributeChanged(int index)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changePositionAttribute(view, map, map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText()), true);
}
}
void RenderTopoSurfaceDockTab::drawDartsChanged(bool b)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changeDrawDarts(view, map, b, true);
}
}
void RenderTopoSurfaceDockTab::dartsColorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changeDartsColor(view, map, combo_dartsColor->color(), true);
}
}
void RenderTopoSurfaceDockTab::drawPhi1Changed(bool b)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changeDrawPhi1(view, map, b, true);
}
}
void RenderTopoSurfaceDockTab::phi1ColorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changePhi1Color(view, map, combo_phi1Color->color(), true);
}
}
void RenderTopoSurfaceDockTab::drawPhi2Changed(bool b)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changeDrawPhi2(view, map, b, true);
}
}
void RenderTopoSurfaceDockTab::phi2ColorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changePhi2Color(view, map, combo_phi2Color->color(), true);
}
}
void RenderTopoSurfaceDockTab::facesScaleFactorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changeEdgesScaleFactor(view, map, i, true);
}
}
void RenderTopoSurfaceDockTab::edgesScaleFactorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
if(map)
m_plugin->changeFacesScaleFactor(view, map, i, true);
}
}
void RenderTopoSurfaceDockTab::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));