 !S8Help.F95         Group ID: #8     Stereo-3D Simulation Environment Vsn:1.00
!2025.05.24.1840cdt- S8Help.txt file -> Screen

!            Author- Jeffrey M. Setterholm, Lakeville,MN 55044 USA
!         IP Status- Free source code (e.g.: post copyright)
!
!          Computer- "T3"/Dell Precision T3500/Intel i5 E5520/Win10Pro-21H2
!                     ^name ^Mfgr.Id           ^chipset       ^OS 
!                    /Absoft Pro Fortran 21.0.2/GeForce GTX 1050/f90gl~Glut3.7
!                     ^compiler ~Fortran 95     ^graphics card   ^graphics

!    f90gl bindings- public domain; see "https://math.nist.gov/f90gl/"

!Disclaimer:
! ***************************************************************
! **********   Individual cognition is always flawed,  **********
! **********         including yours and mine.         **********
! **********                 - So: -                   **********
! **********       Use this code at your own risk.     **********
! ***************************************************************

!Table of Contents: ...use to search...
! Subroutine Boilerplate(iDetails)
! Subroutine TextToScreen(HelpFileIn,nRowIn,nColIn,iColor,iP)

!---------------------------------------------------------------------------7-9

Subroutine Boilerplate(iDetails)
!2025.04.18.1315cdt JMS- Displays key variables on the acreen
!  OpenGL Screen:  +X:right,+Y:up,+Z:into screen (left-handed coordinates)
!   The screen has only proportions, with vert. & depth ranges [-1.,+1.]
!--Globals                                                      in S1ModDef.f95
 use ioDef      ,only: DaTimeLabel,NowView,iTeapot,Up,UpVerb !Input/Output
 use TaskDef    ,only: ExeBanner  &                          !Project/Context
     ,Analyst,Phone,Street,CityStateZip,IPSummary
 use ScreenDef  ,only: &                                     !screen & colors
      nCharMaxX,ctlKbd,xWindowFull,yWindowFull,lCharX,lCharY,nCharMaxXS,Side &
     ,nCharMaxY,nCharCenXS
 use MouseDef   ,only: MouseScreenh &                        !Mouse
     ,iMouseState,iMouseButton,MouseDirect,Mouse,MouseU,MChan,MChanX,MChanY &
     ,iMouse7DoF,MouseDirectPrev,MXY,MXYdel
 use KeyboardDef,only: &                                     !Keyboard
      KbdKey,KbdKeyIn,ArrowKey,ArrowKeyIn,iKeyMods
 use ModelDef   ,only: M7,Nnutate                            !Model7DoF
 use ViewDef    ,only: Key
 use SimDef     ,only: SimMode,RunTimer
 use HelpDef    ,only: HhHelpView
 use AppsDef    ,only: AppNumber,AppBanner
 use BreakPtDef ,only: BrkOn                       !BreakPoint & scroll tracker

