3 * Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * See the file ./license.txt
21 /*--------------------------------------------------------------------------*/
23 \file scoWindowScope.c
26 \date September 2006 - January 2007
27 \brief Source Code of all functions wich interact with the window like creation of graphical object or refreshing the window
29 /*--------------------------------------------------------------------------*/
33 #include "scoWindowScope.h"
34 #include "scoMemoryScope.h"
37 #include "scoGetProperty.h"
38 #include "scoSetProperty.h"
39 #include "SetProperty.h"
40 #include "BuildObjects.h"
41 #include "scicos_malloc.h"
42 #include "scicos_free.h"
44 #include "WindowList.h"
45 #include "DrawingBridge.h"
46 #include "CurrentObjectsManagement.h"
47 #include "ObjectSelection.h"
48 #include "HandleManagement.h" /* sciGetHandle */
49 #include "scicos_block4.h"
50 #include "localization.h"
51 /*--------------------------------------------------------------------------*/
52 extern int C2F(dcopy)();
53 /*--------------------------------------------------------------------------*/
54 static void scoSetWindowIDInUserData(ScopeMemory * pScopeMemory,int block_number)
56 /* 15/07/2009, S. Steer: user data set to a Scilab data structure instead of only the block_number value */
58 int **user_data_ptr=NULL,*size_ptr=NULL;
60 scoGraphicalObject pTemp = scoGetPointerScopeWindow(pScopeMemory);
61 sciGetPointerToUserData (pTemp,&user_data_ptr, &size_ptr);
63 if ((*user_data_ptr=(int *)MALLOC(6*sizeof(int))) == NULL) {
64 scoScopeError(pScopeMemory,1);
67 /* one double to scilab stack */
68 *(*user_data_ptr) = 1;
69 *(*user_data_ptr+1) = 1;
70 *(*user_data_ptr+2) = 1;
71 *(*user_data_ptr+3) = 0;
72 ptr_d = (double *) (*user_data_ptr+4);
73 *ptr_d = (double) block_number;
76 /*--------------------------------------------------------------------------*/
77 scoInteger scoGetUserData(scoGraphicalObject pTemp)
79 /* 15/07/2009, S. Steer: to take into account the scoSetWindowIDInUserData change */
81 int **user_data_ptr=NULL,*size_ptr=NULL;
82 sciGetPointerToUserData (pTemp,&user_data_ptr, &size_ptr);
83 ptr_d = (double *) (*user_data_ptr+4);
84 return (scoInteger) *ptr_d;
86 /*--------------------------------------------------------------------------*/
87 void scoInitOfWindow(ScopeMemory * pScopeMemory, int dimension, int win_id, int * win_pos, int * win_dim, double * xmin, double * xmax, double * ymin, double * ymax, double * zmin, double * zmax)
90 int block_number = get_block_number();
92 scoGraphicalObject pTemp;
93 scoGraphicalObject pTemp2;
94 //if win-id is -1 we give an auto number based on the block_number on the diagram
97 win_id = 20000 + block_number;
99 //if we restart the simulation this command delete all previous children of the window
101 /* warning C4047: '=' : 'scoGraphicalObject' differs in levels of indirection from 'BOOL' */
102 if ((sciIsExistingFigure(win_id)))
104 pTemp = getFigureFromIndex(win_id);
105 if (pFIGURE_FEATURE(pTemp)->user_data != NULL)
107 user_data = scoGetUserData(pTemp);
110 sciClearFigure(pTemp); //** if already present is cleared
113 /*if ((user_data == -1 ) || (user_data == win_id))*/
114 if ((user_data == -1 ) || (user_data == block_number))
116 scoSetWindowID(pScopeMemory,win_id);
118 scoSetScopeActivation(pScopeMemory,1); //Activate It ! Let's Rock !
119 //Dont forget this kind of command
120 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
121 pTemp = sciGetCurrentFigure();
122 scoSetHandleScopeWindow(pScopeMemory,sciGetHandle(pTemp));
123 scoSetWindowIDInUserData(pScopeMemory,block_number);
124 for (i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
128 //We are getting the Handle of the current axes but in the same time we are constructing it (see below)
129 //Here pTemp is the pointer on the ScopeWindow
130 // J-B please check this
131 scoSetHandleAxes(pScopeMemory,i,sciGetHandle(sciGetFirstTypedSelectedSon( pTemp, SCI_SUBWIN )) );
135 //Here pTemp is the pointer on the ScopeWindow
136 scoSetHandleAxes(pScopeMemory,i,sciGetHandle(ConstructSubWin(pTemp)));
138 //Here pTemp2 is the pointer on the current Axes
139 pTemp2 = scoGetPointerAxes(pScopeMemory,i);
140 sciInitFontSize(pTemp2, 1); //** axes font size (numbers)
142 //** sciSetIsBoxed(pTemp2,TRUE); //** obsolete in Scilab 5
143 sciSetBoxType(pTemp2,BT_ON);
145 //Here we don't want "smart" limits
146 pSUBWIN_FEATURE(pTemp2)->tight_limits = TRUE;
147 //Here PTemp2 is the pointer on the current Subwint
148 //WRect is for position of Axes in the window
149 pSUBWIN_FEATURE(pTemp2)->WRect[0] = 0;
150 pSUBWIN_FEATURE(pTemp2)->WRect[1] = (double)i/scoGetNumberOfSubwin(pScopeMemory);
151 pSUBWIN_FEATURE(pTemp2)->WRect[2] = 1;
152 pSUBWIN_FEATURE(pTemp2)->WRect[3] = (double)1/scoGetNumberOfSubwin(pScopeMemory);
153 pSUBWIN_FEATURE(pTemp2)->axes.filled = FALSE;
157 pSUBWIN_FEATURE(pTemp2)->is3d = TRUE;
158 pSUBWIN_FEATURE(pTemp2)->axes.axes_visible[2] = TRUE;
159 //SRECT is here to give number of x,y, or z legends
160 pSUBWIN_FEATURE(pTemp2)->SRect[4] = zmin[i];
161 pSUBWIN_FEATURE(pTemp2)->SRect[5] = zmax[i];
163 pSUBWIN_FEATURE(pTemp2)->axes.axes_visible[1] = TRUE;
164 pSUBWIN_FEATURE(pTemp2)->SRect[2] = ymin[i];
165 pSUBWIN_FEATURE(pTemp2)->SRect[3] = ymax[i];
167 pSUBWIN_FEATURE(pTemp2)->axes.axes_visible[0] = TRUE;
168 pSUBWIN_FEATURE(pTemp2)->SRect[0] = xmin[i];
169 pSUBWIN_FEATURE(pTemp2)->SRect[1] = xmax[i];
172 Coserror(_("Incorrect value for dimension argument."));
180 if (win_pos[0] >= 0) {
181 sciInitScreenPosition(pTemp, win_pos[0], win_pos[1]);
186 if (win_dim[0] >= 0) {
187 sciSetDimension(pTemp, win_dim[0], win_dim[1]);
191 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
196 Coserror(_("This scope has the same window id than another."));
199 /*--------------------------------------------------------------------------*/
200 void scoRefreshDataBoundsX(ScopeMemory * pScopeMemory, double t)
202 scoGraphicalObject pLongDraw = NULL;
203 scoGraphicalObject pShortDraw;
204 scoGraphicalObject pAxes;
206 int NbrPts = 0, current_period_counter = 0;
209 /* To know if one or more subwindows need to be redrawn */
210 BOOL needRedraw = FALSE;
213 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
214 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
216 /*if we have to redraw the axis for x-axis*/
217 if (scoGetNewDraw(pScopeMemory,i) < 0)
220 pAxes = scoGetPointerAxes(pScopeMemory,i);
221 period = scoGetPeriod(pScopeMemory,i);
223 /*Calculating the current period counter and update the value of x bounds*/
224 current_period_counter = (int)(t/period);
225 pSUBWIN_FEATURE(pAxes)->SRect[0] = period*(current_period_counter);
226 pSUBWIN_FEATURE(pAxes)->SRect[1] = period*(current_period_counter+1);
227 /*forceRedraw(pAxes);*/
228 /*Don't forget to save the new value - because we have activated the refresh we are going one step over*/
229 scoSetPeriodCounter(pScopeMemory,i,current_period_counter);
231 /*Instruction to reinitialize the ShortDraw and to copy the last points of the ShortDraw in the LongDraw to be sure to have continuity*/
232 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,0);
233 switch(sciGetEntityType(pShortDraw))
235 /*Getting Number of Points in the ShortDraw
236 Then for each polyline in the axis :
237 -Reinitialize LongDraw
238 -Copy last points of the ShortDraw into the LongDraw
240 -Reinitialize the ShortDraw
241 -copy last points of the last short into the new for continuity
242 -initialize shortdraw
246 NbrPts = pPOLYLINE_FEATURE(pShortDraw)->n1;
247 for (j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
249 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
250 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
251 //We don't have to draw it because for instance there will be only one point and if it is a line it is not good
252 /* was commented in scilab5 */
253 //pPOLYLINE_FEATURE(pShortDraw)->visible = FALSE;
255 pPOLYLINE_FEATURE(pLongDraw)->n1 = 0;
256 /* We copy ShortDraw data in LongDraw to ensure the continuity */
257 C2F(dcopy)(&NbrPts,pPOLYLINE_FEATURE(pShortDraw)->pvx,&c__1,pPOLYLINE_FEATURE(pLongDraw)->pvx,&c__1);
258 C2F(dcopy)(&NbrPts,pPOLYLINE_FEATURE(pShortDraw)->pvy,&c__1,pPOLYLINE_FEATURE(pLongDraw)->pvy,&c__1);
259 pPOLYLINE_FEATURE(pLongDraw)->n1 = NbrPts;
261 /* Reset the ShortDraw keeping the last point as new satrting point */
262 pPOLYLINE_FEATURE(pShortDraw)->pvx[0] = pPOLYLINE_FEATURE(pLongDraw)->pvx[NbrPts-1];
263 pPOLYLINE_FEATURE(pShortDraw)->pvy[0] = pPOLYLINE_FEATURE(pLongDraw)->pvy[NbrPts-1];
264 pPOLYLINE_FEATURE(pShortDraw)->n1 = 1;
270 NbrPts = pSEGS_FEATURE(pShortDraw)->Nbr1;
271 for (j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
273 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
274 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
275 //pSEGS_FEATURE(pShortDraw)->visible = FALSE;
277 pSEGS_FEATURE(pLongDraw)->Nbr1 = 0;
278 pSEGS_FEATURE(pLongDraw)->Nbr2 = 0;
279 C2F(dcopy)(&NbrPts,pSEGS_FEATURE(pShortDraw)->vx ,&c__1,pSEGS_FEATURE(pLongDraw)->vx,&c__1);
280 C2F(dcopy)(&NbrPts,pSEGS_FEATURE(pShortDraw)->vy ,&c__1,pSEGS_FEATURE(pLongDraw)->vy,&c__1);
281 pSEGS_FEATURE(pLongDraw)->Nbr1 = NbrPts;
282 pSEGS_FEATURE(pLongDraw)->Nbr2 = NbrPts;
287 Coserror(_("Cannot use %s with this type of object."), "scoRefreshDataBoundsX");
290 /* Dont forget to reinit it */
291 scoSetNewDraw(pScopeMemory,i,0);
293 /* we have modified some thing it is that we need to redraw the subwin */
294 forceRedraw(pShortDraw);
295 forceRedraw(pLongDraw);
303 sciDrawObj(scoGetPointerScopeWindow(pScopeMemory));
309 //Now that we have redrawn the window we can reactivate the shortdraw because there will be more than one point in the futur
310 //THIS PART CAN BE RECODED - NOT EFFICIENT
311 // as previous pSEGS_FEATURE(pShortDraw)->visible = FALSE; have been commented out, the following code is not usefull
312 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
314 for (j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
316 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,0);
317 switch(sciGetEntityType(pShortDraw))
321 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
322 pPOLYLINE_FEATURE(pShortDraw)->visible = TRUE;
327 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
328 pSEGS_FEATURE(pShortDraw)->visible = TRUE;
339 /*--------------------------------------------------------------------------*/
340 //** ------------------------------------------------------------------------------------------------
342 //** ------------ The physical redraw of the scope is hidden here -----------------------------------
345 void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
349 int NbrPtsShort = 0,NbrPtsLong = 0,inc = 0;
350 int NbrPtsToCopy = 0;
351 int current_period_counter = 0;
352 int NumCurvInSubWin = 0;
354 int NumCurvTotal = 0;
355 int ShortDrawTableIndex = 0;
356 scoGraphicalObject pLongDraw = NULL;
357 scoGraphicalObject pShortDraw = NULL;
358 scoGraphicalObject *pShortDrawTable = NULL;
360 double d_current_real_time = 0. ; //** the current real time as double (52 bit) data structure
361 double last_update_time = 0. , delta_time = 0.;
362 int force_update[256]; //** ... for some headroom :)
363 //** ------ Real Time section -------------------------------------------------------------
364 //** current real time as double [second]
365 d_current_real_time = scoGetRealTime();
366 last_update_time = pScopeMemory->d_last_scope_update_time; //** recover the last update time
367 delta_time = d_current_real_time - last_update_time ;
368 //refresh_time = 0.040 ; //** 40ms -> 25 fps min
369 //** ------ End of Real Time section ------------------------------------------------------
371 ShortDrawTableIndex = 0;
373 NumSubWin = scoGetNumberOfSubwin(pScopeMemory);
374 for(i = 0 ; i < NumSubWin ; i++) //** for all the subwindows in the scope
376 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,0);
377 switch (sciGetEntityType(pShortDraw))
381 NbrPtsShort = pPOLYLINE_FEATURE(pShortDraw)->n1; //** this is incremented by one at each iteration
385 NbrPtsShort = pSEGS_FEATURE(pShortDraw)->Nbr1;
389 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
393 //** combined condition for forced redraw
394 //S.Steer time condition commented out because it slow down the display
395 //an option should be to increase the ShortDraw size if it is full before refresh_time is reached
396 force_update[i]=/*((delta_time>refresh_time) && (NbrPtsShort>=2)) ||*/
397 (NbrPtsShort>=scoGetShortDrawSize(pScopeMemory,i));
401 NumCurvTotal += scoGetNumberOfCurvesBySubwin(pScopeMemory,i);
405 pShortDrawTable = scicos_malloc( NumCurvTotal * sizeof(scoGraphicalObject) );
406 //** for all the sub window in the scope
407 for (i = 0 ; i < NumSubWin ; i++)
409 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,0);
410 switch (sciGetEntityType(pShortDraw))
414 NbrPtsShort = pPOLYLINE_FEATURE(pShortDraw)->n1; //** this is incremented by one at each iteration
418 NbrPtsShort = pSEGS_FEATURE(pShortDraw)->Nbr1;
422 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
426 //**-------------------------------------------------------------------------------------------------------
428 if (force_update[i] == 1)
430 /*Block for Realloc*/
431 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,0);
432 switch (sciGetEntityType(pLongDraw))
435 NbrPtsLong = pPOLYLINE_FEATURE(pLongDraw)->n1;
438 NbrPtsLong = pSEGS_FEATURE(pLongDraw)->Nbr1;
441 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
445 if ((NbrPtsLong + scoGetShortDrawSize(pScopeMemory,i)) >= scoGetLongDrawSize(pScopeMemory,i))
447 for (j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
449 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
450 scoReallocLongDraw(pLongDraw, NbrPtsLong, scoGetShortDrawSize(pScopeMemory,i),10000);
452 //Dont forget this one - If in the futur LongDrawSize is a table we can put it in the scoReallocLongDraw() function
453 scoSetLongDrawSize(pScopeMemory,i,NbrPtsLong + scoGetShortDrawSize(pScopeMemory,i)+10000);
455 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,0);
456 /*End od block for Realloc*/
459 NumCurvInSubWin = scoGetNumberOfCurvesBySubwin(pScopeMemory,i); //** get number of curves in subwin
460 for (j = 0 ; j < NumCurvInSubWin ; j++)
462 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
463 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
465 if (pShortDraw != NULL) //** protection for NULL pointer
467 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
468 sciSetSelectedSubWin(scoGetPointerAxes(pScopeMemory,i));
469 sciSetVisibility(pShortDraw, TRUE);
470 pShortDrawTable[ShortDrawTableIndex] = pShortDraw ;
471 ShortDrawTableIndex++;
475 scoScopeError(pScopeMemory,0);
477 } //** end of the for() loop
478 /*End of Block for Draw*/
481 } //** end of the for loop for all the subwindow in the scope
483 /* Draw all short draw(s) in all the _concerned_ subwindows in a row :) */
484 sciDrawSetOfObj(pShortDrawTable, ShortDrawTableIndex );
485 scicos_free(pShortDrawTable);
487 for (i = 0 ; i < NumSubWin ; i++) //** for all the subwin in the scope
489 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,0);
490 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,0);
491 switch (sciGetEntityType(pShortDraw))
494 NbrPtsShort = pPOLYLINE_FEATURE(pShortDraw)->n1; //** this is incremented by one at each iteration
497 NbrPtsShort = pSEGS_FEATURE(pShortDraw)->Nbr1;
500 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
503 if (force_update[i] == 1) //** scope need a redraw
505 switch (sciGetEntityType(pLongDraw))
508 NbrPtsShort = pPOLYLINE_FEATURE(pShortDraw)->n1-1;
509 NbrPtsLong = pPOLYLINE_FEATURE(pLongDraw)->n1;
512 NbrPtsShort = pSEGS_FEATURE(pShortDraw)->Nbr1;
513 NbrPtsLong = pSEGS_FEATURE(pLongDraw)->Nbr1;
516 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
520 for (j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
522 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
523 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
526 * Alan's patch, 04/10/2007 : add NbrPtsToCopy to copy good numbers of pts for the first buffer in LongDraw +
527 * Tricks to handle the trace empty case
530 NbrPtsToCopy = NbrPtsShort + (NbrPtsLong==0);
532 switch (sciGetEntityType(pShortDraw))
535 NbrPtsToCopy = NbrPtsShort + (NbrPtsLong==0);
536 // We have draw but now we have to copy values in the memory of the shortdraw
537 C2F(dcopy)(&NbrPtsToCopy,pPOLYLINE_FEATURE(pShortDraw)->pvx+inc,&c__1,pPOLYLINE_FEATURE(pLongDraw)->pvx+NbrPtsLong,&c__1);
538 C2F(dcopy)(&NbrPtsToCopy,pPOLYLINE_FEATURE(pShortDraw)->pvy+inc,&c__1,pPOLYLINE_FEATURE(pLongDraw)->pvy+NbrPtsLong,&c__1);
539 pPOLYLINE_FEATURE(pLongDraw)->n1 = NbrPtsLong+NbrPtsToCopy;
542 C2F(dcopy)(&NbrPtsShort,pSEGS_FEATURE(pShortDraw)->vx,&c__1,pSEGS_FEATURE(pLongDraw)->vx+NbrPtsLong,&c__1);
543 C2F(dcopy)(&NbrPtsShort,pSEGS_FEATURE(pShortDraw)->vy,&c__1,pSEGS_FEATURE(pLongDraw)->vy+NbrPtsLong,&c__1);
544 pSEGS_FEATURE(pLongDraw)->Nbr1 = NbrPtsLong+NbrPtsShort;
545 pSEGS_FEATURE(pLongDraw)->Nbr2 = NbrPtsLong+NbrPtsShort;
548 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
551 /*End of Block for Memory*/
554 /* Block for Detecting redrawing of x-axis values and others activities*/
555 current_period_counter = (int)(t/scoGetPeriod(pScopeMemory,i));
556 // Maybe for the axes we are at the end of it - it is here that we detect and notify it
557 if (current_period_counter != scoGetPeriodCounter(pScopeMemory,i))
559 scoSetNewDraw(pScopeMemory,i,-1);
560 scoSetPeriodCounter(pScopeMemory,i,current_period_counter);
564 for (j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
566 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
567 switch (sciGetEntityType(pShortDraw))
570 /* Last point is next first point*/
571 pPOLYLINE_FEATURE(pShortDraw)->pvx[0] = pPOLYLINE_FEATURE(pShortDraw)->pvx[NbrPtsShort];
572 pPOLYLINE_FEATURE(pShortDraw)->pvy[0] = pPOLYLINE_FEATURE(pShortDraw)->pvy[NbrPtsShort];
573 pPOLYLINE_FEATURE(pShortDraw)->n1 = 1;
579 Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
585 pScopeMemory->d_last_scope_update_time = scoGetRealTime(); //** update the time stamping AFTER the draw
586 //** this "trick" assure at least 25ms of pure simulation (if the buffer is big enough)
588 } //** the scope has been updated
590 } //** for all the subwin
594 //**-------------------------------------------------------------------------------------------------------------
595 scoGraphicalObject scoCreatePolyline(scoGraphicalObject pAxes, scoInteger polyline_size, int color)
597 scoGraphicalObject pPolyline;
599 double * vx, * vy, *vz;
601 vx = (double*)scicos_malloc(polyline_size*sizeof(double));
602 vy = (double*)scicos_malloc(polyline_size*sizeof(double));
604 /* Alan, 29/09/07 : initial value set to zero for buffer
605 * to disable random display at the beginning of the simulation
607 for (i=0;i<polyline_size;i++) {
612 if (pSUBWIN_FEATURE(pAxes)->axes.axes_visible[2] == TRUE) //3D
614 vz = (double*)scicos_malloc(polyline_size*sizeof(double));
615 /* Alan, 29/09/07 : initial values set to zero for buffer
616 * to disable random display at the beginning of the simulation
618 for (i=0;i<polyline_size;i++) {
621 pPolyline=ConstructPolyline(pAxes,vx,vy,vz,0,polyline_size,1, NULL,NULL,NULL,NULL,NULL,FALSE,FALSE,TRUE,FALSE);
626 pPolyline=ConstructPolyline(pAxes,vx,vy,NULL,0,polyline_size,1, NULL,NULL,NULL,NULL,NULL,FALSE,FALSE,TRUE,FALSE);
632 pPOLYLINE_FEATURE(pPolyline)->n1 = 0;
636 sciSetForeground(pPolyline, color);
637 sciSetIsLine(pPolyline, 1);
638 sciSetLineStyle(pPolyline, 1);
639 sciSetMarkStyle(pPolyline, 0);
640 sciSetIsMark(pPolyline, 0);
644 sciSetMarkForeground(pPolyline, -1);
645 sciSetIsLine(pPolyline, 0);
646 sciSetLineStyle(pPolyline, 0);
647 sciSetIsMark(pPolyline, 1);
648 sciSetMarkSizeUnit(pPolyline, 1);
650 sciSetMarkStyle(pPolyline, -color);
651 sciSetMarkSize(pPolyline, 4);
654 sciSetMarkStyle(pPolyline, 11);
655 sciSetMarkSize(pPolyline, 0);
656 sciSetMarkBackground(pPolyline, -1);
659 sciSetIsClipping(pPolyline, 0);
665 /*--------------------------------------------------------------------------*/
666 void scoAddPolylineForShortDraw(ScopeMemory * pScopeMemory, int i, int j, int color)
668 scoGraphicalObject pShortDraw;
669 pShortDraw = scoCreatePolyline(scoGetPointerAxes(pScopeMemory,i),scoGetShortDrawSize(pScopeMemory,i),color);
670 scoSetHandleFromPointerShortDraw(pScopeMemory,i,j,pShortDraw);
672 /*--------------------------------------------------------------------------*/
673 void scoAddPolylineForLongDraw(ScopeMemory * pScopeMemory, int i, int j, int color)
676 scoGraphicalObject pLongDraw;
677 pLongDraw = scoCreatePolyline(scoGetPointerAxes(pScopeMemory,i),scoGetLongDrawSize(pScopeMemory,i),color);
678 scoSetHandleFromPointerLongDraw(pScopeMemory,i,j,pLongDraw);
681 /*--------------------------------------------------------------------------*/
682 void scoAddCoupleOfPolylines(ScopeMemory * pScopeMemory, int * colors)
686 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
687 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
689 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
693 scoAddPolylineForShortDraw(pScopeMemory,i,j,colors[j+1+inc]);
694 scoAddPolylineForLongDraw(pScopeMemory,i,j,colors[j+1+inc]);
698 scoAddPolylineForShortDraw(pScopeMemory,i,j,-1);
699 scoAddPolylineForLongDraw(pScopeMemory,i,j,-1);
702 inc = j+inc; //not +1 because of we have exited the loop
705 /*--------------------------------------------------------------------------*/
706 void scoDelCoupleOfPolylines(ScopeMemory * pScopeMemory)
710 scoGraphicalObject pLongDraw;
711 scoGraphicalObject pShortDraw;
712 int NbrPtsLong, NbrPtsShort;
713 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
714 if(scoGetPointerScopeWindow(pScopeMemory) != NULL)
716 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
718 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,0);
719 NbrPtsLong = pPOLYLINE_FEATURE(pLongDraw)->n1;
720 if(NbrPtsLong + scoGetShortDrawSize(pScopeMemory,i) > scoGetLongDrawSize(pScopeMemory,i))
722 //We realloc because maybe if we add the shortdraw the size would be bigger than the longdraw size
723 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
725 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
726 scoReallocLongDraw(pLongDraw, NbrPtsLong, scoGetShortDrawSize(pScopeMemory,i), 1000);
728 scoSetLongDrawSize(pScopeMemory,i,NbrPtsLong + scoGetShortDrawSize(pScopeMemory,i) + 1000);
731 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,0);
732 NbrPtsShort = pPOLYLINE_FEATURE(pShortDraw)->n1;
733 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,0);
734 NbrPtsLong = pPOLYLINE_FEATURE(pLongDraw)->n1;
736 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
738 pShortDraw = scoGetPointerShortDraw(pScopeMemory,i,j);
739 pLongDraw = scoGetPointerLongDraw(pScopeMemory,i,j);
740 //Here we copy values in memory
741 C2F(dcopy)(&NbrPtsShort,pPOLYLINE_FEATURE(pShortDraw)->pvx,&c__1,pPOLYLINE_FEATURE(pLongDraw)->pvx+NbrPtsLong,&c__1);
742 C2F(dcopy)(&NbrPtsShort,pPOLYLINE_FEATURE(pShortDraw)->pvy,&c__1,pPOLYLINE_FEATURE(pLongDraw)->pvy+NbrPtsLong,&c__1);
744 pPOLYLINE_FEATURE(pLongDraw)->n1 = NbrPtsLong + NbrPtsShort;
745 pPOLYLINE_FEATURE(pShortDraw)->n1 = 0;
746 //Destruction of the polyline - no presence in the menu editor anymore
747 DestroyPolyline(pShortDraw);
749 forceRedraw(pLongDraw);
752 //** sciSetUsedWindow(scoGetWindowID(pScopeMemory));
755 sciDrawObj(scoGetPointerScopeWindow(pScopeMemory));
756 //**redrawHierarchy(scoGetPointerScopeWindow(pScopeMemory));
759 /*--------------------------------------------------------------------------*/
760 void scoAddCoupleOfSegments(ScopeMemory * pScopeMemory, int * color)
764 double vx1[2], vy1[2];
767 scoGraphicalObject pShortDraw;
768 scoGraphicalObject pLongDraw;
769 scoGraphicalObject pAxes;
771 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
772 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
774 longdraw_size = scoGetLongDrawSize(pScopeMemory,i);
775 //ConstructSegs dont support for the moment the NULL parameter
781 vx2 = (double*)scicos_malloc(longdraw_size*sizeof(double));
782 vy2 = (double*)scicos_malloc(longdraw_size*sizeof(double));
784 for(j = 0 ; j < longdraw_size ; j++)
794 pAxes = scoGetPointerAxes(pScopeMemory,i);
796 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
799 /* Compute color of segments */
807 /* User specified color */
811 pLongDraw = ConstructSegs(pAxes, 0, vx2, vy2, NULL, longdraw_size, longdraw_size, 0, NULL, NULL,0,style, 0, TRUE, 0);
812 pSEGS_FEATURE(pLongDraw)->Nbr1 = 0;
813 pSEGS_FEATURE(pLongDraw)->Nbr2 = 0;
814 sciSetIsLine(pLongDraw, 1);
815 sciSetLineStyle(pLongDraw, 1);
816 sciSetMarkStyle(pLongDraw, 0);
817 sciSetIsMark(pLongDraw, 0);
818 sciSetIsClipping(pLongDraw, 0);
819 scoSetHandleFromPointerLongDraw(pScopeMemory,i,j,pLongDraw);
821 pShortDraw = ConstructSegs(pAxes, 0, vx1, vy1, NULL, 2, 2, 0, NULL, NULL,0,style, 0, TRUE, 0);
822 pSEGS_FEATURE(pShortDraw)->Nbr1 = 0;
823 pSEGS_FEATURE(pShortDraw)->Nbr2 = 0;
825 sciSetIsLine(pShortDraw, 1);
826 sciSetLineStyle(pShortDraw, 1);
827 sciSetMarkStyle(pShortDraw, 0);
828 sciSetIsMark(pShortDraw, 0);
829 sciSetIsClipping(pShortDraw, 0);
830 scoSetHandleFromPointerShortDraw(pScopeMemory,i,j,pShortDraw);
837 /*--------------------------------------------------------------------------*/
838 void scoDelCoupleOfSegments(ScopeMemory * pScopeMemory)
840 /* destroy all short draw */
843 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
845 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
847 sciDelGraphicObj(scoGetPointerShortDraw(pScopeMemory, i, j));
850 sciDrawObj(scoGetPointerScopeWindow(pScopeMemory));
852 /*--------------------------------------------------------------------------*/
853 scoGraphicalObject scoCreateSphere(scoGraphicalObject pAxes, double radius, int color)
855 scoGraphicalObject pSphere;
856 pSphere=ConstructArc(pAxes, 0, 0, radius, radius, 0, 23040, &color, &color, TRUE, FALSE);
859 /*--------------------------------------------------------------------------*/
860 void scoAddSphereForShortDraw(ScopeMemory * pScopeMemory, int i, int j, double radius, int color)
862 scoGraphicalObject pShortDraw;
863 pShortDraw = scoCreateSphere(scoGetPointerAxes(pScopeMemory,i),radius,color);
864 scoSetHandleFromPointerShortDraw(pScopeMemory,i,j,pShortDraw);
866 /*--------------------------------------------------------------------------*/
867 void scoAddSphereForLongDraw(ScopeMemory * pScopeMemory, int i, int j, double radius, int color)
869 scoGraphicalObject pLongDraw;
870 pLongDraw = scoCreateSphere(scoGetPointerAxes(pScopeMemory,i),radius,color);
871 scoSetHandleFromPointerLongDraw(pScopeMemory,i,j,pLongDraw);
873 /*--------------------------------------------------------------------------*/
874 void scoAddCoupleOfSpheres(ScopeMemory * pScopeMemory, double * radius, int * colors)
877 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
878 for (i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
880 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,i) ; j++)
884 scoAddSphereForShortDraw(pScopeMemory,i,j,radius[i+j], colors[i+j]);
885 scoAddSphereForLongDraw(pScopeMemory,i,j,radius[i+j], colors[i+j]);
889 scoAddSphereForShortDraw(pScopeMemory,i,j,1,1);
890 scoAddSphereForLongDraw(pScopeMemory,i,j,1,1);
895 /*--------------------------------------------------------------------------*/
896 scoGraphicalObject scoCreateRectangle(scoGraphicalObject pAxes, double x, double y, double width, double height)
898 scoGraphicalObject pRectangle;
899 pRectangle = ConstructRectangle(pAxes,x,y,height,width,NULL,NULL,0,1);
902 /*--------------------------------------------------------------------------*/
903 void scoAddRectangleForLongDraw(ScopeMemory * pScopeMemory, int i, int j, double x, double y, double width, double height)
905 scoGraphicalObject pLongDraw;
906 pLongDraw = scoCreateRectangle(scoGetPointerAxes(pScopeMemory,i),x,y,width,height);
907 scoSetHandleFromPointerLongDraw(pScopeMemory,i,j,pLongDraw);
909 /*--------------------------------------------------------------------------*/
910 void scoAddTitlesScope(ScopeMemory * pScopeMemory, char * label, char * x, char * y, char * z)
919 title = (char**)scicos_malloc(scoGetNumberOfSubwin(pScopeMemory)*sizeof(char*));
920 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
922 title[i] = (char*)scicos_malloc(20*sizeof(char)); //Why 20 ? BECAUSE :) should be less than 255
923 sprintf(title[i],"Graphic %d",i+1);
930 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
931 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
933 sciSetText(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_title,&title[i],1,1); /* 1,1 is nbrow, nbcol */
934 sciSetText(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_x_label,&x_title,1,1); /* 1,1 is nbrow, nbcol */
935 sciSetText(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_y_label,&y_title,1,1);/* 1,1 is nbrow, nbcol */
938 sciSetFontSize(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_x_label, 1);
939 sciSetFontSize(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_y_label, 1);
940 sciSetFontSize(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_title, 1);
941 forceRedraw(scoGetPointerAxes(pScopeMemory,i));
949 for(i = 0 ; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
951 sciSetFontSize(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_z_label, 1);
952 sciSetText(pSUBWIN_FEATURE(scoGetPointerAxes(pScopeMemory,i))->mon_z_label,&z_title,1,1); /* 1,1 is nbrow, nbcol */
955 for(i = 0; i < scoGetNumberOfSubwin(pScopeMemory) ; i++)
957 scicos_free(title[i]);
961 /* Code for naming the window*/
964 nxname = (int)strlen(label);
970 *(label + nxname) = *"\000";
971 if((nxname == 1 && *(unsigned char *)label == ' ') || (nxname ==0))
977 sciSetName(scoGetPointerScopeWindow(pScopeMemory), label);
979 /*End of code for naming window */
980 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
981 sciDrawObj(scoGetPointerScopeWindow(pScopeMemory));
982 //**redrawHierarchy(scoGetPointerScopeWindow(pScopeMemory));
984 /*--------------------------------------------------------------------------*/
985 void scoDrawScopeXYStyle(ScopeMemory * pScopeMemory)
987 /* 15/07/2009, S. Steer: efficiency improved by grouping the objects to be drawn */
989 scoGraphicalObject Pinceau; //Pencil
990 scoGraphicalObject Trait; //Line
991 int NbrPtsShort, NbrPtsLong;
994 int Ncurv = scoGetNumberOfCurvesBySubwin(pScopeMemory,0);
995 scoGraphicalObject *DrawTable = NULL;
996 int DrawTableIndex=0;
997 //Coded only for one subwin can be easily extended to many with a factorj , j < scoGetNumberOfSubwin()
999 /* Display the ShortDraw polylines which are filled */
1000 /* The loop on curv has been duplicated for efficiency reason:
1001 to be able to draw all the polyline in one call*/
1003 DrawTable = scicos_malloc( Ncurv * sizeof(scoGraphicalObject) );
1004 for(i = 0 ; i < Ncurv ;i++)
1006 Pinceau = scoGetPointerShortDraw(pScopeMemory,0,i);
1007 NbrPtsShort = pPOLYLINE_FEATURE(Pinceau)->n1;
1008 if(NbrPtsShort >= scoGetShortDrawSize(pScopeMemory,0)){
1009 DrawTable[ DrawTableIndex++]=Pinceau;
1012 if (DrawTableIndex>0) {
1013 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
1014 sciDrawSetOfObj(DrawTable,DrawTableIndex);
1016 scicos_free(DrawTable);
1018 /* Update the polylines */
1019 for(i = 0 ; i < Ncurv ;i++)
1021 Pinceau = scoGetPointerShortDraw(pScopeMemory,0,i);
1022 Trait = scoGetPointerLongDraw(pScopeMemory,0,i);
1024 NbrPtsShort = pPOLYLINE_FEATURE(Pinceau)->n1;
1025 if(NbrPtsShort >= scoGetShortDrawSize(pScopeMemory,0))
1027 NbrPtsLong = pPOLYLINE_FEATURE(Trait)->n1;
1028 /*Extend LongDraw polyline allocation if necessary */
1029 if(NbrPtsLong + NbrPtsShort >= scoGetLongDrawSize(pScopeMemory,0))
1031 for(j = 0 ; j < scoGetNumberOfCurvesBySubwin(pScopeMemory,0) ; j++)
1033 scoReallocLongDraw(scoGetPointerLongDraw(pScopeMemory,0,j), NbrPtsLong, NbrPtsShort, 5000);
1035 scoSetLongDrawSize(pScopeMemory, 0, NbrPtsLong + NbrPtsShort + 5000);
1037 NbrPtsLong = pPOLYLINE_FEATURE(Trait)->n1;
1039 /*Append the ShortDraw polyline points at the end of the LongDraw one */
1040 C2F(dcopy)(&NbrPtsShort,pPOLYLINE_FEATURE(Pinceau)->pvx,&c__1,pPOLYLINE_FEATURE(Trait)->pvx+NbrPtsLong,&c__1);
1041 C2F(dcopy)(&NbrPtsShort,pPOLYLINE_FEATURE(Pinceau)->pvy,&c__1,pPOLYLINE_FEATURE(Trait)->pvy+NbrPtsLong,&c__1);
1042 if(pPOLYLINE_FEATURE(Pinceau)->pvz != NULL)
1044 C2F(dcopy)(&NbrPtsShort,pPOLYLINE_FEATURE(Pinceau)->pvz,&c__1,pPOLYLINE_FEATURE(Trait)->pvz+NbrPtsLong,&c__1);
1046 pPOLYLINE_FEATURE(Trait)->n1 = NbrPtsLong + NbrPtsShort;
1047 /*reset the ShortDraw polyline */
1048 pPOLYLINE_FEATURE(Pinceau)->pvx[0] = pPOLYLINE_FEATURE(Pinceau)->pvx[NbrPtsShort-1];
1049 pPOLYLINE_FEATURE(Pinceau)->pvy[0] = pPOLYLINE_FEATURE(Pinceau)->pvy[NbrPtsShort-1];
1050 if(pPOLYLINE_FEATURE(Pinceau)->pvz != NULL)
1052 pPOLYLINE_FEATURE(Pinceau)->pvz[0] = pPOLYLINE_FEATURE(Pinceau)->pvz[NbrPtsShort-1];
1054 pPOLYLINE_FEATURE(Pinceau)->n1 = 1;
1058 /*--------------------------------------------------------------------------*/
1059 void scoDrawScopeAnimXYStyle(ScopeMemory * pScopeMemory, double * u1, double * u2, double * u3)
1060 /* 15/07/2009, S. Steer: efficiency improved by grouping the objects to be drawn */
1063 scoGraphicalObject Gomme; //Rubber
1064 scoGraphicalObject Pinceau; //Pencil
1065 scoGraphicalObject Trait; //Line
1067 scoGraphicalObject *DrawTable = NULL;
1069 /*If only one element to draw*/
1070 if(scoGetLongDrawSize(pScopeMemory,0) == 0)
1072 nbr_curves = scoGetNumberOfCurvesBySubwin(pScopeMemory,0);
1073 DrawTable = scicos_malloc( nbr_curves * sizeof(scoGraphicalObject) );
1074 for(i = 0 ; i < nbr_curves ; i++)
1076 Pinceau = scoGetPointerShortDraw(pScopeMemory,0,i);
1077 pPOLYLINE_FEATURE(Pinceau)->pvx[0] = u1[i];
1078 pPOLYLINE_FEATURE(Pinceau)->pvy[0] = u2[i];
1081 pPOLYLINE_FEATURE(Pinceau)->pvz[0] = u3[i];
1084 /* Draw all the objects in a single call for efficiency */
1085 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
1086 sciDrawSetOfObj(DrawTable,nbr_curves);
1087 scicos_free(DrawTable);
1089 else /*It is a polyline scope*/
1091 nbr_curves = scoGetNumberOfCurvesBySubwin(pScopeMemory,0)/2;
1092 DrawTable = scicos_malloc((2 * nbr_curves) * sizeof(scoGraphicalObject) );
1093 if(scoGetShortDrawSize(pScopeMemory,0) == 1)/*It is a mark style scope*/
1095 for(i = 0 ; i < nbr_curves ; i++)
1097 Pinceau = scoGetPointerShortDraw(pScopeMemory,0,i);
1098 Gomme = scoGetPointerShortDraw(pScopeMemory,0,i+nbr_curves);
1099 Trait = scoGetPointerLongDraw(pScopeMemory,0,i);
1101 pPOLYLINE_FEATURE(Gomme)->pvx[0] = pPOLYLINE_FEATURE(Trait)->pvx[scoGetLongDrawSize(pScopeMemory,0)-1];
1102 pPOLYLINE_FEATURE(Gomme)->pvy[0] = pPOLYLINE_FEATURE(Trait)->pvy[scoGetLongDrawSize(pScopeMemory,0)-1];
1104 for (j = scoGetLongDrawSize(pScopeMemory,0)-1 ; j > 0 ; j--)
1106 pPOLYLINE_FEATURE(Trait)->pvx[j] = pPOLYLINE_FEATURE(Trait)->pvx[j-1];
1107 pPOLYLINE_FEATURE(Trait)->pvy[j] = pPOLYLINE_FEATURE(Trait)->pvy[j-1];
1110 pPOLYLINE_FEATURE(Trait)->pvx[0] = pPOLYLINE_FEATURE(Pinceau)->pvx[0];
1111 pPOLYLINE_FEATURE(Trait)->pvy[0] = pPOLYLINE_FEATURE(Pinceau)->pvy[0];
1113 pPOLYLINE_FEATURE(Pinceau)->pvx[0] = u1[i];
1114 pPOLYLINE_FEATURE(Pinceau)->pvy[0] = u2[i];
1115 if(u3 != NULL) //3D scope
1117 pPOLYLINE_FEATURE(Gomme)->pvz[0] = pPOLYLINE_FEATURE(Trait)->pvz[scoGetLongDrawSize(pScopeMemory,0)-1];
1118 for (j = scoGetLongDrawSize(pScopeMemory,0)-1 ; j > 0 ; j--)
1120 pPOLYLINE_FEATURE(Trait)->pvz[j] = pPOLYLINE_FEATURE(Trait)->pvz[j-1];
1122 pPOLYLINE_FEATURE(Trait)->pvz[0] = pPOLYLINE_FEATURE(Pinceau)->pvz[0];
1123 pPOLYLINE_FEATURE(Pinceau)->pvz[0] = u3[i];
1126 /* memorize objects to be drawn */
1127 DrawTable[2*i] = Pinceau;
1128 DrawTable[2*i+1] = Gomme;
1131 /* Draw all the objects in one call for efficiency*/
1132 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
1133 sciDrawSetOfObj(DrawTable,2*nbr_curves);
1134 scicos_free(DrawTable);
1136 else /*It is a line style polyline scope*/
1138 nbr_curves = scoGetNumberOfCurvesBySubwin(pScopeMemory,0)/2;
1139 DrawTable = scicos_malloc((2 * nbr_curves) * sizeof(scoGraphicalObject) );
1141 for(i = 0 ; i < nbr_curves ; i++)
1143 Pinceau = scoGetPointerShortDraw(pScopeMemory,0,i);
1144 Gomme = scoGetPointerShortDraw(pScopeMemory,0,i+nbr_curves);
1145 Trait = scoGetPointerLongDraw(pScopeMemory,0,i);
1147 pPOLYLINE_FEATURE(Gomme)->pvx[0] = pPOLYLINE_FEATURE(Trait)->pvx[scoGetLongDrawSize(pScopeMemory,0)-1];
1148 pPOLYLINE_FEATURE(Gomme)->pvy[0] = pPOLYLINE_FEATURE(Trait)->pvy[scoGetLongDrawSize(pScopeMemory,0)-1];
1150 pPOLYLINE_FEATURE(Gomme)->pvx[1] = pPOLYLINE_FEATURE(Trait)->pvx[scoGetLongDrawSize(pScopeMemory,0)-2];
1151 pPOLYLINE_FEATURE(Gomme)->pvy[1] = pPOLYLINE_FEATURE(Trait)->pvy[scoGetLongDrawSize(pScopeMemory,0)-2];
1153 for (j = scoGetLongDrawSize(pScopeMemory,0)-1 ; j > 0 ; j--)
1155 pPOLYLINE_FEATURE(Trait)->pvx[j] = pPOLYLINE_FEATURE(Trait)->pvx[j-1];
1156 pPOLYLINE_FEATURE(Trait)->pvy[j] = pPOLYLINE_FEATURE(Trait)->pvy[j-1];
1159 pPOLYLINE_FEATURE(Trait)->pvx[0] = pPOLYLINE_FEATURE(Pinceau)->pvx[0];
1160 pPOLYLINE_FEATURE(Trait)->pvy[0] = pPOLYLINE_FEATURE(Pinceau)->pvy[0];
1162 pPOLYLINE_FEATURE(Pinceau)->pvx[1] = pPOLYLINE_FEATURE(Pinceau)->pvx[0];
1163 pPOLYLINE_FEATURE(Pinceau)->pvy[1] = pPOLYLINE_FEATURE(Pinceau)->pvy[0];
1165 pPOLYLINE_FEATURE(Pinceau)->pvx[0] = u1[i];
1166 pPOLYLINE_FEATURE(Pinceau)->pvy[0] = u2[i];
1167 if(u3 != NULL)//3D Scope Mode
1169 pPOLYLINE_FEATURE(Gomme)->pvz[0] = pPOLYLINE_FEATURE(Trait)->pvz[scoGetLongDrawSize(pScopeMemory,0)-1];
1170 pPOLYLINE_FEATURE(Gomme)->pvz[1] = pPOLYLINE_FEATURE(Trait)->pvz[scoGetLongDrawSize(pScopeMemory,0)-2];
1171 for (j = scoGetLongDrawSize(pScopeMemory,0)-1 ; j > 0 ; j--)
1173 pPOLYLINE_FEATURE(Trait)->pvz[j] = pPOLYLINE_FEATURE(Trait)->pvz[j-1];
1175 pPOLYLINE_FEATURE(Trait)->pvz[0] = pPOLYLINE_FEATURE(Pinceau)->pvz[0];
1176 pPOLYLINE_FEATURE(Pinceau)->pvz[1] = pPOLYLINE_FEATURE(Pinceau)->pvz[0];
1177 pPOLYLINE_FEATURE(Pinceau)->pvz[0] = u3[i];
1179 /* memorize objects to be drawn */
1180 DrawTable[2*i] = Pinceau;
1181 DrawTable[2*i+1] = Gomme;
1185 /* Draw all the objects in one call for efficiency*/
1186 sciSetUsedWindow(scoGetWindowID(pScopeMemory));
1187 sciDrawSetOfObj(DrawTable,2*nbr_curves);
1188 scicos_free(DrawTable);
1193 /*--------------------------------------------------------------------------*/
1194 scoGraphicalObject scoCreateGrayplot(scoGraphicalObject pAxes, int size_x, int size_y)
1196 scoGraphicalObject pGrayplot;
1197 double * pvecx = NULL, * pvecy = NULL, * pvecz = NULL;
1200 pvecx = (double*)scicos_malloc(size_x*sizeof(double));
1201 for(i = 0; i < size_x ; i++)
1204 pvecy = (double*)scicos_malloc(size_y*sizeof(double));
1205 for(i = 0; i < size_y ; i++)
1208 pvecz = (double*)scicos_malloc(size_x*size_y*sizeof(double));
1209 for(i = 0; i < size_x*size_y ; i++)
1212 pGrayplot = ConstructGrayplot(pAxes, pvecx, pvecy, pvecz, size_x, size_y, 0);
1220 /*--------------------------------------------------------------------------*/
1221 void scoAddGrayplotForShortDraw(ScopeMemory * pScopeMemory, int i, int j, int size_x, int size_y)
1223 scoGraphicalObject pShortDraw;
1224 pShortDraw = scoCreateGrayplot(scoGetPointerAxes(pScopeMemory,i),size_x,size_y);
1225 scoSetHandleFromPointerShortDraw(pScopeMemory,i,j,pShortDraw);
1227 /*--------------------------------------------------------------------------*/
1228 scoGraphicalObject scoCreatePlot3d(scoGraphicalObject pAxes, int size_x, int size_y)
1230 scoGraphicalObject pPlot3d;
1231 double * pvecx = NULL, * pvecy = NULL, *pvecz = NULL;
1236 int m1 = 0,n1 = 0,m2 = 0,n2 = 0,m3 = 0,n3 = 0,m3n = 0,n3n = 0;
1239 pvecx = (double*)scicos_malloc(size_x*sizeof(double));
1240 for(i = 0; i < size_x ; i++)
1243 pvecy = (double*)scicos_malloc(size_y*sizeof(double));
1244 for(i = 0; i < size_y ; i++)
1247 pvecz = (double*)scicos_malloc(size_x*size_y*sizeof(double));
1248 for(i = 0; i < size_x*size_y ; i++)
1251 //I have found all these values thanks to gdb and debugging a demo of scilab with a grayplot. I don't know exactly what they are and I don't care :p
1276 pPlot3d = ConstructSurface (pAxes, SCI_PLOT3D, pvecx, pvecy, pvecz, NULL, 0, size_x, size_y, flag, ebox, colorflag, &isfac, &m1, &n1, &m2, &n2, &m3, &n3, &m3n, &n3n);
1284 /*--------------------------------------------------------------------------*/
1285 void scoAddPlot3dForShortDraw(ScopeMemory * pScopeMemory, int i, int j, int size_x, int size_y)
1287 scoGraphicalObject pShortDraw;
1288 pShortDraw = scoCreatePlot3d(scoGetPointerAxes(pScopeMemory,i),size_x,size_y);
1289 scoSetHandleFromPointerShortDraw(pScopeMemory,i,j,pShortDraw);
1291 /*--------------------------------------------------------------------------*/