Mantid
Loading...
Searching...
No Matches
WorkspaceSelector.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "DllOption.h"
11#include <QComboBox>
12#include <QStringList>
13#include <mutex>
14
15#include <Poco/AutoPtr.h>
16#include <Poco/NObserver.h>
17
18// Forward declarations
19namespace Mantid {
20namespace API {
21class Algorithm;
22}
23} // namespace Mantid
24
25namespace MantidQt {
26namespace MantidWidgets {
48 Q_OBJECT
49
50 Q_PROPERTY(QStringList WorkspaceTypes READ getWorkspaceTypes WRITE setWorkspaceTypes)
51 Q_PROPERTY(bool ShowHidden READ showHiddenWorkspaces WRITE showHiddenWorkspaces)
52 Q_PROPERTY(bool ShowGroups READ showWorkspaceGroups WRITE showWorkspaceGroups)
53 Q_PROPERTY(bool Optional READ isOptional WRITE setOptional)
54 Q_PROPERTY(bool Sorted READ isSorted WRITE setSorted)
55 Q_PROPERTY(QStringList Suffix READ getSuffixes WRITE setSuffixes)
56 Q_PROPERTY(QString Algorithm READ getValidatingAlgorithm WRITE setValidatingAlgorithm)
57 friend class DataSelector;
58
59public:
60 using QComboBox::currentIndexChanged;
61
63 WorkspaceSelector(QWidget *parent = nullptr, bool init = true);
65 ~WorkspaceSelector() override;
66
67 // delete copy operations - Poco::NObserver contains std::atomic which is not copyable
69 WorkspaceSelector &operator=(const WorkspaceSelector &) = delete;
70
71 const QStringList &getWorkspaceTypes() const;
72 void setWorkspaceTypes(const QStringList &types);
73 bool showHiddenWorkspaces() const;
74 void showHiddenWorkspaces(bool show);
75 bool showWorkspaceGroups() const;
76 void showWorkspaceGroups(bool show);
77 bool isOptional() const;
78 void setOptional(bool optional);
79 bool isSorted() const;
80 void setSorted(bool sorted);
81 const QStringList &getSuffixes() const;
82 void setSuffixes(const QStringList &suffix);
83 void setLowerBinLimit(int numberOfBins);
84 void setUpperBinLimit(int numberOfBins);
85 const QString &getValidatingAlgorithm() const;
86 void setValidatingAlgorithm(const QString &algName);
87 bool isValid() const;
88 void refresh();
89 void disconnectObservers();
90 void connectObservers();
91 bool isConnected() const;
92
93signals:
94 void emptied();
95 void focussed();
96
97private:
98 void handleAddEvent(Mantid::API::WorkspaceAddNotification_ptr pNf);
99 void handleRemEvent(Mantid::API::WorkspacePostDeleteNotification_ptr pNf);
100 void handleClearEvent(Mantid::API::ClearADSNotification_ptr pNf);
101 void handleRenameEvent(Mantid::API::WorkspaceRenameNotification_ptr pNf);
102 void handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf);
103
104 bool checkEligibility(const QString &name, const Mantid::API::Workspace_sptr &object) const;
105 bool hasValidSuffix(const QString &name) const;
106 bool hasValidNumberOfBins(const Mantid::API::Workspace_sptr &object) const;
107
108protected:
109 // Method for handling drop events
110 void dropEvent(QDropEvent * /*unused*/) override;
111 // called when a drag event enters the class
112 void dragEnterEvent(QDragEnterEvent * /*unused*/) override;
113 // Method for handling focus in events
114 void focusInEvent(QFocusEvent * /*unused*/) override;
115
116private:
120 Poco::NObserver<WorkspaceSelector, Mantid::API::ClearADSNotification> m_clearObserver;
123
124 bool m_init;
125 bool m_connected;
126
128 QStringList m_workspaceTypes;
130 bool m_showHidden;
131 // show/hide workspace groups
132 bool m_showGroups;
134 bool m_optional;
136 bool m_sorted;
138 std::pair<int, int> m_binLimits;
139 QStringList m_suffix;
140 QString m_algName;
141 QString m_algPropName;
142
143 // Algorithm to validate against
144 std::shared_ptr<Mantid::API::Algorithm> m_algorithm;
145
146 // Mutex for synchronized event handling
147 std::mutex m_adsMutex;
148};
149} // namespace MantidWidgets
150} // namespace MantidQt
std::string name
Definition Run.cpp:60
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
This class defines a widget for selecting a workspace of file path by using a combination of two chil...
This class defines a widget for selecting a workspace present in the AnalysisDataService.
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
AddNotification is sent after an new object is added to the data service.
Definition DataService.h:96
AfterReplaceNotification is sent after an object is replaced in the addOrReplace() function.
Clear notification is sent when the service is cleared.
PostDeleteNotification is sent after an object is deleted from the data service.
Rename notification is sent when the rename method is called.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AfterReplaceNotification > & WorkspaceAfterReplaceNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::ClearNotification > & ClearADSNotification_ptr
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::RenameNotification > & WorkspaceRenameNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AddNotification > & WorkspaceAddNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::PostDeleteNotification > & WorkspacePostDeleteNotification_ptr
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.