DIAG: Allow drawing the square the user path points to
This commit is contained in:
@@ -19,8 +19,8 @@ diag p obj@(Object _)
|
||||
mkDiag (mconcat [convexHPText, convexHP, convexHLs, coordPoints, plotterBG])
|
||||
p obj
|
||||
| alg p == 4 =
|
||||
mkDiag (mconcat [squares, coordPointsText, coordPoints, polyLines,
|
||||
plotterBG])
|
||||
mkDiag (mconcat [quadPathSquare, squares, coordPointsText,
|
||||
coordPoints, polyLines, plotterBG])
|
||||
p obj
|
||||
| otherwise = mempty
|
||||
diag p objs@(Objects _)
|
||||
|
||||
@@ -6,11 +6,13 @@ import Algebra.VectorTypes
|
||||
import Algorithms.ConvexHull.GrahamScan
|
||||
import Algorithms.RangeSearch.Core
|
||||
import Algorithms.PolygonIntersection.Core
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
import Diagrams.Backend.Cairo
|
||||
import Diagrams.Prelude hiding ((<>))
|
||||
import Graphics.Diagram.Types
|
||||
import Graphics.Gloss.Data.Extent
|
||||
import Parser.PathParser
|
||||
|
||||
|
||||
-- |Creates a Diagram that shows the coordinates from the points
|
||||
@@ -188,6 +190,30 @@ squares = Diag f
|
||||
f _ _ = mempty
|
||||
|
||||
|
||||
-- |Create a diagram that shows a single square of the RangeSearch algorithm
|
||||
-- from the quad tree in red, according to the given path in pQt.
|
||||
quadPathSquare :: Diag
|
||||
quadPathSquare = Diag f
|
||||
where
|
||||
f p (Object []) = mempty
|
||||
f p (Object vt) =
|
||||
(\((xmin, xmax), (ymin, ymax)) -> rect (xmax - xmin) (ymax - ymin)
|
||||
# moveTo (p2 ((xmax + xmin) / 2,(ymax + ymin) / 2)) # lw thin # lc red)
|
||||
(getSquare (stringToQuads (pQt p)) (qt, []))
|
||||
where
|
||||
quads :: [QuadOrOrient]
|
||||
quads = stringToQuads (pQt p)
|
||||
getSquare :: [QuadOrOrient] -> Zipper PT -> Square
|
||||
getSquare [] z = getSquareByZipper (dX p, dY p) z
|
||||
getSquare (q:qs) z = case q of
|
||||
Orient x -> getSquare qs (fromMaybe z (findNeighbor x z))
|
||||
Quad x -> getSquare qs (fromMaybe z (goQuad x z))
|
||||
qt :: QuadTree PT
|
||||
qt = quadTree vtf (dX p, dY p)
|
||||
vtf :: [PT]
|
||||
vtf = filterValidPT p vt
|
||||
|
||||
|
||||
-- |Creates a Diagram that shows an XAxis which is bound
|
||||
-- by the dimensions given in xD from DiagProp.
|
||||
xAxis :: Diag
|
||||
|
||||
@@ -53,7 +53,9 @@ data DiagProp = MkProp {
|
||||
-- |If we want to show the coordinates as text.
|
||||
ct :: Bool,
|
||||
-- |Square size used to show the grid and x/y-axis.
|
||||
sqS :: Double
|
||||
sqS :: Double,
|
||||
-- |The path to a quad in the quad tree.
|
||||
pQt :: String
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +85,7 @@ instance Monoid Diag where
|
||||
|
||||
-- |The default properties of the Diagram.
|
||||
defaultProp :: DiagProp
|
||||
defaultProp = MkProp 2 (0,500) (0,500) 0 False False 50
|
||||
defaultProp = MkProp 2 (0,500) (0,500) 0 False False 50 ""
|
||||
|
||||
|
||||
-- |Extract the lower bound of the x-axis dimension.
|
||||
|
||||
Reference in New Issue
Block a user