GedManagement.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------------------*/
00002 /* Copyright INRIA 2006                                                                    */
00003 /* File   : GedManagement.c                                                                */
00004 /* Author : Jean-Baptiste Silvy                                                            */
00005 /* Desc   : C functions to manage ged (only destroy for now)                               */
00006 /*-----------------------------------------------------------------------------------------*/
00007 
00008 #include "GedManagement.h"
00009 #include "TCL_Global.h"
00010 /*-----------------------------------------------------------------------------------------*/
00011 /* return the ged interpreter (default interpreter for now) */
00012 static Tcl_Interp * getGedInterpreter( void ) ;
00013 /*-----------------------------------------------------------------------------------------*/
00014 int sciDestroyGed( int figureId )
00015 {
00016   Tcl_Interp * gedInterp = getGedInterpreter() ;
00017   if ( isGedOpenedOn( figureId ) )
00018   {
00019     /* try to close the ticks editor */
00020     Tcl_Eval( gedInterp, "catch { destroy .ticks }" ) ;
00021     /* try to close the editor */
00022     Tcl_Eval( gedInterp, "catch { destroy .axes }"  ) ;
00023     return 0 ;
00024   }
00025   else
00026   {
00027     return 1 ;
00028   }
00029 }
00030 
00031 /*-----------------------------------------------------------------------------------------*/
00032 int isGedOpenedOn( int figureId )
00033 {
00034   Tcl_Interp * gedInterp = getGedInterpreter() ;
00035   if ( gedInterp != NULL )
00036   {
00037     /* check is sciGedIsAlive variable exists */
00038     char * sGedWindowNum = (char * ) Tcl_GetVar( gedInterp, "sciGedIsAlive", TCL_GLOBAL_ONLY ) ;
00039     if ( sGedWindowNum )
00040     {
00041       /* get the number of the window ged modified */
00042       int iGedWindowNum ;
00043       sscanf( sGedWindowNum, "%d", &iGedWindowNum ) ;
00044       /* check if ged is opened on the checked window */
00045       if ( iGedWindowNum == figureId )
00046       {
00047         return TRUE ;
00048       }
00049       else
00050       {
00051         return FALSE ;
00052       }
00053     }
00054     else
00055     {
00056       return FALSE ;
00057     }
00058   }
00059   else
00060   {
00061     /* tcl has not been initialized yet */
00062     return FALSE ;
00063   }
00064 }
00065 
00066 /*-----------------------------------------------------------------------------------------*/
00067 
00068 /*-----------------------------------------------------------------------------------------*/
00069 
00070 static Tcl_Interp * getGedInterpreter( void )
00071 {
00072   return TCLinterp ;
00073 }
00074 
00075 /*-----------------------------------------------------------------------------------------*/

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