Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
2ed26a3c
Commit
2ed26a3c
authored
Dec 21, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] cursorSize setting removed (code simplification)
parent
a4a24fc8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
5 additions
and
102 deletions
+5
-102
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+3
-18
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+2
-3
SlideButton.purs
src/Gargantext/Components/GraphExplorer/SlideButton.purs
+0
-12
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+0
-1
Sigmajs.js
src/Gargantext/Hooks/Sigmax/Sigmajs.js
+0
-66
Sigmajs.purs
src/Gargantext/Hooks/Sigmax/Sigmajs.purs
+0
-2
No files found.
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
2ed26a3c
module Gargantext.Components.GraphExplorer.Controls
( Controls
, controlsToSigmaSettings
, useGraphControls
, controls
, controlsCpt
, getShowTree, setShowTree
, getShowControls, setShowControls
, getCursorSize, setCursorSize
) where
import Data.Array as A
...
...
@@ -25,7 +23,7 @@ import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
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.Types as GET
import Gargantext.Hooks.Sigmax as Sigmax
...
...
@@ -34,8 +32,7 @@ import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2
type Controls =
( cursorSize :: R.State Number
, edgeConfluence :: R.State Range.NumberRange
( edgeConfluence :: R.State Range.NumberRange
, edgeWeight :: R.State Range.NumberRange
, forceAtlasState :: R.State SigmaxTypes.ForceAtlasState
, graph :: SigmaxTypes.SGraph
...
...
@@ -50,9 +47,6 @@ type Controls =
, sigmaRef :: R.Ref Sigmax.Sigma
)
controlsToSigmaSettings :: Record Controls -> Record Graph.SigmaSettings
controlsToSigmaSettings { cursorSize: (cursorSize /\ _)} = Graph.sigmaSettings
type LocalControls =
( labelSize :: R.State Number
, mouseSelectorSize :: R.State Number
...
...
@@ -147,7 +141,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- run demo
-- search button
-- search topics
, RH.li {} [ cursorSizeButton props.cursorSize ] -- cursor size: 0-100
, RH.li {} [ labelSizeButton props.sigmaRef localControls.labelSize ] -- labels size: 1-4
, RH.li {} [ nodeSizeControl nodeSizeRange props.nodeSize ]
-- zoom: 0 -100 - calculate ratio
...
...
@@ -162,7 +155,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
useGraphControls :: SigmaxTypes.SGraph -> R.Hooks (Record Controls)
useGraphControls graph = do
cursorSize <- R.useState' 10.0
edgeConfluence <- 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
...
...
@@ -177,8 +169,7 @@ useGraphControls graph = do
sigma <- Sigmax.initSigma
sigmaRef <- R.useRef sigma
pure { cursorSize
, edgeConfluence
pure { edgeConfluence
, edgeWeight
, forceAtlasState
, graph
...
...
@@ -199,14 +190,8 @@ getShowControls { showControls: ( should /\ _ ) } = should
getShowTree :: Record Controls -> Boolean
getShowTree { showTree: ( should /\ _ ) } = should
getCursorSize :: Record Controls -> Number
getCursorSize { cursorSize: ( size /\ _ ) } = size
setShowControls :: Record Controls -> Boolean -> Effect Unit
setShowControls { showControls: ( _ /\ set ) } v = set $ const v
setShowTree :: Record Controls -> Boolean -> Effect Unit
setShowTree { showTree: ( _ /\ set ) } v = set $ not <<< const v
setCursorSize :: Record Controls -> Number -> Effect Unit
setCursorSize { cursorSize: ( _ /\ setSize ) } v = setSize $ const v
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
2ed26a3c
...
...
@@ -9,7 +9,7 @@ import Data.Map as Map
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Data.Set as Set
import Data.Traversable (traverse)
import Data.Traversable (traverse
_
)
import Data.Tuple.Nested((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
...
...
@@ -126,8 +126,7 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
deleteNodes :: Session -> Array Int -> Effect Unit
deleteNodes session nodeIds = do
_ <- traverse (launchAff_ <<< deleteNode session) nodeIds
pure unit
traverse_ (launchAff_ <<< deleteNode session) nodeIds
deleteNode :: Session -> Int -> Aff Int
deleteNode session nodeId = delete session $ NodeAPI Node (Just nodeId) ""
...
...
src/Gargantext/Components/GraphExplorer/SlideButton.purs
View file @
2ed26a3c
module Gargantext.Components.GraphExplorer.SlideButton
( Props
, sizeButton
, cursorSizeButton
, labelSizeButton
, mouseSelectorSizeButton
) where
import Global (readFloat)
import Prelude
import Data.Tuple (snd)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Reactix as R
...
...
@@ -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 sigmaRef state =
sizeButton {
...
...
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
2ed26a3c
...
...
@@ -79,7 +79,6 @@ instance showSelectedNode :: Show SelectedNode where
type State = (
-- corpusId :: R.State Int
--, cursorSize :: R.State Number
--, filePath :: R.State String
--, graphData :: R.State GraphData
--, legendData :: R.State (Array Legend)
...
...
src/Gargantext/Hooks/Sigmax/Sigmajs.js
View file @
2ed26a3c
...
...
@@ -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
);
}
};
};
};
src/Gargantext/Hooks/Sigmax/Sigmajs.purs
View file @
2ed26a3c
...
...
@@ -6,7 +6,6 @@ import Data.Nullable (Nullable)
import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1)
import React (ReactRef, SyntheticEventHandler)
import React.SyntheticEvent (SyntheticMouseEvent)
import Record.Unsafe (unsafeGet)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional)
...
...
@@ -92,7 +91,6 @@ foreign import data CameraInstance' :: # Type
type SigmaInstance = { | SigmaInstance' }
type CameraInstance = { | CameraInstance' }
foreign import sigmaOnMouseMove :: {cursorSize :: Number} -> SyntheticMouseEvent -> Effect Unit
cameras :: SigmaInstance -> Array CameraInstance
cameras = unsafeGet "cameras"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment