cgma
GfxDebug.hpp
Go to the documentation of this file.
00001 
00002 
00003 #ifndef GFX_DEBUG_INTERFACE_HPP
00004 #define GFX_DEBUG_INTERFACE_HPP
00005 
00006 // An interface for any tools, algorithms, etc... to draw things.
00007 // NOTE: this is an "interface" in the sense that using it will not 
00008 // create additional depedencies in your code.  If a subclass of GfxDebug
00009 // is not instantiated, then this class acts as a stub with empty implementation.
00010 //
00011 // any graphics primitives drawn with this interface are temporary primitives and
00012 // not permanent ones.  Any primitive or window created with this class are 
00013 // owned by this class (or the user of this class in a sense) 
00014 // and not by any other graphics model (ie GGeomModel, GMeshModel, etc...).
00015 
00016 
00017 // We only have forward declarations and NO #includes !!! (except those already in the util folder)
00018 template <class X> class DLIList;
00019 class RefEntity;
00020 class MeshEntity;
00021 class CubitNode;
00022 class CubitEdge;
00023 class CubitFace;
00024 class CubitTri;
00025 class CubitTet;
00026 class CubitHex;
00027 class CubitPyramid;
00028 class CubitWedge;
00029 struct GPoint;
00030 class CubitFacet;
00031 class CubitFacetEdge;
00032 class GeoTet;
00033 class GeoNode;
00034 class CubitVector;
00035 class RefEntity;
00036 class RefVertex;
00037 class RefEdge;
00038 class RefFace;
00039 class RefVolume;
00040 class Body;
00041 class MRefEntity;
00042 class MRefVertex;
00043 class MRefEdge;
00044 class MRefFace;
00045 class MRefVolume;
00046 class MBody;
00047 class CubitTransformMatrix;
00048 class CubitBox;
00049 class Surface;
00050 
00051 #include "CubitColor.hpp"
00052 #include "CGMUtilConfigure.h"
00053 
00054 class CUBIT_UTIL_EXPORT GfxDebug
00055 {
00056   // the one instance of the Graphics Debug object
00057   // creating a second instance will delete and replace the first instance.
00058 protected:
00059   static GfxDebug* mInstance;
00060 
00061   public:
00062     GfxDebug();
00063     virtual ~GfxDebug();
00064   
00065     static bool is_initialized();
00066 
00067     // this will clear out all temporary data and delete any graphics windows created
00068     // with this interface.  It'll restore the persistent geom/mesh model.
00069     //static void reset();
00070 
00071     // this will clear out the geom/mesh model and only subsequent drawing
00072     // will be visible
00073     static void clear();
00074 
00075     // same as DrawingTool::display_all
00076     static void display_all(bool flush_highlight = true, bool import_mesh_display = false);
00077 
00078     // clear out the highlighted
00079     static void clear_highlight();
00080 
00081     // set the drawing mode
00082     static void drawing_mode(int mode);
00083 
00084     // rebuild all
00085     //static void rebuild_all();
00086 
00087   // Window Related Functions
00088 
00089     // creates a graphics window 
00090     // not creating a window will use an existing current window
00091     // all drawing goes only into all windows created here or an existing window
00092     static int create_window();
00093     // deletes a window created by this interface
00094     static void delete_window(int window_id);
00095     
00096     // switches a window created by this interface into a 2D drawing mode.
00097     static void set_2D_mode(int window_id);
00098 
00099     // causes the window(s) to be redrawn
00100     static void flush();
00101 
00102     // give control to the window(s) to handle mouse events
00103     static void mouse_xforms();
00104 
00105     static void display_to_world_length(double pixels, double& length);
00106 
00107   // Geometry Drawing Functions
00108     static void draw_ref_entity(RefEntity* entity, int color = CUBIT_DEFAULT_COLOR_INDEX,
00109                                    CubitTransformMatrix* trans_mat = 0);
00110     static void draw_ref_vertex(RefVertex* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00111     static void draw_ref_edge(RefEdge* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00112     static void draw_ref_face(RefFace* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00113     static void draw_ref_face_edges(RefFace* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00114     static void draw_ref_volume(RefVolume* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00115     static void draw_ref_body(Body* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00116     
00117     //static void highlight_ref_entity(RefEntity* entity);
00118     static void highlight_ref_vertex(RefVertex* entity);
00119     static void highlight_ref_edge(RefEdge* entity);
00120     static void highlight_ref_face(RefFace* entity);
00121     static void highlight_ref_volume(RefVolume* entity);
00122     static void highlight_ref_body(Body* entity);
00123     
00124     static void draw_mref_entity(MRefEntity* entity, int color = CUBIT_DEFAULT_COLOR_INDEX,
00125                                     bool draw_geom = true, bool draw_mesh = true, 
00126                                     CubitTransformMatrix* trans_mat = 0);
00127     static void draw_mref_vertex(MRefVertex* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00128     static void draw_mref_edge(MRefEdge* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00129     static void draw_mref_face(MRefFace* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00130     static void draw_mref_volume(MRefVolume* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00131     static void draw_mref_body(MBody* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00132     static void draw_mref_entity_mesh(MRefEntity* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00133     static void draw_mref_volume_faces(MRefVolume* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00134     
00135     //static void highlight_mref_entity(MRefEntity* entity);
00136     static void highlight_mref_vertex(MRefVertex* entity);
00137     static void highlight_mref_edge(MRefEdge* entity);
00138     static void highlight_mref_face(MRefFace* entity);
00139     static void highlight_mref_volume(MRefVolume* entity);
00140     static void highlight_mref_body(MBody* entity);
00141 
00142 
00143   // Mesh Drawing Functions
00144     
00145     // draws mesh entities with a color from the cubit color table
00146     // prefer these functions to a loop drawing each entity separately
00147     //static void draw_mesh_entities(DLIList<MeshEntity*>* entities, int color);
00148     static void draw_nodes(DLIList<CubitNode*>* entities, int color);
00149     static void draw_edges(DLIList<CubitEdge*>* entities, int color);
00150     static void draw_quads(DLIList<CubitFace*>* entities, int color);
00151     static void draw_tris(DLIList<CubitTri*>* entities, int color);
00152     static void draw_tets(DLIList<CubitTet*>* entities, int color);
00153     static void draw_hexes(DLIList<CubitHex*>* entities, int color);
00154     //static void draw_pyramids(DLIList<CubitPyramid*>* entities, int color);
00155     static void draw_wedges(DLIList<CubitWedge*>* entities, int color);
00156 
00157     static void draw_mesh_entity(MeshEntity* entity, int color);
00158     static void draw_node(CubitNode* entity, int color);
00159     static void draw_edge(CubitEdge* entity, int color);
00160     static void draw_quad(CubitFace* entity, int color);
00161     static void draw_tri(CubitTri* entity, int color);
00162     static void draw_tet(CubitTet* entity, int color);
00163     static void draw_hex(CubitHex* entity, int color);
00164     static void draw_pyramid(CubitPyramid* entity, int color);
00165     static void draw_wedge(CubitWedge* entity, int color);
00166     //static void draw_node_array(CubitNode* nodes[], int color, bool ink_edges = true);
00167 
00168     static void highlight_node(CubitNode* entity);
00169     static void highlight_edge(CubitEdge* entity);
00170     static void highlight_quad(CubitFace* entity);
00171     static void highlight_tri(CubitTri* entity);
00172     static void highlight_tet(CubitTet* entity);
00173     static void highlight_hex(CubitHex* entity);
00174     static void highlight_pyramid(CubitPyramid* entity);
00175     static void highlight_wedge(CubitWedge* entity);
00176     
00177 
00178   // Facet Drawing Functions
00179     static void draw_facet(CubitFacet* facet, int color, int draw_uv = 0);
00180     static void draw_facet_edge(CubitFacetEdge* facet_edge, int color);
00181     static void draw_geotet( GeoTet *tet, int color );
00182     static void draw_geonode( GeoNode *node, int color );
00183 
00184   // Generic Primitive Drawing Functions
00185     
00186     static void draw_box(CubitBox& box, int color);
00187     
00188     // draw point x,y,z of color
00189     static void draw_point(float x, float y, float z, int color);
00190     static void draw_point(const CubitVector& vector, int color);
00191     static void draw_point(CubitVector* vector, int color);
00192     static void draw_points( DLIList<CubitVector> &points, int color );
00193 
00194     // draw line of points {x,y,z}, {x,y,z} of color
00195     static void draw_line(float x1, float y1, float z1, 
00196                           float x2, float y2, float z2, int color);
00197     
00198     static void draw_line(const CubitVector& x, const CubitVector& y, int color);
00199 
00200     // draw a polyline with a number of points of a color
00201     static void draw_polyline(const GPoint* points, int num_points, int color);
00202 
00203     // draw a polygon with a number of points of a color and filled or not
00204     static void draw_polygon(const GPoint* points, int num_points, int color, int border_color, bool filled = true);
00205 
00206     // draw a quad of a color
00207     static void draw_quad(const GPoint* points, int color);
00208 
00209     // draw a tri of a color
00210     static void draw_tri(const GPoint* points, int color);
00211 
00212     // draw a vector (tail -> head) of color
00213     static void draw_vector(const GPoint* tail, const GPoint* head, int color);
00214     static void draw_vector(const CubitVector& tail, const CubitVector& head, int color);
00215 
00216     // draw a shell (num points, point list, num faces, face list) of color
00217     static void draw_shell(int num_pts, const GPoint* points, 
00218                            int num_faces, const int* face_list, int color);
00219     
00220     // draw a shell (num points, point list, num faces, face list) with point colors
00221     static void draw_shell(int num_pts, const GPoint* points, 
00222                            int num_faces, const int* face_list, const int* colors);
00223 
00224     // draw a label at position x,y,z of color
00225     static void draw_label(const char* label, float x, float y, float z, int color);
00226     static void draw_label(int label, float x, float y, float z, int color);
00227 
00228     // zoom to specified bounding box
00229     static void zoom(CubitBox &box);
00230 
00231     // highlight simple primitives
00232     static void highlight_points(int num_points, const double* xyzs);
00233     static void highlight_polylines(int num_points, const double* xyzs, int num_line_points, const int* line_list);
00234     static void highlight_polygons(int num_points, const double* xyzs, int num_face_points, const int* face_list );
00235     
00236     static void draw_surface(Surface *surf, int color);
00237     
00238   protected:
00239 
00240     // p is for protected in case you were wondering :)
00241     
00242     //virtual void p_reset() = 0;
00243     virtual void p_clear() = 0;
00244     virtual void p_display_all(bool,bool) = 0;
00245     virtual void p_clear_highlight() = 0;
00246     virtual void p_drawing_mode(int) = 0;
00247     //virtual void p_rebuild_all() = 0;
00248     
00249     virtual int p_create_window() = 0;
00250     virtual void p_delete_window(int) = 0;
00251     virtual void p_set_2D_mode(int) = 0;
00252     virtual void p_flush() = 0;
00253     virtual void p_mouse_xforms() = 0;
00254     virtual void p_display_to_world_length(double pixels, double& length) = 0;
00255 
00256     virtual void p_draw_ref_entity(RefEntity* entity, int color, CubitTransformMatrix* mat) = 0;
00257     virtual void p_draw_ref_vertex(RefVertex* entity, int color) = 0;
00258     virtual void p_draw_ref_edge(RefEdge* entity, int color) = 0;
00259     virtual void p_draw_ref_face(RefFace* entity, int color) = 0;
00260     virtual void p_draw_ref_face_edges(RefFace* entity, int color) = 0;
00261     virtual void p_draw_ref_volume(RefVolume* entity, int color) = 0;
00262     virtual void p_draw_ref_body(Body* entity, int color) = 0;
00263     virtual void p_draw_mref_entity(MRefEntity* entity, int color, bool geom, bool mesh, CubitTransformMatrix* mat) = 0;
00264     virtual void p_draw_mref_vertex(MRefVertex* entity, int color) = 0;
00265     virtual void p_draw_mref_edge(MRefEdge* entity, int color) = 0;
00266     virtual void p_draw_mref_face(MRefFace* entity, int color) = 0;
00267     virtual void p_draw_mref_volume(MRefVolume* entity, int color) = 0;
00268     virtual void p_draw_mref_body(MBody* entity, int color) = 0;
00269     virtual void p_draw_mref_entity_mesh(MRefEntity* entity, int color) = 0;
00270     virtual void p_draw_mref_volume_faces(MRefVolume* entity, int color) = 0;
00271     
00272     //virtual void p_highlight_ref_entity(RefEntity* entity) = 0;
00273     virtual void p_highlight_ref_vertex(RefVertex* entity) = 0;
00274     virtual void p_highlight_ref_edge(RefEdge* entity) = 0;
00275     virtual void p_highlight_ref_face(RefFace* entity) = 0;
00276     virtual void p_highlight_ref_volume(RefVolume* entity) = 0;
00277     virtual void p_highlight_ref_body(Body* entity) = 0;
00278     //virtual void p_highlight_mref_entity(MRefEntity* entity) = 0;
00279     virtual void p_highlight_mref_vertex(MRefVertex* entity) = 0;
00280     virtual void p_highlight_mref_edge(MRefEdge* entity) = 0;
00281     virtual void p_highlight_mref_face(MRefFace* entity) = 0;
00282     virtual void p_highlight_mref_volume(MRefVolume* entity) = 0;
00283     virtual void p_highlight_mref_body(MBody* entity) = 0;
00284 
00285 
00286     //virtual void p_draw_mesh_entities(DLIList<MeshEntity*>*, int) = 0;
00287     virtual void p_draw_nodes(DLIList<CubitNode*>*, int) = 0;
00288     virtual void p_draw_edges(DLIList<CubitEdge*>*, int) = 0;
00289     virtual void p_draw_quads(DLIList<CubitFace*>*, int) = 0;
00290     virtual void p_draw_tris(DLIList<CubitTri*>*, int) = 0;
00291     virtual void p_draw_tets(DLIList<CubitTet*>*, int) = 0;
00292     virtual void p_draw_hexes(DLIList<CubitHex*>*, int) = 0;
00293     //virtual void p_draw_pyramids(DLIList<CubitPyramid*>*, int) = 0;
00294     virtual void p_draw_wedges(DLIList<CubitWedge*>*, int) = 0;
00295     virtual void p_draw_mesh_entity(MeshEntity*, int) = 0;
00296     virtual void p_draw_node(CubitNode*, int) = 0;
00297     virtual void p_draw_edge(CubitEdge*, int) = 0;
00298     virtual void p_draw_quad(CubitFace*, int) = 0;
00299     virtual void p_draw_tri(CubitTri*, int) = 0;
00300     virtual void p_draw_tet(CubitTet*, int) = 0;
00301     virtual void p_draw_hex(CubitHex*, int) = 0;
00302     virtual void p_draw_pyramid(CubitPyramid*, int) = 0;
00303     virtual void p_draw_wedge(CubitWedge*, int) = 0;
00304     virtual void p_highlight_node(CubitNode* entity) = 0;
00305     virtual void p_highlight_edge(CubitEdge* entity) = 0;
00306     virtual void p_highlight_quad(CubitFace* entity) = 0;
00307     virtual void p_highlight_tri(CubitTri* entity) = 0;
00308     virtual void p_highlight_tet(CubitTet* entity) = 0;
00309     virtual void p_highlight_hex(CubitHex* entity) = 0;
00310     virtual void p_highlight_pyramid(CubitPyramid* entity) = 0;
00311     virtual void p_highlight_wedge(CubitWedge* entity) = 0;
00312 
00313     virtual void p_draw_facet(CubitFacet*, int,int) = 0;
00314     virtual void p_draw_facet_edge(CubitFacetEdge*, int) = 0;
00315     virtual void p_draw_geotet(GeoTet*, int) = 0;
00316     virtual void p_draw_geonode(GeoNode *, int) = 0;
00317     
00318     virtual void p_draw_box(CubitBox& box, int color) = 0;
00319 
00320     virtual void p_draw_point(float, float, float, int) = 0;
00321     virtual void p_draw_point(const CubitVector& vector, int color) = 0;
00322     virtual void p_draw_line(float, float, float, float, float, float, int) = 0;
00323     virtual void p_draw_line(const CubitVector& x, const CubitVector& y, int color) = 0;
00324     virtual void p_draw_polyline(const GPoint*, int, int) = 0;
00325     virtual void p_draw_polygon(const GPoint* points, int num_points, int color, int border_color, bool filled) = 0;
00326     virtual void p_draw_quad(const GPoint*, int) = 0;
00327     virtual void p_draw_tri(const GPoint*, int) = 0;
00328     virtual void p_draw_vector(const CubitVector&, const CubitVector&, int) = 0;
00329     virtual void p_draw_shell(int, const GPoint*, int, const int*, int) = 0;
00330     virtual void p_draw_shell(int, const GPoint*, int, const int*, const int*) = 0;
00331     virtual void p_draw_label(const char*, float, float, float, int) = 0;
00332     virtual void p_draw_label(int, float, float, float, int) = 0;
00333     virtual void p_zoom(CubitBox &box) = 0;
00334     
00335     virtual void p_highlight_points(int num_points, const double* xyzs) = 0;
00336     virtual void p_highlight_polylines(int num_points, const double* xyzs, int num_line_points, const int* line_list) = 0;
00337     virtual void p_highlight_polygons(int num_points, const double* xyzs, int num_face_points, const int* face_list ) = 0;
00338 
00339     virtual void p_draw_surface(Surface *surf, int color) = 0;
00340 
00341 };
00342 
00343 #endif
00344 
00345 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines