QScriptValue
        REcmaSharedPointerTextLabel::getUserData
        (QScriptContext* context, QScriptEngine* engine) 
        
        {
            //REcmaHelper::functionStart("REcmaSharedPointerTextLabel::getUserData", context, engine);
            //qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerTextLabel::getUserData";
            //QCoreApplication::processEvents();

            QScriptValue result = engine->undefinedValue();
            
                    // public function: can be called from ECMA wrapper of ECMA shell:
                    RTextLabel* self = 
                        getSelf("getUserData", 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 'QVariant'
    QVariant cppResult =
        
               self->getUserData();
        // return type: QVariant
                // QVariant:
                result = REcmaHelper::toScriptValue(engine, cppResult);
            
    } else


        
            {
               return REcmaHelper::throwError("Wrong number/types of arguments for RTextLabel.getUserData().",
                   context);
            }
            //REcmaHelper::functionEnd("REcmaSharedPointerTextLabel::getUserData", context, engine);
            return result;
        }
Ejemplo n.º 2
0
void REventHandler::drawInfoLabel(QPainter* painter, const RTextLabel& textLabel) {
    RVector pos = textLabel.getPosition();
    QString text = textLabel.getText();

    RVector p = graphicsView->mapToView(pos);
    // info labels might have individual colors in future
    //var color = RSettings.getColor("GraphicsViewColors/TextLabelColor", new RColor(249,198,31));
    RColor color = RSettings::getColor("GraphicsViewColors/MeasurementToolsColor", RColor(155,220,112));
    painter->setPen(color);

    if (!text.isEmpty()) {
        QFont font = RSettings::getInfoLabelFont();
        font.setPointSizeF(font.pointSizeF()*graphicsView->getDevicePixelRatio());
        QFontMetrics fm(font);
        int w = fm.width(text)+10;
        int h = fm.height()+10;
        //fm.destroy();
        painter->setFont(font);
        painter->drawText(p.x - w - 15, p.y + h + 5, w, h, Qt::AlignHCenter | Qt::AlignVCenter, text, NULL);
    }
}
Ejemplo n.º 3
0
void REcmaHelper::fromScriptValue(QScriptEngine* engine, QScriptValue scriptValue, QList<QSharedPointer<RShape> >& cppValue) {
    QVariantList variantList = engine->fromScriptValue<QVariantList>(scriptValue);
    for (int i = 0; i < variantList.size(); ++i) {
        QVariant v = variantList.at(i);
        QSharedPointer<RShape> pShape = v.value<QSharedPointer<RShape> >();
        if (!pShape.isNull()) {
            cppValue.append(pShape);
        }
        else {
            RShape* shape = v.value<RShape*>();
            if (shape!=NULL) {
                QSharedPointer<RShape> pShape(shape->clone());
                cppValue.append(pShape);
            }

            else if (v.canConvert<RArc>()) {
                RArc obj = v.value<RArc>();
                QSharedPointer<RArc> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RCircle>()) {
                RCircle obj = v.value<RCircle>();
                QSharedPointer<RCircle> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RLine>()) {
                RLine obj = v.value<RLine>();
                QSharedPointer<RLine> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RPoint>()) {
                RPoint obj = v.value<RPoint>();
                QSharedPointer<RPoint> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RPolyline>()) {
                RPolyline obj = v.value<RPolyline>();
                QSharedPointer<RPolyline> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RSpline>()) {
                RSpline obj = v.value<RSpline>();
                QSharedPointer<RSpline> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RTextLabel>()) {
                RTextLabel obj = v.value<RTextLabel>();
                QSharedPointer<RTextLabel> p(obj.clone());
                cppValue.append(p);
            }

            else if (v.canConvert<RTriangle>()) {
                RTriangle obj = v.value<RTriangle>();
                QSharedPointer<RTriangle> p(obj.clone());
                cppValue.append(p);
            }
        }
    }
}