src/HSLib/SpinSystem.cc
/* These functons return vectors of strings that can be used in functions that
   print out spin system information. The strings are of a specified width so
   that they can easily form nice columns when printed. The value of colwd sets
   the width of the srings returned. Function SYSStrings will return strings
   for printing the entire spin system. Each string in that case will appear
   as
                |<--w1-->|_:w3|<--w2-->|w3|<--w2-->|w3|<--w2-->|......
   e.g.         Isotope    :      1H          13C         2H

   where the column widths have default and minimal values built in. Note 
   this function coincides with the base class function of the same type.
   The difference is that it uses a wider width for the successive columns,
   setting those values in spin_sys as well.                                */
These functons return vectors of strings that can be used in functions that
print out spin system information. The strings are of a specified width so
that they can easily form nice columns when printed. The value of colwd sets
the width of the srings returned. Function SYSStrings will return strings
for printing the entire spin system.


These functons return vectors of strings that can be used in functions that print out spin system information . The strings are of a specified width so that they can easily form nice columns when printed . The value of colwd sets the width of the srings returned . Function SYSStrings will return strings for printing the entire spin system .
std::vector<std::string> spin_system::SYSStrings(int cw1, int cw2, int csp) const
  {
  std::vector<std::string> StrArray;		
  std::vector<std::string> StrTemp;		
  std::string semicol(" :");			
  std::string colspcr(csp, ' ');		
  int i, sbuff;					
  std::string Stemp;				
  if(cw1 < 10) cw1 = 10;			
  if(cw2 < 10) cw2 = 10;			
  if(csp < 0)  csp = 1;				
  StrArray = spin_sys::SYSStrings(cw1,cw2,csp);	
  int ns = spins();				
  int dadp = 2;					
  if(nucleons())
    {
    StrTemp = VStrings(cw2, dadp);		
    Stemp = std::string("Shifts");		
    sbuff = cw1 - Stemp.length();		
    if(sbuff > 0) Stemp += std::string(sbuff, ' ');
    Stemp += semicol + colspcr;
     for(i=0; i<ns; i++)			
      {						
      Stemp += StrTemp[i];
      if(i+1 < ns) Stemp += colspcr;
      }
    StrArray.push_back(Stemp);			
    }
  if(nucleons() && spectrometer_frequency())
    {
    StrTemp = PPMStrings(cw2);			
    Stemp = std::string(cw1, ' ');		
    Stemp += semicol + colspcr;
    for(i=0; i<ns; i++)				
      {						
      Stemp += StrTemp[i];
      if(i+1 < ns) Stemp += colspcr;
      }
    StrArray.push_back(Stemp);			
    }
  if(electrons())
    {
    StrTemp = GFStrings(cw2);			
    Stemp = std::string("g Factors");		
    sbuff = cw1 - Stemp.length();		
    if(sbuff > 0) Stemp += std::string(sbuff, ' ');
    Stemp += semicol + colspcr;
    for(i=0; i<ns; i++)				
      {						
      Stemp += StrTemp[i];
      if(i+1 < ns) Stemp += colspcr;
      }
    StrArray.push_back(Stemp);			
    }
  if(electrons() && spectrometer_frequency())
    {
    StrTemp = BeStrings(cw2);			
    Stemp = std::string("B (Gauss)");		
    sbuff = cw1 - Stemp.length();		
    if(sbuff > 0) Stemp += std::string(sbuff, ' ');
    Stemp += semicol; 
    for(i=0; i<ns; i++)				
      {						
      Stemp += StrTemp[i];
      if(i+1 < ns) Stemp += colspcr;
      }
    StrArray.push_back(Stemp);			
    }
  int nsl = Gdec(ns).length();
  std::string sbase, sfill;
  if(nucleons() > 1)
    {
    StrTemp = JStrings(cw2);			
    sbase = std::string("Js Spin ");		
    sbuff = cw1 - sbase.length() - nsl;		
    if(sbuff > 0) sfill += std::string(sbuff, ' ');
    int j, k;
    for(i=0, k=0; i<ns-1; i++)			
      {						
      Stemp = sbase + Gdec(i, nsl) + sfill
            + semicol + colspcr;
      for(j=0; j<ns; j++, k++)			
        {					
        Stemp += StrTemp[k];
        if(j+1 < ns) Stemp += colspcr;
        }
      StrArray.push_back(Stemp);		
      }
    }
  if(nucleons() && electrons())
    {
    StrTemp = AStrings(cw2);			
    sbase = std::string("As Spin ");		
    sbuff = cw1 - sbase.length() - nsl;		
    if(sbuff > 0) sfill += std::string(sbuff, ' ');
    int j, k;
    for(i=0, k=0; i<ns-1; i++)			
      {						
      Stemp = sbase + Gdec(i, nsl) + sfill
            + semicol + colspcr;
      for(j=0; j<ns; j++, k++)			
        {					
        Stemp += StrTemp[k];
        if(j+1 < ns) Stemp += colspcr;
        }
      StrArray.push_back(Stemp);		
      }
    }
  if(Omega())					
    {						
    StrTemp = OmStrings(cw2, 2);		s
    Stemp = std::string("Omega");		
    sbuff = cw1 - Stemp.length();		
    if(sbuff > 0) Stemp += std::string(sbuff, ' ');
    Stemp += semicol + colspcr;
     for(i=0; i<ns; i++)				
      {						
      Stemp += StrTemp[i];
      if(i+1 < ns) Stemp += colspcr;
      }
    StrArray.push_back(Stemp);			
    }
  return StrArray;				
  }
