예제 #1
0
/*------------------------------------------------------------------------*/
int get_title_property(void* _pvCtx, int iObjUID)
{
    int iLabelUID = 0;
    int* piLabelUID = &iLabelUID;
    long labelHandle = 0;

    int iType = -1;
    int *piType = &iType;

    getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piType);
    if (piType == NULL)
    {
        Scierror(999, _("Wrong value for '%s' property.\n"), "type");
        return -1;
    }

    if (iType != __GO_AXES__)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "title");
        return -1;
    }

    getGraphicObjectProperty(iObjUID, __GO_TITLE__, jni_int, (void **)&piLabelUID);

    if (iLabelUID == 0)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "title");
        return -1;
    }

    labelHandle = getHandle(iLabelUID);

    return sciReturnHandle(_pvCtx, labelHandle);
}
/*--------------------------------------------------------------------------*/
void* get_default_figure_property(void* _pvCtx, int iObjUID)
{
    if (iObjUID != 0)
    {
        /* This property should not be called on an handle */
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "default_figure");
        return NULL;
    }
    return sciReturnHandle(getHandle(getFigureModel()));
}
예제 #3
0
/*--------------------------------------------------------------------------*/
int get_default_axes_property(void* _pvCtx, char* pobjUID)
{

    if (pobjUID != NULL)
    {
        /* This property should not be called on an handle */
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "default_axes");
        return -1;
    }

    return sciReturnHandle(_pvCtx, getHandle(getAxesModel()));
}
예제 #4
0
/*------------------------------------------------------------------------*/
int get_x_label_property(void* _pvCtx, char* pobjUID)
{
    char* labelUID = NULL;

    getGraphicObjectProperty(pobjUID, __GO_X_AXIS_LABEL__, jni_string, (void **)&labelUID);

    if (labelUID == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "x_label");
        return -1;
    }

    return sciReturnHandle(_pvCtx, getHandle(labelUID));
}
예제 #5
0
/*------------------------------------------------------------------------*/
int get_z_label_property(void* _pvCtx, int iObjUID)
{
    int iLabelUID = 0;
    int* piLabelUID = &iLabelUID;

    getGraphicObjectProperty(iObjUID, __GO_Z_AXIS_LABEL__, jni_int, (void **) &piLabelUID);

    if (iLabelUID == 0)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "z_label");
        return -1;
    }

    return sciReturnHandle(_pvCtx, getHandle(iLabelUID));
}
/*--------------------------------------------------------------------------*/
void* get_current_figure_property(void* _pvCtx, int iObjUID)
{
    int iCurrentFigureId = 0;

    if (iObjUID != 0)
    {
        /* This property should not be called on an handle */
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "current_figure");
        return NULL;
    }

    iCurrentFigureId = getCurrentFigure();

    if (iCurrentFigureId == 0)
    {
        /* return handle on the current figure if none : create it */
        iCurrentFigureId = createNewFigureWithAxes();
        setCurrentFigure(iCurrentFigureId);
    }

    return sciReturnHandle(getHandle(iCurrentFigureId));
}
예제 #7
0
/*--------------------------------------------------------------------------*/
int sci_get(char *fname, void *pvApiCtx)
{
    SciErr sciErr;

    int* piAddrl1 = NULL;
    long long* l1 = NULL;
    int* piAddrl2 = NULL;
    char* l2 = NULL;

    int m1 = 0, n1 = 0;
    long hdl = 0;

    int lw = 0;
    int iObjUID = 0;

    int status = SET_PROPERTY_ERROR;

    CheckInputArgument(pvApiCtx, 1, 2);
    CheckOutputArgument(pvApiCtx, 0, 1);

    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 1;
    }

    if (isMListType(pvApiCtx, piAddrl1) || isTListType(pvApiCtx, piAddrl1))
    {
        OverLoad(1);
        return 0;
    }

    /*
     * The first input argument can be an ID or a marker (in this case, get returns the value of the current object */
    switch (getInputArgumentType(pvApiCtx, 1))
    {
    case sci_matrix: //console handle
    {
        double dbll1 = 0;

        if (isScalar(pvApiCtx, piAddrl1) == 0)
        {
            Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
            return 1;
        }

        // Retrieve a matrix of double at position 1.
        if (getScalarDouble(pvApiCtx, piAddrl1, &dbll1))
        {
            Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
            return 1;
        }

        if ((int)dbll1 == 0) /* Console property */
        {
            int* piAddrstkAdr = NULL;
            char *stkAdr = NULL;
            if (nbInputArgument(pvApiCtx) == 1)
            {
                if (sciReturnHandle(getHandle(getConsoleIdentifier())) != 0)    /* Get Console handle */
                {
                    ReturnArguments(pvApiCtx);
                    return 0;
                }
                AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
                ReturnArguments(pvApiCtx);
                return 0;
            }

            CheckInputArgument(pvApiCtx, 2, 2);
            sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrstkAdr);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                return 1;
            }

            // Retrieve a matrix of string at position 2.
            if (getAllocatedSingleString(pvApiCtx, piAddrstkAdr, &stkAdr))
            {
                Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
                return 1;
            }

            if (GetScreenProperty(pvApiCtx, stkAdr) != SET_PROPERTY_SUCCEED)
            {
                Scierror(999, _("%s: Could not read property '%s' for console object.\n"), "get", stkAdr[0]);
                freeAllocatedSingleString(stkAdr);
                return 1;
            }
            freeAllocatedSingleString(stkAdr);
            AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
            ReturnArguments(pvApiCtx);
        }

        return 0;
        break;
    }
    case sci_handles:          /* scalar argument (hdl + string) */
        CheckInputArgument(pvApiCtx, 1, 2);

        // Retrieve a matrix of handle at position 1.
        sciErr = getMatrixOfHandle(pvApiCtx, piAddrl1, &m1, &n1, &l1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1);
            return 1;
        }

        if (m1 != 1 || n1 != 1)
        {
            //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx);
            OverLoad(1);
            return 0;
        }

        if (nbInputArgument(pvApiCtx) == 1)
        {
            //get path from handle
            int uic = getObjectFromHandle((long) * l1);
            char* path = get_path(uic);
            if (path[0] == '\0')
            {
                Scierror(999, _("%s: Unable to get useful path from this handle.\n"), fname);
                return 1;
            }

            createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, path);
            FREE(path);

            AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
            ReturnArguments(pvApiCtx);
            return 0;
        }

        sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0)
        {
            Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
            return 1;
        }

        // Retrieve a matrix of double at position 2.
        if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2))
        {
            Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
            return 1;
        }

        hdl = (long) * l1; /* on recupere le pointeur d'objet par le handle */
        break;
    case sci_strings:          /* string argument (string) */
    {
        char* pstFirst = NULL;
        CheckInputArgument(pvApiCtx, 1, 2);

        if (isScalar(pvApiCtx, piAddrl1) == 0)
        {
            Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
            return 1;
        }

        // Retrieve a matrix of double at position 1.
        if (getAllocatedSingleString(pvApiCtx, piAddrl1, &pstFirst))
        {
            Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 1);
            return 1;
        }

        if (strcmp(pstFirst, "default_figure") == 0 ||
                strcmp(pstFirst, "default_axes") == 0 ||
                strcmp(pstFirst, "current_figure") == 0 ||
                strcmp(pstFirst, "current_axes") == 0 ||
                strcmp(pstFirst, "current_entity") == 0 ||
                strcmp(pstFirst, "hdl") == 0 ||
                strcmp(pstFirst, "figures_id") == 0)
        {
            hdl = 0;
            l2 = pstFirst;
        }
        else
        {
            int uid = search_path(pstFirst);
            if (uid != 0)
            {
                freeAllocatedSingleString(pstFirst);
                hdl = getHandle(uid);

                if (nbInputArgument(pvApiCtx) == 1)
                {
                    createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, hdl);
                    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
                    ReturnArguments(pvApiCtx);
                    return 0;
                }

                sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2);
                if (sciErr.iErr)
                {
                    printError(&sciErr, 0);
                    return 1;
                }

                if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0)
                {
                    Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
                    return 1;
                }

                if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2))
                {
                    Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
                    return 1;
                }
            }
            else
            {
                createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
                AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
                ReturnArguments(pvApiCtx);
                return 0;
            }
        }
        break;
    }
    default:
        //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx);
        OverLoad(1);
        return 0;
        break;
    }
    /* (l2) est la commande, l3 l'indice sur les parametres de la commande */
    CheckOutputArgument(pvApiCtx, 0, 1);

    if (hdl == 0)
    {
        /* No handle specified */
        if (callGetProperty(pvApiCtx, 0, (l2)) != 0)
        {
            /* An error has occurred */
            freeAllocatedSingleString(l2);
            ReturnArguments(pvApiCtx);
            return 0;
        }
    }
    else
    {
        iObjUID = getObjectFromHandle(hdl);
        if (iObjUID != 0)
        {

            if (callGetProperty(pvApiCtx, iObjUID, (l2)) != 0)
            {
                /* An error has occurred */
                freeAllocatedSingleString(l2);
                ReturnArguments(pvApiCtx);
                return 0;
            }
        }
        else
        {
            Scierror(999, _("%s: The handle is not or no more valid.\n"), fname);
            freeAllocatedSingleString(l2);
            return 0;
        }
    }

    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
    ReturnArguments(pvApiCtx);
    freeAllocatedSingleString(l2);
    return 0;
}