module Graphics.Gnuplot.Frame.OptionSet (
   OptionSet.T,
   deflt,

   OptionSet.add,
   OptionSet.remove,
   OptionSet.boolean,
   OptionSet.addBool,

   size,
   sizeRatio,
   sizeSquare,
   title,
   key,
   keyInside,
   keyOutside,
   xRange2d,
   yRange2d,
   xRange3d,
   yRange3d,
   zRange3d,
   xLabel,
   yLabel,
   zLabel,
   xTicks2d,
   yTicks2d,
   xTicks3d,
   yTicks3d,
   zTicks3d,
   xLogScale,
   yLogScale,
   zLogScale,
   grid,
   gridXTicks,
   gridYTicks,
   gridZTicks,
   xFormat,
   yFormat,
   zFormat,

   view,
   viewMap,

   boxwidthRelative,
   boxwidthAbsolute,
   ) where


import qualified Graphics.Gnuplot.Graph.ThreeDimensional as Graph3D
import qualified Graphics.Gnuplot.Graph.TwoDimensional as Graph2D

import qualified Graphics.Gnuplot.Private.FrameOptionSet as OptionSet
import qualified Graphics.Gnuplot.Private.FrameOption as Option
import qualified Graphics.Gnuplot.Private.Graph as Graph

import qualified Graphics.Gnuplot.Value.Atom as Atom
import qualified Graphics.Gnuplot.Value.Tuple as Tuple

import Graphics.Gnuplot.Private.FrameOptionSet (T, )

import Graphics.Gnuplot.Utility (quote, commaConcat, )

import qualified Data.List as List


deflt :: Graph.C graph => T graph
deflt :: T graph
deflt = T graph
forall graph. C graph => T graph
Graph.defltOptions


size :: Graph.C graph => Double -> Double -> T graph -> T graph
size :: Double -> Double -> T graph -> T graph
size Double
x Double
y =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.sizeScale [Double -> String
forall a. Show a => a -> String
show Double
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Double -> String
forall a. Show a => a -> String
show Double
y]

sizeRatio :: Graph.C graph => Double -> T graph -> T graph
sizeRatio :: Double -> T graph -> T graph
sizeRatio Double
r =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.sizeRatio [String
"ratio", Double -> String
forall a. Show a => a -> String
show Double
r]

sizeSquare :: Graph.C graph => T graph -> T graph
sizeSquare :: T graph -> T graph
sizeSquare =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.sizeRatio [String
"square"]

title :: Graph.C graph => String -> T graph -> T graph
title :: String -> T graph -> T graph
title String
text =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.title [String -> String
quote String
text]

key :: Graph.C graph => Bool -> T graph -> T graph
key :: Bool -> T graph -> T graph
key = T -> Bool -> T graph -> T graph
forall graph. T -> Bool -> T graph -> T graph
OptionSet.boolean T
Option.keyShow

keyInside :: Graph.C graph => T graph -> T graph
keyInside :: T graph -> T graph
keyInside = T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.keyPosition [String
"inside"]

keyOutside :: Graph.C graph => T graph -> T graph
keyOutside :: T graph -> T graph
keyOutside = T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.keyPosition [String
"outside"]

{-
xRange :: Graph.C graph => (Double, Double) -> T graph -> T graph
xRange = range Option.xRange

yRange :: Graph.C graph => (Double, Double) -> T graph -> T graph
yRange = range Option.yRange

zRange :: (Double, Double) -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
zRange = range Option.zRange
-}

xRange2d ::
   (Atom.C x, Atom.C y, Tuple.C x) =>
   (x, x) -> T (Graph2D.T x y) -> T (Graph2D.T x y)
xRange2d :: (x, x) -> T (T x y) -> T (T x y)
xRange2d = T -> (x, x) -> T (T x y) -> T (T x y)
forall a graph.
(C a, C a, C graph) =>
T -> (a, a) -> T graph -> T graph
range T
Option.xRangeBounds

yRange2d ::
   (Atom.C x, Atom.C y, Tuple.C y) =>
   (y, y) -> T (Graph2D.T x y) -> T (Graph2D.T x y)
