cgma
GfxPreview.hpp
Go to the documentation of this file.
00001 
00002 
00003 #ifndef GFX_PREVIEW_INTERFACE_HPP
00004 #define GFX_PREVIEW_INTERFACE_HPP
00005 
00006 // An interface for any tools, algorithms, etc... to draw preview objects.
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 GfxPreview
00009 // is not instantiated, then this class acts as a stub with empty implementation.
00010 // CGM users may implement preview code by deriving from this class and implementing
00011 // graphics code in the pure virtual p_* methods.  Creating an instance of the
00012 // derived class will result in the correct methods being called by this interface.
00013 
00014 // PLEASE!!! use this interface to implement any graphical preview code in CGM.
00015 //           This will identify graphics code that must be maintained for end users.
00016 
00017 //
00018 // any graphics primitives drawn with this interface are temporary primitives and
00019 // not permanent ones.  All items are draw into a single drawing set owned by the 
00020 // 
00021 
00022 
00023 // We only have forward declarations and NO #includes !!! (except those already in the util folder)
00024 template <class X> class DLIList;
00025 class RefEntity;
00026 struct GPoint;
00027 class CubitVector;
00028 class RefEntity;
00029 class RefVertex;
00030 class RefEdge;
00031 class RefFace;
00032 class RefVolume;
00033 class Body;
00034 class CubitTransformMatrix;
00035 class CubitBox;
00036 class Curve;
00037 class Surface;
00038 class TBPoint;
00039 
00040 #include "CubitColor.hpp"
00041 #include "CGMGeomConfigure.h"
00042 #include "DrawingToolDefines.h"
00043 
00044 class CUBIT_GEOM_EXPORT GfxPreview
00045 {
00046   // the one instance of the Graphics Preview object
00047   // creating a second instance will delete and replace the first instance.
00048   static GfxPreview* mInstance;
00049 
00050   public:
00051     GfxPreview();
00052     virtual ~GfxPreview();
00053 
00054     // this will clear out all temporary data and delete any graphics windows created
00055     // with this interface.  It'll restore the persistent geom/mesh model.
00056     //static void reset();
00057 
00058     // this will clear out any objects drawn using preview graphics.
00059     // no other graphics will be affected so you can now do something like
00060     //   draw vol 4
00061     //   webcut vol all plane x preview
00062     // and then clear the preview and you will still only have vol 4 displaye.
00063     static void clear();  
00064 
00065     // causes the window(s) to be redrawn
00066     static void flush();
00067 
00068   // Geometry Drawing Functions
00069     static void draw_ref_entity(RefEntity* entity, int color = CUBIT_DEFAULT_COLOR_INDEX,
00070                                    CubitTransformMatrix* trans_mat = 0);
00071     static void draw_ref_vertex(RefVertex* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00072     static void draw_ref_edge(RefEdge* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00073     static void draw_ref_face(RefFace* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00074     static void draw_ref_face_edges(RefFace* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00075     static void draw_ref_volume(RefVolume* entity, int color = CUBIT_DEFAULT_COLOR_INDEX, int mode = CUBIT_SMOOTH_SHADING);
00076     static void draw_ref_volume_edges(RefVolume* entity, int color = CUBIT_DEFAULT_COLOR_INDEX);
00077     static void draw_ref_body(Body* entity, int color = CUBIT_DEFAULT_COLOR_INDEX, int mode = CUBIT_SMOOTH_SHADING);
00078 
00079     static void draw_point(TBPoint *pt, int color);
00080     static void draw_curve(Curve *curve, int color);
00081     static void draw_surface(Surface *surf, int color);
00082     static void draw_surface_facets_shaded(Surface *surf, int color);
00083 
00084   // Generic Primitive Drawing Functions
00085     
00086     static void draw_box(CubitBox& box, int color);
00087     
00088     // draw point x,y,z of color
00089     static void draw_point(float x, float y, float z, int color);
00090     static void draw_point(const CubitVector& vector, int color);
00091     static void draw_point(CubitVector* vector, int color);
00092 
00093     // draw line of points {x,y,z}, {x,y,z} of color
00094     static void draw_line(float x1, float y1, float z1, 
00095                           float x2, float y2, float z2, int color);
00096     
00097     static void draw_line(const CubitVector& x, const CubitVector& y, int color);
00098 
00099     // draw a polyline with a number of points of a color
00100     static void draw_polyline(const GPoint* points, int num_points, int color);
00101 
00102     // draw a polygon with a number of points of a color and filled or not
00103     static void draw_polygon(const GPoint* points, int num_points, int color, int border_color, bool filled = true);
00104     // draw a list of polygons (much more efficent than drawing a single polygon multiple times.)
00105     // pass in the coordinates and the connectivity
00106     // the face_list is comprised of a list num_points_in_face, face_pt1, face_pt2, face_pt3, ...
00107     static void draw_polygons(int num_points, const double *xyzs, int num_face_points,
00108                               const int* face_list, int color, int mode);
00109 
00116     static void  draw_cylinder(const CubitVector& axis, const CubitVector& origin, 
00117                                CubitBox& bounding_box, float radius, int color);
00118 
00119     static void  draw_frustum( const CubitVector axis , const CubitVector origin1, const CubitVector origin2,double dRad1 , double dRad2,
00120                                CubitBox& bounding_box ,int color);
00121     // draw a quad of a color
00122     static void draw_quad(const GPoint* points, int color);
00123 
00124     // draw a tri of a color
00125     static void draw_tri(const GPoint* points, int color);
00126 
00127     // draw a vector (tail -> head) of color
00128     static void draw_vector(const GPoint* tail, const GPoint* head, int color);
00129     static void draw_vector(const CubitVector& tail, const CubitVector& head, int color);
00130 
00131     // draw a label at position x,y,z of color
00132     static void draw_label(const char* label, float x, float y, float z, int color);
00133     static void draw_label(int label, float x, float y, float z, int color);
00134 
00135   protected:
00136 
00137     // p is for protected in case you were wondering :)
00138     
00139     virtual void p_clear() = 0;
00140     virtual void p_flush() = 0;
00141 
00142     virtual void p_draw_ref_entity(RefEntity* entity, int color, CubitTransformMatrix* mat) = 0;
00143     virtual void p_draw_ref_vertex(RefVertex* entity, int color) = 0;
00144     virtual void p_draw_ref_edge(RefEdge* entity, int color) = 0;
00145     virtual void p_draw_ref_face(RefFace* entity, int color) = 0;
00146     virtual void p_draw_ref_face_edges(RefFace* entity, int color) = 0;
00147     virtual void p_draw_ref_volume(RefVolume* entity, int color, int mode) = 0;
00148     virtual void p_draw_ref_volume_edges(RefVolume* entity, int color) = 0;
00149     virtual void p_draw_ref_body(Body* entity, int color, int mode) = 0;
00150     virtual void p_draw_box(CubitBox& box, int color) = 0;
00151     virtual void p_draw_point(float, float, float, int) = 0;
00152     virtual void p_draw_point(const CubitVector& vector, int color) = 0;
00153     virtual void p_draw_line(float, float, float, float, float, float, int) = 0;
00154     virtual void p_draw_line(const CubitVector& x, const CubitVector& y, int color) = 0;
00155     virtual void p_draw_polyline(const GPoint*, int, int) = 0;
00156     virtual void p_draw_polygon(const GPoint* points, int num_points, int color, int border_color, bool filled) = 0;
00157     virtual void p_draw_polygons(int num_points, const double* xyzs, int num_face_points,
00158                                  const int* face_list, int color, int mode) = 0;
00159     virtual void p_draw_cylinder(const CubitVector& axis, const CubitVector& origin, 
00160                                CubitBox& bounding_box, float radius, int color) = 0;
00161     virtual void p_draw_frustum(const CubitVector axis, const CubitVector origin1, const CubitVector origin2, 
00162                                   double radius1 , double radius2 ,CubitBox bounding_box , int color) = 0;
00163     virtual void p_draw_quad(const GPoint*, int) = 0;
00164     virtual void p_draw_tri(const GPoint*, int) = 0;
00165     virtual void p_draw_vector(const CubitVector&, const CubitVector&, int) = 0;
00166     virtual void p_draw_label(const char*, float, float, float, int) = 0;
00167     virtual void p_draw_label(int, float, float, float, int) = 0;
00168 };
00169 
00170 #endif
00171 
00172 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines