Пример #1
0
int POVMS_List::GetListSize()
{
    int len = 0;
    int err;

    err = POVMSAttrList_Count(&data, &len);
    if(err != pov_base::kNoErr)
        throw POV_EXCEPTION_CODE(err);

    return len;
}
Пример #2
0
ITextStream *ProcessRenderOptions::OpenINIFileStream(const char *filename, unsigned int stype, char *buffer, POVMSObjectPtr obj)
{
    int i,ii,l[4];
    char pathname[FILE_NAME_LENGTH];
    char file[FILE_NAME_LENGTH];
    char file_x[4][FILE_NAME_LENGTH];
    int cnt = 0;
    int ll;
    POVMSAttribute attr, item;

    if(Has_Extension(filename))
    {
        for(i = 0; i < 4; i++)
            l[i]=0;
    }
    else
    {
        for(i = 0; i < 4; i++)
        {
            if((l[i] = strlen(gPOV_File_Extensions[stype].ext[i])) > 0)
            {
                strcpy(file_x[i], filename);
                strcat(file_x[i], gPOV_File_Extensions[stype].ext[i]);
            }
        }
    }

    // Check the current directory first
    for(i = 0; i < 4; i++)
    {
        if(l[i])
        {
            if(EXIST_FILE(file_x[i]) == true)
            {
                strcpy(buffer,file_x[i]);
                return new ITextStream(file_x[i], stype);
            }
        }
    }
    if(EXIST_FILE(filename) == true)
    {
        strcpy(buffer,filename);
        return new ITextStream(filename, stype);
    }

    if(POVMSObject_Get(obj, &attr, kPOVAttrib_LibraryPath) != 0)
        return NULL;

    if(POVMSAttrList_Count(&attr, &cnt) != 0)
    {
        (void)POVMSAttrList_Delete(&attr);
        return NULL;
    }

    for (i = 1; i <= cnt; i++)
    {
        (void)POVMSAttr_New(&item);
        if(POVMSAttrList_GetNth(&attr, i, &item) != 0)
            continue;
        ll = 0;
        if(POVMSAttr_Size(&item, &ll) != 0)
        {
            (void)POVMSAttr_Delete(&item);
            continue;
        }
        if(ll <= 0)
        {
            (void)POVMSAttr_Delete(&item);
            continue;
        }
        if(POVMSAttr_Get(&item, kPOVMSType_CString, file, &ll) != 0)
        {
            (void)POVMSAttr_Delete(&item);
            continue;
        }
        (void)POVMSAttr_Delete(&item);

        file[strlen(file)+1] = '\0';
        if(file[strlen(file) - 1] != DRIVE_SEPARATOR)
            file[strlen(file)] = FILENAME_SEPARATOR;

        for(ii = 0; ii < 4; ii++)
        {
            if(l[ii])
            {
                strcpy(pathname, file);
                strcat(pathname, file_x[ii]);
                if(EXIST_FILE(pathname) == true)
                {
                    strcpy(buffer,pathname);
                    (void)POVMSAttrList_Delete(&attr);
                    return new ITextStream(pathname, stype);
                }
            }
        }
        strcpy(pathname, file);
        strcat(pathname, filename);
        if(EXIST_FILE(pathname) == true)
        {
            strcpy(buffer,pathname);
            (void)POVMSAttrList_Delete(&attr);
            return new ITextStream(pathname, stype);
        }
    }

    (void)POVMSAttrList_Delete(&attr);

    if(l[0])
        ParseError("Could not find file '%s%s'", filename, gPOV_File_Extensions[stype].ext[0]);
    else
        ParseError("Could not find file '%s'", filename);

    return NULL;
}
Пример #3
0
int Receive_RenderOptions(POVMSObjectPtr msg, POVMSObjectPtr result, int, void *)
{
   POVMSAttribute attr;
   POVMSInt i;
   POVMSFloat f;
   POVMSBool b;
   int l = 0;

   if(Cooperate_Render_Flag != 1)
      return -1;

   if(gStartedStreamMessage == NULL)
   {
      if(POVMSObject_New(&gStartedStreamMessageData, kPOVMSType_WildCard) == kNoErr)
         gStartedStreamMessage = &gStartedStreamMessageData;
   }

   l = sizeof(unsigned long);
   if(POVMSObject_Get(msg, &attr, kPOVAttrib_PreviewRefCon) == kNoErr)
   {
      (void)POVMSAttr_Get(&attr, kPOVMSType_WildCard, (void *)(&opts.Preview_RefCon), &l);
      (void)POVMSAttr_Delete(&attr);
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_WarningLevel, &i) == 0)
      opts.Warning_Level = i;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_Height, &i) == 0)
      Frame.Screen_Height = i;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_Width, &i) == 0)
      Frame.Screen_Width = i;
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_StartColumn, &f) == 0)
   {
      if(f >= 0.0 && f < 1.0)
      {
         opts.First_Column = -1;
         opts.First_Column_Percent = f;
      }
      else
         opts.First_Column = (int)f;
   }
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_EndColumn, &f) == 0)
   {
      if((f >= 0.0 && f < 1.0) || ((f >= 0.0 && f <= 1.0) && (opts.First_Column < 1)))
      {
         opts.Last_Column = -1;
         opts.Last_Column_Percent = f;
      }
      else
         opts.Last_Column = (int)f;
   }
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_StartRow, &f) == 0)
   {
      if(f >= 0.0 && f < 1.0)
      {
         opts.First_Line = -1;
         opts.First_Line_Percent = f;
      }
      else
         opts.First_Line = (int)f;
   }
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_EndRow, &f) == 0)
   {
      if((f >= 0.0 && f < 1.0) || ((f >= 0.0 && f <= 1.0) && (opts.First_Line < 1)))
      {
         opts.Last_Line = -1;
         opts.Last_Line_Percent = f;
      }
      else
         opts.Last_Line = (int)f;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_TestAbort, &b) == 0)
   {
      if(b == true)
         opts.Options |= EXITENABLE;
      else
         opts.Options &= ~EXITENABLE;
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_TestAbortCount, &i) == 0)
      opts.Abort_Test_Counter = i;
   if(POVMSUtil_GetBool(msg, kPOVAttrib_ContinueTrace, &b) == 0)
   {
      if(b == true)
         opts.Options |= CONTINUE_TRACE;
      else
         opts.Options &= ~CONTINUE_TRACE;
   }
   l = FILE_NAME_LENGTH;
   (void)POVMSUtil_GetString(msg, kPOVAttrib_CreateIni, opts.Ini_Output_File_Name, &l);
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_Clock, &f) == 0)
      opts.FrameSeq.Clock_Value = f;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_InitialFrame, &i) == 0)
      opts.FrameSeq.InitialFrame = i;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_FinalFrame, &i) == 0)
      opts.FrameSeq.FinalFrame = i;
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_InitialClock, &f) == 0)
      opts.FrameSeq.InitialClock = f;
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_FinalClock, &f) == 0)
      opts.FrameSeq.FinalClock = f;
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_SubsetStartFrame, &f) == 0)
   {
      if(f > 0.0 && f < 1.0)
         opts.FrameSeq.SubsetStartPercent = f;
      else
         opts.FrameSeq.SubsetStartFrame = (int)f;
   }
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_SubsetEndFrame, &f) == 0)
   {
      if(f > 0.0 && f < 1.0)
         opts.FrameSeq.SubsetEndPercent = f;
      else
         opts.FrameSeq.SubsetEndFrame = (int)f;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_CyclicAnimation, &b) == 0)
   {
      if(b == true)
         opts.Options |= CYCLIC_ANIMATION;
      else
         opts.Options &= ~CYCLIC_ANIMATION;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_FieldRender, &b) == 0)
      opts.FrameSeq.Field_Render_Flag = b;
   if(POVMSUtil_GetBool(msg, kPOVAttrib_OddField, &b) == 0)
      opts.FrameSeq.Odd_Field_Flag = b;
   if(POVMSUtil_GetBool(msg, kPOVAttrib_PauseWhenDone, &b) == 0)
   {
      if(b == true)
         opts.Options |= PROMPTEXIT;
      else
         opts.Options &= ~PROMPTEXIT;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_Verbose, &b) == 0)
   {
      if(b == true)
         opts.Options |= VERBOSE;
      else
         opts.Options &= ~VERBOSE;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_DrawVistas, &b) == 0)
   {
      if(b == true)
         opts.Options |= USE_VISTA_DRAW;
      else
         opts.Options &= ~USE_VISTA_DRAW;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_Display, &b) == 0)
   {
      if(b == true)
         opts.Options |= DISPLAY;
      else
         opts.Options &= ~DISPLAY;
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_VideoMode, &i) == 0)
      opts.DisplayFormat = (char)toupper(i);
   if(POVMSUtil_GetInt(msg, kPOVAttrib_Palette, &i) == 0)
      opts.PaletteOption = (char)toupper(i);
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_DisplayGamma, &f) == 0)
   {
      if(f > 0.0)
         opts.DisplayGamma = f;
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_PreviewStartSize, &i) == 0)
      opts.PreviewGridSize_Start = i;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_PreviewEndSize, &i) == 0)
      opts.PreviewGridSize_End = i;
   if(POVMSUtil_GetBool(msg, kPOVAttrib_OutputToFile, &b) == 0)
   {
      if(b == true)
         opts.Options |= DISKWRITE;
      else
         opts.Options &= ~DISKWRITE;
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_OutputFileType, &i) == 0)
      opts.OutputFormat = (char)tolower(i);
   if(POVMSUtil_GetInt(msg, kPOVAttrib_Compression, &i) == 0)
   {
      if(opts.OutputFormat == 'j')
      {
         opts.OutputQuality = i;
         opts.OutputQuality = max(0, opts.OutputQuality);
         opts.OutputQuality = min(100, opts.OutputQuality);
      }
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_OutputAlpha, &b) == 0)
   {
      if(b == true)
         opts.Options |= OUTPUT_ALPHA;
      else
         opts.Options &= ~OUTPUT_ALPHA;
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_BitsPerColor, &i) == 0)
   {
      if(opts.OutputFormat != 'j')
      {
         opts.OutputQuality = i;
         opts.OutputQuality = max(5, opts.OutputQuality);
         opts.OutputQuality = min(16, opts.OutputQuality);
      }
   }
   l = FILE_NAME_LENGTH;
   if(POVMSUtil_GetString(msg, kPOVAttrib_OutputFile, opts.Output_File_Name, &l) == 0)
   {
      if(!strcmp(opts.Output_File_Name, "-") || !strcmp(opts.Output_File_Name, "stdout"))
      {
         strcpy(opts.Output_File_Name, "stdout");
         opts.Options |= TO_STDOUT;
      }
   }
   l = FILE_NAME_LENGTH;
   opts.Ini_Output_File_Name[0] = '\0';
   (void)POVMSUtil_GetString(msg, kPOVAttrib_CreateIni, opts.Ini_Output_File_Name, &l);