yRange2d :: (y, y) -> T (T x y) -> T (T x y)
yRange2d = T -> (y, y) -> T (T x y) -> T (T x y)
forall a graph.
(C a, C a, C graph) =>
T -> (a, a) -> T graph -> T graph
range T
Option.yRangeBounds


xRange3d ::
   (Atom.C x, Atom.C y, Atom.C z, Tuple.C x) =>
   (x, x) -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
xRange3d :: (x, x) -> T (T x y z) -> T (T x y z)
xRange3d = T -> (x, x) -> T (T x y z) -> T (T x y z)
forall a graph.
(C a, C a, C graph) =>
T -> (a, a) -> T graph -> T graph
range T
Option.xRangeBounds

yRange3d ::
   (Atom.C x, Atom.C y, Atom.C z, Tuple.C y) =>
   (y, y) -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
yRange3d :: (y, y) -> T (T x y z) -> T (T x y z)
yRange3d = T -> (y, y) -> T (T x y z) -> T (T x y z)
forall a graph.
(C a, C a, C graph) =>
T -> (a, a) -> T graph -> T graph
range T
Option.yRangeBounds

zRange3d ::
   (Atom.C x, Atom.C y, Atom.C z, Tuple.C z) =>
   (z, z) -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
zRange3d :: (z, z) -> T (T x y z) -> T (T x y z)
zRange3d = T -> (z, z) -> T (T x y z) -> T (T x y z)
forall a graph.
(C a, C a, C graph) =>
T -> (a, a) -> T graph -> T graph
range T
Option.zRangeBounds


range ::
   (Atom.C a, Tuple.C a, Graph.C graph) =>
   Option.T -> (a, a) -> T graph -> T graph
