00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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 "InitObjects.h"
00021 #include "SetProperty.h"
00022 #include "GetProperty.h"
00023 #include "bcg.h"
00024 #include "PloEch.h"
00025 #include "Axes.h"
00026 #include "DestroyObjects.h"
00027 #include "CloneObjects.h"
00028 #include "BuildObjects.h"
00029 #include "Xcall1.h"
00030 #include "sciprint.h"
00031 #include "CurrentObjectsManagement.h"
00032 #include "ObjectSelection.h"
00033
00034 #include "MALLOC.h"
00035
00036 static char error_message[70];
00037 extern unsigned short defcolors[];
00038
00039 static sciPointObj * pfiguremdl = (sciPointObj *) NULL;
00040 static sciPointObj * paxesmdl = (sciPointObj *) NULL;
00041
00042 sciPointObj * getFigureModel( void )
00043 {
00044 return pfiguremdl ;
00045 }
00046
00047 sciPointObj * getAxesModel( void )
00048 {
00049 return paxesmdl ;
00050 }
00051
00052
00053
00054 int C2F(graphicsmodels) (void)
00055 {
00056 sciHandleTab * newhd1 ;
00057 sciHandleTab * newhd2 ;
00058 sciSubWindow * ppaxesmdl = NULL ;
00059
00060 if ((pfiguremdl = MALLOC ((sizeof (sciPointObj)))) == NULL)
00061 {
00062 strcpy(error_message,"Default figure cannot be create");
00063 return 0;
00064 }
00065 sciSetEntityType (pfiguremdl, SCI_FIGURE);
00066 if ((pfiguremdl->pfeatures = MALLOC ((sizeof (sciFigure)))) == NULL)
00067 {
00068 FREE(pfiguremdl);
00069 strcpy(error_message,"Default figure cannot be create");
00070 return 0;
00071 }
00072
00073 if ((newhd1 = MALLOC ((sizeof (sciHandleTab)))) == NULL)
00074 {
00075 FREE(pfiguremdl->pfeatures);
00076 FREE(pfiguremdl);
00077 strcpy(error_message,"Default figure cannot be create");
00078 return 0;
00079 }
00080 newhd1->pnext = (sciHandleTab *) NULL;
00081 newhd1->pprev = (sciHandleTab *) NULL;
00082 newhd1->index = (long)pfiguremdl;
00083 (sciGetRelationship (pfiguremdl))->phandle = newhd1;
00084
00085 if (!(sciAddThisToItsParent(pfiguremdl, (sciPointObj *)NULL)))
00086 {
00087 sciDelHandle (pfiguremdl);
00088 FREE(pfiguremdl->pfeatures);
00089 FREE(pfiguremdl);
00090 strcpy(error_message,"Default figure cannot be create");
00091 return 0;
00092 }
00093
00094 sciInitSelectedSons( pfiguremdl ) ;
00095
00096 pFIGURE_FEATURE (pfiguremdl)->relationship.psons = (sciSons *) NULL;
00097 pFIGURE_FEATURE (pfiguremdl)->relationship.plastsons = (sciSons *) NULL;
00098
00099
00100 if ( InitFigureModel() < 0 )
00101 {
00102 sciDelHandle (pfiguremdl);
00103 FREE(pfiguremdl->pfeatures);
00104 FREE(pfiguremdl);
00105 strcpy(error_message,"Default figure cannot be create");
00106 return 0;
00107 }
00108
00109
00110
00111
00112
00113 if ((paxesmdl = MALLOC ((sizeof (sciPointObj)))) == NULL)
00114 {
00115 strcpy(error_message,"Default axes cannot be create");
00116 return 0;
00117 }
00118 sciSetEntityType (paxesmdl, SCI_SUBWIN);
00119 if ((paxesmdl->pfeatures = MALLOC ((sizeof (sciSubWindow)))) == NULL)
00120 {
00121 FREE(paxesmdl);
00122 strcpy(error_message,"Default axes cannot be create");
00123 return 0;
00124 }
00125 if ((newhd2 = MALLOC ((sizeof (sciHandleTab)))) == NULL)
00126 {
00127 FREE(paxesmdl->pfeatures);
00128 FREE(paxesmdl);
00129 strcpy(error_message,"Default axes cannot be create");
00130 return 0;
00131 }
00132 newhd2->pnext = (sciHandleTab *) NULL;
00133 newhd2->pprev = (sciHandleTab *) NULL;
00134 newhd2->index = (long)paxesmdl;
00135 (sciGetRelationship (paxesmdl))->phandle = newhd2;
00136
00137 if (!(sciAddThisToItsParent (paxesmdl, pfiguremdl)))
00138 {
00139 sciDelHandle (paxesmdl);
00140 FREE(paxesmdl->pfeatures);
00141 FREE(paxesmdl);
00142 strcpy(error_message,"Default axes cannot be create");
00143 return 0;
00144 }
00145
00146 ppaxesmdl = pSUBWIN_FEATURE (paxesmdl);
00147
00148 sciInitSelectedSons( paxesmdl ) ;
00149 ppaxesmdl->relationship.psons = (sciSons *) NULL;
00150 ppaxesmdl->relationship.plastsons = (sciSons *) NULL;
00151
00152 if ( InitAxesModel() < 0 )
00153 {
00154 sciDelThisToItsParent (paxesmdl, sciGetParent (paxesmdl));
00155 sciDelHandle (paxesmdl);
00156 FREE(paxesmdl->pfeatures);
00157 FREE(paxesmdl);
00158 strcpy(error_message,"Default axes cannot be create");
00159 return 0;
00160 }
00161
00162
00163
00164
00165 ppaxesmdl->FirstPlot = TRUE;
00166 ppaxesmdl->with_leg = 0;
00167
00168 ppaxesmdl->ARect[0] = 0.125;
00169 ppaxesmdl->ARect[1] = 0.125;
00170 ppaxesmdl->ARect[2] = 0.125;
00171 ppaxesmdl->ARect[3] = 0.125;
00172
00173 ppaxesmdl->clip_region[0] = 0.;
00174 ppaxesmdl->clip_region[1] = 0.;
00175 ppaxesmdl->clip_region[2] = 0.;
00176 ppaxesmdl->clip_region[3] = 0.;
00177
00178
00179 ppaxesmdl->clip_region_set = 0 ;
00180
00181
00182
00183
00184 return 1;
00185 }
00186
00187
00191 int
00192 sciInitGraphicContext (sciPointObj * pobj)
00193 {
00194
00195
00196
00197
00198
00199
00200 switch (sciGetEntityType (pobj))
00201 {
00202 case SCI_FIGURE:
00203 if ( pobj == pfiguremdl )
00204 {
00205 (sciGetGraphicContext(pobj))->backgroundcolor = -3;
00206 (sciGetGraphicContext(pobj))->foregroundcolor = -2;
00207 (sciGetGraphicContext(pobj))->fillstyle = HS_HORIZONTAL;
00208 (sciGetGraphicContext(pobj))->fillcolor = (sciGetGraphicContext(pobj))->backgroundcolor;
00209 (sciGetGraphicContext(pobj))->linewidth = 1;
00210 (sciGetGraphicContext(pobj))->linestyle = PS_SOLID;
00211 (sciGetGraphicContext(pobj))->ismark = FALSE;
00212 (sciGetGraphicContext(pobj))->isline = TRUE;
00213 (sciGetGraphicContext(pobj))->markstyle = 0;
00214 (sciGetGraphicContext(pobj))->marksize = 0 ;
00215 (sciGetGraphicContext(pobj))->markbackground = -3;
00216 (sciGetGraphicContext(pobj))->markforeground = -2;
00217 (sciGetGraphicContext(pobj))->marksizeunit = 2;
00218 }
00219 else
00220 {
00221 cloneGraphicContext( pfiguremdl, pobj ) ;
00222 }
00223 return 0;
00224 break;
00225 case SCI_SUBWIN:
00226 if ( pobj == paxesmdl )
00227 {
00228 cloneGraphicContext( sciGetParent (pobj), pobj ) ;
00229 sciGetGraphicContext(pobj)->backgroundcolor = -3 ;
00230 sciGetGraphicContext(pobj)->foregroundcolor = -2 ;
00231 sciGetGraphicContext(pobj)->markbackground = -3 ;
00232 sciGetGraphicContext(pobj)->markforeground = -2 ;
00233 }
00234 else
00235 {
00236 cloneGraphicContext( paxesmdl, pobj ) ;
00237 }
00238 return 0;
00239 break;
00240 case SCI_ARC:
00241 case SCI_SEGS:
00242 case SCI_FEC:
00243 case SCI_GRAYPLOT:
00244 case SCI_POLYLINE:
00245 case SCI_RECTANGLE:
00246 case SCI_SURFACE:
00247 case SCI_LIGHT:
00248 case SCI_AXES:
00249 case SCI_MENU:
00250 case SCI_MENUCONTEXT:
00251 case SCI_STATUSB:
00252 case SCI_LEGEND:
00253 case SCI_TEXT:
00254 cloneGraphicContext( sciGetParent (pobj), pobj ) ;
00255 return 0;
00256 break;
00257 case SCI_LABEL:
00258 if ( sciGetParent(pobj) == paxesmdl )
00259 {
00260
00261 cloneGraphicContext( sciGetParent( pobj ), pobj ) ;
00262 return 0;
00263 }
00264 else
00265 {
00266 sciPointObj * plabelmdl = NULL ;
00267 switch ( pLABEL_FEATURE(pobj)->ptype )
00268 {
00269 case 1:
00270 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_title;
00271 break ;
00272 case 2:
00273 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_x_label;
00274 break ;
00275 case 3:
00276 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_y_label;
00277 break ;
00278 case 4:
00279 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_z_label;
00280 break ;
00281 default:
00282
00283 return -1 ;
00284 break ;
00285 }
00286 cloneGraphicContext( plabelmdl, pobj ) ;
00287 return 0 ;
00288 }
00289 case SCI_AGREG:
00290 case SCI_TITLE:
00291 case SCI_PANNER:
00292 case SCI_SBH:
00293 case SCI_SBV:
00294 case SCI_UIMENU:
00295 default:
00296 return -1;
00297 break;
00298 }
00299 return 0;
00300 }
00301
00307 int initFCfromCopy( sciPointObj * pObjSource, sciPointObj * pObjDest )
00308 {
00309 sciGetFontContext( pObjDest )->fontnamelen = 0 ;
00310 sciGetFontContext( pObjDest )->pfontname = NULL ;
00311 return cloneFontContext( pObjSource, pObjDest ) ;
00312 }
00313
00318 int
00319 sciInitFontContext (sciPointObj * pobj)
00320 {
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 switch (sciGetEntityType (pobj))
00335 {
00336 case SCI_TEXT:
00337 case SCI_TITLE:
00338 case SCI_LEGEND:
00339 case SCI_AXES:
00340 case SCI_MENU:
00341 case SCI_MENUCONTEXT:
00342 case SCI_STATUSB:
00343 {
00344 initFCfromCopy( sciGetParent(pobj), pobj ) ;
00345 }
00346 break;
00347 case SCI_LABEL:
00348 if ( sciGetParent(pobj) == paxesmdl )
00349 {
00350 initFCfromCopy( sciGetParent(pobj), pobj ) ;
00351 }
00352 else
00353 {
00354 sciPointObj * plabelmdl = NULL;
00355
00356 if(pLABEL_FEATURE(pobj)->ptype == 1)
00357 {
00358 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_title;
00359 }
00360 else if(pLABEL_FEATURE(pobj)->ptype == 2)
00361 {
00362 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_x_label;
00363 }
00364 else if(pLABEL_FEATURE(pobj)->ptype == 3)
00365 {
00366 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_y_label;
00367 }
00368 else if(pLABEL_FEATURE(pobj)->ptype == 4)
00369 {
00370 plabelmdl = pSUBWIN_FEATURE(paxesmdl)->mon_z_label;
00371 }
00372
00373 initFCfromCopy( plabelmdl, pobj ) ;
00374
00375 }
00376 break;
00377 case SCI_SUBWIN:
00378 if (pobj == paxesmdl)
00379 {
00380 initFCfromCopy( sciGetParent( pobj ), pobj ) ;
00381 }
00382 else
00383 {
00384 initFCfromCopy( paxesmdl, pobj ) ;
00385 }
00386 break;
00387 case SCI_FIGURE:
00388 if (pobj == pfiguremdl)
00389 {
00390 sciInitFontStyle (pobj, 6);
00391 (sciGetFontContext(pobj))->backgroundcolor = -3;
00392 (sciGetFontContext(pobj))->foregroundcolor = -2;
00393 (sciGetFontContext(pobj))->fontdeciwidth = 100;
00394 (sciGetFontContext(pobj))->textorientation = 0;
00395 (sciGetFontContext(pobj))->fontnamelen=1;
00396
00397 if (
00398 ((sciGetFontContext(pobj))->pfontname = CALLOC ((sciGetFontContext(pobj))->fontnamelen + 1,
00399 sizeof (char))) == NULL)
00400 {
00401 sciprint ("No more Memory for fontname\n");
00402 return 0;
00403 }
00404
00405 }
00406 else
00407 {
00408 initFCfromCopy( pfiguremdl, pobj ) ;
00409 }
00410 break;
00411 case SCI_PANNER:
00412 case SCI_SBH:
00413 case SCI_SBV:
00414 case SCI_ARC:
00415 case SCI_SEGS:
00416 case SCI_FEC:
00417 case SCI_GRAYPLOT:
00418 case SCI_POLYLINE:
00419 case SCI_RECTANGLE:
00420 case SCI_SURFACE:
00421 case SCI_LIGHT:
00422 case SCI_AGREG:
00423 case SCI_UIMENU:
00424 default:
00425 return -1;
00426 break;
00427 }
00428 return 0;
00429 }
00430
00431 void initsubwin()
00432 {
00433 sciPointObj * psubwin ;
00434 sciSubWindow * ppSubWin ;
00435
00436
00437 Cscale2default();
00438 psubwin = sciGetCurrentSubWin();
00439 ppSubWin = pSUBWIN_FEATURE (psubwin) ;
00440
00441
00442 initSubWinSize( psubwin ) ;
00443
00444 clearUserData( psubwin ) ;
00445
00446 reinitSubWin( psubwin ) ;
00447
00448 (ppSubWin->axes).axes_visible[0] = FALSE;
00449 (ppSubWin->axes).axes_visible[1] = FALSE;
00450 (ppSubWin->axes).axes_visible[2] = FALSE;
00451
00452 (ppSubWin->axes).reverse[0] = FALSE;
00453 (ppSubWin->axes).reverse[1] = FALSE;
00454 (ppSubWin->axes).reverse[2] = FALSE;
00455
00456 ppSubWin->axes.rect = BT_OFF;
00457 ppSubWin->axes.ticscolor = -1;
00458 ppSubWin->axes.subint[0] = 1;
00459 ppSubWin->axes.subint[1] = 1;
00460 ppSubWin->axes.subint[2] = 1;
00461 ppSubWin->axes.limits[0] = 0;
00462
00463 }
00464
00465 int InitFigureModel( void )
00466 {
00467 int i ;
00468 int m = NUMCOLORS_SCI ;
00469
00470 pFIGURE_FEATURE (pfiguremdl)->allredraw = FALSE;
00471
00472 if ( sciInitGraphicContext(pfiguremdl) < 0 )
00473 {
00474 return -1 ;
00475 }
00476 if ( sciInitGraphicMode(pfiguremdl) < 0 )
00477 {
00478 return -1 ;
00479 }
00480 if ( sciInitFontContext(pfiguremdl) < 0)
00481 {
00482
00483 return -1 ;
00484 }
00485 strncpy (pFIGURE_FEATURE (pfiguremdl)->name, "Scilab Graphic", sizeof ("Scilab Graphic") + 4);
00486 pFIGURE_FEATURE (pfiguremdl)->namelen = Min (sizeof ("Scilab Graphic") + 4, 14);
00487 pFIGURE_FEATURE (pfiguremdl)->number = 0 ;
00488 pFIGURE_FEATURE (pfiguremdl)->figuredimwidth = 610 ;
00489 pFIGURE_FEATURE (pfiguremdl)->figuredimheight = 461 ;
00490 pFIGURE_FEATURE (pfiguremdl)->windowdimwidth = 600 ;
00491 pFIGURE_FEATURE (pfiguremdl)->windowdimheight = 400 ;
00492 pFIGURE_FEATURE (pfiguremdl)->inrootposx = 200 ;
00493 pFIGURE_FEATURE (pfiguremdl)->inrootposy = 200 ;
00494
00495 if((pFIGURE_FEATURE(pfiguremdl)->pcolormap = (double *) MALLOC (m * 3 * sizeof (double))) == (double *) NULL)
00496 {
00497 strcpy(error_message,"Cannot init color map");
00498 return -1 ;
00499 }
00500 for (i= 0 ; i < m ; i++)
00501 {
00502 pFIGURE_FEATURE(pfiguremdl)->pcolormap[i] = (double) (defcolors[3*i]/255.0);
00503 pFIGURE_FEATURE(pfiguremdl)->pcolormap[i+m] = (double) (defcolors[3*i+1]/255.0);
00504 pFIGURE_FEATURE(pfiguremdl)->pcolormap[i+2*m] = (double) (defcolors[3*i+2]/255.0);
00505 }
00506
00507 pFIGURE_FEATURE (pfiguremdl)->numcolors = m;
00508 pFIGURE_FEATURE (pfiguremdl)->isiconified = FALSE;
00509 pFIGURE_FEATURE (pfiguremdl)->isselected = TRUE;
00510 pFIGURE_FEATURE (pfiguremdl)->rotstyle = 0;
00511 pFIGURE_FEATURE (pfiguremdl)->visible = TRUE;
00512 pFIGURE_FEATURE (pfiguremdl)->auto_redraw = TRUE;
00513
00514 pFIGURE_FEATURE (pfiguremdl)->user_data = (int *) NULL;
00515 pFIGURE_FEATURE (pfiguremdl)->size_of_user_data = 0;
00516
00517 pFIGURE_FEATURE (pfiguremdl)->numsubwinselected = 0;
00518 pFIGURE_FEATURE (pfiguremdl)->pixmap = 0 ;
00519 pFIGURE_FEATURE (pfiguremdl)->wshow = 0 ;
00520
00521 pFIGURE_FEATURE(pfiguremdl)->infoMessage = NULL ;
00522 sciSetInfoMessage( pfiguremdl, "" ) ;
00523
00524 return 0;
00525 }
00526
00527
00528
00529 int InitAxesModel()
00530 {
00531 int i;
00532 double tab[] = {0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.};
00533 sciPointObj * pobj = NULL;
00534 sciSubWindow * ppobj = NULL;
00535 sciSubWindow * ppaxesmdl = pSUBWIN_FEATURE (paxesmdl);
00536
00537 sciInitGraphicContext (paxesmdl);
00538 sciInitGraphicMode (paxesmdl);
00539 sciInitFontContext (paxesmdl);
00540 ppaxesmdl->cube_scaling = FALSE;
00541 ppaxesmdl->callback = (char *)NULL;
00542 ppaxesmdl->callbacklen = 0;
00543 ppaxesmdl->callbackevent = 100;
00544 ppaxesmdl->logflags[0] = 'n';
00545 ppaxesmdl->logflags[1] = 'n';
00546 ppaxesmdl->logflags[2] = 'n';
00547 ppaxesmdl->axes.ticscolor = -1;
00548 ppaxesmdl->axes.subint[0] = 1;
00549 ppaxesmdl->axes.subint[1] = 1;
00550 ppaxesmdl->axes.subint[2] = 1;
00551 ppaxesmdl->axes.xdir='d';
00552 ppaxesmdl->axes.ydir='l';
00553 ppaxesmdl->axes.rect = BT_OFF;
00554
00555 ppaxesmdl->user_data = (int *) NULL;
00556 ppaxesmdl->size_of_user_data = 0;
00557
00558 for (i=0 ; i<7 ; i++)
00559 {
00560 ppaxesmdl->axes.limits[i] = 0;
00561 }
00562
00563 for (i=0 ; i<3 ; i++)
00564 {
00565 ppaxesmdl->grid[i] = -1;
00566 }
00567
00568 ppaxesmdl->alpha = 0.0;
00569 ppaxesmdl->theta = 270.0;
00570 ppaxesmdl->alpha_kp = 45.0;
00571 ppaxesmdl->theta_kp = 215.0;
00572 ppaxesmdl->is3d = FALSE;
00573
00574 for (i=0 ; i<4 ; i++)
00575 {
00576 ppaxesmdl->axes.xlim[i]= Cscale.xtics[i];
00577 ppaxesmdl->axes.ylim[i]= Cscale.ytics[i];
00578 }
00579
00580
00581 (ppaxesmdl->axes).axes_visible[0] = FALSE;
00582 (ppaxesmdl->axes).axes_visible[1] = FALSE;
00583 (ppaxesmdl->axes).axes_visible[2] = FALSE;
00584 (ppaxesmdl->axes).reverse[0] = FALSE;
00585 (ppaxesmdl->axes).reverse[1] = FALSE;
00586 (ppaxesmdl->axes).reverse[2] = FALSE;
00587 ppaxesmdl->flagNax = FALSE;
00588
00589
00590 ppaxesmdl->axes.nbsubtics[0] = 1;
00591 ppaxesmdl->axes.nbsubtics[1] = 1;
00592 ppaxesmdl->axes.nbsubtics[2] = 1;
00593
00594 (ppaxesmdl->axes).nxgrads = 11;
00595 (ppaxesmdl->axes).nygrads = 11;
00596 (ppaxesmdl->axes).nzgrads = 3;
00597
00598 for(i=0;i<11;i++)
00599 {
00600 ppaxesmdl->axes.xgrads[i] = tab[i];
00601 }
00602
00603 for(i=0;i<11;i++)
00604 {
00605 ppaxesmdl->axes.ygrads[i] = tab[i];
00606 }
00607
00608 (ppaxesmdl->axes).zgrads[0] = -1.;
00609 (ppaxesmdl->axes).zgrads[1] = 0.;
00610 (ppaxesmdl->axes).zgrads[2] = 1.;
00611
00612 (ppaxesmdl->axes).u_xgrads = (double *)NULL;
00613 (ppaxesmdl->axes).u_ygrads = (double *)NULL;
00614 (ppaxesmdl->axes).u_zgrads = (double *)NULL;
00615 (ppaxesmdl->axes).u_nxgrads = 0;
00616 (ppaxesmdl->axes).u_nygrads = 0;
00617 (ppaxesmdl->axes).u_nzgrads = 0;
00618 (ppaxesmdl->axes).u_xlabels= (char **) NULL;
00619 (ppaxesmdl->axes).u_ylabels= (char **) NULL;
00620 (ppaxesmdl->axes).u_zlabels= (char **) NULL;
00621
00622 (ppaxesmdl->axes).auto_ticks[0] = TRUE;
00623 (ppaxesmdl->axes).auto_ticks[1] = TRUE;
00624 (ppaxesmdl->axes).auto_ticks[2] = TRUE;
00625
00626
00627 ppaxesmdl->axes.zlim[0]= -1.0;
00628 ppaxesmdl->axes.zlim[1]= 1.0;
00629 ppaxesmdl->axes.flag[0]= 2;
00630 ppaxesmdl->axes.flag[1]= 2;
00631 ppaxesmdl->axes.flag[2]= 4;
00632 ppaxesmdl->axes.hiddenAxisColor = 4 ;
00633 ppaxesmdl->project[0]= 1;
00634 ppaxesmdl->project[1]= 1;
00635 ppaxesmdl->project[2]= 0;
00636 ppaxesmdl->hiddencolor=4;
00637 ppaxesmdl->hiddenstate=0;
00638 ppaxesmdl->isoview= FALSE;
00639
00640 ppaxesmdl->facetmerge = FALSE;
00641 ppaxesmdl->WRect[0] = 0;
00642 ppaxesmdl->WRect[1] = 0;
00643 ppaxesmdl->WRect[2] = 1;
00644 ppaxesmdl->WRect[3] = 1;
00645 ppaxesmdl->FRect[0] = 0.0;
00646 ppaxesmdl->FRect[1] = 0.0;
00647 ppaxesmdl->FRect[2] = 1.0;
00648 ppaxesmdl->FRect[3] = 1.0;
00649 ppaxesmdl->FRect[4] = -1.0;
00650 ppaxesmdl->FRect[5] = 1.0;
00651 ppaxesmdl->visible = sciGetVisibility(pfiguremdl);
00652
00653
00654
00655 ppaxesmdl->isclip = -1;
00656 ppaxesmdl->pPopMenu = (sciPointObj *)NULL;
00657
00658
00659
00660 ppaxesmdl->SRect[0] = 0.0;
00661 ppaxesmdl->SRect[1] = 1.0;
00662 ppaxesmdl->SRect[2] = 0.0;
00663 ppaxesmdl->SRect[3] = 1.0;
00664 ppaxesmdl->SRect[4] = -1.0;
00665 ppaxesmdl->SRect[5] = 1.0;
00666
00667 ppaxesmdl->tight_limits = FALSE;
00668
00669
00670
00671
00672
00673 pobj = paxesmdl;
00674 ppobj = pSUBWIN_FEATURE(paxesmdl);
00675
00676
00677
00678 ppobj->mon_title = initLabel( paxesmdl ) ;
00679
00680 if ( ppobj->mon_title == NULL )
00681 {
00682 return -1 ;
00683 }
00684
00685 pLABEL_FEATURE(ppobj->mon_title)->ptype = 1;
00686
00687
00688
00689 ppobj->mon_x_label = initLabel( paxesmdl ) ;
00690
00691 if ( ppobj->mon_x_label == NULL )
00692 {
00693 return -1 ;
00694 }
00695
00696 pLABEL_FEATURE( ppobj->mon_x_label )->ptype = 2 ;
00697
00698
00699
00700 ppobj->mon_y_label = initLabel( paxesmdl ) ;
00701
00702 if ( ppobj->mon_y_label == NULL )
00703 {
00704 return -1 ;
00705 }
00706
00707 pLABEL_FEATURE( ppobj->mon_y_label )->ptype = 3 ;
00708
00709
00710
00711 ppobj->mon_z_label = initLabel( paxesmdl ) ;
00712
00713 if ( ppobj->mon_z_label == NULL )
00714 {
00715 return -1 ;
00716 }
00717
00718 pLABEL_FEATURE( ppobj->mon_z_label )->ptype = 4 ;
00719
00720 return 0;
00721 }
00722
00723
00724
00725 int ResetFigureToDefaultValues(sciPointObj * pobj)
00726 {
00727
00728 integer x[2], verbose=0, narg=0;
00729 struct BCG *XGC=NULL;
00730 int succeed = 0;
00731
00732
00733 if(sciGetEntityType(pobj)!=SCI_FIGURE)
00734 return -1;
00735
00736 XGC = pFIGURE_FEATURE (pobj)->pScilabXgc;
00737
00738 pFIGURE_FEATURE (pobj)->relationship.psons = (sciSons *) NULL;
00739 pFIGURE_FEATURE (pobj)->relationship.plastsons = (sciSons *) NULL;
00740
00742
00743
00744 pFIGURE_FEATURE (pobj)->pcolormap = NULL ;
00745 sciInitNumColors(pobj, 0) ;
00746
00747 sciSetColormap( pobj, pFIGURE_FEATURE(pfiguremdl)->pcolormap, sciGetNumColors(pfiguremdl), 3 ) ;
00748
00749
00750
00751 if (sciInitGraphicContext (pobj) == -1)
00752 {
00753 sciDelHandle (pobj);
00754 FREE(pFIGURE_FEATURE(pobj)->pcolormap);
00755 FREE(pobj->pfeatures);
00756 FREE(pobj);
00757 return -1;
00758 }
00759 if (sciInitGraphicMode (pobj) == -1)
00760 {
00761 sciDelHandle (pobj);
00762 FREE(pFIGURE_FEATURE(pobj)->pcolormap);
00763 FREE(pobj->pfeatures);
00764 FREE(pobj);
00765 return -1;
00766 }
00767
00768
00769 if (sciInitFontContext (pobj) == -1)
00770 {
00771 sciDelHandle (pobj);
00772 FREE(pobj->pfeatures);
00773 FREE(pobj);
00774 return -1;
00775 }
00776 sciSetNum (pobj, &(XGC->CurWindow));
00777 sciSetName(pobj, sciGetName(pfiguremdl), sciGetNameLength(pfiguremdl));
00778 sciSetResize((sciPointObj *) pobj,sciGetResize(pobj));
00779 pFIGURE_FEATURE(pobj)->windowdimwidth=pFIGURE_FEATURE(pfiguremdl)->windowdimwidth;
00780 pFIGURE_FEATURE(pobj)->windowdimheight=pFIGURE_FEATURE(pfiguremdl)->windowdimheight;
00781 C2F(dr)("xset","wdim",&(pFIGURE_FEATURE(pobj)->windowdimwidth),
00782 &(pFIGURE_FEATURE(pobj)->windowdimheight),PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00783 pFIGURE_FEATURE (pobj)->figuredimwidth = pFIGURE_FEATURE (pfiguremdl)->figuredimwidth;
00784 pFIGURE_FEATURE (pobj)->figuredimheight = pFIGURE_FEATURE (pfiguremdl)->figuredimheight;
00785 C2F(dr)("xset","wpdim",&(pFIGURE_FEATURE(pobj)->figuredimwidth),
00786 &(pFIGURE_FEATURE(pobj)->figuredimheight),PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00787 C2F(dr)("xget","wpos",&verbose,x,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,4L,4L);
00788 x[0]=(pFIGURE_FEATURE (pfiguremdl)->inrootposx <0)?x[0]:pFIGURE_FEATURE (pfiguremdl)->inrootposx;
00789 x[1]=(pFIGURE_FEATURE (pfiguremdl)->inrootposy <0)?x[1]:pFIGURE_FEATURE (pfiguremdl)->inrootposy;
00790 x[0]=(pFIGURE_FEATURE (pfiguremdl)->inrootposx <0)?x[0]:pFIGURE_FEATURE (pfiguremdl)->inrootposx;
00791 x[1]=(pFIGURE_FEATURE (pfiguremdl)->inrootposy <0)?x[1]:pFIGURE_FEATURE (pfiguremdl)->inrootposy;
00792 sciSetScreenPosition(pobj,x[0],x[1]);
00793 pFIGURE_FEATURE (pobj)->isiconified = pFIGURE_FEATURE (pfiguremdl)->isiconified;
00794 pFIGURE_FEATURE (pobj)->isselected = pFIGURE_FEATURE (pfiguremdl)->isselected;
00795 pFIGURE_FEATURE (pobj)->rotstyle = pFIGURE_FEATURE (pfiguremdl)->rotstyle;
00796 pFIGURE_FEATURE (pobj)->visible = pFIGURE_FEATURE (pfiguremdl)->visible;
00797 pFIGURE_FEATURE (pobj)->auto_redraw = pFIGURE_FEATURE (pfiguremdl)->auto_redraw;
00798 pFIGURE_FEATURE (pobj)->numsubwinselected = pFIGURE_FEATURE (pfiguremdl)->numsubwinselected;
00799 pFIGURE_FEATURE (pobj)->pixmap = pFIGURE_FEATURE (pfiguremdl)->pixmap ;
00800 pFIGURE_FEATURE (pobj)->wshow = pFIGURE_FEATURE (pfiguremdl)->wshow ;
00801
00802 return 0;
00803 }
00804
00805
00806
00810 int
00811 sciInitGraphicMode (sciPointObj * pobj)
00812 {
00813 switch (sciGetEntityType (pobj))
00814 {
00815 case SCI_FIGURE:
00816 if (pobj == pfiguremdl)
00817 {
00818 (sciGetGraphicMode (pobj))->wresize = TRUE;
00819 (sciGetGraphicMode (pobj))->addplot = TRUE;
00820 (sciGetGraphicMode (pobj))->autoscaling = TRUE;
00821 (sciGetGraphicMode (pobj))->zooming = FALSE;
00822 (sciGetGraphicMode (pobj))->xormode = 3;
00823 }
00824 else
00825 {
00826 (sciGetGraphicMode (pobj))->wresize = (sciGetGraphicMode (pfiguremdl))->wresize;
00827 (sciGetGraphicMode (pobj))->addplot = (sciGetGraphicMode (pfiguremdl))->addplot;
00828 (sciGetGraphicMode (pobj))->autoscaling = (sciGetGraphicMode (pfiguremdl))->autoscaling;
00829 (sciGetGraphicMode (pobj))->zooming = (sciGetGraphicMode (pfiguremdl))->zooming;
00830 (sciGetGraphicMode (pobj))->xormode = (sciGetGraphicMode (pfiguremdl))->xormode;
00831 }
00832 break;
00833 case SCI_SUBWIN:
00834 if (pobj == paxesmdl)
00835 {
00836 (sciGetGraphicMode (pobj))->wresize =sciGetResize (sciGetParent (pobj));
00837 (sciGetGraphicMode (pobj))->addplot =sciGetAddPlot (sciGetParent (pobj));
00838 (sciGetGraphicMode (pobj))->autoscaling =sciGetAutoScale (sciGetParent (pobj));
00839 (sciGetGraphicMode (pobj))->zooming =sciGetZooming (sciGetParent (pobj));
00840 (sciGetGraphicMode (pobj))->xormode =sciGetXorMode (sciGetParent (pobj));
00841 }
00842 else
00843 {
00844 (sciGetGraphicMode (pobj))->addplot =(sciGetGraphicMode (paxesmdl))->addplot;
00845 (sciGetGraphicMode (pobj))->autoscaling = (sciGetGraphicMode (paxesmdl))->autoscaling;
00846 (sciGetGraphicMode (pobj))->zooming =(sciGetGraphicMode (paxesmdl))->zooming;
00847 (sciGetGraphicMode (pobj))->xormode =(sciGetGraphicMode (paxesmdl))->xormode;
00848 }
00849 break;
00850 case SCI_TEXT:
00851 case SCI_TITLE:
00852 case SCI_LEGEND:
00853 case SCI_ARC:
00854 case SCI_SEGS:
00855 case SCI_FEC:
00856 case SCI_GRAYPLOT:
00857 case SCI_POLYLINE:
00858 case SCI_RECTANGLE:
00859 case SCI_SURFACE:
00860 case SCI_LIGHT:
00861 case SCI_AXES:
00862 case SCI_PANNER:
00863 case SCI_SBH:
00864 case SCI_SBV:
00865 case SCI_MENU:
00866 case SCI_MENUCONTEXT:
00867 case SCI_STATUSB:
00868 case SCI_AGREG:
00869 case SCI_LABEL:
00870 case SCI_UIMENU:
00871 default:
00872 sciprint ("This object haven't any graphic mode\n");
00873 return -1;
00874 break;
00875 }
00876 return 0;
00877 }
00878
00879
00880
00881 sciPointObj * initLabel( sciPointObj * pParentObj )
00882 {
00883 sciPointObj * newLabel = MALLOC (sizeof (sciPointObj)) ;
00884 sciLabel * ppLabel ;
00885 char * emptyString = "" ;
00886
00887 if ( newLabel == NULL )
00888 {
00889 return NULL ;
00890 }
00891
00892 sciSetEntityType( newLabel, SCI_LABEL ) ;
00893
00894 newLabel->pfeatures = MALLOC ( sizeof (sciLabel) ) ;
00895 if ( newLabel->pfeatures == NULL)
00896 {
00897 FREE( newLabel );
00898 return NULL ;
00899 }
00900
00901 ppLabel = pLABEL_FEATURE( newLabel ) ;
00902
00903
00904 ppLabel->text = allocateText( pParentObj, &emptyString, 1, 1,
00905 0.0, 0.0, TRUE, NULL, FALSE, NULL, NULL,
00906 FALSE, FALSE, FALSE, ALIGN_LEFT ) ;
00907
00908 if ( ppLabel->text == NULL )
00909 {
00910 deallocateText( ppLabel->text ) ;
00911 FREE( ppLabel ) ;
00912 FREE( newLabel );
00913 return NULL ;
00914 }
00915
00916 if ( sciAddNewHandle ( newLabel ) == -1 )
00917 {
00918 FREE( ppLabel ) ;
00919 FREE( newLabel ) ;
00920 return NULL ;
00921 }
00922
00923 if ( !sciAddThisToItsParent( newLabel, pParentObj ) )
00924 {
00925 sciDelHandle (newLabel);
00926 FREE( ppLabel ) ;
00927 FREE( newLabel );
00928 return NULL ;
00929 }
00930
00931 sciInitSelectedSons( newLabel ) ;
00932
00933 ppLabel->auto_position = TRUE;
00934 ppLabel->auto_rotation = TRUE;
00935
00936 ppLabel->isselected = TRUE;
00937
00938 ppLabel->ptype = 0 ;
00939
00940 sciInitIs3d( newLabel, FALSE ) ;
00941
00942 if ( sciInitGraphicContext( newLabel ) == -1 )
00943 {
00944 DestroyLabel( newLabel ) ;
00945 return NULL ;
00946 }
00947
00948 if ( sciInitFontContext( newLabel ) == -1 )
00949 {
00950 DestroyLabel( newLabel ) ;
00951 return NULL ;
00952 }
00953
00954
00955
00956 return newLabel ;
00957 }
00958
00959
00960 void destroyDefaultObjects( void )
00961 {
00962 DestroyAllGraphicsSons( pfiguremdl ) ;
00963 DestroyFigure( pfiguremdl ) ;
00964 pfiguremdl = NULL ;
00965 }
00966