BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
JobView.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Job/JobView.cpp
6 //! @brief Implements class JobView
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "GUI/View/Job/JobView.h"
16 #include "GUI/Model/Job/JobItem.h"
28 #include <QMenu>
29 
31  : m_docks(new DocksController(this))
32  , m_progressAssistant(new JobProgressAssistant(mainWindow, document->jobModel()))
33  , m_activityActions(this)
34  , m_document(document)
35 {
36  setObjectName("JobView");
37  createActions();
40 }
41 
42 void JobView::fillViewMenu(QMenu* menu)
43 {
44  menu->addActions(m_activityActions.actions());
45  menu->addSeparator();
46 
48 
49  menu->addSeparator();
50 
51  auto* action = new QAction(menu);
52  action->setText("Reset to default layout");
53  connect(action, &QAction::triggered, this, &JobView::resetLayout);
54  menu->addAction(action);
55 }
56 
58 {
59  if (jobItem->runInBackground())
60  return;
61 
62  QVector<JobItem*> jobs = m_jobSelector->selectedJobs();
63  if (jobs.size() != 1 || jobItem != jobs.front()) {
66  }
67 
69 }
70 
71 //! Sets docks visibility in accordance with required activity.
72 
74 {
75  QVector<JobViewFlags::Dock> docksToShow = JobViewActivities::activeDocks(activity);
76 
77  std::vector<int> docks_id;
78  for (auto x : docksToShow)
79  docks_id.push_back(static_cast<int>(x));
80 
81  m_docks->setVisibleDocks(docks_id);
82  m_activityActions.actions()[static_cast<int>(activity)]->setChecked(true);
83  emit activityChanged(activity);
84 }
85 
86 //! Propagates change in JobItem's selection down into main widgets.
87 
88 void JobView::onSelectionChanged(const QVector<JobItem*>& jobs)
89 {
90  JobItem* jobItem = nullptr;
91  if (jobs.size() == 1)
92  jobItem = jobs.front();
94  m_jobRealTimeWidget->setItem(jobItem);
95  m_fitActivityPanel->setItem(jobItem);
96 }
97 
99 {
105 
106  m_docks->addWidget(JobViewFlags::JOB_LIST_DOCK, m_jobSelector, Qt::LeftDockWidgetArea);
110 
112 
113  setCentralWidget(m_jobResultsPresenter);
114 
115  resetLayout();
116 }
117 
119 {
120  for (JobViewActivity activity : JobViewActivities::all()) {
121  auto* action = new QAction(this);
122  action->setText(JobViewActivities::name(activity));
123  action->setCheckable(true);
124  connect(action, &QAction::triggered, [=]() { setActivity(activity); });
125  m_activityActions.addAction(action);
126  }
127 }
128 
130 {
133 }
134 
135 //! Connects signal related to activity change.
136 
138 {
139  // Activity was changed: this -> JobResultsPresenter
141  qOverload<JobViewActivity>(&JobResultsPresenter::setPresentation));
142 }
143 
144 //! Connects signals related to JobItem
146 {
147  // Focus request: JobModel -> this
149 
150  // JobItem selection: JobSelectorWidget -> this
153 
156 
157  // activate view for the selected job at project opening
159 }
160 
161 //! Sets appropriate activity for new JobItem
162 
164 {
165  if (!jobItem)
166  return;
167 
168  if (jobItem->isValidForFitting()) {
169  // fitting presentation
171  // ALTERNATIVE:
172  // fitting activity
173  // setActivity(JobViewActivity::Fitting);
174  }
175 }
176 
178 {
179  m_docks->resetLayout();
181 }
Defines class DocksController.
Defines class FitActivityPanel.
Defines class JobItem.
Defines class JobMessagePanel.
Defines class JobModel.
Defines class JobProgressAssistant.
Defines class JobRealTimeWidget.
Defines class JobResultsPresenter.
Defines class JobSelectorWidget.
Defines class JobViewActivities.
JobViewActivity
Defines class JobView.
Defines class MainWindow.
Defines class ProjectManager.
Handles creation and appearance of docked widgets in the context of QMainWindow. It is used for Sampl...
void addDockActionsToMenu(QMenu *menu)
void addWidget(int id, QWidget *widget, Qt::DockWidgetArea area)
void setVisibleDocks(const std::vector< int > &visibleDocks)
Show docks with id's from the list. Other docks will be hidden.
The FitActivityPanel class is a main widget to run the fitting. Occupies bottom right corner of JobVi...
void showLog(FitLog *log)
void setRealTimeWidget(JobRealTimeWidget *realTimeWidget)
void setItem(JobItem *item)
bool isValidForFitting()
Definition: JobItem.cpp:154
bool runInBackground() const
Definition: JobItem.cpp:217
The JobMessagePanel class shows log messages from FitActivityPanel at the bottom part of JobView.
void setLog(FitLog *log)
void focusRequest(JobItem *item)
The JobProgressAssistant class helps JobView to visualize current progress.
The JobRealTimeWidget class provides tuning of sample parameters in real time. Located on the right s...
void setItem(JobItem *jobItem)
Presents results of job (JobItem) using stack of different widgets and combo box in the right top cor...
void setItem(SessionItem *item) override
void setPresentation(const QString &presentationType) override
Sets stack to show widget corresponding to given presentation.
The JobSelectorWidget class represents left panel of JobView. Contains a tree to select jobs on the t...
void makeJobItemSelected(JobItem *)
void selectedJobsChanged(const QVector< JobItem * > &jobs)
QVector< JobItem * > selectedJobs() const
void connectJobRelated()
Connects signals related to JobItem.
Definition: JobView.cpp:145
void connectActivityRelated()
Connects signal related to activity change.
Definition: JobView.cpp:137
void setActivity(JobViewActivity activity)
Sets docks visibility in accordance with required activity.
Definition: JobView.cpp:73
void setAppropriateActivityForJob(JobItem *jobItem)
Sets appropriate activity for new JobItem.
Definition: JobView.cpp:163
void createActions()
Definition: JobView.cpp:118
JobResultsPresenter * m_jobResultsPresenter
Definition: JobView.h:68
JobView(MainWindow *mainWindow, ProjectDocument *document)
Definition: JobView.cpp:30
FitActivityPanel * m_fitActivityPanel
Definition: JobView.h:70
JobRealTimeWidget * m_jobRealTimeWidget
Definition: JobView.h:69
DocksController * m_docks
Definition: JobView.h:64
void onSelectionChanged(const QVector< JobItem * > &jobs)
Propagates change in JobItem's selection down into main widgets.
Definition: JobView.cpp:88
void fillViewMenu(QMenu *menu)
Definition: JobView.cpp:42
void focusRequest(int)
void onFocusRequest(JobItem *jobItem)
Definition: JobView.cpp:57
void activityChanged(JobViewActivity activity)
ProjectDocument * m_document
Definition: JobView.h:74
JobSelectorWidget * m_jobSelector
Definition: JobView.h:67
void connectSignals()
Definition: JobView.cpp:129
JobMessagePanel * m_jobMessagePanel
Definition: JobView.h:71
void createSubWindows()
Definition: JobView.cpp:98
void resetLayout()
Definition: JobView.cpp:177
QActionGroup m_activityActions
Definition: JobView.h:73
Project document class handles all data related to the opened project (sample, job,...
JobModel * jobModel() const
static QMainWindow * mainWindow
Definition: Globals.h:22
QString name(JobViewActivity activity)
Returns name of activity.
QVector< JobViewFlags::Dock > activeDocks(JobViewActivity activity)
Returns vector of JobView's dockId which have to be shown for given activity.
QList< JobViewActivity > all()
Returns list of all available activities.