Add python shell qt window

This commit is contained in:
baldurk
2017-04-19 18:03:19 +01:00
parent 31050d651e
commit 2a4596e06a
13 changed files with 858 additions and 4 deletions
+24
View File
@@ -42,6 +42,7 @@
#include "Windows/MainWindow.h"
#include "Windows/PipelineState/PipelineStateViewer.h"
#include "Windows/PixelHistoryView.h"
#include "Windows/PythonShell.h"
#include "Windows/ShaderViewer.h"
#include "Windows/StatisticsViewer.h"
#include "Windows/TextureViewer.h"
@@ -732,6 +733,18 @@ IStatisticsViewer *CaptureContext::GetStatisticsViewer()
return m_StatisticsViewer;
}
IPythonShell *CaptureContext::GetPythonShell()
{
if(m_PythonShell)
return m_PythonShell;
m_PythonShell = new PythonShell(*this, m_MainWindow);
m_PythonShell->setObjectName("pythonShell");
setupDockWindow(m_PythonShell);
return m_PythonShell;
}
void CaptureContext::ShowEventBrowser()
{
m_MainWindow->showEventBrowser();
@@ -772,6 +785,11 @@ void CaptureContext::ShowStatisticsViewer()
m_MainWindow->showStatisticsViewer();
}
void CaptureContext::ShowPythonShell()
{
m_MainWindow->showPythonShell();
}
IShaderViewer *CaptureContext::EditShader(bool customShader, const QString &entryPoint,
const QStringMap &files,
IShaderViewer::SaveCallback saveCallback,
@@ -865,6 +883,10 @@ QWidget *CaptureContext::CreateBuiltinWindow(const QString &objectName)
{
return GetStatisticsViewer()->Widget();
}
else if(objectName == "pythonShell")
{
return GetPythonShell()->Widget();
}
return NULL;
}
@@ -887,6 +909,8 @@ void CaptureContext::BuiltinWindowClosed(QWidget *window)
m_DebugMessageView = NULL;
else if(m_StatisticsViewer && m_StatisticsViewer->Widget() == window)
m_StatisticsViewer = NULL;
else if(m_PythonShell && m_PythonShell->Widget() == window)
m_PythonShell = NULL;
else
qCritical() << "Unrecognised window being closed: " << window;
}
+5
View File
@@ -46,6 +46,7 @@ class TextureViewer;
class CaptureDialog;
class DebugMessageView;
class StatisticsViewer;
class PythonShell;
QString ConfigFilePath(const QString &filename);
@@ -128,6 +129,7 @@ public:
ICaptureDialog *GetCaptureDialog() override;
IDebugMessageView *GetDebugMessageView() override;
IStatisticsViewer *GetStatisticsViewer() override;
IPythonShell *GetPythonShell() override;
bool HasEventBrowser() override { return m_EventBrowser != NULL; }
bool HasAPIInspector() override { return m_APIInspector != NULL; }
@@ -137,6 +139,7 @@ public:
bool HasCaptureDialog() override { return m_CaptureDialog != NULL; }
bool HasDebugMessageView() override { return m_DebugMessageView != NULL; }
bool HasStatisticsViewer() override { return m_StatisticsViewer != NULL; }
bool HasPythonShell() override { return m_PythonShell != NULL; }
void ShowEventBrowser() override;
void ShowAPIInspector() override;
void ShowTextureViewer() override;
@@ -145,6 +148,7 @@ public:
void ShowCaptureDialog() override;
void ShowDebugMessageView() override;
void ShowStatisticsViewer() override;
void ShowPythonShell() override;
IShaderViewer *EditShader(bool customShader, const QString &entryPoint, const QStringMap &files,
IShaderViewer::SaveCallback saveCallback,
@@ -265,4 +269,5 @@ private:
CaptureDialog *m_CaptureDialog = NULL;
DebugMessageView *m_DebugMessageView = NULL;
StatisticsViewer *m_StatisticsViewer = NULL;
PythonShell *m_PythonShell = NULL;
};
+31
View File
@@ -318,6 +318,21 @@ protected:
DECLARE_REFLECTION_STRUCT(IStatisticsViewer);
DOCUMENT("The interactive python shell.");
struct IPythonShell
{
DOCUMENT(
"Retrieves the QWidget for this :class:`PythonShell` if PySide2 is available, or "
"``None``.");
virtual QWidget *Widget() = 0;
protected:
IPythonShell() = default;
~IPythonShell() = default;
};
DECLARE_REFLECTION_STRUCT(IPythonShell);
DOCUMENT(R"(A shader window used for viewing, editing, or debugging.
.. function:: SaveCallback(context, viewer, files)
@@ -990,6 +1005,13 @@ as well as messages generated during replay and analysis.
)");
virtual IStatisticsViewer *GetStatisticsViewer() = 0;
DOCUMENT(R"(Retrieve the current singleton :class:`PythonShell`.
:return: The current window, which is created (but not shown) it there wasn't one open.
:rtype: PythonShell
)");
virtual IPythonShell *GetPythonShell() = 0;
DOCUMENT(R"(Check if there is a current :class:`EventBrowser` open.
:return: ``True`` if there is a window open.
@@ -1046,6 +1068,13 @@ as well as messages generated during replay and analysis.
)");
virtual bool HasStatisticsViewer() = 0;
DOCUMENT(R"(Check if there is a current :class:`PythonShell` open.
:return: ``True`` if there is a window open.
:rtype: ``bool``
)");
virtual bool HasPythonShell() = 0;
DOCUMENT("Raise the current :class:`EventBrowser`, showing it in the default place if needed.");
virtual void ShowEventBrowser() = 0;
DOCUMENT("Raise the current :class:`APIInspector`, showing it in the default place if needed.");
@@ -1064,6 +1093,8 @@ as well as messages generated during replay and analysis.
DOCUMENT(
"Raise the current :class:`StatisticsViewer`, showing it in the default place if needed.");
virtual void ShowStatisticsViewer() = 0;
DOCUMENT("Raise the current :class:`PythonShell`, showing it in the default place if needed.");
virtual void ShowPythonShell() = 0;
DOCUMENT(R"(Show a new :class:`ShaderViewer` window, showing an editable view of a given shader.
@@ -424,6 +424,11 @@ void PythonContext::GlobalShutdown()
Py_Finalize();
}
QString PythonContext::versionString()
{
return QString("%1.%2.%3").arg(PY_MAJOR_VERSION).arg(PY_MINOR_VERSION).arg(PY_MICRO_VERSION);
}
void PythonContext::executeString(const QString &filename, const QString &source, bool interactive)
{
if(!initialised())
@@ -55,6 +55,8 @@ public:
static void GlobalInit();
static void GlobalShutdown();
QString versionString();
template <typename T>
void setGlobal(const char *varName, T *object)
{