Skip to content

Commit

Permalink
Merge pull request #206 from Autodesk/donnels/MAYA-101325/new_import_…
Browse files Browse the repository at this point in the history
…ui_feature_wip

New Import UI feature - WIP
  • Loading branch information
Krystian Ligenza authored Feb 10, 2020
2 parents 81aff08 + 3446485 commit a792378
Show file tree
Hide file tree
Showing 37 changed files with 2,597 additions and 67 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ if(CMAKE_WANT_UFE_BUILD)
endif()
endif()

if(DEFINED QT_LOCATION)
set(CMAKE_PREFIX_PATH "${QT_LOCATION}")
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
if(Qt5_FOUND)
message(STATUS "Building with Qt features enabled.")
endif()
else()
message(STATUS "QT_LOCATION not set. Building Qt features will be disabled.")
endif()

#==============================================================================
# Compiler
#==============================================================================
Expand Down
11 changes: 11 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ def BuildAndInstall(context, buildArgs, stages):
else:
extraArgs.append('-DMAYAUSD_DEFINE_BOOST_DEBUG_PYTHON_FLAG=OFF')

if context.qtLocation:
extraArgs.append('-DQT_LOCATION="{qtLocation}"'
.format(qtLocation=context.qtLocation))

extraArgs += buildArgs
stagesArgs += stages

Expand Down Expand Up @@ -422,6 +426,9 @@ def Package(context):
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.")

parser.add_argument("--build-args", type=str, nargs="*", default=[],
help=("Comma-separated list of arguments passed into CMake when building libraries"))

Expand Down Expand Up @@ -493,6 +500,10 @@ def __init__(self, args):
self.devkitLocation = (os.path.abspath(args.devkit_location)
if args.devkit_location else None)

# Qt Location
self.qtLocation = (os.path.abspath(args.qt_location)
if args.qt_location else None)

# Log File Name
logFileName="build_log.txt"
self.logFileLocation=os.path.join(self.buildDir, logFileName)
Expand Down
44 changes: 35 additions & 9 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function(mayaUsd_find_python_module module)
"Location of Python module ${module}")
endif(NOT _${module}_status)
endif(NOT ${module_found})
endfunction(mayaUsd_find_python_module)
endfunction()

# Initialize a variable to accumulate an rpath. The origin is the
# RUNTIME DESTINATION of the target. If not absolute it's appended
Expand Down Expand Up @@ -158,10 +158,36 @@ function(mayaUsd_promoteMayaUsdHeader)
configure_file(${srcFile} ${dstFile})
endfunction()

#
# 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})

set(content "#pragma once\n#include \"${srcFile}\"\n")

Expand Down Expand Up @@ -193,9 +219,9 @@ endfunction()
#
function(mayaUsd_copyFiles target)
cmake_parse_arguments(PREFIX
"TARGET"
"DESTINATION"
"FILES"
"" # options
"DESTINATION" # one_value keywords
"FILES" # multi_value keywords
${ARGN}
)

Expand Down Expand Up @@ -236,9 +262,9 @@ endfunction()
#
function(mayaUsd_copyDirectory target)
cmake_parse_arguments(PREFIX
"TARGET"
"DESTINATION"
"DIRECTORY"
"" # options
"DESTINATION" # one_value keywords
"DIRECTORY" # multi_value keywords
${ARGN}
)

