Esempio n. 1
0
void
MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
{
    if ( result.isNull() )
        return;

    m_result = result;
    setEditable( result->collection() && result->collection()->source()->isLocal() );

    setTitle( result->track()->track() );
    setArtist( result->track()->artist() );
    setAlbum( result->track()->album() );
    setAlbumPos( result->track()->albumpos() );
    setDuration( result->track()->duration() );
    setYear( result->track()->year() );
    setBitrate( result->bitrate() );

    if ( result->collection() && result->collection()->source()->isLocal() )
    {
        QString furl = m_result->url();
        if ( furl.startsWith( "file://" ) )
            furl = furl.right( furl.length() - 7 );

        QFileInfo fi( furl );
        setFileName( fi.absoluteFilePath() );
        setFileSize( TomahawkUtils::filesizeToString( fi.size() ) );
    }

    setWindowTitle( result->track()->track() );

    if ( m_interface )
    {
        m_index = m_interface->indexOfResult( result );

        if ( m_index >= 0 )
            enablePushButtons();
    }
}
Esempio n. 2
0
DisAssembler::DisAssembler()
{
	bankselhelp = 0;

	ifstream hxfile(setFileName() + ".HEX");
	int count = 0;
	string linetest;
	for (int i = 0; i < 128; ++i)
	{
		program[i] = "\0";
	}
	for (int i = 0; i < 16; ++i)
	{
		hx[i] = intStrConv(i);
	}
	while (getline(hxfile, line))
	{
		parseLine(count);
		++count;
	}
	hxfile.close();
	displayProgram();
}
Esempio n. 3
0
	void EditorState::load()
	{
		if (EditorWidgets::getInstance().load(mFileName))
		{
			if (mFileName != mDefaultFileName && !isProjectFile(mFileName))
				RecentFilesManager::getInstance().addRecentFile(mFileName);

			UndoManager::getInstance().addValue();
			UndoManager::getInstance().setUnsaved(false);
		}
		else
		{
			/*MyGUI::Message* message = */MessageBoxManager::getInstance().create(
				replaceTags("Error"),
				replaceTags("MessageFailedLoadFile"),
				MyGUI::MessageBoxStyle::IconError | MyGUI::MessageBoxStyle::Ok
			);

			setFileName(mDefaultFileName);

			updateCaption();
		}
	}
