BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Makes alignment of sample droped on graphics scene. More...
Public Member Functions | |
SampleViewAligner (DesignerScene *scene) | |
void | advance () |
Applies calculated positions to views. More... | |
void | alignSample (const QModelIndex &parentIndex, QPointF reference={}, bool force_alignment=false) |
Aligns sample starting from reference point. More... | |
void | alignSample (SessionItem *item, QPointF reference={}, bool force_alignment=false) |
Aligns sample starting from. More... | |
void | calculateForces (IView *view) |
Calculates forces acting on single view (simplified force directed spring algorithm) and deduce new position of views. More... | |
void | smartAlign () |
Spring based implified algorithm for smart alignment. More... | |
void | updateForces () |
Calculates forces acting on all views for smart alignment. More... | |
void | updateViews (const QModelIndex &parentIndex={}) |
Forms list of all views which are subject for smart alignment (i.e. More... | |
Private Member Functions | |
QList< IView * > | getConnectedViews (IView *view) |
Returns list of views connected with given view for the subsequent force calculation. More... | |
IView * | getViewForIndex (const QModelIndex &index) |
Private Attributes | |
DesignerScene * | m_scene |
QList< IView * > | m_views |
list of all views which are subject to smart align More... | |
QMap< IView *, QPointF > | m_viewToPos |
Makes alignment of sample droped on graphics scene.
Implements additional algorithm for smart alignment.
Definition at line 27 of file SampleViewAligner.h.
SampleViewAligner::SampleViewAligner | ( | DesignerScene * | scene | ) |
Definition at line 33 of file SampleViewAligner.cpp.
void SampleViewAligner::advance | ( | ) |
Applies calculated positions to views.
Definition at line 105 of file SampleViewAligner.cpp.
References m_views, and m_viewToPos.
Referenced by smartAlign().
void SampleViewAligner::alignSample | ( | const QModelIndex & | parentIndex, |
QPointF | reference = {} , |
||
bool | force_alignment = false |
||
) |
Aligns sample starting from reference point.
If force_alignment=false, view's position will be changed only if it has Null coordinate, if force_alignment=true the position will be changed anyway. Position of View which has parent item (like Layer) will remain unchainged.
Definition at line 161 of file SampleViewAligner.cpp.
References alignSample(), DesignerScene::getSampleModel(), getViewForIndex(), SessionModel::index(), m_scene, and SessionModel::rowCount().
void SampleViewAligner::alignSample | ( | SessionItem * | item, |
QPointF | reference = {} , |
||
bool | force_alignment = false |
||
) |
Aligns sample starting from.
Definition at line 151 of file SampleViewAligner.cpp.
References ASSERT, DesignerScene::getSampleModel(), SessionModel::indexOfItem(), and m_scene.
Referenced by alignSample(), DesignerScene::alignViews(), and DesignerScene::dropEvent().
void SampleViewAligner::calculateForces | ( | IView * | view | ) |
Calculates forces acting on single view (simplified force directed spring algorithm) and deduce new position of views.
Definition at line 73 of file SampleViewAligner.cpp.
References getConnectedViews(), m_views, and m_viewToPos.
Referenced by updateForces().
Returns list of views connected with given view for the subsequent force calculation.
Weirdness of given function is due to the fact, that, for example, ParticleLayout view should interact not with Layer view, but with its parent - MultiLayer view. Similarly, MultiLayer is not interacting with its Layers, but directly with the ParticleLayout.
Definition at line 117 of file SampleViewAligner.cpp.
References SessionItem::children(), IView::getItem(), DesignerScene::getViewForItem(), m_scene, SessionItem::modelType(), and SessionItem::parent().
Referenced by calculateForces().
|
private |
Definition at line 187 of file SampleViewAligner.cpp.
References DesignerScene::getSampleModel(), DesignerScene::getViewForItem(), SessionModel::itemForIndex(), and m_scene.
Referenced by alignSample(), and updateViews().
void SampleViewAligner::smartAlign | ( | ) |
Spring based implified algorithm for smart alignment.
Definition at line 39 of file SampleViewAligner.cpp.
References advance(), m_views, updateForces(), and updateViews().
Referenced by DesignerScene::onSmartAlign().
void SampleViewAligner::updateForces | ( | ) |
Calculates forces acting on all views for smart alignment.
Definition at line 63 of file SampleViewAligner.cpp.
References calculateForces(), m_views, and m_viewToPos.
Referenced by smartAlign().
void SampleViewAligner::updateViews | ( | const QModelIndex & | parentIndex = {} | ) |
Forms list of all views which are subject for smart alignment (i.e.
views which do not have parent view)
Definition at line 49 of file SampleViewAligner.cpp.
References DesignerScene::getSampleModel(), getViewForIndex(), SessionModel::index(), m_scene, m_views, and SessionModel::rowCount().
Referenced by smartAlign().
|
private |
Definition at line 45 of file SampleViewAligner.h.
Referenced by SampleViewAligner(), alignSample(), getConnectedViews(), getViewForIndex(), and updateViews().
|
private |
list of all views which are subject to smart align
Definition at line 46 of file SampleViewAligner.h.
Referenced by advance(), calculateForces(), smartAlign(), updateForces(), and updateViews().
|
private |
Definition at line 47 of file SampleViewAligner.h.
Referenced by advance(), calculateForces(), and updateForces().