예제 #1
0
HRESULT CTryData4Dlg::OnDataExport(IHTMLElement* pElement)
{
	if(m_State == RUNNING) return S_OK;
	if(m_bAddData)		InternalRoutines('9'); //update the 测量结果
	CString content,result;
	char DirUse[300];
	::GetCurrentDirectory(300,DirUse);
	content=CString(GetElementHtml("cont"));
	content.Replace("单击测量","    ");
	CFileDialog cfd(FALSE,_T("htm"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("Html File(*.htm)|*.htm||"),NULL);
	if(cfd.DoModal() == IDOK){
		CStdioFile jsfile;
		if(jsfile.Open(cfd.GetPathName(),CFile::modeCreate|CFile::modeWrite)){
			jsfile.WriteString(content);
			jsfile.Close();
			if(::AfxMessageBox("原始数据已导出成功\n是否需要立即打印原始数据报告?",MB_YESNO) == IDYES)
			{
				ShellExecute(0,"print",cfd.GetPathName(),"","",SW_HIDE);
			}
		}
		else
		{
			::AfxMessageBox("原始数据保存失败");
		}
		::SetCurrentDirectory(DirUse);
	}
    return S_OK;
}
예제 #2
0
void CCollegeTimeTableView::OnFileOpen() 
{	CFileDialog cfd(TRUE,"tit","*.tit");
    if(cfd.DoModal()==IDOK)
	{ CString token;
	  CString college;
	  CString filepath=cfd.GetPathName();
	  CFile thefile;
	  CFileException exc;

	  thefile.Open(filepath,CFile::modeRead,&exc);
     CArchive archive(&thefile,CArchive::load);
       
        int i,j;

		CString temp;
        
		archive>>token
		       >>college;
        for (i=1;i<ROWS;i++)
			for(j=0;j<COLS;j++)  
			{ archive>>temp;
			  m_master.SetItemText(i,j,temp);
			}	
    	RefreshFormat();
		archive.Close();
		thefile.Close();
	}
//=================================================================================
///	GetPictures
///
///	This function collects all the pictures the user chooses into a vector.
//=================================================================================
void CSLICSuperpixelsDlg::GetPictures(vector<string>& picvec)
{
	CFileDialog cfd(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,L"*.*|*.*|",NULL);
	cfd.m_ofn.Flags |= OFN_ALLOWMULTISELECT;

	//cfd.PostMessage(WM_COMMAND, 40964, NULL);
	
	CString strFileNames;
	cfd.m_ofn.lpstrFile = strFileNames.GetBuffer(2048);
	cfd.m_ofn.nMaxFile = 2048;

	BOOL bResult = cfd.DoModal() == IDOK ? TRUE : FALSE;
	strFileNames.ReleaseBuffer();

	//if(cfd.DoModal() == IDOK)
	if( bResult )
	{
		POSITION pos = cfd.GetStartPosition();
		while (pos) 
		{
			CString imgFile = cfd.GetNextPathName(pos);			
			PictureHandler ph;
			string name = ph.Wide2Narrow(imgFile.GetString());
			picvec.push_back(name);
		}
	}
	else return;
}
void CLogDlg::OnBnClickedButtonSaveas() {
    CFileDialog cfd(FALSE, "txt", "live_tools_log", OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
                    "*.txt|*.txt|All|*||", this);

    if (IDOK == cfd.DoModal()) {
        CLogMgr::Instance().SaveAs(cfd.GetPathName());
    }
}
예제 #5
0
파일: MainFrm.cpp 프로젝트: ohzooboy/oh
void CMainFrame::OnFileLoadTableMap() 
{
	CFileDialog			cfd(true);
	int					line = 0, ret = 0;
	CString				e = "";

	cfd.m_ofn.lpstrInitialDir = prefs.path_tm();
	cfd.m_ofn.lpstrFilter = "OpenScrape Table Maps (.tm)\0*.tm\0All files (*.*)\0*.*\0\0";
	cfd.m_ofn.lpstrTitle = "Select OpenScrape table map to OPEN";

	if (cfd.DoModal() == IDOK)
	{
		CString loaded_version;
		ret = p_tablemap->LoadTablemap(cfd.m_ofn.lpstrFile, VER_OPENSCRAPE_2, &line, &loaded_version);
		
		if (loaded_version == VER_OPENHOLDEM_1 && ret == ERR_VERSION && !prefs.disable_msgbox())
		{
			e.Format("This is an OpenHoldem v1 profile (.ohdb1).\n"
					 "OpenHoldem versions 1.2.0 and higher require v2 Profiles (.ohdb2),\n"
					 "or OpenScrape Table Maps.\n");
			OH_MessageBox(e, "Table map load error", MB_OK);
		}

		else if ( (loaded_version == VER_OPENSCRAPE_1 || loaded_version == VER_OPENHOLDEM_2) )
		{
			OH_MessageBox("This is a version 1 table map.\n\n"\
					   "Version 2.0.0 and higher of OpenHoldem use a new format (version 2).  This\n"\
					   "table map has been loaded, but it is highly unlikely to work correctly until\n"\
					   "it has been opened in OpenScrape version 2.0.0 or higher, and adjustments\n"\
					   "have been made to autoplayer settings and region sizes.\n\n"\
					   "Please do not use this table map prior to updating it to version 2 in\n"\
					   "OpenScrape or you run the very serious risk of costly mis-scrapes.",
					   "Table map load warning", MB_OK | MB_ICONEXCLAMATION);		
		}

		else if (ret != SUCCESS)
		{
			e.Format("Error code: %d  line: %d", ret, line);
			OH_MessageBox(e, "Table map load error", MB_OK);
		}
		
		if (ret == SUCCESS)
		{
			// Reset "ScraperOutput" dialog, if it is live
			if (m_ScraperOutputDlg) 
			{
				m_ScraperOutputDlg->AddListboxItems();
				m_ScraperOutputDlg->UpdateDisplay();
			}

			prefs.set_path_tm(cfd.GetPathName());
		}
	}
}
예제 #6
0
void CFrameLocs::OnFileExportlist() 
{
	// TODO: Add your command handler code here
	CFileDialog cfd(FALSE, "xml", NULL, OFN_OVERWRITEPROMPT, "XML file (*.xml)|*.xml|Text file (*.txt)|*.txt|Locations List (*.lox)|*.lox|Rich List Format (*.rl)|*.rl||");

	if (cfd.DoModal() != IDOK)
		return;

	// 0 = TXT, 1 = XML
	theLocs.SaveAs( cfd.GetPathName(), cfd.m_ofn.nFilterIndex);	
	
}
예제 #7
0
void CMainFrame::OnDllLoadspecificfile() {
	CFileDialog			cfd(true);

	cfd.m_ofn.lpstrInitialDir = preferences.path_dll();
	cfd.m_ofn.lpstrFilter = "DLL Files (.dll)\0*.dll\0\0";
	cfd.m_ofn.lpstrTitle = "Select OpenHoldem DLL file to OPEN";

	if (cfd.DoModal() == IDOK) {
		p_dll_extension->Load(cfd.m_ofn.lpstrFile);
		preferences.SetValue(k_prefs_path_dll, cfd.GetPathName());
	}
}
예제 #8
0
파일: MainFrm.cpp 프로젝트: ohzooboy/oh
void CMainFrame::OnPerlLoadSpecificFormula()
{
    CFileDialog			cfd(true);

    cfd.m_ofn.lpstrInitialDir = preferences.path_perl();
    cfd.m_ofn.lpstrFilter = "Perl Scripts (*.pl)\0*.pl\0Perl Modules (*.pm)\0*.pm\0All Files (*.*)\0*.*\0\0";
    cfd.m_ofn.lpstrTitle = "Select Perl formula file to OPEN";
    if (cfd.DoModal() == IDOK)
    {
        p_perl->LoadFormulaFile(cfd.m_ofn.lpstrFile);
        preferences.SetValue(k_prefs_path_perl, cfd.GetPathName());
    }
}
예제 #9
0
LRESULT CMainFrame::OnFileOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
{
	static TCHAR filter[] = _T("PDB files (*.pdb)\0*.pdb\0All files (*.*)\0*.*\0\0");
	CFileDialog cfd(TRUE, NULL, NULL, 4|2, filter, this->m_hWnd);
	cfd.m_ofn.Flags |= OFN_NOCHANGEDIR;
	if(cfd.DoModal() == IDOK)
	{
		m_view.LoadMolecule(cfd.m_ofn.lpstrFile);
		CString title;
		title.Format(_T("%s: %s"), _APPTITLE, cfd.m_ofn.lpstrFileTitle);
		SetWindowText(title);
	}
	bHandled = TRUE;
	return 0;
}
예제 #10
0
void CMainFrame::OnFileOpen() {
  COpenHoldemDoc *pDoc = (COpenHoldemDoc *)this->GetActiveDocument();   
  if (!pDoc->SaveModified()) {
    return;        // leave the original one
  }
	CFileDialog			cfd(true);
  cfd.m_ofn.lpstrInitialDir = "";
  // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx
  cfd.m_ofn.lpstrFilter = "OpenHoldem Formula Files (*.ohf, *.oppl, *.txt)\0*.ohf;*.oppl;*.txt\0All files (*.*)\0*.*\0\0";
	cfd.m_ofn.lpstrTitle = "Select Formula file to OPEN";
	if (cfd.DoModal() == IDOK) {				
		pDoc->OnOpenDocument(cfd.GetPathName());
		pDoc->SetPathName(cfd.GetPathName());
		// Update window title, registry
		p_openholdem_title->UpdateTitle();
		theApp.StoreLastRecentlyUsedFileList();
	}
}
예제 #11
0
void SendSettings::setStudents(){
    ui->label_2->setAlignment(Qt::AlignCenter);

    if(m_Students->empty()){ //no students added this run
        string fpath;
        chooseFileDialog cfd(&fpath);
        cfd.setModal(true);
        cfd.exec();
        if(!loadFile(fpath)){
            ui->label_2->setText("Studenti nenačteni!");
            return;
        }
        QString text = "Studenti načteni z " + QString::fromStdString(fpath);
        ui->label_2->setText(text);
    } else {
        ui->label_2->setText("Studenti načteni z paměti programu.");
    }
}
예제 #12
0
파일: MainFrm.cpp 프로젝트: ohzooboy/oh
void CMainFrame::OnFileOpen()
{
    COpenHoldemDoc *pDoc = (COpenHoldemDoc *)this->GetActiveDocument();

    if (!pDoc->SaveModified())
        return;        // leave the original one

    CFileDialog			cfd(true);

    cfd.m_ofn.lpstrInitialDir = preferences.path_ohf();
    cfd.m_ofn.lpstrFilter = "OpenHoldem Files (.ohf)\0*.ohf\0All files (*.*)\0*.*\0\0";
    cfd.m_ofn.lpstrTitle = "Select Formula file to OPEN";
    if (cfd.DoModal() == IDOK)
    {
        pDoc->OnOpenDocument(cfd.GetPathName());
        pDoc->SetPathName(cfd.GetPathName());
        // Update window title, registry
        SetMainWindowTitle(cfd.GetFileTitle() + " - " + CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)));
        preferences.SetValue(k_prefs_path_ohf, cfd.GetPathName());
    }
}
예제 #13
0
파일: rectangle.cpp 프로젝트: aveminus/freq
void Rectangle::
        test()
{
    std::string name = "Rectangle";
    int argc = 1;
    char * argv = &name[0];
    QApplication a(argc,&argv);

    // It should apply a bandpass and time filter between f1,s1 and f2,s2 to a signal.
    {
        Signal::Processing::Chain::ptr cp = Signal::Processing::Chain::createDefaultChain ();
        Signal::OperationDesc::ptr transparent(new Test::TransparentOperationDesc);
        Signal::OperationDesc::ptr buffersource(new Signal::BufferSource(Test::RandomBuffer::smallBuffer ()));
        Tfr::ChunkFilterDesc::ptr cfd(new Rectangle(1,2,4,4,false));
        Signal::OperationDesc::ptr rectangledesc(new TransformOperationDesc(cfd));
        Signal::Processing::TargetMarker::ptr at = cp->addTarget(transparent);
        Signal::Processing::TargetNeeds::ptr n = at->target_needs();
        cp->addOperationAt(buffersource,at);
        cp->addOperationAt(rectangledesc,at);
        n->updateNeeds(Signal::Interval(0,10));
        EXCEPTION_ASSERT( n->sleep (200) );
    }
}
예제 #14
0
void test_action::test_cf_action() {

   eosio::action act = eosio::get_action( 0, 0 );
   cf_action cfa = act.data_as<cf_action>();
   if ( cfa.payload == 100 ) {
      // verify read of get_context_free_data, also verifies system api access
      int size = get_context_free_data( cfa.cfd_idx, nullptr, 0 );
      eosio_assert( size > 0, "size determination failed" );
      eosio::bytes cfd( static_cast<size_t>(size) );
      size = get_context_free_data( cfa.cfd_idx, &cfd[0], static_cast<size_t>(size) );
      eosio_assert(static_cast<size_t>(size) == cfd.size(), "get_context_free_data failed" );
      uint32_t v = eosio::unpack<uint32_t>( &cfd[0], cfd.size() );
      eosio_assert( v == cfa.payload, "invalid value" );

      // verify crypto api access
      checksum256 hash;
      char test[] = "test";
      sha256( test, sizeof(test), &hash );
      assert_sha256( test, sizeof(test), &hash );
      // verify action api access
      action_data_size();
      // verify console api access
      eosio::print("test\n");
      // verify memory api access
      uint32_t i = 42;
      memccpy(&v, &i, sizeof(i), sizeof(i));
      // verify transaction api access
      eosio_assert(transaction_size() > 0, "transaction_size failed");
      // verify softfloat api access
      float f1 = 1.0f, f2 = 2.0f;
      float f3 = f1 + f2;
      eosio_assert( f3 >  2.0f, "Unable to add float.");
      // verify compiler builtin api access
      __int128 ret;
      __divti3(ret, 2, 2, 2, 2);
      // verify context_free_system_api
      eosio_assert( true, "verify eosio_assert can be called" );


   } else if ( cfa.payload == 200 ) {
      // attempt to access non context free api, privileged_api
      is_privileged(act.name);
      eosio_assert( false, "privileged_api should not be allowed" );
   } else if ( cfa.payload == 201 ) {
      // attempt to access non context free api, producer_api
      get_active_producers( nullptr, 0 );
      eosio_assert( false, "producer_api should not be allowed" );
   } else if ( cfa.payload == 202 ) {
      // attempt to access non context free api, db_api
      db_store_i64( N(testapi), N(testapi), N(testapi), 0, "test", 4 );
      eosio_assert( false, "db_api should not be allowed" );
   } else if ( cfa.payload == 203 ) {
      // attempt to access non context free api, db_api
      uint64_t i = 0;
      db_idx64_store( N(testapi), N(testapi), N(testapi), 0, &i );
      eosio_assert( false, "db_api should not be allowed" );
   } else if ( cfa.payload == 204 ) {
      db_find_i64( N(testapi), N(testapi), N(testapi), 1);
      eosio_assert( false, "db_api should not be allowed" );
   } else if ( cfa.payload == 205 ) {
      // attempt to access non context free api, send action
      eosio::action dum_act;
      dum_act.send();
      eosio_assert( false, "action send should not be allowed" );
   } else if ( cfa.payload == 206 ) {
      eosio::require_auth(N(test));
      eosio_assert( false, "authorization_api should not be allowed" );
   } else if ( cfa.payload == 207 ) {
      now();
      eosio_assert( false, "system_api should not be allowed" );
   } else if ( cfa.payload == 208 ) {
      current_time();
      eosio_assert( false, "system_api should not be allowed" );
   } else if ( cfa.payload == 209 ) {
      publication_time();
      eosio_assert( false, "system_api should not be allowed" );
   } else if ( cfa.payload == 210 ) {
      send_inline( "hello", 6 );
      eosio_assert( false, "transaction_api should not be allowed" );
   } else if ( cfa.payload == 211 ) {
      send_deferred( N(testapi), N(testapi), "hello", 6 );
      eosio_assert( false, "transaction_api should not be allowed" );
   }

}
예제 #15
0
/// Download preview & get timestamp if newer than cachefile's
/// last modified time, otherwise just get the timestamp
QDateTime RemoteGetPreviewIfModified(
    const ProgramInfo &pginfo, const QString &cachefile)
{
    QString loc("RemoteGetPreviewIfModified: ");
    QDateTime cacheLastModified;
    QFileInfo cachefileinfo(cachefile);
    if (cachefileinfo.exists())
        cacheLastModified = cachefileinfo.lastModified();

    QStringList strlist("QUERY_PIXMAP_GET_IF_MODIFIED");
    strlist << ((cacheLastModified.isValid()) ? // unix secs, UTC
                QString::number(cacheLastModified.toTime_t()) : QString("-1"));
    strlist << QString::number(200 * 1024); // max size of preview file
    pginfo.ToStringList(strlist);

    if (!gCoreContext->SendReceiveStringList(strlist) ||
        strlist.isEmpty() || strlist[0] == "ERROR")
    {
        LOG(VB_GENERAL, LOG_ERR, loc + "Remote error" +
            ((strlist.size() >= 2) ? (":\n\t\t\t" + strlist[1]) : ""));

        return QDateTime();
    }

    if (strlist[0] == "WARNING")
    {
        LOG(VB_NETWORK, LOG_WARNING, loc + "Remote warning" +
                 ((strlist.size() >= 2) ? (":\n\t\t\t" + strlist[1]) : ""));

        return QDateTime();
    }

    QDateTime retdatetime;
    qlonglong timet = strlist[0].toLongLong();
    if (timet >= 0)
        retdatetime = MythDate::fromTime_t(timet);

    if (strlist.size() < 4)
    {
        return retdatetime;
    }

    size_t  length     = strlist[1].toULongLong();
    quint16 checksum16 = strlist[2].toUInt();
    QByteArray data = QByteArray::fromBase64(strlist[3].toLatin1());
    if ((size_t) data.size() < length)
    { // (note data.size() may be up to 3 bytes longer after decoding
        LOG(VB_GENERAL, LOG_ERR, loc +
            QString("Preview size check failed %1 < %2")
                .arg(data.size()).arg(length));
        return QDateTime();
    }
    data.resize(length);

    if (checksum16 != qChecksum(data.constData(), data.size()))
    {
        LOG(VB_GENERAL, LOG_ERR, loc + "Preview checksum failed");
        return QDateTime();
    }

    QString pdir(cachefile.section("/", 0, -2));
    QDir cfd(pdir);
    if (!cfd.exists() && !cfd.mkdir(pdir))
    {
        LOG(VB_GENERAL, LOG_ERR, loc +
            QString("Unable to create remote cache directory '%1'")
                .arg(pdir));

        return QDateTime();
    }

    QFile file(cachefile);
    if (!file.open(QIODevice::WriteOnly|QIODevice::Truncate))
    {
        LOG(VB_GENERAL, LOG_ERR, loc +
            QString("Unable to open cached preview file for writing '%1'")
                .arg(cachefile));

        return QDateTime();
    }

    off_t offset = 0;
    size_t remaining = length;
    uint failure_cnt = 0;
    while ((remaining > 0) && (failure_cnt < 5))
    {
        ssize_t written = file.write(data.data() + offset, remaining);
        if (written < 0)
        {
            failure_cnt++;
            usleep(50000);
            continue;
        }

        failure_cnt  = 0;
        offset      += written;
        remaining   -= written;
    }

    if (remaining)
    {
        LOG(VB_GENERAL, LOG_ERR, loc +
            QString("Failed to write cached preview file '%1'")
                .arg(cachefile));

        file.resize(0); // in case unlink fails..
        file.remove();  // closes fd
        return QDateTime();
    }

    file.close();

    return retdatetime;
}
예제 #16
0
bool CHtmlHandler::ReportHandler(CString op,CString scmd)
{
	bool brefresh=false;
	if(op.Compare("init") == 0)
	{
		//set the corresponding report-setting
		if(g_RGroup.sReportLst.IsEmpty())
		{
			g_RGroup.sReportUrl = m_gPath+"\\doccopy.doc";
			g_RGroup.sReportLst = SSearchDir(m_gPath+"\\Doc","*.doc");
			g_RGroup.sReportLst.Replace("\n",",");
		}
		
		if(	g_RGroup.sReportSel.IsEmpty() || (g_RGroup.sReportLst.Find(g_RGroup.sReportSel,0) < 0))
			scmd = g_RGroup.sReportLst.Left(g_RGroup.sReportLst.Find(',',0));
		else
			scmd = g_RGroup.sReportSel;//use the value of last time
		
		op = _T("select");
	}
	
	if(op.Compare("print") == 0)
	{
		ShellExecute(0,"print",g_RGroup.sReportUrl,"","",SW_HIDE);
	}
	if(op.Compare("savenew") == 0)
	{
		CString tfile;
		char DirUse[300];
		::GetCurrentDirectory(300,DirUse);
		
		CFileDialog cfd(FALSE,_T("doc"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("Doc File(*.doc)|*.doc||"),NULL);
		if(cfd.DoModal() == IDOK){
			tfile=cfd.GetPathName();
			CopyFile(g_RGroup.sReportUrl,tfile,TRUE);
		}
		::SetCurrentDirectory(DirUse);
	}
	if(op.Compare("select") == 0)
	{
		g_RGroup.sReportSel = scmd;
		SqlSelect(PathQuery(CLSMDB,IDREG),g_RGroup.sRegSel,"*");	//append the reg info
		SqlSelect(PathQuery(CLSMDB,IDDATA),g_RGroup.sDataSel,g_RGroup.sRegSel);//append the data info
		SqlSelect(PathQuery(CLSMDB,IDJH),g_RGroup.sJhSel1,PathQuery(CLSGROUP,IDJH));//append the jh info
		this->DataIntegrateForCheck(g_msTemp,ZINDEX_MAX,false);
		PrepareArrayForReport(g_msTemp);
		DeleteFile(g_RGroup.sReportUrl);
		if(CopyFile(m_gPath+"\\Doc\\"+g_RGroup.sReportSel+".doc",g_RGroup.sReportUrl,FALSE))
		{
			SJReplaceWordByBookmark(g_RGroup.sReportUrl,g_msTemp);
			brefresh = true;
		}
		else
			::AfxMessageBox("请关闭报告结果后重试");
	}
	
	CString stmp = g_RGroup.sReportUrl;
	stmp.Replace("\\","\\\\");
	g_msTemp.SetAt("reporturl",stmp);
	
	stmp = m_gPath+PathQuery(CLSJS,IDWAIT);
	stmp.Replace("\\","\\\\");
	g_msTemp.SetAt("waiturl",stmp);
	
	g_msTemp.SetAt("reportlst",g_RGroup.sReportLst);
	g_msTemp.SetAt("reportsz",g_RGroup.sReportSel);
	g_msTemp.SetAt("curview","reporthtm");
	g_msTemp.SetAt("curhtm","reporthtm");
	if(brefresh)			
		SJReplaceTxtByMark(m_gPath+PathQuery(CLSJS,IDREPORT),m_gPath+REPORT_FORM,MDB_PATTERN,CallBack_Replace);
	return brefresh;
}
예제 #17
0
void Application::
        execute_command_line_options()
{
    string message = Sawe::Configuration::parseCommandLineMessage();

    if (!message.empty())
    {
        cerr    << message << endl    // Want output in logfile
                << Sawe::Configuration::commandLineUsageString();
        this->rs.reset();
        cerr    << message << endl    // Want output in console window, if any
                << Sawe::Configuration::commandLineUsageString();
        QErrorMessage::qtHandler()->showMessage( QString::fromStdString( message ) );
        ::exit(1);
        //mb.setWindowModality( Qt::ApplicationModal );
        //mb.show();
        return;
    }


    Sawe::pProject p; // p will be owned by Application and released before a.exec()

    if (!Sawe::Configuration::input_file().empty())
        p = Sawe::Application::slotOpen_file( Sawe::Configuration::input_file() );

    if (!p)
        p = Sawe::Application::slotNew_recording( );

    if (!p)
        ::exit(3);

    Tools::RenderModel& render_model = p->tools().render_model;
    auto td = render_model.transform_descs ().write ();
    Tfr::Cwt& cwt = td->getParam<Tfr::Cwt>();
    //Signal::pOperation source = render_model.renderSignalTarget->post_sink()->source();
    Signal::OperationDesc::Extent extent = p->processing_chain()->extent(p->default_target ());
    Signal::IntervalType number_of_samples = extent.interval.get_value_or (Signal::Interval());
    float sample_rate = extent.sample_rate.get_value_or (1);
    unsigned samples_per_chunk_hint = Sawe::Configuration::samples_per_chunk_hint();
    unsigned total_samples_per_chunk = cwt.prev_good_size( 1<<samples_per_chunk_hint, sample_rate );

    bool sawe_exit = false;

    unsigned get_csv = Sawe::Configuration::get_csv();
    if (get_csv != (unsigned)-1) {
        if (0==number_of_samples) {
            Sawe::Application::display_fatal_exception(std::invalid_argument("Can't extract CSV without input file."));
            ::exit(4);
        }

        Tfr::ChunkFilterDesc::ptr cfd(new Adapters::CsvDesc(QString("sonicawe-%1.csv").arg(get_csv).toStdString()));
        Signal::OperationDesc::ptr o(new Tfr::TransformOperationDesc(cfd));
        Signal::Processing::TargetMarker::ptr t = p->processing_chain ()->addTargetBefore(o, p->default_target ());
        Signal::Processing::TargetNeeds::ptr needs = t->target_needs ();

        Signal::Interval I( get_csv*total_samples_per_chunk, (get_csv+1)*total_samples_per_chunk );
        needs->updateNeeds (I);
        needs->sleep(-1);

        TaskInfo("Samples per chunk = %u", total_samples_per_chunk);
        sawe_exit = true;
    }

    unsigned get_hdf = Sawe::Configuration::get_hdf();
    if (get_hdf != (unsigned)-1) {
        if (0==number_of_samples) {
            Sawe::Application::display_fatal_exception(std::invalid_argument("Can't extract HDF without input file."));
            ::exit(5);
        }

        Tfr::ChunkFilterDesc::ptr cfd(new Adapters::Hdf5ChunkDesc(QString("sonicawe-%1.h5").arg(get_hdf).toStdString()));
        Signal::OperationDesc::ptr o(new Tfr::TransformOperationDesc(cfd));
        Signal::Processing::TargetMarker::ptr t = p->processing_chain ()->addTargetBefore(o, p->default_target ());
        Signal::Processing::TargetNeeds::ptr needs = t->target_needs ();

        Signal::Interval I( get_hdf*total_samples_per_chunk, (get_hdf+1)*total_samples_per_chunk );
        needs->updateNeeds (I);
        needs->sleep(-1);

        TaskInfo("Samples per chunk = %u", total_samples_per_chunk);
        sawe_exit = true;
    }

    if (Sawe::Configuration::get_chunk_count()) {
        TaskInfo("number of samples = %u", number_of_samples);
        TaskInfo("samples per chunk = %u", total_samples_per_chunk);
        TaskInfo("chunk count = %u", (number_of_samples + total_samples_per_chunk-1) / total_samples_per_chunk);
        this->rs.reset();
        cout    << "number_of_samples = " << number_of_samples << endl
                << "samples_per_chunk = " << total_samples_per_chunk << endl
                << "chunk_count = " << (number_of_samples + total_samples_per_chunk-1) / total_samples_per_chunk << endl;
        sawe_exit = true;
    }

    if (sawe_exit)
    {
        ::exit(0);
    }
    else
    {
        // Ensures that an OpenGL context is created
        if( !QGLContext::currentContext() )
            QMessageBox::information(0,"Sonic AWE", "Sonic AWE couldn't start");
    }
}