#if PRECISION_TIMER_AVAILABLE
   if(POVMSUtil_GetBool(msg, kPOVAttrib_CreateHistogram, &b) == 0)
      opts.histogram_on = b;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_HistogramFileType, &i) == 0)
   {
      char *def_ext = NULL;

      switch(i)
      {
         case 'C':
         case 'c':
            opts.histogram_type = CSV;
    	    opts.histogram_file_type = NO_FILE; // CSV has special handling in histogram output, so this is correct [trf]
            def_ext = ".csv";
            break;
         case 'S':
         case 's':
            opts.histogram_type = SYS ;
    	    opts.histogram_file_type = SYS_FILE;
            def_ext = SYS_DEF_EXT;
            break ;
         case 'P' :
         case 'p' :
            opts.histogram_type = PPM;
    	    opts.histogram_file_type = PPM_FILE;
            def_ext = ".ppm";
            break;
         case 'T':
         case 't':
            opts.histogram_type = TARGA;
    	    opts.histogram_file_type = TGA_FILE;
            def_ext = ".tga";
            break;
         case 'N':
         case 'n':
            opts.histogram_type = PNG;
    	    opts.histogram_file_type = PNG_FILE;
            def_ext = ".png";
            break;
         default:
            opts.histogram_type = TARGA;
    	    opts.histogram_file_type = TGA_FILE;
            Warning(0, "Unknown histogram output type '%c'.", (char)i);
            break ;
      }

      // Process the histogram file name now, if it hasn't
      // yet been specified, and in case it isn't set later.
      if (opts.histogram_on && (opts.Histogram_File_Name[0] == '\0') && (def_ext != NULL))
         sprintf(opts.Histogram_File_Name, "histgram%s", def_ext);
   }
   l = FILE_NAME_LENGTH;
   if(POVMSUtil_GetString(msg, kPOVAttrib_HistogramFile, opts.Histogram_File_Name, &l) == 0)
   {
      if(opts.histogram_on && opts.Histogram_File_Name[0] == '\0')
      {
         char *def_ext = NULL;

         switch(opts.histogram_type)
         {
				case CSV:	 def_ext = ".csv"; break;
				case TARGA:  def_ext = ".tga"; break;
				case PNG:	 def_ext = ".png"; break;
				case PPM:	 def_ext = ".ppm"; break;
				case SYS:	 def_ext = SYS_DEF_EXT; break;
				case NONE:	 def_ext = ""; break;	/* To quiet warnings */
         }
         sprintf(opts.Histogram_File_Name, "histgram%s", def_ext);
      }
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_HistogramGridSizeX, &i) == 0)
      opts.histogram_x = i;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_HistogramGridSizeY, &i) == 0)
      opts.histogram_y = i;

