Esempio n. 1
0
/* @TODO: remove stackPointer, nbRow, nbCol which are used */
int set_z_ticks_property(void* _pvCtx, char* pobjUID, void* _pvData, int valueType, int nbRow, int nbCol)
{
    BOOL autoTicks = FALSE;
    BOOL status = FALSE;
    AssignedList * tlist     = NULL;
    int            nbTicsRow = 0   ;
    int            nbTicsCol = 0   ;

    double* userGrads = NULL;
    char** userLabels = NULL;

    if (valueType != sci_tlist)
    {
        Scierror(999, _("Wrong type for '%s' property: Typed list expected.\n"), "z_ticks");
        return SET_PROPERTY_ERROR;
    }

    tlist = createTlistForTicks(_pvCtx);

    if (tlist == NULL)
    {
        return SET_PROPERTY_ERROR;
    }

    /* locations */
    userGrads = createCopyDoubleMatrixFromList(_pvCtx, tlist, &nbTicsRow, &nbTicsCol);

    if (userGrads == NULL && nbTicsRow == -1)
    {
        // if nbTicsRow = 0, it's just an empty matrix
        Scierror(999, _("%s: No more memory.\n"), "set_z_ticks_property");
        return SET_PROPERTY_ERROR;
    }

    /* Automatic ticks must be first deactivated in order to set user ticks */
    autoTicks = FALSE;

    setGraphicObjectProperty(pobjUID, __GO_Z_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1);

    status = setGraphicObjectProperty(pobjUID, __GO_Z_AXIS_TICKS_LOCATIONS__, userGrads, jni_double_vector, nbTicsRow * nbTicsCol);

    if (status == FALSE)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "z_ticks");
        FREE(userGrads);
        return SET_PROPERTY_ERROR;
    }

    /*  labels */
    // Here we check the size of "locations" instead of "labels", but they have the same size.
    // We need to check the size to not be 0 because an empty matrix is a matrix of double
    // and 'getCurrentStringMatrixFromList' expect a matrix of string (see bug 5148).
    // P.Lando
    if (nbTicsCol * nbTicsRow)
    {
        userLabels = getCurrentStringMatrixFromList(_pvCtx, tlist, &nbTicsRow, &nbTicsCol);
        /* Check if we should load LaTex / MathML Java libraries */
        loadTextRenderingAPI(userLabels, nbTicsCol, nbTicsRow);

        setGraphicObjectProperty(pobjUID, __GO_Z_AXIS_TICKS_LABELS__, userLabels, jni_string_vector, nbTicsRow * nbTicsCol);
    }
    else
    {
        /* To be implemented */
#if 0
        ppSubWin->axes.u_zlabels = NULL;
#endif
    }

    if (userGrads != NULL)
    {
        FREE(userGrads);
    }

    destroyAssignedList(tlist);

    return SET_PROPERTY_SUCCEED;

}
/*--------------------------------------------------------------------------*/
int set_data_property(char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol)
{
    char* type;

    getGraphicObjectProperty(pobjUID, __GO_TYPE__, jni_string, &type);

    if (strcmp(type, __GO_CHAMP__) == 0)
    {
        AssignedList* tlist = NULL;
        int status = -1;

        if( !isParameterTlist( valueType ) )
        {
            Scierror(999, "Incorrect argument, must be a Tlist!\n");
            return SET_PROPERTY_ERROR;
        }

        /* we should have 4 properties in the tlist */
        tlist = createAssignedList( 3, 4 );
        if ( tlist == NULL )
        {
            return SET_PROPERTY_ERROR;
        }

        status = setchampdata( pobjUID, tlist );
        destroyAssignedList( tlist );
        return status;
    }
    else if (strcmp(type, __GO_GRAYPLOT__) == 0)
    {
        AssignedList * tlist = NULL;
        int status = -1;

        if( !isParameterTlist( valueType ) )
        {
            Scierror(999, _("Wrong type for input argument: Tlist expected.\n"));
            return SET_PROPERTY_ERROR;
        }

        /* we should have 3 properties in the tlist */
        tlist = createAssignedList( 3, 3 );
        if ( tlist == NULL )
        {
            return SET_PROPERTY_ERROR;
        }

        status = setgrayplotdata( pobjUID, tlist );
        destroyAssignedList( tlist );
        return status;
    }
    else if ((strcmp(type, __GO_FAC3D__) == 0) || (strcmp(type, __GO_PLOT3D__) == 0))
    {
        AssignedList * tlist = NULL;
        int status = -1;
        int listSize = 0;

        if( !isParameterTlist( valueType ) )
        {
            Scierror(999, _("Wrong type for input argument: Tlist expected.\n"));
            return SET_PROPERTY_ERROR ;
        }

        listSize = getStackListNbElement( 3 );

        if ( listSize == 3 )
        {
            tlist = createAssignedList( 3, 3 );
        }
        else if ( listSize == 4 )
        {
            tlist = createAssignedList( 3, 4 );
        }
        else
        {
            Scierror(999, _("Wrong size for input argument: %d or %d expected.\n"),4,5);
            return SET_PROPERTY_ERROR;
        }

        if ( tlist == NULL )
        {
            return SET_PROPERTY_ERROR;
        }

        status = set3ddata( pobjUID, tlist );
        destroyAssignedList( tlist );
        return status;

    }
    else  /* F.Leray 02.05.05 : "data" case for others (using sciGetPoint routine inside GetProperty.c) */
    {
        if ( !isParameterDoubleMatrix( valueType ) )
        {
            Scierror(999, _("Incompatible type for property %s.\n"),"data");
            return SET_PROPERTY_ERROR;
        }

        return sciSetPoint( pobjUID, getDoubleMatrixFromStack( stackPointer ), &nbRow, &nbCol );
    }
    return SET_PROPERTY_ERROR;

}