!--End Globals
 implicit none
 !--Arguments
  integer(4)::iDetails
 !--Internals
  integer(4)::iP
  integer(4)::nRow,nCol,iColor  !,Pass
  character(len=80)::PText
  !--EndDefs-----------------------------------------------
   iP=Up !; if(UpVerb==0) iP=0

  !--Introductory on-screen information begins here:
  !--At upper  left of screen:
   if(iP>5) write(iP,"('Boilerplate: nCharMaxXS=',3i5,' Side=',i2))") &
                                     nCharMaxXS      ,  Side
                                                          if(NowView/=1) return
                             nRow = 0;              nCol = 1
   write(PText,"(a58)") ExeBanner                                 !White
                             nRow=nRow+1; call PrntOrtho(nRow,   5, 1, 0,PText)
   write(PText,"('F',i1,': ',a58)") AppNumber,AppBanner(AppNumber)!White
                             nRow=nRow+1; call PrntOrtho(nRow,   1, 1, 0,PText)
  !--At upper right of screen:
                             nRow = 0;                 nCol=nCharMaxXS(Side)-22
   call Datime18
   write(PText,"(a18)")   DaTimeLabel                             !White
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 1, 0,PText)
  !write(PText,"('AppNumber = F',i1.1)") S.AppNumber              !Yellow
  !                          nRow=nRow+1; call PrntOrtho(nRow,nCol, 9, 0,PText)
                                                     iColor=1  !White
                                              if(NowView<1) return !2021.10.04
   select case(SimMode)
    case(0); write(PText,"('Sim Timer uses F9-F12')");iColor=2  !LWhite
    case(1); write(PText,"('Reset Timer=',f8.2)") RunTimer
    case(2); write(PText,"('Hold  Timer=',f8.2)") RunTimer
    case(3); write(PText,"('Run   Timer=',f8.2)") RunTimer
    case(4); write(PText,"('Stop  Timer=',f8.2)") RunTimer
    case(5); write(PText,"('Drop  Timer=',f8.2)") RunTimer
   end select!(S.SimMode)
                         nRow=nRow+1; call PrntOrtho(nRow,nCol,iColor, 0,PText)
   write(PText,"('Qq^Q:->QUIT   Hh:Help')")
   write(PText,"('Hh:Help=','   Qq^Q:->QUIT')")                   !Cyan
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,12, 0,PText)
   select case(Key%SplitScreen)
    case(-1); write(PText,"('E:-1 Right|L')") !-1
    case( 0); write(PText,"('E: 0 FullScr')") ! 0
    case(+1); write(PText,"('E:+1 Left|Rt ')")!+1
   end select!(Key.Split)                                         !White
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 1, 0,PText)
   select case(Key%VuMode)
    case(-1); write(PText,"('e:-1 raw OpenGL')")!-1
    case( 0); write(PText,"('e:0 Ortho')")      !0
    case( 1); write(PText,"('e:2 Persp')")      !1
    case( 2); write(PText,"('e:3  3D')")        !2
   end select!(Key.VuMode)                                        !White
                                       call PrntOrtho(nRow,nCol+13, 1, 0,PText)
   write(PText,"('~ :Screen Selfie->.bmp')")                      !Cyan
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,12, 0,PText)
   write(PText,"('` :Depth  Selfie')")                            !Cyan
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,12, 0,PText)
  !write(PText,"('on')")
  !                if(S.DepthSelfie>0) call PrntOrtho(nRow,nCol+17, 2, 0,PText)

   write(PText,"('Escape:toggles screen')")                       !Cyan
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,12, 0,PText)
                                                          if(iDetails<2) return

                                if(UpVerb==2)  return  !2021.10.04:
  !--Author info:
 !!write(PText,"('Email ServerName')")                            !LRed
 !!                       nRow=nRow+1; call PrntOrtho(nRow,nCol   , 6, 0,PText)
 !!write(PText,"('@')");               call PrntOrtho(nRow,nCol+ 5,10, 0,PText)
 !!write(PText,"('.com')");            call PrntOrtho(nRow,nCol+16,10, 0,PText)
 !!write(PText,"(a14)")              S.Phone                      !White
 !!                       nRow=nRow+1; call PrntOrtho(nRow,nCol+ 2, 1, 0,PText)
                                                           if(iDetails<3)return
  !--KeyPress info:
                             nRow=nRow+1
   write(Ptext,"('ctl-K redirection:')")                          !LWhite
                            if(ctlKbd==1) call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('KeyChar =',2i5,1x,a1)") KbdKey,KbdKeyIn,char(KbdKeyIn)
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('ArrowKey=',2i5      )") ArrowKey,ArrowKeyIn
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('iKeyMods=',i5,' S,^,Alt')") iKeyMods
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
                                                           if(iDetails<4)return
   write(Ptext,"('Tt: iTeapot =',i5)")         iTeapot            !Magenta
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 8, 0,PText)
   write(Ptext,"('Bb: BrkOn   =   on')");       iColor= 4; if(BrkOn>0) iColor=1
                         nRow=nRow+1; call PrntOrtho(nRow,nCol,iColor, 0,PText)
   write(Ptext,"('Nn: Nutation=   on')");       iColor= 4;if(Nnutate>0)iColor=1
                         nRow=nRow+1; call PrntOrtho(nRow,nCol,iColor, 0,PText)
   write(Ptext,"('(X,Y,Depth) GL-screen:')")                      !LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"(3f6.3)")                      MouseScreenh(1)  &
                                              ,MouseScreenh(2)  &
                                              ,MouseScreenh(3)    !LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
                             nRow=nRow+1
                                                           if(iDetails<5)return
  !--Current mouse location info:
