Unverified Commit 0538f5ee authored by Mael NICOLAS's avatar Mael NICOLAS Committed by Nicolas Pouillard

Toggle Edges #44

Done using DisplayEdge action. We can now toggle the edge drawing using the
button "Toggle Edges" in the toolbar.
parent 7d1ff4f8
......@@ -14,7 +14,7 @@ import Data.Either (Either(..))
import Data.HTTP.Method (Method(..))
import Data.Int (fromString, toNumber)
import Data.Int as Int
import Data.Lens (over, (+~), (^.), (.~), Lens, Lens')
import Data.Lens (Lens, Lens', over, (%~), (+~), (.~), (^.))
import Data.Lens.Record (prop)
import Data.Maybe (Maybe(..), fromJust, fromMaybe)
import Data.Newtype (class Newtype)
......@@ -54,6 +54,7 @@ data Action
| ToggleTree
| ChangeLabelSize Number
| ChangeNodeSize Number
| DisplayEdges
newtype SelectedNode = SelectedNode {id :: String, label :: String}
......@@ -82,6 +83,13 @@ _minNodeSize' = prop (SProxy :: SProxy "minNodeSize")
_minNodeSize :: Lens' SigmaSettings Number
_minNodeSize f = unsafeCoerce $ _minNodeSize' f
_drawEdges' :: forall s a. Lens' { drawEdges :: a | s} a
_drawEdges' = prop (SProxy :: SProxy "drawEdges")
_drawEdges :: Lens' SigmaSettings Boolean
_drawEdges f = unsafeCoerce $ _drawEdges' f
-- TODO remove newtype here
newtype State = State
{ graphData :: GraphData
......@@ -154,6 +162,10 @@ performAction (ChangeNodeSize size) _ _ =
let maxNoded = ((_settings <<< _maxNodeSize) .~ size) s
State $ ((_settings <<< _minNodeSize) .~ (size * 0.10)) maxNoded
performAction DisplayEdges _ _ =
modifyState_ $ \(State s) -> do
State $ ((_settings <<< _drawEdges) %~ not) s
convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges}
where
......@@ -228,7 +240,7 @@ mySettings :: SigmaSettings
mySettings = sigmaSettings { verbose : true
, drawLabels: true
, drawEdgeLabels: true
, drawEdges: true
, drawEdges: false
, drawNodes: true
, labelSize : "proportional"
--, nodesPowRatio: 0.3
......@@ -408,6 +420,14 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
li'
[ button [className "btn btn-success btn-sm"] [text "Change Type"]
]
,
li'
[ button [
className "btn btn-primary btn-sm"
, onClick \_ -> d DisplayEdges
]
[text "Toggle Edges"]
]
, li'
[ button [className "btn btn-primary btn-sm"] [text "Change Level"]
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment