Skip to content

Commit

Permalink
#194 Converting EGridFlatGui to projection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Dec 7, 2022
1 parent fe58559 commit c227544
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Tiling/src/egrid/EGridFlatGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ case class EGridFlatGui(canv: CanvasPlatform, scen: EScenFlat, viewIn: HGView) e
//debvar(terrPolys.length)

def tiles: RArr[PolygonCompound] = gridSys.map{ hc => hc.hVertPolygon.toPolygon(gridSys.flatHCoordToPt2(_)).fillActive(terrs(hc).colour.modAlpha(128), hc) }
def sides: GraphicElems = sTerrs.truesMap{hs => Rectangle.fromAxisRatio(hs.lineSegDepr, 0.3).fill(Colour.DarkBlue) }
// def sides: GraphicElems = sTerrs.truesMap{hs => Rectangle.fromAxisRatio(hs.lineSegDepr, 0.3).fill(Colour.DarkBlue) }
def sides2: GraphicElems = sTerrs.projTruesMap(proj){hs => Rectangle.fromAxisRatio(proj.lineSeg(hs), 0.3).fill(Colour.DarkBlue) }

def tileStrs: RArr[PolygonCompound] = gridSys.map{ hc =>
hc.hVertPolygon.toPolygon(gridSys.flatHCoordToPt2(_)).fillTextActive(terrs(hc).colour.modAlpha(128), hc, hc.rcStr32 --- hc.rcStr, 12, terrs(hc).contrastBW)
}

def thisTop(): Unit = reTop(proj.buttons ++ navButtons)
def frame: GraphicElems = terrPolys ++
/* (ife(cPScale > 25, tileStrs, tiles) ++*/( sides).slate(-focus).scale(cPScale)
def thisTop(): Unit = reTop(proj.buttons)// ++ navButtons)
def frame: GraphicElems = terrPolys ++ sides2
// /* (ife(cPScale > 25, tileStrs, tiles) ++*/( sides).slate(-focus).scale(cPScale)
repaint()
proj.getFrame = () => frame
proj.setStatusText = { str =>
Expand Down
11 changes: 11 additions & 0 deletions Tiling/src/prid/phex/HSideLayer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ final class HSideBoolLayer(val unsafeArray: Array[Boolean]) extends AnyVal with

def trueHSides(implicit gridSys: HGridSys): HSideArr = truesMap(hs => hs)

def projTruesMap[B, ArrB <: Arr[B]](proj: HSysProjection)(f: HSide => B)(implicit build: ArrMapBuilder[B, ArrB]): ArrB = {
var i = 0
val buff = build.newBuff()
proj.gChild.sidesForeach { hs =>
if (unsafeArray(i))
build.buffGrow(buff, f(hs))
i += 1
}
build.buffToSeqLike(buff)
}

def set(hs: HSide, value: Boolean)(implicit grid: HGridSys): Unit = {
val i = grid.sideArrIndex(hs)
if (i >= unsafeArray.length) deb(s"$hs")
Expand Down
2 changes: 2 additions & 0 deletions Tiling/src/prid/phex/HSysProjection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ trait HSysProjection extends TSysProjection
def transOptLineSeg(seg: LineSegHC): Option[LineSeg]
def transLineSeg(seg: LineSegHC): LineSeg

def lineSeg(hs: HSide): LineSeg = transLineSeg(hs.lineSegHC)

/** Produces optional data about the HCoord. for example on a world projection it can give the latitude and longitude. */
def hCoordOptStr(hc: HCoord): Option[String] = None

Expand Down

0 comments on commit c227544

Please sign in to comment.