BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleViewAligner.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/SampleDesigner/SampleViewAligner.h
6 //! @brief Defines class SampleViewAligner
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 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWALIGNER_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWALIGNER_H
17 
18 #include <QMap>
19 #include <QModelIndex>
20 #include <QPointF>
21 class DesignerScene;
22 class IView;
23 class SessionItem;
24 
25 //! Makes alignment of sample droped on graphics scene.
26 //! Implements additional algorithm for smart alignment.
28 public:
30 
31  void alignSample(SessionItem* item, QPointF reference = {}, bool force_alignment = false);
32  void alignSample(const QModelIndex& parentIndex, QPointF reference = {},
33  bool force_alignment = false);
34 
35  void smartAlign();
36  void updateViews(const QModelIndex& parentIndex = {});
37  void updateForces();
38  void calculateForces(IView* view);
39  void advance();
40 
41 private:
42  IView* getViewForIndex(const QModelIndex& index);
43  QList<IView*> getConnectedViews(IView* view);
44 
46  QList<IView*> m_views; //!< list of all views which are subject to smart align
47  QMap<IView*, QPointF> m_viewToPos;
48 };
49 
50 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWALIGNER_H
Main class which represents SessionModel on graphics scene.
Definition: DesignerScene.h:37
parent class for graphic representation of all ISampleNode's
Definition: IView.h:25
Makes alignment of sample droped on graphics scene.
void advance()
Applies calculated positions to views.
void updateForces()
Calculates forces acting on all views for smart alignment.
void alignSample(SessionItem *item, QPointF reference={}, bool force_alignment=false)
Aligns sample starting from.
void smartAlign()
Spring based implified algorithm for smart alignment.
void calculateForces(IView *view)
Calculates forces acting on single view (simplified force directed spring algorithm) and deduce new p...
DesignerScene * m_scene
QList< IView * > m_views
list of all views which are subject to smart align
QList< IView * > getConnectedViews(IView *view)
Returns list of views connected with given view for the subsequent force calculation.
void updateViews(const QModelIndex &parentIndex={})
Forms list of all views which are subject for smart alignment (i.e.
QMap< IView *, QPointF > m_viewToPos
IView * getViewForIndex(const QModelIndex &index)
SampleViewAligner(DesignerScene *scene)