Added not yet working vtkinteractorstyle subclass + fixed sigabrt when switching...
[engrid.git] / guimainwindow.cpp
blob1cffd3597ada029ef2b84aaaf0291ff6f41074eb
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "guimainwindow.h"
24 #include "guiselectboundarycodes.h"
25 #include "guiimproveaspectratio.h"
26 #include "guinormalextrusion.h"
27 #include "guisetboundarycode.h"
28 #include "guipick.h"
30 #include "vtkEgPolyDataToUnstructuredGridFilter.h"
31 #include "stlreader.h"
32 #include "gmshreader.h"
33 #include "gmshwriter.h"
34 #include "neutralwriter.h"
35 #include "stlwriter.h"
36 #include "correctsurfaceorientation.h"
37 #include "guieditboundaryconditions.h"
39 #include <vtkRenderer.h>
40 #include <vtkRenderWindow.h>
41 #include <vtkXMLUnstructuredGridWriter.h>
42 #include <vtkXMLUnstructuredGridReader.h>
43 #include <vtkProperty.h>
44 #include <vtkCallbackCommand.h>
45 #include <vtkCamera.h>
46 #include <vtkCharArray.h>
47 #include <vtkTextActor.h>
48 #include <vtkVectorText.h>
49 #include <vtkFollower.h>
51 #include <QFileDialog>
52 #include <QFileSystemWatcher>
53 #include <stdlib.h>
54 #include <stdio.h>
56 #include "geometrytools.h"
57 using namespace GeometryTools;
59 #include "guisettingsviewer.h"
60 #include "guitransform.h"
62 GuiOutputWindow::GuiOutputWindow()
64 ui.setupUi(this);
67 QString GuiMainWindow::cwd = ".";
68 QSettings GuiMainWindow::qset("enGits","enGrid");
69 GuiMainWindow* GuiMainWindow::THIS = NULL;
70 QMutex GuiMainWindow::mutex;
71 vtkIdType GuiMainWindow::PickedPoint;
72 vtkIdType GuiMainWindow::PickedCell;
73 bool GuiMainWindow::m_UseVTKInteractor;
75 GuiMainWindow::GuiMainWindow() : QMainWindow(NULL)
77 ui.setupUi(this);
78 THIS = this;
79 dock_widget = new QDockWidget(tr("output"), this);
80 dock_widget->setFeatures(QDockWidget::AllDockWidgetFeatures);
81 output_window = new GuiOutputWindow();
82 dock_widget->setWidget(output_window);
83 addDockWidget(Qt::LeftDockWidgetArea, dock_widget);
84 ui.menuView->addAction(dock_widget->toggleViewAction());
86 connect(ui.actionImportSTL, SIGNAL(activated()), this, SLOT(importSTL()));
87 connect(ui.actionImportGmsh1Ascii, SIGNAL(activated()), this, SLOT(importGmsh1Ascii()));
88 connect(ui.actionImportGmsh2Ascii, SIGNAL(activated()), this, SLOT(importGmsh2Ascii()));
89 connect(ui.actionExportGmsh1Ascii, SIGNAL(activated()), this, SLOT(exportGmsh1Ascii()));
90 connect(ui.actionExportGmsh2Ascii, SIGNAL(activated()), this, SLOT(exportGmsh2Ascii()));
91 connect(ui.actionExportNeutral, SIGNAL(activated()), this, SLOT(exportNeutral()));
92 connect(ui.actionExportAsciiStl, SIGNAL(activated()), this, SLOT(exportAsciiStl()));
93 connect(ui.actionExportBinaryStl, SIGNAL(activated()), this, SLOT(exportBinaryStl()));
94 connect(ui.actionExit, SIGNAL(activated()), this, SLOT(exit()));
95 connect(ui.actionZoomAll, SIGNAL(activated()), this, SLOT(zoomAll()));
96 connect(ui.actionOpen, SIGNAL(activated()), this, SLOT(open()));
97 connect(ui.actionSave, SIGNAL(activated()), this, SLOT(save()));
98 connect(ui.actionSaveAs, SIGNAL(activated()), this, SLOT(saveAs()));
99 connect(ui.actionBoundaryCodes, SIGNAL(activated()), this, SLOT(selectBoundaryCodes()));
100 connect(ui.actionNormalExtrusion, SIGNAL(activated()), this, SLOT(normalExtrusion()));
101 connect(ui.actionViewAxes, SIGNAL(changed()), this, SLOT(setAxesVisibility()));
102 connect(ui.actionViewOrthogonal, SIGNAL(changed()), this, SLOT(setViewingMode()));
103 connect(ui.actionViewNodeIDs, SIGNAL(changed()), this, SLOT(ViewNodeIDs()));
104 connect(ui.actionViewCellIDs, SIGNAL(changed()), this, SLOT(ViewCellIDs()));
105 connect(ui.actionChangeOrientation, SIGNAL(activated()), this, SLOT(changeSurfaceOrientation()));
106 connect(ui.actionCheckOrientation, SIGNAL(activated()), this, SLOT(checkSurfaceOrientation()));
107 connect(ui.actionImproveAspectRatio, SIGNAL(activated()), this, SLOT(improveAspectRatio()));
108 connect(ui.actionRedraw, SIGNAL(activated()), this, SLOT(updateActors()));
109 connect(ui.actionClearOutputWindow, SIGNAL(activated()), this, SLOT(clearOutput()));
110 connect(ui.actionEditBoundaryConditions, SIGNAL(activated()), this, SLOT(editBoundaryConditions()));
111 connect(ui.actionConfigure, SIGNAL(activated()), this, SLOT(configure()));
112 connect(ui.actionAbout, SIGNAL(activated()), this, SLOT(about()));
113 // connect(ui.checkBox_UseVTKInteractor, SIGNAL(stateChanged()), this, SLOT(setPickMode(ui.checkBox_UseVTKInteractor->isChecked(),ui.radioButton_CellPicker->isChecked())));
115 connect(ui.actionViewXP, SIGNAL(activated()), this, SLOT(viewXP()));
116 connect(ui.actionViewXM, SIGNAL(activated()), this, SLOT(viewXM()));
117 connect(ui.actionViewYP, SIGNAL(activated()), this, SLOT(viewYP()));
118 connect(ui.actionViewYM, SIGNAL(activated()), this, SLOT(viewYM()));
119 connect(ui.actionViewZP, SIGNAL(activated()), this, SLOT(viewZP()));
120 connect(ui.actionViewZM, SIGNAL(activated()), this, SLOT(viewZM()));
123 #include "std_connections.h"
125 if (qset.contains("working_directory")) {
126 cwd = qset.value("working_directory").toString();
128 grid = vtkUnstructuredGrid::New();
129 renderer = vtkRenderer::New();
130 getRenderWindow()->AddRenderer(renderer);
131 surface_actor = vtkActor::New();
132 surface_wire_actor = vtkActor::New();
134 tetra_mapper = vtkPolyDataMapper::New();
135 pyramid_mapper = vtkPolyDataMapper::New();
136 wedge_mapper = vtkPolyDataMapper::New();
137 hexa_mapper = vtkPolyDataMapper::New();
138 volume_wire_mapper = vtkPolyDataMapper::New();
139 surface_mapper = vtkPolyDataMapper::New();
140 surface_wire_mapper = vtkPolyDataMapper::New();
142 backface_property = vtkProperty::New();
144 tetra_actor = NULL;
145 pyramid_actor = NULL;
146 wedge_actor = NULL;
147 hexa_actor = NULL;
148 volume_wire_actor = NULL;
150 surface_filter = vtkGeometryFilter::New();
151 bcodes_filter = vtkEgBoundaryCodesFilter::New();
152 renderer->AddActor(surface_actor);
153 renderer->AddActor(surface_wire_actor);
154 pick_sphere = vtkSphereSource::New();
155 pick_mapper = vtkPolyDataMapper::New();
156 pick_actor = NULL;
158 extr_vol = vtkEgExtractVolumeCells::New();
159 extr_tetras = vtkEgExtractVolumeCells::New();
160 extr_pyramids = vtkEgExtractVolumeCells::New();
161 extr_wedges = vtkEgExtractVolumeCells::New();
162 extr_hexas = vtkEgExtractVolumeCells::New();
164 volume_geometry = vtkGeometryFilter::New();
165 tetra_geometry = vtkGeometryFilter::New();
166 pyramid_geometry = vtkGeometryFilter::New();
167 wedge_geometry = vtkGeometryFilter::New();
168 hexa_geometry = vtkGeometryFilter::New();
170 extr_tetras->SetAllOff();
171 extr_tetras->SetTetrasOn();
172 extr_pyramids->SetAllOff();
173 extr_pyramids->SetPyramidsOn();
174 extr_wedges->SetAllOff();
175 extr_wedges->SetWedgesOn();
176 extr_hexas->SetAllOff();
177 extr_hexas->SetHexasOn();
179 boundary_pd = vtkPolyData::New();
180 tetras_pd = vtkPolyData::New();
181 wedges_pd = vtkPolyData::New();
182 pyras_pd = vtkPolyData::New();
183 hexas_pd = vtkPolyData::New();
184 volume_pd = vtkPolyData::New();
186 current_filename = "untitled.vtu";
187 setWindowTitle(current_filename + " - enGrid");
189 status_bar = new QStatusBar(this);
190 setStatusBar(status_bar);
191 status_label = new QLabel(this);
192 status_bar->addWidget(status_label);
193 QString txt = "0 volume cells (0 tetras, 0 hexas, 0 pyramids, 0 prisms), ";
194 txt += "0 surface cells (0 triangles, 0 quads), 0 nodes";
195 status_label->setText(txt);
197 axes = vtkCubeAxesActor2D::New();
198 axes->SetCamera(getRenderer()->GetActiveCamera());
199 getRenderer()->AddActor(axes);
200 setAxesVisibility();
202 CellPicker = vtkCellPicker::New();
203 // getInteractor()->SetPicker(CellPicker);
204 PointPicker = vtkPointPicker::New();
205 // getInteractor()->SetPicker(PointPicker);
207 ui.radioButton_CellPicker->setChecked(true);
208 pick_sphere->SetRadius(0.25);//in case the user starts picking points instead of cells
210 vtkCallbackCommand *cbc = vtkCallbackCommand::New();
211 cbc->SetCallback(pickCellCallBack);
212 CellPicker->AddObserver(vtkCommand::EndPickEvent, cbc);
213 cbc->SetCallback(pickPointCallBack);
214 PointPicker->AddObserver(vtkCommand::EndPickEvent, cbc);
215 cbc->Delete();
217 QString user = QString(getenv("USER"));
218 QString basename="enGrid_output_"+user+".txt";
220 if (qset.contains("tmp_directory")) {
221 log_file_name = qset.value("tmp_directory").toString() + "/" + basename;
222 } else {
223 log_file_name = "/tmp/" + basename;
225 system_stdout = stdout;
226 freopen (log_file_name.toAscii().data(), "w", stdout);
228 busy = false;
229 updateStatusBar();
231 connect(&garbage_timer, SIGNAL(timeout()), this, SLOT(periodicUpdate()));
232 garbage_timer.start(1000);
234 connect(&log_timer, SIGNAL(timeout()), this, SLOT(updateOutput()));
235 log_timer.start(1000);
237 N_chars = 0;
239 bool exp_features;
240 getSet("","enable experimental features",false,exp_features);
241 ui.actionFoamWriter->setEnabled(exp_features);
243 ReferenceSize=0.2;
245 ui.checkBox_UseVTKInteractor->setCheckState(Qt::Checked);
246 setPickMode(true,true);
247 PickedPoint=-1;
248 PickedCell=-1;
251 GuiMainWindow::~GuiMainWindow()
255 void GuiMainWindow::updateOutput()
257 QFile log_file(log_file_name);
258 log_file.open(QIODevice::ReadOnly);
259 QByteArray buffer = log_file.readAll();
260 if (buffer.size() > N_chars) {
261 QByteArray newchars = buffer.right(buffer.size() - N_chars);
262 N_chars = buffer.size();
263 QString txt(newchars);
264 if (txt.right(1) == "\n") {
265 txt = txt.left(txt.size()-1);
267 output_window->ui.textEditOutput->append(txt);
271 void GuiMainWindow::exit()
273 QCoreApplication::exit();
276 vtkRenderWindow* GuiMainWindow::getRenderWindow()
278 return ui.qvtkWidget->GetRenderWindow();
281 vtkRenderer* GuiMainWindow::getRenderer()
283 return renderer;
286 QVTKInteractor* GuiMainWindow::getInteractor()
288 return ui.qvtkWidget->GetInteractor();
291 QString GuiMainWindow::getCwd()
293 return cwd;
296 void GuiMainWindow::setCwd(QString dir)
298 cwd = dir;
299 qset.setValue("working_directory",dir);
302 void GuiMainWindow::updateActors()
304 if (!tryLock()) return;
305 try {
308 if (!grid->GetCellData()->GetScalars("cell_index")) {
309 EG_VTKSP(vtkLongArray_t, cell_idx);
310 cell_idx->SetName("cell_index");
311 cell_idx->SetNumberOfValues(grid->GetNumberOfCells());
312 grid->GetCellData()->AddArray(cell_idx);
315 EG_VTKDCC(vtkLongArray_t, cell_index, grid, "cell_index");
316 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
317 cell_index->SetValue(cellId, cellId);
321 axes->SetInput(grid);
323 double xmin = 1e99;
324 double xmax = -1e99;
325 double ymin = 1e99;
326 double ymax = -1e99;
327 double zmin = 1e99;
328 double zmax = -1e99;
329 for (vtkIdType nodeId = 0; nodeId < grid->GetNumberOfPoints(); ++nodeId) {
330 vec3_t x;
331 grid->GetPoints()->GetPoint(nodeId, x.data());
332 xmin = min(x[0], xmin);
333 xmax = max(x[0], xmax);
334 ymin = min(x[1], ymin);
335 ymax = max(x[1], ymax);
336 zmin = min(x[2], zmin);
337 zmax = max(x[2], zmax);
340 if (surface_actor) {
341 getRenderer()->RemoveActor(surface_actor);
342 surface_actor->Delete();
343 surface_actor = NULL;
345 if (surface_wire_actor) {
346 getRenderer()->RemoveActor(surface_wire_actor);
347 surface_wire_actor->Delete();
348 surface_wire_actor = NULL;
350 if (tetra_actor) {
351 getRenderer()->RemoveActor(tetra_actor);
352 tetra_actor->Delete();
353 tetra_actor = NULL;
355 if (pyramid_actor) {
356 getRenderer()->RemoveActor(pyramid_actor);
357 pyramid_actor->Delete();
358 pyramid_actor = NULL;
360 if (wedge_actor) {
361 getRenderer()->RemoveActor(wedge_actor);
362 wedge_actor->Delete();
363 wedge_actor = NULL;
365 if (hexa_actor) {
366 getRenderer()->RemoveActor(hexa_actor);
367 hexa_actor->Delete();
368 hexa_actor = NULL;
370 if (volume_wire_actor) {
371 getRenderer()->RemoveActor(volume_wire_actor);
372 volume_wire_actor->Delete();
373 volume_wire_actor = NULL;
375 if (pick_actor) {
376 getRenderer()->RemoveActor(pick_actor);
377 pick_actor->Delete();
378 pick_actor = NULL;
381 if (ui.checkBoxSurface->isChecked()) {
382 bcodes_filter->SetBoundaryCodes(&display_boundary_codes);
383 bcodes_filter->SetInput(grid);
384 surface_filter->SetInput(bcodes_filter->GetOutput());
385 surface_filter->Update();
386 boundary_pd->DeepCopy(surface_filter->GetOutput());
387 surface_mapper->SetInput(boundary_pd);
388 surface_wire_mapper->SetInput(boundary_pd);
389 surface_actor = vtkActor::New();
390 surface_actor->GetProperty()->SetRepresentationToSurface();
391 surface_actor->GetProperty()->SetColor(0.5,1,0.5);
392 surface_actor->SetBackfaceProperty(backface_property);
393 surface_actor->GetBackfaceProperty()->SetColor(1,1,0.5);
394 surface_wire_actor = vtkActor::New();
395 surface_wire_actor->GetProperty()->SetRepresentationToWireframe();
396 surface_wire_actor->GetProperty()->SetColor(0,0,1);
397 surface_actor->SetMapper(surface_mapper);
398 surface_wire_actor->SetMapper(surface_wire_mapper);
399 getRenderer()->AddActor(surface_actor);
400 getRenderer()->AddActor(surface_wire_actor);
401 bcodes_filter->Update();
403 if(ui.checkBox_UseVTKInteractor->isChecked())
405 if(ui.radioButton_CellPicker->isChecked())
407 // CellPicker->Pick(0,0,0, getRenderer());
408 getInteractor()->SetPicker(CellPicker);
409 // CellPicker->Pick(0,0,0, getRenderer());
410 vtkIdType cellId = getPickedCell();
411 pickCell(cellId);
413 else
415 getInteractor()->SetPicker(PointPicker);
416 vtkIdType nodeId = getPickedPoint();
417 pickPoint(nodeId);
420 else
422 if(ui.radioButton_CellPicker->isChecked()) pickCell(PickedCell);
423 else pickPoint(PickedPoint);
425 /* getInteractor()->SetPicker(CellPicker);
426 vtkIdType cellId = getPickedCell();
427 pickCell(cellId);
428 getInteractor()->SetPicker(PointPicker);
429 vtkIdType nodeId = getPickedPoint();
430 pickPoint(nodeId);*/
434 vec3_t x, n;
435 x[0] = ui.lineEditClipX->text().toDouble();
436 x[1] = ui.lineEditClipY->text().toDouble();
437 x[2] = ui.lineEditClipZ->text().toDouble();
438 n[0] = ui.lineEditClipNX->text().toDouble();
439 n[1] = ui.lineEditClipNY->text().toDouble();
440 n[2] = ui.lineEditClipNZ->text().toDouble();
441 n.normalise();
442 x = x + ui.lineEditOffset->text().toDouble()*n;
443 extr_vol->SetAllOff();
444 if (ui.checkBoxTetra->isChecked()) {
445 extr_vol->SetTetrasOn();
446 extr_tetras->SetInput(grid);
447 if (ui.checkBoxClip->isChecked()) {
448 extr_tetras->SetClippingOn();
449 extr_tetras->SetX(x);
450 extr_tetras->SetN(n);
451 } else {
452 extr_tetras->SetClippingOff();
454 tetra_actor = vtkActor::New();
455 tetra_geometry->SetInput(extr_tetras->GetOutput());
456 tetra_geometry->Update();
457 tetras_pd->DeepCopy(tetra_geometry->GetOutput());
458 tetra_mapper->SetInput(tetras_pd);
459 tetra_actor = vtkActor::New();
460 tetra_actor->SetMapper(tetra_mapper);
461 tetra_actor->GetProperty()->SetColor(1,0,0);
462 getRenderer()->AddActor(tetra_actor);
464 if (ui.checkBoxPyramid->isChecked()) {
465 extr_vol->SetPyramidsOn();
466 extr_pyramids->SetInput(grid);
467 if (ui.checkBoxClip->isChecked()) {
468 extr_pyramids->SetClippingOn();
469 extr_pyramids->SetX(x);
470 extr_pyramids->SetN(n);
471 } else {
472 extr_pyramids->SetClippingOff();
474 pyramid_actor = vtkActor::New();
475 pyramid_geometry->SetInput(extr_pyramids->GetOutput());
476 pyramid_geometry->Update();
477 pyras_pd->DeepCopy(pyramid_geometry->GetOutput());
478 pyramid_mapper->SetInput(pyras_pd);
479 pyramid_actor = vtkActor::New();
480 pyramid_actor->SetMapper(pyramid_mapper);
481 pyramid_actor->GetProperty()->SetColor(1,1,0);
482 getRenderer()->AddActor(pyramid_actor);
484 if (ui.checkBoxWedge->isChecked()) {
485 extr_vol->SetWedgesOn();
486 extr_wedges->SetInput(grid);
487 if (ui.checkBoxClip->isChecked()) {
488 extr_wedges->SetClippingOn();
489 extr_wedges->SetX(x);
490 extr_wedges->SetN(n);
491 } else {
492 extr_wedges->SetClippingOff();
494 wedge_actor = vtkActor::New();
495 wedge_geometry->SetInput(extr_wedges->GetOutput());
496 wedge_geometry->Update();
497 wedges_pd->DeepCopy(wedge_geometry->GetOutput());
498 wedge_mapper->SetInput(wedges_pd);
499 wedge_actor = vtkActor::New();
500 wedge_actor->SetMapper(wedge_mapper);
501 wedge_actor->GetProperty()->SetColor(0,1,0);
502 getRenderer()->AddActor(wedge_actor);
504 if (ui.checkBoxHexa->isChecked()) {
505 extr_vol->SetHexasOn();
506 extr_hexas->SetInput(grid);
507 if (ui.checkBoxClip->isChecked()) {
508 extr_hexas->SetClippingOn();
509 extr_hexas->SetX(x);
510 extr_hexas->SetN(n);
511 } else {
512 extr_hexas->SetClippingOff();
514 hexa_actor = vtkActor::New();
515 hexa_geometry->SetInput(extr_hexas->GetOutput());
516 hexa_geometry->Update();
517 hexas_pd->DeepCopy(hexa_geometry->GetOutput());
518 hexa_mapper->SetInput(hexas_pd);
519 hexa_actor = vtkActor::New();
520 hexa_actor->SetMapper(hexa_mapper);
521 hexa_actor->GetProperty()->SetColor(0,0.7,1);
522 getRenderer()->AddActor(hexa_actor);
525 // wireframe
526 extr_vol->SetInput(grid);
527 if (ui.checkBoxClip->isChecked()) {
528 extr_vol->SetClippingOn();
529 extr_vol->SetX(x);
530 extr_vol->SetN(n);
531 } else {
532 extr_vol->SetClippingOff();
534 volume_wire_actor = vtkActor::New();
535 volume_geometry->SetInput(extr_vol->GetOutput());
536 volume_geometry->Update();
537 volume_pd->DeepCopy(volume_geometry->GetOutput());
538 volume_wire_mapper->SetInput(volume_pd);
539 volume_wire_actor->SetMapper(volume_wire_mapper);
540 volume_wire_actor->GetProperty()->SetRepresentationToWireframe();
541 volume_wire_actor->GetProperty()->SetColor(0,0,1);
542 getRenderer()->AddActor(volume_wire_actor);
545 updateStatusBar();
546 getRenderWindow()->Render();
547 } catch (Error err) {
548 err.display();
550 unlock();
553 void GuiMainWindow::setPickMode(bool a_UseVTKInteractor,bool a_CellPickerMode)
555 m_UseVTKInteractor=a_UseVTKInteractor;
556 if(a_UseVTKInteractor) ui.checkBox_UseVTKInteractor->setCheckState(Qt::Checked);
557 else ui.checkBox_UseVTKInteractor->setCheckState(Qt::Unchecked);
558 if(a_CellPickerMode) ui.radioButton_CellPicker->toggle();
559 else ui.radioButton_PointPicker->toggle();
560 cout<<"m_UseVTKInteractor="<<m_UseVTKInteractor<<endl;
563 bool GuiMainWindow::pickPoint(vtkIdType nodeId)
565 if (nodeId >= 0 && nodeId<grid->GetNumberOfPoints()) {
566 vec3_t x(0,0,0);
567 grid->GetPoints()->GetPoint(nodeId, x.data());
568 pick_sphere->SetCenter(x.data());
569 pick_mapper->SetInput(pick_sphere->GetOutput());
570 pick_actor = vtkActor::New();
571 pick_actor->SetMapper(pick_mapper);
572 pick_actor->GetProperty()->SetRepresentationToSurface();
573 pick_actor->GetProperty()->SetColor(0,0,1);
574 getRenderer()->AddActor(pick_actor);
575 PickedPoint=nodeId;
576 return(true);
578 else return(false);
581 bool GuiMainWindow::pickCell(vtkIdType cellId)
583 if (cellId >= 0 && cellId<grid->GetNumberOfCells()) {
584 vtkIdType *pts, Npts;
585 grid->GetCellPoints(cellId, Npts, pts);
586 vec3_t x(0,0,0);
587 for (vtkIdType i = 0; i < Npts; ++i) {
588 vec3_t xp;
589 grid->GetPoints()->GetPoint(pts[i], xp.data());
590 x += double(1)/Npts * xp;
592 pick_sphere->SetCenter(x.data());
593 double R = 1e99;
594 for (vtkIdType i = 0; i < Npts; ++i) {
595 vec3_t xp;
596 grid->GetPoints()->GetPoint(pts[i], xp.data());
597 R = min(R, 0.25*(xp-x).abs());
599 ReferenceSize=R;//Used for text annotations too!
600 pick_sphere->SetRadius(R);
601 pick_mapper->SetInput(pick_sphere->GetOutput());
602 pick_actor = vtkActor::New();
603 pick_actor->SetMapper(pick_mapper);
604 pick_actor->GetProperty()->SetRepresentationToSurface();
605 pick_actor->GetProperty()->SetColor(1,0,0);
606 getRenderer()->AddActor(pick_actor);
607 PickedCell=cellId;
608 return(true);
610 else return(false);
613 void GuiMainWindow::importSTL()
615 StlReader stl;
616 stl();
617 updateBoundaryCodes(true);
618 updateActors();
619 updateStatusBar();
620 zoomAll();
623 void GuiMainWindow::importGmsh1Ascii()
625 GmshReader gmsh;
626 gmsh.setV1Ascii();
627 gmsh();
628 updateBoundaryCodes(true);
629 updateActors();
630 updateStatusBar();
631 zoomAll();
634 void GuiMainWindow::exportGmsh1Ascii()
636 GmshWriter gmsh;
637 gmsh.setV1Ascii();
638 gmsh();
641 void GuiMainWindow::importGmsh2Ascii()
643 GmshReader gmsh;
644 gmsh.setV2Ascii();
645 gmsh();
646 updateBoundaryCodes(true);
647 updateActors();
648 updateStatusBar();
649 zoomAll();
652 void GuiMainWindow::exportGmsh2Ascii()
654 GmshWriter gmsh;
655 gmsh.setV2Ascii();
656 gmsh();
659 void GuiMainWindow::exportNeutral()
661 NeutralWriter neutral;
662 neutral();
665 void GuiMainWindow::zoomAll()
667 getRenderer()->ResetCamera();
668 getRenderWindow()->Render();
671 void GuiMainWindow::open()
673 current_filename = QFileDialog::getOpenFileName
675 NULL,
676 "open grid from file",
677 getCwd(),
678 "VTK unstructured grid files (*.vtu *.VTU)"
680 if (!current_filename.isNull()) {
681 GuiMainWindow::setCwd(QFileInfo(current_filename).absolutePath());
682 EG_VTKSP(vtkXMLUnstructuredGridReader,vtu);
683 vtu->SetFileName(current_filename.toAscii().data());
684 vtu->Update();
685 grid->DeepCopy(vtu->GetOutput());
686 createBasicFields(grid, grid->GetNumberOfCells(), grid->GetNumberOfPoints(), false);
687 setWindowTitle(current_filename + " - enGrid");
688 openBC();
689 updateBoundaryCodes(true);
690 updateActors();
691 updateStatusBar();
692 zoomAll();
696 void GuiMainWindow::undo()
700 void GuiMainWindow::redo()
704 void GuiMainWindow::openBC()
706 QString bc_file = current_filename + ".bcs";
707 QFile file(bc_file);
708 bcmap.clear();
709 if (file.exists()) {
710 file.open(QIODevice::ReadOnly | QIODevice::Text);
711 QTextStream f(&file);
712 while (!f.atEnd()) {
713 QString name, type;
714 int i;
715 f >> i >> name >> type;
716 bcmap[i] = BoundaryCondition(name,type);
721 void GuiMainWindow::saveBC()
723 QString bc_file = current_filename + ".bcs";
724 QFile file(bc_file);
725 file.open(QIODevice::WriteOnly | QIODevice::Text);
726 QTextStream f(&file);
727 foreach(int i, all_boundary_codes) {
728 BoundaryCondition bc = bcmap[i];
729 f << i << " " << bc.getName() << " " << bc.getType() << "\n";
733 void GuiMainWindow::save()
735 cout << current_filename.toAscii().data() << endl;
736 if (current_filename == "untitled.vtu") {
737 saveAs();
738 } else {
739 EG_VTKDCC(vtkDoubleArray, cell_VA, grid, "cell_VA");
740 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
741 cell_VA->SetValue(cellId, GeometryTools::cellVA(grid, cellId, true));
743 EG_VTKSP(vtkXMLUnstructuredGridWriter,vtu);
744 addVtkTypeInfo();
745 createIndices(grid);
746 vtu->SetFileName(current_filename.toAscii().data());
747 vtu->SetDataModeToBinary();
748 vtu->SetInput(grid);
749 vtu->Write();
750 saveBC();
754 void GuiMainWindow::saveAs()
756 current_filename = QFileDialog::getSaveFileName
758 NULL,
759 "write grid to file",
760 getCwd(),
761 "VTK unstructured grid files (*.vtu *.VTU)"
763 if (!current_filename.isNull()) {
764 if (current_filename.right(4) != ".vtu") {
765 if (current_filename.right(4) != ".VTU") {
766 current_filename += ".vtu";
769 EG_VTKDCC(vtkDoubleArray, cell_VA, grid, "cell_VA");
770 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
771 cell_VA->SetValue(cellId, GeometryTools::cellVA(grid, cellId, true));
773 GuiMainWindow::setCwd(QFileInfo(current_filename).absolutePath());
774 EG_VTKSP(vtkXMLUnstructuredGridWriter,vtu);
775 addVtkTypeInfo();
776 createIndices(grid);
777 vtu->SetFileName(current_filename.toAscii().data());
778 vtu->SetDataModeToBinary();
779 vtu->SetInput(grid);
780 vtu->Write();
781 saveBC();
782 setWindowTitle(current_filename + " - enGrid");
786 void GuiMainWindow::updateStatusBar()
788 QString num, txt = "enGrid is currently busy with an operation ...";
789 if (!busy) {
790 txt = "";
792 if (!tryLock()) {
793 status_label->setText(txt);
794 return;
796 vtkIdType Ncells = grid->GetNumberOfCells();
797 vtkIdType Nnodes = grid->GetNumberOfPoints();
798 vtkIdType Ntris = 0;
799 vtkIdType Nquads = 0;
800 vtkIdType Ntets = 0;
801 vtkIdType Npyras = 0;
802 vtkIdType Nprism = 0;
803 vtkIdType Nhexas = 0;
804 for (vtkIdType i = 0; i < Ncells; ++i) {
805 int ct = grid->GetCellType(i);
806 if (ct == VTK_TRIANGLE) ++Ntris;
807 else if (ct == VTK_QUAD) ++Nquads;
808 else if (ct == VTK_TETRA) ++Ntets;
809 else if (ct == VTK_WEDGE) ++Nprism;
810 else if (ct == VTK_PYRAMID) ++Npyras;
811 else if (ct == VTK_HEXAHEDRON) ++Nhexas;
813 num.setNum(Ntets + Npyras + Nprism + Nhexas); txt += num + " volume cells(";
814 num.setNum(Ntets); txt += num + " tetras, ";
815 num.setNum(Npyras); txt += num + " pyramids, ";
816 num.setNum(Nprism); txt += num + " prisms, ";
817 num.setNum(Nhexas); txt += num + " hexas), ";
818 num.setNum(Ntris + Nquads); txt += num + " surface cells(";
819 num.setNum(Ntris); txt += num + " triangles, ";
820 num.setNum(Nquads); txt += num + " quads), ";
821 num.setNum(Nnodes); txt += num + " nodes";
823 if(ui.radioButton_CellPicker->isChecked())
825 QString pick_txt = ", picked cell: ";
826 vtkIdType id_cell = getPickedCell();
827 if (id_cell < 0) {
828 pick_txt += "no cell picked";
829 } else {
830 vtkIdType type_cell = grid->GetCellType(id_cell);
831 if (type_cell == VTK_TRIANGLE) pick_txt += "triangle";
832 else if (type_cell == VTK_QUAD) pick_txt += "quad";
833 else if (type_cell == VTK_TETRA) pick_txt += "tetrahedron";
834 else if (type_cell == VTK_PYRAMID) pick_txt += "pyramid";
835 else if (type_cell == VTK_WEDGE) pick_txt += "prism";
836 else if (type_cell == VTK_HEXAHEDRON) pick_txt += "hexahedron";
837 vtkIdType N_pts, *pts;
838 grid->GetCellPoints(id_cell, N_pts, pts);
839 pick_txt += " [";
840 for (int i_pts = 0; i_pts < N_pts; ++i_pts) {
841 QString num;
842 num.setNum(pts[i_pts]);
843 pick_txt += num;
844 if (i_pts < N_pts-1) {
845 pick_txt += ",";
848 pick_txt += "]";
849 QString tmp;
850 tmp.setNum(id_cell);
851 pick_txt += " id_cell=" + tmp;
853 txt += pick_txt;
855 else
857 QString pick_txt = ", picked node: ";
858 vtkIdType id_node = getPickedPoint();
859 if (id_node < 0) {
860 pick_txt += "no node picked";
861 } else {
862 vec3_t x;
863 grid->GetPoints()->GetPoint(id_node,x.data());
864 pick_txt += " [";
865 for (int i = 0; i < 3; i++) {
866 QString num;
867 num.setNum(x[i]);
868 pick_txt += num;
869 if (i < 2) {
870 pick_txt += ",";
873 pick_txt += "]";
874 QString tmp;
875 tmp.setNum(id_node);
876 pick_txt += " id_node=" + tmp;
877 EG_VTKDCN(vtkDoubleArray, node_meshdensity, grid, "node_meshdensity");
878 tmp.setNum(node_meshdensity->GetValue(id_node));
879 pick_txt += " wanted density=" + tmp;
880 EG_VTKDCN(vtkDoubleArray, node_meshdensity_current, grid, "node_meshdensity_current");
881 tmp.setNum(node_meshdensity_current->GetValue(id_node));
882 pick_txt += " current density=" + tmp;
883 EG_VTKDCN(vtkCharArray, node_type, grid, "node_type");
884 pick_txt += " type=" + QString(VertexType2Str( node_type->GetValue(id_node)));
887 txt += pick_txt;
890 status_label->setText(txt);
891 unlock();
894 void GuiMainWindow::selectBoundaryCodes()
896 GuiSelectBoundaryCodes bcodes;
897 bcodes.setDisplayBoundaryCodes(display_boundary_codes);
898 bcodes.setBoundaryCodes(all_boundary_codes);
899 bcodes();
900 bcodes.getThread().wait();
901 bcodes.getSelectedBoundaryCodes(display_boundary_codes);
902 updateActors();
905 void GuiMainWindow::updateBoundaryCodes(bool all_on)
907 try {
908 all_boundary_codes.clear();
909 EG_VTKDCC(vtkIntArray, cell_code, grid, "cell_code");
910 for (vtkIdType i = 0; i < grid->GetNumberOfCells(); ++i) {
911 int ct = grid->GetCellType(i);
912 if ((ct == VTK_TRIANGLE) || (ct == VTK_QUAD)) {
913 all_boundary_codes.insert(cell_code->GetValue(i));
916 if (all_on) {
917 display_boundary_codes.clear();
918 foreach (int bc, all_boundary_codes) {
919 display_boundary_codes.insert(bc);
921 } else {
922 QSet<int> dbcs;
923 foreach (int bc, display_boundary_codes) {
924 if (all_boundary_codes.contains(bc)) {
925 dbcs.insert(bc);
928 display_boundary_codes.clear();
929 foreach (int bc, all_boundary_codes) {
930 if (dbcs.contains(bc)) {
931 display_boundary_codes.insert(bc);
935 } catch (Error err) {
936 err.display();
940 void GuiMainWindow::normalExtrusion()
942 GuiNormalExtrusion extr;
943 extr();
944 updateBoundaryCodes(false);
945 updateActors();
948 void GuiMainWindow::setAxesVisibility()
950 if (ui.actionViewAxes->isChecked()) axes->SetVisibility(1);
951 else axes->SetVisibility(0);
952 getRenderWindow()->Render();
955 void GuiMainWindow::setViewingMode()
957 if (ui.actionViewOrthogonal->isChecked()) getRenderer()->GetActiveCamera()->ParallelProjectionOn();
958 else getRenderer()->GetActiveCamera()->ParallelProjectionOff();
959 getRenderWindow()->Render();
962 void GuiMainWindow::ViewNodeIDs()
964 int N=grid->GetNumberOfPoints();
965 cout<<"N="<<N<<endl;
966 if (ui.actionViewNodeIDs->isChecked()) {
967 cout<<"Activating node ID view"<<endl;
968 NodeText_VectorText.resize(N);
969 NodeText_PolyDataMapper.resize(N);
970 NodeText_Follower.resize(N);
971 for(int i=0;i<N;i++){
972 NodeText_VectorText[i]=vtkVectorText::New();
973 QString tmp;
974 tmp.setNum(i);
975 NodeText_VectorText[i]->SetText(tmp.toLatin1().data());
976 NodeText_PolyDataMapper[i]=vtkPolyDataMapper::New();
977 NodeText_PolyDataMapper[i]->SetInputConnection(NodeText_VectorText[i]->GetOutputPort());
978 NodeText_Follower[i]=vtkFollower::New();
979 NodeText_Follower[i]->SetMapper(NodeText_PolyDataMapper[i]);
980 NodeText_Follower[i]->SetScale(ReferenceSize,ReferenceSize,ReferenceSize);
981 vec3_t M;
982 grid->GetPoint(i,M.data());
983 NodeText_Follower[i]->AddPosition(M[0],M[1],M[2]+ReferenceSize);
984 NodeText_Follower[i]->SetCamera(getRenderer()->GetActiveCamera());
985 NodeText_Follower[i]->GetProperty()->SetColor(0,0,1);
986 getRenderer()->AddActor(NodeText_Follower[i]);
989 else {
990 cout<<"Deactivating node ID view"<<endl;
991 for(unsigned int i=0;i<NodeText_Follower.size();i++){
992 getRenderer()->RemoveActor(NodeText_Follower[i]);
993 NodeText_Follower[i]->Delete();
994 NodeText_PolyDataMapper[i]->Delete();
995 NodeText_VectorText[i]->Delete();
997 NodeText_Follower.clear();
998 NodeText_PolyDataMapper.clear();
999 NodeText_VectorText.clear();
1002 getRenderWindow()->Render();
1005 void GuiMainWindow::ViewCellIDs()
1007 int N=grid->GetNumberOfCells();
1008 cout<<"N="<<N<<endl;
1009 if (ui.actionViewCellIDs->isChecked()) {
1010 cout<<"Activating cell ID view"<<endl;
1011 CellText_VectorText.resize(N);
1012 CellText_PolyDataMapper.resize(N);
1013 CellText_Follower.resize(N);
1014 for(int i=0;i<N;i++){
1015 CellText_VectorText[i]=vtkVectorText::New();
1016 QString tmp;
1017 tmp.setNum(i);
1018 CellText_VectorText[i]->SetText(tmp.toLatin1().data());
1019 CellText_PolyDataMapper[i]=vtkPolyDataMapper::New();
1020 CellText_PolyDataMapper[i]->SetInputConnection(CellText_VectorText[i]->GetOutputPort());
1021 CellText_Follower[i]=vtkFollower::New();
1022 CellText_Follower[i]->SetMapper(CellText_PolyDataMapper[i]);
1023 CellText_Follower[i]->SetScale(ReferenceSize,ReferenceSize,ReferenceSize);
1024 vtkIdType N_pts,*pts;
1025 grid->GetCellPoints(i,N_pts,pts);
1026 vec3_t Center(0,0,0);
1027 for(int p=0;p<N_pts;p++)
1029 vec3_t M;
1030 grid->GetPoint(pts[p],M.data());
1031 Center+=M.data();
1033 vec3_t OffSet=ReferenceSize*triNormal(grid,pts[0],pts[1],pts[2]).normalise();
1034 Center=1.0/(double)N_pts*Center+OffSet;
1035 CellText_Follower[i]->AddPosition(Center[0],Center[1],Center[2]);
1036 CellText_Follower[i]->SetCamera(getRenderer()->GetActiveCamera());
1037 CellText_Follower[i]->GetProperty()->SetColor(1,0,0);
1038 getRenderer()->AddActor(CellText_Follower[i]);
1041 else {
1042 cout<<"Deactivating cell ID view"<<endl;
1043 for(unsigned int i=0;i<CellText_Follower.size();i++){
1044 getRenderer()->RemoveActor(CellText_Follower[i]);
1045 CellText_Follower[i]->Delete();
1046 CellText_PolyDataMapper[i]->Delete();
1047 CellText_VectorText[i]->Delete();
1049 CellText_Follower.clear();
1050 CellText_PolyDataMapper.clear();
1051 CellText_VectorText.clear();
1054 getRenderWindow()->Render();
1057 void GuiMainWindow::addVtkTypeInfo()
1059 EG_VTKSP(vtkIntArray, vtk_type);
1060 vtk_type->SetName("vtk_type");
1061 vtk_type->SetNumberOfValues(grid->GetNumberOfCells());
1062 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
1063 vtk_type->SetValue(cellId, grid->GetCellType(cellId));
1065 grid->GetCellData()->AddArray(vtk_type);
1068 void GuiMainWindow::pickCellCallBack
1070 vtkObject *caller,
1071 unsigned long int eid,
1072 void *clientdata,
1073 void *calldata
1076 caller = caller;
1077 eid = eid;
1078 clientdata = clientdata;
1079 calldata = calldata;
1080 THIS->updateActors();
1081 THIS->updateStatusBar();
1084 void GuiMainWindow::pickPointCallBack
1086 vtkObject *caller,
1087 unsigned long int eid,
1088 void *clientdata,
1089 void *calldata
1092 caller = caller;
1093 eid = eid;
1094 clientdata = clientdata;
1095 calldata = calldata;
1096 THIS->updateActors();
1097 THIS->updateStatusBar();
1100 vtkIdType GuiMainWindow::getPickedCell()
1102 vtkIdType picked_cell = -1;
1103 if (THIS->grid->GetNumberOfCells() > 0) {
1104 THIS->bcodes_filter->Update();
1105 EG_VTKDCC(vtkLongArray_t, cell_index, THIS->bcodes_filter->GetOutput(), "cell_index");
1107 vtkIdType cellId;
1108 if(m_UseVTKInteractor) cellId = THIS->CellPicker->GetCellId();
1109 else cellId = PickedCell;
1111 if (cellId >= 0) {
1112 if (cellId < THIS->bcodes_filter->GetOutput()->GetNumberOfCells()) {
1113 picked_cell = cell_index->GetValue(cellId);
1117 return picked_cell;
1120 vtkIdType GuiMainWindow::getPickedPoint()
1122 vtkIdType picked_point = -1;
1123 if (THIS->grid->GetNumberOfCells() > 0) {
1124 THIS->bcodes_filter->Update();
1126 vtkIdType pointId;
1127 if(m_UseVTKInteractor) pointId = THIS->PointPicker->GetPointId();
1128 else pointId = PickedPoint;
1130 if (pointId >= 0) {
1131 picked_point = pointId;
1134 return picked_point;
1137 void GuiMainWindow::changeSurfaceOrientation()
1139 for (vtkIdType cellId = 0; cellId < grid->GetNumberOfCells(); ++cellId) {
1140 vtkIdType Npts, *pts;
1141 grid->GetCellPoints(cellId, Npts, pts);
1142 QVector<vtkIdType> nodes(Npts);
1143 for (vtkIdType j = 0; j < Npts; ++j) nodes[j] = pts[j];
1144 for (vtkIdType j = 0; j < Npts; ++j) pts[Npts - j - 1] = nodes[j];
1146 updateActors();
1149 void GuiMainWindow::checkSurfaceOrientation()
1151 CorrectSurfaceOrientation corr_surf;
1152 vtkIdType picked_cell = getPickedCell();
1153 if (picked_cell >= 0) {
1154 corr_surf.setStart(picked_cell);
1156 corr_surf();
1157 updateActors();
1160 void GuiMainWindow::improveAspectRatio()
1162 GuiImproveAspectRatio impr_ar;
1163 impr_ar();
1164 updateActors();
1167 void GuiMainWindow::exportAsciiStl()
1169 StlWriter stl;
1170 stl();
1173 void GuiMainWindow::exportBinaryStl()
1177 void GuiMainWindow::periodicUpdate()
1179 Operation::collectGarbage();
1180 updateStatusBar();
1183 void GuiMainWindow::viewXP()
1185 getRenderer()->ResetCamera();
1186 double x[3];
1187 getRenderer()->GetActiveCamera()->GetFocalPoint(x);
1188 x[0] += 1;
1189 getRenderer()->GetActiveCamera()->SetPosition(x);
1190 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1191 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1192 getRenderer()->ResetCamera();
1193 getRenderWindow()->Render();
1196 void GuiMainWindow::viewXM()
1198 getRenderer()->ResetCamera();
1199 double x[3];
1200 getRenderer()->GetActiveCamera()->GetFocalPoint(x);
1201 x[0] -= 1;
1202 getRenderer()->GetActiveCamera()->SetPosition(x);
1203 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1204 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1205 getRenderer()->ResetCamera();
1206 getRenderWindow()->Render();
1209 void GuiMainWindow::viewYP()
1211 getRenderer()->ResetCamera();
1212 double x[3];
1213 getRenderer()->GetActiveCamera()->GetFocalPoint(x);
1214 x[1] += 1;
1215 getRenderer()->GetActiveCamera()->SetPosition(x);
1216 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1217 getRenderer()->GetActiveCamera()->SetViewUp(0,0,-1);
1218 getRenderer()->ResetCamera();
1219 getRenderWindow()->Render();
1222 void GuiMainWindow::viewYM()
1224 getRenderer()->ResetCamera();
1225 double x[3];
1226 getRenderer()->GetActiveCamera()->GetFocalPoint(x);
1227 x[1] -= 1;
1228 getRenderer()->GetActiveCamera()->SetPosition(x);
1229 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1230 getRenderer()->GetActiveCamera()->SetViewUp(0,0,-1);
1231 getRenderer()->ResetCamera();
1232 getRenderWindow()->Render();
1235 void GuiMainWindow::viewZP()
1237 getRenderer()->ResetCamera();
1238 double x[3];
1239 getRenderer()->GetActiveCamera()->GetFocalPoint(x);
1240 x[2] += 1;
1241 getRenderer()->GetActiveCamera()->SetPosition(x);
1242 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1243 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1244 getRenderer()->ResetCamera();
1245 getRenderWindow()->Render();
1248 void GuiMainWindow::viewZM()
1250 getRenderer()->ResetCamera();
1251 double x[3];
1252 getRenderer()->GetActiveCamera()->GetFocalPoint(x);
1253 x[2] -= 1;
1254 getRenderer()->GetActiveCamera()->SetPosition(x);
1255 getRenderer()->GetActiveCamera()->ComputeViewPlaneNormal();
1256 getRenderer()->GetActiveCamera()->SetViewUp(0,1,0);
1257 getRenderer()->ResetCamera();
1258 getRenderWindow()->Render();
1261 void GuiMainWindow::callFixSTL()
1263 FixSTL *fix;
1264 fix = new FixSTL();
1265 fix->setGui();
1266 (*fix)();
1267 updateBoundaryCodes(false);
1268 updateActors();
1271 void GuiMainWindow::editBoundaryConditions()
1273 GuiEditBoundaryConditions editbcs;
1274 editbcs.setBoundaryCodes(all_boundary_codes);
1275 editbcs.setMap(&bcmap);
1276 editbcs();
1279 void GuiMainWindow::configure()
1282 // Just to create initial entries in the settings file
1283 // so that the options menu isn't empty at first start.
1284 GridSmoother tmp01;
1285 GuiCreateBoundaryLayer tmp02;
1287 GuiSettingsViewer settings(&qset);
1288 settings.exec();
1291 void GuiMainWindow::about()
1293 QMessageBox box(this);
1295 QString title="ENGRID";
1296 QString version = QString("version ") + ENGRID_VERSION;
1297 if (version == "version CVS") {
1298 version += " build on ";
1299 version += QString(__DATE__);
1300 version += " at ";
1301 version += QString(__TIME__);
1303 QString address = tr("ENGRID is being developed and maintained by:<br/>"
1304 "enGits GmbH<br/>"
1305 "Marie-Curie-Strasse 8<br/>"
1306 "79539 Loerrach<br/>"
1307 "Germany<br/>");
1309 QString mainurl="<a href=\"http://www.engits.com\">www.engits.com</a>";
1310 QString mail="<a href=\"mailto:info@engits.com\">info@engits.com</a>";
1311 QString gnuurl="<a href=\"http://www.gnu.org/licenses\">http://www.gnu.org/licenses</a>";
1312 QString license=tr("ENGRID is licenced under the GPL version 3.<br/>"
1313 "(see ")+gnuurl+tr(" for details)<br/>");
1314 QString bugurl="<a href=\"http://sourceforge.net/tracker2/?func=add&group_id=245110&atid=1126548\">the bugtracker available on Sourceforge</a>";
1315 QString bugreporting=tr("To submit a bug report, please use ")+bugurl;
1316 box.setText(QString::fromLatin1("<center><img src=\":/icons/resources/icons/G.png\">"
1317 "<h3>%1</h3>"
1318 "<p>%2</p>"
1319 "<p>%3</p>"
1320 "<p>Homepage: %4</p>"
1321 "<p>E-mail: %5</p>"
1322 "<p>%6</p>"
1323 "<p>%7</p></center>")
1324 .arg(title).arg(version).arg(address).arg(mainurl).arg(mail).arg(license).arg(bugreporting));
1325 box.setWindowTitle(tr("about ENGRID"));
1326 box.setIcon(QMessageBox::NoIcon);
1327 box.exec();
1331 void GuiMainWindow::getAllBoundaryCodes(QSet<int> &bcs)
1333 bcs.clear();
1334 foreach (int bc, all_boundary_codes) {
1335 bcs.insert(bc);