00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <stdio.h>
00017 #include <string.h>
00018 #include <math.h>
00019 #include <stdlib.h>
00020 #include <stdarg.h>
00021 #include <time.h>
00022
00023 #ifdef _MSC_VER
00024 #include <windows.h>
00025 #endif
00026
00027 #include "BuildObjects.h"
00028 #include "GetProperty.h"
00029 #include "InitObjects.h"
00030 #include "DestroyObjects.h"
00031 #include "bcg.h"
00032 #include "BuildObjects.h"
00033 #include "SetProperty.h"
00034 #include "CloneObjects.h"
00035 #include "StringMatrix.h"
00036 #include "Xcall1.h"
00037 #include "sciprint.h"
00038 #include "CurrentObjectsManagement.h"
00039 #include "ObjectSelection.h"
00040
00041 #include "MALLOC.h"
00042
00043 extern int LinearScaling2Colormap(sciPointObj* pobj);
00044 extern double * AllocUserGrads(double * u_xgrads, int nb);
00045 extern char ** AllocAndSetUserLabelsFromMdl(char ** u_xlabels, char ** u_xlabels_MDL, int u_nxgrads);
00046 extern int CopyUserGrads(double *u_xgrad_SRC, double *u_xgrad_DEST, int dim);
00047
00048 extern unsigned short defcolors[];
00049
00053 sciPointObj *
00054 ConstructStatusBar (sciPointObj * pparentfigure)
00055 {
00056 sciPointObj *pobj = (sciPointObj *) NULL;
00057
00058 if (sciGetEntityType (pparentfigure) == SCI_FIGURE)
00059 {
00060 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
00061 return NULL;
00062 sciSetEntityType (pobj, SCI_STATUSB);
00063 if ((pobj->pfeatures = MALLOC ((sizeof (sciStatusBar)))) == NULL)
00064 {
00065 FREE(pobj);
00066 return (sciPointObj *) NULL;
00067 }
00068 if ( sciStandrardBuildOperations( pobj, pparentfigure ) == NULL )
00069 {
00070 return NULL ;
00071 }
00072
00073 if (sciInitGraphicContext (pobj) == -1)
00074 {
00075 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00076 sciDelHandle (pobj);
00077 FREE(pobj->pfeatures);
00078 FREE(pobj);
00079 return (sciPointObj *) NULL;
00080 }
00081 if (sciInitFontContext (pobj) == -1)
00082 {
00083 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00084 sciDelHandle (pobj);
00085 FREE(pobj->pfeatures);
00086 FREE(pobj);
00087 return (sciPointObj *) NULL;
00088 }
00089 return (sciPointObj *)pobj;
00090 }
00091 else
00092 {
00093 sciprint ("The parent has to be a FIGURE \n");
00094 return (sciPointObj *) NULL;
00095 }
00096 }
00097
00098
00099
00103 int C2F(sciwin)( void )
00104 {
00105 integer verb = 0 ;
00106 integer win = 0 ;
00107 integer v = 1 ;
00108 integer na ;
00109 double dv ;
00110 C2F(dr)("xget","window",&verb,&win,&na,PI0,PI0,PI0,&dv,&dv,&dv,&dv,5L,7L);
00111 C2F(dr)("xset","window",&win,&v,PI0,PI0,PI0,PI0,&dv,&dv,&dv,&dv,5L,7L);
00112 return sciSwitchWindow(&win);
00113 }
00114
00115
00119
00120 sciPointObj * ConstructFigure( sciPointObj * pparent, struct BCG * XGC )
00121 {
00122
00123 sciPointObj *pobj = (sciPointObj *) NULL;
00124 integer x[2], verbose=0, narg=0;
00125 int succeed = 0;
00126 sciPointObj * pfiguremdl = getFigureModel() ;
00127 sciFigure * ppFigure = NULL ;
00128 sciFigure * ppModel = pFIGURE_FEATURE(pfiguremdl) ;
00129
00130
00131
00132 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
00133 {
00134 return NULL;
00135 }
00136 sciSetEntityType (pobj, SCI_FIGURE);
00137 if ((pobj->pfeatures = MALLOC ((sizeof (sciFigure)))) == NULL)
00138 {
00139 FREE(pobj);
00140 return (sciPointObj *) NULL;
00141 }
00142
00143
00144 ppFigure = pFIGURE_FEATURE(pobj) ;
00145
00146 if ( sciStandrardBuildOperations( pobj, pparent ) == NULL )
00147 {
00148 return NULL ;
00149 }
00150
00151 ppFigure->pScilabXgc = XGC;
00152 XGC->mafigure = pobj ;
00153
00154
00155 if (sciInitGraphicContext (pobj) == -1)
00156 {
00157 sciDelHandle (pobj);
00158 FREE(pobj->pfeatures);
00159 FREE(pobj);
00160 return (sciPointObj *) NULL;
00161 }
00162 if (sciInitGraphicMode (pobj) == -1)
00163 {
00164 sciDelHandle (pobj);
00165 FREE(pobj->pfeatures);
00166 FREE(pobj);
00167 return (sciPointObj *) NULL;
00168 }
00169
00170
00171 if (sciInitFontContext (pobj) == -1)
00172 {
00173 sciDelHandle (pobj);
00174 FREE(pobj->pfeatures);
00175 FREE(pobj);
00176 return (sciPointObj *) NULL;
00177 }
00178 sciInitNum (pobj, &(XGC->CurWindow));
00179 sciSetName(pobj, sciGetName(pfiguremdl), sciGetNameLength(pfiguremdl));
00180 sciInitResize((sciPointObj *) pobj,sciGetResize(pobj));
00181 ppFigure->windowdimwidth=ppModel->windowdimwidth;
00182 ppFigure->windowdimheight=ppModel->windowdimheight;
00183 C2F(dr)("xset","wdim",&(ppFigure->windowdimwidth),
00184 &(ppFigure->windowdimheight),PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00185 ppFigure->figuredimwidth = ppModel->figuredimwidth;
00186 ppFigure->figuredimheight = ppModel->figuredimheight;
00187 C2F(dr)("xset","wpdim",&(ppFigure->figuredimwidth),
00188 &(ppFigure->figuredimheight),PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00189 C2F(dr)("xget","wpos",&verbose,x,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,4L,4L);
00190 x[0]=(ppModel->inrootposx <0)?x[0]:ppModel->inrootposx;
00191 x[1]=(ppModel->inrootposy <0)?x[1]:ppModel->inrootposy;
00192 x[0]=(ppModel->inrootposx <0)?x[0]:ppModel->inrootposx;
00193 x[1]=(ppModel->inrootposy <0)?x[1]:ppModel->inrootposy;
00194 sciInitScreenPosition(pobj,x[0],x[1]);
00195 ppFigure->isiconified = ppModel->isiconified;
00196 ppFigure->isselected = ppModel->isselected;
00197 ppFigure->rotstyle = ppModel->rotstyle;
00198 ppFigure->visible = ppModel->visible;
00199 ppFigure->auto_redraw = ppModel->auto_redraw;
00200
00201 ppFigure->numsubwinselected = ppModel->numsubwinselected;
00202 ppFigure->pixmap = ppModel->pixmap ;
00203 ppFigure->wshow = ppModel->wshow ;
00204 ppFigure->allredraw = ppModel->allredraw;
00205
00206 ppFigure->infoMessage = NULL ;
00207 sciSetInfoMessage( pobj, sciGetInfoMessage(pfiguremdl) ) ;
00208
00210
00211
00212 ppFigure->pcolormap = NULL ;
00213 sciInitNumColors(pobj, 0) ;
00214
00215 sciSetColormap( pobj, ppModel->pcolormap, sciGetNumColors(pfiguremdl), 3 ) ;
00216
00217 return pobj;
00218 }
00219
00220
00221
00222
00223
00224
00225
00229 sciPointObj *
00230 ConstructSubWin (sciPointObj * pparentfigure, int pwinnum)
00231 {
00232
00233 char dir;
00234 int i;
00235 sciPointObj *pobj = (sciPointObj *) NULL;
00236 sciSubWindow * ppsubwin = NULL;
00237 sciPointObj * paxesmdl = getAxesModel() ;
00238 sciSubWindow * ppaxesmdl = pSUBWIN_FEATURE (paxesmdl);
00239
00240
00241 if (sciGetEntityType (pparentfigure) == SCI_FIGURE)
00242 {
00243
00244 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
00245 return NULL;
00246 sciSetEntityType (pobj, SCI_SUBWIN);
00247 if ((pobj->pfeatures = MALLOC ((sizeof (sciSubWindow)))) == NULL)
00248 {
00249 FREE(pobj);
00250 return (sciPointObj *) NULL;
00251 }
00252
00253 if ( sciStandrardBuildOperations( pobj, pparentfigure ) == NULL )
00254 {
00255 return NULL ;
00256 }
00257
00258 ppsubwin = pSUBWIN_FEATURE (pobj);
00259
00260 ppsubwin->vertices_list = (Vertices*) NULL;
00261
00262
00263 ppsubwin->callback = (char *)NULL;
00264 ppsubwin->callbacklen = 0;
00265 ppsubwin->callbackevent = 100;
00266
00267 if (sciInitGraphicContext (pobj) == -1)
00268 {
00269 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00270 sciDelHandle (pobj);
00271 FREE(pobj->pfeatures);
00272 FREE(pobj);
00273 return (sciPointObj *) NULL;
00274 }
00275 if (sciInitGraphicMode (pobj) == -1)
00276 {
00277 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00278 sciDelHandle (pobj);
00279 FREE(pobj->pfeatures);
00280 FREE(pobj);
00281 return (sciPointObj *) NULL;
00282 }
00283
00284
00285 if (sciInitFontContext (pobj) == -1)
00286 {
00287 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00288 sciDelHandle (pobj);
00289 FREE(pobj->pfeatures);
00290 FREE(pobj);
00291 return (sciPointObj *) NULL;
00292 }
00293
00294 dir= ppaxesmdl->logflags[0];
00295 ppsubwin->logflags[0] = dir;
00296
00297 dir= ppaxesmdl->logflags[1];
00298 ppsubwin->logflags[1] = dir;
00299
00300 dir= ppaxesmdl->logflags[2];
00301 ppsubwin->logflags[2] = dir;
00302
00303 ppsubwin->axes.ticscolor = ppaxesmdl->axes.ticscolor;
00304 ppsubwin->axes.subint[0] = ppaxesmdl->axes.subint[0];
00305 ppsubwin->axes.subint[1] = ppaxesmdl->axes.subint[1];
00306 ppsubwin->axes.subint[2] = ppaxesmdl->axes.subint[2];
00307
00308 dir= ppaxesmdl->axes.xdir;
00309 ppsubwin->axes.xdir = dir;
00310 dir= ppaxesmdl->axes.ydir;
00311 ppsubwin->axes.ydir = dir;
00312
00313 ppsubwin->axes.rect = ppaxesmdl->axes.rect;
00314 for (i=0 ; i<7 ; i++)
00315 ppsubwin->axes.limits[i] = ppaxesmdl->axes.limits[i] ;
00316
00317 for (i=0 ; i<3 ; i++)
00318 ppsubwin->grid[i] = ppaxesmdl->grid[i] ;
00319 ppsubwin->alpha = ppaxesmdl->alpha;
00320 ppsubwin->theta = ppaxesmdl->theta;
00321 ppsubwin->alpha_kp = ppaxesmdl->alpha_kp;
00322 ppsubwin->theta_kp = ppaxesmdl->theta_kp;
00323 ppsubwin->is3d = ppaxesmdl->is3d;
00324
00325 for (i=0 ; i<4 ; i++)
00326 {
00327 ppsubwin->axes.xlim[i]= ppaxesmdl->axes.xlim[i];
00328 ppsubwin->axes.ylim[i]= ppaxesmdl->axes.ylim[i];
00329 }
00330
00331
00332
00333 ppsubwin->axes.u_xlabels = (char **) NULL;
00334 ppsubwin->axes.u_ylabels = (char **) NULL;
00335 ppsubwin->axes.u_zlabels = (char **) NULL;
00336 ppsubwin->axes.u_xgrads = (double *)NULL;
00337 ppsubwin->axes.u_ygrads = (double *)NULL;
00338 ppsubwin->axes.u_zgrads = (double *)NULL;
00339
00340
00341 (ppsubwin->axes).axes_visible[0] = ppaxesmdl->axes.axes_visible[0];
00342 (ppsubwin->axes).axes_visible[1] = ppaxesmdl->axes.axes_visible[1];
00343 (ppsubwin->axes).axes_visible[2] = ppaxesmdl->axes.axes_visible[2];
00344 (ppsubwin->axes).reverse[0] = ppaxesmdl->axes.reverse[0];
00345 (ppsubwin->axes).reverse[1] = ppaxesmdl->axes.reverse[1];
00346 (ppsubwin->axes).reverse[2] = ppaxesmdl->axes.reverse[2];
00347 ppsubwin->flagNax = ppaxesmdl->flagNax;
00348
00349
00350 (ppsubwin->axes).nbsubtics[0] = ppaxesmdl->axes.nbsubtics[0];
00351 (ppsubwin->axes).nbsubtics[1] = ppaxesmdl->axes.nbsubtics[1];
00352 (ppsubwin->axes).nbsubtics[2] = ppaxesmdl->axes.nbsubtics[2];
00353
00354 (ppsubwin->axes).nxgrads = ppaxesmdl->axes.nxgrads;
00355 (ppsubwin->axes).nygrads = ppaxesmdl->axes.nygrads;
00356 (ppsubwin->axes).nzgrads = ppaxesmdl->axes.nzgrads;
00357
00358 for(i=0;i<(ppsubwin->axes).nxgrads;i++) ppsubwin->axes.xgrads[i] = ppaxesmdl->axes.xgrads[i];
00359 for(i=0;i<(ppsubwin->axes).nygrads;i++) ppsubwin->axes.ygrads[i] = ppaxesmdl->axes.ygrads[i];
00360 for(i=0;i<(ppsubwin->axes).nzgrads;i++) ppsubwin->axes.zgrads[i] = ppaxesmdl->axes.zgrads[i];
00361
00362 (ppsubwin->axes).u_nxgrads = ppaxesmdl->axes.u_nxgrads;
00363 (ppsubwin->axes).u_nygrads = ppaxesmdl->axes.u_nygrads;
00364 (ppsubwin->axes).u_nzgrads = ppaxesmdl->axes.u_nzgrads;
00365 (ppsubwin->axes).u_xgrads = AllocUserGrads(ppsubwin->axes.u_xgrads,ppaxesmdl->axes.u_nxgrads);
00366 CopyUserGrads(ppaxesmdl->axes.u_xgrads,
00367 ppsubwin->axes.u_xgrads,
00368 ppsubwin->axes.u_nxgrads);
00369 (ppsubwin->axes).u_ygrads = AllocUserGrads(ppsubwin->axes.u_ygrads,ppaxesmdl->axes.u_nygrads);
00370 CopyUserGrads(ppaxesmdl->axes.u_ygrads,
00371 ppsubwin->axes.u_ygrads,
00372 ppsubwin->axes.u_nygrads);
00373 (ppsubwin->axes).u_zgrads = AllocUserGrads(ppsubwin->axes.u_zgrads,ppaxesmdl->axes.u_nzgrads);
00374 CopyUserGrads(ppaxesmdl->axes.u_zgrads,
00375 ppsubwin->axes.u_zgrads,
00376 ppsubwin->axes.u_nzgrads);
00377 (ppsubwin->axes).u_xlabels = AllocAndSetUserLabelsFromMdl(ppsubwin->axes.u_xlabels,
00378 ppaxesmdl->axes.u_xlabels,
00379 ppsubwin->axes.u_nxgrads);
00380
00381 (ppsubwin->axes).u_ylabels = AllocAndSetUserLabelsFromMdl(ppsubwin->axes.u_ylabels,
00382 ppaxesmdl->axes.u_ylabels,
00383 ppsubwin->axes.u_nygrads);
00384
00385 (ppsubwin->axes).u_zlabels = AllocAndSetUserLabelsFromMdl(ppsubwin->axes.u_zlabels,
00386 ppaxesmdl->axes.u_zlabels,
00387 ppsubwin->axes.u_nzgrads);
00388
00389 (ppsubwin->axes).auto_ticks[0] = ppaxesmdl->axes.auto_ticks[0];
00390 (ppsubwin->axes).auto_ticks[1] = ppaxesmdl->axes.auto_ticks[1];
00391 (ppsubwin->axes).auto_ticks[2] = ppaxesmdl->axes.auto_ticks[2];
00392
00393
00394 ppsubwin->axes.zlim[0]= ppaxesmdl->axes.zlim[0];
00395 ppsubwin->axes.zlim[1]= ppaxesmdl->axes.zlim[1];
00396 ppsubwin->axes.flag[0]= ppaxesmdl->axes.flag[0];
00397 ppsubwin->axes.flag[1]= ppaxesmdl->axes.flag[1];
00398 ppsubwin->axes.flag[2]= ppaxesmdl->axes.flag[2];
00399 ppsubwin->axes.hiddenAxisColor = ppaxesmdl->axes.hiddenAxisColor ;
00400 ppsubwin->project[0]= ppaxesmdl->project[0];
00401 ppsubwin->project[1]= ppaxesmdl->project[1];
00402 ppsubwin->project[2]= ppaxesmdl->project[2];
00403 ppsubwin->hiddencolor= ppaxesmdl->hiddencolor;
00404 ppsubwin->hiddenstate= ppaxesmdl->hiddenstate;
00405 ppsubwin->isoview= ppaxesmdl->isoview;
00406 ppsubwin->facetmerge = ppaxesmdl->facetmerge;
00407 ppsubwin->WRect[0] = ppaxesmdl->WRect[0];
00408 ppsubwin->WRect[1] = ppaxesmdl->WRect[1];
00409 ppsubwin->WRect[2] = ppaxesmdl->WRect[2];
00410 ppsubwin->WRect[3] = ppaxesmdl->WRect[3];
00411
00412 ppsubwin->ARect[0] = ppaxesmdl->ARect[0];
00413 ppsubwin->ARect[1] = ppaxesmdl->ARect[1];
00414 ppsubwin->ARect[2] = ppaxesmdl->ARect[2];
00415 ppsubwin->ARect[3] = ppaxesmdl->ARect[3];
00416
00417 ppsubwin->FRect[0] = ppaxesmdl->FRect[0];
00418 ppsubwin->FRect[1] = ppaxesmdl->FRect[1] ;
00419 ppsubwin->FRect[2] = ppaxesmdl->FRect[2];
00420 ppsubwin->FRect[3] = ppaxesmdl->FRect[3];
00421 ppsubwin->FRect[4] = ppaxesmdl->FRect[4] ;
00422 ppsubwin->FRect[5] = ppaxesmdl->FRect[5];
00423
00424 ppsubwin->visible = ppaxesmdl->visible;
00425
00426 ppsubwin->clip_region_set = 0 ;
00427 sciInitIsClipping( pobj, sciGetIsClipping(paxesmdl) ) ;
00428 sciSetClipping( pobj, sciGetClipping( paxesmdl) ) ;
00429
00430 ppsubwin->cube_scaling = ppaxesmdl->cube_scaling;
00431
00432 ppsubwin->SRect[0] = ppaxesmdl->SRect[0];
00433 ppsubwin->SRect[1] = ppaxesmdl->SRect[1];
00434 ppsubwin->SRect[2] = ppaxesmdl->SRect[2];
00435 ppsubwin->SRect[3] = ppaxesmdl->SRect[3];
00436 ppsubwin->SRect[4] = ppaxesmdl->SRect[4];
00437 ppsubwin->SRect[5] = ppaxesmdl->SRect[5];
00438
00439 ppsubwin->tight_limits = ppaxesmdl->tight_limits;
00440 ppsubwin->FirstPlot = ppaxesmdl->FirstPlot;
00441 ppsubwin->with_leg = ppaxesmdl->with_leg;
00442
00443 if (sciInitSelectedSubWin(pobj) < 0 )
00444 {
00445 return (sciPointObj *)NULL ;
00446 }
00447
00448
00449
00450 if ((ppsubwin->mon_title = ConstructLabel (pobj, "",1)) == NULL){
00451 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00452 sciDelHandle (pobj);
00453 FREE(pobj->pfeatures);
00454 FREE(pobj);
00455 return (sciPointObj *) NULL;
00456 }
00457
00458 sciSetStrings( ppsubwin->mon_title,
00459 sciGetText( pSUBWIN_FEATURE(paxesmdl)->mon_title) ) ;
00460
00461
00462
00463 if ((ppsubwin->mon_x_label = ConstructLabel (pobj, "",2)) == NULL){
00464 DestroyLabel(ppsubwin->mon_title);
00465 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00466 sciDelHandle (pobj);
00467 FREE(pobj->pfeatures);
00468 FREE(pobj);
00469 return (sciPointObj *) NULL;
00470 }
00471
00472 sciSetStrings( ppsubwin->mon_x_label,
00473 sciGetText(pSUBWIN_FEATURE(paxesmdl)->mon_x_label) ) ;
00474
00475
00476
00477 if ((ppsubwin->mon_y_label = ConstructLabel (pobj, "",3)) == NULL){
00478 DestroyLabel(ppsubwin->mon_title);
00479 DestroyLabel(ppsubwin->mon_x_label);
00480 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00481 sciDelHandle (pobj);
00482 FREE(pobj->pfeatures);
00483 FREE(pobj);
00484 return (sciPointObj *) NULL;
00485 }
00486 sciSetStrings( ppsubwin->mon_y_label,
00487 sciGetText( pSUBWIN_FEATURE(paxesmdl)->mon_y_label) ) ;
00488
00489
00490 if ((ppsubwin->mon_z_label = ConstructLabel (pobj, "",4)) == NULL){
00491 DestroyLabel(ppsubwin->mon_title);
00492 DestroyLabel(ppsubwin->mon_x_label);
00493 DestroyLabel(ppsubwin->mon_y_label);
00494 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00495 sciDelHandle (pobj);
00496 FREE(pobj->pfeatures);
00497 FREE(pobj);
00498 return (sciPointObj *) NULL;
00499 }
00500 sciSetStrings( ppsubwin->mon_z_label,
00501 sciGetText(pSUBWIN_FEATURE(paxesmdl)->mon_z_label) ) ;
00502
00503
00504 pLABEL_FEATURE(ppsubwin->mon_x_label)->auto_position =
00505 pLABEL_FEATURE(ppaxesmdl->mon_x_label)->auto_position;
00506
00507 pLABEL_FEATURE(ppsubwin->mon_y_label)->auto_position =
00508 pLABEL_FEATURE(ppaxesmdl->mon_y_label)->auto_position;
00509
00510 pLABEL_FEATURE(ppsubwin->mon_z_label)->auto_position =
00511 pLABEL_FEATURE(ppaxesmdl->mon_z_label)->auto_position;
00512
00513 pLABEL_FEATURE(ppsubwin->mon_title)->auto_position =
00514 pLABEL_FEATURE(ppaxesmdl->mon_title)->auto_position;
00515
00516
00517 pLABEL_FEATURE(ppsubwin->mon_x_label)->auto_rotation =
00518 pLABEL_FEATURE(ppaxesmdl->mon_x_label)->auto_rotation;
00519
00520 pLABEL_FEATURE(ppsubwin->mon_y_label)->auto_rotation =
00521 pLABEL_FEATURE(ppaxesmdl->mon_y_label)->auto_rotation;
00522
00523 pLABEL_FEATURE(ppsubwin->mon_z_label)->auto_rotation =
00524 pLABEL_FEATURE(ppaxesmdl->mon_z_label)->auto_rotation;
00525
00526 pLABEL_FEATURE(ppsubwin->mon_title)->auto_rotation =
00527 pLABEL_FEATURE(ppaxesmdl->mon_title)->auto_rotation;
00528
00529 cloneGraphicContext( ppaxesmdl->mon_x_label, ppsubwin->mon_x_label ) ;
00530 cloneGraphicContext( ppaxesmdl->mon_y_label, ppsubwin->mon_y_label ) ;
00531 cloneGraphicContext( ppaxesmdl->mon_z_label, ppsubwin->mon_z_label ) ;
00532 cloneGraphicContext( ppaxesmdl->mon_title , ppsubwin->mon_title ) ;
00533
00534 ppsubwin->pPopMenu = (sciPointObj *)NULL;
00535 ppsubwin->surfcounter = 0;
00536 return (sciPointObj *)pobj;
00537
00538 }
00539 else
00540 {
00541 sciprint ("The parent has to be a FIGURE \n");
00542 return (sciPointObj *) NULL;
00543 }
00544
00545 return (sciPointObj *) NULL;
00546 }
00547
00548
00549
00553 sciPointObj *
00554 ConstructScrollV (sciPointObj * pparentfigure)
00555 {
00556 sciPointObj *pobjsbv = (sciPointObj *) NULL;
00557
00558 if (sciGetEntityType (pparentfigure) == SCI_FIGURE)
00559 {
00560
00561
00562 if ((pobjsbv = MALLOC ((sizeof (sciPointObj)))) == NULL)
00563 return NULL;
00564 sciSetEntityType (pobjsbv, SCI_SBV);
00565 if ((pobjsbv->pfeatures = MALLOC ((sizeof (sciScrollBarVert)))) == NULL)
00566 {
00567 FREE(pobjsbv);
00568 return (sciPointObj *) NULL;
00569 }
00570 if ( sciStandrardBuildOperations( pobjsbv, pparentfigure ) == NULL )
00571 {
00572 return NULL ;
00573 }
00574 return pobjsbv;
00575 }
00576 else
00577 {
00578 sciprint ("The parent has to be a FIGURE \n");
00579 return (sciPointObj *) NULL;
00580 }
00581 }
00582
00583
00584
00588 sciPointObj *
00589 ConstructScrollH (sciPointObj * pparentfigure)
00590 {
00591 sciPointObj *pobjsbh = (sciPointObj *) NULL;
00592
00593 if (sciGetEntityType (pparentfigure) == SCI_FIGURE)
00594 {
00595
00596
00597 if ((pobjsbh = MALLOC ((sizeof (sciPointObj)))) == NULL)
00598 return NULL;
00599 sciSetEntityType (pobjsbh, SCI_SBH);
00600 if ((pobjsbh->pfeatures = MALLOC ((sizeof (sciScrollBarHorz)))) == NULL)
00601 {
00602 FREE(pobjsbh);
00603 return (sciPointObj *) NULL;
00604 }
00605 if ( sciStandrardBuildOperations( pobjsbh, pparentfigure ) == NULL )
00606 {
00607 return NULL ;
00608 }
00609 return pobjsbh;
00610 }
00611 else
00612 {
00613 sciprint ("The parent has to be a FIGURE \n");
00614 return (sciPointObj *) NULL;
00615 }
00616 }
00617
00618
00624 sciPointObj * allocateText( sciPointObj * pparentsubwin,
00625 char ** text ,
00626 int nbRow ,
00627 int nbCol ,
00628 double x ,
00629 double y ,
00630 BOOL autoSize ,
00631 double userSize[2] ,
00632 BOOL centerPos ,
00633 int * foreground ,
00634 int * background ,
00635 BOOL isboxed ,
00636 BOOL isline ,
00637 BOOL isfilled ,
00638 sciTextAlignment align )
00639 {
00640 sciPointObj * pObj = NULL ;
00641 sciText * ppText ;
00642 if ( ( pObj = MALLOC( sizeof(sciPointObj) ) ) == NULL )
00643 {
00644 return NULL;
00645 }
00646
00647 sciSetEntityType (pObj, SCI_TEXT);
00648
00649 if ( ( pObj->pfeatures = MALLOC( sizeof (sciText) ) ) == NULL )
00650 {
00651 FREE( pObj ) ;
00652 return NULL;
00653 }
00654
00655 ppText = pTEXT_FEATURE( pObj ) ;
00656
00657 ppText->user_data = (int *) NULL;
00658 ppText->size_of_user_data = 0;
00659 sciInitSelectedSons( pObj ) ;
00660 ppText->relationship.psons = NULL;
00661 ppText->relationship.plastsons = NULL;
00662
00663
00664 sciSetParent( pObj, pparentsubwin ) ;
00665
00666 ppText->callback = (char *)NULL;
00667 ppText->callbacklen = 0;
00668 ppText->callbackevent = 100;
00669 ppText->visible = sciGetVisibility( pparentsubwin );
00670
00671 ppText->clip_region_set = 0 ;
00672 sciInitIsClipping( pObj, sciGetIsClipping( pparentsubwin ) ) ;
00673 sciSetClipping( pObj, sciGetClipping(pparentsubwin) );
00674
00675
00676 ppText->pStrings = newFullStringMatrix( text, nbRow, nbCol ) ;
00677 if ( ppText->pStrings == NULL )
00678 {
00679 FREE(pObj->pfeatures);
00680 FREE(pObj);
00681 return NULL ;
00682 }
00683
00684
00685 ppText->is3d = TRUE ;
00686 ppText->x = x;
00687 ppText->y = y;
00688 ppText->z = 0.0;
00690 ppText->centeredPos = centerPos ;
00691 ppText->autoSize = autoSize ;
00692
00693
00694
00695
00696 if ( !autoSize || centerPos )
00697 {
00698 ppText->userSize[0] = userSize[0] ;
00699 ppText->userSize[1] = userSize[1] ;
00700 }
00701 else
00702 {
00703 ppText->userSize[0] = 0.0 ;
00704 ppText->userSize[1] = 0.0 ;
00705 }
00706
00707 ppText->stringsAlign = align ;
00708
00709 sciInitIsBoxed(pObj,isboxed);
00710 sciInitIsLine(pObj,isline);
00711 sciInitIsFilled(pObj,isfilled);
00712
00713 if ( foreground != NULL )
00714 {
00715 sciInitForeground(pObj,(*foreground));
00716 }
00717
00718 if ( background != NULL )
00719 {
00720 sciInitBackground(pObj,(*background));
00721 }
00722
00723 return pObj;
00724 }
00725
00734 sciPointObj *
00735 ConstructText (sciPointObj * pparentsubwin, char ** text, int nbRow, int nbCol, double x,
00736 double y, BOOL autoSize, double userSize[2], BOOL centerPos, int *foreground, int *background,
00737 BOOL isboxed, BOOL isline, BOOL isfilled, sciTextAlignment align )
00738 {
00739 if ( sciGetEntityType( pparentsubwin ) == SCI_SUBWIN )
00740 {
00741 sciPointObj * pobj = allocateText( pparentsubwin, text, nbRow, nbCol, x, y,
00742 autoSize, userSize, centerPos, foreground, background,
00743 isboxed, isline, isfilled, align ) ;
00744
00745 if ( pobj == NULL )
00746 {
00747 return NULL ;
00748 }
00749
00750 if ( sciInitFontContext( pobj ) == -1 )
00751 {
00752 FREE(pobj->pfeatures);
00753 FREE(pobj);
00754 return NULL ;
00755 }
00756
00757 if ( sciInitGraphicContext( pobj ) == -1 )
00758 {
00759 deallocateText( pobj ) ;
00760 return NULL ;
00761 }
00762
00763 if (sciAddNewHandle (pobj) == -1)
00764 {
00765 deallocateText( pobj ) ;
00766 return NULL;
00767 }
00768
00769 if ( !(sciAddThisToItsParent (pobj, pparentsubwin)) )
00770 {
00771 deleteMatrix( pTEXT_FEATURE( pobj )->pStrings ) ;
00772 sciDelHandle (pobj);
00773 FREE(pobj->pfeatures);
00774 FREE(pobj);
00775 return NULL;
00776 }
00777
00778 return pobj ;
00779
00780 }
00781
00782 sciprint ("The parent has to be a SUBWIN \n");
00783 return NULL;
00784 }
00785
00786
00787
00796 sciPointObj *
00797 ConstructTitle (sciPointObj * pparentsubwin, char text[], int type)
00798 {
00799 sciPointObj * pobj = (sciPointObj *) NULL;
00800 sciTitle * ppTitle ;
00801
00802 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
00803 {
00804 if ((pobj = MALLOC (sizeof (sciPointObj))) == NULL)
00805 return (sciPointObj *) NULL;
00806 sciSetEntityType (pobj, SCI_TITLE);
00807 if ((pobj->pfeatures = MALLOC ((sizeof (sciTitle)))) == NULL)
00808 {
00809 FREE(pobj);
00810 return (sciPointObj *) NULL;
00811 }
00812
00813 ppTitle = pTITLE_FEATURE(pobj) ;
00814
00815 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
00816 {
00817 return NULL ;
00818 }
00819
00820 ppTitle->text.callback = (char *)NULL;
00821 ppTitle->text.callbacklen = 0;
00822 ppTitle->visible = sciGetVisibility(sciGetParentSubwin(pobj));
00823 ppTitle->text.isboxed = FALSE ;
00824 ppTitle->text.isline = TRUE ;
00825
00826 ppTitle->text.pStrings = newFullStringMatrix( &text, 1, 1 ) ;
00827
00828 if ( ppTitle->text.pStrings == NULL )
00829 {
00830 sciprint("No more place to allocates text string, try a shorter string");
00831 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00832 sciDelHandle (pobj);
00833 FREE(ppTitle);
00834 FREE(pobj);
00835 return (sciPointObj *) NULL;
00836 }
00837
00838
00839 ppTitle->ptype = type;
00840
00841 ppTitle->text.fontcontext.textorientation = 0;
00842
00843 ppTitle->titleplace = SCI_TITLE_IN_TOP;
00844 ppTitle->isselected = TRUE;
00845 if (sciInitFontContext (pobj) == -1 )
00846 {
00847 deleteMatrix(ppTitle->text.pStrings);
00848 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00849 sciDelHandle (pobj);
00850 FREE(ppTitle);
00851 FREE(pobj);
00852 return (sciPointObj *) NULL;
00853 }
00854 return (sciPointObj *) pobj;
00855 }
00856 else
00857 {
00858 sciprint ("The parent has to be a SUBWIN \n");
00859 return (sciPointObj *) NULL;
00860 }
00861 }
00862
00863
00864
00868 sciPointObj *
00869 ConstructLegend (sciPointObj * pparentsubwin, char text[], int n, int nblegends, int *pstyle
00870 , sciPointObj **pptabofpointobj)
00871 {
00872 sciPointObj * pobj = (sciPointObj *) NULL;
00873 sciLegend * ppLegend ;
00874
00875
00876
00877
00878
00879
00880 sciSons *psonstmp;
00881 int i=0;
00882
00883 psonstmp = sciGetSons (pparentsubwin);
00884
00885 if (psonstmp != (sciSons *) NULL)
00886
00887 while ((psonstmp->pnext != (sciSons *) NULL)
00888 && sciGetEntityType (psonstmp->pointobj) != SCI_LEGEND)
00889 psonstmp = psonstmp->pnext;
00890
00891 if (sciGetEntityType (psonstmp->pointobj) == SCI_LEGEND)
00892 DestroyLegend (psonstmp->pointobj);
00893
00894 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
00895 {
00896 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
00897 return (sciPointObj *) NULL;
00898 sciSetEntityType (pobj, SCI_LEGEND);
00899 if ((pobj->pfeatures = MALLOC ((sizeof (sciLegend)))) == NULL)
00900 {
00901 FREE(pobj);
00902 return (sciPointObj *) NULL;
00903 }
00904
00905 ppLegend = pLEGEND_FEATURE( pobj );
00906
00907 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
00908 {
00909 return NULL ;
00910 }
00911
00912 ppLegend->text.relationship.psons = (sciSons *) NULL;
00913 ppLegend->text.relationship.plastsons = (sciSons *) NULL;
00914 ppLegend->text.callback = (char *)NULL;
00915 ppLegend->text.callbacklen = 0;
00916 ppLegend->text.callbackevent = 100;
00917 ppLegend->text.isboxed = FALSE ;
00918 ppLegend->text.isline = TRUE ;
00919
00920 ppLegend->visible = sciGetVisibility(sciGetParentSubwin(pobj));
00921
00922 ppLegend->text.pStrings = newFullStringMatrix( &text, 1, 1 ) ;
00923
00924
00925 if ( ppLegend->text.pStrings == NULL)
00926 {
00927 sciprint("\nNo more place to allocates text string, try a shorter string\n");
00928 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00929 sciDelHandle (pobj);
00930 FREE(ppLegend);
00931 FREE(pobj);
00932 return (sciPointObj *) NULL;
00933 }
00934
00935 ppLegend->nblegends = nblegends;
00936
00937 if ((ppLegend->pptabofpointobj =
00938 MALLOC(nblegends*sizeof(sciPointObj*))) == NULL)
00939 {
00940 sciprint("No more memory for legend\n");
00941 deleteMatrix( ppLegend->text.pStrings ) ;
00942 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00943 sciDelHandle (pobj);
00944 FREE(ppLegend);
00945 FREE(pobj);
00946 return (sciPointObj *) NULL;
00947 }
00948
00949 if ((ppLegend->pstyle = MALLOC(nblegends*sizeof(int))) != NULL)
00950 {
00951 for (i=0; i < nblegends; i++)
00952 {
00953 ppLegend->pstyle[i] = pstyle[i];
00954 ppLegend->pptabofpointobj[i] = pptabofpointobj[i];
00955 }
00956 }
00957 else
00958 {
00959 sciprint("\nNo more place to allocates style\n");
00960 FREE(ppLegend->pptabofpointobj);
00961 deleteMatrix( ppLegend->text.pStrings ) ;
00962 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00963 sciDelHandle (pobj);
00964 FREE(ppLegend);
00965 FREE(pobj);
00966 return (sciPointObj *) NULL;
00967 }
00968
00969
00970
00971 ppLegend->text.fontcontext.textorientation = 0;
00972 ppLegend->pos.x = 0;
00973 ppLegend->pos.y = 0;
00974 ppLegend->width = 0;
00975 ppLegend->height = 0;
00976 ppLegend->place = SCI_LEGEND_IN_INSIDE;
00977 ppLegend->isselected = TRUE;
00978 ppLegend->issurround = FALSE;
00979
00980 if (sciInitGraphicContext (pobj) == -1)
00981 {
00982 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00983 sciDelHandle (pobj);
00984 FREE(pobj->pfeatures);
00985 FREE(pobj);
00986 return (sciPointObj *) NULL;
00987 }
00988
00989 if (sciInitFontContext (pobj) == -1)
00990 {
00991 sciprint("Problem with sciInitFontContext\n");
00992 FREE(ppLegend->pptabofpointobj);
00993 deleteMatrix( ppLegend->text.pStrings ) ;
00994 sciDelThisToItsParent (pobj, sciGetParent (pobj));
00995 sciDelHandle (pobj);
00996 FREE(ppLegend);
00997 FREE(pobj);
00998 return (sciPointObj *) NULL;
00999 }
01000
01001 return pobj;
01002 }
01003 else
01004 {
01005 sciprint ("The parent has to be a SUBWIN \n");
01006 return (sciPointObj *) NULL;
01007 }
01008 }
01009
01010
01011
01015 sciPointObj *
01016 ConstructPolyline (sciPointObj * pparentsubwin, double *pvecx, double *pvecy, double *pvecz,
01017 int closed, int n1, int n2,int plot, int *foreground, int *background,
01018 int *mark_style, int *mark_foreground, int *mark_background,
01019 BOOL isline, BOOL isfilled, BOOL ismark, BOOL isinterpshaded)
01020 {
01021 sciPointObj *pobj = (sciPointObj *) NULL;
01022 sciPolyline *ppoly = (sciPolyline *) NULL;
01023 int i = 0;
01024
01025 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01026 {
01027 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01028 return (sciPointObj *) NULL;
01029 sciSetEntityType (pobj, SCI_POLYLINE);
01030 if ((pobj->pfeatures = MALLOC ((sizeof (sciPolyline)))) == NULL)
01031 {
01032 FREE(pobj);
01033 return (sciPointObj *) NULL;
01034 }
01035 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01036 {
01037 return NULL ;
01038 }
01039 pPOLYLINE_FEATURE (pobj)->x_shift = (double *) NULL;
01040 pPOLYLINE_FEATURE (pobj)->y_shift = (double *) NULL;
01041 pPOLYLINE_FEATURE (pobj)->z_shift = (double *) NULL;
01042 pPOLYLINE_FEATURE (pobj)->bar_width = 0.;
01043
01044 pPOLYLINE_FEATURE (pobj)->callback = (char *)NULL;
01045 pPOLYLINE_FEATURE (pobj)->callbacklen = 0;
01046 pPOLYLINE_FEATURE (pobj)->callbackevent = 100;
01047 pPOLYLINE_FEATURE (pobj)->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01048
01049 pPOLYLINE_FEATURE (pobj)->clip_region_set = 0;
01050 sciInitIsClipping( pobj, sciGetIsClipping((sciPointObj *) sciGetParentSubwin(pobj)) ) ;
01051 sciSetClipping(pobj,sciGetClipping(sciGetParentSubwin(pobj)));
01052
01053
01054 pPOLYLINE_FEATURE (pobj)->arsize_factor = 1;
01055
01056 pPOLYLINE_FEATURE (pobj)->isselected = TRUE;
01057 ppoly = pPOLYLINE_FEATURE (pobj);
01058
01059 if ( n1 != 0 )
01060 {
01061 if ((ppoly->pvx = MALLOC (n1 * sizeof (double))) == NULL)
01062 {
01063 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01064 sciDelHandle (pobj);
01065 FREE(pPOLYLINE_FEATURE(pobj));
01066 FREE(pobj);
01067 return (sciPointObj *) NULL;
01068 }
01069
01070 if ((ppoly->pvy = MALLOC (n1 * sizeof (double))) == NULL)
01071 {
01072 FREE(pPOLYLINE_FEATURE (pobj)->pvx);
01073 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01074 sciDelHandle (pobj);
01075 FREE(pPOLYLINE_FEATURE(pobj));
01076 FREE(pobj);
01077 return (sciPointObj *) NULL;
01078 }
01079
01080 if ((pvecx != (double *)NULL)&&(pvecy != (double *)NULL))
01081 {
01082 for (i = 0; i < n1; i++)
01083 {
01084 ppoly->pvx[i] = pvecx[i] ;
01085 ppoly->pvy[i] = pvecy[i] ;
01086 }
01087 }
01088 else
01089 {
01090 for (i = 0; i < n1; i++)
01091 {
01092 ppoly->pvx[i] = 0.0;
01093 ppoly->pvy[i] = 0.0;
01094 }
01095 }
01096
01097
01099 if (pvecz == (double *) NULL)
01100 {
01101 pPOLYLINE_FEATURE (pobj)->pvz=NULL;
01102 }
01103 else
01104 {
01105 if ((ppoly->pvz = MALLOC (n1 * sizeof (double))) == NULL)
01106 {
01107 FREE(pPOLYLINE_FEATURE (pobj)->pvx);
01108 FREE(pPOLYLINE_FEATURE (pobj)->pvy);
01109 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01110 sciDelHandle (pobj);
01111 FREE(pPOLYLINE_FEATURE(pobj));
01112 FREE(pobj);
01113 return (sciPointObj *) NULL;
01114 }
01115 for (i = 0; i < n1; i++)
01116 {
01117 ppoly->pvz[i] = pvecz[i];
01118 }
01119 }
01120 }
01121 else
01122 {
01123 ppoly->pvx = NULL ;
01124 ppoly->pvy = NULL ;
01125 ppoly->pvz = NULL ;
01126 }
01127
01128 ppoly->n1 = n1;
01129 ppoly->n2 = n2;
01130 ppoly->closed = (closed > 0) ? 1 : 0;
01131 ppoly->plot = plot;
01132
01133 if (sciInitGraphicContext (pobj) == -1)
01134 {
01135 FREE(pPOLYLINE_FEATURE (pobj)->pvy);
01136 FREE(pPOLYLINE_FEATURE (pobj)->pvx);
01137 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01138 sciDelHandle (pobj);
01139 FREE(pPOLYLINE_FEATURE(pobj));
01140 FREE(pobj);
01141 return (sciPointObj *) NULL;
01142 }
01143
01144
01145 sciInitIsMark(pobj,ismark);
01146 sciInitIsLine(pobj,isline);
01147 sciInitIsFilled(pobj,isfilled);
01148
01149
01150 ppoly->isinterpshaded = isinterpshaded;
01151
01152 if(foreground != NULL)
01153 sciInitForeground(pobj,(*foreground));
01154
01155 ppoly->scvector = (int *) NULL;
01156
01157 ppoly->dim_icv = n1;
01158
01159 if(background != NULL){
01160 if(isinterpshaded == TRUE){
01161
01162 sciSetInterpVector(pobj,n1,background);
01163 }
01164 else
01165 sciInitBackground(pobj,(*background));
01166 }
01167
01168 if(mark_style != NULL)
01169 sciInitMarkStyle(pobj,(*mark_style));
01170
01171 if(mark_foreground != NULL)
01172 sciInitMarkForeground(pobj,(*mark_foreground));
01173
01174 if(mark_background != NULL)
01175 sciInitMarkBackground(pobj,(*mark_background));
01176
01177 return pobj;
01178 }
01179 else
01180 {
01181 sciprint ("The parent has to be a SUBWIN \n");
01182 return (sciPointObj *) NULL;
01183 }
01184 }
01185
01186
01187
01191 sciPointObj *
01192 ConstructArc (sciPointObj * pparentsubwin, double x, double y,
01193 double height, double width, double alphabegin, double alphaend,
01194 int *foreground, int *background, BOOL isfilled, BOOL isline)
01195 {
01196 sciPointObj * pobj = (sciPointObj *) NULL;
01197 sciArc * ppArc = NULL ;
01198
01199 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01200 {
01201 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01202 return (sciPointObj *) NULL;
01203 sciSetEntityType (pobj, SCI_ARC);
01204 if ((pobj->pfeatures = MALLOC ((sizeof (sciArc)))) == NULL)
01205 {
01206 FREE(pobj);
01207 return (sciPointObj *) NULL;
01208 }
01209
01210
01211 ppArc = pobj->pfeatures ;
01212
01213 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01214 {
01215 return NULL ;
01216 }
01217
01218 ppArc->callback = (char *)NULL;
01219 ppArc->callbacklen = 0;
01220 ppArc->callbackevent = 100;
01221
01222 ppArc->x = x;
01223 ppArc->y = y;
01224 ppArc->z = 0;
01225 ppArc->height = height;
01226 ppArc->width = width;
01227 ppArc->alphabegin = alphabegin;
01228 ppArc->alphaend = alphaend;
01229 ppArc->isselected = TRUE;
01230 ppArc->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01231
01232 ppArc->clip_region_set = 0;
01233
01234 sciInitIsClipping( pobj, sciGetIsClipping((sciPointObj *) sciGetParentSubwin(pobj)) ) ;
01235 sciSetClipping(pobj,sciGetClipping(sciGetParentSubwin(pobj)));
01236
01237
01238
01239 if (sciInitGraphicContext (pobj) == -1)
01240 {
01241 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01242 sciDelHandle (pobj);
01243 FREE(ppArc);
01244 FREE(pobj);
01245 sciprint("pas de context");
01246 return (sciPointObj *) NULL;
01247 }
01248
01249 sciInitIsFilled(pobj,isfilled);
01250
01251 sciInitIsLine(pobj,isline);
01252
01253 if(foreground != NULL)
01254 {
01255 sciInitForeground(pobj,(*foreground));
01256 }
01257
01258 if(background != NULL)
01259 {
01260 sciInitBackground(pobj,(*background));
01261 }
01262
01263 return pobj;
01264 }
01265 else
01266 {
01267 sciprint ("The parent has to be a SUBWIN \n");
01268 return (sciPointObj *) NULL;
01269 }
01270 }
01271
01272
01273
01277 sciPointObj *
01278 ConstructRectangle (sciPointObj * pparentsubwin, double x, double y,
01279 double height, double width, double horzcurvature,
01280 double vertcurvature, int *foreground, int *background,
01281 int isfilled, int isline, int str, BOOL flagstring)
01282 {
01283 sciPointObj *pobj = (sciPointObj *) NULL;
01284
01285 if ( height < 0.0 || width < 0.0 )
01286 {
01287 Scierror(999,"Width and height must be positive.\n");
01288 return NULL ;
01289 }
01290
01291 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01292 {
01293 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01294 return (sciPointObj *) NULL;
01295 sciSetEntityType (pobj, SCI_RECTANGLE);
01296 if ((pobj->pfeatures = MALLOC ((sizeof (sciRectangle)))) == NULL)
01297 {
01298 FREE(pobj);
01299 return (sciPointObj *) NULL;
01300 }
01301 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01302 {
01303 return NULL ;
01304 }
01305
01306 pRECTANGLE_FEATURE (pobj)->callback = (char *)NULL;
01307 pRECTANGLE_FEATURE (pobj)->callbacklen = 0;
01308 pRECTANGLE_FEATURE (pobj)->callbackevent = 100;
01309
01310
01311 pRECTANGLE_FEATURE (pobj)->flagstring = flagstring;
01312 pRECTANGLE_FEATURE (pobj)->x = x;
01313 pRECTANGLE_FEATURE (pobj)->y = y;
01314 pRECTANGLE_FEATURE (pobj)->z = 0;
01315 pRECTANGLE_FEATURE (pobj)->height = height;
01316 pRECTANGLE_FEATURE (pobj)->width = width;
01317 pRECTANGLE_FEATURE (pobj)->str = str;
01318 pRECTANGLE_FEATURE (pobj)->strheight = 0;
01319 pRECTANGLE_FEATURE (pobj)->strwidth = 0;
01320 pRECTANGLE_FEATURE (pobj)->horzcurvature = horzcurvature;
01321 pRECTANGLE_FEATURE (pobj)->vertcurvature = vertcurvature;
01322 pRECTANGLE_FEATURE (pobj)->isselected = TRUE;
01323 pRECTANGLE_FEATURE (pobj)->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01324
01325 pRECTANGLE_FEATURE (pobj)->clip_region_set = 0;
01326
01327 sciInitIsClipping( pobj, sciGetIsClipping((sciPointObj *) sciGetParentSubwin(pobj)) ) ;
01328 sciSetClipping(pobj,sciGetClipping(sciGetParentSubwin(pobj)));
01329
01330
01331
01332 if (sciInitGraphicContext (pobj) == -1)
01333 {
01334 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01335 sciDelHandle (pobj);
01336 FREE(pRECTANGLE_FEATURE (pobj));
01337 FREE(pobj);
01338 return (sciPointObj *) NULL;
01339 }
01340
01341 sciInitIsLine(pobj,isline);
01342 sciInitIsFilled(pobj,isfilled);
01343
01344 if(foreground != NULL)
01345 sciInitForeground(pobj,(*foreground));
01346
01347 if(background != NULL)
01348 sciInitBackground(pobj,(*background));
01349
01350 return pobj;
01351 }
01352 else
01353 {
01354 sciprint ("The parent has to be a SUBWIN \n");
01355 return (sciPointObj *) NULL;
01356 }
01357 }
01358
01359
01360
01364 sciPointObj *
01365 ConstructSurface (sciPointObj * pparentsubwin, sciTypeOf3D typeof3d,
01366 double * pvecx, double * pvecy, double * pvecz,double *zcol,
01367 integer izcol, integer dimzx, integer dimzy,
01368 integer *flag, double *ebox,integer flagcolor,
01369 integer *isfac, integer *m1, integer *n1, integer *m2,
01370 integer *n2, integer *m3, integer *n3, integer *m3n, integer *n3n)
01371 {
01372 sciPointObj *pobj = (sciPointObj *) NULL;
01373
01374 sciSurface *psurf;
01375
01376 int i=0, j=0;
01377 int nx,ny,nz,nc,izc=izcol;
01378
01379 if (typeof3d == SCI_PLOT3D) {
01380 nx=dimzx;
01381 ny=dimzy;
01382 nz=dimzx*dimzy;
01383 if (flagcolor == 2)
01384 nc=nz;
01385 else if (flagcolor == 3)
01386 nc=nz*4;
01387
01388
01389 else
01390 nc=0;
01391 }
01392
01393 else {
01394 nx=dimzx*dimzy;
01395 ny=dimzx*dimzy;
01396 nz=dimzx*dimzy;
01397 if (flagcolor == 2)
01398 nc=dimzy;
01399 else if (flagcolor == 3)
01400 nc=nz;
01401 else
01402 nc=0;
01403 }
01404
01405
01406 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01407 {
01408 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01409 return (sciPointObj *) NULL;
01410 sciSetEntityType (pobj, SCI_SURFACE);
01411 if ((pobj->pfeatures = MALLOC ((sizeof (sciSurface)))) == NULL)
01412 {
01413 FREE(pobj);
01414 return (sciPointObj *) NULL;
01415 }
01416
01417 psurf = pSURFACE_FEATURE (pobj);
01418 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01419 {
01420 return NULL ;
01421 }
01422
01423 psurf->callback = (char *)NULL;
01424 psurf->callbacklen = 0;
01425 psurf->callbackevent = 100;
01426 psurf->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01427
01428
01429
01430
01431 psurf->nc = nc;
01432 psurf->nx = nx;
01433 psurf->ny = ny;
01434 psurf->nz = nz;
01435 psurf->isfac = *isfac;
01436 psurf->m1= *m1;
01437 psurf->m2= *m2;
01438 psurf->m3= *m3;
01439 psurf->n1= *n1;
01440 psurf->n2= *n2;
01441 psurf->n3= *n3;
01442
01443
01444 psurf->m3n= *m3n;
01445 psurf->n3n= *n3n;
01446
01447 if (((psurf->pvecx = MALLOC ((nx * sizeof (double)))) == NULL))
01448 {
01449 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01450 sciDelHandle (pobj);
01451 FREE(psurf);
01452 FREE(pobj); pobj = NULL;
01453 return (sciPointObj *) NULL;
01454 }
01455 else
01456 {
01457 for (i = 0;i < nx; i++)
01458 psurf->pvecx[i] = pvecx[i];
01459 }
01460 if (((psurf->pvecy = MALLOC ((ny * sizeof (double)))) == NULL))
01461 {
01462 FREE(psurf->pvecx);
01463 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01464 sciDelHandle (pobj);
01465 FREE(psurf);
01466 FREE(pobj); pobj = NULL;
01467 return (sciPointObj *) NULL;
01468 }
01469 else
01470 {
01471 for (j = 0;j < ny; j++)
01472 psurf->pvecy[j] = pvecy[j];
01473 }
01474
01475 if (((psurf->pvecz = MALLOC ((nz * sizeof (double)))) == NULL))
01476 {
01477 FREE(psurf->pvecy);
01478 FREE(psurf->pvecx);
01479 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01480 sciDelHandle (pobj);
01481 FREE(psurf);
01482 FREE(pobj); pobj = NULL;
01483 return (sciPointObj *) NULL;
01484 }
01485 else
01486 {
01487 for (j = 0;j < nz; j++)
01488 psurf->pvecz[j] = pvecz[j];
01489 }
01490
01491
01492 psurf->inputCMoV = NULL;
01493
01494 if((*m3n)*(*n3n) != 0){
01495 if (((psurf->inputCMoV = MALLOC (( (*m3n)*(*n3n) * sizeof (double)))) == NULL))
01496 {
01497 FREE(psurf->pvecy); psurf->pvecy = NULL;
01498 FREE(psurf->pvecx); psurf->pvecx = NULL;
01499 FREE(psurf->pvecz); psurf->pvecz = NULL;
01500 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01501 sciDelHandle (pobj);
01502 FREE(psurf);
01503 FREE(pobj); pobj = NULL;
01504 return (sciPointObj *) NULL;
01505 }
01506 }
01507
01508 for (j = 0;j < (*m3n)*(*n3n); j++)
01509 psurf->inputCMoV[j] = zcol[j];
01510
01511
01512 psurf->zcol = NULL;
01513 psurf->color = NULL;
01514
01515
01516
01517
01518 if (izc !=0&&nc>0 ) {
01519 if (((psurf->zcol = MALLOC ((nc * sizeof (double)))) == NULL))
01520 {
01521 FREE(psurf->pvecy); psurf->pvecy = NULL;
01522 FREE(psurf->pvecx); psurf->pvecx = NULL;
01523 FREE(psurf->pvecz); psurf->pvecz = NULL;
01524 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01525 sciDelHandle (pobj);
01526 FREE(psurf);
01527 FREE(pobj); pobj = NULL;
01528 return (sciPointObj *) NULL;
01529 }
01530 }
01531
01532 if(nc>0)
01533 {
01534
01535 if(flagcolor==2 && ( *m3n==1 || *n3n ==1))
01536 {
01537
01538 for (j = 0;j < nc; j++)
01539 psurf->zcol[j]= psurf->inputCMoV[j];
01540 }
01541 else if(flagcolor==2 && !( *m3n==1 || *n3n ==1))
01542 {
01543
01544
01545
01546
01547 for (j = 0;j < nc; j++)
01548 {
01549 double tmp = 0;
01550 int ii=0;
01551 for(ii=0;ii<(*m3n);ii++)
01552 tmp = tmp + psurf->inputCMoV[j*(*m3n) + ii];
01553 tmp = tmp / (*m3n);
01554 psurf->zcol[j]= tmp;
01555 }
01556 }
01557
01558 else if(flagcolor==3 && ( *m3n==1 || *n3n ==1))
01559 {
01560
01561
01562 for(i = 0; i< dimzy; i++){
01563 for (j = 0;j < dimzx; j++)
01564 psurf->zcol[dimzx*i+j]= psurf->inputCMoV[i];
01565 }
01566 }
01567 else if(flagcolor==3 && !( *m3n==1 || *n3n ==1))
01568 {
01569
01570 for (j = 0;j < nc; j++)
01571 psurf->zcol[j]= psurf->inputCMoV[j];
01572 }
01573
01574
01575
01576
01577 }
01578
01579
01580 psurf->cdatamapping = 1;
01581
01582
01583
01584 if(psurf->cdatamapping == 0){
01585 FREE(psurf->color);
01586 LinearScaling2Colormap(pobj);
01587 }
01588 else{
01589
01590 FREE(psurf->color);
01591
01592 if(nc>0){
01593 if ((psurf->color = MALLOC (nc * sizeof (double))) == NULL)
01594 return (sciPointObj *) NULL;
01595 }
01596
01597 for(i=0;i<nc;i++)
01598 psurf->color[i] = psurf->zcol[i];
01599
01600 }
01601
01602
01603
01604 psurf->dimzx = dimzx;
01605 psurf->dimzy = dimzy;
01606 psurf->izcol = izc;
01607 psurf->isselected = TRUE;
01608
01609 psurf->flag[0] = flag[0];
01610 psurf->flag[1] = flag[1];
01611 psurf->flag[2] = flag[2];
01612
01613
01614
01615 psurf->ebox[0] = ebox[0];
01616 psurf->ebox[1] = ebox[1];
01617 psurf->ebox[2] = ebox[2];
01618 psurf->ebox[3] = ebox[3];
01619 psurf->ebox[4] = ebox[4];
01620 psurf->ebox[5] = ebox[5];
01621 psurf->flagcolor =flagcolor;
01622 psurf->typeof3d = typeof3d;
01623 psurf->hiddencolor = pSUBWIN_FEATURE(pparentsubwin)->hiddencolor;
01624
01625 if (sciInitGraphicContext (pobj) == -1)
01626 {
01627 FREE(psurf->pvecz);
01628 FREE(psurf->pvecy);
01629 FREE(psurf->pvecx);
01630 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01631 sciDelHandle (pobj);
01632 FREE(psurf);
01633 FREE(pobj);
01634 return (sciPointObj *) NULL;
01635 }
01636 pSUBWIN_FEATURE(pparentsubwin)->surfcounter++;
01637 return pobj;
01638 }
01639 else
01640 {
01641 sciprint ("The parent has to be a SUBWIN \n");
01642 return (sciPointObj *) NULL;
01643 }
01644 }
01645
01646
01647
01648 sciPointObj *
01649 ConstructMerge (sciPointObj * pparentsubwin,int N,int *index_in_entity,long *from_entity)
01650 {
01651 sciPointObj *pobj = (sciPointObj *) NULL;
01652
01653 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01654 {
01655 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL) return (sciPointObj *) NULL;
01656
01657 sciSetEntityType (pobj, SCI_MERGE);
01658 if ((pobj->pfeatures = MALLOC ((sizeof (sciMerge)))) == NULL) {
01659 FREE(pobj);
01660 return (sciPointObj *) NULL;
01661 }
01662 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01663 {
01664 return NULL ;
01665 }
01666 pMERGE_FEATURE (pobj)->index_in_entity=index_in_entity;
01667 pMERGE_FEATURE (pobj)->from_entity=from_entity;
01668 pMERGE_FEATURE (pobj)->N=N;
01669 return pobj;
01670 }
01671 else
01672 {
01673 return NULL;
01674 }
01675 }
01676
01677
01678
01679
01680
01681
01682
01683 sciPointObj *
01684 ConstructGrayplot (sciPointObj * pparentsubwin, double *pvecx, double *pvecy,
01685 double *pvecz, int n1, int n2, int type)
01686 {
01687 sciPointObj *pobj = (sciPointObj *) NULL;
01688 sciGrayplot *pgray = (sciGrayplot *) NULL;
01689 int i = 0,cmpt;
01690
01691 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01692 {
01693 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01694 return (sciPointObj *) NULL;
01695 sciSetEntityType (pobj, SCI_GRAYPLOT);
01696 if ((pobj->pfeatures = MALLOC ((sizeof (sciGrayplot)))) == NULL)
01697 {
01698 FREE(pobj);
01699 return (sciPointObj *) NULL;
01700 }
01701 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01702 {
01703 return NULL ;
01704 }
01705
01706 pGRAYPLOT_FEATURE (pobj)->callback = (char *)NULL;
01707 pGRAYPLOT_FEATURE (pobj)->callbacklen = 0;
01708 pGRAYPLOT_FEATURE (pobj)->callbackevent = 100;
01709
01710 pGRAYPLOT_FEATURE (pobj)->isselected = TRUE;
01711 pGRAYPLOT_FEATURE (pobj)->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01712
01713 pGRAYPLOT_FEATURE (pobj)->type = type;
01714 pGRAYPLOT_FEATURE (pobj)->pvecx = (double *)NULL;
01715 pGRAYPLOT_FEATURE (pobj)->pvecy = (double *)NULL;
01716
01717 strcpy( pGRAYPLOT_FEATURE (pobj)->datamapping, "scaled" ) ;
01718 pgray = pGRAYPLOT_FEATURE (pobj);
01719
01720 if (pvecx && (pgray->pvecx = MALLOC (n1 * sizeof (double))) == NULL)
01721 {
01722 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01723 sciDelHandle (pobj);
01724 FREE(pGRAYPLOT_FEATURE(pobj));
01725 FREE(pobj);
01726 return (sciPointObj *) NULL;
01727 }
01728 cmpt = (type == 2)? 4:n2 ;
01729 if (type != 2)
01730 if (pvecy && (pgray->pvecy = MALLOC (cmpt * sizeof (double))) == NULL)
01731 {
01732 if (pvecx) FREE(pGRAYPLOT_FEATURE (pobj)->pvecx);
01733 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01734 sciDelHandle (pobj);
01735 FREE(pGRAYPLOT_FEATURE(pobj));
01736 FREE(pobj);
01737 return (sciPointObj *) NULL;
01738 }
01739 if ((pgray->pvecz = MALLOC ((n1*n2) * sizeof (double))) == NULL){
01740 if (pvecx) FREE(pGRAYPLOT_FEATURE (pobj)->pvecx);
01741 if (pvecy) FREE(pGRAYPLOT_FEATURE (pobj)->pvecy);
01742 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01743 sciDelHandle (pobj);
01744 FREE(pGRAYPLOT_FEATURE(pobj));
01745 FREE(pobj);
01746 return (sciPointObj *) NULL;
01747 }
01748 if (pvecx) {
01749 for (i = 0; i < n1; i++) pgray->pvecx[i] = pvecx[i];
01750 }
01751
01752
01753 if (pvecy) {
01754 if (type != 2)
01755 for (i = 0; i < n2; i++) pgray->pvecy[i] = pvecy[i];
01756 }
01757
01758 pgray->nx = n1;pgray->ny = n2;
01759 for (i = 0; i < (n1*n2); i++) pgray->pvecz[i] = pvecz[i];
01760
01761 if (sciInitGraphicContext (pobj) == -1)
01762 {
01763 if (pvecx) FREE(pGRAYPLOT_FEATURE (pobj)->pvecx);
01764 if (pvecy) FREE(pGRAYPLOT_FEATURE (pobj)->pvecy);
01765 FREE(pGRAYPLOT_FEATURE (pobj)->pvecz);
01766 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01767 sciDelHandle (pobj);
01768 FREE(pGRAYPLOT_FEATURE(pobj));
01769 FREE(pobj);
01770 return (sciPointObj *) NULL;
01771 }
01772 return pobj;
01773 }
01774 else
01775 {
01776 sciprint ("The parent has to be a SUBWIN \n");
01777 return (sciPointObj *) NULL;
01778 }
01779 }
01780
01781
01782
01783
01784
01791 sciPointObj *
01792 ConstructAxes (sciPointObj * pparentsubwin, char dir, char tics, double *vx,
01793 int nx, double *vy, int ny,char **str, int subint, char *format,
01794 int fontsize, int textcolor, int ticscolor, char logscale, int seg, int nb_tics_labels)
01795 {
01796 sciPointObj *pobj = (sciPointObj *) NULL;
01797 sciAxes *paxes = (sciAxes *) NULL;
01798 int i;
01799
01800 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01801 {
01802 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01803 return (sciPointObj *) NULL;
01804 sciSetEntityType (pobj, SCI_AXES);
01805 if ((pobj->pfeatures = MALLOC ((sizeof (sciAxes)))) == NULL)
01806 {
01807 FREE(pobj);
01808 return (sciPointObj *) NULL;
01809 }
01810 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01811 {
01812 return NULL ;
01813 }
01814
01815 pAXES_FEATURE (pobj)->callback = (char *)NULL;
01816 pAXES_FEATURE (pobj)->callbacklen = 0;
01817 pAXES_FEATURE (pobj)->callbackevent = 100;
01818 pAXES_FEATURE (pobj)->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01819
01820
01821 pAXES_FEATURE (pobj)->clip_region_set = 0;
01822
01823 sciInitIsClipping( pobj, -1 ) ;
01824 sciSetClipping(pobj,sciGetClipping(sciGetParentSubwin(pobj)));
01825
01826
01827 pAXES_FEATURE (pobj)->dir =dir;
01828 pAXES_FEATURE (pobj)->tics =tics;
01829
01830 paxes = pAXES_FEATURE (pobj);
01831 if ((paxes->vector = MALLOC (Max(nx,ny) * sizeof (POINT2D))) == NULL)
01832 {
01833 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01834 sciDelHandle (pobj);
01835 FREE(pPOLYLINE_FEATURE(pobj));
01836 FREE(pobj);
01837 return (sciPointObj *) NULL;
01838 }
01839
01840 if ((paxes->vx = MALLOC (nx * sizeof (double))) == NULL)
01841 {
01842 FREE(pAXES_FEATURE (pobj)->vector);
01843 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01844 sciDelHandle (pobj);
01845 FREE(pAXES_FEATURE(pobj));
01846 FREE(pobj);
01847 return (sciPointObj *) NULL;
01848 }
01849 if ((paxes->vy = MALLOC (ny * sizeof (double))) == NULL)
01850 {
01851 FREE(pAXES_FEATURE (pobj)->vector);
01852 FREE(pAXES_FEATURE (pobj)->vx);
01853 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01854 sciDelHandle (pobj);
01855 FREE(pAXES_FEATURE(pobj));
01856 FREE(pobj);
01857 return (sciPointObj *) NULL;
01858 }
01859
01860 for (i = 0; i < nx; i++)
01861 {
01862 paxes->vx[i] = vx[i];
01863 }
01864 for (i = 0; i < ny; i++)
01865 {
01866 paxes->vy[i] = vy[i];
01867 }
01868
01869
01870
01871 pAXES_FEATURE (pobj)->nx =nx;
01872
01873
01874 pAXES_FEATURE (pobj)->ny =ny;
01875
01876 pAXES_FEATURE (pobj)->nb_tics_labels = nb_tics_labels;
01877
01878
01879 if(str != (char **) NULL)
01880 {
01881 if(pAXES_FEATURE (pobj)->nb_tics_labels == -1){
01882 sciprint("Impossible case when buyilding axis\n");
01883 return (sciPointObj *) NULL;
01884 }
01885
01886 if ((pAXES_FEATURE(pobj)->str= MALLOC (pAXES_FEATURE (pobj)->nb_tics_labels * sizeof (char*))) == NULL)
01887 return (sciPointObj *) NULL;
01888
01889 for(i=0;i<pAXES_FEATURE (pobj)->nb_tics_labels;i++)
01890 {
01891 if(str[i] != (char *) NULL)
01892 {
01893 if((pAXES_FEATURE (pobj)->str[i] = MALLOC( (strlen(str[i])+1) * sizeof(char))) == NULL)
01894 return (sciPointObj *) NULL;
01895 else
01896 strcpy(pAXES_FEATURE (pobj)->str[i],str[i]);
01897 }
01898 else
01899 pAXES_FEATURE (pobj)->str[i] = (char *) NULL;
01900 }
01901 }
01902 else
01903 {
01904 pAXES_FEATURE (pobj)->str = (char **) NULL;
01905 }
01906
01907 pAXES_FEATURE (pobj)->subint = subint;
01908 pAXES_FEATURE (pobj)->fontsize =fontsize;
01909 pAXES_FEATURE (pobj)->textcolor =textcolor;
01910 pAXES_FEATURE (pobj)->ticscolor =ticscolor;
01911 pAXES_FEATURE (pobj)->seg =seg;
01912
01913 pAXES_FEATURE (pobj)->logscale=logscale;
01914 if(format != (char *) NULL)
01915 {
01916 if((pAXES_FEATURE (pobj)->format = MALLOC( (strlen(format)+1) * sizeof(char))) == NULL)
01917 return (sciPointObj *) NULL;
01918 else
01919 strcpy(pAXES_FEATURE (pobj)->format,format);
01920 }
01921 else
01922 pAXES_FEATURE (pobj)->format = (char *) NULL;
01923
01924 if (sciInitGraphicContext (pobj) == -1)
01925 {
01926 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01927 sciDelHandle (pobj);
01928 FREE(pAXES_FEATURE (pobj));
01929 FREE(pobj);
01930 return (sciPointObj *) NULL;
01931 }
01932
01933
01934 return pobj;
01935 }
01936 else
01937 {
01938 sciprint ("The parent has to be a SUBWIN \n");
01939 return (sciPointObj *) NULL;
01940 }
01941 }
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951 sciPointObj *
01952 ConstructFec (sciPointObj * pparentsubwin, double *pvecx, double *pvecy, double *pnoeud,
01953 double *pfun, int Nnode, int Ntr, double *zminmax, integer *colminmax,
01954 integer *colout, BOOL with_mesh)
01955 {
01956 sciPointObj *pobj = (sciPointObj *) NULL;
01957 sciFec *pfec = (sciFec *) NULL;
01958 int i = 0;
01959
01960 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
01961 {
01962 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
01963 return (sciPointObj *) NULL;
01964 sciSetEntityType (pobj, SCI_FEC);
01965 if ((pobj->pfeatures = MALLOC ((sizeof (sciFec)))) == NULL)
01966 {
01967 FREE(pobj);
01968 return (sciPointObj *) NULL;
01969 }
01970 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
01971 {
01972 return NULL ;
01973 }
01974
01975 pFEC_FEATURE (pobj)->callback = (char *)NULL;
01976 pFEC_FEATURE (pobj)->callbacklen = 0;
01977 pFEC_FEATURE (pobj)->callbackevent = 100;
01978
01979 pFEC_FEATURE (pobj)->isselected = TRUE;
01980 pFEC_FEATURE (pobj)->visible = sciGetVisibility(sciGetParentSubwin(pobj));
01981
01982 pfec = pFEC_FEATURE (pobj);
01983
01984 if ((pfec->pvecx = MALLOC (Nnode * sizeof (double))) == NULL)
01985 {
01986 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01987 sciDelHandle (pobj);
01988 FREE(pFEC_FEATURE(pobj));
01989 FREE(pobj);
01990 return (sciPointObj *) NULL;
01991 }
01992 if ((pfec->pvecy = MALLOC (Nnode * sizeof (double))) == NULL)
01993 {
01994 FREE(pFEC_FEATURE (pobj)->pvecx);
01995 sciDelThisToItsParent (pobj, sciGetParent (pobj));
01996 sciDelHandle (pobj);
01997 FREE(pFEC_FEATURE(pobj));
01998 FREE(pobj);
01999 return (sciPointObj *) NULL;
02000 }
02001 if ((pfec->pnoeud = MALLOC ((5*Ntr) * sizeof (double))) == NULL)
02002 {
02003 FREE(pFEC_FEATURE (pobj)->pvecx);
02004 FREE(pFEC_FEATURE (pobj)->pvecy);
02005 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02006 sciDelHandle (pobj);
02007 FREE(pFEC_FEATURE(pobj));
02008 FREE(pobj);
02009 return (sciPointObj *) NULL;
02010 }
02011 if ((pfec->pfun = MALLOC (Nnode * sizeof (double))) == NULL)
02012 {
02013 FREE(pFEC_FEATURE (pobj)->pvecx);
02014 FREE(pFEC_FEATURE (pobj)->pvecy);
02015 FREE(pFEC_FEATURE (pobj)->pnoeud);
02016 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02017 sciDelHandle (pobj);
02018 FREE(pFEC_FEATURE(pobj));
02019 FREE(pobj);
02020 return (sciPointObj *) NULL;
02021 }
02022 if ((pfec->zminmax = MALLOC (2 * sizeof (double))) == NULL)
02023 {
02024 FREE(pFEC_FEATURE (pobj)->pvecx);
02025 FREE(pFEC_FEATURE (pobj)->pvecy);
02026 FREE(pFEC_FEATURE (pobj)->pnoeud);
02027 FREE(pFEC_FEATURE (pobj)->pfun);
02028 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02029 sciDelHandle (pobj);
02030 FREE(pFEC_FEATURE(pobj));
02031 FREE(pobj);
02032 return (sciPointObj *) NULL;
02033 }
02034 if ((pfec->colminmax = MALLOC (2 * sizeof (integer))) == NULL)
02035 {
02036 FREE(pFEC_FEATURE (pobj)->pvecx);
02037 FREE(pFEC_FEATURE (pobj)->pvecy);
02038 FREE(pFEC_FEATURE (pobj)->pnoeud);
02039 FREE(pFEC_FEATURE (pobj)->pfun);
02040 FREE(pFEC_FEATURE (pobj)->zminmax);
02041 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02042 sciDelHandle (pobj);
02043 FREE(pFEC_FEATURE(pobj));
02044 FREE(pobj);
02045 return (sciPointObj *) NULL;
02046 }
02047
02048 if ((pfec->colout = MALLOC (2 * sizeof (integer))) == NULL)
02049 {
02050 FREE(pFEC_FEATURE (pobj)->pvecx);
02051 FREE(pFEC_FEATURE (pobj)->pvecy);
02052 FREE(pFEC_FEATURE (pobj)->pnoeud);
02053 FREE(pFEC_FEATURE (pobj)->pfun);
02054 FREE(pFEC_FEATURE (pobj)->zminmax);
02055 FREE(pFEC_FEATURE (pobj)->colminmax);
02056 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02057 sciDelHandle (pobj);
02058 FREE(pFEC_FEATURE(pobj));
02059 FREE(pobj);
02060 return (sciPointObj *) NULL;
02061 }
02062
02063 for (i = 0; i < Nnode; i++)
02064 {
02065 pfec->pvecx[i] = pvecx[i];
02066 pfec->pvecy[i] = pvecy[i];
02067 pfec->pfun[i] = pfun[i];
02068 }
02069 for (i = 0; i < (5*Ntr); i++)
02070 {
02071 pfec->pnoeud[i] = pnoeud[i];
02072 }
02073 for (i = 0; i < 2; i++)
02074 {
02075 pfec->zminmax[i] = zminmax[i];
02076 pfec->colminmax[i] = colminmax[i];
02077 pfec->colout[i] = colout[i];
02078 }
02079 pfec->with_mesh = with_mesh;
02080 pfec->Nnode = Nnode;
02081 pfec->Ntr = Ntr;
02082 if (sciInitGraphicContext (pobj) == -1)
02083 {
02084 FREE(pFEC_FEATURE (pobj)->pvecx);
02085 FREE(pFEC_FEATURE (pobj)->pvecy);
02086 FREE(pFEC_FEATURE (pobj)->pnoeud);
02087 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02088 sciDelHandle (pobj);
02089 FREE(pFEC_FEATURE(pobj));
02090 FREE(pobj);
02091 return (sciPointObj *) NULL;
02092 }
02093 return pobj;
02094 }
02095 else
02096 {
02097 sciprint ("The parent has to be a SUBWIN \n");
02098 return (sciPointObj *) NULL;
02099 }
02100 }
02101
02102
02103
02110 sciPointObj *
02111 ConstructSegs (sciPointObj * pparentsubwin, integer type,double *vx, double *vy,
02112 integer Nbr1,integer Nbr2, double *vfx, double *vfy, integer flag,
02113 integer *style, double arsize, integer colored, double arfact, int typeofchamp)
02114 {
02115 sciPointObj *pobj = (sciPointObj *) NULL;
02116 sciSegs * ppSegs = (sciSegs *) NULL;
02117 integer i;
02118
02119 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
02120 {
02121 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
02122 return (sciPointObj *) NULL;
02123 sciSetEntityType (pobj, SCI_SEGS);
02124 if ((pobj->pfeatures = MALLOC ((sizeof (sciSegs)))) == NULL)
02125 {
02126 FREE(pobj);
02127 return (sciPointObj *) NULL;
02128 }
02129 if ( sciStandrardBuildOperations( pobj, pparentsubwin ) == NULL )
02130 {
02131 return NULL ;
02132 }
02133
02134 ppSegs = pSEGS_FEATURE(pobj) ;
02135
02136 ppSegs->callback = (char *)NULL;
02137 ppSegs->callbacklen = 0;
02138 ppSegs->callbackevent = 100;
02139
02140 ppSegs->isselected = TRUE;
02141 ppSegs->visible = sciGetVisibility(sciGetParentSubwin(pobj));
02142
02143
02144
02145 ppSegs->clip_region_set = 0;
02146 sciInitIsClipping( pobj, sciGetIsClipping(sciGetParentSubwin(pobj) ));
02147 sciSetClipping(pobj,sciGetClipping(sciGetParentSubwin(pobj)));
02148
02149
02150 ppSegs = pSEGS_FEATURE (pobj);
02151 ppSegs->ptype = type;
02152
02153 ppSegs->pstyle = NULL ;
02154
02155 if ((ppSegs->vx = MALLOC (Nbr1 * sizeof (double))) == NULL)
02156 {
02157 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02158 sciDelHandle (pobj);
02159 FREE(ppSegs);
02160 FREE(pobj);
02161 return (sciPointObj *) NULL;
02162 }
02163 if ((ppSegs->vy = MALLOC (Nbr2 * sizeof (double))) == NULL)
02164 {
02165 FREE(ppSegs->vx);
02166 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02167 sciDelHandle (pobj);
02168 FREE(ppSegs);
02169 FREE(pobj);
02170 return (sciPointObj *) NULL;
02171 }
02172
02173 for (i = 0; i < Nbr1; i++)
02174 {
02175 ppSegs->vx[i] = vx[i];
02176 }
02177 for (i = 0; i < Nbr2; i++)
02178 {
02179 ppSegs->vy[i] = vy[i];
02180 }
02181 pSEGS_FEATURE (pobj)->vz=(double *) NULL;
02182 ppSegs->ptype = type;
02183
02184
02185 if (type == 0)
02186 {
02187 ppSegs->typeofchamp = -1;
02188 ppSegs->arrowsize = arsize ;
02189 if ((ppSegs->pstyle = MALLOC (Nbr1 * sizeof (integer))) == NULL)
02190 {
02191 FREE(ppSegs->vx);
02192 FREE(ppSegs->vy);
02193 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02194 sciDelHandle (pobj);
02195 FREE(ppSegs);
02196 FREE(pobj);
02197 return (sciPointObj *) NULL;
02198 }
02199 if (flag == 1)
02200 {
02201 for (i = 0; i < Nbr1; i++)
02202 {
02203 ppSegs->pstyle[i] = style[i];
02204 }
02205 }
02206 else
02207 {
02208 for (i = 0; i < Nbr1; i++)
02209 {
02210 ppSegs->pstyle[i] = style[0];
02211 }
02212 }
02213
02214 ppSegs->iflag = flag;
02215 ppSegs->Nbr1 = Nbr1;
02216 }
02217 else
02218 {
02219
02220 ppSegs->arrowsize = arsize ;
02221 ppSegs->Nbr1 = Nbr1;
02222 ppSegs->Nbr2 = Nbr2;
02223 sciInitForeground(pobj,sciGetForeground(sciGetCurrentSubWin()));
02224 ppSegs->typeofchamp = typeofchamp;
02225 ppSegs->parfact = arfact;
02226 if ((ppSegs->vfx = MALLOC ((Nbr1*Nbr2) * sizeof (double))) == NULL)
02227 {
02228 FREE(ppSegs->vx);
02229 FREE(ppSegs->vy);
02230 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02231 sciDelHandle (pobj);
02232 FREE(ppSegs);
02233 FREE(pobj);
02234 return (sciPointObj *) NULL;
02235 }
02236 if ((ppSegs->vfy = MALLOC ((Nbr1*Nbr2) * sizeof (double))) == NULL)
02237 {
02238 FREE(ppSegs->vx);
02239 FREE(ppSegs->vy);
02240 FREE(ppSegs->vfx);
02241 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02242 sciDelHandle (pobj);
02243 FREE(ppSegs);
02244 FREE(pobj);
02245 return (sciPointObj *) NULL;
02246 }
02247
02248 for (i = 0; i < (Nbr1*Nbr2); i++)
02249 {
02250 ppSegs->vfx[i] = vfx[i];
02251 ppSegs->vfy[i] = vfy[i];
02252 }
02253 pSEGS_FEATURE (pobj)->vfz=(double *) NULL;
02254 }
02255 if (sciInitGraphicContext (pobj) == -1)
02256 {
02257 FREE(ppSegs->vx);
02258 FREE(ppSegs->vy);
02259 if (type ==0)
02260 {
02261 FREE(ppSegs->pstyle);
02262 }
02263 else
02264 {
02265 FREE(ppSegs->vfx);
02266 FREE(ppSegs->vfy);
02267 }
02268 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02269 sciDelHandle (pobj);
02270 FREE(ppSegs);
02271 FREE(pobj);
02272 return (sciPointObj *) NULL;
02273 }
02274 return pobj;
02275 }
02276 else
02277 {
02278 sciprint ("The parent has to be a SUBWIN \n");
02279 return (sciPointObj *) NULL;
02280 }
02281 }
02282
02283
02289 sciPointObj *
02290 ConstructCompound (long *handelsvalue, int number)
02291 {
02292
02293 sciPointObj * pobj ;
02294 sciAgreg * ppCompound ;
02295 int i;
02296 long xtmp;
02297
02298
02299 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
02300 return (sciPointObj *) NULL;
02301
02302 sciSetEntityType (pobj, SCI_AGREG);
02303 if ((pobj->pfeatures = MALLOC ((sizeof (sciAgreg)))) == NULL)
02304 return (sciPointObj *) NULL;
02305
02306
02307 ppCompound = pAGREG_FEATURE (pobj) ;
02308
02309 if ( sciStandrardBuildOperations( pobj, sciGetParent(sciGetPointerFromHandle( (long) handelsvalue[0])) ) == NULL )
02310 {
02311 return NULL ;
02312 }
02313
02314 ppCompound->callback = (char *)NULL;
02315 ppCompound->callbacklen = 0;
02316 ppCompound->visible = sciGetVisibility(sciGetParentSubwin(pobj));
02317
02318
02319
02320
02321 xtmp = (long) handelsvalue[0];
02322 for ( i = 0 ; i < number ; i++ )
02323 {
02324
02325
02326
02327
02328 sciPointObj * movedObject ;
02329 xtmp = handelsvalue[i] ;
02330 movedObject = sciGetPointerFromHandle(xtmp) ;
02331 if ( movedObject != NULL )
02332 {
02333 sciDelThisToItsParent( movedObject, sciGetParent(movedObject) ) ;
02334 sciAddThisToItsParent( movedObject, pobj ) ;
02335 }
02336 }
02337
02338
02339 ppCompound->isselected = TRUE;
02340
02341 return (sciPointObj *)pobj;
02342 }
02343
02353 sciPointObj *
02354 ConstructCompoundSeq (int number)
02355 {
02356 sciSons *sons, *lastsons;
02357 sciPointObj *pobj;
02358 int i;
02359
02360 sciPointObj *psubwin;
02361 sciSubWindow *ppsubwin;
02362 sciAgreg *ppagr;
02363
02364 psubwin = sciGetCurrentSubWin();
02365 ppsubwin=pSUBWIN_FEATURE(psubwin);
02366
02367
02368 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
02369 return (sciPointObj *) NULL;
02370
02371 sciSetEntityType (pobj, SCI_AGREG);
02372 if ((pobj->pfeatures = MALLOC ((sizeof (sciAgreg)))) == NULL)
02373 return (sciPointObj *) NULL;
02374 ppagr=pAGREG_FEATURE(pobj);
02375
02376 if (sciAddNewHandle (pobj) == -1)
02377 {
02378 sciprint("no handle to allocate\n");
02379 FREE(pobj->pfeatures);FREE(pobj);
02380 return (sciPointObj *) NULL;
02381 }
02382
02383
02384 sons=ppsubwin->relationship.psons;
02385
02386 if (sons->pprev != (sciSons *)NULL) {
02387 sciprint("Unexpected case, please report\n");
02388 FREE(pobj->pfeatures);FREE(pobj);
02389 return (sciPointObj *) NULL;
02390 }
02391
02392
02393 lastsons=sons;
02394
02395
02396
02397
02398 for (i=0;i<number;i++) {
02399
02400
02401
02402
02403 (sciGetRelationship (lastsons->pointobj))->pparent=pobj;
02404 lastsons=lastsons->pnext;
02405 }
02406
02407 lastsons=lastsons->pprev;
02408
02409
02410 ppsubwin->relationship.psons = lastsons->pnext;
02411 ppsubwin->relationship.psons->pprev = (sciSons *)NULL;
02412
02413
02414 if (!(sciAddThisToItsParent (pobj, (sciPointObj *)psubwin))) {
02415 FREE(pobj->pfeatures);FREE(pobj);
02416 return (sciPointObj *) NULL;
02417 }
02418 sciInitSelectedSons(pobj);
02419
02420
02421
02422 ppagr->user_data = (int *) NULL;
02423 ppagr->size_of_user_data = 0;
02424 ppagr->callback = (char *)NULL;
02425 ppagr->callbacklen = 0;
02426 ppagr->visible = sciGetVisibility (sciGetParentFigure(pobj));
02427
02428 ppagr->isselected = TRUE;
02429
02430
02431 ppagr->relationship.psons = sons;
02432
02433 ppagr->relationship.plastsons = lastsons;
02434 ppagr->relationship.plastsons->pnext = (sciSons *)NULL;
02435 ppagr->relationship.psons->pprev = (sciSons *)NULL;
02436
02437
02438
02439 return (sciPointObj *)pobj;
02440 }
02441
02442
02443
02451 sciPointObj *
02452 ConstructLabel (sciPointObj * pparentsubwin, char *text, int type)
02453 {
02454 sciPointObj * pobj = NULL;
02455
02456 sciLabel * ppLabel ;
02457 char * emptyString = "" ;
02458 int defaultColor = 0 ;
02459
02460 if (sciGetEntityType (pparentsubwin) == SCI_SUBWIN)
02461 {
02462 if ((pobj = MALLOC (sizeof (sciPointObj))) == NULL)
02463 {
02464 return (sciPointObj *) NULL;
02465 }
02466
02467 sciSetEntityType (pobj, SCI_LABEL);
02468 if ((pobj->pfeatures = MALLOC ((sizeof (sciLabel)))) == NULL)
02469 {
02470 FREE(pobj);
02471 return (sciPointObj *) NULL;
02472 }
02473
02474 ppLabel = pLABEL_FEATURE( pobj ) ;
02475
02476 ppLabel->text = allocateText( pparentsubwin, &emptyString, 1, 1,
02477 0.0, 0.0, TRUE, NULL, FALSE, &defaultColor, &defaultColor,
02478 FALSE, FALSE, FALSE, ALIGN_LEFT ) ;
02479
02480 if ( ppLabel->text == NULL )
02481 {
02482 FREE(ppLabel);
02483 FREE(pobj);
02484 return NULL ;
02485 }
02486
02487 if (sciAddNewHandle (pobj) == -1)
02488 {
02489 deallocateText( ppLabel->text ) ;
02490 FREE(ppLabel);
02491 FREE(pobj);
02492 return NULL;
02493 }
02494
02495 if (!(sciAddThisToItsParent (pobj, pparentsubwin)))
02496 {
02497 deallocateText( ppLabel->text ) ;
02498 sciDelHandle (pobj);
02499 FREE(ppLabel);
02500 FREE(pobj);
02501 return NULL;
02502 }
02503
02504 sciInitSelectedSons(pobj);
02505 sciInitIsFilled(pobj,FALSE);
02506
02507 sciInitIs3d( pobj, FALSE ) ;
02508
02509 ppLabel->ptype = type;
02510 ppLabel->auto_position = TRUE;
02511 ppLabel->auto_rotation = TRUE;
02512
02513 ppLabel->isselected = TRUE;
02514 if (sciInitFontContext (pobj) == -1)
02515 {
02516 DestroyLabel( pobj ) ;
02517 return (sciPointObj *) NULL;
02518 }
02519
02520 return (sciPointObj *) pobj;
02521 }
02522 else
02523 {
02524 sciprint ("The parent has to be a SUBWIN \n");
02525 return (sciPointObj *) NULL;
02526 }
02527 }
02528
02529
02533 sciPointObj *
02534 ConstructMenu (sciPointObj * pparentfigure, char plabel[], int n)
02535 {
02536 sciPointObj *pobj = (sciPointObj *) NULL;
02537
02538 if (sciGetEntityType (pparentfigure) == SCI_FIGURE)
02539 {
02540 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
02541 return (sciPointObj *) NULL;
02542 sciSetEntityType (pobj, SCI_MENU);
02543 if ((pobj->pfeatures = MALLOC ((sizeof (sciMenu)))) == NULL)
02544 {
02545 FREE(pobj);
02546 return (sciPointObj *) NULL;
02547 }
02548
02549 if ( sciStandrardBuildOperations( pobj, pparentfigure ) == NULL )
02550 {
02551 return NULL ;
02552 }
02553
02554 if (sciAddLabelMenu (pobj, plabel, n) == -1)
02555 {
02556 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02557 sciDelHandle (pobj);
02558 FREE(pMENU_FEATURE (pobj));
02559 FREE(pobj);
02560 return (sciPointObj *) NULL;
02561 }
02562
02563 if (sciInitGraphicContext (pobj) == -1)
02564 {
02565 sciDelLabelsMenu (pobj);
02566 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02567 sciDelHandle (pobj);
02568 FREE(pMENU_FEATURE (pobj));
02569 FREE(pobj);
02570 return (sciPointObj *) NULL;
02571 }
02572 sciInitFontContext (pobj);
02573
02574 return (sciPointObj *) pobj;
02575 }
02576 else
02577 {
02578 sciprint ("The parent has to be a SUBWIN \n");
02579 return (sciPointObj *) NULL;
02580 }
02581 }
02582
02583
02590 sciPointObj *
02591 ConstructMenuContext (sciPointObj * pparentfigure)
02592 {
02593 sciPointObj *pobj = (sciPointObj *) NULL;
02594
02595 if (sciGetEntityType (pparentfigure) == SCI_FIGURE)
02596 {
02597 if ((pobj = MALLOC ((sizeof (sciPointObj)))) == NULL)
02598 return (sciPointObj *) NULL;
02599 sciSetEntityType (pobj, SCI_MENUCONTEXT);
02600 if ((pobj->pfeatures = MALLOC ((sizeof (sciMenuContext)))) == NULL)
02601 {
02602 FREE(pobj);
02603 return (sciPointObj *) NULL;
02604 }
02605 if ( sciStandrardBuildOperations( pobj, pparentfigure ) == NULL )
02606 {
02607 return NULL ;
02608 }
02609
02610 if (sciInitGraphicContext (pobj) == -1)
02611 {
02612 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02613 sciDelHandle (pobj);
02614 FREE(pMENUCONTEXT_FEATURE (pobj));
02615 FREE(pobj);
02616 return (sciPointObj *) NULL;
02617 }
02618 sciInitFontContext (pobj);
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634 return (sciPointObj *) pobj;
02635 }
02636 else
02637 {
02638 sciprint ("The parent has to be a SUBWIN \n");
02639 return (sciPointObj *) NULL;
02640 }
02641 }
02642
02643
02644
02650 int
02651 sciAddLabelMenu (sciPointObj * pthis, char plabel[], int n)
02652 {
02653 sciLabelMenu *pscilabelmenutmp;
02654
02655 switch (sciGetEntityType (pthis))
02656 {
02657 case SCI_MENU:
02658 pscilabelmenutmp = (sciLabelMenu *) (pMENU_FEATURE (pthis)->plabelmenu);
02659 break;
02660 case SCI_MENUCONTEXT:
02661 pscilabelmenutmp =
02662 (sciLabelMenu *) (pMENUCONTEXT_FEATURE (pthis)->plabelmenu);
02663 break;
02664 case SCI_AGREG:
02665 default:
02666 return -1;
02667 break;
02668 }
02669 while (pscilabelmenutmp != (sciLabelMenu *) NULL)
02670 pscilabelmenutmp = (sciLabelMenu *) pscilabelmenutmp->pnextlabelmenu;
02671 if ((pscilabelmenutmp = MALLOC (sizeof (sciLabelMenu))) == NULL)
02672 return -1;
02673 if ((pscilabelmenutmp->plabel = CALLOC (n+1, sizeof (char))) == NULL)
02674 {
02675 sciprint("\nNo more place to allocates text string, try a shorter string\n");
02676 return -1;
02677 }
02678 strncpy (pscilabelmenutmp->plabel, plabel, n);
02679 pscilabelmenutmp->pnextlabelmenu = (sciLabelMenu *) NULL;
02680 return 0;
02681 }
02682
02683
02684
02685
02686
02687
02688 int
02689 sciAttachPopMenu (sciPointObj *pthis, sciPointObj *pPopMenu)
02690 {
02691
02692
02693 if (sciGetEntityType(pPopMenu) == SCI_MENUCONTEXT)
02694 {
02695
02696
02697 switch(sciGetEntityType(pthis)) {
02698 case SCI_SUBWIN:
02699 pSUBWIN_FEATURE (pthis)->pPopMenu = pPopMenu;
02700 return 0;
02701 break;
02702 case SCI_MENUCONTEXT:
02703 case SCI_FIGURE:
02704 case SCI_TEXT:
02705 case SCI_TITLE:
02706 case SCI_LEGEND:
02707 case SCI_ARC:
02708 case SCI_SEGS:
02709 case SCI_FEC:
02710 case SCI_GRAYPLOT:
02711 case SCI_POLYLINE:
02712 case SCI_RECTANGLE:
02713 case SCI_SURFACE:
02714 case SCI_LIGHT:
02715 case SCI_AXES:
02716 case SCI_PANNER:
02717 case SCI_SBH:
02718 case SCI_SBV:
02719 case SCI_MENU:
02720 case SCI_STATUSB:
02721 case SCI_AGREG:
02722 case SCI_LABEL:
02723 default:
02724 return -1;
02725 break;
02726 }
02727 }
02728 sciprint("Your second entity is not a popup menu !\n");
02729 return -1;
02730 }
02731
02740 sciPointObj * ConstructUimenu (sciPointObj * pparent, char *label,char *callback,BOOL handle_visible)
02741 {
02742 sciPointObj *pobj = (sciPointObj *) NULL;
02743 sciUimenu *ppobj=NULL;
02744
02745 if ( (sciGetEntityType (pparent) == SCI_FIGURE) || (sciGetEntityType (pparent) == SCI_UIMENU) )
02746 {
02747 if ((pobj = MALLOC (sizeof (sciPointObj))) == NULL) return (sciPointObj *) NULL;
02748
02749 sciSetEntityType (pobj, SCI_UIMENU);
02750
02751 if ((pobj->pfeatures = MALLOC ((sizeof (sciUimenu)))) == NULL)
02752 {
02753 FREE(pobj);
02754 return (sciPointObj *) NULL;
02755 }
02756 ppobj=pUIMENU_FEATURE (pobj);
02757 if ( sciStandrardBuildOperations( pobj, pparent ) == NULL )
02758 {
02759 return NULL ;
02760 }
02761
02762 if ((pUIMENU_FEATURE (pobj)->label.callback = CALLOC(strlen(callback)+1,sizeof(char))) == NULL )
02763 {
02764 sciprint("No more place to allocates text string, try a shorter string");
02765 return (sciPointObj *) NULL;
02766 }
02767
02768 strcpy(pUIMENU_FEATURE (pobj)->label.callback,callback);
02769 pUIMENU_FEATURE (pobj)->label.callbacklen = strlen(callback);
02770
02771 pUIMENU_FEATURE (pobj)->visible = TRUE;
02772
02773 pUIMENU_FEATURE (pobj)->label.pStrings = newFullStringMatrix( &label, 1 , 1 ) ;
02774
02775 if ( pUIMENU_FEATURE (pobj)->label.pStrings == NULL)
02776 {
02777 sciprint("No more place to allocates label string, try a shorter string");
02778 sciDelThisToItsParent (pobj, sciGetParent (pobj));
02779 sciDelHandle (pobj);
02780 FREE(pUIMENU_FEATURE(pobj));
02781 FREE(pobj);
02782 return (sciPointObj *) NULL;
02783 }
02784
02785 pUIMENU_FEATURE (pobj)->handle_visible=handle_visible;
02786 pUIMENU_FEATURE (pobj)->MenuPosition=0;
02787 pUIMENU_FEATURE (pobj)->CallbackType=0;
02788 pUIMENU_FEATURE (pobj)->Enable=TRUE;
02789
02790 return (sciPointObj *) pobj;
02791 }
02792 else
02793 {
02794 sciprint ("The parent has to be a FIGURE or a UIMENU\n");
02795 return (sciPointObj *) NULL;
02796 }
02797 }
02798
02799 sciPointObj * sciConstructConsole( sciPointObj * pparent )
02800 {
02801 sciPointObj * pObj = NULL ;
02802
02803 pObj = MALLOC(sizeof(sciPointObj)) ;
02804 if ( pObj == NULL )
02805 {
02806 sciprint("Unable to allocate new object, memory full.\n") ;
02807 return NULL ;
02808 }
02809
02810 sciSetEntityType( pObj, SCI_CONSOLE ) ;
02811
02812 pObj->pfeatures = MALLOC(sizeof(sciConsole)) ;
02813 if ( pObj->pfeatures == NULL )
02814 {
02815 sciprint("Unable to allocate new object, memory full.\n") ;
02816 FREE(pObj) ;
02817 return NULL ;
02818
02819 }
02820
02821 pObj = sciStandrardBuildOperations( pObj, pparent ) ;
02822
02823 return pObj ;
02824
02825 }
02826
02833 sciPointObj * sciStandrardBuildOperations( sciPointObj * pObj, sciPointObj * parent )
02834 {
02835 int ** userData = NULL ;
02836 int * udSize = NULL ;
02837
02838
02839 if ( sciAddNewHandle(pObj) == -1 )
02840 {
02841 FREE( pObj->pfeatures ) ;
02842 FREE( pObj ) ;
02843 return NULL ;
02844 }
02845
02846
02847 if ( !sciAddThisToItsParent( pObj, parent) )
02848 {
02849 sciDelHandle(pObj) ;
02850 FREE( pObj->pfeatures ) ;
02851 FREE( pObj ) ;
02852 return NULL ;
02853 }
02854
02855
02856 sciInitSelectedSons( pObj ) ;
02857
02858 sciGetRelationship(pObj)->psons = NULL ;
02859 sciGetRelationship(pObj)->plastsons = NULL ;
02860 sciGetRelationship(pObj)->pSelectedSon = NULL ;
02861
02862 sciSetVisibility( pObj, TRUE ) ;
02863
02864 sciGetPointerToUserData( pObj, &userData, &udSize ) ;
02865 *userData = NULL ;
02866 *udSize = 0 ;
02867
02868 return pObj ;
02869
02870 }
02871
02872 sciPointObj * sciConstructFrame( sciPointObj * pparent )
02873 {
02874 sciPointObj * pObj = NULL ;
02875
02876 pObj = MALLOC(sizeof(sciPointObj)) ;
02877 if ( pObj == NULL )
02878 {
02879 sciprint("Unable to allocate new object, memory full.\n") ;
02880 return NULL ;
02881 }
02882
02883 sciSetEntityType( pObj, SCI_FRAME ) ;
02884
02885 pObj->pfeatures = MALLOC(sizeof(sciFrame)) ;
02886 if ( pObj->pfeatures == NULL )
02887 {
02888 sciprint("Unable to allocate new object, memory full.\n") ;
02889 FREE(pObj) ;
02890 return NULL ;
02891
02892 }
02893
02894 pObj = sciStandrardBuildOperations( pObj, pparent ) ;
02895
02896 return pObj ;
02897
02898 }
02899
02900 sciPointObj * sciConstructWindow( sciPointObj * pparent )
02901 {
02902 sciPointObj * pObj = NULL ;
02903
02904 pObj = MALLOC(sizeof(sciPointObj)) ;
02905 if ( pObj == NULL )
02906 {
02907 sciprint("Unable to allocate new object, memory full.\n") ;
02908 return NULL ;
02909 }
02910
02911 sciSetEntityType( pObj, SCI_WINDOW ) ;
02912
02913 pObj->pfeatures = MALLOC(sizeof(sciWindow)) ;
02914 if ( pObj->pfeatures == NULL )
02915 {
02916 sciprint("Unable to allocate new object, memory full.\n") ;
02917 FREE(pObj) ;
02918 return NULL ;
02919
02920 }
02921
02922 pObj = sciStandrardBuildOperations( pObj, pparent ) ;
02923
02924 return pObj ;
02925
02926 }
02927
02928 sciPointObj * sciConstructWindowFrame( sciPointObj * pparent )
02929 {
02930 sciPointObj * pObj = NULL ;
02931
02932 pObj = MALLOC(sizeof(sciPointObj)) ;
02933 if ( pObj == NULL )
02934 {
02935 sciprint("Unable to allocate new object, memory full.\n") ;
02936 return NULL ;
02937 }
02938
02939 sciSetEntityType( pObj, SCI_WINDOWFRAME ) ;
02940
02941 pObj->pfeatures = MALLOC(sizeof(sciWindowFrame)) ;
02942 if ( pObj->pfeatures == NULL )
02943 {
02944 sciprint("Unable to allocate new object, memory full.\n") ;
02945 FREE(pObj) ;
02946 return NULL ;
02947
02948 }
02949
02950 pObj = sciStandrardBuildOperations( pObj, pparent ) ;
02951
02952 return pObj ;
02953
02954 }
02955
02956 sciPointObj * sciConstructScreen( sciPointObj * pparent )
02957 {
02958 sciPointObj * pObj = NULL ;
02959
02960 pObj = MALLOC(sizeof(sciPointObj)) ;
02961 if ( pObj == NULL )
02962 {
02963 sciprint("Unable to allocate new object, memory full.\n") ;
02964 return NULL ;
02965 }
02966
02967 sciSetEntityType( pObj, SCI_SCREEN ) ;
02968
02969 pObj->pfeatures = MALLOC(sizeof(sciScreen)) ;
02970 if ( pObj->pfeatures == NULL )
02971 {
02972 sciprint("Unable to allocate new object, memory full.\n") ;
02973 FREE(pObj) ;
02974 return NULL ;
02975
02976 }
02977
02978 pObj = sciStandrardBuildOperations( pObj, pparent ) ;
02979
02980 return pObj ;
02981
02982 }
02983