QScriptValue REcmaLinetypePattern::isSymmetrical (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaLinetypePattern::isSymmetrical", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaLinetypePattern::isSymmetrical"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RLinetypePattern* self = getSelf("isSymmetrical", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 1 && ( context->argument(0).isNumber() ) /* type: int */ ){ // prepare arguments: // argument isStandardType int a0 = (int) context->argument( 0 ). toNumber(); // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->isSymmetrical(a0); // return type: bool // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RLinetypePattern.isSymmetrical().", context); } //REcmaHelper::functionEnd("REcmaLinetypePattern::isSymmetrical", context, engine); return result; }
/** * \return Offset to use to apply the given pattern to an entity of the * given length that the pattern is symmetrical. */ double RExporter::getPatternOffset(double length, const RLinetypePattern& pattern) { double optOffset = 0.0; double gap = 0.0; double maxGap = RMINDOUBLE; for (int i = 0; i < pattern.getNumDashes(); ++i) { if (!pattern.isSymmetrical(i)) { continue; } double offset = getPatternOffset(length, pattern, i, &gap); if (gap > maxGap) { maxGap = gap; optOffset = offset; // qDebug(QString("RExporter::getPatternOffset: i=%1").arg(i)); } } return optOffset; }