Exemplo 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;

}
Exemplo n.º 2
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;

}