Commit d4217e84 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps plugins: compute curvature & render multiple vectors

parent 58d48034
......@@ -21,11 +21,9 @@ file(
GLOB
SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/context.cpp
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp
${SCHNApps_ROOT_DIR}/src/system.cpp
${SCHNApps_ROOT_DIR}/src/view.cpp
${SCHNApps_ROOT_DIR}/src/window.cpp
${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp
......
......@@ -71,7 +71,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="attributeName"/>
<widget class="QLineEdit" name="normalAttributeName"/>
</item>
</layout>
</item>
......
......@@ -21,7 +21,7 @@ void ComputeNormalDialog::init()
mapList->clear();
combo_positionAttribute->clear();
combo_normalAttribute->clear();
attributeName->setText("normal");
normalAttributeName->setText("normal");
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
......
......@@ -3,6 +3,7 @@
#include "mapHandler.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Geometry/curvature.h"
bool DifferentialPropertiesPlugin::enable()
......@@ -51,10 +52,10 @@ void DifferentialPropertiesPlugin::cb_computeNormal()
std::string positionName = m_computeNormalDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName;
if(m_computeNormalDialog->attributeName->text().isEmpty())
if(m_computeNormalDialog->normalAttributeName->text().isEmpty())
normalName = m_computeNormalDialog->combo_normalAttribute->currentText().toUtf8().constData();
else
normalName = m_computeNormalDialog->attributeName->text().toUtf8().constData();
normalName = m_computeNormalDialog->normalAttributeName->text().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName);
if(!normal.isValid())
......@@ -98,15 +99,6 @@ void DifferentialPropertiesPlugin::cb_computeCurvature()
if(!Kmax.isValid())
Kmax = map->addAttribute<VEC3, VERTEX>(KmaxName);
std::string KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText().toUtf8().constData();
else
KminName = m_computeCurvatureDialog->KminAttributeName->text().toUtf8().constData();
VertexAttribute<VEC3> Kmin = map->getAttribute<VEC3, VERTEX>(KminName);
if(!Kmin.isValid())
Kmin = map->addAttribute<VEC3, VERTEX>(KminName);
std::string kmaxName;
if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty())
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText().toUtf8().constData();
......@@ -116,6 +108,15 @@ void DifferentialPropertiesPlugin::cb_computeCurvature()
if(!kmax.isValid())
kmax = map->addAttribute<REAL, VERTEX>(kmaxName);
std::string KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText().toUtf8().constData();
else
KminName = m_computeCurvatureDialog->KminAttributeName->text().toUtf8().constData();
VertexAttribute<VEC3> Kmin = map->getAttribute<VEC3, VERTEX>(KminName);
if(!Kmin.isValid())
Kmin = map->addAttribute<VEC3, VERTEX>(KminName);
std::string kminName;
if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty())
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText().toUtf8().constData();
......@@ -125,10 +126,36 @@ void DifferentialPropertiesPlugin::cb_computeCurvature()
if(!kmin.isValid())
kmin = map->addAttribute<REAL, VERTEX>(kminName);
Algo::Geometry::computeCurvatureVertices_NormalCycles<PFP>(*map, position, normal);
std::string KnormalName;
if(m_computeCurvatureDialog->KnormalAttributeName->text().isEmpty())
KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText().toUtf8().constData();
else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text().toUtf8().constData();
VertexAttribute<VEC3> Knormal = map->getAttribute<VEC3, VERTEX>(KnormalName);
if(!Knormal.isValid())
Knormal = map->addAttribute<VEC3, VERTEX>(KnormalName);
if(m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked)
mh->createVBO(normal);
EdgeAttribute<REAL> edgeAngle = map->getAttribute<REAL, EDGE>("edgeAngle");
if(!edgeAngle.isValid())
edgeAngle = map->addAttribute<REAL, EDGE>("edgeAngle");
Algo::Geometry::computeAnglesBetweenNormalsOnEdges<PFP>(*map, position, edgeAngle);
Algo::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP>(*map, 0.01f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
if(m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked)
mh->createVBO(Kmax);
if(m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked)
mh->createVBO(kmax);
if(m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked)
mh->createVBO(Kmin);
if(m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked)
mh->createVBO(kmin);
if(m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked)
mh->createVBO(Knormal);
QList<View*> views = m_window->getViewsList();
foreach(View* view, views)
......
......@@ -7,7 +7,6 @@
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
positionVBO(NULL),
vectorVBO(NULL),
vectorsScaleFactor(1.0f)
{
QList<Utils::VBO*> vbos = map->getVBOList();
......@@ -19,8 +18,6 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
if(positionVBO == NULL && vbos.count() > 0)
positionVBO = vbos[0];
if(vectorVBO == NULL && vbos.count() > 0)
vectorVBO = vbos[0];
}
......@@ -36,7 +33,7 @@ bool RenderVectorPlugin::enable()
connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
connect(m_dockTab->combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_positionVBOChanged(int)));
connect(m_dockTab->combo_vectorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_vectorVBOChanged(int)));
connect(m_dockTab->list_vectorVBO, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedVectorVBOChanged()));
connect(m_dockTab->button_refreshVBOs, SIGNAL(clicked()), this, SLOT(cb_refreshVBOs()));
connect(m_dockTab->slider_vectorsScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_vectorsScaleFactorChanged(int)));
......@@ -56,13 +53,16 @@ void RenderVectorPlugin::redraw(View* view)
foreach(MapHandlerGen* m, maps)
{
const PerMapParameterSet& p = params->perMap[m->getName()];
if(p.positionVBO != NULL && p.vectorVBO != NULL)
m_vectorShader->setScale(m->getBBdiagSize() / 100.0f * p.vectorsScaleFactor) ;
if(p.positionVBO != NULL)
{
m_vectorShader->setScale(m->getBBdiagSize() / 100.0f * p.vectorsScaleFactor) ;
m_vectorShader->setAttributePosition(p.positionVBO) ;
m_vectorShader->setAttributeVector(p.vectorVBO) ;
glLineWidth(1.0f) ;
m->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
for(std::vector<Utils::VBO*>::const_iterator it = p.vectorVBO.begin(); it != p.vectorVBO.end(); ++it)
{
m_vectorShader->setAttributeVector(*it) ;
glLineWidth(1.0f) ;
m->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
}
}
}
......@@ -155,14 +155,20 @@ void RenderVectorPlugin::cb_positionVBOChanged(int index)
}
}
void RenderVectorPlugin::cb_vectorVBOChanged(int index)
void RenderVectorPlugin::cb_selectedVectorVBOChanged()
{
if(!b_refreshingUI)
{
View* current = m_window->getCurrentView();
ParameterSet* params = h_viewParams[current];
MapHandlerGen* map = params->selectedMap;
params->perMap[map->getName()].vectorVBO = map->getVBO(m_dockTab->combo_vectorVBO->currentText());
PerMapParameterSet& mapParam = params->perMap[map->getName()];
mapParam.vectorVBO.clear();
QList<QListWidgetItem*> currentItems = m_dockTab->list_vectorVBO->selectedItems();
foreach(QListWidgetItem* item, currentItems)
mapParam.vectorVBO.push_back(map->getVBO(item->text()));
current->updateGL();
}
}
......@@ -194,7 +200,7 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
mapList->clear();
combo_positionVBO->clear();
combo_vectorVBO->clear();
list_vectorVBO->clear();
MapHandlerGen* map = params->selectedMap;
......@@ -209,6 +215,7 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
PerMapParameterSet& p = params->perMap[map->getName()];
// QList<Utils::VBO*> vbos = map->getVBOList(nameOfType(VEC3()));
QList<Utils::VBO*> vbos = map->getVBOList();
for(int i = 0; i < vbos.count(); ++i)
{
......@@ -224,9 +231,9 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
else if(vbos[i] == p.positionVBO)
combo_positionVBO->setCurrentIndex(i);
combo_vectorVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.vectorVBO)
combo_vectorVBO->setCurrentIndex(i);
list_vectorVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(std::find(p.vectorVBO.begin(), p.vectorVBO.end(), vbos[i]) != p.vectorVBO.end())
list_vectorVBO->item(i)->setSelected(true);
}
if(p.positionVBO == NULL && vbos.count() > 0)
......@@ -234,11 +241,6 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
p.positionVBO = vbos[0];
combo_positionVBO->setCurrentIndex(0);
}
if(p.vectorVBO == NULL && vbos.count() > 0)
{
p.vectorVBO = vbos[0];
combo_vectorVBO->setCurrentIndex(0);
}
slider_vectorsScaleFactor->setSliderPosition(p.vectorsScaleFactor * 50.0);
}
......
......@@ -15,14 +15,13 @@ struct PerMapParameterSet
{
PerMapParameterSet() :
positionVBO(NULL),
vectorVBO(NULL),
vectorsScaleFactor(1.0f)
{}
PerMapParameterSet(MapHandlerGen* map);
Utils::VBO* positionVBO;
Utils::VBO* vectorVBO;
std::vector<Utils::VBO*> vectorVBO;
float vectorsScaleFactor;
};
......@@ -99,7 +98,7 @@ protected:
public slots:
void cb_selectedMapChanged();
void cb_positionVBOChanged(int index);
void cb_vectorVBOChanged(int index);
void cb_selectedVectorVBOChanged();
void cb_refreshVBOs();
void cb_vectorsScaleFactorChanged(int i);
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>174</width>
<height>489</height>
<height>545</height>
</rect>
</property>
<property name="windowTitle">
......@@ -18,35 +18,15 @@
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vector :</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="combo_vectorVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<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="2">
<item>
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
......@@ -56,24 +36,38 @@
</property>
</widget>
</item>
<item row="2" column="2" alignment="Qt::AlignRight">
<widget class="QPushButton" name="button_refreshVBOs">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vectors :</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="list_vectorVBO">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_refreshVBOs">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
......
......@@ -21,11 +21,9 @@ file(
GLOB
SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/context.cpp
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp
${SCHNApps_ROOT_DIR}/src/system.cpp
${SCHNApps_ROOT_DIR}/src/view.cpp
${SCHNApps_ROOT_DIR}/src/window.cpp
${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp
......
#include "system.h"
#include <QErrorMessage>
#include <QMessageBox>
#include <QFileInfo>
#include <QUrl>
#include <QVBoxLayout>
#include <QTextBrowser>
namespace CGoGN
{
namespace SCHNApps
{
namespace System
{
} // namespace System
} // namespace SCHNApps
} // namespace CGoGN
#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#include <QWidget>
#include <QSplashScreen>
#include "types.h"
namespace CGoGN
{
namespace SCHNApps
{
class Window;
class SplitArea;
namespace System
{
} // namespace System
} // namespace SCHNApps
} // namespace CGoGN
#endif
......@@ -61,6 +61,7 @@ public:
Utils::VBO* getVBO(const QString& name);
QList<Utils::VBO*> getVBOList() const { return h_vbo.values(); }
QList<Utils::VBO*> getVBOList(const std::string& typeName);
void deleteVBO(const QString& name);
/*********************************************************
......
#ifndef _STATEHANDLER_H_
#define _STATEHANDLER_H_
class StateHandler{
class StateHandler
{
};
......
#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#include <QWidget>
#include <QSplashScreen>
#include "types.h"
//#include "ui_questionSessionDialog.h"
//#include "ui_infoDialog.h"
namespace CGoGN
{
namespace SCHNApps
{
class Window;
class SplitArea;
namespace System
{
//namespace Dialog
//{
//
//class QuestionSessionDialog : public QDialog, public Ui::QSDialog
//{
// Q_OBJECT
//
//public:
// QuestionSessionDialog(QWidget *parent = 0) : QDialog(parent)
// {
// this->setupUi(this);
// }
//};
//class InfoDialog : public QDialog, public Ui::InfoDialog
//{
// Q_OBJECT
//
//public:
// InfoDialog(QWidget *parent = 0) : QDialog(parent)
// {
// this->setupUi(this);
// }
//
// bool setContent(QUrl urlHTMLFile);
//};
//
//} // namespace Dialog
class Error
{
public:
virtual ~Error() = 0;
typedef enum
{
SUCCESS,
NO_SCENE,
SCENE_EXISTS,
SCENE_DOES_NOT_EXIST,
VIEW_EXISTS,
VIEW_DOES_NOT_EXIST,
CAMERA_EXISTS,
CAMERA_DOES_NOT_EXIST,
NO_DOCK,
NO_PLUGIN_PATH_FILE,
ERROR_OPEN_PLUGIN_FILE,
BAD_PLUGIN_PATH_FILE,
BAD_PLUGIN_PATH_IN_FILE,
NO_PLUGIN_IN_DIR,
PLUGIN_EXISTS,
PLUGIN_DOES_NOT_EXIST,
ERROR_PLUGIN_LOAD,
BAD_LINK_PLUGIN_WINDOW,
UNSATSIFIED_PLUGIN_DEPENDENCIE,
BAD_ACTION_MENU_PATH,
MAP_UNREFERENCED,
MAP_EXISTS,
MAP_DOES_NOT_EXIST,
SHADER_EXISTS,
SHADER_NOT_FOUND,
VBO_EXISTS,
VBO_DOES_NOT_EXIST,
VBO_NOT_FOUND,
TOPO3RENDER_EXISTS,
TOPO3RENDER_NOT_FOUND,
OPEN_FILE_ERROR,
BAD_XML_FILE
} ERROR_CODE;
static QString parameter;
static ERROR_CODE code;
static ERROR_CODE BAD_PLUGIN_PATH_IN_FILE_f(QString file);
static ERROR_CODE NO_PLUGIN_IN_DIR_f(QString dir);
static ERROR_CODE PLUGIN_EXISTS_f(QString plugin);
static ERROR_CODE ERROR_PLUGIN_LOAD_f(QString plugin);
static ERROR_CODE BAD_LINK_PLUGIN_WINDOW_f(QString plugin);
static ERROR_CODE UNSATSIFIED_PLUGIN_DEPENDENCIE_f(QString dependencie, QString from = QString());
static ERROR_CODE BAD_ACTION_MENU_PATH_f(QString actionPath);
static ERROR_CODE MAP_UNREFERENCED_f(QString map_name);
static ERROR_CODE MAP_EXISTS_f(QString map_name);
static ERROR_CODE SHADER_EXISTS_f(QString shader_name, QString glv_name = QString());
static ERROR_CODE SHADER_NOT_FOUND_f(QString shader_name, QString glv_name = QString());
static ERROR_CODE VBO_EXISTS_f(QString vbo_name, QString glv_name = QString());
static ERROR_CODE VBO_NOT_FOUND_f(QString vbo_name, QString glv_name = QString());
static ERROR_CODE TOPO3RENDER_EXISTS_f(QString name, QString glv_name = QString());
static ERROR_CODE TOPO3RENDER_NOT_FOUND_f(QString name, QString glv_name = QString());
static ERROR_CODE OPEN_FILE_ERROR_f(QString filepath);
static ERROR_CODE BAD_XML_FILE_f(QString filepath);
static void showError(QWidget *parent = 0);
};
class Events
{
public:
virtual ~Events() = 0;
static bool movieDialogOpened;
};
//class Info
//{
//public:
// virtual ~Info() = 0;
//
// static void showPluginInfo(QString pluginAbsolutePath, QWidget *parent = 0);
// static void showPluginInfo(QString locationPath, QString pluginName, QWidget *parent = 0);
//};
//class StateHandler
//{
//public:
// virtual ~StateHandler() = 0;
//
// static bool saveState(Window *window, PluginHash *pluginHash, SceneHash *sceneHash, SplitArea *splitArea);
// static bool loadState(Window *window, PluginHash *pluginHash, SceneHash *sceneHash, SplitArea *splitArea);
// static void unsaveState();
// static bool savePluginsInfo(Window *window, PluginHash *pluginHash, QStringList paths);
//};
//typedef enum
//{
// GLVIEWER_IN_DOCK,
// SIMPLE_GLVIEWER
//} QGLV_CREATE_SETTINGS;
} // namespace System
} // namespace SCHNApps
} // namespace CGoGN
#endif
......@@ -3,7 +3,7 @@
#include "ui_window.h"
#include "system.h"
#include "types.h"
class QVBoxLayout;
class QSplitter;
......
......@@ -13,7 +13,6 @@
//#include <QRegExp>
//#include <QTextBrowser>
#include "system.h"
#include "window.h"
#include "plugin.h"