func Init(fern float64) { // called by points.Start () // const ( D = 2.0 // -fache Bildschirmbreite nah = C.GLdouble(0.2) ) if !initialized { initialize() } C.glMatrixMode(C.GL_PROJECTION) C.glLoadIdentity() deg := D * math.Atan((0.5/D)/scr.Proportion()) deg /= 0.9 // experimentelle Weitwinkelkorrektur var m [4][4]C.GLdouble m[1][1] = 1.0 / C.GLdouble(math.Tan(deg)) // Cot m[0][0] = m[1][1] / C.GLdouble(scr.Proportion()) // delta:= C.GLdouble(fern) - nah // m[2][2] = - (C.GLdouble(fern) + nah) / delta // m[2][3] = GLdouble(-1.0) // m[3][2] = -2. * nah * C.GLdouble(fern) / delta m[2][2] = C.GLdouble(-1.0) m[2][3] = C.GLdouble(-1.0) m[3][2] = C.GLdouble(-1.0) * nah C.glMultMatrixd(&m[0][0]) // q:= C.GLdouble(0.75) // GLFrustum (-1.0 * nah, 1.0 * nah, -q * nah, q * nah, 1.0 * nah, C.GLdouble(fern)) C.glMatrixMode(C.GL_MODELVIEW) }
func init() { // bMin, lMin := 12.8800, 52.2850 // x, y bMax, hMax := 1.0647, 0.4859 // 72, 54 km if scr.Proportion() > 4/3 { bMax = bMax / 4 * 3 * scr.Proportion() } b0, l0 := 13.2610, 52.4550 scale.Def(b0*dB, l0*dL, 16) scale.Lim(bMin*dB, lMin*dL, bMax*dB, hMax*dL, 6) scr.SwitchTransparence(true) scr.MouseCursor(true) var bhf Bahnhof = New() if bhf == nil { } }
func def(x, y, w float64) { // nX, nY = float64(scr.NX()), float64(scr.NY()) x0, y0 = x, y if w <= 0 { width = 1 } else { width = w } height = width / scr.Proportion() xm, ym = x0+width/2, y0+height/2 mX, mY = nX/width, nY/height }
func edit() { // var d uint c := kbd.LastCommand(&d) if d > 2 { d = 2 } switch c { case kbd.Back: if width < maxWidth { w := width * mm[d] if w > maxWidth { w = maxWidth } dw := (w - width) / 2 x0, y0 = x0-dw, y0-dw/scr.Proportion() width = w } else { // überschritten x0, y0 = xMin, yMin width = maxWidth } height = width / scr.Proportion() mX, mY = nX/width, nY/height case kbd.Enter: if width > maxWidth/maxMag { w := width / mm[d] if w < maxWidth/maxMag { w = maxWidth / maxMag } dw := (w - width) / 2 x0, y0 = x0-dw, y0-dw/scr.Proportion() width = w height = width / scr.Proportion() mX, mY = nX/width, nY/height } case kbd.Left: if x0 >= xMin { x0 = x0 - width/nn[d] } case kbd.Right: if x0+width <= xMin+maxWidth { x0 = x0 + width/nn[d] } // TODO: Rollrad von Maus einbauen - die sendet Up/Down case kbd.Up: if y0+height < yMin+maxHeight { y0 = y0 + width/nn[d] } case kbd.Down: if y0 >= yMin { y0 = y0 - width/nn[d] } case kbd.This: x, y := scr.MousePosGr() y = int(scr.NY()) - y x0 = x0 + float64(x)/mX - width/2 y0 = y0 + float64(y)/mY - height/2 case kbd.There: x, y := scr.MousePosGr() xt, yt = float64(x), float64(int(scr.NY())-y) case kbd.Push, kbd.Thither: x, y := scr.MousePosGr() x0 = x0 - (float64(x)-xt)/mX y0 = y0 - (float64(int(scr.NY())-y)-yt)/mY xt, yt = float64(x), float64(int(scr.NY())-y) } if x0 < xMin { x0 = xMin } if x0+width > xMin+maxWidth { x0 = xMin + maxWidth - width } if y0 < yMin { y0 = yMin } if y0+height >= yMin+maxHeight { y0 = yMin + maxHeight - height } }