drawSubWinEntity.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------*/
00002 /* file: drawSubWinEntity.c                                               */
00003 /* Copyright INRIA 2006                                                   */
00004 /* Authors : Jean-Baptiste Silvy                                          */
00005 /* desc : Contains functions needed to draw a subwindow handle            */
00006 /*------------------------------------------------------------------------*/
00007 
00008 #include "drawSubWinEntity.h"
00009 #include "Axes.h"
00010 #include "SetProperty.h"
00011 #include "GetProperty.h"
00012 #include "PloEch.h"
00013 #include "Xcall1.h"
00014 #include "periScreen.h"
00015 #include "DrawObjects.h"
00016 #include "GraphicZoom.h"
00017 #include "clipping.h"
00018 
00019 /*----------------------------------------------------------------------------------------*/
00020 int drawSubWinEntity( sciPointObj * pObj )
00021 {
00022   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(pObj) ;
00023 
00024   if ( !sciGetVisibility(pObj) ) { return 0 ; }
00025   
00026   sciSetSelectedSubWin(pObj); 
00027 
00028   set_scale("tttftt", ppsubwin->WRect, ppsubwin->FRect,
00029     NULL, ppsubwin->logflags, 
00030     ppsubwin->ARect); 
00031 
00032   if ( sciGetIs3d(pObj) ) 
00033   {  
00034     int isoflag = 0 ;
00035     int axesFlag = ppsubwin->axes.flag[1] ;
00036     double xbox[8] ;
00037     double ybox[8] ;
00038     double zbox[8] ;
00039     int    InsideU[4] ;
00040     int    InsideD[4] ;
00041     sciSons * curSon = NULL ;
00042 
00043     /* to avoid re-drawing on screen during computation of the vertices (at least)... */
00044     /* see zoom_box function in Plo2dEch.c*/
00045     if ( isZoom3dOn() )
00046     {
00047       int one = 1 ;
00048       C2F(dr)("xset","pixmap",&one,PI0,PI0,PI0,PI0,PI0,PD0,
00049         PD0,PD0,PD0,0L,0L);
00050       C2F (dr) ("xset","wwpc", PI0, PI0, PI0, PI0, PI0, PI0, PD0, PD0, PD0, PD0,0L, 0L);
00051     }
00052 
00053     /* 3D Coordinates */ /* verifier si c'est encore utile SS */
00054     /*To have directly all the possible ISOVIEW Modes*/
00055     isoflag = ( axesFlag + 1 ) / 2 ; 
00056 
00057     if( ppsubwin->isoview )
00058     {
00059       if( isoflag != 2 && isoflag != 3 )
00060       {
00061         if( axesFlag == 0 || axesFlag == 2 )
00062         {
00063           /* The default isoview mode is type=4 3d isometric bounds 
00064           derived from the data, to similarily type=2  */
00065           ppsubwin->axes.flag[1] = 4 ;
00066         }
00067         else if ( axesFlag == 1 )
00068         {
00069           ppsubwin->axes.flag[1] = 3 ;
00070         }
00071       }
00072     }
00073     else {
00074       if ( axesFlag == 3 || axesFlag == 5 )
00075       {
00076         ppsubwin->axes.flag[1] = 1; /* computed from ebox*/
00077       }
00078       else if( axesFlag == 4 || axesFlag == 6 )
00079       {
00080         /* The default NON-isoview mode is 2 computed from data*/
00081         ppsubwin->axes.flag[1] = 2 ;
00082       }
00083     }
00084 
00085     axis_3ddraw( pObj,xbox,ybox,zbox,InsideU,InsideD); /* TEST on sciGetVisibility inside : REMOVED F.Leray 21.01.05 */
00086     /* because axis_3ddraw displays 3d axes BUT ALSO compute + reset the 3d scale BEFORE !! */
00087 
00088     /* merge object is drawn first  since it might conceal other objects */
00089     /* which are not merged. */
00090     if ( ppsubwin->facetmerge )
00091     {
00092       sciDrawObj( sciGetMerge( pObj ) ) ;
00093     }
00094 
00095     curSon = sciGetLastSons (pObj);
00096     while ( curSon != NULL)
00097     {
00098       if ( !(ppsubwin->facetmerge && sciIsMergeable(curSon->pointobj))  )
00099       {
00100         sciDrawObj( curSon->pointobj ) ;
00101       }
00102       curSon = curSon->pprev;
00103     }
00104 
00105     triedre(pObj,xbox,ybox,zbox,InsideU,InsideD);
00106   }
00107   else /* we are in 2D mode...*/
00108   {
00109     sciSons * curSon = NULL ;
00110     int foreground = sciGetForeground( pObj ) ;
00111     int lineWidth  = sciGetLineWidth( pObj ) ;
00112     int markStyle = sciGetMarkStyle( pObj ) ;
00113     int markSize  = sciGetLineWidth( pObj ) ;
00114     int v = 0 ;
00115     double dv = 0.0 ;
00116     char strFlag[4];
00117 
00118 #ifdef _MSC_VER
00119     flag_DO=MaybeSetWinhdc();
00120 #endif
00121     C2F (dr) ("xset","dashes",&foreground,&foreground,&v,&v,&v,&v,&dv,&dv,&dv,&dv,5L,4096);
00122     C2F (dr) ("xset","foreground",&foreground,&foreground,&v,&v,&v,&v,&dv,&dv,&dv,&dv,5L,4096);
00123     C2F (dr) ("xset","thickness",&lineWidth,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00124     C2F (dr) ("xset","mark",&markStyle,&markSize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00125 
00126     sciUpdateScaleAngles( ppsubwin->theta, ppsubwin->alpha ) ; /* for merge objects */
00127     sci_update_frame_bounds_2d(pObj);
00128 
00129 
00130     /* Clipping only exists in 2d */
00131     /* the global var. Cscale has just been updated */
00132     /* therefore I can re-compute the clipping now (if it is "clipgrf") */
00133 
00134     sciClip( pObj ) ; /* to update the clip_box if needed */
00135     sciUnClip( pObj ) ;
00136 
00137     DrawAxesBackground();
00138 
00139     drawAxesGrid( pObj ) ;
00140 
00141     /* there is a bug here */
00142     /* We should make a check for merge objects here */
00143     /* But merge object has been only created only for 3d */
00144     /* so sometimes it works, sometime not */
00145     curSon = sciGetLastSons( pObj ) ;
00146     while ( curSon != NULL )
00147     {
00148       if ( !(ppsubwin->facetmerge && sciGetEntityType(curSon->pointobj) == SCI_SEGS) )
00149       {
00150         sciDrawObj( curSon->pointobj ) ;
00151       }
00152        
00153       curSon = curSon->pprev;
00154     }     
00155 
00156     /* F.Leray 07.12.04 */
00157     /* TO CORRECT the bug 1115 : Big object (grayplots) could cover axes*/
00158     C2F (dr) ("xset","dashes",&foreground,&foreground,&v,&v,&v,&v,&dv,&dv,&dv,&dv,5L,4096);
00159     C2F (dr) ("xset","foreground",&foreground,&foreground,&v,&v,&v,&v,&dv,&dv,&dv,&dv,5L,4096);
00160     C2F (dr) ("xset","thickness",&lineWidth,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00161     C2F (dr) ("xset","mark",&markStyle,&markSize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00162 
00163     rebuild_strflag( pObj, strFlag ) ;
00164     axis_draw2( strFlag ) ;
00165 
00166     labels2D_draw( pObj ) ; /* F.Leray 08.08.05 : labels' drawing at the end */
00167 
00168 #ifdef _MSC_VER
00169     if ( flag_DO == 1) { ReleaseWinHdc() ; }
00170 #endif
00171     wininfo("") ;
00172   }
00173   return 0 ;
00174 }
00175 /*----------------------------------------------------------------------------------------*/

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