Ejemplo n.º 1
0
AssignedList * createTlistForTicks(void* _pvCtx)
{
    AssignedList* tlist = NULL;
    int nbRowLoc  = 0;
    int nbColLoc  = 0;
    int nbRowLab  = 0;
    int nbColLab  = 0;

    tlist = createAssignedList(_pvCtx, 3, 2);

    if (tlist == NULL)
    {
        Scierror(999, _("Tlist could not be created, check ticks location and label vectors.\n"));
        return NULL;
    }

    if (!isListCurrentElementDoubleMatrix(_pvCtx, tlist))
    {
        Scierror(999, _("%s should be a vector of double.\n"), "locations");
        return NULL;
    }

    getCurrentDoubleMatrixFromList(_pvCtx, tlist, &nbRowLoc, &nbColLoc);

    if (nbRowLoc * nbColLoc == 0)
    {
        /* labels should also be an empty matrix */
        if (!isListCurrentElementEmptyMatrix(_pvCtx, tlist))
        {
            Scierror(999, _("Ticks location and label vectors must have the same size.\n"));
            return NULL;
        }
    }
    else
    {
        if (!isListCurrentElementStringMatrix(_pvCtx, tlist))
        {
            Scierror(999, _("%s should be a string vector.\n"), "labels");
            return NULL;
        }

        getCurrentStringMatrixFromList(_pvCtx, tlist, &nbRowLab, &nbColLab);

        if (nbRowLoc != nbRowLab || nbColLoc != nbColLab)
        {
            Scierror(999, _("Ticks location and label vectors must have the same size.\n"));
            return NULL;
        }
    }

    rewindAssignedList(tlist);

    return tlist;

}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------------*/
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;

}