#include "sceneIndexObserverLoggingTreeView.h"
#include "pxr/imaging/hd/filteringSceneIndex.h"
+#include "pxr/imaging/hd/utils.h"
+#include "pxr/base/arch/fileSystem.h"
#include "pxr/base/tf/stringUtils.h"
#include <QHBoxLayout>
#include <QSplitter>
#include <QWidgetAction>
+#include <fstream>
#include <iostream>
#include <sstream>
#include <typeinfo>
QPushButton * loggerButton = new QPushButton("Show Notice Logger");
toolbarLayout->addWidget(loggerButton);
+ QPushButton * writeToFileButton = new QPushButton("Write to file");
+ toolbarLayout->addWidget(writeToFileButton);
+
toolbarLayout->addStretch();
QSplitter * splitter = new QSplitter(Qt::Horizontal);
this->_currentSceneIndex);
}
});
+
+ QObject::connect(writeToFileButton, &QPushButton::clicked,
+ [this](){
+ const HdSceneIndexBaseRefPtr si = this->_currentSceneIndex;
+ if (si) {
+ const std::string fileNamePrefix =
+ "si_" + si->GetDisplayName() + "_";
+
+ std::string filePath;
+ if (ArchMakeTmpFile(fileNamePrefix, &filePath) == -1) {
+ TF_RUNTIME_ERROR(
+ "Could not create file to write out scene index.");
+ return;
+ }
+
+ // XXX May be useful to allow a subtree to be dumped.
+ // For now, use the absolute root.
+ const SdfPath &rootPath = SdfPath::AbsoluteRootPath();
+
+ std::fstream output(filePath, std::ios::out);
+ HdUtils::PrintSceneIndex(output, si, rootPath);
+ output.close();
+
+ std::cerr << "Wrote scene index contents to "
+ << filePath << std::endl;
+ }
+ });
}
void
#include "pxr/imaging/hd/sceneGlobalsSchema.h"
#include "pxr/imaging/hd/sceneIndex.h"
+#include "pxr/imaging/hd/sceneIndexPrimView.h"
#include "pxr/imaging/hd/tokens.h"
-#include "pxr/usd/sdf/path.h"
-
PXR_NAMESPACE_OPEN_SCOPE
namespace HdUtils {
return CameraUtilFit;
}
+void
+PrintSceneIndex(
+ std::ostream &out,
+ const HdSceneIndexBaseRefPtr &si,
+ const SdfPath &rootPath /* = SdfPath::AbsoluteRootPath()*/)
+{
+ // Traverse the scene index to populate a lexicographically
+ // ordered path set.
+ SdfPathSet primPathSet;
+ HdSceneIndexPrimView view(si, rootPath);
+ for (auto it = view.begin(); it != view.end(); ++it) {
+ const SdfPath &primPath = *it;
+ primPathSet.insert(primPath);
+ }
+
+ // Write out each prim without indenting it based on its depth in the
+ // hierarchy for ease of readability,
+ for (const SdfPath &primPath : primPathSet) {
+ HdSceneIndexPrim prim = si->GetPrim(primPath);
+ if (prim.dataSource) {
+ out << "<" << primPath << "> type = " << prim.primType << std::endl;
+
+ HdDebugPrintDataSource(out, prim.dataSource, /* indent = */1);
+ }
+ }
+}
+
+
}
PXR_NAMESPACE_CLOSE_SCOPE
#include "pxr/imaging/cameraUtil/conformWindow.h"
#include "pxr/base/tf/declarePtrs.h"
+#include "pxr/usd/sdf/path.h"
+#include <iosfwd>
#include <memory>
#include <string>
#include <unordered_map>
TF_DECLARE_REF_PTRS(HdSceneIndexBase);
-class SdfPath;
class TfToken;
namespace HdUtils {
/// Translate the given aspect ratio conform policy \p token into an equivalent
/// CameraUtilConformWindowPolicy enum.
+///
HD_API
CameraUtilConformWindowPolicy
ToConformWindowPolicy(const TfToken &token);
+/// Lexicographically sorts the scene index prims in the subtree rooted at
+/// \p rootPath and writes them out.
+///
+HD_API
+void
+PrintSceneIndex(
+ std::ostream &out,
+ const HdSceneIndexBaseRefPtr &si,
+ const SdfPath &rootPath = SdfPath::AbsoluteRootPath());
+
}
PXR_NAMESPACE_CLOSE_SCOPE