Path: blob/devel/ElmerGUI/Application/src/mainwindow.h
3203 views
/*****************************************************************************1* *2* Elmer, A Finite Element Software for Multiphysical Problems *3* *4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *5* *6* This program is free software; you can redistribute it and/or *7* modify it under the terms of the GNU General Public License *8* as published by the Free Software Foundation; either version 2 *9* of the License, or (at your option) any later version. *10* *11* This program is distributed in the hope that it will be useful, *12* but WITHOUT ANY WARRANTY; without even the implied warranty of *13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *14* GNU General Public License for more details. *15* *16* You should have received a copy of the GNU General Public License *17* along with this program (in file fem/GPL-2); if not, write to the *18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *19* Boston, MA 02110-1301, USA. *20* *21*****************************************************************************/2223/*****************************************************************************24* *25* ElmerGUI mainwindow *26* *27*****************************************************************************28* *29* Authors: Mikko Lyly, Juha Ruokolainen and Peter RÃ¥back *30* Email: [email protected] *31* Web: http://www.csc.fi/elmer *32* Address: CSC - IT Center for Science Ltd. *33* Keilaranta 14 *34* 02101 Espoo, Finland *35* *36* Original Date: 15 Mar 2008 *37* *38*****************************************************************************/3940#ifndef MAINWINDOW_H41#define MAINWINDOW_H4243#include <QDomDocument>44#include <QMainWindow>45#include <QProcess>4647#include "bodypropertyeditor.h"48#include "boundarydivision.h"49#include "boundarypropertyeditor.h"50#include "checkmpi.h"51#include "dynamiceditor.h"52#include "edfeditor.h"53#include "egini.h"54#include "generalsetup.h"55#include "glcontrol.h"56#include "glwidget.h"57#include "materiallibrary.h"58#include "maxlimits.h"59#include "meshcontrol.h"60#include "meshingthread.h"61#include "meshutils.h"62#include "objectbrowser.h"63#include "operation.h"64#include "parallel.h"65#include "plugins/elmergrid_api.h"66#include "plugins/nglib_api.h"67#include "plugins/tetlib_api.h"68#include "sifgenerator.h"69#include "sifwindow.h"70#include "solverlogwindow.h"71#include "summaryeditor.h"72#include "twod/twodview.h"7374#ifdef EG_QWT75#include "convergenceview.h"76#endif7778#if __APPLE__79// #ifndef EG_OCC80// #define EG_OCC81// #endif82#endif8384#ifdef EG_OCC85#include "cad/cadview.h"86#endif8788class QAction;89class QMenu;90class GLWidget;91class QProgressBar;92class QSystemTrayIcon;93class QContextMenuEvent;9495#ifdef EG_VTK96class VtkPost;97#endif9899#define MAXPATHLENGTH 600100101class MainWindow : public QMainWindow {102Q_OBJECT103104friend class ObjectBrowser;105106public:107MainWindow();108~MainWindow();109110void parseCmdLine();111112static QVariant settings_value(const QString &key,113const QVariant &defaultValue = QVariant());114static void settings_setValue(const QString &key, const QVariant &value);115void saveAndRun(bool generateSif);116void showContextMenu(QPoint);117118protected:119void contextMenuEvent(QContextMenuEvent *event);120void closeEvent(QCloseEvent *event);121122private slots:123// menu slots:124void openSlot(); // File -> Open...125void loadSlot(); // File -> Load...126void loadProjectSlot(); // File -> Load project...127void saveSlot(); // File -> Save...128void saveAsSlot(); // File -> Save As...129void saveProjectSlot(); // File -> Save project130void saveProjectAsSlot(); // File -> Save project as...131void newProjectSlot(); // File -> New project...132void savePictureSlot(); // File -> Save picture as...133void grabFrameSlot(); // utility slot134void closeMainWindowSlot(); // File -> exit135void modelSetupSlot(); // Model -> Setup...136void addEquationSlot(); // Model -> Equation...137void addMaterialSlot(); // Model -> Material...138void addBodyForceSlot(); // Model -> Body force...139void addInitialConditionSlot(); // Model -> Initial condition...140void addBoundaryConditionSlot(); // Model -> Boundary condition...141void bodyEditSlot(); // Model -> Set body properties142void bcEditSlot(); // Model -> Set boundary conditions143void modelSummarySlot(); // Model -> Summary...144void modelClearSlot(); // Model -> Clear145void generateSifSlot(); // Edit -> Generate sif146void showsifSlot(); // Edit -> Solver input file...147void editDefinitionsSlot(); // Edit -> Definitions...148void meshcontrolSlot(); // Mesh -> Control...149void remeshSlot(); // Mesh -> Remesh150void stopMeshingSlot(); // Mesh -> Kill generator151void surfaceDivideSlot(); // Mesh -> Divide surface...152void surfaceUnifySlot(); // Mesh -> Unify surface153void edgeUnifySlot(); // Mesh -> Unify edge154void edgeDivideSlot(); // Mesh -> Divide edge...155void cleanHangingSharpEdgesSlot(); // Mesh -> Clean up156void viewFullScreenSlot(); // View -> Full screen157void hidesurfacemeshSlot(); // View -> Surface mesh158void hidevolumemeshSlot(); // View -> Volume mesh159void hidesharpedgesSlot(); // View -> Sharp edges160void viewCoordinatesSlot(); // View -> Coordinates161void selectAllSurfacesSlot(); // View -> Select all surfaces162void selectAllEdgesSlot(); // View -> Select all edges163void selectDefinedEdgesSlot(); // View -> Select defined edges164void showSurfaceNumbersSlot(); // View -> Show numbering -> surface numbering165void showEdgeNumbersSlot(); // View -> Show numbering -> edge numbering166void showNodeNumbersSlot(); // View -> Show numbering -> node numbering167void showBoundaryIndexSlot(); // View -> Show numbering -> boundary index168void showBodyIndexSlot(); // View -> Show numbering -> body index169void glControlSlot(); // View -> Colors -> GL controls170void backgroundColorSlot(); // View -> Colors -> Background171void surfaceColorSlot(); // View -> Colors -> Surfaces172void edgeColorSlot(); // View -> Colors -> Edges173void surfaceMeshColorSlot(); // View -> Colors -> Surface mesh174void sharpEdgeColorSlot(); // View -> Colors -> Sharp edges175void selectionColorSlot(); // View -> Colors -> Selection176void colorizeBoundarySlot(); // View -> Colors -> Boundaries177void colorizeBodySlot(); // View -> Colors -> Bodies178void selectDefinedSurfacesSlot(); // View -> Select defined surfaces179void hideselectedSlot(); // View -> Hide/show selected180void showallSlot(); // View -> Show all181void resetSlot(); // View -> Reset model view182void flatShadeSlot(); // View -> Shade model -> flat183void smoothShadeSlot(); // View -> Shade model -> smooth184void orthoSlot(); // View -> Projection -> Ortho185void perspectiveSlot(); // View -> Projection -> Perspective186void showCadModelSlot(); // View -> Show cad model...187void showTwodViewSlot(); // View -> Show 2D view...188void showVtkPostSlot(); // View -> Show VTK post processor...189void showParaViewSlot(); // View -> Use ParaView for postprocessing190void showObjectBrowserSlot(); // view -> Show Object Browser191void parallelSettingsSlot(); // Solver -> Parallel settings192void runsolverSlot(); // Solver -> Run solver193void killsolverSlot(); // Solver -> Kill solver194void showConvergenceSlot(); // Solver -> Show convergence...195void resultsSlot(); // Solver -> Post process196void killresultsSlot(); // Solver -> Kill post process197void compileSolverSlot(); // Solver -> Compile...198void showaboutSlot(); // Help -> About...199void getStartedSlot(); // Help -> Get Started...200void generateAndSaveAndRunSlot();201202// other private slots:203void meshingStartedSlot(); // signal emitted by meshingThread204void meshingTerminatedSlot(); // signal emitted by meshingThread205void meshingFinishedSlot(); // signal emitted by meshingThread206207void boundarySelectedSlot(list_t *, Qt::KeyboardModifiers); // signal emitted by glWidget208void doDivideSurfaceSlot(double); // signal emitted by boundaryDivide209void doDivideEdgeSlot(double); // signal emitted by boundaryDivide210211void postProcessFinishedSlot(int); // signal emitted by postProcess212void paraviewProcessFinishedSlot(int); // signal emitted by paraview213214void solverStdoutSlot(); // solver's stdout redirection215void solverStderrSlot(); // solver's stderr redirection216void solverFinishedSlot(int); // signal emitted by solver process217void solverErrorSlot(QProcess::ProcessError); // solver error signal218void solverStateChangedSlot(QProcess::ProcessState); // state changed219220void compilerStdoutSlot(); // compiler's stdout redirection221void compilerStderrSlot(); // compiler's stderr redirection222void compilerFinishedSlot(int); // signal emitted by compiler223224void meshSplitterStdoutSlot(); // meshSplitter's stdout redirection225void meshSplitterStderrSlot(); // meshSplitter's stderr redirection226void meshSplitterFinishedSlot(int); // signal emitted by meshSplitter227228void meshUnifierStdoutSlot(); // meshUnifier's stdout redirection229void meshUnifierStderrSlot(); // meshUnifier's stderr redirection230void meshUnifierFinishedSlot(int); // signal emitted by meshUnifier231232void pdeEditorFinishedSlot(int, int); // signal emitted by pde editor233void matEditorFinishedSlot(int, int); // signal emitted by mat editor234void bodyForceEditorFinishedSlot(int, int); // signal emitted by bf editor235void initialConditionEditorFinishedSlot(int, int); // emitted by ic editor236void boundaryConditionEditorFinishedSlot(int, int); // emitted by bc editor237238void equationSelectedSlot(QAction *); // signal emitted by Equation menu239void materialSelectedSlot(QAction *); // signal emitted by Material menu240void bodyForceSelectedSlot(QAction *); // signal emitted by BodyForce menu241void initialConditionSelectedSlot(QAction *); // emitted by ic menu242void boundaryConditionSelectedSlot(QAction *); // emitted by bc menu243244void materialComboChanged(BodyPropertyEditor *, QString);245void initialComboChanged(BodyPropertyEditor *, QString);246void forceComboChanged(BodyPropertyEditor *, QString);247void equationComboChanged(BodyPropertyEditor *, QString);248void boundaryAsABodyChanged(BoundaryPropertyEditor *, int);249void boundaryComboChanged(BoundaryPropertyEditor *, QString);250251void dynamicEditorNameChange(QString);252253void editNumericalMethods(int, int); // signal emitted by dynamic editor254void showMaterialLibrary(int, int); // signal emitted by dynamic editor255void materialBodyChanged(int);256void initialBodyChanged(int);257void forceBodyChanged(int);258void bcBoundaryChanged(int);259void equationBodyChanged(int);260261void viewNormalModeSlot();262263void menuBarTriggeredSlot(QAction *);264265void loadRecentProject0Slot();266void loadRecentProject1Slot();267void loadRecentProject2Slot();268void loadRecentProject3Slot();269void loadRecentProject4Slot();270void loadRecentProject5Slot();271void loadRecentProject6Slot();272void loadRecentProject7Slot();273void loadRecentProject8Slot();274void loadRecentProject9Slot();275276void selectElmerPostSlot();277void selectVtkPostSlot();278void selectParaViewSlot();279280private:281// widgets and helpers:282GLWidget *glWidget; // central gl widget283SifWindow *sifWindow; // sif text editor284MeshControl *meshControl; // mesh generator control285BoundaryDivide *boundaryDivide; // boundary division control286Meshutils *meshutils; // mesh manipulation utilities287MeshingThread *meshingThread; // meshing thread288SolverLogWindow *solverLogWindow; // Solver log289SifGenerator *sifGenerator; // SIF generator290EdfEditor *edfEditor; // Edf editor291#ifdef EG_QWT292ConvergenceView *convergenceView; // Convergence plotter293#endif294295void createActions();296void createMenus();297void createToolBars();298void createStatusBar();299void applyOperations();300void populateBodyComboBoxes(BodyPropertyEditor *);301void populateBoundaryComboBoxes(BoundaryPropertyEditor *);302void saveProjectContents(QDomDocument, QString, QVector<DynamicEditor *> &);303void loadProjectContents(QDomElement, QVector<DynamicEditor *> &, QString);304QString getDefaultDirName();305void loadProject(QString);306bool saveProject(QString);307void loadSettings();308void saveSettings();309bool loadExtraSolver(310QString); // load the solver with specified solver name, Nov 2019 by TS311void checkAndLoadExtraSolvers(QFile *);312313QMenu *fileMenu; // File menu314QMenu *recentProjectsMenu; // File -> Recent projects menu315QMenu *modelMenu; // Model menu316QMenu *equationMenu; // Model -> Equation menu317QMenu *materialMenu; // Model -> Material menu318QMenu *bodyForceMenu; // Model -> Body force...319QMenu *initialConditionMenu; // Model -> Initial condition...320QMenu *boundaryConditionMenu; // Model -> Boundary condition...321QMenu *editMenu; // Edit menu322QMenu *viewMenu; // View menu323QMenu *shadeMenu; // View -> Shade model menu324QMenu *projectionMenu; // View -> Projection menu325QMenu *numberingMenu; // View -> Show numbering menu326QMenu *colorizeMenu; // View -> Colors menu327QMenu *meshMenu; // Mesh menu328QMenu *solverMenu; // Solver menu329QMenu *helpMenu; // Help menu330QMenu *sysTrayMenu; // System tray menu331QMenu *contextMenu; // Context menu332QMenu *selectPostMenu;333334QToolBar *fileToolBar; // File toolbar335QToolBar *editToolBar; // Edit toolbar336QToolBar *meshToolBar; // Mesh toolbar337QToolBar *solverToolBar; // Solver toolbar338339QAction *openAct; // File -> Open...340QAction *loadAct; // File -> Load...341QAction *loadProjectAct; // File -> Load project....342QAction *newProjectAct; // File -> New Project...343QAction *recentProject0Act;344QAction *recentProject1Act;345QAction *recentProject2Act;346QAction *recentProject3Act;347QAction *recentProject4Act;348QAction *recentProject5Act;349QAction *recentProject6Act;350QAction *recentProject7Act;351QAction *recentProject8Act;352QAction *recentProject9Act;353QAction *saveAct; // File -> Save...354QAction *saveAsAct; // File -> Save As...355QAction *saveProjectAct; // File -> Save project356QAction *saveProjectAsAct; // File -> Save project as...357QAction *savePictureAct; // File -> Save picture as...358QAction *exitAct; // File -> Exit359QAction *modelSetupAct; // Model -> Setup...360QAction *addEquationAct; // Model -> Equation...361QAction *addMaterialAct; // Model -> Material...362QAction *addBodyForceAct; // Model -> Body force...363QAction *addInitialConditionAct; // Model -> Initial condition...364QAction *addBoundaryConditionAct; // Model -> Boundary condition...365QAction *bodyEditAct; // Model -> Set body properties366QAction *bcEditAct; // Model -> Set boundary conditions367QAction *modelSummaryAct; // Model -> Summary...368QAction *modelClearAct; // Model -> Clear369QAction *generateSifAct; // Edit -> Generate sif370QAction *showsifAct; // Edit -> Edit SIF...371QAction *editDefinitionsAct; // Edit -> Edit SIF...372QAction *viewFullScreenAct; // View -> Full screen373QAction *hidesurfacemeshAct; // View -> Show surface mesh374QAction *hidevolumemeshAct; // View -> Show volume mesh375QAction *hidesharpedgesAct; // View -> Show sharp edges376QAction *viewCoordinatesAct; // View -> Show sharp edges377QAction *selectAllSurfacesAct; // View -> Select all surfaces378QAction *selectAllEdgesAct; // View -> Select all edges379QAction *selectDefinedEdgesAct; // View -> Select defined edges380QAction *selectDefinedSurfacesAct; // View -> Select defined surfaces381QAction *showSurfaceNumbersAct; // View -> Show numbering -> element numbers382QAction *showEdgeNumbersAct; // View -> Show numbering -> edge numbers383QAction *showNodeNumbersAct; // View -> Show numbering -> node numbers384QAction *showBoundaryIndexAct; // View -> Show numbering -> boundary index385QAction *showBodyIndexAct; // View -> Show numbering -> body index386QAction *glControlAct; // View -> Colors -> GL controls387QAction *chooseBGColorAct; // View -> Colors -> Background color388QAction *chooseSurfaceColorAct; // View -> Colors -> Surface color389QAction *chooseSurfaceMeshColorAct; // View -> Colors -> Surface mesh390QAction *chooseSharpEdgeColorAct; // View -> Colors -> Sharp edges391QAction *chooseEdgeColorAct; // View -> Colors -> Edge color392QAction *chooseSelectionColorAct; // View -> Colors -> Selection393QAction *showBoundaryColorAct; // View -> Colors -> Boundaries394QAction *showBodyColorAct; // View -> Colors -> Body395QAction *hideselectedAct; // View -> Show selected396QAction *flatShadeAct; // View -> Shade model -> Flat397QAction *smoothShadeAct; // View -> Shade model -> Smooth398QAction *orthoAct; // View -> Projection -> Ortho399QAction *perspectiveAct; // View -> Projection -> Perspective400QAction *showallAct; // View -> Show all401QAction *resetAct; // View -> Reset model view402QAction *showCadModelAct; // View -> Show cad model...403QAction *showTwodViewAct; // View -> Show 2d view...404QAction *showVtkPostAct; // View -> Show VTK post processor...405QAction *showObjectBrowserAct; // View -> Show Object Browser406QAction *meshcontrolAct; // Mesh -> Control...407QAction *remeshAct; // Mesh -> Remesh408QAction *stopMeshingAct; // Mesh -> Kill generator409QAction *surfaceDivideAct; // Mesh -> Divide surface...410QAction *surfaceUnifyAct; // Mesh -> Unify surface411QAction *edgeDivideAct; // Mesh -> Divide edges...412QAction *edgeUnifyAct; // Mesh -> Unify edge413QAction *cleanHangingSharpEdgesAct; // Mesh -> Clean up414QAction *parallelSettingsAct; // Solver -> Parallel settings415QAction *runsolverAct; // Solver -> Run solver416QAction *killsolverAct; // Solver -> Kill solver417QAction *showConvergenceAct; // Solver -> Show convergence...418QAction *resultsAct; // Solver -> Post process419QAction *killresultsAct; // Solver -> Kill post process420QAction *paraviewAct; // Solver -> Launch Paraview421QAction *compileSolverAct; // Solver -> Compile...422QAction *aboutAct; // Help -> About...423QAction *getStartedAct; // Help -> Get Started...424QAction *generateAndSaveAndRunAct;425QAction *runPostProcessorAct;426QAction *selectElmerPostAct;427QAction *selectVtkPostAct;428QAction *selectParaViewAct;429430// property editors etc:431GeneralSetup *generalSetup;432433QVector<DynamicEditor *> equationEditor;434QVector<DynamicEditor *> materialEditor;435QVector<DynamicEditor *> bodyForceEditor;436QVector<DynamicEditor *> initialConditionEditor;437QVector<DynamicEditor *> boundaryConditionEditor;438QVector<BoundaryPropertyEditor *> boundaryPropertyEditor;439QVector<BodyPropertyEditor *> bodyPropertyEditor;440QVector<SolverParameterEditor *> solverParameterEditor;441442SummaryEditor *summaryEditor;443GLcontrol *glControl;444Parallel *parallel;445CheckMpi *checkMpi;446MaterialLibrary *materialLibrary;447448#ifdef EG_OCC449CadView *cadView;450#endif451452TwodView *twodView;453454#ifdef EG_VTK455VtkPost *vtkPost;456#endif457458// elmer definitions:459QDomDocument *elmerDefs;460461// tetlib:462bool tetlibPresent;463TetlibAPI *tetlibAPI;464tetgenio *in;465tetgenio *out;466QString tetlibControlString;467bool tetlibInputOk;468469// nglib:470bool nglibPresent;471NglibAPI *nglibAPI;472nglib::Ng_Mesh *ngmesh;473nglib::Ng_STL_Geometry *nggeom;474nglib::Ng_Geometry_2D *nggeom2d;475nglib::Ng_Meshing_Parameters mp;476int ngDim;477QString stlFileName;478QString in2dFileName;479bool nglibInputOk;480481// occ:482bool occInputOk;483484// vtkPost:485bool vtkPostMeshUnifierRunning;486487// elmergrid:488ElmergridAPI *elmergridAPI;489490// solver, post processor, and other processes:491QProcess *solver;492QProcess *post;493QProcess *paraview;494QProcess *compiler;495QProcess *meshSplitter;496QProcess *meshUnifier;497498// utility functions:499void readInputFile(QString);500void loadElmerMesh(QString);501void saveElmerMesh(QString);502void makeElmerMeshFromTetlib();503void makeElmerMeshFromNglib();504void logMessage(QString);505void loadDefinitions();506void createBoundaryCheckBoxes(DynamicEditor *);507void createBodyCheckBoxes(int, DynamicEditor *);508void synchronizeMenuToState();509510// state variables:511int activeGenerator;512bool bcEditActive;513bool bodyEditActive;514bool showConvergence;515QString saveDirName;516QString geometryInputFileName;517518// splash screen:519QPixmap pixmap;520QSplashScreen splash;521void setupSplash();522void updateSplash(QString);523void finalizeSplash();524525// sys tray icon:526QSystemTrayIcon *sysTrayIcon;527void setupSysTrayIcon();528void updateSysTrayIcon(QString, QString);529void finalizeSysTrayIcon();530531// initialization:532EgIni *egIni;533534// limits:535void setDynamicLimits();536Limit *limit;537538// operations:539int operations;540operation_t operation;541542// progress bar:543QProgressBar *progressBar;544QLabel *progressLabel;545546// screen shot:547QTimeLine *grabTimeLine;548QString pictureFileName;549550// #ifdef __APPLE__551// This is only needed for Mac OS X, but it's easier to include in all552// architectures and it's small so there's no marked adverse effects553QString homePath;554// #endif555556// variables and functions for "Recent projects..." menu557QStringList recentProject;558void addRecentProject(QString, bool);559560// String to store current project dir for "generate, save and run" button561QString currentProjectDirName;562563564ObjectBrowser *objectBrowser;565566public:567/*568rebuildGLLists() is assumed to be called from ObjectBrowser to avoid a problem of 3D surface569mesh not shown correctly when project loading (typically, TemperatureGeneric sample)570*/571void rebuildGLLists();572};573574#endif // MAINWINDOW_H575576577