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

New Import UI feature - WIP #206

Merged
merged 9 commits into from
Feb 10, 2020

Conversation

seando-adsk
Copy link
Collaborator

MAYA-101325 - Implement Qt Model base class that supports/exposes a USD stage

MAYA-101326 - Implement filtering proxy on top of USD stage model

MAYA-101566 - Hook up the new Import pop-up dialog options to import command

MAYA-101565 - Add VariantSets to import dialog and allow selection of a Variant

  • Added new build flag --qt-location with corresponding define QT_LOCATION.

  • Building of Qt UI is optional based on 'CMAKE_WANT_QT_BUILD' (default ON) and QT_LOCATION being passed in.

  • Added optional SUBDIR arg when promoting files.

  • Created a USD ImportUI dialog from internal design.

  • Added usd/ui folder with new ImportUI dialog.

  • From the mayaUsd plugin register a new command to open the ImportUI dialog.

  • Added the mayaUsd translator import options based on design specs.

  • New import data, which supports:
    ** Root prim path.
    ** Stage population mask for importing partial usd file.
    ** Stage load set.
    ** Variant sets associated with root prim and invididual prims.
    ** Added clearData flag to usdImportDialog command.
    ** Merged variants into single column.
    ** Added ItemDelegate for customized widget creation for Variants. Use persistent editor with label/combobox for variant selection.
    ** Moved tree item creation logic from factory to tree item.
    ** Tree checking & stage population mask.
    ** New tree header with checkbox for load column - not hooked up yet.
    ** Commented out all the usd import options (for now) as none of them are implemented yet.

…SD stage

MAYA-101326 - Implement filtering proxy on top of USD stage model
MAYA-101566 - Hook up the new Import pop-up dialog options to import command
MAYA-101565 - Add VariantSets to import dialog and allow selection of a Variant

* Added new build flag --qt-location with corresponding define QT_LOCATION.
* Building of Qt UI is optional based on 'CMAKE_WANT_QT_BUILD' (default ON)
  and QT_LOCATION being passed in.
* Added optional SUBDIR arg when promoting files.
* Created a USD ImportUI dialog from internal design.
* Added usd/ui folder with new ImportUI dialog.
* From the mayaUsd plugin register a new command to open
  the ImportUI dialog.
* Added the mayaUsd translator import options based on design specs.

* New import data, which supports:
** Root prim path.
** Stage population mask for importing partial usd file.
** Stage load set.
** Variant sets associated with root prim and invididual prims.
** Added clearData flag to usdImportDialog command.
** Merged variants into single column.
** Added ItemDelegate for customized widget creation for Variants.
   Use persistent editor with label/combobox for variant selection.
** Moved tree item creation logic from factory to tree item.
** Tree checking & stage population mask.
** New tree header with checkbox for load column - not hooked up yet.
** Commented out all the usd import options (for now) as none
   of them are implemented yet.
@seando-adsk seando-adsk added the enhancement New feature or request label Jan 16, 2020
@@ -371,6 +375,9 @@ def RunTests(context,extraArgs):
parser.add_argument("--debug-python", dest="debug_python", action="store_true",
help="Define Boost Python Debug if your Python library comes with Debugging symbols (default: %(default)s).")

parser.add_argument("--qt-location", type=str,
help="Directory where Qt is installed.")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To build the new UI (which uses) Qt you need to specify where to find Qt (should be the same one that Maya is using).

@@ -169,19 +168,6 @@ find_path(MAYA_INCLUDE_DIR
"Maya's headers path"
)