!                            nRow =4;                    nCol=1
   write(Ptext,"('      State=',i2)") iMouseState                 !LGreen
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('     Button=',i2)") iMouseButton                !LGreen
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"(' iMouse7DoF=',i2)") iMouse7DoF                  !LGreen
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('MouseDirect=',i2,1x,a6)")    MouseDirect,MouseU%ID!LGreen
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('            ',i2,' ^prev')") MouseDirectPrev    !LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('DoF`s ',a6,3x,a6)") MChanX%ID,MChanY%ID         !LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 1, 0,PText)
   write(Ptext,"('MChan    #',i2.2,'   &  #',i2.2)") MChanX%mc,MChany%mc
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('Pix      Hor   &  Ver')")                       !LGreen
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('   max ',i5,2x,i7)")          xWindowFull,yWindowFull
                                                                  !LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('Mouse  ',i5,4x,i5)")      MChanX%Pp(1)%iPix,MChanY%Pp(1)%iPix
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('.r01  ',f6.3,f9.3)")          MChanX%r01 ,MChanY%r01!LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('.rm11 ',f6.3,f9.3)")          MChanX%rm11 ,MChanY%rm11
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('.v    ',f6.3,f9.3)")          MChanX%v ,MChanY%v !LWhite
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('Txt      Col   &  Row')")                       !LGreen
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('   max ',i5,2x,i7)")          nCharMaxX,nCharMaxY !Green
                             nRow=nRow+1; call PrntOrtho(nRow,nCol, 2, 0,PText)
   write(Ptext,"('   ->  ',i5,4x,i5)")    MChanX%Pp(1)%nChar, MChanY%Pp(1)%nChar
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
   write(Ptext,"('   <-  ',i5,4x,i5)")         MouseU%iX/lCharX  -nCharMaxX &
                                              ,MouseU%iY/lCharY-1-nCharMaxY
                             nRow=nRow+1; call PrntOrtho(nRow,nCol,10, 0,PText)
!  write(Ptext,"(4x,'>',a6,2x,'^',a6)") MChan(3).ID,MChan(4).ID   !White
!                            nRow=nRow+2; call PrntOrtho(nRow,nCol, 1, 0,PText)
   write(Ptext,"('Mouse history:       Iter#')")                  !LWhite
                           nRow=nRow+2; call PrntOrtho(nRow,nCol-4, 2, 0,PText)
   write(Ptext,"('MXYdel=',2i5,i3,i6)") MXYdel                    !LLWhite
                           nRow=nRow+1; call PrntOrtho(nRow,nCol-4, 3, 0,PText)
   write(Ptext,"('MXY(1)=',2i5,i3,i6)") MXY(1:4,1)
                           nRow=nRow+1; call PrntOrtho(nRow,nCol-4, 3, 0,PText)
   write(Ptext,"('MXY(2)=',2i5,i3,i6)") MXY(1:4,2)
                           nRow=nRow+1; call PrntOrtho(nRow,nCol-4, 3, 0,PText)
   write(Ptext,"('MXY(3)=',2i5,i3,i6)") MXY(1:4,3)
                           nRow=nRow+1; call PrntOrtho(nRow,nCol-4, 3, 0,PText)
   !--Auxiliary mouse inputs for manual control of eight app. variables:
   if(iMouse7DoF==2) then
   write(Ptext,"('`M` manual app. controls:')")                   !White
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 1, 0,PText)
   write(Ptext,"('MChan    #',i2.2,'   &  #',i2.2)") MChanX%mc,MChany%mc
   write(Ptext,"('MChan(13).rm11=',f7.4,' LMB-up-X')") MChan(13)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(14).rm11=',f7.4,'       -Y')") MChan(14)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(15).rm11=',f7.4,'    -dn-X')") MChan(15)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(16).rm11=',f7.4,'       -Y')") MChan(16)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(21).rm11=',f7.4,' RMB-up-X')") MChan(21)%rm11 !LWhite
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(22).rm11=',f7.4,'       -Y')") MChan(22)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(23).rm11=',f7.4,'    -dn-X')") MChan(23)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   write(Ptext,"('MChan(24).rm11=',f7.4,'       -Y')") MChan(24)%rm11
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 13, 0,PText)
   endif!iMouse7DoF==2
!                                                          if(iDetails<6)return
  !--At upper center of screen - IP information:
  !write(Ptext,"(a1,' 2024 ',a35)") char(169)  &   !<-Copyright symbol
  !                                , Analyst;            nCol =nCharCenXS(Side)
  !write(Ptext,"(a1,' 2024 ',a35)") char(224)  &   !<-Free symbol (wrong font)
  !                                , Analyst;            nCol =nCharCenXS(Side)
   write(Ptext,"(1x,   6x   ,a35)")  Analyst(AppNumber)     !<-Name only
                                                         nCol =nCharCenXS(Side)
                          nRow=1     ; call PrntOrtho(nRow,nCol-17, 1, 0,PText)
   write(Ptext,"(a35)")              Street(AppNumber)      !LWhite
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 2, 0,PText)
   write(Ptext,"(a35)")              CityStateZip(AppNumber)
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 2, 0,PText)
   write(Ptext,"(a35)")              Phone(AppNumber)
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 2, 0,PText)
   write(Ptext,"(a35)")              IPSummary(AppNumber)    !Red
                          nRow=nRow+1; call PrntOrtho(nRow,nCol-10, 7, 0,PText)
                                                                         return
