/*------------------------------------------------------------------------*/
int get_grid_style_property(void* _pvCtx, int iObjUID)
{
    double grid[3];
    int iGridStyle = 0;
    int* piGridStyle = &iGridStyle;
    int iView = 0;
    int* piView = &iView;

    /* need conversion for display in double */
    getGraphicObjectProperty(iObjUID, __GO_X_AXIS_GRID_STYLE__, jni_int, (void **)&piGridStyle);

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

    grid[0] = (double) iGridStyle;

    getGraphicObjectProperty(iObjUID, __GO_Y_AXIS_GRID_STYLE__, jni_int, (void **)&piGridStyle);
    if (piGridStyle == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "grid_style");
        return -1;
    }

    grid[1] = (double) iGridStyle;

    getGraphicObjectProperty(iObjUID, __GO_Z_AXIS_GRID_STYLE__, jni_int, (void **)&piGridStyle);
    if (piGridStyle == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "grid_style");
        return -1;
    }

    grid[2] = (double) iGridStyle;

    getGraphicObjectProperty(iObjUID, __GO_VIEW__, jni_int, (void **)&piView);

    if (iView)
    {
        return sciReturnRowVector(_pvCtx, grid, 3);
    }
    else
    {
        return sciReturnRowVector(_pvCtx, grid, 2);
    }

}
/*------------------------------------------------------------------------*/
int get_grid_thickness_property(void* _pvCtx, int iObjUID)
{
    double grid[3];
    double dGridThickness = 0;
    double * pdGridThickness = &dGridThickness;
    int iView = 0;
    int* piView = &iView;

    /* need conversion for display in double */
    getGraphicObjectProperty(iObjUID, __GO_X_AXIS_GRID_THICKNESS__, jni_double, (void **)&pdGridThickness);

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

    grid[0] = dGridThickness;

    getGraphicObjectProperty(iObjUID, __GO_Y_AXIS_GRID_THICKNESS__, jni_double, (void **)&pdGridThickness);
    if (pdGridThickness == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "grid");
        return -1;
    }

    grid[1] = dGridThickness;

    getGraphicObjectProperty(iObjUID, __GO_Z_AXIS_GRID_THICKNESS__, jni_double, (void **)&pdGridThickness);
    if (pdGridThickness == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "grid");
        return -1;
    }

    grid[2] = dGridThickness;

    getGraphicObjectProperty(iObjUID, __GO_VIEW__, jni_int, (void **)&piView);

    if (iView)
    {
        return sciReturnRowVector(_pvCtx, grid, 3);
    }
    else
    {
        return sciReturnRowVector(_pvCtx, grid, 2);
    }
}
Exemple #3
0
/*------------------------------------------------------------------------*/
int get_y_shift_property(void* _pvCtx, char* pobjUID)
{
    double* shiftCoordinates = NULL;
    int iValue = 0;
    int* piValue = &iValue;

    getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__, jni_int, (void**)&piValue);

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

    if (iValue == 0)
    {
        return sciReturnEmptyMatrix(_pvCtx);
    }
    else
    {
        getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_Y_COORDINATES_SHIFT__, jni_double_vector, (void **)&shiftCoordinates);
        getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_NUM_ELEMENTS__, jni_int, (void**)&piValue);

        return sciReturnRowVector(_pvCtx, shiftCoordinates, iValue);
    }
}
/*------------------------------------------------------------------------*/
int get_zoom_box_property(void* _pvCtx, char* pobjUID)
{
    double dblTmp = 0;
    double* zoomBox = NULL;
    int iZoomEnabled = 0;
    int* zoomEnabled = &iZoomEnabled;

    getGraphicObjectProperty(pobjUID, __GO_ZOOM_ENABLED__, jni_bool, (void **)&zoomEnabled);

    getGraphicObjectProperty(pobjUID, __GO_ZOOM_BOX__, jni_double_vector, (void **)&zoomBox);

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

    if (iZoomEnabled)
    {
        // Swap zoomBox values to feat Scilab View ordering.
        // MVC stores [xmin, xmax, ymin, ymax, zmin, zmax]
        // Scilab expects [xmin, ymin, xmax, ymax, zmin, zmax]
        dblTmp = zoomBox[2];
        zoomBox[2] = zoomBox[1];
        zoomBox[1] = dblTmp;
        return sciReturnRowVector(_pvCtx, zoomBox, 6);
    }
    else
    {
        return sciReturnEmptyMatrix(_pvCtx);
    }
}
/*------------------------------------------------------------------------*/
int get_grid_property(char *pobjUID)
{
    double grid[3];
    int iGridColor = 0;
    int* piGridColor = &iGridColor;
    int iView = 0;
    int* piView = &iView;

#if 0
    if (sciGetEntityType (pobj) != SCI_SUBWIN)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"),"grid");
        return -1;
    }
