Commit c2fbbbce authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of /home/git/repositories/thery/cgogn into develop

parents b29a40b3 9a03f38e
...@@ -78,7 +78,7 @@ void Viewer::initGUI() ...@@ -78,7 +78,7 @@ void Viewer::initGUI()
void Viewer::cb_initGL() void Viewer::cb_initGL()
{ {
Utils::GLSLShader::setCurrentOGLVersion(3) ; Utils::GLSLShader::setCurrentOGLVersion(2) ;
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl; CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl;
Utils::GLSLShader::areShadersSupported(); Utils::GLSLShader::areShadersSupported();
...@@ -102,6 +102,7 @@ void Viewer::cb_initGL() ...@@ -102,6 +102,7 @@ void Viewer::cb_initGL()
m_flatShader->setAttributePosition(m_positionVBO) ; m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ; m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ; m_flatShader->setDiffuse(colDif) ;
m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
m_flatShader->setExplode(faceShrinkage) ; m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ; m_vectorShader = new Utils::ShaderVectorPerVertex() ;
......
...@@ -144,7 +144,6 @@ IF (WITH_QT) ...@@ -144,7 +144,6 @@ IF (WITH_QT)
find_package(QGLViewer REQUIRED) find_package(QGLViewer REQUIRED)
SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} ) SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} )
SET (CGoGN_EXT_LIBS ${QGLVIEWER_LIBRARIES} ${QT_LIBRARIES} ${CGoGN_EXT_LIBS}) SET (CGoGN_EXT_LIBS ${QGLVIEWER_LIBRARIES} ${QT_LIBRARIES} ${CGoGN_EXT_LIBS})
ENDIF (WITH_QT) ENDIF (WITH_QT)
IF (WITH_GLEWMX) IF (WITH_GLEWMX)
...@@ -286,22 +285,35 @@ file( GLOB_RECURSE ...@@ -286,22 +285,35 @@ file( GLOB_RECURSE
${CGoGN_ROOT_DIR}/ThirdParty/include/*.hpp ${CGoGN_ROOT_DIR}/ThirdParty/include/*.hpp
) )
link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
IF (ONELIB) IF (ONELIB)
IF(WITH_QT) IF(WITH_QT)
add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils_withQt}) add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils_withQt})
ELSE() ELSE()
add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils} ) add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils} )
ENDIF() ENDIF()
add_dependencies(cgogn shader_target ) add_dependencies(cgogn shader_target)
target_link_libraries(cgogn ${CGoGN_EXT_LIBS})
ELSE() ELSE()
add_library( container ${files_container})
add_library( topology ${files_topology})
add_library( algo ${files_algo})
IF (WITH_QT) IF (WITH_QT)
add_library( utils ${files_utils_withQt} ) add_library( utils ${files_utils_withQt} )
ELSE() ELSE()
add_library( utils ${files_utils} ) add_library( utils ${files_utils} )
ENDIF() ENDIF()
target_link_libraries(utils ${CGoGN_EXT_LIBS})
add_library( container ${files_container})
target_link_libraries(container utils)
add_library( topology ${files_topology})
target_link_libraries(topology container)
add_library( algo ${files_algo})
target_link_libraries(algo utils topology)
add_custom_target( Geometry SOURCES ${files_geometry} ) add_custom_target( Geometry SOURCES ${files_geometry} )
add_custom_target( ThirdParty SOURCES ${files_thirdParty} ) add_custom_target( ThirdParty SOURCES ${files_thirdParty} )
add_dependencies( utils shader_target ) add_dependencies( utils shader_target )
......
...@@ -33,6 +33,7 @@ SET( QT_USE_QTXML TRUE ) ...@@ -33,6 +33,7 @@ SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTDESIGNER TRUE ) SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE ) SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE ) SET( QT_USE_QTPLUGIN TRUE )
SET( QT_USE_QTSVG TRUE )
INCLUDE(${QT_USE_FILE}) INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS}) ADD_DEFINITIONS(${QT_DEFINITIONS})
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>472</width> <width>472</width>
<height>276</height> <height>292</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -75,6 +75,16 @@ ...@@ -75,6 +75,16 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="enableVBO">
<property name="text">
<string>Create VBO</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
...@@ -121,6 +121,14 @@ void Surface_DifferentialProperties_Plugin::computeNormalFromDialog() ...@@ -121,6 +121,14 @@ void Surface_DifferentialProperties_Plugin::computeNormalFromDialog()
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked); bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
computeNormal(mapName, positionName, normalName, autoUpdate); computeNormal(mapName, positionName, normalName, autoUpdate);
// create VBO if asked
if (m_computeNormalDialog->enableVBO->isChecked())
{
MapHandlerGen* mhg = getSCHNApps()->getMap(mapName);
if (mhg != NULL)
mhg->createVBO(normalName);
}
} }
} }
......
...@@ -16,8 +16,7 @@ class Surface_Import_Plugin : public PluginProcessing ...@@ -16,8 +16,7 @@ class Surface_Import_Plugin : public PluginProcessing
public: public:
Surface_Import_Plugin() Surface_Import_Plugin()
{ {}
}
~Surface_Import_Plugin() ~Surface_Import_Plugin()
{} {}
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>200</width> <width>246</width>
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
...@@ -14,12 +14,23 @@ ...@@ -14,12 +14,23 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="9" column="0" rowspan="2" colspan="2">
<widget class="QLabel" name="label_2"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="text"> <item>
<string>Position :</string> <widget class="QCheckBox" name="check_renderEdges">
</property> <property name="text">
</widget> <string>render edges</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="scolorButton">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="combo_normalVBO"> <widget class="QComboBox" name="combo_normalVBO">
...@@ -36,27 +47,27 @@ ...@@ -36,27 +47,27 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="20" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderVertices"> <spacer name="verticalSpacer">
<property name="text"> <property name="orientation">
<string>render vertices</string> <enum>Qt::Vertical</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
</property>
</spacer>
</item> </item>
<item row="7" column="0"> <item row="1" column="0">
<widget class="QRadioButton" name="radio_flatShading"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Flat</string> <string>Normal :</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
<attribute name="buttonGroup">
<string notr="true">group_faceShading</string>
</attribute>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="15" column="1">
<widget class="QRadioButton" name="radio_phongShading"> <widget class="QRadioButton" name="radio_phongShading">
<property name="text"> <property name="text">
<string>Phong</string> <string>Phong</string>
...@@ -66,38 +77,42 @@ ...@@ -66,38 +77,42 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Normal :</string> <string>Position :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderFaces"> <widget class="QSlider" name="slider_verticesScaleFactor">
<property name="text"> <property name="value">
<string>render faces</string> <number>50</number>
</property> </property>
<property name="checked"> <property name="orientation">
<bool>true</bool> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="16" column="0" colspan="2">
<widget class="Line" name="line"/> <widget class="QCheckBox" name="check_renderBoundary">
<property name="text">
<string>render boundary</string>
</property>
</widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="15" column="0">
<spacer name="verticalSpacer"> <widget class="QRadioButton" name="radio_flatShading">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Flat</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="checked">
<size> <bool>true</bool>
<width>156</width>
<height>161</height>
</size>
</property> </property>
</spacer> <attribute name="buttonGroup">
<string notr="true">group_faceShading</string>
</attribute>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="combo_positionVBO"> <widget class="QComboBox" name="combo_positionVBO">
...@@ -114,29 +129,165 @@ ...@@ -114,29 +129,165 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderEdges"> <widget class="Line" name="line"/>
<property name="text">
<string>render edges</string>
</property>
</widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="12" column="0" rowspan="2" colspan="2">
<widget class="QSlider" name="slider_verticesScaleFactor"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="value"> <item>
<number>50</number> <widget class="QCheckBox" name="check_renderFaces">
</property> <property name="text">
<property name="orientation"> <string>render faces</string>
<enum>Qt::Horizontal</enum> </property>
</property> <property name="checked">
</widget> <bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="dcolorButton">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>143</red>
<green>146</green>
<blue>147</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="3" column="0" rowspan="2" colspan="2">
<widget class="QCheckBox" name="check_renderBoundary"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="text"> <item>
<string>render boundary</string> <widget class="QCheckBox" name="check_renderVertices">
</property> <property name="text">
</widget> <string>render vertices</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="vcolorButton">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
......
...@@ -32,7 +32,11 @@ struct MapParameters ...@@ -32,7 +32,11 @@ struct MapParameters
renderVertices(false), renderVertices(false),
renderEdges(false), renderEdges(false),
renderFaces(true), renderFaces(true),
faceStyle(FLAT) faceStyle(FLAT),
diffuseColor(0.8,0.9,0.7,0.0),
simpleColor(0.0,0.0,0.0,0.0),
vertexColor(0.0,0.0,1.0,0.0)
{} {}
Utils::VBO* positionVBO; Utils::VBO* positionVBO;
...@@ -43,6 +47,10 @@ struct MapParameters ...@@ -43,6 +47,10 @@ struct MapParameters
bool renderFaces; bool renderFaces;
bool renderBoundary; bool renderBoundary;
FaceShadingStyle faceStyle; FaceShadingStyle faceStyle;
Geom::Vec4f diffuseColor;
Geom::Vec4f simpleColor;
Geom::Vec4f vertexColor;
}; };
class Surface_Render_Plugin : public PluginInteraction class Surface_Render_Plugin : public PluginInteraction
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "ui_surface_render.h" #include "ui_surface_render.h"
#include "Utils/vbo.h" #include "Utils/vbo.h"
#include <QColorDialog>
namespace CGoGN namespace CGoGN
{ {
...@@ -27,6 +28,11 @@ private: ...@@ -27,6 +28,11 @@ private:
SCHNApps* m_schnapps; SCHNApps* m_schnapps;
Surface_Render_Plugin* m_plugin; Surface_Render_Plugin* m_plugin;
bool b_updatingUI; bool b_updatingUI;
QColorDialog* m_colorDial;
QColor m_diffuseColor;
QColor m_simpleColor;
QColor m_vertexColor;
int m_currentColorDial;
private slots: private slots:
void positionVBOChanged(int index); void positionVBOChanged(int index);
...@@ -38,6 +44,13 @@ private slots: ...@@ -38,6 +44,13 @@ private slots:
void faceStyleChanged(QAbstractButton* b); void faceStyleChanged(QAbstractButton* b);
void renderBoundaryChanged(bool b); void renderBoundaryChanged(bool b);
void diffuseColorClicked();
void simpleColorClicked();
void vertexColorClicked();
void colorSelected(const QColor& col);
private: private:
void addPositionVBO(QString name); void addPositionVBO(QString name);
void removePositionVBO(QString name); void removePositionVBO(QString name);
......
...@@ -74,7 +74,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -74,7 +74,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{ {
m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor); m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor);
m_pointSprite->setAttributePosition(p.positionVBO); m_pointSprite->setAttributePosition(p.positionVBO);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)); m_pointSprite->setColor(p.vertexColor);
map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS); map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
} }
if(p.renderEdges) if(p.renderEdges)
...@@ -83,6 +83,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -83,6 +83,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
CGoGN::Geom::Vec4f c(0.1f, 0.1f, 0.1f, 1.0f); CGoGN::Geom::Vec4f c(0.1f, 0.1f, 0.1f, 1.0f);
m_simpleColorShader->setColor(c); m_simpleColorShader->setColor(c);
m_simpleColorShader->setAttributePosition(p.positionVBO); m_simpleColorShader->setAttributePosition(p.positionVBO);
m_simpleColorShader->setColor(p.simpleColor);
map->draw(m_simpleColorShader, CGoGN::Algo::Render::GL2::LINES); map->draw(m_simpleColorShader, CGoGN::Algo::Render::GL2::LINES);
} }
if(p.renderFaces) if(p.renderFaces)
...@@ -95,6 +96,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -95,6 +96,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{ {
case MapParameters::FLAT : case MapParameters::FLAT :
m_flatShader->setAttributePosition(p.positionVBO); m_flatShader->setAttributePosition(p.positionVBO);
m_flatShader->setDiffuse(p.diffuseColor);
map->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES); map->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES);
break; break;
case MapParameters::PHONG : case MapParameters::PHONG :
...@@ -102,6 +104,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -102,6 +104,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{ {
m_phongShader->setAttributePosition(p.positionVBO); m_phongShader->setAttributePosition(p.positionVBO);
m_phongShader->setAttributeNormal(p.normalVBO); m_phongShader->setAttributeNormal(p.normalVBO);
m_phongShader->setDiffuse(p.diffuseColor);
map->draw(m_phongShader, CGoGN::Algo::Render::GL2::TRIANGLES); map->draw(m_phongShader, CGoGN::Algo::Render::GL2::TRIANGLES);
} }
break; break;
......
...@@ -13,7 +13,9 @@ namespace SCHNApps ...@@ -13,7 +13,9 @@ namespace SCHNApps
Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) : Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) :
m_schnapps(s), m_schnapps(s),
m_plugin(p), m_plugin(p),
b_updatingUI(false) b_updatingUI(false),
m_currentColorDial(0)
{ {
setupUi(this); setupUi(this);
...@@ -25,6 +27,91 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi ...@@ -25,6 +27,91 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi
connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool))); connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool)));
connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*))); connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*)));
connect(check_renderBoundary, SIGNAL(toggled(bool)), this, SLOT(renderBoundaryChanged(bool))); connect(check_renderBoundary, SIGNAL(toggled(bool)), this, SLOT(renderBoundaryChanged(bool)));
m_colorDial = new QColorDialog(m_diffuseColor,NULL);
connect(dcolorButton,SIGNAL(clicked()),this,SLOT(diffuseColorClicked()));
connect(scolorButton,SIGNAL(clicked()),this,SLOT(simpleColorClicked()));
connect(vcolorButton,SIGNAL(clicked()),this,SLOT(vertexColorClicked()));
connect(m_colorDial,SIGNAL(colorSelected(const QColor&)),this,SLOT(colorSelected(const QColor&)));
}
void Surface_Render_DockTab::diffuseColorClicked()