Newer
Older
// ************************************************************************************************
// BornAgain: simulate and fit reflection and scattering
//! @file GUI/Views/InstrumentWidgets/InstrumentView.cpp
//! @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)
// ************************************************************************************************
#include "GUI/Views/InstrumentWidgets/InstrumentView.h"
#include "GUI/Models/InstrumentItems.h"
#include "GUI/Views/CommonWidgets/StyledToolBar.h"
#include "GUI/Views/InstrumentWidgets/InstrumentEditor.h"
#include "GUI/Views/InstrumentWidgets/InstrumentSelectorWidget.h"
Matthias Puchner
committed
#include "GUI/mainwindow/projectdocument.h"
Matthias Puchner
committed
InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document)
: QWidget(parent), m_instrumentEditor(new InstrumentEditor), m_document(document)
auto horizontalLayout = new QHBoxLayout;
m_instrumentSelector = new InstrumentSelectorWidget(document, this);
Pospelov, Gennady
committed
horizontalLayout->addWidget(m_instrumentEditor, 1);
StyledToolBar* toolbar = new StyledToolBar(this);
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar->addActions(m_instrumentSelector->toolbarActions());
Matthias Puchner
committed
auto mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
setLayout(mainLayout);
Van Herck, Walter
committed
connect(m_instrumentSelector, &InstrumentSelectorWidget::selectionChanged, this,
&InstrumentView::onItemSelectionChanged);
onItemSelectionChanged(nullptr);
void InstrumentView::onItemSelectionChanged(SessionItem* instrumentItem)
{
m_instrumentEditor->setItem(dynamic_cast<InstrumentItem*>(instrumentItem));
void InstrumentView::showEvent(QShowEvent*)
{
m_instrumentSelector->updateSelection();
}