Skip to content
Snippets Groups Projects
InstrumentView.cpp 2.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • //  ************************************************************************************************
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    //
    
    //  BornAgain: simulate and fit reflection and scattering
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    //
    
    //! @file      GUI/Views/InstrumentWidgets/InstrumentView.cpp
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    //! @brief     Implements class InstrumentView
    //!
    
    //! @homepage  http://www.bornagainproject.org
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    //! @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)
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    //
    
    //  ************************************************************************************************
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
    
    
    #include "GUI/Views/InstrumentWidgets/InstrumentView.h"
    
    #include "GUI/Models/InstrumentItems.h"
    
    t.knopff's avatar
    t.knopff committed
    #include "GUI/Models/InstrumentModel.h"
    
    #include "GUI/Views/CommonWidgets/StyledToolBar.h"
    
    #include "GUI/Views/InstrumentWidgets/InstrumentEditor.h"
    
    t.knopff's avatar
    t.knopff committed
    #include "GUI/Views/InstrumentWidgets/InstrumentSelectorWidget.h"
    
    #include "GUI/mainwindow/projectdocument.h"
    
    #include <QBoxLayout>
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady 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's avatar
    Pospelov, Gennady committed
        horizontalLayout->addWidget(m_instrumentSelector);
    
        horizontalLayout->addWidget(m_instrumentEditor, 1);
    
        StyledToolBar* toolbar = new StyledToolBar(this);
        toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    
        toolbar->addActions(m_instrumentSelector->toolbarActions());
    
        auto mainLayout = new QVBoxLayout;
    
        mainLayout->setMargin(0);
        mainLayout->setSpacing(0);
    
        mainLayout->addWidget(toolbar);
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady committed
        mainLayout->addLayout(horizontalLayout);
    
        setLayout(mainLayout);
    
    Pospelov, Gennady's avatar
    Pospelov, Gennady 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();
    }