From d911f0e83f9973cfd92a27e518c430b7fbe5c7dd Mon Sep 17 00:00:00 2001 From: Nicolas Vuaille Date: Wed, 5 Feb 2025 15:24:32 +0100 Subject: [PATCH 1/3] Allow pqPVApplicationCore override in pv based app --- CMake/ParaViewClient.cmake | 30 +++++++++++++++++-- CMake/paraview_client_initializer.cxx.in | 6 ++-- .../release/dev/custom-applicationcore.md | 11 +++++++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 Documentation/release/dev/custom-applicationcore.md diff --git a/CMake/ParaViewClient.cmake b/CMake/ParaViewClient.cmake index 965e1bfed46..e047ff8e02e 100644 --- a/CMake/ParaViewClient.cmake +++ b/CMake/ParaViewClient.cmake @@ -14,8 +14,10 @@ paraview_client_add( [APPLICATION_XMLS ...] [QCH_FILES ...] - [MAIN_WINDOW_CLASS ] - [MAIN_WINDOW_INCLUDE ] + [MAIN_WINDOW_CLASS ] + [MAIN_WINDOW_INCLUDE ] + [APPLICATION_CORE_CLASS ] + [APPLICATION_CORE_INCLUDE ] [PLUGINS_TARGETS ...] [REQUIRED_PLUGINS ...] @@ -55,6 +57,10 @@ paraview_client_add( * `MAIN_WINDOW_INCLUDE`: (Defaults to `QMainWindow` or `.h` if it is specified) The include file for the main window. + * `APPLICATION_CORE_CLASS` (Defaults to `pqPVApplicationCore`) The name + of the application core class. + * `APPLICATION_CORE_INCLUDE` (Defaults to `pqPVApplicationCore.h`) The include + file for the application core class. * `PLUGINS_TARGETS`: The targets for plugins. The associated functions will be called upon startup. * `REQUIRED_PLUGINS`: Plugins to load upon startup. @@ -92,7 +98,7 @@ paraview_client_add( function (paraview_client_add) cmake_parse_arguments(_paraview_client "" - "NAME;APPLICATION_NAME;ORGANIZATION;TITLE;SPLASH_IMAGE;BUNDLE_DESTINATION;BUNDLE_ICON;BUNDLE_PLIST;APPLICATION_ICON;MAIN_WINDOW_CLASS;MAIN_WINDOW_INCLUDE;VERSION;FORCE_UNIX_LAYOUT;PLUGINS_TARGET;DEFAULT_STYLE;RUNTIME_DESTINATION;LIBRARY_DESTINATION;NAMESPACE;EXPORT;TRANSLATION_TARGET;TRANSLATE_XML;TRANSLATIONS_DIRECTORY" + "NAME;APPLICATION_NAME;ORGANIZATION;TITLE;SPLASH_IMAGE;BUNDLE_DESTINATION;BUNDLE_ICON;BUNDLE_PLIST;APPLICATION_ICON;MAIN_WINDOW_CLASS;MAIN_WINDOW_INCLUDE;APPLICATION_CORE_CLASS;APPLICATION_CORE_INCLUDE;VERSION;FORCE_UNIX_LAYOUT;PLUGINS_TARGET;DEFAULT_STYLE;RUNTIME_DESTINATION;LIBRARY_DESTINATION;NAMESPACE;EXPORT;TRANSLATION_TARGET;TRANSLATE_XML;TRANSLATIONS_DIRECTORY" "REQUIRED_PLUGINS;OPTIONAL_PLUGINS;APPLICATION_XMLS;SOURCES;QCH_FILES;QCH_FILE;PLUGINS_TARGETS" ${ARGN}) @@ -195,6 +201,24 @@ function (paraview_client_add) "${_paraview_client_MAIN_WINDOW_CLASS}.h") endif () + if (NOT DEFINED _paraview_client_APPLICATION_CORE_CLASS) + if (DEFINED _paraview_client_APPLICATION_CORE_INCLUDE) + message(FATAL_ERROR + "The `APPLICATION_CORE_INCLUDE` argument cannot be specified without " + "`APPLICATION_CORE_CLASS`.") + endif () + + set(_paraview_client_APPLICATION_CORE_CLASS + "pqPVApplicationCore") + set(_paraview_client_APPLICATION_CORE_INCLUDE + "pqPVApplicationCore.h") + endif () + + if (NOT DEFINED _paraview_client_APPLICATION_CORE_INCLUDE) + set(_paraview_client_APPLICATION_CORE_INCLUDE + "${_paraview_client_APPLICATION_CORE_CLASS}.h") + endif () + set(_paraview_client_extra_sources) set(_paraview_client_bundle_args) diff --git a/CMake/paraview_client_initializer.cxx.in b/CMake/paraview_client_initializer.cxx.in index 975922f1628..9fc9ad2bfeb 100644 --- a/CMake/paraview_client_initializer.cxx.in +++ b/CMake/paraview_client_initializer.cxx.in @@ -15,7 +15,7 @@ #include "@_paraview_client_MAIN_WINDOW_INCLUDE@" -#include "pqPVApplicationCore.h" +#include "@_paraview_client_APPLICATION_CORE_INCLUDE@" #include "pqPluginManager.h" #include "pqQtDeprecated.h" #include "pqSettings.h" @@ -58,8 +58,8 @@ pq@_paraview_client_NAME@Initializer::Status pq@_paraview_client_NAME@Initialize { try { - vtkVLogScopeF(PARAVIEW_LOG_APPLICATION_VERBOSITY(), "initialize pqPVApplicationCore"); - this->PVApp = new pqPVApplicationCore (argc, argv); + vtkVLogScopeF(PARAVIEW_LOG_APPLICATION_VERBOSITY(), "initialize @_paraview_client_APPLICATION_CORE_CLASS@"); + this->PVApp = new @_paraview_client_APPLICATION_CORE_CLASS@ (argc, argv); } catch (const pqApplicationCoreExitCode& exitCode) { diff --git a/Documentation/release/dev/custom-applicationcore.md b/Documentation/release/dev/custom-applicationcore.md new file mode 100644 index 00000000000..547945cfec6 --- /dev/null +++ b/Documentation/release/dev/custom-applicationcore.md @@ -0,0 +1,11 @@ +## Custom ApplicationCore class for ParaView based application + +ParaView based application already can specify a `MAIN_WINDOW_CLASS` +in `paraview_client_add` CMake method. This is in fact the main point of a those kind of app. + +You can now also specify a `APPLICATION_CORE_CLASS`, that should subclass +the `pqPVApplicationCore` default class. + +It is useful to control core features at creation, before the end of the initialization. +An example is using or not the app version in the settings filename. +(see pqApplicationCore::useVersionedSettings) -- GitLab From 1354f7997c037a1967780594ce15c405fe320235 Mon Sep 17 00:00:00 2001 From: Nicolas Vuaille Date: Wed, 5 Feb 2025 15:26:52 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Illustrate=20APPLICATION=5FCORE=5FCLASS?= =?UTF-8?q?=E2=80=AFin=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also test the "unversioned" settings behavior. --- Examples/CustomApplications/Clone1/CMakeLists.txt | 4 ++++ Examples/CustomApplications/Clone1/Testing/CMakeLists.txt | 2 +- Examples/CustomApplications/Clone1/myApplication.cxx | 7 +++++++ Examples/CustomApplications/Clone1/myApplication.h | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Examples/CustomApplications/Clone1/myApplication.cxx create mode 100644 Examples/CustomApplications/Clone1/myApplication.h diff --git a/Examples/CustomApplications/Clone1/CMakeLists.txt b/Examples/CustomApplications/Clone1/CMakeLists.txt index 0c7d980b3c1..a44a5ee66fb 100644 --- a/Examples/CustomApplications/Clone1/CMakeLists.txt +++ b/Examples/CustomApplications/Clone1/CMakeLists.txt @@ -20,6 +20,8 @@ set(CMAKE_AUTOMOC 1) set(CMAKE_AUTOUIC 1) set(sources + myApplication.cxx + myApplication.h myMainWindow.cxx myMainWindow.h) set(ui_files @@ -39,6 +41,8 @@ paraview_client_add( SOURCES ${sources} ${ui_files} APPLICATION_XMLS ${xml_files} MAIN_WINDOW_CLASS myMainWindow + APPLICATION_CORE_CLASS myApplicationCore + APPLICATION_CORE_INCLUDE "myApplication.h" ORGANIZATION ${organization_name} TITLE "ParaView (ReVisEd)") diff --git a/Examples/CustomApplications/Clone1/Testing/CMakeLists.txt b/Examples/CustomApplications/Clone1/Testing/CMakeLists.txt index 6bf192de4d2..dadbae22b5d 100644 --- a/Examples/CustomApplications/Clone1/Testing/CMakeLists.txt +++ b/Examples/CustomApplications/Clone1/Testing/CMakeLists.txt @@ -20,7 +20,7 @@ set(suffix "-dr") # Custom configuration file that makes "advanced" properties visible by default configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/${app_name}.ini.in" - "${SiteSettingsDir}/${organization_name}/${app_name}${app_version}${suffix}.ini" @ONLY) + "${SiteSettingsDir}/${organization_name}/${app_name}${suffix}.ini" @ONLY) # Custom configuration file that overrides some SphereSource property visibilities. configure_file( diff --git a/Examples/CustomApplications/Clone1/myApplication.cxx b/Examples/CustomApplications/Clone1/myApplication.cxx new file mode 100644 index 00000000000..54d14a6ced1 --- /dev/null +++ b/Examples/CustomApplications/Clone1/myApplication.cxx @@ -0,0 +1,7 @@ +#include + +myApplicationCore::myApplicationCore(int argc, char* argv[]) + : pqPVApplicationCore(argc, argv) +{ + this->useVersionedSettings(false); +} diff --git a/Examples/CustomApplications/Clone1/myApplication.h b/Examples/CustomApplications/Clone1/myApplication.h new file mode 100644 index 00000000000..a690bea724f --- /dev/null +++ b/Examples/CustomApplications/Clone1/myApplication.h @@ -0,0 +1,7 @@ +#include + +class myApplicationCore : public pqPVApplicationCore +{ +public: + myApplicationCore(int argc, char* argv[]); +}; -- GitLab From d6fe6f8e54aa025c6cb77fd33e62386928ef375c Mon Sep 17 00:00:00 2001 From: Nicolas Vuaille Date: Thu, 27 Feb 2025 14:23:50 +0100 Subject: [PATCH 3/3] StandardPath logs using dynamic Application verbosity --- Remoting/Application/vtkPVStandardPaths.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Remoting/Application/vtkPVStandardPaths.cxx b/Remoting/Application/vtkPVStandardPaths.cxx index ea156573d43..1bdc3e48883 100644 --- a/Remoting/Application/vtkPVStandardPaths.cxx +++ b/Remoting/Application/vtkPVStandardPaths.cxx @@ -21,7 +21,7 @@ std::string GetWindowsUserSettingsDirectory() std::string appData; if (vtksys::SystemTools::GetEnv("APPDATA", appData)) { - vtkLog(TRACE, << "found APPDATA env: " << appData); + vtkVLog(PARAVIEW_LOG_APPLICATION_VERBOSITY(), << "found APPDATA env: " << appData); std::string separator("\\"); if (appData[appData.size() - 1] != separator[0]) { @@ -42,7 +42,7 @@ std::vector GetWindowsSystemDirectories() // https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid if (vtksys::SystemTools::GetEnv("COMMON_APPDATA", appData)) { - vtkLog(TRACE, << "found COMMON_APPDATA env: " << appData); + vtkVLog(PARAVIEW_LOG_APPLICATION_VERBOSITY(), << "found COMMON_APPDATA env: " << appData); paths.push_back(appData); } @@ -61,7 +61,8 @@ std::string GetUnixUserSettingsDirectory() std::string xdgConfigHome; if (vtksys::SystemTools::GetEnv("XDG_CONFIG_HOME", xdgConfigHome)) { - vtkLog(TRACE, << "found XDG_CONFIG_HOME env: " << xdgConfigHome); + vtkVLog( + PARAVIEW_LOG_APPLICATION_VERBOSITY(), << "found XDG_CONFIG_HOME env: " << xdgConfigHome); directoryPath = xdgConfigHome; if (directoryPath[directoryPath.size() - 1] != separator[0]) { @@ -75,7 +76,7 @@ std::string GetUnixUserSettingsDirectory() { return std::string(); } - vtkLog(TRACE, << "found HOME env: " << home); + vtkVLog(PARAVIEW_LOG_APPLICATION_VERBOSITY(), << "found HOME env: " << home); directoryPath = home; if (directoryPath[directoryPath.size() - 1] != separator[0]) { @@ -95,7 +96,7 @@ std::vector GetUnixSystemDirectories() std::string dataDirs; if (vtksys::SystemTools::GetEnv("XDG_DATA_DIRS", dataDirs)) { - vtkLog(TRACE, << "found XDG_DATA_DIRS env: " << dataDirs); + vtkVLog(PARAVIEW_LOG_APPLICATION_VERBOSITY(), << "found XDG_DATA_DIRS env: " << dataDirs); std::string envDir(dataDirs); std::vector dirs = vtksys::SystemTools::SplitString(envDir, ':'); for (const std::string& directory : dirs) -- GitLab