From 1c3153c5dd51dac33f3276e66789b9fd891d13f9 Mon Sep 17 00:00:00 2001 From: debloip Date: Tue, 5 Sep 2023 15:01:21 -0400 Subject: [PATCH 1/3] Make Hydra Scene Browser source files usable in independent builds --- extras/imaging/examples/hdui/api.h | 47 +++++++++++++++++++ .../examples/hdui/dataSourceTreeWidget.h | 4 +- .../examples/hdui/dataSourceValueTreeView.cpp | 7 +-- .../examples/hdui/dataSourceValueTreeView.h | 4 +- .../hdui/registeredSceneIndexChooser.h | 4 +- .../hdui/sceneIndexDebuggerWidget.cpp | 2 +- .../examples/hdui/sceneIndexDebuggerWidget.h | 4 +- .../hdui/sceneIndexObserverLoggingTreeView.h | 6 ++- .../hdui/sceneIndexObserverLoggingWidget.h | 4 +- .../examples/hdui/sceneIndexTreeWidget.h | 3 +- 10 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 extras/imaging/examples/hdui/api.h diff --git a/extras/imaging/examples/hdui/api.h b/extras/imaging/examples/hdui/api.h new file mode 100644 index 0000000000..b390edc34c --- /dev/null +++ b/extras/imaging/examples/hdui/api.h @@ -0,0 +1,47 @@ +// +// Copyright 2023 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. +// +#ifndef EXTRAS_IMAGING_EXAMPLES_HDUI_API_H +#define EXTRAS_IMAGING_EXAMPLES_HDUI_API_H + +#include "pxr/base/arch/export.h" + +#if defined(PXR_STATIC) +# define HDUI_API +# define HDUI_API_TEMPLATE_CLASS(...) +# define HDUI_API_TEMPLATE_STRUCT(...) +# define HDUI_LOCAL +#else +# if defined(HDUI_EXPORTS) +# define HDUI_API ARCH_EXPORT +# define HDUI_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) +# define HDUI_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) +# else +# define HDUI_API ARCH_IMPORT +# define HDUI_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) +# define HDUI_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) +# endif +# define HDUI_LOCAL ARCH_HIDDEN +#endif + +#endif // EXTRAS_IMAGING_EXAMPLES_HDUI_API_H diff --git a/extras/imaging/examples/hdui/dataSourceTreeWidget.h b/extras/imaging/examples/hdui/dataSourceTreeWidget.h index 69c18563a0..2d0e119254 100644 --- a/extras/imaging/examples/hdui/dataSourceTreeWidget.h +++ b/extras/imaging/examples/hdui/dataSourceTreeWidget.h @@ -24,13 +24,15 @@ #ifndef PXR_IMAGING_HDUI_DATA_SOURCE_TREE_WIDGET_H #define PXR_IMAGING_HDUI_DATA_SOURCE_TREE_WIDGET_H +#include "api.h" + #include "pxr/imaging/hd/sceneIndex.h" #include PXR_NAMESPACE_OPEN_SCOPE -class HduiDataSourceTreeWidget : public QTreeWidget +class HDUI_API HduiDataSourceTreeWidget : public QTreeWidget { Q_OBJECT; diff --git a/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp b/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp index f33de26275..e939c865d1 100644 --- a/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp +++ b/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp @@ -26,6 +26,7 @@ #include #include +#include #include @@ -56,7 +57,7 @@ class Hdui_ValueItemModel : public QAbstractItemModel if (index.column() == 0) { std::ostringstream buffer; buffer << _value; - return QVariant(buffer.str().data()); + return QVariant(QLatin1String(buffer.str().data())); } } @@ -141,7 +142,7 @@ class Hdui_TypedArrayValueItemModel : public Hdui_ValueItemModel if (index.row() < static_cast(_array.size())) { std::ostringstream buffer; buffer << _array.cdata()[index.row()]; - return QVariant(buffer.str().data()); + return QVariant(QLatin1String(buffer.str().data())); } } @@ -154,7 +155,7 @@ class Hdui_TypedArrayValueItemModel : public Hdui_ValueItemModel if (section == 1) { std::ostringstream buffer; buffer << _array.size() << " values"; - return QVariant(buffer.str().c_str()); + return QVariant(QLatin1String(buffer.str().c_str())); } } diff --git a/extras/imaging/examples/hdui/dataSourceValueTreeView.h b/extras/imaging/examples/hdui/dataSourceValueTreeView.h index 28fe4d72ad..f711e8784c 100644 --- a/extras/imaging/examples/hdui/dataSourceValueTreeView.h +++ b/extras/imaging/examples/hdui/dataSourceValueTreeView.h @@ -24,13 +24,15 @@ #ifndef PXR_IMAGING_HDUI_DATA_SOURCE_VALUE_TREE_VIEW_H #define PXR_IMAGING_HDUI_DATA_SOURCE_VALUE_TREE_VIEW_H +#include "api.h" + #include "pxr/imaging/hd/dataSource.h" #include PXR_NAMESPACE_OPEN_SCOPE -class HduiDataSourceValueTreeView : public QTreeView +class HDUI_API HduiDataSourceValueTreeView : public QTreeView { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/registeredSceneIndexChooser.h b/extras/imaging/examples/hdui/registeredSceneIndexChooser.h index 6a4cf90fcd..40bbf8051f 100644 --- a/extras/imaging/examples/hdui/registeredSceneIndexChooser.h +++ b/extras/imaging/examples/hdui/registeredSceneIndexChooser.h @@ -24,6 +24,8 @@ #ifndef PXR_IMAGING_HDUI_REGISTERED_SCENE_INDEX_CHOOSER_H #define PXR_IMAGING_HDUI_REGISTERED_SCENE_INDEX_CHOOSER_H +#include "api.h" + #include "pxr/imaging/hd/sceneIndex.h" #include @@ -31,7 +33,7 @@ PXR_NAMESPACE_OPEN_SCOPE -class HduiRegisteredSceneIndexChooser : public QPushButton +class HDUI_API HduiRegisteredSceneIndexChooser : public QPushButton { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.cpp b/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.cpp index 2a01a10a90..8c2e367c4b 100644 --- a/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.cpp +++ b/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.cpp @@ -198,7 +198,7 @@ HduiSceneIndexDebuggerWidget::_FillGoToInputMenu() }); QObject::connect(menuTreeWidget, &QTreeWidget::itemClicked, - [this, menu, menuTreeWidget](QTreeWidgetItem *item, int column) { + [this, menu](QTreeWidgetItem *item, int column) { if (_InputSelectionItem *selectionItem = dynamic_cast<_InputSelectionItem*>(item)) { diff --git a/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h b/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h index cd3de3fe70..677c3647a8 100644 --- a/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h +++ b/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h @@ -24,6 +24,8 @@ #ifndef PXR_IMAGING_HDUI_SCENE_INDEX_DEBUGGING_WIDGET_H #define PXR_IMAGING_HDUI_SCENE_INDEX_DEBUGGING_WIDGET_H +#include "api.h" + #include "pxr/imaging/hd/sceneIndex.h" #include @@ -38,7 +40,7 @@ class HduiDataSourceTreeWidget; class HduiDataSourceValueTreeView; class HduiRegisteredSceneIndexChooser; -class HduiSceneIndexDebuggerWidget : public QWidget, public TfWeakBase +class HDUI_API HduiSceneIndexDebuggerWidget : public QWidget, public TfWeakBase { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h b/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h index ee93f3157a..3c5fc0d2f5 100644 --- a/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h +++ b/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h @@ -24,13 +24,15 @@ #ifndef PXR_IMAGING_HDUI_SCENE_INDEX_OBSERVER_LOGGING_TREE_VIEW_H #define PXR_IMAGING_HDUI_SCENE_INDEX_OBSERVER_LOGGING_TREE_VIEW_H +#include "api.h" + #include "pxr/imaging/hd/sceneIndex.h" #include PXR_NAMESPACE_OPEN_SCOPE -class HduiSceneIndexObserverLoggingTreeView : public QTreeView +class HDUI_API HduiSceneIndexObserverLoggingTreeView : public QTreeView { Q_OBJECT; public: @@ -50,7 +52,7 @@ public Q_SLOTS: private: - class _ObserverModel : + class HDUI_API _ObserverModel : public HdSceneIndexObserver, public QAbstractItemModel { public: diff --git a/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h b/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h index 78a957b6e2..0391c9d257 100644 --- a/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h +++ b/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h @@ -24,6 +24,8 @@ #ifndef PXR_IMAGING_HDUI_SCENE_INDEX_OBSERVER_LOGGING_WIDGET_H #define PXR_IMAGING_HDUI_SCENE_INDEX_OBSERVER_LOGGING_WIDGET_H +#include "api.h" + #include "pxr/pxr.h" #include @@ -33,7 +35,7 @@ PXR_NAMESPACE_OPEN_SCOPE class HduiSceneIndexObserverLoggingTreeView; -class HduiSceneIndexObserverLoggingWidget : public QWidget +class HDUI_API HduiSceneIndexObserverLoggingWidget : public QWidget { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/sceneIndexTreeWidget.h b/extras/imaging/examples/hdui/sceneIndexTreeWidget.h index 6653c1024a..5d535895f6 100644 --- a/extras/imaging/examples/hdui/sceneIndexTreeWidget.h +++ b/extras/imaging/examples/hdui/sceneIndexTreeWidget.h @@ -24,6 +24,7 @@ #ifndef PXR_IMAGING_HDUI_SCENE_INDEX_TREE_WIDGET_H #define PXR_IMAGING_HDUI_SCENE_INDEX_TREE_WIDGET_H +#include "api.h" #include "pxr/imaging/hd/sceneIndex.h" @@ -36,7 +37,7 @@ class Hdui_SceneIndexPrimTreeWidgetItem; //----------------------------------------------------------------------------- -class HduiSceneIndexTreeWidget : public QTreeWidget, public HdSceneIndexObserver +class HDUI_API HduiSceneIndexTreeWidget : public QTreeWidget, public HdSceneIndexObserver { Q_OBJECT; public: From 39da1a95da0dbffd3a3ab15625c2e99df9266893 Mon Sep 17 00:00:00 2001 From: debloip Date: Tue, 26 Sep 2023 14:49:11 -0400 Subject: [PATCH 2/3] Use UTF-8 strings for constructing QVariants using a char* --- extras/imaging/examples/hdui/dataSourceValueTreeView.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp b/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp index e939c865d1..cf54465858 100644 --- a/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp +++ b/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp @@ -57,7 +57,8 @@ class Hdui_ValueItemModel : public QAbstractItemModel if (index.column() == 0) { std::ostringstream buffer; buffer << _value; - return QVariant(QLatin1String(buffer.str().data())); + std::string str = buffer.str(); + return QVariant(QString::fromUtf8(str.data(), str.size())); } } @@ -142,7 +143,8 @@ class Hdui_TypedArrayValueItemModel : public Hdui_ValueItemModel if (index.row() < static_cast(_array.size())) { std::ostringstream buffer; buffer << _array.cdata()[index.row()]; - return QVariant(QLatin1String(buffer.str().data())); + std::string str = buffer.str(); + return QVariant(QString::fromUtf8(str.data(), str.size())); } } @@ -155,7 +157,8 @@ class Hdui_TypedArrayValueItemModel : public Hdui_ValueItemModel if (section == 1) { std::ostringstream buffer; buffer << _array.size() << " values"; - return QVariant(QLatin1String(buffer.str().c_str())); + std::string str = buffer.str(); + return QVariant(QString::fromUtf8(str.data(), str.size())); } } From ce77a7e3b3b1427c668be99645bff60f6f3bb94a Mon Sep 17 00:00:00 2001 From: debloip Date: Fri, 3 May 2024 15:05:38 -0400 Subject: [PATCH 3/3] Add HDUI_API_CLASS macro as synonym of HDUI_API for classes --- extras/imaging/examples/hdui/api.h | 2 ++ extras/imaging/examples/hdui/dataSourceTreeWidget.h | 2 +- extras/imaging/examples/hdui/dataSourceValueTreeView.h | 2 +- extras/imaging/examples/hdui/registeredSceneIndexChooser.h | 2 +- extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h | 2 +- .../imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h | 4 ++-- .../imaging/examples/hdui/sceneIndexObserverLoggingWidget.h | 2 +- extras/imaging/examples/hdui/sceneIndexTreeWidget.h | 2 +- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/extras/imaging/examples/hdui/api.h b/extras/imaging/examples/hdui/api.h index b390edc34c..8efca4880f 100644 --- a/extras/imaging/examples/hdui/api.h +++ b/extras/imaging/examples/hdui/api.h @@ -44,4 +44,6 @@ # define HDUI_LOCAL ARCH_HIDDEN #endif +#define HDUI_API_CLASS HDUI_API + #endif // EXTRAS_IMAGING_EXAMPLES_HDUI_API_H diff --git a/extras/imaging/examples/hdui/dataSourceTreeWidget.h b/extras/imaging/examples/hdui/dataSourceTreeWidget.h index 2d0e119254..0d429a9ecb 100644 --- a/extras/imaging/examples/hdui/dataSourceTreeWidget.h +++ b/extras/imaging/examples/hdui/dataSourceTreeWidget.h @@ -32,7 +32,7 @@ PXR_NAMESPACE_OPEN_SCOPE -class HDUI_API HduiDataSourceTreeWidget : public QTreeWidget +class HDUI_API_CLASS HduiDataSourceTreeWidget : public QTreeWidget { Q_OBJECT; diff --git a/extras/imaging/examples/hdui/dataSourceValueTreeView.h b/extras/imaging/examples/hdui/dataSourceValueTreeView.h index f711e8784c..45f3c0d6a7 100644 --- a/extras/imaging/examples/hdui/dataSourceValueTreeView.h +++ b/extras/imaging/examples/hdui/dataSourceValueTreeView.h @@ -32,7 +32,7 @@ PXR_NAMESPACE_OPEN_SCOPE -class HDUI_API HduiDataSourceValueTreeView : public QTreeView +class HDUI_API_CLASS HduiDataSourceValueTreeView : public QTreeView { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/registeredSceneIndexChooser.h b/extras/imaging/examples/hdui/registeredSceneIndexChooser.h index 40bbf8051f..86dd4ccdd6 100644 --- a/extras/imaging/examples/hdui/registeredSceneIndexChooser.h +++ b/extras/imaging/examples/hdui/registeredSceneIndexChooser.h @@ -33,7 +33,7 @@ PXR_NAMESPACE_OPEN_SCOPE -class HDUI_API HduiRegisteredSceneIndexChooser : public QPushButton +class HDUI_API_CLASS HduiRegisteredSceneIndexChooser : public QPushButton { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h b/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h index 677c3647a8..069900eae3 100644 --- a/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h +++ b/extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h @@ -40,7 +40,7 @@ class HduiDataSourceTreeWidget; class HduiDataSourceValueTreeView; class HduiRegisteredSceneIndexChooser; -class HDUI_API HduiSceneIndexDebuggerWidget : public QWidget, public TfWeakBase +class HDUI_API_CLASS HduiSceneIndexDebuggerWidget : public QWidget, public TfWeakBase { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h b/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h index 3c5fc0d2f5..e57f5814aa 100644 --- a/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h +++ b/extras/imaging/examples/hdui/sceneIndexObserverLoggingTreeView.h @@ -32,7 +32,7 @@ PXR_NAMESPACE_OPEN_SCOPE -class HDUI_API HduiSceneIndexObserverLoggingTreeView : public QTreeView +class HDUI_API_CLASS HduiSceneIndexObserverLoggingTreeView : public QTreeView { Q_OBJECT; public: @@ -52,7 +52,7 @@ public Q_SLOTS: private: - class HDUI_API _ObserverModel : + class HDUI_API_CLASS _ObserverModel : public HdSceneIndexObserver, public QAbstractItemModel { public: diff --git a/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h b/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h index 0391c9d257..e2236d750d 100644 --- a/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h +++ b/extras/imaging/examples/hdui/sceneIndexObserverLoggingWidget.h @@ -35,7 +35,7 @@ PXR_NAMESPACE_OPEN_SCOPE class HduiSceneIndexObserverLoggingTreeView; -class HDUI_API HduiSceneIndexObserverLoggingWidget : public QWidget +class HDUI_API_CLASS HduiSceneIndexObserverLoggingWidget : public QWidget { Q_OBJECT; public: diff --git a/extras/imaging/examples/hdui/sceneIndexTreeWidget.h b/extras/imaging/examples/hdui/sceneIndexTreeWidget.h index 5d535895f6..8a275ddc61 100644 --- a/extras/imaging/examples/hdui/sceneIndexTreeWidget.h +++ b/extras/imaging/examples/hdui/sceneIndexTreeWidget.h @@ -37,7 +37,7 @@ class Hdui_SceneIndexPrimTreeWidgetItem; //----------------------------------------------------------------------------- -class HDUI_API HduiSceneIndexTreeWidget : public QTreeWidget, public HdSceneIndexObserver +class HDUI_API_CLASS HduiSceneIndexTreeWidget : public QTreeWidget, public HdSceneIndexObserver { Q_OBJECT; public: