Mantid
Loading...
Searching...
No Matches
UserSubWindow.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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/* Used to register classes into the factory. Creates a global object in an
10 * anonymous namespace. The object itself does nothing, but the comma operator
11 * is used in the call to its constructor to effect a call to the factory's
12 * subscribe method.
13 */
14#define DECLARE_SUBWINDOW(classname) \
15 namespace { \
16 Mantid::Kernel::RegistrationHelper \
17 register_subwindow_##classname(((MantidQt::API::UserSubWindowFactory::Instance().subscribe<classname>()), 0)); \
18 }
19
20#define DECLARE_SUBWINDOW_AND_CODERS(classname, encodertype, decodertype, decodertag) \
21 namespace { \
22 Mantid::Kernel::RegistrationHelper register_subwindow_##classname( \
23 ((MantidQt::API::UserSubWindowFactory::Instance().subscribe<classname, encodertype, decodertype>(decodertag)), \
24 0)); \
25 }
26
27//----------------------------------
28// Includes
29//----------------------------------
30#include "DllOption.h"
31#include "PythonRunner.h"
33
34#include <QLabel>
35#include <QMainWindow>
36#include <QPointer>
37#include <QStringList>
38#include <QWidget>
39#include <set>
40
41//----------------------------------
42// Qt Forward declarations
43//----------------------------------
44
45//----------------------------------
46// Mantid Forward declarations
47//----------------------------------
48
49// Top-level namespace for this library
50namespace MantidQt {
51namespace MantidWidgets {
52class FitPropertyBrowser;
53}
54
55namespace API {
56
57//----------------------------------
58// Forward declarations
59//----------------------------------
60class InterfaceManager;
61
70class EXPORT_OPT_MANTIDQT_COMMON UserSubWindow : public QMainWindow {
71 Q_OBJECT
72
73public:
75 static std::string name() { return "UserSubWindow::name() default Reimplement static name() method."; }
77 static std::set<std::string> aliases() { return std::set<std::string>(); }
78
79public:
81 UserSubWindow(QWidget *parent = nullptr);
83 void initializeLayout();
86 void initializeLocalPython();
88 bool isInitialized() const;
90 bool isPyInitialized() const;
91
92signals:
94 void runAsPythonScript(const QString &code, bool /*_t2*/);
95
98
99protected:
101 virtual void initLayout() = 0;
103 virtual void initLocalPython() {}
104
106 virtual void otherUserSubWindowCreated(QPointer<UserSubWindow> window) { UNUSED_ARG(window); }
107
109 virtual void otherUserSubWindowCreated(QList<QPointer<UserSubWindow>> &windows) { UNUSED_ARG(windows); }
110
112 void showInformationBox(const QString &message) const;
113
116 QString runPythonCode(const QString &code, bool no_output = false);
117 QString openFileDialog(const bool save, const QStringList &exts);
118 QLabel *newValidator(QWidget *parent);
119
120private:
121 // This is so that it can set the name
122 // I can't pass anything as an argument to the constructor as I am using
123 // the DynamicFactory
124 friend class InterfaceManager;
125
127 void setInterfaceName(const QString &iface_name);
128
134 QString m_ifacename;
135
138};
139} // namespace API
140} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
This class is responsible for creating the correct dialog for an algorithm.
This is the base class all customised user interfaces that do not wish to be tied to a specific Manti...
Definition: PythonRunner.h:26
This is the base class all customised user interfaces that do not wish to be tied to a specific Manti...
Definition: UserSubWindow.h:70
void setFitPropertyBrowser(MantidQt::MantidWidgets::FitPropertyBrowser *browser)
Thrown when used fit property browser should be changed to given one.
void runAsPythonScript(const QString &code, bool)
Emitted to start a (generally small) script running.
static std::set< std::string > aliases()
A list of aliases.
Definition: UserSubWindow.h:77
QString m_ifacename
Store the name of the interface.
bool m_bIsInitialized
Has this already been initialized.
virtual void otherUserSubWindowCreated(QPointer< UserSubWindow > window)
To be overridden in order to connect a signal between two interfaces.
virtual void initLocalPython()
Run local Python setup code.
virtual void otherUserSubWindowCreated(QList< QPointer< UserSubWindow > > &windows)
To be overridden in order to connect a signal between two interfaces.
virtual void initLayout()=0
To be overridden to set the appropriate layout.
static std::string name()
Name of the interface.
Definition: UserSubWindow.h:75
PythonRunner m_pythonRunner
Python executor.
bool m_isPyInitialized
Has the python initialization been run.
Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function paramet...
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...