From: Pierre LANDO Date: Fri, 30 Mar 2012 14:42:49 +0000 (+0200) Subject: Plug back 'unzoom' function and 'unzoom' buttons. X-Git-Tag: 5.4.0-beta-1~691^2~34 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=efec9c8531a6582b425cf901e729cef96558a799;hp=bf6226a04d59f4bec7147c79de12a058b298201b Plug back 'unzoom' function and 'unzoom' buttons. Change-Id: I884e194a10d53c22c78fc7205bf074e256683a94 --- diff --git a/scilab/modules/graphics/includes/axesScale.h b/scilab/modules/graphics/includes/axesScale.h index 492f309..08fb21e 100644 --- a/scilab/modules/graphics/includes/axesScale.h +++ b/scilab/modules/graphics/includes/axesScale.h @@ -30,10 +30,9 @@ GRAPHICS_IMPEXP int sciFigureZoom2D(sciPointObj * figure, const double zoomRect[ GRAPHICS_IMPEXP void sciGetZoom3D(sciPointObj * pObj, double zoomBox[6]); GRAPHICS_IMPEXP void sciDefaultInteractiveZoom(void); GRAPHICS_IMPEXP void sciInteractiveZoom(sciPointObj * pObj); -GRAPHICS_IMPEXP void sciUnzoomSubwin(char * subwinUID); -GRAPHICS_IMPEXP void sciUnzoomFigure(sciPointObj * figure); -GRAPHICS_IMPEXP void sciUnzoomAll(void); -GRAPHICS_IMPEXP void sciUnzoomArray(sciPointObj * zoomedObjects[], int nbSubwin); +GRAPHICS_IMPEXP void sciUnzoomSubwin(char* subwinUID); +GRAPHICS_IMPEXP void sciUnzoomFigure(char* figureUID); +GRAPHICS_IMPEXP void sciUnzoomArray(char* objectsUID[], int nbSubwin); /** * Update subwin size and scale if needed diff --git a/scilab/modules/graphics/sci_gateway/c/sci_unzoom.c b/scilab/modules/graphics/sci_gateway/c/sci_unzoom.c index 9802723..12ed7c4 100644 --- a/scilab/modules/graphics/sci_gateway/c/sci_unzoom.c +++ b/scilab/modules/graphics/sci_gateway/c/sci_unzoom.c @@ -3,11 +3,11 @@ * Copyright (C) 2006 - ENPC - Jean-Philipe Chancelier * Copyright (C) 2006 - INRIA - Fabrice Leray * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy - * + * * This file must be used under the terms of the CeCILL. * This source file is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at + * are also available at * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt * */ @@ -27,26 +27,43 @@ #include "getPropertyAssignedValue.h" #include "HandleManagement.h" +#include "CurrentFigure.h" +#include "graphicObjectProperties.h" +#include "getGraphicObjectProperty.h" + /*--------------------------------------------------------------------------*/ int sci_unzoom(char *fname,unsigned long fname_len) { + /* number of object to unzoom */ + int nbObjects = 0; + + /* ids of object to unzoom */ + char** objectsId = NULL; + + char* objectUID; + + /* object type */ + char *pstType; + CheckRhs(0,1) ; CheckLhs(0,1) ; if ( Rhs == 0 ) { - sciUnzoomAll(); + objectUID = getCurrentFigure(); + if (objectUID != NULL) + { + sciUnzoomFigure(objectUID); + } } else { - int nbUnzoomedObjects = 0; int m,n,i; size_t stackPointer = 0; - sciPointObj ** zoomedObjects = NULL; /* array of object to unzoom */ - GetRhsVar(1,GRAPHICAL_HANDLE_DATATYPE,&m,&n,&stackPointer); - - nbUnzoomedObjects = m * n; - zoomedObjects = MALLOC(nbUnzoomedObjects * sizeof(sciPointObj *)); - if (zoomedObjects == NULL) + GetRhsVar(1, GRAPHICAL_HANDLE_DATATYPE, &m, &n, &stackPointer); + + nbObjects = m * n; + objectsId = MALLOC(nbObjects * sizeof(char*)); + if (objectsId == NULL) { Scierror(999, _("%s: No more memory.\n"),fname); return -1; @@ -54,26 +71,27 @@ int sci_unzoom(char *fname,unsigned long fname_len) /* first pass, check that all the handles are subwindows or figures */ /* and copy them into an array of objects */ - for ( i = 0 ; i < nbUnzoomedObjects ; i++ ) + for (i = 0; i < nbObjects; i++ ) { - zoomedObjects[i] = sciGetPointerFromHandle(getHandleFromStack(stackPointer + i)); - if (sciGetEntityType(zoomedObjects[i]) != SCI_SUBWIN && sciGetEntityType(zoomedObjects[i]) != SCI_FIGURE) + objectUID = getObjectFromHandle(getHandleFromStack(stackPointer + i)); + getGraphicObjectProperty(objectUID, __GO_TYPE__, jni_string, (void **) &pstType); + if ((strcmp(pstType, __GO_FIGURE__) != 0) && (strcmp(pstType, __GO_AXES__) != 0)) { - FREE(zoomedObjects); + FREE(objectsId); Scierror(999, _("%s: Wrong type for input argument: Vector of Axes and Figure handles expected.\n"),fname); return -1; } + objectsId[i] = objectUID; } - /* second pass draw the objects */ - sciUnzoomArray(zoomedObjects, nbUnzoomedObjects); - - FREE(zoomedObjects); + /* second pass un zoom the objects */ + sciUnzoomArray(objectsId, nbObjects); + FREE(objectsId); } - - LhsVar(1)=0; + + LhsVar(1)=0; PutLhsVar(); return 0; } diff --git a/scilab/modules/graphics/src/c/axesScale.c b/scilab/modules/graphics/src/c/axesScale.c index 6a27346..57d833e 100644 --- a/scilab/modules/graphics/src/c/axesScale.c +++ b/scilab/modules/graphics/src/c/axesScale.c @@ -314,34 +314,19 @@ BOOL checkDataBounds(char * subwinUID, double xMin, double xMax, /** * Unzoom a single subwindow */ -void sciUnzoomSubwin(char * subwinUID) +void sciUnzoomSubwin(char* subwinUID) { - // We directly do a call to unzoomSubwin instead off path through the java code - // See bug 4979 - // javaUnzoomSubwin(pSubwin); - char* parentFigure = NULL; int zoomEnabled = 0; - getGraphicObjectProperty(subwinUID, __GO_PARENT_FIGURE__, jni_string, &parentFigure); + getGraphicObjectProperty(subwinUID, __GO_PARENT_FIGURE__, jni_string, (void **) &parentFigure); if( subwinUID == NULL || parentFigure == NULL ) { return; } - setGraphicObjectProperty(subwinUID, __GO_ZOOM_ENABLED__, &zoomEnabled, jni_bool, 1); - - /* - * Deactivated since it performs drawing operations. - * To be implemented. - */ -#if 0 - startFigureDataWriting(parentFigure); - unzoomSubwin(pSubwin); - endFigureDataWriting(parentFigure); -#endif - + setGraphicObjectProperty(subwinUID, __GO_ZOOM_ENABLED__, (void **) &zoomEnabled, jni_bool, 1); } /*------------------------------------------------------------------------------*/ void unzoomSubwin(sciPointObj * pSubwin) @@ -358,78 +343,56 @@ void unzoomSubwin(sciPointObj * pSubwin) /** * Unzoom all the subwindows contained in a figure */ -void sciUnzoomFigure(sciPointObj * figure) +void sciUnzoomFigure(char* figureUID) { - /* Copy subwins into the array */ - sciSons * pSons = sciGetSons(figure); - while (pSons != NULL) + char* pstType; + char** pstChildrenUID; + + int i; + int zoomEnabled = 0; + int childrenCount; + int* piChildrenCount = &childrenCount; + + getGraphicObjectProperty(figureUID, __GO_CHILDREN__, jni_string_vector, (void **) &pstChildrenUID); + getGraphicObjectProperty(figureUID, __GO_CHILDREN_COUNT__, jni_int, (void **) &piChildrenCount); + + if (piChildrenCount != NULL) { - sciPointObj * curObj = pSons->pointobj; - if (sciGetEntityType(curObj) == SCI_SUBWIN) + + for (i = 0; i < childrenCount; i++) { - sciUnzoomSubwin(curObj); - } - pSons = pSons->pnext; + getGraphicObjectProperty(pstChildrenUID[i], __GO_TYPE__, jni_string, (void **) &pstType); + if (strcmp(pstType, __GO_AXES__) == 0) + setGraphicObjectProperty(pstChildrenUID[i], __GO_ZOOM_ENABLED__, (void **) &zoomEnabled, jni_bool, 1); + } } } /*------------------------------------------------------------------------------*/ /** - * Un zoom all the subwindow of a figure - */ -void sciUnzoomAll(void) -{ - sciPointObj * pFigure = NULL; - - //startGraphicDataWriting(); - pFigure = sciGetCurrentFigure(); - //endGraphicDataWriting(); - - /* unzoom current figure */ - sciUnzoomFigure(pFigure); - - //sciDrawObj(pFigure); -} -/*------------------------------------------------------------------------------*/ -/** * Unzoom a set of subwindows and figures - * @param zoomedObjects array of figure and subwindow objects + * @param objectsUID array of figure and subwindow objects id. + * @param nbObjects number of objects. */ -void sciUnzoomArray(sciPointObj * zoomedObjects[], int nbObjects) +void sciUnzoomArray(char* objectsUID[], int nbObjects) { + /* object type */ + char* pstType; int i; - /* list of parent figure to redraw */ - DoublyLinkedList * redrawnFigures = DoublyLinkedList_new(); for (i = 0; i < nbObjects; i++) { - sciPointObj * parentFigure = sciGetParentFigure(zoomedObjects[i]); - - if (sciGetEntityType(zoomedObjects[i]) == SCI_FIGURE) + getGraphicObjectProperty(objectsUID[i], __GO_TYPE__, jni_string, (void **) &pstType); + if (strcmp(pstType, __GO_FIGURE__) == 0) { /* Unzoom all subwindows of the figure */ - sciUnzoomFigure(zoomedObjects[i]); + sciUnzoomFigure(objectsUID[i]); } - else if (sciGetEntityType(zoomedObjects[i]) == SCI_SUBWIN) + else if (strcmp(pstType, __GO_AXES__) == 0) { - /* Unzoom only figure */ - sciUnzoomSubwin(zoomedObjects[i]); + /* Unzoom the axes */ + sciUnzoomSubwin(objectsUID[i]); } - if (List_find(redrawnFigures, parentFigure) == NULL) - { - /* figure not already added for redraw */ - redrawnFigures = List_push(redrawnFigures, parentFigure); - } } - - /* redraw only needed figures */ - while (!List_is_empty(redrawnFigures)) - { - sciPointObj * curFigure = NULL; - redrawnFigures = List_pop(redrawnFigures, (void**)&curFigure); - //sciDrawObj(curFigure); - } - - List_free(redrawnFigures); } /*--------------------------------------------------------------------------------*/ void updateSubwinScale(char * pSubwinUID)