netgen/libsrc/visualization/mvdraw.hpp

265 lines
6.4 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_MVDRAW
#define FILE_MVDRAW
2009-07-20 14:36:36 +06:00
namespace netgen
{
2009-01-13 04:40:13 +05:00
2009-09-07 21:15:22 +06:00
2009-07-20 14:36:36 +06:00
class VisualScene
{
protected:
static NGGUI_API Point3d center;
static NGGUI_API double rad;
2009-01-13 04:40:13 +05:00
static double lookatmat[16];
static double transmat[16];
static double rotmat[16];
static double centermat[16];
2012-10-29 23:52:31 +06:00
static NGGUI_API double transformationmat[16];
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
GLdouble clipplane[4];
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
int changeval;
static NGGUI_API GLdouble backcolor;
2009-01-13 04:40:13 +05:00
static int NGGUI_API selface;
2009-07-20 14:36:36 +06:00
static int selelement;
static PointIndex NGGUI_API selpoint;
2016-12-11 16:12:05 +05:00
static PointIndex selpoint2;
2009-07-20 14:36:36 +06:00
static int locpi;
static int NGGUI_API seledge;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
static int selecttimestamp;
static optional<Point<3>> marker;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
public:
2014-10-06 15:57:44 +06:00
static int viewport[4];
2009-07-20 14:36:36 +06:00
static GLuint coltexname;
static int ntexcols;
int invcolor;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
public:
NGGUI_API VisualScene ();
NGGUI_API virtual ~VisualScene();
2009-01-13 04:40:13 +05:00
NGGUI_API virtual void BuildScene (int zoomall = 0);
NGGUI_API virtual void DrawScene ();
2009-01-13 04:40:13 +05:00
NGGUI_API void CalcTransformationMatrices();
NGGUI_API void StandardRotation (const char * dir);
NGGUI_API void ArbitraryRotation (const NgArray<double> & alpha, const NgArray<Vec3d> & vec);
NGGUI_API void ArbitraryRotation (const double alpha, const Vec3d & vec);
2009-01-13 04:40:13 +05:00
NGGUI_API virtual void MouseMove(int oldx, int oldy,
int newx, int newy,
char mode);
2009-01-13 04:40:13 +05:00
NGGUI_API void LookAt (const Point<3> & cam, const Point<3> & obj,
2009-07-20 14:36:36 +06:00
const Point<3> & camup);
2009-01-13 04:40:13 +05:00
NGGUI_API void SetClippingPlane ();
2009-01-13 04:40:13 +05:00
NGGUI_API virtual void MouseDblClick (int px, int py);
2009-01-13 04:40:13 +05:00
NGGUI_API void SetLight ();
2009-07-20 14:36:36 +06:00
static void SetBackGroundColor (double col)
2009-01-13 04:40:13 +05:00
{ backcolor = col; }
NGGUI_API void CreateTexture (int ncols, int linear, double alpha, int typ);
NGGUI_API void DrawColorBar (double minval, double maxval, int logscale = 0, bool linear = 1, string format="%8.3e", string unit="");
NGGUI_API void DrawTitle (string title);
NGGUI_API void DrawCoordinateCross ();
NGGUI_API void DrawMarker();
NGGUI_API void DrawNetgenLogo ();
NGGUI_API void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0);
2012-10-29 23:52:31 +06:00
2009-01-13 04:40:13 +05:00
#ifdef PARALLELGL
NGGUI_API void InitParallelGL ();
NGGUI_API void Broadcast ();
2009-01-13 04:40:13 +05:00
#endif
2009-07-20 14:36:36 +06:00
};
2009-01-13 04:40:13 +05:00
NGGUI_API extern void MyOpenGLText (const char * text);
2022-10-06 18:29:13 +05:00
NGGUI_API extern int MyOpenGLTextWidth ();
NGGUI_API extern void Set_OpenGLText_Callback ( void (*fun) (const char * text), int width );
NGGUI_API extern VisualScene visual_scene_cross;
NGGUI_API extern VisualScene *visual_scene;
2009-09-07 21:15:22 +06:00
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
class VisualSceneSurfaceMeshing : public VisualScene
{
double scalex = 1., scaley = 1., shiftx = 0., shifty = 0.;
2009-07-20 14:36:36 +06:00
public:
2019-09-29 19:22:00 +05:00
shared_ptr<NgArray<Point<3>>> locpointsptr;
2019-09-22 01:08:35 +05:00
shared_ptr<NgArray<INDEX_2>> loclinesptr;
2019-09-29 19:22:00 +05:00
shared_ptr<NgArray<Point<2>>> plainpointsptr;
int oldnl;
2019-09-22 01:08:35 +05:00
bool clearptr;
2009-07-20 14:36:36 +06:00
VisualSceneSurfaceMeshing ();
virtual ~VisualSceneSurfaceMeshing ();
2009-01-13 04:40:13 +05:00
void BuildScene (int zoomall = 0) override;
void DrawScene () override;
NGGUI_API void MouseMove(int oldx, int oldy, int newx, int newy,
char mode) override;
2009-07-20 14:36:36 +06:00
};
2009-01-13 04:40:13 +05:00
NGGUI_API extern VisualSceneSurfaceMeshing vssurfacemeshing;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
class VisualSceneMesh : public VisualScene
{
int filledlist;
int linelist;
int edgelist;
int pointnumberlist;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
int tetlist;
int prismlist;
int pyramidlist;
int hexlist;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
int badellist;
int identifiedlist;
int domainsurflist;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
int vstimestamp;//, selecttimestamp;
int filledtimestamp;
int linetimestamp;
int edgetimestamp;
int pointnumbertimestamp;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
int tettimestamp;
int prismtimestamp;
int pyramidtimestamp;
int hextimestamp;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
int badeltimestamp;
int identifiedtimestamp;
int domainsurftimestamp;
2009-01-13 04:40:13 +05:00
#ifdef PARALLELGL
2019-07-09 13:39:16 +05:00
NgArray<int> par_linelists;
NgArray<int> par_filledlists;
2009-01-13 04:40:13 +05:00
#endif
2012-08-30 19:40:17 +06:00
MouseEventHandler * user_me_handler;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
NgLock *lock;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
// int selface, selelement;
// int selpoint, selpoint2, locpi;
// int seledge;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
double minh, maxh; // for meshsize coloring
2009-01-13 04:40:13 +05:00
2015-01-09 02:18:33 +05:00
// weak_ptr<Mesh> wp_mesh;
2014-10-06 15:57:44 +06:00
2009-07-20 14:36:36 +06:00
public:
NGGUI_API VisualSceneMesh ();
NGGUI_API virtual ~VisualSceneMesh ();
2009-01-13 04:40:13 +05:00
NGGUI_API virtual void BuildScene (int zoomall = 0);
NGGUI_API virtual void DrawScene ();
NGGUI_API virtual void MouseDblClick (int px, int py);
2009-01-13 04:40:13 +05:00
2015-01-09 02:18:33 +05:00
// void SetMesh (shared_ptr<Mesh> mesh) { wp_mesh = mesh; }
// shared_ptr<Mesh> GetMesh () { return shared_ptr<Mesh>(wp_mesh); }
shared_ptr<Mesh> GetMesh () const { return shared_ptr<Mesh>(global_mesh); }
2014-10-06 15:57:44 +06:00
2012-08-30 19:40:17 +06:00
void SetMouseEventHandler (MouseEventHandler * handler)
{ user_me_handler = handler; }
NGGUI_API int SelectedFace () const
2009-01-13 04:40:13 +05:00
{ return selface; }
NGGUI_API void SetSelectedFace (int asf);
2009-07-20 14:36:36 +06:00
// { selface = asf; selecttimestamp = GetTimeStamp(); }
2009-01-13 04:40:13 +05:00
NGGUI_API int SelectedEdge () const
2009-01-13 04:40:13 +05:00
{ return seledge; }
NGGUI_API int SelectedElement () const
2009-01-13 04:40:13 +05:00
{ return selelement; }
NGGUI_API int SelectedPoint () const
2009-01-13 04:40:13 +05:00
{ return selpoint; }
2011-01-15 01:50:12 +05:00
void BuildFilledList (bool names);
2009-07-20 14:36:36 +06:00
// private:
void BuildLineList();
void BuildEdgeList();
void BuildPointNumberList();
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
void BuildTetList();
void BuildPrismList();
void BuildPyramidList();
void BuildHexList();
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
void BuildBadelList();
void BuildIdentifiedList();
void BuildDomainSurfList();
2021-01-08 12:30:47 +05:00
bool Unproject (int px, int py, Point<3> &p);
2009-07-20 14:36:36 +06:00
};
2009-01-13 04:40:13 +05:00
NGGUI_API extern VisualSceneMesh vsmesh;
2014-10-06 15:57:44 +06:00
2009-01-13 04:40:13 +05:00
class NGGUI_API VisualSceneSpecPoints : public VisualScene
2009-07-20 14:36:36 +06:00
{
public:
VisualSceneSpecPoints ();
virtual ~VisualSceneSpecPoints ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
double len;
};
2011-01-11 01:18:01 +05:00
2014-10-12 17:40:12 +06:00
2011-01-11 01:18:01 +05:00
2009-07-20 14:36:36 +06:00
// extern struct Tcl_Interp * hinterp;
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
extern void AddVisualizationScene (const string & name,
VisualScene * vs);
2009-01-13 04:40:13 +05:00
2009-07-20 14:36:36 +06:00
void MouseDblClickSelect (const int px, const int py,
const GLdouble * clipplane, const GLdouble backcolor,
const double * transformationmat,
2009-07-20 14:36:36 +06:00
const Point3d & center,
const double rad,
const int displaylist,
2016-12-11 16:12:05 +05:00
int & selelement, int & selface, int & seledge, PointIndex & selpoint,
PointIndex & selpoint2, int & locpi);
2009-01-13 04:40:13 +05:00
NGGUI_API std::vector<unsigned char> Snapshot( int w, int h );
2009-07-20 14:36:36 +06:00
}
2009-01-13 04:40:13 +05:00
#endif