From 863d1e09cbec261cb77239c7adef89c24c6214da Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 6 Aug 2019 18:20:51 -0400 Subject: [PATCH 001/123] Sconstruct : add Windows build options --- SConstruct | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index 9f0625601dd..0b2ab657bb6 100644 --- a/SConstruct +++ b/SConstruct @@ -2,6 +2,7 @@ # # Copyright (c) 2011-2014, John Haddon. All rights reserved. # Copyright (c) 2011-2014, Image Engine Design Inc. All rights reserved. +# Copyright 2019, Hypothetical Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -77,13 +78,13 @@ options = Variables( optionsFile, ARGUMENTS ) options.Add( "CXX", "The C++ compiler.", - "clang++" if sys.platform == "darwin" else "g++", + {"darwin" : "clang++", "win32" : "cl"}.get(sys.platform, "g++") ) options.Add( "CXXFLAGS", "The extra flags to pass to the C++ compiler during compilation.", - [ "-pipe", "-Wall" ] + [ "-pipe", "-Wall" ] if Environment()["PLATFORM"] != "win32" else [], ) options.Add( @@ -118,7 +119,7 @@ options.Add( options.Add( "BUILD_DIR", "The destination directory in which the build will be made.", - "./build/gaffer-${GAFFER_MILESTONE_VERSION}.${GAFFER_MAJOR_VERSION}.${GAFFER_MINOR_VERSION}.${GAFFER_PATCH_VERSION}-${GAFFER_PLATFORM}", + os.path.join( "build", "gaffer-${GAFFER_MILESTONE_VERSION}.${GAFFER_MAJOR_VERSION}.${GAFFER_MINOR_VERSION}.${GAFFER_PATCH_VERSION}-${GAFFER_PLATFORM}" ), ) options.Add( @@ -132,13 +133,13 @@ options.Add( options.Add( "INSTALL_DIR", "The destination directory for the installation.", - "./install/gaffer-${GAFFER_MILESTONE_VERSION}.${GAFFER_MAJOR_VERSION}.${GAFFER_MINOR_VERSION}.${GAFFER_PATCH_VERSION}-${GAFFER_PLATFORM}", + os.path.join( "install", "gaffer-${GAFFER_MILESTONE_VERSION}.${GAFFER_MAJOR_VERSION}.${GAFFER_MINOR_VERSION}.${GAFFER_PATCH_VERSION}-${GAFFER_PLATFORM}" ), ) options.Add( "PACKAGE_FILE", "The file in which the final gaffer file will be created by the package target.", - "${INSTALL_DIR}.tar.gz", + "${INSTALL_DIR}.tar.gz" if sys.platform != "win32" else "${INSTALL_DIR}.zip", ) options.Add( @@ -167,7 +168,7 @@ options.Add( options.Add( "APPLESEED_ROOT", "The directory in which Appleseed is installed. Used to build Gafferseed", - "$BUILD_DIR/appleseed", + os.path.join( "$BUILD_DIR", "appleseed" ), ) options.Add( From 755a341df7e8cbcdd80d7b22ba9abcba38e94c44 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 6 Aug 2019 18:58:52 -0400 Subject: [PATCH 002/123] Sconstruct : add Windows build flags --- SConstruct | 232 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 166 insertions(+), 66 deletions(-) diff --git a/SConstruct b/SConstruct index 0b2ab657bb6..affd55bca58 100644 --- a/SConstruct +++ b/SConstruct @@ -382,75 +382,175 @@ if "clang++" in os.path.basename( env["CXX"] ): env["BUILD_DIR"] = os.path.abspath( env["BUILD_DIR"] ) -# DISPLAY and HOME are essential for running gaffer when generating -# the documentation. TERM is needed to get coloured output from the -# compiler. -for e in env["ENV_VARS_TO_IMPORT"].split() + [ "DISPLAY", "HOME", "TERM" ] : - if e in os.environ : - env["ENV"][e] = os.environ[e] - -if env["PLATFORM"] == "darwin" : - - env.Append( CXXFLAGS = [ "-D__USE_ISOC99" ] ) - env["GAFFER_PLATFORM"] = "osx" - - osxVersion = [ int( v ) for v in platform.mac_ver()[0].split( "." ) ] - if osxVersion[0] == 10 and osxVersion[1] > 7 : - # Fix problems with Boost 1.55 and recent versions of Clang. - env.Append( CXXFLAGS = [ "-DBOOST_HAS_INT128", "-Wno-unused-local-typedef" ] ) - -elif env["PLATFORM"] == "posix" : - - if "g++" in os.path.basename( env["CXX"] ) : - - # Get GCC version. - gccVersion = subprocess.check_output( [ env["CXX"], "-dumpversion" ], env=env["ENV"] ).decode().strip() - if "." not in gccVersion : - # GCC 7 onwards requires `-dumpfullversion` to get minor/patch, but this - # flag does not exist on earlier GCCs, where minor/patch was provided by `-dumpversion`. - gccVersion = subprocess.check_output( [ env["CXX"], "-dumpfullversion" ], env=env["ENV"] ).decode().strip() - gccVersion = [ int( v ) for v in gccVersion.split( "." ) ] - - # GCC 4.1.2 in conjunction with boost::flat_map produces crashes when - # using the -fstrict-aliasing optimisation (which defaults to on with -O2), - # so we turn the optimisation off here, only for that specific GCC version. - if gccVersion == [ 4, 1, 2 ] : - env.Append( CXXFLAGS = [ "-fno-strict-aliasing" ] ) - - # GCC emits spurious "assuming signed overflow does not occur" - # warnings, typically triggered by the comparisons in Box3f::isEmpty(). - # Downgrade these back to warning status. - if gccVersion >= [ 4, 2 ] : - env.Append( CXXFLAGS = [ "-Wno-error=strict-overflow" ] ) - - # Old GCC emits spurious "maybe uninitialized" warnings when using - # boost::optional - if gccVersion < [ 5, 1 ] : - env.Append( CXXFLAGS = [ "-Wno-error=maybe-uninitialized" ] ) - - if gccVersion >= [ 5, 1 ] : - env.Append( CXXFLAGS = [ "-D_GLIBCXX_USE_CXX11_ABI=0" ] ) - - if gccVersion >= [ 9, 2 ] : - env.Append( CXXFLAGS = [ "-Wsuggest-override" ] ) - - env["GAFFER_PLATFORM"] = "linux" - -env.Append( CXXFLAGS = [ "-std=$CXXSTD", "-fvisibility=hidden" ] ) - -if env["BUILD_TYPE"] == "DEBUG" : - env.Append( CXXFLAGS = ["-g", "-O0", "-DTBB_USE_DEBUG=1"] ) -elif env["BUILD_TYPE"] == "RELEASE" : - env.Append( CXXFLAGS = ["-DNDEBUG", "-DBOOST_DISABLE_ASSERTS", "-O3"] ) -elif env["BUILD_TYPE"] == "RELWITHDEBINFO" : - env.Append( CXXFLAGS = ["-DNDEBUG", "-DBOOST_DISABLE_ASSERTS", "-O3", "-g", "-fno-omit-frame-pointer"] ) - -if env["WARNINGS_AS_ERRORS"] : +########################################################################################### +# POSIX configuration +########################################################################################### + +if env["PLATFORM"] != "win32" : + + # DISPLAY and HOME are essential for running gaffer when generating + # the documentation. TERM is needed to get coloured output from the + # compiler. + for e in env["ENV_VARS_TO_IMPORT"].split() + [ "DISPLAY", "HOME", "TERM" ] : + if e in os.environ : + env["ENV"][e] = os.environ[e] + + if env["PLATFORM"] == "darwin" : + + env.Append( CXXFLAGS = [ "-D__USE_ISOC99" ] ) + env["GAFFER_PLATFORM"] = "osx" + + osxVersion = [ int( v ) for v in platform.mac_ver()[0].split( "." ) ] + if osxVersion[0] == 10 and osxVersion[1] > 7 : + # Fix problems with Boost 1.55 and recent versions of Clang. + env.Append( CXXFLAGS = [ "-DBOOST_HAS_INT128", "-Wno-unused-local-typedef" ] ) + + else : + + if "g++" in os.path.basename( env["CXX"] ) : + + # Get GCC version. + gccVersion = subprocess.check_output( [ env["CXX"], "-dumpversion" ], env=env["ENV"] ).decode().strip() + if "." not in gccVersion : + # GCC 7 onwards requires `-dumpfullversion` to get minor/patch, but this + # flag does not exist on earlier GCCs, where minor/patch was provided by `-dumpversion`. + gccVersion = subprocess.check_output( [ env["CXX"], "-dumpfullversion" ], env=env["ENV"] ).decode().strip() + gccVersion = [ int( v ) for v in gccVersion.split( "." ) ] + + # GCC 4.1.2 in conjunction with boost::flat_map produces crashes when + # using the -fstrict-aliasing optimisation (which defaults to on with -O2), + # so we turn the optimisation off here, only for that specific GCC version. + if gccVersion == [ 4, 1, 2 ] : + env.Append( CXXFLAGS = [ "-fno-strict-aliasing" ] ) + + # GCC emits spurious "assuming signed overflow does not occur" + # warnings, typically triggered by the comparisons in Box3f::isEmpty(). + # Downgrade these back to warning status. + if gccVersion >= [ 4, 2 ] : + env.Append( CXXFLAGS = [ "-Wno-error=strict-overflow" ] ) + + # Old GCC emits spurious "maybe uninitialized" warnings when using + # boost::optional + if gccVersion < [ 5, 1 ] : + env.Append( CXXFLAGS = [ "-Wno-error=maybe-uninitialized" ] ) + + if gccVersion >= [ 5, 1 ] : + env.Append( CXXFLAGS = [ "-D_GLIBCXX_USE_CXX11_ABI=0" ] ) + + if gccVersion >= [ 9, 2 ] : + env.Append( CXXFLAGS = [ "-Wsuggest-override" ] ) + + env["GAFFER_PLATFORM"] = "linux" + + env.Append( CXXFLAGS = [ "-std=$CXXSTD", "-fvisibility=hidden" ] ) + + if env["BUILD_TYPE"] == "DEBUG" : + env.Append( CXXFLAGS = ["-g", "-O0", "-DTBB_USE_DEBUG=1"] ) + elif env["BUILD_TYPE"] == "RELEASE" : + env.Append( CXXFLAGS = ["-DNDEBUG", "-DBOOST_DISABLE_ASSERTS", "-O3"] ) + elif env["BUILD_TYPE"] == "RELWITHDEBINFO" : + env.Append( CXXFLAGS = ["-DNDEBUG", "-DBOOST_DISABLE_ASSERTS", "-O3", "-g", "-fno-omit-frame-pointer"] ) + + if env["WARNINGS_AS_ERRORS"] : + env.Append( + CXXFLAGS = [ "-Werror" ], + SHLINKFLAGS = [ "-Wl,-fatal_warnings" ], + ) + +########################################################################################### +# Windows configuration +########################################################################################### + +else: env.Append( - CXXFLAGS = [ "-Werror" ], - SHLINKFLAGS = [ "-Wl,-fatal_warnings" ], + CXXFLAGS = [ + "/nologo", # Suppress startup banner + "/DOPENEXR_DLL", # Link to dynamic OpenEXR library + "/DNOMINMAX", # Suppress compiler definition of `min` and `max` + "/D__PRETTY_FUNCTION__=__FUNCSIG__", + "/DBOOST_ALL_DYN_LINK", + "/DBOOST_FILESYSTEM_NO_DEPRECATED", + "/DBOOST_SIGNALS_NO_DEPRECATION_WARNING", + "/DBOOST_PYTHON_MAX_ARITY=20", + "/W4", # Warning level 4, one level less than all warnings + "/experimental:external", # Allow use of /external:I + "/external:W0", # Suppress warnings for headers included with /external:I + "/Zc:inline", # Remove unreferenced function or data if it is COMDAT or has internal linkage only + "/GR", # Enable RTTI + "/TP", # Treat all files as c++ (vs C) + "/FC", # Display full paths in diagnostics + "/EHsc", # Catch c++ exceptions only + "/MP", # Enable multiprocessing of builds + "/permissive-", # Disable permissive mode, which also enables standard compliant two phase name lookup + "/D_USE_MATH_DEFINES", # Required when permissive mode is off, for defining constants like M_PI used by OpenVDB + "/std:$CXXSTD", + ] ) + if env["WARNINGS_AS_ERRORS"] : + env.Append( + CXXFLAGS = [ + "/WX", # Treat warnings as errors + "/wd4100", # Suppress warning about unused parameters + "/wd4706", # Suppress warning about using assignment in conditionals + "/wd4267", # Suppress warning about conversion from int to size_t + "/wd4244", # Suppress warning about possible loss of data in type conversion + "/wd4305", # Suppress warning about conversion from double to float + "/D_CRT_SECURE_NO_WARNINGS", # Suppress warnings about getenv and similar + ], + ) + + if env["BUILD_TYPE"] == "DEBUG" : + env.Append( + CXXFLAGS = + [ + "/O0", + "/Zi", + "/MDd", + "/DBOOST_DISABLE_ASSERTS", + "/bigobj", + ], + CCPDBFLAGS= + [ + "/Zi", + "/Fd${TARGET}.pdb", + ], + ) + elif env["BUILD_TYPE"] == "RELEASE" : + env.Append( + CXXFLAGS = + [ + "/DNDEBUG", + "/MD", # create multithreaded DLL + "/DBOOST_DISABLE_ASSERTS", + "/O2", + # /Og optimization (included via /O2) generates lots of unreachable + # code warnings from boost::intrusive_ptr. Disabled in release build only. + "/wd4702" + ] + ) + elif env["BUILD_TYPE"] == "RELWITHDEBINFO" : + env.Append( + CXXFLAGS = + [ + "/DNDEBUG", + "/MD", + "/bigobj", + "/DBOOST_DISABLE_ASSERTS", + "/Zi", + ], + LINKFLAGS = + [ + "/DEBUG", + ], + CCPDBFLAGS= + [ + "/Zi", + "/Fd${TARGET}.pdb", + ], + ) + + if env["BUILD_CACHEDIR"] != "" : CacheDir( env["BUILD_CACHEDIR"] ) From 3e5d1ff2218c3621f4050f99b9c5ba6c4c096ecd Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 6 Aug 2019 18:52:19 -0400 Subject: [PATCH 003/123] Sconstruct : make system includes cross-platform --- SConstruct | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index affd55bca58..3535de874f6 100644 --- a/SConstruct +++ b/SConstruct @@ -329,6 +329,10 @@ options.Add( "GAFFER_PATCH_VERSION", "Patch version", str( gafferPatchVersion ) # Basic environment object. All the other environments will be based on this. ############################################################################################### +########################################################################################### +# All platforms +########################################################################################### + env = Environment( options = options, @@ -365,6 +369,9 @@ env = Environment( # this should turn off warnings from those headers, allowing us to # build with -Werror. there are so many warnings from boost # in particular that this would be otherwise impossible. + +systemIncludeArgument = "/external:I" if env[ "PLATFORM" ] == "win32" else "-isystem" + for path in [ "$BUILD_DIR/include", "$BUILD_DIR/include/OpenEXR", @@ -372,7 +379,7 @@ for path in [ ] + env["LOCATE_DEPENDENCY_SYSTEMPATH"] : env.Append( - CXXFLAGS = [ "-isystem", path ] + CXXFLAGS = [ systemIncludeArgument, path ] ) if "clang++" in os.path.basename( env["CXX"] ): @@ -813,7 +820,7 @@ gafferLib = {} if os.path.exists( vTuneRoot ): gafferLib = { "envAppends" : { - "CXXFLAGS" : [ "-isystem", "$VTUNE_ROOT/include", "-DGAFFER_VTUNE"], + "CXXFLAGS" : [ systemIncludeArgument, "$VTUNE_ROOT/include", "-DGAFFER_VTUNE"], "LIBPATH" : [ "$VTUNE_ROOT/lib64" ], "LIBS" : [ "ittnotify" ] }, @@ -1097,12 +1104,12 @@ libraries = { "GafferAppleseed" : { "envAppends" : { - "CXXFLAGS" : [ "-isystem", "$APPLESEED_ROOT/include", "-DAPPLESEED_ENABLE_IMATH_INTEROP", "-DAPPLESEED_USE_SSE" ], + "CXXFLAGS" : [ systemIncludeArgument, "$APPLESEED_ROOT/include", "-DAPPLESEED_ENABLE_IMATH_INTEROP", "-DAPPLESEED_USE_SSE" ], "LIBPATH" : [ "$APPLESEED_ROOT/lib" ], "LIBS" : [ "Gaffer", "GafferDispatch", "GafferScene", "appleseed", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreAppleseed$CORTEX_LIB_SUFFIX", "OpenImageIO$OIIO_LIB_SUFFIX", "oslquery$OSL_LIB_SUFFIX" ], }, "pythonEnvAppends" : { - "CXXFLAGS" : [ "-isystem", "$APPLESEED_ROOT/include", "-DAPPLESEED_ENABLE_IMATH_INTEROP", "-DAPPLESEED_USE_SSE" ], + "CXXFLAGS" : [ systemIncludeArgument, "$APPLESEED_ROOT/include", "-DAPPLESEED_ENABLE_IMATH_INTEROP", "-DAPPLESEED_USE_SSE" ], "LIBPATH" : [ "$APPLESEED_ROOT/lib" ], "LIBS" : [ "Gaffer", "GafferDispatch", "GafferScene", "GafferBindings", "GafferAppleseed" ], }, From 0339577206a5b4784ed40c80605fac587207f293 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 11:31:51 -0400 Subject: [PATCH 004/123] Sconstruct : add Windows compatibility to commandEnv --- SConstruct | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index 3535de874f6..5710b4c4e35 100644 --- a/SConstruct +++ b/SConstruct @@ -653,7 +653,7 @@ if env["ASAN"] : # An environment for running commands with access to the applications we've built ############################################################################################### -def split( stringOrList, separator = ":" ) : +def split( stringOrList, separator = os.path.pathsep ) : if isinstance( stringOrList, list ) : return stringOrList @@ -661,14 +661,18 @@ def split( stringOrList, separator = ":" ) : return stringOrList.split( separator ) commandEnv = env.Clone() -commandEnv["ENV"]["PATH"] = commandEnv.subst( "$BUILD_DIR/bin:" ) + commandEnv["ENV"]["PATH"] +commandEnv["ENV"]["PATH"] = commandEnv.subst( "$BUILD_DIR/bin" + os.path.pathsep ) + commandEnv["ENV"]["PATH"] +if env["PLATFORM"] == "win32" : + commandEnv["ENV"]["PATH"] = commandEnv.subst( "$BUILD_DIR/lib" + os.path.pathsep ) + commandEnv["ENV"]["PATH"] if commandEnv["PLATFORM"]=="darwin" : - commandEnv["ENV"]["DYLD_LIBRARY_PATH"] = commandEnv.subst( ":".join( [ "$BUILD_DIR/lib" ] + split( commandEnv["LOCATE_DEPENDENCY_LIBPATH"] ) ) ) -else : - commandEnv["ENV"]["LD_LIBRARY_PATH"] = commandEnv.subst( ":".join( [ "$BUILD_DIR/lib" ] + split( commandEnv["LOCATE_DEPENDENCY_LIBPATH"] ) ) ) + commandEnv["ENV"]["DYLD_LIBRARY_PATH"] = commandEnv.subst( os.path.pathsep.join( [ "$BUILD_DIR/lib" ] + split( commandEnv["LOCATE_DEPENDENCY_LIBPATH"] ) ) ) +elif commandEnv["PLATFORM"] == "win32" : + commandEnv["ENV"]["PATH"] = commandEnv.subst( os.path.pathsep.join( [ "$BUILD_DIR/lib" ] + split( commandEnv[ "LOCATE_DEPENDENCY_LIBPATH" ] ) + [ commandEnv["ENV"]["PATH"] ] ) ) +else: + commandEnv["ENV"]["LD_LIBRARY_PATH"] = commandEnv.subst( os.path.pathsep.join( [ "$BUILD_DIR/lib" ] + split( commandEnv["LOCATE_DEPENDENCY_LIBPATH"] ) ) ) -commandEnv["ENV"]["PYTHONPATH"] = commandEnv.subst( ":".join( split( commandEnv["LOCATE_DEPENDENCY_PYTHONPATH"] ) ) ) +commandEnv["ENV"]["PYTHONPATH"] = commandEnv.subst( os.path.pathsep.join( split( commandEnv["LOCATE_DEPENDENCY_PYTHONPATH"] ) ) ) # SIP on MacOS prevents DYLD_LIBRARY_PATH being passed down so we make sure # we also pass through to gaffer the other base vars it uses to populate paths From f5cd3196bc34c43e92dd28e570ac815b3f5f2e6f Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 12:44:32 -0400 Subject: [PATCH 005/123] Sconstruct : add Windows support for string substitutions in files --- SConstruct | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index 5710b4c4e35..239a0d9cc0a 100644 --- a/SConstruct +++ b/SConstruct @@ -44,6 +44,8 @@ import platform import subprocess import distutils.dir_util +EnsureSConsVersion( 3, 0, 2 ) # Substfile is a default builder as of 3.0.2 + ############################################################################################### # Version ############################################################################################### @@ -365,6 +367,7 @@ env = Environment( ) + # include 3rd party headers with -isystem rather than -I. # this should turn off warnings from those headers, allowing us to # build with -Werror. there are so many warnings from boost @@ -1270,10 +1273,12 @@ for libraryName, libraryDef in libraries.items() : # header install - sedSubstitutions = "s/!GAFFER_MILESTONE_VERSION!/$GAFFER_MILESTONE_VERSION/g" - sedSubstitutions += "; s/!GAFFER_MAJOR_VERSION!/$GAFFER_MAJOR_VERSION/g" - sedSubstitutions += "; s/!GAFFER_MINOR_VERSION!/$GAFFER_MINOR_VERSION/g" - sedSubstitutions += "; s/!GAFFER_PATCH_VERSION!/$GAFFER_PATCH_VERSION/g" + fileSubstitutions = { + "!GAFFER_MILESTONE_VERSION!" : "$GAFFER_MILESTONE_VERSION", + "!GAFFER_MAJOR_VERSION!" : "$GAFFER_MAJOR_VERSION", + "!GAFFER_MINOR_VERSION!" : "$GAFFER_MINOR_VERSION", + "!GAFFER_PATCH_VERSION!" : "$GAFFER_PATCH_VERSION", + } headers = ( glob.glob( "include/" + libraryName + "/*.h" ) + @@ -1283,7 +1288,12 @@ for libraryName, libraryDef in libraries.items() : ) for header in headers : - headerInstall = env.Command( os.path.join( installRoot, header ), header, "sed \"" + sedSubstitutions + "\" $SOURCE > $TARGET" ) + headerInstall = env.Substfile( + os.path.join( installRoot, header ), + header, + SUBST_DICT = fileSubstitutions + ) + libEnv.Alias( "build", headerInstall ) # bindings library @@ -1311,7 +1321,11 @@ for libraryName, libraryDef in libraries.items() : ) for header in bindingsHeaders : - headerInstall = env.Command( os.path.join( installRoot, header ), header, "sed \"" + sedSubstitutions + "\" $SOURCE > $TARGET" ) + headerInstall = env.Substfile( + os.path.join( installRoot, header ), + header, + SUBST_DICT = fileSubstitutions + ) bindingsEnv.Alias( "build", headerInstall ) # python module binary component @@ -1358,7 +1372,11 @@ for libraryName, libraryDef in libraries.items() : pythonFiles = glob.glob( "python/" + libraryName + "/*.py" ) + glob.glob( "python/" + libraryName + "/*/*.py" ) + glob.glob( "python/" + libraryName + "/*/*/*.py" ) for pythonFile in pythonFiles : - pythonFileInstall = env.Command( os.path.join( installRoot, pythonFile ), pythonFile, "sed \"" + sedSubstitutions + "\" $SOURCE > $TARGET" ) + pythonFileInstall = env.Substfile( + os.path.join( installRoot, pythonFile ), + pythonFile, + SUBST_DICT = fileSubstitutions + ) env.Alias( "build", pythonFileInstall ) # apps From a04e997b246855915f31fbe9bcf1c5c4e210a665 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 13:49:37 -0400 Subject: [PATCH 006/123] Sconstruct : Quote Inkscape command to allow spaces in the path - Inkscape on Windows is likely installed in "C:\Program Files" - the space in the directory name requires quoting to be run --- SConstruct | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 239a0d9cc0a..ac81ca177fa 100644 --- a/SConstruct +++ b/SConstruct @@ -1446,6 +1446,9 @@ for libraryName, libraryDef in libraries.items() : # Graphics ######################################################################################################### +def inkscapeCmd(): + return env["INKSCAPE"] if env["PLATFORM"] != "win32" else "\"{}\"".format( env["INKSCAPE"] ) # Quote command string to support spaces in path on Windows + def buildImageCommand( source, target, env ) : # Requires env to have buildImageOptions set, containing, at minimum: @@ -1472,7 +1475,7 @@ def buildImageCommand( source, target, env ) : svgPath = os.path.abspath( svgFilename ), **substitutions ) - subprocess.check_call( env["INKSCAPE"] + " " + args, shell = True ) + subprocess.check_call( inkscapeCmd() + " " + args, shell = True ) def validateAndFlattenImageOptions( imageOptions, svg ) : @@ -1522,7 +1525,7 @@ def svgQuery( svgFile, id_ ) : objects = {} - queryCommand = env["INKSCAPE"] + " --query-all \"" + filepath + "\"" + queryCommand = inkscapeCmd() + " --query-all \"" + filepath + "\"" output = subprocess.check_output( queryCommand, shell=True ).decode() for line in output.split( "\n" ) : tokens = line.split( "," ) From dbf406f16315bc8c3c84c0e191ccc2f9f1cf9c40 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 16:43:55 -0400 Subject: [PATCH 007/123] Sconstruct : include environment variables on Windows --- SConstruct | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index ac81ca177fa..1d00a346424 100644 --- a/SConstruct +++ b/SConstruct @@ -392,6 +392,10 @@ if "clang++" in os.path.basename( env["CXX"] ): env["BUILD_DIR"] = os.path.abspath( env["BUILD_DIR"] ) +for e in env["ENV_VARS_TO_IMPORT"].split() : + if e in os.environ : + env["ENV"][e] = os.environ[e] + ########################################################################################### # POSIX configuration ########################################################################################### @@ -401,7 +405,7 @@ if env["PLATFORM"] != "win32" : # DISPLAY and HOME are essential for running gaffer when generating # the documentation. TERM is needed to get coloured output from the # compiler. - for e in env["ENV_VARS_TO_IMPORT"].split() + [ "DISPLAY", "HOME", "TERM" ] : + for e in [ "DISPLAY", "HOME", "TERM" ] : if e in os.environ : env["ENV"][e] = os.environ[e] From b1e547ee6d258e24a31d3b6bcb10203b93818fe2 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 16:44:52 -0400 Subject: [PATCH 008/123] Sconstruct : MSVC needs Advapi32 library for file owner information --- SConstruct | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 1d00a346424..61d385ce3fb 100644 --- a/SConstruct +++ b/SConstruct @@ -826,7 +826,14 @@ if env["ARNOLD_ROOT"] : vTuneRoot = env.subst("$VTUNE_ROOT") -gafferLib = {} +if env["PLATFORM"] == "win32" : + gafferLib = { + "envAppends" : { + "LIBS" : [ "Advapi32" ] + } + } +else: + gafferLib = {} if os.path.exists( vTuneRoot ): gafferLib = { From 243ebbcf878c2b02c8b8ee906607cc40fb98777f Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 16:45:18 -0400 Subject: [PATCH 009/123] Sconstruct : Locate Windows libraries - Arnold stores ai.lib in the `lib` directory - OpenGL uses opengl32 as the library name - Python stores libraries in `libs` --- SConstruct | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index 61d385ce3fb..61048a2408e 100644 --- a/SConstruct +++ b/SConstruct @@ -797,6 +797,10 @@ else : CPPPATH = [ "$BUILD_DIR/include/python$PYTHON_ABI_VERSION" ] ) + if basePythonEnv["PLATFORM"] == "win32" : + + basePythonEnv.Append( LIBPATH = "$BUILD_DIR/libs" ) + ############################################################################################### # Arnold configuration ############################################################################################### @@ -991,7 +995,7 @@ libraries = { "IECoreArnold" : { "envAppends" : { - "LIBPATH" : [ "$ARNOLD_ROOT/bin" ], + "LIBPATH" : [ "$ARNOLD_ROOT/bin", "$ARNOLD_ROOT/lib" ], ## \todo Remove GafferScene. We need it at present to get access to `IECoreScenePreview::Renderer`, # but IECoreArnold must never depend on Gaffer code; logically it is in the layer below Gaffer. "LIBS" : [ "GafferScene", "ai", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreVDB$CORTEX_LIB_SUFFIX", "openvdb$VDB_LIB_SUFFIX" ], @@ -999,7 +1003,7 @@ libraries = { "CPPPATH" : [ "$ARNOLD_ROOT/include" ], }, "pythonEnvAppends" : { - "LIBPATH" : [ "$ARNOLD_ROOT/bin" ], + "LIBPATH" : [ "$ARNOLD_ROOT/bin", "$ARNOLD_ROOT/lib" ], "LIBS" : [ "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreArnold" ], "CXXFLAGS" : [ "-DAI_ENABLE_DEPRECATION_WARNINGS" ], "CPPPATH" : [ "$ARNOLD_ROOT/include" ], @@ -1016,13 +1020,13 @@ libraries = { "GafferArnold" : { "envAppends" : { - "LIBPATH" : [ "$ARNOLD_ROOT/bin" ], + "LIBPATH" : [ "$ARNOLD_ROOT/bin", "$ARNOLD_ROOT/lib" ], "LIBS" : [ "Gaffer", "GafferScene", "GafferDispatch", "ai", "GafferVDB", "openvdb$VDB_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreVDB$CORTEX_LIB_SUFFIX", "IECoreArnold", "GafferOSL" ], "CXXFLAGS" : [ "-DAI_ENABLE_DEPRECATION_WARNINGS" ], "CPPPATH" : [ "$ARNOLD_ROOT/include" ], }, "pythonEnvAppends" : { - "LIBPATH" : [ "$ARNOLD_ROOT/bin" ], + "LIBPATH" : [ "$ARNOLD_ROOT/bin", "$ARNOLD_ROOT/lib" ], "LIBS" : [ "Gaffer", "GafferScene", "GafferBindings", "GafferVDB", "GafferDispatch", "GafferArnold", "GafferOSL", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreArnold" ], "CXXFLAGS" : [ "-DAI_ENABLE_DEPRECATION_WARNINGS" ], "CPPPATH" : [ "$ARNOLD_ROOT/include" ], @@ -1040,7 +1044,7 @@ libraries = { "GafferArnoldUI" : { "envAppends" : { - "LIBPATH" : [ "$ARNOLD_ROOT/bin" ], + "LIBPATH" : [ "$ARNOLD_ROOT/bin", "$ARNOLD_ROOT/lib" ], "LIBS" : [ "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "OpenImageIO$OIIO_LIB_SUFFIX", "oslquery$OSL_LIB_SUFFIX", "Gaffer", "GafferScene", "GafferOSL", "GafferSceneUI", "ai" ], "CXXFLAGS" : [ "-DAI_ENABLE_DEPRECATION_WARNINGS" ], "CPPPATH" : [ "$ARNOLD_ROOT/include" ], @@ -1060,7 +1064,7 @@ libraries = { "GafferArnoldPlugin" : { "envAppends" : { - "LIBPATH" : [ "$ARNOLD_ROOT/bin" ], + "LIBPATH" : [ "$ARNOLD_ROOT/bin", "$ARNOLD_ROOT/lib" ], "LIBS" : [ "IECoreArnold", "ai", "IECoreImage$CORTEX_LIB_SUFFIX" ], "CXXFLAGS" : [ "-DAI_ENABLE_DEPRECATION_WARNINGS" ], "CPPPATH" : [ "$ARNOLD_ROOT/include" ], @@ -1216,6 +1220,8 @@ libraries = { for library in ( "GafferUI", "GafferScene", "GafferSceneUI", "GafferImageUI" ) : if env["PLATFORM"] == "darwin" : libraries[library]["envAppends"].setdefault( "FRAMEWORKS", [] ).append( "OpenGL" ) + elif env["PLATFORM"] == "win32" : + libraries[library]["envAppends"]["LIBS"].append( "opengl32" ) else : libraries[library]["envAppends"]["LIBS"].append( "GL" ) libraries[library]["envAppends"]["LIBS"].append( "GLEW$GLEW_LIB_SUFFIX" ) From 1c7041fc31a6c4423c8d6729289a1c1be11a0d2f Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 16:45:54 -0400 Subject: [PATCH 010/123] Sconstruct : Windows Python libraries end in .pyd --- SConstruct | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SConstruct b/SConstruct index 61048a2408e..03dd8d23085 100644 --- a/SConstruct +++ b/SConstruct @@ -1367,6 +1367,8 @@ for libraryName, libraryDef in libraries.items() : # LIBSUFFIXES variable used by the library scanner. pythonModuleEnv["LIBSUFFIXES"].append( pythonModuleEnv.subst( "$SHLIBSUFFIX" ) ) pythonModuleEnv["SHLIBSUFFIX"] = ".so" + elif pythonModuleEnv["PLATFORM"] == "win32" : + pythonModuleEnv["SHLIBSUFFIX"] = ".pyd" pythonModule = pythonModuleEnv.SharedLibrary( "python/" + libraryName + "/_" + libraryName, pythonModuleSource ) pythonModuleEnv.Default( pythonModule ) From 978fb1a1237a20227c2917de7b5a32f4dae463cc Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 16:46:21 -0400 Subject: [PATCH 011/123] Sconstruct : MSVC preprocessor variables are case-sensitive --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 03dd8d23085..266620ae971 100644 --- a/SConstruct +++ b/SConstruct @@ -1319,7 +1319,7 @@ for libraryName, libraryDef in libraries.items() : pythonEnv.Append( **(libraryDef.get( "pythonEnvAppends", {} )) ) bindingsEnv = pythonEnv.Clone() - bindingsEnv.Append( CXXFLAGS = "-D{0}BINDINGS_EXPORTS".format( libraryName ) ) + bindingsEnv.Append( CXXFLAGS = "-D{0}Bindings_EXPORTS".format( libraryName ) ) bindingsSource = sorted( glob.glob( "src/" + libraryName + "Bindings/*.cpp" ) ) if bindingsSource : From aff09dee2279d6a89a9bc2af46762554ea1d67cf Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 15 Aug 2019 16:55:09 -0400 Subject: [PATCH 012/123] Sconstruct : Windows needs the full path to oslc --- SConstruct | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 266620ae971..a3f9b9f9e49 100644 --- a/SConstruct +++ b/SConstruct @@ -1429,8 +1429,7 @@ for libraryName, libraryDef in libraries.items() : # osl shaders def buildOSL( target, source, env ) : - - subprocess.check_call( [ "oslc", "-I./shaders", "-o", str( target[0] ), str( source[0] ) ], env = env["ENV"] ) + subprocess.check_call( [ env.subst( "$BUILD_DIR/bin/oslc" ), "-I./shaders", "-o", str( target[0] ), str( source[0] ) ], env = env["ENV"] ) for oslShader in libraryDef.get( "oslShaders", [] ) : env.Alias( "build", oslShader ) From 618a732041f7be698dc5ee34d3e9222c5b645891 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Apr 2021 15:18:48 -0400 Subject: [PATCH 013/123] Github Workflows : build for Windows --- .github/workflows/main.yml | 4 +- .github/workflows/main/installArnold.py | 78 +++++++++++ .github/workflows/main/installArnold.sh | 66 --------- .github/workflows/main/installDelight.py | 127 ++++++++++++++++++ .github/workflows/main/installDelight.sh | 19 --- .github/workflows/main/installDependencies.py | 21 ++- .github/workflows/main/sconsOptions | 41 +++++- 7 files changed, 266 insertions(+), 90 deletions(-) create mode 100755 .github/workflows/main/installArnold.py delete mode 100755 .github/workflows/main/installArnold.sh create mode 100755 .github/workflows/main/installDelight.py delete mode 100755 .github/workflows/main/installDelight.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2566d1b1523..41982e7af5d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,7 +144,7 @@ jobs: # below. run: | echo GAFFER_DEPENDENCIES_HASH=`python .github/workflows/main/installDependencies.py --archiveURL ${{ matrix.dependenciesURL }} --dependenciesDir ${{ env.GAFFER_BUILD_DIR }} --outputFormat "{archiveDigest}"` >> $GITHUB_ENV - ./.github/workflows/main/installDelight.sh + ./.github/workflows/main/installDelight.py echo DELIGHT=$GITHUB_WORKSPACE/3delight >> $GITHUB_ENV - name: Cache @@ -174,7 +174,7 @@ jobs: for arnoldVersion in 6.2.0.1 7.0.0.0 do # Install Arnold - ./.github/workflows/main/installArnold.sh $arnoldVersion + ./.github/workflows/main/installArnold.py --version $arnoldVersion export ARNOLD_ROOT=$GITHUB_WORKSPACE/arnoldRoot/$arnoldVersion # Build Arnold extension scons -j 2 build BUILD_TYPE=${{ matrix.buildType }} OPTIONS=.github/workflows/main/sconsOptions diff --git a/.github/workflows/main/installArnold.py b/.github/workflows/main/installArnold.py new file mode 100755 index 00000000000..7478b934573 --- /dev/null +++ b/.github/workflows/main/installArnold.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright (c) 2021, Hypothetical Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Image Engine Design nor the names of any +# other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + +import sys +import argparse +import os +import urllib +import zipfile + +if sys.version_info[0] < 3 : + from urllib import urlretrieve +else: + from urllib.request import urlretrieve + +platform = { "darwin" : "osx", "win32" : "windows" }.get( sys.platform, "linux" ) +format = { "win32" : "zip" }.get( sys.platform, "tar.gz" ) + +parser = argparse.ArgumentParser() + +parser.add_argument( + "--version", + help = "The Arnold version to install." +) + +args = parser.parse_args() + +archive = "Arnold-{version}-{platform}.{format}".format( + version = args.version, + platform = platform, + format = format +) + +url="https://forgithubci.solidangle.com/arnold/{}".format( archive ) + +installDir = os.path.join( "arnoldRoot", args.version ) +os.makedirs( installDir ) +os.chdir( installDir ) + +print( "Downloading Arnold \"{}\"".format( url ) ) +archiveFile, headers = urlretrieve( url ) + +if format == "tar.gz" : + os.system( "tar -xzf {}".format( archiveFile ) ) +elif format == "zip": + with zipfile.ZipFile( archiveFile ) as f : + f.extractall() diff --git a/.github/workflows/main/installArnold.sh b/.github/workflows/main/installArnold.sh deleted file mode 100755 index 73a2c7e077e..00000000000 --- a/.github/workflows/main/installArnold.sh +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/bash -########################################################################## -# -# Copyright (c) 2019, Cinesite VFX Ltd. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with -# the distribution. -# -# * Neither the name of Cinesite VFX Ltd. nor the names of -# any other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -set -e - -if [ -z $1 ] ; then - echo "Usage : installArnold.sh arnoldVersion" >&2 - exit 1 -fi - -arnoldVersion=$1 - -if [[ `uname` = "Linux" ]] ; then - arnoldPlatform=linux -else - arnoldPlatform=darwin -fi - -url=forgithubci.solidangle.com/arnold/Arnold-${arnoldVersion}-${arnoldPlatform}.tgz - -# Configure the login information, if this has been supplied. -login="" -if [ ! -z "${ARNOLD_LOGIN}" ] && [ ! -z "${ARNOLD_PASSWORD}" ] ; then - login="${ARNOLD_LOGIN}:${ARNOLD_PASSWORD}@" -fi - -mkdir -p arnoldRoot/$arnoldVersion && cd arnoldRoot/$arnoldVersion - -echo Downloading Arnold "https://${url}" -curl -L https://${login}${url} -o Arnold-${arnoldVersion}-${arnoldPlatform}.tgz - -tar -xzf Arnold-${arnoldVersion}-${arnoldPlatform}.tgz diff --git a/.github/workflows/main/installDelight.py b/.github/workflows/main/installDelight.py new file mode 100755 index 00000000000..860f9620cc3 --- /dev/null +++ b/.github/workflows/main/installDelight.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright (c) 2021, Hypothetical Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Image Engine Design nor the names of any +# other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + +import sys +import os +import shutil +import subprocess + +if sys.version_info[0] < 3 : + from urllib import urlretrieve +else : + from urllib.request import urlretrieve + +delightVersion="1.1.12" +delightDirectory="free/beta/2018-11-01-oIDoJTpO" + +baseUrl = "https://3delight-downloads.s3-us-east-2.amazonaws.com" + +if sys.platform.startswith("linux") : # pre Python 3.3 the major version is added at the end + package="3DelightNSI-{}-Linux-x86_64".format( delightVersion ) + + url = "{baseUrl}/{delightDirectory}/{package}.tar.xz".format( + baseUrl = baseUrl, + delightDirectory = delightDirectory, + package = package + ) + + print( "Downloading 3Delight \"{}\"".format( url ) ) + archiveFileName, headers = urlretrieve( url ) + + exitStatus = os.system( "tar -xf {} -C .".format( archiveFileName ) ) + if exitStatus != 0 : + exit( exitStatus ) + + shutil.copytree( "./{}/3delight/Linux-x86_64".format( package ), "./3delight" ) + +elif sys.platform == "darwin" : + package="3DelightNSI-{}-Darwin-Universal".format( delightVersion ) + + url = "{baseUrl}/{delightDirectory}/{package}.dmg".format( + baseUrl = baseUrl, + delightDirectory = delightDirectory, + package = package + ) + + print( "Downloading 3Delight \"{}\"".format( url ) ) + archiveFileName, headers = urlretrieve( url ) + + subprocess.check_call( + [ + "sudo", + "hdiutil", + "mount", + archiveFileName, + ] + ) + subprocess.check_call( + [ + "sudo", + "installer", + "-pkg", + "/Volumes/3Delight NSI " + "{delightVersion}/3DelightNSI-{delightVersion}-Darwin-x86_64.pkg".format( + delightVersion = delightVersion + ), + "-target", + "/", + ] + ) + subprocess.check_call( + [ + "sudo", + "mv", + "/Applications/3Delight", + "./3delight", + ] + ) + + +elif sys.platform == "win32": + package = "3DelightNSI-{}-setup.exe".format( delightVersion ) + + url = "{baseUrl}/{delightDirectory}/{package}".format( + baseUrl = baseUrl, + delightDirectory = delightDirectory, + package = package + ) + + print( "Downloading 3Delight \"{}\"".format( url ) ) + archiveFileName, headers = urlretrieve( url ) + + subprocess.check_call( [ archiveFileName, "/VERYSILENT", "/DIR=3delight" ] ) + + + diff --git a/.github/workflows/main/installDelight.sh b/.github/workflows/main/installDelight.sh deleted file mode 100755 index c74600ed712..00000000000 --- a/.github/workflows/main/installDelight.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash - -set -e - -version=1.1.12 -directory=free/beta/2018-11-01-oIDoJTpO - -if [[ `uname` = "Linux" ]] ; then - package=3DelightNSI-$version-Linux-x86_64 - curl https://3delight-downloads.s3-us-east-2.amazonaws.com/$directory/$package.tar.xz > $package.tar.xz - tar -xf $package.tar.xz - mv ./$package/3delight/Linux-x86_64 ./3delight -else - package=3DelightNSI-$version-Darwin-Universal - curl https://3delight-downloads.s3-us-east-2.amazonaws.com/$directory/$package.dmg > $package.dmg - sudo hdiutil mount $package.dmg - sudo installer -pkg /Volumes/3Delight\ NSI\ $version/3DelightNSI-$version-Darwin-x86_64.pkg -target / - sudo mv /Applications/3Delight ./3delight -fi diff --git a/.github/workflows/main/installDependencies.py b/.github/workflows/main/installDependencies.py index b76ac7b3fb9..b623e60467e 100755 --- a/.github/workflows/main/installDependencies.py +++ b/.github/workflows/main/installDependencies.py @@ -38,6 +38,9 @@ import sys import argparse import hashlib +import subprocess +import glob +import shutil if sys.version_info[0] < 3 : from urllib import urlretrieve @@ -46,7 +49,7 @@ # Determine default archive URL. -platform = "osx" if sys.platform == "darwin" else "linux" +platform = { "darwin" : "osx", "win32" : "windows" }.get( sys.platform, "linux" ) defaultURL = "https://github.com/GafferHQ/dependencies/releases/download/4.0.0/gafferDependencies-4.0.0-Python2-" + platform + ".tar.gz" # Parse command line arguments. @@ -81,7 +84,21 @@ archiveFileName, headers = urlretrieve( args.archiveURL ) os.makedirs( args.dependenciesDir ) -os.system( "tar xf %s -C %s --strip-components=1" % ( archiveFileName, args.dependenciesDir ) ) +if platform != "windows": + os.system( "tar xf %s -C %s --strip-components=1" % ( archiveFileName, args.dependenciesDir ) ) +else: + subprocess.check_output( "7z x %s -o%s -aoa -y" % ( archiveFileName, args.dependenciesDir ) ) + # 7z (and zip extractors generally) don't have an equivalent of --strip-components=1 + # Copy the files up one directory level to compensate + for p in glob.glob( + os.path.join( + args.dependenciesDir.replace( "/", "\\" ), + os.path.splitext( args.archiveURL.split( "/" )[-1] )[0], + "*" + ) + ): + shutil.move( p, args.dependenciesDir ) + # Tell the world diff --git a/.github/workflows/main/sconsOptions b/.github/workflows/main/sconsOptions index 5d4daad8690..eab69b1ba3c 100644 --- a/.github/workflows/main/sconsOptions +++ b/.github/workflows/main/sconsOptions @@ -35,6 +35,11 @@ ########################################################################## import os +import sys +import glob +import subprocess + +platform = {"darwin" : "osx", "win32" : "windows"}.get(sys.platform, "linux") ENV_VARS_TO_IMPORT = "PATH" @@ -46,6 +51,40 @@ DELIGHT_ROOT = os.environ["DELIGHT"] BUILD_DIR = os.environ["GAFFER_BUILD_DIR"] INSTALL_DIR = os.path.join( "install", os.environ["GAFFER_BUILD_NAME"] ) -PACKAGE_FILE = "%s.tar.gz" % os.environ["GAFFER_BUILD_NAME"] +PACKAGE_FILE = "{}.{}".format( + os.environ["GAFFER_BUILD_NAME"], + {"win32" : "zip"}.get( sys.platform, "tar.gz" ) +) SPHINX = os.environ["GAFFER_SPHINX"] + +if sys.platform == "win32" : + + # It would be nice to get this from the command line, but I don't know of any way + # to do that. It will need to be changed when upgrading Visual Studio versions. + toolSetVersion = "141" + + # Get the Boost version from the include directory. + # It is named "boost-_" + boostInclude = glob.glob( os.path.join( os.environ["GAFFER_BUILD_DIR"], "include", "boost-*" ) ) + if len( boostInclude ) > 0 : + boostVersion = os.path.split( boostInclude[0] )[-1].split( '-' )[1] + + # Get the Python version, as in SConstruct but without the '.' separating major from minor version + pythonVersion = subprocess.check_output( + [ "python", "-c", "import sys; print( '{}{}'.format( *sys.version_info[:2] ) )" ], + universal_newlines=True + ).strip() + + BOOST_LIB_SUFFIX = "-vc" + toolSetVersion + "-mt-x64-" + boostVersion + BOOST_PYTHON_LIB_SUFFIX = pythonVersion + "-vc" + toolSetVersion + "-mt-x64-" + boostVersion + LOCATE_DEPENDENCY_SYSTEMPATH = [ + os.path.join( os.environ["GAFFER_BUILD_DIR"], "include", "boost-" + boostVersion ) + ] + + LOCATE_DEPENDENCY_LIBPATH=os.path.join(os.environ["GAFFER_BUILD_DIR"], "lib") + LOCATE_DEPENDENCY_PYTHONPATH=os.path.join(os.environ["GAFFER_BUILD_DIR"], "python") + GLEW_LIB_SUFFIX = "32" + INKSCAPE = "C:\\Program Files\\Inkscape\\inkscape.com" + WARNINGS_AS_ERRORS = False + APPLESEED_ROOT = None From 9c88ee26985a5503cdb9cf3a9a2b89750b5441a5 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 4 Jan 2022 17:57:23 -0500 Subject: [PATCH 014/123] installDependencies : open archive in binary mode for hashing - Opening the file in text mode on Windows generates an error during hashing : "UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 129: character maps to " --- .github/workflows/main/installDependencies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main/installDependencies.py b/.github/workflows/main/installDependencies.py index b623e60467e..096fcdf7825 100755 --- a/.github/workflows/main/installDependencies.py +++ b/.github/workflows/main/installDependencies.py @@ -105,7 +105,7 @@ if args.outputFormat : md5 = hashlib.md5() - with open( archiveFileName ) as f : + with open( archiveFileName, mode="rb" ) as f : md5.update( f.read() ) print( From 56aaaab661327812e3860164a6e78ac2162332cc Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 4 Jan 2022 15:25:55 -0500 Subject: [PATCH 015/123] TEMP : build all branches on CI --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41982e7af5d..92a080c8aef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,8 +3,7 @@ name: CI on: push: branches: - - master - - '*_maintenance' + - '*' pull_request: branches: - master From a1acf65ba33dd11503fd09d32237f1498fb3eeb0 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 10 Jan 2022 17:13:00 -0500 Subject: [PATCH 016/123] Github workflows : build Windows configuration --- .github/workflows/main.yml | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92a080c8aef..0776c98b5ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,7 @@ jobs: linux-python2-debug, linux-python3, macos-python2, + windows-python3, ] include: @@ -78,6 +79,14 @@ jobs: testRunner: bash -c sconsCacheMegabytes: 400 + - name: windows-python3 + os: windows-2016 + buildType: RELEASE + variant: windows-python3 + publish: false + containerImage: + dependenciesURL: https://github.com/hypothetical-inc/gafferDependencies/releases/download/4.0.0/gafferDependencies-4.0.0-Python3-windows.zip + runs-on: ${{ matrix.os }} container: ${{ matrix.containerImage }} @@ -92,6 +101,21 @@ jobs: - uses: actions/checkout@v2 + - uses: ilammy/msvc-dev-cmd@v1.10.0 + with: + sdk: 10.0.17763.0 + + - name: Install toolchain (Windows) + run: python -m pip install scons + if: runner.os == 'Windows' + + - name: Install Inkscape (Windows) + run: | + Invoke-WebRequest -Uri "https://inkscape.org/gallery/item/18067/inkscape-0.92.5-x64.exe" -OutFile "inkscape.exe" + Start-Process .\inkscape.exe /S -NoNewWindow -Wait + shell: pwsh + if: runner.os == 'Windows' + - name: Install toolchain (MacOS) # Prefer `pip install` where possible because it is faster # than `brew install`. @@ -130,6 +154,7 @@ jobs: env: GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} GAFFER_BUILD_VARIANT: ${{ matrix.name }} + shell: bash - name: Disable macOS PR Docs run: | @@ -145,6 +170,7 @@ jobs: echo GAFFER_DEPENDENCIES_HASH=`python .github/workflows/main/installDependencies.py --archiveURL ${{ matrix.dependenciesURL }} --dependenciesDir ${{ env.GAFFER_BUILD_DIR }} --outputFormat "{archiveDigest}"` >> $GITHUB_ENV ./.github/workflows/main/installDelight.py echo DELIGHT=$GITHUB_WORKSPACE/3delight >> $GITHUB_ENV + shell: bash - name: Cache uses: actions/cache@v1 @@ -167,8 +193,9 @@ jobs: echo "::add-matcher::./.github/workflows/main/problemMatchers/unittest.json" ${{ matrix.testRunner }} "${{ env.GAFFER_BUILD_DIR }}/bin/gaffer test" echo "::remove-matcher owner=unittest::" + if: runner.os == 'macOS' || runner.os == 'Linux' - - name: Build and test Arnold extension + - name: Build and test Arnold extension (MacOS and Linux) run: | for arnoldVersion in 6.2.0.1 7.0.0.0 do @@ -185,6 +212,22 @@ jobs: # so we can build the docs for GafferArnold. echo ARNOLD_ROOT=$ARNOLD_ROOT >> $GITHUB_ENV done + if: runner.os == 'macOS' || runner.os == 'Linux' + + - name: Build and test Arnold extension (Windows) + run: | + for %%G in (6.2.0.1 7.0.0.0) do ( + REM Install Arnold + python .github/workflows/main/installArnold.py --version %%G + set ARNOLD_ROOT=%GITHUB_WORKSPACE%\arnoldRoot\%%G + REM Build Arnold extension + scons -j 2 build BUILD_TYPE=${{ matrix.buildType }} OPTIONS=.github/workflows/main/sconsOptions + REM Publish ARNOLD_ROOT to the environment for subsequent steps, + REM so we can build the docs for GafferArnold. + echo ARNOLD_ROOT=%ARNOLD_ROOT% >> %GITHUB_ENV% + ) + shell: cmd + if: runner.os == 'Windows' - name: Build Docs and Package # We currently experience sporadic hangs in the docs builds (mac), this From 75c5ac071725f5fc1dc1e6dd3952f1abfa708095 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sun, 8 Jul 2018 16:37:33 -0400 Subject: [PATCH 017/123] Gaffer : Export symbols --- include/Gaffer/Animation.h | 6 +-- include/Gaffer/Context.h | 8 +-- include/Gaffer/ContextAlgo.h | 2 +- include/Gaffer/ContextMonitor.h | 2 +- include/Gaffer/Expression.h | 2 +- include/Gaffer/Monitor.h | 2 +- include/Gaffer/PerformanceMonitor.h | 2 +- include/Gaffer/Spreadsheet.h | 6 +-- include/Gaffer/ThreadState.h | 2 +- include/GafferBindings/DataBinding.h | 2 + .../MatchPatternPathFilterBinding.h | 49 +++++++++++++++++++ include/GafferBindings/MetadataBinding.h | 2 + include/GafferBindings/Serialisation.h | 2 +- include/GafferBindings/SignalBinding.inl | 2 + src/Gaffer/Context.cpp | 2 +- src/GafferBindings/SignalBinding.cpp | 4 +- 16 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 include/GafferBindings/MatchPatternPathFilterBinding.h diff --git a/include/Gaffer/Animation.h b/include/Gaffer/Animation.h index ee788ada1d2..7fed119d773 100644 --- a/include/Gaffer/Animation.h +++ b/include/Gaffer/Animation.h @@ -105,7 +105,7 @@ class GAFFER_API Animation : public ComputeNode IE_CORE_DECLAREPTR( Interpolator ) // Defines a tangent - class Tangent : private boost::noncopyable + class GAFFER_API Tangent : private boost::noncopyable { public: @@ -200,7 +200,7 @@ class GAFFER_API Animation : public ComputeNode }; /// Defines a single keyframe. - class Key : public IECore::RunTimeTyped + class GAFFER_API Key : public IECore::RunTimeTyped { public : @@ -318,7 +318,7 @@ class GAFFER_API Animation : public ComputeNode /// Defines a curve as a collection of keyframes and methods /// for editing them. Provides methods for evaluating the /// interpolated curve at arbitrary positions. - class CurvePlug : public ValuePlug + class GAFFER_API CurvePlug : public ValuePlug { public : diff --git a/include/Gaffer/Context.h b/include/Gaffer/Context.h index 445ebc09833..ac9098ca273 100644 --- a/include/Gaffer/Context.h +++ b/include/Gaffer/Context.h @@ -189,7 +189,7 @@ class GAFFER_API Context : public IECore::RefCounted /// The Scope class is used to push and pop the current context on /// the calling thread. - class Scope : private ThreadState::Scope + class GAFFER_API Scope : private ThreadState::Scope { public : @@ -209,7 +209,7 @@ class GAFFER_API Context : public IECore::RefCounted /// because it is harder to provide the necessary lifetime /// guarantees there, and performance critical code should /// not be implemented in Python in any case. - class EditableScope : private ThreadState::Scope + class GAFFER_API EditableScope : private ThreadState::Scope { public : @@ -307,7 +307,7 @@ class GAFFER_API Context : public IECore::RefCounted // along with the `IECore::TypeId` for `TypedData`, which is used to // validate type-safe access. Does not manage memory or ownership in any // way : this is the responsibility of calling code. - struct Value + struct GAFFER_API Value { Value(); @@ -349,7 +349,7 @@ class GAFFER_API Context : public IECore::RefCounted const void *m_value; IECore::MurmurHash m_hash; - struct TypeFunctions + struct GAFFER_API TypeFunctions { IECore::DataPtr (*makeData)( const Value &value, const void **dataValue ); bool (*isEqual)( const Value &a, const Value &b ); diff --git a/include/Gaffer/ContextAlgo.h b/include/Gaffer/ContextAlgo.h index 3756707eb05..2fea5af28d7 100644 --- a/include/Gaffer/ContextAlgo.h +++ b/include/Gaffer/ContextAlgo.h @@ -62,7 +62,7 @@ class GAFFER_API GlobalScope : boost::noncopyable GlobalScope( const Context *context, const Plug *plug ); ~GlobalScope(); - struct Registration + struct GAFFER_API Registration { Registration( IECore::TypeId plugTypeId, const std::initializer_list &variablesToRemove ); }; diff --git a/include/Gaffer/ContextMonitor.h b/include/Gaffer/ContextMonitor.h index 1cb4effba17..3ea33d6e8e0 100644 --- a/include/Gaffer/ContextMonitor.h +++ b/include/Gaffer/ContextMonitor.h @@ -71,7 +71,7 @@ class GAFFER_API ContextMonitor : public Monitor IE_CORE_DECLAREMEMBERPTR( ContextMonitor ) - struct Statistics + struct GAFFER_API Statistics { size_t numUniqueContexts() const; diff --git a/include/Gaffer/Expression.h b/include/Gaffer/Expression.h index 15c8da2c051..b8b3d6c1020 100644 --- a/include/Gaffer/Expression.h +++ b/include/Gaffer/Expression.h @@ -90,7 +90,7 @@ class GAFFER_API Expression : public ComputeNode /// for use in the Expression node. All methods /// are protected as Engines are for the internal /// use of the Expression node only. - class Engine : public IECore::RefCounted + class GAFFER_API Engine : public IECore::RefCounted { public : diff --git a/include/Gaffer/Monitor.h b/include/Gaffer/Monitor.h index 8355edacb68..e1570380df5 100644 --- a/include/Gaffer/Monitor.h +++ b/include/Gaffer/Monitor.h @@ -59,7 +59,7 @@ class GAFFER_API Monitor : public IECore::RefCounted using MonitorSet = boost::container::flat_set; - class Scope : private ThreadState::Scope + class GAFFER_API Scope : ThreadState::Scope { public : diff --git a/include/Gaffer/PerformanceMonitor.h b/include/Gaffer/PerformanceMonitor.h index d471d39321b..d0930864e8f 100644 --- a/include/Gaffer/PerformanceMonitor.h +++ b/include/Gaffer/PerformanceMonitor.h @@ -65,7 +65,7 @@ class GAFFER_API PerformanceMonitor : public Monitor IE_CORE_DECLAREMEMBERPTR( PerformanceMonitor ) - struct Statistics + struct GAFFER_API Statistics { Statistics( diff --git a/include/Gaffer/Spreadsheet.h b/include/Gaffer/Spreadsheet.h index eef2156db47..60f87f80101 100644 --- a/include/Gaffer/Spreadsheet.h +++ b/include/Gaffer/Spreadsheet.h @@ -70,7 +70,7 @@ class GAFFER_API Spreadsheet : public ComputeNode /// /// > Note : It is strongly recommended that the child RowPlugs are /// > accessed via their numeric indices and never via their names. - class RowsPlug : public ValuePlug + class GAFFER_API RowsPlug : public ValuePlug { public : @@ -143,7 +143,7 @@ class GAFFER_API Spreadsheet : public ComputeNode /// Defines a single row of the spreadsheet. Access using /// `RowPlug::Range( *rowsPlug() )` or via `rowsPlug()->getChild()`. - class RowPlug : public ValuePlug + class GAFFER_API RowPlug : public ValuePlug { public : @@ -171,7 +171,7 @@ class GAFFER_API Spreadsheet : public ComputeNode /// Defines a single cell in the spreadsheet. Access using /// `CellPlug::Range( *rowPlug->cellsPlug() )` or via /// `rowPlug->cellsPlug()->getChild()`. - class CellPlug : public ValuePlug + class GAFFER_API CellPlug : public ValuePlug { public : diff --git a/include/Gaffer/ThreadState.h b/include/Gaffer/ThreadState.h index 9050a27bbc0..37edf862400 100644 --- a/include/Gaffer/ThreadState.h +++ b/include/Gaffer/ThreadState.h @@ -81,7 +81,7 @@ class GAFFER_API ThreadState /// no active monitors, and a default constructed Context. ThreadState(); - class Scope : public boost::noncopyable + class GAFFER_API Scope : public boost::noncopyable { public : diff --git a/include/GafferBindings/DataBinding.h b/include/GafferBindings/DataBinding.h index 9b42331bd8a..fa3eb3f55ac 100644 --- a/include/GafferBindings/DataBinding.h +++ b/include/GafferBindings/DataBinding.h @@ -43,6 +43,8 @@ #include "IECore/Data.h" +#include "GafferBindings/Export.h" + namespace GafferBindings { diff --git a/include/GafferBindings/MatchPatternPathFilterBinding.h b/include/GafferBindings/MatchPatternPathFilterBinding.h new file mode 100644 index 00000000000..363a286f86e --- /dev/null +++ b/include/GafferBindings/MatchPatternPathFilterBinding.h @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERBINDINGS_MATCHPATTERNPATHFILTERBINDING_H +#define GAFFERBINDINGS_MATCHPATTERNPATHFILTERBINDING_H + +#include "GafferBindings/Export.h" + +namespace GafferBindings +{ + +GAFFERBINDINGS_API void bindMatchPatternPathFilter(); + +} // namespace GafferBindings + +#endif // GAFFERBINDINGS_MATCHPATTERNPATHFILTERBINDING_H diff --git a/include/GafferBindings/MetadataBinding.h b/include/GafferBindings/MetadataBinding.h index ddc442dfa55..19d0eaeae91 100644 --- a/include/GafferBindings/MetadataBinding.h +++ b/include/GafferBindings/MetadataBinding.h @@ -41,6 +41,8 @@ #include "GafferBindings/Serialisation.h" +#include "GafferBindings/Export.h" + namespace GafferBindings { diff --git a/include/GafferBindings/Serialisation.h b/include/GafferBindings/Serialisation.h index 0213d063051..a3d18aa5066 100644 --- a/include/GafferBindings/Serialisation.h +++ b/include/GafferBindings/Serialisation.h @@ -113,7 +113,7 @@ class GAFFERBINDINGS_API Serialisation : boost::noncopyable /// on Serialiser and adding to the methods on Serialisation. The logical conclusion /// may be a single `Serialiser::serialise()` method and various `Serialisation::add*()` /// methods. - class Serialiser : public IECore::RefCounted + class GAFFERBINDINGS_API Serialiser : public IECore::RefCounted { public : diff --git a/include/GafferBindings/SignalBinding.inl b/include/GafferBindings/SignalBinding.inl index 0b28ffab39a..fc3eb014ead 100644 --- a/include/GafferBindings/SignalBinding.inl +++ b/include/GafferBindings/SignalBinding.inl @@ -45,6 +45,8 @@ #include "boost/signals.hpp" #include "boost/version.hpp" +#include "GafferBindings/Export.h" + namespace GafferBindings { diff --git a/src/Gaffer/Context.cpp b/src/Gaffer/Context.cpp index 31c447e49cf..50a102d113d 100644 --- a/src/Gaffer/Context.cpp +++ b/src/Gaffer/Context.cpp @@ -167,7 +167,7 @@ void Context::Value::validate( const IECore::InternedString &name ) const typeFunctions( m_typeId ).validate( name, *this ); } -Context::Value::TypeMap &Context::Value::typeMap() +GAFFER_API Context::Value::TypeMap &Context::Value::typeMap() { static TypeMap m_map; return m_map; diff --git a/src/GafferBindings/SignalBinding.cpp b/src/GafferBindings/SignalBinding.cpp index edcf4774c16..38bd86822f5 100644 --- a/src/GafferBindings/SignalBinding.cpp +++ b/src/GafferBindings/SignalBinding.cpp @@ -41,6 +41,8 @@ #include "boost/signals.hpp" +#include "GafferBindings/Export.h" + using namespace boost::python; namespace GafferBindings @@ -49,7 +51,7 @@ namespace GafferBindings namespace Detail { -boost::python::object pythonConnection( const boost::signals::connection &connection, bool scoped ) +GAFFERBINDINGS_API boost::python::object pythonConnection( const boost::signals::connection &connection, bool scoped ) { if( scoped ) { From 7e331eda71e5fe4af89ae535534074317373ba07 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 4 Jan 2022 11:45:34 -0500 Subject: [PATCH 018/123] GafferBindings : Export symbols --- include/GafferBindings/DependencyNodeBinding.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/GafferBindings/DependencyNodeBinding.h b/include/GafferBindings/DependencyNodeBinding.h index 1ac0e3be7d2..6e877d2ae7c 100644 --- a/include/GafferBindings/DependencyNodeBinding.h +++ b/include/GafferBindings/DependencyNodeBinding.h @@ -40,6 +40,7 @@ #include "boost/python.hpp" +#include "GafferBindings/Export.h" #include "GafferBindings/NodeBinding.h" #include "Gaffer/Context.h" @@ -64,7 +65,7 @@ class DependencyNodeClass : public NodeClass }; -class GAFFER_API DependencyNodeWrapperBase +class GAFFERBINDINGS_API DependencyNodeWrapperBase { protected : From 389646d92de935faa5bb8db0104cf2ee9fd3847f Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:04:40 -0700 Subject: [PATCH 019/123] GafferUI : Export symbols --- include/GafferUI/ButtonEvent.h | 1 + include/GafferUI/ContainerGadget.h | 1 + include/GafferUI/DragDropEvent.h | 1 + include/GafferUI/Frame.h | 1 + include/GafferUI/Handle.h | 5 +- include/GafferUI/IndividualContainer.h | 1 + include/GafferUI/KeyEvent.h | 1 + include/GafferUI/LinearContainer.h | 1 + include/GafferUI/ModifiableEvent.h | 1 + include/GafferUI/NameGadget.h | 1 + include/GafferUI/NodeGadget.h | 1 + include/GafferUI/PlugGadget.h | 1 + include/GafferUI/Pointer.h | 2 + include/GafferUI/RenderableGadget.h | 157 +++++++++++++++++++++++++ include/GafferUI/RotateHandle.h | 1 + include/GafferUI/ScaleHandle.h | 1 + include/GafferUI/SpacerGadget.h | 1 + include/GafferUI/SplinePlugGadget.h | 109 +++++++++++++++++ include/GafferUI/StandardGraphLayout.h | 1 + include/GafferUI/TextGadget.h | 1 + include/GafferUI/TranslateHandle.h | 1 + include/GafferUI/ViewportGadget.h | 4 +- 22 files changed, 290 insertions(+), 4 deletions(-) create mode 100644 include/GafferUI/RenderableGadget.h create mode 100644 include/GafferUI/SplinePlugGadget.h diff --git a/include/GafferUI/ButtonEvent.h b/include/GafferUI/ButtonEvent.h index 8b46fc0139d..51eb3ec19f7 100644 --- a/include/GafferUI/ButtonEvent.h +++ b/include/GafferUI/ButtonEvent.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_BUTTONEVENT_H #define GAFFERUI_BUTTONEVENT_H +#include "GafferUI/Export.h" #include "GafferUI/ModifiableEvent.h" #include "IECore/LineSegment.h" diff --git a/include/GafferUI/ContainerGadget.h b/include/GafferUI/ContainerGadget.h index cb1c29ac73d..b42a3bebc5b 100644 --- a/include/GafferUI/ContainerGadget.h +++ b/include/GafferUI/ContainerGadget.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_CONTAINERGADGET_H #define GAFFERUI_CONTAINERGADGET_H +#include "GafferUI/Export.h" #include "GafferUI/Gadget.h" namespace GafferUI diff --git a/include/GafferUI/DragDropEvent.h b/include/GafferUI/DragDropEvent.h index a920ea4ddb1..ebf176d52a1 100644 --- a/include/GafferUI/DragDropEvent.h +++ b/include/GafferUI/DragDropEvent.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_DRAGDROPEVENT_H #define GAFFERUI_DRAGDROPEVENT_H +#include "GafferUI/Export.h" #include "GafferUI/ButtonEvent.h" #include "IECore/RunTimeTyped.h" diff --git a/include/GafferUI/Frame.h b/include/GafferUI/Frame.h index ebb4ef8a0a6..f6f32888803 100644 --- a/include/GafferUI/Frame.h +++ b/include/GafferUI/Frame.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_FRAME_H #define GAFFERUI_FRAME_H +#include "GafferUI/Export.h" #include "GafferUI/IndividualContainer.h" namespace GafferUI diff --git a/include/GafferUI/Handle.h b/include/GafferUI/Handle.h index 029047e0896..e8352e53431 100644 --- a/include/GafferUI/Handle.h +++ b/include/GafferUI/Handle.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_HANDLE_H #define GAFFERUI_HANDLE_H +#include "GafferUI/Export.h" #include "GafferUI/Gadget.h" #include "GafferUI/Style.h" @@ -85,7 +86,7 @@ class GAFFERUI_API Handle : public Gadget // Helper for performing linear drags. Should be constructed // in `dragBegin()` and then `position()` should be used // to measure the progress of the drag. - struct LinearDrag + struct GAFFERUI_API LinearDrag { LinearDrag( bool processModifiers = true ); @@ -117,7 +118,7 @@ class GAFFERUI_API Handle : public Gadget }; // Helper for performing drags in a plane. - struct PlanarDrag + struct GAFFERUI_API PlanarDrag { PlanarDrag( bool processModifiers = true ); diff --git a/include/GafferUI/IndividualContainer.h b/include/GafferUI/IndividualContainer.h index 0f5946d3850..a14981f6c78 100644 --- a/include/GafferUI/IndividualContainer.h +++ b/include/GafferUI/IndividualContainer.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_INDIVIDUALCONTAINER_H #define GAFFERUI_INDIVIDUALCONTAINER_H +#include "GafferUI/Export.h" #include "GafferUI/ContainerGadget.h" namespace GafferUI diff --git a/include/GafferUI/KeyEvent.h b/include/GafferUI/KeyEvent.h index 20a16e23f18..d12a7e2a70f 100644 --- a/include/GafferUI/KeyEvent.h +++ b/include/GafferUI/KeyEvent.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_KEYEVENT_H #define GAFFERUI_KEYEVENT_H +#include "GafferUI/Export.h" #include "GafferUI/ModifiableEvent.h" #include "IECore/Export.h" diff --git a/include/GafferUI/LinearContainer.h b/include/GafferUI/LinearContainer.h index a6cc43738a8..16f49c2a3a8 100644 --- a/include/GafferUI/LinearContainer.h +++ b/include/GafferUI/LinearContainer.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_LINEARCONTAINER_H #define GAFFERUI_LINEARCONTAINER_H +#include "GafferUI/Export.h" #include "GafferUI/ContainerGadget.h" namespace GafferUI diff --git a/include/GafferUI/ModifiableEvent.h b/include/GafferUI/ModifiableEvent.h index 604f387f2a6..84fa2b95766 100644 --- a/include/GafferUI/ModifiableEvent.h +++ b/include/GafferUI/ModifiableEvent.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_MODIFIABLEEVENT_H #define GAFFERUI_MODIFIABLEEVENT_H +#include "GafferUI/Export.h" #include "GafferUI/Event.h" namespace GafferUI diff --git a/include/GafferUI/NameGadget.h b/include/GafferUI/NameGadget.h index 2a8d1f142d6..c9fb48ae900 100644 --- a/include/GafferUI/NameGadget.h +++ b/include/GafferUI/NameGadget.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_NAMEGADGET_H #define GAFFERUI_NAMEGADGET_H +#include "GafferUI/Export.h" #include "GafferUI/TextGadget.h" #include "IECoreScene/Font.h" diff --git a/include/GafferUI/NodeGadget.h b/include/GafferUI/NodeGadget.h index c615b39a76c..dbf40585555 100644 --- a/include/GafferUI/NodeGadget.h +++ b/include/GafferUI/NodeGadget.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_NODEGADGET_H #define GAFFERUI_NODEGADGET_H +#include "GafferUI/Export.h" #include "GafferUI/IndividualContainer.h" #include "Gaffer/Set.h" diff --git a/include/GafferUI/PlugGadget.h b/include/GafferUI/PlugGadget.h index 94cbd6bb16e..56b9bbc86e4 100644 --- a/include/GafferUI/PlugGadget.h +++ b/include/GafferUI/PlugGadget.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_PLUGGADGET_H #define GAFFERUI_PLUGGADGET_H +#include "GafferUI/Export.h" #include "GafferUI/ContainerGadget.h" namespace Gaffer diff --git a/include/GafferUI/Pointer.h b/include/GafferUI/Pointer.h index ab19d0e68b3..e8fd55afcef 100644 --- a/include/GafferUI/Pointer.h +++ b/include/GafferUI/Pointer.h @@ -43,6 +43,8 @@ #include "boost/signals.hpp" +#include "GafferUI/Export.h" + namespace GafferUI { diff --git a/include/GafferUI/RenderableGadget.h b/include/GafferUI/RenderableGadget.h new file mode 100644 index 00000000000..7294c5a1be9 --- /dev/null +++ b/include/GafferUI/RenderableGadget.h @@ -0,0 +1,157 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2011-2012, John Haddon. All rights reserved. +// Copyright (c) 2012-2013, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERUI_RENDERABLEGADGET_H +#define GAFFERUI_RENDERABLEGADGET_H + +#include "IECore/VisibleRenderable.h" + +#include "GafferUI/Export.h" +#include "GafferUI/Gadget.h" + +namespace IECoreGL +{ + +IE_CORE_FORWARDDECLARE( Scene ) +IE_CORE_FORWARDDECLARE( State ) +IE_CORE_FORWARDDECLARE( Group ) +IE_CORE_FORWARDDECLARE( StateComponent ) + +} // namespace IECoreGL + +namespace GafferUI +{ + +IE_CORE_FORWARDDECLARE( RenderableGadget ); + +/// \todo Either remove this or move it to GafferCortexUI. +class GAFFERUI_API RenderableGadget : public Gadget +{ + + public : + + RenderableGadget( IECore::VisibleRenderablePtr renderable = 0 ); + virtual ~RenderableGadget(); + + IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferUI::RenderableGadget, RenderableGadgetTypeId, Gadget ); + + virtual Imath::Box3f bound() const; + + void setRenderable( IECore::ConstVisibleRenderablePtr renderable ); + IECore::ConstVisibleRenderablePtr getRenderable() const; + + /// Returns the IECoreGL::State object used as the base display + /// style for the Renderable. This may be modified freely to + /// change the display style. + IECoreGL::State *baseState(); + + /// Returns the name of the frontmost object intersecting the specified line + /// through gadget space, or "" if there is no such object. + std::string objectAt( const IECore::LineSegment3f &lineInGadgetSpace ) const; + /// Fills objectNames with all objects intersected by a rectangle in screen space, + /// defined by two corners in gadget space (as required for drag selection). + size_t objectsAt( + const Imath::V3f &corner0InGadgetSpace, + const Imath::V3f &corner1InGadgetSpace, + std::vector &objectNames + ) const; + + /// @name Selection + /// The RenderableGadget maintains a set of selected object, based + /// on object name. The user can manipulate the selection with the + /// mouse, and the selected objects are drawn in a highlighted fashion. + /// The selection may be queried and set programatically, and the + /// SelectionChangedSignal can be used to provide notifications of + /// such changes. + //////////////////////////////////////////////////////////////////// + //@{ + /// The selection is simply stored as a set of object names. + typedef std::set Selection; + /// Returns the selection. + Selection &getSelection(); + const Selection &getSelection() const; + /// Sets the selection, triggering selectionChangedSignal() if + /// necessary. + void setSelection( const std::set &selection ); + /// A signal emitted when the selection has changed, either through + /// a call to setSelection() or through user action. + typedef boost::signal SelectionChangedSignal; + SelectionChangedSignal &selectionChangedSignal(); + /// Returns the bounding box of all the selected objects. + Imath::Box3f selectionBound() const; + //@} + + /// Implemented to return the name of the object under the mouse as + /// a tooltip. + virtual std::string getToolTip( const IECore::LineSegment3f &line ) const; + + protected : + + virtual void doRender( const Style *style ) const; + + private : + + bool buttonPress( GadgetPtr gadget, const ButtonEvent &event ); + IECore::RunTimeTypedPtr dragBegin( GadgetPtr gadget, const DragDropEvent &event ); + bool dragEnter( GadgetPtr gadget, const DragDropEvent &event ); + bool dragMove( GadgetPtr gadget, const DragDropEvent &event ); + bool dragEnd( GadgetPtr gadget, const DragDropEvent &event ); + + void applySelection( IECoreGL::Group *group = 0 ); + Imath::Box3f selectionBound( IECoreGL::Group *group ) const; + + IECore::ConstVisibleRenderablePtr m_renderable; + IECoreGL::ScenePtr m_scene; + IECoreGL::StatePtr m_baseState; + IECoreGL::StateComponentPtr m_selectionColor; + IECoreGL::StateComponentPtr m_wireframeOn; + + Selection m_selection; + SelectionChangedSignal m_selectionChangedSignal; + + Imath::V3f m_dragStartPosition; + Imath::V3f m_lastDragPosition; + bool m_dragSelecting; + +}; + +typedef Gaffer::FilteredChildIterator > RenderableGadgetIterator; +typedef Gaffer::FilteredRecursiveChildIterator > RecursiveRenderableGadgetIterator; + +} // namespace GafferUI + +#endif // GAFFERUI_RenderableGadget_H diff --git a/include/GafferUI/RotateHandle.h b/include/GafferUI/RotateHandle.h index d1dc78480a9..72140183c36 100644 --- a/include/GafferUI/RotateHandle.h +++ b/include/GafferUI/RotateHandle.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_ROTATEHANDLE_H #define GAFFERUI_ROTATEHANDLE_H +#include "GafferUI/Export.h" #include "GafferUI/Handle.h" IECORE_PUSH_DEFAULT_VISIBILITY diff --git a/include/GafferUI/ScaleHandle.h b/include/GafferUI/ScaleHandle.h index 709f1ee4e19..86660886126 100644 --- a/include/GafferUI/ScaleHandle.h +++ b/include/GafferUI/ScaleHandle.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_SCALEHANDLE_H #define GAFFERUI_SCALEHANDLE_H +#include "GafferUI/Export.h" #include "GafferUI/Handle.h" namespace GafferUI diff --git a/include/GafferUI/SpacerGadget.h b/include/GafferUI/SpacerGadget.h index 1269d3b6410..18042af4752 100644 --- a/include/GafferUI/SpacerGadget.h +++ b/include/GafferUI/SpacerGadget.h @@ -37,6 +37,7 @@ #ifndef GAFFERUI_SPACERGADGET_H #define GAFFERUI_SPACERGADGET_H +#include "GafferUI/Export.h" #include "GafferUI/Gadget.h" namespace GafferUI diff --git a/include/GafferUI/SplinePlugGadget.h b/include/GafferUI/SplinePlugGadget.h new file mode 100644 index 00000000000..5ce658ca1b5 --- /dev/null +++ b/include/GafferUI/SplinePlugGadget.h @@ -0,0 +1,109 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2011-2012, John Haddon. All rights reserved. +// Copyright (c) 2011-2012, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERUI_SPLINEPLUGGADGET_H +#define GAFFERUI_SPLINEPLUGGADGET_H + +#include "GafferUI/Export.h" +#include "GafferUI/Gadget.h" + +#include "Gaffer/SplinePlug.h" +#include "Gaffer/StandardSet.h" + +namespace GafferUI +{ + +/// \todo I think this should work with any sort of Set for the splines. +class GAFFERUI_API SplinePlugGadget : public Gadget +{ + + public : + + SplinePlugGadget( const std::string &name=defaultName() ); + virtual ~SplinePlugGadget(); + + IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferUI::SplinePlugGadget, SplinePlugGadgetTypeId, Gadget ); + + /// The splines to be edited + Gaffer::StandardSetPtr splines(); + Gaffer::ConstStandardSetPtr splines() const; + + /// The selected spline points + Gaffer::StandardSetPtr selection(); + Gaffer::ConstStandardSetPtr selection() const; + + virtual Imath::Box3f bound() const; + + protected : + + virtual void doRender( const Style *style ) const; + + private : + + void splineAdded( Gaffer::SetPtr splineSet, IECore::RunTimeTypedPtr splinePlug ); + void splineRemoved( Gaffer::SetPtr splineSet, IECore::RunTimeTypedPtr splinePlug ); + void plugSet( Gaffer::Plug *plug ); + Gaffer::StandardSetPtr m_splines; + Gaffer::StandardSetPtr m_selection; + + void pointAdded( Gaffer::GraphComponentPtr spline, Gaffer::GraphComponentPtr point ); + void pointRemoved( Gaffer::GraphComponentPtr spline, Gaffer::GraphComponentPtr point ); + + bool selectionAcceptance( Gaffer::ConstStandardSetPtr selection, IECore::ConstRunTimeTypedPtr point ); + + struct UI; + typedef std::map SplineUIMap; + mutable SplineUIMap m_uis; + void updateCurve( SplineUIMap::iterator it ) const; + + bool buttonPress( GadgetPtr gadget, const ButtonEvent &event ); + IECore::RunTimeTypedPtr dragBegin( GadgetPtr gadget, const ButtonEvent &event ); + bool dragMove( GadgetPtr gadget, const ButtonEvent &event ); + Imath::V2f m_lastDragPosition; + + bool keyPress( GadgetPtr gadget, const KeyEvent &event ); + +}; + +IE_CORE_DECLAREPTR( SplinePlugGadget ) + +typedef Gaffer::FilteredChildIterator > SplinePlugGadgetIterator; +typedef Gaffer::FilteredRecursiveChildIterator > RecursiveSplinePlugGadgetIterator; + +} // namespace GafferUI + +#endif // GAFFERUI_SPLINEPLUGGADGET_H diff --git a/include/GafferUI/StandardGraphLayout.h b/include/GafferUI/StandardGraphLayout.h index 800263d54d4..6e0a128ee1d 100644 --- a/include/GafferUI/StandardGraphLayout.h +++ b/include/GafferUI/StandardGraphLayout.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_STANDARDGRAPHLAYOUT_H #define GAFFERUI_STANDARDGRAPHLAYOUT_H +#include "GafferUI/Export.h" #include "GafferUI/GraphLayout.h" namespace Gaffer diff --git a/include/GafferUI/TextGadget.h b/include/GafferUI/TextGadget.h index b1f6a177e02..d5fc89bd1f5 100644 --- a/include/GafferUI/TextGadget.h +++ b/include/GafferUI/TextGadget.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_TEXTGADGET_H #define GAFFERUI_TEXTGADGET_H +#include "GafferUI/Export.h" #include "GafferUI/Gadget.h" #include "IECoreScene/Font.h" diff --git a/include/GafferUI/TranslateHandle.h b/include/GafferUI/TranslateHandle.h index 46056cda857..8af2a99b1aa 100644 --- a/include/GafferUI/TranslateHandle.h +++ b/include/GafferUI/TranslateHandle.h @@ -38,6 +38,7 @@ #ifndef GAFFERUI_TRANSLATEHANDLE_H #define GAFFERUI_TRANSLATEHANDLE_H +#include "GafferUI/Export.h" #include "GafferUI/Handle.h" namespace GafferUI diff --git a/include/GafferUI/ViewportGadget.h b/include/GafferUI/ViewportGadget.h index d978cc8858a..a495edcb952 100644 --- a/include/GafferUI/ViewportGadget.h +++ b/include/GafferUI/ViewportGadget.h @@ -183,7 +183,7 @@ class GAFFERUI_API ViewportGadget : public Gadget /// The SelectionScope class can be used by child Gadgets to perform /// OpenGL selection from event signal callbacks. - class SelectionScope : boost::noncopyable + class GAFFERUI_API SelectionScope : boost::noncopyable { public : @@ -225,7 +225,7 @@ class GAFFERUI_API ViewportGadget : public Gadget }; /// The RasterScope class can be used to perform drawing in raster space. - class RasterScope : boost::noncopyable + class GAFFERUI_API RasterScope : boost::noncopyable { public : From 5573f8c6a8712b9adab7e821e96ded695dca8e03 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:06:44 -0700 Subject: [PATCH 020/123] GafferUIBindings : Export symbols --- include/GafferUIBindings/Export.h | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/GafferUIBindings/Export.h diff --git a/include/GafferUIBindings/Export.h b/include/GafferUIBindings/Export.h new file mode 100644 index 00000000000..bddaf8e5bba --- /dev/null +++ b/include/GafferUIBindings/Export.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2016, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERUIBINDINGS_EXPORT_H +#define GAFFERUIBINDINGS_EXPORT_H + +#include "Gaffer/Export.h" + +// define GAFFERUIBINDINGS_API macro based on whether or not we are compiling +// GafferUIBindings, or including headers for linking to it. the GAFFERUIBINDINGS_API +// macro is the one that is used in the class definitions. +#ifdef GafferUIBindings_EXPORTS + #define GAFFERUIBINDINGS_API GAFFER_EXPORT +#else + #define GAFFERUIBINDINGS_API GAFFER_IMPORT +#endif + +#endif // #ifndef GAFFERUIBINDINGS_EXPORT_H From c6f520f61636cdee572dd04c0d660891900e72d8 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Tue, 9 May 2017 23:51:42 -0700 Subject: [PATCH 021/123] GafferImage : Export symbols --- include/GafferImage/BufferAlgo.h | 2 +- include/GafferImage/Catalogue.h | 2 +- include/GafferImage/ColorSpace.h | 1 + include/GafferImage/CopyImageMetadata.h | 1 + include/GafferImage/Dilate.h | 1 + include/GafferImage/Erode.h | 1 + include/GafferImage/FilterAlgo.h | 4 ++-- include/GafferImage/Format.h | 2 ++ include/GafferImage/ImageAlgo.h | 2 ++ include/GafferImage/ImagePlug.h | 4 ++-- include/GafferImage/ImageProcessor.h | 1 + include/GafferImage/ImageTransform.h | 1 + include/GafferImage/Median.h | 1 + include/GafferImage/Shuffle.h | 2 +- include/GafferImage/VectorWarp.h | 1 + src/GafferImage/FormatData.cpp | 7 ++++--- 16 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/GafferImage/BufferAlgo.h b/include/GafferImage/BufferAlgo.h index 755ecc30528..830f3969bd3 100644 --- a/include/GafferImage/BufferAlgo.h +++ b/include/GafferImage/BufferAlgo.h @@ -37,7 +37,7 @@ #ifndef GAFFERIMAGE_BUFFERALGO_H #define GAFFERIMAGE_BUFFERALGO_H -#include "IECore/Export.h" +#include "GafferImage/Export.h" IECORE_PUSH_DEFAULT_VISIBILITY #include "OpenEXR/ImathBox.h" diff --git a/include/GafferImage/Catalogue.h b/include/GafferImage/Catalogue.h index 820229108e0..158a89d6ea3 100644 --- a/include/GafferImage/Catalogue.h +++ b/include/GafferImage/Catalogue.h @@ -68,7 +68,7 @@ class GAFFERIMAGE_API Catalogue : public ImageNode ~Catalogue() override; /// Plug type used to represent an image in the catalogue. - class Image : public Gaffer::Plug + class GAFFERIMAGE_API Image : public Gaffer::Plug { public : diff --git a/include/GafferImage/ColorSpace.h b/include/GafferImage/ColorSpace.h index 5e162050be0..e5b6a9439f1 100644 --- a/include/GafferImage/ColorSpace.h +++ b/include/GafferImage/ColorSpace.h @@ -38,6 +38,7 @@ #ifndef GAFFERIMAGE_COLORSPACE_H #define GAFFERIMAGE_COLORSPACE_H +#include "GafferImage/Export.h" #include "GafferImage/OpenColorIOTransform.h" namespace Gaffer diff --git a/include/GafferImage/CopyImageMetadata.h b/include/GafferImage/CopyImageMetadata.h index b6e235b0ff5..4e3e154c4bc 100644 --- a/include/GafferImage/CopyImageMetadata.h +++ b/include/GafferImage/CopyImageMetadata.h @@ -37,6 +37,7 @@ #ifndef GAFFERIMAGE_COPYIMAGEMETADATA_H #define GAFFERIMAGE_COPYIMAGEMETADATA_H +#include "GafferImage/Export.h" #include "GafferImage/MetadataProcessor.h" #include "Gaffer/StringPlug.h" diff --git a/include/GafferImage/Dilate.h b/include/GafferImage/Dilate.h index 3d88a97e715..7f0f5320e29 100644 --- a/include/GafferImage/Dilate.h +++ b/include/GafferImage/Dilate.h @@ -37,6 +37,7 @@ #ifndef GAFFERIMAGE_DILATE_H #define GAFFERIMAGE_DILATE_H +#include "GafferImage/Export.h" #include "GafferImage/RankFilter.h" namespace GafferImage diff --git a/include/GafferImage/Erode.h b/include/GafferImage/Erode.h index 9bfab274e54..243939eed7b 100644 --- a/include/GafferImage/Erode.h +++ b/include/GafferImage/Erode.h @@ -37,6 +37,7 @@ #ifndef GAFFERIMAGE_ERODE_H #define GAFFERIMAGE_ERODE_H +#include "GafferImage/Export.h" #include "GafferImage/RankFilter.h" namespace GafferImage diff --git a/include/GafferImage/FilterAlgo.h b/include/GafferImage/FilterAlgo.h index 5ac83e34330..3fb7699a943 100644 --- a/include/GafferImage/FilterAlgo.h +++ b/include/GafferImage/FilterAlgo.h @@ -60,7 +60,7 @@ GAFFERIMAGE_API const OIIO::Filter2D* acquireFilter( const std::string &name ); // Find the region covered by a filter with a given width, given a position and axis-aligned derivatives // to compute the bounding rectangle -Imath::Box2f filterSupport( const Imath::V2f &p, float dx, float dy, float filterWidth ); +GAFFERIMAGE_API Imath::Box2f filterSupport( const Imath::V2f &p, float dx, float dy, float filterWidth ); // Filter over a rectangle shaped region of the image defined by a center point and two axis-aligned derivatives. // The sampler must have been initialized to cover all pixels with centers lying with the support of the filter, @@ -77,7 +77,7 @@ GAFFERIMAGE_API float sampleParallelogram( Sampler &sampler, const Imath::V2f &p // If you have a point and derivatives defining a region to filter over, but you want to use sampleBox // instead of sampleParallelogram for performance reasons, you can use this function to get axis-aligned // derivatives which will approximate the result of sampleParallelogram -Imath::V2f derivativesToAxisAligned( const Imath::V2f &p, const Imath::V2f &dpdx, const Imath::V2f &dpdy ); +GAFFERIMAGE_API Imath::V2f derivativesToAxisAligned( const Imath::V2f &p, const Imath::V2f &dpdx, const Imath::V2f &dpdy ); } // namespace FilterAlgo diff --git a/include/GafferImage/Format.h b/include/GafferImage/Format.h index 56de1c444e5..dcd7dedd8dd 100644 --- a/include/GafferImage/Format.h +++ b/include/GafferImage/Format.h @@ -49,6 +49,8 @@ IECORE_POP_DEFAULT_VISIBILITY #include #include +#include "GafferImage/Export.h" + namespace GafferImage { diff --git a/include/GafferImage/ImageAlgo.h b/include/GafferImage/ImageAlgo.h index 53db9b4d130..859796c34b2 100644 --- a/include/GafferImage/ImageAlgo.h +++ b/include/GafferImage/ImageAlgo.h @@ -50,6 +50,8 @@ IECORE_POP_DEFAULT_VISIBILITY #include +#include "GafferImage/Export.h" + namespace GafferImage { diff --git a/include/GafferImage/ImagePlug.h b/include/GafferImage/ImagePlug.h index 5fad08c1398..11817cb7764 100644 --- a/include/GafferImage/ImagePlug.h +++ b/include/GafferImage/ImagePlug.h @@ -130,7 +130,7 @@ class GAFFERIMAGE_API ImagePlug : public Gaffer::ValuePlug /// with tile/channel specific variables removed. This can be used /// when evaluating plugs which must be global to the whole image, /// and can improve performance by reducing pressure on the hash cache. - struct GlobalScope : public Gaffer::Context::EditableScope + struct GAFFERIMAGE_API GlobalScope : public Gaffer::Context::EditableScope { GlobalScope( const Gaffer::Context *context ); GlobalScope( const Gaffer::ThreadState &threadState ); @@ -139,7 +139,7 @@ class GAFFERIMAGE_API ImagePlug : public Gaffer::ValuePlug /// Utility class to scope a temporary copy of a context, /// with convenient accessors to set tileOrigin and channelName, /// which you often need to do while accessing channelData - struct ChannelDataScope : public Gaffer::Context::EditableScope + struct GAFFERIMAGE_API ChannelDataScope : public Gaffer::Context::EditableScope { ChannelDataScope( const Gaffer::Context *context ); ChannelDataScope( const Gaffer::ThreadState &threadState ); diff --git a/include/GafferImage/ImageProcessor.h b/include/GafferImage/ImageProcessor.h index 9dc016ec26a..bab80804f18 100644 --- a/include/GafferImage/ImageProcessor.h +++ b/include/GafferImage/ImageProcessor.h @@ -38,6 +38,7 @@ #ifndef GAFFERIMAGE_IMAGEPROCESSOR_H #define GAFFERIMAGE_IMAGEPROCESSOR_H +#include "GafferImage/Export.h" #include "GafferImage/ImageNode.h" namespace Gaffer diff --git a/include/GafferImage/ImageTransform.h b/include/GafferImage/ImageTransform.h index 44aaaef6036..d7bbc470b33 100644 --- a/include/GafferImage/ImageTransform.h +++ b/include/GafferImage/ImageTransform.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_IMAGETRANSFORM_H #define GAFFERSCENE_IMAGETRANSFORM_H +#include "GafferImage/Export.h" #include "GafferImage/FlatImageProcessor.h" namespace Gaffer diff --git a/include/GafferImage/Median.h b/include/GafferImage/Median.h index 40e6c19e0d6..75799d3d68f 100644 --- a/include/GafferImage/Median.h +++ b/include/GafferImage/Median.h @@ -37,6 +37,7 @@ #ifndef GAFFERIMAGE_MEDIAN_H #define GAFFERIMAGE_MEDIAN_H +#include "GafferImage/Export.h" #include "GafferImage/RankFilter.h" namespace GafferImage diff --git a/include/GafferImage/Shuffle.h b/include/GafferImage/Shuffle.h index b8f52368081..1f12075cf2a 100644 --- a/include/GafferImage/Shuffle.h +++ b/include/GafferImage/Shuffle.h @@ -58,7 +58,7 @@ class GAFFERIMAGE_API Shuffle : public ImageProcessor /// A custom plug to hold the name of an output channel and the /// name of an input channel to shuffle into it. Add instances /// of these to the Shuffle::channelsPlug() to define the shuffle. - class ChannelPlug : public Gaffer::ValuePlug + class GAFFERIMAGE_API ChannelPlug : public Gaffer::ValuePlug { public : diff --git a/include/GafferImage/VectorWarp.h b/include/GafferImage/VectorWarp.h index 7ffce9f65b2..757a9745baf 100644 --- a/include/GafferImage/VectorWarp.h +++ b/include/GafferImage/VectorWarp.h @@ -37,6 +37,7 @@ #ifndef GAFFERIMAGE_UVWARP_H #define GAFFERIMAGE_UVWARP_H +#include "GafferImage/Export.h" #include "GafferImage/Warp.h" namespace GafferImage diff --git a/src/GafferImage/FormatData.cpp b/src/GafferImage/FormatData.cpp index 6a71f149382..ab5c604da99 100644 --- a/src/GafferImage/FormatData.cpp +++ b/src/GafferImage/FormatData.cpp @@ -36,6 +36,7 @@ #include "GafferImage/FormatData.h" +#include "GafferImage/Export.h" #include "GafferImage/TypeIds.h" #include "Gaffer/Context.h" @@ -57,7 +58,7 @@ namespace IECore IECORE_RUNTIMETYPED_DEFINETEMPLATESPECIALISATION( GafferImage::FormatData, GafferImage::FormatDataTypeId ) -template<> +template<> GAFFERIMAGE_API void FormatData::save( SaveContext *context ) const { Data::save( context ); @@ -67,7 +68,7 @@ void FormatData::save( SaveContext *context ) const container->write( "pixelAspect", readable().getPixelAspect() ); } -template<> +template<> GAFFERIMAGE_API void FormatData::load( LoadContextPtr context ) { Data::load( context ); @@ -84,7 +85,7 @@ void FormatData::load( LoadContextPtr context ) writable().setPixelAspect( pixelAspect ); } -template<> +template<> GAFFERIMAGE_API void SimpleDataHolder::hash( MurmurHash &h ) const { const GafferImage::Format &f = readable(); From 84e86d7c33c0d1b92b3bde1f51dc31372529edcd Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 16 Jun 2021 13:46:45 -0400 Subject: [PATCH 022/123] GafferImageUI : Export symbols --- include/GafferImageUI/ImageView.h | 4 ++-- src/GafferImageUI/ImageView.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/GafferImageUI/ImageView.h b/include/GafferImageUI/ImageView.h index 3f58ce80067..d8ad9d6b301 100644 --- a/include/GafferImageUI/ImageView.h +++ b/include/GafferImageUI/ImageView.h @@ -117,10 +117,10 @@ class GAFFERIMAGEUI_API ImageView : public GafferUI::View static void registeredDisplayTransforms( std::vector &names ); static GafferImage::ImageProcessorPtr createDisplayTransform( const std::string &name ); - class ColorInspectorPlug : public Gaffer::ValuePlug + class GAFFERIMAGEUI_API ColorInspectorPlug : public Gaffer::ValuePlug { public : - enum class Mode + enum class GAFFERIMAGEUI_API Mode { Cursor, Pixel, diff --git a/src/GafferImageUI/ImageView.cpp b/src/GafferImageUI/ImageView.cpp index eb12a59744c..1f15b0bb530 100644 --- a/src/GafferImageUI/ImageView.cpp +++ b/src/GafferImageUI/ImageView.cpp @@ -1386,7 +1386,7 @@ class ImageView::ColorInspector : public boost::signals::trackable GAFFER_NODE_DEFINE_TYPE( ImageView ); -ImageView::ViewDescription ImageView::g_viewDescription( GafferImage::ImagePlug::staticTypeId() ); +GAFFERIMAGEUI_API ImageView::ViewDescription ImageView::g_viewDescription( GafferImage::ImagePlug::staticTypeId() ); ImageView::ImageView( const std::string &name ) : View( name, new GafferImage::ImagePlug() ), From 76eca6dc7559b6ea2f99c5550c4673208e17c00c Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:02:22 -0700 Subject: [PATCH 023/123] GafferImageTest : Export symbols --- include/GafferImageTest/ContextSanitiser.h | 4 +- include/GafferImageTest/Export.h | 51 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 include/GafferImageTest/Export.h diff --git a/include/GafferImageTest/ContextSanitiser.h b/include/GafferImageTest/ContextSanitiser.h index fe5d6edd34e..f0cbe0abc72 100644 --- a/include/GafferImageTest/ContextSanitiser.h +++ b/include/GafferImageTest/ContextSanitiser.h @@ -37,6 +37,8 @@ #ifndef GAFFERIMAGETEST_CONTEXTSANITISER_H #define GAFFERIMAGETEST_CONTEXTSANITISER_H +#include "GafferImageTest/Export.h" + #include "Gaffer/Monitor.h" #include "Gaffer/Plug.h" @@ -46,7 +48,7 @@ namespace GafferImageTest { /// A monitor which warns about common context handling mistakes. -class GAFFER_API ContextSanitiser : public Gaffer::Monitor +class GAFFERIMAGETEST_API ContextSanitiser : public Gaffer::Monitor { public : diff --git a/include/GafferImageTest/Export.h b/include/GafferImageTest/Export.h new file mode 100644 index 00000000000..3bfc8695000 --- /dev/null +++ b/include/GafferImageTest/Export.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2016, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERIMAGETEST_EXPORT_H +#define GAFFERIMAGETEST_EXPORT_H + +#include "IECore/Export.h" + +// define GAFFERIMAGETEST_API macro based on whether or not we are compiling +// GafferImageTest, or including headers for linking to it. the GAFFERIMAGETEST_API +// macro is the one that is used in the class definitions. +#ifdef GafferImageTest_EXPORTS + #define GAFFERIMAGETEST_API IECORE_EXPORT +#else + #define GAFFERIMAGETEST_API IECORE_IMPORT +#endif + +#endif // #ifndef GAFFERIMAGETEST_EXPORT_H From 70f25471ee3c64ea8fdf08de2b9a656fdd462e06 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:14:59 -0700 Subject: [PATCH 024/123] GafferScene : Export symbols --- include/GafferScene/AimConstraint.h | 1 + include/GafferScene/AttributeProcessor.h | 10 +++++++++- include/GafferScene/Camera.h | 2 ++ include/GafferScene/ClippingPlane.h | 1 + include/GafferScene/CollectScenes.h | 1 + include/GafferScene/Constraint.h | 1 + include/GafferScene/CoordinateSystem.h | 1 + include/GafferScene/CustomAttributes.h | 1 + include/GafferScene/DeleteAttributes.h | 1 + include/GafferScene/DeleteCurves.h | 1 + include/GafferScene/DeleteFaces.h | 1 + include/GafferScene/DeleteGlobals.h | 1 + include/GafferScene/DeleteOptions.h | 1 + include/GafferScene/DeleteOutputs.h | 1 + include/GafferScene/DeletePoints.h | 1 + include/GafferScene/DeletePrimitiveVariables.h | 1 + include/GafferScene/DeleteSets.h | 1 + include/GafferScene/Encapsulate.h | 1 + include/GafferScene/FilterPlug.h | 2 +- include/GafferScene/FilterProcessor.h | 3 ++- include/GafferScene/FreezeTransform.h | 1 + include/GafferScene/GlobalsProcessor.h | 1 + include/GafferScene/Group.h | 1 + include/GafferScene/Instancer.h | 3 ++- include/GafferScene/Isolate.h | 1 + include/GafferScene/Light.h | 1 + include/GafferScene/LightToCamera.h | 1 + include/GafferScene/MapOffset.h | 1 + include/GafferScene/MapProjection.h | 1 + include/GafferScene/MeshTangents.h | 1 + include/GafferScene/MeshToPoints.h | 1 + include/GafferScene/MeshType.h | 1 + include/GafferScene/ObjectToScene.h | 1 + include/GafferScene/OpenGLAttributes.h | 1 + include/GafferScene/OpenGLRender.h | 1 + include/GafferScene/OpenGLShader.h | 1 + include/GafferScene/Parent.h | 1 + include/GafferScene/PointConstraint.h | 1 + include/GafferScene/PointsType.h | 2 ++ .../Private/IECoreScenePreview/CapturingRenderer.h | 6 +++--- .../GafferScene/Private/IECoreScenePreview/Geometry.h | 4 +++- .../Private/IECoreScenePreview/Procedural.h | 4 +++- .../GafferScene/Private/IECoreScenePreview/Renderer.h | 10 ++++++---- include/GafferScene/Prune.h | 1 + include/GafferScene/ResamplePrimitiveVariables.h | 1 + include/GafferScene/SceneElementProcessor.h | 1 + include/GafferScene/ScenePlug.h | 8 ++++---- include/GafferScene/SceneProcessor.h | 5 ++++- include/GafferScene/Seeds.h | 1 + include/GafferScene/ShaderAssignment.h | 1 + include/GafferScene/StandardAttributes.h | 1 + include/GafferScene/StandardOptions.h | 1 + include/GafferScene/SubTree.h | 1 + include/GafferScene/Text.h | 1 + include/GafferScene/UnionFilter.h | 1 + 55 files changed, 84 insertions(+), 18 deletions(-) diff --git a/include/GafferScene/AimConstraint.h b/include/GafferScene/AimConstraint.h index 0032b79d952..b070d201b9d 100644 --- a/include/GafferScene/AimConstraint.h +++ b/include/GafferScene/AimConstraint.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_AIMCONSTRAINT_H #define GAFFERSCENE_AIMCONSTRAINT_H +#include "GafferScene/Export.h" #include "GafferScene/Constraint.h" namespace GafferScene diff --git a/include/GafferScene/AttributeProcessor.h b/include/GafferScene/AttributeProcessor.h index cf5332afac1..f48d829b671 100644 --- a/include/GafferScene/AttributeProcessor.h +++ b/include/GafferScene/AttributeProcessor.h @@ -37,7 +37,15 @@ #ifndef GAFFERSCENE_ATTRIBUTEPROCESSOR_H #define GAFFERSCENE_ATTRIBUTEPROCESSOR_H -#include "GafferScene/FilteredSceneProcessor.h" +#include "GafferScene/SceneElementProcessor.h" +#include "GafferScene/Export.h" + +namespace Gaffer +{ + +IE_CORE_FORWARDDECLARE( StringPlug ) + +} // namespace Gaffer namespace GafferScene { diff --git a/include/GafferScene/Camera.h b/include/GafferScene/Camera.h index cc7facbdf0b..523e73aaa2b 100644 --- a/include/GafferScene/Camera.h +++ b/include/GafferScene/Camera.h @@ -38,6 +38,8 @@ #ifndef GAFFERSCENE_CAMERA_H #define GAFFERSCENE_CAMERA_H +#include "GafferScene/Export.h" + #include "Gaffer/CompoundDataPlug.h" #include "GafferScene/ObjectSource.h" diff --git a/include/GafferScene/ClippingPlane.h b/include/GafferScene/ClippingPlane.h index 1c65a65cabb..d421942520e 100644 --- a/include/GafferScene/ClippingPlane.h +++ b/include/GafferScene/ClippingPlane.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_CLIPPINGPLANE_H #define GAFFERSCENE_CLIPPINGPLANE_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectSource.h" namespace GafferScene diff --git a/include/GafferScene/CollectScenes.h b/include/GafferScene/CollectScenes.h index 2f8f91fbdea..38b09611d23 100644 --- a/include/GafferScene/CollectScenes.h +++ b/include/GafferScene/CollectScenes.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_COLLECTSCENES_H #define GAFFERSCENE_COLLECTSCENES_H +#include "GafferScene/Export.h" #include "GafferScene/SceneProcessor.h" namespace Gaffer diff --git a/include/GafferScene/Constraint.h b/include/GafferScene/Constraint.h index 9514881e43b..d9a53d0dea1 100644 --- a/include/GafferScene/Constraint.h +++ b/include/GafferScene/Constraint.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_CONSTRAINT_H #define GAFFERSCENE_CONSTRAINT_H +#include "GafferScene/Export.h" #include "GafferScene/SceneElementProcessor.h" namespace Gaffer diff --git a/include/GafferScene/CoordinateSystem.h b/include/GafferScene/CoordinateSystem.h index fbdf7ef6d6b..68797871d55 100644 --- a/include/GafferScene/CoordinateSystem.h +++ b/include/GafferScene/CoordinateSystem.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_COORDINATESYSTEM_H #define GAFFERSCENE_COORDINATESYSTEM_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectSource.h" namespace GafferScene diff --git a/include/GafferScene/CustomAttributes.h b/include/GafferScene/CustomAttributes.h index 2befbd9ed77..1c28d79729f 100644 --- a/include/GafferScene/CustomAttributes.h +++ b/include/GafferScene/CustomAttributes.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_CUSTOMATTRIBUTES_H #define GAFFERSCENE_CUSTOMATTRIBUTES_H +#include "GafferScene/Export.h" #include "GafferScene/Attributes.h" namespace GafferScene diff --git a/include/GafferScene/DeleteAttributes.h b/include/GafferScene/DeleteAttributes.h index 4805292183f..dce31fa32b6 100644 --- a/include/GafferScene/DeleteAttributes.h +++ b/include/GafferScene/DeleteAttributes.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_DELETEATTRIBUTES_H #define GAFFERSCENE_DELETEATTRIBUTES_H +#include "GafferScene/Export.h" #include "GafferScene/AttributeProcessor.h" #include "Gaffer/StringPlug.h" diff --git a/include/GafferScene/DeleteCurves.h b/include/GafferScene/DeleteCurves.h index 7931540e8d1..37a06491b00 100644 --- a/include/GafferScene/DeleteCurves.h +++ b/include/GafferScene/DeleteCurves.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_DELETECURVES_H #define GAFFERSCENE_DELETECURVES_H +#include "GafferScene/Export.h" #include "GafferScene/Deformer.h" namespace Gaffer diff --git a/include/GafferScene/DeleteFaces.h b/include/GafferScene/DeleteFaces.h index 567025fe06a..eb6ffb37e63 100644 --- a/include/GafferScene/DeleteFaces.h +++ b/include/GafferScene/DeleteFaces.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_DELETEFACES_H #define GAFFERSCENE_DELETEFACES_H +#include "GafferScene/Export.h" #include "GafferScene/Deformer.h" namespace Gaffer diff --git a/include/GafferScene/DeleteGlobals.h b/include/GafferScene/DeleteGlobals.h index 6abeba90766..49bcf74fa98 100644 --- a/include/GafferScene/DeleteGlobals.h +++ b/include/GafferScene/DeleteGlobals.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_DELETEGLOBALS_H #define GAFFERSCENE_DELETEGLOBALS_H +#include "GafferScene/Export.h" #include "GafferScene/GlobalsProcessor.h" namespace Gaffer diff --git a/include/GafferScene/DeleteOptions.h b/include/GafferScene/DeleteOptions.h index a1580b552b7..06393d873df 100644 --- a/include/GafferScene/DeleteOptions.h +++ b/include/GafferScene/DeleteOptions.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_DELETEOPTIONS_H #define GAFFERSCENE_DELETEOPTIONS_H +#include "GafferScene/Export.h" #include "GafferScene/DeleteGlobals.h" namespace GafferScene diff --git a/include/GafferScene/DeleteOutputs.h b/include/GafferScene/DeleteOutputs.h index a07f23a0157..434721f5768 100644 --- a/include/GafferScene/DeleteOutputs.h +++ b/include/GafferScene/DeleteOutputs.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_DELETEOUTPUTS_H #define GAFFERSCENE_DELETEOUTPUTS_H +#include "GafferScene/Export.h" #include "GafferScene/DeleteGlobals.h" namespace GafferScene diff --git a/include/GafferScene/DeletePoints.h b/include/GafferScene/DeletePoints.h index 9e3088062a6..d478936e9e1 100644 --- a/include/GafferScene/DeletePoints.h +++ b/include/GafferScene/DeletePoints.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_DELETEPOINTS_H #define GAFFERSCENE_DELETEPOINTS_H +#include "GafferScene/Export.h" #include "GafferScene/Deformer.h" namespace Gaffer diff --git a/include/GafferScene/DeletePrimitiveVariables.h b/include/GafferScene/DeletePrimitiveVariables.h index 618b42e0fd7..ea2e0fa3d92 100644 --- a/include/GafferScene/DeletePrimitiveVariables.h +++ b/include/GafferScene/DeletePrimitiveVariables.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_DELETEPRIMITIVEVARIABLE_H #define GAFFERSCENE_DELETEPRIMITIVEVARIABLE_H +#include "GafferScene/Export.h" #include "GafferScene/PrimitiveVariableProcessor.h" namespace GafferScene diff --git a/include/GafferScene/DeleteSets.h b/include/GafferScene/DeleteSets.h index 8a6f51e30d7..807cbb70f1c 100644 --- a/include/GafferScene/DeleteSets.h +++ b/include/GafferScene/DeleteSets.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_DELETESETS_H #define GAFFERSCENE_DELETESETS_H +#include "GafferScene/Export.h" #include "GafferScene/SceneProcessor.h" namespace Gaffer diff --git a/include/GafferScene/Encapsulate.h b/include/GafferScene/Encapsulate.h index e550174099a..f10b2d1168a 100644 --- a/include/GafferScene/Encapsulate.h +++ b/include/GafferScene/Encapsulate.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_ENCAPSULATE_H #define GAFFERSCENE_ENCAPSULATE_H +#include "GafferScene/Export.h" #include "GafferScene/FilteredSceneProcessor.h" namespace GafferScene diff --git a/include/GafferScene/FilterPlug.h b/include/GafferScene/FilterPlug.h index 954cb436ca7..b979ceda5ee 100644 --- a/include/GafferScene/FilterPlug.h +++ b/include/GafferScene/FilterPlug.h @@ -97,7 +97,7 @@ class GAFFERSCENE_API FilterPlug : public Gaffer::IntPlug static const IECore::InternedString inputSceneContextName; /// Provides the input scene for a filter evaluation - struct SceneScope : public Gaffer::Context::EditableScope + struct GAFFERSCENE_API SceneScope : public Gaffer::Context::EditableScope { SceneScope( const Gaffer::Context *context, const ScenePlug *scenePlug ); private : diff --git a/include/GafferScene/FilterProcessor.h b/include/GafferScene/FilterProcessor.h index c1457d3710c..848ab63e377 100644 --- a/include/GafferScene/FilterProcessor.h +++ b/include/GafferScene/FilterProcessor.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_FILTERPROCESSOR_H #define GAFFERSCENE_FILTERPROCESSOR_H +#include "GafferScene/Export.h" #include "GafferScene/Filter.h" namespace Gaffer @@ -62,7 +63,7 @@ class GAFFERSCENE_API FilterProcessor : public Filter /// Constructs with an ArrayPlug called "in". Use inPlug() as a /// convenience for accessing the first child in the array, and use /// inPlugs() to access the array itself. - FilterProcessor( const std::string &name, size_t minInputs, size_t maxInputs = Imath::limits::max() ); + FilterProcessor( const std::string &name, size_t minInputs, size_t maxInputs = std::numeric_limits::max() ); ~FilterProcessor() override; diff --git a/include/GafferScene/FreezeTransform.h b/include/GafferScene/FreezeTransform.h index c6528b5bc70..50b89356304 100644 --- a/include/GafferScene/FreezeTransform.h +++ b/include/GafferScene/FreezeTransform.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_FREEZETRANSFORM_H #define GAFFERSCENE_FREEZETRANSFORM_H +#include "GafferScene/Export.h" #include "GafferScene/FilteredSceneProcessor.h" namespace GafferScene diff --git a/include/GafferScene/GlobalsProcessor.h b/include/GafferScene/GlobalsProcessor.h index 00af82622cf..3f3f290efe5 100644 --- a/include/GafferScene/GlobalsProcessor.h +++ b/include/GafferScene/GlobalsProcessor.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_GLOBALSPROCESSOR_H #define GAFFERSCENE_GLOBALSPROCESSOR_H +#include "GafferScene/Export.h" #include "GafferScene/SceneProcessor.h" namespace GafferScene diff --git a/include/GafferScene/Group.h b/include/GafferScene/Group.h index 19e526beba1..da3d8d22a33 100644 --- a/include/GafferScene/Group.h +++ b/include/GafferScene/Group.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_GROUP_H #define GAFFERSCENE_GROUP_H +#include "GafferScene/Export.h" #include "GafferScene/SceneProcessor.h" namespace Gaffer diff --git a/include/GafferScene/Instancer.h b/include/GafferScene/Instancer.h index ed8a1134b7f..ef4114d6126 100644 --- a/include/GafferScene/Instancer.h +++ b/include/GafferScene/Instancer.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_INSTANCER_H #define GAFFERSCENE_INSTANCER_H +#include "GafferScene/Export.h" #include "GafferScene/BranchCreator.h" namespace GafferScene @@ -52,7 +53,7 @@ class GAFFERSCENE_API Instancer : public BranchCreator /// Compound plug for representing an image format in a way /// easily edited by users, with individual child plugs for /// each aspect of the format. - class ContextVariablePlug : public Gaffer::ValuePlug + class GAFFERSCENE_API ContextVariablePlug : public Gaffer::ValuePlug { public : diff --git a/include/GafferScene/Isolate.h b/include/GafferScene/Isolate.h index ec0b17c8f94..e544d8882b8 100644 --- a/include/GafferScene/Isolate.h +++ b/include/GafferScene/Isolate.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_ISOLATE_H #define GAFFERSCENE_ISOLATE_H +#include "GafferScene/Export.h" #include "GafferScene/FilteredSceneProcessor.h" namespace Gaffer diff --git a/include/GafferScene/Light.h b/include/GafferScene/Light.h index 51eb90778f4..ad5ae413328 100644 --- a/include/GafferScene/Light.h +++ b/include/GafferScene/Light.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_LIGHT_H #define GAFFERSCENE_LIGHT_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectSource.h" #include "Gaffer/CompoundDataPlug.h" diff --git a/include/GafferScene/LightToCamera.h b/include/GafferScene/LightToCamera.h index 04d126483c6..a70e1fa16a7 100644 --- a/include/GafferScene/LightToCamera.h +++ b/include/GafferScene/LightToCamera.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_LIGHTTOCAMERA_H #define GAFFERSCENE_LIGHTTOCAMERA_H +#include "GafferScene/Export.h" #include "GafferScene/SceneElementProcessor.h" namespace GafferScene diff --git a/include/GafferScene/MapOffset.h b/include/GafferScene/MapOffset.h index d3aabe73af9..ef775cbfaaa 100644 --- a/include/GafferScene/MapOffset.h +++ b/include/GafferScene/MapOffset.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_MAPOFFSET_H #define GAFFERSCENE_MAPOFFSET_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectProcessor.h" namespace Gaffer diff --git a/include/GafferScene/MapProjection.h b/include/GafferScene/MapProjection.h index 333576478c3..1fbac650573 100644 --- a/include/GafferScene/MapProjection.h +++ b/include/GafferScene/MapProjection.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_MAPPROJECTION_H #define GAFFERSCENE_MAPPROJECTION_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectProcessor.h" namespace Gaffer diff --git a/include/GafferScene/MeshTangents.h b/include/GafferScene/MeshTangents.h index 95a61cbd431..f5419ec530d 100644 --- a/include/GafferScene/MeshTangents.h +++ b/include/GafferScene/MeshTangents.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_MESHTANGENTS_H #define GAFFERSCENE_MESHTANGENTS_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectProcessor.h" #include "Gaffer/StringPlug.h" diff --git a/include/GafferScene/MeshToPoints.h b/include/GafferScene/MeshToPoints.h index e3d3d868f7e..3ca243b5570 100644 --- a/include/GafferScene/MeshToPoints.h +++ b/include/GafferScene/MeshToPoints.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_MESHTOPOINTS_H #define GAFFERSCENE_MESHTOPOINTS_H +#include "GafferScene/Export.h" #include "GafferScene/Deformer.h" namespace Gaffer diff --git a/include/GafferScene/MeshType.h b/include/GafferScene/MeshType.h index 1e48983fb3b..dedfba609c3 100644 --- a/include/GafferScene/MeshType.h +++ b/include/GafferScene/MeshType.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_MESHTYPE_H #define GAFFERSCENE_MESHTYPE_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectProcessor.h" namespace Gaffer diff --git a/include/GafferScene/ObjectToScene.h b/include/GafferScene/ObjectToScene.h index 7bbc44cd0f0..fee894643d7 100644 --- a/include/GafferScene/ObjectToScene.h +++ b/include/GafferScene/ObjectToScene.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_OBJECTTOSCENE_H #define GAFFERSCENE_OBJECTTOSCENE_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectSource.h" namespace GafferScene diff --git a/include/GafferScene/OpenGLAttributes.h b/include/GafferScene/OpenGLAttributes.h index 798df8aa35c..3628d5f3128 100644 --- a/include/GafferScene/OpenGLAttributes.h +++ b/include/GafferScene/OpenGLAttributes.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_OPENGLATTRIBUTES_H #define GAFFERSCENE_OPENGLATTRIBUTES_H +#include "GafferScene/Export.h" #include "GafferScene/Attributes.h" namespace GafferScene diff --git a/include/GafferScene/OpenGLRender.h b/include/GafferScene/OpenGLRender.h index 52c49294355..301d4cdfac0 100644 --- a/include/GafferScene/OpenGLRender.h +++ b/include/GafferScene/OpenGLRender.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_OPENGLRENDER_H #define GAFFERSCENE_OPENGLRENDER_H +#include "GafferScene/Export.h" #include "GafferScene/Render.h" namespace GafferScene diff --git a/include/GafferScene/OpenGLShader.h b/include/GafferScene/OpenGLShader.h index f3786213362..282a26b9902 100644 --- a/include/GafferScene/OpenGLShader.h +++ b/include/GafferScene/OpenGLShader.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_OPENGLSHADER_H #define GAFFERSCENE_OPENGLSHADER_H +#include "GafferScene/Export.h" #include "GafferScene/Shader.h" namespace GafferScene diff --git a/include/GafferScene/Parent.h b/include/GafferScene/Parent.h index 2877dc4a18e..c9e42ee26ea 100644 --- a/include/GafferScene/Parent.h +++ b/include/GafferScene/Parent.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_PARENT_H #define GAFFERSCENE_PARENT_H +#include "GafferScene/Export.h" #include "GafferScene/BranchCreator.h" #include "Gaffer/ArrayPlug.h" diff --git a/include/GafferScene/PointConstraint.h b/include/GafferScene/PointConstraint.h index f5068f1d377..ff68bd26ac8 100644 --- a/include/GafferScene/PointConstraint.h +++ b/include/GafferScene/PointConstraint.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_POINTCONSTRAINT_H #define GAFFERSCENE_POINTCONSTRAINT_H +#include "GafferScene/Export.h" #include "GafferScene/Constraint.h" namespace GafferScene diff --git a/include/GafferScene/PointsType.h b/include/GafferScene/PointsType.h index 81c57ce4e38..aac6176acf5 100644 --- a/include/GafferScene/PointsType.h +++ b/include/GafferScene/PointsType.h @@ -37,6 +37,8 @@ #ifndef GAFFERSCENE_POINTSTYPE_H #define GAFFERSCENE_POINTSTYPE_H +#include "GafferScene/Export.h" + #include "GafferScene/ObjectProcessor.h" namespace Gaffer diff --git a/include/GafferScene/Private/IECoreScenePreview/CapturingRenderer.h b/include/GafferScene/Private/IECoreScenePreview/CapturingRenderer.h index 18a1f9bfeae..583d8eb7c99 100644 --- a/include/GafferScene/Private/IECoreScenePreview/CapturingRenderer.h +++ b/include/GafferScene/Private/IECoreScenePreview/CapturingRenderer.h @@ -54,7 +54,7 @@ namespace IECoreScenePreview /// If the Bool `cr:unrenderable` attribute is set to true at a location, then /// calls to object, light, lightFilter, camera, etc... for that location will /// return nullptr rather than a valid ObjectInterface. -class IECORESCENE_API CapturingRenderer : public Renderer +class GAFFERSCENE_API CapturingRenderer : public Renderer { public : @@ -71,7 +71,7 @@ class IECORESCENE_API CapturingRenderer : public Renderer /// Introspection /// ============= - class CapturedAttributes : public AttributesInterface + class GAFFERSCENE_API CapturedAttributes : public AttributesInterface { public : @@ -92,7 +92,7 @@ class IECORESCENE_API CapturingRenderer : public Renderer IE_CORE_DECLAREPTR( CapturedAttributes ); - class CapturedObject : public ObjectInterface + class GAFFERSCENE_API CapturedObject : public ObjectInterface { public : diff --git a/include/GafferScene/Private/IECoreScenePreview/Geometry.h b/include/GafferScene/Private/IECoreScenePreview/Geometry.h index 416bcc91d02..3944e861026 100644 --- a/include/GafferScene/Private/IECoreScenePreview/Geometry.h +++ b/include/GafferScene/Private/IECoreScenePreview/Geometry.h @@ -35,6 +35,8 @@ #ifndef IECORE_GEOMETRY_H #define IECORE_GEOMETRY_H +#include "GafferScene/Export.h" + #include "GafferScene/TypeIds.h" #include "IECoreScene/VisibleRenderable.h" @@ -44,7 +46,7 @@ namespace IECoreScenePreview /// Class used to represent additional geometry types supported /// by specific renderers but not present in Cortex (think RiGeometry). -class IECORESCENE_API Geometry : public IECoreScene::VisibleRenderable +class GAFFERSCENE_API Geometry : public IECoreScene::VisibleRenderable { public: diff --git a/include/GafferScene/Private/IECoreScenePreview/Procedural.h b/include/GafferScene/Private/IECoreScenePreview/Procedural.h index 6dddf0c8a84..c882ce14b3d 100644 --- a/include/GafferScene/Private/IECoreScenePreview/Procedural.h +++ b/include/GafferScene/Private/IECoreScenePreview/Procedural.h @@ -37,6 +37,8 @@ #ifndef IECORESCENEPREVIEW_PROCEDURAL_H #define IECORESCENEPREVIEW_PROCEDURAL_H +#include "GafferScene/Export.h" + #include "GafferScene/TypeIds.h" #include "IECoreScene/VisibleRenderable.h" @@ -48,7 +50,7 @@ class Renderer; /// \todo Would it be useful to have a virtual function that returns an /// ExternalProcedural, for use when serialising scenes? -class IECORESCENE_API Procedural : public IECoreScene::VisibleRenderable +class GAFFERSCENE_API Procedural : public IECoreScene::VisibleRenderable { public : diff --git a/include/GafferScene/Private/IECoreScenePreview/Renderer.h b/include/GafferScene/Private/IECoreScenePreview/Renderer.h index a4cb355a2d0..3517985d094 100644 --- a/include/GafferScene/Private/IECoreScenePreview/Renderer.h +++ b/include/GafferScene/Private/IECoreScenePreview/Renderer.h @@ -37,6 +37,8 @@ #ifndef IECORESCENEPREVIEW_RENDERER_H #define IECORESCENEPREVIEW_RENDERER_H +#include "GafferScene/Export.h" + #include "IECoreScene/Camera.h" #include "IECoreScene/Output.h" @@ -70,12 +72,12 @@ namespace IECoreScenePreview /// - Change the python bindings so that the lifetime of the object /// handles and the renderer are tied together, or have the object /// handles keep the renderer alive on the C++ side anyway. -class IECORESCENE_API Renderer : public IECore::RefCounted +class GAFFERSCENE_API Renderer : public IECore::RefCounted { public : - enum RenderType + enum GAFFERSCENE_API RenderType { /// Locations are emitted to the renderer immediately /// and not retained for later editing. @@ -119,7 +121,7 @@ class IECORESCENE_API Renderer : public IECore::RefCounted /// A handle to a block of attributes. Currently all /// AttributesInterfaces _must_ be destroyed prior /// to destruction of the renderer itself. - class AttributesInterface : public IECore::RefCounted + class GAFFERSCENE_API AttributesInterface : public IECore::RefCounted { public : @@ -167,7 +169,7 @@ class IECORESCENE_API Renderer : public IECore::RefCounted /// /// Currently all ObjectInterfaces _must_ be destroyed prior to destruction /// of the renderer itself. - class ObjectInterface : public IECore::RefCounted + class GAFFERSCENE_API ObjectInterface : public IECore::RefCounted { public : diff --git a/include/GafferScene/Prune.h b/include/GafferScene/Prune.h index b10e7af62c7..66fa8c49004 100644 --- a/include/GafferScene/Prune.h +++ b/include/GafferScene/Prune.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_PRUNE_H #define GAFFERSCENE_PRUNE_H +#include "GafferScene/Export.h" #include "GafferScene/FilteredSceneProcessor.h" namespace GafferScene diff --git a/include/GafferScene/ResamplePrimitiveVariables.h b/include/GafferScene/ResamplePrimitiveVariables.h index 9fab1cfed03..e05a26f1012 100644 --- a/include/GafferScene/ResamplePrimitiveVariables.h +++ b/include/GafferScene/ResamplePrimitiveVariables.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_RESAMPLEPRIMITIVEVARIABLES_H #define GAFFERSCENE_RESAMPLEPRIMITIVEVARIABLES_H +#include "GafferScene/Export.h" #include "GafferScene/PrimitiveVariableProcessor.h" namespace GafferScene diff --git a/include/GafferScene/SceneElementProcessor.h b/include/GafferScene/SceneElementProcessor.h index 60c4c54463e..aca3e5ceab1 100644 --- a/include/GafferScene/SceneElementProcessor.h +++ b/include/GafferScene/SceneElementProcessor.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_SCENEELEMENTPROCESSOR_H #define GAFFERSCENE_SCENEELEMENTPROCESSOR_H +#include "GafferScene/Export.h" #include "GafferScene/FilteredSceneProcessor.h" namespace GafferScene diff --git a/include/GafferScene/ScenePlug.h b/include/GafferScene/ScenePlug.h index f9542b9d13d..a05521da19e 100644 --- a/include/GafferScene/ScenePlug.h +++ b/include/GafferScene/ScenePlug.h @@ -153,7 +153,7 @@ class GAFFERSCENE_API ScenePlug : public Gaffer::ValuePlug /// Utility class to scope a temporary copy of a context, /// specifying the scene path. - struct PathScope : public Gaffer::Context::EditableScope + struct GAFFERSCENE_API PathScope : public Gaffer::Context::EditableScope { /// NOTE : Any of these calls which take a pointer are fast versions which require /// the caller to keep the source memory valid for the lifetime of the PathScope. @@ -178,7 +178,7 @@ class GAFFERSCENE_API ScenePlug : public Gaffer::ValuePlug /// Utility class to scope a temporary copy of a context, /// specifying the set name. - struct SetScope : public Gaffer::Context::EditableScope + struct GAFFERSCENE_API SetScope : public Gaffer::Context::EditableScope { /// NOTE : Any of these calls which take a pointer are fast versions which require /// the caller to keep the source memory valid for the lifetime of the SetScope. @@ -206,7 +206,7 @@ class GAFFERSCENE_API ScenePlug : public Gaffer::ValuePlug /// when evaluating plugs which must not be sensitive /// to such variables, and can improve performance by /// reducing pressure on the hash cache. - struct GlobalScope : public Gaffer::Context::EditableScope + struct GAFFERSCENE_API GlobalScope : public Gaffer::Context::EditableScope { /// Standard constructor, for modifying context on the current thread. GlobalScope( const Gaffer::Context *context ); @@ -302,6 +302,6 @@ IE_CORE_DECLAREPTR( ScenePlug ); } // namespace GafferScene -GAFFERSCENE_API std::ostream &operator << ( std::ostream &o, const GafferScene::ScenePlug::ScenePath &path ); +std::ostream &operator << ( std::ostream &o, const GafferScene::ScenePlug::ScenePath &path ); #endif // GAFFERSCENE_SCENEPLUG_H diff --git a/include/GafferScene/SceneProcessor.h b/include/GafferScene/SceneProcessor.h index 9ba6f50dbe7..2c02c49126d 100644 --- a/include/GafferScene/SceneProcessor.h +++ b/include/GafferScene/SceneProcessor.h @@ -38,6 +38,9 @@ #ifndef GAFFERSCENE_SCENEPROCESSOR_H #define GAFFERSCENE_SCENEPROCESSOR_H +#include + +#include "GafferScene/Export.h" #include "GafferScene/SceneNode.h" namespace Gaffer @@ -63,7 +66,7 @@ class GAFFERSCENE_API SceneProcessor : public SceneNode /// Constructs with an ArrayPlug called "in". Use inPlug() as a /// convenience for accessing the first child in the array, and use /// inPlugs() to access the array itself. - SceneProcessor( const std::string &name, size_t minInputs, size_t maxInputs = Imath::limits::max() ); + SceneProcessor( const std::string &name, size_t minInputs, size_t maxInputs = std::numeric_limits::max() ); ~SceneProcessor() override; diff --git a/include/GafferScene/Seeds.h b/include/GafferScene/Seeds.h index ddc51fb2e41..6a9e6b5d4e3 100644 --- a/include/GafferScene/Seeds.h +++ b/include/GafferScene/Seeds.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_SEEDS_H #define GAFFERSCENE_SEEDS_H +#include "GafferScene/Export.h" #include "GafferScene/BranchCreator.h" namespace GafferScene diff --git a/include/GafferScene/ShaderAssignment.h b/include/GafferScene/ShaderAssignment.h index c31ef981e77..452137f0486 100644 --- a/include/GafferScene/ShaderAssignment.h +++ b/include/GafferScene/ShaderAssignment.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_SHADERASSIGNMENT_H #define GAFFERSCENE_SHADERASSIGNMENT_H +#include "GafferScene/Export.h" #include "GafferScene/AttributeProcessor.h" #include "GafferScene/ShaderPlug.h" diff --git a/include/GafferScene/StandardAttributes.h b/include/GafferScene/StandardAttributes.h index 77cb597794a..37337c078db 100644 --- a/include/GafferScene/StandardAttributes.h +++ b/include/GafferScene/StandardAttributes.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_STANDARDATTRIBUTES_H #define GAFFERSCENE_STANDARDATTRIBUTES_H +#include "GafferScene/Export.h" #include "GafferScene/Attributes.h" namespace GafferScene diff --git a/include/GafferScene/StandardOptions.h b/include/GafferScene/StandardOptions.h index 914b6cd2647..35f7a9f70fb 100644 --- a/include/GafferScene/StandardOptions.h +++ b/include/GafferScene/StandardOptions.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_STANDARDOPTIONS_H #define GAFFERSCENE_STANDARDOPTIONS_H +#include "GafferScene/Export.h" #include "GafferScene/Options.h" namespace GafferScene diff --git a/include/GafferScene/SubTree.h b/include/GafferScene/SubTree.h index fc7a391a81f..203c26d9e8d 100644 --- a/include/GafferScene/SubTree.h +++ b/include/GafferScene/SubTree.h @@ -38,6 +38,7 @@ #ifndef GAFFERSCENE_SUBTREE_H #define GAFFERSCENE_SUBTREE_H +#include "GafferScene/Export.h" #include "GafferScene/SceneProcessor.h" #include "Gaffer/StringPlug.h" diff --git a/include/GafferScene/Text.h b/include/GafferScene/Text.h index 5dd48a527f6..80018c08afa 100644 --- a/include/GafferScene/Text.h +++ b/include/GafferScene/Text.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_TEXT_H #define GAFFERSCENE_TEXT_H +#include "GafferScene/Export.h" #include "GafferScene/ObjectSource.h" namespace GafferScene diff --git a/include/GafferScene/UnionFilter.h b/include/GafferScene/UnionFilter.h index 3bb46dabe75..f4d9c5b1fff 100644 --- a/include/GafferScene/UnionFilter.h +++ b/include/GafferScene/UnionFilter.h @@ -37,6 +37,7 @@ #ifndef GAFFERSCENE_UNIONFILTER_H #define GAFFERSCENE_UNIONFILTER_H +#include "GafferScene/Export.h" #include "GafferScene/FilterProcessor.h" namespace GafferScene From 97a8dd955dad321831c869299a25611a98213a83 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 16:42:33 -0400 Subject: [PATCH 025/123] GafferSceneTest : Export symbols --- include/GafferSceneTest/ContextSanitiser.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/GafferSceneTest/ContextSanitiser.h b/include/GafferSceneTest/ContextSanitiser.h index 4fa8bb0ec53..33d86c3740b 100644 --- a/include/GafferSceneTest/ContextSanitiser.h +++ b/include/GafferSceneTest/ContextSanitiser.h @@ -37,6 +37,8 @@ #ifndef GAFFERSCENETEST_CONTEXTSANITISER_H #define GAFFERSCENETEST_CONTEXTSANITISER_H +#include "GafferSceneTest/Export.h" + #include "Gaffer/Monitor.h" #include "Gaffer/Plug.h" @@ -46,7 +48,7 @@ namespace GafferSceneTest { /// A monitor which warns about common context handling mistakes. -class GAFFER_API ContextSanitiser : public Gaffer::Monitor +class GAFFERSCENETEST_API ContextSanitiser : public Gaffer::Monitor { public : From 3f10c739a20f8b4f7a6259cd831a5981da9751c9 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 13:28:55 -0500 Subject: [PATCH 026/123] GafferSceneUI : Export symbols --- include/GafferSceneUI/TransformTool.h | 2 +- src/GafferSceneUI/ContextAlgo.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/GafferSceneUI/TransformTool.h b/include/GafferSceneUI/TransformTool.h index 9c00db9c831..ab534fc2a4a 100644 --- a/include/GafferSceneUI/TransformTool.h +++ b/include/GafferSceneUI/TransformTool.h @@ -73,7 +73,7 @@ class GAFFERSCENEUI_API TransformTool : public GafferSceneUI::SelectionTool Gaffer::FloatPlug *sizePlug(); const Gaffer::FloatPlug *sizePlug() const; - struct Selection + struct GAFFERSCENEUI_API Selection { // Constructs an empty selection. diff --git a/src/GafferSceneUI/ContextAlgo.cpp b/src/GafferSceneUI/ContextAlgo.cpp index 56bb383972d..2a2a065e5ad 100644 --- a/src/GafferSceneUI/ContextAlgo.cpp +++ b/src/GafferSceneUI/ContextAlgo.cpp @@ -42,6 +42,8 @@ #include "IECore/VectorTypedData.h" +#include "GafferSceneUI/ContextAlgo.h" + using namespace IECore; using namespace Gaffer; using namespace GafferScene; From 5d4fbe7fa4058c2d9e94561a4097b6802eebfd02 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:20:18 -0700 Subject: [PATCH 027/123] GafferSceneUIBindings : Export symbols --- include/GafferUI/RenderableGadget.h | 157 ---------------------------- include/GafferUI/SplinePlugGadget.h | 109 ------------------- 2 files changed, 266 deletions(-) delete mode 100644 include/GafferUI/RenderableGadget.h delete mode 100644 include/GafferUI/SplinePlugGadget.h diff --git a/include/GafferUI/RenderableGadget.h b/include/GafferUI/RenderableGadget.h deleted file mode 100644 index 7294c5a1be9..00000000000 --- a/include/GafferUI/RenderableGadget.h +++ /dev/null @@ -1,157 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011-2012, John Haddon. All rights reserved. -// Copyright (c) 2012-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above -// copyright notice, this list of conditions and the following -// disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with -// the distribution. -// -// * Neither the name of John Haddon nor the names of -// any other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef GAFFERUI_RENDERABLEGADGET_H -#define GAFFERUI_RENDERABLEGADGET_H - -#include "IECore/VisibleRenderable.h" - -#include "GafferUI/Export.h" -#include "GafferUI/Gadget.h" - -namespace IECoreGL -{ - -IE_CORE_FORWARDDECLARE( Scene ) -IE_CORE_FORWARDDECLARE( State ) -IE_CORE_FORWARDDECLARE( Group ) -IE_CORE_FORWARDDECLARE( StateComponent ) - -} // namespace IECoreGL - -namespace GafferUI -{ - -IE_CORE_FORWARDDECLARE( RenderableGadget ); - -/// \todo Either remove this or move it to GafferCortexUI. -class GAFFERUI_API RenderableGadget : public Gadget -{ - - public : - - RenderableGadget( IECore::VisibleRenderablePtr renderable = 0 ); - virtual ~RenderableGadget(); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferUI::RenderableGadget, RenderableGadgetTypeId, Gadget ); - - virtual Imath::Box3f bound() const; - - void setRenderable( IECore::ConstVisibleRenderablePtr renderable ); - IECore::ConstVisibleRenderablePtr getRenderable() const; - - /// Returns the IECoreGL::State object used as the base display - /// style for the Renderable. This may be modified freely to - /// change the display style. - IECoreGL::State *baseState(); - - /// Returns the name of the frontmost object intersecting the specified line - /// through gadget space, or "" if there is no such object. - std::string objectAt( const IECore::LineSegment3f &lineInGadgetSpace ) const; - /// Fills objectNames with all objects intersected by a rectangle in screen space, - /// defined by two corners in gadget space (as required for drag selection). - size_t objectsAt( - const Imath::V3f &corner0InGadgetSpace, - const Imath::V3f &corner1InGadgetSpace, - std::vector &objectNames - ) const; - - /// @name Selection - /// The RenderableGadget maintains a set of selected object, based - /// on object name. The user can manipulate the selection with the - /// mouse, and the selected objects are drawn in a highlighted fashion. - /// The selection may be queried and set programatically, and the - /// SelectionChangedSignal can be used to provide notifications of - /// such changes. - //////////////////////////////////////////////////////////////////// - //@{ - /// The selection is simply stored as a set of object names. - typedef std::set Selection; - /// Returns the selection. - Selection &getSelection(); - const Selection &getSelection() const; - /// Sets the selection, triggering selectionChangedSignal() if - /// necessary. - void setSelection( const std::set &selection ); - /// A signal emitted when the selection has changed, either through - /// a call to setSelection() or through user action. - typedef boost::signal SelectionChangedSignal; - SelectionChangedSignal &selectionChangedSignal(); - /// Returns the bounding box of all the selected objects. - Imath::Box3f selectionBound() const; - //@} - - /// Implemented to return the name of the object under the mouse as - /// a tooltip. - virtual std::string getToolTip( const IECore::LineSegment3f &line ) const; - - protected : - - virtual void doRender( const Style *style ) const; - - private : - - bool buttonPress( GadgetPtr gadget, const ButtonEvent &event ); - IECore::RunTimeTypedPtr dragBegin( GadgetPtr gadget, const DragDropEvent &event ); - bool dragEnter( GadgetPtr gadget, const DragDropEvent &event ); - bool dragMove( GadgetPtr gadget, const DragDropEvent &event ); - bool dragEnd( GadgetPtr gadget, const DragDropEvent &event ); - - void applySelection( IECoreGL::Group *group = 0 ); - Imath::Box3f selectionBound( IECoreGL::Group *group ) const; - - IECore::ConstVisibleRenderablePtr m_renderable; - IECoreGL::ScenePtr m_scene; - IECoreGL::StatePtr m_baseState; - IECoreGL::StateComponentPtr m_selectionColor; - IECoreGL::StateComponentPtr m_wireframeOn; - - Selection m_selection; - SelectionChangedSignal m_selectionChangedSignal; - - Imath::V3f m_dragStartPosition; - Imath::V3f m_lastDragPosition; - bool m_dragSelecting; - -}; - -typedef Gaffer::FilteredChildIterator > RenderableGadgetIterator; -typedef Gaffer::FilteredRecursiveChildIterator > RecursiveRenderableGadgetIterator; - -} // namespace GafferUI - -#endif // GAFFERUI_RenderableGadget_H diff --git a/include/GafferUI/SplinePlugGadget.h b/include/GafferUI/SplinePlugGadget.h deleted file mode 100644 index 5ce658ca1b5..00000000000 --- a/include/GafferUI/SplinePlugGadget.h +++ /dev/null @@ -1,109 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2011-2012, John Haddon. All rights reserved. -// Copyright (c) 2011-2012, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above -// copyright notice, this list of conditions and the following -// disclaimer. -// -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with -// the distribution. -// -// * Neither the name of John Haddon nor the names of -// any other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef GAFFERUI_SPLINEPLUGGADGET_H -#define GAFFERUI_SPLINEPLUGGADGET_H - -#include "GafferUI/Export.h" -#include "GafferUI/Gadget.h" - -#include "Gaffer/SplinePlug.h" -#include "Gaffer/StandardSet.h" - -namespace GafferUI -{ - -/// \todo I think this should work with any sort of Set for the splines. -class GAFFERUI_API SplinePlugGadget : public Gadget -{ - - public : - - SplinePlugGadget( const std::string &name=defaultName() ); - virtual ~SplinePlugGadget(); - - IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferUI::SplinePlugGadget, SplinePlugGadgetTypeId, Gadget ); - - /// The splines to be edited - Gaffer::StandardSetPtr splines(); - Gaffer::ConstStandardSetPtr splines() const; - - /// The selected spline points - Gaffer::StandardSetPtr selection(); - Gaffer::ConstStandardSetPtr selection() const; - - virtual Imath::Box3f bound() const; - - protected : - - virtual void doRender( const Style *style ) const; - - private : - - void splineAdded( Gaffer::SetPtr splineSet, IECore::RunTimeTypedPtr splinePlug ); - void splineRemoved( Gaffer::SetPtr splineSet, IECore::RunTimeTypedPtr splinePlug ); - void plugSet( Gaffer::Plug *plug ); - Gaffer::StandardSetPtr m_splines; - Gaffer::StandardSetPtr m_selection; - - void pointAdded( Gaffer::GraphComponentPtr spline, Gaffer::GraphComponentPtr point ); - void pointRemoved( Gaffer::GraphComponentPtr spline, Gaffer::GraphComponentPtr point ); - - bool selectionAcceptance( Gaffer::ConstStandardSetPtr selection, IECore::ConstRunTimeTypedPtr point ); - - struct UI; - typedef std::map SplineUIMap; - mutable SplineUIMap m_uis; - void updateCurve( SplineUIMap::iterator it ) const; - - bool buttonPress( GadgetPtr gadget, const ButtonEvent &event ); - IECore::RunTimeTypedPtr dragBegin( GadgetPtr gadget, const ButtonEvent &event ); - bool dragMove( GadgetPtr gadget, const ButtonEvent &event ); - Imath::V2f m_lastDragPosition; - - bool keyPress( GadgetPtr gadget, const KeyEvent &event ); - -}; - -IE_CORE_DECLAREPTR( SplinePlugGadget ) - -typedef Gaffer::FilteredChildIterator > SplinePlugGadgetIterator; -typedef Gaffer::FilteredRecursiveChildIterator > RecursiveSplinePlugGadgetIterator; - -} // namespace GafferUI - -#endif // GAFFERUI_SPLINEPLUGGADGET_H From 0dbec678cf73716e21c5c0b7e6083582dd311797 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 16:51:28 -0500 Subject: [PATCH 028/123] GafferVDB : Export symbols --- include/GafferVDB/SphereLevelSet.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/GafferVDB/SphereLevelSet.h b/include/GafferVDB/SphereLevelSet.h index d8821112548..81d73f8f06c 100644 --- a/include/GafferVDB/SphereLevelSet.h +++ b/include/GafferVDB/SphereLevelSet.h @@ -37,6 +37,8 @@ #ifndef GAFFERSCENE_SPHERELEVELSET_H #define GAFFERSCENE_SPHERELEVELSET_H +#include "GafferVDB/Export.h" + #include "GafferScene/ObjectSource.h" #include "Gaffer/CompoundNumericPlug.h" @@ -46,7 +48,7 @@ namespace GafferVDB { -class GAFFERSCENE_API SphereLevelSet : public GafferScene::ObjectSource +class GAFFERVDB_API SphereLevelSet : public GafferScene::ObjectSource { public : From 1b83908c0cd90f425aa13eab22e0c7ad8334eed9 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:22:04 -0700 Subject: [PATCH 029/123] GafferOSL : Export symbols --- include/GafferOSL/OSLCode.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/GafferOSL/OSLCode.h b/include/GafferOSL/OSLCode.h index 539c094e2c7..c4774a55011 100644 --- a/include/GafferOSL/OSLCode.h +++ b/include/GafferOSL/OSLCode.h @@ -37,6 +37,7 @@ #ifndef GAFFEROSL_OSLCODE_H #define GAFFEROSL_OSLCODE_H +#include "GafferOSL/Export.h" #include "GafferOSL/OSLShader.h" namespace GafferOSL From 46c79dfa95c37877d01ce561c1ae913c9d247521 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 13:28:04 -0500 Subject: [PATCH 030/123] GafferDispatch : Export symbols --- include/GafferDispatch/Dispatcher.h | 2 +- include/GafferDispatch/TaskNode.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/GafferDispatch/Dispatcher.h b/include/GafferDispatch/Dispatcher.h index 7d37543dcc4..08cd4b686b0 100644 --- a/include/GafferDispatch/Dispatcher.h +++ b/include/GafferDispatch/Dispatcher.h @@ -224,7 +224,7 @@ class GAFFERDISPATCH_API Dispatcher : public Gaffer::Node /// All tasks within a batch are from the same plug /// and have identical contexts except for the frame /// number. - class TaskBatch : public IECore::RefCounted + class GAFFERDISPATCH_API TaskBatch : public IECore::RefCounted { public : diff --git a/include/GafferDispatch/TaskNode.h b/include/GafferDispatch/TaskNode.h index ce6c6160910..25e4cc1f4be 100644 --- a/include/GafferDispatch/TaskNode.h +++ b/include/GafferDispatch/TaskNode.h @@ -85,7 +85,7 @@ class GAFFERDISPATCH_API TaskNode : public Gaffer::DependencyNode /// the context in which it should be executed. See TaskPlug /// for the main public interface for the execution of /// individual tasks. - class Task + class GAFFERDISPATCH_API Task { public : @@ -121,7 +121,7 @@ class GAFFERDISPATCH_API TaskNode : public Gaffer::DependencyNode /// Plug type used to represent tasks within the /// node graph. This provides the primary public /// interface for querying and executing tasks. - class TaskPlug : public Gaffer::Plug + class GAFFERDISPATCH_API TaskPlug : public Gaffer::Plug { public : From 12d2d38129270522e3c3ecf48b4ea9ddf9a8cb86 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Tue, 9 May 2017 23:42:51 -0700 Subject: [PATCH 031/123] GafferDispatcherBindings : Export symbols --- include/GafferDispatchBindings/Export.h | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/GafferDispatchBindings/Export.h diff --git a/include/GafferDispatchBindings/Export.h b/include/GafferDispatchBindings/Export.h new file mode 100644 index 00000000000..a0cd7338074 --- /dev/null +++ b/include/GafferDispatchBindings/Export.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2016, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERDISPATCHBINDINGS_EXPORT_H +#define GAFFERDISPATCHBINDINGS_EXPORT_H + +#include "Gaffer/Export.h" + +// define GAFFERDISPATCHBINDINGS_API macro based on whether or not we are compiling +// GafferDispatchBindings, or including headers for linking to it. the GAFFERDISPATCHBINDINGS_API +// macro is the one that is used in the class definitions. +#ifdef GafferDispatchBindings_EXPORTS + #define GAFFERDISPATCHBINDINGS_API GAFFER_EXPORT +#else + #define GAFFERDISPATCHBINDINGS_API GAFFER_IMPORT +#endif + +#endif // #ifndef GAFFERDISPATCHBINDINGS_EXPORT_H From d803619d0c9bf69419dcd58486e6dc955f889278 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Tue, 9 May 2017 23:47:06 -0700 Subject: [PATCH 032/123] GafferCortex : Export symbols --- include/GafferCortex/ExecutableOpHolder.h | 1 + include/GafferCortex/OpHolder.h | 1 + include/GafferCortex/ParameterHandler.h | 2 ++ include/GafferCortex/ParameterisedHolder.h | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/GafferCortex/ExecutableOpHolder.h b/include/GafferCortex/ExecutableOpHolder.h index dcc1bbc190e..fd5f0cdf225 100644 --- a/include/GafferCortex/ExecutableOpHolder.h +++ b/include/GafferCortex/ExecutableOpHolder.h @@ -37,6 +37,7 @@ #ifndef GAFFERCORTEX_EXECUTABLEOPHOLDER_H #define GAFFERCORTEX_EXECUTABLEOPHOLDER_H +#include "GafferCortex/Export.h" #include "GafferCortex/ParameterisedHolder.h" namespace IECore diff --git a/include/GafferCortex/OpHolder.h b/include/GafferCortex/OpHolder.h index 25bdfea0f3a..dc575415acf 100644 --- a/include/GafferCortex/OpHolder.h +++ b/include/GafferCortex/OpHolder.h @@ -37,6 +37,7 @@ #ifndef GAFFERCORTEX_OPHOLDER_H #define GAFFERCORTEX_OPHOLDER_H +#include "GafferCortex/Export.h" #include "GafferCortex/ParameterisedHolder.h" namespace IECore diff --git a/include/GafferCortex/ParameterHandler.h b/include/GafferCortex/ParameterHandler.h index 560f3766487..de842eb30db 100644 --- a/include/GafferCortex/ParameterHandler.h +++ b/include/GafferCortex/ParameterHandler.h @@ -46,6 +46,8 @@ #include +#include "GafferCortex/Export.h" + namespace GafferCortex { diff --git a/include/GafferCortex/ParameterisedHolder.h b/include/GafferCortex/ParameterisedHolder.h index f963aac96f0..ae12dffc2e4 100644 --- a/include/GafferCortex/ParameterisedHolder.h +++ b/include/GafferCortex/ParameterisedHolder.h @@ -86,7 +86,7 @@ class GAFFERCORTEX_API ParameterisedHolder : public BaseType void setParameterisedValues(); /// \todo Is this even needed? Can we just use an UndoScope instead? - class ParameterModificationContext + class GAFFERCORTEX_API ParameterModificationContext { public : ParameterModificationContext( Ptr parameterisedHolder ); From 460c3cf0558bfe1e9d8a3b65e363bffac8d03f95 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Tue, 9 May 2017 23:47:41 -0700 Subject: [PATCH 033/123] GafferCortexBindings : Export symbols --- include/GafferCortexBindings/Export.h | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/GafferCortexBindings/Export.h diff --git a/include/GafferCortexBindings/Export.h b/include/GafferCortexBindings/Export.h new file mode 100644 index 00000000000..b046072d14a --- /dev/null +++ b/include/GafferCortexBindings/Export.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2016, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERCORTEXBINDINGS_EXPORT_H +#define GAFFERCORTEXBINDINGS_EXPORT_H + +#include "Gaffer/Export.h" + +// define GAFFERCORTEXBINDINGS_API macro based on whether or not we are compiling +// GafferCortexBindings, or including headers for linking to it. the GAFFERCORTEXBINDINGS_API +// macro is the one that is used in the class definitions. +#ifdef GafferCortexBindings_EXPORTS + #define GAFFERCORTEXBINDINGS_API GAFFER_EXPORT +#else + #define GAFFERCORTEXBINDINGS_API GAFFER_IMPORT +#endif + +#endif // #ifndef GAFFERCORTEXBINDINGS_EXPORT_H From 43b15df25e93ba9afbebf3986d3b3e92b18a7165 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:22:51 -0700 Subject: [PATCH 034/123] GafferArnold : Export symbols --- include/GafferArnold/ArnoldAtmosphere.h | 2 +- include/GafferArnold/ArnoldBackground.h | 2 +- include/GafferArnold/ArnoldColorManager.h | 2 +- include/GafferArnold/ArnoldMeshLight.h | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/GafferArnold/ArnoldAtmosphere.h b/include/GafferArnold/ArnoldAtmosphere.h index 90a4069a06b..e682a217b37 100644 --- a/include/GafferArnold/ArnoldAtmosphere.h +++ b/include/GafferArnold/ArnoldAtmosphere.h @@ -45,7 +45,7 @@ namespace GafferArnold { -class GAFFERSCENE_API ArnoldAtmosphere : public GafferScene::GlobalShader +class GAFFERARNOLD_API ArnoldAtmosphere : public GafferScene::GlobalShader { public : diff --git a/include/GafferArnold/ArnoldBackground.h b/include/GafferArnold/ArnoldBackground.h index cf0d56be58d..fc111011a0a 100644 --- a/include/GafferArnold/ArnoldBackground.h +++ b/include/GafferArnold/ArnoldBackground.h @@ -45,7 +45,7 @@ namespace GafferArnold { -class GAFFERSCENE_API ArnoldBackground : public GafferScene::GlobalShader +class GAFFERARNOLD_API ArnoldBackground : public GafferScene::GlobalShader { public : diff --git a/include/GafferArnold/ArnoldColorManager.h b/include/GafferArnold/ArnoldColorManager.h index 7401bbf7f1d..3ee221512fe 100644 --- a/include/GafferArnold/ArnoldColorManager.h +++ b/include/GafferArnold/ArnoldColorManager.h @@ -50,7 +50,7 @@ namespace GafferArnold class ArnoldShader; -class GAFFERSCENE_API ArnoldColorManager : public GafferScene::GlobalsProcessor +class GAFFERARNOLD_API ArnoldColorManager : public GafferScene::GlobalsProcessor { public : diff --git a/include/GafferArnold/ArnoldMeshLight.h b/include/GafferArnold/ArnoldMeshLight.h index 00a4d51f903..3168fe356ee 100644 --- a/include/GafferArnold/ArnoldMeshLight.h +++ b/include/GafferArnold/ArnoldMeshLight.h @@ -42,6 +42,8 @@ #include "GafferScene/FilteredSceneProcessor.h" +#include "GafferArnold/Export.h" + namespace GafferArnold { From a557678782bc3d57a2198a4ddeafd8ab56c1baf7 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 6 Aug 2019 13:35:42 -0400 Subject: [PATCH 035/123] GafferArnoldUI : Export symbols - Symbols for GafferArnoldUI need to be exported - MSVC2017 prevents unnamed namespaces from being exported, so exports need to be in a named namespace - MSVC gives an error with multiple definitions of 'parameterOrDefault' found in multiple source files when linking - Isolate 'parameterOrDefault' to individual namespaces as a short-term fix before refactoring --- src/GafferArnoldUI/ArnoldLightVisualiser.cpp | 9 ++- src/GafferArnoldUI/BarndoorVisualiser.cpp | 39 ++++++----- src/GafferArnoldUI/DecayVisualiser.cpp | 69 ++++++++++--------- src/GafferArnoldUI/Export.h | 46 +++++++++++++ src/GafferArnoldUI/GoboVisualiser.cpp | 11 ++- src/GafferArnoldUI/LightBlockerVisualiser.cpp | 8 ++- 6 files changed, 127 insertions(+), 55 deletions(-) create mode 100644 src/GafferArnoldUI/Export.h diff --git a/src/GafferArnoldUI/ArnoldLightVisualiser.cpp b/src/GafferArnoldUI/ArnoldLightVisualiser.cpp index 1183b475c3a..e50e4641b51 100644 --- a/src/GafferArnoldUI/ArnoldLightVisualiser.cpp +++ b/src/GafferArnoldUI/ArnoldLightVisualiser.cpp @@ -34,6 +34,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include "GafferArnoldUI/Export.h" + #include "GafferArnoldUI/Private/VisualiserAlgo.h" #include "GafferSceneUI/StandardLightVisualiser.h" @@ -64,7 +66,7 @@ using namespace GafferArnoldUI::Private; // Arnold shaders are present in the network, a fallback of the last image // node found will be used instead:. -namespace +namespace GafferArnoldUI { ////////////////////////////////////////////////////////////////////////// @@ -177,7 +179,7 @@ IECoreGL::RenderablePtr iesVisualisation( const std::string &filename ) // ArnoldLightVisualiser implementation ////////////////////////////////////////////////////////////////////////// -class GAFFERSCENEUI_API ArnoldLightVisualiser : public GafferSceneUI::StandardLightVisualiser +class GAFFERARNOLDUI_API ArnoldLightVisualiser : public GafferSceneUI::StandardLightVisualiser { public : @@ -289,4 +291,5 @@ IECore::DataPtr ArnoldLightVisualiser::surfaceTexture( const IECoreScene::Shader return surfaceTexture; } -} +} // namespace GafferArnoldUI + diff --git a/src/GafferArnoldUI/BarndoorVisualiser.cpp b/src/GafferArnoldUI/BarndoorVisualiser.cpp index f5010c1725b..16d1f79fa32 100644 --- a/src/GafferArnoldUI/BarndoorVisualiser.cpp +++ b/src/GafferArnoldUI/BarndoorVisualiser.cpp @@ -34,6 +34,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include "GafferArnoldUI/Export.h" + #include "GafferSceneUI/StandardLightVisualiser.h" #include "GafferScene/Private/IECoreGLPreview/LightFilterVisualiser.h" @@ -58,21 +60,26 @@ using namespace IECoreGL; using namespace IECoreGLPreview; using namespace GafferSceneUI; -namespace +namespace BarndoorVisualiserUtils { -enum class BarndoorLocation { Top, Right, Left, Bottom }; - -float parameterOrDefault( const IECore::CompoundData *data, const char *key, const float def ) +float parameterOrDefault(const IECore::CompoundData *data, const char *key, const float def) { - ConstFloatDataPtr member = data->member( key ); - if( member ) + ConstFloatDataPtr member = data->member(key); + if (member) { return member->readable(); } return def; } +} // namespace BarndoorVisualiserUtils + +namespace GafferArnoldUI +{ + +enum class BarndoorLocation { Top, Right, Left, Bottom }; + const char *barndoorFragSource() { return @@ -147,7 +154,7 @@ void addBarndoor( IECoreGL::GroupPtr result, BarndoorLocation location, float co result->addChild( barndoorGroup ); } -class BarndoorVisualiser final : public LightFilterVisualiser +class GAFFERARNOLDUI_API BarndoorVisualiser final : public LightFilterVisualiser { public : @@ -184,17 +191,17 @@ Visualisations BarndoorVisualiser::visualise( const IECore::InternedString &attr const IECore::CompoundData *filterShaderParameters = shaderNetwork->outputShader()->parametersData(); - float topLeft = parameterOrDefault( filterShaderParameters, "barndoor_top_left", 0.0f ); - float topRight = parameterOrDefault( filterShaderParameters, "barndoor_top_right", 0.0f ); + float topLeft = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_top_left", 0.0f ); + float topRight = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_top_right", 0.0f ); - float rightTop = parameterOrDefault( filterShaderParameters, "barndoor_right_top", 1.0f ); - float rightBottom = parameterOrDefault( filterShaderParameters, "barndoor_right_bottom", 1.0f ); + float rightTop = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_right_top", 1.0f ); + float rightBottom = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_right_bottom", 1.0f ); - float bottomLeft = parameterOrDefault( filterShaderParameters, "barndoor_bottom_left", 1.0f ); - float bottomRight = parameterOrDefault( filterShaderParameters, "barndoor_bottom_right", 1.0f ); + float bottomLeft = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_bottom_left", 1.0f ); + float bottomRight = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_bottom_right", 1.0f ); - float leftTop = parameterOrDefault( filterShaderParameters, "barndoor_left_top", 0.0f ); - float leftBottom = parameterOrDefault( filterShaderParameters, "barndoor_left_bottom", 0.0f ); + float leftTop = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_left_top", 0.0f ); + float leftBottom = BarndoorVisualiserUtils::parameterOrDefault( filterShaderParameters, "barndoor_left_bottom", 0.0f ); addBarndoor( result, BarndoorLocation::Top, topLeft, topRight ); @@ -237,4 +244,4 @@ Visualisations BarndoorVisualiser::visualise( const IECore::InternedString &attr } -} // namespace +} // namespace GafferArnoldUI diff --git a/src/GafferArnoldUI/DecayVisualiser.cpp b/src/GafferArnoldUI/DecayVisualiser.cpp index 6d34f7fbdf0..3a66743821f 100644 --- a/src/GafferArnoldUI/DecayVisualiser.cpp +++ b/src/GafferArnoldUI/DecayVisualiser.cpp @@ -34,6 +34,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include "GafferArnoldUI/Export.h" + #include "GafferScene/Private/IECoreGLPreview/LightFilterVisualiser.h" #include "IECoreGL/Group.h" @@ -54,7 +56,34 @@ using namespace IECoreScene; using namespace IECoreGL; using namespace IECoreGLPreview; -namespace +namespace DecayVisualiserUtils +{ + +// \todo These should be consolidated with the function in BarndoorVisualiser into a templatized version +// Where should that live? +float parameterOrDefault(const IECore::CompoundData *data, const char *key, const float def) +{ + ConstFloatDataPtr member = data->member(key); + if (member) + { + return member->readable(); + } + return def; +} + +bool parameterOrDefault(const IECore::CompoundData *data, const char *key, const bool def) +{ + ConstBoolDataPtr member = data->member(key); + if (member) + { + return member->readable(); + } + return def; +} + +} // namespace DecayVisualiserUtils + +namespace GafferArnoldUI { typedef std::pair Knot; typedef std::vector KnotVector; @@ -97,39 +126,17 @@ const char *knotFragSource() ; } -// \todo These should be consolidated with the function in BarndoorVisualiser into a templatized version -// Where should that live? -float parameterOrDefault( const IECore::CompoundData *data, const char *key, const float def ) -{ - ConstFloatDataPtr member = data->member( key ); - if( member ) - { - return member->readable(); - } - return def; -} - -bool parameterOrDefault( const IECore::CompoundData *data, const char *key, const bool def ) -{ - ConstBoolDataPtr member = data->member( key ); - if( member ) - { - return member->readable(); - } - return def; -} - void getKnotsToVisualize( const IECoreScene::ShaderNetwork *shaderNetwork, KnotVector &knots ) { const IECore::CompoundData *filterShaderParameters = shaderNetwork->outputShader()->parametersData(); - bool nearEnabled = parameterOrDefault( filterShaderParameters, "use_near_atten", false ); - bool farEnabled = parameterOrDefault( filterShaderParameters, "use_far_atten", false ); + bool nearEnabled = DecayVisualiserUtils::parameterOrDefault( filterShaderParameters, "use_near_atten", false ); + bool farEnabled = DecayVisualiserUtils::parameterOrDefault( filterShaderParameters, "use_far_atten", false ); if( nearEnabled ) { - float nearStart = parameterOrDefault( filterShaderParameters, "near_start", 0.0f ); - float nearEnd = parameterOrDefault( filterShaderParameters, "near_end", 0.0f ); + float nearStart = DecayVisualiserUtils::parameterOrDefault( filterShaderParameters, "near_start", 0.0f ); + float nearEnd = DecayVisualiserUtils::parameterOrDefault( filterShaderParameters, "near_end", 0.0f ); knots.push_back( Knot( nearStart, V3f( 0.0f ) ) ); knots.push_back( Knot( nearEnd, V3f( 1.0f ) ) ); @@ -137,8 +144,8 @@ void getKnotsToVisualize( const IECoreScene::ShaderNetwork *shaderNetwork, KnotV if( farEnabled ) { - float farStart = parameterOrDefault( filterShaderParameters, "far_start", 0.0f ); - float farEnd = parameterOrDefault( filterShaderParameters, "far_end", 0.0f ); + float farStart = DecayVisualiserUtils::parameterOrDefault( filterShaderParameters, "far_start", 0.0f ); + float farEnd = DecayVisualiserUtils::parameterOrDefault( filterShaderParameters, "far_end", 0.0f ); knots.push_back( Knot( farStart, V3f( 1.0f ) ) ); knots.push_back( Knot( farEnd, V3f( 0.0f ) ) ); @@ -190,7 +197,7 @@ void addKnot( IECoreGL::GroupPtr group, const Knot &knot ) group->addChild( markerGroup ); } -class DecayVisualiser final : public LightFilterVisualiser +class GAFFERARNOLDUI_API DecayVisualiser final : public LightFilterVisualiser { public : @@ -245,4 +252,4 @@ Visualisations DecayVisualiser::visualise( const IECore::InternedString &attribu return { Visualisation( result, Visualisation::Scale::None ) }; } -} // namespace +} // namespace GafferArnoldUI diff --git a/src/GafferArnoldUI/Export.h b/src/GafferArnoldUI/Export.h new file mode 100644 index 00000000000..2a9d10bae77 --- /dev/null +++ b/src/GafferArnoldUI/Export.h @@ -0,0 +1,46 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2018, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of Image Engine Design nor the names of any +// other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERARNOLDUI_EXPORT_H +#define GAFFERARNOLDUI_EXPORT_H + +#include "IECore/Export.h" + +#ifdef GafferArnoldUI_EXPORTS + #define GAFFERARNOLDUI_API IECORE_EXPORT +#else + #define GAFFERARNOLDUI_API IECORE_IMPORT +#endif + +#endif // #ifndef GAFFERARNOLDUI_EXPORT_H diff --git a/src/GafferArnoldUI/GoboVisualiser.cpp b/src/GafferArnoldUI/GoboVisualiser.cpp index d343952a523..a5f5fbedad8 100644 --- a/src/GafferArnoldUI/GoboVisualiser.cpp +++ b/src/GafferArnoldUI/GoboVisualiser.cpp @@ -34,6 +34,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include "GafferArnoldUI/Export.h" + #include "GafferArnoldUI/Private/VisualiserAlgo.h" #include "GafferOSL/ShadingEngineAlgo.h" @@ -111,6 +113,11 @@ T parameterOrDefault( const IECore::CompoundData *parameters, const IECore::Inte } } +} // namespace + +namespace GafferArnoldUI +{ + struct OSLTextureCacheGetterKey { @@ -187,7 +194,7 @@ const char *constantFragSource() } -class GoboVisualiser final : public LightFilterVisualiser +class GAFFERARNOLDUI_API GoboVisualiser final : public LightFilterVisualiser { public : @@ -324,4 +331,4 @@ Visualisations GoboVisualiser::visualise( const IECore::InternedString &attribut return { Visualisation::createOrnament( result, true ) }; } -} // namespace +} // namespace \ No newline at end of file diff --git a/src/GafferArnoldUI/LightBlockerVisualiser.cpp b/src/GafferArnoldUI/LightBlockerVisualiser.cpp index d0c07b80a56..6f4dddc5bb6 100644 --- a/src/GafferArnoldUI/LightBlockerVisualiser.cpp +++ b/src/GafferArnoldUI/LightBlockerVisualiser.cpp @@ -34,6 +34,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include "GafferArnoldUI/Export.h" + #include "GafferScene/Private/IECoreGLPreview/LightFilterVisualiser.h" #include "Gaffer/Metadata.h" @@ -55,7 +57,7 @@ using namespace IECoreGL; using namespace IECoreGLPreview; using namespace Gaffer; -namespace +namespace GafferArnoldUI { const IECore::CompoundData *parametersAndMetadataTarget( const IECore::InternedString &attributeName, const IECoreScene::ShaderNetwork *filterShaderNetwork, InternedString &metadataTarget ) @@ -173,7 +175,7 @@ void setFalloffGroupSettings( IECoreGL::Group *group, const IECore::CompoundData // LightBlockerVisualiser implementation. ////////////////////////////////////////////////////////////////////////// -class LightBlockerVisualiser : public LightFilterVisualiser +class GAFFERARNOLDUI_API LightBlockerVisualiser : public LightFilterVisualiser { public : @@ -458,4 +460,4 @@ IECoreGL::ConstRenderablePtr LightBlockerVisualiser::planeShape( const IECore::C return group; } -} // namespace +} // namespace GafferArnoldUI From c5323ea3f7185cc3af90641386a8869c0865fe55 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 10 May 2017 00:23:17 -0700 Subject: [PATCH 036/123] GafferRenderMan : Export symbols --- include/GafferRenderMan/Export.h | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/GafferRenderMan/Export.h diff --git a/include/GafferRenderMan/Export.h b/include/GafferRenderMan/Export.h new file mode 100644 index 00000000000..96d9a9f6166 --- /dev/null +++ b/include/GafferRenderMan/Export.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2016, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERRENDERMAN_EXPORT_H +#define GAFFERRENDERMAN_EXPORT_H + +#include "Gaffer/Export.h" + +// define GAFFERRENDERMAN_API macro based on whether or not we are compiling +// GafferRenderman, or including headers for linking to it. the GAFFERRENDERMAN_API +// macro is the one that is used in the class definitions. +#ifdef GafferRenderMan_EXPORTS + #define GAFFERRENDERMAN_API GAFFER_EXPORT +#else + #define GAFFERRENDERMAN_API GAFFER_IMPORT +#endif + +#endif // #ifndef GAFFERRENDERMAN_EXPORT_H From 748c26b78aaacc3c91ab9b3212650ec268e39c06 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 13:27:55 -0500 Subject: [PATCH 037/123] GafferDelight : Export symbols --- .../GafferDelight/IECoreDelightPreview/NodeAlgo.h | 14 +++++++++----- .../IECoreDelightPreview/ParameterList.h | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/GafferDelight/IECoreDelightPreview/NodeAlgo.h b/include/GafferDelight/IECoreDelightPreview/NodeAlgo.h index f16463d9cbe..dfaebb35217 100644 --- a/include/GafferDelight/IECoreDelightPreview/NodeAlgo.h +++ b/include/GafferDelight/IECoreDelightPreview/NodeAlgo.h @@ -44,6 +44,10 @@ #include +// Change this to "IECoreDelight/Export.h" and remove the define when it goes into Cortex. +#include "GafferDelight/Export.h" +#define IECOREDELIGHT_API GAFFERDELIGHT_API + namespace IECoreDelight { @@ -55,10 +59,10 @@ namespace NodeAlgo /// Converts the specified IECore::Object into an equivalent /// NSI node with the specified handle, returning true on /// success and false on failure. -bool convert( const IECore::Object *object, NSIContext_t context, const char *handle ); +IECOREDELIGHT_API bool convert( const IECore::Object *object, NSIContext_t context, const char *handle ); /// As above, but converting a moving object. If no motion converter /// is available, the first sample is converted instead. -bool convert( const std::vector &samples, const std::vector &sampleTimes, NSIContext_t context, const char *handle ); +IECOREDELIGHT_API bool convert( const std::vector &samples, const std::vector &sampleTimes, NSIContext_t context, const char *handle ); /// Signature of a function which can convert an IECore::Object /// into an NSI node. @@ -68,7 +72,7 @@ typedef bool (*MotionConverter)( const std::vector &samp /// Registers a converter for a specific type. /// Use the ConverterDescription utility class in preference to /// this, since it provides additional type safety. -void registerConverter( IECore::TypeId fromType, Converter converter, MotionConverter motionConverter = nullptr ); +IECOREDELIGHT_API void registerConverter( IECore::TypeId fromType, Converter converter, MotionConverter motionConverter = nullptr ); /// Class which registers a converter for type T automatically /// when instantiated. @@ -94,10 +98,10 @@ class ConverterDescription }; /// Adds all PrimitiveVariables into a ParameterList for use with NSISetAttribute. -void primitiveVariableParameterList( const IECoreScene::Primitive *primitive, ParameterList ¶meters, const IECore::IntVectorData *vertexIndices = nullptr ); +IECOREDELIGHT_API void primitiveVariableParameterList( const IECoreScene::Primitive *primitive, ParameterList ¶meters, const IECore::IntVectorData *vertexIndices = nullptr ); /// As above, but splits out animated primitive variables into a separate vector of ParameterLists /// for use with NSISetAttributeAtTime. -void primitiveVariableParameterLists( const std::vector &primitives, ParameterList &staticParameters, std::vector &animatedParameters, const IECore::IntVectorData *vertexIndices = nullptr ); +IECOREDELIGHT_API void primitiveVariableParameterLists( const std::vector &primitives, ParameterList &staticParameters, std::vector &animatedParameters, const IECore::IntVectorData *vertexIndices = nullptr ); } // namespace NodeAlgo diff --git a/include/GafferDelight/IECoreDelightPreview/ParameterList.h b/include/GafferDelight/IECoreDelightPreview/ParameterList.h index 7303d0f0686..fa247394e98 100644 --- a/include/GafferDelight/IECoreDelightPreview/ParameterList.h +++ b/include/GafferDelight/IECoreDelightPreview/ParameterList.h @@ -44,6 +44,10 @@ #include +// Change this to "IECoreDelight/Export.h" and remove the define when it goes into Cortex. +#include "GafferDelight/Export.h" +#define IECOREDELIGHT_API GAFFERDELIGHT_API + namespace IECoreDelight { @@ -51,7 +55,7 @@ namespace IECoreDelight /// NSI API. The ParameterList does not copy any of the data passed /// to it; it is the caller's responsibility to keep all data alive /// for as long as the ParameterList is used. -class ParameterList +class IECOREDELIGHT_API ParameterList { public : From 19e12a33b575252ede9d95ce9186931817967744 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 23 May 2018 18:49:26 -0400 Subject: [PATCH 038/123] Container : remove symbol export - Fixes MSVC error 'Gaffer::Container::typeId': definition of dllimport function not allowed (compili ng source file M:\gaffer\src\GafferModule\NodeBinding.cpp) --- include/Gaffer/Container.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Gaffer/Container.h b/include/Gaffer/Container.h index ec493bb9629..9f9ecff672a 100644 --- a/include/Gaffer/Container.h +++ b/include/Gaffer/Container.h @@ -43,7 +43,7 @@ namespace Gaffer { template -class GAFFER_API Container : public Base +class Container : public Base { public : From 3952f0cb11ff2d393f0c6f85699d198883b99999 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 3 Aug 2018 15:00:25 -0400 Subject: [PATCH 039/123] Use `std::numeric_limits` instead of Imath::limits - gcc and MSVC define size_t slightly differently, use the standard library to link on msvc --- include/Gaffer/ArrayPlug.h | 2 +- include/GafferImage/FlatImageProcessor.h | 2 +- include/GafferImage/ImageProcessor.h | 4 +++- include/GafferScene/Deformer.h | 2 +- include/GafferScene/ObjectProcessor.h | 2 +- include/GafferUI/GraphGadget.h | 12 ++++++------ src/Gaffer/NameSwitch.cpp | 2 +- src/Gaffer/Switch.cpp | 2 +- src/GafferImageModule/ImageProcessorBinding.cpp | 4 +++- src/GafferModule/ArrayPlugBinding.cpp | 4 ++-- src/GafferScene/InteractiveRender.cpp | 2 +- src/GafferSceneModule/CoreBinding.cpp | 2 +- src/GafferUI/GraphGadget.cpp | 2 +- src/GafferUIModule/GraphGadgetBinding.cpp | 6 +++--- 14 files changed, 26 insertions(+), 22 deletions(-) diff --git a/include/Gaffer/ArrayPlug.h b/include/Gaffer/ArrayPlug.h index 6572308434b..9b9521f9e1c 100644 --- a/include/Gaffer/ArrayPlug.h +++ b/include/Gaffer/ArrayPlug.h @@ -64,7 +64,7 @@ class GAFFER_API ArrayPlug : public Plug Direction direction = In, PlugPtr element = nullptr, size_t minSize = 1, - size_t maxSize = Imath::limits::max(), + size_t maxSize = std::numeric_limits::max(), unsigned flags = Default, bool resizeWhenInputsChange = true ); diff --git a/include/GafferImage/FlatImageProcessor.h b/include/GafferImage/FlatImageProcessor.h index eae0948746d..076cb7cf99e 100644 --- a/include/GafferImage/FlatImageProcessor.h +++ b/include/GafferImage/FlatImageProcessor.h @@ -58,7 +58,7 @@ class GAFFERIMAGE_API FlatImageProcessor : public ImageProcessor /// Constructs with an ArrayPlug called "in". Use inPlug() as a /// convenience for accessing the first child in the array, and use /// inPlugs() to access the array itself. - FlatImageProcessor( const std::string &name, size_t minInputs, size_t maxInputs = Imath::limits::max() ); + FlatImageProcessor( const std::string &name, size_t minInputs, size_t maxInputs = std::numeric_limits::max() ); ~FlatImageProcessor() override; GAFFER_NODE_DECLARE_TYPE( GafferImage::FlatImageProcessor, FlatImageProcessorTypeId, ImageProcessor ); diff --git a/include/GafferImage/ImageProcessor.h b/include/GafferImage/ImageProcessor.h index bab80804f18..695f74f8f99 100644 --- a/include/GafferImage/ImageProcessor.h +++ b/include/GafferImage/ImageProcessor.h @@ -38,6 +38,8 @@ #ifndef GAFFERIMAGE_IMAGEPROCESSOR_H #define GAFFERIMAGE_IMAGEPROCESSOR_H +#include + #include "GafferImage/Export.h" #include "GafferImage/ImageNode.h" @@ -65,7 +67,7 @@ class GAFFERIMAGE_API ImageProcessor : public ImageNode /// Constructs with an ArrayPlug called "in". Use inPlug() as a /// convenience for accessing the first child in the array, and use /// inPlugs() to access the array itself. - ImageProcessor( const std::string &name, size_t minInputs, size_t maxInputs = Imath::limits::max() ); + ImageProcessor( const std::string &name, size_t minInputs, size_t maxInputs = std::numeric_limits::max() ); ~ImageProcessor() override; GAFFER_NODE_DECLARE_TYPE( GafferImage::ImageProcessor, ImageProcessorTypeId, ImageNode ); diff --git a/include/GafferScene/Deformer.h b/include/GafferScene/Deformer.h index 2ea623ec160..61085cab9d2 100644 --- a/include/GafferScene/Deformer.h +++ b/include/GafferScene/Deformer.h @@ -70,7 +70,7 @@ class GAFFERSCENE_API Deformer : public ObjectProcessor /// Constructs with an ArrayPlug called "in". Use inPlug() as a /// convenience for accessing the first child in the array, and use /// inPlugs() to access the array itself. - Deformer( const std::string &name, size_t minInputs, size_t maxInputs = Imath::limits::max() ); + Deformer( const std::string &name, size_t minInputs, size_t maxInputs = std::numeric_limits::max() ); /// Used to determine whether adjusted bounds need to be propagated up to /// all ancestor locations. Default implementation checks the value of `adjustBoundsPlug()` diff --git a/include/GafferScene/ObjectProcessor.h b/include/GafferScene/ObjectProcessor.h index fea4ec68eee..72d57b1767f 100644 --- a/include/GafferScene/ObjectProcessor.h +++ b/include/GafferScene/ObjectProcessor.h @@ -66,7 +66,7 @@ class GAFFERSCENE_API ObjectProcessor : public FilteredSceneProcessor /// Constructs with an ArrayPlug called "in". Use inPlug() as a /// convenience for accessing the first child in the array, and use /// inPlugs() to access the array itself. - ObjectProcessor( const std::string &name, size_t minInputs, size_t maxInputs = Imath::limits::max() ); + ObjectProcessor( const std::string &name, size_t minInputs, size_t maxInputs = std::numeric_limits::max() ); /// Must be implemented by derived classes to return true if `input` is used /// by `computeProcessedObject()`. Overrides must start by calling the base diff --git a/include/GafferUI/GraphGadget.h b/include/GafferUI/GraphGadget.h index 2327583d3a0..6e127035105 100644 --- a/include/GafferUI/GraphGadget.h +++ b/include/GafferUI/GraphGadget.h @@ -144,24 +144,24 @@ class GAFFERUI_API GraphGadget : public ContainerGadget /// \note Here "upstream" nodes are defined as nodes at the end of input /// connections as shown in the graph - auxiliary connections and /// invisible nodes are not considered at all. - size_t upstreamNodeGadgets( const Gaffer::Node *node, std::vector &upstreamNodeGadgets, size_t degreesOfSeparation = Imath::limits::max() ); - size_t upstreamNodeGadgets( const Gaffer::Node *node, std::vector &upstreamNodeGadgets, size_t degreesOfSeparation = Imath::limits::max() ) const; + size_t upstreamNodeGadgets( const Gaffer::Node *node, std::vector &upstreamNodeGadgets, size_t degreesOfSeparation = std::numeric_limits::max() ); + size_t upstreamNodeGadgets( const Gaffer::Node *node, std::vector &upstreamNodeGadgets, size_t degreesOfSeparation = std::numeric_limits::max() ) const; /// Finds all the downstream NodeGadgets connected to the specified node /// and appends them to the specified vector. Returns the new size of the vector. /// \note Here "downstream" nodes are defined as nodes at the end of output /// connections as shown in the graph - auxiliary connections and /// invisible nodes are not considered at all. - size_t downstreamNodeGadgets( const Gaffer::Node *node, std::vector &downstreamNodeGadgets, size_t degreesOfSeparation = Imath::limits::max() ); - size_t downstreamNodeGadgets( const Gaffer::Node *node, std::vector &downstreamNodeGadgets, size_t degreesOfSeparation = Imath::limits::max() ) const; + size_t downstreamNodeGadgets( const Gaffer::Node *node, std::vector &downstreamNodeGadgets, size_t degreesOfSeparation = std::numeric_limits::max() ); + size_t downstreamNodeGadgets( const Gaffer::Node *node, std::vector &downstreamNodeGadgets, size_t degreesOfSeparation = std::numeric_limits::max() ) const; /// Finds all the NodeGadgets connected to the specified node /// and appends them to the specified vector. Returns the new size of the vector. /// \note Here "connected" nodes are defined as nodes at the end of /// connections as shown in the graph - auxiliary connections and /// invisible nodes are not considered at all. - size_t connectedNodeGadgets( const Gaffer::Node *node, std::vector &connectedNodeGadgets, Gaffer::Plug::Direction direction = Gaffer::Plug::Invalid, size_t degreesOfSeparation = Imath::limits::max() ); - size_t connectedNodeGadgets( const Gaffer::Node *node, std::vector &connectedNodeGadgets, Gaffer::Plug::Direction direction = Gaffer::Plug::Invalid, size_t degreesOfSeparation = Imath::limits::max() ) const; + size_t connectedNodeGadgets( const Gaffer::Node *node, std::vector &connectedNodeGadgets, Gaffer::Plug::Direction direction = Gaffer::Plug::Invalid, size_t degreesOfSeparation = std::numeric_limits::max() ); + size_t connectedNodeGadgets( const Gaffer::Node *node, std::vector &connectedNodeGadgets, Gaffer::Plug::Direction direction = Gaffer::Plug::Invalid, size_t degreesOfSeparation = std::numeric_limits::max() ) const; /// Finds all the NodeGadgets which haven't been given an explicit position /// using setNodePosition(). diff --git a/src/Gaffer/NameSwitch.cpp b/src/Gaffer/NameSwitch.cpp index ad8893fef18..1f5bd4faf20 100644 --- a/src/Gaffer/NameSwitch.cpp +++ b/src/Gaffer/NameSwitch.cpp @@ -81,7 +81,7 @@ void NameSwitch::setup( const Plug *plug ) Plug::In, element, 2, - Imath::limits::max(), + std::numeric_limits::max(), Plug::Default, /* resizeWhenInputsChange = */ false ); diff --git a/src/Gaffer/Switch.cpp b/src/Gaffer/Switch.cpp index d972f2c1d73..974e7c71b22 100644 --- a/src/Gaffer/Switch.cpp +++ b/src/Gaffer/Switch.cpp @@ -90,7 +90,7 @@ void Switch::setup( const Plug *plug ) Plug::In, inElement, 0, - Imath::limits::max() + std::numeric_limits::max() ); addChild( in ); diff --git a/src/GafferImageModule/ImageProcessorBinding.cpp b/src/GafferImageModule/ImageProcessorBinding.cpp index a0531045151..391b34f807c 100644 --- a/src/GafferImageModule/ImageProcessorBinding.cpp +++ b/src/GafferImageModule/ImageProcessorBinding.cpp @@ -32,6 +32,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include + #include "boost/python.hpp" #include "ImageProcessorBinding.h" @@ -64,7 +66,7 @@ void GafferImageModule::bindImageProcessor() ( arg( "name" ) = GraphComponent::defaultName(), arg( "minInputs" ), - arg( "maxInputs" ) = Imath::limits::max() + arg( "maxInputs" ) = std::numeric_limits::max() ) ) ) diff --git a/src/GafferModule/ArrayPlugBinding.cpp b/src/GafferModule/ArrayPlugBinding.cpp index 2d3b462b6ef..c48007e8a71 100644 --- a/src/GafferModule/ArrayPlugBinding.cpp +++ b/src/GafferModule/ArrayPlugBinding.cpp @@ -68,7 +68,7 @@ std::string repr( const ArrayPlug *plug ) result += boost::str( boost::format( "minSize = %d, " ) % plug->minSize() ); } - if( plug->maxSize() != Imath::limits::max() ) + if( plug->maxSize() != std::numeric_limits::max() ) { result += boost::str( boost::format( "maxSize = %d, " ) % plug->maxSize() ); } @@ -144,7 +144,7 @@ void GafferModule::bindArrayPlug() arg( "direction" ) = Plug::In, arg( "element" ) = PlugPtr(), arg( "minSize" ) = 1, - arg( "maxSize" ) = Imath::limits::max(), + arg( "maxSize" ) = std::numeric_limits::max(), arg( "flags" ) = Plug::Default, arg( "resizeWhenInputsChange" ) = true ) diff --git a/src/GafferScene/InteractiveRender.cpp b/src/GafferScene/InteractiveRender.cpp index 59d54863a03..50a24eee392 100644 --- a/src/GafferScene/InteractiveRender.cpp +++ b/src/GafferScene/InteractiveRender.cpp @@ -326,7 +326,7 @@ void InteractiveRender::update() m_controller.reset( new RenderController( adaptedInPlug(), effectiveContext(), m_renderer ) ); - m_controller->setMinimumExpansionDepth( limits::max() ); + m_controller->setMinimumExpansionDepth( numeric_limits::max() ); m_controller->updateRequiredSignal().connect( boost::bind( &InteractiveRender::update, this ) ); diff --git a/src/GafferSceneModule/CoreBinding.cpp b/src/GafferSceneModule/CoreBinding.cpp index a013d23890c..1d50085376e 100644 --- a/src/GafferSceneModule/CoreBinding.cpp +++ b/src/GafferSceneModule/CoreBinding.cpp @@ -399,7 +399,7 @@ void GafferSceneModule::bindCore() ( arg( "name" ) = GraphComponent::defaultName(), arg( "minInputs" ), - arg( "maxInputs" ) = Imath::limits::max() + arg( "maxInputs" ) = std::numeric_limits::max() ) ) ) diff --git a/src/GafferUI/GraphGadget.cpp b/src/GafferUI/GraphGadget.cpp index 7e65de892b9..191b5c817f9 100644 --- a/src/GafferUI/GraphGadget.cpp +++ b/src/GafferUI/GraphGadget.cpp @@ -1679,7 +1679,7 @@ bool GraphGadget::dragMove( GadgetPtr gadget, const DragDropEvent &event ) const std::vector &snapOffsets = m_dragSnapOffsets[axis]; float offset = pos[axis] - m_dragStartPosition[axis]; - float snappedDist = Imath::limits::max(); + float snappedDist = std::numeric_limits::max(); float snappedOffset = offset; vector::const_iterator it = lower_bound( snapOffsets.begin(), snapOffsets.end(), offset ); if( it != snapOffsets.end() ) diff --git a/src/GafferUIModule/GraphGadgetBinding.cpp b/src/GafferUIModule/GraphGadgetBinding.cpp index 029c79fbb55..3b9398171b1 100644 --- a/src/GafferUIModule/GraphGadgetBinding.cpp +++ b/src/GafferUIModule/GraphGadgetBinding.cpp @@ -267,9 +267,9 @@ void GafferUIModule::bindGraphGadget() .def( "connectionGadgets", &connectionGadgets1, ( arg_( "plug" ), arg_( "excludedNodes" ) = object() ) ) .def( "connectionGadgets", &connectionGadgets2, ( arg_( "node" ), arg_( "excludedNodes" ) = object() ) ) .def( "auxiliaryConnectionsGadget", (AuxiliaryConnectionsGadget *(GraphGadget::*)())&GraphGadget::auxiliaryConnectionsGadget, return_value_policy() ) - .def( "upstreamNodeGadgets", &upstreamNodeGadgets, ( arg( "node" ), arg( "degreesOfSeparation" ) = Imath::limits::max() ) ) - .def( "downstreamNodeGadgets", &downstreamNodeGadgets, ( arg( "node" ), arg( "degreesOfSeparation" ) = Imath::limits::max() ) ) - .def( "connectedNodeGadgets", &connectedNodeGadgets, ( arg( "node" ), arg( "direction" ) = Gaffer::Plug::Invalid, arg( "degreesOfSeparation" ) = Imath::limits::max() ) ) + .def( "upstreamNodeGadgets", &upstreamNodeGadgets, ( arg( "node" ), arg( "degreesOfSeparation" ) = std::numeric_limits::max() ) ) + .def( "downstreamNodeGadgets", &downstreamNodeGadgets, ( arg( "node" ), arg( "degreesOfSeparation" ) = std::numeric_limits::max() ) ) + .def( "connectedNodeGadgets", &connectedNodeGadgets, ( arg( "node" ), arg( "direction" ) = Gaffer::Plug::Invalid, arg( "degreesOfSeparation" ) = std::numeric_limits::max() ) ) .def( "unpositionedNodeGadgets", &unpositionedNodeGadgets ) .def( "setNodePosition", &setNodePosition ) .def( "getNodePosition", &GraphGadget::getNodePosition ) From 6d33bcfd0a55207e630950d819f8ccc4c7e527a1 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 14:39:28 -0500 Subject: [PATCH 040/123] Context : Don't include `unistd.h` on Windows --- src/Gaffer/Context.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gaffer/Context.cpp b/src/Gaffer/Context.cpp index 50a102d113d..b6306c4ee08 100644 --- a/src/Gaffer/Context.cpp +++ b/src/Gaffer/Context.cpp @@ -48,6 +48,7 @@ #ifdef __APPLE__ #include static char **environ = *_NSGetEnviron(); +#elif _MSC_VER #else #include #endif From 7c172a96245c6fcec5a994e44e51aeb21faf6b75 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 18 May 2018 13:06:06 -0400 Subject: [PATCH 041/123] FileSystemPath : Windows doesn't support getpwuid and getgrgid --- src/Gaffer/FileSystemPath.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Gaffer/FileSystemPath.cpp b/src/Gaffer/FileSystemPath.cpp index 38fb4a8c171..067d173b394 100644 --- a/src/Gaffer/FileSystemPath.cpp +++ b/src/Gaffer/FileSystemPath.cpp @@ -51,8 +51,11 @@ #include "boost/filesystem.hpp" #include "boost/filesystem/operations.hpp" -#include -#include +#ifndef _MSC_VER + #include + #include +#endif + #include using namespace std; @@ -188,8 +191,12 @@ IECore::ConstRunTimeTypedPtr FileSystemPath::property( const IECore::InternedStr IECore::Canceller::check( canceller ); struct stat s; stat( it->c_str(), &s ); + #ifndef _MSC_VER struct passwd *pw = getpwuid( s.st_uid ); std::string value = pw ? pw->pw_name : ""; + #else + std::string value = ""; + #endif std::pair::iterator,bool> oIt = ownerCounter.insert( std::pair( value, 0 ) ); oIt.first->second++; if( oIt.first->second > maxCount ) @@ -205,8 +212,12 @@ IECore::ConstRunTimeTypedPtr FileSystemPath::property( const IECore::InternedStr std::string n = this->string(); struct stat s; stat( n.c_str(), &s ); + #ifndef _MSC_VER struct passwd *pw = getpwuid( s.st_uid ); return new StringData( pw ? pw->pw_name : "" ); + #else + return new StringData( "" ); + #endif } else if( name == g_groupPropertyName ) { @@ -228,8 +239,12 @@ IECore::ConstRunTimeTypedPtr FileSystemPath::property( const IECore::InternedStr IECore::Canceller::check( canceller ); struct stat s; stat( it->c_str(), &s ); + #ifndef _MSC_VER struct group *gr = getgrgid( s.st_gid ); std::string value = gr ? gr->gr_name : ""; + #else + std::string value = ""; + #endif std::pair::iterator,bool> oIt = ownerCounter.insert( std::pair( value, 0 ) ); oIt.first->second++; if( oIt.first->second > maxCount ) @@ -245,8 +260,12 @@ IECore::ConstRunTimeTypedPtr FileSystemPath::property( const IECore::InternedStr std::string n = this->string(); struct stat s; stat( n.c_str(), &s ); + #ifndef _MSC_VER struct group *gr = getgrgid( s.st_gid ); return new StringData( gr ? gr->gr_name : "" ); + #else + return new StringData( "" ); + #endif } else if( name == g_modificationTimePropertyName ) { From 744c8d799f383258f30c91dff08b4dfd2f6a2c0c Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 23 Aug 2018 21:48:15 -0400 Subject: [PATCH 042/123] FileSystemPath : Leaving out symlink support on Windows (it's only available to administrators by default, and boost does not support it either), just test that the regular file is valid --- src/Gaffer/FileSystemPath.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Gaffer/FileSystemPath.cpp b/src/Gaffer/FileSystemPath.cpp index 067d173b394..2e640501703 100644 --- a/src/Gaffer/FileSystemPath.cpp +++ b/src/Gaffer/FileSystemPath.cpp @@ -104,7 +104,11 @@ bool FileSystemPath::isValid( const IECore::Canceller *canceller ) const return true; } +#ifndef _MSC_VER const file_type t = symlink_status( path( this->string() ) ).type(); +#else + const file_type t = status( path( this->string() ) ).type(); +#endif return t != status_error && t != file_not_found; } From 61b0bc259dadfac50ab914784266771e85047720 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sun, 25 Mar 2018 11:34:27 -0400 Subject: [PATCH 043/123] ScriptNode : Change readonly testing to be cross-platform --- src/Gaffer/ScriptNode.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Gaffer/ScriptNode.cpp b/src/Gaffer/ScriptNode.cpp index cc95dc68fad..cf96109cc12 100644 --- a/src/Gaffer/ScriptNode.cpp +++ b/src/Gaffer/ScriptNode.cpp @@ -59,8 +59,6 @@ #include -#include - using namespace Gaffer; ////////////////////////////////////////////////////////////////////////// @@ -969,9 +967,18 @@ void ScriptNode::plugSet( Plug *plug ) { const boost::filesystem::path fileName( fileNamePlug()->getValue() ); context()->set( g_scriptName, fileName.stem().string() ); + + bool isReadOnly = false; + if( boost::filesystem::exists( fileName ) ) + { + std::ofstream testOpen( fileName.c_str(), std::fstream::app ); + isReadOnly = !testOpen.is_open(); + testOpen.close(); + } + MetadataAlgo::setReadOnly( this, - boost::filesystem::exists( fileName ) && 0 != access( fileName.c_str(), W_OK ), + isReadOnly, /* persistent = */ false ); } From 53a26ae1a4e6c961a9b4a96756c477ddea3308f8 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 5 Aug 2019 21:05:06 -0400 Subject: [PATCH 044/123] Process : include declarations for Plug and Context MSVC is not able to cast Gaffer::Plug and Gaffer::Context to IECore::RefCounted unless their declarations are included --- include/Gaffer/Process.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Gaffer/Process.h b/include/Gaffer/Process.h index ea1d82517a3..4860a6338f0 100644 --- a/include/Gaffer/Process.h +++ b/include/Gaffer/Process.h @@ -39,6 +39,8 @@ #include "Gaffer/Export.h" #include "Gaffer/ThreadState.h" +#include "Gaffer/Plug.h" +#include "Gaffer/Context.h" #include "IECore/InternedString.h" From c0b58a1d56cecfd722b476d1e0c458c971cfa53c Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 10 Dec 2020 13:57:15 -0500 Subject: [PATCH 045/123] TypedObjectPlug : don't use "extern" on Windows - Marking variables as "extern" in MSVC generates this warning: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4910?view=msvc-160 - The "extern"s were introduced to fix a Mac error, so it is safe, and desireable, to exclude these on Windows (https://github.com/ImageEngine/cortex/commit/d6d9e783a36f07dfa1d0e67f929ec75f45cb4ab0#diff-bb99ebf651102989cbabc86eb2c276d7f986964d779a679c3541f8be14e21615) --- include/Gaffer/TypedObjectPlug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Gaffer/TypedObjectPlug.h b/include/Gaffer/TypedObjectPlug.h index d2ca647a002..c6f2d4eb931 100644 --- a/include/Gaffer/TypedObjectPlug.h +++ b/include/Gaffer/TypedObjectPlug.h @@ -120,7 +120,7 @@ class IECORE_EXPORT TypedObjectPlug : public ValuePlug }; -#ifndef Gaffer_EXPORTS +#if !defined( Gaffer_EXPORTS ) && !defined( _MSC_VER ) extern template class TypedObjectPlug; extern template class TypedObjectPlug; From 4de9c49d0bdf0a4cc8d855e98b5e38c1c34ae847 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 16:55:57 -0500 Subject: [PATCH 046/123] ValuePlug : Include MurmurHash.h --- src/Gaffer/ValuePlug.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gaffer/ValuePlug.cpp b/src/Gaffer/ValuePlug.cpp index 036b958337d..7adbf51be89 100644 --- a/src/Gaffer/ValuePlug.cpp +++ b/src/Gaffer/ValuePlug.cpp @@ -44,6 +44,7 @@ #include "Gaffer/Process.h" #include "IECore/MessageHandler.h" +#include "IECore/MurmurHash.h" #include "boost/bind.hpp" #include "boost/format.hpp" From fad58fada4aa31a4aa2ba6ff4fd82ec431d71a23 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 12 Apr 2018 10:11:45 -0400 Subject: [PATCH 047/123] GafferModule : Restrict process naming to Linux and Mac --- src/GafferModule/GafferModule.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/GafferModule/GafferModule.cpp b/src/GafferModule/GafferModule.cpp index 81e22df3800..69d1b03b559 100644 --- a/src/GafferModule/GafferModule.cpp +++ b/src/GafferModule/GafferModule.cpp @@ -107,6 +107,8 @@ bool isDebug() #endif } +#ifndef _WIN32 + int g_argc = 0; char **g_argv = nullptr; @@ -166,12 +168,15 @@ void clobberArgv() g_argv[g_argc-1] = c; memset( c, 0, end - c ); } +#endif void nameProcess() { // Some things (for instance, `ps` in default mode) look at `argv` to get // the name. +#ifndef _WIN32 clobberArgv(); +#endif // Others (for instance, `top` in default mode) use other methods. // Cater to everyone as best we can. #ifdef __linux__ From 885832d8d99d6a909af5c91b94278e2a895cdc70 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 29 Dec 2021 13:04:08 -0500 Subject: [PATCH 048/123] PathBinding : set default value to variable declared outside assignment - Fixes MSVC "error C2064: term does not evaluate to a function taking 0 arguments" at line 182 --- include/GafferBindings/PathBinding.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/GafferBindings/PathBinding.inl b/include/GafferBindings/PathBinding.inl index 3d4242bea08..f30519a39e8 100644 --- a/include/GafferBindings/PathBinding.inl +++ b/include/GafferBindings/PathBinding.inl @@ -179,7 +179,8 @@ PathClass::PathClass( const char *docString ) this->def( "isValid", &Detail::isValid, boost::python::arg( "canceller" ) = boost::python::object() ); this->def( "isLeaf", &Detail::isLeaf, boost::python::arg( "canceller" ) = boost::python::object() ); this->def( "propertyNames", &Detail::propertyNames, boost::python::arg( "canceller" ) = boost::python::object() ); - this->def( "property", &Detail::property, ( boost::python::arg( "name" ), boost::python::arg( "canceller" ) = boost::python::object() ) ); + boost::python::object o = boost::python::object(); + this->def( "property", &Detail::property, ( boost::python::arg( "name" ), boost::python::arg( "canceller" ) = o ) ); this->def( "cancellationSubject", &Detail::cancellationSubject ); // Backwards compatibility with deprecated Path.info() // method from original python implementation. From 8ca63e1d55f97daa531a6c1f2ed7341827643996 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 10 Dec 2020 16:19:35 -0500 Subject: [PATCH 049/123] TypedObjectPlugBinding : fix error when compiling on MSVC with "/permissive-" - MSVC was erroring with: include\gafferbindings\typedobjectplugbinding.inl(156): error C2064: term does not evaluate to a function taking 0 arguments --- include/GafferBindings/TypedObjectPlugBinding.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/GafferBindings/TypedObjectPlugBinding.inl b/include/GafferBindings/TypedObjectPlugBinding.inl index e48c268a491..ec2a6ad5316 100644 --- a/include/GafferBindings/TypedObjectPlugBinding.inl +++ b/include/GafferBindings/TypedObjectPlugBinding.inl @@ -143,7 +143,8 @@ TypedObjectPlugClass::TypedObjectPlugClass( const char *docString ) ); this->def( "defaultValue", &Detail::defaultValue, ( boost::python::arg_( "_copy" ) = true ) ); this->def( "setValue", Detail::setValue, ( boost::python::arg_( "value" ), boost::python::arg_( "_copy" ) = true ) ); - this->def( "getValue", Detail::getValue, ( boost::python::arg_( "_precomputedHash" ) = boost::python::object(), boost::python::arg_( "_copy" ) = true ) ); + boost::python::object b = boost::python::object(); + this->def( "getValue", Detail::getValue, ( boost::python::arg_( "_precomputedHash" ) = b, boost::python::arg_( "_copy" ) = true ) ); boost::python::scope s = *this; From 09ee11b7e10f7705e94bdc77c23d49d162077315 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 27 Dec 2017 20:59:40 -0800 Subject: [PATCH 050/123] StandardGraphLayout : 'and' to '&&' --- src/GafferUI/StandardGraphLayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GafferUI/StandardGraphLayout.cpp b/src/GafferUI/StandardGraphLayout.cpp index 28dadbbd664..9d3b1e4e7de 100644 --- a/src/GafferUI/StandardGraphLayout.cpp +++ b/src/GafferUI/StandardGraphLayout.cpp @@ -1473,7 +1473,7 @@ size_t StandardGraphLayout::unconnectedInputPlugs( NodeGadget *nodeGadget, std:: plugs.clear(); for( Plug::RecursiveInputIterator it( nodeGadget->node() ); !it.done(); it++ ) { - if( (*it)->getInput() == nullptr and nodeGadget->nodule( it->get() ) ) + if( (*it)->getInput() == nullptr && nodeGadget->nodule( it->get() ) ) { plugs.push_back( it->get() ); } From 532a65d31be9731a7b1daed6038ec932d43884ba Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Thu, 28 Dec 2017 16:58:41 -0800 Subject: [PATCH 051/123] GafferUI : :wqPython fixes/workarounds for windows --- python/GafferUI/GLWidget.py | 6 ++++-- python/GafferUI/_StyleSheet.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/GafferUI/GLWidget.py b/python/GafferUI/GLWidget.py index 9ece1f99357..806af0049fb 100644 --- a/python/GafferUI/GLWidget.py +++ b/python/GafferUI/GLWidget.py @@ -35,6 +35,7 @@ # ########################################################################## +import os import sys import logging import collections @@ -255,8 +256,9 @@ def resizeEvent( self, event ) : # clear any existing errors that may trigger # error checking code in _resize implementations. - while GL.glGetError() : - pass + if os.name == 'posix': + while GL.glGetError() : + pass owner._makeCurrent() diff --git a/python/GafferUI/_StyleSheet.py b/python/GafferUI/_StyleSheet.py index ad1c5c8889e..57da2f9c377 100644 --- a/python/GafferUI/_StyleSheet.py +++ b/python/GafferUI/_StyleSheet.py @@ -139,7 +139,7 @@ } substitutions = { - "GAFFER_ROOT" : os.environ["GAFFER_ROOT"] + "GAFFER_ROOT" : os.environ["GAFFER_ROOT"] if os.name == 'posix' else os.environ["GAFFER_ROOT"].replace("\\", "/"), } for k, v in _styleColors.items() : From 92f7604d3395d92fe79b9448e2930d78f2a7fc5d Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 10 Apr 2018 20:44:41 -0400 Subject: [PATCH 052/123] ImageWriter : Make machine name cross platform --- src/GafferImage/ImageWriter.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/GafferImage/ImageWriter.cpp b/src/GafferImage/ImageWriter.cpp index 00a2e746be9..a329d0b1914 100644 --- a/src/GafferImage/ImageWriter.cpp +++ b/src/GafferImage/ImageWriter.cpp @@ -35,6 +35,8 @@ // ////////////////////////////////////////////////////////////////////////// +#include "boost/asio/ip/host_name.hpp" + #include "GafferImage/ImageWriter.h" #include "GafferImage/BufferAlgo.h" @@ -64,7 +66,6 @@ #include -#include #include OIIO_NAMESPACE_USING @@ -1240,11 +1241,9 @@ ImageSpec createImageSpec( const ImageWriter *node, const ImageOutput *out, cons // Add common attribs to the spec std::string software = ( boost::format( "Gaffer %d.%d.%d.%d" ) % GAFFER_MILESTONE_VERSION % GAFFER_MAJOR_VERSION % GAFFER_MINOR_VERSION % GAFFER_PATCH_VERSION ).str(); spec.attribute( "Software", software ); - struct utsname info; - if ( !uname( &info ) ) - { - spec.attribute( "HostComputer", info.nodename ); - } + + spec.attribute( "HostComputer", boost::asio::ip::host_name() ); + if ( const char *artist = getenv( "USER" ) ) { spec.attribute( "Artist", artist ); From daf453c7cbab0c20b9ed91bddca4dc13e0dc6bda Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 22 May 2018 19:57:19 -0400 Subject: [PATCH 053/123] BufferAlgo : MSVC needs to find std::min and std::max --- include/GafferImage/BufferAlgo.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/GafferImage/BufferAlgo.inl b/include/GafferImage/BufferAlgo.inl index 1a42407226e..b67be3c147d 100644 --- a/include/GafferImage/BufferAlgo.inl +++ b/include/GafferImage/BufferAlgo.inl @@ -38,6 +38,7 @@ #define GAFFERIMAGE_BUFFERALGO_INL #include +#include namespace GafferImage { From ae9676f5a152958f600f8dc1fabddeb1e6372d36 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 29 Dec 2021 13:06:02 -0500 Subject: [PATCH 054/123] Text : undefine `SearchPath` - Windows defines `SearchPath`. We undefine it in `IECore::SearchPath` but an update to TBB includes the definition via `tbb/enumerable_thread_specific.h` --- src/GafferImage/Text.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/GafferImage/Text.cpp b/src/GafferImage/Text.cpp index 9bf8ce7fe82..c6ecdef8edd 100644 --- a/src/GafferImage/Text.cpp +++ b/src/GafferImage/Text.cpp @@ -45,6 +45,9 @@ #include "IECore/SearchPath.h" #include "tbb/enumerable_thread_specific.h" +#ifdef SearchPath +#undef SearchPath +#endif #include "boost/locale/encoding_utf.hpp" From ce783d5d6c8251e0c6ea14d97baf11c0c866877e Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 12 Apr 2018 20:18:35 -0400 Subject: [PATCH 055/123] GafferImageModule : MSVC needs boost namespace specified error C2872: 'list': ambiguous symbol 'std::list': class has no constructors 'boost::python::ssize_t boost::python::len(const boost::python::api::object &)': cannot convert argument 1 from 'std::list' to 'const boost::python::api::object &' binary '[': 'std::list' does not define this operator or a conversion to a type acceptable to the predefined operator 'arg': ambiguous symbol 'std::arg': no matching overloaded function found '_Promote_to_float<_Ty>::type std::arg(_Ty)': could not deduce template argument for '' '_Ty std::arg(const std::complex<_Other> &)': could not deduce template argument for 'const std::complex<_Other> &' from 'const char [5]' '_Ty std::arg(const std::complex<_Other> &)': could not deduce template argument for 'const std::complex<_Other> &' from 'const char [10]' '_Ty std::arg(const std::complex<_Other> &)': could not deduce template argument for 'const std::complex<_Other> &' from 'const char [6]' --- src/GafferImageModule/CatalogueBinding.cpp | 2 +- src/GafferImageModule/CoreBinding.cpp | 10 +++++----- src/GafferImageModule/FilterAlgoBinding.cpp | 4 ++-- src/GafferImageModule/ImageProcessorBinding.cpp | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/GafferImageModule/CatalogueBinding.cpp b/src/GafferImageModule/CatalogueBinding.cpp index a172537b6fe..1c33c3ba10b 100644 --- a/src/GafferImageModule/CatalogueBinding.cpp +++ b/src/GafferImageModule/CatalogueBinding.cpp @@ -126,7 +126,7 @@ void GafferImageModule::bindCatalogue() { scope s = GafferBindings::DependencyNodeClass() - .def( "setDriver", &Display::setDriver, ( arg( "driver" ), arg( "copy" ) = false ) ) + .def( "setDriver", &Display::setDriver, ( boost::python::arg_( "driver" ), boost::python::arg_( "copy" ) = false ) ) .def( "getDriver", (IECoreImage::DisplayDriver *(Display::*)())&Display::getDriver, return_value_policy() ) .def( "driverCreatedSignal", &Display::driverCreatedSignal, return_value_policy() ).staticmethod( "driverCreatedSignal" ) .def( "imageReceivedSignal", &Display::imageReceivedSignal, return_value_policy() ).staticmethod( "imageReceivedSignal" ) diff --git a/src/GafferImageModule/CoreBinding.cpp b/src/GafferImageModule/CoreBinding.cpp index a1397229d06..799443c4dcc 100644 --- a/src/GafferImageModule/CoreBinding.cpp +++ b/src/GafferImageModule/CoreBinding.cpp @@ -275,13 +275,13 @@ void GafferImageModule::bindCore() init< const std::string &, Gaffer::Plug::Direction, unsigned > ( ( - arg( "name" ) = Gaffer::GraphComponent::defaultName(), - arg( "direction" ) = Gaffer::Plug::In, - arg( "flags" ) = Gaffer::Plug::Default + boost::python::arg_( "name" ) = Gaffer::GraphComponent::defaultName(), + boost::python::arg_( "direction" ) = Gaffer::Plug::In, + boost::python::arg_( "flags" ) = Gaffer::Plug::Default ) ) ) - .def( "channelData", &channelData, ( arg( "_copy" ) = true ) ) + .def( "channelData", &channelData, ( boost::python::arg_( "_copy" ) = true ) ) .def( "channelDataHash", &channelDataHash ) .def( "format", &format ) .def( "formatHash", &formatHash ) @@ -413,7 +413,7 @@ void GafferImageModule::bindCore() init ( ( - arg( "boundingMode" ) = Sampler::Black + boost::python::arg_( "boundingMode" ) = Sampler::Black ) ) ) diff --git a/src/GafferImageModule/FilterAlgoBinding.cpp b/src/GafferImageModule/FilterAlgoBinding.cpp index 4dd87d6062f..fa8f9e7c94f 100644 --- a/src/GafferImageModule/FilterAlgoBinding.cpp +++ b/src/GafferImageModule/FilterAlgoBinding.cpp @@ -55,9 +55,9 @@ namespace return GafferImage::FilterAlgo::sampleParallelogram( sampler, p, dpdx, dpdy, f ); } - list filterNamesWrapper() + boost::python::list filterNamesWrapper() { - list result; + boost::python::list result; const std::vector &filters = GafferImage::FilterAlgo::filterNames(); for ( unsigned i=0; i < filters.size(); i++ ) { diff --git a/src/GafferImageModule/ImageProcessorBinding.cpp b/src/GafferImageModule/ImageProcessorBinding.cpp index 391b34f807c..e9f18125fe6 100644 --- a/src/GafferImageModule/ImageProcessorBinding.cpp +++ b/src/GafferImageModule/ImageProcessorBinding.cpp @@ -64,9 +64,9 @@ void GafferImageModule::bindImageProcessor() GafferBindings::DependencyNodeClass() .def( init( ( - arg( "name" ) = GraphComponent::defaultName(), - arg( "minInputs" ), - arg( "maxInputs" ) = std::numeric_limits::max() + boost::python::arg_( "name" ) = GraphComponent::defaultName(), + boost::python::arg_( "minInputs" ), + boost::python::arg_( "maxInputs" ) = std::numeric_limits::max() ) ) ) From 671ae8d33aa042f0909e5548d2cf927ed8f1c841 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 27 Dec 2017 21:00:19 -0800 Subject: [PATCH 056/123] ImageGadget : Public/private workaround for MSVC error C2248: 'GafferImageUI::ImageGadget::TileIndex': cannot access private struct declared in class 'GafferImageUI::ImageGadget' --- include/GafferImageUI/ImageGadget.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/GafferImageUI/ImageGadget.h b/include/GafferImageUI/ImageGadget.h index 9c23075e07a..c883b8279a7 100644 --- a/include/GafferImageUI/ImageGadget.h +++ b/include/GafferImageUI/ImageGadget.h @@ -246,6 +246,7 @@ class GAFFERIMAGEUI_API ImageGadget : public GafferUI::Gadget // be inserted/updated in parallel in a multithreaded // update step. + public: struct TileIndex { TileIndex( const Imath::V2i &tileOrigin, IECore::InternedString channelName ) @@ -277,6 +278,7 @@ class GAFFERIMAGEUI_API ImageGadget : public GafferUI::Gadget IECore::InternedString channelName; }; + private: struct Tile { From 12c94eae70926a711b6f83e4829017d5a1c83231 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Wed, 27 Dec 2017 21:00:01 -0800 Subject: [PATCH 057/123] Context : undefine `near` and `far` on Windows --- src/GafferSceneUI/CameraVisualiser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/GafferSceneUI/CameraVisualiser.cpp b/src/GafferSceneUI/CameraVisualiser.cpp index 9e0d6e75f6c..f86c9402304 100644 --- a/src/GafferSceneUI/CameraVisualiser.cpp +++ b/src/GafferSceneUI/CameraVisualiser.cpp @@ -44,6 +44,15 @@ #include "IECore/AngleConversion.h" #include "IECore/SimpleTypedData.h" +#ifdef _MSC_VER +#ifdef near +#undef near +#endif +#ifdef far +#undef far +#endif +#endif + using namespace std; using namespace Imath; using namespace IECoreGLPreview; From cfbd0963535c5489e9599b7107c5a3b9fd1aa188 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 29 Dec 2021 14:18:38 -0500 Subject: [PATCH 058/123] SceneView : add default name to plugs for setting up attribute queries - Works around MSVC bug : k:\build\gaffer\include\gaffer\numericplug.h(60): fatal error C1001: An internal error has occurred in the compiler. (compiler file 'msc1.cpp', line 1518) To work around this problem, try simplifying or changing the program near the locations listed above. Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information Internal Compiler Error in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe. You will be prompted to send an error report to Microsoft later. INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe' --- src/GafferSceneUI/SceneView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GafferSceneUI/SceneView.cpp b/src/GafferSceneUI/SceneView.cpp index 11e7da044f5..e351bbe0f02 100644 --- a/src/GafferSceneUI/SceneView.cpp +++ b/src/GafferSceneUI/SceneView.cpp @@ -1095,12 +1095,12 @@ class SceneView::Camera : public boost::signals::trackable lightFilter->setExpressionPlug()->setValue( "__lights" ); m_distantApertureAttributeQuery->scenePlug()->setInput( view->inPlug() ); - FloatPlugPtr defaultFloatPlug = new Gaffer::FloatPlug(); + FloatPlugPtr defaultFloatPlug = new Gaffer::FloatPlug( "defaultFloatPlug" ); m_distantApertureAttributeQuery->setup( defaultFloatPlug.get() ); m_distantApertureAttributeQuery->attributePlug()->setValue( "gl:light:lookThroughAperture" ); m_distantApertureAttributeQuery->defaultPlug()->setInput( lightLookThroughDefaultDistantAperturePlug() ); m_clippingPlanesAttributeQuery->scenePlug()->setInput( view->inPlug() ); - V2fPlugPtr defaultV2fPlug = new Gaffer::V2fPlug(); + V2fPlugPtr defaultV2fPlug = new Gaffer::V2fPlug( "defaultV2fPlug" ); m_clippingPlanesAttributeQuery->setup( defaultV2fPlug.get() ); m_clippingPlanesAttributeQuery->attributePlug()->setValue( "gl:light:lookThroughClippingPlanes" ); m_clippingPlanesAttributeQuery->defaultPlug()->setInput( lightLookThroughDefaultClippingPlanesPlug() ); From 172b49793c6677921622bc29297ffb57bcbe47cc Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 14:56:59 -0500 Subject: [PATCH 059/123] GafferOSLModule : MSVC needs `boost::python` namespace specified --- src/GafferOSLModule/GafferOSLModule.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/GafferOSLModule/GafferOSLModule.cpp b/src/GafferOSLModule/GafferOSLModule.cpp index d2d52b8ceab..3bda0806620 100644 --- a/src/GafferOSLModule/GafferOSLModule.cpp +++ b/src/GafferOSLModule/GafferOSLModule.cpp @@ -113,8 +113,8 @@ IECore::CompoundDataPtr shadeWrapper( ShadingEngine &shadingEngine, const IECore { ShadingEngine::Transforms transforms; - list values = pythonTransforms.values(); - list keys = pythonTransforms.keys(); + boost::python::list values = pythonTransforms.values(); + boost::python::list keys = pythonTransforms.keys(); for (int i = 0; i < boost::python::len( keys ); i++) { @@ -169,9 +169,9 @@ BOOST_PYTHON_MODULE( _GafferOSL ) PlugClass() .def( init( ( - arg( "name" ) = Gaffer::GraphComponent::defaultName(), - arg( "direction" ) = Gaffer::Plug::In, - arg( "flags" ) = Gaffer::Plug::Default + boost::python::arg( "name" ) = Gaffer::GraphComponent::defaultName(), + boost::python::arg( "direction" ) = Gaffer::Plug::In, + boost::python::arg( "flags" ) = Gaffer::Plug::Default ) ) ) From c3903d6f9f4df56b4b10eb35ca69b6e22ef8b798 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 18 May 2018 15:16:56 -0400 Subject: [PATCH 060/123] GafferDispatch : On Windows filename().c_str() is a wchar_t so we need an extra conversion to solve the error: error C2664: 'long strtol(const char *,char **,int)': cannot convert argument 1 from 'const boost::filesystem::path::value_type *' to 'const char *' --- src/GafferDispatch/Dispatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GafferDispatch/Dispatcher.cpp b/src/GafferDispatch/Dispatcher.cpp index 44888ee6c53..6e63b27c6fd 100644 --- a/src/GafferDispatch/Dispatcher.cpp +++ b/src/GafferDispatch/Dispatcher.cpp @@ -227,7 +227,7 @@ void Dispatcher::createJobDirectory( const Gaffer::ScriptNode *script, Gaffer::C long i = -1; for( const auto &d : boost::filesystem::directory_iterator( jobDirectory ) ) { - i = std::max( i, strtol( d.path().filename().c_str(), nullptr, 10 ) ); + i = std::max( i, strtol( d.path().filename().string().c_str(), nullptr, 10 ) ); } // Now create the next directory. We do this in a loop until we From 6cb705ca936d86c52541f36712e2661ed0d3e30c Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 3 Aug 2018 12:05:51 -0400 Subject: [PATCH 061/123] LocalDispatcher : Windows subprocess.Popen doesn't support start_new_session --- python/GafferDispatch/LocalDispatcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/GafferDispatch/LocalDispatcher.py b/python/GafferDispatch/LocalDispatcher.py index 6806af4f936..5bbbdb1aa98 100644 --- a/python/GafferDispatch/LocalDispatcher.py +++ b/python/GafferDispatch/LocalDispatcher.py @@ -281,7 +281,10 @@ def __doBackgroundDispatch( self, batch ) : self.__setStatus( batch, LocalDispatcher.Job.Status.Running ) IECore.msg( IECore.MessageHandler.Level.Info, self.__messageTitle, " ".join( args ) ) - process = subprocess.Popen( args, start_new_session=True ) + if os.name == "nt": + process = subprocess.Popen( args ) + else: + process = subprocess.Popen( args, start_new_session=True ) batch.blindData()["pid"] = IECore.IntData( process.pid ) while process.poll() is None : From 05a18e5d43d93426ad0d40df36c65c2caa1c8d91 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 6 Aug 2019 13:28:58 -0400 Subject: [PATCH 062/123] IECoreArnoldPreview : MSVC can't compare IECore::InternedString to std::string directly --- src/IECoreArnold/Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IECoreArnold/Renderer.cpp b/src/IECoreArnold/Renderer.cpp index 3e935d97d32..2214c5f211d 100644 --- a/src/IECoreArnold/Renderer.cpp +++ b/src/IECoreArnold/Renderer.cpp @@ -955,7 +955,7 @@ class ArnoldAttributes : public IECoreScenePreview::Renderer::AttributesInterfac } } - if( it->first.string() == g_arnoldLightFilterShaderAttributeName ) + if( it->first.string() == g_arnoldLightFilterShaderAttributeName.string() ) { continue; } From a310ac9f3e8a3c1df397765a3e3fb22e34cd4675 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 24 Sep 2021 11:13:32 -0400 Subject: [PATCH 063/123] ParameterHandler : set default M44fPlug value --- src/GafferArnold/ParameterHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GafferArnold/ParameterHandler.cpp b/src/GafferArnold/ParameterHandler.cpp index 6c766040ddc..50114354f15 100644 --- a/src/GafferArnold/ParameterHandler.cpp +++ b/src/GafferArnold/ParameterHandler.cpp @@ -338,7 +338,7 @@ Gaffer::Plug *ParameterHandler::setupPlug( const IECore::InternedString ¶met case AI_TYPE_MATRIX : - return setupTypedPlug( parameterName, plugParent, direction, false ); + return setupTypedPlug( parameterName, plugParent, direction, M44f() ); default : From 94a0aa738ad527053df1d3d7aeb178afbffd6df7 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 22 Jun 2021 17:05:06 -0400 Subject: [PATCH 064/123] FormatData : define type description in Format.cpp instead of FormatData.cpp IS THIS NEEDED AFTER CORTEX FIX? - Including Context.h and TypedData.inl causes problems with explicit template instantiation --- src/GafferImage/Format.cpp | 5 +++++ src/GafferImage/FormatData.cpp | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/GafferImage/Format.cpp b/src/GafferImage/Format.cpp index 2a9e78ba752..b7be4c97ea2 100644 --- a/src/GafferImage/Format.cpp +++ b/src/GafferImage/Format.cpp @@ -35,6 +35,9 @@ ////////////////////////////////////////////////////////////////////////// #include "GafferImage/Format.h" +#include "GafferImage/FormatData.h" + +#include "Gaffer/Context.h" #include @@ -43,6 +46,8 @@ using namespace GafferImage; namespace { +Gaffer::Context::TypeDescription g_formatDataTypeDescription; + typedef std::map FormatMap; FormatMap &formatMap() diff --git a/src/GafferImage/FormatData.cpp b/src/GafferImage/FormatData.cpp index ab5c604da99..ea39d71e63d 100644 --- a/src/GafferImage/FormatData.cpp +++ b/src/GafferImage/FormatData.cpp @@ -39,20 +39,11 @@ #include "GafferImage/Export.h" #include "GafferImage/TypeIds.h" -#include "Gaffer/Context.h" - #include "IECore/TypedData.h" #include "IECore/TypedData.inl" using namespace Imath; -namespace -{ - -Gaffer::Context::TypeDescription g_formatDataTypeDescription; - -} // namespace - namespace IECore { From 403f1c05ae09137d4c7d597a419aafaea7e91505 Mon Sep 17 00:00:00 2001 From: Alex Fuller Date: Thu, 28 Dec 2017 16:57:17 -0800 Subject: [PATCH 065/123] gaffer.bat : Add Windows launch script - Default `GAFFER_JEMALLOC` to disabled because JEMalloc is not stable on Windows until 5.x versions. - Disable Appleseed because it is not currently working on Gaffer for Windows. --- bin/gaffer.bat | 153 +++++++++++++++++++++++ python/GafferDispatch/LocalDispatcher.py | 5 +- 2 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 bin/gaffer.bat diff --git a/bin/gaffer.bat b/bin/gaffer.bat new file mode 100644 index 00000000000..e22bb866277 --- /dev/null +++ b/bin/gaffer.bat @@ -0,0 +1,153 @@ +@echo off + +setlocal EnableDelayedExpansion + +set GAFFER_ROOT=%~dp0%.. + +set HOME=%USERPROFILE% + +set GAFFER_JEMALLOC=0 + +call :prependToPath "%GAFFER_ROOT%\glsl" IECOREGL_SHADER_PATHS +call :prependToPath "%GAFFER_ROOT%\glsl" IECOREGL_SHADER_INCLUDE_PATHS + +call :prependToPath "%GAFFER_ROOT%\fonts" IECORE_FONT_PATHS +call :prependToPath "%GAFFER_ROOT%\ops" IECORE_OP_PATHS + +call :prependToPath "%USERPROFILE%\gaffer\opPresets;%GAFFER_ROOT%\opPresets" IECORE_OP_PRESET_PATHS +call :prependToPath "%USERPROFILE%\gaffer\procedurals;%GAFFER_ROOT%\procedurals" IECORE_PROCEDURAL_PATHS +call :prependToPath "%USERPROFILE%\gaffer\proceduralPresets;%GAFFER_ROOT%\proceduralPresets" IECORE_PROCEDURAL_PRESET_PATHS + +set CORTEX_POINTDISTRIBUTION_TILESET=%GAFFER_ROOT%\resources\cortex\tileset_2048.dat + +call :prependToPath "%USERPROFILE%\gaffer\apps;%GAFFER_ROOT%\apps" GAFFER_APP_PATHS + +call :prependToPath "%USERPROFILE%\gaffer\startup" GAFFER_STARTUP_PATHS +call :appendToPath "%GAFFER_ROOT%\startup" GAFFER_STARTUP_PATHS + +call :prependToPath "%GAFFER_ROOT%\graphics" GAFFERUI_IMAGE_PATHS + +set OSLHOME=%GAFFER_ROOT% + +call :prependToPath "%USERPROFILE%\gaffer\shaders;%GAFFER_ROOT%\shaders" OSL_SHADER_PATHS + +set GAFFEROSL_CODE_DIRECTORY=%USERPROFILE%\gaffer\oslCode +call :prependToPath "%GAFFER_OSL_CODE_DIRECTORY%" PATH + +set PYTHONHOME=%GAFFER_ROOT% + +call :prependToPath "%GAFFER_ROOT%\python" PYTHONPATH + +call :prependToPath "%GAFFER_ROOT%\lib" PATH + +set QT_OPENGL=desktop +set QT_QPA_PLATFORM_PLUGIN_PATH=%GAFFER_ROOT%\qt\plugins + +call :prependToPath "%GAFFER_ROOT%\bin" PATH + +rem Appleseed +rem if "%APPLESEED%" == "" ( +rem if EXIST "%GAFFER_ROOT%"\appleseed ( +rem set APPLESEED=%GAFFER_ROOT%\appleseed +rem ) +rem ) + +rem if "%APPLESEED%" NEQ "" ( +rem call :prependToPath "%APPLESEED%\shaders\gaffer" OSL_SHADER_PATHS +rem call :prependToPath "%APPLESEED%\shaders\appleseed" OSL_SHADER_PATHS +rem ) + +rem if "%APPLESEED%" NEQ "" ( +rem call :prependToPath "%APPLESEED%\bin;%APPLESEED%\lib" PATH +rem call :prependToPath "%APPLESEED%\lib\python2.7" PYTHONPATH +rem call :prependToPath "%OSL_SHADER_PATHS%;%GAFFER_ROOT%\appleseedDisplays" APPLESEED_SEARCHPATH +rem ) + +rem Arnold +if "%ARNOLD_ROOT%" NEQ "" ( + call :appendToPath "%ARNOLD_ROOT%\bin" PATH + call :appendToPath "%ARNOLD_ROOT%\python" PYTHONPATH + + if exist "%ARNOLD_ROOT%\include\ai_version.h" ( + for /f "tokens=3" %%A in ('findstr /R /C:"#define *AI_VERSION_ARCH_NUM" "%ARNOLD_ROOT%\include\ai_version.h"') do ( + set ARNOLD_ARCH_NUM=%%A + ) + for /f "tokens=3" %%A in ('findstr /R /C:"#define *AI_VERSION_MAJOR_NUM" "%ARNOLD_ROOT%\include\ai_version.h"') do ( + set ARNOLD_VERSION_NUM=%%A + ) + + set ARNOLD_VERSION=!ARNOLD_ARCH_NUM!.!ARNOLD_VERSION_NUM! + if exist "%GAFFER_ROOT%\arnold\%ARNOLD_VERSION%" ( + call :prependToPath "%GAFFER_ROOT%\arnold\!ARNOLD_VERSION!" GAFFER_EXTENSION_PATHS + call :prependToPath "%GAFFER_ROOT%\arnold\!ARNOLD_VERSION!\arnoldPlugins" ARNOLD_PLUGIN_PATH + call :prependToPath "%ARNOLD_ROOT%\plugins" ARNOLD_PLUGIN_PATH + ) else ( + echo WARNING : GafferArnold extension not available for Arnold %ARNOLD_VERSION% + ) + ) else ( + echo WARNING : Unable to determine Arnold version + ) +) + +rem 3Delight +if "%DELIGHT%" NEQ "" ( + call :appendToPath "%DELIGHT%\bin" PATH + call :appendToPath "%DELIGHT%\python" PYTHONPATH + call :appendToPath "%DELIGHT%\shaders" DL_SHADERS_PATH + call :appendToPath "%DELIGHT%\displays" DL_DISPLAYS_PATH + + call :appendToPath "%DELIGHT%" OSL_SHADER_PATHS + + call :appendToPath "%GAFFER_ROOT%\renderMan\displayDrivers" DL_RESOURCES_PATH +) + +rem Set up 3rd party extensions +rem Batch files are awkward at `for` loops. The default `for`, without `/f` +rem uses semi-colons AND spaces as delimiters, meaning we would not be able +rem to support spaces in extension paths. Bad. Using the `/f` switch lets +rem us specify the delimiter, but it then separates the tokens into a +rem set number that must be known ahead of time (i.e. %%A, %%B, etc.). +rem The accepted pattern seems to be to use recursion to pop the first token +rem then recurse through the remaining tokens until there are none left. + +set EXTENSION_PATH=%GAFFER_EXTENSION_PATHS% +:NextPath +for /f "tokens=1* delims=;" %%A in ("%EXTENSION_PATH%") do ( + if "%%A" NEQ "" ( + call :appendToPath "%%A\bin" PATH + call :appendToPath "%%A\lib" PATH + call :appendToPath "%%A\python" PYTHONPATH + call :appendToPath "%%A\apps" GAFFER_APP_PATHS + call :appendToPath "%%A\graphics" GAFFERUI_IMAGE_PATHS + call :appendToPath "%%A\glsl" IECOREGL_SHADER_PATHS + call :appendToPath "%%A\glsl" IECOREGL_SHADER_INCLUDE_PATHS + call :appendToPath "%%A\shaders" OSL_SHADER_PATHS + call :prependToPath "%%A\startup" GAFFER_STARTUP_PATHS + ) + if "%%B" NEQ "" ( + set EXTENSION_PATH=%%B + goto :NextPath + ) +) + +if "%GAFFER_DEBUG%" NEQ "" ( + %GAFFER_DEBUGGER% /debugexe "%GAFFER_ROOT%\bin\python.exe" "%GAFFER_ROOT%"/bin/__gaffer.py %* +) else ( + "%GAFFER_ROOT%"\bin\python.exe "%GAFFER_ROOT%"/bin/__gaffer.py %* +) + +if %ERRORLEVEL% NEQ 0 ( + echo "Error(s) running Gaffer" + exit /B %ERRORLEVEL% +) + +ENDLOCAL +exit /B 0 + +:prependToPath + set "%~2=%~1;!%~2!" + exit /B 0 + +:appendToPath + set "%~2=!%~2!;%~1" + exit /B 0 \ No newline at end of file diff --git a/python/GafferDispatch/LocalDispatcher.py b/python/GafferDispatch/LocalDispatcher.py index 5bbbdb1aa98..3d5a67a73c9 100644 --- a/python/GafferDispatch/LocalDispatcher.py +++ b/python/GafferDispatch/LocalDispatcher.py @@ -259,8 +259,9 @@ def __doBackgroundDispatch( self, batch ) : taskContext = batch.context() frames = str( IECore.frameListFromList( [ int(x) for x in batch.frames() ] ) ) - args = [ - "gaffer", "execute", + args = [ "gaffer.bat" ] if os.name == "nt" else [ "gaffer" ] + args = args + [ + "execute", "-script", self.__scriptFile, "-nodes", batch.blindData()["nodeName"].value, "-frames", frames, From 904829a8c5f6d9a9b4a4c75ffe2e8fec11e988e1 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 17:45:21 -0400 Subject: [PATCH 066/123] SConstruct : install Gaffer batch file for Windows --- SConstruct | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SConstruct b/SConstruct index a3f9b9f9e49..94d911e4422 100644 --- a/SConstruct +++ b/SConstruct @@ -1216,6 +1216,10 @@ libraries = { } +if env["PLATFORM"] == "win32" : + libraries["scripts"]["additionalFiles"].append( "bin/gaffer.bat" ) + + # Add on OpenGL libraries to definitions - these vary from platform to platform for library in ( "GafferUI", "GafferScene", "GafferSceneUI", "GafferImageUI" ) : if env["PLATFORM"] == "darwin" : From e1e1b1dd64e3abedc9068ea94be9d387a1b77ab9 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 12 Apr 2018 22:35:20 -0400 Subject: [PATCH 067/123] GafferOSLTest : Make PATH separators cross-platform --- python/GafferOSLTest/OSLTestCase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/GafferOSLTest/OSLTestCase.py b/python/GafferOSLTest/OSLTestCase.py index 93beb96495a..59b3214947e 100644 --- a/python/GafferOSLTest/OSLTestCase.py +++ b/python/GafferOSLTest/OSLTestCase.py @@ -47,7 +47,7 @@ def compileShader( self, sourceFileName ) : subprocess.check_call( [ "oslc", "-q" ] + - [ "-I" + p for p in os.environ.get( "OSL_SHADER_PATHS", "" ).split( ":" ) ] + + [ "-I" + p for p in os.environ.get( "OSL_SHADER_PATHS", "" ).split( os.pathsep ) ] + [ "-o", outputFileName, sourceFileName ] ) From 866e445c53e5bd13c43b3d93d2b114bd8547dfda Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 14:42:45 -0500 Subject: [PATCH 068/123] GafferArnoldTest : Make PATH separators cross-platform --- python/GafferArnoldTest/ArnoldShaderTest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/GafferArnoldTest/ArnoldShaderTest.py b/python/GafferArnoldTest/ArnoldShaderTest.py index 7bb4acde32d..481debc7ab7 100644 --- a/python/GafferArnoldTest/ArnoldShaderTest.py +++ b/python/GafferArnoldTest/ArnoldShaderTest.py @@ -59,10 +59,10 @@ def withMetadata( func ) : def wrapper( self ) : metadataPath = os.path.join( os.path.dirname( __file__ ), "metadata" ) - if metadataPath not in os.environ["ARNOLD_PLUGIN_PATH"].split( ":" ) : + if metadataPath not in os.environ["ARNOLD_PLUGIN_PATH"].split( os.pathsep ) : env = os.environ.copy() - env["ARNOLD_PLUGIN_PATH"] = env["ARNOLD_PLUGIN_PATH"] + ":" + metadataPath + env["ARNOLD_PLUGIN_PATH"] = env["ARNOLD_PLUGIN_PATH"] + os.pathsep + metadataPath try : subprocess.check_output( From 197a29bee03734b0d4eaef28617c14aab96bc2a7 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 18 Jul 2018 15:17:14 -0400 Subject: [PATCH 069/123] GafferArnold : setdlopenflags is not available on windows --- python/GafferArnold/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python/GafferArnold/__init__.py b/python/GafferArnold/__init__.py index 0fe758bb220..49183be131c 100644 --- a/python/GafferArnold/__init__.py +++ b/python/GafferArnold/__init__.py @@ -49,15 +49,19 @@ import sys import ctypes - originalDLOpenFlags = sys.getdlopenflags() - sys.setdlopenflags( originalDLOpenFlags & ~ctypes.RTLD_GLOBAL ) + import os + + if os.name == "posix": + originalDLOpenFlags = sys.getdlopenflags() + sys.setdlopenflags( originalDLOpenFlags & ~ctypes.RTLD_GLOBAL ) from ._GafferArnold import * finally : - sys.setdlopenflags( originalDLOpenFlags ) - del sys, ctypes, originalDLOpenFlags + if os.name == "posix": + sys.setdlopenflags( originalDLOpenFlags ) + del sys, ctypes, originalDLOpenFlags from .ArnoldShaderBall import ArnoldShaderBall from .ArnoldTextureBake import ArnoldTextureBake From 7fac9fd97ddbb9a19e9145648420bbadd05effb8 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 18 Jul 2018 19:04:31 -0400 Subject: [PATCH 070/123] GafferDispatchTest : use `subprocess` on Windows - Per recommended usage of subprocess32: https://github.com/google/python-subprocess32 --- python/GafferDispatchTest/StatsApplicationTest.py | 7 ++++++- python/GafferDispatchTest/SystemCommandTest.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/python/GafferDispatchTest/StatsApplicationTest.py b/python/GafferDispatchTest/StatsApplicationTest.py index 8571a6fa4c0..d17dd81e783 100644 --- a/python/GafferDispatchTest/StatsApplicationTest.py +++ b/python/GafferDispatchTest/StatsApplicationTest.py @@ -36,7 +36,12 @@ import inspect import unittest -import subprocess32 as subprocess +import os +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import Gaffer import GafferTest diff --git a/python/GafferDispatchTest/SystemCommandTest.py b/python/GafferDispatchTest/SystemCommandTest.py index 0405efddb52..725b90b9362 100644 --- a/python/GafferDispatchTest/SystemCommandTest.py +++ b/python/GafferDispatchTest/SystemCommandTest.py @@ -35,7 +35,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import unittest import IECore From b15ceb153a8a579988acf42541ff22301014ebe0 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 15:10:05 -0500 Subject: [PATCH 071/123] GafferAppleseedTest : use `subprocess` on Windows` - Per recommended usage of subprocess32: https://github.com/google/python-subprocess32 --- python/GafferAppleseedTest/AppleseedTest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/GafferAppleseedTest/AppleseedTest.py b/python/GafferAppleseedTest/AppleseedTest.py index aa2cb1090bb..86598bbca53 100644 --- a/python/GafferAppleseedTest/AppleseedTest.py +++ b/python/GafferAppleseedTest/AppleseedTest.py @@ -35,7 +35,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess def appleseedProjectSchemaPath(): From 92e6ba16fd8372c9f71ab60eeb3f12e4f65ce0ec Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 15:09:38 -0500 Subject: [PATCH 072/123] GafferDispatch : use `subprocess` on Windows - Per recommended usage of subprocess32: https://github.com/google/python-subprocess32 --- python/GafferDispatch/LocalDispatcher.py | 6 +++++- python/GafferDispatch/SystemCommand.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/python/GafferDispatch/LocalDispatcher.py b/python/GafferDispatch/LocalDispatcher.py index 3d5a67a73c9..85d81718317 100644 --- a/python/GafferDispatch/LocalDispatcher.py +++ b/python/GafferDispatch/LocalDispatcher.py @@ -38,7 +38,11 @@ import errno import signal import shlex -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import threading import time import traceback diff --git a/python/GafferDispatch/SystemCommand.py b/python/GafferDispatch/SystemCommand.py index c77fc934b12..526e9e12258 100644 --- a/python/GafferDispatch/SystemCommand.py +++ b/python/GafferDispatch/SystemCommand.py @@ -36,7 +36,11 @@ import os import shlex -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import IECore From 32f1070c1f362848a9cfe95de8aa126911484abc Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 22 Aug 2018 22:11:58 -0400 Subject: [PATCH 073/123] FileSystemPath : add nativeString function - Returns the path value in OS-specific format. --- include/Gaffer/FileSystemPath.h | 3 ++ python/GafferTest/FileSystemPathTest.py | 43 +++++++++++++++++++------ src/Gaffer/FileSystemPath.cpp | 21 ++++++++++++ src/GafferModule/PathBinding.cpp | 1 + 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/include/Gaffer/FileSystemPath.h b/include/Gaffer/FileSystemPath.h index b3d972fe187..443ffbfb22a 100644 --- a/include/Gaffer/FileSystemPath.h +++ b/include/Gaffer/FileSystemPath.h @@ -82,6 +82,9 @@ class GAFFER_API FileSystemPath : public Path // a FileSequence. IECore::FileSequencePtr fileSequence() const; + // Returns the path converted to the OS native format + std::string nativeString() const; + static PathFilterPtr createStandardFilter( const std::vector &extensions = std::vector(), const std::string &extensionsLabel = "", bool includeSequenceFilter = false ); protected : diff --git a/python/GafferTest/FileSystemPathTest.py b/python/GafferTest/FileSystemPathTest.py index 82147dcf327..05612d52728 100644 --- a/python/GafferTest/FileSystemPathTest.py +++ b/python/GafferTest/FileSystemPathTest.py @@ -121,11 +121,13 @@ def testCopy( self ) : self.assertEqual( p, p2 ) self.assertEqual( str( p ), str( p2 ) ) + self.assertEqual( p.nativeString(), p2.nativeString() ) def testEmptyPath( self ) : p = Gaffer.FileSystemPath() self.assertEqual( str( p ), "" ) + self.assertEqual( p.nativeString(), "" ) self.assertTrue( p.isEmpty() ) self.assertFalse( p.isValid() ) @@ -139,12 +141,14 @@ def testRelativePath( self ) : p = Gaffer.FileSystemPath( "a" ) self.assertEqual( str( p ), "a" ) + self.assertEqual( p.nativeString(), "a" ) self.assertFalse( p.isEmpty() ) self.assertTrue( p.isValid() ) p2 = Gaffer.FileSystemPath( "nonexistent" ) self.assertEqual( str( p2 ), "nonexistent" ) + self.assertEqual( p2.nativeString(), "nonexistent" ) self.assertFalse( p2.isEmpty() ) self.assertFalse( p2.isValid() ) @@ -160,6 +164,10 @@ def testRelativePathChildren( self ) : c = p.children() self.assertEqual( len( c ), 1 ) self.assertEqual( str( c[0] ), "dir/a" ) + if os.name == "nt": + self.assertEqual( c[0].nativeString(), "dir\\a" ) + else: + self.assertEqual( c[0].nativeString(), "dir/a" ) self.assertTrue( c[0].isValid() ) def testChildrenOfFile( self ) : @@ -172,7 +180,7 @@ def testModificationTimes( self ) : p = Gaffer.FileSystemPath( self.temporaryDirectory() ) p.append( "t" ) - with open( str( p ), "w" ) as f : + with open( p.nativeString(), "w" ) as f : f.write( "AAAA" ) mt = p.property( "fileSystem:modificationTime" ) @@ -181,7 +189,7 @@ def testModificationTimes( self ) : time.sleep( 1 ) - with open( str( p ), "w" ) as f : + with open( p.nativeString(), "w" ) as f : f.write( "BBBB" ) mt = p.property( "fileSystem:modificationTime" ) @@ -193,24 +201,25 @@ def testOwner( self ) : p = Gaffer.FileSystemPath( self.temporaryDirectory() ) p.append( "t" ) - with open( str( p ), "w" ) as f : + with open( p.nativeString(), "w" ) as f : f.write( "AAAA" ) o = p.property( "fileSystem:owner" ) self.assertTrue( isinstance( o, str ) ) - self.assertEqual( o, pwd.getpwuid( os.stat( str( p ) ).st_uid ).pw_name ) + + self.assertEqual( o, self.getFileOwner( p.nativeString() ) ) def testGroup( self ) : p = Gaffer.FileSystemPath( self.temporaryDirectory() ) p.append( "t" ) - with open( str( p ), "w" ) as f : + with open( p.nativeString(), "w" ) as f : f.write( "AAAA" ) g = p.property( "fileSystem:group" ) self.assertTrue( isinstance( g, str ) ) - self.assertEqual( g, grp.getgrgid( os.stat( str( p ) ).st_gid ).gr_name ) + self.assertEqual( g, grp.getgrgid( os.stat( p.nativeString() ).st_gid ).gr_name ) def testPropertyNames( self ) : @@ -243,18 +252,26 @@ def testSequences( self ) : s = sorted( c, key=str ) self.assertEqual( str(s[0]), self.temporaryDirectory() + "/a.###.txt" ) + self.assertEqual( s[0].nativeString(), os.path.join( self.temporaryDirectory(), "a.###.txt" ) ) self.assertEqual( str(s[1]), self.temporaryDirectory() + "/a.001.txt" ) + self.assertEqual( s[1].nativeString(), os.path.join( self.temporaryDirectory(), "a.001.txt" ) ) self.assertEqual( str(s[2]), self.temporaryDirectory() + "/a.002.txt" ) + self.assertEqual( s[2].nativeString(), os.path.join( self.temporaryDirectory(), "a.002.txt" ) ) self.assertEqual( str(s[3]), self.temporaryDirectory() + "/a.004.txt" ) + self.assertEqual( s[3].nativeString(), os.path.join( self.temporaryDirectory(), "a.004.txt" ) ) self.assertEqual( str(s[4]), self.temporaryDirectory() + "/b.###.txt" ) + self.assertEqual( s[4].nativeString(), os.path.join( self.temporaryDirectory(), "b.###.txt" ) ) self.assertEqual( str(s[5]), self.temporaryDirectory() + "/b.003.txt" ) + self.assertEqual( s[5].nativeString(), os.path.join( self.temporaryDirectory(), "b.003.txt" ) ) self.assertEqual( str(s[6]), self.temporaryDirectory() + "/dir" ) + self.assertEqual( s[6].nativeString(), os.path.join( self.temporaryDirectory(), "dir" ) ) self.assertEqual( str(s[7]), self.temporaryDirectory() + "/singleFile.txt" ) + self.assertEqual( s[7].nativeString(), os.path.join( self.temporaryDirectory(), "singleFile.txt" ) ) for x in s : self.assertTrue( x.isValid() ) - if not os.path.isdir( str(x) ) : + if not os.path.isdir( x.nativeString() ) : self.assertTrue( x.isLeaf() ) self.assertEqual( x.property( "fileSystem:owner" ), pwd.getpwuid( os.stat( str( p ) ).st_uid ).pw_name ) @@ -264,7 +281,7 @@ def testSequences( self ) : self.assertFalse( x.isFileSequence() ) self.assertEqual( x.fileSequence(), None ) self.assertEqual( x.property( "fileSystem:frameRange" ), "" ) - if os.path.isdir( str(x) ) : + if os.path.isdir( x.nativeString() ) : self.assertEqual( x.property( "fileSystem:size" ), 0 ) else : self.assertEqual( x.property( "fileSystem:size" ), 4 ) @@ -272,13 +289,13 @@ def testSequences( self ) : self.assertEqual( s[0].property( "fileSystem:frameRange" ), "1-2,4" ) self.assertTrue( s[0].isFileSequence() ) self.assertTrue( isinstance( s[0].fileSequence(), IECore.FileSequence ) ) - self.assertEqual( s[0].fileSequence(), IECore.FileSequence( str(s[0]), IECore.frameListFromList( [ 1, 2, 4 ] ) ) ) + self.assertEqual( s[0].fileSequence(), IECore.FileSequence( s[0].nativeString(), IECore.frameListFromList( [ 1, 2, 4 ] ) ) ) self.assertEqual( s[0].property( "fileSystem:size" ), 4 * 3 ) self.assertEqual( s[4].property( "fileSystem:frameRange" ), "3" ) self.assertTrue( s[4].isFileSequence() ) self.assertTrue( isinstance( s[4].fileSequence(), IECore.FileSequence ) ) - self.assertEqual( s[4].fileSequence(), IECore.FileSequence( str(s[4]), IECore.frameListFromList( [ 3 ] ) ) ) + self.assertEqual( s[4].fileSequence(), IECore.FileSequence( s[4].nativeString(), IECore.frameListFromList( [ 3 ] ) ) ) self.assertEqual( s[4].property( "fileSystem:size" ), 4 ) # make sure we can copy @@ -295,11 +312,17 @@ def testSequences( self ) : s = sorted( c, key=str ) self.assertEqual( str(s[0]), self.temporaryDirectory() + "/a.001.txt" ) + self.assertEqual( s[0].nativeString(), os.path.join( self.temporaryDirectory(), "a.001.txt" ) ) self.assertEqual( str(s[1]), self.temporaryDirectory() + "/a.002.txt" ) + self.assertEqual( s[1].nativeString(), os.path.join( self.temporaryDirectory(), "a.002.txt" ) ) self.assertEqual( str(s[2]), self.temporaryDirectory() + "/a.004.txt" ) + self.assertEqual( s[2].nativeString(), os.path.join( self.temporaryDirectory(), "a.004.txt" ) ) self.assertEqual( str(s[3]), self.temporaryDirectory() + "/b.003.txt" ) + self.assertEqual( s[3].nativeString(), os.path.join( self.temporaryDirectory(), "b.003.txt" ) ) self.assertEqual( str(s[4]), self.temporaryDirectory() + "/dir" ) + self.assertEqual( s[4].nativeString(), os.path.join( self.temporaryDirectory(), "dir" ) ) self.assertEqual( str(s[5]), self.temporaryDirectory() + "/singleFile.txt" ) + self.assertEqual( s[5].nativeString(), os.path.join( self.temporaryDirectory(), "singleFile.txt" ) ) # and we can include them again p.setIncludeSequences( True ) diff --git a/src/Gaffer/FileSystemPath.cpp b/src/Gaffer/FileSystemPath.cpp index 2e640501703..80cecb9ccae 100644 --- a/src/Gaffer/FileSystemPath.cpp +++ b/src/Gaffer/FileSystemPath.cpp @@ -455,3 +455,24 @@ PathFilterPtr FileSystemPath::createStandardFilter( const std::vectorroot(); + Path::Names names = this->names(); + for( size_t i = 0, s = names.size(); i < s; ++i ) + { + if( i != 0 ) + { + result += separator; + } + result += names[i].string(); + } + return result; +} diff --git a/src/GafferModule/PathBinding.cpp b/src/GafferModule/PathBinding.cpp index 270391b530e..7a2ebf7418a 100644 --- a/src/GafferModule/PathBinding.cpp +++ b/src/GafferModule/PathBinding.cpp @@ -533,6 +533,7 @@ void GafferModule::bindPath() arg( "includeSequenceFilter" ) = false ) ) + .def( "nativeString", &FileSystemPath::nativeString ) .staticmethod( "createStandardFilter" ) ; From 5129a6683ac3f8e7ba9f3d4fd2410bdadfb2d327 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 23 Aug 2018 20:59:42 -0400 Subject: [PATCH 074/123] FileSystemPath : Support Windows paths - Store all paths internally using forward slashes. - Convert Windows paths to use foward slashes instead of back slashes. - For Windows drive letter paths, store the drive letter as the root of the path. - For Windows UNC paths and POSIX paths, store the leading '/' as the root of the path. --- include/Gaffer/FileSystemPath.h | 5 + include/Gaffer/Path.h | 5 +- python/GafferTest/FileSystemPathTest.py | 101 ++++++++--- src/Gaffer/FileSystemPath.cpp | 222 +++++++++++++++++++++--- src/Gaffer/Path.cpp | 12 ++ 5 files changed, 296 insertions(+), 49 deletions(-) diff --git a/include/Gaffer/FileSystemPath.h b/include/Gaffer/FileSystemPath.h index 443ffbfb22a..292f1a0e804 100644 --- a/include/Gaffer/FileSystemPath.h +++ b/include/Gaffer/FileSystemPath.h @@ -58,6 +58,9 @@ class GAFFER_API FileSystemPath : public Path ~FileSystemPath() override; + /// Sets the path root and names from an OS native path string + void setFromString(const std::string &string) override; + bool isValid( const IECore::Canceller *canceller = nullptr ) const override; bool isLeaf( const IECore::Canceller *canceller = nullptr ) const override; void propertyNames( std::vector &names, const IECore::Canceller *canceller = nullptr ) const override; @@ -82,6 +85,7 @@ class GAFFER_API FileSystemPath : public Path // a FileSequence. IECore::FileSequencePtr fileSequence() const; + std::string string() const override; // Returns the path converted to the OS native format std::string nativeString() const; @@ -90,6 +94,7 @@ class GAFFER_API FileSystemPath : public Path protected : void doChildren( std::vector &children, const IECore::Canceller *canceller ) const override; + std::string getOwner( const std::string &pathString ) const; private : diff --git a/include/Gaffer/Path.h b/include/Gaffer/Path.h index 9a5f7fd3543..568f9a33d96 100644 --- a/include/Gaffer/Path.h +++ b/include/Gaffer/Path.h @@ -90,6 +90,7 @@ class GAFFER_API Path : public IECore::RunTimeTyped /// Returns the root of the path - this will be "/" for absolute /// paths and "" for relative paths. const IECore::InternedString &root() const; + void setRoot( IECore::InternedString &newRoot ); /// Returns true if this path is empty. bool isEmpty() const; @@ -141,7 +142,7 @@ class GAFFER_API Path : public IECore::RunTimeTyped /// Sets the path root and names from a "/" /// separated string. - void setFromString( const std::string &string ); + virtual void setFromString( const std::string &string ); /// Returns a copy of this path. Must be reimplemented /// by derived classes so that the copy has the appropriate @@ -180,7 +181,7 @@ class GAFFER_API Path : public IECore::RunTimeTyped /// Returns the path concatenated into a string, using '/' /// as a separator between names. - std::string string() const; + virtual std::string string() const; bool operator == ( const Path &other ) const; bool operator != ( const Path &other ) const; diff --git a/python/GafferTest/FileSystemPathTest.py b/python/GafferTest/FileSystemPathTest.py index 05612d52728..5b657a5462a 100644 --- a/python/GafferTest/FileSystemPathTest.py +++ b/python/GafferTest/FileSystemPathTest.py @@ -38,9 +38,10 @@ import unittest import time import datetime -import pwd -import grp import os +if os.name is not "nt": + import pwd + import grp import IECore @@ -76,6 +77,7 @@ def testConstructWithFilter( self ) : p = Gaffer.FileSystemPath( __file__, filter = f ) self.assertTrue( p.getFilter().isSame( f ) ) + @unittest.skipIf( os.name == "nt", "Windows does not support symbolic links." ) def testBrokenSymbolicLinks( self ) : os.symlink( self.temporaryDirectory() + "/nonExistent", self.temporaryDirectory() + "/broken" ) @@ -97,6 +99,7 @@ def testBrokenSymbolicLinks( self ) : # since we said it was valid, it ought to have some info self.assertIsNotNone( l.info() ) + @unittest.skipIf( os.name == "nt", "Windows does not support symbolic links." ) def testSymLinkInfo( self ) : with open( self.temporaryDirectory() + "/a", "w" ) as f : @@ -135,7 +138,7 @@ def testRelativePath( self ) : os.chdir( self.temporaryDirectory() ) - with open( self.temporaryDirectory() + "/a", "w" ) as f : + with open( os.path.join( self.temporaryDirectory(), "a" ), "w" ) as f : f.write( "AAAA" ) p = Gaffer.FileSystemPath( "a" ) @@ -152,11 +155,42 @@ def testRelativePath( self ) : self.assertFalse( p2.isEmpty() ) self.assertFalse( p2.isValid() ) + def testDriveLetterPath( self ) : + p = Gaffer.FileSystemPath( "C:\\this\\path\\does\\not\\exist.ext" ) + + self.assertEqual( str( p ), "C:/this/path/does/not/exist.ext" ) + if os.name == "nt": + self.assertEqual( p.nativeString(), "C:\\this\\path\\does\\not\\exist.ext") + self.assertFalse( p.isEmpty() ) + self.assertFalse( p.isValid() ) + + def testUNCPath( self ) : + p = Gaffer.FileSystemPath( "\\\\this.server\\path\\does\\not\\exist.ext" ) + + self.assertEqual( str( p ), "//this.server/path/does/not/exist.ext" ) + if os.name == "nt": + self.assertEqual( p.nativeString(), "\\\\this.server\\path\\does\\not\\exist.ext") + self.assertFalse( p.isEmpty() ) + self.assertFalse( p.isValid() ) + + def testPosixPath( self ) : + p = Gaffer.FileSystemPath( "/this/path/does/not/exist.ext" ) + + if os.name == "nt": + self.assertEqual( str( p ), "//this/path/does/not/exist.ext" ) + else: + self.assertEqual( str( p ), "/this/path/does/not/exist.ext" ) + + if os.name is not "nt": + self.assertEqual( p.nativeString(), "/this/path/does/not/exist.ext") + self.assertFalse( p.isEmpty() ) + self.assertFalse( p.isValid() ) + def testRelativePathChildren( self ) : os.chdir( self.temporaryDirectory() ) os.mkdir( "dir" ) - with open( self.temporaryDirectory() + "/dir/a", "w" ) as f : + with open( os.path.join( self.temporaryDirectory(), "dir", "a" ), "w" ) as f : f.write( "AAAA" ) p = Gaffer.FileSystemPath( "dir" ) @@ -209,6 +243,7 @@ def testOwner( self ) : self.assertEqual( o, self.getFileOwner( p.nativeString() ) ) + @unittest.skipIf( os.name == "nt", "Windows does separate group ownership." ) def testGroup( self ) : p = Gaffer.FileSystemPath( self.temporaryDirectory() ) @@ -239,9 +274,9 @@ def testPropertyNames( self ) : def testSequences( self ) : - os.mkdir( self.temporaryDirectory() + "/dir" ) + os.mkdir( os.path.join( self.temporaryDirectory(), "dir" ) ) for n in [ "singleFile.txt", "a.001.txt", "a.002.txt", "a.004.txt", "b.003.txt" ] : - with open( self.temporaryDirectory() + "/" + n, "w" ) as f : + with open( os.path.join( self.temporaryDirectory(), n ), "w" ) as f : f.write( "AAAA" ) p = Gaffer.FileSystemPath( self.temporaryDirectory(), includeSequences = True ) @@ -251,21 +286,21 @@ def testSequences( self ) : self.assertEqual( len( c ), 8 ) s = sorted( c, key=str ) - self.assertEqual( str(s[0]), self.temporaryDirectory() + "/a.###.txt" ) + self.assertEqual( str(s[0]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.###.txt" ) self.assertEqual( s[0].nativeString(), os.path.join( self.temporaryDirectory(), "a.###.txt" ) ) - self.assertEqual( str(s[1]), self.temporaryDirectory() + "/a.001.txt" ) + self.assertEqual( str(s[1]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.001.txt" ) self.assertEqual( s[1].nativeString(), os.path.join( self.temporaryDirectory(), "a.001.txt" ) ) - self.assertEqual( str(s[2]), self.temporaryDirectory() + "/a.002.txt" ) + self.assertEqual( str(s[2]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.002.txt" ) self.assertEqual( s[2].nativeString(), os.path.join( self.temporaryDirectory(), "a.002.txt" ) ) - self.assertEqual( str(s[3]), self.temporaryDirectory() + "/a.004.txt" ) + self.assertEqual( str(s[3]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.004.txt" ) self.assertEqual( s[3].nativeString(), os.path.join( self.temporaryDirectory(), "a.004.txt" ) ) - self.assertEqual( str(s[4]), self.temporaryDirectory() + "/b.###.txt" ) + self.assertEqual( str(s[4]), self.temporaryDirectory().replace( "\\", "/" ) + "/b.###.txt" ) self.assertEqual( s[4].nativeString(), os.path.join( self.temporaryDirectory(), "b.###.txt" ) ) - self.assertEqual( str(s[5]), self.temporaryDirectory() + "/b.003.txt" ) + self.assertEqual( str(s[5]), self.temporaryDirectory().replace( "\\", "/" ) + "/b.003.txt" ) self.assertEqual( s[5].nativeString(), os.path.join( self.temporaryDirectory(), "b.003.txt" ) ) - self.assertEqual( str(s[6]), self.temporaryDirectory() + "/dir" ) + self.assertEqual( str(s[6]), self.temporaryDirectory().replace( "\\", "/" ) + "/dir" ) self.assertEqual( s[6].nativeString(), os.path.join( self.temporaryDirectory(), "dir" ) ) - self.assertEqual( str(s[7]), self.temporaryDirectory() + "/singleFile.txt" ) + self.assertEqual( str(s[7]), self.temporaryDirectory().replace( "\\", "/" ) + "/singleFile.txt" ) self.assertEqual( s[7].nativeString(), os.path.join( self.temporaryDirectory(), "singleFile.txt" ) ) for x in s : @@ -274,10 +309,11 @@ def testSequences( self ) : if not os.path.isdir( x.nativeString() ) : self.assertTrue( x.isLeaf() ) - self.assertEqual( x.property( "fileSystem:owner" ), pwd.getpwuid( os.stat( str( p ) ).st_uid ).pw_name ) - self.assertEqual( x.property( "fileSystem:group" ), grp.getgrgid( os.stat( str( p ) ).st_gid ).gr_name ) + self.assertEqual( x.property( "fileSystem:owner" ), self.getFileOwner( p.nativeString() ) ) + if os.name is not "nt": + self.assertEqual( x.property( "fileSystem:group" ), grp.getgrgid( os.stat( str( p ) ).st_gid ).gr_name ) self.assertLess( (datetime.datetime.utcnow() - x.property( "fileSystem:modificationTime" )).total_seconds(), 2 ) - if "###" not in str(x) : + if "###" not in str( x ) : self.assertFalse( x.isFileSequence() ) self.assertEqual( x.fileSequence(), None ) self.assertEqual( x.property( "fileSystem:frameRange" ), "" ) @@ -311,17 +347,17 @@ def testSequences( self ) : self.assertEqual( len( c ), 6 ) s = sorted( c, key=str ) - self.assertEqual( str(s[0]), self.temporaryDirectory() + "/a.001.txt" ) + self.assertEqual( str(s[0]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.001.txt" ) self.assertEqual( s[0].nativeString(), os.path.join( self.temporaryDirectory(), "a.001.txt" ) ) - self.assertEqual( str(s[1]), self.temporaryDirectory() + "/a.002.txt" ) + self.assertEqual( str(s[1]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.002.txt" ) self.assertEqual( s[1].nativeString(), os.path.join( self.temporaryDirectory(), "a.002.txt" ) ) - self.assertEqual( str(s[2]), self.temporaryDirectory() + "/a.004.txt" ) + self.assertEqual( str(s[2]), self.temporaryDirectory().replace( "\\", "/" ) + "/a.004.txt" ) self.assertEqual( s[2].nativeString(), os.path.join( self.temporaryDirectory(), "a.004.txt" ) ) - self.assertEqual( str(s[3]), self.temporaryDirectory() + "/b.003.txt" ) + self.assertEqual( str(s[3]), self.temporaryDirectory().replace( "\\", "/" ) + "/b.003.txt" ) self.assertEqual( s[3].nativeString(), os.path.join( self.temporaryDirectory(), "b.003.txt" ) ) - self.assertEqual( str(s[4]), self.temporaryDirectory() + "/dir" ) + self.assertEqual( str(s[4]), self.temporaryDirectory().replace( "\\", "/" ) + "/dir" ) self.assertEqual( s[4].nativeString(), os.path.join( self.temporaryDirectory(), "dir" ) ) - self.assertEqual( str(s[5]), self.temporaryDirectory() + "/singleFile.txt" ) + self.assertEqual( str(s[5]), self.temporaryDirectory().replace( "\\", "/" ) + "/singleFile.txt" ) self.assertEqual( s[5].nativeString(), os.path.join( self.temporaryDirectory(), "singleFile.txt" ) ) # and we can include them again @@ -363,6 +399,11 @@ def testCancellation( self ) : with self.assertRaises( IECore.Cancelled ) : p.property( "fileSystem:modificationTime", c ) + def testTruncateUntilValid( self ): + + p = Gaffer.FileSystemPath( "T" ) + self.assertEqual( str( p.truncateUntilValid() ), "" ) + def setUp( self ) : GafferTest.TestCase.setUp( self ) @@ -371,9 +412,21 @@ def setUp( self ) : def tearDown( self ) : + os.chdir( self.__originalCWD ) + GafferTest.TestCase.tearDown( self ) - os.chdir( self.__originalCWD ) + def getFileOwner( self, filepath ): + + # Windows Python does not have a reliable native method to get the owner + # without installing the Win32 package. Since the files being tested + # are created within the test process, assume the current user is + # an acceptable standin for the file owner + if os.name is not "nt" : + return pwd.getpwuid( os.stat( filepath ).st_uid ).pw_name + else : + return os.environ["USERNAME"] + if __name__ == "__main__": unittest.main() diff --git a/src/Gaffer/FileSystemPath.cpp b/src/Gaffer/FileSystemPath.cpp index 80cecb9ccae..1187b6a1427 100644 --- a/src/Gaffer/FileSystemPath.cpp +++ b/src/Gaffer/FileSystemPath.cpp @@ -50,10 +50,17 @@ #include "boost/date_time/posix_time/conversion.hpp" #include "boost/filesystem.hpp" #include "boost/filesystem/operations.hpp" +#include "boost/regex.hpp" #ifndef _MSC_VER #include #include +#else +#include +#include +#include +#include "accctrl.h" +#include "aclapi.h" #endif #include @@ -73,6 +80,12 @@ static InternedString g_modificationTimePropertyName( "fileSystem:modificationTi static InternedString g_sizePropertyName( "fileSystem:size" ); static InternedString g_frameRangePropertyName( "fileSystem:frameRange" ); +static InternedString g_windowsSeparator( "\\" ); +static InternedString g_genericSeparator( "/" ); +static InternedString g_uncPrefix( "\\\\" ); +static InternedString g_uncGenericPrefix( "//" ); +static boost::regex g_driveLetterPattern{ "[A-Za-z]:" }; + FileSystemPath::FileSystemPath( PathFilterPtr filter, bool includeSequences ) : Path( filter ), m_includeSequences( includeSequences ) { @@ -81,6 +94,7 @@ FileSystemPath::FileSystemPath( PathFilterPtr filter, bool includeSequences ) FileSystemPath::FileSystemPath( const std::string &path, PathFilterPtr filter, bool includeSequences ) : Path( path, filter ), m_includeSequences( includeSequences ) { + setFromString( path ); } FileSystemPath::FileSystemPath( const Names &names, const IECore::InternedString &root, PathFilterPtr filter, bool includeSequences ) @@ -92,6 +106,60 @@ FileSystemPath::~FileSystemPath() { } +// Create a path that is aware of differences in OS naming schemes. +// Linux and MacOS can have a relative path with no root, or a path rooted at "/" : +// Windows can have a relative path with no root, a path rooted at a drive letter followed by a colon +// or a path rooted at a server name and share name (UNC paths). + +void FileSystemPath::setFromString(const std::string &string) +{ + Names newNames; + std::string sanitizedString = string; + + boost::replace_all( sanitizedString, g_windowsSeparator.c_str(), g_genericSeparator.c_str() ); + +#ifdef _MSC_VER + // If `string` is coming from a PathMatcher, it will always have a single leading slash. + // On Windows, interpret that to be the start of a UNC path. + if( sanitizedString.size() && sanitizedString[0] == '/' && !boost::starts_with( sanitizedString, "//" ) ) + { + sanitizedString = "/" + sanitizedString; + } +#endif + + StringAlgo::tokenize(sanitizedString, '/', back_inserter(newNames)); + + InternedString newRoot; + if ( newNames.size() && boost::regex_match( newNames[0].string(), g_driveLetterPattern ) ) + { + newRoot = newNames[0]; + newNames.erase( newNames.begin() ); + } + else if ( boost::starts_with( sanitizedString, "//" ) ) + { + // The server name and share name are both required before the path is valid. + if( newNames.size() > 1 ) + { + newRoot = newNames[0].string() + g_genericSeparator.string() + newNames[1].string(); + newNames.erase( newNames.begin(), newNames.begin() + 2 ); + } + } + else if( sanitizedString.size() && sanitizedString[0] == '/' ) + { + newRoot = g_genericSeparator; + } + + if (newRoot == this->root() && newNames == this->names() ) + { + return; + } + + set( 0, this->names().size(), newNames ); + setRoot( newRoot ); + + emitPathChanged(); +} + bool FileSystemPath::isValid( const IECore::Canceller *canceller ) const { if( !Path::isValid() ) @@ -154,7 +222,7 @@ FileSequencePtr FileSystemPath::fileSequence() const FileSequencePtr sequence = nullptr; /// \todo Add cancellation support to `ls`. - IECore::ls( this->string(), sequence, /* minSequenceSize = */ 1 ); + IECore::ls( this->nativeString(), sequence, /* minSequenceSize = */ 1 ); return sequence; } @@ -193,14 +261,7 @@ IECore::ConstRunTimeTypedPtr FileSystemPath::property( const IECore::InternedStr for( std::vector::iterator it = files.begin(); it != files.end(); ++it ) { IECore::Canceller::check( canceller ); - struct stat s; - stat( it->c_str(), &s ); - #ifndef _MSC_VER - struct passwd *pw = getpwuid( s.st_uid ); - std::string value = pw ? pw->pw_name : ""; - #else - std::string value = ""; - #endif + std::string value = getOwner( it->c_str() ); std::pair::iterator,bool> oIt = ownerCounter.insert( std::pair( value, 0 ) ); oIt.first->second++; if( oIt.first->second > maxCount ) @@ -214,14 +275,8 @@ IECore::ConstRunTimeTypedPtr FileSystemPath::property( const IECore::InternedStr } std::string n = this->string(); - struct stat s; - stat( n.c_str(), &s ); - #ifndef _MSC_VER - struct passwd *pw = getpwuid( s.st_uid ); - return new StringData( pw ? pw->pw_name : "" ); - #else - return new StringData( "" ); - #endif + + return new StringData( getOwner( n.c_str() ) ); } else if( name == g_groupPropertyName ) { @@ -373,7 +428,7 @@ void FileSystemPath::doChildren( std::vector &children, const IECore::C { IECore::Canceller::check( canceller ); std::vector sequences; - IECore::ls( p.string(), sequences, /* minSequenceSize */ 1 ); + IECore::ls( this->nativeString(), sequences, /* minSequenceSize */ 1 ); for( std::vector::iterator it = sequences.begin(); it != sequences.end(); ++it ) { IECore::Canceller::check( canceller ); @@ -456,15 +511,52 @@ PathFilterPtr FileSystemPath::createStandardFilter( const std::vectorroot(); + + if ( boost::regex_match(result, g_driveLetterPattern) ) + { + result += g_genericSeparator; + } + else if( result.size() && result != "/" ) + { + result = g_uncGenericPrefix.string() + result + g_genericSeparator.string(); + } + + Path::Names names = this->names(); + for (size_t i = 0, s = names.size(); i < s; ++i) + { + if (i != 0) + { + result += g_genericSeparator; + } + result += names[i].string(); + } + return result; +} + std::string FileSystemPath::nativeString() const { - #ifdef _MSC_VER - std::string separator = "\\"; - #else - std::string separator = "/"; - #endif +#ifdef _MSC_VER + std::string separator = g_windowsSeparator; +#else + std::string separator = g_genericSeparator; +#endif std::string result = this->root(); + + if( boost::regex_match( result, g_driveLetterPattern ) ) + { + result += separator; + } + else if( result.size() && result != "/" ) + { + // We included the generic separator in the root name, now it needs to be converted back. + boost::replace_all( result, g_genericSeparator.c_str(), g_windowsSeparator.c_str() ); + result = g_uncPrefix.string() + result + separator; + } + Path::Names names = this->names(); for( size_t i = 0, s = names.size(); i < s; ++i ) { @@ -476,3 +568,87 @@ std::string FileSystemPath::nativeString() const } return result; } + +std::string FileSystemPath::getOwner( const std::string &pathString ) const +{ + std::string value; +#ifndef _MSC_VER + struct stat s; + stat(pathString.c_str(), &s); + struct passwd *pw = getpwuid(s.st_uid); + value = pw ? pw->pw_name : ""; +#else + DWORD dwRtnCode = 0; + PSID pSidOwner = NULL; + BOOL bRtnBool = TRUE; + LPTSTR AcctName = NULL; + LPTSTR DomainName = NULL; + DWORD dwAcctName = 1, dwDomainName = 1; + SID_NAME_USE eUse = SidTypeUnknown; + HANDLE hFile; + PSECURITY_DESCRIPTOR pSD = NULL; + + // First get the size of the data + DWORD dwSize; + if( GetFileSecurity( pathString.c_str(), OWNER_SECURITY_INFORMATION, pSD, 0, &dwSize ) ) + { + return ""; + } + + pSD = ( PSECURITY_DESCRIPTOR ) malloc( dwSize ); + + if( pSD == NULL) + { + return ""; + } + + if( !GetFileSecurity( pathString.c_str(), OWNER_SECURITY_INFORMATION, pSD, dwSize, &dwSize ) ) + { + free( pSD ); + return ""; + } + + BOOL defaulted = false; + GetSecurityDescriptorOwner( pSD, &pSidOwner, &defaulted); + if( defaulted ) + { + free( pSD ); + return ""; + } + + // First call to LookupAccountSid to get the buffer sizes. + bRtnBool = LookupAccountSid(NULL, pSidOwner, AcctName, (LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &eUse); + + // Reallocate memory for the buffers. + AcctName = (LPTSTR)GlobalAlloc(GMEM_FIXED, dwAcctName); + + // Check GetLastError for GlobalAlloc error condition. + if (AcctName == NULL) { + free( pSD ); + return ""; + } + + DomainName = (LPTSTR)GlobalAlloc(GMEM_FIXED, dwDomainName); + + // Check GetLastError for GlobalAlloc error condition. + if (DomainName == NULL) { + free( pSD ); + return ""; + } + + // Second call to LookupAccountSid to get the account name. + bRtnBool = LookupAccountSid(NULL, pSidOwner, AcctName, (LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &eUse); + + if (bRtnBool == FALSE) { + free( pSD ); + return ""; + } + + free( pSD ); + value = AcctName; + +#endif + + return value; +} + diff --git a/src/Gaffer/Path.cpp b/src/Gaffer/Path.cpp index 3348e0f657f..af0b0f441bd 100644 --- a/src/Gaffer/Path.cpp +++ b/src/Gaffer/Path.cpp @@ -95,6 +95,18 @@ const IECore::InternedString &Path::root() const return m_root; } +void Path::setRoot( IECore::InternedString &newRoot ) +{ + + if ( newRoot == m_root ) + { + return; + } + + m_root = newRoot; + emitPathChanged(); +} + bool Path::isEmpty() const { return m_names.empty() && m_root.string().empty(); From 22765e7a619f627e4315aca20f2a492b6fb429a4 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 23 Nov 2018 16:43:39 -0500 Subject: [PATCH 075/123] FileSystemPathPlug : add new plug for cross-platform file paths --- include/Gaffer/FileSystemPathPlug.h | 113 +++++ include/Gaffer/StringPlug.h | 2 +- include/Gaffer/TypeIds.h | 1 + python/GafferTest/FileSystemPathInOutNode.py | 75 ++++ python/GafferTest/FileSystemPathPlugTest.py | 399 ++++++++++++++++++ python/GafferTest/__init__.py | 2 + src/Gaffer/FileSystemPathPlug.cpp | 188 +++++++++ src/GafferDispatch/Dispatcher.cpp | 2 +- src/GafferImage/OpenImageIOReader.cpp | 3 +- .../FileSystemPathPlugBinding.cpp | 153 +++++++ src/GafferModule/FileSystemPathPlugBinding.h | 47 +++ src/GafferModule/GafferModule.cpp | 2 + 12 files changed, 984 insertions(+), 3 deletions(-) create mode 100644 include/Gaffer/FileSystemPathPlug.h create mode 100644 python/GafferTest/FileSystemPathInOutNode.py create mode 100644 python/GafferTest/FileSystemPathPlugTest.py create mode 100644 src/Gaffer/FileSystemPathPlug.cpp create mode 100644 src/GafferModule/FileSystemPathPlugBinding.cpp create mode 100644 src/GafferModule/FileSystemPathPlugBinding.h diff --git a/include/Gaffer/FileSystemPathPlug.h b/include/Gaffer/FileSystemPathPlug.h new file mode 100644 index 00000000000..32f67485fd6 --- /dev/null +++ b/include/Gaffer/FileSystemPathPlug.h @@ -0,0 +1,113 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2011-2012, John Haddon. All rights reserved. +// Copyright (c) 2011-2015, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFER_FILESYSTEMPATHPLUG_H +#define GAFFER_FILESYSTEMPATHPLUG_H + +#include "Gaffer/Context.h" +#include "Gaffer/StringPlug.h" + +#include "IECore/StringAlgo.h" + + +namespace Gaffer +{ + +/// Plug for providing file system path values. +/// +/// Inherit from StringPlug so all substitutions work and it +/// is backwards compatible with Gaffer scripts from previous versions. +/// +/// Gaffer standardizes on using forward slashes for separating directories +/// in a path in the UI. Pulling on the FileSystemPathPlug returns an OS +/// native format string. Directories are separated by forward slashes on +/// POSIX systems and back slashes on Windows. +/// On Windows, interpret a path starting with a forward slash as a UNC +/// path, converting it to a double back slash. + +class GAFFER_API FileSystemPathPlug : public StringPlug +{ + + public : + + typedef std::string ValueType; + + IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Gaffer::FileSystemPathPlug, FileSystemPathPlugTypeId, StringPlug ); + + + FileSystemPathPlug( + const std::string &name = defaultName(), + Direction direction=In, + const std::string &defaultValue = "", + unsigned flags = Default, + unsigned substitutions = IECore::StringAlgo::AllSubstitutions + ); + ~FileSystemPathPlug() override; + + /// Accepts instances StringPlug or derived classes, + /// which includes FileSystemPath Plug. + bool acceptsInput( const Plug *input ) const override; + PlugPtr createCounterpart( const std::string &name, Direction direction ) const override; + + /// \undoable + void setValue(const std::string &value); + /// Returns the value. See comments in TypedObjectPlug::getValue() + /// for details of the optional precomputedHash argument - and use + /// with care! + std::string getValue( const IECore::MurmurHash *precomputedHash = nullptr, const Context *context = nullptr, const bool forceSubstitutions = false ) const; + + void setFrom(const ValuePlug *other) override; + + IECore::MurmurHash hash() const override; + /// Ensures the method above doesn't mask + /// ValuePlug::hash( h ) + using ValuePlug::hash; +}; + +IE_CORE_DECLAREPTR( FileSystemPathPlug ); + +typedef FilteredChildIterator > FileSystemPathPlugIterator; +typedef FilteredChildIterator > InputFileSystemPathPlugIterator; +typedef FilteredChildIterator > OutputFileSystemPathPlugIterator; + +typedef FilteredRecursiveChildIterator, PlugPredicate<> > RecursiveFileSystemPathPlugIterator; +typedef FilteredRecursiveChildIterator, PlugPredicate<> > RecursiveInputFileSystemPathPlugIterator; +typedef FilteredRecursiveChildIterator, PlugPredicate<> > RecursiveOutputFileSystemPathPlugIterator; + +} // namespace Gaffer + +#endif // GAFFER_FILESYSTEMPATHPLUGPLUG_H diff --git a/include/Gaffer/StringPlug.h b/include/Gaffer/StringPlug.h index 7e581eaf790..59c4c917fdb 100644 --- a/include/Gaffer/StringPlug.h +++ b/include/Gaffer/StringPlug.h @@ -112,7 +112,7 @@ class GAFFER_API StringPlug : public ValuePlug /// Returns the value. See comments in TypedObjectPlug::getValue() /// for details of the optional precomputedHash argument - and use /// with care! - std::string getValue( const IECore::MurmurHash *precomputedHash = nullptr ) const; + virtual std::string getValue( const IECore::MurmurHash *precomputedHash = nullptr ) const; void setFrom( const ValuePlug *other ) override; diff --git a/include/Gaffer/TypeIds.h b/include/Gaffer/TypeIds.h index d34bdb0b8bf..4d5ee49a687 100644 --- a/include/Gaffer/TypeIds.h +++ b/include/Gaffer/TypeIds.h @@ -142,6 +142,7 @@ enum TypeId M33fVectorDataPlugTypeId = 110095, ScriptNodeFocusSetTypeId = 110096, AnimationKeyTypeId = 110097, + FileSystemPathPlugTypeId = 110098, LastTypeId = 110159, diff --git a/python/GafferTest/FileSystemPathInOutNode.py b/python/GafferTest/FileSystemPathInOutNode.py new file mode 100644 index 00000000000..c2748100464 --- /dev/null +++ b/python/GafferTest/FileSystemPathInOutNode.py @@ -0,0 +1,75 @@ +########################################################################## +# +# Copyright (c) 2012, John Haddon. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with +# the distribution. +# +# * Neither the name of John Haddon nor the names of +# any other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + +import IECore +import Gaffer + +class FileSystemPathInOutNode( Gaffer.ComputeNode ) : + + def __init__( self, name="FileSystemPathInOutNode", defaultValue="", substitutions = Gaffer.Context.Substitutions.AllSubstitutions ) : + + Gaffer.ComputeNode.__init__( self, name ) + + self.addChild( Gaffer.FileSystemPathPlug( "in", Gaffer.Plug.Direction.In, defaultValue, substitutions = substitutions ) ) + self.addChild( Gaffer.FileSystemPathPlug( "out", Gaffer.Plug.Direction.Out ) ) + + self.numHashCalls = 0 + self.numComputeCalls = 0 + + def affects( self, input ) : + + outputs = Gaffer.ComputeNode.affects( self, input ) + + if input.isSame( self["in"] ) : + outputs.append( self["out"] ) + + return outputs + + def hash( self, output, context, h ) : + + if output.isSame( self["out"] ) : + self["in"].hash( h ) + + self.numHashCalls += 1 + + def compute( self, plug, context ) : + + if plug.isSame( self["out"] ) : + plug.setValue( self["in"].getValue() ) + + self.numComputeCalls += 1 + +IECore.registerRunTimeTyped( FileSystemPathInOutNode, typeName = "GafferTest::FileSystemPathInOutNode" ) diff --git a/python/GafferTest/FileSystemPathPlugTest.py b/python/GafferTest/FileSystemPathPlugTest.py new file mode 100644 index 00000000000..50e9cd1f9dd --- /dev/null +++ b/python/GafferTest/FileSystemPathPlugTest.py @@ -0,0 +1,399 @@ +########################################################################## +# +# Copyright (c) 2012, John Haddon. All rights reserved. +# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with +# the distribution. +# +# * Neither the name of John Haddon nor the names of +# any other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + +import os +import inspect +import unittest + +import IECore + +import Gaffer +import GafferTest + +class FileSystemPathPlugTest( GafferTest.TestCase ) : + + def testSlashConversion( self ) : + n = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n ) + + n["in"].setValue( "C:/path/test.exr" ) + self.assertEqual( n["out"].getValue(), os.path.join( "C:", os.sep, "path", "test.exr" ) ) + + n2 = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n2 ) + + n2["in"].setInput( n["out"] ) + self.assertEqual( n2["out"].getValue(), os.path.join( "C:", os.sep, "path", "test.exr") ) + + n3 = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n3 ) + n3["in"].setValue( "relative/path/test.exr" ) + self.assertEqual( n3["out"].getValue(), os.path.join( "relative", "path", "test.exr" ) ) + + n4 = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n4 ) + n4["in"].setValue( "C:\\backslash\\should\\work\\too.exr" ) + self.assertEqual( n4["out"].getValue(), os.path.join("C:", os.sep, "backslash", "should", "work", "too.exr")) + + def testUNC( self ) : + if os.name == "nt": + n = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n ) + + # generic starting with a single forward slash is interpreted + # as a UNC path and should start with double back slash + + n["in"].setValue( "/test.server/path/test.exr" ) + self.assertEqual( n["out"].getValue(), "\\\\test.server\\path\\test.exr" ) + + def testPosixRootPath( self ): + if os.name != "nt": + n = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n ) + + n["in"].setValue( "root/path/test.exr" ) + self.assertEqual( n["out"].getValue(), "root/path/test.exr" ) + + def testStringNodeCompatibility( self ): + n = GafferTest.FileSystemPathInOutNode() + s = GafferTest.StringInOutNode() + s["in"].setValue( "test/string.exr" ) + + + n["in"].setInput( s["out"] ) + + self.assertEqual( n["out"].getValue(), os.path.join( "test", "string.exr" ) ) + + def testExpansion( self ) : + + n = GafferTest.FileSystemPathInOutNode() + self.assertHashesValid( n ) + + # nothing should be expanded when we're in a non-computation context + n["in"].setValue( "testyTesty.##.exr" ) + self.assertEqual( n["in"].getValue(), "testyTesty.##.exr" ) + + n["in"].setValue( "${a}/$b/${a:b}" ) + self.assertEqual( n["in"].getValue(), os.path.join("${a}", "$b", "${a:b}" ) ) + + # but expansions should happen magically when the compute() + # calls getValue(). + context = Gaffer.Context() + context.setFrame( 10 ) + n["in"].setValue( "testyTesty.###.exr" ) + with context : + self.assertEqual( n["out"].getValue(), "testyTesty.010.exr" ) + + context["A"] = "apple" + n["in"].setValue( "what/a/lovely/$A" ) + with context : + self.assertEqual( n["out"].getValue(), os.path.join( "what", "a", "lovely", "apple" ) ) + n["in"].setValue( "what/a/lovely/${A}" ) + with context : + self.assertEqual( n["out"].getValue(), os.path.join( "what", "a", "lovely", "apple" ) ) + context["A"] = "peach" + with context : + self.assertEqual( n["out"].getValue(), os.path.join( "what", "a", "lovely", "peach" ) ) + + context["env:dir"] = "a/path" + n["in"].setValue( "a/${env:dir}/b" ) + with context : + self.assertEqual( n["out"].getValue(), os.path.join( "a", "a", "path", "b" ) ) + + n["in"].setValue( "$dontExist" ) + with context : + self.assertEqual( n["out"].getValue(), "" ) + + # once again, nothing should be expanded when we're in a + # non-computation context + n["in"].setValue( "testyTesty.##.exr" ) + self.assertEqual( n["in"].getValue(), "testyTesty.##.exr" ) + + def testRecursiveExpansion( self ) : + + n = GafferTest.FileSystemPathInOutNode() + n["in"].setValue( "$a" ) + + context = Gaffer.Context() + context["a"] = "a$b" + context["b"] = "b" + + with context : + self.assertEqual( n["out"].getValue(), "ab" ) + + def testRecursiveExpansionCycles( self ) : + + n = GafferTest.FileSystemPathInOutNode() + n["in"].setValue( "$a" ) + + context = Gaffer.Context() + context["a"] = "a$b" + context["b"] = "b$a" + + with context : + self.assertRaises( RuntimeError, n["out"].getValue ) + + def testDefaultValueExpansion( self ) : + + n = GafferTest.FileSystemPathInOutNode( defaultValue = "${A}" ) + context = Gaffer.Context() + context["A"] = "b" + with context : + self.assertEqual( n["out"].getValue(), "b" ) + + def testExpansionFromInputConnection( self ) : + + p = Gaffer.FileSystemPathPlug() + p.setValue( "${foo}" ) + + n = GafferTest.FileSystemPathInOutNode() + n["in"].setInput( p ) + + c = Gaffer.Context() + with c : + self.assertEqual( n["out"].getValue(), "" ) + h = n["out"].hash() + + c["foo"] = "foo" + with c : + self.assertNotEqual( n["out"].hash(), h ) + self.assertEqual( n["out"].getValue(), "foo" ) + + def testExpansionMask( self ) : + + n1 = GafferTest.FileSystemPathInOutNode( substitutions = Gaffer.Context.Substitutions.AllSubstitutions ) + n2 = GafferTest.FileSystemPathInOutNode( substitutions = Gaffer.Context.Substitutions.AllSubstitutions & ~Gaffer.Context.Substitutions.FrameSubstitutions ) + + n1["in"].setValue( "hello.####.${ext}" ) + n2["in"].setValue( "hello.####.${ext}" ) + self.assertEqual( n1["out"].getValue(), os.path.expanduser( "hello.0001." ) ) + self.assertEqual( n2["out"].getValue(), os.path.expanduser( "hello.####." ) ) + + c = Gaffer.Context() + c["ext"] = "cob" + c.setFrame( 10 ) + with c : + self.assertEqual( n1["out"].getValue(), os.path.expanduser( "hello.0010.cob" ) ) + self.assertEqual( n2["out"].getValue(), os.path.expanduser( "hello.####.cob" ) ) + + def testSubstitutionsSerialisation( self ) : + + s = Gaffer.ScriptNode() + s["n"] = Gaffer.Node() + s["n"]["p"] = Gaffer.FileSystemPathPlug( + "p", + flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, + substitutions = Gaffer.Context.Substitutions.AllSubstitutions & ~Gaffer.Context.Substitutions.FrameSubstitutions + ) + self.assertEqual( s["n"]["p"].substitutions(), Gaffer.Context.Substitutions.AllSubstitutions & ~Gaffer.Context.Substitutions.FrameSubstitutions ) + + s2 = Gaffer.ScriptNode() + s2.execute( s.serialise() ) + self.assertEqual( s["n"]["p"].substitutions(), s2["n"]["p"].substitutions() ) + + def testSubstitutionsRepr( self ) : + + p = Gaffer.FileSystemPathPlug( + substitutions = Gaffer.Context.Substitutions.TildeSubstitutions | Gaffer.Context.Substitutions.FrameSubstitutions + ) + + p2 = eval( repr( p ) ) + self.assertEqual( p.substitutions(), p2.substitutions() ) + + def testSubstitutionsCounterpart( self ) : + + p = Gaffer.FileSystemPathPlug( + substitutions = Gaffer.Context.Substitutions.TildeSubstitutions | Gaffer.Context.Substitutions.FrameSubstitutions + ) + + p2 = p.createCounterpart( "p2", p.Direction.In ) + self.assertEqual( p.substitutions(), p2.substitutions() ) + + def testTildeExpansion( self ) : + + n = GafferTest.FileSystemPathInOutNode() + + n["in"].setValue( "~" ) + self.assertEqual( n["out"].getValue(), os.path.expanduser( "~" ) ) + + n["in"].setValue( "~/something.tif" ) + self.assertEqual( n["out"].getValue(), os.path.join( os.path.expanduser( "~"), "something.tif" ) ) + + # ~ shouldn't be expanded unless it's at the front - it would + # be meaningless in other cases. + n["in"].setValue( "in/~1900" ) + self.assertEqual( n["out"].getValue(), os.path.join("in", "~1900" ) ) + + def testEnvironmentExpansion( self ) : + + n = GafferTest.FileSystemPathInOutNode() + + n["in"].setValue( "${NOT_AN_ENVIRONMENT_VARIABLE}" ) + h1 = n["out"].hash() + self.assertEqual( n["out"].getValue(), "" ) + + n["in"].setValue( "${GAFFER_ROOT}" ) + self.assertEqual( n["out"].getValue(), os.environ["GAFFER_ROOT"] ) + h2 = n["out"].hash() + self.assertNotEqual( h1, h2 ) + + context = Gaffer.Context() + context["GAFFER_ROOT"] = "b" + with context : + # context should win against environment + self.assertEqual( n["out"].getValue(), "b" ) + self.assertNotEqual( n["out"].hash(), h1 ) + self.assertNotEqual( n["out"].hash(), h2 ) + + def testSubstitutionsFromExpressionInput( self ) : + + s = Gaffer.ScriptNode() + + # Should output a substituted version of the input. + s["substitionsOn"] = GafferTest.FileSystemPathInOutNode() + + # Should pass through the input directly, without substitutions. + s["substitionsOff"] = GafferTest.FileSystemPathInOutNode( substitutions = Gaffer.Context.Substitutions.NoSubstitutions ) + + # The third case is trickier. The "in" plug on the node + # itself requests no substitutions, but it receives its + # input via an indirect connection with substitutions + # turned on. We resolve this by defining substitutions + # to occur only when observing a value inside a compute, + # and to always be determined by the plug used to access + # the value. A chain of connections can be thought of as + # carrying an unsubstituted string all the way along + # internally, with each plug along the way determining + # the substitutions applied when peeking in to see the value + # at that point. + # + # In practice this works best because typically it is only + # nodes that know when a substitution is relevant, and the + # user shouldn't be burdened with the job of thinking about + # them when making intermediate connections to that node. + s["substitionsOnIndirectly"] = GafferTest.FileSystemPathInOutNode( substitutions = Gaffer.Context.Substitutions.NoSubstitutions ) + s["substitionsOnIndirectly"]["user"]["in"] = Gaffer.FileSystemPathPlug() + s["substitionsOnIndirectly"]["in"].setInput( s["substitionsOnIndirectly"]["user"]["in"] ) + + # All three nodes above receive their input from this expression + # which outputs a sequence value to be substituted (or not). + + s["e"] = Gaffer.Expression() + s["e"].setExpression( inspect.cleandoc( + """ + parent["substitionsOn"]["in"] = "test.#.exr" + parent["substitionsOff"]["in"] = "test.#.exr" + parent["substitionsOnIndirectly"]["user"]["in"] = "test.#.exr" + """ + ) ) + + with Gaffer.Context() as c : + + # Frame 1 + ######### + + c.setFrame( 1 ) + + # The output of the expression itself is not substituted. + # Substitutions occur only on input plugs. + + self.assertEqual( s["substitionsOn"]["in"].getInput().getValue(), "test.#.exr" ) + self.assertEqual( s["substitionsOff"]["in"].getInput().getValue(), "test.#.exr" ) + self.assertEqual( s["substitionsOnIndirectly"]["user"]["in"].getInput().getValue(), "test.#.exr" ) + + # We should get frame numbers out of the substituting node. + + self.assertEqual( s["substitionsOn"]["out"].getValue(), "test.1.exr" ) + substitutionsOnHash1 = s["substitionsOn"]["out"].hash() + self.assertEqual( s["substitionsOn"]["out"].getValue( _precomputedHash = substitutionsOnHash1 ), "test.1.exr" ) + + # We should get sequences out of the non-substituting node. + + self.assertEqual( s["substitionsOff"]["out"].getValue(), "test.#.exr" ) + substitutionsOffHash1 = s["substitionsOff"]["out"].hash() + self.assertEqual( s["substitionsOff"]["out"].getValue( _precomputedHash = substitutionsOffHash1 ), "test.#.exr" ) + self.assertNotEqual( substitutionsOnHash1, substitutionsOffHash1 ) + + # We shouldn't get frame numbers out of the third node, because the + # requirements of the node (no substitutions) trump any upstream opinions. + # Substitutions are performed by the plug during value access, and do not + # affect the actual data flow. + + self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue(), "test.#.exr" ) + substitionsOnIndirectlyHash1 = s["substitionsOnIndirectly"]["out"].hash() + self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue( _precomputedHash = substitionsOnIndirectlyHash1 ), "test.#.exr" ) + + # Frame 2 + ######### + + c.setFrame( 2 ) + + # The output of the expression itself is not substituted. + # Substitutions occur only on input plugs. + + self.assertEqual( s["substitionsOn"]["in"].getInput().getValue(), "test.#.exr" ) + self.assertEqual( s["substitionsOff"]["in"].getInput().getValue(), "test.#.exr" ) + self.assertEqual( s["substitionsOnIndirectly"]["user"]["in"].getInput().getValue(), "test.#.exr" ) + + # We should get frame numbers out of the substituting node. + # The hash must has changed to make this possible. + + self.assertEqual( s["substitionsOn"]["out"].getValue(), "test.2.exr" ) + substitutionsOnHash2 = s["substitionsOn"]["out"].hash() + self.assertEqual( s["substitionsOn"]["out"].getValue( _precomputedHash = substitutionsOnHash2 ), "test.2.exr" ) + self.assertNotEqual( substitutionsOnHash2, substitutionsOnHash1 ) + + # We should still get sequences out of the non-substituting node, + # and it should have the same output hash as it had on frame 1. + + self.assertEqual( s["substitionsOff"]["out"].getValue(), "test.#.exr" ) + substitutionsOffHash2 = s["substitionsOff"]["out"].hash() + self.assertEqual( s["substitionsOff"]["out"].getValue( _precomputedHash = substitutionsOffHash2 ), "test.#.exr" ) + self.assertEqual( substitutionsOffHash1, substitutionsOffHash2 ) + self.assertNotEqual( substitutionsOnHash2, substitutionsOffHash2 ) + + # The third node should still be non-substituting. + + self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue(), "test.#.exr" ) + substitionsOnIndirectlyHash2 = s["substitionsOnIndirectly"]["out"].hash() + self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue( _precomputedHash = substitionsOnIndirectlyHash2 ), "test.#.exr" ) + self.assertEqual( substitionsOnIndirectlyHash2, substitionsOnIndirectlyHash1 ) + + + +if __name__ == "__main__": + unittest.main() diff --git a/python/GafferTest/__init__.py b/python/GafferTest/__init__.py index a4c0db0176e..c7f48cb9ec2 100644 --- a/python/GafferTest/__init__.py +++ b/python/GafferTest/__init__.py @@ -164,6 +164,8 @@ def inCI( platforms = set() ) : from .SpreadsheetTest import SpreadsheetTest from .ShufflePlugTest import ShufflePlugTest from .EditScopeTest import EditScopeTest +from .FileSystemPathInOutNode import FileSystemPathInOutNode +from .FileSystemPathPlugTest import FileSystemPathPlugTest from .IECorePreviewTest import * diff --git a/src/Gaffer/FileSystemPathPlug.cpp b/src/Gaffer/FileSystemPathPlug.cpp new file mode 100644 index 00000000000..bfba68d6b62 --- /dev/null +++ b/src/Gaffer/FileSystemPathPlug.cpp @@ -0,0 +1,188 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2011-2012, John Haddon. All rights reserved. +// Copyright (c) 2011-2015, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#include "Gaffer/FileSystemPathPlug.h" +#include "Gaffer/FileSystemPath.h" +#include "Gaffer/PathFilter.h" + +#include "Gaffer/Context.h" +#include "Gaffer/Process.h" + +using namespace IECore; +using namespace Gaffer; + +IE_CORE_DEFINERUNTIMETYPED( FileSystemPathPlug ); + +namespace +{ + + // Before using the HashProcess/ComputeProcess classes to get a hash or + // a value, we first traverse back down the chain of input plugs to the + // start, or till we find a plug of a different type. This traversal is + /// much quicker than using the Process classes for every step in the chain + /// and avoids the creation of lots of unnecessary cache entries. + inline const ValuePlug *sourcePlug(const ValuePlug *p) + { + const IECore::TypeId typeId = p->typeId(); + + const ValuePlug *in = p->getInput(); + while (in && in->typeId() == typeId) + { + p = in; + in = p->getInput(); + } + + return p; + } + +} // namespace + +FileSystemPathPlug::FileSystemPathPlug( + const std::string &name, + Direction direction, + const std::string &defaultValue, + unsigned flags, + unsigned substitutions +) + : StringPlug( name, direction, defaultValue, flags, substitutions ) +{ +} + +FileSystemPathPlug::~FileSystemPathPlug() +{ +} + +bool FileSystemPathPlug::acceptsInput( const Plug *input ) const +{ + if( !ValuePlug::acceptsInput( input ) ) + { + return false; + } + if( input ) + { + return input->isInstanceOf( staticTypeId() ) || input->isInstanceOf( StringPlug::staticTypeId() ); + } + return true; +} + +PlugPtr FileSystemPathPlug::createCounterpart( const std::string &name, Direction direction ) const +{ + return new FileSystemPathPlug( name, direction, defaultValue(), getFlags(), substitutions() ); +} + +void FileSystemPathPlug::setValue(const std::string &value) +{ + // Set the value to the generic string representation + // This helps when calling getValue since it won't remove + // back slashes when calling substitute + setObjectValue(new StringData(Gaffer::FileSystemPath(value).string())); +} + +std::string FileSystemPathPlug::getValue( const IECore::MurmurHash *precomputedHash, const Context *context, const bool forceSubstitutions ) const +{ + if( !context ) + { + context = Context::current(); + } + IECore::ConstObjectPtr o = getObjectValue(precomputedHash); + const IECore::StringData *s = IECore::runTimeCast(o.get()); + if (!s) + { + throw IECore::Exception("FileSystemPathPlug::getObjectValue() didn't return StringData - is the hash being computed correctly?"); + } + + const bool performSubstitutions = + forceSubstitutions || + (substitutions() && + direction() == In && + Process::current() && + IECore::StringAlgo::hasSubstitutions(s->readable())); + const std::string substituted_path = performSubstitutions ? context->substitute(s->readable(), substitutions()) : s->readable(); + return Gaffer::FileSystemPath(substituted_path).nativeString(); +} + +void FileSystemPathPlug::setFrom(const ValuePlug *other) +{ + if (const FileSystemPathPlug *tOther = runTimeCast(other)) + { + setValue(tOther->getValue()); + } + else if (const StringPlug *tOther = runTimeCast(other)) + { + setValue(tOther->getValue()); + } + else + { + throw IECore::Exception("Unsupported plug type"); + } +} + +IECore::MurmurHash FileSystemPathPlug::hash() const +{ + const bool performSubstitutions = + substitutions() && + direction() == In + ; + + // We need to allow backwards compatibility with StringPlug. + // Check to see if our root plug is a StringPlug and return + // its hash. + const ValuePlug *r = sourcePlug(this); + if (const StringPlug *p = runTimeCast(r->getInput())) + { + return p->hash(); + } + if (performSubstitutions) + { + IECore::ConstObjectPtr o = getObjectValue(); + const IECore::StringData *s = IECore::runTimeCast(o.get()); + if (!s) + { + throw IECore::Exception("StringPlug::getObjectValue() didn't return StringData - is the hash being computed correctly?"); + } + + if (IECore::StringAlgo::hasSubstitutions(s->readable())) + { + IECore::MurmurHash result; + result.append(Context::current()->substitute(s->readable(), substitutions())); + return result; + } + } + + // no substitutions + return ValuePlug::hash(); +} diff --git a/src/GafferDispatch/Dispatcher.cpp b/src/GafferDispatch/Dispatcher.cpp index 6e63b27c6fd..8023ac587a0 100644 --- a/src/GafferDispatch/Dispatcher.cpp +++ b/src/GafferDispatch/Dispatcher.cpp @@ -185,7 +185,7 @@ const std::string Dispatcher::jobDirectory() const void Dispatcher::createJobDirectory( const Gaffer::ScriptNode *script, Gaffer::Context *context ) const { - boost::filesystem::path jobDirectory( context->substitute( jobsDirectoryPlug()->getValue() ) ); + boost::filesystem::path jobDirectory( jobsDirectoryPlug()->getValue(nullptr, context, true) ); jobDirectory /= context->substitute( jobNamePlug()->getValue() ); if( jobDirectory == "" ) diff --git a/src/GafferImage/OpenImageIOReader.cpp b/src/GafferImage/OpenImageIOReader.cpp index 521640e22cc..a9e0193ea69 100644 --- a/src/GafferImage/OpenImageIOReader.cpp +++ b/src/GafferImage/OpenImageIOReader.cpp @@ -716,7 +716,8 @@ FilePtr retrieveFile( std::string &fileName, OpenImageIOReader::MissingFrameMode return nullptr; } - const std::string resolvedFileName = context->substitute( fileName ); + // All other substitutions are handled in the FileSystemPathPlug + const std::string resolvedFileName = context->substitute( fileName, IECore::StringAlgo::Substitutions::FrameSubstitutions ); FileHandleCache *cache = fileCache(); CacheEntry cacheEntry = cache->get( resolvedFileName ); diff --git a/src/GafferModule/FileSystemPathPlugBinding.cpp b/src/GafferModule/FileSystemPathPlugBinding.cpp new file mode 100644 index 00000000000..bb7d9da23de --- /dev/null +++ b/src/GafferModule/FileSystemPathPlugBinding.cpp @@ -0,0 +1,153 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2015, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#include "FileSystemPathPlugBinding.h" + +#include "GafferBindings/ValuePlugBinding.h" + +#include "Gaffer/FileSystemPathPlug.h" + +#include "IECorePython/ScopedGILRelease.h" + +#include "IECore/StringAlgo.h" + +using namespace boost::python; +using namespace Gaffer; +using namespace GafferBindings; + +namespace +{ + +void setValue( FileSystemPathPlug *plug, const std::string& value ) +{ + // we use a GIL release here to prevent a lock in the case where this triggers a graph + // evaluation which decides to go back into python on another thread: + IECorePython::ScopedGILRelease r; + plug->setValue( value ); +} + +std::string getValue( const FileSystemPathPlug *plug, const IECore::MurmurHash *precomputedHash ) +{ + // Must release GIL in case computation spawns threads which need + // to reenter Python. + IECorePython::ScopedGILRelease r; + return plug->getValue( precomputedHash ); +} + +std::string substitutionsRepr( unsigned substitutions ) +{ + static const IECore::StringAlgo::Substitutions values[] = { IECore::StringAlgo::FrameSubstitutions, IECore::StringAlgo::VariableSubstitutions, IECore::StringAlgo::EscapeSubstitutions, IECore::StringAlgo::TildeSubstitutions,IECore::StringAlgo::NoSubstitutions }; + static const char *names[] = { "FrameSubstitutions", "VariableSubstitutions", "EscapeSubstitutions", "TildeSubstitutions", nullptr }; + + if( substitutions == IECore::StringAlgo::AllSubstitutions ) + { + return "Gaffer.Context.Substitutions.AllSubstitutions"; + } + else if( substitutions == IECore::StringAlgo::NoSubstitutions ) + { + return "Gaffer.Context.Substitutions.NoSubstitutions"; + } + + std::string result; + for( int i = 0; names[i]; ++i ) + { + if( substitutions & values[i] ) + { + if( result.size() ) + { + result += " | "; + } + result += "Gaffer.Context.Substitutions." + std::string( names[i] ); + } + } + + return result; +} + +std::string serialisationRepr( const Gaffer::FileSystemPathPlug *plug, Serialisation *serialisation ) +{ + std::string extraArguments; + if( plug->substitutions() != IECore::StringAlgo::AllSubstitutions ) + { + extraArguments = "substitutions = " + substitutionsRepr( plug->substitutions() ); + } + return ValuePlugSerialiser::repr( plug, extraArguments, serialisation ); +} + +std::string repr( const Gaffer::FileSystemPathPlug *plug ) +{ + return serialisationRepr( plug, nullptr ); +} + +class FileSystemPathPlugSerialiser : public ValuePlugSerialiser +{ + + public : + + std::string constructor( const Gaffer::GraphComponent *graphComponent, Serialisation &serialisation ) const override + { + return serialisationRepr( static_cast( graphComponent ), &serialisation ); + } + +}; + +} // namespace + +void GafferModule::bindFileSystemPathPlug() +{ + + PlugClass() + .def( + boost::python::init( + ( + boost::python::arg_( "name" )=Gaffer::GraphComponent::defaultName(), + boost::python::arg_( "direction" )=Gaffer::Plug::In, + boost::python::arg_( "defaultValue" )="", + boost::python::arg_( "flags" )=Gaffer::Plug::Default, + boost::python::arg_( "substitutions" )=IECore::StringAlgo::AllSubstitutions + ) + ) + ) + .def( "__repr__", &repr ) + .def( "substitutions", &FileSystemPathPlug::substitutions ) + .def( "defaultValue", &FileSystemPathPlug::defaultValue, return_value_policy() ) + .def( "setValue", &setValue ) + .def( "getValue", &getValue, ( boost::python::arg( "_precomputedHash" ) = object() ) ) + ; + + Serialisation::registerSerialiser( FileSystemPathPlug::staticTypeId(), new FileSystemPathPlugSerialiser ); + +} diff --git a/src/GafferModule/FileSystemPathPlugBinding.h b/src/GafferModule/FileSystemPathPlugBinding.h new file mode 100644 index 00000000000..1cdb5fac44b --- /dev/null +++ b/src/GafferModule/FileSystemPathPlugBinding.h @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2015, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFERMODULE_FILESYSTEMPATHPLUGBINDING_H +#define GAFFERMODULE_FILESYSTEMPATHPLUGBINDING_H + +namespace GafferModule +{ + +void bindFileSystemPathPlug(); + +} // namespace GafferModule + +#endif // GAFFERMODULE_STRINGPLUGBINDING_H diff --git a/src/GafferModule/GafferModule.cpp b/src/GafferModule/GafferModule.cpp index 69d1b03b559..e2f61a5d9cb 100644 --- a/src/GafferModule/GafferModule.cpp +++ b/src/GafferModule/GafferModule.cpp @@ -48,6 +48,7 @@ #include "DirtyPropagationScopeBinding.h" #include "DotBinding.h" #include "ExpressionBinding.h" +#include "FileSystemPathPlugBinding.h" #include "GraphComponentBinding.h" #include "ProcessMessageHandlerBinding.h" #include "MetadataAlgoBinding.h" @@ -245,6 +246,7 @@ BOOST_PYTHON_MODULE( _Gaffer ) bindNodeAlgo(); bindShuffles(); bindMessages(); + bindFileSystemPathPlug(); NodeClass(); From e593e13e2860b679b551a38836e936ed914fa380 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 28 Nov 2018 18:37:24 -0500 Subject: [PATCH 076/123] FileSystemPathPlug : convert StringPlugs --- include/Gaffer/ScriptNode.h | 6 ++-- include/GafferDispatch/Dispatcher.h | 5 ++-- include/GafferImage/Catalogue.h | 9 +++--- include/GafferImage/ImageReader.h | 5 ++-- include/GafferImage/ImageWriter.h | 5 ++-- include/GafferImage/LUT.h | 6 ++-- include/GafferImage/OpenImageIOReader.h | 5 ++-- include/GafferImage/Text.h | 5 ++-- include/GafferScene/ExternalProcedural.h | 5 ++-- include/GafferScene/Render.h | 5 ++-- include/GafferScene/SceneReader.h | 5 ++-- include/GafferScene/SceneWriter.h | 5 ++-- include/GafferScene/Text.h | 5 ++-- include/GafferSceneUI/UVView.h | 5 ++-- src/Gaffer/ScriptNode.cpp | 12 ++++---- src/GafferDispatch/Dispatcher.cpp | 11 ++++---- src/GafferImage/Catalogue.cpp | 35 ++++++++++++------------ src/GafferImage/ImageReader.cpp | 11 ++++---- src/GafferImage/ImageWriter.cpp | 18 ++++++++---- src/GafferImage/LUT.cpp | 12 ++++---- src/GafferImage/OpenImageIOReader.cpp | 14 +++++----- src/GafferImage/Text.cpp | 11 ++++---- src/GafferScene/ExternalProcedural.cpp | 12 ++++---- src/GafferScene/Outputs.cpp | 3 +- src/GafferScene/Render.cpp | 10 +++---- src/GafferScene/SceneReader.cpp | 11 ++++---- src/GafferScene/SceneWriter.cpp | 12 ++++---- src/GafferScene/Text.cpp | 11 ++++---- src/GafferSceneUI/UVView.cpp | 20 +++++++------- 29 files changed, 152 insertions(+), 127 deletions(-) diff --git a/include/Gaffer/ScriptNode.h b/include/Gaffer/ScriptNode.h index 89b96331d61..9a789cd46df 100644 --- a/include/Gaffer/ScriptNode.h +++ b/include/Gaffer/ScriptNode.h @@ -67,7 +67,7 @@ IE_CORE_FORWARDDECLARE( ApplicationRoot ); IE_CORE_FORWARDDECLARE( Context ); IE_CORE_FORWARDDECLARE( StandardSet ); IE_CORE_FORWARDDECLARE( CompoundDataPlug ); -IE_CORE_FORWARDDECLARE( StringPlug ); +IE_CORE_FORWARDDECLARE( FileSystemPathPlug ); typedef Container ScriptContainer; IE_CORE_DECLAREPTR( ScriptContainer ); @@ -220,8 +220,8 @@ class GAFFER_API ScriptNode : public Node //////////////////////////////////////////////////////////////////// /// Returns the plug which specifies the file used in all load and save /// operations. - StringPlug *fileNamePlug(); - const StringPlug *fileNamePlug() const; + FileSystemPathPlug *fileNamePlug(); + const FileSystemPathPlug *fileNamePlug() const; /// Returns a plug which is used to flag when the script has had changes /// made since the last call to save(). BoolPlug *unsavedChangesPlug(); diff --git a/include/GafferDispatch/Dispatcher.h b/include/GafferDispatch/Dispatcher.h index 08cd4b686b0..52acafef893 100644 --- a/include/GafferDispatch/Dispatcher.h +++ b/include/GafferDispatch/Dispatcher.h @@ -60,6 +60,7 @@ namespace Gaffer { IE_CORE_FORWARDDECLARE( StringPlug ) +IE_CORE_FORWARDDECLARE( FileSystemPathPlug ) } // namespace Gaffer @@ -170,8 +171,8 @@ class GAFFERDISPATCH_API Dispatcher : public Gaffer::Node const Gaffer::StringPlug *jobNamePlug() const; /// Returns the plug which specifies the directory used by dispatchers to store temporary /// files on a per-job basis. - Gaffer::StringPlug *jobsDirectoryPlug(); - const Gaffer::StringPlug *jobsDirectoryPlug() const; + Gaffer::FileSystemPathPlug *jobsDirectoryPlug(); + const Gaffer::FileSystemPathPlug *jobsDirectoryPlug() const; /// At the start of dispatch(), a directory is created under jobsDirectoryPlug + jobNamePlug /// which the dispatcher writes temporary files to. This method returns the most recent created directory. const std::string jobDirectory() const; diff --git a/include/GafferImage/Catalogue.h b/include/GafferImage/Catalogue.h index 158a89d6ea3..d93556481bd 100644 --- a/include/GafferImage/Catalogue.h +++ b/include/GafferImage/Catalogue.h @@ -41,6 +41,7 @@ #include "Gaffer/NumericPlug.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "Gaffer/Switch.h" #include "IECoreImage/DisplayDriver.h" @@ -77,8 +78,8 @@ class GAFFERIMAGE_API Catalogue : public ImageNode Image( const std::string &name = defaultName(), Direction direction = In, unsigned flags = Default ); - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; Gaffer::StringPlug *descriptionPlug(); const Gaffer::StringPlug *descriptionPlug() const; @@ -117,8 +118,8 @@ class GAFFERIMAGE_API Catalogue : public ImageNode Gaffer::StringPlug *namePlug(); const Gaffer::StringPlug *namePlug() const; - Gaffer::StringPlug *directoryPlug(); - const Gaffer::StringPlug *directoryPlug() const; + Gaffer::FileSystemPathPlug *directoryPlug(); + const Gaffer::FileSystemPathPlug *directoryPlug() const; /// All Catalogues share a single DisplayDriverServer instance /// to receive rendered images. To send an image to the catalogues, diff --git a/include/GafferImage/ImageReader.h b/include/GafferImage/ImageReader.h index a8a1b9f14bb..73c116caf9f 100644 --- a/include/GafferImage/ImageReader.h +++ b/include/GafferImage/ImageReader.h @@ -47,6 +47,7 @@ namespace Gaffer { IE_CORE_FORWARDDECLARE( StringPlug ) +IE_CORE_FORWARDDECLARE( FileSystemPathPlug ) } // namespace Gaffer @@ -87,8 +88,8 @@ class GAFFERIMAGE_API ImageReader : public ImageNode ClampToFrame, }; - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; /// Number of times the node has been refreshed. Gaffer::IntPlug *refreshCountPlug(); diff --git a/include/GafferImage/ImageWriter.h b/include/GafferImage/ImageWriter.h index f8cc57c53b4..9db8da3672b 100644 --- a/include/GafferImage/ImageWriter.h +++ b/include/GafferImage/ImageWriter.h @@ -50,6 +50,7 @@ namespace Gaffer { IE_CORE_FORWARDDECLARE( ValuePlug ) IE_CORE_FORWARDDECLARE( StringPlug ) + IE_CORE_FORWARDDECLARE( FileSystemPathPlug ) } // namespace Gaffer namespace GafferImage @@ -74,8 +75,8 @@ class GAFFERIMAGE_API ImageWriter : public GafferDispatch::TaskNode GAFFER_NODE_DECLARE_TYPE( GafferImage::ImageWriter, ImageWriterTypeId, TaskNode ); - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; GafferImage::ImagePlug *inPlug(); const GafferImage::ImagePlug *inPlug() const; diff --git a/include/GafferImage/LUT.h b/include/GafferImage/LUT.h index 9692ce3e19c..f90b672bb3a 100644 --- a/include/GafferImage/LUT.h +++ b/include/GafferImage/LUT.h @@ -44,7 +44,7 @@ namespace Gaffer { -IE_CORE_FORWARDDECLARE( StringPlug ) +IE_CORE_FORWARDDECLARE( FileSystemPathPlug ) } // namespace Gaffer @@ -75,8 +75,8 @@ class GAFFERIMAGE_API LUT : public OpenColorIOTransform Inverse }; - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; Gaffer::IntPlug *interpolationPlug(); const Gaffer::IntPlug *interpolationPlug() const; diff --git a/include/GafferImage/OpenImageIOReader.h b/include/GafferImage/OpenImageIOReader.h index 6d593d97564..5e2eaf5d820 100644 --- a/include/GafferImage/OpenImageIOReader.h +++ b/include/GafferImage/OpenImageIOReader.h @@ -46,6 +46,7 @@ namespace Gaffer { IE_CORE_FORWARDDECLARE( StringPlug ) +IE_CORE_FORWARDDECLARE( FileSystemPathPlug ) } // namespace Gaffer @@ -69,8 +70,8 @@ class GAFFERIMAGE_API OpenImageIOReader : public ImageNode Hold, }; - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; /// Number of times the node has been refreshed. Gaffer::IntPlug *refreshCountPlug(); diff --git a/include/GafferImage/Text.h b/include/GafferImage/Text.h index c0d6e63eaeb..eac8ce46b1f 100644 --- a/include/GafferImage/Text.h +++ b/include/GafferImage/Text.h @@ -40,6 +40,7 @@ #include "GafferImage/Shape.h" #include "Gaffer/BoxPlug.h" +#include "Gaffer/FileSystemPathPlug.h" namespace Gaffer { @@ -79,8 +80,8 @@ class GAFFERIMAGE_API Text : public Shape Gaffer::StringPlug *textPlug(); const Gaffer::StringPlug *textPlug() const; - Gaffer::StringPlug *fontPlug(); - const Gaffer::StringPlug *fontPlug() const; + Gaffer::FileSystemPathPlug *fontPlug(); + const Gaffer::FileSystemPathPlug *fontPlug() const; Gaffer::V2iPlug *sizePlug(); const Gaffer::V2iPlug *sizePlug() const; diff --git a/include/GafferScene/ExternalProcedural.h b/include/GafferScene/ExternalProcedural.h index 085dfdb9d5f..c9159c6816d 100644 --- a/include/GafferScene/ExternalProcedural.h +++ b/include/GafferScene/ExternalProcedural.h @@ -40,6 +40,7 @@ #include "GafferScene/ObjectSource.h" #include "Gaffer/CompoundDataPlug.h" +#include "Gaffer/FileSystemPathPlug.h" namespace GafferScene { @@ -54,8 +55,8 @@ class GAFFERSCENE_API ExternalProcedural : public ObjectSource ExternalProcedural( const std::string &name=defaultName() ); ~ExternalProcedural() override; - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; Gaffer::Box3fPlug *boundPlug(); const Gaffer::Box3fPlug *boundPlug() const; diff --git a/include/GafferScene/Render.h b/include/GafferScene/Render.h index 0780bf39bc3..fbbe051c7d8 100644 --- a/include/GafferScene/Render.h +++ b/include/GafferScene/Render.h @@ -44,6 +44,7 @@ #include "Gaffer/NumericPlug.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" namespace GafferScene { @@ -75,8 +76,8 @@ class GAFFERSCENE_API Render : public GafferDispatch::TaskNode Gaffer::IntPlug *modePlug(); const Gaffer::IntPlug *modePlug() const; - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; ScenePlug *outPlug(); const ScenePlug *outPlug() const; diff --git a/include/GafferScene/SceneReader.h b/include/GafferScene/SceneReader.h index 12315c55cd9..fe2aae613f2 100644 --- a/include/GafferScene/SceneReader.h +++ b/include/GafferScene/SceneReader.h @@ -47,6 +47,7 @@ namespace Gaffer { IE_CORE_FORWARDDECLARE( StringPlug ) +IE_CORE_FORWARDDECLARE( FileSystemPathPlug ) IE_CORE_FORWARDDECLARE( TransformPlug ) } // namespace Gaffer @@ -65,8 +66,8 @@ class GAFFERSCENE_API SceneReader : public SceneNode GAFFER_NODE_DECLARE_TYPE( GafferScene::SceneReader, SceneReaderTypeId, SceneNode ) /// Holds the name of the file to be loaded. - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; /// Number of times the node has been refreshed. Gaffer::IntPlug *refreshCountPlug(); diff --git a/include/GafferScene/SceneWriter.h b/include/GafferScene/SceneWriter.h index 13a5ad9702b..91c0061d5d9 100644 --- a/include/GafferScene/SceneWriter.h +++ b/include/GafferScene/SceneWriter.h @@ -44,6 +44,7 @@ #include "Gaffer/TypedPlug.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "IECoreScene/SceneInterface.h" @@ -60,8 +61,8 @@ class GAFFERSCENE_API SceneWriter : public GafferDispatch::TaskNode GAFFER_NODE_DECLARE_TYPE( GafferScene::SceneWriter, SceneWriterTypeId, GafferDispatch::TaskNode ); - Gaffer::StringPlug *fileNamePlug(); - const Gaffer::StringPlug *fileNamePlug() const; + Gaffer::FileSystemPathPlug *fileNamePlug(); + const Gaffer::FileSystemPathPlug *fileNamePlug() const; ScenePlug *inPlug(); const ScenePlug *inPlug() const; diff --git a/include/GafferScene/Text.h b/include/GafferScene/Text.h index 80018c08afa..87776a783db 100644 --- a/include/GafferScene/Text.h +++ b/include/GafferScene/Text.h @@ -39,6 +39,7 @@ #include "GafferScene/Export.h" #include "GafferScene/ObjectSource.h" +#include "Gaffer/FileSystemPathPlug.h" namespace GafferScene { @@ -56,8 +57,8 @@ class GAFFERSCENE_API Text : public ObjectSource Gaffer::StringPlug *textPlug(); const Gaffer::StringPlug *textPlug() const; - Gaffer::StringPlug *fontPlug(); - const Gaffer::StringPlug *fontPlug() const; + Gaffer::FileSystemPathPlug *fontPlug(); + const Gaffer::FileSystemPathPlug *fontPlug() const; void affects( const Gaffer::Plug *input, AffectedPlugsContainer &outputs ) const override; diff --git a/include/GafferSceneUI/UVView.h b/include/GafferSceneUI/UVView.h index 32be86f8ce9..c5928745cc1 100644 --- a/include/GafferSceneUI/UVView.h +++ b/include/GafferSceneUI/UVView.h @@ -48,6 +48,7 @@ #include "Gaffer/BackgroundTask.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include @@ -71,8 +72,8 @@ class GAFFERSCENEUI_API UVView : public GafferUI::View Gaffer::StringPlug *uvSetPlug(); const Gaffer::StringPlug *uvSetPlug() const; - Gaffer::StringPlug *textureFileNamePlug(); - const Gaffer::StringPlug *textureFileNamePlug() const; + Gaffer::FileSystemPathPlug *textureFileNamePlug(); + const Gaffer::FileSystemPathPlug *textureFileNamePlug() const; Gaffer::StringPlug *displayTransformPlug(); const Gaffer::StringPlug *displayTransformPlug() const; diff --git a/src/Gaffer/ScriptNode.cpp b/src/Gaffer/ScriptNode.cpp index cf96109cc12..d2aa5cbb8ec 100644 --- a/src/Gaffer/ScriptNode.cpp +++ b/src/Gaffer/ScriptNode.cpp @@ -45,7 +45,7 @@ #include "Gaffer/DependencyNode.h" #include "Gaffer/MetadataAlgo.h" #include "Gaffer/StandardSet.h" -#include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "Gaffer/TypedPlug.h" #include "IECore/Exception.h" @@ -334,7 +334,7 @@ ScriptNode::ScriptNode( const std::string &name ) { storeIndexOfNextChild( g_firstPlugIndex ); - addChild( new StringPlug( "fileName", Plug::In, "", Plug::Default & ~Plug::Serialisable ) ); + addChild( new FileSystemPathPlug( "fileName", Plug::In, "", Plug::Default & ~Plug::Serialisable ) ); addChild( new BoolPlug( "unsavedChanges", Plug::In, false, Plug::Default & ~Plug::Serialisable ) ); ValuePlugPtr frameRangePlug = new ValuePlug( "frameRange", Plug::In ); @@ -362,14 +362,14 @@ ScriptNode::~ScriptNode() { } -StringPlug *ScriptNode::fileNamePlug() +FileSystemPathPlug *ScriptNode::fileNamePlug() { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -const StringPlug *ScriptNode::fileNamePlug() const +const FileSystemPathPlug *ScriptNode::fileNamePlug() const { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } BoolPlug *ScriptNode::unsavedChangesPlug() diff --git a/src/GafferDispatch/Dispatcher.cpp b/src/GafferDispatch/Dispatcher.cpp index 8023ac587a0..13860f75219 100644 --- a/src/GafferDispatch/Dispatcher.cpp +++ b/src/GafferDispatch/Dispatcher.cpp @@ -41,6 +41,7 @@ #include "Gaffer/Process.h" #include "Gaffer/ScriptNode.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "Gaffer/SubGraph.h" #include "Gaffer/Switch.h" @@ -131,7 +132,7 @@ Dispatcher::Dispatcher( const std::string &name ) addChild( new IntPlug( "framesMode", Plug::In, CurrentFrame, CurrentFrame ) ); addChild( new StringPlug( "frameRange", Plug::In, "1-100x10" ) ); addChild( new StringPlug( "jobName", Plug::In, "" ) ); - addChild( new StringPlug( "jobsDirectory", Plug::In, "" ) ); + addChild( new FileSystemPathPlug( "jobsDirectory", Plug::In, "" ) ); } Dispatcher::~Dispatcher() @@ -168,14 +169,14 @@ const StringPlug *Dispatcher::jobNamePlug() const return getChild( g_firstPlugIndex + 2 ); } -StringPlug *Dispatcher::jobsDirectoryPlug() +FileSystemPathPlug *Dispatcher::jobsDirectoryPlug() { - return getChild( g_firstPlugIndex + 3 ); + return getChild( g_firstPlugIndex + 3 ); } -const StringPlug *Dispatcher::jobsDirectoryPlug() const +const FileSystemPathPlug *Dispatcher::jobsDirectoryPlug() const { - return getChild( g_firstPlugIndex + 3 ); + return getChild( g_firstPlugIndex + 3 ); } const std::string Dispatcher::jobDirectory() const diff --git a/src/GafferImage/Catalogue.cpp b/src/GafferImage/Catalogue.cpp index 6714913c8d9..8398e750fa9 100644 --- a/src/GafferImage/Catalogue.cpp +++ b/src/GafferImage/Catalogue.cpp @@ -52,6 +52,7 @@ #include "Gaffer/ParallelAlgo.h" #include "Gaffer/ScriptNode.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "boost/algorithm/string.hpp" #include "boost/bind.hpp" @@ -105,7 +106,7 @@ class Catalogue::InternalImage : public ImageNode { storeIndexOfNextChild( g_firstChildIndex ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new StringPlug( "description" ) ); // Used to load an image from disk, according to @@ -165,14 +166,14 @@ class Catalogue::InternalImage : public ImageNode } } - StringPlug *fileNamePlug() + FileSystemPathPlug *fileNamePlug() { - return getChild( g_firstChildIndex ); + return getChild( g_firstChildIndex ); } - const StringPlug *fileNamePlug() const + const FileSystemPathPlug *fileNamePlug() const { - return getChild( g_firstChildIndex ); + return getChild( g_firstChildIndex ); } StringPlug *descriptionPlug() @@ -188,7 +189,7 @@ class Catalogue::InternalImage : public ImageNode void copyFrom( const InternalImage *other ) { descriptionPlug()->source()->setValue( other->descriptionPlug()->getValue() ); - fileNamePlug()->source()->setValue( other->fileNamePlug()->getValue() ); + fileNamePlug()->source()->setValue( other->fileNamePlug()->getValue() ); imageSwitch()->indexPlug()->setValue( other->imageSwitch()->indexPlug()->getValue() ); text()->enabledPlug()->setValue( other->text()->enabledPlug()->getValue() ); @@ -590,7 +591,7 @@ class Catalogue::InternalImage : public ImageNode { // Set up the client to read from the saved image client->text()->enabledPlug()->setValue( false ); - client->fileNamePlug()->source()->setValue( m_writer->fileNamePlug()->getValue() ); + client->fileNamePlug()->source()->setValue( m_writer->fileNamePlug()->getValue() ); client->imageSwitch()->indexPlug()->setValue( 0 ); // But force hashChannelData and computeChannelData to be called // so that we can reuse the cache entries created by the original @@ -629,21 +630,21 @@ GAFFER_PLUG_DEFINE_TYPE( Catalogue::Image ); Catalogue::Image::Image( const std::string &name, Direction direction, unsigned flags ) : Plug( name, direction, flags ) { - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new StringPlug( "description" ) ); addChild( new StringPlug( "__name", Plug::In, name, Plug::Default & ~Plug::Serialisable ) ); nameChangedSignal().connect( boost::bind( &Image::nameChanged, this ) ); } -Gaffer::StringPlug *Catalogue::Image::fileNamePlug() +Gaffer::FileSystemPathPlug *Catalogue::Image::fileNamePlug() { - return getChild( 0 ); + return getChild( 0 ); } -const Gaffer::StringPlug *Catalogue::Image::fileNamePlug() const +const Gaffer::FileSystemPathPlug *Catalogue::Image::fileNamePlug() const { - return getChild( 0 ); + return getChild( 0 ); } Gaffer::StringPlug *Catalogue::Image::descriptionPlug() @@ -769,7 +770,7 @@ Catalogue::Catalogue( const std::string &name ) addChild( new Plug( "images" ) ); addChild( new IntPlug( "imageIndex" ) ); addChild( new StringPlug( "name" ) ); - addChild( new StringPlug( "directory" ) ); + addChild( new FileSystemPathPlug( "directory" ) ); addChild( new IntPlug( "__imageIndex", Plug::Out ) ); // Switch used to choose which image to output @@ -833,14 +834,14 @@ const Gaffer::StringPlug *Catalogue::namePlug() const return getChild( g_firstPlugIndex + 2 ); } -Gaffer::StringPlug *Catalogue::directoryPlug() +Gaffer::FileSystemPathPlug *Catalogue::directoryPlug() { - return getChild( g_firstPlugIndex + 3 ); + return getChild( g_firstPlugIndex + 3 ); } -const Gaffer::StringPlug *Catalogue::directoryPlug() const +const Gaffer::FileSystemPathPlug *Catalogue::directoryPlug() const { - return getChild( g_firstPlugIndex + 3 ); + return getChild( g_firstPlugIndex + 3 ); } Gaffer::IntPlug *Catalogue::internalImageIndexPlug() diff --git a/src/GafferImage/ImageReader.cpp b/src/GafferImage/ImageReader.cpp index 579d980e04d..39a726c4342 100644 --- a/src/GafferImage/ImageReader.cpp +++ b/src/GafferImage/ImageReader.cpp @@ -40,6 +40,7 @@ #include "GafferImage/OpenImageIOReader.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "OpenEXR/ImathFun.h" @@ -118,7 +119,7 @@ ImageReader::ImageReader( const std::string &name ) { storeIndexOfNextChild( g_firstChildIndex ); addChild( - new StringPlug( + new FileSystemPathPlug( "fileName", Plug::In, "", /* flags */ Plug::Default, /* substitutions */ IECore::StringAlgo::AllSubstitutions & ~IECore::StringAlgo::FrameSubstitutions @@ -167,14 +168,14 @@ ImageReader::~ImageReader() { } -StringPlug *ImageReader::fileNamePlug() +FileSystemPathPlug *ImageReader::fileNamePlug() { - return getChild( g_firstChildIndex ); + return getChild( g_firstChildIndex ); } -const StringPlug *ImageReader::fileNamePlug() const +const FileSystemPathPlug *ImageReader::fileNamePlug() const { - return getChild( g_firstChildIndex ); + return getChild( g_firstChildIndex ); } IntPlug *ImageReader::refreshCountPlug() diff --git a/src/GafferImage/ImageWriter.cpp b/src/GafferImage/ImageWriter.cpp index a329d0b1914..e85c63a5819 100644 --- a/src/GafferImage/ImageWriter.cpp +++ b/src/GafferImage/ImageWriter.cpp @@ -48,6 +48,7 @@ #include "Gaffer/Context.h" #include "Gaffer/ScriptNode.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "IECoreImage/OpenImageIOAlgo.h" @@ -1244,7 +1245,12 @@ ImageSpec createImageSpec( const ImageWriter *node, const ImageOutput *out, cons spec.attribute( "HostComputer", boost::asio::ip::host_name() ); - if ( const char *artist = getenv( "USER" ) ) +#ifdef _WIN32 + const char *artist = getenv("username"); +#else + const char *artist = getenv( "USER" ); +#endif + if ( artist ) { spec.attribute( "Artist", artist ); } @@ -1277,7 +1283,7 @@ ImageWriter::ImageWriter( const std::string &name ) { storeIndexOfNextChild( g_firstPlugIndex ); addChild( new ImagePlug( "in" ) ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new StringPlug( "channels", Gaffer::Plug::In, "*" ) ); addChild( new StringPlug( "colorSpace" ) ); addChild( new ImagePlug( "out", Plug::Out, Plug::Default & ~Plug::Serialisable ) ); @@ -1382,14 +1388,14 @@ const GafferImage::ImagePlug *ImageWriter::inPlug() const return getChild( g_firstPlugIndex ); } -Gaffer::StringPlug *ImageWriter::fileNamePlug() +Gaffer::FileSystemPathPlug *ImageWriter::fileNamePlug() { - return getChild( g_firstPlugIndex+1 ); + return getChild( g_firstPlugIndex+1 ); } -const Gaffer::StringPlug *ImageWriter::fileNamePlug() const +const Gaffer::FileSystemPathPlug *ImageWriter::fileNamePlug() const { - return getChild( g_firstPlugIndex+1 ); + return getChild( g_firstPlugIndex+1 ); } Gaffer::StringPlug *ImageWriter::channelsPlug() diff --git a/src/GafferImage/LUT.cpp b/src/GafferImage/LUT.cpp index c49e9cb4213..c3a10d55749 100644 --- a/src/GafferImage/LUT.cpp +++ b/src/GafferImage/LUT.cpp @@ -36,7 +36,7 @@ #include "GafferImage/LUT.h" -#include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" using namespace std; using namespace IECore; @@ -51,7 +51,7 @@ LUT::LUT( const std::string &name ) : OpenColorIOTransform( name ) { storeIndexOfNextChild( g_firstPlugIndex ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new IntPlug( "interpolation", Plug::In, @@ -73,14 +73,14 @@ LUT::~LUT() { } -Gaffer::StringPlug *LUT::fileNamePlug() +Gaffer::FileSystemPathPlug *LUT::fileNamePlug() { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -const Gaffer::StringPlug *LUT::fileNamePlug() const +const Gaffer::FileSystemPathPlug *LUT::fileNamePlug() const { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } Gaffer::IntPlug *LUT::interpolationPlug() diff --git a/src/GafferImage/OpenImageIOReader.cpp b/src/GafferImage/OpenImageIOReader.cpp index a9e0193ea69..56272c1e7f4 100644 --- a/src/GafferImage/OpenImageIOReader.cpp +++ b/src/GafferImage/OpenImageIOReader.cpp @@ -45,6 +45,7 @@ #include "Gaffer/Context.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "IECoreImage/OpenImageIOAlgo.h" @@ -800,10 +801,9 @@ OpenImageIOReader::OpenImageIOReader( const std::string &name ) { storeIndexOfNextChild( g_firstPlugIndex ); addChild( - new StringPlug( + new FileSystemPathPlug( "fileName", Plug::In, "", - /* flags */ Plug::Default, - /* substitutions */ IECore::StringAlgo::AllSubstitutions & ~IECore::StringAlgo::FrameSubstitutions + /* flags */ Plug::Default ) ); addChild( new IntPlug( "refreshCount" ) ); @@ -818,14 +818,14 @@ OpenImageIOReader::~OpenImageIOReader() { } -Gaffer::StringPlug *OpenImageIOReader::fileNamePlug() +Gaffer::FileSystemPathPlug *OpenImageIOReader::fileNamePlug() { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -const Gaffer::StringPlug *OpenImageIOReader::fileNamePlug() const +const Gaffer::FileSystemPathPlug *OpenImageIOReader::fileNamePlug() const { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } Gaffer::IntPlug *OpenImageIOReader::refreshCountPlug() diff --git a/src/GafferImage/Text.cpp b/src/GafferImage/Text.cpp index c6ecdef8edd..540bc8686b1 100644 --- a/src/GafferImage/Text.cpp +++ b/src/GafferImage/Text.cpp @@ -39,6 +39,7 @@ #include "GafferImage/BufferAlgo.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "Gaffer/Transform2DPlug.h" #include "Gaffer/Private/IECorePreview/LRUCache.h" @@ -217,7 +218,7 @@ Text::Text( const std::string &name ) { storeIndexOfNextChild( g_firstPlugIndex ); addChild( new StringPlug( "text", Plug::In, "Hello World" ) ); - addChild( new StringPlug( "font", Plug::In, "Vera.ttf" ) ); + addChild( new FileSystemPathPlug( "font", Plug::In, "Vera.ttf" ) ); addChild( new V2iPlug( "size", Plug::In, V2i( 50 ), V2i( 0 ) ) ); addChild( new Box2iPlug( "area" ) ); addChild( new IntPlug( "horizontalAlignment", Plug::In, Left, Left, HorizontalCenter ) ); @@ -240,14 +241,14 @@ const Gaffer::StringPlug *Text::textPlug() const return getChild( g_firstPlugIndex ); } -Gaffer::StringPlug *Text::fontPlug() +Gaffer::FileSystemPathPlug *Text::fontPlug() { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } -const Gaffer::StringPlug *Text::fontPlug() const +const Gaffer::FileSystemPathPlug *Text::fontPlug() const { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } Gaffer::V2iPlug *Text::sizePlug() diff --git a/src/GafferScene/ExternalProcedural.cpp b/src/GafferScene/ExternalProcedural.cpp index 390b7fa859b..fe15acc5616 100644 --- a/src/GafferScene/ExternalProcedural.cpp +++ b/src/GafferScene/ExternalProcedural.cpp @@ -36,7 +36,7 @@ #include "GafferScene/ExternalProcedural.h" -#include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "IECoreScene/ExternalProcedural.h" @@ -52,7 +52,7 @@ ExternalProcedural::ExternalProcedural( const std::string &name ) : ObjectSource( name, "procedural" ) { storeIndexOfNextChild( g_firstPlugIndex ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new Box3fPlug( "bound", Plug::In, Box3f( V3f( -0.5 ), V3f( 0.5 ) ) ) ); addChild( new CompoundDataPlug( "parameters" ) ); } @@ -61,14 +61,14 @@ ExternalProcedural::~ExternalProcedural() { } -Gaffer::StringPlug *ExternalProcedural::fileNamePlug() +Gaffer::FileSystemPathPlug *ExternalProcedural::fileNamePlug() { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -const Gaffer::StringPlug *ExternalProcedural::fileNamePlug() const +const Gaffer::FileSystemPathPlug *ExternalProcedural::fileNamePlug() const { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } Gaffer::Box3fPlug *ExternalProcedural::boundPlug() diff --git a/src/GafferScene/Outputs.cpp b/src/GafferScene/Outputs.cpp index e9c5455bca1..c2c3370842d 100644 --- a/src/GafferScene/Outputs.cpp +++ b/src/GafferScene/Outputs.cpp @@ -39,6 +39,7 @@ #include "Gaffer/CompoundDataPlug.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "boost/multi_index/member.hpp" #include "boost/multi_index/ordered_index.hpp" @@ -132,7 +133,7 @@ Gaffer::ValuePlug *Outputs::addOutput( const std::string &name, const IECoreScen activePlug->setFlags( Plug::Dynamic, true ); outputPlug->addChild( activePlug ); - StringPlugPtr fileNamePlug = new StringPlug( "fileName" ); + FileSystemPathPlugPtr fileNamePlug = new FileSystemPathPlug( "fileName" ); fileNamePlug->setValue( output->getName() ); fileNamePlug->setFlags( Plug::Dynamic, true ); outputPlug->addChild( fileNamePlug ); diff --git a/src/GafferScene/Render.cpp b/src/GafferScene/Render.cpp index 2e168f9ad99..98e035c8b11 100644 --- a/src/GafferScene/Render.cpp +++ b/src/GafferScene/Render.cpp @@ -109,7 +109,7 @@ Render::Render( const IECore::InternedString &rendererType, const std::string &n addChild( new ScenePlug( "in" ) ); addChild( new StringPlug( rendererType.string().empty() ? "renderer" : "__renderer", Plug::In, rendererType.string() ) ); addChild( new IntPlug( "mode", Plug::In, RenderMode, RenderMode, SceneDescriptionMode ) ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new ScenePlug( "out", Plug::Out, Plug::Default & ~Plug::Serialisable ) ); addChild( new ScenePlug( "__adaptedIn", Plug::In, Plug::Default & ~Plug::Serialisable ) ); @@ -155,14 +155,14 @@ const Gaffer::IntPlug *Render::modePlug() const return getChild( g_firstPlugIndex + 2 ); } -Gaffer::StringPlug *Render::fileNamePlug() +Gaffer::FileSystemPathPlug *Render::fileNamePlug() { - return getChild( g_firstPlugIndex + 3 ); + return getChild( g_firstPlugIndex + 3 ); } -const Gaffer::StringPlug *Render::fileNamePlug() const +const Gaffer::FileSystemPathPlug *Render::fileNamePlug() const { - return getChild( g_firstPlugIndex + 3 ); + return getChild( g_firstPlugIndex + 3 ); } ScenePlug *Render::outPlug() diff --git a/src/GafferScene/SceneReader.cpp b/src/GafferScene/SceneReader.cpp index 992a69c2025..0bd5e6bd7ab 100644 --- a/src/GafferScene/SceneReader.cpp +++ b/src/GafferScene/SceneReader.cpp @@ -38,6 +38,7 @@ #include "Gaffer/Context.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "Gaffer/TransformPlug.h" #include "IECoreScene/SceneCache.h" @@ -71,7 +72,7 @@ SceneReader::SceneReader( const std::string &name ) : SceneNode( name ) { storeIndexOfNextChild( g_firstPlugIndex ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new IntPlug( "refreshCount" ) ); addChild( new StringPlug( "tags" ) ); addChild( new TransformPlug( "transform" ) ); @@ -84,14 +85,14 @@ SceneReader::~SceneReader() { } -Gaffer::StringPlug *SceneReader::fileNamePlug() +Gaffer::FileSystemPathPlug *SceneReader::fileNamePlug() { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } -const Gaffer::StringPlug *SceneReader::fileNamePlug() const +const Gaffer::FileSystemPathPlug *SceneReader::fileNamePlug() const { - return getChild( g_firstPlugIndex ); + return getChild( g_firstPlugIndex ); } Gaffer::IntPlug *SceneReader::refreshCountPlug() diff --git a/src/GafferScene/SceneWriter.cpp b/src/GafferScene/SceneWriter.cpp index 8dd0040425d..3acba3bfba9 100644 --- a/src/GafferScene/SceneWriter.cpp +++ b/src/GafferScene/SceneWriter.cpp @@ -39,7 +39,7 @@ #include "GafferScene/SceneAlgo.h" #include "Gaffer/Context.h" -#include "Gaffer/StringPlug.h" +#include "Gaffer/FileSystemPathPlug.h" #include "IECoreScene/SceneInterface.h" @@ -160,7 +160,7 @@ SceneWriter::SceneWriter( const std::string &name ) { storeIndexOfNextChild( g_firstPlugIndex ); addChild( new ScenePlug( "in", Plug::In ) ); - addChild( new StringPlug( "fileName" ) ); + addChild( new FileSystemPathPlug( "fileName" ) ); addChild( new ScenePlug( "out", Plug::Out, Plug::Default & ~Plug::Serialisable ) ); outPlug()->setInput( inPlug() ); } @@ -179,14 +179,14 @@ const ScenePlug *SceneWriter::inPlug() const return getChild( g_firstPlugIndex ); } -StringPlug *SceneWriter::fileNamePlug() +FileSystemPathPlug *SceneWriter::fileNamePlug() { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } -const StringPlug *SceneWriter::fileNamePlug() const +const FileSystemPathPlug *SceneWriter::fileNamePlug() const { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } ScenePlug *SceneWriter::outPlug() diff --git a/src/GafferScene/Text.cpp b/src/GafferScene/Text.cpp index 045f3b3edab..134ff1ab1b9 100644 --- a/src/GafferScene/Text.cpp +++ b/src/GafferScene/Text.cpp @@ -38,6 +38,7 @@ #include "Gaffer/StringPlug.h" #include "Gaffer/Private/IECorePreview/LRUCache.h" +#include "Gaffer/FileSystemPathPlug.h" #include "IECoreScene/Font.h" #include "IECoreScene/MeshPrimitive.h" @@ -100,7 +101,7 @@ Text::Text( const std::string &name ) { storeIndexOfNextChild( g_firstPlugIndex ); addChild( new StringPlug( "text", Plug::In, "Hello World" ) ); - addChild( new StringPlug( "font", Plug::In, "Vera.ttf" ) ); + addChild( new FileSystemPathPlug( "font", Plug::In, "Vera.ttf" ) ); } Text::~Text() @@ -117,14 +118,14 @@ const Gaffer::StringPlug *Text::textPlug() const return getChild( g_firstPlugIndex ); } -Gaffer::StringPlug *Text::fontPlug() +Gaffer::FileSystemPathPlug *Text::fontPlug() { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } -const Gaffer::StringPlug *Text::fontPlug() const +const Gaffer::FileSystemPathPlug *Text::fontPlug() const { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } void Text::affects( const Plug *input, AffectedPlugsContainer &outputs ) const diff --git a/src/GafferSceneUI/UVView.cpp b/src/GafferSceneUI/UVView.cpp index f796d1e7297..e5425e9f461 100644 --- a/src/GafferSceneUI/UVView.cpp +++ b/src/GafferSceneUI/UVView.cpp @@ -101,7 +101,7 @@ class UVView::UVScene : public SceneProcessor addChild( new StringVectorDataPlug( "visiblePaths", Plug::In, new StringVectorData ) ); addChild( new StringPlug( "uvSet", Plug::In, "uv" ) ); - addChild( new StringPlug( "textureFileName", Plug::In, "" ) ); + addChild( new FileSystemPathPlug( "textureFileName", Plug::In, "" ) ); addChild( new CompoundObjectPlug( "textures", Plug::Out, new CompoundObject ) ); addChild( new StringVectorDataPlug( "__udimQueryPaths", Plug::Out, new StringVectorData ) ); @@ -169,14 +169,14 @@ class UVView::UVScene : public SceneProcessor return getChild( g_firstPlugIndex + 1 ); } - StringPlug *textureFileNamePlug() + FileSystemPathPlug *textureFileNamePlug() { - return getChild( g_firstPlugIndex + 2 ); + return getChild( g_firstPlugIndex + 2 ); } - const StringPlug *textureFileNamePlug() const + const FileSystemPathPlug *textureFileNamePlug() const { - return getChild( g_firstPlugIndex + 2 ); + return getChild( g_firstPlugIndex + 2 ); } CompoundObjectPlug *texturesPlug() @@ -623,7 +623,7 @@ UVView::UVView( const std::string &name ) storeIndexOfNextChild( g_firstPlugIndex ); addChild( new StringPlug( "uvSet", Plug::In, "uv" ) ); - addChild( new StringPlug( "textureFileName" ) ); + addChild( new FileSystemPathPlug( "textureFileName" ) ); addChild( new StringPlug( "displayTransform", Plug::In, "Default" ) ); addChild( new CompoundObjectPlug( "__textures", Plug::In, new CompoundObject ) ); @@ -690,14 +690,14 @@ const Gaffer::StringPlug *UVView::uvSetPlug() const return getChild( g_firstPlugIndex ); } -Gaffer::StringPlug *UVView::textureFileNamePlug() +Gaffer::FileSystemPathPlug *UVView::textureFileNamePlug() { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } -const Gaffer::StringPlug *UVView::textureFileNamePlug() const +const Gaffer::FileSystemPathPlug *UVView::textureFileNamePlug() const { - return getChild( g_firstPlugIndex + 1 ); + return getChild( g_firstPlugIndex + 1 ); } Gaffer::StringPlug *UVView::displayTransformPlug() From e8945fcbcea79fa7b83009f206eeb71e5551d739 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sun, 30 Sep 2018 12:21:49 -0400 Subject: [PATCH 077/123] ScriptNodeTest : adapt paths for cross-platform testing --- python/GafferTest/ScriptNodeTest.py | 71 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/python/GafferTest/ScriptNodeTest.py b/python/GafferTest/ScriptNodeTest.py index 0ac4bb462f7..9dcd5e2356c 100644 --- a/python/GafferTest/ScriptNodeTest.py +++ b/python/GafferTest/ScriptNodeTest.py @@ -210,11 +210,11 @@ def testSaveAndLoad( self ) : s["a2"]["op1"].setInput( s["a1"]["sum"] ) s["a2"]["op2"].setValue( 10 ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertTrue( s2["a2"]["op1"].getInput().isSame( s2["a1"]["sum"] ) ) @@ -224,7 +224,7 @@ def testLoadClearsFirst( self ) : s = Gaffer.ScriptNode() s["a1"] = GafferTest.AddNode() - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s.load() @@ -405,11 +405,11 @@ def testFrameRangeLoadAndSave( self ) : self.assertEqual( s["frameRange"]["start"].getValue(), 110 ) self.assertEqual( s["frameRange"]["end"].getValue(), 200 ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertEqual( s2["frameRange"]["start"].getValue(), 110 ) @@ -610,11 +610,11 @@ def testDynamicPlugSaveAndLoad( self ) : s["customSetting"] = Gaffer.IntPlug( flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) s["customSetting"].setValue( 100 ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertEqual( s2["customSetting"].getValue(), 100 ) @@ -815,16 +815,16 @@ def testLoadingMovedScriptDoesntKeepOldFileName( self ) : s = Gaffer.ScriptNode() s["n"] = Gaffer.Node() - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() - shutil.move( self.temporaryDirectory() + "/test.gfr", self.temporaryDirectory() + "/test2.gfr" ) + shutil.move( os.path.join( self.temporaryDirectory(), "test.gfr" ), os.path.join( self.temporaryDirectory(), "test2.gfr" ) ) s = Gaffer.ScriptNode() - s["fileName"].setValue( self.temporaryDirectory() + "/test2.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test2.gfr" ) ) s.load() - self.assertEqual( s["fileName"].getValue(), self.temporaryDirectory() + "/test2.gfr" ) + self.assertEqual( s["fileName"].getValue(), os.path.join( self.temporaryDirectory(), "test2.gfr" ) ) def testUnsavedChanges( self ) : @@ -842,7 +842,7 @@ def testUnsavedChanges( self ) : s["node"] = GafferTest.AddNode() self.assertEqual( s["unsavedChanges"].getValue(), True ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() self.assertEqual( s["unsavedChanges"].getValue(), False ) @@ -897,20 +897,20 @@ def testSerialiseToFile( self ) : s["n2"] = GafferTest.AddNode() s["n2"]["op1"].setInput( s["n1"]["sum"] ) - s.serialiseToFile( self.temporaryDirectory() + "/test.gfr" ) + s.serialiseToFile( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertTrue( "n1" in s2 ) self.assertTrue( "n2" in s2 ) self.assertTrue( s2["n2"]["op1"].getInput().isSame( s2["n1"]["sum"] ) ) - s.serialiseToFile( self.temporaryDirectory() + "/test.gfr", filter = Gaffer.StandardSet( [ s["n2"] ] ) ) + s.serialiseToFile( os.path.join( self.temporaryDirectory(), "test.gfr" ), filter = Gaffer.StandardSet( [ s["n2"] ] ) ) s3 = Gaffer.ScriptNode() - s3["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s3["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s3.load() self.assertTrue( "n1" not in s3 ) @@ -924,13 +924,13 @@ def testExecuteFile( self ) : s["n2"] = GafferTest.AddNode() s["n2"]["op1"].setInput( s["n1"]["sum"] ) - s.serialiseToFile( self.temporaryDirectory() + "/test.gfr" ) + s.serialiseToFile( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2 = Gaffer.ScriptNode() self.assertRaises( RuntimeError, s2.executeFile, "thisFileDoesntExist.gfr" ) - s2.executeFile( self.temporaryDirectory() + "/test.gfr" ) + s2.executeFile( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) self.assertTrue( s2["n2"]["op1"].getInput().isSame( s2["n1"]["sum"] ) ) @@ -997,11 +997,11 @@ def testCustomVariables( self ) : p["value"].setValue( 20 ) self.assertEqual( s.context().get( "test" ), 20 ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertEqual( s2["variables"][p.getName()]["value"].getValue(), 20 ) @@ -1012,7 +1012,7 @@ def testFileNameVariables( self ) : s = Gaffer.ScriptNode() self.assertEqual( s.context().get( "script:name" ), "" ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) self.assertEqual( s.context().get( "script:name" ), "test" ) def testReloadWithCustomVariables( self ) : @@ -1020,7 +1020,7 @@ def testReloadWithCustomVariables( self ) : s = Gaffer.ScriptNode() s["variables"].addChild( Gaffer.NameValuePlug( "test", IECore.IntData( 10 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s["variables"][0]["value"].setValue( 100 ) @@ -1037,11 +1037,11 @@ def testLoadCustomVariablesWithDefaultValues( self ) : s["variables"].addChild( p ) self.assertEqual( s.context().get( "test" ), 10 ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertEqual( s2["variables"][p.getName()]["value"].getValue(), 10 ) @@ -1180,7 +1180,7 @@ def testFileVersioning( self ) : self.assertEqual( Gaffer.Metadata.value( s, "serialiser:minorVersion" ), None ) self.assertEqual( Gaffer.Metadata.value( s, "serialiser:patchVersion" ), None ) - s.serialiseToFile( self.temporaryDirectory() + "/test.gfr" ) + s.serialiseToFile( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) self.assertEqual( Gaffer.Metadata.value( s, "serialiser:milestoneVersion" ), None ) self.assertEqual( Gaffer.Metadata.value( s, "serialiser:majorVersion" ), None ) @@ -1188,7 +1188,7 @@ def testFileVersioning( self ) : self.assertEqual( Gaffer.Metadata.value( s, "serialiser:patchVersion" ), None ) s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertEqual( Gaffer.Metadata.value( s2, "serialiser:milestoneVersion" ), Gaffer.About.milestoneVersion() ) @@ -1196,7 +1196,7 @@ def testFileVersioning( self ) : self.assertEqual( Gaffer.Metadata.value( s2, "serialiser:minorVersion" ), Gaffer.About.minorVersion() ) self.assertEqual( Gaffer.Metadata.value( s2, "serialiser:patchVersion" ), Gaffer.About.patchVersion() ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2.load() @@ -1217,11 +1217,11 @@ def testFileVersioningUpdatesOnSave( self ) : self.assertEqual( Gaffer.Metadata.value( s, "serialiser:minorVersion" ), 0 ) self.assertEqual( Gaffer.Metadata.value( s, "serialiser:patchVersion" ), 0 ) - s["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s.save() s2 = Gaffer.ScriptNode() - s2["fileName"].setValue( self.temporaryDirectory() + "/test.gfr" ) + s2["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test.gfr" ) ) s2.load() self.assertEqual( Gaffer.Metadata.value( s2, "serialiser:milestoneVersion" ), Gaffer.About.milestoneVersion() ) @@ -1306,7 +1306,7 @@ def testLineNumberForExecutionSyntaxError( self ) : def testFileNameInExecutionError( self ) : - fileName = self.temporaryDirectory() + "/test.gfr" + fileName = os.path.join( self.temporaryDirectory(), "test.gfr" ) with open( fileName, "w" ) as f : f.write( "a = 10\n" ) f.write( "a = iDontExist\n" ) @@ -1350,10 +1350,11 @@ def f( script, child ) : b = Gaffer.Box.create( s, Gaffer.StandardSet( [ s["n1"] ] ) ) Gaffer.PlugAlgo.promote( b["n1"]["op1"] ) - b.exportForReference( self.temporaryDirectory() + "/test.grf" ) + b.exportForReference( os.path.join( self.temporaryDirectory(), "test.grf" ) ) s["r"] = Gaffer.Reference() - s["r"].load( self.temporaryDirectory() + "/test.grf" ) + # since this will be a Gaffer native path, ensure it only has / on all OS + s["r"].load( os.path.join( self.temporaryDirectory(), "test.grf" ).replace( "\\", "/" ) ) s["r"]["op1"].setInput( s["n"]["sum"] ) @@ -1474,7 +1475,7 @@ def testImport( self ) : s1["frameRange"]["end"].setValue( 101 ) s1["variables"].addChild( Gaffer.NameValuePlug( "test", "test" ) ) - fileName = self.temporaryDirectory() + "/toImport.gfr" + fileName = os.path.join( self.temporaryDirectory(), "toImport.gfr" ) s1.serialiseToFile( fileName ) s2 = Gaffer.ScriptNode() @@ -1489,7 +1490,7 @@ def testImport( self ) : def testReadOnlyMetadata( self ) : - fileName = self.temporaryDirectory() + "/test.gfr" + fileName = os.path.join( self.temporaryDirectory(), "test.gfr" ) s = Gaffer.ScriptNode() self.assertFalse( Gaffer.MetadataAlgo.getReadOnly( s ) ) @@ -1511,7 +1512,7 @@ def testReadOnlyMetadata( self ) : s.load() self.assertTrue( Gaffer.MetadataAlgo.getReadOnly( s ) ) - s["fileName"].setValue( self.temporaryDirectory() + "/test2.gfr" ) + s["fileName"].setValue( os.path.join( self.temporaryDirectory(), "test2.gfr" ) ) self.assertFalse( Gaffer.MetadataAlgo.getReadOnly( s ) ) def testDisableContextVariable( self ) : From 688780f69696db3b98975d2bec1265a2853612c5 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 6 Oct 2018 13:37:32 -0400 Subject: [PATCH 078/123] OSLExpressionEngine : Use platform-specific path separator - OSL expressions using a forward slash on Windows throw errors. --- src/GafferOSL/OSLExpressionEngine.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/GafferOSL/OSLExpressionEngine.cpp b/src/GafferOSL/OSLExpressionEngine.cpp index 110fbbce3e5..2ab9e6fdab1 100644 --- a/src/GafferOSL/OSLExpressionEngine.cpp +++ b/src/GafferOSL/OSLExpressionEngine.cpp @@ -792,7 +792,11 @@ class OSLExpressionEngine : public Gaffer::Expression::Engine // prepend it to the source. shaderName = "oslExpression" + MurmurHash().append( result ).toString(); - result = "#include \"GafferOSL/Expression.h\"\n\nshader " + shaderName + " " + result; + #ifdef _MSC_VER + result = "#include \"GafferOSL\\Expression.h\"\n\nshader " + shaderName + " " + result; + #else + result = "#include \"GafferOSL/Expression.h\"\n\nshader " + shaderName + " " + result; + #endif return result; } @@ -820,7 +824,11 @@ class OSLExpressionEngine : public Gaffer::Expression::Engine vector options; if( const char *includePaths = getenv( "OSL_SHADER_PATHS" ) ) { - StringAlgo::tokenize( includePaths, ':', options ); + #ifdef _MSC_VER + StringAlgo::tokenize( includePaths, ';', options ); + #else + StringAlgo::tokenize( includePaths, ':', options ); + #endif for( vector::iterator it = options.begin(), eIt = options.end(); it != eIt; ++it ) { it->insert( 0, "-I" ); From 6a9fa3b0981f19aa5af14113c40d3c2a4906c7c3 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 17 Nov 2018 14:24:26 -0500 Subject: [PATCH 079/123] split OSL paths from the environment based on OS native separators --- src/GafferOSL/OSLCode.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/GafferOSL/OSLCode.cpp b/src/GafferOSL/OSLCode.cpp index 3c9e0e75f21..0ea0381c4e2 100644 --- a/src/GafferOSL/OSLCode.cpp +++ b/src/GafferOSL/OSLCode.cpp @@ -283,7 +283,11 @@ boost::filesystem::path compile( const std::string &shaderName, const std::strin vector options; if( const char *includePaths = getenv( "OSL_SHADER_PATHS" ) ) { - StringAlgo::tokenize( includePaths, ':', options ); + #ifdef _MSC_VER + StringAlgo::tokenize( includePaths, ';', options ); + #else + StringAlgo::tokenize( includePaths, ':', options ); + #endif for( vector::iterator it = options.begin(), eIt = options.end(); it != eIt; ++it ) { it->insert( 0, "-I" ); From dfba8245589d0c6421186c639308599efcead09f Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 17 Nov 2018 17:56:32 -0500 Subject: [PATCH 080/123] handle Windows paths properly for OSL shaders and conform to forward slash standard for shader paths --- python/GafferSceneUI/ShaderUI.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/GafferSceneUI/ShaderUI.py b/python/GafferSceneUI/ShaderUI.py index b283bf54494..52213c918e2 100644 --- a/python/GafferSceneUI/ShaderUI.py +++ b/python/GafferSceneUI/ShaderUI.py @@ -284,10 +284,10 @@ def __shaderSubMenu( searchPaths, extensions, nodeCreator, matchExpression, sear if path in pathsVisited : continue - for root, dirs, files in os.walk( path ) : + for root, dirs, files in os.walk( path ) : for file in files : if os.path.splitext( file )[1][1:] in extensions : - shaderPath = os.path.join( root, file ).partition( path )[-1].lstrip( "/" ) + shaderPath = os.path.join( root, file ).partition( path )[-1].lstrip( os.path.sep ) if __hiddenShadersPathMatcher.match( shaderPath ) & IECore.PathMatcher.Result.ExactMatch : continue if shaderPath not in shaders and matchExpression.match( shaderPath ) : @@ -296,18 +296,18 @@ def __shaderSubMenu( searchPaths, extensions, nodeCreator, matchExpression, sear pathsVisited.add( path ) shaders = sorted( list( shaders ) ) - categorisedShaders = [ x for x in shaders if "/" in x ] - uncategorisedShaders = [ x for x in shaders if "/" not in x ] + categorisedShaders = [ x for x in shaders if os.path.sep in x ] + uncategorisedShaders = [ x for x in shaders if os.path.sep not in x ] shadersAndMenuPaths = [] for shader in categorisedShaders : - shadersAndMenuPaths.append( ( shader, "/" + shader ) ) + shadersAndMenuPaths.append( ( shader.replace("\\", "/"), "/" + shader.replace("\\", "/") ) ) for shader in uncategorisedShaders : if not categorisedShaders : - shadersAndMenuPaths.append( ( shader, "/" + shader ) ) + shadersAndMenuPaths.append( ( shader.replace("\\", "/"), "/" + shader.replace("\\", "/") ) ) else : - shadersAndMenuPaths.append( ( shader, "/Other/" + shader ) ) + shadersAndMenuPaths.append( ( shader.replace("\\", "/"), "/Other/" + shader.replace("\\", "/") ) ) result = IECore.MenuDefinition() for shader, menuPath in shadersAndMenuPaths : From c33042811a1e019bce21dc6e384b863fea3ab791 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 17 Nov 2018 17:57:06 -0500 Subject: [PATCH 081/123] conform OSLCode shader path to forward slash standard --- src/GafferOSL/OSLCode.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/GafferOSL/OSLCode.cpp b/src/GafferOSL/OSLCode.cpp index 0ea0381c4e2..b88f2683789 100644 --- a/src/GafferOSL/OSLCode.cpp +++ b/src/GafferOSL/OSLCode.cpp @@ -51,6 +51,8 @@ #include "boost/bind.hpp" #include "boost/filesystem.hpp" +#include "boost/algorithm/string/replace.hpp" + #include using namespace std; @@ -263,6 +265,7 @@ boost::filesystem::path compile( const std::string &shaderName, const std::strin // Write the source code out. const std::string tempOSLFileName = ( tempDirectory / ( shaderName + ".osl" ) ).string(); + std::ofstream f( tempOSLFileName.c_str() ); if( !f.good() ) { @@ -346,7 +349,9 @@ class CompileProcess : public Gaffer::Process string shaderName; string shaderSource = generate( oslCode, shaderName ); boost::filesystem::path shaderFile = compile( shaderName, shaderSource ); - oslCode->namePlug()->setValue( shaderFile.replace_extension().string() ); + std::string shaderFileString = shaderFile.replace_extension().string(); + boost::replace_all( shaderFileString, "\\", "/" ); // Convert \ from Windows paths so shader can be found + oslCode->namePlug()->setValue( shaderFileString ); oslCode->typePlug()->setValue( "osl:shader" ); } catch( ... ) From eeb831d34725083d43c42db1e138d52aabe830f3 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 26 Nov 2018 13:21:40 -0500 Subject: [PATCH 082/123] AppleseedRenderTest : 'subprocess32' isn't supported on Windows --- python/GafferAppleseedTest/AppleseedRenderTest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/GafferAppleseedTest/AppleseedRenderTest.py b/python/GafferAppleseedTest/AppleseedRenderTest.py index faf2b196af8..f92cdbe7337 100644 --- a/python/GafferAppleseedTest/AppleseedRenderTest.py +++ b/python/GafferAppleseedTest/AppleseedRenderTest.py @@ -36,7 +36,11 @@ import os import re -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import time import unittest From 33016d775393c504671ab1cdbefbb7ac4ae27985 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 3 Jan 2022 16:15:47 -0500 Subject: [PATCH 083/123] Tests : `subprocess32` isn't supported on Windows --- python/GafferArnoldTest/ArnoldRenderTest.py | 5 ++++- python/GafferDispatchTest/DispatchApplicationTest.py | 6 +++++- python/GafferDispatchTest/ExecuteApplicationTest.py | 6 +++++- python/GafferImageTest/ColorSpaceTest.py | 6 +++++- python/GafferImageTest/DisplayTest.py | 6 +++++- python/GafferImageTest/DisplayTransformTest.py | 6 +++++- python/GafferOSLTest/OSLTestCase.py | 6 +++++- python/GafferTest/ApplicationTest.py | 6 +++++- python/GafferTest/PythonApplicationTest.py | 6 +++++- python/GafferTest/StatsApplicationTest.py | 7 ++++++- python/GafferVDBTest/VDBTestCase.py | 6 +++++- 11 files changed, 55 insertions(+), 11 deletions(-) diff --git a/python/GafferArnoldTest/ArnoldRenderTest.py b/python/GafferArnoldTest/ArnoldRenderTest.py index 4a3a2d7a925..0e5408eb05c 100644 --- a/python/GafferArnoldTest/ArnoldRenderTest.py +++ b/python/GafferArnoldTest/ArnoldRenderTest.py @@ -38,8 +38,11 @@ import os import inspect import unittest -import subprocess32 as subprocess import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import threading import arnold diff --git a/python/GafferDispatchTest/DispatchApplicationTest.py b/python/GafferDispatchTest/DispatchApplicationTest.py index df60d32a6fb..a7a11fd4baf 100644 --- a/python/GafferDispatchTest/DispatchApplicationTest.py +++ b/python/GafferDispatchTest/DispatchApplicationTest.py @@ -35,7 +35,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import unittest import Gaffer diff --git a/python/GafferDispatchTest/ExecuteApplicationTest.py b/python/GafferDispatchTest/ExecuteApplicationTest.py index 10d9e81238c..39aa43e2f8f 100644 --- a/python/GafferDispatchTest/ExecuteApplicationTest.py +++ b/python/GafferDispatchTest/ExecuteApplicationTest.py @@ -36,7 +36,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import unittest import glob import inspect diff --git a/python/GafferImageTest/ColorSpaceTest.py b/python/GafferImageTest/ColorSpaceTest.py index f827fac64b9..c4ab739e072 100644 --- a/python/GafferImageTest/ColorSpaceTest.py +++ b/python/GafferImageTest/ColorSpaceTest.py @@ -37,7 +37,11 @@ import os import unittest -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import imath import IECore diff --git a/python/GafferImageTest/DisplayTest.py b/python/GafferImageTest/DisplayTest.py index afe336b0a47..dd2019c1f12 100644 --- a/python/GafferImageTest/DisplayTest.py +++ b/python/GafferImageTest/DisplayTest.py @@ -38,7 +38,11 @@ import unittest import random import threading -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import imath import IECore diff --git a/python/GafferImageTest/DisplayTransformTest.py b/python/GafferImageTest/DisplayTransformTest.py index 0bce3fb29ec..e4d9e68b01f 100644 --- a/python/GafferImageTest/DisplayTransformTest.py +++ b/python/GafferImageTest/DisplayTransformTest.py @@ -36,7 +36,11 @@ import os import unittest -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import imath import IECore diff --git a/python/GafferOSLTest/OSLTestCase.py b/python/GafferOSLTest/OSLTestCase.py index 59b3214947e..404d4826492 100644 --- a/python/GafferOSLTest/OSLTestCase.py +++ b/python/GafferOSLTest/OSLTestCase.py @@ -35,7 +35,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import GafferSceneTest diff --git a/python/GafferTest/ApplicationTest.py b/python/GafferTest/ApplicationTest.py index 214409e07ba..9c241e5268d 100644 --- a/python/GafferTest/ApplicationTest.py +++ b/python/GafferTest/ApplicationTest.py @@ -36,7 +36,11 @@ import os import time -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import IECore import Gaffer diff --git a/python/GafferTest/PythonApplicationTest.py b/python/GafferTest/PythonApplicationTest.py index 1688a096cda..56c0c88f181 100644 --- a/python/GafferTest/PythonApplicationTest.py +++ b/python/GafferTest/PythonApplicationTest.py @@ -35,7 +35,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import unittest import GafferTest diff --git a/python/GafferTest/StatsApplicationTest.py b/python/GafferTest/StatsApplicationTest.py index c2af1410812..22c424624f3 100644 --- a/python/GafferTest/StatsApplicationTest.py +++ b/python/GafferTest/StatsApplicationTest.py @@ -36,7 +36,12 @@ import re import unittest -import subprocess32 as subprocess +import os +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import Gaffer import GafferTest diff --git a/python/GafferVDBTest/VDBTestCase.py b/python/GafferVDBTest/VDBTestCase.py index f00c6975789..96a47113a14 100644 --- a/python/GafferVDBTest/VDBTestCase.py +++ b/python/GafferVDBTest/VDBTestCase.py @@ -35,7 +35,11 @@ ########################################################################## import os -import subprocess32 as subprocess +import sys +if os.name == 'posix' and sys.version_info[0] < 3: + import subprocess32 as subprocess +else: + import subprocess import IECore import GafferScene From b7f9bcd9a9bd906f40ef8309a35a0bd6f3289885 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 13 Jan 2022 13:34:38 -0500 Subject: [PATCH 084/123] ImageReaderTest : cross platform paths --- python/GafferImageTest/ImageReaderTest.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python/GafferImageTest/ImageReaderTest.py b/python/GafferImageTest/ImageReaderTest.py index 6ad9975bfb4..557eecebd56 100644 --- a/python/GafferImageTest/ImageReaderTest.py +++ b/python/GafferImageTest/ImageReaderTest.py @@ -49,13 +49,14 @@ class ImageReaderTest( GafferImageTest.ImageTestCase ) : - fileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/circles.exr" ) - colorSpaceFileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/circles_as_cineon.exr" ) - offsetDataWindowFileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/rgb.100x100.exr" ) - jpgFileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/circles.jpg" ) - largeFileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_max_clamp.exr" ) - def setUp( self ) : + gaffer_root = os.environ["GAFFER_ROOT"] + + self.fileName = Gaffer.FileSystemPath( gaffer_root + "/python/GafferImageTest/images/circles.exr" ).nativeString() + self.colorSpaceFileName = Gaffer.FileSystemPath( gaffer_root + "/python/GafferImageTest/images/circles_as_cineon.exr" ).nativeString() + self.offsetDataWindowFileName = Gaffer.FileSystemPath( gaffer_root + "/python/GafferImageTest/images/rgb.100x100.exr" ).nativeString() + self.jpgFileName = Gaffer.FileSystemPath( gaffer_root + "/python/GafferImageTest/images/circles.jpg" ).nativeString() + self.largeFileName = Gaffer.FileSystemPath( gaffer_root + "/python/GafferImageTest/images/colorbars_max_clamp.exr" ).nativeString() GafferImageTest.ImageTestCase.setUp( self ) self.__defaultColorSpaceFunction = GafferImage.ImageReader.getDefaultColorSpaceFunction() From 1bd223923a894eb0562dff9282800f92213c6e24 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 15 Dec 2018 13:47:54 -0500 Subject: [PATCH 085/123] UserPlugs : add FileSystemPathPlug and set default widget to FileSystemPathPlugValueWidget --- python/GafferUI/FileSystemPathPlugValueWidget.py | 2 ++ python/GafferUI/UserPlugs.py | 1 + 2 files changed, 3 insertions(+) diff --git a/python/GafferUI/FileSystemPathPlugValueWidget.py b/python/GafferUI/FileSystemPathPlugValueWidget.py index 0a40d60a64a..6fe0ada2519 100644 --- a/python/GafferUI/FileSystemPathPlugValueWidget.py +++ b/python/GafferUI/FileSystemPathPlugValueWidget.py @@ -130,3 +130,5 @@ def __metadataValue( self, name ) : v = Gaffer.Metadata.value( self.getPlug(), "fileSystemPathPlugValueWidget:" + name ) return v + +GafferUI.PlugValueWidget.registerType( Gaffer.FileSystemPathPlug, FileSystemPathPlugValueWidget ) diff --git a/python/GafferUI/UserPlugs.py b/python/GafferUI/UserPlugs.py index 30de2a130fd..142cc955ae5 100644 --- a/python/GafferUI/UserPlugs.py +++ b/python/GafferUI/UserPlugs.py @@ -53,6 +53,7 @@ def appendPlugCreationMenuDefinitions( plugParent, menuDefinition, prefix = "" ) menuDefinition.append( prefix + "/NumericDivider", { "divider" : True } ) menuDefinition.append( prefix + "/String", { "command" : functools.partial( __addPlug, plugParent, Gaffer.StringPlug ), "active" : active } ) + menuDefinition.append( prefix + "/FileSystemPath", { "command" : functools.partial(__addPlug, plugParent, Gaffer.FileSystemPathPlug ), "active" : active } ) menuDefinition.append( prefix + "/StringDivider", { "divider" : True } ) menuDefinition.append( prefix + "/V2i", { "command" : functools.partial( __addPlug, plugParent, Gaffer.V2iPlug ), "active" : active } ) From 1a0c33d1ff1014ca84d908dddddfdda8286954a9 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 15 Dec 2018 13:48:58 -0500 Subject: [PATCH 086/123] ImageWriterTest : adapt for Windows --- python/GafferImageTest/ImageWriterTest.py | 42 +++++++++++++++++------ 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/python/GafferImageTest/ImageWriterTest.py b/python/GafferImageTest/ImageWriterTest.py index 976a1b8af12..6faba043c53 100644 --- a/python/GafferImageTest/ImageWriterTest.py +++ b/python/GafferImageTest/ImageWriterTest.py @@ -54,15 +54,21 @@ class ImageWriterTest( GafferImageTest.ImageTestCase ) : - __largeFilePath = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/large.exr" ) - __rgbFilePath = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/rgb.100x100" ) - __negativeDataWindowFilePath = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/checkerWithNegativeDataWindow.200x150" ) - __representativeDeepPath = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/representativeDeepImage.exr" ) - longMessage = True def setUp( self ) : + if os.name == "nt": + gaffer_root = os.path.expandvars( "%GAFFER_ROOT%" ) + else: + gaffer_root = os.path.expandvars( "$GAFFER_ROOT" ) + + self.__largeFilePath = os.path.abspath( gaffer_root + "/python/GafferImageTest/images/large.exr" ) + self.__rgbFilePath = os.path.abspath( gaffer_root + "/python/GafferImageTest/images/rgb.100x100" ) + self.__negativeDataWindowFilePath = os.path.abspath( gaffer_root + "/python/GafferImageTest/images/checkerWithNegativeDataWindow.200x150" ) + self.__representativeDeepPath = os.path.abspath( gaffer_root + "/python/GafferImageTest/images/representativeDeepImage.exr" ) + + GafferImageTest.ImageTestCase.setUp( self ) self.__defaultColorSpaceFunction = GafferImage.ImageWriter.getDefaultColorSpaceFunction() @@ -477,7 +483,11 @@ def __testExtension( self, ext, formatName, options = {}, metadataToIgnore = [] # the writer adds several standard attributes that aren't in the original file expectedMetadata["Software"] = IECore.StringData( "Gaffer " + Gaffer.About.versionString() ) expectedMetadata["HostComputer"] = IECore.StringData( platform.node() ) - expectedMetadata["Artist"] = IECore.StringData( os.environ["USER"] ) + if os.name == "nt": + user_key = "username" + else: + user_key = "USER" + expectedMetadata["Artist"] = IECore.StringData( os.environ[user_key] ) expectedMetadata["DocumentName"] = IECore.StringData( "untitled" ) for key in overrideMetadata : @@ -784,7 +794,11 @@ def __testMetadataDoesNotAffectPixels( self, ext, overrideMetadata = {}, metadat expectedMetadata["DateTime"] = regularReaderMetadata["DateTime"] expectedMetadata["Software"] = IECore.StringData( "Gaffer " + Gaffer.About.versionString() ) expectedMetadata["HostComputer"] = IECore.StringData( platform.node() ) - expectedMetadata["Artist"] = IECore.StringData( os.environ["USER"] ) + if os.name == "nt": + user_key = "username" + else: + user_key = "USER" + expectedMetadata["Artist"] = IECore.StringData( os.environ[user_key] ) expectedMetadata["DocumentName"] = IECore.StringData( "untitled" ) expectedMetadata["fileFormat"] = regularReaderMetadata["fileFormat"] expectedMetadata["dataType"] = regularReaderMetadata["dataType"] @@ -983,7 +997,13 @@ def testFileNamesWithSubstitutions( self ) : with context : s["w"]["task"].execute() - self.assertTrue( os.path.isfile( self.temporaryDirectory() + "/test.tif" ) ) + self.assertTrue( os.path.isfile( os.path.join( self.temporaryDirectory(), "test.tif" ) ) ) + + s["w"]["fileName"].setValue( self.temporaryDirectory() + "/test.#.tif" ) + context.setFrame( 5 ) + with context : + s["w"]["task"].execute() + self.assertTrue( os.path.isfile( os.path.join( self.temporaryDirectory(), "test.5.tif" ) ) ) def testErrorMessages( self ) : @@ -1070,7 +1090,7 @@ def __init__( self, name = "DerivedImageWriter" ) : GafferImage.ImageWriter.__init__( self, name ) - self["copyFileName"] = Gaffer.StringPlug() + self["copyFileName"] = Gaffer.FileSystemPathPlug() def execute( self ) : @@ -1112,7 +1132,7 @@ def testStringMetadata( self ) : def __testFile( self, mode, channels, ext ) : - return self.temporaryDirectory() + "/test." + channels + "." + str( mode ) + "." + str( ext ) + return os.path.join(self.temporaryDirectory(), "test." + channels + "." + str( mode ) + "." + str( ext )) def testJpgChroma( self ): @@ -1127,7 +1147,7 @@ def testJpgChroma( self ): chromaSubSamplings = ( "4:4:4", "4:2:2", "4:2:0", "4:1:1", "" ) for chromaSubSampling in chromaSubSamplings: - testFile = os.path.join( self.temporaryDirectory(), "chromaSubSampling.{0}.jpg".format( chromaSubSampling ) ) + testFile = os.path.join( self.temporaryDirectory(), "chromaSubSampling.{0}.jpg".format( chromaSubSampling.replace(":", ".") ) ) w["fileName"].setValue( testFile ) w["jpeg"]["chromaSubSampling"].setValue( chromaSubSampling ) From 3efdae12c4a0368fbba4ff9bfa14f510dfeab624 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 28 Dec 2018 15:43:03 -0500 Subject: [PATCH 087/123] Backups : add Windows path compatibility --- python/GafferUI/Backups.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/GafferUI/Backups.py b/python/GafferUI/Backups.py index a61ffda15ee..a9a3429d73b 100644 --- a/python/GafferUI/Backups.py +++ b/python/GafferUI/Backups.py @@ -46,6 +46,9 @@ import stat import weakref +if os.name == "nt": + import ctypes + class Backups( object ) : def __init__( self, applicationRoot ) : @@ -95,6 +98,11 @@ def backup( self, script ) : dirName = os.path.dirname( fileName ) try : os.makedirs( dirName ) + # Avoid the win32 module dependency by using ctypes to make directory hidden + # The magic number 2 comes from https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setfileattributesa + if os.name == "nt": + ctypes.windll.kernel32.SetFileAttributesW( unicode( dirName, "utf-8" ), 2 ) + except OSError : # makedirs very unhelpfully raises an exception if # the directory already exists, but it might also @@ -266,7 +274,7 @@ def __potentialFileNames( self, script ) : context = Gaffer.Context() context["script:name"] = os.path.splitext( os.path.basename( fileName ) )[0] - context["script:directory"] = os.path.dirname( os.path.abspath( fileName ) ) + context["script:directory"] = os.path.dirname( os.path.abspath( fileName ) ).replace( "\\", "/" ) pattern = self.__settings["fileName"].getValue() fileNames = [] From caaf9fd8db2468e5ae60b2fca126f8b04c969f43 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 8 Feb 2019 15:19:41 -0500 Subject: [PATCH 088/123] GafferArnoldUI : use AtStringStruct --- python/GafferArnoldUI/ArnoldShaderUI.py | 2 +- python/GafferArnoldUI/ShaderMenu.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/GafferArnoldUI/ArnoldShaderUI.py b/python/GafferArnoldUI/ArnoldShaderUI.py index 691b1b73474..9a3f14d1586 100644 --- a/python/GafferArnoldUI/ArnoldShaderUI.py +++ b/python/GafferArnoldUI/ArnoldShaderUI.py @@ -56,7 +56,7 @@ def __aiMetadataGetStr( nodeEntry, paramName, name, defaultValue = None ) : - value = arnold.AtStringReturn() + value = arnold.AtStringStruct() if arnold.AiMetaDataGetStr( nodeEntry, paramName, name, value ) : return arnold.AtStringToStr( value ) diff --git a/python/GafferArnoldUI/ShaderMenu.py b/python/GafferArnoldUI/ShaderMenu.py index 159d127be9f..69589cb6370 100644 --- a/python/GafferArnoldUI/ShaderMenu.py +++ b/python/GafferArnoldUI/ShaderMenu.py @@ -136,7 +136,7 @@ def __colorManagerCreator( colorManagerName, nodeName ) : def __aiMetadataGetStr( nodeEntry, paramName, name ) : - value = arnold.AtStringReturn() + value = arnold.AtStringStruct() if arnold.AiMetaDataGetStr( nodeEntry, paramName, name, value ) : return arnold.AtStringToStr( value ) From 3c3ff985d33316e2286916be86574102506a90dc Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 24 Mar 2021 18:51:50 -0400 Subject: [PATCH 089/123] GafferSceneUI : fix utf-8 errors on Windows There seems to be an encoding mismatch when importing Python files with certain utf-8 characters where the files are assumed to have cp1252 encoding which can't convert some characters to utf-8. Even forcing the file to be saved as utf-8 does not fix the problem. Replacing "real" utf-8 characters (wysiwyg in a text editor) with the equivalent utf-8 code solves this. --- python/GafferSceneUI/CameraUI.py | 22 +++++++++++----------- python/GafferSceneUI/StandardOptionsUI.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/GafferSceneUI/CameraUI.py b/python/GafferSceneUI/CameraUI.py index 000e4ef508d..4663203c49c 100644 --- a/python/GafferSceneUI/CameraUI.py +++ b/python/GafferSceneUI/CameraUI.py @@ -169,17 +169,17 @@ "layout:visibilityActivator", "perspectiveModeFocalLength", - "preset:Academy 35mm 21.946 × 16.000", imath.V2f( 21.946, 16 ), - "preset:Super 35mm 24.892 × 18.669", imath.V2f( 24.892, 18.669 ), - "preset:Micro Four Thirds 17.30 × 13.00", imath.V2f( 17.3, 13 ), - "preset:APS-C 22.30 × 14.90", imath.V2f( 22.3, 14.9 ), - "preset:Full Frame 35mm 36.00 × 24.00", imath.V2f( 36, 24 ), - "preset:Alexa SXT 4:3 2.8k 23.76 × 17.82", imath.V2f( 23.76, 17.82 ), - "preset:Alexa SXT Open Gate 3.4k 28.25 × 18.17", imath.V2f( 28.25, 18.17 ), - "preset:Alexa 65 16:9 5.1k 42.24 × 23.76", imath.V2f( 42.24, 23.76 ), - "preset:Alexa 65 Open Gate 6.5k 54.12 × 25.58", imath.V2f( 54.12, 25.58 ), - "preset:RED EPIC-W 5K S35 30.72 × 18.00", imath.V2f( 30.72, 18 ), - "preset:RED EPIC-W 8K S35 29.90 × 15.77", imath.V2f( 29.9, 15.77 ), + "preset:Academy 35mm 21.946 \u00D7 16.000", imath.V2f( 21.946, 16 ), + "preset:Super 35mm 24.892 \u00D7 18.669", imath.V2f( 24.892, 18.669 ), + "preset:Micro Four Thirds 17.30 \u00D7 13.00", imath.V2f( 17.3, 13 ), + "preset:APS-C 22.30 \u00D7 14.90", imath.V2f( 22.3, 14.9 ), + "preset:Full Frame 35mm 36.00 \u00D7 24.00", imath.V2f( 36, 24 ), + "preset:Alexa SXT 4:3 2.8k 23.76 \u00D7 17.82", imath.V2f( 23.76, 17.82 ), + "preset:Alexa SXT Open Gate 3.4k 28.25 \u00D7 18.17", imath.V2f( 28.25, 18.17 ), + "preset:Alexa 65 16:9 5.1k 42.24 \u00D7 23.76", imath.V2f( 42.24, 23.76 ), + "preset:Alexa 65 Open Gate 6.5k 54.12 \u00D7 25.58", imath.V2f( 54.12, 25.58 ), + "preset:RED EPIC-W 5K S35 30.72 \u00D7 18.00", imath.V2f( 30.72, 18 ), + "preset:RED EPIC-W 8K S35 29.90 \u00D7 15.77", imath.V2f( 29.9, 15.77 ), "presetsPlugValueWidget:allowCustom", True, diff --git a/python/GafferSceneUI/StandardOptionsUI.py b/python/GafferSceneUI/StandardOptionsUI.py index 9f1231e3cf4..5d46679acf7 100644 --- a/python/GafferSceneUI/StandardOptionsUI.py +++ b/python/GafferSceneUI/StandardOptionsUI.py @@ -252,7 +252,7 @@ def __statisticsSummary( plug ) : sides of the rendered image. Overscan can be useful when camera shake or blur will be added - as a post-process. This plug just enables overscan as a whole – + as a post-process. This plug just enables overscan as a whole \u2013 use the _Overscan Top_, _Overscan Bottom_, _Overscan Left_ and _Overscan Right_ plugs to specify the amount of overscan on each side of the image. From cd70cdacb0675cd9a1ce279dbafd666f5ea68c06 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 16 Mar 2019 17:08:09 -0400 Subject: [PATCH 090/123] USD : dlopenflags is not supported on Windows --- startup/GafferScene/usd.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/startup/GafferScene/usd.py b/startup/GafferScene/usd.py index 9ea3562f344..6f2b4735424 100644 --- a/startup/GafferScene/usd.py +++ b/startup/GafferScene/usd.py @@ -57,11 +57,13 @@ # > https://github.com/ImageEngine/cortex/pull/810. try : - originalDLOpenFlags = sys.getdlopenflags() - sys.setdlopenflags( originalDLOpenFlags & ~ctypes.RTLD_GLOBAL ) + if os.name != "nt" : + originalDLOpenFlags = sys.getdlopenflags() + sys.setdlopenflags( originalDLOpenFlags & ~ctypes.RTLD_GLOBAL ) from pxr import Usd finally : - sys.setdlopenflags( originalDLOpenFlags ) + if os.name != "nt" : + sys.setdlopenflags( originalDLOpenFlags ) # Import IECoreUSD so that we get the USD SceneInterface registered, # providing USD functionality to both the SceneReader and SceneWriter. From a49db74dd3c3d3844b00879845f9148d318fa089 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Sat, 16 Mar 2019 17:45:49 -0400 Subject: [PATCH 091/123] Help Documentation : convert to platform independent paths --- python/GafferUI/ApplicationMenu.py | 2 +- python/GafferUI/NodeUI.py | 2 +- startup/gui/menus.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/GafferUI/ApplicationMenu.py b/python/GafferUI/ApplicationMenu.py index ff51abad6ed..aa5b21d06c7 100644 --- a/python/GafferUI/ApplicationMenu.py +++ b/python/GafferUI/ApplicationMenu.py @@ -47,7 +47,7 @@ def appendDefinitions( menuDefinition, prefix ) : menuDefinition.append( prefix + "/About Gaffer...", { "command" : about } ) menuDefinition.append( prefix + "/Preferences...", { "command" : preferences } ) - menuDefinition.append( prefix + "/Documentation...", { "command" : functools.partial( GafferUI.showURL, os.path.expandvars( "$GAFFER_ROOT/doc/gaffer/html/index.html" ) ) } ) + menuDefinition.append( prefix + "/Documentation...", { "command" : functools.partial( GafferUI.showURL, os.path.join( os.environ["GAFFER_ROOT"], "doc", "gaffer", "html", "index.html" ) ) } ) menuDefinition.append( prefix + "/Quit", { "command" : quit, "shortCut" : "Ctrl+Q" } ) def quit( menu ) : diff --git a/python/GafferUI/NodeUI.py b/python/GafferUI/NodeUI.py index 4c226ce3e9f..93b04d13503 100644 --- a/python/GafferUI/NodeUI.py +++ b/python/GafferUI/NodeUI.py @@ -45,7 +45,7 @@ def __documentationURL( node ) : - fileName = "$GAFFER_ROOT/doc/gaffer/html/Reference/NodeReference/" + node.typeName().replace( "::", "/" ) + ".html" + fileName = os.path.join( os.environ["GAFFER_ROOT"], "doc", "gaffer", "html", "Reference", "NodeReference", node.typeName().replace( "::", os.sep ) + ".html" ) fileName = os.path.expandvars( fileName ) return "file://" + fileName if os.path.isfile( fileName ) else "" diff --git a/startup/gui/menus.py b/startup/gui/menus.py index acb7648e486..c01d95f4e66 100644 --- a/startup/gui/menus.py +++ b/startup/gui/menus.py @@ -464,7 +464,7 @@ def __shaderNodeCreator( nodeName, shaderName ) : nodeMenu.append( "/OSL/Image", GafferOSL.OSLImage, searchText = "OSLImage" ) nodeMenu.append( "/OSL/Object", GafferOSL.OSLObject, searchText = "OSLObject" ) - oslDocs = os.path.expandvars( "$GAFFER_ROOT/doc/osl-languagespec.pdf" ) + oslDocs = os.path.expandvars( os.path.join( os.environ["GAFFER_ROOT"], "doc", "osl-languagespec.pdf" ) ) scriptWindowMenu.append( "/Help/Open Shading Language/Language Reference", { From f2de96539a25b2d2ea327620abe0b2faaf80bb91 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 9 Aug 2019 13:36:50 -0400 Subject: [PATCH 092/123] DocumentationAlgo : adapt parameters for MSVC - The second argument to markdown_to_html is 'size_t len' which MSVC defines as unsigned int64 --- python/GafferUI/DocumentationAlgo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/GafferUI/DocumentationAlgo.py b/python/GafferUI/DocumentationAlgo.py index 1da75d8306e..a357e8b9f0f 100644 --- a/python/GafferUI/DocumentationAlgo.py +++ b/python/GafferUI/DocumentationAlgo.py @@ -318,6 +318,11 @@ def __cmark() : return __cmarkDLL __cmarkDLL.cmark_markdown_to_html.restype = ctypes.c_char_p - __cmarkDLL.cmark_markdown_to_html.argtypes = [ctypes.c_char_p, ctypes.c_long, ctypes.c_long] + # The second argument is 'size_t len', the length of the markdown string + # MSVC defines size_t as unsigned int64 + if sys == "Windows" : + __cmarkDLL.cmark_markdown_to_html.argtypes = [ctypes.c_char_p, ctypes.c_ulonglong, ctypes.c_long] + else: + __cmarkDLL.cmark_markdown_to_html.argtypes = [ctypes.c_char_p, ctypes.c_long, ctypes.c_long] return __cmarkDLL From a7f7b21d6f769501eaf816b2cdfcfbcb7102d43b Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 7 Aug 2019 17:44:46 -0400 Subject: [PATCH 093/123] Documentation : convert from shell scripts to Python scripts for Windows compatibility --- .../generate.py | 31 ++++++++++++++++++ .../generate.sh | 32 ------------------- .../ControlsAndShortcuts/generate.py | 6 ++++ .../WorkingWithScenes/Camera/generate.py | 16 ++++++++++ .../WorkingWithScenes/Camera/generate.sh | 16 ---------- .../BoxNode/generate.py | 12 +++++++ .../BoxNode/generate.sh | 12 ------- .../TutorialUsingTheOSLCodeNode/generate.py | 6 ++++ .../TutorialUsingTheOSLCodeNode/generate.sh | 6 ---- .../ThePythonEditor/generate.py | 12 +++++++ .../ThePythonEditor/generate.sh | 12 ------- .../generate.py | 10 ++++++ .../generate.sh | 10 ------ .../TutorialStartupConfig1/generate.py | 7 ++++ .../TutorialStartupConfig1/generate.sh | 7 ---- .../TutorialStartupConfig2/generate.py | 8 +++++ .../TutorialStartupConfig2/generate.sh | 8 ----- doc/source/generate.py | 8 +++++ doc/source/generate.sh | 8 ----- 19 files changed, 116 insertions(+), 111 deletions(-) create mode 100644 doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.py delete mode 100755 doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.sh create mode 100644 doc/source/Interface/ControlsAndShortcuts/generate.py create mode 100644 doc/source/WorkingWithScenes/Camera/generate.py delete mode 100755 doc/source/WorkingWithScenes/Camera/generate.sh create mode 100644 doc/source/WorkingWithTheNodeGraph/BoxNode/generate.py delete mode 100755 doc/source/WorkingWithTheNodeGraph/BoxNode/generate.sh create mode 100644 doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.py delete mode 100755 doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.sh create mode 100644 doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.py delete mode 100755 doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.sh create mode 100644 doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.py delete mode 100755 doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.sh create mode 100644 doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.py delete mode 100755 doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.sh create mode 100644 doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.py delete mode 100755 doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.sh create mode 100644 doc/source/generate.py delete mode 100755 doc/source/generate.sh diff --git a/doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.py b/doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.py new file mode 100644 index 00000000000..303a2817bec --- /dev/null +++ b/doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.py @@ -0,0 +1,31 @@ +# BuildTarget: images/expansion.png +# BuildTarget: images/plus.png +# BuildTarget: images/nodeSetDriverNodeSelection.png +# BuildTarget: images/nodeSetDriverNodeSet.png +# BuildTarget: images/nodeSetStandardSet.png +# BuildTarget: images/layoutButton.png +# BuildTarget: images/objects.png +# BuildTarget: images/addObjects.png +# BuildTarget: images/replaceObjects.png +# BuildTarget: images/collapsibleArrowRight.png +# BuildTarget: images/timelinePlay.png +# BuildTarget: images/removeObjects.png +# BuildTarget: images/gafferSceneUITranslateTool.png +# BuildTarget: images/gafferSceneUIRotateTool.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "expansion.png" ), os.path.join( "images", "expansion.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "plus.png" ), os.path.join( "images", "plug.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "nodeSetDriverNodeSelection.png" ), os.path.join( "images", "nodeSetDriverNodeSelection.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "nodeSetStandardSet.png" ), os.path.join( "images", "nodeSetStandardSet.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "layoutButton.png" ), os.path.join( "images", "layoutButton.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "objects.png" ), os.path.join( "images", "objects.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "addObjects.png" ), os.path.join( "images", "addObjects.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "replaceObjects.png" ), os.path.join( "images", "replaceObjects.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "collapsibleArrowRight.png" ), os.path.join( "images", "collapsibleArrowRight.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "timelinePlay.png" ), os.path.join( "images", "timelinePlay.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "removeObjects.png" ), os.path.join( "images", "removeObjects.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "gafferSceneUITranslateTool.png" ), os.path.join( "images", "gafferSceneUITranslateTool.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "gafferSceneUIRotateTool.png" ), os.path.join( "images", "gafferSceneUIRotateTool.png" ) ) diff --git a/doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.sh b/doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.sh deleted file mode 100755 index 0c0d451d5ac..00000000000 --- a/doc/source/GettingStarted/TutorialAssemblingTheGafferBot/generate.sh +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/bash -# BuildTarget: images/expansion.png -# BuildTarget: images/plus.png -# BuildTarget: images/nodeSetNodeSelection.png -# BuildTarget: images/nodeSetFocusNode.png -# BuildTarget: images/nodeSetStandardSet.png -# BuildTarget: images/layoutButton.png -# BuildTarget: images/objects.png -# BuildTarget: images/addObjects.png -# BuildTarget: images/replaceObjects.png -# BuildTarget: images/collapsibleArrowRight.png -# BuildTarget: images/timelinePlay.png -# BuildTarget: images/removeObjects.png -# BuildTarget: images/gafferSceneUITranslateTool.png -# BuildTarget: images/gafferSceneUIRotateTool.png - -set -e - -cp $GAFFER_ROOT/graphics/expansion.png images -cp $GAFFER_ROOT/graphics/plus.png images -cp $GAFFER_ROOT/graphics/nodeSetNodeSelection.png images -cp $GAFFER_ROOT/graphics/nodeSetFocusNode.png images -cp $GAFFER_ROOT/graphics/nodeSetStandardSet.png images -cp $GAFFER_ROOT/graphics/layoutButton.png images -cp $GAFFER_ROOT/graphics/objects.png images -cp $GAFFER_ROOT/graphics/addObjects.png images -cp $GAFFER_ROOT/graphics/replaceObjects.png images -cp $GAFFER_ROOT/graphics/collapsibleArrowRight.png images -cp $GAFFER_ROOT/graphics/timelinePlay.png images -cp $GAFFER_ROOT/graphics/removeObjects.png images -cp $GAFFER_ROOT/graphics/gafferSceneUITranslateTool.png images -cp $GAFFER_ROOT/graphics/gafferSceneUIRotateTool.png images diff --git a/doc/source/Interface/ControlsAndShortcuts/generate.py b/doc/source/Interface/ControlsAndShortcuts/generate.py new file mode 100644 index 00000000000..53135e2c072 --- /dev/null +++ b/doc/source/Interface/ControlsAndShortcuts/generate.py @@ -0,0 +1,6 @@ +# BuildTarget: images/nodeSetStandardSet.png + +import shutil +import os + +shutil.copyfile(os.path.join( os.environ["GAFFER_ROOT"], "graphics", "nodeSetStandardSet.png" ), os.path.join( "images", "nodeSetStandardSet.png" ) ) diff --git a/doc/source/WorkingWithScenes/Camera/generate.py b/doc/source/WorkingWithScenes/Camera/generate.py new file mode 100644 index 00000000000..5acd7eab9af --- /dev/null +++ b/doc/source/WorkingWithScenes/Camera/generate.py @@ -0,0 +1,16 @@ +# BuildTarget: images/gafferSceneUIRotateTool.png +# BuildTarget: images/gafferSceneUITranslateTool.png +# BuildTarget: images/cameraOff.png +# BuildTarget: images/gafferSceneUICameraTool.png +# BuildTarget: images/toggleOff.png +# BuildTarget: images/plus.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "gafferSceneUIRotateTool.png" ), os.path.join( "images", "gafferSceneUIRotateTool.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "gafferSceneUITranslateTool.png" ), os.path.join( "images", "gafferSceneUITranslateTool.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "cameraOff.png" ), os.path.join( "images", "cameraOff.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "gafferSceneUICameraTool.png" ), os.path.join( "images", "gafferSceneUICameraTool.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "toggleOff.png" ), os.path.join( "images", "toggleOff.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "plus.png" ), os.path.join( "images", "plus.png" ) ) diff --git a/doc/source/WorkingWithScenes/Camera/generate.sh b/doc/source/WorkingWithScenes/Camera/generate.sh deleted file mode 100755 index 358253ceadc..00000000000 --- a/doc/source/WorkingWithScenes/Camera/generate.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/bash -# BuildTarget: images/gafferSceneUIRotateTool.png -# BuildTarget: images/gafferSceneUITranslateTool.png -# BuildTarget: images/cameraOff.png -# BuildTarget: images/gafferSceneUICameraTool.png -# BuildTarget: images/toggleOff.png -# BuildTarget: images/plus.png - -set -e - -cp $GAFFER_ROOT/graphics/gafferSceneUIRotateTool.png images -cp $GAFFER_ROOT/graphics/gafferSceneUITranslateTool.png images -cp $GAFFER_ROOT/graphics/cameraOff.png images -cp $GAFFER_ROOT/graphics/gafferSceneUICameraTool.png images -cp $GAFFER_ROOT/graphics/toggleOff.png images -cp $GAFFER_ROOT/graphics/plus.png images diff --git a/doc/source/WorkingWithTheNodeGraph/BoxNode/generate.py b/doc/source/WorkingWithTheNodeGraph/BoxNode/generate.py new file mode 100644 index 00000000000..e0661831327 --- /dev/null +++ b/doc/source/WorkingWithTheNodeGraph/BoxNode/generate.py @@ -0,0 +1,12 @@ +# BuildTarget: images/gear.png +# BuildTarget: images/info.png +# BuildTarget: images/plugAdder.png +# BuildTarget: images/valueChanged.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "gear.png" ), os.path.join( "images", "gear.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "info.png" ), os.path.join( "images", "info.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "plugAdder.png" ), os.path.join( "images", "plugAdder.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "valueChanged.png" ), os.path.join( "images", "valueChanged.png" ) ) diff --git a/doc/source/WorkingWithTheNodeGraph/BoxNode/generate.sh b/doc/source/WorkingWithTheNodeGraph/BoxNode/generate.sh deleted file mode 100755 index 09d3523a4c0..00000000000 --- a/doc/source/WorkingWithTheNodeGraph/BoxNode/generate.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash -# BuildTarget: images/gear.png -# BuildTarget: images/info.png -# BuildTarget: images/plugAdder.png -# BuildTarget: images/valueChanged.png - -set -e - -cp $GAFFER_ROOT/graphics/gear.png images -cp $GAFFER_ROOT/graphics/info.png images -cp $GAFFER_ROOT/graphics/plugAdder.png images -cp $GAFFER_ROOT/graphics/valueChanged.png images diff --git a/doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.py b/doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.py new file mode 100644 index 00000000000..387aa0c22fb --- /dev/null +++ b/doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.py @@ -0,0 +1,6 @@ +# BuildTarget: images/plus.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "plus.png" ), os.path.join( "images", "plus.png" ) ) diff --git a/doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.sh b/doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.sh deleted file mode 100755 index e81010d23d4..00000000000 --- a/doc/source/WorkingWithTheNodeGraph/TutorialUsingTheOSLCodeNode/generate.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/bash -# BuildTarget: images/plus.png - -set -e - -cp $GAFFER_ROOT/graphics/plus.png images diff --git a/doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.py b/doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.py new file mode 100644 index 00000000000..75cdf6d0211 --- /dev/null +++ b/doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.py @@ -0,0 +1,12 @@ +# BuildTarget: images/plug.png +# BuildTarget: images/values.png +# BuildTarget: images/nodes.png +# BuildTarget: images/objects.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "plug.png" ), os.path.join( "images", "plug.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "values.png" ), os.path.join( "images", "values.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "nodes.png" ), os.path.join( "images", "nodes.png" ) ) +shutil.copyfile( os.path.join( os.environ["GAFFER_ROOT"], "graphics", "objects.png" ), os.path.join( "images", "objects.png" ) ) diff --git a/doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.sh b/doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.sh deleted file mode 100755 index 50f3cde1f9a..00000000000 --- a/doc/source/WorkingWithThePythonScriptingAPI/ThePythonEditor/generate.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash -# BuildTarget: images/plug.png -# BuildTarget: images/values.png -# BuildTarget: images/nodes.png -# BuildTarget: images/objects.png - -set -e - -cp $GAFFER_ROOT/graphics/plug.png images/plug.png -cp $GAFFER_ROOT/graphics/values.png images/values.png -cp $GAFFER_ROOT/graphics/nodes.png images/nodes.png -cp $GAFFER_ROOT/graphics/objects.png images/objects.png diff --git a/doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.py b/doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.py new file mode 100644 index 00000000000..6399c62d2dc --- /dev/null +++ b/doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.py @@ -0,0 +1,10 @@ +# BuildTarget: images/nodes.png +# BuildTarget: images/plus.png +# BuildTarget: images/values.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "nodes.png" ), os.path.join( "images", "nodes.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "plug.png" ), os.path.join( "images", "plug.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "values.png" ), os.path.join( "images", "values.png" ) ) diff --git a/doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.sh b/doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.sh deleted file mode 100755 index 12617fe89d0..00000000000 --- a/doc/source/WorkingWithThePythonScriptingAPI/TutorialNodeGraphEditingInPython/generate.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash -# BuildTarget: images/nodes.png -# BuildTarget: images/plus.png -# BuildTarget: images/values.png - -set -e - -cp $GAFFER_ROOT/graphics/nodes.png images -cp $GAFFER_ROOT/graphics/plug.png images -cp $GAFFER_ROOT/graphics/values.png images diff --git a/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.py b/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.py new file mode 100644 index 00000000000..04ae5618819 --- /dev/null +++ b/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.py @@ -0,0 +1,7 @@ +# BuildTarget: images/pathChooser.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "pathChooser.png" ), os.path.join( "images", "pathChooser.png" ) ) + diff --git a/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.sh b/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.sh deleted file mode 100755 index a1796d92c39..00000000000 --- a/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig1/generate.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash -# BuildTarget: images/pathChooser.png - -set -e - -cp $GAFFER_ROOT/graphics/pathChooser.png images - diff --git a/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.py b/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.py new file mode 100644 index 00000000000..3a8c07c4b87 --- /dev/null +++ b/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.py @@ -0,0 +1,8 @@ +# BuildTarget: images/pathChooser.png +# BuildTarget: images/bookmarks.png + +import shutil +import os + +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "pathChooser.png" ), os.path.join( "images", "pathChooser.png" ) ) +shutil.copyfile( os.path.join( os.environ["$GAFFER_ROOT"], "graphics", "bookmarks.png" ), os.path.join( "images", "bookmarks.png" ) ) diff --git a/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.sh b/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.sh deleted file mode 100755 index 0659ca0f6cf..00000000000 --- a/doc/source/WorkingWithThePythonScriptingAPI/TutorialStartupConfig2/generate.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/bash -# BuildTarget: images/pathChooser.png -# BuildTarget: images/bookmarks.png - -set -e - -cp $GAFFER_ROOT/graphics/pathChooser.png images -cp $GAFFER_ROOT/graphics/bookmarks.png images diff --git a/doc/source/generate.py b/doc/source/generate.py new file mode 100644 index 00000000000..b255448df95 --- /dev/null +++ b/doc/source/generate.py @@ -0,0 +1,8 @@ +# BuildTarget: _static/GafferLogo.svg _static/GafferLogoMini.svg +# BuildTarget: _static/GafferLogoMini.svg + +import shutil +import os + +shutil.copyfile( os.path.join( "..", "..", "resources", "GafferLogo.svg" ), os.path.join( "_static", "GafferLogo.svg" ) ) +shutil.copyfile( os.path.join( "..", "..", "resources", "GafferLogoMini.svg" ), os.path.join( "_static", "GafferLogoMini.svg" ) ) diff --git a/doc/source/generate.sh b/doc/source/generate.sh deleted file mode 100755 index 262cc372f4c..00000000000 --- a/doc/source/generate.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/bash -# BuildTarget: _static/GafferLogo.svg -# BuildTarget: _static/GafferLogoMini.svg - -set -e - -cp ../../resources/GafferLogo.svg _static -cp ../../resources/GafferLogoMini.svg _static From 72fd6db440660f20815d0f51ec1068d086066bd1 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 9 Aug 2019 15:58:37 -0400 Subject: [PATCH 094/123] Shaders : cross-platform search path separator --- python/GafferAppleseedUI/ShaderMenu.py | 2 +- startup/gui/menus.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/GafferAppleseedUI/ShaderMenu.py b/python/GafferAppleseedUI/ShaderMenu.py index 4da85efbee3..6ce93d3fc16 100644 --- a/python/GafferAppleseedUI/ShaderMenu.py +++ b/python/GafferAppleseedUI/ShaderMenu.py @@ -62,7 +62,7 @@ def appendShaders( menuDefinition ) : q = asr.ShaderQuery() - for path in os.environ["APPLESEED_SEARCHPATH"].split( ":" ) : + for path in os.environ["APPLESEED_SEARCHPATH"].split( os.path.pathsep ) : for shader in glob.glob( os.path.join( path, "*.oso" ) ) : shaderFilename = os.path.basename( shader ) diff --git a/startup/gui/menus.py b/startup/gui/menus.py index c01d95f4e66..e2e34399bcf 100644 --- a/startup/gui/menus.py +++ b/startup/gui/menus.py @@ -420,7 +420,7 @@ def __shaderNodeCreator( nodeName, shaderName ) : GafferSceneUI.ShaderUI.appendShaders( nodeMenu.definition(), "/OSL/Shader", - os.environ["OSL_SHADER_PATHS"].split( ":" ), + os.environ["OSL_SHADER_PATHS"].split( os.path.pathsep ), [ "oso" ], __shaderNodeCreator, # Appleseed comes with a library of OSL shaders which we put From d911c26040100daf55b61ddcb9385158d8ac7056 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 13 Jan 2020 21:07:43 -0500 Subject: [PATCH 095/123] Catalogue : force substitutions - override Process::current() check in FileSystemPathPlug --- src/GafferImage/Catalogue.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/GafferImage/Catalogue.cpp b/src/GafferImage/Catalogue.cpp index 8398e750fa9..8e27562206c 100644 --- a/src/GafferImage/Catalogue.cpp +++ b/src/GafferImage/Catalogue.cpp @@ -918,10 +918,13 @@ std::string Catalogue::generateFileName( const Image *image ) const std::string Catalogue::generateFileName( const ImagePlug *image ) const { + // Force substitutions because Process::current() is false + // and FileSystemPathPlug won't do substitutions by default string directory = directoryPlug()->getValue(); + if( const ScriptNode *script = ancestor() ) { - directory = script->context()->substitute( directory ); + directory = directoryPlug()->getValue(nullptr, script->context(), true); } else if( IECore::StringAlgo::hasSubstitutions( directory ) ) { From b0d24a701267310d33f768eff5a2975d1c9e9f2f Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 29 Oct 2020 14:45:36 -0400 Subject: [PATCH 096/123] Stats : add Windows Max resident size reporting "resource" module is not available on Windows and it appears the best native Python method of getting MaxRSS is through the pywin32 extension which would introduce a new dependency. Using a subprocess command and parsing the output is a simple alternative since performance is not critical here. --- apps/stats/stats-1.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/stats/stats-1.py b/apps/stats/stats-1.py index d1fff81f4d0..793f22fe999 100644 --- a/apps/stats/stats-1.py +++ b/apps/stats/stats-1.py @@ -39,10 +39,14 @@ import sys import time import tempfile -import resource import collections import six +if sys.platform != "win32": + import resource +else: + import subprocess + import IECore import Gaffer @@ -746,6 +750,9 @@ def maxRSS( cls ) : if sys.platform == "darwin" : return cls( resource.getrusage( resource.RUSAGE_SELF ).ru_maxrss ) + elif sys.platform == "win32" : + result = subprocess.check_output( ["wmic", "process", "where", "processid={}".format(os.getpid()), "get", "PeakWorkingSetSize"] ) + return cls( int( result.split()[1] ) * 1024 ) else : return cls( resource.getrusage( resource.RUSAGE_SELF ).ru_maxrss * 1024 ) From 07687b34a741a5b6aa8a39ef3d5fc996c37ca98b Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 24 Mar 2021 18:54:29 -0400 Subject: [PATCH 097/123] ScriptNodeBinding : remove AST processing in tolerantExec - AST is not available on Windows without a patched, customized Python build. - This comes from the experimental implementation in https://github.com/johnhaddon/gaffer/commit/c817cf623744d91eea3c56a2ae21c0247ecd5058 - Note that it introduces a performance regression for loading scripts vs. the AST implementation. --- python/GafferTest/ScriptNodeTest.py | 2 +- src/GafferModule/ScriptNodeBinding.cpp | 114 ++++--------------------- 2 files changed, 19 insertions(+), 97 deletions(-) diff --git a/python/GafferTest/ScriptNodeTest.py b/python/GafferTest/ScriptNodeTest.py index 9dcd5e2356c..06b729f970c 100644 --- a/python/GafferTest/ScriptNodeTest.py +++ b/python/GafferTest/ScriptNodeTest.py @@ -1146,7 +1146,7 @@ def testErrorTolerantExecution( self ) : s["n"] = GafferTest.AddNode() with IECore.CapturingMessageHandler() as c : - s.execute( 'parent["n"]["op1"].setValue( 101 )\niWillFail(); parent["n"]["op2"].setValue( 102 )', continueOnError=True ) + s.execute( 'parent["n"]["op1"].setValue( 101 )\niWillFail()\nparent["n"]["op2"].setValue( 102 )', continueOnError=True ) self.assertEqual( s["n"]["op1"].getValue(), 101 ) self.assertEqual( s["n"]["op2"].getValue(), 102 ) diff --git a/src/GafferModule/ScriptNodeBinding.cpp b/src/GafferModule/ScriptNodeBinding.cpp index 47388c2dfda..1fa598aea5f 100644 --- a/src/GafferModule/ScriptNodeBinding.cpp +++ b/src/GafferModule/ScriptNodeBinding.cpp @@ -56,52 +56,19 @@ #include "IECore/MessageHandler.h" +#include "boost/algorithm/string/classification.hpp" +#include "boost/algorithm/string/find_iterator.hpp" #include "boost/algorithm/string/replace.hpp" #include "boost/lexical_cast.hpp" #include "boost/regex.hpp" #include +using namespace std; +using namespace boost; using namespace Gaffer; using namespace GafferBindings; -////////////////////////////////////////////////////////////////////////// -// Access to Python AST -////////////////////////////////////////////////////////////////////////// - -extern "C" -{ - -// Essential to include this last, since it defines macros which -// clash with other headers. -#include "Python-ast.h" - -#if PY_MAJOR_VERSION >= 3 -/// \todo The already esoteric AST API appears to be even more obscure -/// in Python 3, and it has never been available on Windows. We would do -/// well to avoid it entirely. One simple alternative is implemented in -/// https://github.com/johnhaddon/gaffer/tree/simpleTolerantExec, but -/// initial benchmarking suggested that performance was worse. -#include "asdl.h" -#undef arg -#define asdl_seq_new _Py_asdl_seq_new -#endif - -}; - -namespace boost { -namespace python { - -// Specialisation to allow use of handle -template<> -struct base_type_traits -{ - typedef PyObject type; -}; - -} // namespace python -} // namespace boost - ////////////////////////////////////////////////////////////////////////// // Serialisation ////////////////////////////////////////////////////////////////////////// @@ -122,75 +89,30 @@ const std::string formattedErrorContext( int lineNumber, const std::string &cont // Execute the script one top level statement at a time, // reporting errors that occur, but otherwise continuing // with execution. -bool tolerantExec( const char *pythonScript, boost::python::object globals, boost::python::object locals, const std::string &context ) +bool tolerantExec( const string &pythonScript, boost::python::object globals, boost::python::object locals, const std::string &context ) { - // The python parsing framework uses an arena to simplify memory allocation, - // which is handy for us, since we're going to manipulate the AST a little. - std::unique_ptr arena( PyArena_New(), PyArena_Free ); - - // Parse the whole script, getting an abstract syntax tree for a - // module which would execute everything. - mod_ty mod = PyParser_ASTFromString( - pythonScript, - "", - Py_file_input, - nullptr, - arena.get() - ); - - if( !mod ) - { - int lineNumber = 0; - std::string message = IECorePython::ExceptionAlgo::formatPythonException( /* withTraceback = */ false, &lineNumber ); - IECore::msg( IECore::Msg::Error, formattedErrorContext( lineNumber, context ), message ); - return false; - } - const IECore::Canceller *canceller = Context::current()->canceller(); IECore::Canceller::check( canceller ); - assert( mod->kind == Module_kind ); - - // Loop over the top-level statements in the module body, - // executing one at a time. bool result = false; - int numStatements = asdl_seq_LEN( mod->v.Module.body ); - for( int i=0; i() ) { IECore::Canceller::check( canceller ); - - // Make a new module containing just this one statement. - asdl_seq *newBody = asdl_seq_new( 1, arena.get() ); - asdl_seq_SET( newBody, 0, asdl_seq_GET( mod->v.Module.body, i ) ); - mod_ty newModule = Module( - newBody, - arena.get() - ); - - // Compile it. - boost::python::handle code( PyAST_Compile( newModule, "", nullptr, arena.get() ) ); - - // And execute it. - boost::python::handle<> v( boost::python::allow_null( - PyEval_EvalCode( -#if PY_MAJOR_VERSION >= 3 - (PyObject *)code.get(), -#else - code.get(), -#endif - globals.ptr(), - locals.ptr() - ) - ) ); - - // Report any errors. - if( v == nullptr) + + const string line( it->begin(), it->end() ); + try + { + exec( line.c_str(), globals, locals ); + } + catch( const boost::python::error_already_set &e ) { - int lineNumber = 0; - std::string message = IECorePython::ExceptionAlgo::formatPythonException( /* withTraceback = */ false, &lineNumber ); + const string message = IECorePython::ExceptionAlgo::formatPythonException( /* withTraceback = */ false ); IECore::msg( IECore::Msg::Error, formattedErrorContext( lineNumber, context ), message ); result = true; } + ++it; ++lineNumber; } return result; @@ -342,7 +264,7 @@ bool execute( ScriptNode *script, const std::string &serialisation, Node *parent } else { - result = tolerantExec( toExecute.c_str(), e, e, context ); + result = tolerantExec( toExecute, e, e, context ); } } catch( boost::python::error_already_set &e ) From 46a56cddbef481b34ff9bf1bbc3f3826d21db8d3 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 26 Apr 2021 11:34:19 -0400 Subject: [PATCH 098/123] ContextTest : add Windows compatibility - Windows does not have `rand_r` function, but `rand` is thread safe, so we use that on Windows only --- src/GafferTest/ContextTest.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/GafferTest/ContextTest.cpp b/src/GafferTest/ContextTest.cpp index 7784effeda6..d69333e49ff 100644 --- a/src/GafferTest/ContextTest.cpp +++ b/src/GafferTest/ContextTest.cpp @@ -210,6 +210,14 @@ std::tuple GafferTest::countContextHash32Collisions( int contex } unsigned int rand_seed = seed; + + // There is no `rand_r` function on Windows, but Windows `rand` is thread safe. + // N.B. `srand` applies per-thread, so if random numbers need to be unique across + // threads, something like `GetCurrentThreadId()` should be added to `rand_seed` + #ifdef _MSC_VER + srand( rand_seed ); + #endif + int collisions[4] = {0,0,0,0}; for( int i = 0; i < contexts; i++ ) { @@ -238,7 +246,11 @@ std::tuple GafferTest::countContextHash32Collisions( int contex { for( int j = 0; j < 20; j++ ) { - c.set( numberNames[j], rand_r( &rand_seed ) ); + #ifndef _MSC_VER + c.set( numberNames[j], rand_r( &rand_seed ) ); + #else + c.set( numberNames[j], rand() ); + #endif } } From 0b44e9edc3827b6e789baddf33c81b04eb1deb89 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Wed, 29 Dec 2021 18:02:08 -0500 Subject: [PATCH 099/123] IECoreArnold : sys.getdlopenflags only applies to POSIX platforms --- python/IECoreArnold/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/IECoreArnold/__init__.py b/python/IECoreArnold/__init__.py index 4d4e111728a..12b47d48954 100644 --- a/python/IECoreArnold/__init__.py +++ b/python/IECoreArnold/__init__.py @@ -39,14 +39,16 @@ # See comments in `GafferArnold/__init__.py` import sys import ctypes - originalDLOpenFlags = sys.getdlopenflags() - sys.setdlopenflags( originalDLOpenFlags & ~ctypes.RTLD_GLOBAL ) + if sys.platform != "win32": + originalDLOpenFlags = sys.getdlopenflags() + sys.setdlopenflags( originalDLOpenFlags & ~ctypes.RTLD_GLOBAL ) from ._IECoreArnold import * finally : - - sys.setdlopenflags( originalDLOpenFlags ) - del sys, ctypes, originalDLOpenFlags + if sys.platform != "win32": + sys.setdlopenflags( originalDLOpenFlags ) + del originalDLOpenFlags + del sys, ctypes from .UniverseBlock import UniverseBlock From c40203831521155697089ccae1050f240dfc442f Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Thu, 13 Jan 2022 11:18:11 -0500 Subject: [PATCH 100/123] HiddenFilePathFilter : add path filter for hidden files - Windows uses file attributes to mark files and directories as hidden, so a MatchPatternPathFilter is unsuitable. --- include/Gaffer/HiddenFilePathFilter.h | 81 +++++++++++++ include/Gaffer/TypeIds.h | 1 + python/GafferTest/HiddenFilePathFilterTest.py | 77 ++++++++++++ python/GafferTest/__init__.py | 1 + src/Gaffer/FileSystemPath.cpp | 4 +- src/Gaffer/HiddenFilePathFilter.cpp | 112 ++++++++++++++++++ src/GafferModule/PathFilterBinding.cpp | 9 ++ 7 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 include/Gaffer/HiddenFilePathFilter.h create mode 100644 python/GafferTest/HiddenFilePathFilterTest.py create mode 100644 src/Gaffer/HiddenFilePathFilter.cpp diff --git a/include/Gaffer/HiddenFilePathFilter.h b/include/Gaffer/HiddenFilePathFilter.h new file mode 100644 index 00000000000..038b97bd773 --- /dev/null +++ b/include/Gaffer/HiddenFilePathFilter.h @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2022, Hypothetical Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with +// the distribution. +// +// * Neither the name of John Haddon nor the names of +// any other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#ifndef GAFFER_HIDDENFILEPATHFILTER_H +#define GAFFER_HIDDENFILEPATHFILTER_H + +#include "Gaffer/PathFilter.h" +#include "Gaffer/TypeIds.h" + +namespace Gaffer +{ + +IE_CORE_FORWARDDECLARE( HiddenFilePathFilter ) + +/// HiddenFilePathFilters can filter the results +/// of FileSystemPath::children() to provide a masked view +/// that either includes or excludes hidden files. +class GAFFER_API HiddenFilePathFilter : public PathFilter +{ + + public : + + HiddenFilePathFilter( IECore::CompoundDataPtr userData = nullptr ); + ~HiddenFilePathFilter() override; + + IE_CORE_DECLARERUNTIMETYPEDEXTENSION( Gaffer::HiddenFilePathFilter, HiddenFilePathFilterTypeId, Gaffer::PathFilter ); + + void setInverted( bool inverted ); + bool getInverted() const; + + protected : + + void doFilter( std::vector &paths, const IECore::Canceller *canceller ) const override; + + private : + + bool invert( bool b ) const; + bool remove( PathPtr path ) const; + + bool m_inverted; + +}; + +IE_CORE_DECLAREPTR( HiddenFilePathFilter ) + +} // namespace Gaffer + +#endif // GAFFER_HIDDENFILEPATHFILTER_H diff --git a/include/Gaffer/TypeIds.h b/include/Gaffer/TypeIds.h index 4d5ee49a687..ee01069e1a2 100644 --- a/include/Gaffer/TypeIds.h +++ b/include/Gaffer/TypeIds.h @@ -143,6 +143,7 @@ enum TypeId ScriptNodeFocusSetTypeId = 110096, AnimationKeyTypeId = 110097, FileSystemPathPlugTypeId = 110098, + HiddenFilePathFilterTypeId = 110099, LastTypeId = 110159, diff --git a/python/GafferTest/HiddenFilePathFilterTest.py b/python/GafferTest/HiddenFilePathFilterTest.py new file mode 100644 index 00000000000..d8e75d547f1 --- /dev/null +++ b/python/GafferTest/HiddenFilePathFilterTest.py @@ -0,0 +1,77 @@ +########################################################################## +# +# Copyright (c) 2022 Hypothetical Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with +# the distribution. +# +# * Neither the name of John Haddon nor the names of +# any other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + +import os +import subprocess +import tempfile +import unittest + +import Gaffer +import GafferTest + +class HiddenFilePathFilterTest( GafferTest.TestCase ) : + + def test( self ) : + + hiddenFile = Gaffer.FileSystemPath( os.path.join( self.temporaryDirectory(), ".sneaky.txt" ) ) + with open( hiddenFile.nativeString(), "w" ) as f : + f.write( "Can't see me" ) + if os.name == "nt" : + subprocess.check_call( [ "attrib", "+H", hiddenFile.nativeString() ] ) + + visibleFile = Gaffer.FileSystemPath( os.path.join( self.temporaryDirectory(), "frank.txt" ) ) + with open( visibleFile.nativeString(), "w" ) as f : + f.write( "Can see me" ) + + p = Gaffer.FileSystemPath( os.path.dirname( hiddenFile.nativeString() ) ) + + self.assertEqual( + sorted( [ str( i ) for i in p.children() ] ), + sorted( [ str( hiddenFile ), str( visibleFile ) ] ) + ) + + h = Gaffer.HiddenFilePathFilter() + p.setFilter( h ) + + self.assertEqual( p.children(), [ hiddenFile ] ) + + h.setInverted( True ) + + self.assertEqual( p.children(), [ visibleFile ] ) + + +if __name__ == "__main__": + unittest.main() diff --git a/python/GafferTest/__init__.py b/python/GafferTest/__init__.py index c7f48cb9ec2..5fdc743348f 100644 --- a/python/GafferTest/__init__.py +++ b/python/GafferTest/__init__.py @@ -166,6 +166,7 @@ def inCI( platforms = set() ) : from .EditScopeTest import EditScopeTest from .FileSystemPathInOutNode import FileSystemPathInOutNode from .FileSystemPathPlugTest import FileSystemPathPlugTest +from .HiddenFilePathFilterTest import HiddenFilePathFilterTest from .IECorePreviewTest import * diff --git a/src/Gaffer/FileSystemPath.cpp b/src/Gaffer/FileSystemPath.cpp index 1187b6a1427..5dc6b394fb8 100644 --- a/src/Gaffer/FileSystemPath.cpp +++ b/src/Gaffer/FileSystemPath.cpp @@ -39,6 +39,7 @@ #include "Gaffer/CompoundPathFilter.h" #include "Gaffer/FileSequencePathFilter.h" +#include "Gaffer/HiddenFilePathFilter.h" #include "Gaffer/MatchPatternPathFilter.h" #include "Gaffer/PathFilter.h" @@ -485,8 +486,7 @@ PathFilterPtr FileSystemPath::createStandardFilter( const std::vector