void SceneWidget::slotImportMeshModels(void) { MainWindow* main_window = MainWindow::getInstance(); QStringList filenames = QFileDialog::getOpenFileNames(main_window, "Import Mesh Models", main_window->getWorkspace().c_str(), "Mesh Models (*.off *.ply *.obj)"); if (filenames.isEmpty()) return; bool flag = true; std::string failed_list; for (QStringList::iterator it = filenames.begin(); it != filenames.end(); ++it) { osg::ref_ptr<MeshModel> mesh_model(new MeshModel()); if (mesh_model->load(it->toStdString())) { mesh_models_.push_back(mesh_model); addSceneChild(mesh_model); } else { flag = false; LOG(ERROR) << "Importing " << it->toStdString() << " failed!" << std::endl; failed_list += it->toStdString() + " "; } } if (!flag) { main_window->showMessageBox("Some mesh importing failed!", failed_list); } centerScene(); return; }
std::vector<std::string> GMSHPrefsDialog::getSelectedObjects(QStringList list) { std::vector<std::string> indexList; for (QStringList::iterator it = list.begin(); it != list.end(); ++it) indexList.push_back(it->toStdString()); return indexList; }
bool LuaList::loadAll() { std::cout << "[Lua] loading all script files from " << _filePath.toStdString() << std::endl; // get everything with ".lua" QStringList files; QDirIterator dirIt(_filePath); while (dirIt.hasNext()) { dirIt.next(); if (QFileInfo(dirIt.filePath()).isFile()) if (QFileInfo(dirIt.filePath()).suffix() == "lua") files.append(dirIt.fileName()); } std::cout << "[Lua] loading all script files from " << _templateFilePath.toStdString() << std::endl; // get everything with ".lua" QDirIterator dirIt2(_templateFilePath); while (dirIt2.hasNext()) { dirIt2.next(); if (QFileInfo(dirIt2.filePath()).isFile()) if (QFileInfo(dirIt2.filePath()).suffix() == "lua") if(!files.contains(dirIt2.fileName(), Qt::CaseInsensitive)) files.append(dirIt2.fileName()); } if(!_luaList.empty()) // clear list before loading clearList(); // load lua files for( QStringList::iterator it = files.begin(); it != files.end(); ++it) { LuaContainer* c = new LuaContainer(); std::cout << "[Lua] loading file " << it->toStdString() << " ..." << std::endl; if(load((*it), c)) _luaList.push_back(c); else std::cerr << "[Lua] can't load file " << it->toStdString() << std::endl; } if(_luaList.empty()) return false; else return true; }
void SignatureDialog::bt_ok_clicked() { m_ok_clicked = true; QMap<QString, QString> options; m_data_layout->options(options, true); QMap<QString, XmlNode>::iterator it = m_nodes.begin(); for( ; it != m_nodes.end() ; it++) { XmlNode & optionNode = it.value(); if( Map::is_single_value(optionNode) ) { XmlNode node( optionNode.content->first_node() ); const std::string value = options[it.key()].toStdString().c_str(); node.content->value( node.content->document()->allocate_string(value.c_str(), value.size()+1), value.size() ); } else { QStringList value = options[it.key()].split(";"); QStringList::iterator itValue = value.begin(); std::string delim(optionNode.content->first_attribute( Protocol::Tags::attr_array_delimiter() )->value()); std::string val_str; rapidxml::xml_node<char>* node = it.value().content; for( ; itValue != value.end() ; itValue++) { if(!val_str.empty()) val_str += delim; val_str += itValue->toStdString(); } node->value( node->document()->allocate_string(val_str.c_str()) ); it.value().set_attribute(Protocol::Tags::attr_array_size(), QString::number(value.count()).toStdString()); } } emit finished(QDialog::Accepted); if(m_is_blocking) this->setVisible(false); }
void synaxErrorJudger::generateSelectAttribute() { int begin = sqlExp.indexOf("select") + 6; int end = sqlExp.indexOf("from") - 1; QStringList selectAttrs = sqlExp.mid(begin, end - begin + 1).split(','); QStringList::iterator it; for (it = selectAttrs.begin(); it != selectAttrs.end(); ++it) { *it = it->trimmed(); if (*it == "") { throw QString("Synax Error: Select statement's format is incorrect."); } if (selectAttribute == 0) { selectAttribute = new vector<string>; } selectAttribute->push_back(it->toStdString()); } }
QIcon* IconLoader::loadIcon_(const String& name) { const QString filename = QString(name.c_str()) + ".png"; for (QStringList::iterator it = icon_dirs_.begin(); it != icon_dirs_.end(); ++it) { QDir base_dir(*it); if (!base_dir.exists()) { Log.error() << "Could not locate the icon directory: " << it->toStdString() << std::endl; return 0; } QString category_name; QIcon* result = 0; for(std::list<int>::iterator sit = sizes_.begin(); sit != sizes_.end(); ++sit) { QDir size_dir = *it + FileSystem::PATH_SEPARATOR + QString::number(*sit) + "x" + QString::number(*sit); if (!size_dir.exists()) { continue; } if (size_dir.exists(filename)) { if (!result) { result = new QIcon(); } result->addFile(size_dir.path() + FileSystem::PATH_SEPARATOR + filename); } } if (result) { icon_map_[name] = result; return result; } } return 0; }
void HIC::WMain::loadLinkTypes() { QString linktypeDirPath = QCoreApplication::applicationDirPath() + tr("/linktypes/"); QDir linktypeDir = QDir(linktypeDirPath); QStringList nameFilters; nameFilters.append(QString("*.linktype")); QStringList fileList = linktypeDir.entryList(nameFilters); std::vector<std::string> linkTypeFilePaths; for (QStringList::iterator iterator = fileList.begin(); iterator != fileList.end(); iterator++) { linkTypeFilePaths.push_back(iterator->toStdString()); } QDir::setCurrent(linktypeDirPath); _application.loadLinkTypeList(linkTypeFilePaths); QDir::setCurrent(QCoreApplication::applicationDirPath()); }
ChatroomInfo ChatDialog::getChatroomInfo() { ChatroomInfo chatroomInfo; chatroomInfo.setName(Name::Component(m_chatroomName)); QStringList prefixList = m_scene->getRosterPrefixList(); for(QStringList::iterator it = prefixList.begin(); it != prefixList.end(); ++it ) { Name participant = Name(it->toStdString()).getPrefix(-3); chatroomInfo.addParticipant(participant); } chatroomInfo.setSyncPrefix(m_chatroomPrefix); if (m_isSecured) chatroomInfo.setTrustModel(ChatroomInfo::TRUST_MODEL_HIERARCHICAL); else chatroomInfo.setTrustModel(ChatroomInfo::TRUST_MODEL_NONE); return chatroomInfo; }
bool MainWindow::LoadDataset(QStringList files, QString targetFilename, bool bNoUserInteraction) { std::vector<std::string> stdFiles; for (QStringList::iterator it = files.begin(); it != files.end(); ++it) { string datasetName = it->toStdString(); stdFiles.push_back(datasetName); } string stdTargetFilename = targetFilename.toStdString(); LuaClassInstance inst = m_MasterController.LuaScript()->cexecRet<LuaClassInstance>( "iv3d.rendererWithParams.new", stdFiles, stdTargetFilename, bNoUserInteraction); return !inst.isDefaultInstance(); }
void PluginManager::display(GenericInterface* gi) { QMenu* menu = gi->menu(tr("&Plugin")); _loadPluginAction = menu->addAction(tr("&Load plugin")); _unloadPluginsAction = menu->addAction(tr("&Unload all plugins")); // TODO: perform this task in a better and most logical place. For now, // it works because 'addPlugin()' signal will be connected when it is emmited // in loadPlugin(), so it will really display its menu in the GenericInterface QDir directory("plugins"); QStringList files = directory.entryList(); std::cout << files.size() << " files in plugins' directory" << std::endl; for(QStringList::iterator it = files.begin(); it != files.end(); ++it) { if(QLibrary::isLibrary(*it)) { std::cout << "library found : " << it->toStdString() << std::endl; loadPlugin(directory.path() + QDir::separator() + *it); } } checkActionsValid(); }
void NRemoteFSBrowser::openDir ( const QString & path ) { SignalFrame frame("read_dir", uri(), SERVER_CORE_PATH); SignalOptions options( frame ); std::vector<std::string> vect; QStringList::iterator it = m_extensions.begin(); while(it != m_extensions.end()) { vect.push_back(it->toStdString()); it++; } options.add_option< OptionT<std::string> >("dirPath", path.toStdString()); options.add_option< OptionT<bool> >("includeFiles", m_includeFiles); options.add_option< OptionT<bool> >("includeNoExtensions", m_includeNoExtensions); options.add_option< OptionArrayT<std::string> >("extensions", vect); options.flush(); NetworkQueue::global_queue()->send( frame, NetworkQueue::IMMEDIATE ); }
void synaxErrorJudger::generateCondition() { int begin = sqlExp.indexOf("where") + 5; int end = sqlExp.indexOf(QRegExp(";$")) - 1; QStringList conditions = sqlExp.mid(begin, end - begin + 1).split("and"); QStringList::iterator it; pair<int, size_t> dataType; int logicType; string rightSide, leftSide; for (it = conditions.begin(); it != conditions.end(); ++it) { *it = it->trimmed(); if (*it == "") { throw QString("Synax Error: Conditions' format is incorrect."); } int begin = 0; int end = it->indexOf(QRegExp("[=><]"))-1; rightSide = it->mid(begin, end - begin + 1).trimmed().toStdString(); begin = end + 1; end = it->indexOf(QRegExp("[=><]"), begin + 1); if (end - begin > 1 || end == -1) { //如果下一个"=",">","<"号出现在较远处 end = begin; //说明这个逻辑关系是"=",">","<"而非">=", "<=", "<>" } logicType = condition::getLogicTypeFromStr(it->mid(begin, end - begin + 1).toStdString()); if (logicType == _ERROR) { throw QString("Synax Error: The logic arithemtic is invalid."); } bool ok; *it = it->mid(end + 1).trimmed(); if (it->indexOf(QRegExp("^'")) != -1) { //引号'应该是字符或字符串 it->remove(0, 1).remove(QRegExp("'$")); size_t len = it->size(); pair<int, size_t> dType; Api::cManager.getAttributeDataType(*tblName, rightSide, dType); if (len < 1 || len > 255 || len > dType.second) { throw QString("Synax Error: The length of string is overflow."); } else if (len == 1) { dataType = pair<int, size_t>(_CHAR, sizeof(char)); } else { dataType = pair<int, size_t>(_STRING, dType.second * sizeof(char)); } } else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float it->toFloat(&ok); if (!ok) { ; } else { dataType = pair<int, size_t>(_FLOAT, sizeof(float)); } } else { //剩下的应该是int类型 it->toInt(&ok); if (!ok) { ; } else { dataType = pair<int, size_t>(_INT, sizeof(int)); } } leftSide = it->toStdString(); if (cond == 0) { cond = new vector<condition>; } cond->push_back(condition(rightSide, logicType, dataType, leftSide)); } }
void CLArgsPrivate::parse() { { QStringList::iterator it = hasToken( QString::fromUtf8("version"), QString::fromUtf8("v") ); if ( it != args.end() ) { QString msg = QObject::tr("%1 version %2 at commit %3 on branch %4 built on %4").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ).arg( QString::fromUtf8(NATRON_VERSION_STRING) ).arg( QString::fromUtf8(GIT_COMMIT) ).arg( QString::fromUtf8(GIT_BRANCH) ).arg( QString::fromUtf8(__DATE__) ); std::cout << msg.toStdString() << std::endl; error = 1; return; } } { QStringList::iterator it = hasToken( QString::fromUtf8("help"), QString::fromUtf8("h") ); if ( it != args.end() ) { CLArgs::printUsage( args[0].toStdString() ); error = 1; return; } } { QStringList::iterator it = hasToken( QString::fromUtf8("background"), QString::fromUtf8("b") ); if ( it != args.end() ) { isBackground = true; args.erase(it); } } { QStringList::iterator it = hasToken( QString::fromUtf8("interpreter"), QString::fromUtf8("t") ); if ( it != args.end() ) { isInterpreterMode = true; isBackground = true; std::cout << QObject::tr("Note: -t argument given, loading in command-line interpreter mode, only Python commands / scripts are accepted").toStdString() << std::endl; args.erase(it); } } { QStringList::iterator it = hasToken( QString::fromUtf8("render-stats"), QString::fromUtf8("s") ); if ( it != args.end() ) { enableRenderStats = true; args.erase(it); } } { QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_PROCESS_PID), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { breakpadProcessPID = it->toLongLong(); args.erase(it); } else { std::cout << QObject::tr("You must specify the breakpad process executable file path").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_PROCESS_EXEC), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { breakpadProcessFilePath = *it; args.erase(it); } else { std::cout << QObject::tr("You must specify the breakpad process executable file path").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_CLIENT_FD_ARG), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { breakpadPipeClientID = it->toInt(); args.erase(it); } else { std::cout << QObject::tr("You must specify the breakpad pipe client FD").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_PIPE_ARG), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { breakpadPipeFilePath = *it; args.erase(it); } else { std::cout << QObject::tr("You must specify the breakpad pipe path").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_COM_PIPE_ARG), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { breakpadComPipeFilePath = *it; args.erase(it); } else { std::cout << QObject::tr("You must specify the breakpad communication pipe path").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8("export-docs"), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { exportDocsPath = *it; args.erase(it); } else { std::cout << QObject::tr("You must specify the doc dir path").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8("IPCpipe"), QString() ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { ipcPipe = *it; args.erase(it); } else { std::cout << QObject::tr("You must specify the IPC pipe filename").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = hasToken( QString::fromUtf8("onload"), QString::fromUtf8("l") ); if ( it != args.end() ) { ++it; if ( it != args.end() ) { defaultOnProjectLoadedScript = *it; #ifdef __NATRON_UNIX__ defaultOnProjectLoadedScript = AppManager::qt_tildeExpansion(defaultOnProjectLoadedScript); #endif QFileInfo fi(defaultOnProjectLoadedScript); if ( !fi.exists() ) { std::cout << QObject::tr("WARNING: --onload %1 ignored because the file does not exist.").arg(defaultOnProjectLoadedScript).toStdString() << std::endl; defaultOnProjectLoadedScript.clear(); } else { defaultOnProjectLoadedScript = fi.canonicalFilePath(); } args.erase(it); if ( !defaultOnProjectLoadedScript.endsWith( QString::fromUtf8(".py") ) ) { std::cout << QObject::tr("The optional on project load script must be a Python script (.py).").toStdString() << std::endl; error = 1; return; } } else { std::cout << QObject::tr("--onload or -l specified, you must enter a script filename afterwards.").toStdString() << std::endl; error = 1; return; } } } { QStringList::iterator it = findFileNameWithExtension( QString::fromUtf8(NATRON_PROJECT_FILE_EXT) ); if ( it == args.end() ) { it = findFileNameWithExtension( QString::fromUtf8("py") ); if ( ( it == args.end() ) && !isInterpreterMode && isBackground ) { std::cout << QObject::tr("You must specify the filename of a script or %1 project. (.%2)").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ).arg( QString::fromUtf8(NATRON_PROJECT_FILE_EXT) ).toStdString() << std::endl; error = 1; return; } isPythonScript = true; } if ( it != args.end() ) { filename = *it; #ifdef __NATRON_UNIX__ filename = AppManager::qt_tildeExpansion(filename); #endif QFileInfo fi(filename); if ( fi.exists() ) { filename = fi.canonicalFilePath(); } args.erase(it); } } //Parse frame range for (QStringList::iterator it = args.begin(); it != args.end(); ++it) { if ( tryParseMultipleFrameRanges(*it, frameRanges) ) { args.erase(it); rangeSet = true; break; } } //Parse python commands for (;; ) { QStringList::iterator it = hasToken( QString::fromUtf8("cmd"), QString::fromUtf8("c") ); if ( it == args.end() ) { break; } if (!isBackground) { std::cout << QObject::tr("You cannot use the -c option in interactive mode").toStdString() << std::endl; error = 1; return; } QStringList::iterator next = it; if ( next != args.end() ) { ++next; } if ( next == args.end() ) { std::cout << QObject::tr("You must specify a command when using the -c option").toStdString() << std::endl; error = 1; return; } pythonCommands.push_back( next->toStdString() ); ++next; args.erase(it, next); } // for (;;) //Parse writers for (;; ) { QStringList::iterator it = hasToken( QString::fromUtf8("writer"), QString::fromUtf8("w") ); if ( it == args.end() ) { break; } if (!isBackground || isInterpreterMode) { std::cout << QObject::tr("You cannot use the -w option in interactive or interpreter mode").toStdString() << std::endl; error = 1; return; } QStringList::iterator next = it; if ( next != args.end() ) { ++next; } if ( next == args.end() ) { std::cout << QObject::tr("You must specify the name of a Write node when using the -w option").toStdString() << std::endl; error = 1; return; } //Check that the name is conform to a Python acceptable script name std::string pythonConform = NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly( next->toStdString() ); if (next->toStdString() != pythonConform) { std::cout << QObject::tr("The name of the Write node specified is not valid: it cannot contain non alpha-numerical " "characters and must not start with a digit.").toStdString() << std::endl; error = 1; return; } CLArgs::WriterArg w; w.name = *next; QStringList::iterator nextNext = next; if ( nextNext != args.end() ) { ++nextNext; } if ( nextNext != args.end() ) { //Check for an optional filename if ( !nextNext->startsWith( QChar::fromLatin1('-') ) && !nextNext->startsWith( QString::fromUtf8("--") ) ) { w.filename = *nextNext; #ifdef __NATRON_UNIX__ w.filename = AppManager::qt_tildeExpansion(w.filename); #endif } } writers.push_back(w); if ( nextNext != args.end() ) { ++nextNext; } args.erase(it, nextNext); } // for (;;) //Parse readers for (;; ) { QStringList::iterator it = hasToken( QString::fromUtf8("reader"), QString::fromUtf8("i") ); if ( it == args.end() ) { break; } if (!isBackground || isInterpreterMode) { std::cout << QObject::tr("You cannot use the -i option in interactive or interpreter mode").toStdString() << std::endl; error = 1; return; } QStringList::iterator next = it; if ( next != args.end() ) { ++next; } if ( next == args.end() ) { std::cout << QObject::tr("You must specify the name of a Read node when using the -i option").toStdString() << std::endl; error = 1; return; } //Check that the name is conform to a Python acceptable script name std::string pythonConform = NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly( next->toStdString() ); if (next->toStdString() != pythonConform) { std::cout << QObject::tr("The name of the Read node specified is not valid: it cannot contain non alpha-numerical " "characters and must not start with a digit.").toStdString() << std::endl; error = 1; return; } CLArgs::ReaderArg r; r.name = *next; QStringList::iterator nextNext = next; if ( nextNext != args.end() ) { ++nextNext; } if ( nextNext == args.end() ) { std::cout << QObject::tr("You must specify the filename for the following Read node: ").toStdString() << r.name.toStdString() << std::endl; error = 1; return; } //Check for filename if ( !nextNext->startsWith( QChar::fromLatin1('-') ) && !nextNext->startsWith( QString::fromUtf8("--") ) ) { r.filename = *nextNext; #ifdef __NATRON_UNIX__ r.filename = AppManager::qt_tildeExpansion(r.filename); #endif } else { std::cout << QObject::tr("You must specify the filename for the following Read node: ").toStdString() << r.name.toStdString() << std::endl; error = 1; return; } readers.push_back(r); if ( nextNext != args.end() ) { ++nextNext; } args.erase(it, nextNext); } // for (;;) bool atLeastOneOutput = false; ///Parse outputs for (;; ) { QString indexStr; QStringList::iterator it = hasOutputToken(indexStr); if (error > 0) { return; } if ( it == args.end() ) { break; } if (!isBackground) { std::cout << QObject::tr("You cannot use the -o option in interactive or interpreter mode").toStdString() << std::endl; error = 1; return; } CLArgs::WriterArg w; w.name = QString( QString::fromUtf8("Output%1") ).arg(indexStr); w.mustCreate = true; atLeastOneOutput = true; //Check for a mandatory file name QStringList::iterator next = it; if ( next != args.end() ) { ++next; } if ( next == args.end() ) { std::cout << QObject::tr("Filename is not optional with the -o option").toStdString() << std::endl; error = 1; return; } //Check for an optional filename if ( !next->startsWith( QChar::fromLatin1('-') ) && !next->startsWith( QString::fromUtf8("--") ) ) { w.filename = *next; } writers.push_back(w); QStringList::iterator endToErase = next; ++endToErase; args.erase(it, endToErase); } if (atLeastOneOutput && !rangeSet) { std::cout << QObject::tr("A frame range must be set when using the -o option").toStdString() << std::endl; error = 1; return; } } // CLArgsPrivate::parse