MCPcopy Create free account
hub / github.com/Kitware/ParaView / savePythonState

Method savePythonState

Qt/ApplicationComponents/pqSaveStateReaction.cxx:104–156  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

102
103//-----------------------------------------------------------------------------
104bool pqSaveStateReaction::savePythonState(
105 const QString& filename, vtkSMProxy* options, vtkTypeUInt32 location)
106{
107#if VTK_MODULE_ENABLE_ParaView_pqPython
108 SCOPED_UNDO_EXCLUDE();
109 if (strcmp(options->GetXMLName(), "PythonStateOptions") != 0)
110 {
111 qCritical() << tr("Unable to read python state options.");
112 return false;
113 }
114
115 vtkSMTrace* tracer = vtkSMTrace::GetActiveTracer();
116 if (tracer)
117 {
118 QMessageBox::warning(pqCoreUtilities::mainWidget(),
119 tr("Trace and Python State incompatibility."),
120 tr("Save Python State can not work while Trace is active. Aborting."));
121
122 return false;
123 }
124
125 const std::string state = vtkSMTrace::GetState(options);
126 if (state.empty())
127 {
128 qWarning() << tr("Empty state generated.");
129 return false;
130 }
131
132 Q_EMIT pqApplicationCore::instance()->aboutToWriteState(filename);
133
134 vtkSMSessionProxyManager* pxm = pqActiveObjects::instance().proxyManager();
135 if (!pxm->SaveString(state.c_str(), filename.toStdString().c_str(), location))
136 {
137 qCritical() << tr("Failed to save state in %1").arg(filename);
138 return false;
139 }
140
141 pqServer* server = pqActiveObjects::instance().activeServer();
142 // Add this to the list of recent server resources ...
143 pqStandardRecentlyUsedResourceLoaderImplementation::addStateFileToRecentResources(
144 server, filename, location);
145
146 return true;
147
148#else
149 Q_UNUSED(location);
150 Q_UNUSED(options);
151 qCritical()
152 << tr("Failed to save '%1' since Python support is not enabled in this build.").arg(filename);
153
154 return false;
155#endif
156}
157
158//-----------------------------------------------------------------------------
159vtkSMProxy* pqSaveStateReaction::createPythonStateOptions(bool interactive)

Callers

nothing calls this directly

Calls 8

trFunction · 0.85
GetActiveTracerFunction · 0.85
mainWidgetFunction · 0.85
instanceFunction · 0.85
SaveStringMethod · 0.80
emptyMethod · 0.45
proxyManagerMethod · 0.45
activeServerMethod · 0.45

Tested by

no test coverage detected