Commit 353f07b8 authored by Pierre Kraemer's avatar Pierre Kraemer

new plugin -> renderVector

parent 4266a0c6
......@@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_differentialProperties)
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME DifferentialProperties )
SET( PLUGIN_NAME Surface_DifferentialProperties )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_differentialProperties )
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SurfaceRender_TabWidget</class>
<widget class="QWidget" name="SurfaceRender_TabWidget">
<class>Surface_Render_TabWidget</class>
<widget class="QWidget" name="Surface_Render_TabWidget">
<property name="geometry">
<rect>
<x>0</x>
......
......@@ -44,18 +44,18 @@ struct MapParameters
FaceShadingStyle faceStyle;
};
class SurfaceRenderPlugin : public PluginInteraction
class Surface_Render_Plugin : public PluginInteraction
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class SurfaceRender_DockTab;
friend class Surface_Render_DockTab;
public:
SurfaceRenderPlugin()
Surface_Render_Plugin()
{}
~SurfaceRenderPlugin()
~Surface_Render_Plugin()
{}
private:
......@@ -97,7 +97,7 @@ public slots:
void changeFacesStyle(const QString& view, const QString& map, MapParameters::FaceShadingStyle style);
protected:
SurfaceRender_DockTab* m_dockTab;
Surface_Render_DockTab* m_dockTab;
QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;
CGoGN::Utils::ShaderFlat* m_flatShader;
......
......@@ -11,21 +11,21 @@ namespace SCHNApps
{
class SCHNApps;
class SurfaceRenderPlugin;
class Surface_Render_Plugin;
struct MapParameters;
class SurfaceRender_DockTab : public QWidget, public Ui::SurfaceRender_TabWidget
class Surface_Render_DockTab : public QWidget, public Ui::Surface_Render_TabWidget
{
Q_OBJECT
friend class SurfaceRenderPlugin;
friend class Surface_Render_Plugin;
public:
SurfaceRender_DockTab(SCHNApps* s, SurfaceRenderPlugin* p);
Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p);
private:
SCHNApps* m_schnapps;
SurfaceRenderPlugin* m_plugin;
Surface_Render_Plugin* m_plugin;
bool b_updatingUI;
private slots:
......
......@@ -8,10 +8,10 @@ namespace CGoGN
namespace SCHNApps
{
bool SurfaceRenderPlugin::enable()
bool Surface_Render_Plugin::enable()
{
m_dockTab = new SurfaceRender_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "SurfaceRender");
m_dockTab = new Surface_Render_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Render");
m_flatShader = new CGoGN::Utils::ShaderFlat();
m_flatShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f));
......@@ -48,7 +48,7 @@ bool SurfaceRenderPlugin::enable()
return true;
}
void SurfaceRenderPlugin::disable()
void Surface_Render_Plugin::disable()
{
delete m_flatShader;
delete m_phongShader;
......@@ -59,7 +59,7 @@ void SurfaceRenderPlugin::disable()
mapRemoved(map);
}
void SurfaceRenderPlugin::drawMap(View* view, MapHandlerGen* map)
void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
const MapParameters& p = h_viewParameterSet[view][map];
if(p.positionVBO)
......@@ -88,15 +88,15 @@ void SurfaceRenderPlugin::drawMap(View* view, MapHandlerGen* map)
case MapParameters::FLAT :
m_flatShader->setAttributePosition(p.positionVBO);
map->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES);
break ;
break;
case MapParameters::PHONG :
if(p.normalVBO != NULL)
{
m_phongShader->setAttributePosition(p.positionVBO) ;
m_phongShader->setAttributeNormal(p.normalVBO) ;
m_phongShader->setAttributePosition(p.positionVBO);
m_phongShader->setAttributeNormal(p.normalVBO);
map->draw(m_phongShader, CGoGN::Algo::Render::GL2::TRIANGLES);
}
break ;
break;
}
glDisable(GL_POLYGON_OFFSET_FILL);
}
......@@ -107,23 +107,23 @@ void SurfaceRenderPlugin::drawMap(View* view, MapHandlerGen* map)
void SurfaceRenderPlugin::selectedViewChanged(View *prev, View *cur)
void Surface_Render_Plugin::selectedViewChanged(View *prev, View *cur)
{
m_dockTab->updateMapParameters();
}
void SurfaceRenderPlugin::selectedMapChanged(MapHandlerGen *prev, MapHandlerGen *cur)
void Surface_Render_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandlerGen *cur)
{
m_dockTab->updateMapParameters();
}
void SurfaceRenderPlugin::mapAdded(MapHandlerGen *map)
void Surface_Render_Plugin::mapAdded(MapHandlerGen *map)
{
connect(map, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
connect(map, SIGNAL(vboRemoved(Utils::VBO*)), this, SLOT(vboRemoved(Utils::VBO*)));
}
void SurfaceRenderPlugin::mapRemoved(MapHandlerGen *map)
void Surface_Render_Plugin::mapRemoved(MapHandlerGen *map)
{
disconnect(map, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
disconnect(map, SIGNAL(vboRemoved(Utils::VBO*)), this, SLOT(vboRemoved(Utils::VBO*)));
......@@ -133,7 +133,7 @@ void SurfaceRenderPlugin::mapRemoved(MapHandlerGen *map)
void SurfaceRenderPlugin::vboAdded(Utils::VBO *vbo)
void Surface_Render_Plugin::vboAdded(Utils::VBO *vbo)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
......@@ -147,7 +147,7 @@ void SurfaceRenderPlugin::vboAdded(Utils::VBO *vbo)
}
}
void SurfaceRenderPlugin::vboRemoved(Utils::VBO *vbo)
void Surface_Render_Plugin::vboRemoved(Utils::VBO *vbo)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
......@@ -188,7 +188,7 @@ void SurfaceRenderPlugin::vboRemoved(Utils::VBO *vbo)
void SurfaceRenderPlugin::changePositionVBO(const QString& view, const QString& map, const QString& vbo)
void Surface_Render_Plugin::changePositionVBO(const QString& view, const QString& map, const QString& vbo)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -204,7 +204,7 @@ void SurfaceRenderPlugin::changePositionVBO(const QString& view, const QString&
}
}
void SurfaceRenderPlugin::changeNormalVBO(const QString& view, const QString& map, const QString& vbo)
void Surface_Render_Plugin::changeNormalVBO(const QString& view, const QString& map, const QString& vbo)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -220,7 +220,7 @@ void SurfaceRenderPlugin::changeNormalVBO(const QString& view, const QString& ma
}
}
void SurfaceRenderPlugin::changeRenderVertices(const QString& view, const QString& map, bool b)
void Surface_Render_Plugin::changeRenderVertices(const QString& view, const QString& map, bool b)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -235,7 +235,7 @@ void SurfaceRenderPlugin::changeRenderVertices(const QString& view, const QStrin
}
}
void SurfaceRenderPlugin::changeVerticesScaleFactor(const QString& view, const QString& map, float f)
void Surface_Render_Plugin::changeVerticesScaleFactor(const QString& view, const QString& map, float f)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -250,7 +250,7 @@ void SurfaceRenderPlugin::changeVerticesScaleFactor(const QString& view, const Q
}
}
void SurfaceRenderPlugin::changeRenderEdges(const QString& view, const QString& map, bool b)
void Surface_Render_Plugin::changeRenderEdges(const QString& view, const QString& map, bool b)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -265,7 +265,7 @@ void SurfaceRenderPlugin::changeRenderEdges(const QString& view, const QString&
}
}
void SurfaceRenderPlugin::changeRenderFaces(const QString& view, const QString& map, bool b)
void Surface_Render_Plugin::changeRenderFaces(const QString& view, const QString& map, bool b)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -280,7 +280,7 @@ void SurfaceRenderPlugin::changeRenderFaces(const QString& view, const QString&
}
}
void SurfaceRenderPlugin::changeFacesStyle(const QString& view, const QString& map, MapParameters::FaceShadingStyle style)
void Surface_Render_Plugin::changeFacesStyle(const QString& view, const QString& map, MapParameters::FaceShadingStyle style)
{
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -296,9 +296,9 @@ void SurfaceRenderPlugin::changeFacesStyle(const QString& view, const QString& m
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(SurfaceRenderPlugin, SurfaceRenderPlugin)
Q_EXPORT_PLUGIN2(Surface_Render_Plugin, Surface_Render_Plugin)
#else
Q_EXPORT_PLUGIN2(SurfaceRenderPluginD, SurfaceRenderPlugin)
Q_EXPORT_PLUGIN2(Surface_Render_PluginD, Surface_Render_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -10,7 +10,7 @@ namespace CGoGN
namespace SCHNApps
{
SurfaceRender_DockTab::SurfaceRender_DockTab(SCHNApps* s, SurfaceRenderPlugin* p) :
Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) :
m_schnapps(s),
m_plugin(p),
b_updatingUI(false)
......@@ -26,7 +26,11 @@ SurfaceRender_DockTab::SurfaceRender_DockTab(SCHNApps* s, SurfaceRenderPlugin* p
connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*)));
}
void SurfaceRender_DockTab::positionVBOChanged(int index)
void Surface_Render_DockTab::positionVBOChanged(int index)
{
if(!b_updatingUI)
{
......@@ -40,7 +44,7 @@ void SurfaceRender_DockTab::positionVBOChanged(int index)
}
}
void SurfaceRender_DockTab::normalVBOChanged(int index)
void Surface_Render_DockTab::normalVBOChanged(int index)
{
if(!b_updatingUI)
{
......@@ -54,7 +58,7 @@ void SurfaceRender_DockTab::normalVBOChanged(int index)
}
}
void SurfaceRender_DockTab::renderVerticesChanged(bool b)
void Surface_Render_DockTab::renderVerticesChanged(bool b)
{
if(!b_updatingUI)
{
......@@ -68,7 +72,7 @@ void SurfaceRender_DockTab::renderVerticesChanged(bool b)
}
}
void SurfaceRender_DockTab::verticesScaleFactorChanged(int i)
void Surface_Render_DockTab::verticesScaleFactorChanged(int i)
{
if(!b_updatingUI)
{
......@@ -82,7 +86,7 @@ void SurfaceRender_DockTab::verticesScaleFactorChanged(int i)
}
}
void SurfaceRender_DockTab::renderEdgesChanged(bool b)
void Surface_Render_DockTab::renderEdgesChanged(bool b)
{
if(!b_updatingUI)
{
......@@ -96,7 +100,7 @@ void SurfaceRender_DockTab::renderEdgesChanged(bool b)
}
}
void SurfaceRender_DockTab::renderFacesChanged(bool b)
void Surface_Render_DockTab::renderFacesChanged(bool b)
{
if(!b_updatingUI)
{
......@@ -110,7 +114,7 @@ void SurfaceRender_DockTab::renderFacesChanged(bool b)
}
}
void SurfaceRender_DockTab::faceStyleChanged(QAbstractButton* b)
void Surface_Render_DockTab::faceStyleChanged(QAbstractButton* b)
{
if(!b_updatingUI)
{
......@@ -131,14 +135,14 @@ void SurfaceRender_DockTab::faceStyleChanged(QAbstractButton* b)
void SurfaceRender_DockTab::addPositionVBO(QString name)
void Surface_Render_DockTab::addPositionVBO(QString name)
{
b_updatingUI = true;
combo_positionVBO->addItem(name);
b_updatingUI = false;
}
void SurfaceRender_DockTab::removePositionVBO(QString name)
void Surface_Render_DockTab::removePositionVBO(QString name)
{
b_updatingUI = true;
int curIndex = combo_positionVBO->currentIndex();
......@@ -149,14 +153,14 @@ void SurfaceRender_DockTab::removePositionVBO(QString name)
b_updatingUI = false;
}
void SurfaceRender_DockTab::addNormalVBO(QString name)
void Surface_Render_DockTab::addNormalVBO(QString name)
{
b_updatingUI = true;
combo_normalVBO->addItem(name);
b_updatingUI = false;
}
void SurfaceRender_DockTab::removeNormalVBO(QString name)
void Surface_Render_DockTab::removeNormalVBO(QString name)
{
b_updatingUI = true;
int curIndex = combo_normalVBO->currentIndex();
......@@ -167,14 +171,14 @@ void SurfaceRender_DockTab::removeNormalVBO(QString name)
b_updatingUI = false;
}
void SurfaceRender_DockTab::updateMapParameters()
void Surface_Render_DockTab::updateMapParameters()
{
b_updatingUI = true;
combo_positionVBO->clear();
combo_normalVBO->clear();
combo_positionVBO->addItem("- select VBO -");
combo_normalVBO->clear();
combo_normalVBO->addItem("- select VBO -");
View* view = m_schnapps->getSelectedView();
......
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME RenderVector )
SET( PLUGIN_NAME Surface_RenderVector )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/renderVector )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_renderVector )
INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include
......@@ -25,8 +25,8 @@ file(
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/renderVector.h
${PLUGIN_ROOT_DIR}/include/renderVectorDockTab.h
${PLUGIN_ROOT_DIR}/include/surface_renderVector.h
${PLUGIN_ROOT_DIR}/include/surface_renderVector_dockTab.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RenderVectorDockWidget</class>
<widget class="QWidget" name="RenderVectorDockWidget">
<class>Surface_RenderVector_TabWidget</class>
<widget class="QWidget" name="Surface_RenderVector_TabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>174</width>
<height>545</height>
<width>200</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="mapList"/>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<property name="text">
<string>- select VBO -</string>
</property>
</item>
</layout>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vectors :</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0" colspan="2">
<widget class="QListWidget" name="list_vectorVBO">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Vectors Size :</string>
</property>
</widget>
</item>
<item>
<item row="4" column="0" colspan="2">
<widget class="QSlider" name="slider_vectorsScaleFactor">
<property name="value">
<number>50</number>
......@@ -69,7 +67,7 @@
</property>
</widget>
</item>
<item>
<item row="5" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
#ifndef _RENDERVECTOR_PLUGIN_H_
#define _RENDERVECTOR_PLUGIN_H_
#ifndef _SURFACE_RENDERVECTOR_PLUGIN_H_
#define _SURFACE_RENDERVECTOR_PLUGIN_H_
#include "plugin.h"
#include "renderVectorDockTab.h"
#include "plugin_interaction.h"
#include "surface_renderVector_dockTab.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
......@@ -12,48 +12,37 @@ namespace CGoGN
namespace SCHNApps
{
struct PerMapParameterSet
struct MapParameters
{
PerMapParameterSet() :
MapParameters() :
positionVBO(NULL),
vectorsScaleFactor(1.0f)
{}
PerMapParameterSet(MapHandlerGen* map);
Utils::VBO* positionVBO;
std::vector<Utils::VBO*> vectorVBO;
QList<Utils::VBO*> vectorVBOs;
float vectorsScaleFactor;
};
struct ParameterSet
{
ParameterSet() : selectedMap(NULL)
{}
QHash<QString, PerMapParameterSet*> perMap;
MapHandlerGen* selectedMap;
};
class RenderVectorPlugin : public Plugin
class Surface_RenderVector_Plugin : public PluginInteraction
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class Surface_RenderVector_DockTab;
public:
RenderVectorPlugin()
{
setProvidesRendering(true);
}
Surface_RenderVector_Plugin()
{}
~RenderVectorPlugin()
~Surface_RenderVector_Plugin()
{}
virtual bool enable();
virtual void disable();
virtual void redraw(View *view);
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) {}
......@@ -62,30 +51,32 @@ public:
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
protected:
RenderVectorDockTab* m_dockTab;
QHash<View*, ParameterSet*> h_viewParams;
virtual void viewLinked(View *view) {}
virtual void viewUnlinked(View *view) {}
CGoGN::Utils::ShaderVectorPerVertex* m_vectorShader;
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);
public slots:
void viewLinked(View* view, Plugin* plugin);
void viewUnlinked(View* view, Plugin* plugin);
void currentViewChanged(View* view);
// slots called from MapHandler signals
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
public slots:
// slots for Python calls
void changePositionVBO(const QString& view, const QString& map, const QString& vbo);
void addVectorVBO(const QString& view, const QString& map, const QString& vbo);
void removeVectorVBO(const QString& view, const QString& map, const QString& vbo);
void changeVectorsScaleFactor(const QString& view, const QString& map, float f);
protected:
void addManagedMap(View *v, MapHandlerGen* m);
void removeManagedMap(View *v, MapHandlerGen* m);
public slots:
void changeSelectedMap(View* view, MapHandlerGen* map);
Surface_RenderVector_DockTab* m_dockTab;
QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeSelectedVectorsVBO(View* view, MapHandlerGen* map, const std::vector<Utils::VBO*>& vbos, bool fromUI = false);
void changeVectorsScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
CGoGN::Utils::ShaderVectorPerVertex* m_vectorShader;
};
} // namespace SCHNApps
......
#ifndef _RENDERVECTOR_DOCK_TAB_H_
#define _RENDERVECTOR_DOCK_TAB_H_
#include "ui_renderVector.h"
#include "ui_surface_renderVector.h"
#include "Utils/vbo.h"
namespace CGoGN
......@@ -10,33 +10,36 @@ namespace CGoGN
namespace SCHNApps
{
class Window;
class RenderVectorPlugin;
struct ParameterSet;
class SCHNApps;
class Surface_RenderVector_Plugin;
struct MapParameters;
class RenderVectorDockTab : public QWidget, public Ui::RenderVectorDockWidget
class Surface_RenderVector_DockTab : public QWidget, public Ui::Surface_RenderVector_TabWidget
{
Q_OBJECT
friend class Surface_RenderVector_Plugin;
public:
RenderVectorDockTab(Window* w, RenderVectorPlugin* p);
Surface_RenderVector_DockTab(SCHNApps* s, Surface_RenderVector_Plugin* p);
private:
Window* m_window;
RenderVectorPlugin* m_plugin;
ParameterSet* m_currentParams;
bool b_refreshingUI;
public slots: