Пример #1
0
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
	setupUi(this);

	frameSlider->setPageStep(1);
	frameSlider->setSingleStep(1);
	
	connect(actionOpen, SIGNAL(triggered()), this, SLOT(fileOpen()));
	connect(actionPangolin_palette, SIGNAL(triggered()), SLOT(usePangolinPalette()));
	connect(actionILDA_palette, SIGNAL(triggered()), SLOT(useILDAPalette()));
	connect(actionAbout, SIGNAL(triggered()), SLOT(about()));
	
	QGraphicsScene *scene = new QGraphicsScene();
	_noFileLoadedItem = scene->addText(tr("No ILDA sequence loaded"));		
	graphicsView->setScene(scene);

	_ildaPalette = loadPalette(":/data/ilda.palette");
	_pangolinPalette = loadPalette(":/data/pangolin.palette");
	_currentPalette = &_ildaPalette;

	readSettings();
}
Пример #2
0
static void loadTitleCodeSection(u64 progId, u8 *code, u32 size)
{
    /* Here we look for "/puma/code_sections/[u64 titleID in hex, uppercase].bin"
       If it exists it should be a decompressed binary code file */

    char path[] = "/puma/code_sections/0000000000000000.bin";
    progIdToStr(path + 35, progId);

    IFile file;

    if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ)))
    {
        u64 fileSize;

        if(R_SUCCEEDED(IFile_GetSize(&file, &fileSize)) && fileSize <= size)
        {
            u64 total;
            IFile_Read(&file, &total, code, fileSize);
        }

        IFile_Close(&file);
    }
}
Пример #3
0
Файл: fs.c Проект: bhanug/harvey
static int
fsEsearch(Fs *fs, char *path, uint32_t savetime, uint32_t *plo)
{
	int n;
	File *f;
	DirEntry de;

	f = fileOpen(fs, path);
	if(f == nil)
		return 0;
	if(!fileGetDir(f, &de)){
		fileDecRef(f);
		return 0;
	}
	if((de.mode & ModeDir) == 0){
		fileDecRef(f);
		deCleanup(&de);
		return 0;
	}
	deCleanup(&de);
	n = fsEsearch1(f, path, savetime, plo);
	fileDecRef(f);
	return n;
}
Пример #4
0
void SimpleUI::setupActions()
{
    KStdAction::open( napp, SLOT(fileOpen()), actionCollection(), "_file_open" );
    new KAction( i18n("&Properties"), 0, propertiesDialog, SLOT(show()),
        actionCollection(), "_file_properties" );
    KStdAction::quit( napp, SLOT(quit()), actionCollection(), "_file_quit");

     NoatunStdAction::playlist( actionCollection(), "view_playlist" );
    actionCollection()->insert(video->action( "half_size" ));
    actionCollection()->insert(video->action( "normal_size" ));
    actionCollection()->insert(video->action( "double_size" ));
    actionCollection()->insert(video->action( "fullscreen_mode" ));

    actionCollection()->insert(napp->pluginActionMenu());

    menubarAction = KStdAction::showMenubar(this, SLOT(showMenubar()),
        actionCollection());
    statusbarAction = KStdAction::showStatusbar(this, SLOT(showStatusbar()),
        actionCollection());
    NoatunStdAction::effects( actionCollection(), "effects" );
    NoatunStdAction::equalizer( actionCollection(), "equalizer" );
    NoatunStdAction::loop( actionCollection(), "loop_style" );
    KStdAction::preferences( napp, SLOT(preferences()), actionCollection() );
}
Пример #5
0
/**
 * Shell command (delete) deletes existing files.
 * @param args array of arguments
 * @return OK for success, SYSERR for syntax error
 */
