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(..)) ...@@ -14,7 +14,7 @@ import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Int (fromString, toNumber) import Data.Int (fromString, toNumber)
import Data.Int as Int import Data.Int as Int
import Data.Lens (over, (+~), (^.), (.~), Lens, Lens') import Data.Lens (Lens, Lens', over, (%~), (+~), (.~), (^.))
import Data.Lens.Record (prop) import Data.Lens.Record (prop)
import Data.Maybe (Maybe(..), fromJust, fromMaybe) import Data.Maybe (Maybe(..), fromJust, fromMaybe)
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
...@@ -54,6 +54,7 @@ data Action ...@@ -54,6 +54,7 @@ data Action
| ToggleTree | ToggleTree
| ChangeLabelSize Number | ChangeLabelSize Number
| ChangeNodeSize Number | ChangeNodeSize Number
| DisplayEdges
newtype SelectedNode = SelectedNode {id :: String, label :: String} newtype SelectedNode = SelectedNode {id :: String, label :: String}
...@@ -82,6 +83,13 @@ _minNodeSize' = prop (SProxy :: SProxy "minNodeSize") ...@@ -82,6 +83,13 @@ _minNodeSize' = prop (SProxy :: SProxy "minNodeSize")
_minNodeSize :: Lens' SigmaSettings Number _minNodeSize :: Lens' SigmaSettings Number
_minNodeSize f = unsafeCoerce $ _minNodeSize' f _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 -- TODO remove newtype here
newtype State = State newtype State = State
{ graphData :: GraphData { graphData :: GraphData
...@@ -154,6 +162,10 @@ performAction (ChangeNodeSize size) _ _ = ...@@ -154,6 +162,10 @@ performAction (ChangeNodeSize size) _ _ =
let maxNoded = ((_settings <<< _maxNodeSize) .~ size) s let maxNoded = ((_settings <<< _maxNodeSize) .~ size) s
State $ ((_settings <<< _minNodeSize) .~ (size * 0.10)) maxNoded State $ ((_settings <<< _minNodeSize) .~ (size * 0.10)) maxNoded
performAction DisplayEdges _ _ =
modifyState_ $ \(State s) -> do
State $ ((_settings <<< _drawEdges) %~ not) s
convert :: GraphData -> SigmaGraphData convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges} convert (GraphData r) = SigmaGraphData { nodes, edges}
where where
...@@ -228,7 +240,7 @@ mySettings :: SigmaSettings ...@@ -228,7 +240,7 @@ mySettings :: SigmaSettings
mySettings = sigmaSettings { verbose : true mySettings = sigmaSettings { verbose : true
, drawLabels: true , drawLabels: true
, drawEdgeLabels: true , drawEdgeLabels: true
, drawEdges: true , drawEdges: false
, drawNodes: true , drawNodes: true
, labelSize : "proportional" , labelSize : "proportional"
--, nodesPowRatio: 0.3 --, nodesPowRatio: 0.3
...@@ -408,6 +420,14 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -408,6 +420,14 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
li' li'
[ button [className "btn btn-success btn-sm"] [text "Change Type"] [ 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' , li'
[ button [className "btn btn-primary btn-sm"] [text "Change Level"] [ 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