Expand Down
30 changes: 16 additions & 14 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ list(APPEND mayaUsd_src
fileio/fallbackPrimReader.cpp
fileio/functorPrimReader.cpp
fileio/functorPrimWriter.cpp
fileio/importData.cpp
fileio/instancedNodeWriter.cpp
fileio/primReader.cpp
fileio/primReaderArgs.cpp
Expand Down Expand Up @@ -244,6 +245,7 @@ list(APPEND mayaUsdFileio_headers
fileio/fallbackPrimReader.h
fileio/functorPrimReader.h
fileio/functorPrimWriter.h
fileio/importData.h
fileio/instancedNodeWriter.h
fileio/primReader.h
fileio/primReaderArgs.h
Expand Down Expand Up @@ -512,22 +514,22 @@ set_property(GLOBAL PROPERTY GLOBAL_LIBRARY_LOCATION ${CMAKE_INSTALL_PREFIX}/lib

# promote headers
mayaUsd_promoteMayaUsdHeader()
mayaUsd_promoteHeaderList(${mayaUsdBase_headers})
mayaUsd_promoteHeaderList(${mayaUsdFileio_headers})
mayaUsd_promoteHeaderList(${mayaUsdChaser_headers})
mayaUsd_promoteHeaderList(${mayaUsdJobs_headers})
mayaUsd_promoteHeaderList(${mayaUsdUtilsIO_headers})
mayaUsd_promoteHeaderList(${mayaUsdShading_headers})
mayaUsd_promoteHeaderList(${mayaUsdTranslators_headers})
mayaUsd_promoteHeaderList(${mayaUsdUtils_headers})
mayaUsd_promoteHeaderList(${mayaUsdNodes_headers})
mayaUsd_promoteHeaderList(${mayaUsdListeners_headers})
mayaUsd_promoteHeaderList(${mayaUsdVP2RenderDelegate_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdBase_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdFileio_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdChaser_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdJobs_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdUtilsIO_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdShading_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdTranslators_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdUtils_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdNodes_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdListeners_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdVP2RenderDelegate_headers})
if(UFE_FOUND)
mayaUsd_promoteHeaderList(${mayaUsdUfe_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdUfe_headers})
endif()
mayaUsd_promoteHeaderList(${mayaUsdPxrUsdMayaGL_headers})
mayaUsd_promoteHeaderList(${mayaUsdPxVP20_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdPxrUsdMayaGL_headers})
mayaUsd_promoteHeaderList(HEADERS ${mayaUsdPxVP20_headers})

# install public headers
install(FILES ${CMAKE_BINARY_DIR}/include/mayaUsd/mayaUsd.h
Expand Down
160 changes: 160 additions & 0 deletions lib/fileio/importData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
//
// Copyright 2019 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "importData.h"

#include <type_traits>

MAYAUSD_NS_DEF {

//------------------------------------------------------------------------------
// ImportData:
//------------------------------------------------------------------------------

constexpr const char* kRootPrimPath = "/";

ImportData::ImportData()
: fLoadSet(UsdStage::InitialLoadSet::LoadAll)
, fRootPrimPath(kRootPrimPath)
{
}

ImportData::ImportData(const std::string& f)
: fLoadSet(UsdStage::InitialLoadSet::LoadAll)
, fRootPrimPath(kRootPrimPath)
, fFilename(f)
{
}

/*static*/
ImportData& ImportData::instance()
{
static ImportData sImportData;
return sImportData;
}

/*static*/
const ImportData& ImportData::cinstance()
{
return instance();
}

void ImportData::clearData()
{
fLoadSet = UsdStage::InitialLoadSet::LoadAll;
UsdStagePopulationMask tmpPopMask;
fPopMask.swap(tmpPopMask);
fRootVariants.clear();
fPrimVariants.clear();
fFilename.clear();
fRootPrimPath = kRootPrimPath;
}

bool ImportData::empty() const
{
// If we don't have a filename set then we are empty.
return fFilename.empty();
}

const std::string& ImportData::filename() const
{
return fFilename;
}

void ImportData::setFilename(const std::string& f)
{
// If the input filename doesn't match what we have stored (empty or not) we
// clear the data because it doesn't belong to the new file.
if (fFilename != f)
clearData();
fFilename = f;
}

const std::string& ImportData::rootPrimPath() const
{
return fRootPrimPath;
}

void ImportData::setRootPrimPath(const std::string& primPath)
{
fRootPrimPath = primPath;
}

bool ImportData::hasPopulationMask() const
{
return !fPopMask.IsEmpty();
}

const UsdStagePopulationMask& ImportData::stagePopulationMask() const
{
return fPopMask;
}

void ImportData::setStagePopulationMask(const UsdStagePopulationMask& mask)
{
fPopMask = mask;
}

void ImportData::setStagePopulationMask(UsdStagePopulationMask&& mask)
{
fPopMask = std::move(mask);
}

UsdStage::InitialLoadSet ImportData::stageInitialLoadSet() const
{
return fLoadSet;
}

void ImportData::setStageInitialLoadSet(UsdStage::InitialLoadSet loadSet)
{
fLoadSet = loadSet;
}

bool ImportData::hasVariantSelections() const
{
return !(fRootVariants.empty() || fPrimVariants.empty());
}

const SdfVariantSelectionMap& ImportData::rootVariantSelections() const
{
return fRootVariants;
}

const ImportData::PrimVariantSelections& ImportData::primVariantSelections() const
{
return fPrimVariants;
}

void ImportData::setRootVariantSelections(const SdfVariantSelectionMap& vars)
{
fRootVariants = vars;
}

void ImportData::setRootVariantSelections(SdfVariantSelectionMap&& vars)
{
fRootVariants = std::move(vars);
}

void ImportData::setPrimVariantSelections(const PrimVariantSelections& vars)
{
fPrimVariants = vars;
}

void ImportData::setPrimVariantSelections(PrimVariantSelections&& vars)
{
fPrimVariants = std::move(vars);
}

} // namespace MayaUsd
Loading

0 comments on commit a792378

Please sign in to comment.