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 QStringList getWorkspaceTypes() const;
68 void setWorkspaceTypes(const QStringList &types);
69 bool showHiddenWorkspaces() const;
70 void showHiddenWorkspaces(bool show);
71 bool showWorkspaceGroups() const;
72 void showWorkspaceGroups(bool show);
73 bool isOptional() const;
74 void setOptional(bool optional);
75 bool isSorted() const;
76 void setSorted(bool sorted);
77 QStringList getSuffixes() const;
78 void setSuffixes(const QStringList &suffix);
79 void setLowerBinLimit(int numberOfBins);
80 void setUpperBinLimit(int numberOfBins);
81 QString getValidatingAlgorithm() const;
82 void setValidatingAlgorithm(const QString &algName);
83 bool isValid() const;
84 void refresh();
85 void disconnectObservers();
86 void connectObservers();
87 bool isConnected() const;
88
89signals:
90 void emptied();
91 void focussed();
92
93private:
94 void handleAddEvent(Mantid::API::WorkspaceAddNotification_ptr pNf);
95 void handleRemEvent(Mantid::API::WorkspacePostDeleteNotification_ptr pNf);
96 void handleClearEvent(Mantid::API::ClearADSNotification_ptr pNf);
97 void handleRenameEvent(Mantid::API::WorkspaceRenameNotification_ptr pNf);
98 void handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf);
99
100 bool checkEligibility(const QString &name, const Mantid::API::Workspace_sptr &object) const;
101 bool hasValidSuffix(const QString &name) const;
102 bool hasValidNumberOfBins(const Mantid::API::Workspace_sptr &object) const;
103
104protected:
105 // Method for handling drop events
106 void dropEvent(QDropEvent * /*unused*/) override;
107 // called when a drag event enters the class
108 void dragEnterEvent(QDragEnterEvent * /*unused*/) override;
109 // Method for handling focus in events
110 void focusInEvent(QFocusEvent * /*unused*/) override;
111
112private:
116 Poco::NObserver<WorkspaceSelector, Mantid::API::ClearADSNotification> m_clearObserver;
119
120 bool m_init;
121 bool m_connected;
122
124 QStringList m_workspaceTypes;
126 bool m_showHidden;
127 // show/hide workspace groups
128 bool m_showGroups;
130 bool m_optional;
132 bool m_sorted;
134 std::pair<int, int> m_binLimits;
135 QStringList m_suffix;
136 QString m_algName;
137 QString m_algPropName;
138
139 // Algorithm to validate against
140 std::shared_ptr<Mantid::API::Algorithm> m_algorithm;
141
142 // Mutex for synchronized event handling
143 std::mutex m_adsMutex;
144};
145} // namespace MantidWidgets
146} // namespace MantidQt
#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...
Definition: DataSelector.h:35
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:85
AddNotification is sent after an new object is added to the data service.
Definition: DataService.h:97
AfterReplaceNotification is sent after an object is replaced in the addOrReplace() function.
Definition: DataService.h:128
Clear notification is sent when the service is cleared.
Definition: DataService.h:163
PostDeleteNotification is sent after an object is deleted from the data service.
Definition: DataService.h:156
Rename notification is sent when the rename method is called.
Definition: DataService.h:169
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
Definition: Workspace_fwd.h:20
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.
Definition: Algorithm.h:30
STL namespace.