DestroyObjects.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *    Graphic library 
00003  *    Copyright INRIA
00004  *    newGraph Library header
00005  *    Matthieu PHILIPPE  , INRIA 2001-2002
00006  *    Djalel ABDEMOUCHE  , INRIA 2002-2004
00007  *    Fabrice Leray      , INRIA 2004-2006
00008  *    Jean-Baptiste Silvy, INRIA 2005-xxxx
00009  *    Comment:
00010  *    This file contains all functions used to BUILD new objects : 
00011  - break the binding between the deleted object and its parent in the 
00012  existing hierarchy
00013  - freeing memory
00014  --------------------------------------------------------------------------*/
00015 
00016 #include <stdio.h> 
00017 #include <string.h>
00018 #include <math.h>
00019 #include <stdlib.h>
00020 #include <stdarg.h>
00021 #include <time.h>
00022 
00023 #include "DestroyObjects.h"
00024 #include "GetProperty.h"
00025 #include "DrawObjects.h"
00026 #include "SetProperty.h"
00027 #include "Interaction.h" /* for callback funtions */
00028 #include "StringMatrix.h"
00029 #include "Xcall1.h"
00030 #include "WindowList.h"
00031 #include "PloEch.h"
00032 #include "sciprint.h"
00033 #include "CurrentObjectsManagement.h"
00034 #include "ObjectSelection.h"
00035 
00036 #ifdef WITH_TK
00037 #include "../../../tclsci/includes/GedManagement.h"
00038 #endif
00039 
00040 #include "MALLOC.h" /* MALLOC */
00041 
00042 
00043 /*----------------------------------------------------------------------------*/
00044 
00045 /********************* modifie le 01/02/2002 ************************
00046  * On detruit pas la sous fenetre, elle est initialiser avec la figure
00047  * pour cette version, on considere qu'il y'a 1 seule sous fenetre et 
00048  * elle suit la fenetre principale (voir xbasc() ), la fenetre n'est pas 
00049  * consideree comme un des fils.  
00050  **DestroyAllGraphicsSons
00051  * This function destroies childs and pthis
00052  * @param sciPointObj * pthis: the pointer to the entity
00053  */
00054 int
00055 DestroyAllGraphicsSons (sciPointObj * pthis)
00056 {
00057   /* to destroy only the sons put the while into the switch !*/
00058   sciSons *toto = NULL;
00059  
00060   toto = sciGetSons (pthis);
00061   while ((toto != (sciSons *) NULL) &&
00062          (toto->pointobj != (sciPointObj *) NULL))
00063     {
00064       DestroyAllGraphicsSons (toto->pointobj);
00065       toto = sciGetSons (pthis);
00066     }
00067   switch (sciGetEntityType (pthis))
00068     {
00069 
00070     case SCI_FIGURE:
00071       return 0;
00072       break;
00073     case SCI_SUBWIN:
00074       DestroySubWin (pthis);
00075       return 0;
00076       break;
00077     case SCI_TEXT:
00078       DestroyText (pthis);
00079       return 0;
00080       break;
00081     case SCI_TITLE:
00082       DestroyTitle (pthis);
00083       return 0;
00084       break;
00085     case SCI_LEGEND:
00086       DestroyLegend (pthis);
00087       return 0;
00088       break;
00089     case SCI_ARC:
00090       DestroyArc (pthis);
00091       return 0; 
00092       break;
00093     case SCI_SEGS:
00094       DestroySegs (pthis);
00095       return 0;
00096       break;  
00097     case SCI_FEC:  
00098       DestroyFec (pthis);
00099       return 0;
00100       break; 
00101     case SCI_GRAYPLOT: 
00102       DestroyGrayplot (pthis);
00103       return 0;
00104       break; 
00105     case SCI_POLYLINE:
00106       DestroyPolyline (pthis);
00107       return 0;
00108       break;
00109     case SCI_RECTANGLE:
00110       DestroyRectangle (pthis);
00111       return 0;
00112       break;
00113     case SCI_SURFACE:
00114       DestroySurface (pthis);
00115       return 0;
00116       break;
00117     case SCI_LIGHT:
00118       break;
00119     case SCI_AXES:
00120       DestroyAxes (pthis);
00121       return 0;
00122       break;
00123     case SCI_PANNER:
00124       break;
00125     case SCI_SBH:
00126       DestroyScrollH (pthis);
00127       return 0;
00128       break;
00129     case SCI_SBV:
00130       DestroyScrollV (pthis);
00131       return 0;
00132       break;
00133     case SCI_MENU:
00134       DestroySciMenu (pthis);
00135       return 0;
00136       break;
00137     case SCI_MENUCONTEXT:
00138       DestroyMenuContext (pthis);
00139       return 0;
00140       break;
00141     case SCI_STATUSB:
00142       DestroyStatusBar (pthis);
00143       return 0;
00144       break;
00145     case SCI_AGREG:
00146       DestroyCompound (pthis);
00147       return 0;
00148       break; 
00149     case SCI_MERGE:
00150       DestroyMerge (pthis);
00151       return 0;
00152       break;
00153     case SCI_LABEL: /* F.Leray 28.05.04 */
00154       DestroyLabel (pthis);
00155       return 0;
00156       break;
00157     case SCI_UIMENU:
00158       DestroyUimenu (pthis);
00159       return 0;
00160       break;
00161     case SCI_CONSOLE:
00162       sciDestroyConsole( pthis ) ;
00163       return 0 ;
00164     case SCI_FRAME:
00165       sciDestroyFrame( pthis ) ;
00166       return 0 ;
00167     case SCI_WINDOW:
00168       sciDestroyWindow(pthis) ;
00169       return 0 ;
00170     case SCI_WINDOWFRAME:
00171       sciDestroyWindowFrame(pthis) ;
00172       return 0 ;
00173     case SCI_SCREEN:
00174       sciDestroyScreen(pthis) ;
00175       return 0 ;
00176     default:
00177       sciprint ("Entity with type %d cannot be destroyed\n",sciGetEntityType (pthis));
00178       return -1;
00179       break;
00180     }
00181 
00182   return 0;
00183 }
00184 
00185 
00186 
00193 int
00194 sciDelGraphicObj (sciPointObj * pthis)
00195 {
00196   switch (sciGetEntityType (pthis))
00197     {
00198     case SCI_TITLE:
00199     case SCI_LEGEND:
00200     case SCI_ARC:
00201     case SCI_SEGS: 
00202     case SCI_FEC: 
00203     case SCI_GRAYPLOT: 
00204     case SCI_POLYLINE:
00205     case SCI_RECTANGLE:
00206     case SCI_SURFACE:
00207 
00208     case SCI_AXES:
00209     case SCI_MENU:
00210     case SCI_MENUCONTEXT:
00211     case SCI_AGREG:
00212     case SCI_TEXT:
00213     case SCI_MERGE: 
00214     case SCI_LABEL:
00215     case SCI_UIMENU:
00216     case SCI_FIGURE:
00217     case SCI_CONSOLE:
00218     case SCI_FRAME:
00219     case SCI_WINDOW:
00220     case SCI_WINDOWFRAME:
00221     case SCI_SCREEN:
00222       DestroyAllGraphicsSons (pthis);
00223       return 0;
00224       break;
00225     case SCI_SUBWIN:
00226       if (sciGetAxes (sciGetParent(pthis),pthis) == (sciPointObj *) NULL)
00227         sciXbasc();
00228       else
00229         DestroyAllGraphicsSons (pthis);
00230       return 0;
00231       break;         
00232     case SCI_LIGHT:
00233     case SCI_PANNER:
00234     case SCI_SBH:
00235     case SCI_SBV:
00236     case SCI_STATUSB:
00237     default:
00238       sciprint ("This object cannot be deleted\n");
00239       return -1;
00240       break;
00241     }
00242 
00243   return 0;
00244 }
00245 
00246 /*-----------------------------------------------------------------------------*/
00250 int C2F(scigerase)( void )
00251 {
00252   integer verb=0,lstr,v,na,win;
00253   double dv;
00254   char str[4];
00255   C2F(xgetg)("auto clear",str,&lstr,11L,4L);
00256   if (strcmp(str,"on") == 0) {
00257     C2F(dr1)("xget","window",&verb,&win,&na,&v,&v,&v,&dv,&dv,&dv,&dv,5L,7L);
00258     C2F(dr1)("xclear",C2F(cha1).buf,&v,&v,&v,&v,&v,&v,&dv,&dv,&dv,&dv,7L,bsiz);
00259     C2F(dr1)("xstart",C2F(cha1).buf,&win,&v,&v,&v,&v,&v,&dv,&dv,&dv,&dv,7L,bsiz);
00260   }
00261   return 0;
00262 } 
00263 /*-----------------------------------------------------------------------------*/
00264 
00269 int DestroyFigure (sciPointObj * pthis)
00270 {
00271   /* This code has to be validated on all systems
00272    * because sciGetPointerToFeature returns a void
00273    */
00274   FREE ((sciGetFontContext(pthis))->pfontname);
00275   FREE(pFIGURE_FEATURE(pthis)->pcolormap);
00276   FREE( pFIGURE_FEATURE(pthis)->infoMessage ) ;
00277   sciStandardDestroyOperations(pthis) ;
00278   /* delete windows() */
00279   return 0;
00280 }
00281 
00282 
00283 
00288 int
00289 DestroyStatusBar (sciPointObj * pthis)
00290 {
00291   sciDelThisToItsParent(pthis, sciGetParent (pthis));
00292   FREE ((sciGetFontContext(pthis))->pfontname);
00293   return sciStandardDestroyOperations(pthis) ;
00294 }
00295 
00296 
00297 
00302 int
00303 DestroySubWin (sciPointObj * pthis)
00304 { 
00305   /* Add. grads arrays */ /* F.Leray 11.10.04 */
00306   /* specific user arrays */
00307   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pthis);
00308 
00309 
00310   FREE( ppsubwin->axes.u_xgrads); ppsubwin->axes.u_xgrads = (double *) NULL;
00311   FREE( ppsubwin->axes.u_ygrads); ppsubwin->axes.u_ygrads = (double *) NULL;
00312   FREE( ppsubwin->axes.u_zgrads); ppsubwin->axes.u_zgrads = (double *) NULL;
00313   ppsubwin->axes.u_xlabels = FreeUserLabels(ppsubwin->axes.u_xlabels, &ppsubwin->axes.u_nxgrads);
00314   ppsubwin->axes.u_ylabels = FreeUserLabels(ppsubwin->axes.u_ylabels, &ppsubwin->axes.u_nygrads);
00315   ppsubwin->axes.u_zlabels = FreeUserLabels(ppsubwin->axes.u_zlabels, &ppsubwin->axes.u_nzgrads);
00316 
00317   ppsubwin->axes.u_xlabels = NULL;
00318   ppsubwin->axes.u_ylabels = NULL;
00319   ppsubwin->axes.u_zlabels = NULL;
00320 
00321   ppsubwin->axes.u_nxgrads = 0;
00322   ppsubwin->axes.u_nygrads = 0;
00323   ppsubwin->axes.u_nzgrads = 0;
00324  
00325  
00326   /* auto (computed) arrays are defined with max. length == 20 */
00327   ppsubwin->axes.nxgrads = 0;
00328   ppsubwin->axes.nygrads = 0;
00329   ppsubwin->axes.nzgrads = 0;
00330   
00331   if ( sciGetCallback(pthis) != (char *)NULL)
00332     FREE(sciGetCallback(pthis));
00333 
00334   FREE ((sciGetFontContext(pthis))->pfontname);
00335   return sciStandardDestroyOperations(pthis) ;
00336 }
00337 
00338 
00339 
00344 int
00345 DestroyScrollV (sciPointObj * pthis)
00346 {
00347    return sciStandardDestroyOperations(pthis) ;
00348 }
00349 
00350 
00351 
00356 int
00357 DestroyScrollH (sciPointObj * pthis)
00358 {
00359   return sciStandardDestroyOperations(pthis) ;
00360 }
00361 
00365 int deallocateText( sciPointObj * pthis )
00366 {
00367   deleteMatrix( pTEXT_FEATURE(pthis)->pStrings ) ;
00368   FREE (pTEXT_FEATURE (pthis)->user_data);
00369   pTEXT_FEATURE (pthis)->size_of_user_data = 0;
00370 
00371   FREE (sciGetFontContext(pthis)->pfontname);
00372   FREE (sciGetPointerToFeature (pthis));
00373   FREE (pthis);
00374 
00375   return 0;
00376 }
00377 
00382 int DestroyText (sciPointObj * pthis)
00383 {
00384   deleteMatrix( pTEXT_FEATURE(pthis)->pStrings ) ;
00385   FREE ((sciGetFontContext(pthis))->pfontname);
00386   return sciStandardDestroyOperations(pthis) ;
00387 }
00388 
00389 
00390 
00391 
00396 int
00397 DestroyTitle (sciPointObj * pthis)
00398 {
00399   deleteMatrix( pTITLE_FEATURE (pthis)->text.pStrings ) ;
00400   FREE ((sciGetFontContext(pthis))->pfontname);
00401   return sciStandardDestroyOperations(pthis) ;
00402 }
00403 
00404 
00405 
00406 
00411 int
00412 DestroyLegend (sciPointObj * pthis)
00413 {
00414   sciLegend * ppLegend = pLEGEND_FEATURE (pthis) ;
00415   FREE ( ppLegend->pptabofpointobj );
00416   FREE ( ppLegend->pstyle ) ;
00417   deleteMatrix( ppLegend->text.pStrings ) ;
00418 
00419   FREE ((sciGetFontContext(pthis))->pfontname);
00420   return sciStandardDestroyOperations(pthis) ;
00421   /* on peut alors destroyer le parent */
00422 }
00423 
00424 
00425 
00430 int
00431 DestroyPolyline (sciPointObj * pthis)
00432 {
00433   FREE (pPOLYLINE_FEATURE (pthis)->pvx);
00434   FREE (pPOLYLINE_FEATURE (pthis)->pvy);
00435 
00436   if (pPOLYLINE_FEATURE (pthis)->pvz != NULL) 
00437     FREE (pPOLYLINE_FEATURE (pthis)->pvz);
00438   return sciStandardDestroyOperations(pthis) ;
00439 }
00440 
00441 
00446 int
00447 DestroyArc (sciPointObj * pthis)
00448 {
00449   FREE(pARC_FEATURE (pthis)->callback);
00450   return sciStandardDestroyOperations(pthis) ;
00451 }
00452 
00453 
00454 
00459 int
00460 DestroyRectangle (sciPointObj * pthis)
00461 {
00462   return sciStandardDestroyOperations(pthis) ;
00463 }
00464 
00465 
00466 
00471 int
00472 DestroySurface (sciPointObj * pthis)
00473 {
00474   sciPointObj * psubwin ;
00475   sciSubWindow * ppSubWin ;
00476   sciSurface * ppSurface = pSURFACE_FEATURE (pthis) ;
00477   int res = -1 ;
00478   
00479   psubwin  = sciGetParentSubwin(pthis) ;
00480   ppSubWin = pSUBWIN_FEATURE ( psubwin ) ;
00481 
00482   FREE(ppSurface->pvecz);
00483   FREE(ppSurface->pvecy);
00484   FREE(ppSurface->pvecx);
00485   FREE(ppSurface->inputCMoV); /* Adding F.Leray 24.03.04*/
00486   FREE(ppSurface->color); /* Adding F.Leray 18.03.05 */
00487   
00488   if ( ppSurface->izcol != 0 )
00489   { 
00490     FREE(ppSurface->zcol);
00491   }
00492   ppSubWin->surfcounter-- ;
00493   /* DJ.A 2003 */
00494   res = sciStandardDestroyOperations(pthis) ;
00495 
00496   /* delete the merge object if needed */
00497   /* Jb Silvy 07/2006 */
00498   updateMerge( psubwin ) ;
00499 
00500   return res;
00501 }
00502 
00503 
00504 int DestroyMerge (sciPointObj * pthis)
00505 {
00506   pSUBWIN_FEATURE (sciGetParentSubwin(pthis))->facetmerge = FALSE;
00507   FREE(pMERGE_FEATURE (pthis)->index_in_entity);
00508   FREE(pMERGE_FEATURE (pthis)->from_entity);
00509   return sciStandardDestroyOperations(pthis) ;
00510 }
00511 
00512 
00513 
00519 int
00520 DestroyGrayplot (sciPointObj * pthis)
00521 {
00522   FREE (pGRAYPLOT_FEATURE (pthis)->pvecx);
00523   if (pGRAYPLOT_FEATURE (pthis)->type != 2)
00524     FREE (pGRAYPLOT_FEATURE (pthis)->pvecy);
00525   FREE (pGRAYPLOT_FEATURE (pthis)->pvecz);
00526   return sciStandardDestroyOperations(pthis) ;
00527 
00528 }
00529 
00530 
00534 int
00535 DestroyAxes (sciPointObj * pthis)
00536 {
00537   int i;
00538   char **str;
00539 
00540   FREE (pAXES_FEATURE(pthis)->vx);
00541   FREE (pAXES_FEATURE(pthis)->vy);
00542   str=pAXES_FEATURE(pthis)->str;
00543   for (i=Max(pAXES_FEATURE(pthis)->nx,pAXES_FEATURE(pthis)->ny)-1;i<0;i--) 
00544     FREE (pAXES_FEATURE(pthis)->str); 
00545   FREE (pAXES_FEATURE(pthis)->str);
00546   return sciStandardDestroyOperations(pthis) ;
00547 }
00548 
00556 int
00557 DestroyFec (sciPointObj * pthis)
00558 {
00559   FREE (pFEC_FEATURE (pthis)->pvecx);
00560   FREE (pFEC_FEATURE (pthis)->pvecy);
00561   FREE (pFEC_FEATURE (pthis)->pnoeud); 
00562   FREE (pFEC_FEATURE (pthis)->pfun); 
00563   FREE (pFEC_FEATURE (pthis)->zminmax);  
00564   FREE (pFEC_FEATURE (pthis)->colminmax);
00565   FREE (pFEC_FEATURE (pthis)->colout);
00566   return sciStandardDestroyOperations(pthis) ;
00567 }
00568 
00569 
00577 int
00578 DestroySegs (sciPointObj * pthis)
00579 {  
00580   FREE (pSEGS_FEATURE (pthis)->vx);
00581   FREE (pSEGS_FEATURE (pthis)->vy); 
00582   if (pSEGS_FEATURE (pthis)->vz != (double *)NULL) 
00583     FREE (pSEGS_FEATURE (pthis)->vz);  
00584   if (pSEGS_FEATURE (pthis)->ptype <=0) 
00585     {
00586       FREE(pSEGS_FEATURE (pthis)->pstyle);
00587     } 
00588   else 
00589     {
00590       FREE(pSEGS_FEATURE (pthis)->vfx); pSEGS_FEATURE (pthis)->vfx = NULL;
00591       FREE(pSEGS_FEATURE (pthis)->vfy); pSEGS_FEATURE (pthis)->vfy = NULL;
00592       FREE(pSEGS_FEATURE (pthis)->vfz); pSEGS_FEATURE (pthis)->vfz = NULL;
00593     } 
00594   return sciStandardDestroyOperations(pthis) ;
00595 }
00596 
00600 int DestroyCompound (sciPointObj * pthis)
00601 {
00602   return sciStandardDestroyOperations(pthis) ;
00603 }
00604 
00605 void DeleteObjs(integer win_num)
00606 {
00607   sciPointObj *figure;
00608   struct BCG *Xgc;
00609 
00610   figure = (sciPointObj *)  sciIsExistingFigure(&win_num);
00611   if (  figure != (sciPointObj *) NULL )
00612     {
00613       Xgc = (struct BCG *) pFIGURE_FEATURE(figure)->pScilabXgc;
00614       
00615       DestroyAllGraphicsSons (figure);
00616 #ifdef WITH_TK
00617             /* close ged to prevent errors when using it */
00618             sciDestroyGed( sciGetNum(figure) ) ;
00619 #endif
00620       DestroyFigure (figure);
00621       Xgc->mafigure = (sciPointObj *) NULL;
00622     }
00623 }
00624 
00625 
00629 int
00630 sciUnCompound (sciPointObj * pobj)
00631 {
00632   sciPointObj *pparent, *pobjson;
00633   sciSons *psons = (sciSons *)NULL;
00634         
00635   if (sciGetEntityType(pobj) != SCI_AGREG)
00636     return -1;
00637 
00638   psons = sciGetLastSons(pobj);
00639   pobjson = psons->pointobj;
00640   pparent = sciGetParent(pobj);
00641   while ((psons != (sciSons *) NULL) && (pobjson != (sciPointObj *) NULL))
00642     {
00643       /* we delete this son to this */ 
00644       pobjson = psons->pointobj;
00645       /* take the previous sons before the current is freed */
00646       psons = psons->pprev;
00647       sciDelThisToItsParent (pobjson, pobj);
00648       /* and link to its old parent */
00649       sciAddThisToItsParent (pobjson, pparent);
00650     }
00651 
00652   sciSetCurrentObj(pparent); /* pparent is the new current object */
00653 
00654   DestroyCompound(pobj);
00655   return 0;
00656 }
00657 
00658 
00663 int DestroyLabel (sciPointObj * pthis)
00664 {
00665   sciLabel * ppLabel = pLABEL_FEATURE (pthis);
00666   int textStatus = -1 ;
00667   sciUnselectSons( pthis ) ;
00668   sciDelThisToItsParent( pthis, sciGetParent(pthis) ) ;
00669   if ( sciDelHandle(pthis) == -1 ) { return -1 ; }
00670   textStatus = deallocateText( ppLabel->text ) ;
00671   if ( textStatus != 0 )
00672   {
00673     return textStatus ;
00674   }
00675   ppLabel->text = NULL ;
00676   FREE(ppLabel) ;
00677   FREE(pthis) ;
00678   return 0 ;
00679 }
00680 
00681 int DestroyUimenu (sciPointObj * pthis)
00682 {
00683   deleteMatrix( pUIMENU_FEATURE (pthis)->label.pStrings ) ;
00684   FREE (pUIMENU_FEATURE (pthis)->label.callback);
00685 
00686   return sciStandardDestroyOperations(pthis) ;
00687 }
00688 
00689 
00690 
00695 int
00696 sciDelLabelsMenu (sciPointObj * pthis)
00697 {
00698   sciLabelMenu *pscilabelmenutmp;
00699   sciLabelMenu *pscilabelmenutofree;
00700 
00701   switch (sciGetEntityType (pthis))
00702     {
00703     case SCI_MENU:
00704       pscilabelmenutmp = (sciLabelMenu *) (pMENU_FEATURE (pthis)->plabelmenu);
00705       break;
00706     case SCI_MENUCONTEXT:
00707       pscilabelmenutmp =
00708         (sciLabelMenu *) (pMENUCONTEXT_FEATURE (pthis)->plabelmenu);
00709       break;
00710     default:
00711     case SCI_AGREG:
00712       return -1;
00713       break;
00714     }
00715   while (pscilabelmenutmp != (sciLabelMenu *) NULL)
00716     {
00717       /* Il faut retirer tous les menus lies par la liste aussi */
00718       pscilabelmenutofree = pscilabelmenutmp;
00719       pscilabelmenutmp = pscilabelmenutmp->pnextlabelmenu;
00720       FREE (pscilabelmenutofree->plabel);
00721       FREE (pscilabelmenutofree);
00722     }
00723   return 0;
00724 }
00725 
00726 
00727 
00732 int
00733 DestroyMenuContext (sciPointObj * pthis)
00734 {
00735   sciDelLabelsMenu (pthis);
00736   return sciStandardDestroyOperations(pthis) ;
00737 }
00738 
00739 
00740 
00745 int
00746 DestroySciMenu (sciPointObj * pthis)
00747 {
00748   sciDelLabelsMenu (pthis);
00749   FREE ((sciGetFontContext(pthis))->pfontname);
00750   return sciStandardDestroyOperations(pthis) ;
00751 }
00752 
00753 
00754 
00758 void delete_sgwin_entities( int win_num )
00759 {
00760   double dv=0;
00761   double *XGC;
00762   struct BCG *CurrentScilabXgc; 
00763   int v=0;
00764   /* Need to reset the new current figure returned by sciGetCurrentFigure */
00765   sciHandleTab *hdl = NULL;
00766   sciPointObj  *pobj= NULL;
00767 
00768   C2F(dr)("xget","gc",&v,&v,&v,&v,&v,&v,(double *)&XGC,&dv,&dv,&dv,5L,10L); /* ajout cast ???*/
00769   CurrentScilabXgc=(struct BCG *)XGC;
00770 
00771 
00772   hdl = sciGetpendofhandletab();
00773 
00774   if(CurrentScilabXgc != NULL)
00775     while (hdl != NULL)
00776     {
00777       pobj=(sciPointObj *) sciGetPointerFromHandle (hdl->index);
00778       if (sciGetEntityType(pobj) == SCI_FIGURE && sciGetNum(pobj) == CurrentScilabXgc->CurWindow ) /* Adding F.Leray 19.04.04 */
00779       {
00780         sciSetCurrentFigure(pobj);
00781         sciSetCurrentObj(pobj); /* The current object will always be the figure too. */
00782         break;
00783 
00784       }
00785       hdl = hdl->pprev;
00786     }
00787 }
00788 
00789 /*------------------------------------------------------------------------------------*/
00790 /* free the user_data */
00791 void clearUserData( sciPointObj * pObj )
00792 {
00793   int ** pUserData ;
00794   int *  pSizeUD   ;
00795   sciGetPointerToUserData( pObj, &pUserData, &pSizeUD ) ;
00796   if ( pUserData != NULL && *pUserData != NULL )
00797   {
00798     FREE( *pUserData ) ;
00799     *pUserData = NULL ;
00800     *pSizeUD = 0 ;
00801   }
00802 }
00803 /*------------------------------------------------------------------------------------*/
00804 extern int C2F(deletewin)(integer *number);
00808 void sciDeleteWindow( int winNum )
00809 {
00810   C2F(deletewin)( &winNum ) ;
00811 }
00812 /*------------------------------------------------------------------------------------*/
00819 int updateMerge( sciPointObj * pSubwin )
00820 {
00821   if ( sciGetSubwinNbSurf( pSubwin ) == 0 )
00822   {
00823     sciPointObj * merge = sciGetMerge( pSubwin ) ;
00824     if ( merge != NULL )
00825     {
00826       DestroyMerge( merge ) ;
00827     }
00828     pSUBWIN_FEATURE( pSubwin )->facetmerge = FALSE ;
00829   }
00830   else
00831   {
00832     /* the merge 3d is updated */
00833     Merge3d( pSubwin ) ;
00834   }
00835   return 0 ;
00836 }
00837 /*-----------------------------------------------------------------------------------------*/
00838 void AllGraphWinDelete( void )
00839 {
00840 
00841   integer iflag=0,num=0;
00842   int *ArrayWGraph=NULL;
00843 
00844   sciGetIdFigure (ArrayWGraph,&num,&iflag);
00845 
00846   if (num > 0)
00847   {
00848     int i=0;
00849     ArrayWGraph=(int*)MALLOC(sizeof(int)*num);
00850 
00851     iflag = 1;
00852     sciGetIdFigure (ArrayWGraph,&num,&iflag);
00853 
00854     for (i=0;i<num;i++)
00855     {
00856       C2F (deletewin) (&ArrayWGraph[i]);
00857       FREE (ArrayWGraph);
00858     }
00859     ArrayWGraph=NULL;
00860   }
00861 }
00862 /*-----------------------------------------------------------------------------------------*/
00863 void CleanPlots(char *unused, integer *winnumber, integer *v3, integer *v4, integer *v5, integer *v6, integer *v7, double *dx1, double *dx2, double *dx3, double *dx4)
00864 {
00865   
00866   /* we remove scales in window number i */
00867   del_window_scale(*winnumber);
00868   /* if *winnumber is also the current window we reset Cscale to default value */
00869   if ( *winnumber == sciGetNum(sciGetCurrentFigure()) ) 
00870   {
00871     Cscale2default();
00872   }
00873   else
00874   {
00875     set_window_scale_with_default(*winnumber);
00876   }
00877 }
00878 
00879 /*-----------------------------------------------------------------------------------------*/
00880 int sciDestroyConsole( sciPointObj * pThis )
00881 {
00882   return sciStandardDestroyOperations( pThis ) ;
00883 }
00884 /*-----------------------------------------------------------------------------------------*/
00888 int sciStandardDestroyOperations( sciPointObj * pThis )
00889 {
00890   int res = 0 ;
00891   clearUserData( pThis ) ;
00892   sciUnselectSons( pThis ) ;
00893   sciDelThisToItsParent( pThis, sciGetParent(pThis) ) ;
00894   if ( sciDelHandle(pThis) == -1 ) { res = -1 ; }
00895   FREE( pThis->pfeatures ) ;
00896   FREE( pThis ) ;
00897   return res ;
00898 }
00899 /*-----------------------------------------------------------------------------------------*/
00900 int sciDestroyFrame( sciPointObj * pThis )
00901 {
00902   return sciStandardDestroyOperations( pThis ) ;
00903 }
00904 /*-----------------------------------------------------------------------------------------*/
00905 int sciDestroyWindow( sciPointObj * pThis )
00906 {
00907   return sciStandardDestroyOperations( pThis ) ;
00908 }
00909 /*-----------------------------------------------------------------------------------------*/
00910 int sciDestroyWindowFrame( sciPointObj * pThis )
00911 {
00912   return sciStandardDestroyOperations( pThis ) ;
00913 }
00914 /*-----------------------------------------------------------------------------------------*/
00915 int sciDestroyScreen( sciPointObj * pThis )
00916 {
00917   return sciStandardDestroyOperations( pThis ) ;
00918 }
00919 /*-----------------------------------------------------------------------------------------*/

Generated on Sun Mar 4 15:03:51 2007 for Scilab [trunk] by  doxygen 1.5.1