Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
DDqtMainWindow.cpp
Go to the documentation of this file.
1/* This file is part of MODEL, the Mechanics Of Defect Evolution Library.
2 *
3 * Copyright (C) 2011 by Giacomo Po <gpo@ucla.edu>.
4 *
5 * model is distributed without any warranty under the
6 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
7 */
8
9#ifndef model_DDqtMainWindow_cpp_
10#define model_DDqtMainWindow_cpp_
11
12
13#include <DDqtMainWindow.h>
14#include <QMenu>
15#include <QMenuBar>
16
17
18namespace model
19{
20
22 /* init */ viewerCount(0)
23 /* init */,tabWidget(new QTabWidget(this))
24 /* init */,newViewerAction(new QAction(tr("&New"), this))
25 {
26 resize(1920, 1080);
27 QMenu* viewertMenu=menuBar()->addMenu(tr("&Viewer"));
28 viewertMenu->addAction(newViewerAction);
29 connect(newViewerAction, &QAction::triggered, this, &DDqtMainWindow::newViewerTab);
30 connect(tabWidget,SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
31 tabWidget->setTabsClosable(true);
32 setCentralWidget(tabWidget);
33 }
34
35 void DDqtMainWindow::newViewerTab()
36 {
37 try
38 {
39 tabWidget->addTab(new DDqtVTKwidget(this), tr(std::string("Viewer "+std::to_string(viewerCount)).c_str()));
40 viewerCount++;
41 }
42 catch(const std::exception& e)
43 {
44 std::cout<<e.what()<<std::endl;
45 }
46 }
47
48void DDqtMainWindow::closeTab(int tabID)
49{
50 auto *page = tabWidget->widget(tabID);
51 if(!page)
52 {
53 return;
54 }
55 if(auto *viewer = qobject_cast<DDqtVTKwidget*>(page))
56 {
57 viewer->defectiveCrystalActor->stopConfigurations();
58 }
59 tabWidget->removeTab(tabID);
60 page->deleteLater();
61}
62
63
64} // namespace model
65#endif
66
67
68
69
70
71
72
int e