Commit 6963af35 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] force atlas flickering fix

parent b2e22224
Pipeline #1590 failed with stage
...@@ -54,14 +54,9 @@ graph = R.createElement graphCpt ...@@ -54,14 +54,9 @@ graph = R.createElement graphCpt
graphCpt :: forall s fa2. R.Component (Props s fa2) graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = here.component "graph" cpt where graphCpt = here.component "graph" cpt where
cpt props@{ elRef cpt props@{ elRef
, mCamera
, multiSelectEnabledRef
, selectedNodeIds
, showEdges , showEdges
, sigmaRef , sigmaRef
, stage , stage } _ = do
, startForceAtlas
, transformedGraph } _ = do
showEdges' <- T.useLive T.unequal showEdges showEdges' <- T.useLive T.unequal showEdges
stage' <- T.useLive T.unequal stage stage' <- T.useLive T.unequal stage
...@@ -83,8 +78,16 @@ graphCpt = here.component "graph" cpt where ...@@ -83,8 +78,16 @@ graphCpt = here.component "graph" cpt where
Nothing -> RH.div {} [] Nothing -> RH.div {} []
Just el -> R.createPortal [] el Just el -> R.createPortal [] el
stageHooks props@{ elRef, mCamera, multiSelectEnabledRef, selectedNodeIds, forceAtlas2Settings: fa2, graph: graph' stageHooks { elRef
, sigmaRef, stage, stage': Init, startForceAtlas } = do , mCamera
, multiSelectEnabledRef
, selectedNodeIds
, forceAtlas2Settings: fa2
, graph: graph'
, sigmaRef
, stage
, stage': Init
, startForceAtlas } = do
R.useEffectOnce' $ do R.useEffectOnce' $ do
let rSigma = R.readRef sigmaRef let rSigma = R.readRef sigmaRef
...@@ -126,7 +129,7 @@ graphCpt = here.component "graph" cpt where ...@@ -126,7 +129,7 @@ graphCpt = here.component "graph" cpt where
Sigma.updateCamera sig { ratio, x, y } Sigma.updateCamera sig { ratio, x, y }
pure unit pure unit
Just sig -> do Just _sig -> do
pure unit pure unit
T.write Ready stage T.write Ready stage
...@@ -145,7 +148,9 @@ graphCpt = here.component "graph" cpt where ...@@ -145,7 +148,9 @@ graphCpt = here.component "graph" cpt where
Sigmax.performDiff sigma transformedGraph Sigmax.performDiff sigma transformedGraph
Sigmax.updateEdges sigma tEdgesMap Sigmax.updateEdges sigma tEdgesMap
Sigmax.updateNodes sigma tNodesMap Sigmax.updateNodes sigma tNodesMap
Sigmax.setEdges sigma (not $ SigmaxTypes.edgeStateHidden showEdges') let edgesState = not $ SigmaxTypes.edgeStateHidden showEdges'
here.log2 "[graphCpt] edgesState" edgesState
Sigmax.setEdges sigma edgesState
stageHooks _ = pure unit stageHooks _ = pure unit
...@@ -300,13 +305,15 @@ sigmaSettings = ...@@ -300,13 +305,15 @@ sigmaSettings =
, zoomMin : 0.0 , zoomMin : 0.0
, zoomingRatio : 1.4 , zoomingRatio : 1.4
} }
type ForceAtlas2Settings = type ForceAtlas2Settings =
( adjustSizes :: Boolean ( adjustSizes :: Boolean
, barnesHutOptimize :: Boolean , barnesHutOptimize :: Boolean
-- , barnesHutTheta :: Number -- , barnesHutTheta :: Number
, batchEdgesDrawing :: Boolean
, edgeWeightInfluence :: Number , edgeWeightInfluence :: Number
-- , fixedY :: Boolean -- , fixedY :: Boolean
, hideEdgesOnMove :: Boolean
, gravity :: Number , gravity :: Number
, includeHiddenEdges :: Boolean , includeHiddenEdges :: Boolean
, includeHiddenNodes :: Boolean , includeHiddenNodes :: Boolean
...@@ -324,19 +331,21 @@ type ForceAtlas2Settings = ...@@ -324,19 +331,21 @@ type ForceAtlas2Settings =
forceAtlas2Settings :: {|ForceAtlas2Settings} forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings = forceAtlas2Settings =
{ adjustSizes : true { adjustSizes : true
, barnesHutOptimize : true , barnesHutOptimize : true
, edgeWeightInfluence : 1.0 , batchEdgesDrawing : true
-- fixedY : false , edgeWeightInfluence : 1.0
, gravity : 0.01 -- fixedY : false
, includeHiddenEdges: false , gravity : 0.01
, includeHiddenNodes: true , hideEdgesOnMove : true
, iterationsPerRender : 50.0 -- 10.0 , includeHiddenEdges : false
, linLogMode : false -- false , includeHiddenNodes : true
, outboundAttractionDistribution: false , iterationsPerRender : 50.0 -- 10.0
, scalingRatio : 1000.0 , linLogMode : false -- false
, skipHidden: false , outboundAttractionDistribution : false
, slowDown : 1.0 , scalingRatio : 1000.0
, startingIterations : 10.0 , skipHidden : false
, strongGravityMode : false , slowDown : 1.0
, startingIterations : 10.0
, strongGravityMode : false
} }
...@@ -78,9 +78,8 @@ explorerWriteGraph :: R2.Component GraphWriteProps ...@@ -78,9 +78,8 @@ explorerWriteGraph :: R2.Component GraphWriteProps
explorerWriteGraph = R.createElement explorerWriteGraphCpt explorerWriteGraph = R.createElement explorerWriteGraphCpt
explorerWriteGraphCpt :: R.Component GraphWriteProps explorerWriteGraphCpt :: R.Component GraphWriteProps
explorerWriteGraphCpt = here.component "explorerWriteGraph" cpt where explorerWriteGraphCpt = here.component "explorerWriteGraph" cpt where
cpt props@{ boxes: { sidePanelGraph, sidePanelState } cpt props@{ boxes: { sidePanelGraph }
, graph , graph
, hyperdataGraph
, mMetaData' } _ = do , mMetaData' } _ = do
R.useEffectOnce' $ do R.useEffectOnce' $ do
T.write_ (Just { mGraph: Just graph T.write_ (Just { mGraph: Just graph
...@@ -99,13 +98,13 @@ explorer = R.createElement explorerCpt ...@@ -99,13 +98,13 @@ explorer = R.createElement explorerCpt
explorerCpt :: R.Component Props explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt explorerCpt = here.component "explorer" cpt
where where
cpt props@{ boxes: boxes@{ graphVersion, handed, reloadForest, showTree, sidePanelGraph, sidePanelState } cpt { boxes: { graphVersion, handed, reloadForest, showTree, sidePanelGraph, sidePanelState }
, graph , graph
, graphId , graphId
, hyperdataGraph , hyperdataGraph
, session , session
} _ = do } _ = do
{ mMetaData, sideTab } <- GEST.focusedSidePanel sidePanelGraph { mMetaData } <- GEST.focusedSidePanel sidePanelGraph
graphVersion' <- T.useLive T.unequal graphVersion graphVersion' <- T.useLive T.unequal graphVersion
handed' <- T.useLive T.unequal handed handed' <- T.useLive T.unequal handed
mMetaData' <- T.useLive T.unequal mMetaData mMetaData' <- T.useLive T.unequal mMetaData
...@@ -318,7 +317,10 @@ transformGraph graph { edgeConfluence' ...@@ -318,7 +317,10 @@ transformGraph graph { edgeConfluence'
hasSelection = not $ Set.isEmpty selectedNodeIds' hasSelection = not $ Set.isEmpty selectedNodeIds'
newEdges' = Seq.filter edgeFilter $ Seq.map ( newEdges' = Seq.filter edgeFilter $ Seq.map (
edgeHideWeight <<< edgeHideConfluence <<< edgeShowFilter <<< edgeMarked -- NOTE We don't use edgeShowFilter anymore because of
-- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/304
-- edgeHideWeight <<< edgeHideConfluence <<< edgeShowFilter <<< edgeMarked
edgeHideWeight <<< edgeHideConfluence <<< edgeMarked
) edges ) edges
newNodes = Seq.filter nodeFilter $ Seq.map (nodeMarked <<< nodeHideSize) nodes newNodes = Seq.filter nodeFilter $ Seq.map (nodeMarked <<< nodeHideSize) nodes
newEdges = Seq.filter (edgeInGraph $ Set.fromFoldable $ Seq.map _.id newNodes) newEdges' newEdges = Seq.filter (edgeInGraph $ Set.fromFoldable $ Seq.map _.id newNodes) newEdges'
......
...@@ -85,7 +85,6 @@ controlsCpt = here.component "controls" cpt ...@@ -85,7 +85,6 @@ controlsCpt = here.component "controls" cpt
, showControls , showControls
, showEdges , showEdges
, showLouvain , showLouvain
, showTree
, sidePanelState , sidePanelState
, sideTab , sideTab
, sigmaRef } _ = do , sigmaRef } _ = do
...@@ -112,8 +111,9 @@ controlsCpt = here.component "controls" cpt ...@@ -112,8 +111,9 @@ controlsCpt = here.component "controls" cpt
-- Handle automatic edge hiding when FA is running (to prevent flickering). -- Handle automatic edge hiding when FA is running (to prevent flickering).
-- TODO Commented temporarily: this breaks forceatlas rendering after reset -- TODO Commented temporarily: this breaks forceatlas rendering after reset
-- R.useEffect2' sigmaRef forceAtlasState' $ do -- NOTE This is a hack anyways. It's force atlas that should be fixed.
-- T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges R.useEffect2' sigmaRef forceAtlasState' $ do
T.modify_ (SigmaxT.forceAtlasEdgeState forceAtlasState') showEdges
-- Automatic opening of sidebar when a node is selected (but only first time). -- Automatic opening of sidebar when a node is selected (but only first time).
R.useEffect' $ do R.useEffect' $ do
......
...@@ -6,7 +6,6 @@ import DOM.Simple.Types (Element) ...@@ -6,7 +6,6 @@ import DOM.Simple.Types (Element)
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Data.Nullable (null)
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Data.Traversable (traverse_) import Data.Traversable (traverse_)
...@@ -48,7 +47,7 @@ sigma = runEffectFn3 _sigma Left Right ...@@ -48,7 +47,7 @@ sigma = runEffectFn3 _sigma Left Right
-- | Kill a sigmajs instance. -- | Kill a sigmajs instance.
kill :: Sigma -> Effect Unit kill :: Sigma -> Effect Unit
kill sigma = pure $ sigma ... "kill" $ [] kill s = pure $ s ... "kill" $ []
-- | Call the `refresh()` method on a sigmajs instance. -- | Call the `refresh()` method on a sigmajs instance.
refresh :: Sigma -> Effect Unit refresh :: Sigma -> Effect Unit
......
...@@ -2,10 +2,8 @@ module Gargantext.Hooks.Sigmax.Sigmajs where ...@@ -2,10 +2,8 @@ module Gargantext.Hooks.Sigmax.Sigmajs where
import Prelude import Prelude
import Data.Nullable (Nullable)
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1) import Effect.Uncurried (EffectFn1, runEffectFn1)
import React (SyntheticEventHandler)
import React.Ref as RR import React.Ref as RR
import Record.Unsafe (unsafeGet) import Record.Unsafe (unsafeGet)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
......
...@@ -173,6 +173,8 @@ toggleForceAtlasState Killed = InitialRunning ...@@ -173,6 +173,8 @@ toggleForceAtlasState Killed = InitialRunning
-- | Custom state for show edges. Normally it is EShow or EHide (show/hide -- | Custom state for show edges. Normally it is EShow or EHide (show/hide
-- | edges). However, edges are temporarily turned off when forceAtlas is -- | edges). However, edges are temporarily turned off when forceAtlas is
-- | running. -- | running.
-- | NOTE ETempHiddenThenShow state is a hack for force atlas
-- | flickering. Ideally it should be removed from here.
data ShowEdgesState = EShow | EHide | ETempHiddenThenShow data ShowEdgesState = EShow | EHide | ETempHiddenThenShow
derive instance Generic ShowEdgesState _ derive instance Generic ShowEdgesState _
......
This diff is collapsed.
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