Commit 3194ec6e authored by Sylvain Thery's avatar Sylvain Thery

color interface for schnapps render plugin

parent 9b43aa64
...@@ -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()
{
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() ...@@ -226,6 +313,17 @@ void Surface_Render_DockTab::updateMapParameters()
check_renderFaces->setChecked(p.renderFaces); check_renderFaces->setChecked(p.renderFaces);
radio_flatShading->setChecked(p.faceStyle == MapParameters::FLAT); radio_flatShading->setChecked(p.faceStyle == MapParameters::FLAT);
radio_phongShading->setChecked(p.faceStyle == MapParameters::PHONG); 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; b_updatingUI = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment