Added some missing headers reported by /usr/lib/build/checks-data/check_gcc_output
[scilab.git] / scilab / modules / graphics / src / c / Interaction.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2001-2002 - INRIA - Mathieu Philipe
4  * Copyright (C) 2002-2004 - INRIA - Djalel Abdemouche
5  * Copyright (C) 2004-2006 - INRIA - Fabrice Leray
6  * Copyright (C) 2005 - INRIA - Jean-Baptiste Silvy
7  * 
8  * This file must be used under the terms of the CeCILL.
9  * This source file is licensed as described in the file COPYING, which
10  * you should have received as part of this distribution.  The terms
11  * are also available at    
12  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13  *
14  */
15
16 /*------------------------------------------------------------------------
17  *    Graphic library 
18  *    Comment:
19  *    This file contains all functions used to INTERACT with the graphic
20  *    window (zoom by pressing button, callbacks...)
21  --------------------------------------------------------------------------*/
22 #include <string.h>
23 #include "Interaction.h"
24 #include "SetProperty.h"
25 #include "GetProperty.h"
26 #include "Scierror.h"
27 #include "MALLOC.h" /* MALLOC */
28 #include "localization.h"
29 #include "DrawingBridge.h"
30 #include "JavaInteraction.h"
31 #include "axesScale.h"
32 #include "math_graphics.h"
33 #include "HandleManagement.h"
34
35 /*-------------------------------------------------------------------------------------*/
36 static int moveObj(sciPointObj * pobj, double displacement[], int displacementSize);
37 /*-------------------------------------------------------------------------------------*/
38
39 /**sciAddCallback
40  * exec the callback associated with pthis
41  */
42 int
43 sciAddCallback (sciPointObj * pthis,char *code, int len, int mevent )
44 {
45   /* Destruction de l'ancienne callback si elle existait */
46   sciDelCallback (pthis);
47
48   switch (sciGetEntityType (pthis))
49     {
50     case SCI_SUBWIN:
51       if ((pSUBWIN_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
52         {
53           Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
54           return -1;
55         }
56       else 
57         {
58           strncpy(pSUBWIN_FEATURE (pthis)->callback, code, len);
59           pSUBWIN_FEATURE (pthis)->callbacklen = len; 
60           pSUBWIN_FEATURE (pthis)->callbackevent = mevent;
61         }
62       break;
63     case SCI_ARC:
64       if ((pARC_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
65         {
66           Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
67           return -1;
68         }
69       else 
70         {
71           strncpy(pARC_FEATURE (pthis)->callback, code, len);
72           pARC_FEATURE (pthis)->callbacklen = len;
73           pARC_FEATURE (pthis)->callbackevent = mevent;
74                      
75         }
76       break;
77     case SCI_RECTANGLE:
78       if ((pRECTANGLE_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
79         {
80           Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
81           return -1;
82         }
83       else 
84         {
85           strncpy(pRECTANGLE_FEATURE (pthis)->callback, code, len);
86           pRECTANGLE_FEATURE (pthis)->callbacklen = len;
87           pRECTANGLE_FEATURE (pthis)->callbackevent = mevent;
88                        
89         }
90       break;
91     case SCI_SEGS:  
92       if ((pSEGS_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
93         {
94           Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
95           return -1;
96         }
97       else 
98         {
99           strncpy(pSEGS_FEATURE (pthis)->callback, code, len);
100           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
101           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
102                        
103         }
104       break;
105     case SCI_FEC:  
106       if ((pFEC_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
107         {
108           Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
109           return -1;
110         }
111       else 
112         {
113           strncpy(pFEC_FEATURE (pthis)->callback, code, len);
114           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
115           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
116                        
117         }
118       break;
119     case SCI_GRAYPLOT: 
120       if ((pGRAYPLOT_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
121         {
122           Scierror(999, _("%s: No more memory.\n"),"sciAddCallback");
123           return -1;
124         }
125       else 
126         {
127           strncpy(pGRAYPLOT_FEATURE (pthis)->callback, code, len);
128           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
129           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
130                        
131         }
132       break;
133     case SCI_POLYLINE:
134       if ((pPOLYLINE_FEATURE (pthis)->callback = CALLOC (len+1, sizeof (char))) == NULL)
135         {
136           Scierror(9999, _("%s: No more memory.\n"),"sciAddCallback");
137           return -1;
138         }
139       else 
140         {
141           strncpy(pPOLYLINE_FEATURE (pthis)->callback, code, len);
142           pPOLYLINE_FEATURE (pthis)->callbacklen = len;
143           pPOLYLINE_FEATURE (pthis)->callbackevent = mevent;
144                         
145         }
146       break;
147     case SCI_UICONTROL:
148     case SCI_UIMENU:
149       break;
150     case SCI_TEXT:
151     case SCI_LEGEND:
152     case SCI_SURFACE:
153     case SCI_AXES:
154     case SCI_FIGURE:
155     case SCI_AGREG:
156     case SCI_LABEL: /* F.Leray 28.05.04 */
157         
158     default:
159       Scierror(999, _("No Callback is associated with this Entity.\n"));
160       return -1;
161       break;
162     }
163   return -1;
164 }
165
166
167
168
169 /**sciGetCallback
170  * returns the scilab callback code
171  */
172 char *sciGetCallback(sciPointObj * pthis)
173 {
174   switch (sciGetEntityType (pthis))
175     {
176     case SCI_SUBWIN:
177       return (char *)(pSUBWIN_FEATURE(pthis)->callback);
178       break;
179     case SCI_ARC:
180       return (char *)(pARC_FEATURE(pthis)->callback);
181       break;
182     case SCI_SEGS: 
183       return (char *)(pSEGS_FEATURE(pthis)->callback);
184       break; 
185     case SCI_FEC: 
186       return (char *)(pFEC_FEATURE(pthis)->callback);
187       break; 
188     case SCI_GRAYPLOT: 
189       return (char *)(pGRAYPLOT_FEATURE(pthis)->callback);
190       break;
191     case SCI_POLYLINE:
192       return (char *)(pPOLYLINE_FEATURE(pthis)->callback);
193       break;
194     case SCI_RECTANGLE:
195       return (char *)(pRECTANGLE_FEATURE(pthis)->callback);
196       break;
197     case SCI_TEXT:
198       return (char *)(pTEXT_FEATURE(pthis)->callback);
199       break;
200     case SCI_SURFACE:
201       return (char *)(pSURFACE_FEATURE(pthis)->callback);
202       break;
203     case SCI_AXES:      
204       return (char *)(pAXES_FEATURE(pthis)->callback);
205       break;
206     case SCI_UIMENU:
207       return (char *)(pUIMENU_FEATURE(pthis)->callback);
208       break;
209     case SCI_UICONTROL:
210       return (char *)(pUICONTROL_FEATURE(pthis)->callback);
211       break;
212     case SCI_LEGEND:
213     case SCI_FIGURE:
214     case SCI_AGREG:
215     case SCI_LABEL: /* F.Leray 28.05.04 */
216     default:
217       Scierror(999, _("No Callback is associated with this Entity.\n"));
218       return (char *)NULL;
219       break;
220     }
221 }
222
223 /* 07/11/2002*/
224 /**sciGetCallbackMouseEvent
225  * @author Djalel Abdemouche
226  */
227 int sciGetCallbackMouseEvent(sciPointObj * pthis)
228 {
229   switch (sciGetEntityType (pthis))
230     {
231     case SCI_SUBWIN:
232       return pSUBWIN_FEATURE(pthis)->callbackevent;
233       break;
234     case SCI_ARC:
235       return pARC_FEATURE(pthis)->callbackevent;
236       break;
237     case SCI_SEGS: 
238       return pSEGS_FEATURE(pthis)->callbackevent;
239       break; 
240     case SCI_FEC: 
241       return pFEC_FEATURE(pthis)->callbackevent;
242       break; 
243     case SCI_GRAYPLOT: 
244       return pGRAYPLOT_FEATURE(pthis)->callbackevent;
245       break;
246     case SCI_POLYLINE:
247       return pPOLYLINE_FEATURE(pthis)->callbackevent;
248       break;
249     case SCI_RECTANGLE:
250       return pRECTANGLE_FEATURE(pthis)->callbackevent;
251       break;
252     case SCI_TEXT:
253       return pTEXT_FEATURE(pthis)->callbackevent;
254       break;
255     case SCI_SURFACE:
256       return pSURFACE_FEATURE(pthis)->callbackevent;
257       break;
258     case SCI_AXES:      
259       return pAXES_FEATURE(pthis)->callbackevent;
260       break;
261     case SCI_UIMENU:
262     case SCI_LEGEND:
263     case SCI_FIGURE:
264     case SCI_AGREG:
265     case SCI_LABEL: /* F.Leray 28.05.04 */
266     default:
267       Scierror(999, _("No Callback is associated with this Entity.\n"));
268       return 100;
269       break;
270     }
271
272 }
273
274 /**sciSetCallbackMouseEvent
275  * @author Djalel Abdemouche
276  */
277 int sciSetCallbackMouseEvent(sciPointObj * pthis, int mevent)
278 {
279   switch (sciGetEntityType (pthis))
280     {
281     case SCI_SUBWIN:
282       pSUBWIN_FEATURE(pthis)->callbackevent = mevent;
283       break;
284     case SCI_ARC:
285       pARC_FEATURE(pthis)->callbackevent = mevent;
286       break;
287     case SCI_SEGS: 
288       pSEGS_FEATURE(pthis)->callbackevent = mevent;
289       break; 
290     case SCI_FEC: 
291       pFEC_FEATURE(pthis)->callbackevent = mevent;
292       break; 
293     case SCI_GRAYPLOT: 
294       pGRAYPLOT_FEATURE(pthis)->callbackevent = mevent;
295       break;
296     case SCI_POLYLINE:
297       pPOLYLINE_FEATURE(pthis)->callbackevent = mevent;
298       break;
299     case SCI_RECTANGLE:
300       pRECTANGLE_FEATURE(pthis)->callbackevent = mevent;
301       break;
302     case SCI_TEXT:
303       pTEXT_FEATURE(pthis)->callbackevent = mevent;
304       break;
305     case SCI_SURFACE:
306       pSURFACE_FEATURE(pthis)->callbackevent = mevent;
307       break;
308     case SCI_AXES:      
309       pAXES_FEATURE(pthis)->callbackevent = mevent;
310       break;
311     case SCI_LEGEND:
312     case SCI_FIGURE:
313     case SCI_AGREG:
314     case SCI_UIMENU:
315     case SCI_LABEL: /* F.Leray 28.05.04 */
316     default:
317       Scierror (999, _("No Callback is associated with this Entity.\n"));
318       return 100;
319       break;
320     }
321   return 100;
322 }
323
324
325
326 /**sciDelCallback
327  * returns the length of the scilab callback code
328  */
329 int
330 sciDelCallback (sciPointObj * pthis)
331 {
332   switch (sciGetEntityType (pthis))
333     {
334     case SCI_SUBWIN:
335       pSUBWIN_FEATURE (pthis)->callbacklen = 0;
336       pSUBWIN_FEATURE (pthis)->callbackevent = 100;
337       FREE(pSUBWIN_FEATURE (pthis)->callback);
338       pSUBWIN_FEATURE (pthis)->callback = NULL;
339       break;
340     case SCI_ARC:
341       pARC_FEATURE (pthis)->callbacklen = 0;
342       pARC_FEATURE (pthis)->callbackevent = 100;
343       FREE(pARC_FEATURE (pthis)->callback);
344       pARC_FEATURE (pthis)->callback = NULL;
345       break;
346     case SCI_RECTANGLE:
347       pRECTANGLE_FEATURE (pthis)->callbacklen = 0;
348       pRECTANGLE_FEATURE (pthis)->callbackevent = 100;
349       FREE(pRECTANGLE_FEATURE (pthis)->callback);
350       pRECTANGLE_FEATURE (pthis)->callback = NULL;
351       break;
352     case SCI_SEGS:  
353       pSEGS_FEATURE (pthis)->callbacklen = 0;
354       pSEGS_FEATURE (pthis)->callbackevent = 100;
355       FREE(pSEGS_FEATURE (pthis)->callback);
356       pSEGS_FEATURE (pthis)->callback = NULL;
357       break;
358     case SCI_FEC:
359       pFEC_FEATURE (pthis)->callbacklen = 0;
360       pFEC_FEATURE (pthis)->callbackevent = 100;
361       FREE(pFEC_FEATURE (pthis)->callback);
362       pFEC_FEATURE (pthis)->callback = NULL;
363       break;  
364     case SCI_GRAYPLOT:
365       pGRAYPLOT_FEATURE (pthis)->callbacklen = 0; 
366       pGRAYPLOT_FEATURE (pthis)->callbackevent = 100;
367       FREE(pGRAYPLOT_FEATURE (pthis)->callback);
368       pGRAYPLOT_FEATURE (pthis)->callback = NULL;
369       break; 
370     case SCI_POLYLINE:
371       pPOLYLINE_FEATURE (pthis)->callbacklen = 0;
372       pPOLYLINE_FEATURE (pthis)->callbackevent = 100;
373       FREE(pPOLYLINE_FEATURE (pthis)->callback);
374       pPOLYLINE_FEATURE (pthis)->callback = NULL;
375       break;
376     case SCI_UIMENU:
377     case SCI_TEXT:
378     case SCI_LEGEND:
379     case SCI_SURFACE:
380     case SCI_AXES:
381     case SCI_FIGURE:
382     case SCI_AGREG:
383     case SCI_LABEL: /* F.Leray 28.05.04 */
384     default:
385       Scierror(999, _("No Callback is associated with this Entity.\n"));
386       return -1;
387       break;
388     }
389   return 0;
390 }
391
392
393 /************************************ End of callback Functions ************************************/
394
395
396 /*----------------------------------------------------------------------------------------*/
397 /* Objmove                                                                                         */
398 /* move a handle in the graphic window                                                             */
399 /*----------------------------------------------------------------------------------------*/
400
401 static int moveObj(sciPointObj * pobj, double displacement[], int displacementSize)
402 {
403   int i,n;
404   double x = displacement[0];
405   double y = displacement[1];
406   double z = (displacementSize == 3? displacement[2] : 0.0);
407
408   switch (sciGetEntityType (pobj))
409   {    
410   case SCI_SUBWIN:
411     {
412       sciSons * psonstmp = sciGetSons(pobj);
413       while ((psonstmp != NULL) && (psonstmp->pointobj != NULL))
414       {
415         moveObj(psonstmp->pointobj, displacement, displacementSize);
416         psonstmp = psonstmp->pnext;
417       }
418     }
419     break;
420   case SCI_ARC:
421     pARC_FEATURE(pobj)->x +=x;
422     pARC_FEATURE(pobj)->y += y; 
423     if (displacementSize == 3) pARC_FEATURE(pobj)->z += z;
424     break;
425   case SCI_RECTANGLE: 
426     pRECTANGLE_FEATURE(pobj)->x += x;  
427     pRECTANGLE_FEATURE(pobj)->y += y; 
428     if (displacementSize == 3) pRECTANGLE_FEATURE(pobj)->z += z;
429     break; 
430   case SCI_AGREG: 
431     {
432       sciSons * psonstmp = sciGetSons(pobj);
433       while ((psonstmp != NULL) && (psonstmp->pointobj != NULL))
434       {
435         moveObj(psonstmp->pointobj, displacement, displacementSize);
436         psonstmp = psonstmp->pnext;
437       }
438     }
439     break;
440   case SCI_TEXT:  
441     pTEXT_FEATURE(pobj)->x += x; 
442     pTEXT_FEATURE(pobj)->y += y;
443     if (displacementSize == 3) pTEXT_FEATURE(pobj)->z += z;
444     break;
445   case SCI_SEGS:
446     n=pSEGS_FEATURE(pobj)->Nbr1;   
447     for (i=0;i<n;i++) {
448       pSEGS_FEATURE(pobj)->vx[i] += x; 
449       pSEGS_FEATURE(pobj)->vy[i] += y;
450     }
451     if (displacementSize == 3) {
452       if  (pSEGS_FEATURE(pobj)->vz == (double *)NULL) {
453         if ((pSEGS_FEATURE(pobj)->vz = MALLOC (n * sizeof (double)))==NULL) return -1;
454         for (i=0;i<n;i++) 
455           pSEGS_FEATURE(pobj)->vz[i] = z; 
456       }
457       else
458         for (i=0;i<n;i++) 
459           pSEGS_FEATURE(pobj)->vz[i] += z; 
460     }
461     break;
462   case SCI_POLYLINE: 
463     n=pPOLYLINE_FEATURE(pobj)->n1;
464     for (i=0;i<n;i++) {
465       pPOLYLINE_FEATURE(pobj)->pvx[i] += x; 
466       pPOLYLINE_FEATURE(pobj)->pvy[i] += y;
467     }
468     if (displacementSize == 3) {
469       if  (pPOLYLINE_FEATURE(pobj)->pvz == (double *)NULL) {
470         if ((pPOLYLINE_FEATURE(pobj)->pvz = MALLOC (n * sizeof (double)))==NULL) return -1;
471         for (i=0;i<n;i++) 
472           pPOLYLINE_FEATURE(pobj)->pvz[i] = z; 
473       }
474       else
475         for (i=0;i<n;i++) 
476           pPOLYLINE_FEATURE(pobj)->pvz[i] += z; 
477     }
478     break;
479   case SCI_FEC: 
480     for (i=0;i<pFEC_FEATURE(pobj)->Nnode;i++) {
481       pFEC_FEATURE(pobj)->pvecx[i] += x; 
482       pFEC_FEATURE(pobj)->pvecy[i] += y;
483     }
484     break;
485   case SCI_GRAYPLOT:
486     if (pGRAYPLOT_FEATURE(pobj)->type == 2)
487     {
488       /* Matplot 1, it is not possible to move a Matplot*/
489       pGRAYPLOT_FEATURE(pobj)->pvecx[0] += x;
490       pGRAYPLOT_FEATURE(pobj)->pvecx[2] += x;
491       pGRAYPLOT_FEATURE(pobj)->pvecx[1] += y;
492       pGRAYPLOT_FEATURE(pobj)->pvecx[3] += y;
493     }
494     else if (pGRAYPLOT_FEATURE(pobj)->type == 0)
495     {
496       /* Grayplot */
497       for (i=0;i<pGRAYPLOT_FEATURE(pobj)->nx;i++)
498         pGRAYPLOT_FEATURE(pobj)->pvecx[i] += x; 
499       for (i=0;i<pGRAYPLOT_FEATURE(pobj)->ny;i++)
500         pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
501     }
502     else
503     {
504       Scierror(999, _("This object can not be moved.\n"));
505       return -1;
506     }
507     
508     break;
509   case SCI_SURFACE: 
510     switch(pSURFACE_FEATURE (pobj)->typeof3d)
511     {
512     case SCI_FAC3D: 
513       n= pSURFACE_FEATURE (pobj)->dimzx* pSURFACE_FEATURE (pobj)->dimzy;
514       for (i=0;i<n;i++) {
515         pSURFACE_FEATURE(pobj)->pvecx[i] += x; 
516         pSURFACE_FEATURE(pobj)->pvecy[i] += y;
517       }
518       if (displacementSize == 3) {
519         if  (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL) {
520           if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double)))==NULL) return -1;
521           for (i=0;i<n;i++) 
522             pSURFACE_FEATURE(pobj)->pvecz[i] = z; 
523         }
524         else
525           for (i=0;i<n;i++) 
526             pSURFACE_FEATURE(pobj)->pvecz[i] += z; 
527       }
528       break;
529     case SCI_PLOT3D:
530       for (i=0;i<pSURFACE_FEATURE (pobj)->dimzx;i++) 
531         pSURFACE_FEATURE(pobj)->pvecx[i] += x; 
532       for (i=0;i<pSURFACE_FEATURE (pobj)->dimzy;i++) 
533         pGRAYPLOT_FEATURE(pobj)->pvecy[i] += y;
534       if (displacementSize == 3) {
535         n=pSURFACE_FEATURE (pobj)->dimzx*pSURFACE_FEATURE (pobj)->dimzy;
536         if  (pSURFACE_FEATURE(pobj)->pvecz == (double *)NULL) {
537           if ((pSURFACE_FEATURE(pobj)->pvecz = MALLOC (n * sizeof (double)))==NULL) return -1;
538           for (i=0;i<n;i++) 
539             pSURFACE_FEATURE(pobj)->pvecz[i] = z; 
540         }
541         else
542           for (i=0;i<n;i++) 
543             pSURFACE_FEATURE(pobj)->pvecz[i] += z; 
544       }
545       break;
546     case SCI_CONTOUR:
547     case SCI_PARAM3D:
548     case SCI_PARAM3D1: /* Nothing to be done */
549       break;
550     }
551     break;
552   case SCI_LABEL:
553     {
554       double pos[3];
555       sciGetTextPos(pobj, pos) ;
556       sciSetTextPos(pobj, pos[0] + x, pos[1] + y, pos[2] + z) ;
557       pLABEL_FEATURE(pobj)->auto_position = FALSE;
558       break;
559     }
560   case SCI_FIGURE:
561   case SCI_AXES:
562   case SCI_LEGEND:
563   case SCI_UIMENU:
564   default:
565     Scierror(999, _("This object can not be moved.\n"));
566     return -1;
567     break;
568   }    
569   
570   /* update the object */
571   forceMove(pobj, x, y, z);
572
573   return 0;
574 }
575
576 int Objmove (sciPointObj * pobj, double d[], int m,BOOL opt)
577 {   
578   int status = moveObj(pobj, d, m);
579
580         if (status < 0)
581         {
582                 return status;
583         }
584
585   if (opt)
586   {
587     /* should be sci draw single obj */
588     sciDrawSingleObj(pobj);
589   }
590   else
591   {
592     sciDrawObj(sciGetParentFigure(pobj));
593   }
594     
595   return status;
596 }
597
598 /*---------------------------------------------------------------------------------*/
599 void pixelRubberBox(sciPointObj * pFigure, BOOL isClick,
600                     const int initialRect[4], int endRect[4], int * usedButton)
601 {
602   javaRubberBox(pFigure, isClick, initialRect, endRect, usedButton);
603 }
604 /*---------------------------------------------------------------------------------*/
605 void rubberBox(sciPointObj * pSubwin, BOOL isClick,
606                const double initialRect[4], double endRect[4], int * usedButton)
607 {
608   int endPixelRect[4];
609   double endFirstCorner[2];
610   double endSecondCorner[2];
611
612   /* get up to date coordinates */
613   updateSubwinScale(pSubwin);
614
615   /* convert initial rect in  */
616
617   if (initialRect != NULL)
618   {
619     int initialPixelRect[4];
620
621     /* Convert initial rect in pixels */
622     double firstCorner[2];
623     double secondCorner[2];
624     firstCorner[0] = initialRect[0];
625     firstCorner[1] = initialRect[1]; /* upper left point */
626     secondCorner[0] = initialRect[0] + initialRect[2];
627     secondCorner[1] = initialRect[1] - initialRect[3];
628     sciGet2dViewPixelCoordinates(pSubwin, firstCorner, initialPixelRect);
629     sciGet2dViewPixelCoordinates(pSubwin, secondCorner, initialPixelRect + 2);
630
631     pixelRubberBox(sciGetParentFigure(pSubwin), isClick, initialPixelRect, endPixelRect, usedButton);
632   }
633   else
634   {
635     pixelRubberBox(sciGetParentFigure(pSubwin), isClick, NULL, endPixelRect, usedButton);
636   }
637
638   /* here we get the two opposite points of the rectangle in pixels */
639   /* convert them in user coordinates */
640   sciGet2dViewCoordFromPixel(pSubwin, endPixelRect, endFirstCorner);
641   sciGet2dViewCoordFromPixel(pSubwin, endPixelRect + 2, endSecondCorner);
642
643   /* [x,y,w,h] array where (x,y) is the upper left point of the rectangle */
644   endRect[0] = Min(endFirstCorner[0], endSecondCorner[0]);
645   endRect[1] = Max(endFirstCorner[1], endSecondCorner[1]);
646   endRect[2] = Abs(endFirstCorner[0] - endSecondCorner[0]);
647   endRect[3] = Abs(endFirstCorner[1] - endSecondCorner[1]);
648
649 }
650 /*---------------------------------------------------------------------------------*/
651 void interactiveZoom(sciPointObj * pObj)
652 {
653         if (sciGetEntityType(pObj) == SCI_FIGURE)
654         {
655                 interactiveJavaZoom(pObj);
656         }
657         else if (sciGetEntityType(pObj) == SCI_SUBWIN)
658         {
659                 interactiveJavaSubwinZoom(pObj);
660         }
661 }
662 /*---------------------------------------------------------------------------------*/
663 void interactiveRotation(sciPointObj * pFigure)
664 {
665         interactiveJavaRotation(pFigure);
666 }
667 /*---------------------------------------------------------------------------------*/
668 void interactiveSubwinRotation(sciPointObj * pSubwin)
669 {
670   /* get coordinates of first mouse click */
671   interactiveJavaSubwinRotation(pSubwin);
672 }
673 /*---------------------------------------------------------------------------------*/
674 void showWindow(sciPointObj * pFigure)
675 {
676   javaShowWindow(pFigure);
677 }
678 /*---------------------------------------------------------------------------------*/
679 void updateViewingAngles(sciPointObj * pSubwin, double deltaAlpha, double deltaTheta)
680 {
681         double newAlpha;
682         double newTheta;
683
684         /* Get current angles */
685         sciGetViewingAngles(pSubwin, &newAlpha, &newTheta);
686
687         /* update them */
688         newAlpha += deltaAlpha;
689         newTheta += deltaTheta;
690
691         Obj_RedrawNewAngle(pSubwin, newAlpha, newTheta);
692
693         /* Update info message */
694         setInfoMessageWithRotationAngles(sciGetParentFigure(pSubwin), newAlpha, newTheta);
695 }
696 /*---------------------------------------------------------------------------------*/
697