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 = fileInfo.path().replace(
"\\",
"/") +
"/" + fileInfo.baseName() +
"." +
"ply";
106 "Creation de fichier temporaire impossible. Veuillez verifier l'espace disque disponible.");
116 std::ostringstream msg;
117 msg << boost::diagnostic_information(exc);
118 logger.
error(
"Could not export current project. Computation won't be done");
119 logger.
debug(msg.str().c_str());
124 logger.
debug(
"Le calcul va s'executer en mode debug.\nLes fichiers temporaires ne seront pas "
125 "supprimes une fois le calcul termine.\nProjet courant non calcule: %s. Projet avec les "
126 "resultats du calcul: %s. Mesh de l'altimetrie au format ply: %s",
127 problemfile.fileName().toStdString().c_str(),
128 resultfile.fileName().toStdString().c_str());
136 QString absolute_plugins_path(QCoreApplication::applicationDirPath());
137 absolute_plugins_path.append(
"/");
138 absolute_plugins_path.append(PLUGINS_PATH);
139 QString absolute_pyscript_path(QCoreApplication::applicationDirPath());
140 absolute_pyscript_path.append(
"/");
141 absolute_pyscript_path.append(SOLVE_PYSCRIPT);
142 args << absolute_pyscript_path << problemfile.fileName() << resultfile.fileName() << meshFilePath
143 << absolute_plugins_path;
148 QRegularExpression altimetry_size_criterion_reg(
"(MeshElementSizeMax\\s?=\\s?)([0-9]+.[0-9]*)");
149 QRegularExpression altimetry_refine_mesh_reg(
"(RefineMesh\\s?=\\s?)(True|False)");
150 QRegularExpression altimetry_use_volumes_landtakes_reg(
"(UseVolumesLandtake\\s?=\\s?)(True|False)");
151 QRegularExpressionMatch match_size = altimetry_size_criterion_reg.match(parameters);
152 QRegularExpressionMatch match_refi = altimetry_refine_mesh_reg.match(parameters);
153 QRegularExpressionMatch match_land = altimetry_use_volumes_landtakes_reg.match(parameters);
157 if (match_size.hasMatch() && match_refi.hasMatch() && match_land.hasMatch())
159 QString altimetry_size_criterion = match_size.captured(2);
160 QString altimetry_refine_mesh = match_refi.captured(2);
161 QString altimetry_use_volumes_landtakes = match_land.captured(2);
162 QString altimetry_update = (altiIsOK) ? QString(
"False") : QString(
"True");
164 args << altimetry_size_criterion << altimetry_refine_mesh << altimetry_use_volumes_landtakes
167 logger.
info(
TR(
"id_msg_go_calcul"));
184 std::ostringstream msg;
185 msg << boost::diagnostic_information(exc);
186 logger.
error(
"Could not import computed project. No results available.");
187 logger.
debug(msg.str().c_str());
189 msgBox.setText(
"Le fichier de resultats n'a pas pu etre lu.");
201 std::deque<OPoint3D> points;
202 std::deque<OTriangle> triangles;
203 std::deque<LPTYSol> materials;
204 pSite->
readMesh(points, triangles, materials, meshFilePath);
218 pCalcul->
getParent()->updateGraphicTree();
219 pCalcul->updateGraphicTree();
241 logger.
info(
TR(
"id_msg_calcul_done"));
301 if (pSite !=
nullptr)
306 if (pAccVolNode.
_pObj !=
nullptr)
310 TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
325 pAccVolNode->getGraphicObject()->update(
true);
328 TYApplication::restoreOverrideCursor();
333 if (pLine.
_pObj !=
nullptr)
337 TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
340 ret = pLine->updateAcoustic();
352 pLine->getGraphicObject()->update(
true);
355 TYApplication::restoreOverrideCursor();
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.
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)
virtual void updateAcoustique(const bool &force=false)
void setMeshFilePath(const QString &path)
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.