Beispiel #1
0
// ****************************************************************************
//
//  Function Name:	RMergeData::SaveFile( )
//
//  Description:		Save the data for this MergeData to the saved file
//
//  Returns:			Nothing
//
//  Exceptions:		None.
//
// ****************************************************************************
//
BOOLEAN RMergeData::SaveFile( )
	{
	//	If no file name choosen, call SaveAsFile
	if ( m_FileName.GetStringLength() == 0 )
		return SaveAsFile( );
	else
		{
		try
			{
			RStorage	storage( m_FileName, kReadWriteReplaceExisting );
			RMergeIterator	iterator		= GetMergeListStart( );
			RMergeIterator	iteratorEnd	= GetMergeListEnd( );

			//	Loop through and ask each entry to save itself
			for ( ; iterator != iteratorEnd; ++iterator )
				(*iterator)->Write( storage );
			}
		catch( YException exception )
			{
			::ReportException( exception );
			return FALSE;
			}
		catch( ... )
			{
			::ReportException( kUnknownError );
			return FALSE;
			}
		}

	return TRUE;
	}
Beispiel #2
0
void FormEdit::SaveFile()
{
	if (!_View.IsLayout())
		return;

	UpdateChildZ();

	if (_File.IsEmpty())
		SaveAsFile();
	else
	{
		bool compression = false;
		if (Upp::GetFileName(_File).Find(".fz") >= 0)
			compression = true;
		_View.SaveAll(_File, compression);
		ProjectSaved(true);
	}
}
Beispiel #3
0
int SaveXmlDocAsFile(xmlDocPtr doc, const char *file, Attributes a)
{
    return SaveAsFile(&SaveXmlCallback, doc, file, a);
}
Beispiel #4
0
/*>HandleEvent(APTR object)
   ------------------------
   Dispatch menu events.
   12.03.92 Original.
   30.03.92 Modified MenuEdit to call OpenFile() directly.
   31.03.92 Modified MenuSave to call SaveAsFile() directly.
   05.05.92 Added Rexx menu handling
   12.06.92 Removed fill grey/hatch items and replaced with requester
   02.07.92 Added MenuPalette
   13.07.92 Added MenuScrBack
   20.07.92 Added DEMO_VERSION conditional
   07.08.92 Added RemoveFills()
*/
HandleEvent(APTR object)
{
   if(object == (APTR)MenuOpen)     { OpenFile(object);        return(0); }
   if(object == (APTR)MenuSave)     { SaveAsFile(object);      return(0); }
   if(object == (APTR)MenuSaveAs)   { SaveAsFile(object);      return(0); }
   if(object == (APTR)MenuEdit)     { OpenFile(object);        return(0); }
   if(object == (APTR)MenuPaper)    { SetPaper(object);        return(0); }
   if(object == (APTR)MenuSetPens)  { SetPens(object);         return(0); }
   if(object == (APTR)MenuPalette)  { SetPalette(object);      return(0); }
   if(object == (APTR)MenuScrBack)  { ScreenToBack(MyScreen);  return(0); }
   if(object == (APTR)MenuAbout)    { About(object);           return(0); }
   if(object == (APTR)MenuQuit)     { QuitProgram(object);     return(0); }
#ifndef DEMO_VERSION
   if(object == (APTR)MenuPS)       { PlotPS(object);          return(0); }
   if(object == (APTR)MenuHPGL)     { PlotHPGL(object);        return(0); }
   if(object == (APTR)MenuDR2D)     { PlotDR2D(object);        return(0); }
#endif
   if(object == (APTR)MenuXY)       { StyleXY(object);         return(0); }
   if(object == (APTR)MenuScatter)  { StyleScatter(object);    return(0); }
   if(object == (APTR)MenuBar)      { StyleBar(object);        return(0); }
   if(object == (APTR)MenuPie)      { StylePie(object);        return(0); }
   if(object == (APTR)MenuErrors)   { ToggleErrors(object);    return(0); }
   if(object == (APTR)MenuEject)    { EjectSlice(object);      return(0); }
   if(object == (APTR)MenuLineSet)  { SetLine(object);         return(0); }
   if(object == (APTR)MenuBarSet)   { SetBar(object);          return(0); }
   if(object == (APTR)MenuPieSet)   { SetPie(object);          return(0); }
   if(object == (APTR)MenuLogX)     { ToggleLogX(object);      return(0); }
   if(object == (APTR)MenuLogY)     { ToggleLogY(object);      return(0); }
   if(object == (APTR)MenuBoxed)    { ToggleBoxed(object);     return(0); }
   if(object == (APTR)MenuGrid)     { ToggleGrid(object);      return(0); }
   if(object == (APTR)MenuAxes)     { SetAxes(object);         return(0); }
   if(object == (APTR)MenuFZero)    { ToggleFZero(object);     return(0); }
   if(object == (APTR)MenuTitle)    { SetTitle(object);        return(0); }
   if(object == (APTR)MenuAxTitle)  { SetAxTitle(object);      return(0); }
   if(object == (APTR)MenuAxLabel)  { SetAxLabel(object);      return(0); }
   if(object == (APTR)MenuKey)      { SetKey(object);          return(0); }
   if(object == (APTR)MenuLabel)    { SetLabel(object);        return(0); }
   if(object == (APTR)MenuPen)      { ChangePen(object);       return(0); }
   if(object == (APTR)MenuFillType) { FillControl(object);     return(0); }
   if(object == (APTR)MenuRegress)  { SetRegress(object);      return(0); }
   if(object == (APTR)MenuRobust)   { ToggleRobust(object);    return(0); }
   if(object == (APTR)MenuFourier)  { SetFourier(object);      return(0); }
   if(object == (APTR)MenuRexxFit)  { RexxFit(object);         return(0); }
   if(object == (APTR)MenuRexx)     { InstallMacro(object);    return(0); }
   if(object == (APTR)MenuRunRexx)  { RunMacro(object);        return(0); }
   if(object == (APTR)MenuDebRexx)  { ToggleRexxDeb(object);   return(0); }
   if(object == (APTR)MenuLS1)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS2)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS3)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS4)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS5)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuLS6)      { SetLineDash(object);     return(0); }
   if(object == (APTR)MenuFT1)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT2)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT3)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT4)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT5)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuFT6)      { SetFillType(object);     return(0); }
   if(object == (APTR)MenuNoFills)  { RemoveFills(object);     return(0); }

   return(0);
}
Beispiel #5
0
int SaveXmlDocAsFile(EvalContext *ctx, xmlDocPtr doc, const char *file, Attributes a, Promise *pp)
{
    return SaveAsFile(ctx, &SaveXmlCallback, doc, file, a, pp);
}
Beispiel #6
0
int main(int argc, char *argv[])
{
    if (argc < 6)
    {
        printf("Usage: image mask start end output\n");
        return -1;
    }

    IplImage *srcMask, *dstMask;
    char *imgPattern = argv[1];
    char *maskPattern = argv[2];
    int s = atoi(argv[3]);
    int e = atoi(argv[4]);
    char *output = argv[5];
    char name[256];
    int imgCount;
    BiImage sift1, sift2, src, dst, tmp;
    
    snprintf(name, 256, imgPattern, s);
    ImageIO::LoadImage(name, src);
    ExtractSIFT(src, sift1);

    snprintf(name, 256, maskPattern, s);
    srcMask = cvLoadImage(name, CV_LOAD_IMAGE_GRAYSCALE);

    int width = src.width();
    int height = src.height();
    int channels = src.nchannels();
    IntImage fv(0, width, height, 2);

    for (imgCount = s + 1; imgCount <= e; imgCount++)
    {
        snprintf(name, 256, imgPattern, imgCount);
        printf("processing %s...\n", name);

        ImageIO::LoadImage(name, dst);
        ExtractSIFT(dst, sift2);

        snprintf(name, 256, maskPattern, imgCount);
        dstMask = cvLoadImage(name, CV_LOAD_IMAGE_GRAYSCALE);

        // layer flow
        snprintf(name, 256, "%s_%d", output, imgCount);
        LayerFlow(sift1, sift2, fv, srcMask, dstMask, name);

        // save flow vector to image
        tmp.setValue(0, width, height, channels);
        FlowColorImage(fv, tmp);
        
        snprintf(name, 256, "%s_fv_%d.bmp", output, imgCount);
        ImageIO::WriteImage(name, tmp);
        tmp.clear();
        
        // save flow vector to file
        snprintf(name, 256, "%s_fv_%d.dat", output, imgCount);
        SaveAsFile(fv.data(), width, height, 2, name);

        // warp image
        tmp.setValue(0, width, height, 3);
        WarpImage(src, fv, tmp);
        snprintf(name, 256, "%s_warp_nobg_%d.bmp", output, imgCount);
        ImageIO::WriteImage(name, tmp);
        tmp.clear();
        
        WarpImage(src, fv, dst);
        src = dst;
        snprintf(name, 256, "%s_warp_%d.bmp", output, imgCount);
        ImageIO::WriteImage(name, src);
        dst.clear();
        
        // warp sift image
        WarpImage(sift1, fv, sift2);
        sift1 = sift2;
        sift2.clear();
        
        cvReleaseImage(&srcMask);
        srcMask = cvCloneImage(dstMask);
        cvReleaseImage(&dstMask);
    }

    cvReleaseImage(&srcMask);

	return 0;
}
Beispiel #7
0
static PromiseResult RenderTemplateMustache(EvalContext *ctx, const Promise *pp, Attributes a,
                                            EditContext *edcontext)
{
    PromiseResult result = PROMISE_RESULT_NOOP;

    if (!FileCanOpen(a.edit_template, "r"))
    {
        cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Template file '%s' could not be opened for reading", a.edit_template);
        return PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
    }

    unsigned char existing_output_digest[EVP_MAX_MD_SIZE + 1] = { 0 };
    if (access(pp->promiser, R_OK) == 0)
    {
        HashFile(pp->promiser, existing_output_digest, CF_DEFAULT_DIGEST);
    }

    int template_fd = safe_open(a.edit_template, O_RDONLY | O_TEXT);
    Writer *template_writer = NULL;
    if (template_fd >= 0)
    {
        template_writer = FileReadFromFd(template_fd, SIZE_MAX, NULL);
        close(template_fd);
    }
    if (!template_writer)
    {
        cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Could not read template file '%s'", a.edit_template);
        return PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
    }

    JsonElement *default_template_data = NULL;
    if (!a.template_data)
    {
        a.template_data = default_template_data = DefaultTemplateData(ctx);
    }

    Buffer *output_buffer = BufferNew();
    if (MustacheRender(output_buffer, StringWriterData(template_writer), a.template_data))
    {
        unsigned char rendered_output_digest[EVP_MAX_MD_SIZE + 1] = { 0 };
        HashString(BufferData(output_buffer), BufferSize(output_buffer), rendered_output_digest, CF_DEFAULT_DIGEST);
        if (!HashesMatch(existing_output_digest, rendered_output_digest, CF_DEFAULT_DIGEST))
        {
            if (SaveAsFile(SaveBufferCallback, output_buffer, edcontext->filename, a, edcontext->new_line_mode))
            {
                cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Updated rendering of '%s' from template mustache template '%s'",
                     pp->promiser, a.edit_template);
                result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
            }
            else
            {
                cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_FAIL, pp, a, "Updated rendering of '%s' from template mustache template '%s'",
                     pp->promiser, a.edit_template);
                result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
            }
        }

        JsonDestroy(default_template_data);
        WriterClose(template_writer);
        BufferDestroy(output_buffer);

        return result;
    }
    else
    {
        cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Error rendering mustache template '%s'", a.edit_template);
        result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
        JsonDestroy(default_template_data);
        WriterClose(template_writer);
        BufferDestroy(output_buffer);
        return PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
    }
}
Beispiel #8
0
int SaveXmlDocAsFile(xmlDocPtr doc, const char *file, Attributes a, Promise *pp,
                       const ReportContext *report_context)
{
    return SaveAsFile(&SaveXmlCallback, doc, file, a, pp, report_context);
}