#endif

    /* need conversion for display in double */
    getGraphicObjectProperty(pobjUID, __GO_X_AXIS_GRID_COLOR__, jni_int, &piGridColor);

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

    grid[0] = (double) iGridColor;

    getGraphicObjectProperty(pobjUID, __GO_Y_AXIS_GRID_COLOR__, jni_int, &piGridColor);
    grid[1] = (double) iGridColor;

    getGraphicObjectProperty(pobjUID, __GO_Z_AXIS_GRID_COLOR__, jni_int, &piGridColor);
    grid[2] = (double) iGridColor;

    getGraphicObjectProperty(pobjUID, __GO_VIEW__, jni_int, &piView);

    if (iView)
    {
        return sciReturnRowVector( grid, 3 );
    }
    else
    {
        return sciReturnRowVector( grid, 2 );
    }

}
/*------------------------------------------------------------------------*/
void* get_rotation_angles_property(void* _pvCtx, int iObjUID)
{
    double* angles = NULL;

    getGraphicObjectProperty(iObjUID, __GO_ROTATION_ANGLES__, jni_double_vector, (void **)&angles);

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

    return sciReturnRowVector(angles, 2);
}
/*------------------------------------------------------------------------*/
int get_z_bounds_property(void* _pvCtx, int iObjUID)
{
    double* zBounds = NULL;

    getGraphicObjectProperty(iObjUID, __GO_Z_BOUNDS__, jni_double_vector, (void **)&zBounds);

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

    return sciReturnRowVector(_pvCtx, zBounds, 2);
}
/*------------------------------------------------------------------------*/
void* get_margins_property(void* _pvCtx, int iObjUID)
{
    double* margins = NULL;

    getGraphicObjectProperty(iObjUID, __GO_MARGINS__, jni_double_vector, (void **)&margins);

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

    return sciReturnRowVector(margins, 4);

}
/*------------------------------------------------------------------------*/
void* get_figure_size_property(void* _pvCtx, int iObjUID)
{
    double figureSize[2];
    int* intSize = NULL;
    getGraphicObjectProperty(iObjUID, __GO_SIZE__, jni_int_vector, (void **)&intSize);

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

    figureSize[0] = (double)intSize[0];
    figureSize[1] = (double)intSize[1];

    return sciReturnRowVector(figureSize, 2);
}
/*------------------------------------------------------------------------*/
int get_figure_position_property(char *pobjUID)
{
  double figurePos[2] ;
  int* position;
  getGraphicObjectProperty(pobjUID, __GO_POSITION__, jni_int_vector, &position);

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

  figurePos[0] = (double) position[0] ;
  figurePos[1] = (double) position[1] ;

  return sciReturnRowVector( figurePos, 2 ) ;

}
int GetUicontrolBackgroundColor(void* _pvCtx, char *sciObjUID)
{
    double *tmp = NULL;
    int status = 0;

    getGraphicObjectProperty(sciObjUID, __GO_UI_BACKGROUNDCOLOR__, jni_double_vector, (void **) &tmp);

    if (tmp == NULL)
    {
        Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "BackgroundColor");
        return FALSE;
    }
    else
    {
        status = sciReturnRowVector(_pvCtx, tmp, 3);
        delete[] tmp;
        return status;
    }
}
int GetUicontrolPosition(void* _pvCtx, char *sciObjUID)
{
    double* position = NULL;
    int status = FALSE;

    getGraphicObjectProperty(sciObjUID, __GO_POSITION__, jni_double_vector, (void**) &position);

    if (position == NULL)
    {
        Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Position");
        return FALSE;
    }
    else
    {
        status = sciReturnRowVector(_pvCtx, position, 4);
        delete[] position;
        return status;
    }
}
void* GetUicontrolSliderStep(void* _pvCtx, int iObjUID)
{
    double *sliderStep = NULL;
    void* status = NULL;

    getGraphicObjectProperty(iObjUID, __GO_UI_SLIDERSTEP__, jni_double_vector, (void**) &sliderStep);

    if (sliderStep != NULL)
    {
        status = sciReturnRowVector(sliderStep, 2);
        delete[] sliderStep;
        return status;
    }
    else
    {
        Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "SliderStep");
        return NULL;
    }
}
int GetUiobjectForegroundColor(char* sciObjUID)
{
    double *tmp;
    int status = 0;

    getGraphicObjectProperty(sciObjUID,  const_cast<char*>(__GO_UI_FOREGROUNDCOLOR__), jni_double_vector, (void **) &tmp);

    if (tmp == NULL)
    {
        Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "ForegroundColor");
        return FALSE;
    }
    else
    {
        status = sciReturnRowVector(tmp, 3);
        delete[] tmp;
        return status;
    }
}
int GetUicontrolValue(void* _pvCtx, char *sciObjUID)
{
    int valueSize = 0;
    int* piValueSize = &valueSize;
    double* pdblValue = NULL;
    int status = 0;

    getGraphicObjectProperty(sciObjUID, __GO_UI_VALUE_SIZE__, jni_int, (void**) &piValueSize);

    if (piValueSize == NULL)
    {
        Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Value");
        return FALSE;
    }
    else
    {
        if (valueSize == 0)
        {
            return sciReturnEmptyMatrix(_pvCtx);
        }
        else
        {
            getGraphicObjectProperty(sciObjUID, __GO_UI_VALUE__, jni_double_vector, (void**) &pdblValue);

            if (pdblValue == NULL)
            {
                Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Value");
                return FALSE;
            }
            else
            {
                status = sciReturnRowVector(_pvCtx, pdblValue, valueSize);
                delete[] pdblValue;
                return status;
            }
        }
    }
    return status;
}
/*------------------------------------------------------------------------*/
int get_clip_box_property(void* _pvCtx, char* pobjUID)
{
    int iClipState = 0;
    int* piClipState = &iClipState;
    double* clipBox = NULL;

    getGraphicObjectProperty(pobjUID, __GO_CLIP_STATE__, jni_int, (void **)&piClipState);

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

    if (iClipState > 1)
    {
        /* clip state on */

        getGraphicObjectProperty(pobjUID, __GO_CLIP_BOX__, jni_double_vector, (void **)&clipBox);

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

        return sciReturnRowVector(_pvCtx, clipBox, 4);
    }
    else if (iClipState == 0 || iClipState == 1)
    {
        /* clip state off or clipgrf */
        return sciReturnEmptyMatrix(_pvCtx);
    }
    else
    {
        Scierror(999, _("Wrong value for '%s' property.\n"), "clip_state");
        return -1;
    }
}
/*------------------------------------------------------------------------*/
void* get_ytics_coord_property(void* _pvCtx, int iObjUID)
{
    int iYNumberTicks = 0;
    int* piYNumberTicks = &iYNumberTicks;
    double* yTicksCoords = NULL;

    getGraphicObjectProperty(iObjUID, __GO_Y_TICKS_COORDS__, jni_double_vector, (void **)&yTicksCoords);

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

    getGraphicObjectProperty(iObjUID, __GO_Y_NUMBER_TICKS__, jni_int, (void**)&piYNumberTicks);
    if (piYNumberTicks == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "ytics_coord");
        return NULL;
    }

    return sciReturnRowVector(yTicksCoords, iYNumberTicks);
}
Exemple #18
0
void* get_tip_detached_property(void* _pvCtx, int iObjUID)
{
    int isDetached = 0;
    int *piDetached = &isDetached;
    getGraphicObjectProperty(iObjUID, __GO_DATATIP_DETACHED_MODE__, jni_bool, (void **)&piDetached);

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

    if (!isDetached)
    {
        return sciReturnEmptyMatrix();
    }
    else
    {
        double *detached_pos = NULL;
        getGraphicObjectProperty(iObjUID, __GO_DATATIP_DETACHED_POSITION__, jni_double_vector, (void **)&detached_pos);
        return sciReturnRowVector(detached_pos, 3);
    }
}
/*------------------------------------------------------------------------*/
void* get_sub_tics_property(void* _pvCtx, int iObjUID)
{
    int iType = -1;
    int *piType = &iType;
    int iSubTicks = 0;
    int* piSubTicks = &iSubTicks;

    /*Dj.A 17/12/2003*/
    /* modified jb Silvy 01/2006 */

    getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piType);
    if (piType == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "type");
        return NULL;
    }

    /*
     * Type test required as the Axis object stores subticks as a single int
     * whereas Axes maintain a 3-element int vector.
     */
    if (iType == __GO_AXIS__)
    {
        getGraphicObjectProperty(iObjUID, __GO_SUBTICKS__, jni_int, (void**)&piSubTicks);

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

        return sciReturnDouble(iSubTicks);
    }
    else if (iType == __GO_AXES__)
    {
        double sub_ticks[3];
        int iView = 0;
        int* piView = &iView;

        getGraphicObjectProperty(iObjUID, __GO_X_AXIS_SUBTICKS__, jni_int, (void**)&piSubTicks);
        if (piSubTicks == NULL)
        {
            Scierror(999, _("'%s' property does not exist for this handle.\n"), "sub_ticks");
            return NULL;
        }

        sub_ticks[0] = iSubTicks;

        getGraphicObjectProperty(iObjUID, __GO_Y_AXIS_SUBTICKS__, jni_int, (void**)&piSubTicks);
        if (piSubTicks == NULL)
        {
            Scierror(999, _("'%s' property does not exist for this handle.\n"), "sub_ticks");
            return NULL;
        }

        sub_ticks[1] = iSubTicks;

        getGraphicObjectProperty(iObjUID, __GO_Z_AXIS_SUBTICKS__, jni_int, (void**)&piSubTicks);
        if (piSubTicks == NULL)
        {
            Scierror(999, _("'%s' property does not exist for this handle.\n"), "sub_ticks");
            return NULL;
        }

        sub_ticks[2] = iSubTicks;

        getGraphicObjectProperty(iObjUID, __GO_VIEW__, jni_int, (void**)&piView);
        if (piView == NULL)
        {
            Scierror(999, _("'%s' property does not exist for this handle.\n"), "view");
            return NULL;
        }

        if (iView == 1)
        {
            return sciReturnRowVector(sub_ticks, 3);
        }
        else
        {
            return sciReturnRowVector(sub_ticks, 2);
        }
    }
    else
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "sub_ticks");
        return NULL;
    }
}
/*------------------------------------------------------------------------*/
void* get_position_property(void* _pvCtx, int iObjUID)
{
    int iType = -1;
    int* piType = &iType;
    double* position = NULL;
    void* ret = NULL;

    getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **) &piType);
    if (piType == NULL)
    {
        Scierror(999, _("'%s' property does not exist for this handle.\n"), "type");
        return NULL;
    }

    /* Special figure case */
    if (iType == __GO_FIGURE__)
    {
        int* figurePosition;
        int* figureSize;
        double position[4];

        getGraphicObjectProperty(iObjUID, __GO_POSITION__, jni_int_vector, (void **) &figurePosition);

        getGraphicObjectProperty(iObjUID, __GO_AXES_SIZE__, jni_int_vector, (void **) &figureSize);

        if (figurePosition == NULL || figureSize == NULL)
        {
            Scierror(999, _("'%s' property does not exist for this handle.\n"), "position");
            return NULL;
        }

        position[0] = (double) figurePosition[0];
        position[1] = (double) figurePosition[1];
        position[2] = (double) figureSize[0];
        position[3] = (double) figureSize[1];

        ret = sciReturnRowVector(position, 4);
        releaseGraphicObjectProperty(__GO_POSITION__, figurePosition, jni_int_vector, 2);
        releaseGraphicObjectProperty(__GO_AXES_SIZE__, figureSize, jni_int_vector, 2);
        return ret;
    }

    /* Special label and legend case : only 2 values for position */
    if (iType == __GO_LABEL__ || iType == __GO_LEGEND__)
    {
        double* position;

        getGraphicObjectProperty(iObjUID, __GO_POSITION__, jni_double_vector, (void **) &position);

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

        ret = sciReturnRowVector(position, 2);
        releaseGraphicObjectProperty(__GO_POSITION__, position, jni_double_vector, 2);
        return ret;
    }

    if (iType == __GO_LIGHT__)
    {
        double* position = NULL;

        getGraphicObjectProperty(iObjUID, __GO_POSITION__, jni_double_vector, (void **)&position);

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

        ret = sciReturnRowVector(position, 3);
        releaseGraphicObjectProperty(__GO_POSITION__, position, jni_double_vector, 3);
        return ret;
    }

    /* Generic case : position is a 4 row vector */

    getGraphicObjectProperty(iObjUID, __GO_POSITION__, jni_double_vector, (void **) &position);

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

    ret = sciReturnRowVector(position, 4);
    releaseGraphicObjectProperty(__GO_POSITION__, position, jni_double_vector, 4);
    return ret;
}