#endif /* PRECISION_TIMER_AVAILABLE */
   (void)SetCommandOption(msg, kPOVAttrib_PreSceneCommand, &opts.Shellouts[PRE_SCENE_SHL]);
   (void)SetCommandOption(msg, kPOVAttrib_PreFrameCommand, &opts.Shellouts[PRE_FRAME_SHL]);
   (void)SetCommandOption(msg, kPOVAttrib_PostSceneCommand, &opts.Shellouts[POST_SCENE_SHL]);
   (void)SetCommandOption(msg, kPOVAttrib_PostFrameCommand, &opts.Shellouts[POST_FRAME_SHL]);
   (void)SetCommandOption(msg, kPOVAttrib_UserAbortCommand, &opts.Shellouts[USER_ABORT_SHL]);
   (void)SetCommandOption(msg, kPOVAttrib_FatalErrorCommand, &opts.Shellouts[FATAL_SHL]);
   l = FILE_NAME_LENGTH;
   if(POVMSUtil_GetString(msg, kPOVAttrib_InputFile, opts.Input_File_Name, &l) == 0)
   {
      if(!strcmp(opts.Input_File_Name, "-") || !strcmp(opts.Input_File_Name, "stdin"))
      {
         strcpy (opts.Input_File_Name, "stdin");
         opts.Options |= FROM_STDIN;
      }
   }
   if(POVMSObject_Get(msg, &attr, kPOVAttrib_LibraryPath) == 0)
   {
      int cnt = 0;

      if(POVMSAttrList_Count(&attr, &cnt) == 0)
      {
         POVMSAttribute item;
         int ii,iii;
         bool rem = false;

         for(ii = 1; ii <= cnt; ii++)
         {
            if(POVMSAttrList_GetNth(&attr, ii, &item) == 0)
            {
               l = 0;
               if(POVMSAttr_Size(&item, &l) == 0)
               {
                  if(l > 0)
                  {
                     if(opts.Library_Path_Index >= MAX_LIBRARIES)
                        Error ("Too many library directories specified.");
                     opts.Library_Paths[opts.Library_Path_Index] = (char *)POV_MALLOC(l, "library paths");
                     if(POVMSAttr_Get(&item, kPOVMSType_CString, opts.Library_Paths[opts.Library_Path_Index], &l) == 0)
                        rem = false;
                     else
                        rem = true;

                     // remove path again if the same one already exists
                     for(iii = 0; iii < opts.Library_Path_Index - 1; iii++)
                     {
                        if(strcmp(opts.Library_Paths[iii], opts.Library_Paths[opts.Library_Path_Index]) == 0)
                        {
                           rem = true;
                           break;
                        }
                     }

                     if(rem == true)
                     {
                        POV_FREE(opts.Library_Paths[opts.Library_Path_Index]);
                        opts.Library_Paths[opts.Library_Path_Index] = NULL;
                     }
                     else
                        opts.Library_Path_Index++;
                  }
               }
               (void)POVMSAttr_Delete(&item);
            }
         }
      }
      (void)POVMSAttr_Delete(&attr);
   }
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_Version, &f) == 0)
      opts.Language_Version = (int)(f * 100 + 0.5);

   (void)POVMSObject_Delete(gStartedStreamMessage);
   (void)POVMSObject_New(gStartedStreamMessage, kPOVMSType_WildCard);
   if(POVMSUtil_GetBool(msg, kPOVAttrib_AllConsole, &b) == 0)
   {
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_AllConsole, b);
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_DebugConsole, b);
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_FatalConsole, b);
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_RenderConsole, b);
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_StatisticsConsole, b);
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_WarningConsole, b);
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_DebugConsole, &b) == 0)
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_DebugConsole, b);
   if(POVMSUtil_GetBool(msg, kPOVAttrib_FatalConsole, &b) == 0)
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_FatalConsole, b);
   if(POVMSUtil_GetBool(msg, kPOVAttrib_RenderConsole, &b) == 0)
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_RenderConsole, b);
   if(POVMSUtil_GetBool(msg, kPOVAttrib_StatisticsConsole, &b) == 0)
      (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_StatisticsConsole, b);
   if(POVMSUtil_GetBool(msg, kPOVAttrib_WarningConsole, &b) == 0)
     (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_WarningConsole, b);
   for(i = 0; i < gStreamTypeUtilDataCount; i++)
   {
      l = 0;
      if(POVMSUtil_GetStringLength(msg, gStreamTypeUtilData[i], &l) == kNoErr)
      {
          char *str = (char *)POV_MALLOC(l, "stream name");

          if(POVMSUtil_GetString(msg, gStreamTypeUtilData[i], str, &l) == kNoErr)
          {
             if(l > 1)
             {
                if(IsTrue(str) == true)
                   (void)POVMSUtil_SetString(gStartedStreamMessage, gStreamTypeUtilData[i], gStreamDefaultFile[i]);
                else if(IsFalse(str) == false)
                   (void)POVMSUtil_SetString(gStartedStreamMessage, gStreamTypeUtilData[i], str);
             }
          }

          POV_FREE(str);
      }
   }

   if(POVMSUtil_GetInt(msg, kPOVAttrib_Quality, &i) == 0)
   {
      opts.Quality = i;
      /* Emit a warning about the "radiosity" quality levels for
       * now.   We can get rid of this some time in the future.
       */
      if ((opts.Quality == 10) || (opts.Quality == 11))
      {
         Warning(0, "Quality settings 10 and 11 are no longer valid.");
         opts.Quality = 9;
      }
      else if ((opts.Quality < 0) || (opts.Quality > 9))
          Error("Illegal Quality setting.");
      opts.Quality_Flags = Quality_Values[opts.Quality];
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_Bounding, &b) == 0)
      opts.Use_Slabs = b;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_BoundingThreshold, &i) == 0)
   {
      if(opts.BBox_Threshold < 1)
         Warning(0, "Too small bounding threshold adjusted to its minimum of one.");
      opts.BBox_Threshold = max(1, i);
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_LightBuffer, &b) == 0)
   {
      if(b == true)
         opts.Options |= USE_LIGHT_BUFFER;
      else
         opts.Options &= ~USE_LIGHT_BUFFER;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_VistaBuffer, &b) == 0)
   {
      if(b == true)
         opts.Options |= USE_VISTA_BUFFER;
      else
         opts.Options &= ~USE_VISTA_BUFFER;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_Radiosity, &b) == 0)
   {
      Warning(0, "Radiosity commandline/INI switch is not needed in POV-Ray 3.5.\n"
                 "Add a radiosity{}-block to your scene to turn on radiosity.");
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_RemoveBounds, &b) == 0)
   {
      if(b == true)
         opts.Options |= REMOVE_BOUNDS;
      else
         opts.Options &= ~REMOVE_BOUNDS;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_SplitUnions, &b) == 0)
   {
      if(b == true)
         opts.Options |= SPLIT_UNION;
      else
         opts.Options &= ~SPLIT_UNION;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_Antialias, &b) == 0)
   {
      if(b == true)
         opts.Options |= ANTIALIAS;
      else
         opts.Options &= ~ANTIALIAS;
   }
   if(POVMSUtil_GetInt(msg, kPOVAttrib_SamplingMethod, &i) == 0)
      opts.Tracing_Method = i;
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_AntialiasThreshold, &f) == 0)
      opts.Antialias_Threshold = f;
   if(POVMSUtil_GetInt(msg, kPOVAttrib_AntialiasDepth, &i) == 0)
   {
      opts.AntialiasDepth = i;
      if(opts.AntialiasDepth < 1)
         opts.AntialiasDepth = 1;
      if(opts.AntialiasDepth > 9)
         opts.AntialiasDepth = 9;
   }
   if(POVMSUtil_GetBool(msg, kPOVAttrib_Jitter, &b) == 0)
   {
      if(b == true)
         opts.Options |= JITTER;
      else
         opts.Options &= ~JITTER;
   }
   if(POVMSUtil_GetFloat(msg, kPOVAttrib_JitterAmount, &f) == 0)
   {
      opts.JitterScale = f;
      if(opts.JitterScale <= 0.0)
         opts.Options &= ~JITTER;
   }
   if(POVMSObject_Exist(msg, kPOVAttrib_IncludeHeader) == 0)
   {
      l = FILE_NAME_LENGTH;
      opts.Header_File_Name[0] = '\0';
      (void)POVMSUtil_GetString(msg, kPOVAttrib_IncludeHeader, opts.Header_File_Name, &l);
   }
   (void)POVMSObject_Get(msg, &opts.Declared_Variables, kPOVAttrib_Declare);

   if(result != NULL)
      (void)BuildRenderOptions(result);

   return 0;
}
Пример #4
0
int ProcessRenderOptions::WriteSpecialOptionHandler(INI_Parser_Table *option, POVMSObjectPtr obj, OTextStream *file)
{
    POVMSAttributeList list;
    POVMSFloat floatval;
    POVMSInt intval,intval2;
    int err = 0;
    int l;
    int i,imax;
    POVMSAttribute item;
    char *bufptr;
    char chr;

    switch(option->key)
    {
    case kPOVAttrib_HistogramGridSizeX:
        if(POVMSUtil_GetInt(obj, kPOVAttrib_HistogramGridSizeX, &intval) == 0)
        {
            if(POVMSUtil_GetInt(obj, kPOVAttrib_HistogramGridSizeY, &intval2) == 0)
                file->printf("%s=%d.%d\n", option->keyword, intval, intval2);
        }
        break;
    case kPOVAttrib_Palette:
    case kPOVAttrib_VideoMode:
    case kPOVAttrib_OutputFileType:
    case kPOVAttrib_HistogramFileType:
        if(POVMSUtil_GetInt(obj, option->key, &intval) == 0)
        {
            chr = intval;
            if(chr > 32)
                file->printf("%s=%c\n", option->keyword, chr);
        }
        break;
    case kPOVAttrib_IncludeIni:
        break;
    case kPOVAttrib_Declare:
        POVMSObject decobj;

        err = POVMSObject_Get(obj, &list, option->key);
        if(err != 0)
            break;

        l = 0;
        err = POVMSAttrList_Count(&list, &l);
        if(err != 0)
            break;
        if(l == 0)
            break;

        imax = l;
        for(i = 1; i <= imax; i++)
        {
            err = POVMSAttrList_GetNth(&list, i, &decobj);
            if(err == 0)
                err = POVMSObject_Get(&decobj, &item, kPOVAttrib_Identifier);
            if(err == 0)
            {
                l = 0;
                err = POVMSAttr_Size(&item, &l);
                if(l > 0)
                {
                    bufptr = new char[l];
                    bufptr[0] = 0;
                    if((POVMSUtil_GetFloat(&decobj, kPOVAttrib_Value, &floatval) == 0) &&
                            (POVMSAttr_Get(&item, kPOVMSType_CString, bufptr, &l) == 0))
                        file->printf("%s=%s=%g\n", option->keyword, bufptr, (float)floatval);
                    delete[] bufptr;
                }
                (void)POVMSAttr_Delete(&item);
            }
        }
        break;
    case kPOVAttrib_LibraryPath:
        err = POVMSObject_Get(obj, &list, option->key);
        if(err != 0)
            break;

        l = 0;
        err = POVMSAttrList_Count(&list, &l);
        if(err != 0)
            break;
        if(l == 0)
            break;

        imax = l;
        for(i = 1; i <= imax; i++)
        {
            err = POVMSAttrList_GetNth(&list, i, &item);
            if(err == 0)
            {
                l = 0;
                err = POVMSAttr_Size(&item, &l);
                if(l > 0)
                {
                    bufptr = new char[l];
                    bufptr[0] = 0;
                    if(POVMSAttr_Get(&item, kPOVMSType_CString, bufptr, &l) == 0)
                        file->printf("%s=\"%s\"\n", option->keyword, bufptr);
                    delete[] bufptr;
                }
                (void)POVMSAttr_Delete(&item);
            }
        }
        break;
    case kPOVAttrib_FatalErrorCommand:
    case kPOVAttrib_PostFrameCommand:
    case kPOVAttrib_PostSceneCommand:
    case kPOVAttrib_PreFrameCommand:
    case kPOVAttrib_PreSceneCommand:
    case kPOVAttrib_UserAbortCommand:
        POVMSObject cmdobj;

        err = POVMSObject_Get(obj, &cmdobj, option->key);
        if(err != 0)
            break;

        err = POVMSObject_Get(&cmdobj, &item, kPOVAttrib_CommandString);
        if(err == 0)
        {
            if(toupper(*(option->keyword + strlen(option->keyword) - 1)) == 'D')
            {
                l = 0;
                err = POVMSAttr_Size(&item, &l);
                if(l > 0)
                {
                    bufptr = new char[l];
                    bufptr[0] = 0;
                    if(POVMSAttr_Get(&item, kPOVMSType_CString, bufptr, &l) == 0)
                        file->printf("%s=%s\n", option->keyword, bufptr);
                    delete[] bufptr;
                }
            }
            else
            {
                if(POVMSUtil_GetInt(&cmdobj, kPOVAttrib_ReturnAction, &intval) == 0)
                {
                    if(intval < 0)
                    {
                        chr = -intval;
                        file->printf("%s=!%c\n", option->keyword, chr);
                    }
                    else
                    {
                        chr = intval;
                        file->printf("%s=%c\n", option->keyword, chr);
                    }
                }
            }
        }
        if(err == 0)
            err = POVMSObject_Delete(&cmdobj);
        break;
    }

    return err;
}