-----------------------------------------------------------------------------
| 102 | |
| 103 | //----------------------------------------------------------------------------- |
| 104 | bool 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 | //----------------------------------------------------------------------------- |
| 159 | vtkSMProxy* pqSaveStateReaction::createPythonStateOptions(bool interactive) |
nothing calls this directly
no test coverage detected