1 #ifndef FILE_MVDRAW 2 #define FILE_MVDRAW 3 4 5 namespace netgen 6 { 7 8 9 class VisualScene 10 { 11 protected: 12 static DLL_HEADER Point3d center; 13 static DLL_HEADER double rad; 14 15 static double lookatmat[16]; 16 static double transmat[16]; 17 static double rotmat[16]; 18 static double centermat[16]; 19 20 static DLL_HEADER double transformationmat[16]; 21 22 GLdouble clipplane[4]; 23 24 int changeval; 25 static DLL_HEADER GLdouble backcolor; 26 27 static int DLL_HEADER selface; 28 static int selelement; 29 static PointIndex DLL_HEADER selpoint; 30 static PointIndex selpoint2; 31 static int locpi; 32 static int DLL_HEADER seledge; 33 34 static int selecttimestamp; 35 36 public: 37 static int viewport[4]; 38 static GLuint coltexname; 39 static int ntexcols; 40 int invcolor; 41 42 43 public: 44 DLL_HEADER VisualScene (); 45 DLL_HEADER virtual ~VisualScene(); 46 47 DLL_HEADER virtual void BuildScene (int zoomall = 0); 48 DLL_HEADER virtual void DrawScene (); 49 50 DLL_HEADER void CalcTransformationMatrices(); 51 DLL_HEADER void StandardRotation (const char * dir); 52 DLL_HEADER void ArbitraryRotation (const NgArray<double> & alpha, const NgArray<Vec3d> & vec); 53 DLL_HEADER void ArbitraryRotation (const double alpha, const Vec3d & vec); 54 55 DLL_HEADER virtual void MouseMove(int oldx, int oldy, 56 int newx, int newy, 57 char mode); 58 59 DLL_HEADER void LookAt (const Point<3> & cam, const Point<3> & obj, 60 const Point<3> & camup); 61 62 DLL_HEADER void SetClippingPlane (); 63 64 DLL_HEADER virtual void MouseDblClick (int px, int py); 65 66 DLL_HEADER void SetLight (); SetBackGroundColor(double col)67 static void SetBackGroundColor (double col) 68 { backcolor = col; } 69 70 DLL_HEADER void CreateTexture (int ncols, int linear, double alpha, int typ); 71 DLL_HEADER void DrawColorBar (double minval, double maxval, int logscale = 0, bool linear = 1); 72 DLL_HEADER void DrawCoordinateCross (); 73 DLL_HEADER void DrawNetgenLogo (); 74 DLL_HEADER void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0); 75 76 77 #ifdef PARALLELGL 78 DLL_HEADER void InitParallelGL (); 79 DLL_HEADER void Broadcast (); 80 #endif 81 }; 82 83 84 DLL_HEADER extern void MyOpenGLText (const char * text); 85 DLL_HEADER extern void Set_OpenGLText_Callback ( void (*fun) (const char * text) ); 86 DLL_HEADER extern VisualScene visual_scene_cross; 87 DLL_HEADER extern VisualScene *visual_scene; 88 89 90 91 92 93 94 95 96 97 98 class VisualSceneSurfaceMeshing : public VisualScene 99 { 100 double scalex = 1., scaley = 1., shiftx = 0., shifty = 0.; 101 public: 102 shared_ptr<NgArray<Point<3>>> locpointsptr; 103 shared_ptr<NgArray<INDEX_2>> loclinesptr; 104 shared_ptr<NgArray<Point<2>>> plainpointsptr; 105 int oldnl; 106 bool clearptr; 107 VisualSceneSurfaceMeshing (); 108 virtual ~VisualSceneSurfaceMeshing (); 109 110 void BuildScene (int zoomall = 0) override; 111 void DrawScene () override; 112 void MouseMove(int oldx, int oldy, int newx, int newy, 113 char mode) override; 114 }; 115 116 117 118 119 120 121 122 class VisualSceneMesh : public VisualScene 123 { 124 int filledlist; 125 int linelist; 126 int edgelist; 127 int pointnumberlist; 128 129 int tetlist; 130 int prismlist; 131 int pyramidlist; 132 int hexlist; 133 134 int badellist; 135 int identifiedlist; 136 int domainsurflist; 137 138 int vstimestamp;//, selecttimestamp; 139 int filledtimestamp; 140 int linetimestamp; 141 int edgetimestamp; 142 int pointnumbertimestamp; 143 144 int tettimestamp; 145 int prismtimestamp; 146 int pyramidtimestamp; 147 int hextimestamp; 148 149 int badeltimestamp; 150 int identifiedtimestamp; 151 int domainsurftimestamp; 152 153 154 #ifdef PARALLELGL 155 NgArray<int> par_linelists; 156 NgArray<int> par_filledlists; 157 #endif 158 159 MouseEventHandler * user_me_handler; 160 161 NgLock *lock; 162 163 // int selface, selelement; 164 // int selpoint, selpoint2, locpi; 165 // int seledge; 166 167 double minh, maxh; // for meshsize coloring 168 169 // weak_ptr<Mesh> wp_mesh; 170 171 public: 172 DLL_HEADER VisualSceneMesh (); 173 DLL_HEADER virtual ~VisualSceneMesh (); 174 175 DLL_HEADER virtual void BuildScene (int zoomall = 0); 176 DLL_HEADER virtual void DrawScene (); 177 DLL_HEADER virtual void MouseDblClick (int px, int py); 178 179 // void SetMesh (shared_ptr<Mesh> mesh) { wp_mesh = mesh; } 180 // shared_ptr<Mesh> GetMesh () { return shared_ptr<Mesh>(wp_mesh); } GetMesh() const181 shared_ptr<Mesh> GetMesh () const { return shared_ptr<Mesh>(global_mesh); } 182 SetMouseEventHandler(MouseEventHandler * handler)183 void SetMouseEventHandler (MouseEventHandler * handler) 184 { user_me_handler = handler; } 185 186 SelectedFace() const187 DLL_HEADER int SelectedFace () const 188 { return selface; } 189 DLL_HEADER void SetSelectedFace (int asf); 190 // { selface = asf; selecttimestamp = GetTimeStamp(); } 191 SelectedEdge() const192 DLL_HEADER int SelectedEdge () const 193 { return seledge; } SelectedElement() const194 DLL_HEADER int SelectedElement () const 195 { return selelement; } SelectedPoint() const196 DLL_HEADER int SelectedPoint () const 197 { return selpoint; } 198 void BuildFilledList (bool names); 199 // private: 200 void BuildLineList(); 201 void BuildEdgeList(); 202 void BuildPointNumberList(); 203 204 void BuildTetList(); 205 void BuildPrismList(); 206 void BuildPyramidList(); 207 void BuildHexList(); 208 209 void BuildBadelList(); 210 void BuildIdentifiedList(); 211 void BuildDomainSurfList(); 212 213 bool Unproject (int px, int py, Point<3> &p); 214 }; 215 216 DLL_HEADER extern VisualSceneMesh vsmesh; 217 218 219 class DLL_HEADER VisualSceneSpecPoints : public VisualScene 220 { 221 public: 222 VisualSceneSpecPoints (); 223 virtual ~VisualSceneSpecPoints (); 224 225 virtual void BuildScene (int zoomall = 0); 226 virtual void DrawScene (); 227 228 double len; 229 }; 230 231 232 233 234 235 236 237 // extern struct Tcl_Interp * hinterp; 238 239 240 extern void AddVisualizationScene (const string & name, 241 VisualScene * vs); 242 243 244 void MouseDblClickSelect (const int px, const int py, 245 const GLdouble * clipplane, const GLdouble backcolor, 246 const double * transformationmat, 247 const Point3d & center, 248 const double rad, 249 const int displaylist, 250 int & selelement, int & selface, int & seledge, PointIndex & selpoint, 251 PointIndex & selpoint2, int & locpi); 252 253 254 DLL_HEADER std::vector<unsigned char> Snapshot( int w, int h ); 255 } 256 257 258 #endif 259 260