find_path(MAYA_LIBRARY_DIR
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not needed. It is duplicated from above in each platform specific section.

@@ -0,0 +1,146 @@
//
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New file containing all the import data, such as root prim path, stage pop mask, variants, etc.

@@ -60,14 +60,12 @@ PXR_NAMESPACE_OPEN_SCOPE

UsdMaya_ReadJob::UsdMaya_ReadJob(
const std::string &iFileName,
const std::string &iPrimPath,
const std::map<std::string, std::string>& iVariants,
const MayaUsd::ImportData &iImportData,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You'll see a few changes like this. I've replaced the primPath and variants arg, with my new import data (which contains both those and more).

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't iFileName be lumped in with the import data also then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes good idea. I've moved it into import data.

@@ -103,7 +102,22 @@ UsdMaya_ReadJob::Read(std::vector<MDagPath>* addedDagPaths)

// Layer and Stage used to Read in the USD file
UsdStageCacheContext stageCacheContext(UsdMayaStageCache::Get());
UsdStageRefPtr stage = UsdStage::Open(rootLayer, sessionLayer);
UsdStageRefPtr stage;
if (mImportData.empty())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Change to how we open the stage depending on what the import data contains.

Copy link
Contributor

Choose a reason for hiding this comment

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

Following up on comments above, I'm not convinced the import data or the file name should ever be empty here. If we made it this far, then we must have a filename from the SdfLayer::FindOrOpen() above.

I think this could/should just be:

    if (mImportData.hasPopulationMask()) {
        stage = UsdStage::OpenMasked(
            rootLayer,
            sessionLayer,
            mImportData.stagePopulationMask(),
            mImportData.stageInitialLoadSet());
    } else {
        stage = UsdStage::Open(
            rootLayer,
            sessionLayer,
            mImportData.stageInitialLoadSet());
    }

The default load set for UsdStage::Open...() is LoadAll, so that hasn't changed here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes correct, now that I've moved the filename into the import data it won't be empty. I've changed the stage open as you've suggested.

Comment on lines +200 to +208
// Set the variants on all the import data prims.
for (auto& varPrim : mImportData.primVariantSelections()) {
for(auto& variant : varPrim.second) {
UsdPrim usdVarPrim = stage->GetPrimAtPath(varPrim.first);
usdVarPrim
.GetVariantSet(variant.first)
.SetVariantSelection(variant.second);
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New loop to set all the individual prim variants.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also following up from above, if root and non-root prim variant selections were unified, we'd only need the latter loop here.

Comment on lines 3 to 10
if(CMAKE_WANT_QT_BUILD)
if(DEFINED QT_LOCATION)
message(STATUS "Building with Qt UI features enabled.")
add_subdirectory(ui)
else()
message(STATUS "QT_LOCATION not set. Building UI features will be disabled.")
endif()
endif()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When the new cmake option is on (enabled by default) and we got a QT_LOCATION passed to build, we'll add the new "ui" subdir.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be more strongly enforced, and/or moved to the top-level CMakeLists.txt? Would it ever be meaningful to enable CMAKE_WANT_QT_BUILD and not specify a QT_LOCATION? Maybe that should be an error instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had originally added CMAKE_WANT_QT_BUILD to make it consistent with UFE, but they aren't really the same. We don't need this option, so I've removed it. I've moved the find_package(Qt5) to the top-level cmake and here I will include the folder "ui" only when Qt5_FOUND is true.

@@ -0,0 +1,47 @@
//
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New api file - similar to the one from lib folder.

Comment on lines +128 to +131
if (BUILD_TESTS)
# A simple executable used to test the import dialog.
add_subdirectory(demo)
endif()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This builds a standalone executable that opens the import ui dialog. Useful during development.

MStatus st;
MArgParser argData(syntax(), args, &st);

if(argData.isFlagSet(kClearDataFlag))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The clear data flag is called by the import dialog when you click on a new file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still unsure about this. Seems like the import dialog should just own an instance of ImportData rather than manipulating a singleton.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason this is a singleton and not owned by the import dialog is because the import dialog is created by the "Hierarchy View" button in the plugin import translator options (plugin\adsk\scripts\mayaUsdTranslatorImport.mel). That dialog can be opened by the user and then they set the prims they want to import and the variants. When the dialog is closed it will write to the importData and then the dialog is destroyed. We feel this data is much to heavy to be set via the "query" action of the translator import options.

syntax.enableQuery(false);
syntax.enableEdit(false);
syntax.addFlag(kClearDataFlag, kClearDataFlagLong);
syntax.setObjectType(MSyntax::kStringObjects, 1, 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The command expects a file path to the USD file.

Comment on lines +26 to +28
add_executable(${PROJECT_NAME}
testMayaUsdUI.cpp
)
Copy link
Collaborator Author

@seando-adsk seando-adsk Jan 16, 2020

Choose a reason for hiding this comment

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

Simple test application to open the dialog. So I can test as standalone without Maya.

@@ -0,0 +1,260 @@
//
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Item delegate used to customize the drawing of the variant columns.

@@ -0,0 +1,76 @@
//
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To have a checkbox in the header.

* displayed to the User when interacting with Tree content.
*/
class MAYAUSD_UI_PUBLIC TreeItem : public QStandardItem
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: there is no Q_OBJECT here as QStandardItem does not derive from QObject. So there cannot be signals/slots in this class.

emit dataChanged(rMinIndex, rMaxIndex);
}

void TreeModel::fillStagePopulationMask(UsdStagePopulationMask& popMask, const QModelIndex& parent)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Helper to fill the stage pop mask depending on what is checked.

return ParentClass::setData(index, value, role);
}

void TreeModel::setParentsCheckState(const QModelIndex &child, Qt::CheckState state)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This method (and next one) are used to check/uncheck items parent/child items when the user interactively checks/unchecks an item in the tree.

}
}

void TreeModel::openPersistentEditors(QTreeView* tv, const QModelIndex& parent)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Helper called after tree is created to create all the variant set widgets on each row (that has variant sets).

In Qt terms this is called a persistent editor. Meaning it's always there, rather than only being created when you click in a cell.

Comment on lines 42 to 44
fUI->findPrev->setHidden(true);
fUI->findNext->setHidden(true);
fUI->findAll->setHidden(true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

WIP - I hid these buttons for now as they aren't implemented yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be preferable for work-in-progress functionality to not be included in a PR. When the functionality is ready, a PR dedicated to adding the new buttons and the code that drives them becomes easier to review, as does this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes okay. I will created a separate commit where I remove all the WIP stuff.

@@ -0,0 +1,278 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created as output from Qt designer.

if(CMAKE_WANT_QT_BUILD AND DEFINED QT_LOCATION)
target_link_libraries(${PLUGIN_PACKAGE}
PRIVATE
mayaUsdUI
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This plugin needs the new UI lib to register the command.

rowLayout -numberOfColumns 3 -cw 1 $cw1 -cat 1 "right" 0;
text -label "Scope and Variants: " -al "right";
textField -ed false -nbg true -text "Please select a file to enable this option." -w $cw2 mayaUsdTranslator_SelectFileField;
button -label "View Hierarchy" -c "string $usdFile = currentFileDialogSelection(); usdImportDialog $usdFile;" mayaUsdTranslator_ViewHierBtn;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The button for opening dialog.

Comment on lines 63 to 97
// checkBoxGrp -label "Load Payloads: " -cw 1 $cw1 mayaUsdTranslator_LoadPayloadsCheckBox;
//
// optionMenuGrp -label "Coordinate System: " -cw 1 $cw1 mayaUsdTranslator_CoordSystemOptionMenu;
// menuItem -label "Local space";
// menuItem -label "Object space";
// menuItem -label "World space";
// optionMenuGrp -e -sl 1 mayaUsdTranslator_CoordSystemOptionMenu;
//
// optionMenuGrp -label "Materials: " -cw 1 $cw1 mayaUsdTranslator_MaterialsOptionMenu;
// menuItem -label "None";
// menuItem -label "Display Colors";
// menuItem -label "USD Shade";
// optionMenuGrp -e -sl 2 mayaUsdTranslator_MaterialsOptionMenu;
//
// checkBoxGrp -label "InstancedPrims: " -label1 "Convert to Instances" -cw 1 $cw1 mayaUsdTranslator_InstancedPrimsCheckBox;
//
// optionMenuGrp -label "Include Metadata: " -cw 1 $cw1 mayaUsdTranslator_IncludeMetadataOptionMenu;
// menuItem "All";
// menuItem "None";
// menuItem "Custom";
// optionMenuGrp -e -sl 3 mayaUsdTranslator_IncludeMetadataOptionMenu;
//
// textFieldGrp -label "Specify Fields: " -cw 1 $cw2 -cw 2 150 mayaUsdTranslator_SpecifyFields;
//
// textFieldGrp -label "Prefix Name: " -cw 1 $cw2 -cw 2 50 mayaUsdTranslator_PrefixName;
//
// optionMenuGrp -label "Include Custom Attributes: " -cw 1 $cw1 mayaUsdTranslator_IncludeCustomAttribOptionMenu;
// menuItem "All";
// menuItem "None";
// menuItem "Custom";
// optionMenuGrp -e -sl 2 mayaUsdTranslator_IncludeCustomAttribOptionMenu;
//
// checkBoxGrp -label "Animation Data: " -cw 1 $cw1 mayaUsdTranslator_AnimDataCheckBox;
//
// intFieldGrp -label "Custom Frame Range Start/End: " -nf 2 -cw 1 $cw2 mayaUsdTranslator_CustomFrameRange;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The rest of the options area here (which I showed at demo). But are all commented for now as they aren't implemented yet.

} else if ($action == "query") {
string $currentOptions = "";

eval($resultCallback+" \""+$currentOptions+"\"");

} else if ($action == "fileselected") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This new section is the callback when user selects something in import dialog. I use it to hide/show the button.

@seando-adsk
Copy link
Collaborator Author

@murphyeoin Would anyone at Animal Logic be interested in reviewing this?

@mattyjams I modified the Pixar plugin, so I included you.

@elrond79 A lot of new Qt code, would you like to review?

* WIP - disable some widgets as they aren't full implemented yet.
* Rename importer from "mayaUsdImport" to "USD Import".
* Added "Animation Data" and "Custom Frame Range" options to
  USD Import.
Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

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

I think there are a few things here that should be addressed first, so I left some notes inline.

Some general notes:

  • I like the idea of ImportData, but I'm not sold on there being a global singleton instance of it. Also, if it's meant to encapsulate everything about an import, we should use its filename property too and stop passing that as a separate argument for the functions that now take an ImportData parameter.
  • I think we may want to discourage the use of assert, since failed asserts will kill the process.
  • The whitespace/indentation level/tab usage seems inconsistent in some files.

@@ -6,12 +6,12 @@
# Variables that will be defined:
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes in this file all look fine, but I don't think they're directly related to this new feature, are they? This would be a great candidate for its own pull request if that's the case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No in the end they are not. I had originally made some changes to this file that were relevant for my changes, but then discovered a better way (it was for Qt). I will revert these changes and they will be done in a separate PR (from Hamed) where he is doing some cmake cleanup.

Comment on lines +159 to +188
#
# mayaUsd_promoteHeaderList(
# [SUBDIR <optional sub-directory>])
# [FILES <list of files>]
#
# SUBDIR - optional sub-directory in which to promote files.
# FILES - list of files to promote.
#
function(mayaUsd_promoteHeaderList)
foreach(header ${ARGV})
cmake_parse_arguments(PREFIX
"" # options
"SUBDIR" # one_value keywords
"HEADERS" # multi_value keywords
${ARGN}
)

set(DEST_DIR ${CMAKE_BINARY_DIR}/include/mayaUsd)
if(PREFIX_SUBDIR)
set(DEST_DIR ${DEST_DIR}/${PREFIX_SUBDIR})
endif()

if(PREFIX_HEADERS)
set(headerFiles ${PREFIX_HEADERS})
else()
message(FATAL_ERROR "HEADERS keyword is not specified.")
endif()

foreach(header ${headerFiles})
set(srcFile ${CMAKE_CURRENT_SOURCE_DIR}/${header})
set(dstFile ${CMAKE_BINARY_DIR}/include/mayaUsd/${header})
set(dstFile ${DEST_DIR}/${header})
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes to these CMake functions and their existing usages would also be nice to see as a dedicated pull request. The new feature only adds one new usage of mayaUsd_promoteHeaderList() that takes advantage of the change, but many existing call sites (unrelated to the feature) have to change to absorb this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mattyjams great point. I am going to have a separate PR addressing all that after this PR is merged into dev.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Matt, you are right. But in this case this is one of our backlog branch issues which was waiting for PR154 to go in.

@@ -49,6 +49,7 @@ list(APPEND mayaUsd_src
#
base/debugCodes.cpp
#
fileio/importData.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Should go just before fileio/instancedNodeWriter.cpp to keep these in order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -237,6 +238,7 @@ list(APPEND mayaUsdBase_headers
)

list(APPEND mayaUsdFileio_headers
fileio/importData.h
Copy link
Contributor

Choose a reason for hiding this comment

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

Should go just before fileio/instancedNodeWriter.h to keep these in order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

fRootVariants.clear();
fPrimVariants.clear();
fFilename.clear();
fRootPrimPath.clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

If a default-constructed ImportData has / as its root path, should this be setting fRootPrimPath to that instead of clearing it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes you are correct. Good catch. I've fixed it.

UsdMaya_ReadJob mUsdReadJob(fileName, primPath, variants, jobArgs);
UsdMaya_ReadJob mUsdReadJob(
fileName,
MayaUsd::ImportData::instance(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we should be constructing an ImportData from the arguments rather than pulling from a singleton.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the only case where we want to pull from the singleton as this is the translator that has the "Hierarchy View" button which opens the import dialog. I've modified it to where it will use an empty import data if the filenames don't match. Otherwise we need the import data as that is where the variant selections and stage population mask are set.

Comment on lines +63 to +93
// checkBoxGrp -label "Load Payloads: " -cw 1 $cw1 mayaUsdTranslator_LoadPayloadsCheckBox;
//
// optionMenuGrp -label "Coordinate System: " -cw 1 $cw1 mayaUsdTranslator_CoordSystemOptionMenu;
// menuItem -label "Local space";
// menuItem -label "Object space";
// menuItem -label "World space";
// optionMenuGrp -e -sl 1 mayaUsdTranslator_CoordSystemOptionMenu;
//
// optionMenuGrp -label "Materials: " -cw 1 $cw1 mayaUsdTranslator_MaterialsOptionMenu;
// menuItem -label "None";
// menuItem -label "Display Colors";
// menuItem -label "USD Shade";
// optionMenuGrp -e -sl 2 mayaUsdTranslator_MaterialsOptionMenu;
//
// checkBoxGrp -label "InstancedPrims: " -label1 "Convert to Instances" -cw 1 $cw1 mayaUsdTranslator_InstancedPrimsCheckBox;
//
// optionMenuGrp -label "Include Metadata: " -cw 1 $cw1 mayaUsdTranslator_IncludeMetadataOptionMenu;
// menuItem "All";
// menuItem "None";
// menuItem "Custom";
// optionMenuGrp -e -sl 3 mayaUsdTranslator_IncludeMetadataOptionMenu;
//
// textFieldGrp -label "Specify Fields: " -cw 1 $cw2 -cw 2 150 mayaUsdTranslator_SpecifyFields;
//
// textFieldGrp -label "Prefix Name: " -cw 1 $cw2 -cw 2 50 mayaUsdTranslator_PrefixName;
//
// optionMenuGrp -label "Include Custom Attributes: " -cw 1 $cw1 mayaUsdTranslator_IncludeCustomAttribOptionMenu;
// menuItem "All";
// menuItem "None";
// menuItem "Custom";
// optionMenuGrp -e -sl 2 mayaUsdTranslator_IncludeCustomAttribOptionMenu;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove all of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes okay. I will created a separate commit where I remove all the WIP stuff.

@@ -201,7 +201,11 @@ UsdMayaImportCommand::doIt(const MArgList & args)
/* importWithProxyShapes = */ false,
timeInterval);

mUsdReadJob = new UsdMaya_ReadJobWithSceneAssembly(mFileName, mPrimPath, mVariants, jobArgs);
MayaUsd::ImportData importData;
importData.setRootVariantSelections(std::move(mVariants));
Copy link
Contributor

Choose a reason for hiding this comment

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

Add mFileName to the importData too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes agreed - done.

@@ -111,8 +109,9 @@ UsdMayaImportTranslator::reader(
userArgs,
/* importWithProxyShapes = */ false,
timeInterval);
MayaUsd::ImportData importData;
Copy link
Contributor

Choose a reason for hiding this comment

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

Set the filename on the importData?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes agreed - done.

@@ -1530,9 +1530,13 @@ bool UsdMayaRepresentationHierBase::activate()
UsdMayaJobImportArgs::CreateFromDictionary(
userArgs, shouldImportWithProxies,
GfInterval::GetFullInterval());

MayaUsd::ImportData importData;
importData.setRootVariantSelections(std::move(variantSetSelections));
Copy link
Contributor

Choose a reason for hiding this comment

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

Add usdFilePath to importData?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes agreed - done.

Copy link
Collaborator Author

@seando-adsk seando-adsk left a comment

Choose a reason for hiding this comment

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

I'll push two commits with changes: 1) will contain code review comment changes and 2) will remove all the WIP code.


MAYAUSD_NS_DEF {

IUSDImportView::~IUSDImportView() { }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's defined as pure in the header (=0) yet we still need an implementation because the derived class invokes the destructor and without it we have an undefined symbol.

Comment on lines 142 to 147
std::string USDImportDialog::filename() const
{
return fFilename;
}

std::string USDImportDialog::rootPrimPath() const
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes agreed

Comment on lines +159 to +188
#
# mayaUsd_promoteHeaderList(
# [SUBDIR <optional sub-directory>])
# [FILES <list of files>]
#
# SUBDIR - optional sub-directory in which to promote files.
# FILES - list of files to promote.
#
function(mayaUsd_promoteHeaderList)
foreach(header ${ARGV})
cmake_parse_arguments(PREFIX
"" # options
"SUBDIR" # one_value keywords
"HEADERS" # multi_value keywords
${ARGN}
)

set(DEST_DIR ${CMAKE_BINARY_DIR}/include/mayaUsd)
if(PREFIX_SUBDIR)
set(DEST_DIR ${DEST_DIR}/${PREFIX_SUBDIR})
endif()

if(PREFIX_HEADERS)
set(headerFiles ${PREFIX_HEADERS})
else()
message(FATAL_ERROR "HEADERS keyword is not specified.")
endif()

foreach(header ${headerFiles})
set(srcFile ${CMAKE_CURRENT_SOURCE_DIR}/${header})
set(dstFile ${CMAKE_BINARY_DIR}/include/mayaUsd/${header})
set(dstFile ${DEST_DIR}/${header})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Matt, you are right. But in this case this is one of our backlog branch issues which was waiting for PR154 to go in.


#pragma once

#include "../base/api.h"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have an open discussion about include directives. Once we get to the agreement, we will address all of them.

/*!
* \brief Singleton class to hold USD UI import data.
*/
class MAYAUSD_CORE_PUBLIC ImportData
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On Windows by exporting the class all the methods are exported.

Comment on lines 68 to 71
std::string ImportData::rootPrimPath() const
{
return fRootPrimPath;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. Done.


void ImportData::setStagePopulationMask(UsdStagePopulationMask&& mask)
{
static_assert(std::is_move_assignable<UsdStagePopulationMask>::value, "UsdStagePopulationMask is not move enabled");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah your right technically they aren't needed. It was just for safety sake. I've removed them.

Comment on lines 114 to 122
const ImportData::VariantSelections& ImportData::rootVariantSelections() const
{
return fRootVariants;
}

const ImportData::PrimVariantSelections& ImportData::primVariantSelections() const
{
return fPrimVariants;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The import/readjob code was already using the concept of root prim variants selections. These were being passed in as an arg to the readjob, etc. I added a new feature to have variant selections on any prim. I wanted to keep these separate.

@@ -60,14 +60,12 @@ PXR_NAMESPACE_OPEN_SCOPE

UsdMaya_ReadJob::UsdMaya_ReadJob(
const std::string &iFileName,
const std::string &iPrimPath,
const std::map<std::string, std::string>& iVariants,
const MayaUsd::ImportData &iImportData,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes good idea. I've moved it into import data.

@@ -103,7 +102,22 @@ UsdMaya_ReadJob::Read(std::vector<MDagPath>* addedDagPaths)

// Layer and Stage used to Read in the USD file
UsdStageCacheContext stageCacheContext(UsdMayaStageCache::Get());
UsdStageRefPtr stage = UsdStage::Open(rootLayer, sessionLayer);
UsdStageRefPtr stage;
if (mImportData.empty())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes correct, now that I've moved the filename into the import data it won't be empty. I've changed the stage open as you've suggested.

MAYA-101325 - Implement Qt Model base class that supports/exposes a USD stage
MAYA-101326 - Implement filtering proxy on top of USD stage model
MAYA-101566 - Hook up the new Import pop-up dialog options to import command
MAYA-101565 - Add VariantSets to import dialog and allow selection of a Variant

Code Review comments:
* Moved find_package(Qt5) to top-level cmake.
* Sorted cmake file lists
* Made some return values const&
* Moved filename input arg from readjob/translator into import data.
* Replaced ImportData::VariantSelections typedef with SdfVariantSelectionMap
* USDImportDialogCmd - use default constructor/destructor
* Replaced TreeModelFactory::SdfPathHash struct with SdfPath::Hash
…SD stage

MAYA-101326 - Implement filtering proxy on top of USD stage model
MAYA-101566 - Hook up the new Import pop-up dialog options to import command
MAYA-101565 - Add VariantSets to import dialog and allow selection of a Variant

* Removing all work-in-progress and non-used or not fully implemented code.
@seando-adsk
Copy link
Collaborator Author

@mattyjams Matt, I've pushed two commits. The first one (1115a2e) addresses all your code review comments. The 2nd (fac4479) removes all the work-in-progress. I've replied to all your comments. Thanks for having a look at this pull-request. I know it was large, so I really appreciate your time and input.

@kxl-adsk kxl-adsk removed the request for review from pmolodo February 7, 2020 18:20
@kxl-adsk
Copy link

kxl-adsk commented Feb 7, 2020

@mattyjams were requested changes made? if so, please approve the PR.

Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

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

Cool! There were just two CMakeLists.txt files where I noticed we still had policy statements, but other than that, looks good to me!

Comment on lines +52 to +56
bool ImportData::empty() const
{
// If we don't have a filename set then we are empty.
return fFilename.empty();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I could still imagine cases where you might want to import from an open stage as opposed to a file, but I don't think we have any existing usage like that currently. Seems like we have what we need for now.

Comment on lines +21 to +23
if (POLICY CMP0074)
cmake_policy(SET CMP0074 OLD)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

Still have a policy requirement here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks Matt. I remember adding this a while ago to remove some cmake warnings. Since we've now updated cmake min version I'll check these.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI, I looked into these policy statements and I don't think they are needed anymore. There were three places where we were setting 0074 to OLD. I removed all of them and didn't see any cmake warnings. I'll make sure these get removed in a future PR.

Comment on lines +21 to +23
if (POLICY CMP0074)
cmake_policy(SET CMP0074 OLD)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

Still have a policy requirement here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants