! ! Subroutines: ! ! LoadBase ! GetBase ! DrawBase ! LineofNumbers ! ! SUBROUTINE LoadBase !*************************************************************************** !* * !* THIS SUBROUTINE CREATES A DIALOG BOX THAT ALLOWS THE USER TO INPUT THE * !* BASE FILE. THIS ROUTINE USES SIMILAR DIALOG ACCESS AS LOADGRID, * !* AND SAVEGRID. * !* CODES ARE USED REDUNDENTLY IN THREE ROUTINES, WHICH IS SORT OF QUICK- * !* AND-DIRTY WAY. NEW STRUCTURING NEEDED DURING FURTHER MODIFICATION!! * !*************************************************************************** use dflib use dfwin use global implicit none type (t_openfilename) iofn logical(4) iret integer(4) ierror character(26*7) allfilters character(60) dlgtitle logical(4) checked ! ! update statusbar ! call setstatusbar(0,'LoadBase'C) call setstatusbar(1,' 'C) ! ALLFILTERS = 'Digitized data files (*.dig)' // char (0) // '*.DIG' // char(0) // char(0) DLGTITLE = 'Input Basemap File Digitized Using DIGITISE'C iofn%LSTRUCTSIZE = (BIT_SIZE(iofn%LSTRUCTSIZE) + & BIT_SIZE(iofn%HWNDOWNER) + & BIT_SIZE(iofn%HINSTANCE) + & BIT_SIZE(iofn%LPSTRFILTER) + & BIT_SIZE(iofn%LPSTRCUSTOMFILTER) + & BIT_SIZE(iofn%NMAXCUSTFILTER) + & BIT_SIZE(iofn%NFILTERINDEX) + & BIT_SIZE(iofn%LPSTRFILE) + & BIT_SIZE(iofn%NMAXFILE) + & BIT_SIZE(iofn%LPSTRFILETITLE) + & BIT_SIZE(iofn%NMAXFILETITLE) + & BIT_SIZE(iofn%LPSTRINITIALDIR) + & BIT_SIZE(iofn%LPSTRTITLE) + & BIT_SIZE(iofn%FLAGS) + & BIT_SIZE(iofn%NFILEOFFSET) + & BIT_SIZE(iofn%NFILEEXTENSION) + & BIT_SIZE(iofn%LPSTRDEFEXT) + & BIT_SIZE(iofn%LCUSTDATA) + & BIT_SIZE(iofn%LPFNHOOK) + & BIT_SIZE(iofn%LPTEMPLATENAME))/8 ! 8 bit = 1 Byte iofn%HWNDOWNER = GETHWNDQQ(QWIN$FRAMEWINDOW) iofn%HINSTANCE = NULL iofn%LPSTRFILTER = LOC(ALLFILTERS) iofn%LPSTRCUSTOMFILTER = NULL iofn%NMAXCUSTFILTER = NULL iofn%NFILTERINDEX = 1 iofn%LPSTRFILE = LOC(DIG_INP) iofn%NMAXFILE = LEN(DIG_INP) iofn%LPSTRFILETITLE = NULL iofn%NMAXFILETITLE = NULL iofn%LPSTRINITIALDIR = NULL iofn%LPSTRTITLE = LOC(DLGTITLE) iofn%FLAGS = NULL iofn%NFILEOFFSET = NULL iofn%NFILEEXTENSION = NULL iofn%LPSTRDEFEXT = NULL iofn%LCUSTDATA = NULL iofn%LPFNHOOK = NULL iofn%LPTEMPLATENAME = NULL iret = GETOPENFILENAME(iofn) CALL COMDLGER(ierror) ! CHECK TO SEE IF THE OK BUTTON HAS BEEN PRESSED if(iret .and. (ierror == 0)) then call GetBase end if if(BaseLoaded) then call CLEARSCREEN($GCLEARSCREEN) call REDRAW ! REDRAW plots grid and basemap whenever they are available end if ! update statusbar infor. call setstatusbar(0,'Running'C) call setstatusbar(1,' 'C) end subroutine LoadBase ! subroutine GetBase ! read into a basemap file. If file does not exist, then display a messagebox use dflib use global implicit none character(len = 512) msg0, msg1 character(len = 150) line integer(4) iret, ierr real lon, lat, Alpha, Beta, Gamma logical AreNumbers logical AreNumOrEndmark ! if base already loaded, DEALLOCATE THE POINT ! DOUBLE CHECK TO SEE IF THERE IS ANY MEMORY LEAK!! if (BaseLoaded) then call ClearLinkList end if msg0 = ' 'C msg1 = ' 'C open(unit = 1, file = DIG_INP, status = 'old', Action = 'read', iostat = ierr) if (ierr /= 0) then msg0 = ' error opening input file ' //DIG_inp//' 'C msg1 = ' error opening file 'C iret = messageboxqq(msg0, msg1, MB$ICONEXCLAMATION.OR.MB$OK) return endif do while(.not.EOF(1)) read(1,'(A150)', iostat=ierr) line call LineofNumbers(line, AreNumbers) if(AreNumbers) then read(line, *, iostat=ierr) lon, lat if (ierr /=0) then call error1 return endif lon = lon * .017453293 lat = lat * .017453293 Alpha = cos(lat)*cos(lon) Beta = cos(lat)*sin(lon) Gamma = sin(lat) AreNumOrEndmark = .true. elseif (line(1:3) == '***') then Alpha = 99.0 Beta = 99.0 Gamma = 99.0 AreNumOrEndmark = .true. else AreNumOrEndmark = .false. end if ! store in dynamic data structure if (AreNumOrEndmark) then if (.not.associated(phead)) then allocate(phead, stat = ierr) ptail => phead nullify(ptail%next_point) ptail%Alpha = Alpha ptail%Beta = Beta ptail%Gamma = Gamma else allocate(ptail%next_point, stat = ierr) ptail => ptail%next_point nullify(ptail%next_point) ptail%Alpha = Alpha ptail%Beta = Beta ptail%Gamma = Gamma end if end if end do close(unit=1) ! ! successfully read (option to display confirmation dialog) !msg0 = ' Successfully reading input file ' //DIG_inp//' 'C !msg1 = ' Successfully reading file 'C !iret = messageboxqq(msg0, msg1, MB$ICONEXCLAMATION.OR.MB$OK) ! ! set global indicator BaseLoaded = .true. end subroutine GetBase ! After Base map file is loaded, then draw it subroutine DrawBase use dflib use Global real tempvec(3), xbase, ybase integer visible,visiblelast integer colbase, rowbase integer(2) status integer count integer(4) iret type(xycoord) xy type(point), pointer:: tmp ! iret = SETCOLORRGB(ibasecolor) count = 0 tmp => phead do while(associated(tmp)) tempvec(1) = tmp%Alpha tempvec(2) = tmp%Beta tempvec(3) = tmp%Gamma tmp => tmp%next_point if (tempvec(1) > 1.1) then ! ending marks count = 0 else count = count + 1 call ABG2xy(tempvec, visible, xbase, ybase) call pixels(xbase, ybase, colbase, rowbase, visible) if (count == 1) then call moveto(colbase, rowbase, xy) visiblelast = visible else if (.not.visiblelast) then call moveto(colbase,rowbase,xy) visiblelast = visible else if(visible) then status = lineto(colbase, rowbase) else call moveto(colbase, rowbase, xy) visiblelast = visible end if end if end if end if end do nullify(tmp) end subroutine DrawBase ! Evaluate one line of a .dig file to decide if it contains a number pair ! Upon return, all preceding and trailing blanks are removed! subroutine LineofNumbers(msg, AreNumbers) character*(*) msg logical AreNumbers integer inum msg = trim(adjustl(msg)) inum = ichar(msg(2:2)) if(((msg(1:1) == '+').or.(msg(1:1) == '-')).and.& ((inum > 47).and.(inum < 58))) then AreNumbers = .true. else AreNumbers = .false. end if end subroutine LineofNumbers