allow 2d plainview to be moved using meta key

This commit is contained in:
Christopher Lackner 2019-09-22 14:37:14 +02:00
parent d274cf8121
commit 4eb7c1860c
6 changed files with 71 additions and 15 deletions

View File

@ -18,7 +18,7 @@ namespace netgen
// // static int geomtrig;
// //static const char * rname;
// static int cntelem, trials, nfaces;
static int oldnl;
// static int oldnl;
// static int qualclass;
@ -257,7 +257,8 @@ namespace netgen
auto &loclines = *loclinesptr;
vssurfacemeshing.loclinesptr = loclinesptr;
int cntelem = 0, trials = 0, nfaces = 0;
oldnl = 0;
int oldnl = 0;
vssurfacemeshing.oldnl = oldnl;
int qualclass;
@ -523,6 +524,7 @@ namespace netgen
{
oldnp = locpoints.Size();
oldnl = loclines.Size();
vssurfacemeshing.oldnl = oldnl;
if (debugflag)
(*testout) << "define new transformation" << endl;
@ -1461,6 +1463,7 @@ namespace netgen
(*testout) << adfront.GetGlobalIndex (pindex.Get(i)) << endl;
(*testout) << "old number of lines = " << oldnl << endl;
vssurfacemeshing.oldnl = oldnl;
for (int i = 1; i <= loclines.Size(); i++)
{
(*testout) << "line ";
@ -1758,8 +1761,6 @@ namespace netgen
float mat_col2d[] = { 1, 1, 1, 1 };
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d);
double scalex = 0.1, scaley = 0.1;
glBegin (GL_LINES);
for (int i = 1; i <= loclines.Size(); i++)
{
@ -1776,8 +1777,8 @@ namespace netgen
Point2d p2 = plainpoints.Get(pi2);
glBegin (GL_LINES);
glVertex3f (scalex * p1.X(), scaley * p1.Y(), -5);
glVertex3f (scalex * p2.X(), scaley * p2.Y(), -5);
glVertex3f (scalex * p1.X() + shiftx, scaley * p1.Y() + shifty, -5);
glVertex3f (scalex * p2.X() + shiftx, scaley * p2.Y() + shifty, -5);
glEnd();
}
}
@ -1789,7 +1790,7 @@ namespace netgen
for (int i = 1; i <= plainpoints.Size(); i++)
{
Point2d p = plainpoints.Get(i);
glVertex3f (scalex * p.X(), scaley * p.Y(), -5);
glVertex3f (scalex * p.X() + shiftx, scaley * p.Y() + shifty, -5);
}
glEnd();

View File

@ -758,9 +758,26 @@ namespace netgen
}
void VisualSceneSurfaceMeshing::MouseMove(int oldx, int oldy,
int newx, int newy,
char mode)
{
double fac = 0.001;
if(mode == 'M')
{
shiftx += fac * (newx - oldx);
shifty += fac * (oldy - newy);
return;
}
else if(mode == 'Z')
{
scalex *= (1 - fac * (newy - oldy));
scaley *= (1 - fac * (newy - oldy));
return;
}
VisualScene::MouseMove(oldx, oldy, newx, newy, mode);
}
#ifdef PARALLELGL

View File

@ -52,9 +52,9 @@ namespace netgen
DLL_HEADER void ArbitraryRotation (const NgArray<double> & alpha, const NgArray<Vec3d> & vec);
DLL_HEADER void ArbitraryRotation (const double alpha, const Vec3d & vec);
DLL_HEADER void MouseMove(int oldx, int oldy,
int newx, int newy,
char mode);
DLL_HEADER virtual void MouseMove(int oldx, int oldy,
int newx, int newy,
char mode);
DLL_HEADER void LookAt (const Point<3> & cam, const Point<3> & obj,
const Point<3> & camup);
@ -95,16 +95,20 @@ namespace netgen
class VisualSceneSurfaceMeshing : public VisualScene
{
double scalex = 1., scaley = 1., shiftx = 0., shifty = 0.;
public:
shared_ptr<NgArray<Point3d>> locpointsptr;
shared_ptr<NgArray<INDEX_2>> loclinesptr;
shared_ptr<NgArray<Point2d>> plainpointsptr;
int oldnl;
bool clearptr;
VisualSceneSurfaceMeshing ();
virtual ~VisualSceneSurfaceMeshing ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
void BuildScene (int zoomall = 0) override;
void DrawScene () override;
void MouseMove(int oldx, int oldy, int newx, int newy,
char mode) override;
};

View File

@ -81,6 +81,18 @@ if { $toglok == 1} {
.ndraw render
set oldmousex %x; set oldmousey %y;
}
bind .ndraw <Alt-B2-Motion> {
Ng_MouseMove $oldmousex $oldmousey %x %y Move2d
.ndraw render
set oldmousex %x; set oldmousey %y;
}
bind .ndraw <Alt-B3-Motion> {
Ng_MouseMove $oldmousex $oldmousey %x %y Zoom2d
.ndraw render
set oldmousex %x; set oldmousey %y;
}
}

View File

@ -54,6 +54,18 @@ if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth t
.ndraw render
set oldmousex %x; set oldmousey %y;
}
bind .ndraw <Alt-B2-Motion> {
Ng_MouseMove $oldmousex $oldmousey %x %y Move2d
.ndraw render
set oldmousex %x; set oldmousey %y;
}
bind .ndraw <Alt-B3-Motion> {
Ng_MouseMove $oldmousex $oldmousey %x %y Zoom2d
.ndraw render
set oldmousex %x; set oldmousey %y;
}
}

View File

@ -3373,6 +3373,16 @@ const char * ngscript[] = {""
,".ndraw render\n"
,"set oldmousex %x; set oldmousey %y;\n"
,"}\n"
,"bind .ndraw <Alt-B2-Motion> {\n"
,"Ng_MouseMove $oldmousex $oldmousey %x %y Move2d\n"
,".ndraw render\n"
,"set oldmousex %x; set oldmousey %y;\n"
,"}\n"
,"bind .ndraw <Alt-B3-Motion> {\n"
,"Ng_MouseMove $oldmousex $oldmousey %x %y Zoom2d\n"
,".ndraw render\n"
,"set oldmousex %x; set oldmousey %y;\n"
,"}\n"
,"}\n"
,"proc popupcheckredraw { vari { x 0 } } {\n"
,"upvar $vari varname\n"