Skip to content

Commit

Permalink
working f and s keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubMitura14 committed Oct 10, 2021
1 parent 638fe04 commit ee18258
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/src/loadExampleData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ Main.SegmentationDisplay.passDataForScrolling(mainScrollDat);
using GLFW
GLFW.PollEvents()

# SegmentationDisplay
2 changes: 1 addition & 1 deletion src/MedEye3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ include(joinpath( "display","GLFW","startModules","PrepareWindow.jl"))
include(joinpath( "display","reactingToMouseKeyboard","ReactToScroll.jl") )
include(joinpath( "display","reactingToMouseKeyboard","ReactOnMouseClickAndDrag.jl") )

include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","KeyboardMouseHelper.jl") )

include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","MaskDiffrence.jl") )
include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","KeyboardVisibility.jl") )
include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","OtherKeyboardActions.jl") )
include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","WindowControll.jl") )
include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","ChangePlane.jl") )
include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","reactToKeyboard.jl") )
include(joinpath( "display","reactingToMouseKeyboard","reactToKeyboard","KeyboardMouseHelper.jl") )



Expand Down
19 changes: 13 additions & 6 deletions src/display/reactingToMouseKeyboard/ReactToScroll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ function reactToScroll(scrollNumb::Int64
current+=scrollNumb
else
current+=scrollNumb*10
end
end


#isScrollUp ? current+=1 : current-=1

# we do not want to move outside of possible range of slices
lastSlice = actor.actor.onScrollData.slicesNumber
if(lastSlice>1)

actor.actor.isSliceChanged = true
actor.actor.isBusy[] = true
if(current<1) current=1 end
Expand All @@ -103,18 +106,22 @@ function reactToScroll(scrollNumb::Int64
(twoDimList)-> SingleSliceDat(listOfDataAndImageNames=twoDimList
,sliceNumber=current
,textToDisp = getTextForCurrentSlice(actor.actor.onScrollData, Int32(current)) )

updateImagesDisplayed(singleSlDat
,actor.actor.mainForDisplayObjects
,actor.actor.textDispObj
,actor.actor.calcDimsStruct
,actor.actor.valueForMasToSet )

actor.actor.currentlyDispDat=singleSlDat
# updating the last mouse position so when we will change plane it will better show actual position
currentDim = actor.actor.onScrollData.dataToScrollDims.dimensionToScroll
actor.actor.lastRecordedMousePosition[currentDim]=current


actor.actor.currentlyDispDat=singleSlDat
# updating the last mouse position so when we will change plane it will better show actual position
currentDim =Int64(actor.actor.onScrollData.dataToScrollDims.dimensionToScroll)
lastMouse = actor.actor.lastRecordedMousePosition
locArr = [lastMouse[1],lastMouse[2],lastMouse[3]]
locArr[currentDim]= current
actor.actor.lastRecordedMousePosition=CartesianIndex(locArr[1],locArr[2],locArr[3])
#saving information about current slice for future reference
actor.actor.currentDisplayedSlice = current
#enable undoing the action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ functions that enable modyfing of reactions to mouse using keyboard
for example by pressing f and s we can controll wheather we have fast or slow scroll
"""
module KeyboardMouseHelper
using ModernGL, ..DisplayWords, ..StructsManag, Setfield, ..PrepareWindow, ..DataStructs , Rocket, GLFW,Dictionaries, ..ForDisplayStructs, ..TextureManag, ..OpenGLDisplayUtils, ..Uniforms, Match, Parameters,DataTypesBasic
using ..StructsManag, Logging, Setfield, ..PrepareWindow, ..DataStructs , Rocket, GLFW, ..ForDisplayStructs, ..TextureManag, ..OpenGLDisplayUtils, ..Uniforms, Match, Parameters,DataTypesBasic


"""
Expand All @@ -16,8 +16,10 @@ function processKeysInfo(isTobeFast::Identity{Tuple{Bool,Bool}}

isTobeFastVal = isTobeFast.value[1]
#passing information to actor that we should do now fast scrolling
actor.actor.mainForDisplayObjects.isFastScroll = isTobeFastVal

# actor.actor.mainForDisplayObjects= setproperties .isFastScroll = isTobeFastVal
@info " in processKeysInfo"
@info actor.actor.mainForDisplayObjects=setproperties(actor.actor.mainForDisplayObjects, (isFastScroll=isTobeFastVal))
actor.actor.mainForDisplayObjects=setproperties(actor.actor.mainForDisplayObjects, (isFastScroll=isTobeFastVal))
# for undoing action
if(toBeSavedForBack)
addToforUndoVector(actor, ()-> processKeysInfo( Option((!isTobeFastVal,false)),actor, keyInfo,false ))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function registerKeyboardFunctions(window::GLFW.Window,stopListening::Base.Threa

GLFW.SetKeyCallback(window, (_, key, scancode, action, mods) -> begin
name = GLFW.GetKeyName(key, scancode)
if name === nothing || name =="+" || name =="-" || name =="z"
if name === nothing || name =="+" || name =="-" || name =="z" || name =="f" || name =="s"
keyboardSubs(key,action)
else
keyboardSubs(name,action)
Expand Down Expand Up @@ -179,7 +179,11 @@ F1, F2 ... - switch between defined window display characteristics - like min sh
"""
function reactToKeyboard(keyInfo::KeyboardStruct
, actor::SyncActor{Any, ActorWithOpenGlObjects})



@info "keyInfo in reactToKeyboard" keyInfo


#we got this only when ctrl/shift/als is released or enter is pressed
obj = actor.actor.mainForDisplayObjects
obj.stopListening[]=true #free GLFW context
Expand Down Expand Up @@ -290,8 +294,10 @@ function parseString(str::Vector{String},actor::SyncActor{Any, ActorWithOpenGlOb
elseif(keyInfo.isZPressed )
return Option(true)
elseif(keyInfo.isFPressed )
@info " f pressed in parseString "
return Option((true,false))
elseif(keyInfo.isSPressed )
@info " s pressed in parseString "
return Option((false,true))
# for control of stroke width
elseif(keyInfo.isTAbPressed && keyInfo.isPlusPressed)
Expand Down
2 changes: 1 addition & 1 deletion src/structs/DataStructs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct is mutable becouse in case of the masks data can be changed multiple time
segmMetr::ResultMetrics=ResultMetrics() #results metrics associated with this slice
nameIndexes::Dictionary{String, Int64}= getLocationDict(listOfDataAndImageNames) #gives a way of efficient querying by supplying dictionary where key is a name we are intrested in and a key is index where it is located in our array
sliceNumber::Int=1 # if we want it to be tamporarly associated with some slice in scrollable data
end #fullScrollableDat
end #SingleSliceDat


"""
Expand Down

0 comments on commit ee18258

Please sign in to comment.