End Subroutine Boilerplate
!---------------------------------------------------------------------------7 9

Subroutine TextToScreen(nRowIn,nColIn,iColor,iP)
!2024.04.02.1340cdt JMS- Draws screen text, scrollable by '+ & '-':
!--Globals
 use S2Callback,only:CheckGL !OpenGL CB's, GlutHandoff, & glGetError
 use ioDef      ,only:   &   !Files,Units,TimeStamp,Selfies,Flags
      Ur,Us,Ut,Uread,Uwrite,Uselfie,DaTimeLabel
 use ScreenDef  ,only: nCharMaxXS,nCharMaxY,Side   !screen & colors
 use KeyboardDef,only: KbdKey
 use AppsDef    ,only: AppNumber
 use HelpDef    ,only:   &   !Help (a text block)
     HhHelpView,nHelpLines,BufferHhHelpView
 use BreakPtDef ,only: BrkOn !BreakPoint & scrolling tracker
!--End Globals
 implicit none
 !--Arguments
  character::HName*80
  character::HNamePrev*80
  integer(4)::nRowIn,nColIn    !Text- screen upper-left character position
  integer(4)::iColor           !    - color on screen
  integer(4)::iP               ! >5: Printing enable, use: write(iP,...)
 !--Internals
  integer(4)::Init=0,i,j,Nfirst=1
  logical  ::LExists      !File existence flag
  character::HelpText(0:200)*80
! integer(4)::iAlloc       !Array allocation flag =0:success
  integer(4)::nRow,nCol        !Internal row/column counter
  character(len=80)::PText
  integer(4)::HhPrev = 0
  integer(4)::AppPrev = 0
  integer(4)::iFound
  !--EndDefs-----------------------------------------------
!call CheckGL(46)
   if(iColor<=0)                                                         return
                       HName = char(0)
   select case(HhHelpView)
    case(1);           HName = 'S8Help.txt'  !'h'
    case(2)                        !'h'
     select case(AppNumber)
      case( :1);       HName = 'S8Help.txt' 
      case(2:8); write(HName,"('S0-AppF',i1,'-Help.txt')") AppNumber        
      case(9: );                                                         return
     end select!AppNumber
   end select!HhHelpView
   if(HName==HNamePrev) then
     if(iFound==0)                                                       return
    !Use the current Helpfile:
     goto 30               
   endif!(HName==HNamePrev
  !Attempt to import file HName...
   Nfirst=1
   HelpText(0)="`Bb` toggles `+` & `-` scrolling of this text."
   inquire(file=HName,exist=LExists)
   if(LExists)then
     open(unit=Ur,file=HName,action='read',err=27)
       do i=1,200
         read(Ur,"(a80)",err=27,end=28) HelpText(i)
         HelpText(i)(80:80)=char(0)
         write(Us,*) HelpText(i)
       enddo
     HhPrev = HhHelpView
     close(Ur); iFound = 1; i = 200; HNamePrev = HName                 ;goto 30
27   close(Ur); iFound = 0                                             ;return
28   close(Ur); iFound = 1; i=i-1  ; HNamePrev = HName                 ;goto 30
    else;       iFound = 0                                             ;return
   endif!LExists
  !--S8Help.txt is imported into HelpText()
30 continue
   if(BrkOn>0) then
     select case(KbdKey) !-----------------------
     !--Adjust Nfirst using the +- keys:
      case(43,61); KbdKey=0; Nfirst=Nfirst+1           !: '+='
             if(Nfirst>i-20) Nfirst=       i-20
      case(45   ); KbdKey=0; Nfirst=Nfirst-1           !:  '-'
                if(Nfirst<1) Nfirst=       1
     end select !KbdKey ------------------------^
   endif!BrkOn>0

  !Offset down/right if>0      Up/left if<0   Text block below has
   nRow=NrowIn !; if(nRow<0) nRow=nCharMaxY+nRow+1    !<=100 rows    -&-
   nCol=nColIn !; if(nCol<0) nCol=nCharMaxX+nCol+1    !<= 80 columns
 call CheckGL(+80283)
   write(PText,"('Hh:Help=',i1)") HhHelpView                      !Cyan
                                        call PrntOrtho(nRow+1,nCol,12, 0,PText)
   do j=0,i; if(j>200) exit
     if((j>0).and.(j<Nfirst)) cycle
     if((len_trim(HelpText(j))>0).and.(len_trim(HelpText(j))<=80)) &
       call PrntOrtho(nRow,nCol,iColor,0,HelpText(j))
              nRow=nRow+1
     if(j==0) nRow=nRow+1
   enddo
   call CheckGL(-80291)                                                 ;return
End Subroutine TextToScreen
!---------------------------------------------------------------------------7 9