command xsh_delete(int nargs, char *args[])
{
    int fd = 0;
    char c = 0;

    /* Output help, if '--help' argument was supplied */
    if ((nargs == 2 && strncmp(args[1], "--help", 6) == 0) || (nargs != 2))
    {
        printf("Usage: delete [filename]\n");
        printf("Print file contents or copy console input into new file.\n");
        printf("\t--help\t display this help and exit\n");

        return OK;
    }
    fd = fileOpen(args[1]);
    if (SYSERR == fd)
    {
	printf("File \"%s\" not found.\n", args[1]);
	return OK;
    }
    fileDelete(fd);

    return OK;
}
Пример #6
0
void TextEdit::setupFileActions()
{
    QToolBar *tb = new QToolBar( this );
    tb->setLabel( "File Actions" );
    QPopupMenu *menu = new QPopupMenu( this );
    menuBar()->insertItem( tr( "&File" ), menu );

    QAction *a;
    a = new QAction( QPixmap::fromMimeSource( "filenew.xpm" ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
    connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
    a->addTo( tb );
    a->addTo( menu );
    a = new QAction( QPixmap::fromMimeSource( "fileopen.xpm" ), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
    connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
    a->addTo( tb );
    a->addTo( menu );
    menu->insertSeparator();
    a = new QAction( QPixmap::fromMimeSource( "filesave.xpm" ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
    connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
    a->addTo( tb );
    a->addTo( menu );
    a = new QAction( tr( "Save &As..." ), 0, this, "fileSaveAs" );
    connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
    a->addTo( menu );
    menu->insertSeparator();
    a = new QAction( QPixmap::fromMimeSource( "fileprint.xpm" ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
    connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
    a->addTo( tb );
    a->addTo( menu );
    a = new QAction( tr( "&Close" ), 0, this, "fileClose" );
    connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
    a->addTo( menu );
    a = new QAction( tr( "E&xit" ), 0, this, "fileExit" );
    connect( a, SIGNAL( activated() ), this, SLOT( fileExit() ) );
    a->addTo( menu );
}
Пример #7
0
  VOID cCELL_OFF_WRITER::MergeGridMeshFiles(INT cellIndex)
  {
	FILE *offGridFile = fileOpen(cellIndex, "grid.off", "rb");
	FILE *mapGridFile = fileOpen(cellIndex, "grid.map", "rb");
	FILE *offMeshFile = fileOpen(cellIndex, "mesh.off", "rb");
	FILE *mapMeshFile = fileOpen(cellIndex, "mesh.map", "rb");
	if (offGridFile == NULL || offMeshFile == NULL)
	  return;
	//map files may be empty, in which case map file is not generated

	cOFF_READER gridFileReader(offGridFile, mapGridFile);
	cOFF_READER meshFileReader(offMeshFile, mapMeshFile);
	gridFileReader.Import();
	meshFileReader.Import();
	FILE *offMergedFile = fileOpen(cellIndex, "merged.off", "wb");
	FILE *mapMergedFile = fileOpen(cellIndex, "merged.map", "wb");
	WriteMergedGridMeshFiles(gridFileReader, meshFileReader, offMergedFile, mapMergedFile);
	fclose(offMergedFile);
	fclose(mapMergedFile);
	fclose(offGridFile);
	fclose(offMeshFile);
	fclose(mapGridFile);
	fclose(mapMeshFile);
  }
Пример #8
0
static void soundPlay(struct Sound *s,char *filename,int fileofs,int filesize,int loop)
{
    // read sound file header
    int err;
    fileHandle fh=0;
    long fsize;
    #define HEADSIZE 78
    unsigned char buf[HEADSIZE];
    memset(buf,0,HEADSIZE);
#ifdef EXTENDFILE
    rfSuperStart=fileofs;
    rfSuperSize=filesize;
#endif
    s->loop=loop;
    #define MCALL1(f) err=f;if(err) {reportErr(err); return;}
    #define MCALL2(f) err=f;if(err) {reportErr(err); err=fileClose(fh); if(err) reportErr(err); return;}
    MCALL1(fileOpen(filename,fileOpenRead,&fh));
    MCALL2(fileGetSize(fh,&fsize));
    MCALL2(fileRead(fh,buf,fsize<HEADSIZE?fsize:HEADSIZE));
    MCALL1(fileClose(fh));
    // analyze sound file header
    // waw sample? starts with "RIFF" with fmt!=55h
    if (buf[0]=='R' && buf[1]=='I' && buf[2]=='F' && buf[3]=='F' /*&& buf[8]=='W' && buf[9]=='A' && buf[10]=='V' && buf[11]=='E'*/  && buf[20]!=0x55)
    {
        extern int lastWAVfreq;
        s->type=Sample;
        s->datahandle=(int)MIDASloadWaveSample(filename,loop?MIDAS_LOOP_YES:MIDAS_LOOP_NO);
        if(s->datahandle) s->playhandle=(int)MIDASplaySample((MIDASsample)s->datahandle,MIDAS_CHANNEL_AUTO,0/*priority*/,lastWAVfreq,64,MIDAS_PAN_MIDDLE);
    }
#ifdef EXTENDFILE
    // iff sample with 0x16 characters long name? (FT2 makes them)
    // it isn't ment as IFF support, just quick 99% working hack
    else if (buf[0]=='F' && buf[1]=='O' && buf[2]=='R' && buf[3]=='M' && buf[8]=='8' && buf[9]=='S' && buf[10]=='V' && buf[11]=='X' && buf[12]=='N' && buf[13]=='A' && buf[14]=='M' && buf[15]=='E' && buf[16]==0 && buf[17]==0 && buf[18]==0 && buf[19]==0x16)
    {
        int rate=(buf[62]<<8)+buf[63];
        rfSuperStart+=78;
        rfSuperSize=MIN(fsize-78,(buf[74]<<24)+(buf[75]<<16)+(buf[76]<<8)+buf[77]);
        rfSuperXor=128;
        s->type=Sample;
        s->datahandle=(int)MIDASloadRawSample(filename,MIDAS_SAMPLE_8BIT_MONO,loop?MIDAS_LOOP_YES:MIDAS_LOOP_NO);
        if(s->datahandle) s->playhandle=(int)MIDASplaySample((MIDASsample)s->datahandle,MIDAS_CHANNEL_AUTO,0/*priority*/,rate,64,MIDAS_PAN_MIDDLE);
    }
#endif
    // mp3 stream? starts with FF Fx or FF Ex or "ID3" or "RIFF" with fmt=55h
    else if ( (buf[0]==0xff && (buf[1] & 0xe0)==0xe0)
           || (buf[0]=='I' && buf[1]=='D' && buf[2]=='3')
           || (buf[0]=='R' && buf[1]=='I' && buf[2]=='F' && buf[3]=='F' && buf[20]==0x55) )
    {
        int rate,stereo;
        s->type=Stream;
        s->datahandle=(int)MP3open(filename,fileofs,filesize,&rate,&stereo,errAdd);
        if(s->datahandle) s->playhandle=(int)MIDASplayStreamPolling(stereo?MIDAS_SAMPLE_16BIT_STEREO:MIDAS_SAMPLE_16BIT_MONO,rate,1000*MP3PRECALCSEC);
        s->bufferbytes=rate*(stereo?4:2)*MP3PRECALCSEC;
    }
    // maybe module?
    else
    {
        s->type=Module;
        s->datahandle=(int)MIDASloadModule(filename);
        if(s->datahandle) s->playhandle=(int)MIDASplayModule((MIDASmodule)s->datahandle,loop);
    }
#ifdef EXTENDFILE
    rfSuperStart=0;
    rfSuperSize=0;
    rfSuperXor=0;
#endif
    MIDASreportErr();
}
Пример #9
0
void TaskJuggler::setupActions()
{
    // "File" menu
    KStdAction::openNew(this, SLOT(fileNew()), actionCollection());
    new KAction(i18n("New &Include File" ), "file_temporary", KShortcut(),
                this, SLOT(fileNewInclude()),
                actionCollection(), "new_include");
    KStdAction::open(this, SLOT(fileOpen()), actionCollection());
    KStdAction::close(this, SLOT(fileClose()), actionCollection());
    KStdAction::print(this, SLOT(filePrint()), actionCollection());
    KStdAction::quit(kapp, SLOT(closeAllWindows()), actionCollection());

    // Setup "Open Recent" menu and load old recent files.
    m_recentAction = KStdAction::openRecent(this, SLOT(load(const KURL&)),
                                            actionCollection());


    // "Goto" menu
    new KAction(i18n("Tas&ks"), "tj_task_group", KShortcut(KKey("ALT+k")),
                m_view, SLOT(setFocusToTaskList()),
                actionCollection(), "tasks");
    new KAction(i18n("&Resources"), "tj_resource_group",
                KShortcut(KKey("ALT+r")),
                m_view, SLOT(setFocusToResourceList()),
                actionCollection(), "resources");
    new KAction(i18n("&Accounts"), "tj_account_group",
                KShortcut(KKey("ALT+a")),
                m_view, SLOT(setFocusToAccountList()),
                actionCollection(), "accounts");
    new KAction(i18n("Re&ports"), "tj_report_list", KShortcut(KKey("ALT+p")),
                m_view, SLOT(setFocusToReportList()),
                actionCollection(), "reports");
    new KAction(i18n("F&iles"), "tj_file_list", KShortcut(KKey("ALT+i")),
                m_view, SLOT(setFocusToFileList()),
                actionCollection(), "files");
    new KAction(i18n("E&ditor"), "tj_editor", KShortcut("ALT+d"),
                m_view, SLOT(setFocusToEditor()),
                actionCollection(), "editor");
    new KAction(i18n("Rep&ort"), "tj_report", KShortcut("ALT+o"),
                m_view, SLOT(setFocusToReport()),
                actionCollection(), "report");

    // "Tools" menu
    new KAction(i18n("&Schedule"), "tj_schedule", KShortcut(KKey("F9")),
                m_view, SLOT(schedule()),
                actionCollection(), "schedule");
    new KAction(i18n("Stop scheduling"), "stop", 0,
                m_view, SLOT(stop()),
                actionCollection(), "stop");
    new KAction(i18n("&Generate all Reports"), 0, 0,
                m_view, SLOT(generate()),
                actionCollection(), "generate");
    new KAction(i18n("Goto &previous Problem"), "tj_previous_problem",
                KShortcut(KKey("F10")),
                m_view, SLOT(previousProblem()),
                actionCollection(), "previous_problem");
    new KAction(i18n("Goto &next Problem"), "tj_next_problem",
                KShortcut(KKey("F11")),
                m_view, SLOT(nextProblem()),
                actionCollection(), "next_problem");

    new KAction(i18n("Zoom &In"), "viewmag+", KShortcut(KKey("F7")),
                m_view, SLOT(zoomIn()),
                actionCollection(), "zoom_in");
    new KAction(i18n("Zoom &Out"), "viewmag-", KShortcut(KKey("F8")),
                m_view, SLOT(zoomOut()),
                actionCollection(), "zoom_out");

    // "Help" menu
    new KAction(i18n("Tip of the day"), "idea", 0, this,
                SLOT(showTip()), actionCollection(), "tip");
    new KAction(i18n("Explain Keyword"), "tj_keyword_help",
                KShortcut(KKey("F2")),
                m_view, SLOT(keywordHelp()),
                actionCollection(), "keyword_help");
    new KAction(i18n("Tutorial"), "tj_tutorial", 0,
                m_view, SLOT(tutorial()),
                actionCollection(), "tutorial");

    setupGUI(ToolBar | Keys | StatusBar | Save | Create);
}
Пример #10
0
void TextEdit::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    a = new QAction(QIcon(rsrcPath + "/filenew.png"), tr("&New"), this);
    a->setShortcut(QKeySequence::New);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/fileopen.png"), tr("&Open..."), this);
    a->setShortcut(QKeySequence::Open);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    actionSave = a = new QAction(QIcon(rsrcPath + "/filesave.png"), tr("&Save"), this);
    a->setShortcut(QKeySequence::Save);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(tr("Save &As..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
    menu->addAction(a);
    menu->addSeparator();

#ifndef QT_NO_PRINTER
    a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("&Print..."), this);
    a->setShortcut(QKeySequence::Print);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("Print Preview..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/exportpdf.png"), tr("&Export PDF..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_D);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();
#endif

    a = new QAction(tr("&Quit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(a, SIGNAL(triggered()), this, SLOT(close()));
    menu->addAction(a);
}
Пример #11
0
QMenus::QMenus(QWidget *parent) 
    : QMainWindow(parent, 0) // QMainWindow's default flag is WType_TopLevel
{
    QAction *action;

    QMenu *file = new QMenu(this);

    action = new QAction(QPixmap((const char**)fileopen), "&Open", this);
    action->setShortcut(tr("CTRL+O"));
    connect(action, SIGNAL(triggered()), this, SLOT(fileOpen()));
    file->addAction(action);

    action = new QAction(QPixmap((const char**)filesave),"&Save", this);
    action->setShortcut(tr("CTRL+S"));
    connect(action, SIGNAL(triggered()), this, SLOT(fileSave()));
    file->addAction(action);

    QMenu *edit = new QMenu(this);

    action = new QAction("&Normal", this);
    action->setShortcut(tr("CTRL+N"));
    action->setToolTip("Normal");
    action->setStatusTip("Toggles Normal");
    action->setCheckable(true);
    connect(action, SIGNAL(triggered()), this, SLOT(editNormal()));
    edit->addAction(action);

    action = new QAction("&Bold", this);
    action->setShortcut(tr("CTRL+B"));
    action->setCheckable(true);
    connect(action, SIGNAL(triggered()), this, SLOT(editBold()));
    edit->addAction(action);

    action = new QAction("&Underline", this);
    action->setShortcut(tr("CTRL+U"));
    action->setCheckable(true);
    connect(action, SIGNAL(triggered()), this, SLOT(editUnderline()));
    edit->addAction(action);

    QMenu *advanced = new QMenu(this);
    action = new QAction("&Font...", this);
    connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedFont()));
    advanced->addAction(action);

    action = new QAction("&Style...", this);
    connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedStyle()));
    advanced->addAction(action);

    edit->addMenu(advanced)->setText("&Advanced");

    edit->addSeparator();

    action = new QAction("Una&vailable", this);
    action->setShortcut(tr("CTRL+V"));
    action->setCheckable(true);
    action->setEnabled(false);
    connect(action, SIGNAL(triggered()), this, SLOT(editUnderline()));
    edit->addAction(action);

    QMenu *help = new QMenu(this);

    action = new QAction("&About...", this);
    action->setShortcut(tr("F1"));
    connect(action, SIGNAL(triggered()), this, SLOT(helpAbout()));
    help->addAction(action);

    action = new QAction("&About Qt...", this);
    connect(action, SIGNAL(triggered()), this, SLOT(helpAboutQt()));
    help->addAction(action);

    if (!QAxFactory::isServer())
        menuBar()->addMenu(file)->setText("&File");
    menuBar()->addMenu(edit)->setText("&Edit");
    menuBar()->addMenu(help)->setText("&Help");

    editor = new QTextEdit(this);
    setCentralWidget(editor);

    statusBar();
}
Пример #12
0
void hrChooseRandomBitmap(char *pFilenameBuffer)
{
#ifdef _WIN32
    struct _finddata_t  FindData;
    long hFind;
#else
    DIR *dp;
    struct dirent* dir_entry;
    FILE* fp;
#endif
    filehandle handle;
    long userScreenShotCount = 0, BigFileCount = 0,
         chosenFileIndex = 0, currentFileIndex = 0, Result;
    char BigName[PATH_MAX], CurDir[PATH_MAX], NewDir[PATH_MAX];

    // Remember the current directory
    getcwd(CurDir, PATH_MAX);

    NewDir[0] = 0;
    strcpy(NewDir, filePathPrepend("ScreenShots", FF_UserSettingsPath));

    // Prefer user screenshots over pre-saved ones; they're more likely to be 
    // at a higher resolution, not to mention more interesting...

    // Switch to the screenshots directory and count the ones in there
    /*SetCurrentDirectory(NewDir);*/
    chdir(NewDir);
#ifdef _WIN32
    hFind = _findfirst("*.jpg", &FindData);
    if(hFind != -1)
    {
        do {
            if( ((FindData.attrib & _A_SUBDIR) == 0) &&
                ((FindData.attrib & _A_HIDDEN) == 0) )
                userScreenShotCount++;
        } while (_findnext(hFind, &FindData) == 0);
        _findclose(hFind);
    }
#else
    dp = opendir(".");

    if (dp)
    {
        unsigned int dir_str_len;

        while ((dir_entry = readdir(dp)))
        {
            if (dir_entry->d_name[0] == '.')
                continue;
            dir_str_len = strlen(dir_entry->d_name);
            if (dir_str_len < 4 ||
                strcasecmp(dir_entry->d_name + dir_str_len - 4, ".jpg"))
                continue;

            /* See if the current process can actually open the file (simple
               check for read permissions and if it's a directory). */
            if (!(fp = fopen(dir_entry->d_name, "rb")))
                continue;
            fclose(fp);

            userScreenShotCount++;
        }

        closedir(dp);
    }
#endif

    if (userScreenShotCount > 0)
    {
        chosenFileIndex = (utyTimerLast % 32777) % userScreenShotCount;

#ifdef _WIN32
        hFind = _findfirst("*.jpg", &FindData);
        if(hFind != -1)
        {
            do {
                if( ((FindData.attrib & _A_SUBDIR) == 0) &&
                    ((FindData.attrib & _A_HIDDEN) == 0) )
                {
                    if(currentFileIndex == chosenFileIndex)
                    {
                        _findclose(hFind);
                        strcpy(pFilenameBuffer, filePathPrepend("ScreenShots\\", FF_UserSettingsPath));
                        strcat(pFilenameBuffer, FindData.name);
                        break;
                    }
                    else
                        currentFileIndex++;
                }
            } while (_findnext(hFind, &FindData) == 0);
        }
#else
        dp = opendir(".");

        if (dp)
        {
            unsigned int dir_str_len;

            while ((dir_entry = readdir(dp)))
            {
                if (dir_entry->d_name[0] == '.')
                    continue;
                dir_str_len = strlen(dir_entry->d_name);
                if (dir_str_len < 4 ||
                    strcasecmp(dir_entry->d_name + dir_str_len - 4, ".jpg"))
                    continue;
                if (!(fp = fopen(dir_entry->d_name, "rb")))
                    continue;
                fclose(fp);

                if (currentFileIndex != chosenFileIndex)
                {
                    currentFileIndex++;
                    continue;
                }

                strcat(pFilenameBuffer, filePathPrepend("ScreenShots/", FF_UserSettingsPath));
                strcat(pFilenameBuffer, dir_entry->d_name);
                
                break;
            }

            closedir(dp);
        }
#endif
    }
    else // look in the big file for fallback images
    {   
        // First, find screen shots listed in the BigFile
#ifdef _WIN32
        handle = fileOpen("ScreenShots\\ShotList.script", FF_ReturnNULLOnFail | FF_TextMode);
#else
        handle = fileOpen("ScreenShots/ShotList.script", FF_ReturnNULLOnFail | FF_TextMode);
#endif
        if(handle)
        {
            do {
                Result = fileLineRead(handle, BigName, 512);

                if(Result != FR_EndOfFile && Result > 0)    // Found one!
                    BigFileCount++;

            } while(Result != FR_EndOfFile);

            fileClose(handle);
        }
        
        if (BigFileCount > 0)
        {
            chosenFileIndex = (utyTimerLast % 32777) % BigFileCount;

#ifdef _WIN32
            handle = fileOpen("ScreenShots\\ShotList.script", FF_ReturnNULLOnFail | FF_TextMode);
#else
            handle = fileOpen("ScreenShots/ShotList.script", FF_ReturnNULLOnFail | FF_TextMode);
#endif
            if(handle)
            {
                do {
                    Result = fileLineRead(handle, BigName, 512);

                    if(Result != FR_EndOfFile && Result > 0)    // Found one!
                        chosenFileIndex--;

                } while( (chosenFileIndex >= 0) && (Result != FR_EndOfFile));
#ifdef _WIN32
                strcpy(pFilenameBuffer, "ScreenShots\\");
#else
                strcpy(pFilenameBuffer, "ScreenShots/");
#endif
                strcat(pFilenameBuffer, BigName);
            }
        }
    }

    // Did we find any at all?
    if(userScreenShotCount == 0 && BigFileCount == 0)
    {
        pFilenameBuffer[0] = 0;
    }

    /*SetCurrentDirectory(CurDir);*/
    chdir(CurDir);
}
Пример #13
0
long writeSnapTimes3D(modPar mod, snaPar sna, bndPar bnd, wavPar wav,
	long ixsrc, long iysrc, long izsrc, long itime, float *vx, float *vy, float *vz,
	float *tzz, float *tyy, float *txx, float *txz, float *tyz, float *txy, long verbose)
{
	FILE    *fpvx, *fpvy, *fpvz, *fptxx, *fptyy, *fptzz, *fptxz, *fptyz, *fptxy, *fpp, *fppp, *fpss;
	long append, isnap;
	static long first=1;
	long n1, n2, ibndx, ibndy, ibndz, ixs, iys, izs, ize, i, j, l;
	long ix, iy, iz, ix2, iy2;
	float *snap, sdx, stime;
	segy hdr;

	if (sna.nsnap==0) return 0;

    ibndx = mod.ioXx;
    ibndy = mod.ioXy;
    ibndz = mod.ioXz;
	n1    = mod.naz;
	n2    = mod.nax;
	sdx   = 1.0/mod.dx;

	if (sna.withbnd) {
		sna.nz=mod.naz;
		sna.z1=0;
		sna.z2=mod.naz-1;
		sna.skipdz=1;

		sna.ny=mod.nax;
		sna.y1=0;
		sna.y2=mod.nay-1;
		sna.skipdy=1;

		sna.nx=mod.nax;
		sna.x1=0;
		sna.x2=mod.nax-1;
		sna.skipdx=1;
	}

	/* check if this itime is a desired snapshot time */
	if ( (((itime-sna.delay) % sna.skipdt)==0) && 
		  (itime >= sna.delay) &&
		  (itime <= sna.delay+(sna.nsnap-1)*sna.skipdt) ) {

		isnap = NINT((itime-sna.delay)/sna.skipdt);

        if (mod.grid_dir) stime = (-wav.nt+1+itime+1)*mod.dt;  /* reverse time modeling */
        else  stime = itime*mod.dt;
		if (verbose) vmess("Writing snapshot(%li) at time=%.4f", isnap+1, stime);
	
		if (first) {
			append=0;
			first=0;
		}
		else {
			append=1;
		}

		if (sna.type.vx)  fpvx  = fileOpen(sna.file_snap, "_svx", (int)append);
		if (sna.type.vy)  fpvy  = fileOpen(sna.file_snap, "_svy", (int)append);
		if (sna.type.vz)  fpvz  = fileOpen(sna.file_snap, "_svz", (int)append);
		if (sna.type.p)   fpp   = fileOpen(sna.file_snap, "_sp", (int)append);
		if (sna.type.txx) fptxx = fileOpen(sna.file_snap, "_stxx", (int)append);
		if (sna.type.tyy) fptyy = fileOpen(sna.file_snap, "_styy", (int)append);
		if (sna.type.tzz) fptzz = fileOpen(sna.file_snap, "_stzz", (int)append);
		if (sna.type.txz) fptxz = fileOpen(sna.file_snap, "_stxz", (int)append);
		if (sna.type.tyz) fptyz = fileOpen(sna.file_snap, "_styz", (int)append);
		if (sna.type.txy) fptxy = fileOpen(sna.file_snap, "_stxy", (int)append);
		if (sna.type.pp)  fppp  = fileOpen(sna.file_snap, "_spp", (int)append);
		if (sna.type.ss)  fpss  = fileOpen(sna.file_snap, "_sss", (int)append);
	
		memset(&hdr,0,TRCBYTES);
		hdr.dt     = 1000000*(sna.skipdt*mod.dt);
		hdr.ungpow  = (sna.delay*mod.dt);
		hdr.scalco = -1000;
		hdr.scalel = -1000;
		hdr.sx     = 1000*(mod.x0+ixsrc*mod.dx);
		hdr.sy     = 1000*(mod.y0+iysrc*mod.dy);
		hdr.sdepth = 1000*(mod.z0+izsrc*mod.dz);
		hdr.fldr   = isnap+1;
		hdr.trid   = 1;
		hdr.ns     = sna.nz;
		hdr.trwf   = sna.nx*sna.nx;
		hdr.ntr    = (isnap+1)*sna.nx;
		hdr.f1     = sna.z1*mod.dz+mod.z0;
		hdr.f2     = sna.x1*mod.dx+mod.x0;
		hdr.d1     = mod.dz*sna.skipdz;
		hdr.d2     = mod.dx*sna.skipdx;
		if (sna.withbnd) {
        	if ( !ISODD(bnd.top)) hdr.f1 = mod.z0 - bnd.ntap*mod.dz;
        	if ( !ISODD(bnd.lef)) hdr.f2 = mod.x0 - bnd.ntap*mod.dx;
        	//if ( !ISODD(bnd.rig)) ;
        	//if ( !ISODD(bnd.bot)) store=1;
		}

/***********************************************************************
* vx velocities have one sample less in x-direction
* vz velocities have one sample less in z-direction
* txz stresses have one sample less in z-direction and x-direction
***********************************************************************/

		snap = (float *)malloc(sna.nz*sizeof(float));

		/* Decimate, with skipdx and skipdz, the number of gridpoints written to file 
		   and write to file. */
		for (iys=sna.y1, l=0; iys<=sna.y2; iys+=sna.skipdy, l++) {
			for (ixs=sna.x1, i=0; ixs<=sna.x2; ixs+=sna.skipdx, i++) {
				hdr.tracf  = l*sna.nx+i+1;
				hdr.tracl  = isnap*sna.nx*sna.ny+l*sna.nx+i+1;
				hdr.gx     = 1000*(mod.x0+ixs*mod.dx);
				hdr.gy     = 1000*(mod.y0+iys*mod.dy);
				ix  = ixs+ibndx;
				ix2 = ix+1;
				iy  = iys+ibndy;
				iy2 = iy+1;

				izs = sna.z1+ibndz;
				ize = sna.z2+ibndz;

				if (sna.withbnd) {
					izs = 0;
					ize = sna.z2;
					ix  = ixs;
					ix2 = ix;
					iy  = iys;
					iy2 = iy;
					if (sna.type.vz || sna.type.txz || sna.type.tyz) izs = -1;
					if ( !ISODD(bnd.lef)) hdr.gx = 1000*(mod.x0 - bnd.ntap*mod.dx);
					if ( !ISODD(bnd.fro)) hdr.gy = 1000*(mod.y0 - bnd.ntap*mod.dy);
				}

				if (sna.type.vx) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = vx[iy*n1*n2+ix2*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fpvx);
				}
				if (sna.type.vy) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = vy[iy2*n1*n2+ix*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fpvy);
				}
				if (sna.type.vz) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = vz[iy*n1*n2+ix*n1+iz+1];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fpvz);
				}
				if (sna.type.p) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = tzz[iy*n1*n2+ix*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fpp);
				}
				if (sna.type.tzz) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = tzz[iy*n1*n2+ix*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fptzz);
				}
				if (sna.type.tyy) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = tyy[iy*n1*n2+ix*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fptyy);
				}
				if (sna.type.txx) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = txx[iy*n1*n2+ix*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fptxx);
				}
				if (sna.type.txz) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = txz[iy*n1*n2+ix2*n1+iz+1];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fptxz);
				}
				if (sna.type.txy) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = txy[iy2*n1*n2+ix2*n1+iz];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fptxy);
				}
				if (sna.type.tyz) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] = tyz[iy2*n1*n2+ix*n1+iz+1];
					}
					traceWrite(&hdr, snap, (int)sna.nz, fptyz);
				}
				/* calculate divergence of velocity field */
				if (sna.type.pp) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] =  sdx*((vx[iy*n1*n2+(ix+1)*n1+iz]-vx[iy*n1*n2+ix*n1+iz])+
										(vy[(iy+1)*n1*n2+ix*n1+iz]-vy[iy*n1*n2+ix*n1+iz])+
										(vz[iy*n1*n2+ix*n1+iz+1]-vz[iy*n1*n2+ix*n1+iz]));
					}
					traceWrite(&hdr, snap, (int)sna.nz, fppp);
				}
				/* calculate rotation of velocity field */
				if (sna.type.ss) {
					for (iz=izs, j=0; iz<=ize; iz+=sna.skipdz, j++) {
						snap[j] =  sdx*((vx[iy*n1*n2+ix*n1+iz]-vx[(iy-1)*n1*n2+ix*n1+iz-1])-
										(vy[iy*n1*n2+ix*n1+iz]-vy[iy*n1*n2+(ix-1)*n1+iz-1])-
										(vz[iy*n1*n2+ix*n1+iz]-vz[(iy-1)*n1*n2+(ix-1)*n1+iz]));
					}
					traceWrite(&hdr, snap, (int)sna.nz, fpss);
				}

			}
		}

		if (sna.type.vx) fclose(fpvx);
		if (sna.type.vy) fclose(fpvy);
		if (sna.type.vz) fclose(fpvz);
		if (sna.type.p) fclose(fpp);
		if (sna.type.txx) fclose(fptxx);
		if (sna.type.tyy) fclose(fptyy);
		if (sna.type.tzz) fclose(fptzz);
		if (sna.type.txz) fclose(fptxz);
		if (sna.type.tyz) fclose(fptyz);
		if (sna.type.txy) fclose(fptxy);
		if (sna.type.pp) fclose(fppp);
		if (sna.type.ss) fclose(fpss);

		free(snap);
	}

	return 0;
}
Пример #14
0
int initRead(char *fileName1, char *fileName2)
{
	char dummy[SEQ_MAX_LENGTH];
	char ch;
	int i, maxCnt=0;

	_r_buf1 = getMem(10000000);
	_r_buf1_pos = getMem(sizeof(int));
	_r_buf1_size = getMem(sizeof(int));
	*_r_buf1_size = *_r_buf1_pos = 0; 
	if ( pairedEndMode && fileName2 != NULL )
	{
		_r_buf2 = getMem(10000000);
		_r_buf2_pos = getMem(sizeof(int));
		_r_buf2_size = getMem(sizeof(int));
	}
	else
	{
		_r_buf2 = _r_buf1;
		_r_buf2_pos = _r_buf1_pos;
		_r_buf2_size = _r_buf1_size;
	}


	if (!seqCompressed)
	{
		_r_fp1 = fileOpen( fileName1, "r");

		if (_r_fp1 == NULL)
			return 0;

		ch = fgetc(_r_fp1);

		if ( pairedEndMode) 
		{
			if ( fileName2 == NULL )
			{
				_r_fp2 = _r_fp1;
			}
			else
			{
				_r_fp2 = fileOpen ( fileName2, "r" );
				if (_r_fp2 == NULL)
					return 0;
			}
		}

		readBuffer1 = &readBufferTxT1;
		readBuffer2 = &readBufferTxT2;
	}
	else
	{

		_r_gzfp1 = fileOpenGZ (fileName1, "r");

		if (_r_gzfp1 == NULL)
		{
			return 0;
		}

		ch = gzgetc(_r_gzfp1);

		if ( pairedEndMode && fileName2 != NULL )
		{
			_r_gzfp2 = fileOpenGZ ( fileName2, "r" );
			if (_r_gzfp2 == NULL)
			{
				return 0;
			}
		}
		else
		{
			_r_gzfp2 = _r_gzfp1;
		}

		readBuffer1 = &readBufferGZ1;
		readBuffer2 = &readBufferGZ2;
	}

	if (!seqCompressed)
		rewind(_r_fp1);
	else
		gzrewind(_r_gzfp1);

	if (ch == '>')
		_r_fastq = 0;
	else
		_r_fastq = 1;
	
	readFirstSeq(dummy,1);
	int nameLen = strlen(dummy);
	readFirstSeq(dummy,2);
	*_r_buf1_pos = 0;
	int seqLen = strlen(dummy);
	SEQ_LENGTH = 0;
	i = 0;
	while (i<seqLen && !isspace(dummy[i]))
	{
		i++;
		SEQ_LENGTH++;
	}
	
	if (cropSize > 0)
		SEQ_LENGTH = cropSize;

	if ( SEQ_LENGTH >= SEQ_MAX_LENGTH )
	{
		fprintf(stdout, "ERR: Read Length is greater than the MAX length we can process (Current Max: %d).\n", SEQ_MAX_LENGTH);
		exit(EXIT_FAILURE);
	}

	if (_r_fastq)
	{
		QUAL_LENGTH = SEQ_LENGTH;
	}
	else
	{
		QUAL_LENGTH = 1;
	}

	CMP_SEQ_LENGTH = calculateCompressedLen(SEQ_LENGTH);

	//TODO MEMORY CALCULATION FIX
	double readMem = sizeof(Read) + (2 + (SEQ_LENGTH * 2) + QUAL_LENGTH + 3 + (CMP_SEQ_LENGTH * 2 * 8) + (nameLen+10) + 4);
	readMem += ((bestMappingMode) ?(sizeof(FullMappingInfo)) :0);
	if (pairedEndMode)
		readMem += sizeof(MappingInfo) + sizeof(MappingLocations);

	_r_maxSeqCnt = (int)(((MAX_MEMORY-1.2) * (1 << 30))/readMem);
	if ( pairedEndMode && _r_maxSeqCnt % 2 )
		_r_maxSeqCnt ++;
	_r_maxSeqCnt -= _r_maxSeqCnt % THREAD_COUNT;

//_r_maxSeqCnt = 500000;

	_r_seq = getMem(sizeof(Read)*_r_maxSeqCnt);

	int maxErrThreshold = (SEQ_LENGTH/WINDOW_SIZE) - 1;
	if (errThreshold == -1)
	{
		errThreshold = SEQ_LENGTH*6/100;
		fprintf(stdout, "# Errors: %d\n", errThreshold);
	}
	if (errThreshold > maxErrThreshold && SEQ_LENGTH>0)
	{
		errThreshold = maxErrThreshold;
		fprintf(stdout, "# Error: %d (full sensitivity)\n", errThreshold);
	}


	checkSumLength = (SEQ_LENGTH / (errThreshold+1)) - WINDOW_SIZE;
	if (checkSumLength > sizeof(CheckSumType)*4)
		checkSumLength = sizeof(CheckSumType)*4;

	calculateSamplingLocations();


	if (!nohitDisabled)
	{
		_r_umfp = fileOpen(unmappedOutput, "w");
	}

	_r_alphIndex = getMem(128);		// used in readChunk()
	_r_alphIndex['A'] = 0;
	_r_alphIndex['C'] = 1;
	_r_alphIndex['G'] = 2;
	_r_alphIndex['T'] = 3;
	_r_alphIndex['N'] = 4;

	return 1;
}
void EDFViewerWindow::fileOpen(){
    char pathname[256];
    QFileDialog dialog(this);
    strcpy(pathname ,dialog.getOpenFileName(this,"Open File",".", "EDF files (*.edf)").toUtf8());
    fileOpen(pathname);
}
Пример #16
0
TTMpeg2MainWnd::TTMpeg2MainWnd( QWidget* parent, const char* name, Qt::WFlags fl )
  : Q3MainWindow( parent, name, fl )
			      //      image0( (const char **) image0_data )
{
  if ( !name )
    setName( "TTMpeg2MainWnd" );

  // images
  // ---------------------------------------------------------------------------
  TTCut::imgDownArrow  = new QPixmap( (const char**)downarrow_18_xpm );
  TTCut::imgUpArrow    = new QPixmap( (const char**)uparrow_18_xpm );
  TTCut::imgDelete     = new QPixmap( (const char**)cancel_18_xpm );
  TTCut::imgFileOpen24 = new QPixmap( (const char**)fileopen_24_xpm );
  TTCut::imgFileNew    = new QPixmap( (const char**)filenew_16_xpm );
  TTCut::imgFileOpen   = new QPixmap( (const char**)fileopen_16_xpm );
  TTCut::imgFileSave   = new QPixmap( (const char**)filesave_16_xpm );;
  TTCut::imgFileSaveAs = new QPixmap( (const char**)filesaveas_16_xpm );
  TTCut::imgSaveImage  = new QPixmap( (const char**)saveimage_16_xpm );
  TTCut::imgSettings   = new QPixmap( (const char**)settings_16_xpm );
  TTCut::imgSettings18 = new QPixmap( (const char**)settings_18_xpm );
  TTCut::imgExit       = new QPixmap( (const char**)exit_16_xpm );
  TTCut::imgPlay       = new QPixmap( (const char**)play_18_xpm );
  TTCut::imgStop       = new QPixmap( (const char**)stop_18_xpm );
  TTCut::imgSearch     = new QPixmap( (const char**)search_18_xpm );
  TTCut::imgChapter    = new QPixmap( (const char**)chapter_18_xpm );
  TTCut::imgPreview    = new QPixmap( (const char**)preview_18_xpm );
  TTCut::imgCutAV      = new QPixmap( (const char**)cutav_18_xpm );
  TTCut::imgCutAudio   = new QPixmap( (const char**)cutaudio_18_xpm );
  TTCut::imgGoTo       = new QPixmap( (const char**)goto_18_xpm );
  TTCut::imgMarker     = new QPixmap( (const char**)note_18_xpm );
  TTCut::imgClock      = new QPixmap( (const char**)clock_16_xpm );
  TTCut::imgApply      = new QPixmap( (const char**)apply_18_xpm );
  TTCut::imgAddToList  = new QPixmap( (const char**)addtolist_18_xpm );
  TTCut::imgFileClose  = new QPixmap( (const char**)fileclose_18_xpm );

  slider_update = true;

  // min widgets size
  // --------------------------------------------------------------------------
  setMinimumSize( QSize( 860, 480 ) );
  setMaximumSize( QSize( 1600, 1280 ) );

  // central widget
  // --------------------------------------------------------------------------
  setCentralWidget( new QWidget( this, "qt_central_widget" ) );


  // --------------------------------------------------------------------------
  // menu-bar
  // --------------------------------------------------------------------------

  // menu actions
  // --------------------------------------------------------------------------

  // file-menu
  fileOpenAction       = new QAction( this, "fileOpenAction" );
  fileOpenAction->setIconSet( QIcon( *(TTCut::imgFileOpen) ) );
  fileSettingsAction   = new QAction( this, "fileSettingsAction" );
  fileSettingsAction->setIconSet( QIcon( *(TTCut::imgSettings) ) );
  fileAnalyzeAction    = new QAction( this, "fileAnalyzeAction" );
  fileAnalyzeAction->setIconSet( QIcon( *(TTCut::imgPreview) ) );
  fileExitAction       = new QAction( this, "fileExitAction" );
  fileExitAction->setIconSet( QIcon( *(TTCut::imgExit) ) );

  // menubar
  MenuBar = new QMenuBar( this, "MenuBar" );
  
  //file-menu
  fileMenu = new Q3PopupMenu( this );
  fileOpenAction->addTo( fileMenu );
  fileAnalyzeAction->addTo( fileMenu );
  fileMenu->insertSeparator();
  fileSettingsAction->addTo( fileMenu );
  fileMenu->insertSeparator();
  fileExitAction->addTo( fileMenu );
  MenuBar->insertItem( QString("File"), fileMenu,   1 );
  

  // ---------------------------------------------------------------------------
  // tool-bar
  // ---------------------------------------------------------------------------
  toolBar = new Q3ToolBar( this, "ToolBar" );

  tbStartAnalyzing = new QToolButton( toolBar, "StartAnalyze" );
  tbStartAnalyzing->setIconSet( QIcon( *(TTCut::imgPreview) ) );

  // ---------------------------------------------------------------------------
  // status-bar
  // ---------------------------------------------------------------------------
  (void)statusBar();


  // central layout manager (grid 4x2)
  // ---------------------------------------------------------------------------
  TTMpeg2MainWndLayout = new QGridLayout( centralWidget(), 
					  4, 1, 11, 6, 
					  "TTMpeg2MainWndLayout"); 

  // open stream section
  // ---------------------------------------------------------------------------
  gbStreamName = new Q3GroupBox( centralWidget(), "gbStreamName" );
  gbStreamName->setColumnLayout(0, Qt::Vertical );
  gbStreamName->layout()->setSpacing( 6 );
  gbStreamName->layout()->setMargin( 11 );
  gbStreamNameLayout = new QGridLayout( gbStreamName->layout() );
  gbStreamNameLayout->setAlignment( Qt::AlignTop );
  
  leStreamName = new QLineEdit( gbStreamName, "leStreamName" );
  
  gbStreamNameLayout->addWidget( leStreamName, 0, 1 );
  
  pbOpenStream = new QPushButton( gbStreamName, "pbOpenStream" );
  pbOpenStream->setMinimumSize( QSize( 24, 24 ) );
  pbOpenStream->setMaximumSize( QSize( 24, 24 ) );
  pbOpenStream->setPixmap( (QPixmap)*(TTCut::imgFileOpen) );
  
  gbStreamNameLayout->addWidget( pbOpenStream, 0, 0 );
  TTMpeg2MainWndLayout->addMultiCellWidget( gbStreamName, 0, 0, 0, 1 );


  // stream info section
  // ---------------------------------------------------------------------------
  layout10 = new QHBoxLayout( 0, 0, 6, "layout10"); 
  layout9 = new QVBoxLayout( 0, 0, 6, "layout9"); 

  // buffer statistics
  gbBufferStatistics = new Q3GroupBox( centralWidget(), "gbBufferStatistics" );
  gbBufferStatistics->setColumnLayout(0, Qt::Vertical );
  gbBufferStatistics->layout()->setSpacing( 6 );
  gbBufferStatistics->layout()->setMargin( 11 );
  gbBufferStatisticsLayout = new QGridLayout( gbBufferStatistics->layout() );
  gbBufferStatisticsLayout->setAlignment( Qt::AlignTop );
  
  layout1 = new QVBoxLayout( 0, 0, 6, "layout1"); 

  slFileLength = new QLabel( gbBufferStatistics, "slFileLength" );
  layout1->addWidget( slFileLength );
  
  slReadOps = new QLabel( gbBufferStatistics, "slReadOps" );
  layout1->addWidget( slReadOps );
  
  slFillOps = new QLabel( gbBufferStatistics, "slFillOps" );
  layout1->addWidget( slFillOps );
  
  slReadTime = new QLabel( gbBufferStatistics, "slReadTime" );
  layout1->addWidget( slReadTime );
  
  gbBufferStatisticsLayout->addLayout( layout1, 0, 0 );
  
  layout2 = new QVBoxLayout( 0, 0, 6, "layout2"); 
  
  laFileLength = new QLabel( gbBufferStatistics, "laFileLength" );
  layout2->addWidget( laFileLength );
  
  laReadOps = new QLabel( gbBufferStatistics, "laReadOps" );
  layout2->addWidget( laReadOps );
  
  laFillOps = new QLabel( gbBufferStatistics, "laFillOps" );
  layout2->addWidget( laFillOps );
  
  laReadTime = new QLabel( gbBufferStatistics, "laReadTime" );
  layout2->addWidget( laReadTime );
  
  gbBufferStatisticsLayout->addLayout( layout2, 0, 1 );
  layout9->addWidget( gbBufferStatistics );

  // stream statistics
  gbStreamStatistics = new Q3GroupBox( centralWidget(), "gbStreamStatistics" );
  gbStreamStatistics->setColumnLayout(0, Qt::Vertical );
  gbStreamStatistics->layout()->setSpacing( 6 );
  gbStreamStatistics->layout()->setMargin( 11 );
  gbStreamStatisticsLayout = new QGridLayout( gbStreamStatistics->layout() );
  gbStreamStatisticsLayout->setAlignment( Qt::AlignTop );

  line1 = new Q3Frame( gbStreamStatistics, "line1" );
  line1->setFrameShape( Q3Frame::HLine );
  line1->setFrameShadow( Q3Frame::Sunken );
  line1->setFrameShape( Q3Frame::HLine );
  
  gbStreamStatisticsLayout->addMultiCellWidget( line1, 1, 1, 0, 1 );
  
  layout5 = new QVBoxLayout( 0, 0, 6, "layout5"); 
  
  slTotalFrames = new QLabel( gbStreamStatistics, "slTotalFrames" );
  layout5->addWidget( slTotalFrames );
  
  slIFrames = new QLabel( gbStreamStatistics, "slIFrames" );
  layout5->addWidget( slIFrames );
  
  slPFrames = new QLabel( gbStreamStatistics, "slPFrames" );
  layout5->addWidget( slPFrames );
  
  slBFrames = new QLabel( gbStreamStatistics, "slBFrames" );
  layout5->addWidget( slBFrames );
  
  gbStreamStatisticsLayout->addLayout( layout5, 0, 0 );
  
  layout4 = new QVBoxLayout( 0, 0, 6, "layout4"); 
  
  slSeqHeader = new QLabel( gbStreamStatistics, "slSeqHeader" );
  layout4->addWidget( slSeqHeader );
  
  slGOPHeader = new QLabel( gbStreamStatistics, "slGOPHeader" );
  layout4->addWidget( slGOPHeader );
  
  slPicHeader = new QLabel( gbStreamStatistics, "slPicHeader" );
  layout4->addWidget( slPicHeader );
  
  slSeqEndHeader = new QLabel( gbStreamStatistics, "slSeqEndHeader" );
  layout4->addWidget( slSeqEndHeader );
  
  gbStreamStatisticsLayout->addLayout( layout4, 2, 0 );
  
  layout6 = new QVBoxLayout( 0, 0, 6, "layout6"); 
  
  laSequence = new QLabel( gbStreamStatistics, "laSequence" );
  layout6->addWidget( laSequence );
  
  laGOP = new QLabel( gbStreamStatistics, "laGOP" );
  layout6->addWidget( laGOP );
  
  laPicture = new QLabel( gbStreamStatistics, "laPicture" );
  layout6->addWidget( laPicture );
  
  laSequenceEnd = new QLabel( gbStreamStatistics, "laSequenceEnd" );
  layout6->addWidget( laSequenceEnd );
  
  gbStreamStatisticsLayout->addLayout( layout6, 2, 1 );

  layout7 = new QVBoxLayout( 0, 0, 6, "layout7"); 

  laFramesTotal = new QLabel( gbStreamStatistics, "laFramesTotal" );
  layout7->addWidget( laFramesTotal );
  
  laIFrames = new QLabel( gbStreamStatistics, "laIFrames" );
  layout7->addWidget( laIFrames );
  
  laPFrames = new QLabel( gbStreamStatistics, "laPFrames" );
  layout7->addWidget( laPFrames );
  
  laBFrames = new QLabel( gbStreamStatistics, "laBFrames" );
  layout7->addWidget( laBFrames );
  
  gbStreamStatisticsLayout->addLayout( layout7, 0, 1 );
  layout9->addWidget( gbStreamStatistics );
  layout10->addLayout( layout9 );

  // list view stream info
  gbStreamInfo = new Q3GroupBox( centralWidget(), "gbStreamInfo" );
  gbStreamInfo->setColumnLayout(0, Qt::Vertical );
  gbStreamInfo->layout()->setSpacing( 6 );
  gbStreamInfo->layout()->setMargin( 11 );
  gbStreamInfoLayout = new QGridLayout( gbStreamInfo->layout() );
  gbStreamInfoLayout->setAlignment( Qt::AlignTop );
  
  lvStreamInfo = new Q3ListView( gbStreamInfo, "lvStreamInfo" );
  lvStreamInfo->addColumn( tr( "Header" ) );
  lvStreamInfo->addColumn( tr( "Offset" ) );
  lvStreamInfo->addColumn( tr( "Type" ) );
  lvStreamInfo->addColumn( tr( "Temp Ref." ) );
  lvStreamInfo->addColumn( tr( "S-Order" ) );
  lvStreamInfo->addColumn( tr( "D-Order" ) );
  lvStreamInfo->addColumn( tr( "Time-code" ) );

  lvStreamInfo->setSorting( 5, TRUE );

  gbStreamInfoLayout->addWidget( lvStreamInfo, 0, 0 );
  layout10->addWidget( gbStreamInfo );
  
  TTMpeg2MainWndLayout->addLayout( layout10, 1, 0 );
  
  // sequence info
  gbSequenceInfo = new Q3GroupBox( centralWidget(), "gbSequenceInfo" );
  gbSequenceInfo->setColumnLayout(0, Qt::Vertical );
  gbSequenceInfo->layout()->setSpacing( 6 );
  gbSequenceInfo->layout()->setMargin( 11 );
  gbSequenceInfoLayout = new QGridLayout( gbSequenceInfo->layout() );
  gbSequenceInfoLayout->setAlignment( Qt::AlignTop );
  
  layout19 = new QVBoxLayout( 0, 0, 6, "layout19"); 
  
  slBitrate = new QLabel( gbSequenceInfo, "slBitrate" );
  layout19->addWidget( slBitrate );
  
  slFramerate = new QLabel( gbSequenceInfo, "slFramerate" );
  layout19->addWidget( slFramerate );
  
  slWidth = new QLabel( gbSequenceInfo, "slWidth" );
  layout19->addWidget( slWidth );
  
  slHeight = new QLabel( gbSequenceInfo, "slHeight" );
  layout19->addWidget( slHeight );
  
  gbSequenceInfoLayout->addLayout( layout19, 0, 0 );
  
  layout20 = new QVBoxLayout( 0, 0, 6, "layout20"); 
   
  laSeqBitrate = new QLineEdit( gbSequenceInfo, "laSeqBitrate" );
  laSeqBitrate->setEnabled( FALSE );
  laSeqBitrate->setReadOnly( TRUE );
  layout20->addWidget( laSeqBitrate );
  
  laSeqFramerate = new QLineEdit( gbSequenceInfo, "laSeqFramerate" );
  laSeqFramerate->setEnabled( FALSE );
  laSeqFramerate->setReadOnly( TRUE );
  layout20->addWidget( laSeqFramerate );
  
  laSeqPicWidth = new QLineEdit( gbSequenceInfo, "laSeqPicWidth" );
  laSeqPicWidth->setEnabled( FALSE );
  laSeqPicWidth->setReadOnly( TRUE );
  layout20->addWidget( laSeqPicWidth );
  
  laSeqPicHeight = new QLineEdit( gbSequenceInfo, "laSeqPicHeight" );
  laSeqPicHeight->setEnabled( FALSE );
  laSeqPicHeight->setReadOnly( TRUE );
  layout20->addWidget( laSeqPicHeight );
  
  gbSequenceInfoLayout->addLayout( layout20, 0, 1 );
  
  TTMpeg2MainWndLayout->addWidget( gbSequenceInfo, 1, 1 );
  
  // scroll-bar
  // ---------------------------------------------------------------------------
  sbFrames = new QScrollBar( centralWidget(), "sbFrames" );
  sbFrames->setOrientation( Qt::Horizontal );
  
  TTMpeg2MainWndLayout->addMultiCellWidget( sbFrames, 2, 2, 0, 1 );
  
  // current frame info and navigation
  // ---------------------------------------------------------------------------
  frameInfo = new TTCurrentFrameInfo( centralWidget() , "FrameInfo" );

  TTMpeg2MainWndLayout->addMultiCellWidget( frameInfo, 3, 3, 0 ,1 );

  // ready
  languageChange();
  resize( QSize(963, 725).expandedTo(minimumSizeHint()) );
  //Qt4.0: clearWState( WState_Polished );

  // initialize some attributes
  // ---------------------------------------------------------------------------
  step_frame     = 0;
  step_order     = 0;
  is_stream_open = false;

  // show the video window
  // ---------------------------------------------------------------------------
  mpeg2_window = new TTMPEG2Window( 0 );
  mpeg2_window->show();
  mpeg2_window->resize( 720, 576 );

  // show the chart window
  // ---------------------------------------------------------------------------
  //chart_window = new TTFrameChart( 0, "CHARTWND", 420, 120 );
  //chart_window->show();

  // mpeg2 info window
  // ---------------------------------------------------------------------------
  //info_window = new TTMpeg2InfoView( 0, "INFOWND" );
  //info_window->show();

  // signals and slots connections
  // ---------------------------------------------------------------------------
  // file-menu
  connect(fileOpenAction,     SIGNAL( activated() ),   this, SLOT(fileOpen()));
  connect(fileAnalyzeAction,  SIGNAL( activated() ),   this, SLOT(fileAnalyze()));
  connect(fileSettingsAction, SIGNAL( activated() ),   this, SLOT(fileSettings()));
  connect(fileExitAction,     SIGNAL( activated() ),   this, SLOT(fileExit()));

  // tool-bar
  connect(tbStartAnalyzing, SIGNAL(clicked()), this, SLOT(fileAnalyze()));

  // open file button
  connect(pbOpenStream,       SIGNAL( clicked() ),     this,   SLOT( fileOpen()));

  // video position slider
  connect( sbFrames,  SIGNAL( valueChanged(int) ), this, SLOT( videoSliderChanged(int) ) );
  
  // current frame info / navigation
  connect(frameInfo,          SIGNAL(nextFrame()),     this, SLOT(nextFrameAction()));
  connect(frameInfo,          SIGNAL(prevFrame()),     this, SLOT(prevFrameAction()));
  connect(frameInfo,          SIGNAL(orderAnyFrame()), this, SLOT(orderAnyFrame()));
  connect(frameInfo,          SIGNAL(orderIFrame()),   this, SLOT(orderIFrame()));
  connect(frameInfo,          SIGNAL(orderPFrame()),   this, SLOT(orderPFrame()));
  connect(frameInfo,          SIGNAL(orderBFrame()),   this, SLOT(orderBFrame()));
  connect(frameInfo,          SIGNAL(orderDisplay()),  this, SLOT(orderDisplay()));
  connect(frameInfo,          SIGNAL(orderStream()),   this, SLOT(orderStream()));

}
Пример #17
0
void Ide::onFileOpen(const QString &p)
{
    emit fileOpen(p);
}
Пример #18
0
/* find_fsdb_score_cut
   Args: (1) FSDB fsdb - has valid data for seq_len, score, and
             unique_best
     (2) double* slope - pointer to slope to be calculated
     (3) double* intercept - pointer to intercept to be calc.
   Returns: void
   Takes all the sequence lengths and scores in a FSDB database.
   Calculates the best fit line through the data:
   score = (slope * seq_len) + intercept
   That is, is determines the dependency of average score on the
   length of the sequence. This can then be used to determine
   what is an inappropriately scoring (for its length) alignment.
*/
void find_fsdb_score_cut( FSDB fsdb, double* slope, double* intercept ) {
  /* Load up the lengths and scores of all unique guys that
     had sensible scores as defined by FIRST_ROUND_SCORE_CUTOFF
     This is necessary in case the distant reference option is
     used in which case we may have some total crap sequences
     and scores that will screw up the fit.  (This exact same loop is
     repeated twice (three times in debug mode), the single pass
     algorithm would be numerically unstable.)
  */
  double slope_bf = 0, intercept_bf = 0; 
  //  double slope_max = 0, intercept_max = 0;
  double slope_delta, max_slope_delta;
  int max_sc_len[INIT_ALN_SEQ_LEN+1]; // place to put maximum 
  // scores at each length
  size_t j = 0, i ;
  FILE* LVSLOG;
  /* Initialization */
  double xbar = 0, ybar = 0 ;
  for ( i = 0; i < (INIT_ALN_SEQ_LEN+1); i++ ) {
    max_sc_len[i] = 0;
  }

  for ( i = 0; i < fsdb->num_fss; i++ ) {
    if ( fsdb->fss[i]->unique_best &&
	(fsdb->fss[i]->score >= FIRST_ROUND_SCORE_CUTOFF) ) {
      xbar += fsdb->fss[i]->seq_len;
      ybar += fsdb->fss[i]->score;
      j++;
      /* Is this the best score for this length? */
      if ( fsdb->fss[i]->score > max_sc_len[fsdb->fss[i]->seq_len] ) {
        max_sc_len[fsdb->fss[i]->seq_len] = fsdb->fss[i]->score;
      }
    }
  }
  xbar /= j ;
  ybar /= j ;

  double ssxy = 0, ssxx = 0 ;
  for ( i = 0; i < fsdb->num_fss; i++ ) {
    if ( fsdb->fss[i]->unique_best &&
	(fsdb->fss[i]->score >= FIRST_ROUND_SCORE_CUTOFF) ) {
      ssxy += (fsdb->fss[i]->seq_len - xbar) * (fsdb->fss[i]->score - ybar) ;
      ssxx += (fsdb->fss[i]->seq_len - xbar) * (fsdb->fss[i]->seq_len - xbar) ;
    }
  }
  slope_bf     = ssxy / ssxx ;
  intercept_bf = ybar - slope_bf * xbar ;


  /* Now find the slope_max and intercept_max */
  /*  xbar = 0;
  ybar = 0;
  j = 0;
  for ( i = 0; i < (INIT_ALN_SEQ_LEN+1); i++ ) {
    if ( max_sc_len[i] > 0 ) {
      xbar += i;
      ybar += max_sc_len[i];
      j++;
    }
  }
  xbar /= j;
  ybar /= j;
  
  ssxy = 0;
  ssxx = 0;
  for ( i = 0; i < (INIT_ALN_SEQ_LEN+1); i++ ) {
    if ( max_sc_len[i] > 0 ) {
      ssxy += (i - xbar) * (max_sc_len[i] - ybar);
      ssxx += (i - xbar) * (i - xbar);
    }
  }
  slope_max = (ssxy / ssxx);
  intercept_max = ybar - slope_max * xbar;
  */

  max_slope_delta = 0;
  for ( i = 0; i < fsdb->num_fss; i++ ) {
    if ( fsdb->fss[i]->unique_best &&
	 (fsdb->fss[i]->score >= FIRST_ROUND_SCORE_CUTOFF) ) {
      slope_delta = ( fsdb->fss[i]->score - 
		      ((slope_bf * fsdb->fss[i]->seq_len) + 
		       intercept_bf) ) 
	/ 
	fsdb->fss[i]->seq_len;
      if ( slope_delta > max_slope_delta ) {
	max_slope_delta = slope_delta;
      }
    }
  }

  *intercept = intercept_bf;
  /* Make sure slope is sane (positive) */
  if ( (slope_bf - max_slope_delta) > 0 ) {
    *slope     = slope_bf - (max_slope_delta * 2.0);
  }
  else {
    *slope = (double)(slope_bf * (SCORE_CUTOFF_BUFFER/100.0));
  }

  if (DEBUG) {
    LVSLOG = fileOpen( "LENvSCORE.dat", "w" );
    fprintf( LVSLOG,
	"# Just calculated length-score best-fit line:\n" );
    fprintf( LVSLOG,
	"# score = %0.4f + (length x %0.4f)\n",
	*intercept, *slope );
    for ( i = 0; i < fsdb->num_fss; i++ ) {
      if ( fsdb->fss[i]->unique_best &&
	  (fsdb->fss[i]->score >= FIRST_ROUND_SCORE_CUTOFF) ) {
	fprintf( LVSLOG, "%d\t%d\n", fsdb->fss[i]->seq_len, fsdb->fss[i]->score );
      }
    }
    fclose( LVSLOG );
  }
}
Пример #19
0
void EffectRack::dropEvent(QDropEvent *event)/*{{{*/
{
    event->accept();
    QString text;
    QListWidgetItem *i = itemAt(event->pos());
    if (!i)
        return;
    int idx = row(i);
    //qDebug("EffectRack::dropEvent: idx: %d", idx);

    Pipeline* pipe = track->efxPipe();
    if (pipe)
    {
        //int size = pipe->size();
        /*if (idx < size)
        {
        	QWidget *sw = event->source();
        	if (sw)
        	{
        		if (strcmp(sw->metaObject()->className(), "EffectRack") == 0)
        		{
        			EffectRack *ser = (EffectRack*) sw;
        			Pipeline* spipe = ser->getTrack()->efxPipe();
        			if (!spipe)
        				return;

        			QListWidgetItem *i = ser->itemAt(ser->getDragPos());
        			int idx0 = ser->row(i);
        			if (!(*spipe)[idx0] ||
        					(idx == idx0 && (ser == this || ser->getTrack()->name() == track->name())))
        				return;
        		}
        	}
        	if (QMessageBox::question(this, tr("Replace effect"), tr("Do you really want to replace the effect %1?").arg(pipe->name(idx)),
        			QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
        	{
        		audio->msgAddPlugin(track, idx, 0);
        		song->update(SC_RACK);
        	}
        	else
        	{
        		return;
        	}
        }*/

        if (event->mimeData()->hasFormat("text/x-oom-plugin"))
        {
            const QMimeData *md = event->mimeData();
            QString outxml(md->data("text/x-oom-plugin"));
            //qDebug("EffectRack::dropEvent Event data:\n%s", outxml.toUtf8().constData());
            //Xml xml(event->mimeData()->data("text/x-oom-plugin").data());
            QByteArray ba = outxml.toUtf8();
            const char* data =  ba.constData();
            Xml xml(data);
            initPlugin(xml, idx);
        }
        else if (event->mimeData()->hasUrls())
        {
            // Multiple urls not supported here. Grab the first one.
            text = event->mimeData()->urls()[0].path();

            if (text.endsWith(".pre", Qt::CaseInsensitive) ||
                    text.endsWith(".pre.gz", Qt::CaseInsensitive) ||
                    text.endsWith(".pre.bz2", Qt::CaseInsensitive))
            {
                //bool popenFlag = false;
                bool popenFlag;
                FILE* fp = fileOpen(this, text, ".pre", "r", popenFlag, false, false);
                if (fp)
                {
                    Xml xml(fp);
                    initPlugin(xml, idx);

                    if (popenFlag)
                        pclose(fp);
                    else
                        fclose(fp);
                }
            }
        }
    }
}/*}}}*/
Пример #20
0
FILE * initUnmapped(char *fileName) {
	FILE * _fp_unmap = NULL;
	if (fileName != NULL)
		_fp_unmap = fileOpen(fileName, "w");
	return _fp_unmap;
}
Пример #21
0
bool CMake::writeProject(const String& targetName, Project& project)
{
  Directory::create(String(".CMake/") + targetName);
  fileOpen(String(".CMake/") + targetName + "/CMakeLists.txt");

  fileWrite("cmake_policy(SET CMP0015 NEW)\n\n");

  for(const Map<String, ProjectConfiguration>::Node* i = project.configurations.getFirst(); i; i = i->getNext())
  {
    const String& configName = i->key;
    const ProjectConfiguration& config = i->data;
    const Target& target = *config.target;

    if(i == project.configurations.getFirst())
      fileWrite(String("if(CMAKE_BUILD_TYPE STREQUAL \"") + configName +"\")\n");
    else
      fileWrite(String("elseif(CMAKE_BUILD_TYPE STREQUAL \"") + configName +"\")\n");

    if(!target.includePaths.isEmpty())
      fileWrite(String("include_directories(") + joinPaths(target.includePaths) + ")\n");

    if(!target.libPaths.isEmpty())
      fileWrite(String("link_directories(") + joinPaths(target.libPaths) + ")\n");

    List<String> customBuildOutput;
    for(const List<const File*>::Node* i = config.customBuildFiles.getFirst(); i; i = i->getNext())
    {
      const File& file = *i->data;
      fileWrite("add_custom_command(\n");
      fileWrite(String("  OUTPUT ") + joinPaths(file.output, true) + "\n");

      Map<String, void*> outputDirs;
      for(const List<String>::Node* i = file.output.getFirst(); i; i = i->getNext())
      {
        String dir = ::File::getDirname(i->data);
        if(dir != "." && !outputDirs.find(dir))
          outputDirs.append(dir);
      }
      for(Map<String, void*>::Node* i = outputDirs.getFirst(); i; i = i->getNext())
        fileWrite(String("  COMMAND ${CMAKE_COMMAND} -E make_directory ") + translatePath(i->key, true) + "\n");

      for(const List<String>::Node* i = file.command.getFirst(); i; i = i->getNext())
        fileWrite(String("  COMMAND ") + i->data + "\n");
      fileWrite(String("  DEPENDS ") + joinPaths(file.input) + "\n");
      fileWrite("  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..\n");
      if(!file.message.isEmpty())
        fileWrite(String("  COMMENT \"") + file.message.getFirst()->data + "\"\n");
      fileWrite("  )\n");
      for(const List<String>::Node* i = file.output.getFirst(); i; i = i->getNext())
        customBuildOutput.append(i->data);
    }

    if(config.type == ProjectConfiguration::applicationType)
      fileWrite(String("add_executable(") + targetName + " " + joinPaths(config.sourceFiles) + " " + joinPaths(customBuildOutput, true) + ")\n");
    else if(config.type == ProjectConfiguration::dynamicLibraryType)
      fileWrite(String("add_library(") + targetName + " SHARED " + joinPaths(config.sourceFiles) + " " + joinPaths(customBuildOutput, true) + ")\n");
    else if(config.type == ProjectConfiguration::staticLibraryType)
      fileWrite(String("add_library(") + targetName + " STATIC " + joinPaths(config.sourceFiles) + " " + joinPaths(customBuildOutput, true) + ")\n");
    else if(config.type == ProjectConfiguration::customTargetType)
    {
        if(!target.output.isEmpty() && !target.command.isEmpty())
        {
          fileWrite("add_custom_command(\n");
          fileWrite(String("  OUTPUT ") + joinPaths(target.output, true) + "\n");

          Map<String, void*> outputDirs;
          for(const List<String>::Node* i = target.output.getFirst(); i; i = i->getNext())
          {
            String dir = ::File::getDirname(i->data);
            if(dir != "." && !outputDirs.find(dir))
              outputDirs.append(dir);
            customBuildOutput.append(i->data);
          }
          for(Map<String, void*>::Node* i = outputDirs.getFirst(); i; i = i->getNext())
            fileWrite(String("  COMMAND ${CMAKE_COMMAND} -E make_directory ") + translatePath(i->key, true) + "\n");

          for(const List<String>::Node* i = target.command.getFirst(); i; i = i->getNext())
            fileWrite(String("  COMMAND ") + i->data + "\n");
          fileWrite(String("  DEPENDS ") + joinPaths(target.input) + "\n");
          fileWrite("  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..\n");
          if(!target.message.isEmpty())
            fileWrite(String("  COMMENT \"") + target.message.getFirst()->data + "\"\n");
          fileWrite("  )\n");
        }
        fileWrite(String("add_custom_target(") + targetName + " ALL\n");
        fileWrite(String("  DEPENDS ") + joinPaths(customBuildOutput, true) + "\n");
        fileWrite(String("  SOURCES ") + joinPaths(config.sourceFiles) + "\n");
        fileWrite("  )\n");
    }
    /*
  if(!config.libs.isEmpty())
  {
    List<String> libs;
    for(const List<Library>::Node* i = config.libs.getFirst(); i; i = i->getNext())
    {
      const Library& lib = i->data;
      if(lib.type == Library::localType)
        libs.append(lib.name);
      else
      {
        fileWrite(String("find_library(") + lib.name + "_LIBRARY " + lib.name + " PATHS " + join(target.libPaths) + ")\n");
        libs.append(String("${") + lib.name + "_LIBRARY}");
      }
    }

    fileWrite(String("target_link_libraries(") + targetName + " " + join(libs) + ")\n");
  }
  */
    if(!config.libs.isEmpty())
    {
      List<String> libs;
      for(const List<Library>::Node* i = config.libs.getFirst(); i; i = i->getNext())
        libs.append(i->data.name);
      fileWrite(String("target_link_libraries(") + targetName + " " + join(libs) + ")\n");
    }

    if(!target.cppCompiler.isEmpty())
    {
      String cppCompiler;
      for(const List<String>::Node* i = target.cppCompiler.getFirst(); i; i = i->getNext())
      {
        const String& word = i->data;
        size_t sep;
        if(word.find('=', sep))
          fileWrite(String("set(ENV{") + word.substr(0, sep) +  "} \"" + word.substr(sep + 1) + "\")\n");
        else
        {
          cppCompiler = word;
          break;
        }
      }

      if(!cppCompiler.isEmpty())
      {
        if(!::File::isPathAbsolute(cppCompiler) && ::File::exists(cppCompiler))
          fileWrite(String("set(CMAKE_CXX_COMPILER \"${CMAKE_CURRENT_SOURCE_DIR}/../../") + cppCompiler + "\")\n");
        else
          fileWrite(String("set(CMAKE_CXX_COMPILER \"") + cppCompiler + "\")\n");
      }
    }
    if(!target.cCompiler.isEmpty())
    {
      String cCompiler;
      for(const List<String>::Node* i = target.cCompiler.getFirst(); i; i = i->getNext())
      {
        const String& word = i->data;
        size_t sep;
        if(word.find('=', sep))
          fileWrite(String("set(ENV{") + word.substr(0, sep) +  "} \"" + word.substr(sep + 1) + "\")\n");
        else
        {
          cCompiler = word;
          break;
        }
      }

      if(!cCompiler.isEmpty())
      {
        if(!::File::isPathAbsolute(cCompiler) && ::File::exists(cCompiler))
          fileWrite(String("set(CMAKE_C_COMPILER \"${CMAKE_CURRENT_SOURCE_DIR}/../../") + cCompiler + "\")\n");
        else
          fileWrite(String("set(CMAKE_C_COMPILER \"") + cCompiler + "\")\n");
      }
    }

    /*
    if(!target.cppFlags.isEmpty())
      fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY COMPILE_FLAGS \"" + join(target.cppFlags) + "\")\n");
    */
    if(!target.cppFlags.isEmpty())
      fileWrite(String("set(CMAKE_CXX_FLAGS \"") + join(target.cppFlags) + "\")\n");
    if(!target.cFlags.isEmpty())
      fileWrite(String("set(CMAKE_C_FLAGS \"") + join(target.cFlags) + "\")\n");

    if(!target.output.isEmpty())
    {
      String outputDirectory = ::File::getDirname(target.output.getFirst()->data);
      // Hi cmake devs! I do not know whats considered to be an ARCHIVE, LIBRARY or RUNTIME. So I will set all properties to be sure.
      fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY ARCHIVE_OUTPUT_DIRECTORY \"" + translatePath(outputDirectory) + "\")\n");
      fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY LIBRARY_OUTPUT_DIRECTORY \"" + translatePath(outputDirectory) + "\")\n");
      fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY RUNTIME_OUTPUT_DIRECTORY \"" + translatePath(outputDirectory) + "\")\n");

      String outputName = ::File::getWithoutExtension(::File::getBasename(target.output.getFirst()->data));
      outputName.patsubst("lib%", "%");
      fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY OUTPUT_NAME \"" + outputName + "\")\n");
    }

    if(!target.linkFlags.isEmpty())
    {
      if(config.type == ProjectConfiguration::staticLibraryType)
        fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY STATIC_LIBRARY_FLAGS " + join(target.linkFlags) + ")\n");
      else
        fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY LINK_FLAGS \"" + join(target.linkFlags) + "\")\n");
    }

    if(!target.defines.isEmpty())
      fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY COMPILE_DEFINITIONS " + join(target.defines) + ")\n");

    if(!target.dependencies.isEmpty())
      fileWrite(String("add_dependencies(") + targetName + " " + join(target.dependencies) + ")\n");
  }
  fileWrite("endif()\n");

  fileClose();
  return true;
}
Пример #22
0
FITSViewer::FITSViewer (const KURL *url, QWidget *parent, const char *name)
	: KMainWindow (parent, name)
{
    image      = NULL;
    currentURL = *url;
    imgBuffer  = NULL;
    histo      = NULL;
    Dirty      = 0;
    
    /* Initiliaze menu actions */
    history = new KCommandHistory(actionCollection());
    history->setUndoLimit(10);
    history->setRedoLimit(10);
    history->documentSaved();
    connect(history, SIGNAL(documentRestored()), this, SLOT(fitsRestore()));
    
    /* Setup image widget */    
    image = new FITSImage(this);
    setCentralWidget(image);
   
    statusBar()->insertItem("", 0);
    statusBar()->setItemFixed(0, 100);
    statusBar()->insertItem("", 1);
    statusBar()->setItemFixed(1, 100);
    statusBar()->insertItem("", 2);
    statusBar()->setItemFixed(2, 100);
    statusBar()->insertItem(i18n("Welcome to KStars FITS Viewer"), 3, 1, true);
    statusBar()->setItemAlignment(3 , Qt::AlignLeft);
    
    /* FITS initializations */
    if (!initFITS())
    {
     close();
     return;
    }
     
    QFile tempFile;
    
    if (KSUtils::openDataFile( tempFile, "imgreduction.png" ) )
    {
    	new KAction( i18n("Image Reduction"), tempFile.name(), KShortcut( "Ctrl+R" ), this, SLOT( imageReduction()), actionCollection(), "image_reduce");
	tempFile.close();
    }
    else
    	new KAction( i18n("Image Reduction"), "blend", KShortcut( "Ctrl+R" ), this, SLOT( imageReduction()), actionCollection(), "image_reduce");
	
    /*if (KSUtils::openDataFile( tempFile, "bricon.png" ) )
    {
    	new KAction( i18n("Brightness/Contrast"), tempFile.name(), KShortcut( "Ctrl+T" ), this, SLOT( BrightContrastDlg()), actionCollection(), "image_brightness_contrast");
	tempFile.close();
    }
    else*/
       	new KAction( i18n("Brightness/Contrast"), "contrast+", KShortcut( "Ctrl+T" ), this, SLOT( BrightContrastDlg()), actionCollection(), "image_brightness_contrast");
	
    if (KSUtils::openDataFile( tempFile, "histogram.png" ) )
    {
    	new KAction ( i18n("Histogram"), tempFile.name(), KShortcut("Ctrl+H"), this, SLOT (imageHistogram()), actionCollection(), "image_histogram");
	tempFile.close();
    }
    else
        new KAction ( i18n("Histogram"), "wizard", KShortcut("Ctrl+H"), this, SLOT (imageHistogram()), actionCollection(), "image_histogram");
    
    KStdAction::open(this, SLOT(fileOpen()), actionCollection());   
    KStdAction::save(this, SLOT(fileSave()), actionCollection());
    KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
    KStdAction::close(this, SLOT(slotClose()), actionCollection());
    KStdAction::copy(this, SLOT(fitsCOPY()), actionCollection());
    KStdAction::zoomIn(image, SLOT(fitsZoomIn()), actionCollection());
    KStdAction::zoomOut(image, SLOT(fitsZoomOut()), actionCollection());
    new KAction( i18n( "&Default Zoom" ), "viewmagfit.png", KShortcut( "Ctrl+D" ),
		image, SLOT(fitsZoomDefault()), actionCollection(), "zoom_default" );
    new KAction( i18n( "Statistics"), "sum", 0, this, SLOT(fitsStatistics()), actionCollection(), "image_stats");
    new KAction( i18n( "FITS Header"), "frame_spreadsheet.png", 0, this, SLOT(fitsHeader()), actionCollection(), "fits_editor");
    
   /* Create GUI */  
   createGUI("fitsviewer.rc");
     
   /* initially resize in accord with KDE rules */
   resize(640, 480); 
}
Пример #23
0
void TextEdit::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    QIcon newIcon = QIcon::fromTheme("document-new", QIcon(rsrcPath + "/filenew.png"));
    a = new QAction( newIcon, tr("&New"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::New);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon::fromTheme("document-open", QIcon(rsrcPath + "/fileopen.png")),
                    tr("&Open..."), this);
    a->setShortcut(QKeySequence::Open);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();


   	actionSave = a = new QAction(QIcon::fromTheme("document-save", QIcon(rsrcPath + "/filesave.png")),
                                 tr("&Save"), this);
    a->setShortcut(QKeySequence::Save);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);
    menu->addSeparator();

    a = new QAction(tr("Save &As ODT..."), this);
    a->setPriority(QAction::LowPriority);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAsOdt()));
    menu->addAction(a);
    
    a = new QAction(tr("Save &As HTML..."), this);
    a->setPriority(QAction::LowPriority);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAsHtml()));
    menu->addAction(a);
    menu->addSeparator();


