diff --git a/SCHNApps/Plugins/differentialProperties/computeNormalsDialog.ui b/SCHNApps/Plugins/differentialProperties/computeNormalsDialog.ui index f0532839447fb524c4bc47bf2d18361bb5a1bc83..50d0c0b5b91e0f7f5ce97166b19a5413043d1d8f 100644 --- a/SCHNApps/Plugins/differentialProperties/computeNormalsDialog.ui +++ b/SCHNApps/Plugins/differentialProperties/computeNormalsDialog.ui @@ -17,6 +17,16 @@ + + + + + 0 + 0 + + + + diff --git a/SCHNApps/Plugins/differentialProperties/differentialProperties.cpp b/SCHNApps/Plugins/differentialProperties/differentialProperties.cpp index 02b588143197f7a14943662afacf0fbe5ba761c6..ebb179b0fa08511f528f77ffcb8be67184cf9a78 100644 --- a/SCHNApps/Plugins/differentialProperties/differentialProperties.cpp +++ b/SCHNApps/Plugins/differentialProperties/differentialProperties.cpp @@ -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 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(); + std::vector 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 currentItems = m_computeNormalsDialog->mapList->selectedItems(); + if(!currentItems.empty()) + { + const QString& mapname = currentItems[0]->text(); + MapHandler* mh = reinterpret_cast*>(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 position = map->getAttribute(positionName); + VertexAttribute normal = map->getAttribute(normalName); + if(!normal.isValid()) + normal = map->addAttribute(normalName); + Algo::Geometry::computeNormalVertices(*map, position, normal); + } +} + #ifndef DEBUG Q_EXPORT_PLUGIN2(DifferentialPropertiesPlugin, DifferentialPropertiesPlugin) #else diff --git a/SCHNApps/Plugins/differentialProperties/differentialProperties.h b/SCHNApps/Plugins/differentialProperties/differentialProperties.h index 03fc6b1cba0174611ea27cf3b2fae6bbf2b7c397..fec9b90fc392656e17dd245251328b23432ea910 100644 --- a/SCHNApps/Plugins/differentialProperties/differentialProperties.h +++ b/SCHNApps/Plugins/differentialProperties/differentialProperties.h @@ -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: diff --git a/SCHNApps/Plugins/renderVector/renderVector.cpp b/SCHNApps/Plugins/renderVector/renderVector.cpp index 95c2ffbe7c0376ea3480ba5a5a58a5164433bda7..6c316139ab87e4e4adc8b1e62f25e72e86a23d0d 100644 --- a/SCHNApps/Plugins/renderVector/renderVector.cpp +++ b/SCHNApps/Plugins/renderVector/renderVector.cpp @@ -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); diff --git a/SCHNApps/include/camera.h b/SCHNApps/include/camera.h index fb5b5884957fa54e9775b55434b75dc7ea85a1a9..1265fd00c89c1987dc3db951febab8d4fbc8fc90 100644 --- a/SCHNApps/include/camera.h +++ b/SCHNApps/include/camera.h @@ -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; } diff --git a/SCHNApps/include/mapHandler.h b/SCHNApps/include/mapHandler.h index 9e886802821c08e25b407eb618f43fedc1b68ab4..19fccac1c38a56ae3d2e47b6c6c40352ea17458c 100644 --- a/SCHNApps/include/mapHandler.h +++ b/SCHNApps/include/mapHandler.h @@ -116,15 +116,6 @@ public: { m_render->initPrimitives(*(reinterpret_cast(m_map)), good, primitive) ; } - - void updateVBOs() - { - QList vbos = getVBOList(); - foreach(Utils::VBO* vbo, vbos) - { - - } - } }; } // namespace SCHNApps diff --git a/SCHNApps/include/types.h b/SCHNApps/include/types.h index 841a0091e430200ce8b9ca0810ce3304e97f1aca..89ced8892c3023243b4d362ba2360b9af59f4082 100644 --- a/SCHNApps/include/types.h +++ b/SCHNApps/include/types.h @@ -21,7 +21,7 @@ class Plugin; class View; class Camera; class MapHandlerGen; -class Texture; +struct Texture; typedef QHash PluginHash; typedef QHash ViewHash; diff --git a/SCHNApps/include/viewButtonArea.h b/SCHNApps/include/viewButtonArea.h index 9d5897bb5ee69c0a528b2d6d5682efda3c2ec010..d65a98f8198e4594b3660fef3e155b02cdffc29d 100644 --- a/SCHNApps/include/viewButtonArea.h +++ b/SCHNApps/include/viewButtonArea.h @@ -16,7 +16,7 @@ namespace SCHNApps { class View; -class Texture; +struct Texture; class ViewButton : public QObject {