void CMainDlg::OnBtnClick_ProjectOpen() { CFileDialogEx fileDlg(TRUE,_T("idx"),_T("uires.idx"),6,_T("soui skin index(*.idx)\0*.idx\0All files (*.*)\0*.*\0\0")); if(IDOK==fileDlg.DoModal()) { OpenProject(fileDlg.m_szFileName); } }
void QtMainWindow::SetupActions() { QtMainWindowHandler *actionHandler = QtMainWindowHandler::Instance(); //File connect(ui->menuFile, SIGNAL(triggered(QAction *)), actionHandler, SLOT(FileMenuTriggered(QAction *))); connect(ui->actionNewScene, SIGNAL(triggered()), actionHandler, SLOT(NewScene())); connect(ui->actionOpenScene, SIGNAL(triggered()), actionHandler, SLOT(OpenScene())); connect(ui->actionOpenProject, SIGNAL(triggered()), actionHandler, SLOT(OpenProject())); connect(ui->actionSaveScene, SIGNAL(triggered()), actionHandler, SLOT(SaveScene())); connect(ui->actionSaveToFolder, SIGNAL(triggered()), actionHandler, SLOT(SaveToFolderWithChilds())); ui->actionExportPVRIOS->setData(GPU_POWERVR_IOS); ui->actionExportPVRAndroid->setData(GPU_POWERVR_ANDROID); ui->actionExportTegra->setData(GPU_TEGRA); ui->actionExportMali->setData(GPU_MALI); ui->actionExportAdreno->setData(GPU_ADRENO); ui->actionExportPNG->setData(GPU_UNKNOWN); connect(ui->menuExport, SIGNAL(triggered(QAction *)), actionHandler, SLOT(ExportMenuTriggered(QAction *))); connect(ui->actionReloadAll, SIGNAL(triggered()), actionHandler, SLOT(RepackAndReloadTextures())); //View connect(ui->actionRestoreViews, SIGNAL(triggered()), actionHandler, SLOT(RestoreViews())); //Tools connect(ui->actionMaterialEditor, SIGNAL(triggered()), actionHandler, SLOT(Materials())); connect(ui->actionTextureConverter, SIGNAL(triggered()), actionHandler, SLOT(ConvertTextures())); connect(ui->actionHeightMapEditor, SIGNAL(triggered()), actionHandler, SLOT(HeightmapEditor())); connect(ui->actionTileMapEditor, SIGNAL(triggered()), actionHandler, SLOT(TilemapEditor())); connect(ui->actionRulerTool, SIGNAL(triggered()), actionHandler, SLOT(RulerTool())); connect(ui->actionShowSettings, SIGNAL(triggered()), actionHandler, SLOT(ShowSettings())); connect(ui->actionSquareTextures, SIGNAL(triggered()), actionHandler, SLOT(SquareTextures())); connect(ui->actionShowMipmapLevel, SIGNAL(triggered()), actionHandler, SLOT(ReplaceZeroMipmaps())); #if defined (__DAVAENGINE_MACOS__) ui->menuTools->removeAction(ui->actionBeast); #else //#if defined (__DAVAENGINE_MACOS__) connect(ui->actionBeast, SIGNAL(triggered()), actionHandler, SLOT(Beast())); #endif //#if defined (__DAVAENGINE_MACOS__) //Edit connect(ui->actionConvertToShadow, SIGNAL(triggered()), actionHandler, SLOT(ConvertToShadow())); //Temporary hided for development-qa branch ui->actionEnableCameraLight->setVisible(false); ui->actionEnableCameraLight->setChecked(EditorSettings::Instance()->GetShowEditorCamerLight()); connect(ui->actionEnableCameraLight, SIGNAL(triggered()), actionHandler, SLOT(CameraLightTrigerred())); //Help connect(ui->actionHelp, SIGNAL(triggered()), actionHandler, SLOT(OpenHelp())); }
void CMainDlg::OnBtnClick_Project_File_Add() { CNewFileDlg dlg(this); if(!m_strPrjPath.IsEmpty() && IDOK==dlg.DoModal()) { xml_document xmlDoc; if(!xmlDoc.load_file(m_strPrjIndex)) return; xml_node xmlRoot = xmlDoc.child(L"resource"); if(!xmlRoot) { return; } xml_node xmlType=xmlRoot.child(S_CT2W(dlg.m_strResType)); xml_node xmlNode=xmlType.child(L"file"); SStringW strName = S_CT2W(dlg.m_strResName); while(xmlNode) { if(xmlNode.attribute(L"name").value() == strName) { break; } xmlNode = xmlNode.next_sibling(L"file"); } if(xmlNode) {//检查type,name重复 SMessageBox(GetActiveWindow(),_T("指定的资源名重复"),_T("错误"),MB_OK|MB_ICONSTOP); return; } BuildFilePath(m_strPrjPath,dlg.m_strResPath,FALSE); CopyFile(dlg.m_strSrcFile,m_strPrjPath+_T("\\")+dlg.m_strResPath,FALSE); //改写XML文件 if(!xmlType) { xmlType = xmlRoot.append_child(S_CT2W(dlg.m_strResType)); } xmlNode = xmlType.append_child(L"file"); xmlNode.append_attribute(L"name").set_value(S_CT2W(dlg.m_strResName)); xmlNode.append_attribute(L"path").set_value(S_CT2W(dlg.m_strResPath)); FILE *f=_tfopen(m_strPrjIndex,_T("wb")); if(f) { xml_writer_file xmlfile(f); xmlDoc.print(xmlfile); fclose(f); OpenProject(m_strPrjIndex); } } }
void MainWindow::OpenProject() { QString initial_directory = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); // Workaround for bug on Mac OS. #if defined(__APPLE__) initial_directory += "/dummy.txt"; #endif QString filename = QFileDialog::getOpenFileName( this, "Open project", initial_directory, "Multitrack project (*.mtpro)"); if (filename.isEmpty()) return; OpenProject(filename); }
void MainWindow::ShowWelcome() { is_project_open_ = false; setWindowTitle("Multitrack"); welcome_widget_ = new WelcomeWidget(this); setCentralWidget(welcome_widget_); UpdateRecentProjects(); adjustSize(); resize(welcome_size_); connect(welcome_widget_, SIGNAL(New()), this, SLOT(NewProject())); connect(welcome_widget_, SIGNAL(Open()), this, SLOT(OpenProject())); connect(welcome_widget_, SIGNAL(RecentProjectChosen(int)), this, SLOT(OpenRecentProject(int))); ui->actionSave_project->setEnabled(false); ui->actionSave_project_as->setEnabled(false); ui->actionClose_project->setEnabled(false); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), project_(new Project), is_project_open_(true), welcome_size_(425, 437), project_size_(894, 636) { ui->setupUi(this); // Load recent projects. QString data_directory = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); QString recent_path = QDir::cleanPath(data_directory + QDir::separator() + "recent.mtcfg"); QFile recent_file(recent_path); if (!recent_file.open(QIODevice::ReadOnly)) { if (!recent_file.open(QIODevice::WriteOnly)) { qDebug("Could not open file %s for writing.", recent_path.toStdString().c_str()); } else { QDataStream ds(&recent_file); ds << recent_projects_; recent_file.close(); } } else { QDataStream ds(&recent_file); ds >> recent_projects_; recent_file.close(); } ShowWelcome(); connect(ui->actionNew_project, SIGNAL(triggered()), this, SLOT(NewProject())); connect(ui->actionOpen_project, SIGNAL(triggered()), this, SLOT(OpenProject())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close())); }
Treenity::Treenity(QWidget *parent) : QMainWindow(parent), m_running(true) { //Set some utility init things Utils::GetInstance()->setParent(this); Utils::GetInstance()->setFloating(true); // Setup component names in the editor. m_componentNames[RootForce::ComponentType::RENDERABLE] = "Renderable"; m_componentNames[RootForce::ComponentType::TRANSFORM] = "Transform"; m_componentNames[RootForce::ComponentType::POINTLIGHT] = "Point Light"; m_componentNames[RootForce::ComponentType::CAMERA] = "Camera"; m_componentNames[RootForce::ComponentType::HEALTH] = "Health"; m_componentNames[RootForce::ComponentType::PLAYERCONTROL] = "Player Control"; m_componentNames[RootForce::ComponentType::PHYSICS] = "Physics"; m_componentNames[RootForce::ComponentType::NETWORK] = "Network"; m_componentNames[RootForce::ComponentType::LOOKATBEHAVIOR] = "Look-At Behaviour"; m_componentNames[RootForce::ComponentType::THIRDPERSONBEHAVIOR] = "Third Person Behaviour"; m_componentNames[RootForce::ComponentType::SCRIPT] = "Script"; m_componentNames[RootForce::ComponentType::COLLISION] = "Physics"; // Required since the component list searches on name. m_componentNames[RootForce::ComponentType::COLLISIONRESPONDER] = "Collision Responder"; m_componentNames[RootForce::ComponentType::PLAYER] = "Player"; m_componentNames[RootForce::ComponentType::ANIMATION] = "Animation"; m_componentNames[RootForce::ComponentType::PARTICLE] = "Particle"; m_componentNames[RootForce::ComponentType::TDMRULES] = "Team-Deathmatch Rules"; m_componentNames[RootForce::ComponentType::PLAYERACTION] = "Player Action"; m_componentNames[RootForce::ComponentType::PLAYERPHYSICS] = "Player Physics"; m_componentNames[RootForce::ComponentType::ENTITYSTATE] = "Entity State"; m_componentNames[RootForce::ComponentType::SHADOWCASTER] = "Shadowcaster"; m_componentNames[RootForce::ComponentType::DIRECTIONALLIGHT] = "Directional Light"; m_componentNames[RootForce::ComponentType::SERVERINFORMATION] = "Server Information"; m_componentNames[RootForce::ComponentType::CLIENT] = "Client"; m_componentNames[RootForce::ComponentType::RAGDOLL] = "Ragdoll"; m_componentNames[RootForce::ComponentType::WATERCOLLIDER] = "Water Collider"; m_componentNames[RootForce::ComponentType::ABILITYSPAWN] = "Ability Spawn"; m_componentNames[RootForce::ComponentType::TRYPICKUPCOMPONENT] = "Try Pickup"; m_componentNames[RootForce::ComponentType::SOUND] = "Sound"; m_componentNames[RootForce::ComponentType::TIMER] = "Timer"; m_componentNames[RootForce::ComponentType::FOLLOW] = "Follow"; m_componentNames[RootForce::ComponentType::HOMING] = "Homing"; m_componentNames[RootForce::ComponentType::RAY] = "Ray"; m_componentNames[RootForce::ComponentType::DAMAGEANDKNOCKBACK] = "Damage and Knockback"; m_componentNames[RootForce::ComponentType::SCALABLE] = "Scalable"; m_componentNames[RootForce::ComponentType::STATCHANGE] = "Stat Change"; m_componentNames[RootForce::ComponentType::KILLANNOUNCEMENT] = "Kill Announcement"; m_componentNames[RootForce::ComponentType::CONTROLLERACTIONS] = "Controller Action"; // Setup the main UI. ui.setupUi(this); setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea ); setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea ); m_compView = new ComponentView(); m_scrollArea = new VerticalScrollArea(); m_scrollArea->setWidget(m_compView); m_scrollArea->setFrameStyle(QFrame::Plain); // Setup the component view and its items. ui.verticalLayout->addWidget(m_scrollArea); m_componentViews[RootForce::ComponentType::TRANSFORM] = new TransformView(); m_componentViews[RootForce::ComponentType::RENDERABLE] = new RenderableView(); m_componentViews[RootForce::ComponentType::COLLISION] = new PhysicsView(); m_componentViews[RootForce::ComponentType::WATERCOLLIDER] = new WaterColliderView(); m_componentViews[RootForce::ComponentType::SCRIPT] = new ScriptView(); m_componentViews[RootForce::ComponentType::COLLISIONRESPONDER] = new CollisionResponderView(); m_componentViews[RootForce::ComponentType::PARTICLE] = new ParticleView(); // Block component views from updates while in game mode. m_componentViews[RootForce::ComponentType::RENDERABLE]->SetReceiveUpdates(false); for (auto it : m_componentViews) { it.second->SetEditorInterface(this); } ui.treeView_entityOutliner->SetEditorInterface(this); //Set up water tool m_waterToolDockable = new WaterTool(this); // Match signals with slots. connect(ui.actionNew, SIGNAL(triggered()), this, SLOT(New())); connect(ui.actionOpen_Project, SIGNAL(triggered()), this, SLOT(OpenProject())); connect(ui.action_saveAs, SIGNAL(triggered()), this, SLOT(SaveAs())); connect(ui.action_save, SIGNAL(triggered()), this, SLOT(Save())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.actionLog, SIGNAL(triggered()), Utils::GetInstance(), SLOT(Show())); connect(ui.action_addEntity, SIGNAL(triggered()), this, SLOT(CreateEntity())); connect(ui.action_removeEntity, SIGNAL(triggered()), this, SLOT(DestroyEntity())); connect(ui.lineEdit_entityName, SIGNAL(editingFinished()), this, SLOT(RenameEntity())); connect(ui.action_addRenderable, SIGNAL(triggered()), this, SLOT(AddRenderable())); connect(ui.action_addPhysics, SIGNAL(triggered()), this, SLOT(AddPhysics())); connect(ui.action_addWaterCollider, SIGNAL(triggered()), this, SLOT(AddWaterCollider())); connect(ui.action_addScript, SIGNAL(triggered()), this, SLOT(AddScriptComponent())); connect(ui.action_collisionResponder, SIGNAL(triggered()), this, SLOT(AddCollisionResponder())); connect(ui.action_addParticle, SIGNAL(triggered()), this, SLOT(AddParticleComponent())); connect(ui.actionPlay, SIGNAL(triggered()), this, SLOT(Play())); connect(ui.pushButton_translateMode, SIGNAL(clicked()), this, SLOT(SetTranslateTool())); connect(ui.pushButton_rotateMode, SIGNAL(clicked()), this, SLOT(SetRotateTool())); connect(ui.pushButton_scaleMode, SIGNAL(clicked()), this, SLOT(SetResizeTool())); connect(ui.comboBox_mode, SIGNAL(currentIndexChanged(int)), this, SLOT(ChangeToolMode(int))); connect(ui.actionWaterSetting, SIGNAL(triggered()), m_waterToolDockable, SLOT(Show())); connect(m_componentViews[RootForce::ComponentType::RENDERABLE], SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveRenderable(ECS::Entity*))); connect(m_componentViews[RootForce::ComponentType::COLLISION], SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemovePhysics(ECS::Entity*))); connect(m_componentViews[RootForce::ComponentType::WATERCOLLIDER], SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveWaterCollider(ECS::Entity*))); connect(m_componentViews[RootForce::ComponentType::SCRIPT], SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveScriptComponent(ECS::Entity*))); connect(m_componentViews[RootForce::ComponentType::COLLISIONRESPONDER], SIGNAL(deleted(ECS::Entity*)), this, SLOT(RemoveCollisionResponder(ECS::Entity*))); // Setup Qt-to-SDL keymatching. InitialiseKeymap(); ui.widget_canvas3D->SetEditorInterface(this); // Set tool mode. m_toolMode = ToolMode::LOCAL; }
void add_infile(std::string text, std::string fileName, bool forceDestroy) { std::vector<std::string> split = SplitFileName(fileName); std::string noExt = split[0] + split[1], ext = split[2]; #if defined(HAVE_COMPRESSED_IO) && defined(HAVE_LIBZ) bool compressed = false; if(ext == ".gz"){ ext = SplitFileName(noExt)[2]; compressed = true; } #endif // make sure we don't add stuff in a non-geo file if(!CTX::instance()->expertMode) { if(ext.size() && ext != ".geo" && ext != ".GEO" ){ std::ostringstream sstream; sstream << "A scripting command is going to be appended to a non-`.geo' file. Are\n" "you sure you want to proceed?\n\n" "You probably want to create a new `.geo' file containing the command\n" "`Merge \"" << split[1] + split[2] << "\";' and use that file instead.\n\n" "(To disable this warning in the future, select `Enable expert mode'\n" "in the option dialog.)"; int ret = Msg::GetAnswer(sstream.str().c_str(), 2, "Cancel", "Proceed as is", "Create new `.geo' file"); if(ret == 2){ std::string newFileName = split[0] + split[1] + ".geo"; if(CTX::instance()->confirmOverwrite) { if(!StatFile(newFileName)){ std::ostringstream sstream; sstream << "File '" << fileName << "' already exists.\n\n" "Do you want to replace it?"; if(!Msg::GetAnswer(sstream.str().c_str(), 0, "Cancel", "Replace")) return; } } FILE *fp = Fopen(newFileName.c_str(), "w"); if(!fp) { Msg::Error("Unable to open file '%s'", newFileName.c_str()); return; } fprintf(fp, "Merge \"%s\";\n%s\n", (split[1] + split[2]).c_str(), text.c_str()); fclose(fp); OpenProject(newFileName); return; } else if(ret == 0) return; } } #if defined(HAVE_PARSER) std::string tmpFileName = CTX::instance()->homeDir + CTX::instance()->tmpFileName; gmshFILE gmsh_yyin_old = gmsh_yyin; FILE *tmp_file; if(!(tmp_file = Fopen(tmpFileName.c_str(), "w"))) { Msg::Error("Unable to open temporary file '%s'", tmpFileName.c_str()); return; } fprintf(tmp_file, "%s\n", text.c_str()); fclose(tmp_file); gmsh_yyin = gmshopen(tmpFileName.c_str(), "r"); while(!gmsheof(gmsh_yyin)) { gmsh_yyparse(); } gmshclose(gmsh_yyin); gmsh_yyin = gmsh_yyin_old; if(forceDestroy){ // we need to start from scratch (e.g. if the command just parsed // could have deleted some entities) GModel::current()->destroy(); } GModel::current()->importGEOInternals(); CTX::instance()->mesh.changed = ENT_ALL; // here we have to be explicit otherwise we append compressed stuff to ascii // file! #if defined(HAVE_COMPRESSED_IO) && defined(HAVE_LIBZ) if(compressed){ gmshFILE fp = gmshopen(fileName.c_str(), "a"); if(!fp) { Msg::Error("Unable to open file '%s'", fileName.c_str()); return; } gmshprintf(fp, "%s\n", text.c_str()); gmshclose(fp); } else{ FILE *fp = Fopen(fileName.c_str(), "a"); if(!fp) { Msg::Error("Unable to open file '%s'", fileName.c_str()); return; } fprintf(fp, "%s\n", text.c_str()); fclose(fp); } #else FILE *fp = Fopen(fileName.c_str(), "a"); if(!fp) { Msg::Error("Unable to open file '%s'", fileName.c_str()); return; } fprintf(fp, "%s\n", text.c_str()); fclose(fp); #endif #else Msg::Error("GEO file creation not available without Gmsh parser"); #endif // mark all Gmsh data as changed in onelab (will force e.g. a reload and a // remesh) #if defined(HAVE_ONELAB) onelab::server::instance()->setChanged(true, "Gmsh"); #endif #if defined(HAVE_ONELAB2) OnelabDatabase::instance()->setChanged(true, "Gmsh"); #endif }
bool gmshLocalNetworkClient::receiveMessage(gmshLocalNetworkClient *master) { // receive a message on the associated GmshServer; 'master' is only used when // creating subclients with GMSH_CONNECT. double timer = GetTimeInSeconds(); if(!getGmshServer()){ Msg::Error("Abnormal server termination (no valid server)"); return false; } int type, length, swap; if(!getGmshServer()->ReceiveHeader(&type, &length, &swap)){ Msg::Error("Abnormal server termination (did not receive message header)"); return false; } std::string message(length, ' '), blank = message; if(!getGmshServer()->ReceiveMessage(length, &message[0])){ Msg::Error("Abnormal server termination (did not receive message body)"); return false; } if(message == blank && !(type == GmshSocket::GMSH_PROGRESS || type == GmshSocket::GMSH_INFO || type == GmshSocket::GMSH_WARNING || type == GmshSocket::GMSH_ERROR)){ // we should still allow blank msg strings to be sent Msg::Error("Abnormal server termination (blank message: client not stopped?)"); return false; } switch (type) { case GmshSocket::GMSH_START: setPid(atoi(message.c_str())); break; case GmshSocket::GMSH_STOP: setPid(-1); if(getFather()){ std::string reply = getName(); // reply is dummy getFather()->getGmshServer()->SendMessage (GmshSocket::GMSH_STOP, reply.size(), &reply[0]); } break; case GmshSocket::GMSH_PARAMETER: case GmshSocket::GMSH_PARAMETER_UPDATE: { std::string version, ptype, name; onelab::parameter::getInfoFromChar(message, version, ptype, name); if(onelab::parameter::version() != version){ Msg::Error("ONELAB version mismatch (server: %s / client: %s)", onelab::parameter::version().c_str(), version.c_str()); } else if(ptype == "number"){ onelab::number p; p.fromChar(message); if(type == GmshSocket::GMSH_PARAMETER_UPDATE){ std::vector<onelab::number> par; get(par, name); if(par.size()) { onelab::number y = p; p = par[0]; onelabUtils::updateNumber(p, y); } } set(p); if(p.getName() == getName() + "/Progress"){ #if defined(HAVE_FLTK) if(FlGui::available()) FlGui::instance()->setProgress(p.getLabel().c_str(), p.getValue(), p.getMin(), p.getMax()); #endif } } else if(ptype == "string"){ onelab::string p; p.fromChar(message); if(type == GmshSocket::GMSH_PARAMETER_UPDATE){ std::vector<onelab::string> par; get(par, name); if(par.size()){ onelab::string y = p; p = par[0]; onelabUtils::updateString(p,y); } } set(p); } else if(ptype == "region"){ onelab::region p; p.fromChar(message); set(p); } else if(ptype == "function"){ onelab::function p; p.fromChar(message); set(p); } else Msg::Error("Unknown ONELAB parameter type: %s", ptype.c_str()); } break; case GmshSocket::GMSH_PARAMETER_QUERY: { std::string version, ptype, name, reply; onelab::parameter::getInfoFromChar(message, version, ptype, name); if(onelab::parameter::version() != version){ Msg::Error("ONELAB version mismatch (server: %s / client: %s)", onelab::parameter::version().c_str(), version.c_str()); } else if(ptype == "number"){ std::vector<onelab::number> par; get(par, name); if(par.size() == 1) reply = par[0].toChar(); } else if(ptype == "string"){ std::vector<onelab::string> par; get(par, name); if(par.size() == 1) reply = par[0].toChar(); } else if(ptype == "region"){ std::vector<onelab::region> par; get(par, name); if(par.size() == 1) reply = par[0].toChar(); } else if(ptype == "function"){ std::vector<onelab::function> par; get(par, name); if(par.size() == 1) reply = par[0].toChar(); } else Msg::Error("Unknown ONELAB parameter type in query: %s", ptype.c_str()); if(reply.size()){ getGmshServer()->SendMessage (GmshSocket::GMSH_PARAMETER, reply.size(), &reply[0]); } else{ reply = name; getGmshServer()->SendMessage (GmshSocket::GMSH_PARAMETER_NOT_FOUND, reply.size(), &reply[0]); } } break; case GmshSocket::GMSH_PARAMETER_QUERY_ALL: { std::string version, ptype, name, reply; std::vector<std::string> replies; onelab::parameter::getInfoFromChar(message, version, ptype, name); if(onelab::parameter::version() != version){ Msg::Error("ONELAB version mismatch (server: %s / client: %s)", onelab::parameter::version().c_str(), version.c_str()); } else if(ptype == "number"){ std::vector<onelab::number> numbers; get(numbers); for(std::vector<onelab::number>::iterator it = numbers.begin(); it != numbers.end(); it++) replies.push_back((*it).toChar()); } else if(ptype == "string"){ std::vector<onelab::string> strings; get(strings); for(std::vector<onelab::string>::iterator it = strings.begin(); it != strings.end(); it++) replies.push_back((*it).toChar()); } else if(ptype == "region"){ std::vector<onelab::region> regions; get(regions); for(std::vector<onelab::region>::iterator it = regions.begin(); it != regions.end(); it++) replies.push_back((*it).toChar()); } else if(ptype == "function"){ std::vector<onelab::function> functions; get(functions); for(std::vector<onelab::function>::iterator it = functions.begin(); it != functions.end(); it++) replies.push_back((*it).toChar()); } else Msg::Error("Unknown ONELAB parameter type in query: %s", ptype.c_str()); for(unsigned int i = 0; i < replies.size(); i++) getGmshServer()->SendMessage (GmshSocket::GMSH_PARAMETER_QUERY_ALL, replies[i].size(), &replies[i][0]); reply = "Sent all ONELAB " + ptype + "s"; getGmshServer()->SendMessage (GmshSocket::GMSH_PARAMETER_QUERY_END, reply.size(), &reply[0]); } break; case GmshSocket::GMSH_PARAMETER_CLEAR: clear(message == "*" ? "" : message); break; case GmshSocket::GMSH_PROGRESS: Msg::StatusBar(false, "%s %s", _name.c_str(), message.c_str()); break; case GmshSocket::GMSH_INFO: Msg::Direct("Info : %s - %s", _name.c_str(), message.c_str()); break; case GmshSocket::GMSH_WARNING: Msg::Warning("%s - %s", _name.c_str(), message.c_str()); break; case GmshSocket::GMSH_ERROR: Msg::Error("%s - %s", _name.c_str(), message.c_str()); break; case GmshSocket::GMSH_MERGE_FILE: if(CTX::instance()->solver.autoMergeFile){ unsigned int n = PView::list.size(); MergePostProcessingFile(message, CTX::instance()->solver.autoShowViews, CTX::instance()->solver.autoShowLastStep, true); #if defined(HAVE_FLTK) drawContext::global()->draw(); if(FlGui::available() && n != PView::list.size()){ FlGui::instance()->rebuildTree(true); FlGui::instance()->openModule("Post-processing"); } #endif } break; case GmshSocket::GMSH_OPEN_PROJECT: OpenProject(message); #if defined(HAVE_FLTK) drawContext::global()->draw(); #endif break; case GmshSocket::GMSH_PARSE_STRING: ParseString(message, true); #if defined(HAVE_FLTK) drawContext::global()->draw(); #endif break; case GmshSocket::GMSH_SPEED_TEST: Msg::Info("got %d Mb message in %g seconds", length / 1024 / 1024, GetTimeInSeconds() - timer); break; case GmshSocket::GMSH_VERTEX_ARRAY: { int n = PView::list.size(); PView::fillVertexArray(this, length, &message[0], swap); #if defined(HAVE_FLTK) if(FlGui::available()) FlGui::instance()->updateViews(n != (int)PView::list.size(), true); drawContext::global()->draw(); #endif } break; case GmshSocket::GMSH_CONNECT: { std::string::size_type first = 0; std::string clientName = onelab::parameter::getNextToken(message, first); std::string command = onelab::parameter::getNextToken(message, first); gmshLocalNetworkClient* subClient = new gmshLocalNetworkClient(clientName, command, "", true); onelabGmshServer *server = new onelabGmshServer(subClient); subClient->setPid(0); onelab::string o(subClient->getName() + "/Action", "compute"); o.setVisible(false); o.setNeverChanged(true); onelab::server::instance()->set(o); int sock = server->LaunchClient(); if(sock < 0){ // could not establish the connection: aborting server->Shutdown(); delete server; Msg::Error("Could not connect client '%s'", subClient->getName().c_str()); } else{ Msg::StatusBar(true, "Running '%s'...", subClient->getName().c_str()); subClient->setGmshServer(server); subClient->setFather(this); master->addClient(subClient); } } break; case GmshSocket::GMSH_OLPARSE: { std::string reply = "unavailable"; #if defined(HAVE_ONELAB_METAMODEL) std::string::size_type first = 0; std::string clientName = onelab::parameter::getNextToken(message, first); std::string fullName = onelab::parameter::getNextToken(message, first); preProcess(clientName, fullName); // contrib/onelab/OnelabParser.cpp Msg::Info("Done preprocessing file '%s'", fullName.c_str()); reply = onelab::server::instance()->getChanged(clientName) ? "true" : "false"; #endif getGmshServer()->SendMessage (GmshSocket::GMSH_OLPARSE, reply.size(), &reply[0]); } break; case GmshSocket::GMSH_CLIENT_CHANGED: { std::string::size_type first = 0; std::string command = onelab::parameter::getNextToken(message, first); std::string name = onelab::parameter::getNextToken(message, first); if(command == "get"){ std::string reply = onelab::server::instance()->getChanged(name) ? "true" : "false"; getGmshServer()->SendMessage (GmshSocket::GMSH_CLIENT_CHANGED, reply.size(), &reply[0]); } else if(command == "set"){ std::string changed = onelab::parameter::getNextToken(message, first); onelab::server::instance()->setChanged(changed=="true"?true:false,name); } } break; default: Msg::Warning("Received unknown message type (%d)", type); break; } return true; }