Commit b5555790 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~untereiner/CGoGN

Conflicts:
	SCHNApps/Plugins/renderTopoSurface/forms/renderTopoSurface.ui
	SCHNApps/Plugins/renderTopoSurface/src/renderTopoSurface.cpp
	SCHNApps/Plugins/renderTopoSurface/src/renderTopoSurfaceDockTab.cpp
parents 687dea0d 03f1fe6a
......@@ -163,15 +163,15 @@ void MyQT::cb_Save()
Utils::SVG::SVGOut svg1(modelViewMatrix(), projectionMatrix());
m_drawer.toSVG(svg1);
svg1.addOpacityAnimation(1.0f);
svg1.addOpacityAnimation(1.0f);
svg1.addOpacityAnimation(0.0f);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(0.0f);
Utils::SVG::SVGOut svg2(modelViewMatrix(), projectionMatrix());
m_render_topo->toSVG(svg2);
svg2.addOpacityAnimation(1.0f);
svg2.addOpacityAnimation(0.0f);
svg2.addOpacityAnimation(1.0f);
// svg2.addOpacityAnimation(1.0f);
// svg2.addOpacityAnimation(0.0f);
// svg2.addOpacityAnimation(1.0f);
Utils::SVG::AnimatedSVGOut anim;
......
......@@ -237,13 +237,13 @@ void MyQT::cb_keyPress(int code)
{
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
Utils::SVG::SVGOut svg(filename, modelViewMatrix(), projectionMatrix());
svg.setWidth(1.0f);
svg.setColor(Geom::Vec3f(0.0f,0.0f,0.5f));
// svg.setWidth(1.0f);
// svg.setColor(Geom::Vec3f(0.0f,0.0f,0.5f));
Algo::Render::SVG::renderEdges<PFP>(svg, myMap, position);
svg.setColor(Geom::Vec3f(0.0f,0.8f,0.0f));
svg.setWidth(5.0f);
// svg.setColor(Geom::Vec3f(0.0f,0.8f,0.0f));
// svg.setWidth(5.0f);
Algo::Render::SVG::renderVertices<PFP>(svg, myMap, position);
svg.setColor(Geom::Vec3f(1.0f,0.0f,0.0f));
// svg.setColor(Geom::Vec3f(1.0f,0.0f,0.0f));
m_strings->toSVG(svg);
//svg destruction close the file
}
......
......@@ -235,6 +235,16 @@ void MyQT::operation(int x)
std::cout << "nb darts after = " << myMap.getNbDarts() << std::endl;
}
break;
case 11 :
CGoGNout <<"unsew volumes"<<CGoGNendl;
if (m_selected != NIL)
{
myMap.unsewVolumes(m_selected);
dm.markAll();
m_selected = NIL;
updateMap();
}
break;
default:
break;
}
......
......@@ -145,6 +145,11 @@
<string>splitVertex</string>
</property>
</item>
<item>
<property name="text">
<string>unsewVolumes</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
......
......@@ -134,6 +134,7 @@ SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h
${SCHNApps_ROOT_DIR}/include/colorComboBox.h
)
......
......@@ -6,45 +6,35 @@
<rect>
<x>0</x>
<y>0</y>
<width>204</width>
<width>190</width>
<height>547</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="2">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
</layout>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line"/>
<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>
<item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawDarts">
<property name="text">
<string>draw darts</string>
......@@ -54,7 +44,10 @@
</property>
</widget>
</item>
<item>
<item row="2" column="3">
<widget class="ColorComboBox" name="combo_dartsColor"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawPhi1">
<property name="text">
<string>draw phi1</string>
......@@ -64,7 +57,10 @@
</property>
</widget>
</item>
<item>
<item row="3" column="3">
<widget class="ColorComboBox" name="combo_phi1Color"/>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="check_drawPhi2">
<property name="text">
<string>draw phi2</string>
......@@ -74,45 +70,44 @@
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>explod edges</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="slider_edgesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>explod faces</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="slider_facesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
<item row="4" column="3">
<widget class="ColorComboBox" name="combo_phi2Color"/>
</item>
<item row="5" 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">
<widget class="QSlider" name="slider_edgesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</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">
<widget class="QSlider" name="slider_facesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<item row="7" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -127,6 +122,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ColorComboBox</class>
<extends>QComboBox</extends>
<header>colorComboBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -24,8 +24,11 @@ struct PerMapParameterSet
VertexAttribute<PFP2::VEC3> positionAttribute;
bool drawDarts;
QColor dartsColor;
bool drawPhi1;
QColor phi1Color;
bool drawPhi2;
QColor phi2Color;
float edgesScaleFactor;
float facesScaleFactor;
};
......@@ -81,8 +84,11 @@ public slots:
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
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);
......
......@@ -32,8 +32,11 @@ public slots:
void selectedMapChanged();
void positionAttributeChanged(int index);
void drawDartsChanged(bool b);
void dartsColorChanged(int);
void drawPhi1Changed(bool b);
void phi1ColorChanged(int);
void drawPhi2Changed(bool b);
void phi2ColorChanged(int);
void edgesScaleFactorChanged(int i);
void facesScaleFactorChanged(int i);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
......
......@@ -11,8 +11,11 @@ namespace SCHNApps
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
mh(m),
drawDarts(true),
dartsColor("white"),
drawPhi1(true),
phi1Color("cyan"),
drawPhi2(true),
phi2Color("red"),
edgesScaleFactor(1.0f),
facesScaleFactor(1.0f)
{
......@@ -223,6 +226,22 @@ void RenderTopoSurfacePlugin::changeDrawDarts(View* view, MapHandlerGen* map, bo
}
}
void RenderTopoSurfacePlugin::changeDartsColor(View* view, MapHandlerGen* map, QColor c, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
PerMapParameterSet* perMap = params->perMap[map->getName()];
perMap->dartsColor = c;
perMap->m_renderTopo->setInitialDartsColor(c.redF(), c.greenF(), c.blueF());
perMap->m_renderTopo->setAllDartsColor(c.redF(), c.greenF(), c.blueF());
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderTopoSurfacePlugin::changeDrawPhi1(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
......@@ -236,6 +255,19 @@ void RenderTopoSurfacePlugin::changeDrawPhi1(View* view, MapHandlerGen* map, boo
}
}
void RenderTopoSurfacePlugin::changePhi1Color(View* view, MapHandlerGen* map, QColor c, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->phi1Color = c;
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderTopoSurfacePlugin::changeDrawPhi2(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
......@@ -249,11 +281,24 @@ void RenderTopoSurfacePlugin::changeDrawPhi2(View* view, MapHandlerGen* map, boo
}
}
void RenderTopoSurfacePlugin::changePhi2Color(View* view, MapHandlerGen* map, QColor c, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->phi2Color = c;
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderTopoSurfacePlugin::changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
PerMapParameterSet* perMap = params->perMap[map->getName()];
perMap->edgesScaleFactor = i / 50.0;
perMap->edgesScaleFactor = i / 100.0;
perMap->updateRender();
if(view->isCurrentView())
......@@ -268,7 +313,7 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen*
{
ParameterSet* params = h_viewParams[view];
PerMapParameterSet* perMap = params->perMap[map->getName()];
perMap->facesScaleFactor = i / 50.0;
perMap->facesScaleFactor = i / 100.0;
perMap->updateRender();
if(view->isCurrentView())
......
......@@ -20,8 +20,11 @@ RenderTopoSurfaceDockTab::RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfaceP
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)));
}
......@@ -65,10 +68,13 @@ void RenderTopoSurfaceDockTab::refreshUI(ParameterSet* params)
}
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);
slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 50.0);
slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0);
combo_phi2Color->setColor(p->phi2Color);
slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 100.0);
slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 100.0);
}
++i;
}
......@@ -106,6 +112,16 @@ void RenderTopoSurfaceDockTab::drawDartsChanged(bool b)
}
}
void RenderTopoSurfaceDockTab::dartsColorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changeDartsColor(view, map, combo_dartsColor->color(), true);
}
}
void RenderTopoSurfaceDockTab::drawPhi1Changed(bool b)
{
if(!b_refreshingUI)
......@@ -116,6 +132,16 @@ void RenderTopoSurfaceDockTab::drawPhi1Changed(bool b)
}
}
void RenderTopoSurfaceDockTab::phi1ColorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changePhi1Color(view, map, combo_phi1Color->color(), true);
}
}
void RenderTopoSurfaceDockTab::drawPhi2Changed(bool b)
{
if(!b_refreshingUI)
......@@ -126,6 +152,16 @@ void RenderTopoSurfaceDockTab::drawPhi2Changed(bool b)
}
}
void RenderTopoSurfaceDockTab::phi2ColorChanged(int i)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changePhi2Color(view, map, combo_phi2Color->color(), true);
}
}
void RenderTopoSurfaceDockTab::facesScaleFactorChanged(int i)
{
if(!b_refreshingUI)
......
importPlugin = schnapps.loadPlugin("ImportSurface");
renderPlugin = schnapps.loadPlugin("Render");
renderVectorPlugin = schnapps.loadPlugin("RenderVector");
renderTopoSurfacePlugin = schnapps.loadPlugin("RenderTopoSurfaceD");
renderTopoSurfacePlugin = schnapps.loadPlugin("RenderTopoSurface");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface");
surfaceDeformationPlugin = schnapps.loadPlugin("SurfaceDeformation");
......
#ifndef COLORCOMBOBOX_H
#define COLORCOMBOBOX_H
#include <QComboBox>
class QColor;
class QWidget;
class ColorComboBox : public QComboBox
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor USER true)
public:
QColor color() const;
void setColor(QColor c);
public:
ColorComboBox(QWidget *widget = 0);
private:
void populateList();
public slots:
void slotHighlight(int index);
};
#endif
#include <QtGui>
#include "colorComboBox.h"
ColorComboBox::ColorComboBox(QWidget *widget) : QComboBox(widget)
{
//connect( this, SIGNAL(highlighted(int)), this, SLOT(slotHighlight(int)) );
populateList();
}
QColor ColorComboBox::color() const
{
return qvariant_cast<QColor>(itemData(currentIndex(), Qt::DecorationRole));
}
void ColorComboBox::setColor(QColor color)
{
setCurrentIndex(findData(color, int(Qt::DecorationRole)));
}
void ColorComboBox::populateList()
{
//QStringList colorNames = QColor::colorNames();
QStringList colorNames;
colorNames <<
"darkGreen" <<
"green" <<
"gray" <<
"red" <<
"white" <<
"blue" <<
"cyan "<<
"darkMagenta" <<
"yellow" <<
"darkRed" <<
"black" <<
"magenta";
for (int i = 0; i < colorNames.size(); ++i) {
QColor color(colorNames[i]);
insertItem(i, colorNames[i]);
setItemData(i, color, Qt::DecorationRole);
}
}
void ColorComboBox::slotHighlight(int index)
{
const QStringList colorNames = QColor::colorNames();
QColor color(colorNames.at(index));
QPalette palette = this->palette();
palette.setColor(QPalette::Highlight, color);
setPalette(palette);
}
......@@ -132,10 +132,205 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute<typ
}
}
//Uniform-distributed additive noise
//TODO do not touch to boundary vertices
template <typename PFP>
void computeUnfirmAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, const VertexAttribute<typename PFP::VEC3>& position, VertexAttribute<typename PFP::VEC3>& position2)
{
typedef typename PFP::VEC3 VEC3 ;
// Compute mesh center
unsigned int count = 0;
VEC3 centroid(0.0);
TraversorV<typename PFP::MAP> tv(map) ;
for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next())
{
centroid += position[dit];
++count;
}
centroid /= count;
double distanceCentroid = 0.0;
// Compute the average distance from vertices to mesh center
for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next())
{
VEC3 dist = position[dit];
dist -= centroid;
distanceCentroid += float(dist.norm());
}
distanceCentroid /= count;
// add random uniform-distributed (between [-noiseLevel, +noiseLevel])
srand((unsigned)time(NULL));
float noisex, noisey, noisez;
float noiseLevel = distanceCentroid * noiseIntensity;
for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next())
{
noisex = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2;
noisey = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2;
noisez = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2;
position2[dit] = position[dit] + VEC3(noisex,noisey,noisez);
}
}
//Gaussian-distributed additive noise
//TODO do not touch to boundary vertices
template <typename PFP>
void computeGaussianAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, const VertexAttribute<typename PFP::VEC3>& position, VertexAttribute<typename PFP::VEC3>& position2)
{
typedef typename PFP::VEC3 VEC3 ;
// Compute mesh center
unsigned int count = 0;
VEC3 centroid(0.0);
TraversorV<typename PFP::MAP> tv(map) ;
for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next())
{
centroid += position[dit];
++count;
}
centroid /= count;
double distanceCentroid = 0.0;
// Compute the average distance from vertices to mesh center
for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next())
{
VEC3 dist = position[dit];
dist -= centroid;
distanceCentroid += float(dist.norm());
}
distanceCentroid /= count;
// add random gaussian-distributed
srand((unsigned)time(NULL));
float noisex, noisey, noisez;
float gaussNumbers[3];
float noiseLevel = distanceCentroid * noiseIntensity;
for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next())
{