示例#1
0
文件: imp.go 项目: CaptainSoOmA/Uni
func suchen() {
	//
	/*
	   const
	     maxU = 8
	   var (
	     startlinie, ziellinie [maxU]Linie
	     startnummer, zielnummer [maxU]uint
	     n, imin, kmin uint
	   )
	   t1, t2:= netz.Get2 ()
	   bhf1, bhf2:= t1.(*bahnhof.Imp), t2.(*bahnhof.Imp)
	   startlinie [0], startnummer [0] = bhf1.Linie (), bhf1.Nummer ()
	   ziellinie [0], zielnummer [0] = bhf2.Linie (), bhf2.Nummer ()
	   ss, zz:= 1, 1
	   netz.Trav (func (a Any) {
	                bhf:= a.(*bahnhof.Imp)
	                if bhf.Equiv (bhf1) {
	                  startlinie [ss], startnummer [ss] = bhf.Linie (), bhf.Nummer ()
	                  ss ++
	                } else if bhf.Equiv (bhf2) {
	                  ziellinie [zz], zielnummer [zz] = bhf.Linie (), bhf.Nummer ()
	                  zz ++
	                }
	             })
	   nmin:= uint(ker.MaxNat)
	   for i:= 0; i < ss; i++ {
	     for k:= 0; k < zz; k++ {
	       l, n:= startlinie [i], startnummer [i]
	       l1, n1:= ziellinie [k], zielnummer [k]
	       if ! netz.ExPred2 (func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l && b.Nummer() == n },
	                          func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l1 && b.Nummer() == n1 }) {
	         ker.Stop (pack, 4)
	       }
	       netz.Actualize ()
	       n = netz.LenAct ()
	       if n < nmin {
	         nmin = n
	         imin, kmin = uint(i), uint(k)
	       }
	     }
	   }
	   l, n:= startlinie [imin], startnummer [imin]
	   l1, n1:= ziellinie [kmin], zielnummer [kmin]
	   if ! netz.ExPred2 (func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l && b.Nummer() == n },
	                      func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l1 && b.Nummer() == n1 }) {
	     ker.Stop (pack, 5)
	   }
	*/
	netz.Actualize()
	write(true)
	scr.Colours(col.HintF, col.HintB)
	scr.SwitchTransparence(false)
	na := netz.LenAct()
	scr.Write("kürzeste Verbindung "+nat.String(na)+" Minuten", 0, 0)
	scr.SwitchTransparence(true)
}
示例#2
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (f *Imp) Invert() {
	//
	if f.Empty() {
		return
	}
	switch f.sort {
	case Pointset:
		scr.PointsetInv(f.x, f.y)
	case Segments:
		scr.SegmentsInv(f.x, f.y)
	case Polygon:
		if f.filled {
			scr.PolygonInv /* TODO Full */ (f.x, f.y)
		} else {
			scr.PolygonInv(f.x, f.y)
		}
	case Curve:
		scr.CurveInv(f.x, f.y)
		if f.filled {
			n := len(f.x) - 1
			scr.CircleInv(f.x[n], f.y[n], 4)
		}
	case InfLine:
		scr.InfLineInv(f.x[0], f.y[0], f.x[1], f.y[1])
	case Rectangle:
		if f.filled {
			scr.RectangleFullInv(f.x[0], f.y[0], f.x[1], f.y[1])
		} else {
			scr.RectangleInv(f.x[0], f.y[0], f.x[1], f.y[1])
		}
	case Circle:
		if f.filled {
			scr.CircleFullInv(f.x[0], f.y[0], uint(f.x[1]))
		} else {
			scr.CircleInv(f.x[0], f.y[0], uint(f.x[1]))
		}
	case Ellipse:
		if f.filled {
			scr.EllipseFullInv(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1]))
		} else {
			scr.EllipseInv(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1]))
		}
	case Text:
		// >>>  sollte in bx integriert werden:
		//  bx.WriteInvGr (tx, x[0], y[0])
		scr.SwitchTransparence(true)
		scr.WriteInvGr(f.tx, f.x[0], f.y[0])
	case Image:
		scr.RectangleInv(f.x[0], f.y[0], f.x[1], f.y[1])
	}
}
示例#3
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (B *Imp) Write(s string, l, c uint) {
	//
	if l >= scr.NLines() {
		return
	}
	if c >= scr.NColumns() {
		return
	}
	//  Wd (&s, s)
	n, b := uint(len(s)), B.width
	if c+b > scr.NColumns() {
		B.width = scr.NColumns() - c
	}
	if B.width == 0 {
		B.width = n
	}
	if B.width > n {
		B.width = n
	}
	if B.width < n {
		Norm(&s, B.width)
	}
	//  Norm (&s, B.width)
	if B.numerical || B.TRnumerical {
		Move(&s, false)
	}
	scr.Lock()
	scr.Colours(B.cF, B.cB)
	if B.transparent {
		scr.SwitchTransparence(true)
	}
	scr.Write(s, l, c)
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
	B.width = b
}
示例#4
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (B *Imp) write(Text string, x, y uint) {
	//
	scr.Lock()
	scr.Colours(B.cF, B.cB)
	if B.transparent {
		scr.SwitchTransparence(true)
	}
	y1 := B.width
	if y1 > uint(len(Text)) {
		y1 = uint(len(Text))
	}
	for x1 := B.index; x1 < y1; x1++ {
		if B.graphical {
			scr.Write1Gr(Text[x1], int(x+scr.NX1()*x1), int(y))
		} else {
			scr.Write1(Text[x1], y/scr.NY1(), x/scr.NX1()+x1)
		}
	}
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
}
示例#5
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (B *Imp) WriteGr(s string, x, y int) {
	//
	if uint(y) >= scr.NY() {
		return
	}
	if uint(x) >= scr.NX()-scr.NX1() {
		return
	}
	n, b := uint(len(s)), B.width
	if B.width == 0 {
		B.width = n
	}
	if uint(x)+B.width*scr.NX1() > scr.NX() {
		B.width = (scr.NX() - uint(x)) / scr.NX1()
	}
	if B.width > n {
		B.width = n
	}
	if B.width < n {
		Norm(&s, B.width)
	}
	if B.numerical || B.TRnumerical {
		Move(&s, false)
	}
	scr.Lock()
	scr.Colours(B.cF, B.cB)
	if B.transparent {
		scr.SwitchTransparence(true)
	}
	scr.WriteGr(s, x, y)
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
	B.width = b
}
示例#6
0
文件: imp.go 项目: CaptainSoOmA/Uni
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 {
	}
}
示例#7
0
文件: main.go 项目: CaptainSoOmA/Uni
func main() {
	//
	if !scr.MouseEx() {
		return
	}
	var symbol [Nfigure]byte
	symbol[line] = 'S'      // "Strecke"
	symbol[rectangle] = 'R' // "Rechteck"
	symbol[circle] = 'K'    // "Kreis"
	symbol[ellipse] = 'E'   // "Ellipse"
	X, Y := 0, 0
	X1, Y1 := scr.NX(), scr.NY()
	//  Farbe, Papier:= col.LightWhite, col.Black
	Farbe, Papier := col.Black, col.LightWhite
	col.ScreenF, col.ScreenB = Farbe, Papier
	scr.Cls()
	paintColour := Farbe
	scr.Colour(paintColour)
	//  Staerke = 3
	bx := box.New()
	bx.Wd(20)
	bx.Colours(Papier, Farbe)
	Name := env.Par(1)
	if str.Empty(Name) {
		Name = "temp"
	}
	scr.Save(0, 0, 20, 1)
	for {
		bx.Edit(&Name, 0, 0)
		if !str.Empty(Name) {
			str.RemSpaces(&Name)
			break
		}
	}
	scr.Restore(0, 0, 20, 1)
	img.Get(Name, uint(X), uint(Y))
	scr.MouseCursor(true)
	Figur := figure(rectangle)
	var x, y, x0, y0 int
loop:
	for {
		scr.Colour(paintColour)
		Zeichen, Kommando, T := kbd.Read()
		switch Kommando {
		case kbd.None:
			x, y = scr.MousePosGr()
			scr.SwitchTransparence(true)
			scr.Write1Gr(Zeichen, x, y-int(scr.NY1()))
			//    scr.WarpMouse (x + scr.NX1(), y)
		case kbd.Esc:
			break loop
		case kbd.Back:
			switch T {
			case 0:
				x, y = scr.MousePosGr()
				x -= int(scr.NX1())
				scr.Colour(Papier)
				scr.Write1Gr(' ', x, y-int(scr.NY1()))
				//        scr.RectangleFull (x, y - scr.NY1(), x + scr.NX1(), y)
				//        scr.WarpMouseGr (x, y)
				scr.Colour(paintColour)
			default:
				scr.Cls()
			}
			/*
			   case kbd.Ins:
			     img.Write (X, Y, X1, Y1 - 16, Name)
			     box.Edit (Feld, Name, scr.Zeilenzahl () - 1, 0)
			     img.Get (X, Y, Name)
			*/
		case kbd.Help:
			paintColour = sel.Colour()
			//    case kbd.LookFor:
			//      Staerke = Strichstaerken.Staerke()
		case kbd.Enter:
			if T > 0 {
				x0, y0 = scr.MousePosGr()
				//        scr.Fill1 (x0, y0)
			}
		case kbd.PrintScr:
			img.Print(uint(X), uint(Y), X1, Y1-16)
		case kbd.Tab:
			if T == 0 {
				if Figur+1 < Nfigure {
					Figur++
				} else {
					Figur = figure(0)
				}
			} else {
				if Figur > 0 {
					Figur--
				} else {
					Figur = figure(Nfigure - 1)
				}
			}
			scr.Colours(col.White, Papier)
			scr.Write1(symbol[Figur], scr.NY()-1, 0)
		case kbd.Here:
			x0, y0 = scr.MousePosGr()
			scr.CircleFull(x0, y0, 3/2)
		case kbd.Pull:
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
			x0, y0 = x, y
		case kbd.Hither:
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
		case kbd.There:
			x0, y0 = scr.MousePosGr()
			x, y = x0, y0
		case kbd.Push:
			paint(Figur, inv, x0, y0, x, y)
			x, y = scr.MousePosGr()
			paint(Figur, inv, x0, y0, x, y)
		case kbd.Thither:
			paint(Figur, inv, x0, y0, x, y)
			//      scr.Colour (paintColour)
			x, y = scr.MousePosGr()
			paint(Figur, border, x0, y0, x, y)
			x0, y0 = x, y
		case kbd.This:
			x0, y0 = scr.MousePosGr()
			x, y = x0, y0
		case kbd.Move:
			scr.LineInv(x0, y0, x, y)
			x, y = scr.MousePosGr()
			scr.LineInv(x0, y0, x, y)
		case kbd.Thus:
			scr.LineInv(x0, y0, x, y)
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
			x0, y0 = x, y
		}
	}
	scr.Save(0, 0, 20, 1)
	for {
		bx.Edit(&Name, 0, 0)
		// TODO make sure, that "Name" is x{x|y} where x is letter, y is digit
		if !str.Empty(Name) {
			str.RemSpaces(&Name)
			break
		}
	}
	scr.Restore(0, 0, 20, 1)
	img.Put(Name, uint(X), uint(Y), X1, Y1)
	ker.Terminate()
}