Commit dd1cbdad authored by Mike Kremer's avatar Mike Kremer

Made simple smoother plugin scriptable and added backup as well as script info...

Made simple smoother plugin scriptable and added backup as well as script info logging to the smoothing function.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9754 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c10f5834
......@@ -77,13 +77,39 @@ void SmootherPlugin::initializePlugin()
emit addToolbox( tr("Simple Smoother") , toolBox );
}
/** \brief
void SmootherPlugin::pluginsInitialized() {
// Emit slot description
emit setSlotDescription(tr("simpleLaplace(int)"), tr("Smooth mesh using the Laplace operator with uniform weights."),
QStringList(tr("iterations")), QStringList(tr("Number of iterations")));
}
/** \brief simpleLaplace
*
* Smooth mesh using the Laplace operator
* with uniform weights.
*/
void SmootherPlugin::simpleLaplace() {
int iterations = 1;
if(!OpenFlipper::Options::nogui()) {
iterations = iterationsSpinbox_->value();
}
simpleLaplace(iterations);
}
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
/** \brief simpleLaplace
*
* Smooth mesh using the Laplace operator
* with uniform weights.
*
* @_iterations Number of iterations
*/
void SmootherPlugin::simpleLaplace(int _iterations) {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
bool selectionExists = false;
......@@ -98,7 +124,7 @@ void SmootherPlugin::simpleLaplace() {
// Add a property to the mesh to store original vertex positions
mesh->add_property( origPositions, "SmootherPlugin_Original_Positions" );
for ( int i = 0 ; i < iterationsSpinbox_->value() ; ++i ) {
for ( int i = 0 ; i < _iterations ; ++i ) {
// Copy original positions to backup ( in Vertex property )
TriMesh::VertexIter v_it, v_end=mesh->vertices_end();
......@@ -165,7 +191,7 @@ void SmootherPlugin::simpleLaplace() {
// Add a property to the mesh to store original vertex positions
mesh->add_property( origPositions, "SmootherPlugin_Original_Positions" );
for ( int i = 0 ; i < iterationsSpinbox_->value() ; ++i ) {
for ( int i = 0 ; i < _iterations ; ++i ) {
// Copy original positions to backup ( in Vertex property )
PolyMesh::VertexIter v_it, v_end=mesh->vertices_end();
......@@ -219,12 +245,18 @@ void SmootherPlugin::simpleLaplace() {
mesh->update_normals();
emit updatedObject( o_it->id() , UPDATE_GEOMETRY);
// Create backup
emit createBackup(o_it->id(), "Simple Smoothing");
} else {
emit log(LOGERR, "DataType not supported.");
}
}
// Show script logging
emit scriptInfo(tr("simpleLaplace(%1)").arg(_iterations));
}
......
......@@ -49,26 +49,38 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/common/Types.hh>
class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface
class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(BackupInterface)
signals:
//BaseInterface
void updateView();
void updatedObject(int _id, const UpdateType _type);
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
//LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
// ToolboxInterface
void addToolbox( QString _name , QWidget* _widget );
void addToolbox( QString _name , QWidget* _widget );
// ScriptInterface
void scriptInfo(QString _functionName);
// BackupInterface
void createBackup(int _objectId, QString _description);
public:
......@@ -86,9 +98,14 @@ class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingI
void initializePlugin(); // BaseInterface
void pluginsInitialized(); // BaseInterface
// Scriptable functions
public slots:
QString version() { return QString("1.0"); };
void simpleLaplace(int _iterations);
QString version() { return QString("1.0"); };
};
#endif //SMOOTHERPLUGIN_HH
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