Example #1
0
bool FileDataCacheItem::FromString( const String& s )
{
   path.Clear();
   lastUsed = 0;
   time.year = 0;

   StringList tokens;
   s.Break( tokens, char16_type( '\n' ) );

   for ( StringList::const_iterator i = tokens.Begin(); i != tokens.End(); )
   {
      if ( *i == "path" )
      {
         if ( ++i == tokens.End() )
            return false;
         path = i->Trimmed();
         ++i;
      }
      else if ( *i == "lastUsed" )
      {
         if ( ++i == tokens.End() )
            return false;
         lastUsed = i->ToUInt();
         ++i;
      }
      else if ( *i == "time" )
      {
         if ( tokens.End() - i < 3 )
            return false;
         int y, m, d; double f;
         JDToComplexTime( y, m, d, f, i[1].ToUInt()+0.5 );
         unsigned t = i[2].ToUInt();
         time.year = y;
         time.month = m;
         time.day = d;
         time.milliseconds = t - 86399000;
         time.hour = TruncI( (t = TruncI( t/1000.0 ))/3600.0 );
         time.minute = TruncI( (t -= time.hour*3600)/60.0 );
         time.second = t - time.minute*60;
         i += 3;
      }
      else if ( *i == "data" )
      {
         if ( !GetDataFromTokens( tokens ) )
            return false;
         ++i;
      }
      else
      {
         ++i;
      }
   }

   return !path.IsEmpty() && lastUsed > 0 && time.year > 0 && ValidateData();
}
Example #2
0
void EditEqCoordPropertyDialog::setRACoords(String value){
   StringList tokens;
   value.Break(tokens,':',true);
   assert(tokens.Length()==3);
   tokens[0].TrimLeft();
   RA_Hour_Edit.SetText(tokens[0]);
   RA_Minute_Edit.SetText(tokens[1]);
   RA_Second_Edit.SetText(tokens[2]);
   m_ra_hour=tokens[0].ToDouble();
   m_ra_minute=tokens[1].ToDouble();
   m_ra_second=tokens[2].ToDouble();
   double coord_ra=m_ra_hour + m_ra_minute / 60 + m_ra_second / 3600;
   m_RA_TargetCoord = String(coord_ra);
}
Example #3
0
void EditEqCoordPropertyDialog::setDECCoords(String value){
   StringList tokens;
   value.Break(tokens,':',true);
   assert(tokens.Length()==3);
   tokens[0].TrimLeft();
   DEC_Hour_Edit.SetText(tokens[0]);
   DEC_Minute_Edit.SetText(tokens[1]);
   DEC_Second_Edit.SetText(tokens[2]);
   m_dec_deg=tokens[0].ToDouble();
   m_dec_arcminute=tokens[1].ToDouble();
   m_dec_arcsecond=tokens[2].ToDouble();
   int sign=m_dec_deg >= 0 ? 1 : -1;
   double coord_dec=sign * (fabs(m_dec_deg) + m_dec_arcminute / 60 + m_dec_arcsecond / 3600);
   m_DEC_TargetCoord = String(coord_dec);
}
Example #4
0
   void LoadFiltersFromGlobalString( const IsoString& globalKey )
   {
      filters.Clear();

      String s = PixInsightSettings::GlobalString( globalKey  );
      if ( !s.IsEmpty() )
      {
         for ( size_type p = 0; ; )
         {
            size_type p1 = s.Find( '(', p );
            if ( p1 == String::notFound )
               break;

            size_type p2 = s.Find( ')', p1 );
            if ( p2 == String::notFound )
               break;

            String extStr = s.Substring( p1, p2-p1 );
            if ( !extStr.IsEmpty() )
            {
               StringList extLst;
               extStr.Break( extLst, ' ', true );
               if ( !extLst.IsEmpty() )
               {
                  FileFilter filter;

                  for ( StringList::const_iterator i = extLst.Begin(); i != extLst.End(); ++i )
                  {
                     size_type d = i->Find( '.' );
                     if ( d != String::notFound )
                        filter.AddExtension( i->Substring( d ) );
                  }

                  if ( !filter.Extensions().IsEmpty() )
                  {
                     String desc = s.Substring( p, p1-p );
                     desc.Trim();
                     filter.SetDescription( desc );

                     filters.Add( filter );
                  }
               }
            }

            p = p2 + 1;
         }
      }
   }