Skip to content

Commit

Permalink
0.8.0 Beta solidify pixel engines, and polish (#4)
Browse files Browse the repository at this point in the history
- add validateTargetLayerColorIndex funciton to all tools that define a target layer
- remove "all" in layerSetKnobs that use CategorizeFilters
- LayerSetKnob.cpp : remove now unneeded layerSetKnobData manipulations
- LayerSetConfig.h, add const reference
- add simple central version handling, cleanup
- adapt to upstream changes to argparse repo, locking it to latest version v0.1.0
- add LayerAlchemy namespace
- namespaced all nuke plugins
- remove redundant of unused includes (again)
- code style tweaks

- GradeLayerSet.cpp: rewrite to follow GradeBeautyLayerSet engines
- FlattenLayerSet.cpp: refactors, and slight tweaks to pixel engine
- add mix luminance back to grade type tools
- createVersionTextKnob to show the version on nuke plugins

- CMake : compile yaml-cpp to custom namespace to avoid namespace clashes with nuke 12 ocio yaml-cpp
- CMake : remove loops, make explicit
- CMake: add documentation package target
- CMake : add external projects in thirdparty directory
- CMake : update to use version.h

- update documentation images
  • Loading branch information
sebjacob authored Dec 19, 2019
1 parent 09f256a commit ca9d982
Show file tree
Hide file tree
Showing 24 changed files with 1,013 additions and 664 deletions.
102 changes: 52 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ cmake_minimum_required(VERSION 2.8)
include(BundleUtilities)
include(ExternalProject)

set(PROJECT_NAME LayerAlchemy)
set(LAYER_ALCHEMY_VERSION_MAJOR 0)
set(LAYER_ALCHEMY_VERSION_MINOR 7)
set(LAYER_ALCHEMY_VERSION_PATCH 1)

project(LayerAlchemy)

# get the LayerAlchemy version info
set(LAYER_ALCHEMY_VERSION_HEADER_FILE ${CMAKE_SOURCE_DIR}/include/version.h)
file(READ ${LAYER_ALCHEMY_VERSION_HEADER_FILE} version)
string(REGEX MATCH "#define LAYER_ALCHEMY_VERSION_MAJOR ([0-9]*)" _ ${version})
set(LAYER_ALCHEMY_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define LAYER_ALCHEMY_VERSION_MINOR ([0-9]*)" _ ${version})
set(LAYER_ALCHEMY_VERSION_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define LAYER_ALCHEMY_VERSION_PATCH ([0-9]*)" _ ${version})
set(LAYER_ALCHEMY_VERSION_PATCH ${CMAKE_MATCH_1})
set(LAYER_ALCHEMY_VERSION_STRING
${LAYER_ALCHEMY_VERSION_MAJOR}.${LAYER_ALCHEMY_VERSION_MINOR}.${LAYER_ALCHEMY_VERSION_PATCH}
)
option(BUILD_APPS "Build binary applications" ON)
option(BUILD_DOCS "Build html documentation" ON)
option(BUILD_NUKE "Build the Nuke plugins" ON)
Expand All @@ -19,7 +28,7 @@ set(NUKE_ROOT "/opt/nuke/Nuke12.0v1" CACHE PATH "Path to Nuke install root")
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-msse -O3")
set(CMAKE_CXX_FLAGS "-msse -O3 -DYAML=LAYER_ALCHEMY_YAML") # avoid Nuke 12 OCIO yaml-cpp namespace clashing
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Tells CMake to add -fPic flag.

if(UNIX AND NOT CYGWIN)
Expand All @@ -42,19 +51,20 @@ ExternalProject_Add(yaml_cpp
# YAML_CPP_BUILD_TESTS -> Don't build tests
# CMAKE_POSITION_INDEPENDENT_CODE -> Tells CMake to add -fPic flag.
# By default yaml-cpp uses fPic only when building in shared mode.
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libs -DYAML_CPP_BUILD_TESTS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
BUILD_COMMAND "$(MAKE)" # $(MAKE) (with parenthesis, not brackets) allows to inherits make -j multi-threads.
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libs -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DYAML_CPP_BUILD_TESTS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
PREFIX "${CMAKE_BINARY_DIR}/third-party/yaml_cpp"
)

ExternalProject_Add(argparse
# A simple C++ header only command line argument parser
# Jesse Laning https://github.com/jamolnng
GIT_REPOSITORY https://github.com/jamolnng/argparse.git
GIT_TAG master
GIT_TAG v0.1.0
BUILD_COMMAND ""
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
UPDATE_COMMAND "" # for cmake cache,
PREFIX "${CMAKE_BINARY_DIR}/third-party/argparse"
)

link_directories(
Expand All @@ -64,49 +74,35 @@ link_directories(
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/libs/include
${CMAKE_CURRENT_BINARY_DIR}/argparse-prefix/src/argparse
${CMAKE_BINARY_DIR}/third-party/argparse/src/argparse
)

set(LAYERSET_LIBS
LayerSetConfig
LayerSetCore
)
# loop over LAYERSET_LIBS
foreach(LAYERSET_LIB ${LAYERSET_LIBS})
add_library(${LAYERSET_LIB}
STATIC
${CMAKE_SOURCE_DIR}/src/${LAYERSET_LIB}.cpp
)
add_dependencies(${LAYERSET_LIB} yaml_cpp)
target_link_libraries(${LAYERSET_LIB} yaml-cpp)
add_library(LayerSetConfig STATIC ${CMAKE_SOURCE_DIR}/src/LayerSetConfig.cpp)
add_dependencies(LayerSetConfig yaml_cpp)
target_link_libraries(LayerSetConfig PRIVATE yaml-cpp)
set_target_properties(LayerSetConfig PROPERTIES PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/LayerSetConfig.h)
list(APPEND LAYERSET_LIBS LayerSetConfig)

install(
TARGETS ${LAYERSET_LIB}
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
endforeach()
add_library(LayerSetCore STATIC ${CMAKE_SOURCE_DIR}/src/LayerSetCore.cpp)
add_dependencies(LayerSetCore LayerSetConfig)
set_target_properties(LayerSetCore PROPERTIES PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/LayerSetCore.h)
list(APPEND LAYERSET_LIBS LayerSetCore)

# include files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${CMAKE_INSTALL_PREFIX}
FILES_MATCHING PATTERN "*.h*"
PATTERN ".DS_Store" EXCLUDE
PATTERN "@eaDir" EXCLUDE
TARGETS ${LAYERSET_LIBS}
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)

if(BUILD_APPS)
add_executable(LayerTester ${CMAKE_SOURCE_DIR}/src/LayerTester.cpp)
add_executable(ConfigTester ${CMAKE_SOURCE_DIR}/src/ConfigTester.cpp)
add_dependencies(LayerTester argparse)
target_link_libraries(LayerTester LayerSetCore LayerSetConfig)
add_dependencies(LayerTester argparse)

add_executable(ConfigTester ${CMAKE_SOURCE_DIR}/src/ConfigTester.cpp)
target_link_libraries(ConfigTester LayerSetCore LayerSetConfig)
install(
TARGETS LayerTester
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
install(
TARGETS ConfigTester
TARGETS LayerTester ConfigTester
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
endif()
Expand All @@ -122,12 +118,18 @@ install(
FILES ${TEXT_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/
)
install(
FILES ${LAYER_ALCHEMY_VERSION_HEADER_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)

if(BUILD_NUKE)
add_subdirectory(src/nuke)
endif(BUILD_NUKE)
endif()

add_subdirectory(documentation)
if(BUILD_DOCS)
add_subdirectory(documentation)
endif()

# Section for packaging the project

Expand All @@ -137,22 +139,22 @@ else()
string(TOLOWER ${CMAKE_SYSTEM_NAME} platformName)
endif()

set(PROJECT_PACKAGE_NAME "${PROJECT_NAME}-${LAYER_ALCHEMY_VERSION_MAJOR}.${LAYER_ALCHEMY_VERSION_MINOR}.${LAYER_ALCHEMY_VERSION_PATCH}-${platformName}")
set(PROJECT_PACKAGE_NAME "${PROJECT_NAME}-${LAYER_ALCHEMY_VERSION_STRING}-${platformName}")

if(BUILD_NUKE)
set(PROJECT_PACKAGE_NAME "${PROJECT_NAME}-${LAYER_ALCHEMY_VERSION_MAJOR}.${LAYER_ALCHEMY_VERSION_MINOR}.${LAYER_ALCHEMY_VERSION_PATCH}-nuke-${NUKE_RELEASE}-${platformName}")
set(PROJECT_PACKAGE_NAME "${PROJECT_NAME}-${LAYER_ALCHEMY_VERSION_STRING}-nuke-${NUKE_RELEASE}-${platformName}")
endif()


if (WIN32)
set(PROJECT_PACKAGE_COMMAND "cfv" "${PROJECT_PACKAGE_NAME}.zip" --format=zip "${CMAKE_INSTALL_PREFIX}")
else(WIN32)
else()
set(PROJECT_PACKAGE_COMMAND "cfvz" "${PROJECT_PACKAGE_NAME}.tgz" "${CMAKE_INSTALL_PREFIX}")
endif(WIN32)
endif()

add_custom_target(package
COMMENT "creating package for ${PROJECT_PACKAGE_NAME}"
COMMAND ${CMAKE_COMMAND} -E tar ${PROJECT_PACKAGE_COMMAND}
DEPENDS ${CMAKE_INSTALL_PREFIX} # make sure the install direcotry exists
)
list (APPEND EXCLUDE "CMakeLists.txt$" ".*" "@eaDir" "*.pyc") # default excludes
DEPENDS ${CMAKE_INSTALL_PREFIX} # make sure the install directory exists
DEPENDS documentation
)
23 changes: 14 additions & 9 deletions documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
find_package(PythonInterp)
find_program(PYTHON "python")
find_program(MKDOCS_ABSPATH NAMES mkdocs)
include(GNUInstallDirs)

get_filename_component(DOCUMENTATION_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/documentation" ABSOLUTE)

add_custom_target(documentation
COMMAND ${MKDOCS_ABSPATH} build -c -s -v -q --site-dir ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${MKDOCS_ABSPATH} build -c -s -v -q --site-dir ${CMAKE_CURRENT_BINARY_DIR}/site
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating mkdocs documentation in ${CMAKE_CURRENT_SOURCE_DIR}"
)

add_custom_target(documentation_package
COMMENT "creating documentation package for ${PROJECT_PACKAGE_NAME}"
COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${PROJECT_NAME}-${LAYER_ALCHEMY_VERSION_STRING}_documentation.tgz" "${DOCUMENTATION_INSTALL_DIR}"
DEPENDS ${CMAKE_INSTALL_PREFIX} # make sure the install directory exists
DEPENDS documentation
)

install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DESTINATION ${CMAKE_INSTALL_PREFIX}
PATTERN "CmakeFiles" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "Makefile" EXCLUDE
PATTERN "cmake_install.cmake" EXCLUDE
)
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/site/
DESTINATION ${DOCUMENTATION_INSTALL_DIR}
)
Binary file modified documentation/docs/media/parameters/FlattenLayerSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/docs/media/parameters/GradeBeauty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/docs/media/parameters/GradeBeautyLayerSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/docs/media/parameters/GradeBeauty_uncollapsed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/docs/media/parameters/GradeLayerSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/docs/media/parameters/MultiplyLayerSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/docs/media/parameters/RemoveLayerSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions include/LayerSetConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

//In the channels config files, these values will be used for topology functions
static const string TOPOLOGY_KEY_LEXICAL = "topology";
static const string TOPOLOGY_KEY_EXR = "exr_topology";

// simple function to load yaml or json from a file path to a YAML::Node object
YAML::Node _loadConfigFromPath(const string&);
// converts YAML::Node data to a map of strings (StrMapType)
StrMapType _categoryMapFromConfig(YAML::Node&);
StrMapType _categoryMapFromConfig(const YAML::Node&);
// simple wrapper function to load a yaml or json file to a map of strings (StrMapType)
StrMapType loadConfigToMap(const string&);
34 changes: 26 additions & 8 deletions include/nuke/LayerSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,40 @@
#include <DDImage/Knobs.h>
#include <DDImage/Knob.h>
#include <DDImage/Enumeration_KnobI.h>
#include <DDImage/Row.h>

#include "LayerSetCore.h"
#include "version.h"

//layerCollection initialized here once.
static LayerCollection layerCollection;
namespace LayerAlchemy {

//layerCollection initialized here once.
static LayerCollection layerCollection;
//using DD::Image::ChannelSet;
typedef map<string, DD::Image::ChannelSet> ChannelSetMapType;

namespace LayerSet {
//alias type to for string:ChannelSet map
typedef map<string, DD::Image::ChannelSet> ChannelSetMapType;
//Gets a vector of unique layer names for a ChannelSet
StrVecType getLayerNames(const DD::Image::ChannelSet&);
DD::Image::Knob* createDocumentationButton(DD::Image::Knob_Callback&);
DD::Image::Knob* createColorKnobResetButton(DD::Image::Knob_Callback&);
StrVecType getCategories(const ChannelSetMapType&);
DD::Image::ChannelSet getChannelSet(const ChannelSetMapType&);

ChannelSetMapType categorizeChannelSet(const LayerCollection&, const DD::Image::ChannelSet&);
ChannelSetMapType categorizeChannelSet(const LayerCollection&, const DD::Image::ChannelSet&, const CategorizeFilter&);
ChannelSetMapType _layerMaptoChannelMap(const LayerMap&, const DD::Image::ChannelSet& inChannels);
StrVecType getCategories(const ChannelSetMapType&);
DD::Image::ChannelSet getChannelSet(const ChannelSetMapType&);
}; // LayerSet
} // End namespace LayerSet

namespace Utilities {
void hard_copy(const DD::Image::Row& fromRow, int x, int r, DD::Image::ChannelSet channels, DD::Image::Row& toRow);
float* hard_copy(const DD::Image::Row& fromRow, int x, int r, DD::Image::Channel channel, DD::Image::Row& toRow);
// use to validate if a target layer the user selects is within the required color ranges
void validateTargetLayerColorIndex(DD::Image::Op* t_op, const DD::Image::ChannelSet& targetLayer, unsigned minIndex, unsigned maxIndex);
} // End namespace Utilities

namespace Knobs {
DD::Image::Knob* createDocumentationButton(DD::Image::Knob_Callback&);
DD::Image::Knob* createColorKnobResetButton(DD::Image::Knob_Callback&);
DD::Image::Knob* createVersionTextKnob(DD::Image::Knob_Callback&);
} // End namespace Knobs
} // End namespace LayerAlchemy
6 changes: 4 additions & 2 deletions include/nuke/LayerSetKnob.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#include "LayerSet.h"

namespace LayerSet {
namespace LayerAlchemy {
namespace LayerSetKnob {

static const char* LAYER_SET_KNOB_NAME = "layer_set";

Expand Down Expand Up @@ -65,4 +66,5 @@ void _updateLayerSetKnob(DD::Image::Op*, LayerSetKnobData&, ChannelSetMapType&,
void updateLayerSetKnob(DD::Image::Op*, LayerSetKnobData&, LayerCollection&, DD::Image::ChannelSet&);
// main update function to update an Op's filtered LayerSetKnob
void updateLayerSetKnob(DD::Image::Op*, LayerSetKnobData&, LayerCollection&, DD::Image::ChannelSet&, const CategorizeFilter&);
}; // LayerSet
} // End namespace LayerSetKnob
} // End namespace LayerAlchemy
11 changes: 11 additions & 0 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#define LAYER_ALCHEMY_VERSION_MAJOR 0
#define LAYER_ALCHEMY_VERSION_MINOR 8
#define LAYER_ALCHEMY_VERSION_PATCH 0

#include <string>

static const std::string LAYER_ALCHEMY_VERSION_STRING =
std::to_string(LAYER_ALCHEMY_VERSION_MAJOR) + "." +
std::to_string(LAYER_ALCHEMY_VERSION_MINOR) + "." +
std::to_string(LAYER_ALCHEMY_VERSION_PATCH);
4 changes: 2 additions & 2 deletions src/LayerSetConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ YAML::Node _loadConfigFromPath(const string& path) {
return config;
}

StrMapType _categoryMapFromConfig(YAML::Node& config) {
StrMapType _categoryMapFromConfig(const YAML::Node& config) {
StrMapType categoryMap;
for (YAML::const_iterator it = config.begin(); it != config.end(); it++) {
string categoryName = it->first.as<string>();
Expand All @@ -19,7 +19,7 @@ StrMapType _categoryMapFromConfig(YAML::Node& config) {
}

StrMapType loadConfigToMap(const string& yamlFilePath) {
YAML::Node config = _loadConfigFromPath(yamlFilePath);
const YAML::Node config = _loadConfigFromPath(yamlFilePath);
StrMapType categoryMap = _categoryMapFromConfig(config);
return categoryMap;
}
26 changes: 15 additions & 11 deletions src/LayerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
* This will just print out various methods of categorizing.
*/
#include <iostream>
#include <iterator>

#include "argparse.h"

#include "LayerSetCore.h"
#include "version.h"

static const string emojiSick = "\xF0\x9F\x98\xB7 ";
static const std::string emojiSick = "\xF0\x9F\x98\xB7 ";
static const string redText = "\x1B[31m";
static const string endColor = "\033[0m";
static const std::string DESCRIPTION = "Simple executable to test the layer categorization";
static const string LAYER_ALCHEMY_PROJECT_URL = "https://github.com/sebjacob/LayerAlchemy";
static const std::string HEADER =
"\nLayerTester " + emojiSick + "\n" + DESCRIPTION +
"\n\nLayerAlchemy " + LAYER_ALCHEMY_VERSION_STRING + "\n" +
LAYER_ALCHEMY_PROJECT_URL + "\n";

void _printLayerMap(const LayerMap &layerMap, std::string message)
{
Expand All @@ -26,14 +33,14 @@ void _printLayerMapTopology(LayerCollection *layerCollection, const StrVecType l
layerCollection->topology(layerNames, topologyStyle::lexical), "Topology style : LEXICAL");
}

int main(int argc, char *argv[])
int main(int argc, const char* argv[])
{
if ((getenv(CHANNEL_ENV_VAR) == NULL) | (getenv(LAYER_ENV_VAR) == NULL))
{
std::cerr << "\nMISSING ENVIRONMENT VARIABLES" << std::endl;
std::cerr << "\nYou need to set paths to yaml files in "
<< LAYER_ENV_VAR << " and " << CHANNEL_ENV_VAR << " environment variables\n"
<< std::endl;
std::cerr << HEADER << std::endl;
std::cerr << redText << std::endl << "MISSING ENVIRONMENT VARIABLES" << std::endl;
std::cerr << std::endl << "You need to set environment variables pointing to yaml files for :\n"
<< std::endl << LAYER_ENV_VAR << std::endl << CHANNEL_ENV_VAR << std::endl << endColor << std::endl;
return 1;
}
ArgumentParser parser(DESCRIPTION);
Expand All @@ -48,10 +55,7 @@ int main(int argc, char *argv[])
}
catch (const ArgumentParser::ArgumentNotFound &ex)
{
string usage =
"\nLayerTester " + emojiSick + "\n" + DESCRIPTION +
"\n\nLayerAlchemy 0.6.0 https://github.com/sebjacob/LayerAlchemy\n";
std::cout << usage << std::endl;
std::cout << HEADER << std::endl;
parser.print_help();

std::cout << ex.what() << std::endl;
Expand Down
Loading

0 comments on commit ca9d982

Please sign in to comment.