Commit b9928792 authored by Dirk Wilden's avatar Dirk Wilden

updated scripting function

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5036 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4caf2844
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
/** \brief Initialize the toolbox
*
* @param _widget reference to the toolbox
* @return was the toolbox successfully created?
*/
bool bool
SmootherPlugin:: SmootherPlugin::
initializeToolbox(QWidget*& _widget) initializeToolbox(QWidget*& _widget)
...@@ -42,6 +47,30 @@ initializeToolbox(QWidget*& _widget) ...@@ -42,6 +47,30 @@ initializeToolbox(QWidget*& _widget)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** \brief Set the scripting slot descriptions
*
*/
void
SmootherPlugin::pluginsInitialized(){
emit setSlotDescription("smooth(int,int,QString,QString,double)", "Smooth an object",
QString("object_id,iterations,direction,continuity,maxDistance").split(","),
QString("id of an object, number of smoothing iterations, Smoothing direction. (tangential;normal;tangential+normal), Continuity. (C1 or C2), max distance the smoothed mesh is allowed to differ from the original").split(","));
emit setSlotDescription("smooth(int,int,QString,QString)", "Smooth an object",
QString("object_id,iterations,direction,continuity").split(","),
QString("id of an object, number of smoothing iterations, Smoothing direction. (tangential;normal;tangential+normal), Continuity. (C1 or C2)").split(","));
}
//-----------------------------------------------------------------------------
/** \brief Smooth all target objects
*
* Parameters for the smoothing are retrieved from the toolbox
*
*/
void void
SmootherPlugin:: SmootherPlugin::
slot_smooth() slot_smooth()
...@@ -107,7 +136,19 @@ slot_smooth() ...@@ -107,7 +136,19 @@ slot_smooth()
} }
void SmootherPlugin::smooth(int _objectId , int _iterations , QString _direction , QString _continuity) {
//-----------------------------------------------------------------------------
/** \brief Smooth object
*
* @param _objectId Object to smooth
* @param _iterations Number of smoothing iterations
* @param _direction tangential/normal/tangential+normal
* @param _continuity C0/C1
* @param _maxDistance the maximum distance that the smoothed mesh is allowed to differ from the original mesh
*/
void SmootherPlugin::smooth(int _objectId , int _iterations , QString _direction , QString _continuity, double _maxDistance) {
BaseObjectData* baseObjectData; BaseObjectData* baseObjectData;
if ( ! PluginFunctions::getObject(_objectId,baseObjectData) ) { if ( ! PluginFunctions::getObject(_objectId,baseObjectData) ) {
emit log(LOGERR,"Unable to get Object"); emit log(LOGERR,"Unable to get Object");
...@@ -152,6 +193,11 @@ void SmootherPlugin::smooth(int _objectId , int _iterations , QString _direction ...@@ -152,6 +193,11 @@ void SmootherPlugin::smooth(int _objectId , int _iterations , QString _direction
else if( c0 ) else if( c0 )
continuity = OpenMesh::Smoother::SmootherT< TriMesh >::C0; continuity = OpenMesh::Smoother::SmootherT< TriMesh >::C0;
if ( _maxDistance > 0.0)
data->smoother->set_absolute_local_error( _maxDistance );
else
data->smoother->set_absolute_local_error( FLT_MAX );
data->smoother->initialize(component,continuity); data->smoother->initialize(component,continuity);
data->smoother->smooth( _iterations ); data->smoother->smooth( _iterations );
......
...@@ -42,26 +42,29 @@ class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingI ...@@ -42,26 +42,29 @@ class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingI
signals: signals:
/// Force Examiner widget to update their views // BaseInterface
void updateView(); void updateView();
void log(Logtype _type, QString _message);
void log(QString _message);
/// Emit this Signal, if object list has changed (e.g. Source or Target changed)
void updatedObject(int); void updatedObject(int);
void activeObjectChanged(); void activeObjectChanged();
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
// LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
public : public :
// default constructor /// default constructor
SmootherPlugin() : tool_(0) {}; SmootherPlugin() : tool_(0) {};
// default destructor /// default destructor
~SmootherPlugin() {}; ~SmootherPlugin() {};
/** Initialize the toolbar (create a widget in the right side toolbox) */ /// Initialize the toolbar (create a widget in the right side toolbox)
bool initializeToolbox(QWidget*& _widget); bool initializeToolbox(QWidget*& _widget);
/// Name of the Plugin /// Name of the Plugin
...@@ -73,6 +76,10 @@ public : ...@@ -73,6 +76,10 @@ public :
/// User selected plugins Toolbox /// User selected plugins Toolbox
void toolboxActivated( bool /*_activated*/ ) {}; void toolboxActivated( bool /*_activated*/ ) {};
private slots:
/// Second initialization stage
void pluginsInitialized();
private : private :
...@@ -81,20 +88,22 @@ private : ...@@ -81,20 +88,22 @@ private :
private slots: private slots:
/// Slot connected to the smooth button in the toolbox
void slot_smooth(); void slot_smooth();
//===========================================================================
/** @name Scripting Functions
* @{ */
//===========================================================================
public slots:
/// Smooth an object
void smooth(int _objectId , int _iterations , QString _direction , QString _continuity, double _maxDistance = -1.0);
public slots: public slots:
QString version() { return QString("1.0"); }; QString version() { return QString("1.0"); };
/** \brief Smooth object /** @} */
*
* @param _objectId Object to smooth
* @param _iterations Number of smoothing iterations
* @param _direction tangential/normal/tangential+normal
* @param _continuity C0/C1
*/
void smooth(int _objectId , int _iterations , QString _direction , QString _continuity);
}; };
......
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