예제 #1
0
파일: mainwindow.cpp 프로젝트: rAum/rum
void MainWindow::saveCode()
{
    QString file = QFileDialog::getSaveFileName(this, tr("Save"), "", tr("Scene Description file (*.sdf);;All files (*.*)"));
    ui.lInfo->setText(file);
    if (file != "")
    {
        QFile qfile(file);

        if (!qfile.open(QFile::WriteOnly | QFile::Text))
        {
            QMessageBox::warning(this, tr("Sphere Marcher"), tr("Cannot write file %1:\n %2").arg(file).arg(qfile.errorString()));
            statusBar()->showMessage(tr("Writing file failed :( %2").arg(qfile.errorString()), 2000);            
        }
        else
        {
            QTextStream content(&qfile);

            content << ui.teCode->toPlainText();

            qfile.close();

            statusBar()->showMessage(tr("Wrote to file %1.").arg(file), 2000);
        }   
    }
}
예제 #2
0
bool Editor::Save(void)
{
	// text open in editor is always associated to a filename
	// so wer don't need to ask for filenames before
	// saving those files

	if (isModified() == false) {
		return true;
	}

	QFile qfile(file);
	qfile.open(QIODevice::WriteOnly);// | QIODevice::Text);
	if (qfile.error() != 0) {		
		ErrorMessage(tr("Error while saving file %1:\n%2.")
								.arg(file)
								.arg(qfile.errorString()));
		return false;
	} else {    		
		QTextStream out(&qfile); // we will serialize the data into the file
		QString utext = QString::fromUtf8(this->text().toUtf8());		// save using UTF-8 format
		out << utext; 		
		qfile.close();

		setModified(false);
        lastModifiedTime = QFileInfo(file).lastModified();
		return true;
	}
}
  QCString VerilogDocGen::getFileNameFromString(const char* fileName){
  
  QCString qfile(fileName);
    QStringList ql=QStringList::split('/',qfile);
	QCString lp=ql.last().data();
	return lp;
  
  }
