Interaction.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-xxxx
00008  *    Comment:
00009  *    This file contains all functions used to INTERACT with the graphic
00010  *    window (zoom by pressing button, callbacks...)
00011  --------------------------------------------------------------------------*/
00012 
00013 #include <stdio.h> 
00014 #include <string.h>
00015 #include <math.h>
00016 #include <stdlib.h>
00017 #include <stdarg.h>
00018 #include <time.h>
00019 
00020 #include "Interaction.h"
00021 #include "SetProperty.h"
00022 #include "GetProperty.h"
00023 #include "DrawObjects.h"
00024 #include "sciprint.h"
00025 #include "MALLOC.h" /* MALLOC */
00026 
00030 int
00031 sciAddCallback (sciPointObj * pthis,char *code, int len, int mevent )
00032 {
00033   /* Destruction de l'ancienne callback si elle existait */
00034   sciDelCallback (pthis);
00035 
00036   switch (sciGetEntityType (pthis))
00037     {
00038     case SCI_SUBWIN:
00039       if ((pSUBWIN_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00040         {
00041           sciprint("No more Memory allocation !\n");
00042           return -1;
00043         }
00044       else 
00045         {
00046           strncpy(pSUBWIN_FEATURE (pthis)->callback, code, len);
00047           pSUBWIN_FEATURE (pthis)->callbacklen = len; 
00048           pSUBWIN_FEATURE (pthis)->callbackevent = mevent;
00049         }
00050       break;
00051     case SCI_ARC:
00052       if ((pARC_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00053         {
00054           sciprint("No more Memory allocation !\n");
00055           return -1;
00056         }
00057       else 
00058         {
00059           strncpy(pARC_FEATURE (pthis)->callback, code, len);
00060           pARC_FEATURE (pthis)->callbacklen = len;
00061           pARC_FEATURE (pthis)->callbackevent = mevent;
00062                      
00063         }
00064       break;
00065     case SCI_RECTANGLE:
00066       if ((pRECTANGLE_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00067         {
00068           sciprint("No more Memory allocation !\n");
00069           return -1;
00070         }
00071       else 
00072         {
00073           strncpy(pRECTANGLE_FEATURE (pthis)->callback, code, len);
00074           pRECTANGLE_FEATURE (pthis)->callbacklen = len;
00075           pRECTANGLE_FEATURE (pthis)->callbackevent = mevent;
00076                        
00077         }
00078       break;
00079     case SCI_SEGS:  
00080       if ((pSEGS_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00081         {
00082           sciprint("No more Memory allocation !\n");
00083           return -1;
00084         }
00085       else 
00086         {
00087           strncpy(pSEGS_FEATURE (pthis)->callback, code, len);
00088           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
00089           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
00090                        
00091         }
00092       break;
00093     case SCI_FEC:  
00094       if ((pFEC_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00095         {
00096           sciprint("No more Memory allocation !\n");
00097           return -1;
00098         }
00099       else 
00100         {
00101           strncpy(pFEC_FEATURE (pthis)->callback, code, len);
00102           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
00103           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
00104                        
00105         }
00106       break;
00107     case SCI_GRAYPLOT: 
00108       if ((pGRAYPLOT_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00109         {
00110           sciprint("No more Memory allocation !\n");
00111           return -1;
00112         }
00113       else 
00114         {
00115           strncpy(pGRAYPLOT_FEATURE (pthis)->callback, code, len);
00116           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
00117           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
00118                        
00119         }
00120       break;
00121     case SCI_POLYLINE:
00122       if ((pPOLYLINE_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
00123         {
00124           sciprint("No more Memory allocation !\n");
00125           return -1;
00126         }
00127       else 
00128         {
00129           strncpy(pPOLYLINE_FEATURE (pthis)->callback, code, len);
00130           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
00131           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
00132                         
00133         }
00134       break;
00135     case SCI_UIMENU:
00136       if ((pUIMENU_FEATURE (pthis)->label.callback = CALLOC (len+1, sizeof (char))) == NULL)
00137         {
00138           sciprint("No more Memory allocation !\n");
00139           return -1;
00140         }
00141       else 
00142         {
00143           strncpy(pUIMENU_FEATURE (pthis)->label.callback, code, len);
00144           pUIMENU_FEATURE (pthis)->label.callbacklen = len;
00145         }
00146       break;
00147     case SCI_TEXT:
00148     case SCI_TITLE:
00149     case SCI_LEGEND:
00150     case SCI_SURFACE:
00151     case SCI_AXES:
00152     case SCI_PANNER:
00153     case SCI_MENU:
00154     case SCI_MENUCONTEXT:
00155     case SCI_STATUSB:
00156     case SCI_FIGURE:
00157     case SCI_SBV:
00158     case SCI_SBH:
00159     case SCI_LIGHT:
00160     case SCI_AGREG:
00161     case SCI_LABEL: /* F.Leray 28.05.04 */
00162         
00163     default:
00164       sciprint ("\r\n No Callback is associated with this Entity");
00165       return -1;
00166       break;
00167     }
00168   return -1;
00169 }
00170 
00171 
00172 
00173 
00177 char *sciGetCallback(sciPointObj * pthis)
00178 {
00179   switch (sciGetEntityType (pthis))
00180     {
00181     case SCI_SUBWIN:
00182       return (char *)(pSUBWIN_FEATURE(pthis)->callback);
00183       break;
00184     case SCI_ARC:
00185       return (char *)(pARC_FEATURE(pthis)->callback);
00186       break;
00187     case SCI_SEGS: 
00188       return (char *)(pSEGS_FEATURE(pthis)->callback);
00189       break; 
00190     case SCI_FEC: 
00191       return (char *)(pFEC_FEATURE(pthis)->callback);
00192       break; 
00193     case SCI_GRAYPLOT: 
00194       return (char *)(pGRAYPLOT_FEATURE(pthis)->callback);
00195       break;
00196     case SCI_POLYLINE:
00197       return (char *)(pPOLYLINE_FEATURE(pthis)->callback);
00198       break;
00199     case SCI_RECTANGLE:
00200       return (char *)(pRECTANGLE_FEATURE(pthis)->callback);
00201       break;
00202     case SCI_TEXT:
00203       return (char *)(pTEXT_FEATURE(pthis)->callback);
00204       break;
00205     case SCI_SURFACE:
00206       return (char *)(pSURFACE_FEATURE(pthis)->callback);
00207       break;
00208     case SCI_AXES:      
00209       return (char *)(pAXES_FEATURE(pthis)->callback);
00210       break;
00211     case SCI_UIMENU:
00212       return (char *)(pUIMENU_FEATURE(pthis)->label.callback);
00213       break;
00214     case SCI_TITLE:
00215     case SCI_LEGEND:
00216     case SCI_PANNER:
00217     case SCI_MENU:
00218     case SCI_MENUCONTEXT:
00219     case SCI_STATUSB:
00220     case SCI_FIGURE:
00221     case SCI_SBV:
00222     case SCI_SBH:
00223     case SCI_LIGHT:
00224     case SCI_AGREG:
00225     case SCI_LABEL: /* F.Leray 28.05.04 */
00226     default:
00227       sciprint ("\r\nNo Callback is associetad with this Entity");
00228       return (char *)NULL;
00229       break;
00230     }
00231   return (char *)NULL;
00232 }
00233 
00234 /* 07/11/2002*/
00238 int sciGetCallbackMouseEvent(sciPointObj * pthis)
00239 {
00240   switch (sciGetEntityType (pthis))
00241     {
00242     case SCI_SUBWIN:
00243       return pSUBWIN_FEATURE(pthis)->callbackevent;
00244       break;
00245     case SCI_ARC:
00246       return pARC_FEATURE(pthis)->callbackevent;
00247       break;
00248     case SCI_SEGS: 
00249       return pSEGS_FEATURE(pthis)->callbackevent;
00250       break; 
00251     case SCI_FEC: 
00252       return pFEC_FEATURE(pthis)->callbackevent;
00253       break; 
00254     case SCI_GRAYPLOT: 
00255       return pGRAYPLOT_FEATURE(pthis)->callbackevent;
00256       break;
00257     case SCI_POLYLINE:
00258       return pPOLYLINE_FEATURE(pthis)->callbackevent;
00259       break;
00260     case SCI_RECTANGLE:
00261       return pRECTANGLE_FEATURE(pthis)->callbackevent;
00262       break;
00263     case SCI_TEXT:
00264       return pTEXT_FEATURE(pthis)->callbackevent;
00265       break;
00266     case SCI_SURFACE:
00267       return pSURFACE_FEATURE(pthis)->callbackevent;
00268       break;
00269     case SCI_AXES:      
00270       return pAXES_FEATURE(pthis)->callbackevent;
00271       break;
00272     case SCI_UIMENU:
00273     case SCI_TITLE:
00274     case SCI_LEGEND:
00275     case SCI_PANNER:
00276     case SCI_MENU:
00277     case SCI_MENUCONTEXT:
00278     case SCI_STATUSB:
00279     case SCI_FIGURE:
00280     case SCI_SBV:
00281     case SCI_SBH:
00282     case SCI_LIGHT:
00283     case SCI_AGREG:
00284     case SCI_LABEL: /* F.Leray 28.05.04 */
00285     default:
00286       sciprint ("\r\nNo Callback is associated with this Entity");
00287       return 100;
00288       break;
00289     }
00290   return 100;
00291 }
00294 int sciSetCallbackMouseEvent(sciPointObj * pthis, int mevent)
00295 {
00296   switch (sciGetEntityType (pthis))
00297     {
00298     case SCI_SUBWIN:
00299       pSUBWIN_FEATURE(pthis)->callbackevent = mevent;
00300       break;
00301     case SCI_ARC:
00302       pARC_FEATURE(pthis)->callbackevent = mevent;
00303       break;
00304     case SCI_SEGS: 
00305       pSEGS_FEATURE(pthis)->callbackevent = mevent;
00306       break; 
00307     case SCI_FEC: 
00308       pFEC_FEATURE(pthis)->callbackevent = mevent;
00309       break; 
00310     case SCI_GRAYPLOT: 
00311       pGRAYPLOT_FEATURE(pthis)->callbackevent = mevent;
00312       break;
00313     case SCI_POLYLINE:
00314       pPOLYLINE_FEATURE(pthis)->callbackevent = mevent;
00315       break;
00316     case SCI_RECTANGLE:
00317       pRECTANGLE_FEATURE(pthis)->callbackevent = mevent;
00318       break;
00319     case SCI_TEXT:
00320       pTEXT_FEATURE(pthis)->callbackevent = mevent;
00321       break;
00322     case SCI_SURFACE:
00323       pSURFACE_FEATURE(pthis)->callbackevent = mevent;
00324       break;
00325     case SCI_AXES:      
00326       pAXES_FEATURE(pthis)->callbackevent = mevent;
00327       break;
00328     case SCI_TITLE:
00329     case SCI_LEGEND:
00330     case SCI_PANNER:
00331     case SCI_MENU:
00332     case SCI_MENUCONTEXT:
00333     case SCI_STATUSB:
00334     case SCI_FIGURE:
00335     case SCI_SBV:
00336     case SCI_SBH:
00337     case SCI_LIGHT:
00338     case SCI_AGREG:
00339     case SCI_UIMENU:
00340     case SCI_LABEL: /* F.Leray 28.05.04 */
00341     default:
00342       sciprint ("\r\nNo Callback is associated with this Entity");
00343       return 100;
00344       break;
00345     }
00346   return 100;
00347 }
00348 
00349 
00350 
00351 
00355 int
00356 sciGetCallbackLen (sciPointObj * pthis)
00357 {
00358   switch (sciGetEntityType (pthis))
00359     {
00360     case SCI_SUBWIN:
00361       return pSUBWIN_FEATURE (pthis)->callbacklen;
00362       break;
00363     case SCI_ARC:
00364       return pARC_FEATURE (pthis)->callbacklen;
00365       break;
00366     case SCI_RECTANGLE:
00367       return pRECTANGLE_FEATURE (pthis)->callbacklen;
00368       break;
00369     case SCI_SEGS: 
00370       return pSEGS_FEATURE (pthis)->callbacklen;
00371       break; 
00372     case SCI_FEC:  
00373       return pFEC_FEATURE (pthis)->callbacklen;
00374       break;  
00375     case SCI_GRAYPLOT: 
00376       return pGRAYPLOT_FEATURE (pthis)->callbacklen;
00377       break;     
00378     case SCI_POLYLINE:
00379       return pPOLYLINE_FEATURE (pthis)->callbacklen;
00380       break;    
00381     case SCI_UIMENU:
00382       return pUIMENU_FEATURE(pthis)->label.callbacklen;
00383       break;
00384     case SCI_TEXT:
00385     case SCI_TITLE:
00386     case SCI_LEGEND:
00387     case SCI_SURFACE:
00388     case SCI_AXES:
00389     case SCI_PANNER:
00390     case SCI_MENU:
00391     case SCI_MENUCONTEXT:
00392     case SCI_STATUSB:
00393     case SCI_FIGURE:
00394     case SCI_SBV:
00395     case SCI_SBH:
00396     case SCI_LIGHT:
00397     case SCI_AGREG:
00398     case SCI_LABEL: /* F.Leray 28.05.04 */
00399     default:
00400       sciprint ("\r\nNo Callback is associated with this Entity");
00401       return -1;
00402       break;
00403     }
00404   return -1;
00405 }
00406 
00407 
00408 
00412 int
00413 sciDelCallback (sciPointObj * pthis)
00414 {
00415   switch (sciGetEntityType (pthis))
00416     {
00417     case SCI_SUBWIN:
00418       pSUBWIN_FEATURE (pthis)->callbacklen = 0;
00419       pSUBWIN_FEATURE (pthis)->callbackevent = 100;
00420       FREE(pSUBWIN_FEATURE (pthis)->callback);
00421       pSUBWIN_FEATURE (pthis)->callback = NULL;
00422       break;
00423     case SCI_ARC:
00424       pARC_FEATURE (pthis)->callbacklen = 0;
00425       pARC_FEATURE (pthis)->callbackevent = 100;
00426       FREE(pARC_FEATURE (pthis)->callback);
00427       pARC_FEATURE (pthis)->callback = NULL;
00428       break;
00429     case SCI_RECTANGLE:
00430       pRECTANGLE_FEATURE (pthis)->callbacklen = 0;
00431       pRECTANGLE_FEATURE (pthis)->callbackevent = 100;
00432       FREE(pRECTANGLE_FEATURE (pthis)->callback);
00433       pRECTANGLE_FEATURE (pthis)->callback = NULL;
00434       break;
00435     case SCI_SEGS:  
00436       pSEGS_FEATURE (pthis)->callbacklen = 0;
00437       pSEGS_FEATURE (pthis)->callbackevent = 100;
00438       FREE(pSEGS_FEATURE (pthis)->callback);
00439       pSEGS_FEATURE (pthis)->callback = NULL;
00440       break;
00441     case SCI_FEC:
00442       pFEC_FEATURE (pthis)->callbacklen = 0;
00443       pFEC_FEATURE (pthis)->callbackevent = 100;
00444       FREE(pFEC_FEATURE (pthis)->callback);
00445       pFEC_FEATURE (pthis)->callback = NULL;
00446       break;  
00447     case SCI_GRAYPLOT:
00448       pGRAYPLOT_FEATURE (pthis)->callbacklen = 0; 
00449       pGRAYPLOT_FEATURE (pthis)->callbackevent = 100;
00450       FREE(pGRAYPLOT_FEATURE (pthis)->callback);
00451       pGRAYPLOT_FEATURE (pthis)->callback = NULL;
00452       break; 
00453     case SCI_POLYLINE:
00454       pPOLYLINE_FEATURE (pthis)->callbacklen = 0;
00455       pPOLYLINE_FEATURE (pthis)->callbackevent = 100;
00456       FREE(pPOLYLINE_FEATURE (pthis)->callback);
00457       pPOLYLINE_FEATURE (pthis)->callback = NULL;
00458       break;
00459     case SCI_UIMENU:
00460       pUIMENU_FEATURE(pthis)->label.callbacklen=0;
00461       FREE(pUIMENU_FEATURE(pthis)->label.callback);
00462       pUIMENU_FEATURE(pthis)->label.callback=NULL;
00463       break;
00464     case SCI_TEXT:
00465     case SCI_TITLE:
00466     case SCI_LEGEND:
00467     case SCI_SURFACE:
00468     case SCI_AXES:
00469     case SCI_PANNER:
00470     case SCI_MENU:
00471     case SCI_MENUCONTEXT:
00472     case SCI_STATUSB:
00473     case SCI_FIGURE:
00474     case SCI_SBV:
00475     case SCI_SBH:
00476     case SCI_LIGHT:
00477     case SCI_AGREG:
00478     case SCI_LABEL: /* F.Leray 28.05.04 */
00479     default:
00480       sciprint ("\r\nNo Callback is associated with this Entity");
00481       return -1;
00482       break;
00483     }
00484   return 0;
00485 }
00486 
00487 
00491 int
00492 sciExecCallback (sciPointObj * pthis)
00493 {
00494   int mlhs = 0, mrhs = 1, ibegin = 1, l1, m1, n1 = 1;
00495   char name[] = "execstr" ;
00496   m1 = sciGetCallbackLen(pthis);
00497   switch (sciGetEntityType (pthis))
00498     {
00499     case SCI_SUBWIN:
00500     case SCI_ARC:
00501     case SCI_RECTANGLE:
00502     case SCI_SEGS: 
00503     case SCI_FEC: 
00504     case SCI_GRAYPLOT: 
00505     case SCI_POLYLINE:
00506       if (sciGetCallback(pthis))
00507         {
00508           CreateVar(1, "c", &m1, &n1, &l1);
00509           strncpy(cstk(l1), sciGetCallback(pthis), sciGetCallbackLen(pthis));
00510           /* back conversion to Scilab coding */
00511           Convert2Sci(1);
00512           SciString(&ibegin,name,&mlhs,&mrhs);
00513           /* check if an error has occured while running a_function */
00514           LhsVar(1) = 0; 
00515           return 0;
00516         }
00517       else sciprint ("\r\nNo Callback is associated with this Entity");
00518       return 0;
00519       break;
00520     case SCI_TEXT:
00521     case SCI_TITLE:
00522     case SCI_LEGEND:
00523     case SCI_SURFACE:
00524     case SCI_AXES:
00525     case SCI_PANNER:
00526     case SCI_MENU:
00527     case SCI_MENUCONTEXT:
00528     case SCI_STATUSB:
00529     case SCI_FIGURE:
00530     case SCI_SBV:
00531     case SCI_SBH:
00532     case SCI_LIGHT:
00533     case SCI_AGREG:
00534     case SCI_LABEL: /* F.Leray 28.05.04 */
00535     case SCI_UIMENU:
00536     default:
00537       sciprint ("\r\nNo Callback is associated with this Entity");
00538       return -1;
00539       break;
00540     }
00541   return -1;
00542 }
00543 
00544 /************************************ End of callback Functions ************************************/
00545 
00546 
00547 /*-------------------------------------------------------------------------------------------------*/
00548 /* Objmove                                                                                         */
00549 /* move a handle in the graphic window                                                             */
00550 /*-------------------------------------------------------------------------------------------------*/
00551 
00552 int Objmove (hdl,d,m,opt)
00553      long *hdl;
00554      double* d;
00555      int m;
00556      BOOL opt;
00557 {   
00558   long tmphdl;
00559   double x,y,z;
00560   sciPointObj *pobj;  
00561   sciSons *psonstmp;
00562   int i,n;
00563   x=d[0];y=d[1];
00564   if (m==3) z=d[2]; else z=0.0;
00565 
00566   pobj = (sciPointObj *)sciGetPointerFromHandle(*hdl);
00567   /*sciSetCurrentObj (pobj);*/  /* Useless*/
00568 
00569   switch (sciGetEntityType (pobj))
00570     {    
00571     case SCI_SUBWIN:
00572       pSUBWIN_FEATURE(pobj)->FRect[0] +=x;
00573       pSUBWIN_FEATURE(pobj)->FRect[2] +=x;
00574       pSUBWIN_FEATURE(pobj)->FRect[1] +=y;
00575       pSUBWIN_FEATURE(pobj)->FRect[3] +=y;
00576       break;
00577     case SCI_ARC:
00578       pARC_FEATURE(pobj)->x +=x;
00579       pARC_FEATURE(pobj)->y += y; 
00580       if (m == 3) pRECTANGLE_FEATURE(pobj)->z += z;
00581       break;
00582     case SCI_RECTANGLE: 
00583       pRECTANGLE_FEATURE(pobj)->x += x;  
00584       pRECTANGLE_FEATURE(pobj)->y += y; 
00585       if (m == 3) pRECTANGLE_FEATURE(pobj)->z += z;
00586       break; 
00587     case SCI_AGREG: 
00588       psonstmp = sciGetSons((sciPointObj *) pobj);
00589       while ((psonstmp != (sciSons *)NULL) && (psonstmp->pointobj != (sciPointObj *)NULL))
00590         {
00591           tmphdl =sciGetHandle((sciPointObj *)psonstmp->pointobj);
00592           Objmove (&tmphdl,d,m,opt);
00593           psonstmp = psonstmp->pnext;
00594         }
00595       break;
00596     case SCI_TEXT:  
00597       pTEXT_FEATURE(pobj)->x += x; 
00598       pTEXT_FEATURE(pobj)->y += y;
00599       if (m == 3) pTEXT_FEATURE(pobj)->z += z;
00600       break;
00601     case SCI_SEGS:
00602       n=pSEGS_FEATURE(pobj)->Nbr1;   
00603       for (i=0;i<n;i++) {
00604         pSEGS_FEATURE(pobj)->vx[i] += x; 
00605         pSEGS_FEATURE(pobj)->vy[i] += y;
00606       }
00607       if (m == 3) {
00608         if  (pSEGS_FEATURE(pobj)->vz == (double *)NULL) {
00609           if ((pSEGS_FEATURE(pobj)->vz = MALLOC (n * sizeof (double)))==NULL) return -1;
00610             for (i=0;i<n;i++) 
00611               pSEGS_FEATURE(pobj)->vz[i] = z; 
00612         }
00613         else
00614           for (i=0;i<n;i++) 
00615             pSEGS_FEATURE(pobj)->vz[i] += z; 
00616       }
00617       break;
00618     case SCI_POLYLINE: 
00619       n=pPOLYLINE_FEATURE(pobj)->n1;
00620       for (i=0;i<n;i++) {
00621         pPOLYLINE_FEATURE(pobj)->pvx[i] += x; 
00622         pPOLYLINE_FEATURE(pobj)->pvy[i] += y;
00623       }
00624       if (m == 3) {
00625         if  (pPOLYLINE_FEATURE(pobj)->pvz == (double *)NULL) {
00626           if ((pPOLYLINE_FEATURE(pobj)->pvz = MALLOC (n * sizeof (double)))==NULL) return -1;
00627             for (i=0;i<n;i++) 
00628               pPOLYLINE_FEATURE(pobj)->pvz[i] = z; 
00629         }
00630         else
00631           for (i=0;i<n;i++) 
00632             pPOLYLINE_FEATURE(pobj)->pvz[i] += z; 
00633       }
00634       break;
00635     case SCI_FEC: 
00636       for (i=0;i<pFEC_FEATURE(pobj)->Nnode;i++) {
00637         pFEC_FEATURE(pobj)->pvecx[i] += x; 
00638         pFEC_FEATURE(pobj)->pvecy[i] += y;
00639       }
00640       break;
00641     case SCI_GRAYPLOT:   
00642       for (i=0;i<pGRAYPLOT_FEATURE(pobj)->nx;i++)
00643         pGRAYPLOT_FEATURE(pobj)->pvecx[i] += x; 
00644       for (i=0;i<pGRAYPLOT_FEATURE(pobj)->ny;i++)
00645         pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
00646       break;
00647     case SCI_SURFACE: 
00648       switch(pSURFACE_FEATURE (pobj)->typeof3d)
00649         {
00650         case SCI_FAC3D: 
00651           n= pSURFACE_FEATURE (pobj)->dimzx* pSURFACE_FEATURE (pobj)->dimzy;
00652           for (i=0;i<n;i++) {
00653             pSURFACE_FEATURE(pobj)->pvecx[i] += x; 
00654             pSURFACE_FEATURE(pobj)->pvecy[i] += y;
00655           }
00656           if (m == 3) {
00657             if  (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL) {
00658               if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double)))==NULL) return -1;
00659               for (i=0;i<n;i++) 
00660                 pSURFACE_FEATURE(pobj)->pvecz[i] = z; 
00661             }
00662             else
00663               for (i=0;i<n;i++) 
00664                 pSURFACE_FEATURE(pobj)->pvecz[i] += z; 
00665           }
00666           break;
00667         case SCI_PLOT3D:
00668           for (i=0;i<pSURFACE_FEATURE (pobj)->dimzx;i++) 
00669             pSURFACE_FEATURE(pobj)->pvecx[i] += x; 
00670           for (i=0;i<pSURFACE_FEATURE (pobj)->dimzy;i++) 
00671             pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
00672           if (m == 3) {
00673             n=pSURFACE_FEATURE (pobj)->dimzx*pSURFACE_FEATURE (pobj)->dimzy;
00674             if  (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL) {
00675               if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double)))==NULL) return -1;
00676               for (i=0;i<n;i++) 
00677                 pSURFACE_FEATURE(pobj)->pvecz[i] = z; 
00678             }
00679             else
00680               for (i=0;i<n;i++) 
00681                 pSURFACE_FEATURE(pobj)->pvecz[i] += z; 
00682           }
00683           break;
00684         case SCI_CONTOUR:
00685         case SCI_PARAM3D:
00686         case SCI_PARAM3D1: /* Nothing to be done */
00687           break;
00688         }
00689       break;
00690     case SCI_LABEL:
00691     {
00692       double posX ;
00693       double posY ;
00694       sciGetPosition( pLABEL_FEATURE(pobj)->text, &posX, &posY ) ;
00695       sciSetPosition( pLABEL_FEATURE(pobj)->text, posX + x, posY + y ) ;
00696       pLABEL_FEATURE(pobj)->auto_position = FALSE;
00697       break;
00698     }
00699     case SCI_FIGURE:
00700     case SCI_AXES:
00701     case SCI_LIGHT:
00702     case SCI_MENU:
00703     case SCI_MENUCONTEXT:
00704     case SCI_STATUSB:
00705     case SCI_PANNER:    
00706     case SCI_SBH:               
00707     case SCI_SBV:             
00708     case SCI_TITLE:
00709     case SCI_LEGEND:
00710     case SCI_UIMENU:
00711     default:
00712       sciprint ("This object can not be moved\r\n");
00713       return -1;
00714       break;
00715     }    
00716   if (opt)
00717   {
00718     /*sciDrawObjIfRequired(pobj);*/
00719     sciRefreshObj( pobj ) ;
00720   }
00721   else
00722   {
00723     /*sciDrawObj(sciGetParentFigure(pobj));*/
00724     sciRefreshObj( sciGetParentFigure( pobj ) ) ;
00725   }
00726   /* sciDrawObj(sciGetParentFigure(sciGetCurrentObj ()));*/
00727     
00728   return 0;
00729 }
00730 
00731 
00732 BOOL sciIsAreaZoom(box,box1,section)
00733      integer box[4];
00734      integer box1[4];
00735      integer section[4];
00736 {
00737   if ( (box[0]<=box1[0]) && (box[2]>box1[0]) && (box[2]<=box1[2]) 
00738        && (box[1]<box1[1]) && (box[3]>box1[1]) && (box[3]<=box1[3]) )
00739     {section[0]=box1[0];  section[2]=box[2];  section[1]=box1[1];  section[3]=box[3];return TRUE;}
00740   
00741   if ( (box[0]<=box1[0]) && (box[2]>box1[0]) && (box[2]<=box1[2]) 
00742        && (box[1]>=box1[1]) && (box[3]<=box1[3]) )
00743     {section[0]=box1[0];  section[2]=box[2];  section[1]=box[1];  section[3]=box[3];return TRUE;}
00744   
00745   if ( (box[0]<=box1[0]) && (box[2]>box1[0]) && (box[2]<=box1[2]) 
00746        && (box[1]>=box1[1]) && (box[1]<=box1[3]) && (box[3]>=box1[3]) )
00747     {section[0]=box1[0];  section[2]=box[2];  section[1]=box[1];  section[3]=box1[3];return TRUE;}
00748 
00749   if ( (box[0]<=box1[0]) && (box[2]>box1[0]) && (box[2]<=box1[2]) 
00750        && (box[1]<box1[1]) &&  (box[3]>box1[3]) )
00751     {section[0]=box1[0];  section[2]=box[2];  section[1]=box1[1];  section[3]=box1[3];return TRUE;}
00752   /*********************/
00753  
00754   if ( (box[0]>box1[0])  && (box[2]<=box1[2]) 
00755        && (box[1]<box1[1]) && (box[3]>box1[1]) && (box[3]<=box1[3]) )
00756     {section[0]=box[0];  section[2]=box[2];  section[1]=box1[1];  section[3]=box[3]; return TRUE;}
00757   
00758   if ( (box[0]>box1[0])  && (box[2]<=box1[2]) 
00759        && (box[1]>=box1[1]) && (box[3]<=box1[3]) )
00760     {section[0]=box[0];  section[2]=box[2];  section[1]=box[1];  section[3]=box[3]; return TRUE;}
00761   
00762   if ( (box[0]>box1[0])  && (box[2]<=box1[2]) 
00763        && (box[1]>=box1[1]) && (box[1]<=box1[3]) && (box[3]>=box1[3]) )
00764     {section[0]=box[0];  section[2]=box[2];  section[1]=box[1];  section[3]=box1[3]; return TRUE;}
00765 
00766   if ( (box[0]>box1[0])  && (box[2]<=box1[2]) 
00767        && (box[1]<box1[1]) &&  (box[3]>box1[3]) )
00768     {section[0]=box[0];  section[2]=box[2];  section[1]=box1[1];  section[3]=box1[3];return TRUE;}
00769   /*********************/ 
00770   if ( (box[0]>box1[0]) && (box[0]<box1[2]) && (box[2]>=box1[2]) 
00771        && (box[1]<box1[1]) && (box[3]>box1[1]) && (box[3]<=box1[3]) )
00772     {section[0]=box[0];  section[2]=box1[2];  section[1]=box1[1];  section[3]=box[3]; return TRUE;}
00773   
00774   if ( (box[0]>box1[0]) && (box[0]<box1[2]) && (box[2]>=box1[2]) 
00775        && (box[1]>=box1[1]) && (box[3]<=box1[3]) )
00776     {section[0]=box[0];  section[2]=box1[2];  section[1]=box[1];  section[3]=box[3];return TRUE;}
00777   
00778   if ( (box[0]>box1[0]) && (box[0]<box1[2]) && (box[2]>=box1[2]) 
00779        && (box[1]>=box1[1]) && (box[1]<=box1[3]) && (box[3]>=box1[3]) )
00780     {section[0]=box[0];  section[2]=box1[2];  section[1]=box[1];  section[3]=box1[3];return TRUE;}
00781 
00782   if ( (box[0]>box1[0]) && (box[0]<box1[2]) && (box[2]>=box1[2]) 
00783        && (box[1]<box1[1]) &&  (box[3]>box1[3]) )
00784     {section[0]=box[0];  section[2]=box1[2];  section[1]=box1[1];  section[3]=box1[3]; return TRUE;}
00785   /*********************/  
00786   if ( (box[0]<box1[0])  && (box[2]>box1[2]) 
00787        && (box[1]<box1[1]) && (box[3]>box1[1]) && (box[3]<=box1[3]) )
00788     {section[0]=box1[0];  section[2]=box1[2];  section[1]=box1[1];  section[3]=box[3];return TRUE;}
00789   
00790   if ( (box[0]<box1[0])  && (box[2]>box1[2])
00791        && (box[1]>=box1[1]) && (box[3]<=box1[3]) )
00792     {section[0]=box1[0];  section[2]=box1[2];  section[1]=box[1];  section[3]=box[3];return TRUE;}
00793   
00794   if ( (box[0]<box1[0])  && (box[2]>box1[2])
00795        && (box[1]>=box1[1]) && (box[1]<=box1[3]) && (box[3]>=box1[3]) )
00796     {section[0]=box1[0];  section[2]=box1[2];  section[1]=box[1];  section[3]=box1[3];return TRUE;}
00797   return FALSE;
00798 
00799 }

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