Skip to content

Commit

Permalink
bind g to open geometry window
Browse files Browse the repository at this point in the history
  • Loading branch information
aoterodelaroza committed Nov 25, 2024
1 parent 395f7f5 commit 6f53207
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.346
1.2.347
13 changes: 9 additions & 4 deletions src/gui/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ subroutine show_main_menu()
wintype_preferences, wintype_view, wpurp_view_alternate,&
wintype_about, wintype_geometry
use utils, only: igIsItemHovered_delayed, iw_tooltip, iw_text, iw_calcwidth, iw_menuitem
use keybindings, only: BIND_QUIT, BIND_OPEN, BIND_NEW, get_bind_keyname, is_bind_event
use keybindings, only: BIND_QUIT, BIND_OPEN, BIND_NEW, BIND_GEOMETRY, get_bind_keyname,&
is_bind_event
use interfaces_glfw, only: GLFW_TRUE, glfwSetWindowShouldClose
use tools_io, only: string

Expand All @@ -832,10 +833,11 @@ subroutine show_main_menu()
integer, parameter :: d_new = 2
integer, parameter :: d_newlib = 3
integer, parameter :: d_preferences = 4
integer, parameter :: d_geometry = 5

character(kind=c_char,len=:), allocatable, target :: str1, str2
integer(c_int) :: idum
logical :: launchquit, launch(4)
logical :: launchquit, launch(5)
integer :: isys

logical, save :: ttshown = .false. ! tooltip flag
Expand All @@ -846,6 +848,7 @@ subroutine show_main_menu()
launch(d_new) = is_bind_event(BIND_NEW)
launch(d_newlib) = .false.
launch(d_preferences) = .false.
launch(d_geometry) = is_bind_event(BIND_GEOMETRY)
launchquit = is_bind_event(BIND_QUIT)

! start the menu
Expand Down Expand Up @@ -931,8 +934,8 @@ subroutine show_main_menu()
str1 = "Tools" // c_null_char
if (igBeginMenu(c_loc(str1),.true._c_bool)) then
isys = win(iwin_tree)%table_selected
if (iw_menuitem("View/Edit Geometry...",enabled=ok_system(isys,sys_init))) &
idum = stack_create_window(wintype_geometry,.true.,isys=isys,orraise=-1)
launch(d_geometry) = launch(d_geometry) .or. &
iw_menuitem("View/Edit Geometry...",BIND_GEOMETRY,enabled=ok_system(isys,sys_init))
call iw_tooltip("View and edit the atomic positions, bonds, etc.",ttshown)

