23 #include <qmessagebox.h>
24 #include <QTemporaryFile>
26 #include "Tympan/core/config.h"
42 #define TR(id) OLocalizator::getString("TYCalculManager", (id))
95 QTemporaryFile problemfile;
96 problemfile.setFileTemplate(QDir::tempPath() + QString(
"/XXXXXX.xml"));
97 QTemporaryFile resultfile;
98 resultfile.setFileTemplate(QDir::tempPath() + QString(
"/XXXXXX.xml"));
100 QFileInfo fileInfo(
getTYApp()->getCurrentFileName());
101 QString meshFilePath =
102 fileInfo.path().replace(
"\\",
"/") +
"/" + fileInfo.completeBaseName() +
"." +
"ply";
107 "Creation de fichier temporaire impossible. Veuillez verifier l'espace disque disponible.");
117 std::ostringstream msg;
118 msg << boost::diagnostic_information(exc);
119 logger.
error(
"Could not export current project. Computation won't be done");
120 logger.
debug(msg.str().c_str());
125 logger.
debug(
"Le calcul va s'executer en mode debug.\nLes fichiers temporaires ne seront pas "
126 "supprimes une fois le calcul termine.\nProjet courant non calcule: %s. Projet avec les "
127 "resultats du calcul: %s.",
128 problemfile.fileName().toStdString().c_str(),
129 resultfile.fileName().toStdString().c_str());
137 QString absolute_plugins_path(QCoreApplication::applicationDirPath());
138 absolute_plugins_path.append(
"/");
139 absolute_plugins_path.append(PLUGINS_PATH);
140 QString absolute_pyscript_path(QCoreApplication::applicationDirPath());
141 absolute_pyscript_path.append(
"/");
142 absolute_pyscript_path.append(SOLVE_PYSCRIPT);
143 args << absolute_pyscript_path << problemfile.fileName() << resultfile.fileName() << meshFilePath
144 << absolute_plugins_path;
149 QRegularExpression altimetry_size_criterion_reg(
"(MeshElementSizeMax\\s?=\\s?)([0-9]+.[0-9]*)");
150 QRegularExpression altimetry_refine_mesh_reg(
"(RefineMesh\\s?=\\s?)(True|False)");
151 QRegularExpression altimetry_use_volumes_landtakes_reg(
"(UseVolumesLandtake\\s?=\\s?)(True|False)");
152 QRegularExpressionMatch match_size = altimetry_size_criterion_reg.match(parameters);
153 QRegularExpressionMatch match_refi = altimetry_refine_mesh_reg.match(parameters);
154 QRegularExpressionMatch match_land = altimetry_use_volumes_landtakes_reg.match(parameters);
158 if (match_size.hasMatch() && match_refi.hasMatch() && match_land.hasMatch())
160 QString altimetry_size_criterion = match_size.captured(2);
161 QString altimetry_refine_mesh = match_refi.captured(2);
162 QString altimetry_use_volumes_landtakes = match_land.captured(2);
163 QString altimetry_update = (altiIsOK) ? QString(
"False") : QString(
"True");
165 args << altimetry_size_criterion << altimetry_refine_mesh << altimetry_use_volumes_landtakes
168 logger.
info(
TR(
"id_msg_go_calcul"));
185 std::ostringstream msg;
186 msg << boost::diagnostic_information(exc);
187 logger.
error(
"Could not import computed project. No results available.");
188 logger.
debug(msg.str().c_str());
190 msgBox.setText(
"Le fichier de resultats n'a pas pu etre lu.");
202 std::deque<OPoint3D> points;
203 std::deque<OTriangle> triangles;
204 std::deque<LPTYSol> materials;
205 pSite->
readMesh(points, triangles, materials, meshFilePath);
219 pCalcul->
getParent()->updateGraphicTree();
220 pCalcul->updateGraphicTree();
242 logger.
info(
TR(
"id_msg_calcul_done"));
253 TYApplication::setOverrideCursor(Qt::WaitCursor);
257 QFileInfo fileInfo(
getTYApp()->getCurrentFileName());
258 QString resultMeshFilePath =
259 fileInfo.path().replace(
"\\",
"/") +
"/" + fileInfo.completeBaseName() +
"." +
"ply";
279 pRootSite->updateGraphicTree();
280 TYApplication::restoreOverrideCursor();
339 if (pSite !=
nullptr)
344 if (pAccVolNode.
_pObj !=
nullptr)
348 TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
363 pAccVolNode->getGraphicObject()->update(
true);
366 TYApplication::restoreOverrideCursor();
371 if (pLine.
_pObj !=
nullptr)
375 TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
378 ret = pLine->updateAcoustic();
390 pLine->getGraphicObject()->update(
true);
393 TYApplication::restoreOverrideCursor();
void writeOutputMsg(QString msg)
Affiche un message dans la fenetre de sortie.
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
TYMainWindow * getTYMainWnd()
Retourne le pointeur sur la fenetre principale.
pour l'application Tympan (fichier header)
Gestionnaire des calculs acoustiques. Il fait l'interface entre l'IHM et le gestionnaire de donnees p...
Fenetre principale de l'application Tympan (fichier header)
utilitaire pour la gestion des messages dans Tympan (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
Frame pour la gestion de projet (fichier header)
Frame pour la gestion de site (fichier header)
Classe Modeler specialisee pour l'edition des sites (fichier header)
virtual void debug(const char *message,...)
virtual void error(const char *message,...)
static OMessageManager * get()
virtual void info(const char *message,...)
T * _pObj
The real pointer, must derived IRefCount.
virtual bool updateAcoustic(const bool &force=false)
void reset()
Reinitialise l'historique.
void plugBackTriangulation(const std::deque< OPoint3D > &points, std::deque< OTriangle > &triangles, const std::deque< LPTYSol > &materials)
plug back triangulation providfed by the TYTopographie
void setIsUpToDate(bool isUpToDate)
static void setCurrentQtDir()
Indique à Qt le chemin du répertoire courant.
LPTYProjet getCurProjet()
Set/Get du projet courant.
void setCurProjet(LPTYProjet pProjet)
Set/Get du projet courant.
virtual ~TYCalculManager()
Destructeur.
bool launchCurrent()
Execute le calcul courant.
bool updateAcoustic(TYElement *pElement)
Appelle la methode de calcul acoustique du volume node passe.
bool askForResetResultat()
Previent l'utilisateur que le resultat va etre efface, si celui-ci est valide.
bool launch(LPTYCalcul pCalcul)
Execute un calcul.
LPTYCalcul _pCurrentCalcul
Le Calcul courant.
void setCurrent(LPTYCalcul pCalcul)
Set du Calcul et Projet courant.
void launchAltiComputation(LPTYSiteNode pRootSite)
Execute altimetry computation.
TYCalculManager()
Constructeur par defaut.
int getState()
Get calculation state.
void setSite(LPTYSiteNode pSite)
Definition of the site on which the calculation will be done.
TYElement * getParent() const
static void setIsSavedOk(const bool &toSave)
void updateModelersAfterComputation(LPTYProjet &result)
TYProjetFrame * getProjetFrame()
void updateModelers(bool clipping=true, bool axesAndGrid=true, bool displayList=true)
TYModelerFrame * getCurrentModeler()
TYActionManager * getActionManager()
void setCalculDone(bool state)
void setProjet(LPTYProjet pProjet)
classe de definition d'un projet.
bool remAllPointControl()
bool updateAltiRecepteurs()
bool remAllMaillage()
Suppression de tous les maillages.
LPTYSiteNode getSite()
Get du site.
void unsetSite()
Supprime la liaison avec le site.
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
void remAllCalcul()
Suppression de tous les elements.
void setProjet(const LPTYProjet pProjet)
LPTYAltimetrie getAltimetry() const
bool readMesh(std::deque< OPoint3D > &points, std::deque< OTriangle > &triangles, std::deque< LPTYSol > &materials, const QString &meshFilePath)
TYProjet * getProjet()
Accesseurs.
virtual void updateAcoustique(const bool &force=false)
void setMeshFilePath(const QString &path)
void update(const bool &force=false)
virtual bool updateAltimetrie(QString resultMeshFilePath)
virtual void updateAltiInfra()
void save_project(const char *filename, const LPTYProjet &project)
save a project into an XML file
LPTYProjet load_project(const char *filename)
load an XML project file
bool python_gui(QStringList args)
Launch a Python-driven computation with a GUI progress dialog.
Utilities for interactions between the GUI and the operating system (headers).
The base exception class for errors due to invalid data.
bool must_keep_tmp_files()
Tell whether temporary files should be preserved (debug mode).
bool init_tmp_file(QTemporaryFile &tmp_file, bool keep_file)
Create and initialize a QTemporaryFile according to the current policy.
Utilities to interact with Python subprocesses from the Tympan application.
Utilities to load a project and a solver.