/** * Maps the given model position to the grid. */ RVector ROrthoGrid::snapToGrid(const RVector& positionUcs) { RDocumentInterface* documentInterface = view.getDocumentInterface(); if (documentInterface==NULL) { return RVector::invalid; } RVector sp = spacing; if (!sp.isValid()) { sp = metaSpacing; if (isometric) { sp /= 2; } } int x = RMath::mround(positionUcs.x / sp.x); int y = RMath::mround(positionUcs.y / sp.y); int z = RMath::mround(positionUcs.z / sp.z); // closest grid point is not available in isometric grid, // find closest available grid point: if (isometric && (x+y)%2!=0) { int cx, cy; double minDist = RMAXDOUBLE; double dist; for (int ix=-1; ix<=1; ix++) { for (int iy=-1; iy<=1; iy++) { if (qAbs(ix) + qAbs(iy)!=1) { continue; } cx = RMath::mround(positionUcs.x / sp.x) + ix; cy = RMath::mround(positionUcs.y / sp.y) + iy; dist = positionUcs.getDistanceTo(RVector(cx*sp.x, cy*sp.y)); if (dist<minDist) { x = cx; y = cy; minDist = dist; } } } } RVector gridPositionUcs = RVector( x * sp.x, y * sp.y, z * sp.z ); RUcs ucs = documentInterface->getCurrentUcs(); return ucs.mapFromUcs(gridPositionUcs); }
QScriptValue REcmaSharedPointerUcs::isSelectedForPropertyEditing (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerUcs::isSelectedForPropertyEditing", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerUcs::isSelectedForPropertyEditing"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RUcs* self = getSelf("isSelectedForPropertyEditing", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 0 ){ // prepare arguments: // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->isSelectedForPropertyEditing(); // return type: bool // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RUcs.isSelectedForPropertyEditing().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerUcs::isSelectedForPropertyEditing", context, engine); return result; }
QScriptValue REcmaSharedPointerUcs::clone (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerUcs::clone", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerUcs::clone"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RUcs* self = getSelf("clone", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 0 ){ // prepare arguments: // end of arguments // call C++ function: // return type 'RUcs *' RUcs * cppResult = self->clone(); // return type: RUcs * // not standard type nor reference result = qScriptValueFromValue(engine, cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RUcs.clone().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerUcs::clone", context, engine); return result; }
QScriptValue REcmaSharedPointerUcs::setProperty (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerUcs::setProperty", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerUcs::setProperty"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RUcs* self = getSelf("setProperty", context); //Q_ASSERT(self!=NULL); if (self==NULL) { return REcmaHelper::throwError("self is NULL", context); } if( context->argumentCount() == 2 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RPropertyTypeId */ && ( context->argument(1).isVariant() || context->argument(1).isQObject() || context->argument(1).isNumber() || context->argument(1).isString() || context->argument(1).isBool() || context->argument(1).isArray() || context->argument(1).isNull() || context->argument(1).isUndefined() ) /* type: QVariant */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RPropertyTypeId* ap0 = qscriptvalue_cast< RPropertyTypeId* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RUcs: Argument 0 is not of type RPropertyTypeId.", context); } RPropertyTypeId a0 = *ap0; // argument isCopyable or pointer QVariant a1 = qscriptvalue_cast< QVariant >( context->argument( 1 ) ); // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->setProperty(a0 , a1); // return type: bool // standard Type result = QScriptValue(cppResult); } else if( context->argumentCount() == 3 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RPropertyTypeId */ && ( context->argument(1).isVariant() || context->argument(1).isQObject() || context->argument(1).isNumber() || context->argument(1).isString() || context->argument(1).isBool() || context->argument(1).isArray() || context->argument(1).isNull() || context->argument(1).isUndefined() ) /* type: QVariant */ && ( context->argument(2).isVariant() || context->argument(2).isQObject() || context->argument(2).isNull() ) /* type: RTransaction * */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RPropertyTypeId* ap0 = qscriptvalue_cast< RPropertyTypeId* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RUcs: Argument 0 is not of type RPropertyTypeId.", context); } RPropertyTypeId a0 = *ap0; // argument isCopyable or pointer QVariant a1 = qscriptvalue_cast< QVariant >( context->argument( 1 ) ); // argument is pointer RTransaction * a2 = NULL; a2 = REcmaHelper::scriptValueTo<RTransaction >( context->argument(2) ); if (a2==NULL && !context->argument(2).isNull()) { return REcmaHelper::throwError("RUcs: Argument 2 is not of type RTransaction *RTransaction *.", context); } // end of arguments // call C++ function: // return type 'bool' bool cppResult = self->setProperty(a0 , a1 , a2); // return type: bool // standard Type result = QScriptValue(cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RUcs.setProperty().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerUcs::setProperty", context, engine); return result; }
QScriptValue REcmaSharedPointerUcs::getProperty (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerUcs::getProperty", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerUcs::getProperty"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RUcs* self = getSelf("getProperty", 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: RPropertyTypeId */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RPropertyTypeId* ap0 = qscriptvalue_cast< RPropertyTypeId* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RUcs: Argument 0 is not of type RPropertyTypeId.", context); } RPropertyTypeId a0 = *ap0; // end of arguments // call C++ function: // return type 'QPair < QVariant , RPropertyAttributes >' QPair < QVariant , RPropertyAttributes > cppResult = self->getProperty(a0); // return type: QPair < QVariant , RPropertyAttributes > // Pair of ...: //result = REcmaHelper::pairToScriptValue(engine, cppResult); QVariantList vl; QVariant v; // first type of pair is variant: if (QString(cppResult.first.typeName())=="RLineweight::Lineweight") { v.setValue((int)cppResult.first.value<RLineweight::Lineweight>()); } else { v.setValue(cppResult.first); } vl.append(v); v.setValue(cppResult.second); vl.append(v); result = qScriptValueFromValue(engine, vl); } else if( context->argumentCount() == 2 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RPropertyTypeId */ && ( context->argument(1).isBool() ) /* type: bool */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RPropertyTypeId* ap0 = qscriptvalue_cast< RPropertyTypeId* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RUcs: Argument 0 is not of type RPropertyTypeId.", context); } RPropertyTypeId a0 = *ap0; // argument isStandardType bool a1 = (bool) context->argument( 1 ). toBool(); // end of arguments // call C++ function: // return type 'QPair < QVariant , RPropertyAttributes >' QPair < QVariant , RPropertyAttributes > cppResult = self->getProperty(a0 , a1); // return type: QPair < QVariant , RPropertyAttributes > // Pair of ...: //result = REcmaHelper::pairToScriptValue(engine, cppResult); QVariantList vl; QVariant v; // first type of pair is variant: if (QString(cppResult.first.typeName())=="RLineweight::Lineweight") { v.setValue((int)cppResult.first.value<RLineweight::Lineweight>()); } else { v.setValue(cppResult.first); } vl.append(v); v.setValue(cppResult.second); vl.append(v); result = qScriptValueFromValue(engine, vl); } else if( context->argumentCount() == 3 && ( context->argument(0).isVariant() || context->argument(0).isQObject() || context->argument(0).isNull() ) /* type: RPropertyTypeId */ && ( context->argument(1).isBool() ) /* type: bool */ && ( context->argument(2).isBool() ) /* type: bool */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RPropertyTypeId* ap0 = qscriptvalue_cast< RPropertyTypeId* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RUcs: Argument 0 is not of type RPropertyTypeId.", context); } RPropertyTypeId a0 = *ap0; // argument isStandardType bool a1 = (bool) context->argument( 1 ). toBool(); // argument isStandardType bool a2 = (bool) context->argument( 2 ). toBool(); // end of arguments // call C++ function: // return type 'QPair < QVariant , RPropertyAttributes >' QPair < QVariant , RPropertyAttributes > cppResult = self->getProperty(a0 , a1 , a2); // return type: QPair < QVariant , RPropertyAttributes > // Pair of ...: //result = REcmaHelper::pairToScriptValue(engine, cppResult); QVariantList vl; QVariant v; // first type of pair is variant: if (QString(cppResult.first.typeName())=="RLineweight::Lineweight") { v.setValue((int)cppResult.first.value<RLineweight::Lineweight>()); } else { v.setValue(cppResult.first); } vl.append(v); v.setValue(cppResult.second); vl.append(v); result = qScriptValueFromValue(engine, vl); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RUcs.getProperty().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerUcs::getProperty", context, engine); return result; }
QScriptValue REcmaSharedPointerUcs::mapToUcs (QScriptContext* context, QScriptEngine* engine) { //REcmaHelper::functionStart("REcmaSharedPointerUcs::mapToUcs", context, engine); //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerUcs::mapToUcs"; //QCoreApplication::processEvents(); QScriptValue result = engine->undefinedValue(); // public function: can be called from ECMA wrapper of ECMA shell: RUcs* self = getSelf("mapToUcs", 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: RVector */ ){ // prepare arguments: // argument isCopyable and has default constructor and isSimpleClass RVector* ap0 = qscriptvalue_cast< RVector* >( context->argument( 0 ) ); if (ap0 == NULL) { return REcmaHelper::throwError("RUcs: Argument 0 is not of type RVector.", context); } RVector a0 = *ap0; // end of arguments // call C++ function: // return type 'RVector' RVector cppResult = self->mapToUcs(a0); // return type: RVector // not standard type nor reference result = qScriptValueFromValue(engine, cppResult); } else { return REcmaHelper::throwError("Wrong number/types of arguments for RUcs.mapToUcs().", context); } //REcmaHelper::functionEnd("REcmaSharedPointerUcs::mapToUcs", context, engine); return result; }