Exemple #1
0
  // redefinition of virtual onelab_client::sendMergeFileRequest
  void sendMergeFileRequest(const std::string &name)
  {
    if(name.find(".geo") != std::string::npos){
      MergePostProcessingFile(name, CTX::instance()->solver.autoShowLastStep,
			      CTX::instance()->solver.autoHideNewViews, true);
      GModel::current()->setFileName(name);
    }
    else if((name.find(".opt") != std::string::npos)){
      MergeFile(name);
    }
    else if((name.find(".macro") != std::string::npos)){
      MergeFile(name);
    }
    else
      MergePostProcessingFile(name, CTX::instance()->solver.autoShowLastStep,
			      CTX::instance()->solver.autoHideNewViews, true);
  }
JBoolean
JStringManager::MergeFile
	(
	const JCharacter*	fileName,
	const JBoolean		debug
	)
{
	std::ifstream input(fileName);
	if (input.good())
		{
		MergeFile(input, debug);
		return kJTrue;
		}
	else
		{
		return kJFalse;
		}
}
Exemple #3
0
void CMainFrame::_connectWidgets()
{
	connect(ui.actionOuvrir, SIGNAL(triggered()), this, SLOT(OpenFile()));
	connect(ui.actionFermer, SIGNAL(triggered()), this, SLOT(CloseFile()));
	connect(ui.actionFusionner, SIGNAL(triggered()), this, SLOT(MergeFile()));
	connect(ui.actionPlein_cran, SIGNAL(triggered(bool)), this, SLOT(SwitchFullscreen(bool)));
	connect(ui.actionStop, SIGNAL(triggered()), this, SLOT(Stop()));
	connect(ui.actionJouer, SIGNAL(triggered(bool)), this, SLOT(Play(bool)));
	connect(ui.action_propos, SIGNAL(triggered()), this, SLOT(About()));
	connect(ui.actionQt, SIGNAL(triggered()), this, SLOT(AboutQt()));
	connect(ui.actionGrille, SIGNAL(triggered(bool)), this, SLOT(ShowGrid(bool)));
	connect(ui.actionModel_3D, SIGNAL(triggered(bool)), m_modelViewer, SLOT(ShowModel3D(bool)));
	connect(ui.actionEnregistrer, SIGNAL(triggered()), this, SLOT(SaveFile()));
	connect(ui.actionEnregistrer_sous, SIGNAL(triggered()), this, SLOT(SaveFileAs()));
	connect(ui.actionCouleur_du_fond, SIGNAL(triggered()), this, SLOT(SetBackgroundColor()));
	connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(SetLanguage(QAction*)));

	connect(m_timeline, SIGNAL(CurrentFrameChanged(int)), m_modelViewer, SLOT(SetFrame(int)));
	connect(m_timeline, SIGNAL(SelectionChanged(int, int)), this, SLOT(EditKey(int, int)));
	connect(m_timeline, SIGNAL(KeyModified(int, int, bool)), this, SLOT(EditKeyModified(int, int, bool)));
	connect(ui.listParts, SIGNAL(currentRowChanged(int)), this, SLOT(ListPartChanged(int)));

	connect(ui.actionAjouter_une_partie, SIGNAL(triggered()), this, SLOT(AddPart()));
	connect(ui.actionSupprimer_la_partie, SIGNAL(triggered()), this, SLOT(RemovePart()));
	connect(ui.btnRemovePart, SIGNAL(clicked()), this, SLOT(RemovePart()));
	connect(ui.btnAddPart, SIGNAL(clicked()), this, SLOT(AddPart()));

	connect(ui.editKeyPosX, SIGNAL(valueChanged(double)), this, SLOT(EditKeyPosX(double)));
	connect(ui.editKeyPosY, SIGNAL(valueChanged(double)), this, SLOT(EditKeyPosY(double)));
	connect(ui.editKeyPosZ, SIGNAL(valueChanged(double)), this, SLOT(EditKeyPosZ(double)));
	connect(ui.editKeyPosRotX, SIGNAL(valueChanged(double)), this, SLOT(EditKeyPosRotX(double)));
	connect(ui.editKeyPosRotY, SIGNAL(valueChanged(double)), this, SLOT(EditKeyPosRotY(double)));
	connect(ui.editKeyPosRotZ, SIGNAL(valueChanged(double)), this, SLOT(EditKeyPosRotZ(double)));
	connect(ui.editKeyRotX, SIGNAL(valueChanged(double)), this, SLOT(EditKeyRotX(double)));
	connect(ui.editKeyRotY, SIGNAL(valueChanged(double)), this, SLOT(EditKeyRotY(double)));
	connect(ui.editKeyRotZ, SIGNAL(valueChanged(double)), this, SLOT(EditKeyRotZ(double)));
	connect(ui.editKeyScaleX, SIGNAL(valueChanged(double)), this, SLOT(EditKeyScaleX(double)));
	connect(ui.editKeyScaleY, SIGNAL(valueChanged(double)), this, SLOT(EditKeyScaleY(double)));
	connect(ui.editKeyScaleZ, SIGNAL(valueChanged(double)), this, SLOT(EditKeyScaleZ(double)));
	connect(ui.editKeyAlpha, SIGNAL(valueChanged(int)), this, SLOT(EditKeyAlpha(int)));

	connect(ui.editPartName, SIGNAL(textEdited(const QString&)), this, SLOT(EditPartName(const QString&)));
	connect(ui.editPartVisible, SIGNAL(toggled(bool)), this, SLOT(EditPartVisible(bool)));
	connect(ui.editPartBill, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(EditPartBill(const QString&)));
	connect(ui.editPartBlend, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(EditPartAlpha(const QString&)));
	connect(ui.editPartTexture, SIGNAL(editingFinished()), this, SLOT(EditPartTextureName()));
	connect(ui.btnSetPartTexture, SIGNAL(clicked()), this, SLOT(EditPartTexture()));
	connect(ui.editPartTexFrame, SIGNAL(valueChanged(int)), this, SLOT(EditPartTexFrame(int)));
	connect(ui.editPartTexLoop, SIGNAL(valueChanged(int)), this, SLOT(EditPartTexLoop(int)));
	connect(ui.editCustomMeshPointCount, SIGNAL(valueChanged(int)), this, SLOT(EditPartPointCount(int)));
	connect(ui.editParticleCreate, SIGNAL(valueChanged(int)), this, SLOT(EditPartParticleCreate(int)));
	connect(ui.editParticleCreateNum, SIGNAL(valueChanged(int)), this, SLOT(EditPartParticleCreateNum(int)));
	connect(ui.editParticleFrameAppear, SIGNAL(valueChanged(int)), this, SLOT(EditPartParticleFrameAppear(int)));
	connect(ui.editParticleFrameKeep, SIGNAL(valueChanged(int)), this, SLOT(EditPartParticleFrameKeep(int)));
	connect(ui.editParticleFrameDisappear, SIGNAL(valueChanged(int)), this, SLOT(EditPartParticleFrameDisappear(int)));
	connect(ui.editParticleStartPosVar, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleStartPosVar(double)));
	connect(ui.editParticleStartPosVarY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleStartPosVarY(double)));
	connect(ui.editParticleYLow, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleYLow(double)));
	connect(ui.editParticleYHigh, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleYHigh(double)));
	connect(ui.editParticleXZLow, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleXZLow(double)));
	connect(ui.editParticleXZHigh, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleXZHigh(double)));
	connect(ui.editParticleAccelX, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleAccelX(double)));
	connect(ui.editParticleAccelY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleAccelY(double)));
	connect(ui.editParticleAccelZ, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleAccelZ(double)));
	connect(ui.editParticleScaleX, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleX(double)));
	connect(ui.editParticleScaleY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleY(double)));
	connect(ui.editParticleScaleZ, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleZ(double)));
	connect(ui.editParticleRotationLowX, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleRotationLowX(double)));
	connect(ui.editParticleRotationLowY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleRotationLowY(double)));
	connect(ui.editParticleRotationLowZ, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleRotationLowZ(double)));
	connect(ui.editParticleRotationHighX, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleRotationHighX(double)));
	connect(ui.editParticleRotationHighY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleRotationHighY(double)));
	connect(ui.editParticleRotationHighZ, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleRotationHighZ(double)));
	connect(ui.editParticleScalSpeedXLow, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScalSpeedXLow(double)));
	connect(ui.editParticleScalSpeedYLow, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScalSpeedYLow(double)));
	connect(ui.editParticleScalSpeedZLow, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScalSpeedZLow(double)));
	connect(ui.editParticleScalSpeedXHigh, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScalSpeedXHigh(double)));
	connect(ui.editParticleScalSpeedYHigh, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScalSpeedYHigh(double)));
	connect(ui.editParticleScalSpeedZHigh, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScalSpeedZHigh(double)));
	connect(ui.editParticleRepeatScale, SIGNAL(toggled(bool)), this, SLOT(EditPartParticleRepeatScale(bool)));
	connect(ui.editParticleRepeat, SIGNAL(toggled(bool)), this, SLOT(EditPartParticleRepeat(bool)));
	connect(ui.editParticleScaleEndX, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleEndX(double)));
	connect(ui.editParticleScaleEndY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleEndY(double)));
	connect(ui.editParticleScaleEndZ, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleEndZ(double)));
	connect(ui.editParticleScaleSpeedX, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleSpeedX(double)));
	connect(ui.editParticleScaleSpeedY, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleSpeedY(double)));
	connect(ui.editParticleScaleSpeedZ, SIGNAL(valueChanged(double)), this, SLOT(EditPartParticleScaleSpeedZ(double)));
}
Exemple #4
0
int GmshRemote()
{
  GmshClient *client = Msg::GetGmshClient();

  int rank = Msg::GetCommRank();
  int nbDaemon = Msg::GetCommSize();

  if(!client && rank == 0) return 0;

  if(client && nbDaemon < 2)
    computeAndSendVertexArrays(client);
  else if(client && nbDaemon >= 2 && rank == 0)
    gatherAndSendVertexArrays(client, false);

  while(1){

    // on the node with MPI rank 0, communicate through a socket
    if (rank == 0) {
      // stop if we have no communications for 5 minutes
      int ret = client->Select(300, 0);
      if(!ret){
        client->Info("Timout: stopping remote Gmsh...");
        break;
      }
      else if(ret < 0){
        client->Error("Error on select: stopping remote Gmsh...");
        break;
      }

      int type, length, swap;
      if(!client->ReceiveHeader(&type, &length, &swap)){
        client->Error("Did not receive message header: stopping remote Gmsh...");
        break;
      }

      char *msg = new char[length + 1];
      if(!client->ReceiveString(length, msg)){
        client->Error("Did not receive message body: stopping remote Gmsh...");
        delete [] msg;
        break;
      }

      if(type == GmshSocket::GMSH_STOP){
        client->Info("Stopping remote Gmsh...");
        delete [] msg;
        break;
      }
      else if(type == GmshSocket::GMSH_VERTEX_ARRAY){
        ParseString(msg);
#if !defined(HAVE_MPI)
        computeAndSendVertexArrays(client);
#else
        int mpi_msg = MPI_GMSH_PARSE_STRING;
        MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        gatherAndSendVertexArrays(client, swap);
#endif
      }
      else if(type == GmshSocket::GMSH_MERGE_FILE){
        MergeFile(msg);
#if !defined(HAVE_MPI)
        computeAndSendVertexArrays(client);
#else
        int mpi_msg = MPI_GMSH_MERGE_FILE;
        MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        gatherAndSendVertexArrays(client, swap);
#endif
      }
      else if(type == GmshSocket::GMSH_PARSE_STRING){
        ParseString(msg);
#if defined(HAVE_MPI)
        int mpi_msg = MPI_GMSH_PARSE_STRING;
        MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
#endif
      }
      else if(type == GmshSocket::GMSH_SPEED_TEST){
        client->Info("Sending huge array");
        std::string huge(500000000, 'a');
        client->SpeedTest(huge.c_str());
      }
      else{
        client->Error("Ignoring unknown message");
      }

      delete [] msg;
    }
    else { // if we're not on the master node (rank != 0) wait for him...
#if defined(HAVE_MPI)
      int mpi_msg;
      MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
      if (mpi_msg == MPI_GMSH_COMPUTE_VIEW)
        computeAndSendVertexArrays();
      else if(mpi_msg == MPI_GMSH_SHUTDOWN)
        Msg::Exit(0);
      else if(mpi_msg == MPI_GMSH_PARSE_STRING){
        int length;
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        char msg[length];
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        ParseString(msg);
      }
      else if (mpi_msg == MPI_GMSH_MERGE_FILE){
        int length;
        MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
        char msg[length];
        MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
        MergeFile(msg);
      }
#endif
    }
  }

#if defined(HAVE_MPI)
  int mpi_msg = MPI_GMSH_SHUTDOWN;
  MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
#endif

  return 0;
}
void
JStringManager::Register
	(
	const JCharacter*	signature,
	const JCharacter**	defaultData
	)
{
	JString tempFileName;
	const JError err = JCreateTempFile(&tempFileName);
	if (!err.OK())
		{
		return;
		}

	{
	std::ofstream tempFile(tempFileName);

	JIndex i = 0;
	while (defaultData[i] != NULL)
		{
		tempFile.write(defaultData[i], strlen(defaultData[i]));
		i++;
		}
	}
	MergeFile(tempFileName);
	JRemoveFile(tempFileName);

	if (!JStringEmpty(signature))
		{
		const JCharacter* lang = getenv("LANG");

		JString path[2];
		JGetJDataDirectories(kDataDirName, path, path+1);

		JString name1, name2;
		for (JIndex i=0; i<2; i++)
			{
			if (!path[i].IsEmpty() &&
				(JDirectoryReadable(path[i]) ||
				 JCreateDirectory(path[i]) == kJNoError))
				{
				name1 = JCombinePathAndName(path[i], signature);

				if (lang != NULL)
					{
					name2 = name1;
					name2.AppendCharacter('_');
					name2.Append(lang);

					if (MergeFile(name2))
						{
						break;
						}
					}

				if (MergeFile(name1))
					{
					break;
					}
				}
			}
		}
}