30 #include <QDockWidget>
32 #include <QToolButton>
36 , m_document(document)
38 setObjectName(
"SampleView");
47 auto* sampleSelectionPane =
new QWidget(
this);
48 auto* sampleSelectionLayout =
new QVBoxLayout(sampleSelectionPane);
49 sampleSelectionLayout->setContentsMargins(0, 0, 0, 0);
50 sampleSelectionLayout->setSpacing(0);
52 auto* sampleSelectionToolbar =
new StyledToolbar(sampleSelectionPane);
55 #ifdef BORNAGAIN_PYTHON
59 if (
auto* btn =
dynamic_cast<QToolButton*
>(sampleSelectionToolbar->widgetForAction(
61 btn->setPopupMode(QToolButton::InstantPopup);
63 sampleSelectionToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
64 sampleSelectionLayout->addWidget(sampleSelectionToolbar);
67 QSizePolicy::MinimumExpanding);
72 sampleSelectionPane->setWindowTitle(
"Samples");
106 Qt::UniqueConnection);
108 setCentralWidget(editor);
121 itemForRealSpace = p;
123 itemForRealSpace = p;
125 itemForRealSpace = p;
127 itemForRealSpace = p;
146 const auto resetIf = [&](
bool b) {
148 canvas->resetScene();
153 canvas->resetScene();
156 resetIf(layerToRemove == currentAsLayer);
157 resetIf(layerToRemove->layouts().contains(currentAsLayout));
158 resetIf(layerToRemove->itemsWithParticles().contains(currentAsParticle));
161 resetIf(layoutToRemove == currentAsLayout);
162 resetIf(layoutToRemove->containedItemsWithParticles().contains(currentAsParticle));
165 resetIf(particleToRemove == currentAsParticle);
166 resetIf(particleToRemove->containedItemsWithParticles().contains(currentAsParticle));
179 menu->addSeparator();
181 auto* action =
new QAction(menu);
182 action->setText(
"Reset to default layout");
184 menu->addAction(action);
Defines class DocksController.
Defines abstract item with a material property.
Defines class LayerOrientedSampleEditor.
Defines class MultiLayerItem.
Defines class ParticleLayoutItem.
Defines class ProjectDocument.
Defines class RealSpaceCanvas.
Defines class RealSpacePanel.
Defines class SampleListView.
Defines class SampleView.
Defines class SampleDesigner.
Handles creation and appearance of docked widgets in the context of QMainWindow. It is used for Sampl...
void setDockVisible(int id, bool visible=true)
void addDockActionsToMenu(QMenu *menu)
void addWidget(int id, QWidget *widget, Qt::DockWidgetArea area)
QDockWidget * findDock(int id)
Sample editor with layer oriented presentation of a sample.
void setCurrentSample(MultiLayerItem *sampleItem)
void aboutToRemoveItem(SampleItem item)
void requestCreateNewSample()
void requestViewInRealSpace(SampleItem itemToShow)
Project document class handles all data related to the opened project (sample, job,...
void singleSampleModeChanged()
Emitted when single sample mode has changed.
bool singleSampleMode() const
void setCurrentItem(MultiLayerItem *containingMultiLayerItem, ItemForRealSpace item)
std::variant< MultiLayerItem *, LayerItem *, ParticleLayoutItem *, ItemWithParticles * > ItemForRealSpace
Defines the item types which can be the "current item".
Panel to show 3D view of sample. Contains toolbar and RealSpaceCanvas.
RealSpaceCanvas * canvas()
This can hold any item which belongs to a sample.
T get_if()
Short version to get a contained pointer (the std::get_if would return pointer-to-pointer)
List view to select one sample (left side of layer-oriented sample editor)
MultiLayerItem * currentSample()
QAction * chooseFromLibraryAction()
QAction * importSampleAction()
void currentSampleChanged(MultiLayerItem *current)
void selectFirstSample()
Select first sample, if any sample exists.
QAction * newSampleAction()
void showEvent(QShowEvent *) override
void onAboutToRemoveItem(SampleItem item)
RealSpacePanel * m_realSpacePanel
void fillViewMenu(QMenu *menu)
SampleListView * m_sampleSelectionView
void updateSingleSampleMode()
void toggleRealSpaceView()
ProjectDocument * m_document
SampleView(QWidget *parent, ProjectDocument *document)
void onRequestViewInRealSpace(SampleItem itemToView)
Show the item in the real space view.
DocksController * m_docks
Resides at the bottom of SampleView and displays a Python script.
void setCurrentSample(MultiLayerItem *sampleItem)