-
Notifications
You must be signed in to change notification settings - Fork 319
/
mainwindow.cpp
8231 lines (6709 loc) · 251 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************
* *
* Elmer, A Finite Element Software for Multiphysical Problems *
* *
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program (in file fem/GPL-2); if not, write to the *
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
* *
*****************************************************************************/
/*****************************************************************************
* *
* ElmerGUI mainwindow *
* *
*****************************************************************************
* *
* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *
* Email: Juha.Ruokolainen@csc.fi *
* Web: http://www.csc.fi/elmer *
* Address: CSC - IT Center for Science Ltd. *
* Keilaranta 14 *
* 02101 Espoo, Finland *
* *
* Original Date: 15 Mar 2008 *
* *
*****************************************************************************/
#include <QAction>
#include <QContextMenuEvent>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QFont>
#include <QProgressBar>
#include <QStringList>
#include <QSystemTrayIcon>
#include <QTimeLine>
#include <QtGui>
#include <fstream>
#include <iostream>
#include <QDebug>
#include "mainwindow.h"
#include "newprojectdialog.h"
#ifdef EG_VTK
#include "vtkpost/vtkpost.h"
VtkPost *vtkp;
#endif
#ifdef __APPLE__
#include <mach-o/dyld.h>
// #ifndef EG_OCC
// #define EG_OCC
// #endif
#endif
using namespace std;
#undef MPICH2
// Construct main window...
//-----------------------------------------------------------------------------
MainWindow::MainWindow() {
#ifdef __APPLE__
// find "Home directory":
char executablePath[MAXPATHLENGTH] = {0};
uint32_t len = MAXPATHLENGTH;
this->homePath = "";
if (!_NSGetExecutablePath((char *)executablePath, &len)) {
// remove executable name from path:
*(strrchr(executablePath, '/')) = '\0';
// remove last path component name from path:
*(strrchr(executablePath, '/')) = '\0';
this->homePath = executablePath;
}
#else
homePath = "";
#endif
// Set icon theme path
#ifdef __APPLE__DONTGO_HERE_TODO
QString themePath = this->homePath + "/icons";
#else
QString themePath =
QCoreApplication::applicationDirPath() + "/../share/ElmerGUI/icons";
QString elmerGuiHome = QString(getenv("ELMERGUI_HOME"));
if (!elmerGuiHome.isEmpty())
themePath = elmerGuiHome + "/icons";
themePath.replace('\\', '/');
#endif
QIcon::setThemeSearchPaths(QStringList(themePath));
QIcon::setThemeName("TangoElmerGUI");
// load ini file:
egIni = new EgIni(this);
// splash screen:
setupSplash();
// load splash screen:
updateSplash("Loading images...");
// load tetlib:
updateSplash("Loading tetlib...");
tetlibAPI = new TetlibAPI;
tetlibPresent = tetlibAPI->loadTetlib();
this->in = tetlibAPI->in;
this->out = tetlibAPI->out;
// load nglib:
updateSplash("Loading nglib...");
nglibAPI = new NglibAPI;
nglibPresent = true;
// construct elmergrid:
updateSplash("Constructing elmergrid...");
elmergridAPI = new ElmergridAPI;
// set dynamic limits:
limit = new Limit;
setDynamicLimits();
// widgets and utilities:
updateSplash("ElmerGUI loading...");
glWidget = new GLWidget(this);
#ifdef WIN32
glWidget->stateDrawSharpEdges = false;
#endif
setCentralWidget(glWidget);
sifWindow = new SifWindow(this);
meshControl = new MeshControl(this);
boundaryDivide = new BoundaryDivide(this);
meshingThread = new MeshingThread(this);
meshutils = new Meshutils;
solverLogWindow = new SolverLogWindow(this);
solver = new QProcess(this);
post = new QProcess(this);
paraview = new QProcess(this);
compiler = new QProcess(this);
meshSplitter = new QProcess(this);
meshUnifier = new QProcess(this);
generalSetup = new GeneralSetup(this);
summaryEditor = new SummaryEditor(this);
sifGenerator = new SifGenerator;
sifGenerator->setLimit(this->limit);
elmerDefs = new QDomDocument;
edfEditor = new EdfEditor;
glControl = new GLcontrol(this);
parallel = new Parallel(this);
checkMpi = new CheckMpi;
materialLibrary = new MaterialLibrary(this);
twodView = new TwodView;
grabTimeLine = new QTimeLine(1000, this);
#ifdef EG_QWT
convergenceView = new ConvergenceView(limit, this);
#endif
#ifdef EG_VTK
vtkp = vtkPost = new VtkPost(this);
vtkPostMeshUnifierRunning = false;
#endif
#ifdef EG_OCC
cadView = new CadView();
if (egIni->isPresent("deflection"))
cadView->setDeflection(egIni->value("deflection").toDouble());
#endif
createActions();
createMenus();
createToolBars();
createStatusBar();
runPostProcessorAct->setMenu(selectPostMenu);
// Always, when an action from the menu bar has been selected, synchronize
// menu to state:
connect(menuBar(), SIGNAL(triggered(QAction *)), this,
SLOT(menuBarTriggeredSlot(QAction *)));
connect(contextMenu, SIGNAL(triggered(QAction *)), this,
SLOT(menuBarTriggeredSlot(QAction *)));
// glWidget emits (list_t*) when a boundary is selected by double clicking:
connect(glWidget, SIGNAL(signalBoundarySelected(list_t *, Qt::KeyboardModifiers)), this,
SLOT(boundarySelectedSlot(list_t *, Qt::KeyboardModifiers)));
// glWidget emits (void) when esc has been pressed:
connect(glWidget, SIGNAL(escPressed()), this, SLOT(viewNormalModeSlot()));
// meshingThread emits (void) when the mesh generation has finished or
// terminated:
connect(meshingThread, SIGNAL(started()), this, SLOT(meshingStartedSlot()));
connect(meshingThread, SIGNAL(finished()), this, SLOT(meshingFinishedSlot()));
connect(meshingThread, SIGNAL(terminated()), this,
SLOT(meshingTerminatedSlot()));
// boundaryDivide emits (double) when "divide button" has been clicked:
connect(boundaryDivide, SIGNAL(signalDoDivideSurface(double)), this,
SLOT(doDivideSurfaceSlot(double)));
// boundaryDivide emits (double) when "divide button" has been clicked:
connect(boundaryDivide, SIGNAL(signalDoDivideEdge(double)), this,
SLOT(doDivideEdgeSlot(double)));
// solver emits (int) when finished:
connect(solver, SIGNAL(finished(int)), this, SLOT(solverFinishedSlot(int)));
// solver emits (void) when there is something to read from stdout:
connect(solver, SIGNAL(readyReadStandardOutput()), this,
SLOT(solverStdoutSlot()));
// solver emits (void) when there is something to read from stderr:
connect(solver, SIGNAL(readyReadStandardError()), this,
SLOT(solverStderrSlot()));
// solver emits (QProcess::ProcessError) when error occurs:
connect(solver, SIGNAL(error(QProcess::ProcessError)), this,
SLOT(solverErrorSlot(QProcess::ProcessError)));
// solver emits (QProcess::ProcessState) when state changed:
connect(solver, SIGNAL(stateChanged(QProcess::ProcessState)), this,
SLOT(solverStateChangedSlot(QProcess::ProcessState)));
// compiler emits (int) when finished:
connect(compiler, SIGNAL(finished(int)), this,
SLOT(compilerFinishedSlot(int)));
// compiler emits (void) when there is something to read from stdout:
connect(compiler, SIGNAL(readyReadStandardOutput()), this,
SLOT(compilerStdoutSlot()));
// compiler emits (void) when there is something to read from stderr:
connect(compiler, SIGNAL(readyReadStandardError()), this,
SLOT(compilerStderrSlot()));
// post emits (int) when finished:
connect(post, SIGNAL(finished(int)), this,
SLOT(postProcessFinishedSlot(int)));
// paraview emits (int) when finished:
connect(paraview, SIGNAL(finished(int)), this,
SLOT(paraviewProcessFinishedSlot(int)));
// meshSplitter emits (int) when finished:
connect(meshSplitter, SIGNAL(finished(int)), this,
SLOT(meshSplitterFinishedSlot(int)));
// meshSplitter emits(void) when there is something to read from stdout:
connect(meshSplitter, SIGNAL(readyReadStandardOutput()), this,
SLOT(meshSplitterStdoutSlot()));
// meshSplitter emits(void) when there is something to read from stderr:
connect(meshSplitter, SIGNAL(readyReadStandardError()), this,
SLOT(meshSplitterStderrSlot()));
// meshUnifier emits (int) when finished:
connect(meshUnifier, SIGNAL(finished(int)), this,
SLOT(meshUnifierFinishedSlot(int)));
// meshUnifier emits(void) when there is something to read from stdout:
connect(meshUnifier, SIGNAL(readyReadStandardOutput()), this,
SLOT(meshUnifierStdoutSlot()));
// meshUnifier emits(void) when there is something to read from stderr:
connect(meshUnifier, SIGNAL(readyReadStandardError()), this,
SLOT(meshUnifierStderrSlot()));
// grabTimeLine emits finished() when done:
connect(grabTimeLine, SIGNAL(finished()), this, SLOT(grabFrameSlot()));
// set initial state:
operations = 0;
meshControl->nglibPresent = nglibPresent;
meshControl->tetlibPresent = tetlibPresent;
meshControl->defaultControls();
nglibInputOk = false;
tetlibInputOk = false;
activeGenerator = GEN_UNKNOWN;
bcEditActive = false;
bodyEditActive = false;
showConvergence = egIni->isSet("showconvergence");
geometryInputFileName = "";
occInputOk = false;
// background image:
glWidget->stateUseBgImage = egIni->isSet("bgimage");
glWidget->stateStretchBgImage = egIni->isSet("bgimagestretch");
glWidget->stateAlignRightBgImage = egIni->isSet("bgimagealignright");
glWidget->bgImageFileName = egIni->value("bgimagefile");
// set font for text editors:
// QFont sansFont("Courier", 10);
// sifWindow->getTextEdit()->setCurrentFont(sansFont);
// solverLogWindow->getTextEdit()->setCurrentFont(sansFont);
// load definition files:
updateSplash("Loading definitions...");
loadDefinitions();
// initialization ready:
// synchronizeMenuToState(); Commented out as this will be called from loadSettings() later
setWindowTitle(tr("ElmerGUI"));
setWindowIcon(QIcon(":/icons/Mesh3D.png"));
finalizeSplash();
setupSysTrayIcon();
// default size:
int defW = egIni->value("width").toInt();
int defH = egIni->value("height").toInt();
if (defW <= 300)
defW = 300;
if (defH <= 300)
defH = 300;
this->resize(defW, defH);
sifWindow->resize(defW - 50, defH - 50);
solverLogWindow->resize(defW - 50, defH - 50);
loadSettings();
}
// dtor...
//-----------------------------------------------------------------------------
MainWindow::~MainWindow() {
saveSettings();
qApp->closeAllWindows();
}
// Set limits for dynamic editors, materials, bcs, etc...
//-----------------------------------------------------------------------------
void MainWindow::setDynamicLimits() {
// Values defined in "edf/egini.xml" that override default limits:
// Deprecated ** 23/04/09 **
if (egIni->isPresent("max_boundaries")) {
limit->setMaxBoundaries(egIni->value("max_boundaries").toInt());
// cout << "Max boundaries: " << limit->maxBoundaries() << endl;
}
// Deprecated ** 23/04/09 **
if (egIni->isPresent("max_solvers")) {
limit->setMaxSolvers(egIni->value("max_solvers").toInt());
// cout << "Max solvers: " << limit->maxSolvers() << endl;
}
// Deprecated ** 23/04/09 **
if (egIni->isPresent("max_bodies")) {
limit->setMaxBodies(egIni->value("max_bodies").toInt());
// cout << "Max bodies: " << limit->maxBodies() << endl;
}
// Deprecated ** 21/04/09 **
if (egIni->isPresent("max_equations")) {
limit->setMaxEquations(egIni->value("max_equations").toInt());
// cout << "Max equations: " << limit->maxEquations() << endl;
}
// Deprecated ** 21/04/09 **
if (egIni->isPresent("max_materials")) {
limit->setMaxMaterials(egIni->value("max_materials").toInt());
// cout << "Max materials: " << limit->maxMaterials() << endl;
}
// Deprecated ** 21/04/09 **
if (egIni->isPresent("max_bodyforces")) {
limit->setMaxBodyforces(egIni->value("max_bodyforces").toInt());
// cout << "Max bodyforces: " << limit->maxBodyforces() << endl;
}
// Deprecated ** 21/04/09 **
if (egIni->isPresent("max_initialconditions")) {
limit->setMaxInitialconditions(
egIni->value("max_initialconditions").toInt());
// cout << "Max initialconditions: " << limit->maxInitialconditions() <<
// endl;
}
// Deprecated ** 21/04/09 **
if (egIni->isPresent("max_bcs")) {
limit->setMaxBcs(egIni->value("max_bcs").toInt());
// cout << "Max bcs: " << limit->maxBcs() << endl;
}
}
// Always synchronize menu to state when the menubar has been triggered...
//-----------------------------------------------------------------------------
void MainWindow::menuBarTriggeredSlot(QAction *act) {
synchronizeMenuToState();
}
// Create actions...
//-----------------------------------------------------------------------------
void MainWindow::createActions() {
// File -> Open file
openAct =
new QAction(QIcon::fromTheme("document-open"), tr("&Open..."), this);
openAct->setShortcut(tr("Ctrl+O"));
openAct->setStatusTip(tr("Open geometry input file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(openSlot()));
// File -> Load mesh...
loadAct = new QAction(QIcon::fromTheme("folder"),
tr("&Load mesh..."), this);
loadAct->setStatusTip(tr("Load Elmer mesh files"));
connect(loadAct, SIGNAL(triggered()), this, SLOT(loadSlot()));
// File -> Load project...
loadProjectAct = new QAction(QIcon::fromTheme("project-load"),
tr("Load &project..."), this);
loadProjectAct->setStatusTip(tr("Load previously saved project"));
connect(loadProjectAct, SIGNAL(triggered()), this, SLOT(loadProjectSlot()));
// File -> New project...
newProjectAct = new QAction(QIcon::fromTheme("project-new"),
tr("&New project..."), this);
newProjectAct->setStatusTip(tr("Create a new project"));
connect(newProjectAct, SIGNAL(triggered()), this, SLOT(newProjectSlot()));
// File -> Recent Projects
recentProject0Act = new QAction("", this);
connect(recentProject0Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject0Slot()));
recentProject1Act = new QAction("", this);
connect(recentProject1Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject1Slot()));
recentProject2Act = new QAction("", this);
connect(recentProject2Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject2Slot()));
recentProject3Act = new QAction("", this);
connect(recentProject3Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject3Slot()));
recentProject4Act = new QAction("", this);
connect(recentProject4Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject4Slot()));
recentProject5Act = new QAction("", this);
connect(recentProject5Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject5Slot()));
recentProject6Act = new QAction("", this);
connect(recentProject6Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject6Slot()));
recentProject7Act = new QAction("", this);
connect(recentProject7Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject7Slot()));
recentProject8Act = new QAction("", this);
connect(recentProject8Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject8Slot()));
recentProject9Act = new QAction("", this);
connect(recentProject9Act, SIGNAL(triggered()), this,
SLOT(loadRecentProject9Slot()));
// File -> Definitions...
editDefinitionsAct = new QAction(QIcon::fromTheme("preferences-system"),
tr("&Definitions..."), this);
editDefinitionsAct->setStatusTip(
tr("Load and edit Elmer sif definitions file"));
connect(editDefinitionsAct, SIGNAL(triggered()), this,
SLOT(editDefinitionsSlot()));
// File -> Save...
saveAct =
new QAction(QIcon::fromTheme("document-save"), tr("&Save..."), this);
saveAct->setShortcut(tr("Ctrl+S"));
saveAct->setStatusTip(tr("Save Elmer mesh and sif-files"));
connect(saveAct, SIGNAL(triggered()), this, SLOT(saveSlot()));
// File -> Save as...
saveAsAct = new QAction(QIcon::fromTheme("document-save-as"),
tr("&Save as..."), this);
saveAsAct->setStatusTip(tr("Save Elmer mesh and sif-files"));
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAsSlot()));
// File -> Save project
saveProjectAct = new QAction(QIcon::fromTheme("project-save"),
tr("&Save project"), this);
saveProjectAct->setStatusTip(tr("Save current project"));
connect(saveProjectAct, SIGNAL(triggered()), this, SLOT(saveProjectSlot()));
// File -> Save project as...
saveProjectAsAct = new QAction(QIcon::fromTheme("project-save-as"),
tr("&Save project as..."), this);
saveProjectAsAct->setStatusTip(
tr("Save current project by specifying directory"));
connect(saveProjectAsAct, SIGNAL(triggered()), this,
SLOT(saveProjectAsSlot()));
// File -> Save picture as...
savePictureAct = new QAction(QIcon::fromTheme("image-x-generic"),
tr("&Save picture as..."), this);
savePictureAct->setStatusTip(tr("Save picture in file"));
connect(savePictureAct, SIGNAL(triggered()), this, SLOT(savePictureSlot()));
// File -> Exit
exitAct =
new QAction(QIcon::fromTheme("emblem-unreadable"), tr("E&xit"), this);
exitAct->setShortcut(tr("Ctrl+Q"));
exitAct->setStatusTip(tr("Exit"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(closeMainWindowSlot()));
// Model -> Setup...
modelSetupAct = new QAction(QIcon::fromTheme("applications-system"), tr("Setup..."), this);
modelSetupAct->setStatusTip(tr("Setup simulation environment"));
connect(modelSetupAct, SIGNAL(triggered()), this, SLOT(modelSetupSlot()));
// Model -> Equation...
addEquationAct = new QAction(QIcon(), tr("Add..."), this);
addEquationAct->setStatusTip(tr("Add a PDE-system to the equation list"));
connect(addEquationAct, SIGNAL(triggered()), this, SLOT(addEquationSlot()));
// Model -> Material...
addMaterialAct = new QAction(QIcon(), tr("Add..."), this);
addMaterialAct->setStatusTip(tr("Add a material set to the material list"));
connect(addMaterialAct, SIGNAL(triggered()), this, SLOT(addMaterialSlot()));
// Model -> Body force...
addBodyForceAct = new QAction(QIcon(), tr("Add..."), this);
addBodyForceAct->setStatusTip(tr("Add body forces..."));
connect(addBodyForceAct, SIGNAL(triggered()), this, SLOT(addBodyForceSlot()));
// Model -> Initial condition...
addInitialConditionAct = new QAction(QIcon(), tr("Add..."), this);
addInitialConditionAct->setStatusTip(tr("Add initial conditions..."));
connect(addInitialConditionAct, SIGNAL(triggered()), this,
SLOT(addInitialConditionSlot()));
// Model -> Boundary condition...
addBoundaryConditionAct = new QAction(QIcon(), tr("Add..."), this);
addBoundaryConditionAct->setStatusTip(tr("Add boundary conditions..."));
connect(addBoundaryConditionAct, SIGNAL(triggered()), this,
SLOT(addBoundaryConditionSlot()));
// Model -> Set body properties
bodyEditAct = new QAction(QIcon(":/icons/set-body-property.png"),
tr("Set body properties"), this);
bodyEditAct->setStatusTip(
tr("Set body properties (equivalent to holding down the SHIFT key)"));
connect(bodyEditAct, SIGNAL(triggered()), this, SLOT(bodyEditSlot()));
bodyEditAct->setCheckable(true);
// Model -> Set boundary conditions
bcEditAct = new QAction(QIcon(":/icons/set-boundary-property.png"),
tr("Set boundary properties"), this);
bcEditAct->setStatusTip(
tr("Set boundary properties (equivalent to holding down the ALT key)"));
connect(bcEditAct, SIGNAL(triggered()), this, SLOT(bcEditSlot()));
bcEditAct->setCheckable(true);
// Model -> Summary...
modelSummaryAct = new QAction(QIcon(), tr("Summary..."), this);
modelSummaryAct->setStatusTip(tr("Model summary"));
connect(modelSummaryAct, SIGNAL(triggered()), this, SLOT(modelSummarySlot()));
// Model -> Clear
modelClearAct = new QAction(QIcon(), tr("Clear all"), this);
modelClearAct->setStatusTip(tr("Clear all model definitions"));
connect(modelClearAct, SIGNAL(triggered()), this, SLOT(modelClearSlot()));
// Edit -> Generate sif
generateSifAct = new QAction(QIcon(""), tr("&Generate"), this);
generateSifAct->setShortcut(tr("Ctrl+G"));
generateSifAct->setStatusTip(tr("Generate solver input file"));
connect(generateSifAct, SIGNAL(triggered()), this, SLOT(generateSifSlot()));
// Edit -> Solver input file...
showsifAct = new QAction(QIcon::fromTheme("text-x-generic-with-pencil"),
tr("&Edit..."), this);
showsifAct->setShortcut(tr("Ctrl+S"));
showsifAct->setStatusTip(tr("Edit solver input file"));
connect(showsifAct, SIGNAL(triggered()), this, SLOT(showsifSlot()));
// Mesh -> Control
meshcontrolAct =
new QAction(QIcon::fromTheme("configure"), tr("&Configure..."), this);
meshcontrolAct->setShortcut(tr("Ctrl+C"));
meshcontrolAct->setStatusTip(tr("Configure mesh generators"));
connect(meshcontrolAct, SIGNAL(triggered()), this, SLOT(meshcontrolSlot()));
// Mesh -> Remesh
remeshAct = new QAction(QIcon::fromTheme("edit-redo"), tr("&Remesh"), this);
remeshAct->setShortcut(tr("Ctrl+R"));
remeshAct->setStatusTip(tr("Remesh"));
connect(remeshAct, SIGNAL(triggered()), this, SLOT(remeshSlot()));
// Mesh -> Kill generator
stopMeshingAct = new QAction(QIcon::fromTheme("dialog-error-round"),
tr("&Terminate meshing"), this);
stopMeshingAct->setStatusTip(tr("Terminate mesh generator"));
connect(stopMeshingAct, SIGNAL(triggered()), this, SLOT(stopMeshingSlot()));
stopMeshingAct->setEnabled(false);
// Mesh -> Divide surface
surfaceDivideAct =
new QAction(QIcon(":/icons/divide.png"), tr("&Divide surface..."), this);
surfaceDivideAct->setStatusTip(tr("Divide surface by sharp edges"));
connect(surfaceDivideAct, SIGNAL(triggered()), this,
SLOT(surfaceDivideSlot()));
// Mesh -> Unify surface
surfaceUnifyAct =
new QAction(QIcon(":/icons/unify.png"), tr("&Unify surface"), this);
surfaceUnifyAct->setStatusTip(tr("Unify surface (merge selected)"));
connect(surfaceUnifyAct, SIGNAL(triggered()), this, SLOT(surfaceUnifySlot()));
// Mesh -> Divide edge
edgeDivideAct = new QAction(QIcon(":/icons/divide-edge.png"),
tr("&Divide edge..."), this);
edgeDivideAct->setStatusTip(tr("Divide edge by sharp points"));
connect(edgeDivideAct, SIGNAL(triggered()), this, SLOT(edgeDivideSlot()));
// Mesh -> Unify edges
edgeUnifyAct =
new QAction(QIcon(":/icons/unify-edge.png"), tr("&Unify edge"), this);
edgeUnifyAct->setStatusTip(tr("Unify edge (merge selected)"));
connect(edgeUnifyAct, SIGNAL(triggered()), this, SLOT(edgeUnifySlot()));
// Mesh -> Clean up
cleanHangingSharpEdgesAct = new QAction(QIcon::fromTheme("edit-clear"), tr("Clean up"), this);
cleanHangingSharpEdgesAct->setStatusTip(
tr("Removes hanging/orphan sharp edges (for visualization)"));
connect(cleanHangingSharpEdgesAct, SIGNAL(triggered()), this,
SLOT(cleanHangingSharpEdgesSlot()));
// View -> Full screen
viewFullScreenAct = new QAction(QIcon::fromTheme("view-fullscreen"), tr("Full screen"), this);
viewFullScreenAct->setShortcut(tr("Ctrl+L"));
viewFullScreenAct->setStatusTip(tr("Full screen mode"));
connect(viewFullScreenAct, SIGNAL(triggered()), this,
SLOT(viewFullScreenSlot()));
viewFullScreenAct->setCheckable(true);
// View -> Show surface mesh
hidesurfacemeshAct = new QAction(QIcon(), tr("Surface mesh"), this);
hidesurfacemeshAct->setStatusTip(tr("Show/hide surface mesh "
"(do/do not outline surface elements)"));
connect(hidesurfacemeshAct, SIGNAL(triggered()), this,
SLOT(hidesurfacemeshSlot()));
hidesurfacemeshAct->setCheckable(true);
// View -> Show volume mesh
hidevolumemeshAct = new QAction(QIcon(), tr("Volume mesh"), this);
hidevolumemeshAct->setStatusTip(tr("Show/hide volume mesh "
"(do/do not outline volume mesh edges)"));
connect(hidevolumemeshAct, SIGNAL(triggered()), this,
SLOT(hidevolumemeshSlot()));
hidevolumemeshAct->setCheckable(true);
// View -> Show sharp edges
hidesharpedgesAct = new QAction(QIcon(), tr("Sharp edges"), this);
hidesharpedgesAct->setStatusTip(tr("Show/hide sharp edges"));
connect(hidesharpedgesAct, SIGNAL(triggered()), this,
SLOT(hidesharpedgesSlot()));
hidesharpedgesAct->setCheckable(true);
// View -> Compass
viewCoordinatesAct = new QAction(QIcon(), tr("Compass"), this);
viewCoordinatesAct->setStatusTip(tr("View coordinates "
"(RGB=XYZ modulo translation)"));
connect(viewCoordinatesAct, SIGNAL(triggered()), this,
SLOT(viewCoordinatesSlot()));
viewCoordinatesAct->setCheckable(true);
// View -> Select all surfaces
selectAllSurfacesAct = new QAction(QIcon(), tr("Select all surfaces"), this);
selectAllSurfacesAct->setStatusTip(tr("Select all surfaces"));
connect(selectAllSurfacesAct, SIGNAL(triggered()), this,
SLOT(selectAllSurfacesSlot()));
// View -> Select all edges
selectAllEdgesAct = new QAction(QIcon(), tr("Select all edges"), this);
selectAllEdgesAct->setStatusTip(tr("Select all edges"));
connect(selectAllEdgesAct, SIGNAL(triggered()), this,
SLOT(selectAllEdgesSlot()));
// View -> Select defined edges
selectDefinedEdgesAct =
new QAction(QIcon(), tr("Select defined edges"), this);
selectDefinedEdgesAct->setStatusTip(tr("Select defined edges"));
connect(selectDefinedEdgesAct, SIGNAL(triggered()), this,
SLOT(selectDefinedEdgesSlot()));
// View -> Select defined surfaces
selectDefinedSurfacesAct =
new QAction(QIcon(), tr("Select defined surfaces"), this);
selectDefinedSurfacesAct->setStatusTip(tr("Select defined surfaces"));
connect(selectDefinedSurfacesAct, SIGNAL(triggered()), this,
SLOT(selectDefinedSurfacesSlot()));
// View -> Hide/show selected
hideselectedAct = new QAction(QIcon(), tr("&Hide/show selected"), this);
hideselectedAct->setShortcut(tr("Ctrl+H"));
hideselectedAct->setStatusTip(tr("Show/hide selected objects"));
connect(hideselectedAct, SIGNAL(triggered()), this, SLOT(hideselectedSlot()));
// View -> Show surface numbers
showSurfaceNumbersAct =
new QAction(QIcon(), tr("Surface element numbers"), this);
showSurfaceNumbersAct->setStatusTip(
tr("Show surface element numbers "
"(Show the surface element numbering)"));
connect(showSurfaceNumbersAct, SIGNAL(triggered()), this,
SLOT(showSurfaceNumbersSlot()));
showSurfaceNumbersAct->setCheckable(true);
// View -> Show edge numbers
showEdgeNumbersAct = new QAction(QIcon(), tr("Edge element numbers"), this);
showEdgeNumbersAct->setStatusTip(tr("Show edge element numbers "
"(Show the node element numbering)"));
connect(showEdgeNumbersAct, SIGNAL(triggered()), this,
SLOT(showEdgeNumbersSlot()));
showEdgeNumbersAct->setCheckable(true);
// View -> Show node numbers
showNodeNumbersAct = new QAction(QIcon(), tr("Node numbers"), this);
showNodeNumbersAct->setStatusTip(tr("Show node numbers "
"(Show the node numbers)"));
connect(showNodeNumbersAct, SIGNAL(triggered()), this,
SLOT(showNodeNumbersSlot()));
showNodeNumbersAct->setCheckable(true);
// View -> Show boundary index
showBoundaryIndexAct = new QAction(QIcon(), tr("Boundary index"), this);
showBoundaryIndexAct->setStatusTip(tr("Show boundary index"));
connect(showBoundaryIndexAct, SIGNAL(triggered()), this,
SLOT(showBoundaryIndexSlot()));
showBoundaryIndexAct->setCheckable(true);
// View -> Show body index
showBodyIndexAct = new QAction(QIcon(), tr("Body index"), this);
showBodyIndexAct->setStatusTip(tr("Show body index"));
connect(showBodyIndexAct, SIGNAL(triggered()), this,
SLOT(showBodyIndexSlot()));
showBodyIndexAct->setCheckable(true);
// View -> Colors -> GL controls
glControlAct = new QAction(QIcon(), tr("GL controls..."), this);
glControlAct->setStatusTip(
tr("Control GL parameters for lights and materials"));
connect(glControlAct, SIGNAL(triggered()), this, SLOT(glControlSlot()));
// View -> Colors -> Background
chooseBGColorAct = new QAction(QIcon(), tr("Background..."), this);
chooseBGColorAct->setStatusTip(tr("Set background color"));
connect(chooseBGColorAct, SIGNAL(triggered()), this,
SLOT(backgroundColorSlot()));
// View -> Colors -> Surface elements
chooseSurfaceColorAct = new QAction(QIcon(), tr("Surface elements..."), this);
chooseSurfaceColorAct->setStatusTip(tr("Set surface color"));
connect(chooseSurfaceColorAct, SIGNAL(triggered()), this,
SLOT(surfaceColorSlot()));
// View -> Colors -> Edge elements
chooseEdgeColorAct = new QAction(QIcon(), tr("Edge elements..."), this);
chooseEdgeColorAct->setStatusTip(tr("Set edge color"));
connect(chooseEdgeColorAct, SIGNAL(triggered()), this, SLOT(edgeColorSlot()));
// View -> Colors -> Surface mesh
chooseSurfaceMeshColorAct = new QAction(QIcon(), tr("Surface mesh..."), this);
chooseSurfaceMeshColorAct->setStatusTip(tr("Set surface mesh color"));
connect(chooseSurfaceMeshColorAct, SIGNAL(triggered()), this,
SLOT(surfaceMeshColorSlot()));
// View -> Colors -> Sharp edges
chooseSharpEdgeColorAct = new QAction(QIcon(), tr("Sharp edges..."), this);
chooseSharpEdgeColorAct->setStatusTip(tr("Set sharp edge color"));
connect(chooseSharpEdgeColorAct, SIGNAL(triggered()), this,
SLOT(sharpEdgeColorSlot()));
// View -> Colors -> Selection
chooseSelectionColorAct = new QAction(QIcon(), tr("Selection..."), this);
chooseSelectionColorAct->setStatusTip(tr("Set selection color"));
connect(chooseSelectionColorAct, SIGNAL(triggered()), this,
SLOT(selectionColorSlot()));
// View -> Colors -> Boundaries
showBoundaryColorAct = new QAction(QIcon(), tr("Boundaries"), this);
showBoundaryColorAct->setStatusTip(
tr("Visualize different boundary parts with color patches"));
connect(showBoundaryColorAct, SIGNAL(triggered()), this,
SLOT(colorizeBoundarySlot()));
showBoundaryColorAct->setCheckable(true);
// View -> Colors -> Bodies
showBodyColorAct = new QAction(QIcon(), tr("Bodies"), this);
showBodyColorAct->setStatusTip(
tr("Visualize different body with color patches"));
connect(showBodyColorAct, SIGNAL(triggered()), this,
SLOT(colorizeBodySlot()));
showBodyColorAct->setCheckable(true);
// View -> Shade model -> Smooth
smoothShadeAct = new QAction(QIcon(), tr("Smooth"), this);
smoothShadeAct->setStatusTip(tr("Set shade model to smooth"));
connect(smoothShadeAct, SIGNAL(triggered()), this, SLOT(smoothShadeSlot()));
smoothShadeAct->setCheckable(true);
// View -> Shade model -> Flat
flatShadeAct = new QAction(QIcon(), tr("Flat"), this);
flatShadeAct->setStatusTip(tr("Set shade model to flat"));
connect(flatShadeAct, SIGNAL(triggered()), this, SLOT(flatShadeSlot()));
flatShadeAct->setCheckable(true);
// View -> Projection -> Orthogonal
orthoAct = new QAction(QIcon(), tr("Orthogonal"), this);
orthoAct->setStatusTip(tr("Set projection to orthogonal"));
connect(orthoAct, SIGNAL(triggered()), this, SLOT(orthoSlot()));
orthoAct->setCheckable(true);
// View -> Projection -> Perspective
perspectiveAct = new QAction(QIcon(), tr("Perspective"), this);
perspectiveAct->setStatusTip(tr("Set projection to perspective"));
connect(perspectiveAct, SIGNAL(triggered()), this, SLOT(perspectiveSlot()));
perspectiveAct->setCheckable(true);
// View -> Show all
showallAct = new QAction(QIcon(), tr("Show all"), this);
showallAct->setStatusTip(tr("Show all objects"));
connect(showallAct, SIGNAL(triggered()), this, SLOT(showallSlot()));
// View -> Reset model view
resetAct = new QAction(QIcon(), tr("Reset model view"), this);
resetAct->setStatusTip(tr("Reset model view"));
connect(resetAct, SIGNAL(triggered()), this, SLOT(resetSlot()));
// View -> Show cad model
showCadModelAct = new QAction(QIcon(), tr("Cad model..."), this);
showCadModelAct->setStatusTip(
tr("Displays the cad model in a separate window"));
connect(showCadModelAct, SIGNAL(triggered()), this, SLOT(showCadModelSlot()));
// View -> Show 2d view
showTwodViewAct = new QAction(QIcon(), tr("2D modeler..."), this);
showTwodViewAct->setStatusTip(
tr("Displays the 2d geometry in a separate window"));
connect(showTwodViewAct, SIGNAL(triggered()), this, SLOT(showTwodViewSlot()));
// View -> Show Object Browser
showObjectBrowserAct = new QAction(QIcon(), tr("Show Object Browser"), this);
showObjectBrowserAct->setStatusTip(tr("Show Object Browser"));
connect(showObjectBrowserAct, SIGNAL(triggered()), this,
SLOT(showObjectBrowserSlot()));
showObjectBrowserAct->setCheckable(true);
// Solver -> Parallel settings
parallelSettingsAct = new QAction(QIcon(), tr("Parallel settings..."), this);
parallelSettingsAct->setStatusTip(
tr("Choose parameters and methods for parallel solution"));
connect(parallelSettingsAct, SIGNAL(triggered()), this,
SLOT(parallelSettingsSlot()));
// Solver -> Run solver
runsolverAct =
new QAction(QIcon(":/icons/Solver.png"), tr("Start solver"), this);
runsolverAct->setStatusTip(tr("Run ElmerSolver"));
connect(runsolverAct, SIGNAL(triggered()), this, SLOT(runsolverSlot()));
// Solver -> Kill solver
killsolverAct =
new QAction(QIcon::fromTheme("dialog-error-round"), tr("Kill solver"), this);
killsolverAct->setStatusTip(tr("Kill ElmerSolver"));
connect(killsolverAct, SIGNAL(triggered()), this, SLOT(killsolverSlot()));
killsolverAct->setEnabled(false);
// Solver -> Show convergence
showConvergenceAct = new QAction(QIcon(), tr("Show convergence"), this);
showConvergenceAct->setStatusTip(tr("Show/hide convergence plot"));
connect(showConvergenceAct, SIGNAL(triggered()), this,
SLOT(showConvergenceSlot()));
showConvergenceAct->setCheckable(true);
// Solver -> Post process
resultsAct =
new QAction(QIcon(":/icons/Post.png"), tr("Start ElmerPost"), this);
resultsAct->setStatusTip(tr("Run ElmerPost for visualization"));
connect(resultsAct, SIGNAL(triggered()), this, SLOT(resultsSlot()));
// Solver -> Kill post process
killresultsAct = new QAction(QIcon::fromTheme("dialog-error-round"),
tr("Kill ElmerPost"), this);
killresultsAct->setStatusTip(tr("Kill ElmerPost"));
connect(killresultsAct, SIGNAL(triggered()), this, SLOT(killresultsSlot()));
killresultsAct->setEnabled(false);
// Solver -> Show Vtk postprocessor
showVtkPostAct = new QAction(QIcon(":/icons/Mesh3D.png"), tr("Start ElmerVTK"), this);
showVtkPostAct->setStatusTip(tr("Invokes VTK based ElmerGUI postprocessor"));
connect(showVtkPostAct, SIGNAL(triggered()), this, SLOT(showVtkPostSlot()));
// Solver -> Show ParaView postprocessor
paraviewAct =
new QAction(QIcon(":/icons/Paraview.png"), tr("Start ParaView"), this);
paraviewAct->setStatusTip(tr("Invokes ParaView for visualization"));
connect(paraviewAct, SIGNAL(triggered()), this, SLOT(showParaViewSlot()));
// Solver -> Compiler...
compileSolverAct = new QAction(QIcon(""), tr("Compiler..."), this);
compileSolverAct->setStatusTip(tr(
"Compile Elmer specific source code (f90) into a shared library (dll)"));
connect(compileSolverAct, SIGNAL(triggered()), this,
SLOT(compileSolverSlot()));
// Help -> About
aboutAct = new QAction(QIcon::fromTheme("emblem-notice"), tr("About..."), this);
aboutAct->setStatusTip(tr("Information about the program"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(showaboutSlot()));
// Help -> Get started
getStartedAct = new QAction(QIcon(""), tr("Get started..."), this);
getStartedAct->setStatusTip(tr("Information to get started"));
connect(getStartedAct, SIGNAL(triggered()), this, SLOT(getStartedSlot()));
generateAndSaveAndRunAct =
new QAction(QIcon::fromTheme("doubletriangle-right"),
tr("&Generate, save and run"), this);
generateAndSaveAndRunAct->setStatusTip(
tr("Generate and save sif, save project, then run solver"));
connect(generateAndSaveAndRunAct, SIGNAL(triggered()), this,
SLOT(generateAndSaveAndRunSlot()));
;
#if WIN32
#else
compileSolverAct->setEnabled(false);
#endif
if (egIni->isSet("bgimage"))
chooseBGColorAct->setEnabled(false);
runPostProcessorAct = new QAction(QIcon(":/icons/Post.png"), tr("ElmerPost"), this);
runPostProcessorAct->setStatusTip(tr("Select ElmerPost as post-processor"));
connect(runPostProcessorAct, SIGNAL(triggered()), this, SLOT(resultsSlot()));
selectElmerPostAct = new QAction(QIcon(":/icons/Post.png"), tr("ElmerPost"), this);
selectElmerPostAct->setStatusTip(tr("Select ElmerPost as post-processor"));
connect(selectElmerPostAct, SIGNAL(triggered()), this, SLOT(selectElmerPostSlot()));
selectElmerPostAct->setCheckable(true);
selectVtkPostAct = new QAction(QIcon(":/icons/Mesh3D.png"), tr("ElmerVTK"), this);
selectVtkPostAct->setStatusTip(tr("Select ElmerVTK as post-processor"));
connect(selectVtkPostAct, SIGNAL(triggered()), this, SLOT(selectVtkPostSlot()));
selectVtkPostAct->setCheckable(true);
selectParaViewAct = new QAction(QIcon(":/icons/Paraview.png"), tr("ParaView"), this);
selectParaViewAct->setStatusTip(tr("Select ParaView as post-processor"));
connect(selectParaViewAct, SIGNAL(triggered()), this, SLOT(selectParaViewSlot()));
selectParaViewAct->setCheckable(true);
}
// Create menus...
//-----------------------------------------------------------------------------
void MainWindow::createMenus() {
// File menu
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newProjectAct);
fileMenu->addAction(loadProjectAct);
recentProjectsMenu = fileMenu->addMenu(tr("&Recent projects"));
recentProjectsMenu->setEnabled(false);
fileMenu->addAction(saveProjectAct);
fileMenu->addAction(saveProjectAct);
fileMenu->addAction(saveProjectAsAct);
fileMenu->addSeparator();
fileMenu->addAction(openAct);
fileMenu->addAction(loadAct);
fileMenu->addAction(saveAct);
fileMenu->addAction(saveAsAct);
fileMenu->addSeparator();
fileMenu->addAction(editDefinitionsAct);
fileMenu->addSeparator();
fileMenu->addAction(savePictureAct);
fileMenu->addSeparator();
fileMenu->addAction(exitAct);
// Mesh menu
meshMenu = menuBar()->addMenu(tr("&Mesh"));
meshMenu->addAction(meshcontrolAct);
meshMenu->addAction(remeshAct);
meshMenu->addAction(stopMeshingAct);
meshMenu->addSeparator();
meshMenu->addAction(surfaceDivideAct);
meshMenu->addAction(surfaceUnifyAct);
meshMenu->addSeparator();
meshMenu->addAction(edgeDivideAct);