Commit c9128d9f authored by Sylvain Thery's avatar Sylvain Thery

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

parents 372b82c5 c2fbbbce
......@@ -78,7 +78,7 @@ void Viewer::initGUI()
void Viewer::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(3) ;
Utils::GLSLShader::setCurrentOGLVersion(2) ;
CGoGNout << "GL VERSION = "<< glGetString(GL_VERSION)<< CGoGNendl;
Utils::GLSLShader::areShadersSupported();
......@@ -102,6 +102,7 @@ void Viewer::cb_initGL()
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ;
m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
......
......@@ -144,7 +144,6 @@ IF (WITH_QT)
find_package(QGLViewer REQUIRED)
SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} )
SET (CGoGN_EXT_LIBS ${QGLVIEWER_LIBRARIES} ${QT_LIBRARIES} ${CGoGN_EXT_LIBS})
ENDIF (WITH_QT)
IF (WITH_GLEWMX)
......@@ -286,22 +285,35 @@ file( GLOB_RECURSE
${CGoGN_ROOT_DIR}/ThirdParty/include/*.hpp
)
link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
IF (ONELIB)
IF(WITH_QT)
add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils_withQt})
ELSE()
add_library( cgogn ${files_topology} ${files_container} ${files_algo} ${files_utils} )
ENDIF()
add_dependencies(cgogn shader_target )
add_dependencies(cgogn shader_target)
target_link_libraries(cgogn ${CGoGN_EXT_LIBS})
ELSE()
add_library( container ${files_container})
add_library( topology ${files_topology})
add_library( algo ${files_algo})
IF (WITH_QT)
add_library( utils ${files_utils_withQt} )
ELSE()
add_library( utils ${files_utils} )
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( ThirdParty SOURCES ${files_thirdParty} )
add_dependencies( utils shader_target )
......
......@@ -33,6 +33,7 @@ SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE )
SET( QT_USE_QTSVG TRUE )
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>472</width>
<height>276</height>
<height>292</height>
</rect>
</property>
<property name="windowTitle">
......@@ -75,6 +75,16 @@
</item>
</layout>
</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>
</widget>
</item>
......
......@@ -121,6 +121,14 @@ void Surface_DifferentialProperties_Plugin::computeNormalFromDialog()
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
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
public:
Surface_Import_Plugin()
{
}
{}
~Surface_Import_Plugin()
{}
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<width>246</width>
<height>600</height>
</rect>
</property>
......@@ -14,12 +14,23 @@
<string>Form</string>
</property>
<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 row="9" column="0" rowspan="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="check_renderEdges">
<property name="text">
<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 row="1" column="1">
<widget class="QComboBox" name="combo_normalVBO">
......@@ -36,27 +47,27 @@
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderVertices">
<property name="text">
<string>render vertices</string>
<item row="20" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0">
<widget class="QRadioButton" name="radio_flatShading">
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Flat</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Normal :</string>
</property>
<attribute name="buttonGroup">
<string notr="true">group_faceShading</string>
</attribute>
</widget>
</item>
<item row="7" column="1">
<item row="15" column="1">
<widget class="QRadioButton" name="radio_phongShading">
<property name="text">
<string>Phong</string>
......@@ -66,38 +77,42 @@
</attribute>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Normal :</string>
<string>Position :</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderFaces">
<property name="text">
<string>render faces</string>
<widget class="QSlider" name="slider_verticesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="checked">
<bool>true</bool>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line"/>
<item row="16" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderBoundary">
<property name="text">
<string>render boundary</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="15" column="0">
<widget class="QRadioButton" name="radio_flatShading">
<property name="text">
<string>Flat</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
<property name="checked">
<bool>true</bool>
</property>
</spacer>
<attribute name="buttonGroup">
<string notr="true">group_faceShading</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combo_positionVBO">
......@@ -114,29 +129,165 @@
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderEdges">
<property name="text">
<string>render edges</string>
</property>
</widget>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QSlider" name="slider_verticesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<item row="12" column="0" rowspan="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="check_renderFaces">
<property name="text">
<string>render faces</string>
</property>
<property name="checked">
<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 row="8" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderBoundary">
<property name="text">
<string>render boundary</string>
</property>
</widget>
<item row="3" column="0" rowspan="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="check_renderVertices">
<property name="text">
<string>render vertices</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="vcolorButton">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
......@@ -32,7 +32,11 @@ struct MapParameters
renderVertices(false),
renderEdges(false),
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;
......@@ -43,6 +47,10 @@ struct MapParameters
bool renderFaces;
bool renderBoundary;
FaceShadingStyle faceStyle;
Geom::Vec4f diffuseColor;
Geom::Vec4f simpleColor;
Geom::Vec4f vertexColor;
};
class Surface_Render_Plugin : public PluginInteraction
......
......@@ -3,6 +3,7 @@
#include "ui_surface_render.h"
#include "Utils/vbo.h"
#include <QColorDialog>
namespace CGoGN
{
......@@ -27,6 +28,11 @@ private:
SCHNApps* m_schnapps;
Surface_Render_Plugin* m_plugin;
bool b_updatingUI;
QColorDialog* m_colorDial;
QColor m_diffuseColor;
QColor m_simpleColor;
QColor m_vertexColor;
int m_currentColorDial;
private slots:
void positionVBOChanged(int index);
......@@ -38,6 +44,13 @@ private slots:
void faceStyleChanged(QAbstractButton* b);
void renderBoundaryChanged(bool b);
void diffuseColorClicked();
void simpleColorClicked();
void vertexColorClicked();
void colorSelected(const QColor& col);
private:
void addPositionVBO(QString name);
void removePositionVBO(QString name);
......
......@@ -74,7 +74,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor);
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);
}
if(p.renderEdges)
......@@ -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);
m_simpleColorShader->setColor(c);
m_simpleColorShader->setAttributePosition(p.positionVBO);
m_simpleColorShader->setColor(p.simpleColor);
map->draw(m_simpleColorShader, CGoGN::Algo::Render::GL2::LINES);
}
if(p.renderFaces)
......@@ -95,6 +96,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
case MapParameters::FLAT :
m_flatShader->setAttributePosition(p.positionVBO);
m_flatShader->setDiffuse(p.diffuseColor);
map->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES);
break;
case MapParameters::PHONG :
......@@ -102,6 +104,7 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
{
m_phongShader->setAttributePosition(p.positionVBO);
m_phongShader->setAttributeNormal(p.normalVBO);
m_phongShader->setDiffuse(p.diffuseColor);
map->draw(m_phongShader, CGoGN::Algo::Render::GL2::TRIANGLES);
}
break;
......
......@@ -13,7 +13,9 @@ namespace SCHNApps
Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugin* p) :
m_schnapps(s),
m_plugin(p),
b_updatingUI(false)
b_updatingUI(false),
m_currentColorDial(0)
{
setupUi(this);
......@@ -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(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*)));
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()
{
m_colorDial->show();
m_colorDial->setCurrentColor(m_diffuseColor);
m_currentColorDial = 1;
}
void Surface_Render_DockTab::simpleColorClicked()
{
m_colorDial->show();
m_colorDial->setCurrentColor(m_simpleColor);
m_currentColorDial = 2;
}
void Surface_Render_DockTab::vertexColorClicked()
{
m_colorDial->show();
m_colorDial->setCurrentColor(m_vertexColor);
m_currentColorDial = 3;
}
void Surface_Render_DockTab::colorSelected(const QColor& col)
{
if (m_currentColorDial == 1)
{
m_diffuseColor = col;
dcolorButton->setStyleSheet("QPushButton { background-color:" + col.name() + "}");
Geom::Vec4f rgbCol(1.0/255.0*m_diffuseColor.red(), 1.0/255.0*m_diffuseColor.green(),1.0/255.0*m_diffuseColor.blue(),0.0f);
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(view && map)
{
m_plugin->h_viewParameterSet[view][map].diffuseColor = rgbCol;
view->updateGL();
}
}
if (m_currentColorDial == 2)
{
m_simpleColor = col;
scolorButton->setStyleSheet("QPushButton { background-color:" + col.name() + "}");
Geom::Vec4f rgbCol(1.0/255.0*m_simpleColor.red(), 1.0/255.0*m_simpleColor.green(),1.0/255.0*m_simpleColor.blue(),0.0f);
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(view && map)
{
m_plugin->h_viewParameterSet[view][map].simpleColor = rgbCol;
view->updateGL();
}
}
if (m_currentColorDial == 3)
{
m_vertexColor = col;
vcolorButton->setStyleSheet("QPushButton { background-color:" + col.name() + "}");
Geom::Vec4f rgbCol(1.0/255.0*m_vertexColor.red(), 1.0/255.0*m_vertexColor.green(),1.0/255.0*m_vertexColor.blue(),0.0f);
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if(view && map)
{
m_plugin->h_viewParameterSet[view][map].vertexColor = rgbCol;
view->updateGL();
}
}
}
......@@ -226,6 +313,17 @@ void Surface_Render_DockTab::updateMapParameters()
check_renderFaces->setChecked(p.renderFaces);
radio_flatShading->setChecked(p.faceStyle == MapParameters::FLAT);
radio_phongShading->setChecked(p.faceStyle == MapParameters::PHONG);
m_diffuseColor = QColor(255*p.diffuseColor[0],255*p.diffuseColor[1],255*p.diffuseColor[2]);
dcolorButton->setStyleSheet("QPushButton { background-color:"+m_diffuseColor.name()+ " }");
m_simpleColor = QColor(255*p.simpleColor[0],255*p.simpleColor[1],255*p.simpleColor[2]);
scolorButton->setStyleSheet("QPushButton { background-color:"+m_simpleColor.name()+ " }");
m_vertexColor = QColor(255*p.simpleColor[0],255*p.vertexColor[1],255*p.vertexColor[2]);
vcolorButton->setStyleSheet("QPushButton { background-color:"+m_vertexColor.name()+ " }");
}
b_updatingUI = false;
......
......@@ -4,8 +4,6 @@
#include <QtPlugin>
#include <QAction>
#include <GL/glew.h>
#include "types.h"
namespace CGoGN
......@@ -21,24 +19,18 @@ class Plugin : public QObject
friend class SCHNApps;
public:
Plugin() : m_schnapps(NULL)
{
glewInit();
}
virtual ~Plugin() {}
const QString& getName() const { return m_name; }
Plugin();
virtual ~Plugin();
public slots:
QString getName() { return m_name; }
const QString& getFilePath() { return m_filePath; }
SCHNApps* getSCHNApps() { return m_schnapps; }
QString getName();
QString getFilePath();
SCHNApps* getSCHNApps();
private:
void setName(const QString& name) { m_name = name; }
void setFilePath(const QString& f) { m_filePath = f; }