Esempio n. 4
0
void
MetadataEditor::loadQuery( const Tomahawk::query_ptr& query )
{
    if ( query.isNull() )
        return;

    if ( query->numResults() )
    {
        loadResult( query->results().first() );
        return;
    }

    m_result = Tomahawk::result_ptr();
    m_query = query;
    setEditable( false );

    setTitle( query->track()->track() );
    setArtist( query->track()->artist() );
    setAlbum( query->track()->album() );
    setAlbumPos( query->track()->albumpos() );
    setDuration( query->track()->duration() );
    setYear( 0 );
    setBitrate( 0 );

    setFileName( QString() );
    setFileSize( 0 );

    setWindowTitle( query->track()->track() );

    if ( m_interface )
    {
        m_index = m_interface->indexOfQuery( query );

        if ( m_index >= 0 )
            enablePushButtons();
    }
}
Esempio n. 5
0
void CDoodFileViewManager::showFilePage(QString id, QString fileName, QString url, QString encryptKey, long long size, QString encryptUser)
{
    qDebug()<<Q_FUNC_INFO;

    QString path("");
    QFileInfo file;

    if(url != ""){//send
        path = QString::fromStdString(APP_SAVE_FILE_APTH)+"/"+fileName;
    }else{
        path = fileName;
    }
    file.setFile(path);
    setFileName(file.fileName());

    mId = id;
    mUrl = url;
    mEncryptKey = encryptKey;
    if(encryptUser != ""){
        mEncryptUser = encryptUser;
    }
    if(size != 0){
        setSize(size);
    }

    if(file.exists()){
        setPath(path);
        setProggress(100);
        setStatus(3);
        setSize(file.size());
    }else{
        setPath("");
        setProggress(0);
        setStatus(1);
    }

}
int QPluginLoader::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = fileName(); break;
        case 1: *reinterpret_cast< QLibrary::LoadHints*>(_v) = loadHints(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFileName(*reinterpret_cast< QString*>(_v)); break;
        case 1: setLoadHints(*reinterpret_cast< QLibrary::LoadHints*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 7
0
bool ParameterFileModel::load(const QString& fName) {
	// determine which file to load
	// (file dialog if fName is empty)
	QString fromDialog = fName;
	if (fromDialog.isEmpty()) {
		QString guess = _fileName;
		if (guess.isEmpty()) {
			QSettings settings;
			QStringList files =
					settings.value("recentFileList").toStringList();
			if (files.size() > 0)
				guess = files[0];
			else
				guess = QDir::homePath();
		}
		fromDialog = QFileDialog::getOpenFileName(0, tr("Open File"),
				guess, tr("ParameterFiles (*.wrp);;All Files (*.*)"));
	}
	if (fromDialog.isEmpty()) {
		emit statusMessage(tr("no file selected"));
	}
	else if (!QFileInfo(fromDialog).isFile()) {
		QMessageBox::warning(0, tr("Error loading file"),
				tr("File <em>%1</em> does not exist or is no file!")
						.arg(fromDialog));
	}
	else if (!QFileInfo(fromDialog).isReadable()) {
		QMessageBox::warning(0, tr("Error loading file"),
				tr("File <em>%1</em> is not readable!").arg(fromDialog));
	}
	else {
		// fromDialog is a readable file now
		setFileName(fromDialog);
		return _load();
	}
	return false;
}
FritzingWindow::FritzingWindow(const QString &untitledFileName, int &untitledFileCount, QString fileExt, QWidget * parent, Qt::WFlags f)
	: QMainWindow(parent, f)
{
	___fritzingTitle___ = QObject::tr("Fritzing");
	m_readOnly = false;

	// Let's set the icon
	this->setWindowIcon(QIcon(QPixmap(":resources/images/fritzing_icon.png")));

	QString fn = untitledFileName;

	if(untitledFileCount > 1) {
		fn += " " + QString::number(untitledFileCount);
	}
	fn += fileExt;
	setFileName(fn);

	untitledFileCount++;

	setTitle();

	m_undoStack = new WaitPushUndoStack(this);
	connect(m_undoStack, SIGNAL(cleanChanged(bool)), this, SLOT(undoStackCleanChanged(bool)) );
}
Esempio n. 9
0
Magic3D::XMLElement* Magic3D::Model::load(XMLElement* root)
{
    if (root)
    {
        XMLElement* model = root->FirstChildElement(M3D_MODEL_XML);

        std::string name = loadString(model, M3D_MODEL_XML_FILE);
        if (name.compare(M3D_XML_NULL) != 0)
        {
            setFileName(name);
        }

        if (getSkeleton())
        {
            getSkeleton()->load(model);
        }
    }

    Object::load(root);

    updateBoundingBox();

    return root;
}
Esempio n. 10
0
bool App::loadWorkspace(const QString &fileName)
{
    /* Clear existing document data */
    clearDocument();
    m_docLoaded = false;
    emit docLoadedChanged();

    QString localFilename =  fileName;
    if (localFilename.startsWith("file:"))
        localFilename = QUrl(fileName).toLocalFile();

    if (loadXML(localFilename) == QFile::NoError)
    {
        setTitle(QString("Q Light Controller Plus - %1").arg(localFilename));
        setFileName(localFilename);
        m_docLoaded = true;
        updateRecentFilesList(localFilename);
        emit docLoadedChanged();
        m_contextManager->resetContexts();
        m_doc->resetModified();
        return true;
    }
    return false;
}
Esempio n. 11
0
std::ostream& pout()
{
#ifdef CH_MPI
  // the common case is _open == true, which just returns s_pout
  if ( ! s_pout_open )
  {
    // the uncommon cae: the file isn't opened, MPI may not be
    // initialized, and the basename may not have been set
    int flag_i, flag_f;
    MPI_Initialized(&flag_i);
    MPI_Finalized(&flag_f);
    // app hasn't set a basename yet, so set the default
    if ( ! s_pout_init )
    {
      s_pout_basename = "pout" ;
      s_pout_init = true ;
    }
    // if MPI not initialized, we cant open the file so return cout
    if ( ! flag_i || flag_f)
    {
      return std::cout; // MPI hasn't been started yet, or has ended....
    }
    // MPI is initialized, so file must not be, so open it
    setFileName() ;
    openFile() ;
    // finally, in case the open failed, return cout
    if ( ! s_pout_open )
    {
      return std::cout ;
    }
  }
  return s_pout ;
#else
  return std::cout;
#endif
}
Esempio n. 12
0
/*!
 * \brief BitmapAnnotation::BitmapAnnotation
 * Used by OMSimulator FMU ModelWidget\n
 * We always make this shape as inherited shape since its not allowed to be modified.
 * \param classFileName
 * \param pGraphicsView
 */
BitmapAnnotation::BitmapAnnotation(QString classFileName, GraphicsView *pGraphicsView)
  : ShapeAnnotation(true, pGraphicsView, 0)
{
  mpComponent = 0;
  mClassFileName = classFileName;
  // set the default values
  GraphicItem::setDefaults();
  ShapeAnnotation::setDefaults();
  // set users default value by reading the settings file.
  ShapeAnnotation::setUserDefaults();
  QList<QPointF> extents;
  extents << QPointF(-100, -100) << QPointF(100, 100);
  setExtents(extents);
  setPos(mOrigin);
  setRotation(mRotation);
  setShapeFlags(true);

  setFileName(mClassFileName);
  if (!mFileName.isEmpty() && QFile::exists(mFileName)) {
    mImage.load(mFileName);
  } else {
    mImage = QImage(":/Resources/icons/bitmap-shape.svg");
  }
}
Esempio n. 13
0
Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) // type must be either DOC_REGULAR or DOC_UNNAMED
	: _pManager(pManager), _id(id), _isDirty(false), _doc(doc), _isFileReadOnly(false), _isUserReadOnly(false), _recentTag(-1), _references(0),
	_canNotify(false), _timeStamp(0), _needReloading(false), _encoding(-1)
{
	NppParameters *pNppParamInst = NppParameters::getInstance();
	const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
	_format = ndds._format;
	_unicodeMode = ndds._encoding;
	_encoding = ndds._codepage;
	if (_encoding != -1)
		_unicodeMode = uniCookie;

	_userLangExt = TEXT("");
	_fullPathName = TEXT("");
	_fileName = NULL;
	setFileName(fileName, ndds._lang);
	updateTimeStamp();
	checkFileState();
	_currentStatus = type;
	_isDirty = false;

	_needLexer = false; //new buffers do not need lexing, Scintilla takes care of that
	_canNotify = true;
}
Esempio n. 14
0
int
MidiFile::read(const char *fileName) {
	if (fileName == NULL)
		return 1;
	
	setFileName(fileName);
	_target = openFile(fileName);
	
	if (!_target)
		return 1;

	readFileHeader();
	setType();
	setTrackCount();
	setBPM();
	for (int i = 0; i < _fileHeader._tracks; i++) {
		_curTrack = i;
		readTrack();
		printContour();
	}

	fclose(_target);
   	return 0;
}		
Esempio n. 15
0
DCIFile::DCIFile(char *fn) {
	setFileName(fn);
}
Esempio n. 16
0
int VirtualFile::writeFile(char *fn) {
	setFileName(fn);
	return(writeData());
};
Esempio n. 17
0
int VirtualFile::readFile(char *fn) {
	setFileName(fn);
	return(readData());
};
Esempio n. 18
0
void
NIImporter_SUMO::_loadNetwork(const OptionsCont& oc) {
    // check whether the option is set (properly)
    if (!oc.isUsableFileList("sumo-net-file")) {
        return;
    }
    // parse file(s)
    std::vector<std::string> files = oc.getStringVector("sumo-net-file");
    for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
        if (!FileHelpers::exists(*file)) {
            WRITE_ERROR("Could not open sumo-net-file '" + *file + "'.");
            return;
        }
        setFileName(*file);
        PROGRESS_BEGIN_MESSAGE("Parsing sumo-net from '" + *file + "'");
        XMLSubSys::runParser(*this, *file);
        PROGRESS_DONE_MESSAGE();
    }
    // build edges
    for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
        EdgeAttrs* ed = (*i).second;
        // skip internal edges
        if (ed->func == toString(EDGEFUNC_INTERNAL)) {
            continue;
        }
        // get and check the nodes
        NBNode* from = myNodeCont.retrieve(ed->fromNode);
        NBNode* to = myNodeCont.retrieve(ed->toNode);
        if (from == 0) {
            WRITE_ERROR("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known.");
            continue;
        }
        if (to == 0) {
            WRITE_ERROR("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
            continue;
        }
        // edge shape
        PositionVector geom;
        if (ed->shape.size() > 0) {
            geom = ed->shape;
            mySuspectKeepShape = false; // no problem with reconstruction if edge shape is given explicit
        } else {
            // either the edge has default shape consisting only of the two node
            // positions or we have a legacy network
            geom = reconstructEdgeShape(ed, from->getPosition(), to->getPosition());
        }
        // build and insert the edge
        NBEdge* e = new NBEdge(ed->id, from, to,
                               ed->type, ed->maxSpeed,
                               (unsigned int) ed->lanes.size(),
                               ed->priority, NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET,
                               geom, ed->streetName, ed->lsf, true); // always use tryIgnoreNodePositions to keep original shape
        e->setLoadedLength(ed->length);
        if (!myNetBuilder.getEdgeCont().insert(e)) {
            WRITE_ERROR("Could not insert edge '" + ed->id + "'.");
            delete e;
            continue;
        }
        ed->builtEdge = myNetBuilder.getEdgeCont().retrieve(ed->id);
    }
    // assign further lane attributes (edges are built)
    for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
        EdgeAttrs* ed = (*i).second;
        NBEdge* nbe = ed->builtEdge;
        if (nbe == 0) { // inner edge or removed by explicit list, vclass, ...
            continue;
        }
        for (unsigned int fromLaneIndex = 0; fromLaneIndex < (unsigned int) ed->lanes.size(); ++fromLaneIndex) {
            LaneAttrs* lane = ed->lanes[fromLaneIndex];
            // connections
            const std::vector<Connection> &connections = lane->connections;
            for (std::vector<Connection>::const_iterator c_it = connections.begin(); c_it != connections.end(); c_it++) {
                const Connection& c = *c_it;
                if (myEdges.count(c.toEdgeID) == 0) {
                    WRITE_ERROR("Unknown edge '" + c.toEdgeID + "' given in connection.");
                    continue;
                }
                NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
                if (toEdge == 0) { // removed by explicit list, vclass, ...
                    continue;
                }
                nbe->addLane2LaneConnection(
                    fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::L2L_VALIDATED,
                    false, c.mayDefinitelyPass);

                // maybe we have a tls-controlled connection
                if (c.tlID != "") {
                    const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.tlID);
                    if (programs.size() > 0) {
                        std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
                        for (it = programs.begin(); it != programs.end(); it++) {
                            NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it->second);
                            if (tlDef) {
                                tlDef->addConnection(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkNo);
                            } else {
                                throw ProcessError("Corrupt traffic light definition '"
                                                   + c.tlID + "' (program '" + it->first + "')");
                            }
                        }
                    } else {
                        WRITE_ERROR("The traffic light '" + c.tlID + "' is not known.");
                    }
                }
            }
            // allow/disallow
            SUMOVehicleClasses allowed;
            SUMOVehicleClasses disallowed;
            parseVehicleClasses(lane->allow, lane->disallow, allowed, disallowed);
            nbe->setVehicleClasses(allowed, disallowed, fromLaneIndex);
            // width, offset
            nbe->setWidth(fromLaneIndex, lane->width);
            nbe->setOffset(fromLaneIndex, lane->offset);
            nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
        }
        nbe->declareConnectionsAsLoaded();
    }
    // insert loaded prohibitions
    for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
        NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
        if (prohibitedFrom == 0) {
            WRITE_ERROR("Edge '" + it->prohibitedFrom + "' in prohibition was not built");
        } else {
            NBNode* n = prohibitedFrom->getToNode();
            n->addSortedLinkFoes(
                NBConnection(myEdges[it->prohibitorFrom]->builtEdge, myEdges[it->prohibitorTo]->builtEdge),
                NBConnection(prohibitedFrom, myEdges[it->prohibitedTo]->builtEdge));
        }
    }

    // final warning
    if (mySuspectKeepShape) {
        WRITE_WARNING("The input network may have been built using option 'xml.keep-shape'.\n... Accuracy of junction positions cannot be guaranteed.");
    }

}
Esempio n. 19
0
VMIFile::VMIFile(char *fn, char *ds, char *cr, char *rn) {
	setFileName(fn);
	setDescription(ds);
	setCopyright(cr);
	setResourceName(rn);
}
Esempio n. 20
0
FileWriter::FileWriter(const string& aFileName)
{
	setFileName(aFileName);
	setLastError(kFileWriterErrorNone);
}
Esempio n. 21
0
// Extract the provider definition from the url
bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
{
  // Close any existing definition
  resetDefinition();

  // Extract the file name
  setFileName( url.toLocalFile() );

  // Extract the encoding
  if ( url.hasQueryItem( "encoding" ) )
  {
    mEncoding = url.queryItemValue( "encoding" );
  }

  //
  if ( url.hasQueryItem( "useWatcher" ) )
  {
    mUseWatcher = ! url.queryItemValue( "useWatcher" ).toUpper().startsWith( 'N' );
  }

  // The default type is csv, to be consistent with the
  // previous implementation (except that quoting should be handled properly)

  QString type( "csv" );
  QString delimiter( "," );
  QString quote = "\"";
  QString escape = "\"";
  mUseHeader = true;
  mSkipLines = 0;

  // Prefer simple "type" for delimiter type, but include delimiterType
  // as optional name  for backwards compatibility
  if ( url.hasQueryItem( "type" ) || url.hasQueryItem( "delimiterType" ) )
  {
    if ( url.hasQueryItem( "type" ) )
      type = url.queryItemValue( "type" );
    else if ( url.hasQueryItem( "delimiterType" ) )
      type = url.queryItemValue( "delimiterType" );

    // Support for previous version of Qgs - plain chars had
    // quote characters ' or "
    if ( type == "plain" )
    {
      quote = "'\"";
      escape = "";
    }
    else if ( type == "regexp " )
    {
      delimiter = "";
      quote = "";
      escape = "";
    }
  }
  if ( url.hasQueryItem( "delimiter" ) )
  {
    delimiter = url.queryItemValue( "delimiter" );
  }
  if ( url.hasQueryItem( "quote" ) )
  {
    quote = url.queryItemValue( "quote" );
  }
  if ( url.hasQueryItem( "escape" ) )
  {
    escape = url.queryItemValue( "escape" );
  }
  if ( url.hasQueryItem( "skipLines" ) )
  {
    mSkipLines = url.queryItemValue( "skipLines" ).toInt();
  }
  if ( url.hasQueryItem( "useHeader" ) )
  {
    mUseHeader = ! url.queryItemValue( "useHeader" ).toUpper().startsWith( 'N' );
  }
  if ( url.hasQueryItem( "skipEmptyFields" ) )
  {
    mDiscardEmptyFields = ! url.queryItemValue( "skipEmptyFields" ).toUpper().startsWith( 'N' );
  }
  if ( url.hasQueryItem( "trimFields" ) )
  {
    mTrimFields = ! url.queryItemValue( "trimFields" ).toUpper().startsWith( 'N' );
  }
  if ( url.hasQueryItem( "maxFields" ) )
  {
    mMaxFields = url.queryItemValue( "maxFields" ).toInt();
  }

  QgsDebugMsg( "Delimited text file is: " + mFileName );
  QgsDebugMsg( "Encoding is: " + mEncoding );
  QgsDebugMsg( "Delimited file type is: " + type );
  QgsDebugMsg( "Delimiter is: [" + delimiter + "]" );
  QgsDebugMsg( "Quote character is: [" + quote + "]" );
  QgsDebugMsg( "Escape character is: [" + escape + "]" );
  QgsDebugMsg( "Skip lines: " + QString::number( mSkipLines ) );
  QgsDebugMsg( "Maximum number of fields in record: " + QString::number( mMaxFields ) );
  QgsDebugMsg( "Use headers: " + QString( mUseHeader ? "Yes" : "No" ) );
  QgsDebugMsg( "Discard empty fields: " + QString( mDiscardEmptyFields ? "Yes" : "No" ) );
  QgsDebugMsg( "Trim fields: " + QString( mTrimFields ? "Yes" : "No" ) );

  // Support for previous version of plain characters
  if ( type == "csv" || type == "plain" )
  {
    setTypeCSV( delimiter, quote, escape );
  }
  else if ( type == "whitespace" )
  {
    setTypeWhitespace();
  }
  else if ( type == "regexp" )
  {
    setTypeRegexp( delimiter );
  }
  else
  {
    return false;
  }
  return mDefinitionValid;
}
Esempio n. 22
0
FileAppender::FileAppender(const QString& fileName)
{
  setFileName(fileName);
}
Esempio n. 23
0
bool PViewDataList::combineSpace(nameData &nd)
{
  // sanity checks
  if(nd.data.size() < 2) return false;
  int ts = nd.data[0]->getNumTimeSteps();
  for(std::size_t i = 1; i < nd.data.size(); i++) {
    if(!nd.data[i]->empty() && nd.data[i]->getNumTimeSteps() != ts) {
      Msg::Error("Cannot combine views having different number of time steps");
      return false;
    }
  }

  for(std::size_t i = 0; i < nd.data.size(); i++) {
    PViewDataList *l = dynamic_cast<PViewDataList *>(nd.data[i]);
    if(!l) {
      Msg::Error("Cannot combine hybrid data");
      return false;
    }

    // copy interpolation matrices
    for(std::map<int, std::vector<fullMatrix<double> *> >::iterator it =
          l->_interpolation.begin();
        it != l->_interpolation.end(); it++)
      if(_interpolation[it->first].empty())
        for(std::size_t i = 0; i < it->second.size(); i++)
          _interpolation[it->first].push_back(
            new fullMatrix<double>(*it->second[i]));

    // copy time values

    if(!i) Time = l->Time;

    // merge elememts
    dVecMerge(l->SP, SP);
    NbSP += l->NbSP;
    dVecMerge(l->VP, VP);
    NbVP += l->NbVP;
    dVecMerge(l->TP, TP);
    NbTP += l->NbTP;
    dVecMerge(l->SL, SL);
    NbSL += l->NbSL;
    dVecMerge(l->VL, VL);
    NbVL += l->NbVL;
    dVecMerge(l->TL, TL);
    NbTL += l->NbTL;
    dVecMerge(l->ST, ST);
    NbST += l->NbST;
    dVecMerge(l->VT, VT);
    NbVT += l->NbVT;
    dVecMerge(l->TT, TT);
    NbTT += l->NbTT;
    dVecMerge(l->SQ, SQ);
    NbSQ += l->NbSQ;
    dVecMerge(l->VQ, VQ);
    NbVQ += l->NbVQ;
    dVecMerge(l->TQ, TQ);
    NbTQ += l->NbTQ;
    dVecMerge(l->SS, SS);
    NbSS += l->NbSS;
    dVecMerge(l->VS, VS);
    NbVS += l->NbVS;
    dVecMerge(l->TS, TS);
    NbTS += l->NbTS;
    dVecMerge(l->SH, SH);
    NbSH += l->NbSH;
    dVecMerge(l->VH, VH);
    NbVH += l->NbVH;
    dVecMerge(l->TH, TH);
    NbTH += l->NbTH;
    dVecMerge(l->SI, SI);
    NbSI += l->NbSI;
    dVecMerge(l->VI, VI);
    NbVI += l->NbVI;
    dVecMerge(l->TI, TI);
    NbTI += l->NbTI;
    dVecMerge(l->SY, SY);
    NbSY += l->NbSY;
    dVecMerge(l->VY, VY);
    NbVY += l->NbVY;
    dVecMerge(l->TY, TY);
    NbTY += l->NbTY;
    dVecMerge(l->VR, VR);
    NbVR += l->NbVR;
    dVecMerge(l->TR, TR);
    NbTR += l->NbTR;

    // merge strings
    for(std::size_t i = 0; i < l->T2D.size(); i += 4) {
      T2D.push_back(l->T2D[i]);
      T2D.push_back(l->T2D[i + 1]);
      T2D.push_back(l->T2D[i + 2]);
      T2D.push_back(T2C.size());
      double beg = l->T2D[i + 3];
      double end;
      if(i > l->T2D.size() - 8)
        end = l->T2C.size();
      else
        end = l->T2D[i + 3 + 4];
      char *c = &l->T2C[(int)beg];
      for(int j = 0; j < (int)(end - beg); j++) T2C.push_back(c[j]);
      NbT2++;
    }
    for(std::size_t i = 0; i < l->T3D.size(); i += 5) {
      T3D.push_back(l->T3D[i]);
      T3D.push_back(l->T3D[i + 1]);
      T3D.push_back(l->T3D[i + 2]);
      T3D.push_back(l->T3D[i + 3]);
      T3D.push_back(T3C.size());
      double beg = l->T3D[i + 4];
      double end;
      if(i > l->T3D.size() - 10)
        end = l->T3C.size();
      else
        end = l->T3D[i + 4 + 5];
      char *c = &l->T3C[(int)beg];
      for(int j = 0; j < (int)(end - beg); j++) T3C.push_back(c[j]);
      NbT3++;
    }
  }

  std::string tmp;
  if(nd.name == "__all__")
    tmp = "all";
  else if(nd.name == "__vis__")
    tmp = "visible";
  else
    tmp = nd.name;
  char name[256];
  sprintf(name, "%s_Combine", tmp.c_str());
  setName(name);
  setFileName(std::string(name) + ".pos");

  return finalize();
}
Esempio n. 24
0
bool FileMgr::fileToMem(const char *sFileName, const int iTableType,bool bShow ,bool bReplace){
    if (0 == sFileName)
        return false;

    setFileName(sFileName);
    setTableType(iTableType);

    char sFullFileName[500]={0};
    char sLineTmp[DATA_LEN]={0};

    if ('/' != m_sFileName[0] ) {
        strcat(sFullFileName, m_sFilePath);
        strcat(sFullFileName, m_sFileName);
    }else {
    	for(int j=(strlen(sFileName)-1);j>0;j--)
    	{
    		if(m_sFileName[j]=='/')
    		{
    			strncpy(m_sFilePath,m_sFileName,j);
    			break;
    		}
    	}
    	strcat(sFullFileName, m_sFileName);
    }
    
		if(!openPath(m_sFilePath)) {
			return false;
		}
    Log::log(0, "导入文件的路径是:%s", m_sFilePath);
    
    if ( access(sFullFileName , R_OK|W_OK) ) {
    		m_poLogGroup->log(MBC_FILE_NOT_EXIST,LOG_LEVEL_ERROR,LOG_CLASS_ERROR,LOG_TYPE_PROC,-1,NULL,"指定文件不存在[%s]",sFullFileName);
        Log::log(0, "文件[%s]不存在,请重新指定文件名后再试!", sFullFileName);
        return false;
    }
    if ( !setColumnInfo(iTableType) ) {
        return false;
    }
    if (!openFile(sFullFileName, "r")) {
        return false;
    }

    //读取文件内字段名
    if ( getLine(sLineTmp, DATA_LEN-1, '\n') ) {
        if ( !checkColumn(sLineTmp) )
            return false;
    } else {
        Log::log(0, "读取文件内字段名信息出错,请检查文件!");
        return false;
    }
    //处理每一行
    int iTotalCnt = 0;
    int iUpdCnt = 0;
    Log::log(0, "开始导入数据...");
    while ( getLine(sLineTmp, DATA_LEN-1, '\n') ) {
        if ( 0 == sLineTmp[0] ) {
            continue;
        }
        if ( !flushToMem(sLineTmp, bShow, iUpdCnt,bReplace) ) {                //每行数据写入内存
            Log::log(0, "无法加载数据,此行为:\n%s", sLineTmp);
            return false;    
        }
        ++iTotalCnt;
    }
    closeFile();
    Log::log(0, "共导入 %d 条数据:更新 %d 条,新增 %d 条!", iTotalCnt, iUpdCnt, iTotalCnt - iUpdCnt);

    return true;
}
Esempio n. 25
0
/*!
It enables to set the path and the name of the file(s) which as/have to be read.

If you want to read a video file, \f$ filename \f$ corresponds to the path to the file (example : /local/video.mpeg).

If you want to read a sequence of images, \f$ filename \f$ corresponds to the path followed by the image name template. For exemple, if you want to read different images named image0001.jpeg, image0002.jpg, ... and located in the folder /local/image, \f$ filename \f$ will be "/local/image/image%04d.jpg".

\param filename : Path to a video file or file name template of a image sequence.
*/
void vpVideoReader::setFileName(const std::string &filename)
{
	setFileName(filename.c_str());
}
Esempio n. 26
0
TEIniFile::TEIniFile(const QString &name)
{
	setFileName(name);
  ts.setEncoding(QTextStream::UnicodeUTF8);
}
Esempio n. 27
0
bool FileMgr::memToFile(const char *sFileName, const int iTableType, bool bShow){
    if ( !sFileName ) {
        return false;
    }

    setFileName(sFileName);
    setTableType(iTableType);

    char sFullFileName[500]={0};
    if ('/' != m_sFileName[0] ) {
        strcat(sFullFileName, m_sFilePath);
        strcat(sFullFileName, m_sFileName);
    }else {
    	for(int j=(strlen(sFileName)-1);j>0;j--)
    	{
    		if(m_sFileName[j]=='/')
    		{
    			strncpy(m_sFilePath,m_sFileName,j);
    			break;
    		}
    	}
    	strcat(sFullFileName, m_sFileName);
    }
    
		if(!openPath(m_sFilePath)) {
			return false;
		}
    Log::log(0, "导出文件的路径是:%s", m_sFilePath);

    if ( !access(sFullFileName , R_OK|W_OK) ) {
        Log::log(0, "文件[%s]已存在,请重新指定文件名后再试!", sFullFileName);
        return false;
    }
    if ( !setColumnInfo(iTableType) ) {
        return false;
    }
    if ( !openDbFile(sFullFileName) ) {
        return false;
    }
    int iTotalCnt = 0;          //待处理数据量

    Log::log(0, "开始导出数据...");
    switch (m_iTableType) {
    	case TABLE_HCODE_INFO:
    	    {
            HCodeInfoStruct *pData = NULL;

            setDataStructSize(sizeof(HCodeInfoStruct));
            iTotalCnt = SHMInfoCtl::getCount(TABLE_HCODE_INFO);
            SHMInfoCtl::getHeadData(&pData, 1);
            addData((char*)pData, iTotalCnt);
            if (bShow) {
                for (int i=0;i<iTotalCnt;++i)
                {
                    SHMInfoCtl::showHCodeInfo(*(pData+i));
                }
            }
    	    }
    	    break;
    	case TABLE_MIN_INFO:
    	    {
            MinInfoStruct *pData = NULL;

            setDataStructSize(sizeof(MinInfoStruct));
            iTotalCnt = SHMInfoCtl::getCount(TABLE_MIN_INFO);
            SHMInfoCtl::getMinData(&pData, 1);
            addData((char*)pData, iTotalCnt);
            if (bShow) {
                for (int i=0;i<iTotalCnt;++i)
                {
                    SHMInfoCtl::showMinInfo(*(pData+i));
                }
            }
    	    }
    	    break;
    	case TABLE_LOCAL_INFO:
    	    {
						
    	    }
    	    break;
    	case TABLE_IMSI_INFO:
    	    {
            IMSIInfoStruct *pData = NULL;

            setDataStructSize(sizeof(IMSIInfoStruct));
            iTotalCnt = SHMInfoCtl::getCount(TABLE_IMSI_INFO);
            SHMInfoCtl::getImsiData(&pData, 1);
            addData((char*)pData, iTotalCnt);
            if (bShow) {
                for (int i=0;i<iTotalCnt;++i)
                {
                    SHMInfoCtl::showImsiInfo(*(pData+i));
                }
            }
    	    }
    	    break;
    default:
        {
            Log::log(0, "未知表类型:%d", iTableType);
            return false;
        }
        break;
    }

    closeFile();
    Log::log(0, "共导出 %d 条数据!", iTotalCnt);

    return true;
}
Esempio n. 28
0
void FileResourcesModel::setFileNameStr(const QString &fileName)
{
    setFileName(QUrl(fileName));
}
Esempio n. 29
0
bool PViewDataList::combineTime(nameData &nd)
{
  // sanity checks
  if(nd.data.size() < 2) return false;
  std::vector<PViewDataList *> data(nd.data.size());
  for(std::size_t i = 0; i < nd.data.size(); i++) {
    data[i] = dynamic_cast<PViewDataList *>(nd.data[i]);
    if(!data[i]) {
      Msg::Error("Cannot combine hybrid data");
      return false;
    }
  }

  int *nbe = 0, *nbe2 = 0, nbn, nbn2, nbc, nbc2;
  std::vector<double> *list = 0, *list2 = 0;

  // use the first data set as the reference
  for(int i = 0; i < 27; i++) {
    _getRawData(i, &list, &nbe, &nbc, &nbn);
    data[0]->_getRawData(i, &list2, &nbe2, &nbc2, &nbn2);
    *nbe = *nbe2;
  }
  NbT2 = data[0]->NbT2;
  NbT3 = data[0]->NbT3;
  for(std::map<int, std::vector<fullMatrix<double> *> >::iterator it =
        data[0]->_interpolation.begin();
      it != data[0]->_interpolation.end(); it++)
    if(_interpolation[it->first].empty())
      for(std::size_t i = 0; i < it->second.size(); i++)
        _interpolation[it->first].push_back(
          new fullMatrix<double>(*it->second[i]));

  // merge values for all element types
  for(int i = 0; i < 27; i++) {
    _getRawData(i, &list, &nbe, &nbc, &nbn);
    for(int j = 0; j < *nbe; j++) {
      for(std::size_t k = 0; k < data.size(); k++) {
        data[k]->_getRawData(i, &list2, &nbe2, &nbc2, &nbn2);
        if(*nbe && *nbe == *nbe2) {
          int nb2 = list2->size() / *nbe2;
          if(!k) {
            // copy coordinates of elm j (we are always here as
            // expected, since the ref view is the first one)
            for(int l = 0; l < 3 * nbn2; l++)
              list->push_back((*list2)[j * nb2 + l]);
          }
          // copy values of elm j
          for(int l = 0; l < nb2 - 3 * nbn2; l++)
            list->push_back((*list2)[j * nb2 + 3 * nbn2 + l]);
        }
      }
    }
  }

  // merge 2d strings
  for(int j = 0; j < NbT2; j++) {
    for(std::size_t k = 0; k < data.size(); k++) {
      if(NbT2 == data[k]->NbT2) {
        if(!k) {
          // copy coordinates
          T2D.push_back(data[k]->T2D[j * 4]);
          T2D.push_back(data[k]->T2D[j * 4 + 1]);
          T2D.push_back(data[k]->T2D[j * 4 + 2]);
          // index
          T2D.push_back(T2C.size());
        }
        // copy char values
        double beg = data[k]->T2D[j * 4 + 3];
        double end;
        if(j == NbT2 - 1)
          end = data[k]->T2C.size();
        else
          end = data[k]->T2D[j * 4 + 4 + 3];
        char *c = &data[k]->T2C[(int)beg];
        for(int l = 0; l < (int)(end - beg); l++) T2C.push_back(c[l]);
      }
    }
  }

  // merge 3d strings
  for(int j = 0; j < NbT3; j++) {
    for(std::size_t k = 0; k < data.size(); k++) {
      if(NbT3 == data[k]->NbT3) {
        if(!k) {
          // copy coordinates
          T3D.push_back(data[k]->T3D[j * 5]);
          T3D.push_back(data[k]->T3D[j * 5 + 1]);
          T3D.push_back(data[k]->T3D[j * 5 + 2]);
          T3D.push_back(data[k]->T3D[j * 5 + 3]);
          // index
          T3D.push_back(T3C.size());
        }
        // copy char values
        double beg = data[k]->T3D[j * 5 + 4];
        double end;
        if(j == NbT3 - 1)
          end = data[k]->T3C.size();
        else
          end = data[k]->T3D[j * 5 + 5 + 4];
        char *c = &data[k]->T3C[(int)beg];
        for(int l = 0; l < (int)(end - beg); l++) T3C.push_back(c[l]);
      }
    }
  }

  // create the time data
  for(std::size_t i = 0; i < data.size(); i++) dVecMerge(data[i]->Time, Time);

  // if all the time values are the same, it probably means that the
  // original views didn't have any time data: then we'll just use
  // time step values
  if(Time.size()) {
    double t0 = Time[0], ti;
    bool allTheSame = true;
    for(std::size_t i = 1; i < Time.size(); i++) {
      ti = Time[i];
      if(ti != t0) {
        allTheSame = false;
        break;
      }
    }
    if(allTheSame) Time.clear();
  }

  std::string tmp;
  if(nd.name == "__all__")
    tmp = "all";
  else if(nd.name == "__vis__")
    tmp = "visible";
  else
    tmp = nd.name;
  char name[256];
  sprintf(name, "%s_Combine", tmp.c_str());

  setName(name);
  setFileName(std::string(name) + ".pos");
  return finalize();
}
Esempio n. 30
0
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName)
	:CommonMultiBodyBase(helper),
	m_grav(-10),
	m_upAxis(2)
{
	m_data = new ImportUrdfInternalData;

	if (option==1)
	{
		m_useMultiBody = true;
	} else
	{
		m_useMultiBody = false;
	}

	static int count = 0;
	if (fileName)
	{
		setFileName(fileName);
	} else
	{
		gFileNameArray.clear();
		


		//load additional urdf file names from file

		FILE* f = fopen("urdf_files.txt","r");
		if (f)
		{
			int result;
			//warning: we don't avoid string buffer overflow in this basic example in fscanf
			char fileName[1024];
			do
			{
				result = fscanf(f,"%s",fileName);
                b3Printf("urdf_files.txt entry %s",fileName);
				if (result==1)
				{
					gFileNameArray.push_back(fileName);
				}
			} while (result==1);

			fclose(f);
		}
		
		if (gFileNameArray.size()==0)
		{
			gFileNameArray.push_back("r2d2.urdf");

		}

		int numFileNames = gFileNameArray.size();

		if (count>=numFileNames)
		{
			count=0;
		}
		sprintf(m_fileName,"%s",gFileNameArray[count++].c_str());
	}
}