call igEndMenu()
Expand Down Expand Up @@ -977,6 +980,8 @@ subroutine show_main_menu()
idum = stack_create_window(wintype_new_struct_library,.true.,orraise=-1)
if (launch(d_open)) &
idum = stack_create_window(wintype_dialog,.true.,wpurp_dialog_openfiles,orraise=-1)
if (launch(d_geometry)) &
idum = stack_create_window(wintype_geometry,.true.,isys=isys,orraise=-1)
if (launchquit) then
if (are_threads_running()) &
call kill_initialization_thread()
Expand Down
54 changes: 28 additions & 26 deletions src/gui/keybindings.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,39 @@ module keybindings
integer, parameter, public :: BIND_QUIT = 1 ! quit the program
integer, parameter, public :: BIND_NEW = 2 ! create new systems
integer, parameter, public :: BIND_OPEN = 3 ! open systems
integer, parameter, public :: BIND_CLOSE_ALL_DIALOGS = 4 ! close all open dialogs
integer, parameter, public :: BIND_CLOSE_FOCUSED_DIALOG = 5 ! close focused dialog
integer, parameter, public :: BIND_OK_FOCUSED_DIALOG = 6 ! OK focused dialog
integer, parameter, public :: BIND_TREE_REMOVE_SYSTEM_FIELD = 7 ! tree: remove system or field
integer, parameter, public :: BIND_TREE_MOVE_UP = 8 ! tree: move selection up
integer, parameter, public :: BIND_TREE_MOVE_DOWN = 9 ! tree: move selection down
integer, parameter, public :: BIND_INPCON_RUN = 10 ! tree: remove system
integer, parameter, public :: BIND_VIEW_INC_NCELL = 11 ! view: increase number of cells
integer, parameter, public :: BIND_VIEW_DEC_NCELL = 12 ! view: decrease number of cells
integer, parameter, public :: BIND_VIEW_ALIGN_A_AXIS = 13 ! view: align view with a axis
integer, parameter, public :: BIND_VIEW_ALIGN_B_AXIS = 14 ! view: align view with b axis
integer, parameter, public :: BIND_VIEW_ALIGN_C_AXIS = 15 ! view: align view with c axis
integer, parameter, public :: BIND_VIEW_ALIGN_X_AXIS = 16 ! view: align view with x axis
integer, parameter, public :: BIND_VIEW_ALIGN_Y_AXIS = 17 ! view: align view with y axis
integer, parameter, public :: BIND_VIEW_ALIGN_Z_AXIS = 18 ! view: align view with z axis
integer, parameter, public :: BIND_VIEW_TOGGLE_ATOMS = 19 ! view: toggle atoms in the first rep
integer, parameter, public :: BIND_VIEW_TOGGLE_BONDS = 20 ! view: toggle bonds in the first rep
integer, parameter, public :: BIND_VIEW_TOGGLE_LABELS = 21 ! view: toggle labels in the first rep
integer, parameter, public :: BIND_VIEW_TOGGLE_CELL = 22 ! view: toggle cell in the first rep
integer, parameter, public :: BIND_NAV_ROTATE = 23 ! view: rotate the view
integer, parameter, public :: BIND_NAV_ROTATE_PERP = 24 ! view: rotate around axis perp. to screen
integer, parameter, public :: BIND_NAV_TRANSLATE = 25 ! view: translate the view
integer, parameter, public :: BIND_NAV_ZOOM = 26 ! view: zoom the view
integer, parameter, public :: BIND_NAV_RESET = 27 ! view: reset the view
integer, parameter, public :: BIND_NAV_MEASURE = 28 ! view: reset the view
integer, parameter, public :: BIND_NUM = 28 ! total number of binds
integer, parameter, public :: BIND_GEOMETRY = 4 ! view/edit geometry
integer, parameter, public :: BIND_CLOSE_ALL_DIALOGS = 5 ! close all open dialogs
integer, parameter, public :: BIND_CLOSE_FOCUSED_DIALOG = 6 ! close focused dialog
integer, parameter, public :: BIND_OK_FOCUSED_DIALOG = 7 ! OK focused dialog
integer, parameter, public :: BIND_TREE_REMOVE_SYSTEM_FIELD = 8 ! tree: remove system or field
integer, parameter, public :: BIND_TREE_MOVE_UP = 9 ! tree: move selection up
integer, parameter, public :: BIND_TREE_MOVE_DOWN = 10 ! tree: move selection down
integer, parameter, public :: BIND_INPCON_RUN = 11 ! tree: remove system
integer, parameter, public :: BIND_VIEW_INC_NCELL = 12 ! view: increase number of cells
integer, parameter, public :: BIND_VIEW_DEC_NCELL = 13 ! view: decrease number of cells
integer, parameter, public :: BIND_VIEW_ALIGN_A_AXIS = 14 ! view: align view with a axis
integer, parameter, public :: BIND_VIEW_ALIGN_B_AXIS = 15 ! view: align view with b axis
integer, parameter, public :: BIND_VIEW_ALIGN_C_AXIS = 16 ! view: align view with c axis
integer, parameter, public :: BIND_VIEW_ALIGN_X_AXIS = 17 ! view: align view with x axis
integer, parameter, public :: BIND_VIEW_ALIGN_Y_AXIS = 18 ! view: align view with y axis
integer, parameter, public :: BIND_VIEW_ALIGN_Z_AXIS = 19 ! view: align view with z axis
integer, parameter, public :: BIND_VIEW_TOGGLE_ATOMS = 20 ! view: toggle atoms in the first rep
integer, parameter, public :: BIND_VIEW_TOGGLE_BONDS = 21 ! view: toggle bonds in the first rep
integer, parameter, public :: BIND_VIEW_TOGGLE_LABELS = 22 ! view: toggle labels in the first rep
integer, parameter, public :: BIND_VIEW_TOGGLE_CELL = 23 ! view: toggle cell in the first rep
integer, parameter, public :: BIND_NAV_ROTATE = 24 ! view: rotate the view
integer, parameter, public :: BIND_NAV_ROTATE_PERP = 25 ! view: rotate around axis perp. to screen
integer, parameter, public :: BIND_NAV_TRANSLATE = 26 ! view: translate the view
integer, parameter, public :: BIND_NAV_ZOOM = 27 ! view: zoom the view
integer, parameter, public :: BIND_NAV_RESET = 28 ! view: reset the view
integer, parameter, public :: BIND_NAV_MEASURE = 29 ! view: reset the view
integer, parameter, public :: BIND_NUM = 29 ! total number of binds

