void RGraphicsSceneQt::exportRay(const RRay& ray) { bool created = beginPath(); Q_ASSERT(currentPainterPath.isValid()); // find largest view box over all attached views: RBox box; QList<RGraphicsView*>::iterator it; for (it=views.begin(); it!=views.end(); it++) { RBox b = (*it)->getBox(); box.growToIncludeBox(b); } // trim line to view box: RLine clippedLine = ray.getClippedLine(box); double offs = clippedLine.getStartPoint().getDistanceTo(ray.getBasePoint()); if (RMath::isSameDirection(ray.getBasePoint().getAngleTo(clippedLine.getStartPoint()), ray.getDirection1())) { offs *= -1; } exportLine(clippedLine, offs); currentPainterPath.setAlwaysRegen(true); if (created) { endPath(); } }
QScriptValue REcmaSharedPointerRay::getClippedLine (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerRay::getClippedLine", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerRay::getClippedLine"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RRay* self = getSelf("getClippedLine", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 1 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RBox */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RBox* ap0 = qscriptvalue_cast< RBox* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RRay: Argument 0 is not of type RBox.", context); } RBox a0 = *ap0; // end of arguments // call C++ function: // return type 'RLine' RLine cppResult = self->getClippedLine(a0); // return type: RLine // not standard type nor reference result = qScriptValueFromValue(engine, cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RRay.getClippedLine().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerRay::getClippedLine", context, engine); return result; }