00001 /* 00002 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 00003 * Copyright (C) 2007 - INRIA - Jean-Baptiste Silvy 00004 * desc : Contains the function to retrieve a the drawer of a graphic handle 00005 * 00006 * This file must be used under the terms of the CeCILL. 00007 * This source file is licensed as described in the file COPYING, which 00008 * you should have received as part of this distribution. The terms 00009 * are also available at 00010 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt 00011 * 00012 */ 00013 00014 #include "getHandleDrawer.h" 00015 #include "DrawableObjectFactory.h" 00016 00017 extern "C" 00018 { 00019 #include "GetProperty.h" 00020 } 00021 00022 namespace sciGraphics 00023 { 00024 00025 /*---------------------------------------------------------------------------------*/ 00026 DrawableObject * getHandleDrawer( sciPointObj * pObj ) 00027 { 00028 if ( pObj->pDrawer != NULL ) 00029 { 00030 return getHandleDrawerPointer( pObj ) ; 00031 } 00032 00033 /* We need to create the drawer */ 00034 00035 DrawableObjectFactory creator ; 00036 creator.setGraphicObj( pObj ) ; 00037 00038 DrawableObject * drawer = creator.create() ; 00039 00040 setHandleDrawerPointer( pObj, drawer ) ; 00041 00042 return drawer ; 00043 } 00044 /*---------------------------------------------------------------------------------*/ 00045 DrawableObject * getHandleDrawerPointer( sciPointObj * pObj ) 00046 { 00047 if ( pObj->pDrawer == NULL ) { return NULL ; } 00048 return ((DrawableObjectWrapper *)(pObj->pDrawer))->drawer ; 00049 } 00050 /*---------------------------------------------------------------------------------*/ 00051 void setHandleDrawerPointer( sciPointObj * pObj, DrawableObject * drawer ) 00052 { 00053 if ( pObj->pDrawer == NULL ) 00054 { 00055 pObj->pDrawer = new DrawableObjectWrapper() ; 00056 } 00057 ((DrawableObjectWrapper *)(pObj->pDrawer))->drawer = drawer ; 00058 } 00059 /*---------------------------------------------------------------------------------*/ 00060 DrawableFigure * getFigureDrawer( sciPointObj * pFigure ) 00061 { 00062 if ( sciGetEntityType(pFigure) != SCI_FIGURE ) 00063 { 00064 return NULL; 00065 } 00066 00067 return dynamic_cast<DrawableFigure *>(getHandleDrawer(pFigure)); 00068 } 00069 /*---------------------------------------------------------------------------------*/ 00070 DrawableRectangle * getRectangleDrawer( sciPointObj * pRectangle ) 00071 { 00072 if ( sciGetEntityType(pRectangle) != SCI_RECTANGLE ) 00073 { 00074 return NULL; 00075 } 00076 00077 return dynamic_cast<DrawableRectangle *>(getHandleDrawer(pRectangle)); 00078 } 00079 /*---------------------------------------------------------------------------------*/ 00080 DrawableArc * getArcDrawer( sciPointObj * pArc ) 00081 { 00082 if ( sciGetEntityType(pArc) != SCI_ARC ) 00083 { 00084 return NULL; 00085 } 00086 00087 return dynamic_cast<DrawableArc *>(getHandleDrawer(pArc)); 00088 } 00089 /*---------------------------------------------------------------------------------*/ 00090 DrawablePolyline * getPolylineDrawer( sciPointObj * pPolyline ) 00091 { 00092 if ( sciGetEntityType(pPolyline) != SCI_POLYLINE ) 00093 { 00094 return NULL; 00095 } 00096 00097 return dynamic_cast<DrawablePolyline *>(getHandleDrawer(pPolyline)); 00098 } 00099 /*---------------------------------------------------------------------------------*/ 00100 DrawableText * getTextDrawer( sciPointObj * pText ) 00101 { 00102 if ( sciGetEntityType(pText) != SCI_TEXT ) 00103 { 00104 return NULL; 00105 } 00106 00107 return dynamic_cast<DrawableText *>(getHandleDrawer(pText)); 00108 } 00109 /*---------------------------------------------------------------------------------*/ 00110 DrawableSubwin * getSubwinDrawer( sciPointObj * pSubwin ) 00111 { 00112 if ( sciGetEntityType(pSubwin) != SCI_SUBWIN ) 00113 { 00114 return NULL; 00115 } 00116 00117 return dynamic_cast<DrawableSubwin *>(getHandleDrawer(pSubwin)); 00118 } 00119 /*---------------------------------------------------------------------------------*/ 00120 DrawableLabel * getLabelDrawer( sciPointObj * pLabel ) 00121 { 00122 if ( sciGetEntityType(pLabel) != SCI_LABEL ) 00123 { 00124 return NULL; 00125 } 00126 00127 return dynamic_cast<DrawableLabel *>(getHandleDrawer(pLabel)); 00128 } 00129 /*---------------------------------------------------------------------------------*/ 00130 DrawableSurface * getSurfaceDrawer( sciPointObj * pSurface ) 00131 { 00132 if ( sciGetEntityType(pSurface) != SCI_SURFACE ) 00133 { 00134 return NULL; 00135 } 00136 00137 return dynamic_cast<DrawableSurface *>(getHandleDrawer(pSurface)); 00138 } 00139 /*---------------------------------------------------------------------------------*/ 00140 DrawableSegs * getSegsDrawer( sciPointObj * pSegs ) 00141 { 00142 if ( sciGetEntityType(pSegs) != SCI_SEGS ) 00143 { 00144 return NULL; 00145 } 00146 00147 return dynamic_cast<DrawableSegs *>(getHandleDrawer(pSegs)); 00148 } 00149 /*---------------------------------------------------------------------------------*/ 00150 DrawableGrayplot * getGrayplotDrawer( sciPointObj * pGrayplot ) 00151 { 00152 00153 if (sciGetEntityType(pGrayplot) != SCI_GRAYPLOT) 00154 { 00155 return NULL; 00156 } 00157 00158 return dynamic_cast<DrawableGrayplot *>(getHandleDrawer(pGrayplot)); 00159 00160 } 00161 /*---------------------------------------------------------------------------------*/ 00162 DrawableFec * getFecDrawer( sciPointObj * pFec ) 00163 { 00164 if (sciGetEntityType(pFec) != SCI_FEC) 00165 { 00166 return NULL; 00167 } 00168 00169 return dynamic_cast<DrawableFec *>(getHandleDrawer(pFec)); 00170 } 00171 /*---------------------------------------------------------------------------------*/ 00172 DrawableAxes * getAxesDrawer( sciPointObj * pAxes ) 00173 { 00174 if (sciGetEntityType(pAxes) != SCI_AXES) 00175 { 00176 return NULL; 00177 } 00178 00179 return dynamic_cast<DrawableAxes *>(getHandleDrawer(pAxes)); 00180 } 00181 /*---------------------------------------------------------------------------------*/ 00182 }
1.5.5