! Bind names
character(len=32), parameter, public :: bindnames(BIND_NUM) = (/&
"Quit ",& ! BIND_QUIT
"New ",& ! BIND_NEW
"View/Edit Geometry ",& ! BIND_GEOMETRY
"Open file(s) ",& ! BIND_OPEN
"Close all dialogs ",& ! BIND_CLOSE_ALL_DIALOGS
"Close focused dialog ",& ! BIND_CLOSE_FOCUSED_DIALOG
Expand Down
2 changes: 2 additions & 0 deletions src/gui/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
integer, parameter :: groupbind(BIND_NUM) = (/&
group_global,& ! BIND_QUIT
group_global,& ! BIND_NEW
group_global,& ! BIND_GEOMETRY
group_global,& ! BIND_OPEN
group_global,& ! BIND_CLOSE_ALL_DIALOGS
group_dialog,& ! BIND_CLOSE_FOCUSED_DIALOG
Expand Down Expand Up @@ -213,6 +214,7 @@ module subroutine set_default_keybindings()
! Default keybindings
call set_bind(BIND_QUIT,ImGuiKey_Q,mod_ctrl)
call set_bind(BIND_NEW,ImGuiKey_N,mod_ctrl)
call set_bind(BIND_GEOMETRY,ImGuiKey_G,mod_none)
call set_bind(BIND_OPEN,ImGuiKey_O,mod_ctrl)
call set_bind(BIND_CLOSE_ALL_DIALOGS,ImGuiKey_Backspace,mod_none)
call set_bind(BIND_CLOSE_FOCUSED_DIALOG,ImGuiKey_Escape,mod_none)
Expand Down
3 changes: 2 additions & 1 deletion src/gui/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ module subroutine draw_tree(w)

subroutine write_maybe_selectable(isys,tooltipstr)
use gui_main, only: are_threads_running, duplicate_system
use keybindings, only: BIND_GEOMETRY
use utils, only: iw_text
use global, only: iunit, iunit_bohr, iunit_ang
use tools_io, only: uout
Expand Down Expand Up @@ -1033,7 +1034,7 @@ subroutine write_maybe_selectable(isys,tooltipstr)
strpop = "System" // c_null_char
if (igBeginMenu(c_loc(strpop),.true._c_bool)) then
! Geometry
if (iw_menuitem("View/Edit Geometry...",enabled=enabled)) &
if (iw_menuitem("View/Edit Geometry...",BIND_GEOMETRY,enabled=enabled)) &
idgeometry = stack_create_window(wintype_geometry,.true.,isys=isys,orraise=-1)
call iw_tooltip("View and edit the atomic positions, bonds, etc.",ttshown)

Expand Down

0 comments on commit 6f53207

Please sign in to comment.