From 725a714bf328671f7edd5ea41b672a95efd37301 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Wed, 12 Feb 2014 15:13:35 +0000 Subject: [PATCH] dbl-clk function with point coordinates --- libsrc/csg/vscsg.cpp | 4 +- libsrc/geom2d/vsgeom2d.cpp | 2 +- libsrc/occ/vsocc.cpp | 4 +- libsrc/stlgeom/vsstl.cpp | 6 +-- libsrc/visualization/meshdoc.cpp | 4 +- libsrc/visualization/mvdraw.cpp | 82 ++++++++++++++--------------- libsrc/visualization/mvdraw.hpp | 12 ++--- libsrc/visualization/soldata.hpp | 2 +- libsrc/visualization/vsmesh.cpp | 27 +++++----- libsrc/visualization/vssolution.cpp | 2 +- 10 files changed, 73 insertions(+), 72 deletions(-) diff --git a/libsrc/csg/vscsg.cpp b/libsrc/csg/vscsg.cpp index dc72b51a..f6102161 100644 --- a/libsrc/csg/vscsg.cpp +++ b/libsrc/csg/vscsg.cpp @@ -59,7 +59,7 @@ namespace netgen glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); SetClippingPlane (); @@ -259,7 +259,7 @@ namespace netgen glLineWidth (1.0f); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); // glEnable (GL_COLOR); // glDisable (GL_COLOR_MATERIAL); diff --git a/libsrc/geom2d/vsgeom2d.cpp b/libsrc/geom2d/vsgeom2d.cpp index 2ab2d066..f0cff330 100644 --- a/libsrc/geom2d/vsgeom2d.cpp +++ b/libsrc/geom2d/vsgeom2d.cpp @@ -39,7 +39,7 @@ namespace netgen // glEnable (GL_LIGHT0); glDisable (GL_LIGHTING); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); // SetClippingPlane (); diff --git a/libsrc/occ/vsocc.cpp b/libsrc/occ/vsocc.cpp index 5107a62b..4d806006 100644 --- a/libsrc/occ/vsocc.cpp +++ b/libsrc/occ/vsocc.cpp @@ -58,7 +58,7 @@ namespace netgen SetLight(); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glShadeModel (GL_SMOOTH); glDisable (GL_COLOR_MATERIAL); @@ -654,7 +654,7 @@ namespace netgen glMatrixMode (GL_MODELVIEW); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glInitNames(); glPushName (1); diff --git a/libsrc/stlgeom/vsstl.cpp b/libsrc/stlgeom/vsstl.cpp index 338c305d..cbd14cb6 100644 --- a/libsrc/stlgeom/vsstl.cpp +++ b/libsrc/stlgeom/vsstl.cpp @@ -84,7 +84,7 @@ void VisualSceneSTLMeshing :: DrawScene () SetLight(); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); SetClippingPlane (); @@ -865,7 +865,7 @@ void VisualSceneSTLMeshing :: MouseDblClick (int px, int py) glMatrixMode (GL_MODELVIEW); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glInitNames(); @@ -1101,7 +1101,7 @@ void VisualSceneSTLMeshing :: MouseDblClick (int px, int py) glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); diff --git a/libsrc/visualization/meshdoc.cpp b/libsrc/visualization/meshdoc.cpp index c2df277e..8638c490 100644 --- a/libsrc/visualization/meshdoc.cpp +++ b/libsrc/visualization/meshdoc.cpp @@ -105,7 +105,7 @@ void VisualSceneMeshDoctor :: DrawScene () SetLight(); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glInitNames (); glPushName (0); @@ -479,7 +479,7 @@ void VisualSceneMeshDoctor :: MouseDblClick (int px, int py) glMatrixMode (GL_MODELVIEW); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glInitNames(); glPushName (1); diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 2b75a88b..489592d6 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -41,11 +41,11 @@ namespace netgen int VisualScene :: ntexcols = -1; - float VisualScene :: lookatmat[16]; - float VisualScene :: transmat[16]; - float VisualScene :: rotmat[16]; - float VisualScene :: centermat[16]; - float VisualScene :: transformationmat[16]; + double VisualScene :: lookatmat[16]; + double VisualScene :: transmat[16]; + double VisualScene :: rotmat[16]; + double VisualScene :: centermat[16]; + double VisualScene :: transformationmat[16]; int VisualScene :: selface; int VisualScene :: selelement; @@ -158,25 +158,25 @@ namespace netgen glLoadIdentity(); gluLookAt (0, 0, 6, 0, 0, 0, 0, 1, 0); - glGetFloatv (GL_MODELVIEW_MATRIX, lookatmat); + glGetDoublev (GL_MODELVIEW_MATRIX, lookatmat); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -dist); - glGetFloatv (GL_MODELVIEW_MATRIX, transmat); + glGetDoublev (GL_MODELVIEW_MATRIX, transmat); glLoadIdentity(); - glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); + glGetDoublev (GL_MODELVIEW_MATRIX, rotmat); - glScalef (1/rad, 1/rad, 1/rad); + glScaled (1/rad, 1/rad, 1/rad); glTranslated (-center.X(), -center.Y(), -center.Z()); - glGetFloatv (GL_MODELVIEW_MATRIX, centermat); + glGetDoublev (GL_MODELVIEW_MATRIX, centermat); glLoadIdentity(); - glMultMatrixf (lookatmat); - glMultMatrixf (transmat); - glMultMatrixf (rotmat); - glMultMatrixf (centermat); - glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); + glMultMatrixd (lookatmat); + glMultMatrixd (transmat); + glMultMatrixd (rotmat); + glMultMatrixd (centermat); + glGetDoublev (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } @@ -193,14 +193,14 @@ namespace netgen glRotatef(alpha[i], vec[i].X(), vec[i].Y(), vec[i].Z()); } - glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); + glGetDoublev (GL_MODELVIEW_MATRIX, rotmat); glLoadIdentity(); - glMultMatrixf (lookatmat); - glMultMatrixf (transmat); - glMultMatrixf (rotmat); - glMultMatrixf (centermat); - glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); + glMultMatrixd (lookatmat); + glMultMatrixd (transmat); + glMultMatrixd (rotmat); + glMultMatrixd (centermat); + glGetDoublev (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } @@ -241,14 +241,14 @@ namespace netgen glRotatef(90.0, 0.0f, 1.0f, 0.0f); - glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); + glGetDoublev (GL_MODELVIEW_MATRIX, rotmat); glLoadIdentity(); - glMultMatrixf (lookatmat); - glMultMatrixf (transmat); - glMultMatrixf (rotmat); - glMultMatrixf (centermat); - glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); + glMultMatrixd (lookatmat); + glMultMatrixd (transmat); + glMultMatrixd (rotmat); + glMultMatrixd (centermat); + glGetDoublev (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } @@ -269,8 +269,8 @@ namespace netgen { glRotatef(float(deltax)/2, 0.0f, 1.0f, 0.0f); glRotatef(float(deltay)/2, 1.0f, 0.0f, 0.0f); - glMultMatrixf (rotmat); - glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); + glMultMatrixd (rotmat); + glGetDoublev (GL_MODELVIEW_MATRIX, rotmat); break; } case 'm': @@ -310,8 +310,8 @@ namespace netgen glTranslated (px2-px1, py2-py1, pz2-pz1); - glMultMatrixf (transmat); - glGetFloatv (GL_MODELVIEW_MATRIX, transmat); + glMultMatrixd (transmat); + glGetDoublev (GL_MODELVIEW_MATRIX, transmat); break; } case 'z': @@ -324,18 +324,18 @@ namespace netgen exp (double (-deltay)/100), exp (double (-deltay)/100)); // glTranslatef(0.0f, 0.0f, dist); - glMultMatrixf (transmat); - glGetFloatv (GL_MODELVIEW_MATRIX, transmat); + glMultMatrixd (transmat); + glGetDoublev (GL_MODELVIEW_MATRIX, transmat); break; } } glLoadIdentity(); - glMultMatrixf (lookatmat); - glMultMatrixf (transmat); - glMultMatrixf (rotmat); - glMultMatrixf (centermat); - glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); + glMultMatrixd (lookatmat); + glMultMatrixd (transmat); + glMultMatrixd (rotmat); + glMultMatrixd (centermat); + glGetDoublev (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } @@ -349,8 +349,8 @@ namespace netgen gluLookAt (cam(0), cam(1), cam(2), obj(0), obj(1), obj(2), camup(0), camup(1), camup(2)); - glMultMatrixf (centermat); - glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); + glMultMatrixd (centermat); + glGetDoublev (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } @@ -631,7 +631,7 @@ namespace netgen glTranslatef (-1, -1, 0.0); glScalef (40.0 / viewport[2], 40.0 / viewport[3], 1); glTranslatef (2.0, 2.0, 0.0); - glMultMatrixf (rotmat); + glMultMatrixd (rotmat); glEnable (GL_COLOR_MATERIAL); glDisable (GL_LIGHTING); diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index 621a7ac5..71093f00 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -22,12 +22,12 @@ namespace netgen static DLL_HEADER Point3d center; static DLL_HEADER double rad; - static float lookatmat[16]; - static float transmat[16]; - static float rotmat[16]; - static float centermat[16]; + static double lookatmat[16]; + static double transmat[16]; + static double rotmat[16]; + static double centermat[16]; - static DLL_HEADER float transformationmat[16]; + static DLL_HEADER double transformationmat[16]; GLdouble clipplane[4]; @@ -236,7 +236,7 @@ namespace netgen void MouseDblClickSelect (const int px, const int py, const GLdouble * clipplane, const GLdouble backcolor, - const float * transformationmat, + const double * transformationmat, const Point3d & center, const double rad, const int displaylist, diff --git a/libsrc/visualization/soldata.hpp b/libsrc/visualization/soldata.hpp index 48989c7b..e8ff1d3c 100644 --- a/libsrc/visualization/soldata.hpp +++ b/libsrc/visualization/soldata.hpp @@ -113,7 +113,7 @@ namespace netgen class DLL_HEADER MouseEventHandler { public: - virtual void DblClick (int elnr) { ; } + virtual void DblClick (int elnr, double x, double y, double z) = 0; }; } diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index 482b2f9e..ffb0c5f6 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -97,9 +97,9 @@ namespace netgen SetLight(); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); - GLdouble projmat[16]; + GLdouble projmat[16]; // brauchen wir das ? glGetDoublev (GL_PROJECTION_MATRIX, projmat); @@ -3093,30 +3093,31 @@ namespace netgen - /* - klappt noch nicht ... + GLdouble modelview[16], projection[16]; GLint viewport[4]; GLdouble result[3]; - glGetDoublev(GL_MODELVIEW_MATRIX, &modelview[0]); + glGetDoublev(GL_PROJECTION_MATRIX, &projection[0]); glGetIntegerv(GL_VIEWPORT, &viewport[0]); int hy = viewport[3]-py; GLfloat pz; - cout << "x, y = " << px << ", " << hy << endl; + // cout << "x, y = " << px << ", " << hy << endl; glReadPixels (px, hy, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pz); - cout << "pz = " << pz << endl; gluUnProject(px, hy, pz, modelview, projection, viewport, + cout << "pz = " << pz << endl; + gluUnProject(px, hy, pz, transformationmat, projection, viewport, &result[0], &result[1], &result[2]); - cout << "3d point : " << result[0] << ", " << result[1] << ", " << result[2] << endl; - */ + + if (pz < 1.0) + cout << "point : " << result[0] << ", " << result[1] << ", " << result[2] << endl; - if (user_me_handler) + if (user_me_handler && pz < 1.0) { if (selelement != -1) - user_me_handler -> DblClick (selelement-1); + user_me_handler -> DblClick (selelement-1, result[0], result[1], result[2]); } selecttimestamp = NextTimeStamp(); @@ -3298,7 +3299,7 @@ namespace netgen void MouseDblClickSelect (const int px, const int py, const GLdouble * clipplane, const GLdouble backcolor, - const float * transformationmat, + const double * transformationmat, const Point3d & center, const double rad, const int displaylist, @@ -3337,7 +3338,7 @@ namespace netgen glMatrixMode (GL_MODELVIEW); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); // SetClippingPlane(); diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index bf5447e0..217460fa 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -362,7 +362,7 @@ namespace netgen SetLight(); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glMatrixMode (GL_MODELVIEW);