예제 #4
0
QString TemplateLayout::readTemplate(QString template_name)
{
	QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name);
	if (qfile.open(QFile::ReadOnly | QFile::Text)) {
		QTextStream in(&qfile);
		return in.readAll();
	}
	return "";
}
예제 #5
0
void TemplateLayout::writeTemplate(QString template_name, QString grantlee_template)
{
	QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name);
	if (qfile.open(QFile::ReadWrite | QFile::Text)) {
		qfile.write(grantlee_template.toUtf8().data());
		qfile.resize(qfile.pos());
		qfile.close();
	}
}
예제 #6
0
QString TemplateLayout::readTemplate(QString template_name)
{
	QFile qfile(getSubsurfaceDataPath("printing_templates") + QDir::separator() + template_name);
	if (qfile.open(QFile::ReadOnly | QFile::Text)) {
		QTextStream in(&qfile);
		return in.readAll();
	}
	return "";
}
예제 #7
0
void MyEditor::slotDecodeFile(TQString fname)
{
        ////////////////     decode file from given url into editor
        TQFile qfile(TQFile::encodeName(fname));
        if (qfile.open(IO_ReadOnly)) {
	KgpgInterface *txtDecrypt=new KgpgInterface();
        connect (txtDecrypt,TQT_SIGNAL(txtdecryptionfinished(TQString)),TQT_TQOBJECT(this),TQT_SLOT(editorUpdateDecryptedtxt(TQString)));
	connect (txtDecrypt,TQT_SIGNAL(txtdecryptionfailed(TQString)),TQT_TQOBJECT(this),TQT_SLOT(editorFailedDecryptedtxt(TQString)));
        txtDecrypt->KgpgDecryptFileToText(KURL(fname),TQStringList::split(TQString(" "),KGpgSettings::customDecrypt().simplifyWhiteSpace()));
        } else
                KMessageBox::sorry(this,i18n("Unable to read file."));
}
예제 #8
0
bool MyMoneyTemplate::saveTemplate(const KUrl& url)
{
  QString filename;

  if (!url.isValid()) {
    qDebug("Invalid template URL '%s'", qPrintable(url.url()));
    return false;
  }

  if (url.isLocalFile()) {
    filename = url.toLocalFile();
    KSaveFile qfile(filename/*, 0600*/);
    if (qfile.open()) {
      saveToLocalFile(&qfile);
      if (!qfile.finalize()) {
        throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
      }
    } else {
      throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
    }
  } else {
    KTemporaryFile tmpfile;
    KSaveFile qfile(tmpfile.fileName());
    if (qfile.open()) {
      saveToLocalFile(&qfile);
      if (!qfile.finalize()) {
        throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.url()));
      }
    } else {
      throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.url()));
    }
    if (!KIO::NetAccess::upload(tmpfile.fileName(), url, 0))
      throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.url()));
  }
  return true;
}
예제 #9
0
bool AntHillFile::save( const QString &filename ) {
	QFile qfile( filename ) ;
	if( !qfile.open(QFile::WriteOnly) ) {
		std::cerr << "Error : aiming at writing file "<<filename.toStdString()<<", the operation fails." << std::endl;
		_error = true ;
		return !_error ;
	}
	QXmlStreamWriter stream(&qfile);
    stream.setAutoFormatting(true);
    stream.writeStartDocument();
	stream.writeStartElement("AntHillProject");
	
	stream.writeStartElement("Dicom");
	stream.writeAttribute("folder", _dicomFolder );
	stream.writeAttribute("serie-uid", _dicomUID );
	stream.writeEndElement(); // Dicom
	
	stream.writeStartElement("DicomMetaData");
	
	for ( QMap< QString, QString >::ConstIterator iter = _dictionary.begin() ; iter != _dictionary.end() ; iter++ ) {
		stream.writeStartElement("Info");
		stream.writeAttribute("name", iter.key() );
		stream.writeAttribute("value",  iter.value() );
		stream.writeEndElement(); // info
	}
	stream.writeEndElement(); // DicomMetaData
	
	if ( !_process.isEmpty() ) {
		stream.writeStartElement("Process");
		for ( QMap< QString, QMap< QString,QString > >::ConstIterator iter = _process.begin() ; iter != _process.end() ; iter++ ) {
			stream.writeStartElement("Algorithm");
			stream.writeAttribute("name", iter.key() );
			for ( QMap< QString, QString >::ConstIterator param = iter.value().begin() ; param != iter.value().end() ; param++ ) {
				stream.writeStartElement("param");
				stream.writeAttribute("name", param.key() );
				stream.writeAttribute("value",  param.value() );
				stream.writeEndElement(); // param
			}
			stream.writeEndElement(); // Algorithm
		}
		stream.writeEndElement(); // Process
	}
	
	stream.writeEndElement(); // AntHillProject	
	stream.writeEndDocument(); 
	qfile.close() ;
	return !_error ;
}
예제 #10
0
void KgpgApp::openDocumentFile(const KURL& url,TQString encoding)
{
TQString tempOpenFile;
        /////////////////////////////////////////////////
if( TDEIO::NetAccess::download( url, tempOpenFile,this ) ) {
        TQFile qfile(tempOpenFile);
        if (qfile.open(IO_ReadOnly)) {
                TQTextStream t( &qfile );
		t.setCodec(TQTextCodec::codecForName (encoding.ascii()));
                view->editor->setText(t.read());
                qfile.close();
                fileSave->setEnabled(false);
                editRedo->setEnabled(false);
                editUndo->setEnabled(false);
        }
}
}
bool Katalysator2Doc::saveDocument(const KURL& url, const char *format /*=0*/)
{
  QDomElement docElem = doc->documentElement();
  cout << "Dokument-Element beim Speichern:" << docElem.tagName() << endl;

  /////////////////////////////////////////////////
  // TODO: Add your document saving code here
  QString tmpfile=url.path();
  Katalysator2App *win=(Katalysator2App *) parent();

  if (url.fileName() == i18n("Untitled"))
    {
     win->slotFileSaveAs();
    }
  else
    {
		QFile qfile(tmpfile);
			if(qfile.open(IO_ReadWrite))
				{
				QString buffer=doc->toString();
				cout<<buffer<<endl;
				qfile.writeBlock(buffer, buffer.length());
				qfile.close();
				}
			else
				{
				QString qerr;
				qerr.sprintf(i18n("Cannot write to file!"));
				KNotifyClient::event(qerr);
				}
			if(!url.isLocalFile())
				{
				if(!KIO::NetAccess::upload(tmpfile, url))
					{
					KNotifyClient::event(i18n("Couldn't upload file!"));
					}
				}
	  };
  /////////////////////////////////////////////////

  modified=false;
  return true;
}
예제 #12
0
파일: qgo.cpp 프로젝트: alserkli/q4Go
Sound * qGo::retrieveSound(const char * filename, SearchPath& sp)
{
  	QFile qfile(filename);
  	QFile * foundFile = sp.findFile(qfile);
	QString msg(filename);
  	if (! foundFile) 
	{
    		QString msg(filename);
    		msg.append(" not found");
    		qDebug(msg);
    		return (Sound *) NULL;
  	}
	else 
	{
		msg.append(" found : " + foundFile->name());
		qDebug(msg);
    		return SoundFactory::newSound(foundFile->name());
  	}
}
예제 #13
0
bool MyEditor::slotCheckContent(TQString fileToCheck, bool checkForPgpMessage)
{
TQFile qfile(fileToCheck);
        if (qfile.open(IO_ReadOnly)) {
                //////////   open file

                        TQTextStream t( &qfile );
                        TQString result(t.read());
                        //////////////     if  pgp data found, decode it
                        if ((checkForPgpMessage) && (result.startsWith("-----BEGIN PGP MESSAGE"))) {
                                qfile.close();
                                slotDecodeFile(fileToCheck);
                                return true;
                        } else
                                if (result.startsWith("-----BEGIN PGP PUBLIC KEY BLOCK")) {//////  dropped file is a public key, ask for import
                                        qfile.close();
                                        int result=KMessageBox::warningContinueCancel(this,i18n("<p>The file <b>%1</b> is a public key.<br>Do you want to import it ?</p>").arg(fileToCheck),i18n("Warning"));
                                        if (result==KMessageBox::Cancel) {
                                                TDEIO::NetAccess::removeTempFile(fileToCheck);
                                                return true;
                                        } else {
                                                KgpgInterface *importKeyProcess=new KgpgInterface();
                                                importKeyProcess->importKeyURL(KURL(fileToCheck));
                                                connect(importKeyProcess,TQT_SIGNAL(importfinished(TQStringList)),TQT_TQOBJECT(this),TQT_SLOT(slotProcessResult(TQStringList)));
                                                return true;
                                        }
                                } else {
                                        if (result.startsWith("-----BEGIN PGP PRIVATE KEY BLOCK")) {
						qfile.close();
                                                KMessageBox::information(0,i18n("This file is a private key.\nPlease use kgpg key management to import it."));
                                                TDEIO::NetAccess::removeTempFile(fileToCheck);
                                                return true;
                                        }

                                        setText(result);
                                        qfile.close();
                                        TDEIO::NetAccess::removeTempFile(fileToCheck);
                                }
                }
		return false;
}
void ribi::QtTestImageCanvasMainDialog::on_button_image_clicked()
{
  QFile qfile(":/ToolTestImageCanvas/images/R.png");
  const std::string filename { fileio::GetTempFileName() };
  qfile.copy(filename.c_str());
  assert(fileio::IsRegularFile(filename));
  m_canvas.reset(
    new ImageCanvas(
      filename,
      GetNcols(),
      GetColorSystem(),
      GetCoordinatSystem()
    )
  );
  delete m_qtcanvas;
  m_qtcanvas = new QtCanvas(m_canvas);
  ui->verticalLayout->addWidget(m_qtcanvas);

  fileio::DeleteFile(filename);
  assert(!fileio::IsRegularFile(filename));
}
예제 #15
0
bool Project::Save(const boost::filesystem::path& file)
{
	QFile qfile(QString::fromStdString(file.string()));

	SCOPE_EXIT(qfile.close());

	if (!qfile.open(QIODevice::WriteOnly | QIODevice::Text))
		return false;

	QXmlStreamWriter writer(&qfile);
	writer.setAutoFormatting(true);
	writer.setAutoFormattingIndent(-1);

	writer.writeStartDocument();
	{

		writer.writeStartElement("project");
		{
			writer.writeTextElement("scene", QString::fromStdString(m_pScene->GetFileName().string()));

			writer.writeTextElement("clear_color", "0, 0, 0");

			writer.writeStartElement("camera");
			{
				writer.writeTextElement("eye_pos", "0, 0, -100");
				writer.writeTextElement("focus_pos", "0, 0, 0");
			}
			writer.writeEndElement();
		}
		writer.writeEndElement();
	}
	writer.writeEndDocument();


	m_filePath = file;

	RestoreProjectRoot();

	return true;
}
예제 #16
0
void BitmapWidget::edit()
{        
  if(!(mpBrowseBox->text().endsWith("png") || mpBrowseBox->text().endsWith("bmp") || mpBrowseBox->text().endsWith("jpg")))
  {
    QMessageBox::critical(mpParentMainWindow, QString(Helper::applicationName).append(" - ").append(Helper::error),
                          GUIMessages::getMessage(GUIMessages::UNKNOWN_FILE_FORMAT).arg(".png,.bmp,.jpg"), Helper::ok);
    return;
  }

  //Set file name as picture path relative to model directory...
  QString modelPath = mpParentMainWindow->mpProjectTabs->getCurrentTab()->mModelFileName;
  QFileInfo qfile(modelPath);
  QDir dir(qfile.absolutePath());
  QString relativePath;
  relativePath = dir.relativeFilePath(mpBrowseBox->text());
  mpBitmapAnnotation->setFileName("/" + relativePath);

  if(!dir.exists(relativePath))
  {
    QMessageBox::critical(mpParentMainWindow, QString(Helper::applicationName).append(" - ").append(Helper::error),
                          GUIMessages::getMessage(GUIMessages::UNABLE_TO_LOAD_FILE).arg(relativePath), Helper::ok);
    return;
  }

  //Store imageSource base64 of the image if checked
  if(mpCheckBox->isChecked())
  {
    QFile* file = new QFile(mpBrowseBox->text());
    file->open(QIODevice::ReadOnly);
    QByteArray image = file->readAll();
    QString imageSource = QString(image.toBase64());

    mpBitmapAnnotation->setImageSource(imageSource);
  }
  else
    mpBitmapAnnotation->setImageSource("");

  accept();
  mpBitmapAnnotation->updateAnnotation();
}
예제 #17
0
파일: lrceditor.cpp 프로젝트: timxx/lyricsx
bool LrcEditor::openFile(const QString &file, const QString &encoding)
{
	QFile qfile(file);
	if (!qfile.open(QFile::ReadOnly | QFile::Text))
		return false;

	QTextStream is(&qfile);
	if (!encoding.isEmpty())
	{
		is.setAutoDetectUnicode(false);
		is.setCodec(encoding.toLocal8Bit());
	}

	setPlainText(is.readAll());

	m_encoding = is.codec()->name();
	m_file = file;

	qfile.close();

	return true;
}
예제 #18
0
GLuint OpenGLUtils::uploadRaw2DTexture(std::string filename,unsigned int width,
                                       unsigned int height,
                                       GLuint internalFormat, GLenum format,GLenum type) {
    QFile qfile(QString::fromStdString(IMAGES_RESOURCES+filename));
    if(!qfile.open(QFile::ReadOnly)) {
        std::cerr<< "Texture resource not found: "<< (IMAGES_RESOURCES+filename) <<std::endl;
        return 0u;
    }
    int len = qfile.size();
    unsigned char *textureData = new unsigned char[len];
    qfile.read((char*)textureData, len);
    qfile.close();
    if(!textureData)
        return 0u;
    GLuint tid = uploadRaw2DTexture(textureData,
                                    width,height,
                                    internalFormat,
                                    format,type);
    delete[] textureData;
    return tid;

}
예제 #19
0
bool AntHillFile::load( const QString &filename ) {
	QFile qfile( filename ) ;
	if( !qfile.open(QFile::ReadOnly) ) {
		std::cerr << "Error : aiming at reading file "<<filename.toStdString()<<", the operation fails." << std::endl;
		_error = true ;
		return !_error ;
	}
	QXmlStreamReader stream( &qfile ) ;
	QString algname ="";
	while ( !stream.atEnd() ) {
		stream.readNext() ;
		if ( stream.isStartElement() ) {
			if ( stream.name() == "Info" ) {
				QXmlStreamAttributes attr = stream.attributes() ;
				_dictionary.insert( attr.value( "name" ).toString() , attr.value( "value" ).toString()  ) ;
			} else if ( stream.name() == "Dicom" ) {
				QXmlStreamAttributes attr = stream.attributes() ;
				_dicomFolder = attr.value( "folder" ).toString();
				_dicomUID = attr.value( "serie-uid" ).toString();
			} else if ( stream.name() == "Algorithm" ) {
				QXmlStreamAttributes attr = stream.attributes() ;
				algname = attr.value( "name" ).toString() ;
				_process.insert( algname , QMap< QString,QString> ()  ) ;
			} else if ( stream.name() == "param" ) {
				if( algname.isEmpty() ) {
					_error = true ;
					qfile.close() ;
					return !_error ;
				}
				QXmlStreamAttributes attr = stream.attributes() ;
				_process[ algname ].insert( attr.value( "name" ).toString() , attr.value( "value" ).toString()  ) ;
			}
		}
	}
	_error = stream.hasError() ;
	qfile.close() ;
	return !_error ;
}
예제 #20
0
void ThemeChooser::saveAndReload(MythUIButtonListItem *item)
{
    ThemeInfo *info = qVariantValue<ThemeInfo *>(item->GetData());

    if (!info)
        return;

    if (!info->GetDownloadURL().isEmpty())
    {
        QString downloadURL = info->GetDownloadURL();
        QFileInfo qfile(downloadURL);
        QString baseName = qfile.fileName();

        if (!gCoreContext->GetSetting("ThemeDownloadURL").isEmpty())
        {
            QStringList tokens =
                gCoreContext->GetSetting("ThemeDownloadURL")
                    .split(";", QString::SkipEmptyParts);
            QString origURL = downloadURL;
            downloadURL.replace(tokens[0], tokens[1]);
            LOG(VB_FILE, LOG_WARNING, LOC +
                QString("Theme download URL overridden from %1 to %2.")
                    .arg(origURL).arg(downloadURL));
        }

        OpenBusyPopup(tr("Downloading %1 Theme").arg(info->GetName()));
        m_downloadTheme = info;
        m_downloadFile = RemoteDownloadFile(downloadURL,
                                            "Temp", baseName);
        m_downloadState = dsDownloadingOnBackend;
    }
    else
    {
        gCoreContext->SaveSetting("Theme", info->GetDirectoryName());
        GetMythMainWindow()->JumpTo("Reload Theme");
    }
}
예제 #21
0
파일: mainwindow.cpp 프로젝트: rAum/rum
void MainWindow::openCode()
{
    QString file = QFileDialog::getOpenFileName(this, tr("Open"), "", tr("Scene Description file (*.sdf);;All files (*.*)"));
    if (file != tr(""))
    {
        QFile qfile(file);

        if (!qfile.open(QFile::ReadOnly | QFile::Text))
        {
            QMessageBox::warning(this, tr("Sphere Marcher"), tr("Cannot read file %1:\n %2").arg(file).arg(qfile.errorString()));
            statusBar()->showMessage(tr("Opening file failed :( %2").arg(qfile.errorString()), 2000);            
        }
        else
        {
            QTextStream content(&qfile);
            
            ui.teCode->setText(content.readAll());
            
            qfile.close();

            statusBar()->showMessage(tr("Opened file %1.").arg(file), 2000);
        }   
    }
}
예제 #22
0
파일: ClsQHarborImpl.cpp 프로젝트: jeez/iqr
void ClsQHarborImpl::loadConfig(string strConfigName) {
#ifdef DEBUG_CLSQHARBORIMPL
    cout << "ClsQHarborImpl::loadConfig(string strConfigName)" << endl;
#endif

    if(strConfigName.length()>0) {
        QFile qfile( strConfigName );
        if ( !qfile.open( IO_ReadOnly ) ) {
            QMessageBox::critical( 0, tr( "Critical Error" ),
                                   tr( "Cannot open file %1" ).arg( strConfigName ) );
            return;
        }

        QDomDocument domTree;
        if ( !domTree.setContent( &qfile ) ) {
            QMessageBox::critical( 0, tr( "Critical Error" ),
                                   tr( "Parsing error for file %1" ).arg( strConfigName ) );
            qfile.close();
            return;
        }
        qfile.close();

//	clearTable();

        // get the header information from the DOM
        QDomElement root = domTree.documentElement();
        QDomNode node;
        node = root.firstChild(); /* ParamTrade */

        while ( !node.isNull() ) {
            string strItemType = node.toElement().attribute("itemType");
            string strItemID = node.toElement().attribute("itemID");
            string strSubItemName = node.toElement().attribute("itemChild");
            string strParamName = node.toElement().attribute("ParamName");
            string strParamLabel = node.toElement().attribute("ParamLabel");
            string strItemName = "";

            ClsItem* clsItemTemp = NULL;
            if(!strItemType.compare("Group")) {
                clsItemTemp = ClsFESystemManager::Instance()->getFEGroup( strItemID );
                if(clsItemTemp!=NULL) {
                    strItemName = dynamic_cast<ClsFEGroup*>(clsItemTemp)->getGroupName();
                }
            }
            else if(!strItemType.compare("Connection")) {
                clsItemTemp = ClsFESystemManager::Instance()->getFEConnection( strItemID );
                if(clsItemTemp!=NULL) {
                    strItemName = dynamic_cast<ClsFEConnection*>(clsItemTemp)->getConnectionName();
                }
            }

            qtableEntries->insertRows(0,1);
            qtableEntries->setText(0, COL_ID, strItemID);
            qtableEntries->setText(0, COL_TYPE, strItemType);
            qtableEntries->setText(0, COL_CHILD, strSubItemName);

            if(clsItemTemp!=NULL) {
                qtableEntries->setText(0, COL_NAME, strItemName);
                qtableEntries->setText(0, COL_PARAM_LABEL, strParamLabel);
                qtableEntries->setText(0, COL_PARAM_NAME, strParamName);
                fillMinMaxValueField(clsItemTemp, strParamName, 0);
            }
            node = node.nextSibling();
        }
        for(int ii = 0; ii<qtableEntries->numCols(); ii++) {
            qtableEntries->adjustColumn(ii);
        }
    }
}
예제 #23
0
char *pj_get_filename(char *prompt, char *suffi, char *button, 
		   			  char *inpath, char *outpath, 
					  Boolean force_suffix, SHORT *scroll_top_name,
					  char *wildcard)

