BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
viewmodelfactory.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/viewmodel/mvvm/factories/viewmodelfactory.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_VIEWMODEL_MVVM_FACTORIES_VIEWMODELFACTORY_H
16 #define BORNAGAIN_MVVM_VIEWMODEL_MVVM_FACTORIES_VIEWMODELFACTORY_H
17 
20 #include "mvvm/viewmodel_export.h"
21 #include <memory>
22 
23 namespace ModelView {
24 
25 class SessionModel;
26 class ViewModel;
27 
28 namespace Factory {
29 
30 //! Creates view model to represent SessionModel for Qt views.
31 //! The model has two columns, all items are shown.
32 MVVM_VIEWMODEL_EXPORT std::unique_ptr<ViewModel> CreateDefaultViewModel(SessionModel* model);
33 
34 //! Creates view model to represent SessionModel for Qt views.
35 //! The model has two columns, shows only property items and simplified group items.
36 MVVM_VIEWMODEL_EXPORT std::unique_ptr<ViewModel> CreatePropertyViewModel(SessionModel* model);
37 
38 //! Creates view model to represent SessionModel for Qt views.
39 //! Shows all properties of CompoundItem in columns of the table, rows of the table represent
40 //! different CompoundItems. Items of same type and table like structure of the model are expected.
41 MVVM_VIEWMODEL_EXPORT std::unique_ptr<ViewModel> CreatePropertyTableViewModel(SessionModel* model);
42 
43 //! Creates view model to represent SessionModel for Qt views.
44 //! Shows only top items.
45 MVVM_VIEWMODEL_EXPORT std::unique_ptr<ViewModel> CreateTopItemsViewModel(SessionModel* model);
46 
47 //! Creates view model to represent SessionModel for Qt views.
48 //! The model has two columns, shows only property items and simplified group items.
49 //! Subproperties of group item moved one level up.
50 MVVM_VIEWMODEL_EXPORT std::unique_ptr<ViewModel> CreatePropertyFlatViewModel(SessionModel* model);
51 
52 //! Creates view model to represent SessionModel for Qt views.
53 //! Use user provided types for ChildrenStrategy and RowStrategy.
54 template <typename ChildrenStrategy, typename RowStrategy>
55 std::unique_ptr<ViewModel> CreateViewModel(SessionModel* session_model)
56 {
57  auto controller = CreateController<ChildrenStrategy, RowStrategy>(session_model, nullptr);
58  return std::make_unique<ViewModel>(std::move(controller));
59 }
60 
61 //! Creates view model to represent SessionModel for Qt views.
62 //! Use user provided controller type.
63 template <typename ViewModelController>
64 std::unique_ptr<ViewModel> CreateViewModel(SessionModel* session_model)
65 {
66  auto controller = std::make_unique<ViewModelController>(session_model);
67  return std::make_unique<ViewModel>(std::move(controller));
68 }
69 
70 } // namespace Factory
71 
72 } // namespace ModelView
73 
74 #endif // BORNAGAIN_MVVM_VIEWMODEL_MVVM_FACTORIES_VIEWMODELFACTORY_H
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
MVVM_VIEWMODEL_EXPORT std::unique_ptr< ViewModel > CreatePropertyTableViewModel(SessionModel *model)
Creates view model to represent SessionModel for Qt views.
MVVM_VIEWMODEL_EXPORT std::unique_ptr< ViewModel > CreatePropertyFlatViewModel(SessionModel *model)
Creates view model to represent SessionModel for Qt views.
MVVM_VIEWMODEL_EXPORT std::unique_ptr< ViewModel > CreateDefaultViewModel(SessionModel *model)
Creates view model to represent SessionModel for Qt views.
MVVM_VIEWMODEL_EXPORT std::unique_ptr< ViewModel > CreatePropertyViewModel(SessionModel *model)
Creates view model to represent SessionModel for Qt views.
std::unique_ptr< ViewModel > CreateViewModel(SessionModel *session_model)
Creates view model to represent SessionModel for Qt views.
MVVM_VIEWMODEL_EXPORT std::unique_ptr< ViewModel > CreateTopItemsViewModel(SessionModel *model)
Creates view model to represent SessionModel for Qt views.
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?
Defines class CLASS?