Skip to content

Commit

Permalink
right button working
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubMitura14 committed Oct 10, 2021
1 parent ee18258 commit f2fed49
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 29 deletions.
11 changes: 8 additions & 3 deletions build/display/GLFW/DispUtils/StructsManag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using ColorTypes
utilities for dealing data structs like FullScrollableDat or SingleSliceDat
"""
module StructsManag
using Setfield, ..ForDisplayStructs, ..DataStructs, Rocket
using Logging, Setfield, ..ForDisplayStructs, ..DataStructs, Rocket
export getThreeDims,addToforUndoVector,cartTwoToThree,getHeightToWidthRatio,threeToTwoDimm,modSlice!, threeToTwoDimm,modifySliceFull!,getSlicesNumber,getMainVerticies

```@doc
Expand Down Expand Up @@ -96,12 +96,17 @@ Based on DataToScrollDims ,2 dim cartesian coordinate and slice number it gives
function cartTwoToThree(dataToScrollDims::DataToScrollDims
,sliceNumber::Int
,cartIn::CartesianIndex{2})::CartesianIndex{3}
toSelect= filter(it-> it!=dataToScrollDims.dimensionToScroll , [1,2,3] )# will be used to get texture width and height


toSelect= filter(it-> it!=dataToScrollDims.dimensionToScroll , [1,2,3] )# will be used to get texture width and height
resArr= [1,1,1]

resArr[dataToScrollDims.dimensionToScroll]=Int64(sliceNumber)

resArr[toSelect[1]] = cartIn[1]
resArr[toSelect[2]] = cartIn[2]
resArr[dataToScrollDims.dimensionToScroll]=Int64(sliceNumber)


return CartesianIndex(resArr[1],resArr[2],resArr[3] )
end#cartTwoToThree

Expand Down
8 changes: 6 additions & 2 deletions src/display/GLFW/DispUtils/StructsManag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ Based on DataToScrollDims ,2 dim cartesian coordinate and slice number it gives
function cartTwoToThree(dataToScrollDims::DataToScrollDims
,sliceNumber::Int
,cartIn::CartesianIndex{2})::CartesianIndex{3}
toSelect= filter(it-> it!=dataToScrollDims.dimensionToScroll , [1,2,3] )# will be used to get texture width and height
dimToScroll = dataToScrollDims.dimensionToScroll
toSelect= filter(it-> it!=dimToScroll , [1,2,3] )# will be used to get texture width and height
resArr= [1,1,1]

resArr[dataToScrollDims.dimensionToScroll]=Int64(sliceNumber)

resArr[toSelect[1]] = cartIn[1]
resArr[toSelect[2]] = cartIn[2]

resArr[dimToScroll]=Int64(sliceNumber)

return CartesianIndex(resArr[1],resArr[2],resArr[3] )
end#cartTwoToThree

Expand Down
21 changes: 11 additions & 10 deletions src/display/reactingToMouseKeyboard/ReactOnMouseClickAndDrag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ so we modify the data that is the basis of the mouse interaction mask and we pa
"""
module ReactOnMouseClickAndDrag
using Parameters, Rocket,Setfield, GLFW, ModernGL, ..ForDisplayStructs, ..TextureManag, ..OpenGLDisplayUtils
using Logging, Parameters, Rocket,Setfield, GLFW, ModernGL, ..ForDisplayStructs, ..TextureManag, ..OpenGLDisplayUtils
using Dates, Parameters, ..DataStructs, ..StructsManag
export registerMouseClickFunctions
export reactToMouseDrag
Expand Down Expand Up @@ -184,15 +184,16 @@ function reactToMouseDrag(mousestr::MouseStruct, actor::SyncActor{Any, ActorWith
elseif( mousestr.isRightButtonDown )
#we save data about right click position in order to change the slicing plane accordingly
mappedCoords = translateMouseToTexture(Int32(1)
,mouseCoords
,actor.actor.calcDimsStruct)
mappedCorrd= mappedCoords
if(!isempty(mappedCorrd))
actor.actor.lastRecordedMousePosition = cartTwoToThree(actor.actor.onScrollData.dataToScrollDims
,actor.actor.currentDisplayedSlice
, mappedCoords[1] )

end#if
,mouseCoords
,actor.actor.calcDimsStruct)
mappedCorrd= mappedCoords
if(!isempty(mappedCorrd))
cartMapped= cartTwoToThree(actor.actor.onScrollData.dataToScrollDims
,actor.actor.currentDisplayedSlice
, mappedCoords[1] )

actor.actor.lastRecordedMousePosition = cartMapped
end#if
end #if
actor.actor.isBusy[]=false # we can do sth in opengl
obj.stopListening[]=false # reactivete event listening loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module ChangePlane
using ModernGL, ..DisplayWords, ..StructsManag, Setfield, ..PrepareWindow, ..DataStructs , Rocket, GLFW,Dictionaries, ..ForDisplayStructs, ..TextureManag, ..OpenGLDisplayUtils, ..Uniforms, Match, Parameters,DataTypesBasic

"""
In case we want to change the dimansion of scrolling so for example from transverse
In case we want to change the dimansion of scrolling so for example from transverse to coronal ...
toBeSavedForBack - just marks weather we wat to save the info how to undo latest action
- false if we invoke it from undoing
"""
Expand Down Expand Up @@ -49,6 +49,7 @@ glDeleteTextures(length(arr), arr)# deleting


actor.actor.onScrollData.dimensionToScroll = toScrollDat.dimensionToScroll
actor.actor.onScrollData.dataToScrollDims = toScrollDat

actor.actor.onScrollData.slicesNumber = getSlicesNumber(actor.actor.onScrollData)
#getting the slice of intrest based on last recorded mouse position
Expand Down Expand Up @@ -84,8 +85,6 @@ updateImagesDisplayed(singleSlDat




#@info "singleSlDat" singleSlDat
#saving information about current slice for future reference
actor.actor.currentDisplayedSlice = current
# to enbling getting back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ 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= 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))
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 @@ -179,11 +179,7 @@ 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 @@ -294,10 +290,8 @@ 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 @@ -63,7 +63,7 @@ end#simpleTextStruct
"""
stores additional data about full dimensions of scrollable dat - this is necessery for switching slicing plane orientation efficiently
"""
@with_kw struct DataToScrollDims
@with_kw mutable struct DataToScrollDims
imageSize::Tuple{Int64, Int64, Int64} = (1,1,1)#amount of voxels in each dimensions
voxelSize::Tuple{Float64, Float64, Float64} = (1.0,1.0,1.0)#physical size of each pixel
dimensionToScroll::Int= 3 # by which dimension we should scroll so for example if set to 3 one and we have slice number x we will get data A by A[:,:,x] if dimensionToScroll = 2 ->A[:,x,:]...
Expand Down

0 comments on commit f2fed49

Please sign in to comment.