Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodesk: Make Hydra Scene Browser source files usable in independent builds #2689

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions extras/imaging/examples/hdui/api.h
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion extras/imaging/examples/hdui/dataSourceTreeWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QTreeWidget>

PXR_NAMESPACE_OPEN_SCOPE

class HduiDataSourceTreeWidget : public QTreeWidget
class HDUI_API HduiDataSourceTreeWidget : public QTreeWidget
{
Q_OBJECT;

Expand Down
7 changes: 4 additions & 3 deletions extras/imaging/examples/hdui/dataSourceValueTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <QAbstractItemModel>
#include <QHeaderView>
#include <QString>

#include <sstream>

Expand Down Expand Up @@ -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()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use a string type that supports UTF-8 identifiers? Tagging @erslavin for thoughts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; in fact it turns out that using UTF-8 strings is actually what Qt5 is doing under the hood in those cases (see the Qt5 documentation for QVariant, confirmed by a Qt employee). We've changed it to do the same, just explicitly, so that it works for both Qt5 and Qt6, and regardless of whether QT_NO_CAST_FROM_ASCII is set or not.

}
}

Expand Down Expand Up @@ -141,7 +142,7 @@ class Hdui_TypedArrayValueItemModel : public Hdui_ValueItemModel
if (index.row() < static_cast<int>(_array.size())) {
std::ostringstream buffer;
buffer << _array.cdata()[index.row()];
return QVariant(buffer.str().data());
return QVariant(QLatin1String(buffer.str().data()));
}
}

Expand All @@ -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()));
}
}

Expand Down
4 changes: 3 additions & 1 deletion extras/imaging/examples/hdui/dataSourceValueTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QTreeView>

PXR_NAMESPACE_OPEN_SCOPE

class HduiDataSourceValueTreeView : public QTreeView
class HDUI_API HduiDataSourceValueTreeView : public QTreeView
{
Q_OBJECT;
public:
Expand Down
4 changes: 3 additions & 1 deletion extras/imaging/examples/hdui/registeredSceneIndexChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
#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 <QPushButton>
#include <QMenu>

PXR_NAMESPACE_OPEN_SCOPE

class HduiRegisteredSceneIndexChooser : public QPushButton
class HDUI_API HduiRegisteredSceneIndexChooser : public QPushButton
{
Q_OBJECT;
public:
Expand Down
2 changes: 1 addition & 1 deletion extras/imaging/examples/hdui/sceneIndexDebuggerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 3 additions & 1 deletion extras/imaging/examples/hdui/sceneIndexDebuggerWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QLabel>
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QTreeView>

PXR_NAMESPACE_OPEN_SCOPE

class HduiSceneIndexObserverLoggingTreeView : public QTreeView
class HDUI_API HduiSceneIndexObserverLoggingTreeView : public QTreeView
{
Q_OBJECT;
public:
Expand All @@ -50,7 +52,7 @@ public Q_SLOTS:

private:

class _ObserverModel :
class HDUI_API _ObserverModel :
public HdSceneIndexObserver, public QAbstractItemModel
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QPushButton>
Expand All @@ -33,7 +35,7 @@ PXR_NAMESPACE_OPEN_SCOPE

class HduiSceneIndexObserverLoggingTreeView;

class HduiSceneIndexObserverLoggingWidget : public QWidget
class HDUI_API HduiSceneIndexObserverLoggingWidget : public QWidget
{
Q_OBJECT;
public:
Expand Down
3 changes: 2 additions & 1 deletion extras/imaging/examples/hdui/sceneIndexTreeWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -36,7 +37,7 @@ class Hdui_SceneIndexPrimTreeWidgetItem;

//-----------------------------------------------------------------------------

class HduiSceneIndexTreeWidget : public QTreeWidget, public HdSceneIndexObserver
class HDUI_API HduiSceneIndexTreeWidget : public QTreeWidget, public HdSceneIndexObserver
{
Q_OBJECT;
public:
Expand Down