CurrentObjectsManagement.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------*/
00002 /* file: CurrentObjectsManagemet.c                                        */
00003 /* Copyright INRIA 2007                                                   */
00004 /* Authors : Jean-Baptiste Silvy                                          */
00005 /* desc : Set of functions to retrieve the currents objects               */
00006 /*------------------------------------------------------------------------*/
00007 
00008 #include "CurrentObjectsManagement.h"
00009 #include "Xcall1.h"
00010 #include "BuildObjects.h"
00011 #include "GetProperty.h"
00012 #include "SetProperty.h"
00013 #include "ObjectSelection.h"
00014 
00015 /*----------------------------------------------------------------------------------*/
00016 /* root of the graphic hierarchy */
00017 /* singleton, there is only one screen */
00018 static sciPointObj * sciScreenRoot    = NULL ;
00019 static sciPointObj * sciCurrentObject = NULL ;
00020 /*----------------------------------------------------------------------------------*/
00021 static int cf_type = 1 ;
00022 /*----------------------------------------------------------------------------------*/
00023 int get_cf_type( void )
00024 {
00025   return cf_type ;
00026 }
00027 /*----------------------------------------------------------------------------------*/
00028 void set_cf_type( int val )
00029 {
00030   cf_type = val ;
00031 }
00032 /*----------------------------------------------------------------------------------*/
00033 sciPointObj * sciGetCurrentFigure( void )
00034 {
00035   /* debug F.Leray 22.07.04 */
00036   struct BCG * moncurScilabXgc = NULL;
00037   sciPointObj * pfigure = NULL;
00038 
00039 
00040   static sciPointObj *mafigure;
00041   static sciPointObj *masousfen;  
00042 
00043   moncurScilabXgc = sciGetCurrentScilabXgc();
00044   if(moncurScilabXgc == (struct BCG *) NULL)
00045     return (sciPointObj *) NULL;
00046 
00047   pfigure = (sciPointObj *) (moncurScilabXgc->mafigure);
00048 
00049   if(pfigure == (sciPointObj *) NULL )
00050   {
00051     /* it would mean that we have change the driver to GIF,Pos or PPM and perform a xinit F.Leray 22.07.04 */
00052     /* for now, no higher entities than figure */
00053     if ((mafigure = ConstructFigure( NULL, moncurScilabXgc)) != NULL)
00054     {
00055       sciSetCurrentObj (mafigure); 
00056       moncurScilabXgc->mafigure = mafigure;
00057       if ((masousfen = ConstructSubWin (mafigure, moncurScilabXgc->CurWindow)) != NULL) {
00058         sciSetCurrentObj (masousfen);
00059         sciSetOriginalSubWin (mafigure, masousfen);
00060         set_cf_type(1);/* current figure is a graphic one */
00061       }
00062     }
00063   }
00064 
00065   return sciGetCurrentScilabXgc()->mafigure  ;
00066 }
00067 /*----------------------------------------------------------------------------------*/
00068 int sciInitCurrentFigure( sciPointObj * mafigure )
00069 {
00070   sciGetCurrentScilabXgc()->mafigure = mafigure ;
00071   set_cf_type(1);/* current figure is a graphic one */
00072   return 0 ;
00073 }
00074 /*----------------------------------------------------------------------------------*/
00075 int sciSetCurrentFigure ( sciPointObj * mafigure )
00076 {
00077   if ( sciGetCurPointedFigure() == mafigure )
00078   {
00079     /* nothing to do */
00080     return 1 ;
00081   }
00082   return sciInitCurrentFigure( mafigure ) ;
00083 }
00084 /*----------------------------------------------------------------------------------*/
00085 sciPointObj * sciGetCurPointedFigure( void )
00086 {
00087   if ( sciGetCurrentScilabXgc() != NULL )
00088   {
00089     return sciGetCurrentScilabXgc()->mafigure ;
00090   }
00091   else
00092   {
00093     return NULL ;
00094   }
00095 }
00096 /*----------------------------------------------------------------------------------*/
00097 struct BCG * sciGetCurrentScilabXgc( void )
00098 {
00099   int verbose = 0 ;
00100   double * XGC = NULL ;
00101 
00102   C2F(dr)("xget","gc",&verbose,PI0,PI0,PI0,PI0,PI0,(double*)&XGC,PD0,PD0,PD0,5L,10L) ;
00103   return (struct BCG *) XGC;
00104 }
00105 /*----------------------------------------------------------------------------------*/
00106 sciPointObj * sciGetCurrentObj( void )
00107 {
00108   return sciCurrentObject ;
00109 }
00110 /*----------------------------------------------------------------------------------*/
00111 void sciSetCurrentObj( sciPointObj * pobj )
00112 {
00113   sciCurrentObject = pobj ;
00114 }
00115 /*----------------------------------------------------------------------------------*/
00116 long sciGetCurrentHandle( void )
00117 {
00118   return sciGetHandle( sciGetCurrentObj() );
00119 }
00120 /*----------------------------------------------------------------------------------*/
00121 sciPointObj * sciGetCurrentFrame( void )
00122 {
00123   return NULL ;
00124 }
00125 /*----------------------------------------------------------------------------------*/
00126 int sciInitCurrentFrame( sciPointObj * pFrame ) ;
00127 /*----------------------------------------------------------------------------------*/
00128 int sciSetCurrentFrame(  sciPointObj * pFrame ) ;
00129 /*-----------------------------------------------------------------------------*/
00130 sciPointObj * sciGetCurrentWindow( void )
00131 {
00132   return sciGetFirstTypedSelectedSon( sciGetCurrentWindowFrame(), SCI_WINDOW ) ;
00133 }
00134 /*-----------------------------------------------------------------------------*/
00135 sciPointObj * sciGetCurrentWindowFrame( void )
00136 {
00137   return sciGetFirstTypedSelectedSon( sciGetCurrentScreen(), SCI_WINDOWFRAME ) ;
00138 }
00139 /*-----------------------------------------------------------------------------*/
00140 sciPointObj * sciGetCurrentScreen( void )
00141 {
00142   /* the screen */
00143   return sciScreenRoot ;
00144 }
00145 /*-----------------------------------------------------------------------------*/
00146 sciPointObj * sciGetCurrentSubWin( void )
00147 {
00148   return sciGetFirstTypedSelectedSon( sciGetCurrentFigure(), SCI_SUBWIN ) ;
00149 }
00150 /*-----------------------------------------------------------------------------*/
00151 sciPointObj * sciGetCurrentConsole( void )
00152 {
00153   return sciGetFirstTypedSelectedSon( sciGetCurrentFrame(), SCI_CONSOLE ) ;
00154 }
00155 /*-----------------------------------------------------------------------------*/

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