/* put up a file requestor.  If inpath or outpath are NULL then
 * use static buffer.  Else start with inpath and update outpath
 * to directory user selects on exit.  Returns NULL if user
 * cancels, otherwise a pointer to outpath with the full path name selected.
 * Wildcard is the initial contents of the wildcard field and is altered to 
 * reflect it's new contents, If wildcard is NULL it will use the stack buffer
 * and if wildcard is empty or NULL it will default to the first suffix as in
 * *.XXX */
{
Errcode err;
static char	path_buf[PATH_SIZE];
char drawer_buf[PATH_SIZE];
char fname_buf[PATH_SIZE];
char wild_buf[WILD_SIZE];
char wildbufs[6*4];
char *wbuf;
char *wilds[4];
size_t num_wilds;
int len;
SHORT top_name = 0;

	if(NULL == (fscroller_top_name = scroll_top_name))
		fscroller_top_name = &top_name;

	if(!inpath)
		inpath = path_buf;
	if(!outpath)
		outpath = path_buf;
	if(!wildcard)
	{
		wildcard = wild_buf;
		wild_buf[0] = 0;
	}

	num_wilds = 0;
	if(suffi)
	{
		wbuf = wildbufs;
		for(;num_wilds < Array_els(wilds);++num_wilds)
		{
			wilds[num_wilds] = wbuf;
			*wbuf++ = '*';
			if((len = parse_to_semi(&suffi,wbuf,5)) == 0)
				break;
			wbuf += len;
			*wbuf++ = 0;
		}
	}

	if(!num_wilds || !pj_valid_suffix(&wildbufs[1]))
		force_suffix = FALSE;

	split_copy_path(inpath,drawer_buf,fname_buf);
	if(fname_buf[0] == 0)
		strcpy(fname_buf,unnamed_str);
	else if(force_suffix)
		sprintf(pj_get_path_suffix(fname_buf),"%.4s", &wildbufs[1]);

	if((err = qfile(outpath, drawer_buf, fname_buf, 
					prompt, button, num_wilds, wilds, wildcard)) < Success)
	{
		outpath = NULL;
		goto error;
	}

	if( *fix_suffix(outpath) == '\0' && force_suffix)
		strcat(outpath, &wildbufs[1]);

error:
	return(outpath);
}
예제 #24
0
파일: ClsQHarborImpl.cpp 프로젝트: jeez/iqr
void ClsQHarborImpl::loadConfig(string strConfigName){
#ifdef DEBUG_CLSQHARBORIMPL
    cout << "ClsQHarborImpl::loadConfig(string strConfigName)" << endl;
#endif

#ifndef _WINDOWS // cannot get this to work under minGW at the moment...

    if(strConfigName.length()>0){
	QFile qfile( strConfigName.c_str() );
	if ( !qfile.open( QIODevice::ReadOnly ) ) {
	    QMessageBox::critical( 0, tr( "Critical Error" ),
				   tr( "Cannot open file %1" ).arg( strConfigName.c_str() ) );
	    return;
	}
	
	QDomDocument domTree;
	if ( !domTree.setContent( &qfile ) ) {
	    QMessageBox::critical( 0, tr( "Critical Error" ),
				   tr( "Parsing error for file %1" ).arg( strConfigName.c_str() ) );
	    qfile.close();
	    return;
	}
	qfile.close();

	// get the header information from the DOM
	QDomElement root = domTree.documentElement();
	QDomNode node;
	node = root.firstChild(); /* ParamTrade */
	
	while ( !node.isNull() ) {
	    string strItemType = node.toElement().attribute("itemType").toStdString();
	    string strItemID = node.toElement().attribute("itemID").toStdString();
	    string strSubItemName = node.toElement().attribute("itemChild").toStdString();
	    string strParamName = node.toElement().attribute("ParamName").toStdString();
	    string strParamLabel = node.toElement().attribute("ParamLabel").toStdString();
	    string strItemName = "";
	    
	    ClsItem* clsItemTemp = NULL;
	    if(!strItemType.compare("Group")){
		clsItemTemp = ClsFESystemManager::Instance()->getFEGroup( strItemID );
		if(clsItemTemp!=NULL){
		    strItemName = dynamic_cast<ClsFEGroup*>(clsItemTemp)->getGroupName();
		}
	    } 
	    else if(!strItemType.compare("Connection")){
		clsItemTemp = ClsFESystemManager::Instance()->getFEConnection( strItemID );
		if(clsItemTemp!=NULL){
		    strItemName = dynamic_cast<ClsFEConnection*>(clsItemTemp)->getConnectionName();
		}
	    }
	    
	    tableWidget->insertRow ( 0 );
	    addItem(0, COL_ID, strItemID.c_str());
	    addItem(0, COL_TYPE, strItemType.c_str());
	    addItem(0, COL_CHILD, strSubItemName.c_str());


	    if(clsItemTemp!=NULL){
		addItem(0, COL_NAME, strItemName.c_str());
		addItem(0, COL_PARAM_LABEL, strParamLabel.c_str());
		addItem(0, COL_PARAM_NAME, strParamName.c_str());
		addItem(0, COL_MIN, "");
		addItem(0, COL_MAX, "");
		addItem(0, COL_VALUE, "");
		fillMinMaxValueField(clsItemTemp, strParamName, 0);	
	    }
	    node = node.nextSibling();
	}
	for(int ii = 0; ii<tableWidget->rowCount(); ii++){
	    tableWidget->resizeColumnToContents(ii);
	}
    }
#endif
}
예제 #25
0
/** Properties dialog addon*/
FileInfoDlg* BaseTreeView::addFileInfoPage(KPropertiesDialog* propDlg)
{
  //If the item is a file, add the Quanta file info page
  FileInfoDlg *quantaFileProperties = 0L;
  if ( !currentKFileTreeViewItem()->isDir() )
  {

    QFrame *quantaFilePage = propDlg->addPage(i18n("Quanta File Info"));
    QVBoxLayout *topLayout = new QVBoxLayout( quantaFilePage);
    quantaFileProperties = new FileInfoDlg( quantaFilePage, i18n("Quanta") );

    int fsize,fimgsize=0;
    int ct=0,imgct=0,position=0;
    KURL u = currentURL();
    if (u.isLocalFile())   //get the file info only for local file. TODO: for non-local ones
    {
       QString nameForInfo = u.path();
       QString path =u.directory(0,0);       //extract path for images
       QString sourcename=u.fileName(0);

       QFile qfile(nameForInfo);
       fsize=qfile.size();                              //html file size

       QString mimetype = KMimeType::findByFileContent(nameForInfo)->name();
       if (mimetype.contains("text"))
       {
        qfile.open(IO_ReadOnly);
        QString imgname,imgpath;
        QTextStream stream(&qfile);
        stream.setEncoding(QTextStream::UnicodeUTF8);
        while (!stream.atEnd())     //open & parse file
        {
          imgname = stream.readLine();
          ct++;
          position=imgname.find("<img",0,false);              //check for images
          if (position!=-1)
          {
            imgname.remove(0,position+4);
            position=imgname.find("src=",0,false);              //extract images names
            imgname.remove(0,position+4);
            if (imgname.startsWith("\"")) imgname.remove(0,1);
            if (imgname.startsWith("'")) imgname.remove(0,1);
            position=imgname.find(" ",0,false);
            if (position!=-1) imgname=imgname.left(position);
            position=imgname.find(">",0,false);
            if (position!=-1) imgname=imgname.left(position);
            position=imgname.find("\"",0,false);
            if (position!=-1) imgname=imgname.left(position);
            position=imgname.find("'",0,false);
            if (position!=-1) imgname=imgname.left(position);
            if (!quantaFileProperties->imageList->findItem(imgname,Qt::ExactMatch))     //check if image was already counted
            {
              KURL v(KURL::fromPathOrURL( path ),imgname);
              imgpath=v.path();
              QFile qimage(imgpath);
              if (qimage.exists() && v.isLocalFile())
              {
               fimgsize+=qimage.size();
               quantaFileProperties->imageList->insertItem(imgname);
               imgct++;
              }
             }
           }
         }
         qfile.close();

         quantaFileProperties->lineNum->setText(i18n("Number of lines: %1").arg(ct));
         quantaFileProperties->imageNum->setText(i18n("Number of images included: %1").arg(imgct));
         quantaFileProperties->imageSize->setText(i18n("Size of the included images: %1 bytes").arg(fimgsize));
         quantaFileProperties->totalSize->setText(i18n("Total size with images: %1 bytes").arg(fsize+fimgsize));
        }
        else if (mimetype.contains("image"))
        {              // assume it's an image file
          QImage imagefile=QImage(nameForInfo);
          quantaFileProperties->lineNum->setText(i18n("Image size: %1 x %2").arg(imagefile.width()).arg(imagefile.height()));
          quantaFileProperties->imageNum->hide();
          quantaFileProperties->imageSize->hide();
          quantaFileProperties->totalSize->hide();
          quantaFileProperties->includedLabel->hide();
          quantaFileProperties->imageList->hide();
        }
        quantaFileProperties->fileDescLbl->setText(i18n("Description:"));
        quantaFileProperties->fileDesc->setText(currentKFileTreeViewItem()->text(1));
        // disable per default
        quantaFileProperties->fileDescLbl->hide();
        quantaFileProperties->fileDesc->hide();
        topLayout->addWidget(quantaFileProperties);
    } //if localfile
  }
  return quantaFileProperties;
}
예제 #26
0
bool Project::Open(const boost::filesystem::path& file)
{
	QFile qfile(QString::fromStdString(file.string()));

	SCOPE_EXIT(qfile.close());

	if (!qfile.open(QIODevice::ReadOnly | QIODevice::Text))
		return false;

	m_filePath = file;
	RestoreProjectRoot();


	QDomDocument doc;

	if(doc.setContent(&qfile) == false)
	{
		return false;
	}

	QDomNodeList s = doc.elementsByTagName("scene");
	if(s.count() == 0)
	{
		return false;
	}
	QString text = s.at(0).toElement().text();

	m_pScene = alloc_shared<GameScene>(m_pEngine);

	if(text == "")
	{
		if(false == m_pScene->New())
		{
			return false;
		}
	}
	else
	{
		if(false == m_pScene->Load(text.toStdString()))
		{
			return false;
		}
	}

	s = doc.elementsByTagName("camera");
	if(s.count() == 0)
	{
		return false;
	}

	QDomElement e = s.at(0).toElement();

	QDomElement eye = e.firstChildElement("eye_pos");

	QDomElement focus = e.firstChildElement("focus_pos");


	if(eye.isNull() == false)
	{
		math::Vector3 ep;

		QString t = eye.text();

		QString tmp;
		QTextStream stream(&t);
		stream >> ep.x >> tmp >> ep.y >> tmp >> ep.z ;

		//m_pRenderer->GetCamera()->SetEyePos(ep);
	}
예제 #27
0
파일: ClsQHarborImpl.cpp 프로젝트: jeez/iqr
void ClsQHarborImpl::loadParamSet(string strParamSetName) {
#ifdef DEBUG_CLSQHARBORIMPL
    cout << "ClsQHarborImpl::loadParamSet(string strParamSetName)" << endl;
#endif

    if(strParamSetName.length()>0) {
        QFile qfile( strParamSetName );
        if ( !qfile.open( IO_ReadOnly ) ) {
            QMessageBox::critical( 0, tr( "Critical Error" ),
                                   tr( "Cannot open file %1" ).arg( strParamSetName ) );
            return;
        }

        QDomDocument domTree;
        if ( !domTree.setContent( &qfile ) ) {
            QMessageBox::critical( 0, tr( "Critical Error" ),
                                   tr( "Parsing error for file %1" ).arg( strParamSetName ) );
            qfile.close();
            return;
        }
        qfile.close();


        // get the header information from the DOM
        QDomElement root = domTree.documentElement();
        QDomNode node;
        node = root.firstChild(); /* Parameter */

        while ( !node.isNull() ) {
            string strItemType = node.toElement().attribute("itemType");
            string strItemID = node.toElement().attribute("itemID");
            string strParamName = node.toElement().attribute("name");
            string strParamValue = node.toElement().attribute("value");
            string strItemName = "";

            if(!setTableItemValue(strItemID, strParamName,strParamValue)) {
                cerr << "parameter not found" << endl;
                string strError = string("Cannot find parameter \"") + strParamName + string("\"\nfor item \"") + strItemID + string("\"\n");
                QMessageBox::warning( this, "iqr Harbor",
                                      strError,
                                      "Ok");
            } else {

                if(!strItemType.compare("Group")) {
                    ClsFEGroup* clsFEGroup = ClsFESystemManager::Instance()->getFEGroup( strItemID );
                    if(clsFEGroup!=NULL) {
                        clsFEGroup->setNeuronParameter(strParamName, strParamValue);
                    } else {
                        cerr << "ClsQHarborImpl::slotChangeValue: group not found" << endl;
                    }
                }
                else if(!strItemType.compare("Connection")) {
                    ClsFEConnection* clsFEConnection = ClsFESystemManager::Instance()->getFEConnection( strItemID );
                    if(clsFEConnection!=NULL) {
                        clsFEConnection->setSynapseParameter(strParamName, strParamValue);
                    } else {
                        cerr << "ClsQHarborImpl::slotChangeValue: connection not found" << endl;
                    }
                }
            }
            node = node.nextSibling();
        }
        for(int ii = 0; ii<qtableEntries->numCols(); ii++) {
            qtableEntries->adjustColumn(ii);
        }
    }

}
예제 #28
0
PairFinder::PairFinder(sdmixer *s, QString f)
{
    sdm = s;
    file = f;

    QFile qfile(f);
    qfile.open(QIODevice::ReadOnly| QIODevice::Text);

    QTextStream in(&qfile);
    header = in.readLine();
    qfile.close();

    sdm->getHeader(header, columns, min_maxValues, INPUT_FILE);
    dimensions = columns.dimensions;
    rawDataCols = columns.rawDataCols;

    if(sdm->getForce2D())
        dimensions=2;

    xCol = columns.x;
    yCol = columns.y;
    if(dimensions>2)
        zCol = columns.z;
    FrameColumn = columns.frame;
    IntensityColumn = columns.Amplitude;

    //getHeader();
    //qDebug() << "dimensions: " << dimensions;
    //qDebug() << "columns: " << rawDataCols;

    if(s->getForce2D())
        dimensions=2;

    NM_PER_PX = sdm->getPixelSize();

    for(int i=0; i< dimensions; ++i)
    {
        offset_units = sdm->getOffsetUnits();

        if(!offset_units.getOffset(i).compare("px"))
            Offset[i]=sdm->getOffset(i)*NM_PER_PX;
        else
            Offset[i]=sdm->getOffset(i);

        if(!offset_units.getEpsilon(i).compare("px"))
            Epsilon[i]=sdm->getEpsilon(i)*NM_PER_PX;
        else
            Epsilon[i]=sdm->getEpsilon(i);

        //qDebug() << "offset : " << Offset[i];
        //qDebug() << "epsilon : " << Epsilon[i];

    }
    fishing_settings = sdm->getFishing();

    if( !fishing_settings.unit.compare("px") )
    {
        fishing_settings.increment*=NM_PER_PX;
        fishing_settings.range*=NM_PER_PX;

    }

    if(!sdm->getCameraOrientation().compare("Top-Bottom"))
        LeftRight = false;
    else
        LeftRight = true;

    if(!sdm->getShortChannelPosition().compare("Top") ||
            !sdm->getShortChannelPosition().compare("Left"))
        ShortChannel=1;
    else
        ShortChannel=2;

    QFile qf(file);
    QFileInfo fi(qf);

    if(!sdm->getOutputDirectory().isEmpty())
        output_dir = sdm->getOutputDirectory();
    else
        output_dir=fi.path();

    fileName = fi.completeBaseName();
    outputFile = output_dir;
    outputFile.append("/");
    outputFile.append(fileName);
    outputFile.append(PairFinderSuffix);
    qDebug() << output_dir;

    runGrouping = sdm->getRunGrouping();
    groupingRadius = sdm->getGroupingRadius();
    groupingUnits = sdm->getGroupingUnits();
    if( !groupingUnits.compare("px") )
    {
        groupingRadius*=NM_PER_PX;
    }
    groupoutFile = output_dir;
    groupoutFile.append("/");
    groupoutFile.append(fileName);
    groupoutFile.append(GroupedFileSuffix);
    qDebug() << "group_out file: " << groupoutFile;


    UnpairedOut = sdm->getUnpairedOut();
    unpairedFile = output_dir;
    unpairedFile.append("/");
    unpairedFile.append(fileName);
    unpairedFile.append(UnpairedFileSuffix);
}
예제 #29
0
GLuint ShaderUtils::CreateShader(ShaderLoadingData data)
{
    if(!glCreateShader) {
        std::cerr << "OpenGL function 'glCreateShader' not found." << std::endl;
        return FAIL_CREATING_SHADER;
    }
    std::string filedata;
    for( std::string file : data.strShaderFiles ) {
        QFile qfile(QString::fromStdString(SHADER_RESOURCES+file));
        if(!qfile.open(QIODevice::ReadOnly)) {
            std::cerr << "Shader file not found: " <<
                      (SHADER_RESOURCES+file) << std::endl;
            return FAIL_CREATING_SHADER;
        }
        QTextStream in(&qfile);
        QString line = in.readAll();
        filedata = filedata+line.toStdString();
        qfile.close();
    }
    //std::cout << "Shader file name: " << data.strShaderFiles[0] << std::endl;
    //std::cout << "Shader file length: " << filedata << std::endl;
    //std::cout << "Shader file content: " << filedata << std::endl;

    GLuint shader = glCreateShader(data.eShaderType);

    //load shader file

    const char *strFileData = filedata.c_str();
    glShaderSource(shader, 1, &strFileData, NULL);
    glCompileShader(shader);

    GLint status;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);

    GLint infoLogLength;
    glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
    if(infoLogLength > 1) {
        GLchar *strInfoLog = new GLchar[infoLogLength + 1];
        glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);

        const char *strShaderType = NULL;
        switch(data.eShaderType)
        {
        case GL_VERTEX_SHADER:
            strShaderType = "vertex";
            break;
        case GL_GEOMETRY_SHADER:
            strShaderType = "geometry";
            break;
        case GL_FRAGMENT_SHADER:
            strShaderType = "fragment";
            break;
//			case GL_COMPUTE_SHADER: strShaderType = "compute"; break;
        }
        if (status == GL_FALSE) {
            std::cerr << "Compile failure in " << strShaderType << " shader: "<< std::endl;
            std::cerr << filedata << std::endl;
            std::cerr << "ERROR: "<< std::endl << strInfoLog << std::endl;
        }
        else {
            std::cout << "Compile Status for " << strShaderType << " shader: " << std::endl;
            std::cout << strInfoLog << std::endl;
        }
        delete[] strInfoLog;
    }
    if (status == GL_FALSE)
        shader = FAIL_CREATING_SHADER;
    //	delete[] buffer;
    return shader;
}
int pictorial_structures_revisited_partapp_main(int argc, char *argv[])
{
	/* parse command line options */
	po::options_description cmd_options_desc("command line options:");
	po::variables_map cmd_vars_map;

	cmd_options_desc.add_options()
		(local::szOption_Help, "help message")
		(local::szOption_ExpOpt, po::value<string>(), "experiment parameters")   
		(local::szOption_TrainClass, "train part detector")
		(local::szOption_TrainBootstrap, "train part detector, adding hard negative samples")
		(local::szOption_Pidx, po::value<int>(), "0-based index of the part")

		(local::szOption_BootstrapPrep, "create bootstrapping dataset (crops of objects with some background)")
		(local::szOption_BootstrapDetect, "run previously trained classifer on bootstrapping images")
		(local::szOption_BootstrapShowRects, "show top negatives on bootstrapping images")

		(local::szOption_First, po::value<int>(), "index of first image")
		(local::szOption_NumImgs, po::value<int>(), "number of images to process")

		(local::szOption_PartDetect, "run part detector on the test set")

		(local::szOption_FindObj, "find_obj")
		(local::szOption_pc_learn, "estimate prior on part configurations with maximum likelihood")
		(local::szOption_SaveRes, "save object recognition results in al/idl formats")

		(local::szOption_EvalSegments, "evaluate part localization according to Ferrari's criteria")

		(local::szOption_Distribute, "split processing into multiple chunks, keep track of the chunks which must be processed")
		(local::szOption_NCPU, po::value<int>(), "number of chunks")
		(local::szOption_BatchNumber, po::value<int>(), "current chunk")
		(local::szOption_VisParts, "visualize ground-truth part positions")
		;


	/* BEGIN: handle 'distribute' option */

	const QString qsArgsFile = ".curexp";
	const QString qsCurBatchFile = ".curexp_batchnum";
	const int MAX_ARGC = 255;
	const int MAX_ARG_LENGTH = 1024;
	cout << "argc: " << argc << endl;
	cout << "argv[0]: " << argv[0] << endl;
	assert(argc <= MAX_ARGC);

	int loaded_argc = 0;
	char loaded_argv[MAX_ARGC][MAX_ARG_LENGTH];
	char *loaded_argv_ptr[MAX_ARGC];
	for (int idx = 0; idx < MAX_ARGC; ++idx) {
		loaded_argv_ptr[idx] = loaded_argv[idx];
	}

	/* try to load parameters from experiment file if none are specified on the command line */
	if (argc <= 1 && filesys::check_file(qsArgsFile)) {
		// load .curexp, fill argc and argv
		cout << "reading arguments from " << qsArgsFile.toStdString() << endl;
		QFile qfile( qsArgsFile );

		assert(qfile.open( QIODevice::ReadOnly | QIODevice::Text));
		QTextStream stream( &qfile );
		QString line;

		while(!(line = stream.readLine()).isNull()) {
			if (!line.isEmpty()) {
				cout << line.toStdString() << endl;
				assert(line.length() < MAX_ARG_LENGTH);

				int cur_idx = loaded_argc;
				strcpy(loaded_argv[cur_idx], line.toStdString().c_str());
				++loaded_argc;
			}
		}

	}

	/* process command option */

	try {

		if (loaded_argc > 0) {
			cout << "reading parameters from " << qsArgsFile.toStdString() << endl;
			po::store(po::parse_command_line(loaded_argc, loaded_argv_ptr, cmd_options_desc), cmd_vars_map);

			ifstream ifs;
			ifs.open(qsCurBatchFile.toStdString().c_str());
			po::store(po::parse_config_file(ifs, cmd_options_desc), cmd_vars_map);
			ifs.close();

			assert(cmd_vars_map.count("batch_num") > 0);
			int batch_num = cmd_vars_map["batch_num"].as<int>();
			cout << "batch_num: " << batch_num << endl;
			++batch_num;

			cout << "updating " << qsCurBatchFile.toStdString() << endl;
			QFile qfile2(qsCurBatchFile);
			assert(qfile2.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text));
			QTextStream stream2( &qfile2 );
			stream2 << "batch_num = " << batch_num << endl;
		}
		else {
			cout << "reading command line parameters" << endl;
			po::store(po::parse_command_line(argc, argv, cmd_options_desc), cmd_vars_map);
		}

		po::notify(cmd_vars_map);
	}
	catch (exception &e) {
		cerr << "error: " << e.what() << endl;
		return 1;
	}  

	/* "distribute" option means store parameters and initialize batch counter */
	if (argc > 1 && cmd_vars_map.count("distribute") > 0) {
		assert(cmd_vars_map.count("ncpu") > 0);

		cout << "saving command line parameters in " << qsArgsFile.toStdString() << endl;
		QFile qfile( qsArgsFile );
		assert(qfile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text));
		QTextStream stream( &qfile );

		for (int idx = 0; idx < argc; ++idx) 
			stream << argv[idx] << endl;

		/* how to initialize program option explicitly ??? */
		cout << "intializing batch counter: " << qsCurBatchFile.toStdString() << endl;
		{
			QFile qfile2(qsCurBatchFile);
			assert(qfile2.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text));
			{
				QTextStream stream2( &qfile2 );
				stream2 << "batch_num = 0" << endl;
			}
			qfile2.close();
		}

		ifstream ifs;
		ifs.open(qsCurBatchFile.toStdString().c_str());
		po::store(po::parse_config_file(ifs, cmd_options_desc), cmd_vars_map);
		ifs.close();

		{
			QFile qfile2(qsCurBatchFile);
			assert(qfile2.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text));
			{
				QTextStream stream2( &qfile2 );
				stream2 << "batch_num = 1" << endl;
			}
			qfile2.close();
		}
	}

	/* END: handle 'distribute' option */


	/* process options which do not require initialized partapp */
	if (cmd_vars_map.count(local::szOption_Help)) {
		cout << cmd_options_desc << endl << endl;
		return 1;
	}

	/* initialize partapp from parameter file */
	if (cmd_vars_map.count(local::szOption_ExpOpt) == 0) {
		cout << cmd_options_desc << endl << endl;
		cout << "'expopt' parameter missing" << endl;
		return 1;
	}

	PartApp part_app;
	QString qsExpParam = cmd_vars_map[local::szOption_ExpOpt].as<string>().c_str();
	cout << "initializing from " << qsExpParam.toStdString() << endl;
	part_app.init(qsExpParam);  

	if (cmd_vars_map.count(local::szOption_TrainClass)) {
		bool bBootstrap = cmd_vars_map.count(local::szOption_TrainBootstrap); // default is false

		if (cmd_vars_map.count(local::szOption_Pidx)) {

			int pidx = cmd_vars_map[local::szOption_Pidx].as<int>();
			assert(pidx < part_app.m_part_conf.part_size());
			assert(part_app.m_part_conf.part(pidx).is_detect());

			cout << "training classifier for part " << pidx << endl;
			part_detect::abc_train_class(part_app, pidx, bBootstrap);
		}
		else {
			for (int pidx = 0; pidx < part_app.m_part_conf.part_size(); ++pidx) {
				if (part_app.m_part_conf.part(pidx).is_detect()) {
					cout << "training classifier for part " << pidx << endl;
					part_detect::abc_train_class(part_app, pidx, bBootstrap);
				}
			}
		}

	}// train class
	else if (cmd_vars_map.count(local::szOption_BootstrapPrep)) {
		part_detect::prepare_bootstrap_dataset(part_app, part_app.m_train_annolist, 0, part_app.m_train_annolist.size() - 1);
	}
	else if (cmd_vars_map.count(local::szOption_BootstrapDetect)) {
		int firstidx, lastidx;
		local::init_firstidx_lastidx(part_app.m_train_annolist, cmd_vars_map, firstidx, lastidx);

		part_detect::bootstrap_partdetect(part_app, firstidx, lastidx);
	}
	else if (cmd_vars_map.count(local::szOption_BootstrapShowRects)) {
		assert(cmd_vars_map.count("pidx") && "part index missing");
		int pidx = cmd_vars_map["pidx"].as<int>();

		int firstidx, lastidx;
		local::init_firstidx_lastidx(part_app.m_train_annolist, cmd_vars_map, firstidx, lastidx);

		int num_rects = 50;
		double min_score = 0.1;
		vector<PartBBox> v_rects;
		vector<double> v_rects_scale;

		bool bIgnorePartRects = true;
		bool bDrawRects = true;

		/* create debug directory to save bootstrap images */
		if (!filesys::check_dir("./debug")) {
			cout << "creating ./debug" << endl;
			filesys::create_dir("./debug");
		}

		part_detect::bootstrap_get_rects(part_app, firstidx, pidx, num_rects, min_score, 
			v_rects, v_rects_scale,
			bIgnorePartRects, bDrawRects);

	}
	else if (cmd_vars_map.count(local::szOption_pc_learn)) {
		object_detect::learn_conf_param(part_app, part_app.m_train_annolist);
	}
	else if (cmd_vars_map.count(local::szOption_SaveRes)) {
		int scoreProbMapType = object_detect::SPMT_NONE;

		object_detect::saveRecoResults(part_app, scoreProbMapType);
	}
	else if (cmd_vars_map.count(local::szOption_EvalSegments)) {
		int firstidx, lastidx;
		local::init_firstidx_lastidx(part_app.m_test_annolist, cmd_vars_map, firstidx, lastidx);
		cout << "processing images: " << firstidx << " to " << lastidx << endl;

		eval_segments(part_app, firstidx, lastidx);

	}
	else if (cmd_vars_map.count(local::szOption_VisParts)) {

		int firstidx, lastidx;
		local::init_firstidx_lastidx(part_app.m_train_annolist, cmd_vars_map, firstidx, lastidx);

		for (int imgidx = firstidx; imgidx <= lastidx; ++imgidx) {
			QImage img = visualize_parts(part_app.m_part_conf, part_app.m_window_param, part_app.m_train_annolist[imgidx]);

			QString qsPartConfPath;
			QString qsPartConfName;
			QString qsPartConfExt;
			filesys::split_filename_ext(part_app.m_exp_param.part_conf().c_str(), qsPartConfPath, qsPartConfName, qsPartConfExt);

			QString qsDebugDir = (part_app.m_exp_param.log_dir() + "/" + 
				part_app.m_exp_param.log_subdir() + "/debug").c_str();

			if (!filesys::check_dir(qsDebugDir))
				filesys::create_dir(qsDebugDir);

			QString qsFilename = qsDebugDir + "/parts-" + qsPartConfName + "-imgidx" + 
				padZeros(QString::number(imgidx), 4) + ".png";
			cout << "saving " << qsFilename.toStdString() << endl;

			assert(img.save(qsFilename));    
		}

	}
	else {
		bool bShowHelpMessage = true;

		if (cmd_vars_map.count(local::szOption_PartDetect)) {

			int firstidx, lastidx;
			local::init_firstidx_lastidx(part_app.m_test_annolist, cmd_vars_map, firstidx, lastidx);

			bool bSaveImageScoreGrid = part_app.m_exp_param.save_image_scoregrid();
			cout << "bSaveImageScoreGrid: " << bSaveImageScoreGrid << endl;

			part_detect::partdetect(part_app, firstidx, lastidx, false, bSaveImageScoreGrid);
			if (part_app.m_exp_param.flip_orientation())
				part_detect::partdetect(part_app, firstidx, lastidx, true, bSaveImageScoreGrid);

			bShowHelpMessage = false;
		}

		if (cmd_vars_map.count(local::szOption_FindObj)) {
			int firstidx, lastidx;
			local::init_firstidx_lastidx(part_app.m_test_annolist, cmd_vars_map, firstidx, lastidx);

			int scoreProbMapType = object_detect::SPMT_NONE;
			object_detect::findObjectDataset(part_app, firstidx, lastidx, scoreProbMapType);

			bShowHelpMessage = false;
		}

		if (bShowHelpMessage) {
			cout << cmd_options_desc << endl;
			return 1;
		}
	}
	
	return 0;
}