range :: T -> (a, a) -> T graph -> T graph
range T
opt (a
x,a
y) =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
opt
      [String -> String -> String
showString String
"[" (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String -> String
forall a. (C a, C a) => a -> String -> String
atomText a
x (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
       String -> String -> String
showString String
":" (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String -> String
forall a. (C a, C a) => a -> String -> String
atomText a
y (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$
       String
"]"]

atomText ::
   (Atom.C a, Tuple.C a) =>
   a -> ShowS
atomText :: a -> String -> String
atomText a
x =
   case a -> [String -> String]
forall a. C a => a -> [String -> String]
Tuple.text a
x of
      [String -> String
s] -> String -> String
s
      [String -> String]
_ -> String -> String -> String
forall a. HasCallStack => String -> a
error String
"OptionSet.fromSingleton: types of Atom class must generate single representation texts"


xLabel :: Graph.C graph => String -> T graph -> T graph
xLabel :: String -> T graph -> T graph
xLabel = T -> String -> T graph -> T graph
forall graph. C graph => T -> String -> T graph -> T graph
label T
Option.xLabelText

yLabel :: Graph.C graph => String -> T graph -> T graph
yLabel :: String -> T graph -> T graph
yLabel = T -> String -> T graph -> T graph
forall graph. C graph => T -> String -> T graph -> T graph
label T
Option.yLabelText

zLabel ::
   (Atom.C x, Atom.C y, Atom.C z) =>
   String -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
zLabel :: String -> T (T x y z) -> T (T x y z)
zLabel = T -> String -> T (T x y z) -> T (T x y z)
forall graph. C graph => T -> String -> T graph -> T graph
label T
Option.zLabelText

label :: Graph.C graph => Option.T -> String -> T graph -> T graph
label :: T -> String -> T graph -> T graph
label T
opt String
x =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
opt [String -> String
quote String
x]


xFormat :: Graph.C graph => String -> T graph -> T graph
xFormat :: String -> T graph -> T graph
xFormat = T -> String -> T graph -> T graph
forall graph. C graph => T -> String -> T graph -> T graph
format T
Option.xFormat

yFormat :: Graph.C graph => String -> T graph -> T graph
yFormat :: String -> T graph -> T graph
yFormat = T -> String -> T graph -> T graph
forall graph. C graph => T -> String -> T graph -> T graph
format T
Option.yFormat

zFormat ::
   (Atom.C x, Atom.C y, Atom.C z) =>
   String -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
zFormat :: String -> T (T x y z) -> T (T x y z)
zFormat = T -> String -> T (T x y z) -> T (T x y z)
forall graph. C graph => T -> String -> T graph -> T graph
format T
Option.zFormat

format :: Graph.C graph => Option.T -> String -> T graph -> T graph
format :: T -> String -> T graph -> T graph
format T
opt String
x =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
opt [String -> String
quote String
x]


{- |
Set parameters of viewing a surface graph.
See <info:gnuplot/view>
-}
view ::
   Double {- ^ rotateX -} ->
   Double {- ^ rotateZ -} ->
   Double {- ^ scale -} ->
   Double {- ^ scaleZ -} ->
   T (Graph3D.T x y z) -> T (Graph3D.T x y z)
view :: Double -> Double -> Double -> Double -> T (T x y z) -> T (T x y z)
view Double
rotateX Double
rotateZ Double
scale Double
scaleZ =
   T -> [String] -> T (T x y z) -> T (T x y z)
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.view
      [[String] -> String
commaConcat [Double -> String
forall a. Show a => a -> String
show Double
rotateX, Double -> String
forall a. Show a => a -> String
show Double
rotateZ, Double -> String
forall a. Show a => a -> String
show Double
scale, Double -> String
forall a. Show a => a -> String
show Double
scaleZ]]

{- |
Show flat pixel map.
-}
viewMap :: T (Graph3D.T x y z) -> T (Graph3D.T x y z)
viewMap :: T (T x y z) -> T (T x y z)
viewMap =
   T -> [String] -> T (T x y z) -> T (T x y z)
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.view [String
"map"]


xTicks2d ::
   (Atom.C x, Atom.C y, Tuple.C x) =>
   [(String, x)] -> T (Graph2D.T x y) -> T (Graph2D.T x y)
xTicks2d :: [(String, x)] -> T (T x y) -> T (T x y)
xTicks2d = T -> [(String, x)] -> T (T x y) -> T (T x y)
forall a graph.
(C a, C a, C graph) =>
T -> [(String, a)] -> T graph -> T graph
ticks T
Option.xTickLabels

yTicks2d ::
   (Atom.C x, Atom.C y, Tuple.C y) =>
   [(String, y)] -> T (Graph2D.T x y) -> T (Graph2D.T x y)
yTicks2d :: [(String, y)] -> T (T x y) -> T (T x y)
yTicks2d = T -> [(String, y)] -> T (T x y) -> T (T x y)
forall a graph.
(C a, C a, C graph) =>
T -> [(String, a)] -> T graph -> T graph
ticks T
Option.yTickLabels


xTicks3d ::
   (Atom.C x, Atom.C y, Atom.C z, Tuple.C x) =>
   [(String, x)] -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
xTicks3d :: [(String, x)] -> T (T x y z) -> T (T x y z)
xTicks3d = T -> [(String, x)] -> T (T x y z) -> T (T x y z)
forall a graph.
(C a, C a, C graph) =>
T -> [(String, a)] -> T graph -> T graph
ticks T
Option.xTickLabels

yTicks3d ::
   (Atom.C x, Atom.C y, Atom.C z, Tuple.C y) =>
   [(String, y)] -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
yTicks3d :: [(String, y)] -> T (T x y z) -> T (T x y z)
yTicks3d = T -> [(String, y)] -> T (T x y z) -> T (T x y z)
forall a graph.
(C a, C a, C graph) =>
T -> [(String, a)] -> T graph -> T graph
ticks T
Option.yTickLabels

zTicks3d ::
   (Atom.C x, Atom.C y, Atom.C z, Tuple.C z) =>
   [(String, z)] -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
zTicks3d :: [(String, z)] -> T (T x y z) -> T (T x y z)
zTicks3d = T -> [(String, z)] -> T (T x y z) -> T (T x y z)
forall a graph.
(C a, C a, C graph) =>
T -> [(String, a)] -> T graph -> T graph
ticks T
Option.zTickLabels


ticks ::
   (Atom.C a, Tuple.C a, Graph.C graph) =>
   Option.T -> [(String, a)] -> T graph -> T graph
ticks :: T -> [(String, a)] -> T graph -> T graph
ticks T
opt [(String, a)]
labels =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
opt
      [(Char
'(' Char -> String -> String
forall a. a -> [a] -> [a]
:) (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ ((String -> String) -> String -> String)
-> String -> [String -> String] -> String
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
($) String
")" ([String -> String] -> String) -> [String -> String] -> String
forall a b. (a -> b) -> a -> b
$
       (String -> String) -> [String -> String] -> [String -> String]
forall a. a -> [a] -> [a]
List.intersperse (String -> String -> String
showString String
", ") ([String -> String] -> [String -> String])
-> [String -> String] -> [String -> String]
forall a b. (a -> b) -> a -> b
$
       ((String, a) -> String -> String)
-> [(String, a)] -> [String -> String]
forall a b. (a -> b) -> [a] -> [b]
map
          (\(String
lab,a
pos) ->
             String -> String -> String
showString (String -> String
quote String
lab) (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
             String -> String -> String
showString String
" " (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
             a -> String -> String
forall a. (C a, C a) => a -> String -> String
atomText a
pos)
          [(String, a)]
labels]


xLogScale :: Graph.C graph => T graph -> T graph
xLogScale :: T graph -> T graph
xLogScale = T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.xLogScale []

yLogScale :: Graph.C graph => T graph -> T graph
yLogScale :: T graph -> T graph
yLogScale = T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.yLogScale []

zLogScale ::
   (Atom.C x, Atom.C y, Atom.C z) =>
   T (Graph3D.T x y z) -> T (Graph3D.T x y z)
zLogScale :: T (T x y z) -> T (T x y z)
zLogScale = T -> [String] -> T (T x y z) -> T (T x y z)
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.zLogScale []


grid :: Graph.C graph => Bool -> T graph -> T graph
grid :: Bool -> T graph -> T graph
grid Bool
b =
   T -> Bool -> T graph -> T graph
forall graph. T -> Bool -> T graph -> T graph
OptionSet.addBool T
Option.gridXTicks Bool
b (T graph -> T graph) -> (T graph -> T graph) -> T graph -> T graph
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
   T -> Bool -> T graph -> T graph
forall graph. T -> Bool -> T graph -> T graph
OptionSet.addBool T
Option.gridYTicks Bool
b (T graph -> T graph) -> (T graph -> T graph) -> T graph -> T graph
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
   T -> Bool -> T graph -> T graph
forall graph. T -> Bool -> T graph -> T graph
OptionSet.addBool T
Option.gridZTicks Bool
b

gridXTicks :: Graph.C graph => Bool -> T graph -> T graph
gridXTicks :: Bool -> T graph -> T graph
gridXTicks = T -> Bool -> T graph -> T graph
forall graph. T -> Bool -> T graph -> T graph
OptionSet.addBool T
Option.gridXTicks

gridYTicks :: Graph.C graph => Bool -> T graph -> T graph
gridYTicks :: Bool -> T graph -> T graph
gridYTicks = T -> Bool -> T graph -> T graph
forall graph. T -> Bool -> T graph -> T graph
OptionSet.addBool T
Option.gridYTicks

gridZTicks ::
   (Atom.C x, Atom.C y, Atom.C z) =>
   Bool -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
gridZTicks :: Bool -> T (T x y z) -> T (T x y z)
gridZTicks = T -> Bool -> T (T x y z) -> T (T x y z)
forall graph. T -> Bool -> T graph -> T graph
OptionSet.addBool T
Option.gridZTicks


boxwidthRelative ::
   (Graph.C graph) =>
   Double -> T graph -> T graph
boxwidthRelative :: Double -> T graph -> T graph
boxwidthRelative Double
width =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.boxwidth [Double -> String
forall a. Show a => a -> String
show Double
width, String
"relative"]

boxwidthAbsolute ::
   (Graph.C graph) =>
   Double -> T graph -> T graph
boxwidthAbsolute :: Double -> T graph -> T graph
boxwidthAbsolute Double
width =
   T -> [String] -> T graph -> T graph
forall graph. T -> [String] -> T graph -> T graph
OptionSet.add T
Option.boxwidth [Double -> String
forall a. Show a => a -> String
show Double
width, String
"absolute"]

{-
cornerToColor :: CornersToColor -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)

type3d :: Plot3dType -> T (Graph3D.T x y z) -> T (Graph3D.T x y z)
-}