Commit 32fbe53b authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis:

Decimater Cleaner-scripting-function-implementation

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6623 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 893426d3
......@@ -82,9 +82,9 @@ bool DecimaterPlugin::initializeToolbox(QWidget*& _widget)
*/
void DecimaterPlugin::pluginsInitialized() {
emit setSlotDescription("decimate(int,QString,QString)","Decimate a given object",
QString("objectId,constraints,values").split(","),
QString("ID of an object; comma separated list of constraints (distance,normal_deviation,roundness,triangles); comma separated list of constraint values suited to 'constraints' parameter").split(";"));
emit setSlotDescription("decimate(int,Object)","Decimate a given object",
QString("objectId,constraints").split(","),
QString("ID of an object; Object that can has one or more constraint properties (distance,normal_deviation,roundness,triangles)").split(";"));
}
......@@ -179,7 +179,7 @@ void DecimaterPlugin::slot_decimate()
* @param _constraints A string containing a comma separated list of constraints (distance,normal_deviation,roundness,triangles)
* @param _values a string containing a comma separated list of constraint values suited to the _constraints parameter
*/
void DecimaterPlugin::decimate(int _objID, QString _constraints, QString _values){
void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints){
BaseObjectData* baseObjectData;
......@@ -207,72 +207,52 @@ void DecimaterPlugin::decimate(int _objID, QString _constraints, QString _values
//remove old constraints
decimater->removeConstraints();
//and set new constraints
QStringList constraints = _constraints.toLower().split(",");
QStringList values = _values.split(",");
//distance constraint
if ( constraints.contains("distance") ){
int i = constraints.indexOf("distance");
if ( _constraints.contains("distance") ){
if ( i >= 0 && i < values.count() ){
bool ok;
bool ok;
double value = values[i].toDouble(&ok);
double value = _constraints["distance"].toDouble(&ok);
if (ok)
decimater->setDistanceConstraint( value );
}
if (ok)
decimater->setDistanceConstraint( value );
}
//normal deviation constraint
if ( constraints.contains("normal_deviation") ){
int i = constraints.indexOf("normal_deviation");
if ( _constraints.contains("normal_deviation") ){
if ( i >= 0 && i < values.count() ){
bool ok;
bool ok;
int value = values[i].toInt(&ok);
int value = _constraints["normal_deviation"].toInt(&ok);
if (ok)
decimater->setNormalDeviationConstraint( value );
}
if (ok)
decimater->setNormalDeviationConstraint( value );
}
//roundness constraint
if ( constraints.contains("roundness") ){
int i = constraints.indexOf("roundness");
if ( _constraints.contains("roundness") ){
if ( i >= 0 && i < values.count() ){
bool ok;
bool ok;
double value = values[i].toDouble(&ok);
double value = _constraints["roundness"].toDouble(&ok);
if (ok)
decimater->setRoundnessConstraint( value );
}
if (ok)
decimater->setRoundnessConstraint( value );
}
//triangleCount constraint
bool triangleCount = false;
int triangles = 0;
if ( constraints.contains("triangles") ){
int i = constraints.indexOf("triangles");
if ( _constraints.contains("triangles") ){
if ( i >= 0 && i < values.count() ){
bool ok;
bool ok;
int value = values[i].toInt(&ok);
int value = _constraints["triangles"].toInt(&ok);
if (ok){
triangleCount = true;
triangles = value;
}
if (ok){
triangleCount = true;
triangles = value;
}
}
......
......@@ -116,7 +116,7 @@ private slots:
//===========================================================================
public slots:
void decimate(int _objID, QString _constraints, QString _values);
void decimate(int _objID, QVariantMap _constraints);
public slots:
QString version() { return QString("1.0"); };
......
Supports Markdown
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