Commit e4868c57 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: remove some warning + start compute normals

parent aadb3d36
......@@ -17,6 +17,16 @@
<item>
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......
......@@ -4,17 +4,47 @@
#include "Algo/Geometry/normal.h"
ComputeNormalsDialog::ComputeNormalsDialog(Window* w) : m_window(w)
{
setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
}
void ComputeNormalsDialog::cb_selectedMapChanged()
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
{
combo_positionAttribute->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname);
GenericMap* map = mh->getGenericMap();
AttributeContainer& cont = map->getAttributeContainer<VERTEX>();
std::vector<std::string> names;
cont.getAttributesNames(names);
for(unsigned int i = 0; i < names.size(); ++i)
combo_positionAttribute->addItem(QString::fromStdString(names[i]));
}
}
bool DifferentialPropertiesPlugin::enable()
{
m_computeNormalsDialog = new ComputeNormalsDialog();
m_computeNormalsDialog = new ComputeNormalsDialog(m_window);
computeNormalsAction = new QAction("import", this);
addMenuAction("Surface;DifferentialProperties;Compute Normals", computeNormalsAction);
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_computeNormals()));
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog()));
connect(m_computeNormalsDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormals()));
return true;
}
void DifferentialPropertiesPlugin::cb_computeNormals()
void DifferentialPropertiesPlugin::cb_openComputeNormalsDialog()
{
m_computeNormalsDialog->mapList->clear();
m_computeNormalsDialog->attributeName->setText("normal");
......@@ -25,6 +55,24 @@ void DifferentialPropertiesPlugin::cb_computeNormals()
m_computeNormalsDialog->show();
}
void DifferentialPropertiesPlugin::cb_computeNormals()
{
QList<QListWidgetItem*> currentItems = m_computeNormalsDialog->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
std::string positionName = m_computeNormalsDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeNormalsDialog->attributeName->text().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName);
if(!normal.isValid())
normal = map->addAttribute<VEC3, VERTEX>(normalName);
Algo::Geometry::computeNormalVertices<PFP>(*map, position, normal);
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(DifferentialPropertiesPlugin, DifferentialPropertiesPlugin)
#else
......
......@@ -25,8 +25,16 @@ typedef PFP::VEC3 VEC3;
class ComputeNormalsDialog : public QDialog, public Ui::ComputeNormalsDialog
{
Q_OBJECT
public:
ComputeNormalsDialog() { setupUi(this); }
ComputeNormalsDialog(Window* w);
public slots:
void cb_selectedMapChanged();
private:
Window* m_window;
};
......@@ -64,6 +72,7 @@ public:
virtual void mapUnlinked(View* view, MapHandlerGen* m) {}
public slots:
void cb_openComputeNormalsDialog();
void cb_computeNormals();
private:
......
......@@ -9,8 +9,8 @@ bool RenderVectorPlugin::enable()
m_dockTab = new RenderVectorDockTab(this);
addTabInDock(m_dockTab, "RenderVector");
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setColor(Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)) ;
m_vectorShader = new Utils::ShaderVectorPerVertex();
m_vectorShader->setColor(Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f));
registerShader(m_vectorShader);
......
......@@ -33,7 +33,7 @@ public:
* CAMERA DRAWING
*********************************************************/
void draw();
virtual void draw();
bool getDraw() const { return m_draw; }
void setDraw(bool b = true) { m_draw = b; }
......
......@@ -116,15 +116,6 @@ public:
{
m_render->initPrimitives<PFP>(*(reinterpret_cast<typename PFP::MAP*>(m_map)), good, primitive) ;
}
void updateVBOs()
{
QList<Utils::VBO*> vbos = getVBOList();
foreach(Utils::VBO* vbo, vbos)
{
}
}
};
} // namespace SCHNApps
......
......@@ -21,7 +21,7 @@ class Plugin;
class View;
class Camera;
class MapHandlerGen;
class Texture;
struct Texture;
typedef QHash<QString, Plugin*> PluginHash;
typedef QHash<QString, View*> ViewHash;
......
......@@ -16,7 +16,7 @@ namespace SCHNApps
{
class View;
class Texture;
struct Texture;
class ViewButton : public QObject
{
......
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