Skip to content
Snippets Groups Projects
Commit 28e183ba authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add project settings view

parent 224834d1
No related branches found
No related tags found
1 merge request!297Add project settings view
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Views/ProjectSettingsView.cpp
//! @brief Implements class ProjectSettingsView
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2021
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Views/ProjectSettingsView.h"
#include "GUI/Models/ApplicationModels.h"
#include "GUI/Models/InstrumentModel.h"
#include "GUI/Views/CommonWidgets/GroupBoxCollapser.h"
#include "GUI/mainwindow/projectdocument.h"
#include "GUI/utils/qstringutils.h"
#include "ui_ProjectSettingsView.h"
#include <QDir>
#include <QMessageBox>
using namespace GUI::Utils;
ProjectSettingsView::ProjectSettingsView(QWidget* parentWidget, ProjectDocument* document)
: QWidget(parentWidget), m_ui(new Ui::ProjectSettingsView), m_document(document)
{
m_ui->setupUi(this);
m_ui->label_6->hide(); // #baTODO show again
m_ui->textEdit->hide();
setAttribute(Qt::WA_StyledBackground, true);
setProperty("stylable", true);
GroupBoxCollapser::installIntoGroupBox(m_ui->groupBox);
GroupBoxCollapser::installIntoGroupBox(m_ui->groupBox_1);
GroupBoxCollapser::installIntoGroupBox(m_ui->groupBox_2);
GroupBoxCollapser::installIntoGroupBox(m_ui->groupBox_3);
connect(m_ui->singleInstrumentModeRadio, &QRadioButton::toggled, this,
&ProjectSettingsView::onSingleInstrumentRadioToggled);
connect(m_ui->gisasCheck, &QCheckBox::toggled, this,
&ProjectSettingsView::onFunctionalityToggled);
connect(m_ui->offSpecCheck, &QCheckBox::toggled, this,
&ProjectSettingsView::onFunctionalityToggled);
connect(m_ui->reflectometryCheck, &QCheckBox::toggled, this,
&ProjectSettingsView::onFunctionalityToggled);
connect(m_ui->depthCheck, &QCheckBox::toggled, this,
&ProjectSettingsView::onFunctionalityToggled);
// #baTODO should be "informationModified" or so?
connect(m_document, &ProjectDocument::modified, this, &ProjectSettingsView::updateInformation);
}
void ProjectSettingsView::showEvent(QShowEvent*)
{
writeOptionsToUI();
}
void ProjectSettingsView::writeOptionsToUI()
{
QSignalBlocker b1(m_ui->singleInstrumentModeRadio);
m_document->singleInstrumentMode() ? m_ui->singleInstrumentModeRadio->setChecked(true)
: m_ui->multipleInstrumentModeRadio->setChecked(true);
writeFunctionalityToUI();
updateInformation();
}
void ProjectSettingsView::writeFunctionalityToUI()
{
const auto f = m_document->functionalities();
QSignalBlocker b1(m_ui->gisasCheck);
QSignalBlocker b2(m_ui->offSpecCheck);
QSignalBlocker b3(m_ui->reflectometryCheck);
QSignalBlocker b4(m_ui->depthCheck);
m_ui->gisasCheck->setChecked(f.testFlag(ProjectDocument::Gisas));
m_ui->offSpecCheck->setChecked(f.testFlag(ProjectDocument::OffSpecular));
m_ui->reflectometryCheck->setChecked(f.testFlag(ProjectDocument::Specular));
m_ui->depthCheck->setChecked(f.testFlag(ProjectDocument::DepthProbe));
}
void ProjectSettingsView::updateInformation()
{
QString location = "--";
QString name = m_document->projectName();
if (m_document->hasValidNameAndPath())
location =
String::withTildeHomePath(QDir::toNativeSeparators(m_document->projectFileName()));
m_ui->currentProjectName->setText(name);
m_ui->currentProjectLocation->setText(location);
}
void ProjectSettingsView::onSingleInstrumentRadioToggled(bool newState)
{
if (newState == true) {
if (m_document->instrumentModel()->instrumentItems().size() > 1) {
QMessageBox::warning(this, "Select single instrument mode",
"This project already contains more than one instrument. Changing "
"this setting is not possible.");
QSignalBlocker b1(m_ui->singleInstrumentModeRadio);
m_ui->multipleInstrumentModeRadio->setChecked(true);
return;
}
m_document->setSingleInstrumentMode(true);
} else
m_document->setSingleInstrumentMode(false);
}
void ProjectSettingsView::onFunctionalityToggled()
{
ProjectDocument::Functionalities f;
f.setFlag(ProjectDocument::Gisas, m_ui->gisasCheck->isChecked());
f.setFlag(ProjectDocument::OffSpecular, m_ui->offSpecCheck->isChecked());
f.setFlag(ProjectDocument::Specular, m_ui->reflectometryCheck->isChecked());
f.setFlag(ProjectDocument::DepthProbe, m_ui->depthCheck->isChecked());
if (f == ProjectDocument::None) {
QMessageBox::warning(this, "Select functionality",
"You have to select at least one functionality. Changing "
"this setting is not possible.");
writeFunctionalityToUI();
return;
}
m_document->setFunctionalities(f);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Views/ProjectSettingsView.h
//! @brief Defines class ProjectSettingsView
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEWS_PROJECTSETTINGSVIEW_H
#define BORNAGAIN_GUI_VIEWS_PROJECTSETTINGSVIEW_H
#include <QWidget>
class ProjectDocument;
namespace Ui {
class ProjectSettingsView;
}
//! Widget to define project settings
class ProjectSettingsView : public QWidget {
Q_OBJECT
public:
ProjectSettingsView(QWidget* parentWidget, ProjectDocument* document);
protected:
virtual void showEvent(QShowEvent*) override;
private:
//! Write entries in OptionsItem to UI
void writeOptionsToUI();
void writeFunctionalityToUI();
void updateInformation();
void onSingleInstrumentRadioToggled(bool newState);
void onFunctionalityToggled();
private:
Ui::ProjectSettingsView* m_ui;
ProjectDocument* m_document;
};
#endif // BORNAGAIN_GUI_VIEWS_PROJECTSETTINGSVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectSettingsView</class>
<widget class="QWidget" name="ProjectSettingsView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>866</width>
<height>835</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="mainLayout">
<property name="spacing">
<number>15</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Information</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="currentProjectName">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;Name&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="currentProjectLocation">
<property name="text">
<string>&lt;Location&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QTextEdit" name="textEdit"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Functionality</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QCheckBox" name="gisasCheck">
<property name="text">
<string>GISAS</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="offSpecCheck">
<property name="text">
<string>Off-Specular</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="reflectometryCheck">
<property name="text">
<string>Reflectometry</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="depthCheck">
<property name="text">
<string>Depth Probe</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Define which types of simulation/analysis you want to use in this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.&lt;/p&gt;&lt;p&gt;You can always come back and change these selection if you need more (or less) functionalities of BornAgain.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_1">
<property name="title">
<string>Instruments</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QRadioButton" name="singleInstrumentModeRadio">
<property name="text">
<string>Use only one instrument</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="multipleInstrumentModeRadio">
<property name="text">
<string>Use multiple instruments</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Define whether you want to use only one ore more instruments within this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.
You can always come back and change these selection if you need more (or less) functionalities of BornAgain.
Note that if your above selection contains more than one type of functionality, the single instrument view is not possible any more.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Sample models</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QRadioButton" name="singleSampleModeRadio">
<property name="text">
<string>Use only one sample model</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="multipleSampleModeRadio">
<property name="text">
<string>Use multiple sample models</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Define whether you want to use one ore more sample models within this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.
You can always come back and change these selection if you need more (or less) functionalities of BornAgain.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>488</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -19,6 +19,7 @@
#include "GUI/Views/ImportDataView.h"
#include "GUI/Views/InstrumentWidgets/InstrumentView.h"
#include "GUI/Views/JobView.h"
#include "GUI/Views/ProjectSettingsView.h"
#include "GUI/Views/SampleView.h"
#include "GUI/Views/SessionModelView.h"
#include "GUI/Views/SimulationView.h"
......@@ -56,6 +57,7 @@ MainWindow::MainWindow()
, m_sampleView(0)
, m_importDataView(0)
, m_simulationView(0)
, m_projectSettingsView(0)
, m_jobView(0)
, m_sessionModelView(0)
{
......@@ -262,7 +264,10 @@ void MainWindow::initViews()
m_simulationView = new SimulationView(this, doc);
m_jobView = new JobView(this, doc);
m_sessionModelView = new SessionModelView(this, doc);
m_projectSettingsView = new ProjectSettingsView(this, doc);
addView(ViewId::PROJECT, QIcon(":/images/main_sessionmodel.svg"), "Project",
"Define project settings", m_projectSettingsView);
addView(ViewId::INSTRUMENT, QIcon(":/images/main_instrumentview.svg"), "Instrument",
"Define the beam and the detector", m_instrumentView);
......
......@@ -35,12 +35,13 @@ class QStackedLayout;
class QStatusBar;
class QToolButton;
class QVBoxLayout;
class ProjectSettingsView;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
enum ViewId { WELCOME, INSTRUMENT, SAMPLE, IMPORT, SIMULATION, JOB, SESSIONMODEL };
enum ViewId { WELCOME, PROJECT, INSTRUMENT, SAMPLE, IMPORT, SIMULATION, JOB, SESSIONMODEL };
explicit MainWindow();
~MainWindow();
......@@ -103,6 +104,7 @@ private:
SampleView* m_sampleView;
ImportDataView* m_importDataView;
SimulationView* m_simulationView;
ProjectSettingsView* m_projectSettingsView;
JobView* m_jobView;
SessionModelView* m_sessionModelView;
......
......@@ -234,7 +234,7 @@ void ProjectManager::newProject()
createNewProject();
emit documentOpenedOrClosed();
m_mainWindow->setCurrentView(MainWindow::INSTRUMENT);
m_mainWindow->setCurrentView(MainWindow::PROJECT);
}
//! Processes close current project request. Call save/discard/cancel dialog, if necessary.
......@@ -346,7 +346,7 @@ void ProjectManager::openProject(QString fileName)
}
if (m_project_document != nullptr) {
emit documentOpenedOrClosed();
m_mainWindow->setCurrentView(MainWindow::INSTRUMENT);
m_mainWindow->setCurrentView(MainWindow::PROJECT);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment