Skip to content

Commit

Permalink
started the system geometry dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
aoterodelaroza committed Nov 23, 2024
1 parent 787a98b commit 6feb70d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.333
1.2.334
6 changes: 6 additions & 0 deletions src/gui/windows.f90
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ module windows
procedure :: draw_vibrations
! rebond
procedure :: draw_rebond
! geometry
procedure :: draw_geometry
! preferences
procedure :: draw_preferences
end type window
Expand Down Expand Up @@ -244,6 +246,7 @@ module windows
integer, parameter, public :: wintype_rebond = 14
integer, parameter, public :: wintype_preferences = 15
integer, parameter, public :: wintype_treeplot = 16
integer, parameter, public :: wintype_geometry = 17

! window purposes
integer, parameter, public :: wpurp_unknown = 0
Expand Down Expand Up @@ -451,6 +454,9 @@ end subroutine draw_vibrations
module subroutine draw_rebond(w)
class(window), intent(inout), target :: w
end subroutine draw_rebond
module subroutine draw_geometry(w)
class(window), intent(inout), target :: w
end subroutine draw_geometry
end interface

end module windows
15 changes: 14 additions & 1 deletion src/gui/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,13 @@ module function stack_create_window(type,isopen,purpose,isys,irep,idcaller,perma
if (orraise < 0) then
raiseid = 0
do i = 1, nwin
! wintype_dialog
ok = win(i)%type == type .and. win(i)%isopen
! specific tests according to type
if (ok.and.type == wintype_dialog) ok = (win(i)%dialog_data%purpose == purpose)
if (ok.and.type == wintype_editrep) ok = (win(i)%isys == isys .and.&
win(i)%irep == irep .and. win(i)%idparent == idcaller)
if (ok.and.type == wintype_scfplot) ok = (win(i)%isys == isys)
if (ok.and.type == wintype_geometry) ok = (win(i)%isys == isys)
if (ok) then
raiseid = i
exit
Expand Down Expand Up @@ -517,6 +518,10 @@ module subroutine window_init(w,type,isopen,id,purpose,isys,irep,idcaller)
! recalculate bonds window
if (.not.present(isys)) &
call ferror('window_init','rebond requires isys',faterr)
elseif (type == wintype_geometry) then
! geometry window
if (.not.present(isys)) &
call ferror('window_init','geometry requires isys',faterr)
end if

end subroutine window_init
Expand Down Expand Up @@ -736,6 +741,12 @@ module subroutine window_draw(w)
inisize%x = 55 * fontsize%x
inisize%y = 23 * fontsize%y
call igSetNextWindowSize(inisize,ImGuiCond_FirstUseEver)
elseif (w%type == wintype_geometry) then
w%name = "Geometry##" // string(w%id) // c_null_char
w%flags = ImGuiWindowFlags_None
inisize%x = 55 * fontsize%x
inisize%y = 23 * fontsize%y
call igSetNextWindowSize(inisize,ImGuiCond_FirstUseEver)
elseif (w%type == wintype_preferences) then
w%name = "Preferences##" // string(w%id) // c_null_char
w%flags = ImGuiWindowFlags_None
Expand Down Expand Up @@ -797,6 +808,8 @@ module subroutine window_draw(w)
call w%draw_vibrations()
elseif (w%type == wintype_rebond) then
call w%draw_rebond()
elseif (w%type == wintype_rebond) then
call w%draw_geometry()
elseif (w%type == wintype_preferences) then
call w%draw_preferences()
elseif (w%type == wintype_treeplot) then
Expand Down
48 changes: 41 additions & 7 deletions src/gui/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module subroutine draw_tree(w)
logical, save :: ttshown = .false. ! tooltip flag
integer(c_int), save :: iresample(3) = (/0,0,0/) ! for the grid resampling menu option
integer(c_int), save :: idrebond = 0 ! ID of the window used to rebond the sytsem
integer(c_int), save :: idgeometry = 0 ! ID of the window used for geometry view/edit
integer(c_int), save :: shown_after_filter = 0 ! number of systems shown after the filter
real*8, save :: timelastupdate = 0d0
real*8, save :: timelastresize = 0d0
Expand Down Expand Up @@ -123,8 +124,9 @@ module subroutine draw_tree(w)
if (timelastsort < sysc(i)%timelastchange) w%forcesort = .true.
end do

! update the window ID for the rebond dialog
! update the window ID for the dialogs
call update_window_id(idrebond)
call update_window_id(idgeometry)

! Tree options button
export = .false.
Expand Down Expand Up @@ -1001,13 +1003,13 @@ subroutine write_maybe_selectable(isys,tooltipstr)
end if

! geometry submenu (system)
strpop = "Geometry" // c_null_char
strpop = "System" // c_null_char
if (igBeginMenu(c_loc(strpop),.true._c_bool)) then
! ! Geometry
! strpop = "Geometry Information" // c_null_char
! if (igMenuItem_Bool(c_loc(strpop),c_null_ptr,.false._c_bool,enabled)) &
! idrebond = stack_create_window(wintype_rebond,.true.,isys=isys,orraise=-1)
! call iw_tooltip("Recalculate the covalent bonds in this system and the molecular structures",ttshown)
! Geometry
strpop = "Geometry" // c_null_char
if (igMenuItem_Bool(c_loc(strpop),c_null_ptr,.false._c_bool,enabled)) &
idgeometry = stack_create_window(wintype_geometry,.true.,isys=isys,orraise=-1)
call iw_tooltip("View and edit the atomic positions, bonds, etc.",ttshown)

! rebond
strpop = "Recalculate Bonds" // c_null_char
Expand Down Expand Up @@ -1165,6 +1167,7 @@ subroutine select_system(i,force)
if (tree_select_updates_view .or. force) &
call win(iwin_view)%select_view(i)
if (idrebond > 0) win(idrebond)%isys = i
if (idgeometry > 0) win(idgeometry)%isys = i

end subroutine select_system

Expand Down Expand Up @@ -2769,4 +2772,35 @@ end subroutine getname

end subroutine draw_treeplot

!> Draw the geometry window.
module subroutine draw_geometry(w)
use keybindings, only: is_bind_event, BIND_CLOSE_FOCUSED_DIALOG,&
BIND_OK_FOCUSED_DIALOG, BIND_CLOSE_ALL_DIALOGS
use gui_main, only: nsys, sysc, sys, sys_init, g
use utils, only: iw_text, iw_tooltip, iw_calcwidth, iw_button, iw_calcheight
use global, only: bondfactor_def
use tools_io, only: string, nameguess
use param, only: atmcov0, maxzat0, bohrtoa, newline
class(window), intent(inout), target :: w

logical :: doquit

! initialize
doquit = .false.

! xxxx

! close button
doquit = (w%focused() .and. (is_bind_event(BIND_OK_FOCUSED_DIALOG) .or.&
is_bind_event(BIND_CLOSE_FOCUSED_DIALOG) .or.&
is_bind_event(BIND_CLOSE_ALL_DIALOGS)))
doquit = doquit .or. iw_button("Close",sameline=.true.)

! quit the window
if (doquit) then
call w%end()
end if

end subroutine draw_geometry

end submodule tree

0 comments on commit 6feb70d

Please sign in to comment.