Commit 2ed26a3c authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] cursorSize setting removed (code simplification)

parent a4a24fc8
module Gargantext.Components.GraphExplorer.Controls module Gargantext.Components.GraphExplorer.Controls
( Controls ( Controls
, controlsToSigmaSettings
, useGraphControls , useGraphControls
, controls , controls
, controlsCpt , controlsCpt
, getShowTree, setShowTree , getShowTree, setShowTree
, getShowControls, setShowControls , getShowControls, setShowControls
, getCursorSize, setCursorSize
) where ) where
import Data.Array as A import Data.Array as A
...@@ -25,7 +23,7 @@ import Gargantext.Components.Graph as Graph ...@@ -25,7 +23,7 @@ import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton) import Gargantext.Components.GraphExplorer.Button (centerButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl) import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Search (nodeSearchControl) import Gargantext.Components.GraphExplorer.Search (nodeSearchControl)
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton, mouseSelectorSizeButton) import Gargantext.Components.GraphExplorer.SlideButton (labelSizeButton, mouseSelectorSizeButton)
import Gargantext.Components.GraphExplorer.ToggleButton (multiSelectEnabledButton, edgesToggleButton, pauseForceAtlasButton) import Gargantext.Components.GraphExplorer.ToggleButton (multiSelectEnabledButton, edgesToggleButton, pauseForceAtlasButton)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
...@@ -34,8 +32,7 @@ import Gargantext.Utils.Range as Range ...@@ -34,8 +32,7 @@ import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
type Controls = type Controls =
( cursorSize :: R.State Number ( edgeConfluence :: R.State Range.NumberRange
, edgeConfluence :: R.State Range.NumberRange
, edgeWeight :: R.State Range.NumberRange , edgeWeight :: R.State Range.NumberRange
, forceAtlasState :: R.State SigmaxTypes.ForceAtlasState , forceAtlasState :: R.State SigmaxTypes.ForceAtlasState
, graph :: SigmaxTypes.SGraph , graph :: SigmaxTypes.SGraph
...@@ -50,9 +47,6 @@ type Controls = ...@@ -50,9 +47,6 @@ type Controls =
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
) )
controlsToSigmaSettings :: Record Controls -> Record Graph.SigmaSettings
controlsToSigmaSettings { cursorSize: (cursorSize /\ _)} = Graph.sigmaSettings
type LocalControls = type LocalControls =
( labelSize :: R.State Number ( labelSize :: R.State Number
, mouseSelectorSize :: R.State Number , mouseSelectorSize :: R.State Number
...@@ -147,7 +141,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt ...@@ -147,7 +141,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- run demo -- run demo
-- search button -- search button
-- search topics -- search topics
, RH.li {} [ cursorSizeButton props.cursorSize ] -- cursor size: 0-100
, RH.li {} [ labelSizeButton props.sigmaRef localControls.labelSize ] -- labels size: 1-4 , RH.li {} [ labelSizeButton props.sigmaRef localControls.labelSize ] -- labels size: 1-4
, RH.li {} [ nodeSizeControl nodeSizeRange props.nodeSize ] , RH.li {} [ nodeSizeControl nodeSizeRange props.nodeSize ]
-- zoom: 0 -100 - calculate ratio -- zoom: 0 -100 - calculate ratio
...@@ -162,7 +155,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt ...@@ -162,7 +155,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
useGraphControls :: SigmaxTypes.SGraph -> R.Hooks (Record Controls) useGraphControls :: SigmaxTypes.SGraph -> R.Hooks (Record Controls)
useGraphControls graph = do useGraphControls graph = do
cursorSize <- R.useState' 10.0
edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 } edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
edgeWeight <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 } edgeWeight <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
forceAtlasState <- R.useState' SigmaxTypes.InitialRunning forceAtlasState <- R.useState' SigmaxTypes.InitialRunning
...@@ -177,8 +169,7 @@ useGraphControls graph = do ...@@ -177,8 +169,7 @@ useGraphControls graph = do
sigma <- Sigmax.initSigma sigma <- Sigmax.initSigma
sigmaRef <- R.useRef sigma sigmaRef <- R.useRef sigma
pure { cursorSize pure { edgeConfluence
, edgeConfluence
, edgeWeight , edgeWeight
, forceAtlasState , forceAtlasState
, graph , graph
...@@ -199,14 +190,8 @@ getShowControls { showControls: ( should /\ _ ) } = should ...@@ -199,14 +190,8 @@ getShowControls { showControls: ( should /\ _ ) } = should
getShowTree :: Record Controls -> Boolean getShowTree :: Record Controls -> Boolean
getShowTree { showTree: ( should /\ _ ) } = should getShowTree { showTree: ( should /\ _ ) } = should
getCursorSize :: Record Controls -> Number
getCursorSize { cursorSize: ( size /\ _ ) } = size
setShowControls :: Record Controls -> Boolean -> Effect Unit setShowControls :: Record Controls -> Boolean -> Effect Unit
setShowControls { showControls: ( _ /\ set ) } v = set $ const v setShowControls { showControls: ( _ /\ set ) } v = set $ const v
setShowTree :: Record Controls -> Boolean -> Effect Unit setShowTree :: Record Controls -> Boolean -> Effect Unit
setShowTree { showTree: ( _ /\ set ) } v = set $ not <<< const v setShowTree { showTree: ( _ /\ set ) } v = set $ not <<< const v
setCursorSize :: Record Controls -> Number -> Effect Unit
setCursorSize { cursorSize: ( _ /\ setSize ) } v = setSize $ const v
...@@ -9,7 +9,7 @@ import Data.Map as Map ...@@ -9,7 +9,7 @@ import Data.Map as Map
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
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_)
import Data.Tuple.Nested((/\)) import Data.Tuple.Nested((/\))
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
...@@ -126,8 +126,7 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt ...@@ -126,8 +126,7 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
deleteNodes :: Session -> Array Int -> Effect Unit deleteNodes :: Session -> Array Int -> Effect Unit
deleteNodes session nodeIds = do deleteNodes session nodeIds = do
_ <- traverse (launchAff_ <<< deleteNode session) nodeIds traverse_ (launchAff_ <<< deleteNode session) nodeIds
pure unit
deleteNode :: Session -> Int -> Aff Int deleteNode :: Session -> Int -> Aff Int
deleteNode session nodeId = delete session $ NodeAPI Node (Just nodeId) "" deleteNode session nodeId = delete session $ NodeAPI Node (Just nodeId) ""
......
module Gargantext.Components.GraphExplorer.SlideButton module Gargantext.Components.GraphExplorer.SlideButton
( Props ( Props
, sizeButton , sizeButton
, cursorSizeButton
, labelSizeButton , labelSizeButton
, mouseSelectorSizeButton , mouseSelectorSizeButton
) where ) where
import Global (readFloat) import Global (readFloat)
import Prelude import Prelude
import Data.Tuple (snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Reactix as R import Reactix as R
...@@ -46,16 +44,6 @@ sizeButtonCpt = R.hooksComponent "SizeButton" cpt ...@@ -46,16 +44,6 @@ sizeButtonCpt = R.hooksComponent "SizeButton" cpt
} }
] ]
cursorSizeButton :: R.State Number -> R.Element
cursorSizeButton state =
sizeButton {
state
, caption: "Cursor Size"
, min: 1.0
, max: 4.0
, onChange: snd state <<< const <<< readFloat <<< R2.unsafeEventValue
}
labelSizeButton :: R.Ref Sigmax.Sigma -> R.State Number -> R.Element labelSizeButton :: R.Ref Sigmax.Sigma -> R.State Number -> R.Element
labelSizeButton sigmaRef state = labelSizeButton sigmaRef state =
sizeButton { sizeButton {
......
...@@ -79,7 +79,6 @@ instance showSelectedNode :: Show SelectedNode where ...@@ -79,7 +79,6 @@ instance showSelectedNode :: Show SelectedNode where
type State = ( type State = (
-- corpusId :: R.State Int -- corpusId :: R.State Int
--, cursorSize :: R.State Number
--, filePath :: R.State String --, filePath :: R.State String
--, graphData :: R.State GraphData --, graphData :: R.State GraphData
--, legendData :: R.State (Array Legend) --, legendData :: R.State (Array Legend)
......
...@@ -15,69 +15,3 @@ exports.pauseForceAtlas2 = function() { ...@@ -15,69 +15,3 @@ exports.pauseForceAtlas2 = function() {
} }
} }
}; };
var trackMouse = function(cursorSize, e) {
if(!e.shiftKey) {
var partialGraph = window.sigmaGargInstance;
// new sigma.js 2D mouse context
var ctx = partialGraph.renderers[0].contexts.mouse;
ctx.globalCompositeOperation = "source-over";
// clear zone each time to prevent repeated frame artifacts
ctx.clearRect(50, 50,
partialGraph.renderers[0].container.offsetWidth,
partialGraph.renderers[0].container.offsetHeight);
// classic mousemove event or other similar non-sigma events
var coord = window.sigma.utils.mouseCoords(e)
var x = (coord.x + coord.clientX) / 2 // ; // sigma.utils.getX(e);
var y = (coord.y + coord.clientY) /2 // ; // sigma.utils.getY(e);
console.log('trackMouse', coord);
// optional: make more labels appear on circle hover (/!\ costly /!\ esp. on large graphs)
// if (partialGraph.conf.moreLabelsUnderArea) {
// // convert screen => mouse => cam
// var mouseCoords = (50,50); // sigma.utils.mouseCoords(e)
// var camCoords = partialGraph.cam.cameraPosition(mouseCoords.x, mouseCoords.y)
//
// var exactNodeset = circleGetAreaNodes(camCoords.x,camCoords.y)
// // console.log("nodes under circle:", exactNodeset)
//
// // we'll use labelThreshold / 3 as the "boosted" cam:size threshold
// var pfx = partialGraph.cam.readPrefix
// var toRedraw = []
// for (var k in exactNodeset) {
// var n = partialGraph.graph.nodes(exactNodeset[k])
// if(!n.hidden && n[pfx+'size'] > (partialGraph.customSettings.labelThreshold / 3)) {
// toRedraw.push(n)
// }
// }
// redrawNodesInHoverLayer(toRedraw, "hovers")
// }
// draw the circle itself
ctx.strokeStyle = '#000';
ctx.lineWidth = 1;
ctx.fillStyle = "#71C3FF";
ctx.globalAlpha = 0.5;
ctx.beginPath();
ctx.arc(x, y, cursorSize, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.stroke();
ctx.globalAlpha = 1
}
};
exports.sigmaOnMouseMove = function(props) {
return function(e) {
return function() {
if(typeof(window.sigmaGargInstance) !== "undefined") {
if(props.cursorSize > 0) trackMouse(props.cursorSize, e);
}
};
};
};
...@@ -6,7 +6,6 @@ import Data.Nullable (Nullable) ...@@ -6,7 +6,6 @@ import Data.Nullable (Nullable)
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1) import Effect.Uncurried (EffectFn1, runEffectFn1)
import React (ReactRef, SyntheticEventHandler) import React (ReactRef, SyntheticEventHandler)
import React.SyntheticEvent (SyntheticMouseEvent)
import Record.Unsafe (unsafeGet) import Record.Unsafe (unsafeGet)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional) import Gargantext.Types (class Optional)
...@@ -92,7 +91,6 @@ foreign import data CameraInstance' :: # Type ...@@ -92,7 +91,6 @@ foreign import data CameraInstance' :: # Type
type SigmaInstance = { | SigmaInstance' } type SigmaInstance = { | SigmaInstance' }
type CameraInstance = { | CameraInstance' } type CameraInstance = { | CameraInstance' }
foreign import sigmaOnMouseMove :: {cursorSize :: Number} -> SyntheticMouseEvent -> Effect Unit
cameras :: SigmaInstance -> Array CameraInstance cameras :: SigmaInstance -> Array CameraInstance
cameras = unsafeGet "cameras" cameras = unsafeGet "cameras"
......
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