[GraphExplorer] display the selector circle if cursorSize > 0.

parent 98794386
...@@ -50,7 +50,6 @@ exports.getSigmaRef = function() { ...@@ -50,7 +50,6 @@ exports.getSigmaRef = function() {
}; };
exports.goToImpl = function(cam) { exports.goToImpl = function(cam) {
return function(props) { return function(props) {
console.log("goTo", cam, props);
return cam.goTo(props); return cam.goTo(props);
}; };
}; };
...@@ -66,17 +65,10 @@ exports.pauseForceAtlas2 = function() { ...@@ -66,17 +65,10 @@ exports.pauseForceAtlas2 = function() {
} }
}; };
exports.cursor_size = 10; var trackMouse = function(cursorSize, e) {
// TODO if(!e.shiftKey) {
//exports.shift_key = false;
exports.shift_key = true;
exports.trackMouse = function(e) {
if(!exports.shift_key) {
var partialGraph = window.sigmaGargInstance; var partialGraph = window.sigmaGargInstance;
console.log('FUN t.minimap:trackMouse');
// new sigma.js 2D mouse context // new sigma.js 2D mouse context
var ctx = partialGraph.renderers[0].contexts.mouse; var ctx = partialGraph.renderers[0].contexts.mouse;
ctx.globalCompositeOperation = "source-over"; ctx.globalCompositeOperation = "source-over";
...@@ -91,7 +83,7 @@ exports.trackMouse = function(e) { ...@@ -91,7 +83,7 @@ exports.trackMouse = function(e) {
var coord = window.sigma.utils.mouseCoords(e) var coord = window.sigma.utils.mouseCoords(e)
var x = (coord.x + coord.clientX) / 2 // ; // sigma.utils.getX(e); var x = (coord.x + coord.clientX) / 2 // ; // sigma.utils.getX(e);
var y = (coord.y + coord.clientY) /2 // ; // sigma.utils.getY(e); var y = (coord.y + coord.clientY) /2 // ; // sigma.utils.getY(e);
console.log(coord); console.log('trackMouse', coord);
// optional: make more labels appear on circle hover (/!\ costly /!\ esp. on large graphs) // optional: make more labels appear on circle hover (/!\ costly /!\ esp. on large graphs)
// if (partialGraph.conf.moreLabelsUnderArea) { // if (partialGraph.conf.moreLabelsUnderArea) {
// // convert screen => mouse => cam // // convert screen => mouse => cam
...@@ -119,8 +111,7 @@ exports.trackMouse = function(e) { ...@@ -119,8 +111,7 @@ exports.trackMouse = function(e) {
ctx.fillStyle = "#71C3FF"; ctx.fillStyle = "#71C3FF";
ctx.globalAlpha = 0.5; ctx.globalAlpha = 0.5;
ctx.beginPath(); ctx.beginPath();
ctx.arc(x, y, 30.0, 0, Math.PI * 2, true); ctx.arc(x, y, cursorSize, 0, Math.PI * 2, true);
//ctx.arc(x, y, partialGraph.gui.circleSize, 0, Math.PI * 2, true);
ctx.closePath(); ctx.closePath();
ctx.fill(); ctx.fill();
ctx.stroke(); ctx.stroke();
...@@ -130,11 +121,12 @@ exports.trackMouse = function(e) { ...@@ -130,11 +121,12 @@ exports.trackMouse = function(e) {
}; };
exports.sigmaOnMouseMove = function(e) { exports.sigmaOnMouseMove = function(props) {
return function(e) {
return function() { return function() {
console.log('sigmaOnMouseMove');
if(typeof(window.sigmaGargInstance) !== "undefined") { if(typeof(window.sigmaGargInstance) !== "undefined") {
if(exports.cursor_size>0) exports.trackMouse(e); if(props.cursorSize > 0) trackMouse(props.cursorSize, e);
} }
}; };
};
}; };
...@@ -6,6 +6,7 @@ import Data.Nullable (Nullable) ...@@ -6,6 +6,7 @@ import Data.Nullable (Nullable)
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1) import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement) import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React.SyntheticEvent (SyntheticMouseEvent)
import Record.Unsafe (unsafeGet) import Record.Unsafe (unsafeGet)
import Thermite (EventHandler) import Thermite (EventHandler)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -260,7 +261,7 @@ type SigmaInstance = { | SigmaInstance' } ...@@ -260,7 +261,7 @@ type SigmaInstance = { | SigmaInstance' }
type CameraInstance = { | CameraInstance' } type CameraInstance = { | CameraInstance' }
foreign import setSigmaRef :: EffectFn1 (Nullable ReactRef) Unit foreign import setSigmaRef :: EffectFn1 (Nullable ReactRef) Unit
foreign import getSigmaRef :: Effect SigmaInstance foreign import getSigmaRef :: Effect SigmaInstance
foreign import sigmaOnMouseMove :: forall o. o -> Effect Unit foreign import sigmaOnMouseMove :: {cursorSize :: Number} -> SyntheticMouseEvent -> Effect Unit
cameras :: SigmaInstance -> Array CameraInstance cameras :: SigmaInstance -> Array CameraInstance
cameras = unsafeGet "cameras" cameras = unsafeGet "cameras"
......
...@@ -26,7 +26,7 @@ endConfig = endConfig' V10 ...@@ -26,7 +26,7 @@ endConfig = endConfig' V10
endConfig' :: ApiVersion -> EndConfig endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontRelative endConfig' v = { front : frontRelative
, back : backLocal v } , back : backDemo v }
-- , back : backDemo v } -- , back : backDemo v }
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
...@@ -63,6 +63,7 @@ data Action ...@@ -63,6 +63,7 @@ data Action
| ChangeNodeSize Number | ChangeNodeSize Number
| DisplayEdges | DisplayEdges
| ToggleMultiNodeSelection | ToggleMultiNodeSelection
| ChangeCursorSize Number
-- | Zoom Boolean -- | Zoom Boolean
newtype SelectedNode = SelectedNode {id :: String, label :: String} newtype SelectedNode = SelectedNode {id :: String, label :: String}
...@@ -74,6 +75,8 @@ derive instance ordSelectedNode :: Ord SelectedNode ...@@ -74,6 +75,8 @@ derive instance ordSelectedNode :: Ord SelectedNode
instance showSelectedNode :: Show SelectedNode where instance showSelectedNode :: Show SelectedNode where
show (SelectedNode node) = node.label show (SelectedNode node) = node.label
_cursorSize :: forall s a. Lens' { cursorSize :: a | s } a
_cursorSize = prop (SProxy :: SProxy "cursorSize")
_multiNodeSelection :: forall s a. Lens' { multiNodeSelection :: a | s } a _multiNodeSelection :: forall s a. Lens' { multiNodeSelection :: a | s } a
_multiNodeSelection = prop (SProxy :: SProxy "multiNodeSelection") _multiNodeSelection = prop (SProxy :: SProxy "multiNodeSelection")
...@@ -117,6 +120,7 @@ newtype State = State ...@@ -117,6 +120,7 @@ newtype State = State
, sigmaGraphData :: Maybe SigmaGraphData , sigmaGraphData :: Maybe SigmaGraphData
, legendData :: Array Legend , legendData :: Array Legend
, selectedNodes :: Set SelectedNode , selectedNodes :: Set SelectedNode
, cursorSize :: Number
, multiNodeSelection :: Boolean , multiNodeSelection :: Boolean
, showSidePanel :: Boolean , showSidePanel :: Boolean
, showControls :: Boolean , showControls :: Boolean
...@@ -135,6 +139,7 @@ initialState = State ...@@ -135,6 +139,7 @@ initialState = State
, sigmaGraphData : Nothing , sigmaGraphData : Nothing
, legendData : [] , legendData : []
, selectedNodes : Set.empty , selectedNodes : Set.empty
, cursorSize : 0.0
, multiNodeSelection : false , multiNodeSelection : false
, showSidePanel : false , showSidePanel : false
, showControls : false , showControls : false
...@@ -200,6 +205,11 @@ performAction ToggleMultiNodeSelection _ _ = ...@@ -200,6 +205,11 @@ performAction ToggleMultiNodeSelection _ _ =
modifyState_ $ \(State s) -> do modifyState_ $ \(State s) -> do
State $ s # _multiNodeSelection %~ not State $ s # _multiNodeSelection %~ not
performAction (ChangeCursorSize size) _ _ =
modifyState_ $ \(State s) ->
State $ s # _cursorSize .~ size
--performAction (Zoom True) _ _ = --performAction (Zoom True) _ _ =
-- modifyState_ $ \() -> do -- modifyState_ $ \() -> do
-- State $ -- State $
...@@ -513,10 +523,16 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -513,10 +523,16 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
] ]
] ]
-} -}
{-, li [className "col-md-2"] , li [className "col-md-1"]
[ span [] [text "Selector"],input [_type "range", _id "myRange", value "90"] [ span [] [text "Selector"]
, input [ _type "range"
, _id "cursorSizeRange"
, min "0"
, max "100"
, defaultValue (show st.cursorSize)
, onChange \e -> d $ ChangeCursorSize (numberTargetValue e)
]
] ]
-}
, li [className "col-md-1"] , li [className "col-md-1"]
[ span [] [text "Labels"],input [_type "range" [ span [] [text "Labels"],input [_type "range"
, _id "labelSizeRange" , _id "labelSizeRange"
...@@ -586,7 +602,7 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -586,7 +602,7 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
, div [className "row"] , div [className "row"]
[div [if (st.showSidePanel && st.showTree) then className "col-md-10" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"] [div [if (st.showSidePanel && st.showTree) then className "col-md-10" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"]
[ div [style {height: "95%"} [ div [style {height: "95%"}
,onMouseMove sigmaOnMouseMove] $ ,onMouseMove (sigmaOnMouseMove {cursorSize: st.cursorSize})] $
[ [
] ]
<> <>
......
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