예제 #1
0
         QScriptValue
        REcmaLinetypePattern::getDelta
        (QScriptContext* context, QScriptEngine* engine) 
        
        {
            //REcmaHelper::functionStart("REcmaLinetypePattern::getDelta", context, engine);
            //qDebug() << "ECMAScript WRAPPER: REcmaLinetypePattern::getDelta";
            //QCoreApplication::processEvents();

            QScriptValue result = engine->undefinedValue();
            
                    // public function: can be called from ECMA wrapper of ECMA shell:
                    RLinetypePattern* self = 
                        getSelf("getDelta", context);
                  

                //Q_ASSERT(self!=NULL);
                if (self==NULL) {
                    return REcmaHelper::throwError("self is NULL", context);
                }
                
    
    if( context->argumentCount() ==
    1 && (
            context->argument(0).isNumber()
        ) /* type: double */
    
    ){
    // prepare arguments:
    
                    // argument isStandardType
                    double
                    a0 =
                    (double)
                    
                    context->argument( 0 ).
                    toNumber();
                
    // end of arguments

    // call C++ function:
    // return type 'double'
    double cppResult =
        
               self->getDelta(a0);
        // return type: double
                // standard Type
                result = QScriptValue(cppResult);
            
    } else


        
            {
               return REcmaHelper::throwError("Wrong number/types of arguments for RLinetypePattern.getDelta().",
                   context);
            }
            //REcmaHelper::functionEnd("REcmaLinetypePattern::getDelta", context, engine);
            return result;
        }
예제 #2
0
double RExporter::getPatternOffset(double length,
        const RLinetypePattern& pattern, int index, double* gap) {
    double patternLength = pattern.getPatternLength();
    if (patternLength<RS::PointTolerance) {
        return 0.0;
    }

    double po = fabs(pattern.getDashLengthAt(index)) / 2;
    for (int i = index - 1; i >= 0; --i) {
        po += fabs(pattern.getDashLengthAt(i));
    }
    double offset = length / 2 - po;
    int m = (int) RMath::trunc(offset / patternLength);
    offset -= (m + 1) * patternLength;
    if (gap != NULL) {
        *gap = pattern.getDelta(-offset);
    }
    return offset;
}