#ifndef QT_NO_PRINTER
    //a = new QAction(QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png")),
    //                tr("&Print..."), this);
    //a->setPriority(QAction::LowPriority);
    //a->setShortcut(QKeySequence::Print);
    //connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    //tb->addAction(a);
    //menu->addAction(a);

    //a = new QAction(QIcon::fromTheme("fileprint", QIcon(rsrcPath + "/fileprint.png")),
     //               tr("Print Preview..."), this);
    //connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
    //menu->addAction(a);

    a = new QAction(QIcon::fromTheme("exportpdf", QIcon(rsrcPath + "/exportpdf.png")),
    tr("&Export PDF..."), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(Qt::CTRL + Qt::Key_D);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();
#endif

    a = new QAction(tr("&Quit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(a, SIGNAL(triggered()), this, SLOT(close()));
    menu->addAction(a);
}
Пример #24
0
/*-----------------------------------------------------------------------------
    Name        : spTitleListLoad
    Description : Scans the missions directory and loads in the titles of all
                    the mission files available.
    Inputs      : void
    Outputs     : Fills in spScenarios and spNumberScenarios
    Return      : void
----------------------------------------------------------------------------*/
void spTitleListLoad(void)
{
#if !(defined(CGW) || defined (Downloadable) || defined(DLPublicBeta) || defined(OEM))
    struct _finddata_t find;
    sdword handle, startHandle;
#endif
    sdword index, numplayers;
    char fileName[_MAX_PATH], nameBuffer[_MAX_PATH];
#if MAIN_Password
    char upperNameBuffer[_MAX_PATH];
#endif
    char bitmapfileName[_MAX_PATH];
    char *pString;
    char *title;
    filehandle scriptFile;

#if defined(CGW) || defined(Downloadable) || defined(DLPublicBeta)
    scriptFile = fileOpen("DemoMissions.script", FF_TextMode);
#else
    //oem has all missions!
    scriptFile = fileOpen("multiPlayerMissions.script", FF_TextMode);
#endif
    dbgAssert(scriptFile != 0);

    while (fileLineRead(scriptFile, nameBuffer, _MAX_PATH) != FR_EndOfFile)
    {
        if (nameBuffer[0] == ';' || (nameBuffer[0] == '/' && nameBuffer[1] == '/'))
        {
            continue;
        }
        numplayers = 0;
        for (pString = nameBuffer; *pString != 0; pString++)
        {                                                   //search for a numeral character
            if (strchr("0123456789", *pString) != NULL)
            {                                               //if this is a numeral
                numplayers = atoi(pString);
                memset(fileName, 0, _MAX_PATH);
                memStrncpy(fileName, nameBuffer, pString - nameBuffer + 1);//copy the start of the string
                memStrncpy(bitmapfileName, nameBuffer, pString - nameBuffer + 1);//copy the start of the string
                strcat(fileName, "%d");                     //make something like:
                strcat(fileName, pString + 1);              //'StdGame%d.level'
            }
        }

        if (numplayers == 0)
        {
            goto alreadyLoaded;
        }

        title = spTitleFind("MultiPlayer\\", nameBuffer);
        if (title == NULL)
        {
            goto alreadyLoaded;                             //break-continue
        }
#if MAIN_Password
        if (!mainEnableSpecialMissions)
        {                                                   //if this is an "off-limits" mission
            strcpy(upperNameBuffer, title);
            _strupr(upperNameBuffer);
            if (strstr(upperNameBuffer, "ALL"))
            {
                memFree(title);
                goto alreadyLoaded;                         //break-continue
            }
        }
#endif //MAIN_Password

        for (index = 0; index < spNumberScenarios; index++)
        {
            if (!_stricmp(spScenarios[index].fileSpec, fileName))
            {                                               //if matching file specs,
                // matches, but we should update max number of player if necessary
                if (numplayers > spScenarios[index].maxplayers) spScenarios[index].maxplayers = numplayers;
                if (numplayers < spScenarios[index].minplayers) spScenarios[index].minplayers = numplayers;
                memFree(title);
                goto alreadyLoaded;                         //break-continue
            }
        }

        if (spNumberScenarios >= spScenarioListLength)
        {
            spScenarioListLength += SP_ScenarioListGrowth;
            spScenarios = memRealloc(spScenarios, spScenarioListLength * sizeof(spscenario), "spScenarios", NonVolatile);
        }
        dbgAssert(spNumberScenarios < spScenarioListLength);
        spScenarios[spNumberScenarios].fileSpec = memStringDupe(fileName);
        spScenarios[spNumberScenarios].bitmapfileSpec = memStringDupe(bitmapfileName);
        spScenarios[spNumberScenarios].title = title;
        spScenarios[spNumberScenarios].maxplayers = numplayers;
        spScenarios[spNumberScenarios].minplayers = numplayers;
        spNumberScenarios++;

alreadyLoaded:;
    }
    fileClose(scriptFile);

#if !(defined(CGW) || defined (Downloadable) || defined(DLPublicBeta) || defined(OEM))
    startHandle = handle = _findfirst(filePathPrepend("MultiPlayer\\*.", 0), &find);

    while (handle != -1)
    {
        if (find.name[0] == '.')
        {
            goto alreadyLoadedFromFileSystem;
        }
        fileName[0] = 0;
        numplayers = 0;
        for (pString = find.name; *pString != 0; pString++)
        {                                                   //search for a numeral character
            if (strchr("0123456789", *pString) != NULL)
            {                                               //if this is a numeral
                numplayers = atoi(pString);
                memset(fileName, 0, _MAX_PATH);
                strncpy(fileName, find.name, pString - find.name);//copy the start of the string
                memStrncpy(bitmapfileName, find.name, pString - find.name + 1);//copy the start of the string
                strcat(fileName, "%d");                     //make something like:
                strcat(fileName, pString + 1);              //'StdGame%d.level'
            }
        }
        if (numplayers == 0)
        {
            goto alreadyLoadedFromFileSystem;
        }

        if (fileName[0] == 0)
        {
            goto alreadyLoadedFromFileSystem;
        }

        title = spTitleFind("MultiPlayer\\", find.name);
        if (title == NULL)
        {
            goto alreadyLoadedFromFileSystem;
        }
#if MAIN_Password
        if (!mainEnableSpecialMissions)
        {                                                   //if this is an "off-limits" mission
            strcpy(upperNameBuffer, title);
            _strupr(upperNameBuffer);
            if (strstr(upperNameBuffer, "ALL"))
            {
                memFree(title);
                goto alreadyLoadedFromFileSystem;           //break-continue
            }
        }
#endif //MAIN_Password

        for (index = 0; index < spNumberScenarios; index++)
        {
            if (!_stricmp(spScenarios[index].fileSpec, fileName))
            {                                               //if matching file specs,
                // matches, but we should update max number of player if necessary
                if (numplayers > spScenarios[index].maxplayers) spScenarios[index].maxplayers = numplayers;
                if (numplayers < spScenarios[index].minplayers) spScenarios[index].minplayers = numplayers;
                memFree(title);
                goto alreadyLoadedFromFileSystem;                         //break-continue
            }
        }

        if (spNumberScenarios >= spScenarioListLength)
        {
            spScenarioListLength += SP_ScenarioListGrowth;
            spScenarios = memRealloc(spScenarios, spScenarioListLength * sizeof(spscenario), "spScenarios", NonVolatile);
        }
        dbgAssert(spNumberScenarios < spScenarioListLength);
        spScenarios[spNumberScenarios].fileSpec = memStringDupe(fileName);
        spScenarios[spNumberScenarios].bitmapfileSpec = memStringDupe(bitmapfileName);
        spScenarios[spNumberScenarios].title = title;
        spScenarios[spNumberScenarios].maxplayers = numplayers;
        spScenarios[spNumberScenarios].minplayers = numplayers;
        spNumberScenarios++;

alreadyLoadedFromFileSystem:;
        handle = _findnext(startHandle, &find);
    }
#endif //defined(CGW) || defined (Downloadable) || defined(DLPublicBeta) || defined(OEM)

    dbgAssert(spNumberScenarios > 0);
    if (spNumberScenarios > 1)
    {
        //alphabetically sort the scenario list
        qsort(&spScenarios[0],spNumberScenarios,sizeof(spscenario),compareScenariosCB);
    }

    //find the default scenario's index
    if (spCurrentSelected == 0)
    {                                                       //if it's not already selected
        spCurrentSelected = spScenarioFind(DefaultScenario);
    }
}
Пример #25
0
void hrInitBackground(void)
{
    char CurDir[PATH_MAX], NewDir[PATH_MAX];
    char hrImageName[PATH_MAX];
    filehandle handle;
    JPEGDATA    jp;
    unsigned char *pTempImage;
    udword i;

    getcwd(CurDir, PATH_MAX);

    hrImageName[0] = 0;
    if (singlePlayerGame)
    {
        hrChooseSinglePlayerBitmap(hrImageName);
    }
    else
    {
        hrChooseRandomBitmap(hrImageName);
    }

    getcwd(NewDir, PATH_MAX);

    dbgAssertOrIgnore(strcasecmp(CurDir,NewDir) == 0);

    // Load the bitmap image
    handle = fileOpen(hrImageName, FF_ReturnNULLOnFail|FF_IgnorePrepend);
    if (handle)
    {
        memset(&jp, 0, sizeof(jp));
        jp.input_file = handle;
        JpegInfo(&jp);

        fileSeek(handle, 0, SEEK_SET);

        hrBackXSize = jp.width;
        hrBackYSize = jp.height;

        jp.ptr = (unsigned char *)memAllocAttempt((hrBackXSize) * (hrBackYSize) * 3, "BackgroundTemp", NonVolatile);
        if (jp.ptr == NULL)
        {
            return;
        }
        
        JpegRead(&jp);
        fileClose(handle);

        hrBackXSize = 1; hrBackYSize = 1;
        while (hrBackXSize < jp.width) hrBackXSize <<= 1;
        while (hrBackYSize < jp.height) hrBackYSize <<= 1;
        pTempImage = (unsigned char *)memAllocAttempt(hrBackXSize * hrBackYSize * 3, "BackgroundTemp", NonVolatile);
        memset(pTempImage, 0, hrBackXSize * hrBackYSize * 3);
        for (i = 0; i < jp.height; i++)
            memcpy(pTempImage + (hrBackXSize * 3 * i), jp.ptr + (jp.width * 3 * i), jp.width * 3);

        glGenTextures(1, &hrBackgroundTexture);
        trClearCurrent();
        glBindTexture(GL_TEXTURE_2D, hrBackgroundTexture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, hrBackXSize, hrBackYSize,
                    0, GL_RGB, GL_UNSIGNED_BYTE, pTempImage);
        
        memFree(jp.ptr);
        memFree(pTempImage);
        
        hrBackXFrac = (GLfloat)jp.width / (GLfloat)hrBackXSize;
        hrBackYFrac = (GLfloat)jp.height / (GLfloat)hrBackYSize;
        hrBackXSize = jp.width;
        hrBackYSize = jp.height;
    }
}
Пример #26
0
static int
usersFileWrite(Ubox* box)
{
	Fs *fs;
	User *u;
	int i, r;
	Fsys *fsys;
	char *p, *q, *s;
	File *dir, *file;

	if((fsys = fsysGet("main")) == nil)
		return 0;
	fsysFsRlock(fsys);
	fs = fsysGetFs(fsys);

	/*
	 * BUG:
	 * 	the owner/group/permissions need to be thought out.
	 */
	r = 0;
	if((dir = fileOpen(fs, "/active")) == nil)
		goto tidy0;
	if((file = fileWalk(dir, uidadm)) == nil)
		file = fileCreate(dir, uidadm, ModeDir|0775, uidadm);
	fileDecRef(dir);
	if(file == nil)
		goto tidy;
	dir = file;
	if((file = fileWalk(dir, "users")) == nil)
		file = fileCreate(dir, "users", 0664, uidadm);
	fileDecRef(dir);
	if(file == nil)
		goto tidy;
	if(!fileTruncate(file, uidadm))
		goto tidy;

	p = s = vtMemAlloc(box->len+1);
	q = p + box->len+1;
	for(u = box->head; u != nil; u = u->next){
		p += snprint(p, q-p, "%s:%s:", u->uid, u->uname);
		if(u->leader != nil)
			p+= snprint(p, q-p, u->leader);
		p += snprint(p, q-p, ":");
		if(u->ngroup){
			p += snprint(p, q-p, u->group[0]);
			for(i = 1; i < u->ngroup; i++)
				p += snprint(p, q-p, ",%s", u->group[i]);
		}
		p += snprint(p, q-p, "\n");
	}
	r = fileWrite(file, s, box->len, 0, uidadm);
	vtMemFree(s);

tidy:
	if(file != nil)
		fileDecRef(file);
tidy0:
	fsysFsRUnlock(fsys);
	fsysPut(fsys);

	return r;
}
bool MainWindow::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0:
        showProperties((QObject*)static_QUType_ptr.get(_o+1));
        break;
    case 1:
        updateProperties((QObject*)static_QUType_ptr.get(_o+1));
        break;
    case 2:
        showDialogHelp();
        break;
    case 3:
        showDebugStep((QObject*)static_QUType_ptr.get(_o+1),(int)static_QUType_int.get(_o+2));
        break;
    case 4:
        showStackFrame((QObject*)static_QUType_ptr.get(_o+1),(int)static_QUType_int.get(_o+2));
        break;
    case 5:
        showErrorMessage((QObject*)static_QUType_ptr.get(_o+1),(int)static_QUType_int.get(_o+2),(const QString&)static_QUType_QString.get(_o+3));
        break;
    case 6:
        finishedRun();
        break;
    case 7:
        breakPointsChanged();
        break;
    case 8:
        fileNew();
        break;
    case 9:
        fileNewDialog();
        break;
    case 10:
        fileNewFile();
        break;
    case 11:
        fileClose();
        break;
    case 12:
        fileQuit();
        break;
    case 13:
        fileCloseProject();
        break;
    case 14:
        fileOpen();
        break;
    case 15:
        fileOpen((const QString&)static_QUType_QString.get(_o+1),(const QString&)static_QUType_QString.get(_o+2));
        break;
    case 16:
        fileOpen((const QString&)static_QUType_QString.get(_o+1),(const QString&)static_QUType_QString.get(_o+2),(const QString&)static_QUType_QString.get(_o+3));
        break;
    case 17:
        fileOpen((const QString&)static_QUType_QString.get(_o+1),(const QString&)static_QUType_QString.get(_o+2),(const QString&)static_QUType_QString.get(_o+3),(bool)static_QUType_bool.get(_o+4));
        break;
    case 18:
        static_QUType_bool.set(_o,fileSave());
        break;
    case 19:
        static_QUType_bool.set(_o,fileSaveForm());
        break;
    case 20:
        static_QUType_bool.set(_o,fileSaveProject());
        break;
    case 21:
        static_QUType_bool.set(_o,fileSaveAs());
        break;
    case 22:
        fileSaveAll();
        break;
    case 23:
        fileCreateTemplate();
        break;
    case 24:
        editUndo();
        break;
    case 25:
        editRedo();
        break;
    case 26:
        editCut();
        break;
    case 27:
        editCopy();
        break;
    case 28:
        editPaste();
        break;
    case 29:
        editDelete();
        break;
    case 30:
        editSelectAll();
        break;
    case 31:
        editLower();
        break;
    case 32:
        editRaise();
        break;
    case 33:
        editAdjustSize();
        break;
    case 34:
        editLayoutHorizontal();
        break;
    case 35:
        editLayoutVertical();
        break;
    case 36:
        editLayoutHorizontalSplit();
        break;
    case 37:
        editLayoutVerticalSplit();
        break;
    case 38:
        editLayoutGrid();
        break;
    case 39:
        editLayoutContainerHorizontal();
        break;
    case 40:
        editLayoutContainerVertical();
        break;
    case 41:
        editLayoutContainerGrid();
        break;
    case 42:
        editBreakLayout();
        break;
    case 43:
        editAccels();
        break;
    case 44:
        editFunctions();
        break;
    case 45:
        editConnections();
        break;
    case 46:
        static_QUType_ptr.set(_o,editSource());
        break;
    case 47:
        static_QUType_ptr.set(_o,editSource((SourceFile*)static_QUType_ptr.get(_o+1)));
        break;
    case 48:
        static_QUType_ptr.set(_o,openSourceEditor());
        break;
    case 49:
        static_QUType_ptr.set(_o,createSourceEditor((QObject*)static_QUType_ptr.get(_o+1),(Project*)static_QUType_ptr.get(_o+2)));
        break;
    case 50:
        static_QUType_ptr.set(_o,createSourceEditor((QObject*)static_QUType_ptr.get(_o+1),(Project*)static_QUType_ptr.get(_o+2),(const QString&)static_QUType_QString.get(_o+3)));
        break;
    case 51:
        static_QUType_ptr.set(_o,createSourceEditor((QObject*)static_QUType_ptr.get(_o+1),(Project*)static_QUType_ptr.get(_o+2),(const QString&)static_QUType_QString.get(_o+3),(const QString&)static_QUType_QString.get(_o+4)));
        break;
    case 52:
        static_QUType_ptr.set(_o,createSourceEditor((QObject*)static_QUType_ptr.get(_o+1),(Project*)static_QUType_ptr.get(_o+2),(const QString&)static_QUType_QString.get(_o+3),(const QString&)static_QUType_QString.get(_o+4),(bool)static_QUType_bool.get(_o+5)));
        break;
    case 53:
        editFormSettings();
        break;
    case 54:
        editProjectSettings();
        break;
    case 55:
        editPixmapCollection();
        break;
    case 56:
        editDatabaseConnections();
        break;
    case 57:
        editPreferences();
        break;
    case 58:
        projectInsertFile();
        break;
    case 59:
        searchFind();
        break;
    case 60:
        searchIncremetalFindMenu();
        break;
    case 61:
        searchIncremetalFind();
        break;
    case 62:
        searchIncremetalFindNext();
        break;
    case 63:
        searchReplace();
        break;
    case 64:
        searchGotoLine();
        break;
    case 65:
        previewForm();
        break;
    case 66:
        previewForm((const QString&)static_QUType_QString.get(_o+1));
        break;
    case 67:
        toolsCustomWidget();
        break;
    case 68:
        toolsConfigure();
        break;
    case 69:
        helpContents();
        break;
    case 70:
        helpManual();
        break;
    case 71:
        helpAbout();
        break;
    case 72:
        helpAboutQt();
        break;
    case 73:
        helpRegister();
        break;
    case 74:
        activeWindowChanged((QWidget*)static_QUType_ptr.get(_o+1));
        break;
    case 75:
        updateUndoRedo((bool)static_QUType_bool.get(_o+1),(bool)static_QUType_bool.get(_o+2),(const QString&)static_QUType_QString.get(_o+3),(const QString&)static_QUType_QString.get(_o+4));
        break;
    case 76:
        updateEditorUndoRedo();
        break;
    case 77:
        toolSelected((QAction*)static_QUType_ptr.get(_o+1));
        break;
    case 78:
        clipboardChanged();
        break;
    case 79:
        selectionChanged();
        break;
    case 80:
        windowsMenuActivated((int)static_QUType_int.get(_o+1));
        break;
    case 81:
        setupWindowActions();
        break;
    case 82:
        createNewTemplate();
        break;
    case 83:
        projectSelected((QAction*)static_QUType_ptr.get(_o+1));
        break;
    case 84:
        setupRecentlyFilesMenu();
        break;
    case 85:
        setupRecentlyProjectsMenu();
        break;
    case 86:
        recentlyFilesMenuActivated((int)static_QUType_int.get(_o+1));
        break;
    case 87:
        recentlyProjectsMenuActivated((int)static_QUType_int.get(_o+1));
        break;
    case 88:
        emitProjectSignals();
        break;
    case 89:
        showStartDialog();
        break;
    case 90:
        doFunctionsChanged();
        break;
    case 91:
        static_QUType_bool.set(_o,openProjectSettings((Project*)static_QUType_ptr.get(_o+1)));
        break;
    default:
        return QMainWindow::qt_invoke( _id, _o );
    }
    return TRUE;
}
Пример #28
0
int writeRec(recPar rec, modPar mod, bndPar bnd, wavPar wav, int ixsrc, int izsrc, int nsam, int ishot, int fileno, 
			 float *rec_vx, float *rec_vz, float *rec_txx, float *rec_tzz, float *rec_txz, 
			 float *rec_p, float *rec_pp, float *rec_ss, float *rec_udp, float *rec_udvz, int verbose)
{
    FILE    *fpvx, *fpvz, *fptxx, *fptzz, *fptxz, *fpp, *fppp, *fpss, *fpup, *fpdown;
	float *rec_up, *rec_down, *trace, *rec_vze, *rec_pe;
	float dx, dt, cp, rho, fmin, fmax;
	complex *crec_vz, *crec_p, *crec_up, *crec_dw;
    int irec, ntfft, nfreq, nkx, xorig, ix, iz, it, ibndx;
	int append;
	double ddt;
	char number[16], filename[1024];
    segy hdr;
    
	if (!rec.n) return 0;
	if (ishot) append=1;
	else append=0;

	/* if the total number of samples exceeds rec_ntsam then a new (numbered) file is opened */
	/* fileno has a non-zero value (from fdelmodc.c) if the number of samples exceeds rec_ntsam. */
	strcpy(filename, rec.file_rcv);
	if (fileno) {
		sprintf(number,"_%03d",fileno);
		name_ext(filename, number);
	}

	if (verbose>2) vmess("Writing receiver data to file %s", filename);
	if (nsam != rec.nt && verbose) vmess("Number of samples written to last file = %d",nsam);

	memset(&hdr,0,TRCBYTES);
	ddt = (double)mod.dt;/* to avoid rounding in 32 bit precision */
    dt  = (float)ddt*rec.skipdt;
	dx  = (rec.x[1]-rec.x[0])*mod.dx;
	hdr.dt     = (unsigned short)lround((((double)1.0e6*ddt*rec.skipdt)));
	hdr.scalco = -1000;
	hdr.scalel = -1000;
	hdr.sx     = 1000*(mod.x0+ixsrc*mod.dx);
	hdr.sdepth = 1000*(mod.z0+izsrc*mod.dz);
    hdr.selev  = (int)(-1000.0*(mod.z0+izsrc*mod.dz));
	hdr.fldr   = ishot+1;
	hdr.trid   = 1;
	hdr.ns     = nsam;
	hdr.trwf   = rec.n;
	hdr.ntr    = (ishot+1)*rec.n;
	hdr.f1     = 0.0;
	hdr.d1     = mod.dt*rec.skipdt;
	hdr.d2     = (rec.x[1]-rec.x[0])*mod.dx;
	hdr.f2     = mod.x0+rec.x[0]*mod.dx;

	if (rec.type.vx)  fpvx  = fileOpen(filename, "_rvx", append);
	if (rec.type.vz)  fpvz  = fileOpen(filename, "_rvz", append);
	if (rec.type.p)   fpp   = fileOpen(filename, "_rp", append);
	if (rec.type.txx) fptxx = fileOpen(filename, "_rtxx", append);
	if (rec.type.tzz) fptzz = fileOpen(filename, "_rtzz", append);
	if (rec.type.txz) fptxz = fileOpen(filename, "_rtxz", append);
	if (rec.type.pp)  fppp  = fileOpen(filename, "_rpp", append);
	if (rec.type.ss)  fpss  = fileOpen(filename, "_rss", append);

	/* decomposed wavefield */
	if (rec.type.ud && (mod.ischeme==1 || mod.ischeme==2) )  {
		fpup   = fileOpen(filename, "_ru", append);
		fpdown = fileOpen(filename, "_rd", append);
		ntfft = optncr(nsam);
		nfreq = ntfft/2+1;
		fmin = 0.0;
		fmax = wav.fmax;
		nkx = optncc(2*mod.nax);
		ibndx = mod.ioPx;
    	if (bnd.lef==4 || bnd.lef==2) ibndx += bnd.ntap;
		cp  = rec.cp;
		rho = rec.rho;
		if (verbose) vmess("Decomposition array at z=%.2f with cp=%.2f rho=%.2f", rec.zr[0]+mod.z0, cp, rho);
		rec_up  = (float *)calloc(ntfft*nkx,sizeof(float));
		rec_down= (float *)calloc(ntfft*nkx,sizeof(float));
		crec_vz = (complex *)malloc(nfreq*nkx*sizeof(complex));
		crec_p  = (complex *)malloc(nfreq*nkx*sizeof(complex));
		crec_up = (complex *)malloc(nfreq*nkx*sizeof(complex));
		crec_dw = (complex *)malloc(nfreq*nkx*sizeof(complex));

		rec_vze = rec_up;
		rec_pe  = rec_down;
		/* copy input data into extended arrays with padded zeroes */
		for (ix=0; ix<mod.nax; ix++) {
			memcpy(&rec_vze[ix*ntfft],&rec_udvz[ix*rec.nt],nsam*sizeof(float));
			memcpy(&rec_pe[ix*ntfft], &rec_udp[ix*rec.nt], nsam*sizeof(float));
		}

		/* transform from t-x to kx-w */
		xorig = ixsrc+ibndx;
		xt2wkx(rec_vze, crec_vz, ntfft, nkx, ntfft, nkx, xorig);
		xt2wkx(rec_pe, crec_p, ntfft, nkx, ntfft, nkx, xorig);

		/* apply decomposition operators */
		kxwdecomp(crec_p, crec_vz, crec_up, crec_dw,
               nkx, mod.dx, nsam, dt, fmin, fmax, cp, rho, verbose);

		/* transform back to t-x */
		wkx2xt(crec_up, rec_up, ntfft, nkx, nkx, ntfft, xorig);
		wkx2xt(crec_dw, rec_down, ntfft, nkx, nkx, ntfft, xorig);

		/* reduce array to rec.nt samples rec.n traces */
		for (irec=0; irec<rec.n; irec++) {
			ix = rec.x[irec]+ibndx;
			for (it=0; it<rec.nt; it++) {
				rec_up[irec*rec.nt+it]   = rec_up[ix*ntfft+it];
				rec_down[irec*rec.nt+it] = rec_down[ix*ntfft+it];
			}
		}
		free(crec_vz);
		free(crec_p);
		free(crec_up);
		free(crec_dw);
	}
	if (rec.type.ud && (mod.ischeme==3 || mod.ischeme==4) )  {
	}

	for (irec=0; irec<rec.n; irec++) {
		hdr.tracf  = irec+1;
		hdr.tracl  = ishot*rec.n+irec+1;
		hdr.gx     = 1000*(mod.x0+rec.x[irec]*mod.dx);
		hdr.offset = (rec.x[irec]-ixsrc)*mod.dx;
        hdr.gelev  = (int)(-1000*(mod.z0+rec.z[irec]*mod.dz));

		if (rec.type.vx) {
			traceWrite( &hdr, &rec_vx[irec*rec.nt], nsam, fpvx) ;
		}
		if (rec.type.vz) {
			traceWrite( &hdr, &rec_vz[irec*rec.nt], nsam, fpvz) ;
		}
		if (rec.type.p) {
			traceWrite( &hdr, &rec_p[irec*rec.nt], nsam, fpp) ;
		}
		if (rec.type.txx) {
			traceWrite( &hdr, &rec_txx[irec*rec.nt], nsam, fptxx) ;
		}
		if (rec.type.tzz) {
			traceWrite( &hdr, &rec_tzz[irec*rec.nt], nsam, fptzz) ;
		}
		if (rec.type.txz) {
			traceWrite( &hdr, &rec_txz[irec*rec.nt], nsam, fptxz) ;
		}
		if (rec.type.pp) {
			traceWrite( &hdr, &rec_pp[irec*rec.nt], nsam, fppp) ;
		}
		if (rec.type.ss) {
			traceWrite( &hdr, &rec_ss[irec*rec.nt], nsam, fpss) ;
		}
		if (rec.type.ud && mod.ischeme==1)  {
			traceWrite( &hdr, &rec_up[irec*rec.nt], nsam, fpup) ;
			traceWrite( &hdr, &rec_down[irec*rec.nt], nsam, fpdown) ;
		}
	}

	if (rec.type.vx) fclose(fpvx);
	if (rec.type.vz) fclose(fpvz);
	if (rec.type.p) fclose(fpp);
	if (rec.type.txx) fclose(fptxx);
	if (rec.type.tzz) fclose(fptzz);
	if (rec.type.txz) fclose(fptxz);
	if (rec.type.pp) fclose(fppp);
	if (rec.type.ss) fclose(fpss);
	if (rec.type.ud) {
		fclose(fpup);
		fclose(fpdown);
		free(rec_up);
		free(rec_down);
	}

    return 0;
}
Пример #29
0
void DevGUI::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    a = new QAction(QIcon(":/new.png"), tr("&New..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_N);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(":/open.png"), tr("&Open..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_O);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    actionSave = a = new QAction(QIcon(":/save.png"), tr("&Save"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_S);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);
    
    a = new QAction(QIcon(":/save.png"), tr("Save &As..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
    a->setEnabled(false);
    menu->addAction(a);

    menu->addSeparator();

    actionSaveAll = a = new QAction(QIcon(":/saveall.png"), tr("&Save All"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_A);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAll()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    a = new QAction(QIcon(":/print.png"), tr("&Print..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_P);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    tb->addAction(a);
    menu->addAction(a);

    actionClose = a = new QAction(QIcon(":/close.png"), tr("&Close"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_W);
	a->setEnabled(false);
    connect(a, SIGNAL(triggered()), this, SLOT(fileClose()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    a = new QAction(QIcon(":/exit.png"), tr("E&xit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect( a, SIGNAL(triggered()), qApp, SLOT( quit() ) );
    menu->addAction(a);
}
Пример #30
0
  void Init()
  {
#ifndef REGAL_NO_GETENV
    const char *tmp;

    tmp = GetEnv("REGAL_LOG_ERROR");
    if (tmp) enableError = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_WARNING");
    if (tmp) enableWarning = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_INFO");
    if (tmp) enableInfo = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_APP");
    if (tmp) enableApp = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_DRIVER");
    if (tmp) enableDriver = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_INTERNAL");
    if (tmp) enableInternal = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_HTTP");
    if (tmp) enableHttp = atoi(tmp)!=0;

    //

    tmp = GetEnv("REGAL_LOG_API");
    if (tmp && atoi(tmp)) enableApp = enableDriver = true;

    tmp = GetEnv("REGAL_LOG_ALL");
    if (tmp && atoi(tmp)) enableError = enableWarning = enableInfo = enableApp = enableDriver = enableInternal = enableHttp = true;

    //

    tmp = GetEnv("REGAL_LOG_MAX_LINES");
    if (tmp) maxLines = atoi(tmp);

    tmp = GetEnv("REGAL_LOG_MAX_BYTES");
    if (tmp) maxBytes = atoi(tmp);

#if REGAL_LOG_ONCE
    tmp = GetEnv("REGAL_LOG_ONCE");
    if (tmp) once = atoi(tmp)!=0;
#endif

    tmp = GetEnv("REGAL_FRAME_TIME");
    if (tmp) frameTime = atoi(tmp)!=0;

#if REGAL_LOG_POINTERS
    tmp = GetEnv("REGAL_LOG_POINTERS");
    if (tmp) pointers = atoi(tmp)!=0;
#endif

#if REGAL_LOG_THREAD
    tmp = GetEnv("REGAL_LOG_THREAD");
    if (tmp) thread = atoi(tmp)!=0;
#endif

#if REGAL_LOG_PROCESS
    tmp = GetEnv("REGAL_LOG_PROCESS");
    if (tmp) process = atoi(tmp)!=0;
#endif

    tmp = GetEnv("REGAL_LOG_CALLBACK");
    if (tmp) callback = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG");
    if (tmp) log = atoi(tmp)!=0;

    tmp =  GetEnv("REGAL_LOG_FILE");
    if (tmp) logFilename = tmp;

    tmp = GetEnv("REGAL_LOG_JSON");
    if (tmp) json = atoi(tmp)!=0;

    tmp = GetEnv("REGAL_LOG_JSON_FILE");
    if (tmp) jsonFilename = tmp;

    tmp = GetEnv("REGAL_HTTP_LOG_LIMIT");
    if (tmp) bufferLimit = atoi(tmp);
#endif

#ifdef REGAL_HTTP_LOG_LIMIT
    bufferLimit = REGAL_HTTP_LOG_LIMIT;
#endif

    if (bufferLimit)
      buffer = new list<string>();

    // Text logging

    if (logFilename.length())
      logOutput = fileOpen(logFilename.c_str(),"wt");

    // JSON logging

    if (jsonFilename.length())
      jsonOutput = fileOpen(jsonFilename.c_str(),"wt");
    if (jsonOutput)
      fprintf(jsonOutput,"%s","{ \"traceEvents\" : [\n");

    Internal("Logging::Init","()");

    initialized = true;

#if REGAL_LOG
    Info("REGAL_LOG          ", log            ? "enabled" : "disabled");
#endif

#if REGAL_LOG_ERROR
    Info("REGAL_LOG_ERROR    ", enableError    ? "enabled" : "disabled");
#endif

#if REGAL_LOG_WARNING
    Info("REGAL_LOG_WARNING  ", enableWarning  ? "enabled" : "disabled");
#endif

#if REGAL_LOG_INFO
    Info("REGAL_LOG_INFO     ", enableInfo     ? "enabled" : "disabled");
#endif

#if REGAL_LOG_APP
    Info("REGAL_LOG_APP      ", enableApp      ? "enabled" : "disabled");
#endif

#if REGAL_LOG_DRIVER
    Info("REGAL_LOG_DRIVER   ", enableDriver   ? "enabled" : "disabled");
#endif

#if REGAL_LOG_INTERNAL
    Info("REGAL_LOG_INTERNAL ", enableInternal ? "enabled" : "disabled");
#endif

#if REGAL_LOG_HTTP
    Info("REGAL_LOG_HTTP     ", enableHttp     ? "enabled" : "disabled");
#endif

#if REGAL_LOG_JSON
    Info("REGAL_LOG_JSON     ", json           ? "enabled" : "disabled");
#endif

#if REGAL_LOG_CALLBACK
    Info("REGAL_LOG_CALLBACK ", callback       ? "enabled" : "disabled");
#endif

#if REGAL_LOG_ONCE
    Info("REGAL_LOG_ONCE     ", once           ? "enabled" : "disabled");
#endif

#if REGAL_LOG_POINTERS
    Info("REGAL_LOG_POINTERS ", pointers       ? "enabled" : "disabled");
#endif

#if REGAL_LOG_THREAD
    Info("REGAL_LOG_THREAD   ", thread         ? "enabled" : "disabled");
#endif

#if REGAL_LOG_PROCESS
    Info("REGAL_LOG_PROCESS  ", process        ? "enabled" : "disabled");
#endif
  }