std :: vector < std :: string > spin_system :: SYSStrings ( int cw1 , int cw2 , int csp ) const { std :: vector < std :: string > StrArray ; std :: vector < std :: string > StrTemp ; std :: string semicol ( " " ) ; std :: string colspcr ( csp , ' ' ) ; int i , sbuff ; std :: string Stemp ; if ( cw1 < 10 ) cw1 = 10 ; if ( cw2 < 10 ) cw2 = 10 ; if ( csp < 0 ) csp = 1 ; StrArray = spin_sys :: SYSStrings ( cw1 , cw2 , csp ) ; int ns = spins ( ) ; int dadp = 2 ; if ( nucleons ( ) ) { StrTemp = VStrings ( cw2 , dadp ) ; Stemp = std :: string ( " " ) ; sbuff = cw1 - Stemp . length ( ) ; if ( sbuff > 0 ) Stemp += std :: string ( sbuff , ' ' ) ; Stemp += semicol + colspcr ; for ( i = 0 ; i < ns ; i ++ ) { Stemp += StrTemp [ i ] ; if ( i + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } if ( nucleons ( ) && spectrometer_frequency ( ) ) { StrTemp = PPMStrings ( cw2 ) ; Stemp = std :: string ( cw1 , ' ' ) ; Stemp += semicol + colspcr ; for ( i = 0 ; i < ns ; i ++ ) { Stemp += StrTemp [ i ] ; if ( i + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } if ( electrons ( ) ) { StrTemp = GFStrings ( cw2 ) ; Stemp = std :: string ( " " ) ; sbuff = cw1 - Stemp . length ( ) ; if ( sbuff > 0 ) Stemp += std :: string ( sbuff , ' ' ) ; Stemp += semicol + colspcr ; for ( i = 0 ; i < ns ; i ++ ) { Stemp += StrTemp [ i ] ; if ( i + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } if ( electrons ( ) && spectrometer_frequency ( ) ) { StrTemp = BeStrings ( cw2 ) ; Stemp = std :: string ( " " ) ; sbuff = cw1 - Stemp . length ( ) ; if ( sbuff > 0 ) Stemp += std :: string ( sbuff , ' ' ) ; Stemp += semicol ; for ( i = 0 ; i < ns ; i ++ ) { Stemp += StrTemp [ i ] ; if ( i + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } int nsl = Gdec ( ns ) . length ( ) ; std :: string sbase , sfill ; if ( nucleons ( ) > 1 ) { StrTemp = JStrings ( cw2 ) ; sbase = std :: string ( " " ) ; sbuff = cw1 - sbase . length ( ) - nsl ; if ( sbuff > 0 ) sfill += std :: string ( sbuff , ' ' ) ; int j , k ; for ( i = 0 , k = 0 ; i < ns - 1 ; i ++ ) { Stemp = sbase + Gdec ( i , nsl ) + sfill + semicol + colspcr ; for ( j = 0 ; j < ns ; j ++ , k ++ ) { Stemp += StrTemp [ k ] ; if ( j + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } } if ( nucleons ( ) && electrons ( ) ) { StrTemp = AStrings ( cw2 ) ; sbase = std :: string ( " " ) ; sbuff = cw1 - sbase . length ( ) - nsl ; if ( sbuff > 0 ) sfill += std :: string ( sbuff , ' ' ) ; int j , k ; for ( i = 0 , k = 0 ; i < ns - 1 ; i ++ ) { Stemp = sbase + Gdec ( i , nsl ) + sfill + semicol + colspcr ; for ( j = 0 ; j < ns ; j ++ , k ++ ) { Stemp += StrTemp [ k ] ; if ( j + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } } if ( Omega ( ) ) { StrTemp = OmStrings ( cw2 , 2 ) ; Stemp = std :: string ( " " ) ; sbuff = cw1 - Stemp . length ( ) ; if ( sbuff > 0 ) Stemp += std :: string ( sbuff , ' ' ) ; Stemp += semicol + colspcr ; for ( i = 0 ; i < ns ; i ++ ) { Stemp += StrTemp [ i ] ; if ( i + 1 < ns ) Stemp += colspcr ; } StrArray . push_back ( Stemp ) ; } return StrArray ; }
These functons return vectors of strings that can be used in functions that
print out spin system information.
These functons return vectors of strings that can be used in functions that print out spin system information .
// Make a string vector // Temporary string array // Need semicolon // Space between columns // Array index, buffer length // Temporary string // Keep 1st column width OK // Keep later col widths OK // Keep col spacer OK //                    Fill Array With Base Class Strings // Get strings for spin sys // Spins in the system // Digits after decimal point //                       Add Chemical Shift Strings // Get strings for shifts //  Set up the first column //  to width cw1 //  Set up the next columns //  using cw2 column widths // Store shift values //                     Add Chemical Shift in PPM Strings // Get strings for ppm //  Set up the first column //  Set up the next columns //  using cw2 column widths // Store ppm values //                     Add Electron G Factor Strings // Get strings for ppm //  Set up the first column //  to width cw1 //  Set up the next columns //  using cw2 column widths // Store g factor values //                     Add Electron Resonance Field Strings // Get strings for field //  Set up the first column //  to width cw1 //+ colspcr; //  Set up the next columns //  using cw2 column widths // Store field values //                     Add Scalar Coupling Strings // Get strings for J couplings // Set up the first column // to width cw1 // Set up the first column // using cw2 column widths // Set up the next columns // using cw2 column widths // Store J values //                     Add Hyperfine Coupling Strings // Get strings for A couplings //  Set up the first column //  to width cw1 //  Set up the first column //  using cw2 column widths //  Set up the next columns //  using cw2 column widths // Store A values //                     Add Field Strength Strings // Print base spectrometer 	 // frequencies per each isotope // Get strings for fields //  Set up the first column //  to width cw1 //  Set up the next columns //  using cw2 column widths // Store shift values // Return the string array