├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── cleanCppExtensions.cmake └── useGoldLinker.cmake ├── conventions.md ├── data ├── .DS_Store ├── CMakeLists.txt ├── nodestyle.txt ├── shaders │ ├── runtime │ │ ├── DefaultLight.glsl │ │ ├── Fragment.glsl │ │ ├── MicrofacetFunction.glsl │ │ ├── PBRCommon.frag.glsl │ │ ├── PBRCommon.vert.glsl │ │ ├── Transform │ │ │ └── TransformStructs.glsl │ │ └── Vertex.glsl │ └── source │ │ ├── DefaultLight.glsl │ │ ├── Fragment.glsl │ │ ├── MaterialModel.glsl │ │ ├── MaterialModelFooter.txt │ │ ├── MaterialModelHeader.txt │ │ ├── MicrofacetFunction.glsl │ │ ├── PBRCommon.frag.glsl │ │ ├── PBRCommon.vert.glsl │ │ ├── Transform │ │ ├── ._TransformStructs.glsl │ │ └── TransformStructs.glsl │ │ └── Vertex.glsl └── textures │ ├── Brick.png │ └── ShaderGraph.png ├── doc ├── .DS_Store ├── .gitignore ├── CMakeLists.txt ├── design.md ├── directoryStructure.md ├── doxygen │ ├── Doxyfile.in │ ├── customdoxygen.css │ ├── footer.html │ └── header.html └── start_working.md ├── external ├── .DS_Store ├── CMakeLists.txt └── nodeeditor │ ├── .appveyor.yml │ ├── .codeclimate.yml │ ├── .gitignore │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── cmake │ └── NodeEditorConfig.cmake.in │ ├── examples │ ├── CMakeLists.txt │ ├── calculator │ │ ├── AdditionModel.hpp │ │ ├── CMakeLists.txt │ │ ├── Converters.cpp │ │ ├── Converters.hpp │ │ ├── DecimalData.hpp │ │ ├── DivisionModel.hpp │ │ ├── IntegerData.hpp │ │ ├── MathOperationDataModel.cpp │ │ ├── MathOperationDataModel.hpp │ │ ├── ModuloModel.cpp │ │ ├── ModuloModel.hpp │ │ ├── MultiplicationModel.hpp │ │ ├── NumberDisplayDataModel.cpp │ │ ├── NumberDisplayDataModel.hpp │ │ ├── NumberSourceDataModel.cpp │ │ ├── NumberSourceDataModel.hpp │ │ ├── SubtractionModel.hpp │ │ └── main.cpp │ ├── connection_colors │ │ ├── CMakeLists.txt │ │ ├── main.cpp │ │ ├── models.cpp │ │ └── models.hpp │ ├── example2 │ │ ├── CMakeLists.txt │ │ ├── TextData.hpp │ │ ├── TextDisplayDataModel.cpp │ │ ├── TextDisplayDataModel.hpp │ │ ├── TextSourceDataModel.cpp │ │ ├── TextSourceDataModel.hpp │ │ └── main.cpp │ ├── images │ │ ├── CMakeLists.txt │ │ ├── ImageLoaderModel.cpp │ │ ├── ImageLoaderModel.hpp │ │ ├── ImageShowModel.cpp │ │ ├── ImageShowModel.hpp │ │ ├── PixmapData.hpp │ │ └── main.cpp │ └── styles │ │ ├── CMakeLists.txt │ │ ├── main.cpp │ │ ├── models.cpp │ │ └── models.hpp │ ├── external │ ├── CMakeLists.txt │ └── Catch2 │ │ └── CMakeLists.txt │ ├── include │ └── nodes │ │ ├── Connection │ │ ├── ConnectionStyle │ │ ├── DataModelRegistry │ │ ├── FlowScene │ │ ├── FlowView │ │ ├── FlowViewStyle │ │ ├── Node │ │ ├── NodeData │ │ ├── NodeDataModel │ │ ├── NodeGeometry │ │ ├── NodePainterDelegate │ │ ├── NodeState │ │ ├── NodeStyle │ │ ├── TypeConverter │ │ └── internal │ │ ├── Compilation.hpp │ │ ├── Connection.hpp │ │ ├── ConnectionGeometry.hpp │ │ ├── ConnectionGraphicsObject.hpp │ │ ├── ConnectionState.hpp │ │ ├── ConnectionStyle.hpp │ │ ├── DataModelRegistry.hpp │ │ ├── Export.hpp │ │ ├── FlowScene.hpp │ │ ├── FlowView.hpp │ │ ├── FlowViewStyle.hpp │ │ ├── Node.hpp │ │ ├── NodeData.hpp │ │ ├── NodeDataModel.hpp │ │ ├── NodeGeometry.hpp │ │ ├── NodeGraphicsObject.hpp │ │ ├── NodePainterDelegate.hpp │ │ ├── NodeState.hpp │ │ ├── NodeStyle.hpp │ │ ├── OperatingSystem.hpp │ │ ├── PortType.hpp │ │ ├── QStringStdHash.hpp │ │ ├── QUuidStdHash.hpp │ │ ├── Serializable.hpp │ │ ├── Style.hpp │ │ ├── TypeConverter.hpp │ │ └── memory.hpp │ ├── pictures │ ├── calculator.png │ ├── chigraph.png │ ├── flow.png │ ├── spkgen.png │ ├── style_example.png │ └── vid1.png │ ├── resources │ ├── DefaultStyle.json │ ├── convert.png │ └── resources.qrc │ ├── src │ ├── Connection.cpp │ ├── ConnectionBlurEffect.cpp │ ├── ConnectionBlurEffect.hpp │ ├── ConnectionGeometry.cpp │ ├── ConnectionGraphicsObject.cpp │ ├── ConnectionPainter.cpp │ ├── ConnectionPainter.hpp │ ├── ConnectionState.cpp │ ├── ConnectionStyle.cpp │ ├── DataModelRegistry.cpp │ ├── FlowScene.cpp │ ├── FlowView.cpp │ ├── FlowViewStyle.cpp │ ├── Node.cpp │ ├── NodeConnectionInteraction.cpp │ ├── NodeConnectionInteraction.hpp │ ├── NodeDataModel.cpp │ ├── NodeGeometry.cpp │ ├── NodeGraphicsObject.cpp │ ├── NodePainter.cpp │ ├── NodePainter.hpp │ ├── NodeState.cpp │ ├── NodeStyle.cpp │ ├── Properties.cpp │ ├── Properties.hpp │ ├── StyleCollection.cpp │ └── StyleCollection.hpp │ └── test │ ├── CMakeLists.txt │ ├── include │ ├── ApplicationSetup.hpp │ ├── Stringify.hpp │ └── StubNodeDataModel.hpp │ ├── src │ ├── TestDataModelRegistry.cpp │ ├── TestDragging.cpp │ ├── TestFlowScene.cpp │ └── TestNodeGraphicsObject.cpp │ └── test_main.cpp ├── license.md ├── misc └── cleanCppProject.sublime-project ├── packaging ├── .DS_Store ├── CMakeLists.txt ├── MacOSXBundleInfo.plist.in ├── ShaderGraph.desktop ├── ShaderGraph.icns ├── ShaderGraph.ico ├── ShaderGraph.icon.in.rc ├── ShaderGraph.png └── dmg_background.png ├── source ├── .DS_Store ├── CMakeLists.txt ├── core │ ├── .DS_Store │ ├── Core.h │ ├── Defines.h │ └── log │ │ ├── .DS_Store │ │ ├── Log.cpp │ │ └── Log.h ├── detail │ ├── DetailDecl.h │ ├── DetailLeaf.cpp │ ├── DetailLeaf.h │ ├── DetailNode.cpp │ ├── DetailNode.h │ └── leaf │ │ ├── DetailBoolean.cpp │ │ ├── DetailBoolean.h │ │ ├── DetailScalar.cpp │ │ ├── DetailScalar.h │ │ ├── DetailText.cpp │ │ ├── DetailText.h │ │ ├── DetailUniform.cpp │ │ ├── DetailUniform.h │ │ ├── DetailVector.cpp │ │ └── DetailVector.h ├── main.cpp ├── model │ ├── Compilation.cpp │ ├── Compilation.h │ ├── Node.cpp │ ├── Node.h │ ├── NodeDecl.h │ ├── converter │ │ ├── Converter.cpp │ │ ├── Converter.h │ │ ├── ToTemplate.cpp │ │ └── ToTemplate.h │ ├── input │ │ ├── ColorNode.cpp │ │ ├── ColorNode.h │ │ ├── CoordinatesExpressions.cpp │ │ ├── CoordinatesExpressions.h │ │ ├── TextureNode.cpp │ │ ├── TextureNode.h │ │ ├── VectorNode.cpp │ │ └── VectorNode.h │ ├── math │ │ ├── Math.cpp │ │ └── Math.h │ ├── misc │ │ ├── VectorFunctions.cpp │ │ └── VectorFunctions.h │ ├── operator │ │ ├── BoolOperator.cpp │ │ ├── BoolOperator.h │ │ ├── CommonOperator.cpp │ │ ├── CommonOperator.h │ │ ├── Operator.cpp │ │ └── Operator.h │ └── output │ │ ├── MasterMaterialOutput.cpp │ │ └── MasterMaterialOutput.h ├── nodeeditor │ ├── FlowScene.cpp │ ├── FlowScene.h │ ├── FlowView.cpp │ ├── FlowView.h │ ├── NodeManager.cpp │ └── NodeManager.h ├── pin │ ├── BooleanPin.cpp │ ├── BooleanPin.h │ ├── FloatPin.cpp │ ├── FloatPin.h │ ├── IPin.h │ ├── Pin.h │ ├── PinDecl.h │ ├── TemplatePin.cpp │ ├── TemplatePin.h │ ├── VectorPin.cpp │ └── VectorPin.h ├── preview │ ├── .DS_Store │ ├── Camera.cpp │ ├── Camera.h │ ├── OpenGL.cpp │ ├── OpenGL.h │ ├── Scene.cpp │ ├── Scene.h │ ├── Shader.cpp │ ├── Shader.h │ ├── Texture.cpp │ └── Texture.h ├── qt │ ├── .DS_Store │ ├── GLWidget.cpp │ ├── GLWidget.h │ ├── WidgetNodeEditor.cpp │ ├── WidgetNodeEditor.h │ ├── Window.cpp │ ├── Window.h │ └── Window.ui ├── unittest │ ├── CMakeLists.txt │ └── testmain.cpp ├── vendor │ ├── .DS_Store │ ├── spdlog │ │ ├── async.h │ │ ├── async_logger.h │ │ ├── common.h │ │ ├── details │ │ │ ├── async_logger_impl.h │ │ │ ├── circular_q.h │ │ │ ├── console_globals.h │ │ │ ├── file_helper.h │ │ │ ├── fmt_helper.h │ │ │ ├── log_msg.h │ │ │ ├── logger_impl.h │ │ │ ├── mpmc_blocking_q.h │ │ │ ├── null_mutex.h │ │ │ ├── os.h │ │ │ ├── pattern_formatter.h │ │ │ ├── periodic_worker.h │ │ │ ├── registry.h │ │ │ └── thread_pool.h │ │ ├── fmt │ │ │ ├── bin_to_hex.h │ │ │ ├── bundled │ │ │ │ ├── LICENSE.rst │ │ │ │ ├── chrono.h │ │ │ │ ├── color.h │ │ │ │ ├── core.h │ │ │ │ ├── format-inl.h │ │ │ │ ├── format.h │ │ │ │ ├── locale.h │ │ │ │ ├── ostream.h │ │ │ │ ├── posix.h │ │ │ │ ├── printf.h │ │ │ │ ├── ranges.h │ │ │ │ └── time.h │ │ │ ├── fmt.h │ │ │ └── ostr.h │ │ ├── formatter.h │ │ ├── logger.h │ │ ├── sinks │ │ │ ├── android_sink.h │ │ │ ├── ansicolor_sink.h │ │ │ ├── base_sink.h │ │ │ ├── basic_file_sink.h │ │ │ ├── daily_file_sink.h │ │ │ ├── dist_sink.h │ │ │ ├── msvc_sink.h │ │ │ ├── null_sink.h │ │ │ ├── ostream_sink.h │ │ │ ├── rotating_file_sink.h │ │ │ ├── sink.h │ │ │ ├── stdout_color_sinks.h │ │ │ ├── stdout_sinks.h │ │ │ ├── syslog_sink.h │ │ │ └── wincolor_sink.h │ │ ├── spdlog.h │ │ ├── tweakme.h │ │ └── version.h │ └── stb │ │ ├── stb_image.cpp │ │ └── stb_image.h ├── version.cpp.in └── version.h └── test ├── .DS_Store └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Logs 35 | *.log 36 | 37 | # Folders 38 | build/ 39 | bin/ 40 | external/Catch/ 41 | external/glm/ 42 | .idea/ 43 | output/* 44 | 45 | data/ShaderGraph_Output.txt 46 | data/shaders/runtime/ 47 | data/shaders/runtime/Material.glsl 48 | 49 | # Files 50 | .DS_Store 51 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Enable C++ support 2 | sudo: required 3 | language: cpp 4 | 5 | matrix: 6 | include: 7 | # linux gcc release 8 | - env: 9 | - COMPILER=g++-8 10 | - PREFIX_PATH="~/Qt/5.10.0/gcc_64/lib/cmake" 11 | os: linux 12 | dist: xenial 13 | compiler: gcc 14 | addons: 15 | apt: 16 | sources: 17 | - ubuntu-toolchain-r-test 18 | packages: 19 | - cmake 20 | - g++-8 21 | 22 | # macos clang release 23 | - env: 24 | - PREFIX_PATH="/usr/local/opt/qt/lib/cmake" 25 | os: osx 26 | compiler: clang 27 | 28 | before_install: 29 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install gnu-which && brew install qt; fi 30 | - if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi 31 | - if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi 32 | - which $CXX 33 | - which $CC 34 | - $CXX --version 35 | - cmake --version 36 | - | 37 | if [ "$TRAVIS_OS_NAME" = "linux" ]; then 38 | sudo add-apt-repository --yes ppa:beineri/opt-qt-5.10.1-xenial 39 | sudo apt-get --yes update 40 | sudo apt-get --yes install qt510-meta-minimal qt510svg 41 | source /opt/qt510/bin/qt510-env.sh # see https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.10.1-xenial 42 | sudo apt-get install freeglut3-dev 43 | fi; 44 | 45 | install: 46 | - mkdir build && cd build 47 | # - cmake .. && make check && make package 48 | - cmake .. 49 | # Build steps 50 | script: 51 | - make 52 | 53 | # branches: 54 | # only: 55 | # - martin 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shader-Graph 2 | Software aimed at GLSL code generation 3 | 4 | 5 | ![](https://image.noelshack.com/fichiers/2019/18/3/1556734143-screenshot-20190501-200748.png) 6 | 7 | ### Purpose 8 | 9 | Shader-Graph is a project developpement, suggested by Mathias Paulin a member of STORM team at IRIT (www.irit.fr). This software is a GUI node editor prototype aimed at GLSL code generation. 10 | 11 | 12 | ### Platforms 13 | 14 | * OSX (Apple Clang - LLVM 3.6), Linux (x64, gcc-8.0): [![Build Status](https://travis-ci.com/sylvaindeker/Shader-Graph.svg?branch=master)](https://travis-ci.com/sylvaindeker/Shader-Graph) 15 | 16 | 17 | 18 | ### Dependencies 19 | 20 | * gcc >= 8 21 | * Qt >= 5.2 22 | * CMake >= 3.10 23 | * Catch2 24 | 25 | ### Functionnalities 26 | 27 | 28 | ### Building 29 | #### Linux 30 | 31 | ~~~ 32 | git clone https://github.com/sylvaindeker/Shader-Graph.git 33 | cd Shader-Graph 34 | mkdir build 35 | cd build 36 | cmake .. 37 | make -j 38 | ~~~ 39 | -------------------------------------------------------------------------------- /cmake/useGoldLinker.cmake: -------------------------------------------------------------------------------- 1 | if (UNIX AND NOT APPLE) 2 | execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version) 3 | if ("${ld_version}" MATCHES "GNU gold") 4 | option(USE_GOLD_LINKER "Wheather the gold linker should be used" OFF) 5 | message(STATUS "USE_GOLD_LINKER ${USE_GOLD_LINKER}") 6 | if(USE_GOLD_LINKER) 7 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") 8 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") 9 | endif() 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/.DS_Store -------------------------------------------------------------------------------- /data/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # copy all from data to install dir /share 2 | # here can be images, models 3 | 4 | # install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/images 5 | # DESTINATION ./share/images 6 | # ) 7 | 8 | -------------------------------------------------------------------------------- /data/nodestyle.txt: -------------------------------------------------------------------------------- 1 | ( 2 | { 3 | "ConnectionStyle": 4 | { 5 | "UseDataDefinedColors": true 6 | } 7 | } 8 | ) -------------------------------------------------------------------------------- /data/shaders/runtime/Fragment.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Resulting Fragment Shader 3 | */ 4 | #include "Material.glsl" 5 | #include "PBRCommon.frag.glsl" 6 | -------------------------------------------------------------------------------- /data/shaders/runtime/PBRCommon.frag.glsl: -------------------------------------------------------------------------------- 1 | // This is the canonic fragmentShader any PBR material will use. 2 | // A specific material fragment shader implements the material interface (computeMaterialInternal) 3 | // and include this shader 4 | 5 | // For the moment, include all the ligh-type interfaces. Will change in the future for performances improvement 6 | #include "DefaultLight.glsl" 7 | 8 | // Fragment shader just ouput the fragment color 9 | out vec4 fragColor; 10 | 11 | in vec3 v_position; 12 | in vec3 v_texcoord; 13 | in vec3 v_normal; 14 | in vec3 v_tangent; 15 | in vec3 v_viewVector; 16 | in vec3 v_lightVector; 17 | 18 | void main() 19 | { 20 | // all vectors are in world space 21 | vec3 binormal = normalize(cross(v_normal, v_tangent)); 22 | vec3 normalWorld = getNormal(material, v_texcoord.xy, v_normal, v_tangent, binormal); 23 | vec3 binormalWorld = normalize(cross(normalWorld, v_tangent)); 24 | vec3 tangentWorld = normalize(cross(binormalWorld, normalWorld)); 25 | 26 | // A material is always evaluated in the fragment local Frame 27 | // compute matrix from World to local Frame 28 | mat3 world2local; 29 | world2local[0] = vec3(tangentWorld.x, binormalWorld.x, normalWorld.x); 30 | world2local[1] = vec3(tangentWorld.y, binormalWorld.y, normalWorld.y); 31 | world2local[2] = vec3(tangentWorld.z, binormalWorld.z, normalWorld.z); 32 | 33 | // transform all vectors in local frame so that N = (0, 0, 1); 34 | vec3 wi = world2local * normalize(v_lightVector); // incident direction 35 | vec3 wo = world2local * normalize(v_viewVector); // outgoing direction 36 | 37 | // Compute the material response (evaluate the bsdf) 38 | vec3 materialColor = computeMaterialInternal(material, v_texcoord.xy, wi, wo); 39 | 40 | // Compute the light contribution 41 | vec3 contribution = lightContributionFrom(light, v_position); 42 | 43 | // Set the final color 44 | fragColor = vec4(materialColor * contribution, 1.0); 45 | 46 | // apply gamma correction 47 | float gamma = 2.2; 48 | fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/runtime/PBRCommon.vert.glsl: -------------------------------------------------------------------------------- 1 | //This is the basic vertexShader any PBR material can use 2 | #include "Transform/TransformStructs.glsl" 3 | 4 | //This is for a preview of the shader composition, but in time we must use more specific Light Shader 5 | #include "DefaultLight.glsl" 6 | 7 | // Inputs of vertex shaders are set by the application wrt the following locations 8 | layout (location = 0) in vec3 in_position; 9 | layout (location = 1) in vec3 in_normal; 10 | layout (location = 2) in vec3 in_texcoord; 11 | layout (location = 3) in vec3 in_tangent; 12 | layout (location = 4) in vec3 in_bitangent; 13 | 14 | // Set of matrices that should be used by the shader 15 | uniform Transform transform; 16 | 17 | // Ouputs of the vertex shader are defined by the following interface and location 18 | // Note that all outputs are in world space (will change in the future for performance improvement) 19 | out vec3 v_position; 20 | out vec3 v_texcoord; 21 | out vec3 v_normal; 22 | out vec3 v_tangent; 23 | out vec3 v_viewVector; 24 | out vec3 v_lightVector; 25 | 26 | void main() 27 | { 28 | // compute position in clip space 29 | gl_Position = transform.mvp * vec4(in_position, 1.0); 30 | 31 | // compute position, normal, tangent and eye in world space 32 | vec4 pos = transform.model * vec4(in_position, 1.0); 33 | pos /= pos.w; 34 | 35 | vec3 normal = normalize(mat3(transform.worldNormal) * in_normal); 36 | vec3 tangent = normalize(mat3(transform.model) * in_tangent); 37 | 38 | vec3 eye = -transform.view[3].xyz * mat3(transform.view); 39 | 40 | // ouput vertex components 41 | v_position = vec3(pos); 42 | v_texcoord = in_texcoord; 43 | 44 | v_normal = normal; 45 | v_tangent = tangent; 46 | 47 | v_viewVector = normalize(vec3(eye - vec3(pos))); 48 | v_lightVector = getLightDirection(light, vec3(pos)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/runtime/Transform/TransformStructs.glsl: -------------------------------------------------------------------------------- 1 | struct Transform 2 | { 3 | mat4 model; 4 | mat4 view; 5 | mat4 proj; 6 | mat4 mvp; 7 | mat4 modelView; 8 | mat4 worldNormal; 9 | mat4 viewNormal; 10 | }; 11 | -------------------------------------------------------------------------------- /data/shaders/runtime/Vertex.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Composite vertex shader for Plastic material 3 | */ 4 | #include "PBRCommon.vert.glsl" 5 | -------------------------------------------------------------------------------- /data/shaders/source/Fragment.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Resulting Fragment Shader 3 | */ 4 | #include "Material.glsl" 5 | #include "PBRCommon.frag.glsl" 6 | -------------------------------------------------------------------------------- /data/shaders/source/MaterialModelFooter.txt: -------------------------------------------------------------------------------- 1 | vec3 getNormal(Material material, vec2 texCoord, vec3 N, vec3 T, vec3 B) { 2 | if (material.tex.hasNormal == 1) { 3 | mat3 tbn; 4 | 5 | tbn[0] = T; 6 | tbn[1] = B; 7 | tbn[2] = N; 8 | 9 | vec3 normalLocal = normalize(vec3(texture(material.tex.normal, texCoord)) * 2 - 1); 10 | return normalize(tbn * normalLocal); 11 | } 12 | 13 | return normalize(N); 14 | } 15 | 16 | /* 17 | * Compute the response of the material according to the incomming (light) diretion wi and the 18 | * outgoing (view) direction wo at the position on surface texC. 19 | * Note that the directions are expressed in the local frame. 20 | */ 21 | vec3 computeMaterialInternal(Material material, vec2 texC, vec3 wi, vec3 wo) { 22 | float cosTi = CosTheta(wi); 23 | float cosTo = CosTheta(wo); 24 | 25 | if (cosTi == 0 || cosTo == 0) 26 | return vec3(0.f); 27 | 28 | 29 | bool reflect = (cosTi * cosTo > 0); 30 | vec3 result = vec3(0.f); 31 | 32 | vec3 kd = getKd(material, texC); 33 | 34 | if (reflect) { 35 | cosTi = abs(cosTi); 36 | cosTo = abs(cosTo); 37 | 38 | result = (kd * InvPi); 39 | 40 | vec3 wh = wi + wo; 41 | if (!(wh.x == 0 && wh.y == 0 && wh.z == 0)) { 42 | wh = normalize(wh); 43 | vec3 ks = getKs(material, texC); 44 | vec3 F0 = vec3(0.04); 45 | F0 = mix(F0, ks, vec3(getMetalness(material, texC))); 46 | vec3 F90 = kd; 47 | vec3 F = FresnelShlick(dot(wi, wh), F0, F90); 48 | vec2 rough = getRoughness(material, texC); 49 | float D = TRD_D(wh, rough.x, rough.y); 50 | float G = TRD_G(wo, wi, rough.x, rough.y); 51 | result += (F * D * G /(4 * cosTi * cosTo)); 52 | } 53 | } 54 | /* result + ambient */ 55 | return result * cosTi + 0.1 * kd; 56 | } 57 | 58 | // Define the uniform that could be accessed from th application 59 | uniform Material material; 60 | 61 | #endif//PLASTICMATERIAL_GLSL 62 | -------------------------------------------------------------------------------- /data/shaders/source/MaterialModelHeader.txt: -------------------------------------------------------------------------------- 1 | #ifndef PLASTICMATERIAL_GLSL 2 | #define PLASTICMATERIAL_GLSL 3 | /* 4 | * Implements material interface for Plastic material 5 | * see at https://www.pbrt.org/fileformat-v3.html#materials for parameters and 6 | * properties 7 | */ 8 | // Microfacet functions used 9 | #include "MicrofacetFunction.glsl" 10 | 11 | /* Material data structure 12 | * Defines the input of the material 13 | * All material parameters will be set by the application 14 | */ 15 | // Material parameters could be textured, 16 | struct MaterialTextures { 17 | int hasKd; 18 | int hasKs; 19 | int hasRoughness; 20 | int hasNormal; 21 | 22 | sampler2D kd; 23 | sampler2D ks; 24 | sampler2D roughness; 25 | sampler2D normal; 26 | }; 27 | 28 | // Main material description 29 | struct Material { 30 | vec4 kd; 31 | vec4 ks; 32 | float roughness; 33 | int remapRoughness; 34 | 35 | MaterialTextures tex; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /data/shaders/source/PBRCommon.frag.glsl: -------------------------------------------------------------------------------- 1 | // This is the canonic fragmentShader any PBR material will use. 2 | // A specific material fragment shader implements the material interface (computeMaterialInternal) 3 | // and include this shader 4 | 5 | // For the moment, include all the ligh-type interfaces. Will change in the future for performances improvement 6 | #include "DefaultLight.glsl" 7 | 8 | // Fragment shader just ouput the fragment color 9 | out vec4 fragColor; 10 | 11 | in vec3 v_position; 12 | in vec3 v_texcoord; 13 | in vec3 v_normal; 14 | in vec3 v_tangent; 15 | in vec3 v_viewVector; 16 | in vec3 v_lightVector; 17 | 18 | void main() 19 | { 20 | // all vectors are in world space 21 | vec3 binormal = normalize(cross(v_normal, v_tangent)); 22 | vec3 normalWorld = getNormal(material, v_texcoord.xy, v_normal, v_tangent, binormal); 23 | vec3 binormalWorld = normalize(cross(normalWorld, v_tangent)); 24 | vec3 tangentWorld = normalize(cross(binormalWorld, normalWorld)); 25 | 26 | // A material is always evaluated in the fragment local Frame 27 | // compute matrix from World to local Frame 28 | mat3 world2local; 29 | world2local[0] = vec3(tangentWorld.x, binormalWorld.x, normalWorld.x); 30 | world2local[1] = vec3(tangentWorld.y, binormalWorld.y, normalWorld.y); 31 | world2local[2] = vec3(tangentWorld.z, binormalWorld.z, normalWorld.z); 32 | 33 | // transform all vectors in local frame so that N = (0, 0, 1); 34 | vec3 wi = world2local * normalize(v_lightVector); // incident direction 35 | vec3 wo = world2local * normalize(v_viewVector); // outgoing direction 36 | 37 | // Compute the material response (evaluate the bsdf) 38 | vec3 materialColor = computeMaterialInternal(material, v_texcoord.xy, wi, wo); 39 | 40 | // Compute the light contribution 41 | vec3 contribution = lightContributionFrom(light, v_position); 42 | 43 | // Set the final color 44 | fragColor = vec4(materialColor * contribution, 1.0); 45 | 46 | // apply gamma correction 47 | float gamma = 2.2; 48 | fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/source/PBRCommon.vert.glsl: -------------------------------------------------------------------------------- 1 | //This is the basic vertexShader any PBR material can use 2 | #include "Transform/TransformStructs.glsl" 3 | 4 | //This is for a preview of the shader composition, but in time we must use more specific Light Shader 5 | #include "DefaultLight.glsl" 6 | 7 | // Inputs of vertex shaders are set by the application wrt the following locations 8 | layout (location = 0) in vec3 in_position; 9 | layout (location = 1) in vec3 in_normal; 10 | layout (location = 2) in vec3 in_texcoord; 11 | layout (location = 3) in vec3 in_tangent; 12 | layout (location = 4) in vec3 in_bitangent; 13 | 14 | // Set of matrices that should be used by the shader 15 | uniform Transform transform; 16 | 17 | // Ouputs of the vertex shader are defined by the following interface and location 18 | // Note that all outputs are in world space (will change in the future for performance improvement) 19 | out vec3 v_position; 20 | out vec3 v_texcoord; 21 | out vec3 v_normal; 22 | out vec3 v_tangent; 23 | out vec3 v_viewVector; 24 | out vec3 v_lightVector; 25 | 26 | void main() 27 | { 28 | // compute position in clip space 29 | gl_Position = transform.mvp * vec4(in_position, 1.0); 30 | 31 | // compute position, normal, tangent and eye in world space 32 | vec4 pos = transform.model * vec4(in_position, 1.0); 33 | pos /= pos.w; 34 | 35 | vec3 normal = normalize(mat3(transform.worldNormal) * in_normal); 36 | vec3 tangent = normalize(mat3(transform.model) * in_tangent); 37 | 38 | vec3 eye = -transform.view[3].xyz * mat3(transform.view); 39 | 40 | // ouput vertex components 41 | v_position = vec3(pos); 42 | v_texcoord = in_texcoord; 43 | 44 | v_normal = normal; 45 | v_tangent = tangent; 46 | 47 | v_viewVector = normalize(vec3(eye - vec3(pos))); 48 | v_lightVector = getLightDirection(light, vec3(pos)); 49 | } 50 | -------------------------------------------------------------------------------- /data/shaders/source/Transform/._TransformStructs.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/shaders/source/Transform/._TransformStructs.glsl -------------------------------------------------------------------------------- /data/shaders/source/Transform/TransformStructs.glsl: -------------------------------------------------------------------------------- 1 | struct Transform 2 | { 3 | mat4 model; 4 | mat4 view; 5 | mat4 proj; 6 | mat4 mvp; 7 | mat4 modelView; 8 | mat4 worldNormal; 9 | mat4 viewNormal; 10 | }; 11 | -------------------------------------------------------------------------------- /data/shaders/source/Vertex.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Composite vertex shader for Plastic material 3 | */ 4 | #include "PBRCommon.vert.glsl" 5 | -------------------------------------------------------------------------------- /data/textures/Brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/textures/Brick.png -------------------------------------------------------------------------------- /data/textures/ShaderGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/data/textures/ShaderGraph.png -------------------------------------------------------------------------------- /doc/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/doc/.DS_Store -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /doc/directoryStructure.md: -------------------------------------------------------------------------------- 1 | # Directory structure 2 | 3 | * mainProjectFolder 4 | - **build** - user created, build takes place here 5 | + **dist** - here builded application is copied (by deafult, see CMAKE_INSTALL_PREFIX in main CMakeLists.txt) 6 | * **bin** 7 | * **share** 8 | - **data** - here folder data is copied 9 | * **doc** 10 | - doxygen lives here documentation 11 | - **cmake** - contains cmake scripts that can be included with include() 12 | + cleanCppExtensions.cmake - reusable helpers for source/CMakeLists.txt 13 | - **data** - contain data 14 | - **doc** - contains documentation 15 | + CMakeLists.txt - doc building 16 | + **doxygen** 17 | * doxygen settings, and modern style config 18 | - **packaging** 19 | + CMakeLists.txt - package creation 20 | + ShaderGraph.desktop - linux shortcut (app is then visible in launchers) 21 | + ShaderGraph.png - icon for linux shortcut 22 | + ShaderGraph.icon.in.rc - icon for windows description file (used in source/CMakeLists.txt) 23 | + ShaderGraph.ico - icon for windows shortcut (linked via ShaderGraph.icon.in.rc into the executable) 24 | - **source** - contain source files 25 | + CMakeLists.txt - source building 26 | + .ycm_extra_conf.py - for ycm smart autocompletion 27 | + **unittest* contains unittest build 28 | + CMakeLists.txt - unittest building 29 | + testmain.cpp - main unit tests function 30 | - **test** - integration tests, CTest, data sets for tests and unit tests 31 | + CMakeLists.txt - tests specification 32 | - **external** 33 | + CMakeLists.txt - external projects handling (eg. Download of Catch) 34 | - readme.md - main readme file 35 | - CMakeLists.md - Main CMake configuration 36 | - .clang-format - clang format config file 37 | - .clang-tidy - clang tidy config file 38 | - .travis.yml - continuous integration configuration for Travis CI 39 | - .gitlab-ci.yml - continuous integration configuration for Gitlab CI 40 | 41 | 42 | -------------------------------------------------------------------------------- /doc/doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/doxygen/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: $title 9 | $title 10 | 11 | 12 | 13 | 14 | 15 | 16 | $treeview 17 | $search 18 | $mathjax 19 | 20 | $extrastylesheet 21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
36 |
$projectname 37 |  $projectnumber 38 |
39 |
$projectbrief
40 |
45 |
$projectbrief
46 |
$searchbox
57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /external/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/.DS_Store -------------------------------------------------------------------------------- /external/nodeeditor/.appveyor.yml: -------------------------------------------------------------------------------- 1 | clone_depth: 5 2 | 3 | environment: 4 | matrix: 5 | - GENERATOR : "Visual Studio 15 2017 Win64" 6 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 7 | QTDIR: C:\Qt\5.12.2\msvc2017_64 8 | PLATFORM: x64 9 | - GENERATOR : "Visual Studio 15 2017" 10 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 11 | QTDIR: C:\Qt\5.12.2\msvc2017 12 | PLATFORM: Win32 13 | - GENERATOR : "MinGW Makefiles" 14 | QTDIR: C:\Qt\5.11.3\mingw53_32 15 | PLATFORM: x86 16 | CMAKE_CXX_FLAGS_INIT: -DCATCH_CONFIG_NO_CPP11_TO_STRING 17 | 18 | configuration: 19 | - Release 20 | 21 | install: 22 | - set PATH=%QTDIR%\bin;%PATH% 23 | - set Qt5_DIR=%QTDIR%\lib\cmake\Qt5 24 | - set PATH=C:\MinGW\bin;C:\MinGW\msys\1.0;%PATH% 25 | - set PATH=C:\Qt\Tools\mingw530_32;%PATH% 26 | - set PATH=%PATH:C:\Program Files\Git\usr\bin=% # trick to remove sh.exe 27 | 28 | before_build: 29 | - mkdir build 30 | - cd build 31 | - mkdir bin 32 | - set OUTPUT_DIR=%cd%\bin 33 | - cmake "-G%GENERATOR%" 34 | -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG="%OUTPUT_DIR%" 35 | -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE="%OUTPUT_DIR%" 36 | -DCMAKE_CXX_FLAGS_INIT="%CMAKE_CXX_FLAGS_INIT%" 37 | .. 38 | 39 | 40 | build_script: 41 | - cmake --build . 42 | 43 | test_script: 44 | - ps: $env:isX86 = $env:PLATFORM.Contains("x86") 45 | - IF %isX86% == False ctest --output-on-failure -C Debug 46 | 47 | 48 | after_build: 49 | - 7z a examples.zip %APPVEYOR_BUILD_FOLDER%/build/bin 50 | - cmd: cd 51 | - cmd: dir \S \P "examples.zip" 52 | 53 | artifacts: 54 | - path: build\examples.zip 55 | name: ex 56 | 57 | #deploy: 58 | #release: $(APPVEYOR_REPO_TAG_NAME) 59 | #provider: GitHub 60 | #artifact: /.*\.exe/ 61 | #auth_token: 62 | #secure: j0nBV9xVItdG3j6d0gHoyvrzi7TOhAy9/QIeyCbFeP8PTqq7DPr1oYwL5WIkPaXe 63 | #draft: false 64 | #prerelease: false 65 | #on: 66 | #appveyor_repo_tag: true 67 | -------------------------------------------------------------------------------- /external/nodeeditor/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | engines: 2 | fixme: 3 | enabled: true 4 | ratings: 5 | paths: [] 6 | exclude_paths: [] 7 | -------------------------------------------------------------------------------- /external/nodeeditor/.gitignore: -------------------------------------------------------------------------------- 1 | *.py 2 | *.pyc 3 | CMakeLists.txt.user 4 | -------------------------------------------------------------------------------- /external/nodeeditor/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | matrix: 4 | include: 5 | - os: osx 6 | osx_image: xcode8.3 7 | compiler: clang 8 | env: Qt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5 9 | 10 | - os: linux 11 | dist: xenial 12 | sudo: false 13 | compiler: clang 14 | env: CXX=clang++-7 CC=clang-7 QT=512 15 | addons: 16 | apt: 17 | sources: 18 | - llvm-toolchain-xenial-7 19 | packages: 20 | - clang-7 21 | 22 | - os: linux 23 | dist: xenial 24 | sudo: false 25 | compiler: gcc 26 | env: CXX=g++-7 CC=gcc-7 QT=512 27 | addons: 28 | apt: 29 | sources: 30 | - ubuntu-toolchain-r-test 31 | packages: 32 | - g++-7 33 | 34 | git: 35 | depth: 10 36 | 37 | before_install: 38 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi 39 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install qt; fi 40 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq ; fi 41 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential libgl1-mesa-dev ; fi 42 | - if [[ "$QT" == "512" ]]; then sudo add-apt-repository ppa:beineri/opt-qt-5.12.1-xenial -y; fi 43 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq; fi 44 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -yqq install qt${QT}base; source /opt/qt${QT}/bin/qt${QT}-env.sh; fi 45 | 46 | script: 47 | - mkdir build 48 | - cd build 49 | - cmake -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_BUILD .. && make -j 50 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then xvfb-run --server-args="-screen 0 1024x768x24" ctest --output-on-failure; fi 51 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ctest --output-on-failure; fi 52 | 53 | notifications: 54 | email: false 55 | -------------------------------------------------------------------------------- /external/nodeeditor/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Dmitry Pinaev 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of copyright holder, nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /external/nodeeditor/cmake/NodeEditorConfig.cmake.in: -------------------------------------------------------------------------------- 1 | get_filename_component(NodeEditor_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | 3 | include(CMakeFindDependencyMacro) 4 | 5 | # NOTE Had to use find_package because find_dependency does not support COMPONENTS or MODULE until 3.8.0 6 | 7 | find_package(Qt5 REQUIRED COMPONENTS 8 | Core 9 | Widgets 10 | Gui 11 | OpenGL) 12 | 13 | if(NOT TARGET NodeEditor::nodes) 14 | include("${NodeEditor_CMAKE_DIR}/NodeEditorTargets.cmake") 15 | endif() 16 | 17 | set(NodeEditor_LIBRARIES NodeEditor::nodes) 18 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(connection_colors) 2 | 3 | add_subdirectory(example2) 4 | 5 | add_subdirectory(calculator) 6 | 7 | add_subdirectory(images) 8 | 9 | add_subdirectory(styles) 10 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/AdditionModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "MathOperationDataModel.hpp" 10 | #include "DecimalData.hpp" 11 | 12 | /// The model dictates the number of inputs and outputs for the Node. 13 | /// In this example it has no logic. 14 | class AdditionModel : public MathOperationDataModel 15 | { 16 | public: 17 | 18 | virtual 19 | ~AdditionModel() {} 20 | 21 | public: 22 | 23 | QString 24 | caption() const override 25 | { return QStringLiteral("Addition"); } 26 | 27 | QString 28 | name() const override 29 | { return QStringLiteral("Addition"); } 30 | 31 | private: 32 | 33 | void 34 | compute() override 35 | { 36 | PortIndex const outPortIndex = 0; 37 | 38 | auto n1 = _number1.lock(); 39 | auto n2 = _number2.lock(); 40 | 41 | if (n1 && n2) 42 | { 43 | modelValidationState = NodeValidationState::Valid; 44 | modelValidationError = QString(); 45 | _result = std::make_shared(n1->number() + 46 | n2->number()); 47 | } 48 | else 49 | { 50 | modelValidationState = NodeValidationState::Warning; 51 | modelValidationError = QStringLiteral("Missing or incorrect inputs"); 52 | _result.reset(); 53 | } 54 | 55 | Q_EMIT dataUpdated(outPortIndex); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE CPPS ./*.cpp ) 2 | 3 | add_executable(calculator ${CPPS}) 4 | 5 | target_link_libraries(calculator nodes) 6 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/Converters.cpp: -------------------------------------------------------------------------------- 1 | #include "Converters.hpp" 2 | 3 | #include 4 | 5 | #include "DecimalData.hpp" 6 | #include "IntegerData.hpp" 7 | 8 | 9 | std::shared_ptr 10 | DecimalToIntegerConverter:: 11 | operator()(std::shared_ptr data) 12 | { 13 | auto numberData = 14 | std::dynamic_pointer_cast(data); 15 | 16 | if (numberData) 17 | { 18 | _integer = std::make_shared(numberData->number()); 19 | } 20 | else 21 | { 22 | _integer.reset(); 23 | } 24 | 25 | return _integer; 26 | } 27 | 28 | 29 | std::shared_ptr 30 | IntegerToDecimalConverter:: 31 | operator()(std::shared_ptr data) 32 | { 33 | auto numberData = 34 | std::dynamic_pointer_cast(data); 35 | 36 | if (numberData) 37 | { 38 | _decimal = std::make_shared(numberData->number()); 39 | } 40 | else 41 | { 42 | _decimal.reset(); 43 | } 44 | 45 | return _decimal; 46 | } 47 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/Converters.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DecimalData.hpp" 4 | #include "IntegerData.hpp" 5 | 6 | using QtNodes::PortType; 7 | using QtNodes::PortIndex; 8 | using QtNodes::NodeData; 9 | using QtNodes::NodeDataType; 10 | using QtNodes::NodeDataModel; 11 | 12 | class DecimalData; 13 | class IntegerData; 14 | 15 | 16 | class DecimalToIntegerConverter 17 | { 18 | 19 | public: 20 | 21 | std::shared_ptr 22 | operator()(std::shared_ptr data); 23 | 24 | private: 25 | 26 | std::shared_ptr _integer; 27 | }; 28 | 29 | 30 | class IntegerToDecimalConverter 31 | { 32 | 33 | public: 34 | 35 | std::shared_ptr 36 | operator()(std::shared_ptr data); 37 | 38 | private: 39 | 40 | std::shared_ptr _decimal; 41 | }; 42 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/DecimalData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using QtNodes::NodeDataType; 6 | using QtNodes::NodeData; 7 | 8 | /// The class can potentially incapsulate any user data which 9 | /// need to be transferred within the Node Editor graph 10 | class DecimalData : public NodeData 11 | { 12 | public: 13 | 14 | DecimalData() 15 | : _number(0.0) 16 | {} 17 | 18 | DecimalData(double const number) 19 | : _number(number) 20 | {} 21 | 22 | NodeDataType type() const override 23 | { 24 | return NodeDataType {"decimal", 25 | "Decimal"}; 26 | } 27 | 28 | double number() const 29 | { return _number; } 30 | 31 | QString numberAsText() const 32 | { return QString::number(_number, 'f'); } 33 | 34 | private: 35 | 36 | double _number; 37 | }; 38 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/DivisionModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "MathOperationDataModel.hpp" 9 | 10 | #include "DecimalData.hpp" 11 | 12 | /// The model dictates the number of inputs and outputs for the Node. 13 | /// In this example it has no logic. 14 | class DivisionModel : public MathOperationDataModel 15 | { 16 | public: 17 | 18 | virtual 19 | ~DivisionModel() {} 20 | 21 | public: 22 | QString 23 | caption() const override 24 | { return QStringLiteral("Division"); } 25 | 26 | bool 27 | portCaptionVisible(PortType portType, PortIndex portIndex) const override 28 | { 29 | Q_UNUSED(portType); Q_UNUSED(portIndex); 30 | return true; 31 | } 32 | 33 | QString 34 | portCaption(PortType portType, PortIndex portIndex) const override 35 | { 36 | switch (portType) 37 | { 38 | case PortType::In: 39 | if (portIndex == 0) 40 | return QStringLiteral("Dividend"); 41 | else if (portIndex == 1) 42 | return QStringLiteral("Divisor"); 43 | 44 | break; 45 | 46 | case PortType::Out: 47 | return QStringLiteral("Result"); 48 | 49 | default: 50 | break; 51 | } 52 | return QString(); 53 | } 54 | 55 | QString 56 | name() const override 57 | { return QStringLiteral("Division"); } 58 | 59 | private: 60 | 61 | void 62 | compute() override 63 | { 64 | PortIndex const outPortIndex = 0; 65 | 66 | auto n1 = _number1.lock(); 67 | auto n2 = _number2.lock(); 68 | 69 | if (n2 && (n2->number() == 0.0)) 70 | { 71 | modelValidationState = NodeValidationState::Error; 72 | modelValidationError = QStringLiteral("Division by zero error"); 73 | _result.reset(); 74 | } 75 | else if (n1 && n2) 76 | { 77 | modelValidationState = NodeValidationState::Valid; 78 | modelValidationError = QString(); 79 | _result = std::make_shared(n1->number() / 80 | n2->number()); 81 | } 82 | else 83 | { 84 | modelValidationState = NodeValidationState::Warning; 85 | modelValidationError = QStringLiteral("Missing or incorrect inputs"); 86 | _result.reset(); 87 | } 88 | 89 | Q_EMIT dataUpdated(outPortIndex); 90 | } 91 | }; 92 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/IntegerData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using QtNodes::NodeDataType; 6 | using QtNodes::NodeData; 7 | 8 | /// The class can potentially incapsulate any user data which 9 | /// need to be transferred within the Node Editor graph 10 | class IntegerData : public NodeData 11 | { 12 | public: 13 | 14 | IntegerData() 15 | : _number(0.0) 16 | {} 17 | 18 | IntegerData(int const number) 19 | : _number(number) 20 | {} 21 | 22 | NodeDataType type() const override 23 | { 24 | return NodeDataType {"integer", 25 | "Integer"}; 26 | } 27 | 28 | int number() const 29 | { return _number; } 30 | 31 | QString numberAsText() const 32 | { return QString::number(_number); } 33 | 34 | private: 35 | 36 | int _number; 37 | }; 38 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/MathOperationDataModel.cpp: -------------------------------------------------------------------------------- 1 | #include "MathOperationDataModel.hpp" 2 | 3 | #include "DecimalData.hpp" 4 | 5 | unsigned int 6 | MathOperationDataModel:: 7 | nPorts(PortType portType) const 8 | { 9 | unsigned int result; 10 | 11 | if (portType == PortType::In) 12 | result = 2; 13 | else 14 | result = 1; 15 | 16 | return result; 17 | } 18 | 19 | 20 | NodeDataType 21 | MathOperationDataModel:: 22 | dataType(PortType, PortIndex) const 23 | { 24 | return DecimalData().type(); 25 | } 26 | 27 | 28 | std::shared_ptr 29 | MathOperationDataModel:: 30 | outData(PortIndex) 31 | { 32 | return std::static_pointer_cast(_result); 33 | } 34 | 35 | 36 | void 37 | MathOperationDataModel:: 38 | setInData(std::shared_ptr data, PortIndex portIndex) 39 | { 40 | auto numberData = 41 | std::dynamic_pointer_cast(data); 42 | 43 | if (portIndex == 0) 44 | { 45 | _number1 = numberData; 46 | } 47 | else 48 | { 49 | _number2 = numberData; 50 | } 51 | 52 | compute(); 53 | } 54 | 55 | 56 | NodeValidationState 57 | MathOperationDataModel:: 58 | validationState() const 59 | { 60 | return modelValidationState; 61 | } 62 | 63 | 64 | QString 65 | MathOperationDataModel:: 66 | validationMessage() const 67 | { 68 | return modelValidationError; 69 | } 70 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/MathOperationDataModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | class DecimalData; 12 | 13 | using QtNodes::PortType; 14 | using QtNodes::PortIndex; 15 | using QtNodes::NodeData; 16 | using QtNodes::NodeDataType; 17 | using QtNodes::NodeDataModel; 18 | using QtNodes::NodeValidationState; 19 | 20 | /// The model dictates the number of inputs and outputs for the Node. 21 | /// In this example it has no logic. 22 | class MathOperationDataModel : public NodeDataModel 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | 28 | virtual 29 | ~MathOperationDataModel() {} 30 | 31 | public: 32 | 33 | unsigned int 34 | nPorts(PortType portType) const override; 35 | 36 | NodeDataType 37 | dataType(PortType portType, 38 | PortIndex portIndex) const override; 39 | 40 | std::shared_ptr 41 | outData(PortIndex port) override; 42 | 43 | void 44 | setInData(std::shared_ptr data, PortIndex portIndex) override; 45 | 46 | QWidget * 47 | embeddedWidget() override { return nullptr; } 48 | 49 | NodeValidationState 50 | validationState() const override; 51 | 52 | QString 53 | validationMessage() const override; 54 | 55 | protected: 56 | 57 | virtual void 58 | compute() = 0; 59 | 60 | protected: 61 | 62 | std::weak_ptr _number1; 63 | std::weak_ptr _number2; 64 | 65 | std::shared_ptr _result; 66 | 67 | NodeValidationState modelValidationState = NodeValidationState::Warning; 68 | QString modelValidationError = QString("Missing or incorrect inputs"); 69 | }; 70 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/MultiplicationModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "MathOperationDataModel.hpp" 9 | 10 | #include "DecimalData.hpp" 11 | 12 | /// The model dictates the number of inputs and outputs for the Node. 13 | /// In this example it has no logic. 14 | class MultiplicationModel : public MathOperationDataModel 15 | { 16 | public: 17 | 18 | virtual 19 | ~MultiplicationModel() {} 20 | 21 | public: 22 | 23 | QString 24 | caption() const override 25 | { return QStringLiteral("Multiplication"); } 26 | 27 | QString 28 | name() const override 29 | { return QStringLiteral("Multiplication"); } 30 | 31 | private: 32 | 33 | void 34 | compute() override 35 | { 36 | PortIndex const outPortIndex = 0; 37 | 38 | auto n1 = _number1.lock(); 39 | auto n2 = _number2.lock(); 40 | 41 | if (n1 && n2) 42 | { 43 | modelValidationState = NodeValidationState::Valid; 44 | modelValidationError = QString(); 45 | _result = std::make_shared(n1->number() * 46 | n2->number()); 47 | } 48 | else 49 | { 50 | modelValidationState = NodeValidationState::Warning; 51 | modelValidationError = QStringLiteral("Missing or incorrect inputs"); 52 | _result.reset(); 53 | } 54 | 55 | Q_EMIT dataUpdated(outPortIndex); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/NumberDisplayDataModel.cpp: -------------------------------------------------------------------------------- 1 | #include "NumberDisplayDataModel.hpp" 2 | 3 | #include "DecimalData.hpp" 4 | 5 | NumberDisplayDataModel:: 6 | NumberDisplayDataModel() 7 | : _label(new QLabel()) 8 | { 9 | _label->setMargin(3); 10 | } 11 | 12 | 13 | unsigned int 14 | NumberDisplayDataModel:: 15 | nPorts(PortType portType) const 16 | { 17 | unsigned int result = 1; 18 | 19 | switch (portType) 20 | { 21 | case PortType::In: 22 | result = 1; 23 | break; 24 | 25 | case PortType::Out: 26 | result = 0; 27 | 28 | default: 29 | break; 30 | } 31 | 32 | return result; 33 | } 34 | 35 | 36 | NodeDataType 37 | NumberDisplayDataModel:: 38 | dataType(PortType, PortIndex) const 39 | { 40 | return DecimalData().type(); 41 | } 42 | 43 | 44 | std::shared_ptr 45 | NumberDisplayDataModel:: 46 | outData(PortIndex) 47 | { 48 | std::shared_ptr ptr; 49 | return ptr; 50 | } 51 | 52 | 53 | void 54 | NumberDisplayDataModel:: 55 | setInData(std::shared_ptr data, int) 56 | { 57 | auto numberData = std::dynamic_pointer_cast(data); 58 | 59 | if (numberData) 60 | { 61 | modelValidationState = NodeValidationState::Valid; 62 | modelValidationError = QString(); 63 | _label->setText(numberData->numberAsText()); 64 | } 65 | else 66 | { 67 | modelValidationState = NodeValidationState::Warning; 68 | modelValidationError = QStringLiteral("Missing or incorrect inputs"); 69 | _label->clear(); 70 | } 71 | 72 | _label->adjustSize(); 73 | } 74 | 75 | 76 | NodeValidationState 77 | NumberDisplayDataModel:: 78 | validationState() const 79 | { 80 | return modelValidationState; 81 | } 82 | 83 | 84 | QString 85 | NumberDisplayDataModel:: 86 | validationMessage() const 87 | { 88 | return modelValidationError; 89 | } 90 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/NumberDisplayDataModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | using QtNodes::PortType; 11 | using QtNodes::PortIndex; 12 | using QtNodes::NodeData; 13 | using QtNodes::NodeDataType; 14 | using QtNodes::NodeDataModel; 15 | using QtNodes::NodeValidationState; 16 | 17 | /// The model dictates the number of inputs and outputs for the Node. 18 | /// In this example it has no logic. 19 | class NumberDisplayDataModel : public NodeDataModel 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | NumberDisplayDataModel(); 25 | 26 | virtual 27 | ~NumberDisplayDataModel() {} 28 | 29 | public: 30 | 31 | QString 32 | caption() const override 33 | { return QStringLiteral("Result"); } 34 | 35 | bool 36 | captionVisible() const override 37 | { return false; } 38 | 39 | QString 40 | name() const override 41 | { return QStringLiteral("Result"); } 42 | 43 | public: 44 | 45 | unsigned int 46 | nPorts(PortType portType) const override; 47 | 48 | NodeDataType 49 | dataType(PortType portType, 50 | PortIndex portIndex) const override; 51 | 52 | std::shared_ptr 53 | outData(PortIndex port) override; 54 | 55 | void 56 | setInData(std::shared_ptr data, int) override; 57 | 58 | QWidget * 59 | embeddedWidget() override { return _label; } 60 | 61 | NodeValidationState 62 | validationState() const override; 63 | 64 | QString 65 | validationMessage() const override; 66 | 67 | private: 68 | 69 | NodeValidationState modelValidationState = NodeValidationState::Warning; 70 | QString modelValidationError = QStringLiteral("Missing or incorrect inputs"); 71 | 72 | QLabel * _label; 73 | }; 74 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/NumberSourceDataModel.cpp: -------------------------------------------------------------------------------- 1 | #include "NumberSourceDataModel.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "DecimalData.hpp" 7 | 8 | NumberSourceDataModel:: 9 | NumberSourceDataModel() 10 | : _lineEdit(new QLineEdit()) 11 | { 12 | _lineEdit->setValidator(new QDoubleValidator()); 13 | 14 | _lineEdit->setMaximumSize(_lineEdit->sizeHint()); 15 | 16 | connect(_lineEdit, &QLineEdit::textChanged, 17 | this, &NumberSourceDataModel::onTextEdited); 18 | 19 | _lineEdit->setText("0.0"); 20 | } 21 | 22 | 23 | QJsonObject 24 | NumberSourceDataModel:: 25 | save() const 26 | { 27 | QJsonObject modelJson = NodeDataModel::save(); 28 | 29 | if (_number) 30 | modelJson["number"] = QString::number(_number->number()); 31 | 32 | return modelJson; 33 | } 34 | 35 | 36 | void 37 | NumberSourceDataModel:: 38 | restore(QJsonObject const &p) 39 | { 40 | QJsonValue v = p["number"]; 41 | 42 | if (!v.isUndefined()) 43 | { 44 | QString strNum = v.toString(); 45 | 46 | bool ok; 47 | double d = strNum.toDouble(&ok); 48 | if (ok) 49 | { 50 | _number = std::make_shared(d); 51 | _lineEdit->setText(strNum); 52 | } 53 | } 54 | } 55 | 56 | 57 | unsigned int 58 | NumberSourceDataModel:: 59 | nPorts(PortType portType) const 60 | { 61 | unsigned int result = 1; 62 | 63 | switch (portType) 64 | { 65 | case PortType::In: 66 | result = 0; 67 | break; 68 | 69 | case PortType::Out: 70 | result = 1; 71 | 72 | default: 73 | break; 74 | } 75 | 76 | return result; 77 | } 78 | 79 | 80 | void 81 | NumberSourceDataModel:: 82 | onTextEdited(QString const &string) 83 | { 84 | Q_UNUSED(string); 85 | 86 | bool ok = false; 87 | 88 | double number = _lineEdit->text().toDouble(&ok); 89 | 90 | if (ok) 91 | { 92 | _number = std::make_shared(number); 93 | 94 | Q_EMIT dataUpdated(0); 95 | } 96 | else 97 | { 98 | Q_EMIT dataInvalidated(0); 99 | } 100 | } 101 | 102 | 103 | NodeDataType 104 | NumberSourceDataModel:: 105 | dataType(PortType, PortIndex) const 106 | { 107 | return DecimalData().type(); 108 | } 109 | 110 | 111 | std::shared_ptr 112 | NumberSourceDataModel:: 113 | outData(PortIndex) 114 | { 115 | return _number; 116 | } 117 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/NumberSourceDataModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | class DecimalData; 11 | 12 | using QtNodes::PortType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::NodeData; 15 | using QtNodes::NodeDataType; 16 | using QtNodes::NodeDataModel; 17 | using QtNodes::NodeValidationState; 18 | 19 | /// The model dictates the number of inputs and outputs for the Node. 20 | /// In this example it has no logic. 21 | class NumberSourceDataModel 22 | : public NodeDataModel 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | NumberSourceDataModel(); 28 | 29 | virtual 30 | ~NumberSourceDataModel() {} 31 | 32 | public: 33 | 34 | QString 35 | caption() const override 36 | { return QStringLiteral("Number Source"); } 37 | 38 | bool 39 | captionVisible() const override 40 | { return false; } 41 | 42 | QString 43 | name() const override 44 | { return QStringLiteral("NumberSource"); } 45 | 46 | public: 47 | 48 | QJsonObject 49 | save() const override; 50 | 51 | void 52 | restore(QJsonObject const &p) override; 53 | 54 | public: 55 | 56 | unsigned int 57 | nPorts(PortType portType) const override; 58 | 59 | NodeDataType 60 | dataType(PortType portType, PortIndex portIndex) const override; 61 | 62 | std::shared_ptr 63 | outData(PortIndex port) override; 64 | 65 | void 66 | setInData(std::shared_ptr, int) override 67 | { } 68 | 69 | QWidget * 70 | embeddedWidget() override { return _lineEdit; } 71 | 72 | private Q_SLOTS: 73 | 74 | void 75 | onTextEdited(QString const &string); 76 | 77 | private: 78 | 79 | std::shared_ptr _number; 80 | 81 | QLineEdit * _lineEdit; 82 | }; 83 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/calculator/SubtractionModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "MathOperationDataModel.hpp" 9 | 10 | #include "DecimalData.hpp" 11 | 12 | /// The model dictates the number of inputs and outputs for the Node. 13 | /// In this example it has no logic. 14 | class SubtractionModel : public MathOperationDataModel 15 | { 16 | public: 17 | 18 | virtual 19 | ~SubtractionModel() {} 20 | 21 | public: 22 | 23 | QString 24 | caption() const override 25 | { return QStringLiteral("Subtraction"); } 26 | 27 | virtual bool 28 | portCaptionVisible(PortType portType, PortIndex portIndex) const override 29 | { 30 | Q_UNUSED(portType); Q_UNUSED(portIndex); 31 | return true; 32 | } 33 | 34 | virtual QString 35 | portCaption(PortType portType, PortIndex portIndex) const override 36 | { 37 | switch (portType) 38 | { 39 | case PortType::In: 40 | if (portIndex == 0) 41 | return QStringLiteral("Minuend"); 42 | else if (portIndex == 1) 43 | return QStringLiteral("Subtrahend"); 44 | 45 | break; 46 | 47 | case PortType::Out: 48 | return QStringLiteral("Result"); 49 | 50 | default: 51 | break; 52 | } 53 | return QString(); 54 | } 55 | 56 | QString 57 | name() const override 58 | { return QStringLiteral("Subtraction"); } 59 | 60 | private: 61 | 62 | void 63 | compute() override 64 | { 65 | PortIndex const outPortIndex = 0; 66 | 67 | auto n1 = _number1.lock(); 68 | auto n2 = _number2.lock(); 69 | 70 | if (n1 && n2) 71 | { 72 | modelValidationState = NodeValidationState::Valid; 73 | modelValidationError = QString(); 74 | _result = std::make_shared(n1->number() - 75 | n2->number()); 76 | } 77 | else 78 | { 79 | modelValidationState = NodeValidationState::Warning; 80 | modelValidationError = QStringLiteral("Missing or incorrect inputs"); 81 | _result.reset(); 82 | } 83 | 84 | Q_EMIT dataUpdated(outPortIndex); 85 | } 86 | }; 87 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/connection_colors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE CPPS ./*.cpp ) 2 | 3 | add_executable(connection_colors ${CPPS}) 4 | 5 | target_link_libraries(connection_colors nodes) 6 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/connection_colors/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "models.hpp" 10 | 11 | using QtNodes::DataModelRegistry; 12 | using QtNodes::FlowScene; 13 | using QtNodes::FlowView; 14 | using QtNodes::ConnectionStyle; 15 | 16 | static std::shared_ptr 17 | registerDataModels() 18 | { 19 | auto ret = std::make_shared(); 20 | 21 | ret->registerModel(); 22 | 23 | /* 24 | We could have more models registered. 25 | All of them become items in the context meny of the scene. 26 | 27 | ret->registerModel(); 28 | ret->registerModel(); 29 | 30 | */ 31 | 32 | return ret; 33 | } 34 | 35 | 36 | static 37 | void 38 | setStyle() 39 | { 40 | ConnectionStyle::setConnectionStyle( 41 | R"( 42 | { 43 | "ConnectionStyle": { 44 | "UseDataDefinedColors": true 45 | } 46 | } 47 | )"); 48 | } 49 | 50 | 51 | //------------------------------------------------------------------------------ 52 | 53 | int 54 | main(int argc, char* argv[]) 55 | { 56 | QApplication app(argc, argv); 57 | 58 | setStyle(); 59 | 60 | FlowScene scene(registerDataModels()); 61 | 62 | FlowView view(&scene); 63 | 64 | view.setWindowTitle("Node-based flow editor"); 65 | view.resize(800, 600); 66 | view.show(); 67 | 68 | return app.exec(); 69 | } 70 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/connection_colors/models.cpp: -------------------------------------------------------------------------------- 1 | #include "models.hpp" 2 | 3 | // For some reason CMake could not generate moc-files correctly 4 | // without having a cpp for an QObject from hpp. 5 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE CPPS ./*.cpp ) 2 | 3 | add_executable(example2 ${CPPS}) 4 | 5 | target_link_libraries(example2 nodes) 6 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/TextData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using QtNodes::NodeData; 6 | using QtNodes::NodeDataType; 7 | 8 | /// The class can potentially incapsulate any user data which 9 | /// need to be transferred within the Node Editor graph 10 | class TextData : public NodeData 11 | { 12 | public: 13 | 14 | TextData() {} 15 | 16 | TextData(QString const &text) 17 | : _text(text) 18 | {} 19 | 20 | NodeDataType type() const override 21 | { return NodeDataType {"text", "Text"}; } 22 | 23 | QString text() const { return _text; } 24 | 25 | private: 26 | 27 | QString _text; 28 | }; 29 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/TextDisplayDataModel.cpp: -------------------------------------------------------------------------------- 1 | #include "TextDisplayDataModel.hpp" 2 | 3 | TextDisplayDataModel:: 4 | TextDisplayDataModel() 5 | : _label(new QLabel("Resulting Text")) 6 | { 7 | _label->setMargin(3); 8 | } 9 | 10 | 11 | unsigned int 12 | TextDisplayDataModel:: 13 | nPorts(PortType portType) const 14 | { 15 | unsigned int result = 1; 16 | 17 | switch (portType) 18 | { 19 | case PortType::In: 20 | result = 1; 21 | break; 22 | 23 | case PortType::Out: 24 | result = 0; 25 | 26 | default: 27 | break; 28 | } 29 | 30 | return result; 31 | } 32 | 33 | 34 | NodeDataType 35 | TextDisplayDataModel:: 36 | dataType(PortType, PortIndex) const 37 | { 38 | return TextData().type(); 39 | } 40 | 41 | 42 | std::shared_ptr 43 | TextDisplayDataModel:: 44 | outData(PortIndex) 45 | { 46 | std::shared_ptr ptr; 47 | return ptr; 48 | } 49 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/TextDisplayDataModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "TextData.hpp" 7 | 8 | #include 9 | 10 | #include 11 | 12 | using QtNodes::PortType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::NodeData; 15 | using QtNodes::NodeDataModel; 16 | 17 | /// The model dictates the number of inputs and outputs for the Node. 18 | /// In this example it has no logic. 19 | class TextDisplayDataModel : public NodeDataModel 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | TextDisplayDataModel(); 25 | 26 | virtual 27 | ~TextDisplayDataModel() {} 28 | 29 | public: 30 | 31 | QString 32 | caption() const override 33 | { return QString("Text Display"); } 34 | 35 | bool 36 | captionVisible() const override { return false; } 37 | 38 | static QString 39 | Name() 40 | { return QString("TextDisplayDataModel"); } 41 | 42 | QString 43 | name() const override 44 | { return TextDisplayDataModel::Name(); } 45 | 46 | public: 47 | 48 | unsigned int 49 | nPorts(PortType portType) const override; 50 | 51 | NodeDataType 52 | dataType(PortType portType, PortIndex portIndex) const override; 53 | 54 | std::shared_ptr 55 | outData(PortIndex port) override; 56 | 57 | void 58 | setInData(std::shared_ptr data, int) override 59 | { 60 | auto textData = std::dynamic_pointer_cast(data); 61 | 62 | if (textData) 63 | { 64 | _label->setText(textData->text()); 65 | } 66 | else 67 | { 68 | _label->clear(); 69 | } 70 | 71 | _label->adjustSize(); 72 | } 73 | 74 | QWidget * 75 | embeddedWidget() override { return _label; } 76 | 77 | private: 78 | 79 | QLabel * _label; 80 | }; 81 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/TextSourceDataModel.cpp: -------------------------------------------------------------------------------- 1 | #include "TextSourceDataModel.hpp" 2 | 3 | TextSourceDataModel:: 4 | TextSourceDataModel() 5 | : _lineEdit(new QLineEdit("Default Text")) 6 | { 7 | connect(_lineEdit, &QLineEdit::textEdited, 8 | this, &TextSourceDataModel::onTextEdited); 9 | } 10 | 11 | 12 | unsigned int 13 | TextSourceDataModel:: 14 | nPorts(PortType portType) const 15 | { 16 | unsigned int result = 1; 17 | 18 | switch (portType) 19 | { 20 | case PortType::In: 21 | result = 0; 22 | break; 23 | 24 | case PortType::Out: 25 | result = 1; 26 | 27 | default: 28 | break; 29 | } 30 | 31 | return result; 32 | } 33 | 34 | 35 | void 36 | TextSourceDataModel:: 37 | onTextEdited(QString const &string) 38 | { 39 | Q_UNUSED(string); 40 | 41 | Q_EMIT dataUpdated(0); 42 | } 43 | 44 | 45 | NodeDataType 46 | TextSourceDataModel:: 47 | dataType(PortType, PortIndex) const 48 | { 49 | return TextData().type(); 50 | } 51 | 52 | 53 | std::shared_ptr 54 | TextSourceDataModel:: 55 | outData(PortIndex) 56 | { 57 | return std::make_shared(_lineEdit->text()); 58 | } 59 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/TextSourceDataModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "TextData.hpp" 7 | 8 | #include 9 | 10 | #include 11 | 12 | using QtNodes::PortType; 13 | using QtNodes::PortIndex; 14 | using QtNodes::NodeData; 15 | using QtNodes::NodeDataModel; 16 | 17 | /// The model dictates the number of inputs and outputs for the Node. 18 | /// In this example it has no logic. 19 | class TextSourceDataModel : public NodeDataModel 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | TextSourceDataModel(); 25 | 26 | virtual 27 | ~TextSourceDataModel() {} 28 | 29 | public: 30 | 31 | QString 32 | caption() const override 33 | { return QString("Text Source"); } 34 | 35 | bool 36 | captionVisible() const override { return false; } 37 | 38 | static QString 39 | Name() 40 | { return QString("TextSourceDataModel"); } 41 | 42 | QString 43 | name() const override 44 | { return TextSourceDataModel::Name(); } 45 | 46 | public: 47 | 48 | unsigned int 49 | nPorts(PortType portType) const override; 50 | 51 | NodeDataType 52 | dataType(PortType portType, PortIndex portIndex) const override; 53 | 54 | std::shared_ptr 55 | outData(PortIndex port) override; 56 | 57 | void 58 | setInData(std::shared_ptr, int) override 59 | { } 60 | 61 | QWidget * 62 | embeddedWidget() override { return _lineEdit; } 63 | 64 | private Q_SLOTS: 65 | 66 | void 67 | onTextEdited(QString const &string); 68 | 69 | private: 70 | 71 | QLineEdit * _lineEdit; 72 | }; 73 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/example2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "TextSourceDataModel.hpp" 10 | #include "TextDisplayDataModel.hpp" 11 | 12 | using QtNodes::DataModelRegistry; 13 | using QtNodes::FlowView; 14 | using QtNodes::FlowScene; 15 | 16 | static std::shared_ptr 17 | registerDataModels() 18 | { 19 | auto ret = std::make_shared(); 20 | 21 | ret->registerModel(); 22 | 23 | ret->registerModel(); 24 | 25 | return ret; 26 | } 27 | 28 | 29 | int 30 | main(int argc, char *argv[]) 31 | { 32 | QApplication app(argc, argv); 33 | 34 | FlowScene scene(registerDataModels()); 35 | 36 | FlowView view(&scene); 37 | 38 | view.setWindowTitle("Node-based flow editor"); 39 | view.resize(800, 600); 40 | view.show(); 41 | 42 | return app.exec(); 43 | } 44 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE CPPS ./*.cpp ) 2 | 3 | add_executable(images ${CPPS}) 4 | 5 | target_link_libraries(images nodes) 6 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/ImageLoaderModel.cpp: -------------------------------------------------------------------------------- 1 | #include "ImageLoaderModel.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | ImageLoaderModel:: 9 | ImageLoaderModel() 10 | : _label(new QLabel("Double click to load image")) 11 | { 12 | _label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); 13 | 14 | QFont f = _label->font(); 15 | f.setBold(true); 16 | f.setItalic(true); 17 | 18 | _label->setFont(f); 19 | 20 | _label->setFixedSize(200, 200); 21 | 22 | _label->installEventFilter(this); 23 | } 24 | 25 | 26 | unsigned int 27 | ImageLoaderModel:: 28 | nPorts(PortType portType) const 29 | { 30 | unsigned int result = 1; 31 | 32 | switch (portType) 33 | { 34 | case PortType::In: 35 | result = 0; 36 | break; 37 | 38 | case PortType::Out: 39 | result = 1; 40 | 41 | default: 42 | break; 43 | } 44 | 45 | return result; 46 | } 47 | 48 | 49 | bool 50 | ImageLoaderModel:: 51 | eventFilter(QObject *object, QEvent *event) 52 | { 53 | if (object == _label) 54 | { 55 | int w = _label->width(); 56 | int h = _label->height(); 57 | 58 | if (event->type() == QEvent::MouseButtonPress) 59 | { 60 | 61 | QString fileName = 62 | QFileDialog::getOpenFileName(nullptr, 63 | tr("Open Image"), 64 | QDir::homePath(), 65 | tr("Image Files (*.png *.jpg *.bmp)")); 66 | 67 | _pixmap = QPixmap(fileName); 68 | 69 | _label->setPixmap(_pixmap.scaled(w, h, Qt::KeepAspectRatio)); 70 | 71 | Q_EMIT dataUpdated(0); 72 | 73 | return true; 74 | } 75 | else if (event->type() == QEvent::Resize) 76 | { 77 | if (!_pixmap.isNull()) 78 | _label->setPixmap(_pixmap.scaled(w, h, Qt::KeepAspectRatio)); 79 | } 80 | } 81 | 82 | return false; 83 | } 84 | 85 | 86 | NodeDataType 87 | ImageLoaderModel:: 88 | dataType(PortType, PortIndex) const 89 | { 90 | return PixmapData().type(); 91 | } 92 | 93 | 94 | std::shared_ptr 95 | ImageLoaderModel:: 96 | outData(PortIndex) 97 | { 98 | return std::make_shared(_pixmap); 99 | } 100 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/ImageLoaderModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "PixmapData.hpp" 12 | 13 | using QtNodes::PortType; 14 | using QtNodes::PortIndex; 15 | using QtNodes::NodeData; 16 | using QtNodes::NodeDataType; 17 | using QtNodes::NodeDataModel; 18 | using QtNodes::NodeValidationState; 19 | 20 | /// The model dictates the number of inputs and outputs for the Node. 21 | /// In this example it has no logic. 22 | class ImageLoaderModel : public NodeDataModel 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | ImageLoaderModel(); 28 | 29 | virtual 30 | ~ImageLoaderModel() {} 31 | 32 | public: 33 | 34 | QString 35 | caption() const override 36 | { return QString("Image Source"); } 37 | 38 | QString 39 | name() const override { return QString("ImageLoaderModel"); } 40 | 41 | public: 42 | 43 | virtual QString 44 | modelName() const 45 | { return QString("Source Image"); } 46 | 47 | unsigned int 48 | nPorts(PortType portType) const override; 49 | 50 | NodeDataType 51 | dataType(PortType portType, PortIndex portIndex) const override; 52 | 53 | std::shared_ptr 54 | outData(PortIndex port) override; 55 | 56 | void 57 | setInData(std::shared_ptr, int) override 58 | { } 59 | 60 | QWidget * 61 | embeddedWidget() override { return _label; } 62 | 63 | bool 64 | resizable() const override { return true; } 65 | 66 | protected: 67 | 68 | bool 69 | eventFilter(QObject *object, QEvent *event) override; 70 | 71 | private: 72 | 73 | QLabel * _label; 74 | 75 | QPixmap _pixmap; 76 | }; 77 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/ImageShowModel.cpp: -------------------------------------------------------------------------------- 1 | #include "ImageShowModel.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "PixmapData.hpp" 11 | 12 | ImageShowModel:: 13 | ImageShowModel() 14 | : _label(new QLabel("Image will appear here")) 15 | { 16 | _label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); 17 | 18 | QFont f = _label->font(); 19 | f.setBold(true); 20 | f.setItalic(true); 21 | 22 | _label->setFont(f); 23 | 24 | _label->setFixedSize(200, 200); 25 | 26 | _label->installEventFilter(this); 27 | } 28 | 29 | unsigned int 30 | ImageShowModel:: 31 | nPorts(PortType portType) const 32 | { 33 | unsigned int result = 1; 34 | 35 | switch (portType) 36 | { 37 | case PortType::In: 38 | result = 1; 39 | break; 40 | 41 | case PortType::Out: 42 | result = 1; 43 | 44 | default: 45 | break; 46 | } 47 | 48 | return result; 49 | } 50 | 51 | 52 | bool 53 | ImageShowModel:: 54 | eventFilter(QObject *object, QEvent *event) 55 | { 56 | if (object == _label) 57 | { 58 | int w = _label->width(); 59 | int h = _label->height(); 60 | 61 | if (event->type() == QEvent::Resize) 62 | { 63 | auto d = std::dynamic_pointer_cast(_nodeData); 64 | if (d) 65 | { 66 | _label->setPixmap(d->pixmap().scaled(w, h, Qt::KeepAspectRatio)); 67 | } 68 | } 69 | } 70 | 71 | return false; 72 | } 73 | 74 | 75 | NodeDataType 76 | ImageShowModel:: 77 | dataType(PortType, PortIndex) const 78 | { 79 | return PixmapData().type(); 80 | } 81 | 82 | 83 | std::shared_ptr 84 | ImageShowModel:: 85 | outData(PortIndex) 86 | { 87 | return _nodeData; 88 | } 89 | 90 | 91 | void 92 | ImageShowModel:: 93 | setInData(std::shared_ptr nodeData, PortIndex) 94 | { 95 | _nodeData = nodeData; 96 | 97 | if (_nodeData) 98 | { 99 | auto d = std::dynamic_pointer_cast(_nodeData); 100 | 101 | int w = _label->width(); 102 | int h = _label->height(); 103 | 104 | _label->setPixmap(d->pixmap().scaled(w, h, Qt::KeepAspectRatio)); 105 | } 106 | else 107 | { 108 | _label->setPixmap(QPixmap()); 109 | } 110 | 111 | Q_EMIT dataUpdated(0); 112 | } 113 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/ImageShowModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | using QtNodes::PortType; 12 | using QtNodes::PortIndex; 13 | using QtNodes::NodeData; 14 | using QtNodes::NodeDataType; 15 | using QtNodes::NodeDataModel; 16 | using QtNodes::NodeValidationState; 17 | 18 | /// The model dictates the number of inputs and outputs for the Node. 19 | /// In this example it has no logic. 20 | class ImageShowModel : public NodeDataModel 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | ImageShowModel(); 26 | 27 | virtual 28 | ~ImageShowModel() {} 29 | 30 | public: 31 | 32 | QString 33 | caption() const override 34 | { return QString("Image Display"); } 35 | 36 | QString 37 | name() const override 38 | { return QString("ImageShowModel"); } 39 | 40 | public: 41 | 42 | virtual QString 43 | modelName() const 44 | { return QString("Resulting Image"); } 45 | 46 | unsigned int 47 | nPorts(PortType portType) const override; 48 | 49 | NodeDataType 50 | dataType(PortType portType, PortIndex portIndex) const override; 51 | 52 | std::shared_ptr 53 | outData(PortIndex port) override; 54 | 55 | void 56 | setInData(std::shared_ptr nodeData, PortIndex port) override; 57 | 58 | QWidget * 59 | embeddedWidget() override { return _label; } 60 | 61 | bool 62 | resizable() const override { return true; } 63 | 64 | protected: 65 | 66 | bool 67 | eventFilter(QObject *object, QEvent *event) override; 68 | 69 | private: 70 | 71 | QLabel * _label; 72 | 73 | std::shared_ptr _nodeData; 74 | }; 75 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/PixmapData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | using QtNodes::NodeData; 8 | using QtNodes::NodeDataType; 9 | 10 | /// The class can potentially incapsulate any user data which 11 | /// need to be transferred within the Node Editor graph 12 | class PixmapData : public NodeData 13 | { 14 | public: 15 | 16 | PixmapData() {} 17 | 18 | PixmapData(QPixmap const &pixmap) 19 | : _pixmap(pixmap) 20 | {} 21 | 22 | NodeDataType 23 | type() const override 24 | { 25 | // id name 26 | return {"pixmap", "P"}; 27 | } 28 | 29 | QPixmap 30 | pixmap() const { return _pixmap; } 31 | 32 | private: 33 | 34 | QPixmap _pixmap; 35 | }; 36 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/images/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "ImageShowModel.hpp" 8 | #include "ImageLoaderModel.hpp" 9 | 10 | using QtNodes::DataModelRegistry; 11 | using QtNodes::FlowScene; 12 | using QtNodes::FlowView; 13 | 14 | static std::shared_ptr 15 | registerDataModels() 16 | { 17 | auto ret = std::make_shared(); 18 | ret->registerModel(); 19 | 20 | ret->registerModel(); 21 | 22 | return ret; 23 | } 24 | 25 | 26 | int 27 | main(int argc, char *argv[]) 28 | { 29 | QApplication app(argc, argv); 30 | 31 | FlowScene scene(registerDataModels()); 32 | 33 | FlowView view(&scene); 34 | 35 | view.setWindowTitle("Node-based flow editor"); 36 | view.resize(800, 600); 37 | view.show(); 38 | 39 | return app.exec(); 40 | } 41 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/styles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE CPPS ./*.cpp ) 2 | 3 | add_executable(styles ${CPPS}) 4 | 5 | target_link_libraries(styles nodes) 6 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/styles/models.cpp: -------------------------------------------------------------------------------- 1 | #include "models.hpp" 2 | 3 | // For some reason CMake could not generate moc-files correctly 4 | // without having a cpp for an QObject from hpp. 5 | -------------------------------------------------------------------------------- /external/nodeeditor/examples/styles/models.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | using QtNodes::PortType; 11 | using QtNodes::PortIndex; 12 | using QtNodes::NodeData; 13 | using QtNodes::NodeDataType; 14 | using QtNodes::NodeDataModel; 15 | using QtNodes::NodeValidationState; 16 | 17 | /// The class can potentially incapsulate any user data which 18 | /// need to be transferred within the Node Editor graph 19 | class MyNodeData : public NodeData 20 | { 21 | public: 22 | 23 | NodeDataType 24 | type() const override 25 | { return NodeDataType {"MyNodeData", "My Node Data"}; } 26 | }; 27 | 28 | //------------------------------------------------------------------------------ 29 | 30 | /// The model dictates the number of inputs and outputs for the Node. 31 | /// In this example it has no logic. 32 | class MyDataModel : public NodeDataModel 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | 38 | virtual 39 | ~MyDataModel() {} 40 | 41 | public: 42 | 43 | QString 44 | caption() const override 45 | { 46 | return QString("My Data Model"); 47 | } 48 | 49 | QString 50 | name() const override 51 | { 52 | return QString("MyDataModel"); 53 | } 54 | 55 | public: 56 | 57 | QJsonObject 58 | save() const override 59 | { 60 | QJsonObject modelJson; 61 | 62 | modelJson["name"] = name(); 63 | 64 | return modelJson; 65 | } 66 | 67 | public: 68 | 69 | unsigned int 70 | nPorts(PortType) const override 71 | { 72 | return 3; 73 | } 74 | 75 | NodeDataType 76 | dataType(PortType, PortIndex) const override 77 | { 78 | return MyNodeData().type(); 79 | } 80 | 81 | std::shared_ptr 82 | outData(PortIndex) override 83 | { 84 | return std::make_shared(); 85 | } 86 | 87 | void 88 | setInData(std::shared_ptr, int) override 89 | { 90 | // 91 | } 92 | 93 | QWidget * 94 | embeddedWidget() override { return nullptr; } 95 | }; 96 | -------------------------------------------------------------------------------- /external/nodeeditor/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(BUILD_TESTING) 2 | find_package(Catch2 2.3.0 QUIET) 3 | 4 | if(NOT Catch2_FOUND) 5 | add_subdirectory(Catch2) 6 | endif() 7 | endif() 8 | 9 | macro(find_package pkg) 10 | if(NOT TARGET "${pkg}") 11 | _find_package(${ARGV}) 12 | endif() 13 | endmacro() 14 | -------------------------------------------------------------------------------- /external/nodeeditor/external/Catch2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/single_include/catch2/catch.hpp") 2 | file(DOWNLOAD https://raw.githubusercontent.com/catchorg/Catch2/v2.4.1/single_include/catch2/catch.hpp 3 | "${CMAKE_CURRENT_BINARY_DIR}/single_include/catch2/catch.hpp" 4 | EXPECTED_HASH SHA256=a4b90030cb813f0452bb00e97c92ca6c2ecf9386a2f000b6effb8e265a53959e 5 | ) 6 | endif() 7 | 8 | add_library(Catch2 INTERFACE) 9 | add_library(Catch2::Catch2 ALIAS Catch2) 10 | target_include_directories(Catch2 11 | INTERFACE 12 | "${CMAKE_CURRENT_BINARY_DIR}/single_include" 13 | ) 14 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/Connection: -------------------------------------------------------------------------------- 1 | #include "internal/Connection.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/ConnectionStyle: -------------------------------------------------------------------------------- 1 | #include "internal/ConnectionStyle.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/DataModelRegistry: -------------------------------------------------------------------------------- 1 | #include "internal/DataModelRegistry.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/FlowScene: -------------------------------------------------------------------------------- 1 | #include "internal/FlowScene.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/FlowView: -------------------------------------------------------------------------------- 1 | #include "internal/FlowView.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/FlowViewStyle: -------------------------------------------------------------------------------- 1 | #include "internal/FlowViewStyle.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/Node: -------------------------------------------------------------------------------- 1 | #include "internal/Node.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/NodeData: -------------------------------------------------------------------------------- 1 | #include "internal/NodeData.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/NodeDataModel: -------------------------------------------------------------------------------- 1 | #include "internal/NodeDataModel.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/NodeGeometry: -------------------------------------------------------------------------------- 1 | #include "internal/NodeGeometry.hpp" 2 | 3 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/NodePainterDelegate: -------------------------------------------------------------------------------- 1 | #include "internal/NodePainterDelegate.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/NodeState: -------------------------------------------------------------------------------- 1 | #include "internal/NodeState.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/NodeStyle: -------------------------------------------------------------------------------- 1 | #include "internal/NodeStyle.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/TypeConverter: -------------------------------------------------------------------------------- 1 | #include "internal/TypeConverter.hpp" 2 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/Compilation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if \ 4 | defined (__MINGW32__) || \ 5 | defined (__MINGW64__) 6 | # define NODE_EDITOR_COMPILER "MinGW" 7 | # define NODE_EDITOR_COMPILER_MINGW 8 | #elif \ 9 | defined (__GNUC__) 10 | # define NODE_EDITOR_COMPILER "GNU" 11 | # define NODE_EDITOR_COMPILER_GNU 12 | # define NODE_EDITOR_COMPILER_GNU_VERSION_MAJOR __GNUC__ 13 | # define NODE_EDITOR_COMPILER_GNU_VERSION_MINOR __GNUC_MINOR__ 14 | # define NODE_EDITOR_COMPILER_GNU_VERSION_PATCH __GNUC_PATCHLEVEL__ 15 | #elif \ 16 | defined (__clang__) 17 | # define NODE_EDITOR_COMPILER "Clang" 18 | # define NODE_EDITOR_COMPILER_CLANG 19 | #elif \ 20 | defined (_MSC_VER) 21 | # define NODE_EDITOR_COMPILER "Microsoft Visual C++" 22 | # define NODE_EDITOR_COMPILER_MICROSOFT 23 | #elif \ 24 | defined (__BORLANDC__) 25 | # define NODE_EDITOR_COMPILER "Borland C++ Builder" 26 | # define NODE_EDITOR_COMPILER_BORLAND 27 | #elif \ 28 | defined (__CODEGEARC__) 29 | # define NODE_EDITOR_COMPILER "CodeGear C++ Builder" 30 | # define NODE_EDITOR_COMPILER_CODEGEAR 31 | #elif \ 32 | defined (__INTEL_COMPILER) || \ 33 | defined (__ICL) 34 | # define NODE_EDITOR_COMPILER "Intel C++" 35 | # define NODE_EDITOR_COMPILER_INTEL 36 | #elif \ 37 | defined (__xlC__) || \ 38 | defined (__IBMCPP__) 39 | # define NODE_EDITOR_COMPILER "IBM XL C++" 40 | # define NODE_EDITOR_COMPILER_IBM 41 | #elif \ 42 | defined (__HP_aCC) 43 | # define NODE_EDITOR_COMPILER "HP aC++" 44 | # define NODE_EDITOR_COMPILER_HP 45 | #elif \ 46 | defined (__WATCOMC__) 47 | # define NODE_EDITOR_COMPILER "Watcom C++" 48 | # define NODE_EDITOR_COMPILER_WATCOM 49 | #endif 50 | 51 | #ifndef NODE_EDITOR_COMPILER 52 | # error "Current compiler is not supported." 53 | #endif 54 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/ConnectionGeometry.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PortType.hpp" 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace QtNodes 11 | { 12 | 13 | class ConnectionGeometry 14 | { 15 | public: 16 | 17 | ConnectionGeometry(); 18 | 19 | public: 20 | 21 | QPointF const& 22 | getEndPoint(PortType portType) const; 23 | 24 | void 25 | setEndPoint(PortType portType, QPointF const& point); 26 | 27 | void 28 | moveEndPoint(PortType portType, QPointF const &offset); 29 | 30 | QRectF 31 | boundingRect() const; 32 | 33 | std::pair 34 | pointsC1C2() const; 35 | 36 | QPointF 37 | source() const { return _out; } 38 | QPointF 39 | sink() const { return _in; } 40 | 41 | double 42 | lineWidth() const { return _lineWidth; } 43 | 44 | bool 45 | hovered() const { return _hovered; } 46 | void 47 | setHovered(bool hovered) { _hovered = hovered; } 48 | 49 | private: 50 | // local object coordinates 51 | QPointF _in; 52 | QPointF _out; 53 | 54 | //int _animationPhase; 55 | 56 | double _lineWidth; 57 | 58 | bool _hovered; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/ConnectionGraphicsObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | class QGraphicsSceneMouseEvent; 8 | 9 | namespace QtNodes 10 | { 11 | 12 | class FlowScene; 13 | class Connection; 14 | class ConnectionGeometry; 15 | class Node; 16 | 17 | /// Graphic Object for connection. Adds itself to scene 18 | class ConnectionGraphicsObject 19 | : public QGraphicsObject 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | 25 | ConnectionGraphicsObject(FlowScene &scene, 26 | Connection &connection); 27 | 28 | virtual 29 | ~ConnectionGraphicsObject(); 30 | 31 | enum { Type = UserType + 2 }; 32 | int 33 | type() const override { return Type; } 34 | 35 | public: 36 | 37 | Connection& 38 | connection(); 39 | 40 | QRectF 41 | boundingRect() const override; 42 | 43 | QPainterPath 44 | shape() const override; 45 | 46 | void 47 | setGeometryChanged(); 48 | 49 | /// Updates the position of both ends 50 | void 51 | move(); 52 | 53 | void 54 | lock(bool locked); 55 | 56 | protected: 57 | 58 | void 59 | paint(QPainter* painter, 60 | QStyleOptionGraphicsItem const* option, 61 | QWidget* widget = 0) override; 62 | 63 | void 64 | mousePressEvent(QGraphicsSceneMouseEvent* event) override; 65 | 66 | void 67 | mouseMoveEvent(QGraphicsSceneMouseEvent* event) override; 68 | 69 | void 70 | mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override; 71 | 72 | void 73 | hoverEnterEvent(QGraphicsSceneHoverEvent* event) override; 74 | 75 | void 76 | hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override; 77 | 78 | private: 79 | 80 | void 81 | addGraphicsEffect(); 82 | 83 | private: 84 | 85 | FlowScene & _scene; 86 | 87 | Connection& _connection; 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/ConnectionState.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "PortType.hpp" 6 | 7 | class QPointF; 8 | 9 | namespace QtNodes 10 | { 11 | 12 | class Node; 13 | 14 | /// Stores currently draggind end. 15 | /// Remembers last hovered Node. 16 | class ConnectionState 17 | { 18 | public: 19 | 20 | ConnectionState(PortType port = PortType::None) 21 | : _requiredPort(port) 22 | {} 23 | 24 | ConnectionState(const ConnectionState&) = delete; 25 | ConnectionState operator=(const ConnectionState&) = delete; 26 | 27 | ~ConnectionState(); 28 | 29 | public: 30 | 31 | void setRequiredPort(PortType end) 32 | { _requiredPort = end; } 33 | 34 | PortType requiredPort() const 35 | { return _requiredPort; } 36 | 37 | bool requiresPort() const 38 | { return _requiredPort != PortType::None; } 39 | 40 | void setNoRequiredPort() 41 | { _requiredPort = PortType::None; } 42 | 43 | public: 44 | 45 | void interactWithNode(Node* node); 46 | 47 | void setLastHoveredNode(Node* node); 48 | 49 | Node* 50 | lastHoveredNode() const 51 | { return _lastHoveredNode; } 52 | 53 | void resetLastHoveredNode(); 54 | 55 | private: 56 | 57 | PortType _requiredPort; 58 | 59 | Node* _lastHoveredNode{nullptr}; 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/ConnectionStyle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Export.hpp" 6 | #include "Style.hpp" 7 | 8 | namespace QtNodes 9 | { 10 | 11 | class NODE_EDITOR_PUBLIC ConnectionStyle : public Style 12 | { 13 | public: 14 | 15 | ConnectionStyle(); 16 | 17 | ConnectionStyle(QString jsonText); 18 | 19 | public: 20 | 21 | static void setConnectionStyle(QString jsonText); 22 | 23 | private: 24 | 25 | void loadJsonText(QString jsonText) override; 26 | 27 | void loadJsonFile(QString fileName) override; 28 | 29 | void loadJsonFromByteArray(QByteArray const &byteArray) override; 30 | 31 | public: 32 | 33 | QColor constructionColor() const; 34 | QColor normalColor() const; 35 | QColor normalColor(QString typeId) const; 36 | QColor selectedColor() const; 37 | QColor selectedHaloColor() const; 38 | QColor hoveredColor() const; 39 | 40 | float lineWidth() const; 41 | float constructionLineWidth() const; 42 | float pointDiameter() const; 43 | 44 | bool useDataDefinedColors() const; 45 | 46 | private: 47 | 48 | QColor ConstructionColor; 49 | QColor NormalColor; 50 | QColor SelectedColor; 51 | QColor SelectedHaloColor; 52 | QColor HoveredColor; 53 | 54 | float LineWidth; 55 | float ConstructionLineWidth; 56 | float PointDiameter; 57 | 58 | bool UseDataDefinedColors; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/Export.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Compilation.hpp" 4 | #include "OperatingSystem.hpp" 5 | 6 | #ifdef NODE_EDITOR_PLATFORM_WINDOWS 7 | # define NODE_EDITOR_EXPORT __declspec(dllexport) 8 | # define NODE_EDITOR_IMPORT __declspec(dllimport) 9 | # define NODE_EDITOR_LOCAL 10 | #elif \ 11 | NODE_EDITOR_COMPILER_GNU_VERSION_MAJOR >= 4 || \ 12 | defined (NODE_EDITOR_COMPILER_CLANG) 13 | # define NODE_EDITOR_EXPORT __attribute__((visibility("default"))) 14 | # define NODE_EDITOR_IMPORT __attribute__((visibility("default"))) 15 | # define NODE_EDITOR_LOCAL __attribute__((visibility("hidden"))) 16 | #else 17 | # define NODE_EDITOR_EXPORT 18 | # define NODE_EDITOR_IMPORT 19 | # define NODE_EDITOR_LOCAL 20 | #endif 21 | 22 | #ifdef __cplusplus 23 | # define NODE_EDITOR_DEMANGLED extern "C" 24 | #else 25 | # define NODE_EDITOR_DEMANGLED 26 | #endif 27 | 28 | 29 | #if defined (NODE_EDITOR_SHARED) && !defined (NODE_EDITOR_STATIC) 30 | # ifdef NODE_EDITOR_EXPORTS 31 | # define NODE_EDITOR_PUBLIC NODE_EDITOR_EXPORT 32 | # else 33 | # define NODE_EDITOR_PUBLIC NODE_EDITOR_IMPORT 34 | # endif 35 | # define NODE_EDITOR_PRIVATE NODE_EDITOR_LOCAL 36 | #elif !defined (NODE_EDITOR_SHARED) && defined (NODE_EDITOR_STATIC) 37 | # define NODE_EDITOR_PUBLIC 38 | # define NODE_EDITOR_PRIVATE 39 | #elif defined (NODE_EDITOR_SHARED) && defined (NODE_EDITOR_STATIC) 40 | # ifdef NODE_EDITOR_EXPORTS 41 | # error "Cannot build as shared and static simultaneously." 42 | # else 43 | # error "Cannot link against shared and static simultaneously." 44 | # endif 45 | #else 46 | # ifdef NODE_EDITOR_EXPORTS 47 | # error "Choose whether to build as shared or static." 48 | # else 49 | # error "Choose whether to link against shared or static." 50 | # endif 51 | #endif 52 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/FlowView.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Export.hpp" 6 | 7 | namespace QtNodes 8 | { 9 | 10 | class FlowScene; 11 | 12 | class NODE_EDITOR_PUBLIC FlowView 13 | : public QGraphicsView 14 | { 15 | Q_OBJECT 16 | public: 17 | 18 | explicit FlowView(QWidget *parent = Q_NULLPTR); 19 | explicit FlowView(FlowScene *scene, QWidget *parent = Q_NULLPTR); 20 | 21 | FlowView(const FlowView&) = delete; 22 | 23 | QAction* clearSelectionAction() const; 24 | 25 | QAction* deleteSelectionAction() const; 26 | 27 | void setScene(FlowScene *scene); 28 | 29 | public Q_SLOTS: 30 | 31 | void scaleUp(); 32 | 33 | void scaleDown(); 34 | 35 | virtual void deleteSelectedNodes(); 36 | 37 | protected: 38 | 39 | virtual void contextMenuEvent(QContextMenuEvent *event) override; 40 | 41 | void wheelEvent(QWheelEvent *event) override; 42 | 43 | void keyPressEvent(QKeyEvent *event) override; 44 | 45 | void keyReleaseEvent(QKeyEvent *event) override; 46 | 47 | void mousePressEvent(QMouseEvent *event) override; 48 | 49 | void mouseMoveEvent(QMouseEvent *event) override; 50 | 51 | void drawBackground(QPainter* painter, const QRectF& r) override; 52 | 53 | void showEvent(QShowEvent *event) override; 54 | 55 | protected: 56 | 57 | FlowScene * scene(); 58 | 59 | private: 60 | 61 | QAction* _clearSelectionAction; 62 | QAction* _deleteSelectionAction; 63 | 64 | QPointF _clickPos; 65 | 66 | FlowScene* _scene; 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/FlowViewStyle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Export.hpp" 6 | #include "Style.hpp" 7 | 8 | namespace QtNodes 9 | { 10 | 11 | class NODE_EDITOR_PUBLIC FlowViewStyle : public Style 12 | { 13 | public: 14 | 15 | FlowViewStyle(); 16 | 17 | FlowViewStyle(QString jsonText); 18 | 19 | public: 20 | 21 | static void setStyle(QString jsonText); 22 | 23 | private: 24 | 25 | void loadJsonText(QString jsonText) override; 26 | 27 | void loadJsonFile(QString fileName) override; 28 | 29 | void loadJsonFromByteArray(QByteArray const &byteArray) override; 30 | 31 | public: 32 | 33 | QColor BackgroundColor; 34 | QColor FineGridColor; 35 | QColor CoarseGridColor; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/NodeData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Export.hpp" 6 | 7 | namespace QtNodes 8 | { 9 | 10 | struct NodeDataType 11 | { 12 | QString id; 13 | QString name; 14 | }; 15 | 16 | /// Class represents data transferred between nodes. 17 | /// @param type is used for comparing the types 18 | /// The actual data is stored in subtypes 19 | class NODE_EDITOR_PUBLIC NodeData 20 | { 21 | public: 22 | 23 | virtual ~NodeData() = default; 24 | 25 | virtual bool sameType(NodeData const &nodeData) const 26 | { 27 | return (this->type().id == nodeData.type().id); 28 | } 29 | 30 | /// Type for inner use 31 | virtual NodeDataType type() const = 0; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/NodeGraphicsObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Connection.hpp" 7 | 8 | #include "NodeGeometry.hpp" 9 | #include "NodeState.hpp" 10 | 11 | class QGraphicsProxyWidget; 12 | 13 | namespace QtNodes 14 | { 15 | 16 | class FlowScene; 17 | class FlowItemEntry; 18 | 19 | /// Class reacts on GUI events, mouse clicks and 20 | /// forwards painting operation. 21 | class NodeGraphicsObject : public QGraphicsObject 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | NodeGraphicsObject(FlowScene &scene, 27 | Node& node); 28 | 29 | virtual 30 | ~NodeGraphicsObject(); 31 | 32 | Node& 33 | node(); 34 | 35 | Node const& 36 | node() const; 37 | 38 | QRectF 39 | boundingRect() const override; 40 | 41 | void 42 | setGeometryChanged(); 43 | 44 | /// Visits all attached connections and corrects 45 | /// their corresponding end points. 46 | void 47 | moveConnections() const; 48 | 49 | enum { Type = UserType + 1 }; 50 | 51 | int 52 | type() const override { return Type; } 53 | 54 | void 55 | lock(bool locked); 56 | 57 | protected: 58 | void 59 | paint(QPainter* painter, 60 | QStyleOptionGraphicsItem const* option, 61 | QWidget* widget = 0) override; 62 | 63 | QVariant 64 | itemChange(GraphicsItemChange change, const QVariant &value) override; 65 | 66 | void 67 | mousePressEvent(QGraphicsSceneMouseEvent* event) override; 68 | 69 | void 70 | mouseMoveEvent(QGraphicsSceneMouseEvent* event) override; 71 | 72 | void 73 | mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override; 74 | 75 | void 76 | hoverEnterEvent(QGraphicsSceneHoverEvent* event) override; 77 | 78 | void 79 | hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override; 80 | 81 | void 82 | hoverMoveEvent(QGraphicsSceneHoverEvent *) override; 83 | 84 | void 85 | mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override; 86 | 87 | void 88 | contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override; 89 | 90 | private: 91 | void 92 | embedQWidget(); 93 | 94 | private: 95 | 96 | FlowScene & _scene; 97 | 98 | Node& _node; 99 | 100 | bool _locked; 101 | 102 | // either nullptr or owned by parent QGraphicsItem 103 | QGraphicsProxyWidget * _proxyWidget; 104 | }; 105 | } 106 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/NodePainterDelegate.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "NodeGeometry.hpp" 6 | #include "NodeDataModel.hpp" 7 | #include "Export.hpp" 8 | 9 | namespace QtNodes { 10 | 11 | /// Class to allow for custom painting 12 | class NODE_EDITOR_PUBLIC NodePainterDelegate 13 | { 14 | 15 | public: 16 | 17 | virtual 18 | ~NodePainterDelegate() = default; 19 | 20 | virtual void 21 | paint(QPainter* painter, 22 | NodeGeometry const& geom, 23 | NodeDataModel const * model) = 0; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/NodeState.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "Export.hpp" 9 | 10 | #include "PortType.hpp" 11 | #include "NodeData.hpp" 12 | #include "memory.hpp" 13 | 14 | namespace QtNodes 15 | { 16 | 17 | class Connection; 18 | class NodeDataModel; 19 | 20 | /// Contains vectors of connected input and output connections. 21 | /// Stores bool for reacting on hovering connections 22 | class NODE_EDITOR_PUBLIC NodeState 23 | { 24 | public: 25 | enum ReactToConnectionState 26 | { 27 | REACTING, 28 | NOT_REACTING 29 | }; 30 | 31 | public: 32 | 33 | NodeState(std::unique_ptr const &model); 34 | 35 | public: 36 | 37 | using ConnectionPtrSet = 38 | std::unordered_map; 39 | 40 | /// Returns vector of connections ID. 41 | /// Some of them can be empty (null) 42 | std::vector const& 43 | getEntries(PortType) const; 44 | 45 | std::vector & 46 | getEntries(PortType); 47 | 48 | ConnectionPtrSet 49 | connections(PortType portType, PortIndex portIndex) const; 50 | 51 | void 52 | setConnection(PortType portType, 53 | PortIndex portIndex, 54 | Connection& connection); 55 | 56 | void 57 | eraseConnection(PortType portType, 58 | PortIndex portIndex, 59 | QUuid id); 60 | 61 | ReactToConnectionState 62 | reaction() const; 63 | 64 | PortType 65 | reactingPortType() const; 66 | 67 | NodeDataType 68 | reactingDataType() const; 69 | 70 | void 71 | setReaction(ReactToConnectionState reaction, 72 | PortType reactingPortType = PortType::None, 73 | 74 | NodeDataType reactingDataType = 75 | NodeDataType()); 76 | 77 | bool 78 | isReacting() const; 79 | 80 | void 81 | setResizing(bool resizing); 82 | 83 | bool 84 | resizing() const; 85 | 86 | private: 87 | 88 | std::vector _inConnections; 89 | std::vector _outConnections; 90 | 91 | ReactToConnectionState _reaction; 92 | PortType _reactingPortType; 93 | NodeDataType _reactingDataType; 94 | 95 | bool _resizing; 96 | }; 97 | } 98 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/NodeStyle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Export.hpp" 6 | #include "Style.hpp" 7 | 8 | namespace QtNodes 9 | { 10 | 11 | class NODE_EDITOR_PUBLIC NodeStyle : public Style 12 | { 13 | public: 14 | 15 | NodeStyle(); 16 | 17 | NodeStyle(QString jsonText); 18 | 19 | public: 20 | 21 | static void setNodeStyle(QString jsonText); 22 | 23 | private: 24 | 25 | void loadJsonText(QString jsonText) override; 26 | 27 | void loadJsonFile(QString fileName) override; 28 | 29 | void loadJsonFromByteArray(QByteArray const &byteArray) override; 30 | 31 | public: 32 | 33 | QColor NormalBoundaryColor; 34 | QColor SelectedBoundaryColor; 35 | QColor GradientColor0; 36 | QColor GradientColor1; 37 | QColor GradientColor2; 38 | QColor GradientColor3; 39 | QColor ShadowColor; 40 | QColor FontColor; 41 | QColor FontColorFaded; 42 | 43 | QColor ConnectionPointColor; 44 | QColor FilledConnectionPointColor; 45 | 46 | QColor WarningColor; 47 | QColor ErrorColor; 48 | 49 | float PenWidth; 50 | float HoveredPenWidth; 51 | 52 | float ConnectionPointDiameter; 53 | 54 | float Opacity; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/PortType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace QtNodes 7 | { 8 | 9 | enum class PortType 10 | { 11 | None, 12 | In, 13 | Out 14 | }; 15 | 16 | static const int INVALID = -1; 17 | 18 | using PortIndex = int; 19 | 20 | struct Port 21 | { 22 | PortType type; 23 | 24 | PortIndex index; 25 | 26 | Port() 27 | : type(PortType::None) 28 | , index(INVALID) 29 | {} 30 | 31 | Port(PortType t, PortIndex i) 32 | : type(t) 33 | , index(i) 34 | {} 35 | 36 | bool 37 | indexIsValid() { return index != INVALID; } 38 | 39 | bool 40 | portTypeIsValid() { return type != PortType::None; } 41 | }; 42 | 43 | //using PortAddress = std::pair; 44 | 45 | inline 46 | PortType 47 | oppositePort(PortType port) 48 | { 49 | PortType result = PortType::None; 50 | 51 | switch (port) 52 | { 53 | case PortType::In: 54 | result = PortType::Out; 55 | break; 56 | 57 | case PortType::Out: 58 | result = PortType::In; 59 | break; 60 | 61 | default: 62 | break; 63 | } 64 | 65 | return result; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/QStringStdHash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace std 9 | { 10 | template<> 11 | struct hash 12 | { 13 | inline std::size_t 14 | operator()(QString const &s) const 15 | { 16 | return qHash(s); 17 | } 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/QUuidStdHash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace std 9 | { 10 | template<> 11 | struct hash 12 | { 13 | inline 14 | std::size_t 15 | operator()(QUuid const& uid) const 16 | { 17 | return qHash(uid); 18 | } 19 | }; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/Serializable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace QtNodes 6 | { 7 | 8 | class Serializable 9 | { 10 | public: 11 | 12 | virtual 13 | ~Serializable() = default; 14 | 15 | virtual 16 | QJsonObject 17 | save() const = 0; 18 | 19 | virtual void 20 | restore(QJsonObject const & /*p*/) {} 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/Style.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Style 6 | { 7 | public: 8 | 9 | virtual 10 | ~Style() = default; 11 | 12 | private: 13 | 14 | virtual void 15 | loadJsonText(QString jsonText) = 0; 16 | 17 | virtual void 18 | loadJsonFile(QString fileName) = 0; 19 | 20 | virtual void 21 | loadJsonFromByteArray(QByteArray const &byteArray) = 0; 22 | }; 23 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/TypeConverter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NodeData.hpp" 4 | #include "memory.hpp" 5 | 6 | #include 7 | 8 | namespace QtNodes 9 | { 10 | 11 | using SharedNodeData = std::shared_ptr; 12 | 13 | // a function taking in NodeData and returning NodeData 14 | using TypeConverter = 15 | std::function; 16 | 17 | // data-type-in, data-type-out 18 | using TypeConverterId = 19 | std::pair; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /external/nodeeditor/include/nodes/internal/memory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace QtNodes 7 | { 8 | namespace detail { 9 | #if (!defined(_MSC_VER) && (__cplusplus < 201300)) || \ 10 | ( defined(_MSC_VER) && (_MSC_VER < 1800)) 11 | //_MSC_VER == 1800 is Visual Studio 2013, which is already somewhat C++14 compilant, 12 | // and it has make_unique in it's standard library implementation 13 | template 14 | std::unique_ptr make_unique(Args&&... args) 15 | { 16 | return std::unique_ptr(new T(std::forward(args)...)); 17 | } 18 | #else 19 | template 20 | std::unique_ptr make_unique(Args&&... args) 21 | { 22 | return std::make_unique(std::forward(args)...); 23 | } 24 | #endif 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /external/nodeeditor/pictures/calculator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/pictures/calculator.png -------------------------------------------------------------------------------- /external/nodeeditor/pictures/chigraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/pictures/chigraph.png -------------------------------------------------------------------------------- /external/nodeeditor/pictures/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/pictures/flow.png -------------------------------------------------------------------------------- /external/nodeeditor/pictures/spkgen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/pictures/spkgen.png -------------------------------------------------------------------------------- /external/nodeeditor/pictures/style_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/pictures/style_example.png -------------------------------------------------------------------------------- /external/nodeeditor/pictures/vid1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/pictures/vid1.png -------------------------------------------------------------------------------- /external/nodeeditor/resources/DefaultStyle.json: -------------------------------------------------------------------------------- 1 | { 2 | "FlowViewStyle": { 3 | "BackgroundColor": [53, 53, 53], 4 | "FineGridColor": [60, 60, 60], 5 | "CoarseGridColor": [25, 25, 25] 6 | }, 7 | "NodeStyle": { 8 | "NormalBoundaryColor": [255, 255, 255], 9 | "SelectedBoundaryColor": [255, 165, 0], 10 | "GradientColor0": "gray", 11 | "GradientColor1": [80, 80, 80], 12 | "GradientColor2": [64, 64, 64], 13 | "GradientColor3": [58, 58, 58], 14 | "ShadowColor": [20, 20, 20], 15 | "FontColor" : "white", 16 | "FontColorFaded" : "gray", 17 | "ConnectionPointColor": [169, 169, 169], 18 | "FilledConnectionPointColor": "cyan", 19 | "ErrorColor": "red", 20 | "WarningColor": [128, 128, 0], 21 | 22 | "PenWidth": 1.0, 23 | "HoveredPenWidth": 1.5, 24 | 25 | "ConnectionPointDiameter": 8.0, 26 | 27 | "Opacity": 0.8 28 | }, 29 | "ConnectionStyle": { 30 | "ConstructionColor": "gray", 31 | "NormalColor": "darkcyan", 32 | "SelectedColor": [100, 100, 100], 33 | "SelectedHaloColor": "orange", 34 | "HoveredColor": "lightcyan", 35 | 36 | "LineWidth": 3.0, 37 | "ConstructionLineWidth": 2.0, 38 | "PointDiameter": 10.0, 39 | 40 | "UseDataDefinedColors": false 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /external/nodeeditor/resources/convert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/external/nodeeditor/resources/convert.png -------------------------------------------------------------------------------- /external/nodeeditor/resources/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | DefaultStyle.json 4 | convert.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /external/nodeeditor/src/ConnectionBlurEffect.cpp: -------------------------------------------------------------------------------- 1 | #include "ConnectionBlurEffect.hpp" 2 | 3 | #include "ConnectionGraphicsObject.hpp" 4 | #include "ConnectionPainter.hpp" 5 | 6 | using QtNodes::ConnectionBlurEffect; 7 | using QtNodes::ConnectionGraphicsObject; 8 | 9 | ConnectionBlurEffect:: 10 | ConnectionBlurEffect(ConnectionGraphicsObject*) 11 | { 12 | // 13 | } 14 | 15 | 16 | void 17 | ConnectionBlurEffect:: 18 | draw(QPainter* painter) 19 | { 20 | QGraphicsBlurEffect::draw(painter); 21 | 22 | //ConnectionPainter::paint(painter, 23 | //_object->connectionGeometry(), 24 | //_object->connectionState()); 25 | 26 | //_item->paint(painter, nullptr, nullptr); 27 | } 28 | -------------------------------------------------------------------------------- /external/nodeeditor/src/ConnectionBlurEffect.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace QtNodes 6 | { 7 | 8 | class ConnectionGraphicsObject; 9 | 10 | class ConnectionBlurEffect : public QGraphicsBlurEffect 11 | { 12 | 13 | public: 14 | 15 | ConnectionBlurEffect(ConnectionGraphicsObject* item); 16 | 17 | void 18 | draw(QPainter* painter) override; 19 | 20 | private: 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /external/nodeeditor/src/ConnectionPainter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace QtNodes 6 | { 7 | 8 | class ConnectionGeometry; 9 | class ConnectionState; 10 | class Connection; 11 | 12 | class ConnectionPainter 13 | { 14 | public: 15 | 16 | static 17 | void 18 | paint(QPainter* painter, 19 | Connection const& connection); 20 | 21 | static 22 | QPainterPath 23 | getPainterStroke(ConnectionGeometry const& geom); 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /external/nodeeditor/src/ConnectionState.cpp: -------------------------------------------------------------------------------- 1 | #include "ConnectionState.hpp" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "FlowScene.hpp" 8 | #include "Node.hpp" 9 | 10 | using QtNodes::ConnectionState; 11 | using QtNodes::Node; 12 | 13 | ConnectionState:: 14 | ~ConnectionState() 15 | { 16 | resetLastHoveredNode(); 17 | } 18 | 19 | 20 | void 21 | ConnectionState:: 22 | interactWithNode(Node* node) 23 | { 24 | if (node) 25 | { 26 | _lastHoveredNode = node; 27 | } 28 | else 29 | { 30 | resetLastHoveredNode(); 31 | } 32 | } 33 | 34 | 35 | void 36 | ConnectionState:: 37 | setLastHoveredNode(Node* node) 38 | { 39 | _lastHoveredNode = node; 40 | } 41 | 42 | 43 | void 44 | ConnectionState:: 45 | resetLastHoveredNode() 46 | { 47 | if (_lastHoveredNode) 48 | _lastHoveredNode->resetReactionToConnection(); 49 | 50 | _lastHoveredNode = nullptr; 51 | } 52 | -------------------------------------------------------------------------------- /external/nodeeditor/src/DataModelRegistry.cpp: -------------------------------------------------------------------------------- 1 | #include "DataModelRegistry.hpp" 2 | 3 | #include 4 | #include 5 | 6 | using QtNodes::DataModelRegistry; 7 | using QtNodes::NodeDataModel; 8 | using QtNodes::NodeDataType; 9 | using QtNodes::TypeConverter; 10 | 11 | std::unique_ptr 12 | DataModelRegistry:: 13 | create(QString const &modelName) 14 | { 15 | auto it = _registeredItemCreators.find(modelName); 16 | 17 | if (it != _registeredItemCreators.end()) 18 | { 19 | return it->second(); 20 | } 21 | 22 | return nullptr; 23 | } 24 | 25 | 26 | DataModelRegistry::RegisteredModelCreatorsMap const & 27 | DataModelRegistry:: 28 | registeredModelCreators() const 29 | { 30 | return _registeredItemCreators; 31 | } 32 | 33 | 34 | DataModelRegistry::RegisteredModelsCategoryMap const & 35 | DataModelRegistry:: 36 | registeredModelsCategoryAssociation() const 37 | { 38 | return _registeredModelsCategory; 39 | } 40 | 41 | 42 | DataModelRegistry::CategoriesSet const & 43 | DataModelRegistry:: 44 | categories() const 45 | { 46 | return _categories; 47 | } 48 | 49 | 50 | TypeConverter 51 | DataModelRegistry:: 52 | getTypeConverter(NodeDataType const & d1, 53 | NodeDataType const & d2) const 54 | { 55 | TypeConverterId converterId = std::make_pair(d1, d2); 56 | 57 | auto it = _registeredTypeConverters.find(converterId); 58 | 59 | if (it != _registeredTypeConverters.end()) 60 | { 61 | return it->second; 62 | } 63 | 64 | return TypeConverter{}; 65 | } 66 | -------------------------------------------------------------------------------- /external/nodeeditor/src/NodeConnectionInteraction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node.hpp" 4 | #include "Connection.hpp" 5 | 6 | namespace QtNodes 7 | { 8 | 9 | class DataModelRegistry; 10 | class FlowScene; 11 | class NodeDataModel; 12 | 13 | /// Class performs various operations on the Node and Connection pair. 14 | /// An instance should be created on the stack and destroyed when 15 | /// the operation is completed 16 | class NodeConnectionInteraction 17 | { 18 | public: 19 | NodeConnectionInteraction(Node& node, 20 | Connection& connection, 21 | FlowScene& scene); 22 | 23 | /// Can connect when following conditions are met: 24 | /// 1) Connection 'requires' a port 25 | /// 2) Connection's vacant end is above the node port 26 | /// 3) Node port is vacant 27 | /// 4) Connection type equals node port type, or there is a registered type conversion that can translate between the two 28 | bool canConnect(PortIndex & portIndex, 29 | TypeConverter & converter) const; 30 | 31 | /// 1) Check conditions from 'canConnect' 32 | /// 1.5) If the connection is possible but a type conversion is needed, add a converter node to the scene, and connect it properly 33 | /// 2) Assign node to required port in Connection 34 | /// 3) Assign Connection to empty port in NodeState 35 | /// 4) Adjust Connection geometry 36 | /// 5) Poke model to initiate data transfer 37 | bool tryConnect() const; 38 | 39 | 40 | /// 1) Node and Connection should be already connected 41 | /// 2) If so, clear Connection entry in the NodeState 42 | /// 3) Propagate invalid data to IN node 43 | /// 4) Set Connection end to 'requiring a port' 44 | bool disconnect(PortType portToDisconnect) const; 45 | 46 | private: 47 | 48 | PortType connectionRequiredPort() const; 49 | 50 | QPointF connectionEndScenePosition(PortType) const; 51 | 52 | QPointF nodePortScenePosition(PortType portType, 53 | PortIndex portIndex) const; 54 | 55 | PortIndex nodePortIndexUnderScenePoint(PortType portType, 56 | QPointF const &p) const; 57 | 58 | bool nodePortIsEmpty(PortType portType, PortIndex portIndex) const; 59 | 60 | private: 61 | 62 | Node* _node; 63 | 64 | Connection* _connection; 65 | 66 | FlowScene* _scene; 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /external/nodeeditor/src/NodeDataModel.cpp: -------------------------------------------------------------------------------- 1 | #include "NodeDataModel.hpp" 2 | 3 | #include "StyleCollection.hpp" 4 | 5 | using QtNodes::NodeDataModel; 6 | using QtNodes::NodeStyle; 7 | 8 | NodeDataModel:: 9 | NodeDataModel() 10 | : _nodeStyle(StyleCollection::nodeStyle()) 11 | { 12 | // Derived classes can initialize specific style here 13 | } 14 | 15 | 16 | QJsonObject 17 | NodeDataModel:: 18 | save() const 19 | { 20 | QJsonObject modelJson; 21 | 22 | modelJson["name"] = name(); 23 | 24 | return modelJson; 25 | } 26 | 27 | 28 | NodeStyle const& 29 | NodeDataModel:: 30 | nodeStyle() const 31 | { 32 | return _nodeStyle; 33 | } 34 | 35 | 36 | void 37 | NodeDataModel:: 38 | setNodeStyle(NodeStyle const& style) 39 | { 40 | _nodeStyle = style; 41 | } 42 | -------------------------------------------------------------------------------- /external/nodeeditor/src/NodePainter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace QtNodes 6 | { 7 | 8 | class Node; 9 | class NodeState; 10 | class NodeGeometry; 11 | class NodeGraphicsObject; 12 | class NodeDataModel; 13 | class FlowItemEntry; 14 | class FlowScene; 15 | 16 | class NodePainter 17 | { 18 | public: 19 | 20 | NodePainter(); 21 | 22 | public: 23 | 24 | static 25 | void 26 | paint(QPainter* painter, 27 | Node& node, 28 | FlowScene const& scene); 29 | 30 | static 31 | void 32 | drawNodeRect(QPainter* painter, 33 | NodeGeometry const& geom, 34 | NodeDataModel const* model, 35 | NodeGraphicsObject const & graphicsObject); 36 | 37 | static 38 | void 39 | drawModelName(QPainter* painter, 40 | NodeGeometry const& geom, 41 | NodeState const& state, 42 | NodeDataModel const * model); 43 | 44 | static 45 | void 46 | drawEntryLabels(QPainter* painter, 47 | NodeGeometry const& geom, 48 | NodeState const& state, 49 | NodeDataModel const * model); 50 | 51 | static 52 | void 53 | drawConnectionPoints(QPainter* painter, 54 | NodeGeometry const& geom, 55 | NodeState const& state, 56 | NodeDataModel const * model, 57 | FlowScene const & scene); 58 | 59 | static 60 | void 61 | drawFilledConnectionPoints(QPainter* painter, 62 | NodeGeometry const& geom, 63 | NodeState const& state, 64 | NodeDataModel const * model); 65 | 66 | static 67 | void 68 | drawResizeRect(QPainter* painter, 69 | NodeGeometry const& geom, 70 | NodeDataModel const * model); 71 | 72 | static 73 | void 74 | drawValidationRect(QPainter * painter, 75 | NodeGeometry const & geom, 76 | NodeDataModel const * model, 77 | NodeGraphicsObject const & graphicsObject); 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /external/nodeeditor/src/Properties.cpp: -------------------------------------------------------------------------------- 1 | #include "Properties.hpp" 2 | 3 | using QtNodes::Properties; 4 | 5 | void 6 | Properties:: 7 | put(QString const &name, QVariant const &v) 8 | { 9 | _values.insert(name, v); 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /external/nodeeditor/src/Properties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "Export.hpp" 8 | 9 | namespace QtNodes 10 | { 11 | 12 | class NODE_EDITOR_PUBLIC Properties 13 | { 14 | public: 15 | 16 | void 17 | put(QString const &name, QVariant const &v); 18 | 19 | template 20 | bool 21 | get(QString name, T* v) const 22 | { 23 | QVariant const &var = _values[name]; 24 | 25 | if (var.canConvert()) 26 | { 27 | *v = _values[name].value(); 28 | 29 | return true; 30 | } 31 | 32 | return false; 33 | } 34 | 35 | QVariantMap const & 36 | values() const 37 | { return _values; } 38 | 39 | QVariantMap & 40 | values() 41 | { return _values; } 42 | 43 | private: 44 | 45 | QVariantMap _values; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /external/nodeeditor/src/StyleCollection.cpp: -------------------------------------------------------------------------------- 1 | #include "StyleCollection.hpp" 2 | 3 | using QtNodes::StyleCollection; 4 | using QtNodes::NodeStyle; 5 | using QtNodes::ConnectionStyle; 6 | using QtNodes::FlowViewStyle; 7 | 8 | NodeStyle const& 9 | StyleCollection:: 10 | nodeStyle() 11 | { 12 | return instance()._nodeStyle; 13 | } 14 | 15 | 16 | ConnectionStyle const& 17 | StyleCollection:: 18 | connectionStyle() 19 | { 20 | return instance()._connectionStyle; 21 | } 22 | 23 | 24 | FlowViewStyle const& 25 | StyleCollection:: 26 | flowViewStyle() 27 | { 28 | return instance()._flowViewStyle; 29 | } 30 | 31 | 32 | void 33 | StyleCollection:: 34 | setNodeStyle(NodeStyle nodeStyle) 35 | { 36 | instance()._nodeStyle = nodeStyle; 37 | } 38 | 39 | 40 | void 41 | StyleCollection:: 42 | setConnectionStyle(ConnectionStyle connectionStyle) 43 | { 44 | instance()._connectionStyle = connectionStyle; 45 | } 46 | 47 | 48 | void 49 | StyleCollection:: 50 | setFlowViewStyle(FlowViewStyle flowViewStyle) 51 | { 52 | instance()._flowViewStyle = flowViewStyle; 53 | } 54 | 55 | 56 | 57 | StyleCollection& 58 | StyleCollection:: 59 | instance() 60 | { 61 | static StyleCollection collection; 62 | 63 | return collection; 64 | } 65 | -------------------------------------------------------------------------------- /external/nodeeditor/src/StyleCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NodeStyle.hpp" 4 | #include "ConnectionStyle.hpp" 5 | #include "FlowViewStyle.hpp" 6 | 7 | namespace QtNodes 8 | { 9 | 10 | class StyleCollection 11 | { 12 | public: 13 | 14 | static 15 | NodeStyle const& 16 | nodeStyle(); 17 | 18 | static 19 | ConnectionStyle const& 20 | connectionStyle(); 21 | 22 | static 23 | FlowViewStyle const& 24 | flowViewStyle(); 25 | 26 | public: 27 | 28 | static 29 | void 30 | setNodeStyle(NodeStyle); 31 | 32 | static 33 | void 34 | setConnectionStyle(ConnectionStyle); 35 | 36 | static 37 | void 38 | setFlowViewStyle(FlowViewStyle); 39 | 40 | private: 41 | 42 | StyleCollection() = default; 43 | 44 | StyleCollection(StyleCollection const&) = delete; 45 | 46 | StyleCollection& 47 | operator=(StyleCollection const&) = delete; 48 | 49 | static 50 | StyleCollection& 51 | instance(); 52 | 53 | private: 54 | 55 | NodeStyle _nodeStyle; 56 | 57 | ConnectionStyle _connectionStyle; 58 | 59 | FlowViewStyle _flowViewStyle; 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /external/nodeeditor/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Catch2 2.3.0 REQUIRED) 2 | find_package(Qt5 COMPONENTS Test) 3 | 4 | add_executable(test_nodes 5 | test_main.cpp 6 | src/TestDragging.cpp 7 | src/TestDataModelRegistry.cpp 8 | src/TestNodeGraphicsObject.cpp 9 | src/TestFlowScene.cpp 10 | ) 11 | 12 | target_include_directories(test_nodes 13 | PRIVATE 14 | ../src 15 | ../include/internal 16 | include 17 | ) 18 | 19 | target_link_libraries(test_nodes 20 | PRIVATE 21 | NodeEditor::nodes 22 | Catch2::Catch2 23 | Qt5::Test 24 | ) 25 | 26 | add_test( 27 | NAME test_nodes 28 | COMMAND 29 | $ 30 | $<$:--use-colour=yes> 31 | ) 32 | -------------------------------------------------------------------------------- /external/nodeeditor/test/include/ApplicationSetup.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | inline std::unique_ptr 9 | applicationSetup() 10 | { 11 | static int Argc = 0; 12 | static char ArgvVal = '\0'; 13 | static char* ArgvValPtr = &ArgvVal; 14 | static char** Argv = &ArgvValPtr; 15 | 16 | auto app = std::make_unique(Argc, Argv); 17 | app->setAttribute(Qt::AA_Use96Dpi, true); 18 | 19 | return app; 20 | } 21 | -------------------------------------------------------------------------------- /external/nodeeditor/test/include/Stringify.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace Catch 11 | { 12 | template <> 13 | struct StringMaker 14 | { 15 | static std::string 16 | convert(QPointF const& p) 17 | { 18 | return std::string(QTest::toString(p)); 19 | } 20 | }; 21 | 22 | template <> 23 | struct StringMaker 24 | { 25 | static std::string 26 | convert(QPoint const& p) 27 | { 28 | return std::string(QTest::toString(p)); 29 | } 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /external/nodeeditor/test/include/StubNodeDataModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | class StubNodeDataModel : public QtNodes::NodeDataModel 8 | { 9 | public: 10 | QString 11 | name() const override 12 | { 13 | return _name; 14 | } 15 | 16 | QString 17 | caption() const override 18 | { 19 | return _caption; 20 | } 21 | 22 | unsigned int nPorts(QtNodes::PortType) const override { return 0; } 23 | 24 | QWidget* 25 | embeddedWidget() override 26 | { 27 | return nullptr; 28 | } 29 | 30 | QtNodes::NodeDataType dataType(QtNodes::PortType, QtNodes::PortIndex) const override 31 | { 32 | return QtNodes::NodeDataType(); 33 | } 34 | 35 | std::shared_ptr outData(QtNodes::PortIndex) override 36 | { 37 | return nullptr; 38 | } 39 | 40 | void setInData(std::shared_ptr, QtNodes::PortIndex) override 41 | { 42 | } 43 | 44 | void 45 | name(QString name) 46 | { 47 | _name = std::move(name); 48 | } 49 | 50 | void 51 | caption(QString caption) 52 | { 53 | _caption = std::move(caption); 54 | } 55 | 56 | private: 57 | QString _name = "name"; 58 | QString _caption = "caption"; 59 | }; 60 | -------------------------------------------------------------------------------- /external/nodeeditor/test/src/TestDataModelRegistry.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "StubNodeDataModel.hpp" 6 | 7 | using QtNodes::DataModelRegistry; 8 | using QtNodes::NodeData; 9 | using QtNodes::NodeDataModel; 10 | using QtNodes::NodeDataType; 11 | using QtNodes::PortIndex; 12 | using QtNodes::PortType; 13 | 14 | namespace 15 | { 16 | class StubModelStaticName : public StubNodeDataModel 17 | { 18 | public: 19 | static QString 20 | Name() 21 | { 22 | return "Name"; 23 | } 24 | }; 25 | } 26 | 27 | TEST_CASE("DataModelRegistry::registerModel", "[interface]") 28 | { 29 | DataModelRegistry registry; 30 | 31 | SECTION("stub model") 32 | { 33 | registry.registerModel(); 34 | auto model = registry.create("name"); 35 | 36 | CHECK(model->name() == "name"); 37 | } 38 | SECTION("stub model with static name") 39 | { 40 | registry.registerModel(); 41 | auto model = registry.create("Name"); 42 | 43 | CHECK(model->name() == "name"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /external/nodeeditor/test/src/TestDragging.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "ApplicationSetup.hpp" 12 | #include "Stringify.hpp" 13 | #include "StubNodeDataModel.hpp" 14 | 15 | using QtNodes::Connection; 16 | using QtNodes::DataModelRegistry; 17 | using QtNodes::FlowScene; 18 | using QtNodes::FlowView; 19 | using QtNodes::Node; 20 | using QtNodes::NodeData; 21 | using QtNodes::NodeDataModel; 22 | using QtNodes::NodeDataType; 23 | using QtNodes::PortIndex; 24 | using QtNodes::PortType; 25 | 26 | TEST_CASE("Dragging node changes position", "[gui]") 27 | { 28 | auto app = applicationSetup(); 29 | 30 | FlowScene scene; 31 | FlowView view(&scene); 32 | 33 | view.show(); 34 | REQUIRE(QTest::qWaitForWindowExposed(&view)); 35 | 36 | SECTION("just one node") 37 | { 38 | auto& node = scene.createNode(std::make_unique()); 39 | 40 | auto& ngo = node.nodeGraphicsObject(); 41 | 42 | QPointF scPosBefore = ngo.pos(); 43 | 44 | QPointF scClickPos = ngo.boundingRect().center(); 45 | scClickPos = QPointF(ngo.sceneTransform().map(scClickPos).toPoint()); 46 | 47 | QPoint vwClickPos = view.mapFromScene(scClickPos); 48 | QPoint vwDestPos = vwClickPos + QPoint(10, 20); 49 | 50 | QPointF scExpectedDelta = view.mapToScene(vwDestPos) - scClickPos; 51 | 52 | CAPTURE(scClickPos); 53 | CAPTURE(vwClickPos); 54 | CAPTURE(vwDestPos); 55 | CAPTURE(scExpectedDelta); 56 | 57 | QTest::mouseMove(view.windowHandle(), vwClickPos); 58 | QTest::mousePress(view.windowHandle(), Qt::LeftButton, Qt::NoModifier, vwClickPos); 59 | QTest::mouseMove(view.windowHandle(), vwDestPos); 60 | QTest::mouseRelease(view.windowHandle(), Qt::LeftButton, Qt::NoModifier, vwDestPos); 61 | 62 | QPointF scDelta = ngo.pos() - scPosBefore; 63 | QPoint roundDelta = scDelta.toPoint(); 64 | QPoint roundExpectedDelta = scExpectedDelta.toPoint(); 65 | 66 | CHECK(roundDelta == roundExpectedDelta); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /external/nodeeditor/test/src/TestNodeGraphicsObject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "ApplicationSetup.hpp" 11 | #include "StubNodeDataModel.hpp" 12 | 13 | using QtNodes::FlowScene; 14 | using QtNodes::FlowView; 15 | using QtNodes::Node; 16 | using QtNodes::NodeDataModel; 17 | using QtNodes::NodeGraphicsObject; 18 | using QtNodes::PortType; 19 | 20 | TEST_CASE("NodeDataModel::portOutConnectionPolicy(...) isn't called for input " 21 | "connections (issue #127)", 22 | "[gui]") 23 | { 24 | class MockModel : public StubNodeDataModel 25 | { 26 | public: 27 | unsigned int nPorts(PortType) const override { return 1; } 28 | 29 | NodeDataModel::ConnectionPolicy 30 | portOutConnectionPolicy(int index) const override 31 | { 32 | portOutConnectionPolicyCalledCount++; 33 | return NodeDataModel::ConnectionPolicy::One; 34 | } 35 | 36 | mutable int portOutConnectionPolicyCalledCount = 0; 37 | }; 38 | 39 | auto setup = applicationSetup(); 40 | 41 | FlowScene scene; 42 | FlowView view(&scene); 43 | 44 | // Ensure we have enough size to contain the node 45 | view.resize(640, 480); 46 | 47 | view.show(); 48 | REQUIRE(QTest::qWaitForWindowExposed(&view)); 49 | 50 | auto& node = scene.createNode(std::make_unique()); 51 | auto& model = dynamic_cast(*node.nodeDataModel()); 52 | auto& ngo = node.nodeGraphicsObject(); 53 | auto& ngeom = node.nodeGeometry(); 54 | 55 | // Move the node to somewhere in the middle of the screen 56 | ngo.setPos(QPointF(50, 50)); 57 | 58 | // Compute the on-screen position of the input port 59 | QPointF scInPortPos = ngeom.portScenePosition(0, PortType::In, ngo.sceneTransform()); 60 | QPoint vwInPortPos = view.mapFromScene(scInPortPos); 61 | 62 | // Create a partial connection by clicking on the input port of the node 63 | QTest::mousePress(view.windowHandle(), Qt::LeftButton, Qt::NoModifier, vwInPortPos); 64 | 65 | CHECK(model.portOutConnectionPolicyCalledCount == 0); 66 | } 67 | -------------------------------------------------------------------------------- /external/nodeeditor/test/test_main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include 3 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Kracejic 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /misc/cleanCppProject.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "file_exclude_patterns":[ 6 | "*swp" 7 | ], 8 | "folder_exclude_patterns": 9 | [ 10 | "build*" 11 | ], 12 | "path": "." 13 | } 14 | ], 15 | "build_systems": 16 | [ 17 | { 18 | "name": "build", 19 | "working_dir": "${project_path}/build", 20 | "file_regex": "^([\\/\\.^\\s^\\[]..*?):([0-9]+):([0-9]+):(.*)", 21 | "shell": true, 22 | "cmd":["cmake --build ."], 23 | // "syntax": "Packages/cppinabox/C++build.sublime-syntax", 24 | "windows":{"shell_cmd":"c:/runLinux32.bat cmake --build ."}, 25 | "variants": [ 26 | { 27 | "name":"install", 28 | "cmd":["cmake --build . --target install"], 29 | "windows":{"shell_cmd":"c:/runLinux32.bat cmake --build . --target install"}, 30 | }, 31 | { 32 | "name":"doc", 33 | "cmd":["cmake --build . --target doc"], 34 | "windows":{"shell_cmd":"c:/runLinux32.bat cmake --build . --target doc"}, 35 | }, 36 | { 37 | "name":"check", 38 | "cmd":["cmake --build . --target check"], 39 | "windows":{"shell_cmd":"c:/runLinux32.bat cmake --build . --target check"}, 40 | }, 41 | { 42 | "name":"clean", 43 | "cmd":["cmake --build . --target clean"], 44 | "windows":{"shell_cmd":"c:/runLinux32.bat cmake --build . --target clean"}, 45 | }, 46 | { 47 | "name":"run", 48 | "cmd":["cmake --build . --target run"], 49 | "windows":{"shell_cmd":"c:/runLinux32.bat cmake --build . --target run"}, 50 | }, 51 | 52 | ] 53 | }, 54 | 55 | ] 56 | } -------------------------------------------------------------------------------- /packaging/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/packaging/.DS_Store -------------------------------------------------------------------------------- /packaging/MacOSXBundleInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | ${MACOSX_BUNDLE_INFO_STRING} 11 | CFBundleIconFile 12 | ${MACOSX_BUNDLE_ICON_FILE} 13 | CFBundleIdentifier 14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleLongVersionString 18 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 19 | CFBundleName 20 | ${MACOSX_BUNDLE_BUNDLE_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 29 | NSHumanReadableCopyright 30 | ${MACOSX_BUNDLE_COPYRIGHT} 31 | NSHighResolutionCapable 32 | True 33 | NSSupportsAutomaticGraphicsSwitching 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /packaging/ShaderGraph.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Example Application 3 | Comment=This is an example application for C++ 4 | Keywords=cpp;cmake;example; 5 | Exec=ShaderGraph 6 | Icon=ShaderGraph.png 7 | Terminal=true 8 | Type=Application 9 | Categories=Utility;Photography;GNOME;GTK; 10 | -------------------------------------------------------------------------------- /packaging/ShaderGraph.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/packaging/ShaderGraph.icns -------------------------------------------------------------------------------- /packaging/ShaderGraph.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/packaging/ShaderGraph.ico -------------------------------------------------------------------------------- /packaging/ShaderGraph.icon.in.rc: -------------------------------------------------------------------------------- 1 | id ICON "@CMAKE_CURRENT_SOURCE_DIR@/ShaderGraph.ico" 2 | -------------------------------------------------------------------------------- /packaging/ShaderGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/packaging/ShaderGraph.png -------------------------------------------------------------------------------- /packaging/dmg_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/packaging/dmg_background.png -------------------------------------------------------------------------------- /source/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/source/.DS_Store -------------------------------------------------------------------------------- /source/core/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/source/core/.DS_Store -------------------------------------------------------------------------------- /source/core/Core.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_CORE_H 2 | #define SHADERGRAPH_CORE_H 3 | 4 | #include "Defines.h" 5 | 6 | #include "log/Log.h" 7 | 8 | #include "glm/glm.hpp" 9 | 10 | #endif //SHADERGRAPH_CORE_H 11 | -------------------------------------------------------------------------------- /source/core/Defines.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DEFINES_H 2 | #define SHADERGRAPH_DEFINES_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #endif //SHADERGRAPH_DEFINES_H 12 | -------------------------------------------------------------------------------- /source/core/log/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/source/core/log/.DS_Store -------------------------------------------------------------------------------- /source/detail/DetailDecl.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DETAILDECL_H 2 | #define SHADERGRAPH_DETAILDECL_H 3 | 4 | #include "DetailNode.h" 5 | #include "DetailLeaf.h" 6 | 7 | #include "leaf/DetailScalar.h" 8 | #include "leaf/DetailUniform.h" 9 | #include "leaf/DetailText.h" 10 | #include "leaf/DetailBoolean.h" 11 | #include "leaf/DetailVector.h" 12 | 13 | #endif //SHADERGRAPH_DETAILDECL_H 14 | -------------------------------------------------------------------------------- /source/detail/DetailLeaf.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-02. 3 | // 4 | 5 | #include "DetailLeaf.h" 6 | -------------------------------------------------------------------------------- /source/detail/DetailLeaf.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DETAILLEAF_H 2 | #define SHADERGRAPH_DETAILLEAF_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | #include "../pin/IPin.h" 13 | 14 | namespace ShaderGraph 15 | { 16 | class DetailLeaf 17 | { 18 | public: 19 | /// Default Constructor. 20 | DetailLeaf() = default; 21 | 22 | /// Constructor : 23 | /// Construct a node of a sub-tree. 24 | /// @tree : the root of this leaf. 25 | /// @name : the name of this leaf. 26 | /// @parent : The node to detail. 27 | explicit DetailLeaf(QTreeWidgetItem * root, 28 | QString name, 29 | QtNodes::NodeDataModel * nodeDataModel = nullptr, 30 | QColor textColor = QColor("white")) : 31 | m_name(name), 32 | m_nodeDataModel(nodeDataModel) 33 | { 34 | m_node = new QTreeWidgetItem(root); 35 | m_node->setText(0, name); 36 | m_node->setData(0, Qt::UserRole, QStringLiteral("skip me")); 37 | m_node->setTextColor(0, textColor); 38 | m_node->setExpanded(true); 39 | 40 | m_item = new QTreeWidgetItem(m_node); 41 | } 42 | 43 | /// Destructor. 44 | virtual ~DetailLeaf() = default; 45 | 46 | /// Display this hidden pin in the TreeWidget. 47 | inline void show() { m_item->setHidden(false); } 48 | 49 | /// Hide this hidden pin from the TreeWidget. 50 | void hide() { m_item->setHidden(true); } 51 | 52 | /// Getter : The item. 53 | inline QTreeWidgetItem * getItem() { return m_item; } 54 | 55 | /// Getter : The parent. 56 | inline QtNodes::NodeDataModel * getNodeDataModel() { return m_nodeDataModel; } 57 | 58 | /// Getter : The name. 59 | inline const QString& getName() const { return m_name; } 60 | 61 | private: 62 | /// The name of this leaf. 63 | QString m_name; 64 | 65 | /// The node to detail. 66 | QtNodes::NodeDataModel * m_nodeDataModel; 67 | 68 | /// The root of this subtree. 69 | QTreeWidgetItem * m_node; 70 | 71 | /// The item. 72 | QTreeWidgetItem * m_item; 73 | }; 74 | } 75 | 76 | #endif //SHADERGRAPH_DETAILLEAF_H 77 | -------------------------------------------------------------------------------- /source/detail/DetailNode.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-02. 3 | // 4 | 5 | #include "DetailNode.h" 6 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailBoolean.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-02. 3 | // 4 | 5 | #include "DetailBoolean.h" 6 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailBoolean.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DETAILBOOL_H 2 | #define SHADERGRAPH_DETAILBOOL_H 3 | 4 | #include "../DetailLeaf.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "../DetailNode.h" 11 | 12 | namespace ShaderGraph 13 | { 14 | class DetailBool : public DetailLeaf 15 | { 16 | public: 17 | /// Default Constructor. 18 | DetailBool() = default; 19 | 20 | /// Constructor : 21 | /// Construct a Scalar Item. 22 | /// @node : the leaf parent. 23 | /// @tree : the root of this leaf. 24 | /// @parent : The node to detail. 25 | explicit DetailBool(QCheckBox * checkBox, 26 | QTreeWidgetItem * node, 27 | QString name, 28 | QtNodes::NodeDataModel * nodeDataModel = nullptr, 29 | QColor textColor = QColor("white")) : 30 | DetailLeaf(node, name, nodeDataModel, textColor), 31 | m_checkBox(checkBox) 32 | { 33 | node->treeWidget()->setItemWidget(getItem(), 0, m_checkBox); 34 | } 35 | 36 | /// Destructor. 37 | ~DetailBool() override = default; 38 | 39 | private: 40 | QCheckBox * m_checkBox = nullptr; 41 | 42 | }; 43 | } 44 | 45 | #endif //SHADERGRAPH_DETAILBOOL_H 46 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailScalar.cpp: -------------------------------------------------------------------------------- 1 | #include "DetailScalar.h" 2 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailScalar.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DETAILSCALAR_H 2 | #define SHADERGRAPH_DETAILSCALAR_H 3 | 4 | #include "../DetailLeaf.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "../DetailNode.h" 11 | 12 | namespace ShaderGraph 13 | { 14 | class DetailScalar : public DetailLeaf 15 | { 16 | public: 17 | /// Default Constructor. 18 | DetailScalar() = default; 19 | 20 | /// Constructor : 21 | /// Construct a Scalar Item. 22 | /// @node : the leaf parent. 23 | /// @tree : the root of this leaf. 24 | /// @parent : The node to detail. 25 | explicit DetailScalar(QDoubleSpinBox * spinBox, 26 | QTreeWidgetItem * node, 27 | QString name, 28 | QtNodes::NodeDataModel * nodeDataModel = nullptr, 29 | QColor textColor = QColor("white")) : 30 | DetailLeaf(node, name, nodeDataModel, textColor), 31 | m_spinBox(spinBox) 32 | { 33 | node->treeWidget()->setItemWidget(getItem(), 0, m_spinBox); 34 | } 35 | 36 | /// Destructor. 37 | ~DetailScalar() override = default; 38 | 39 | private: 40 | QDoubleSpinBox * m_spinBox; 41 | 42 | }; 43 | } 44 | 45 | #endif //SHADERGRAPH_DETAILSCALAR_H 46 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailText.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-02. 3 | // 4 | 5 | #include "DetailText.h" 6 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailText.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DETAILTEXT_H 2 | #define SHADERGRAPH_DETAILTEXT_H 3 | 4 | #include "../DetailLeaf.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "../DetailNode.h" 11 | 12 | namespace ShaderGraph 13 | { 14 | class DetailText : public DetailLeaf 15 | { 16 | public: 17 | /// Default Constructor. 18 | DetailText() = default; 19 | 20 | /// Constructor : 21 | /// Construct a Scalar Item. 22 | /// @node : the leaf parent. 23 | /// @tree : the root of this leaf. 24 | /// @parent : The node to detail. 25 | explicit DetailText(QLineEdit * textField, 26 | QTreeWidgetItem * node, 27 | QString name, 28 | QtNodes::NodeDataModel * nodeDataModel = nullptr, 29 | QColor textColor = QColor("white")) : 30 | DetailLeaf(node, name, nodeDataModel, textColor), 31 | m_textField(textField) 32 | { 33 | node->treeWidget()->setItemWidget(getItem(), 0, m_textField); 34 | } 35 | 36 | /// Destructor. 37 | ~DetailText() override = default; 38 | 39 | private: 40 | QLineEdit * m_textField = nullptr; 41 | 42 | }; 43 | } 44 | 45 | #endif //SHADERGRAPH_DETAILTEXT_H 46 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailUniform.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-02. 3 | // 4 | 5 | #include "DetailUniform.h" 6 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailUniform.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_DETAILUNIFORM_H 2 | #define SHADERGRAPH_DETAILUNIFORM_H 3 | 4 | #include 5 | 6 | #include "../DetailNode.h" 7 | 8 | #include "DetailBoolean.h" 9 | #include "DetailText.h" 10 | 11 | namespace ShaderGraph 12 | { 13 | class IUniform 14 | { 15 | public: 16 | virtual ~IUniform() = default; 17 | 18 | /// @return : True if this node is a uniform. 19 | virtual bool isUniform() = 0; 20 | 21 | /// @return : The name of the uniform. 22 | /// @warning : Only valid if @isUniform equals true. 23 | virtual std::string getUniformName() = 0; 24 | 25 | /// @return : The default value of the uniform. 26 | /// @warning : Only valid if @isUniform equals true. 27 | virtual std::string getUniformDefaultValue() = 0; 28 | }; 29 | 30 | class DetailUniform : public DetailNode 31 | { 32 | public: 33 | /// Default Constructor. 34 | DetailUniform() = default; 35 | 36 | /// Constructor : 37 | /// Construct a uniform Item. 38 | /// @node : the leaf parent. 39 | /// @tree : the root of this leaf. 40 | /// @parent : The node to detail. 41 | explicit DetailUniform(QCheckBox * isUniformCheckBox, 42 | QLineEdit * uniformName, 43 | QTreeWidgetItem * node, 44 | QString name, 45 | QtNodes::NodeDataModel * nodeDataModel = nullptr, 46 | QColor textColor = QColor("white")) : 47 | DetailNode(node, name, nodeDataModel, textColor) 48 | { 49 | m_isUniform = DetailBool(isUniformCheckBox, QNode(), "Is Uniform ?", nodeDataModel); 50 | m_uniformName = DetailText(uniformName, QNode(), "Name", nodeDataModel); 51 | } 52 | 53 | /// Destructor. 54 | ~DetailUniform() override = default; 55 | 56 | private: 57 | DetailBool m_isUniform; 58 | DetailText m_uniformName; 59 | }; 60 | } 61 | 62 | #endif //SHADERGRAPH_DETAILUNIFORM_H 63 | -------------------------------------------------------------------------------- /source/detail/leaf/DetailVector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-02. 3 | // 4 | 5 | #include "DetailVector.h" 6 | -------------------------------------------------------------------------------- /source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qt/Window.h" 3 | 4 | #include "core/Core.h" 5 | //#include "model/NodeManager.h" 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | QApplication app(argc, argv); 10 | 11 | Window window; 12 | window.show(); 13 | return app.exec(); 14 | } -------------------------------------------------------------------------------- /source/model/Compilation.cpp: -------------------------------------------------------------------------------- 1 | #include "Compilation.h" 2 | -------------------------------------------------------------------------------- /source/model/Compilation.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_COMPILER_H 2 | #define SHADERGRAPH_COMPILER_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #define GLSL_CODE(_code_, ...) \ 10 | do \ 11 | { \ 12 | fmt::memory_buffer membuf; \ 13 | format_to(membuf, __VA_ARGS__); \ 14 | _code_ = to_string(membuf); \ 15 | } while (false); \ 16 | 17 | namespace ShaderGraph 18 | { 19 | struct TextureData 20 | { 21 | std::string name; 22 | std::string path; 23 | }; 24 | 25 | struct GLSLData 26 | { 27 | std::string generatedCode; 28 | std::string uniforms; 29 | 30 | bool hasFailed = false; 31 | std::string errmsg; 32 | 33 | std::list texturePaths; 34 | 35 | inline GLSLData operator+(const GLSLData& glslData) const 36 | { 37 | GLSLData output; 38 | output.generatedCode = generatedCode + glslData.generatedCode; 39 | output.uniforms = uniforms + glslData.uniforms; 40 | output.hasFailed = hasFailed || glslData.hasFailed; 41 | output.errmsg = errmsg + glslData.errmsg; 42 | 43 | output.texturePaths = texturePaths; 44 | output.texturePaths.insert(output.texturePaths.end(), 45 | glslData.texturePaths.begin(), 46 | glslData.texturePaths.end()); 47 | 48 | return output; 49 | } 50 | }; 51 | } 52 | 53 | #endif //SHADERGRAPH_COMPILER_H 54 | -------------------------------------------------------------------------------- /source/model/NodeDecl.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_NODEDECL_H 2 | #define SHADERGRAPH_NODEDECL_H 3 | 4 | #include "converter/Converter.h" 5 | 6 | #include "output/MasterMaterialOutput.h" 7 | 8 | #include "input/ColorNode.h" 9 | #include "input/VectorNode.h" 10 | #include "input/TextureNode.h" 11 | #include "input/CoordinatesExpressions.h" 12 | 13 | #include "operator/Operator.h" 14 | 15 | #include "math/Math.h" 16 | 17 | #include "misc/VectorFunctions.h" 18 | 19 | #endif //SHADERGRAPH_NODEDECL_H 20 | -------------------------------------------------------------------------------- /source/model/converter/Converter.cpp: -------------------------------------------------------------------------------- 1 | #include "Converter.h" 2 | 3 | namespace ShaderGraph 4 | { 5 | 6 | } -------------------------------------------------------------------------------- /source/model/converter/Converter.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_ABSTRACTOR_H 2 | #define SHADERGRAPH_ABSTRACTOR_H 3 | 4 | #include "../Node.h" 5 | 6 | #include "ToTemplate.h" 7 | 8 | namespace ShaderGraph 9 | { 10 | 11 | } 12 | 13 | #endif //SHADERGRAPH_ABSTRACTOR_H 14 | -------------------------------------------------------------------------------- /source/model/converter/ToTemplate.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_TOTEMPLATE_H 2 | #define SHADERGRAPH_TOTEMPLATE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "../Node.h" 8 | #include "../../pin/PinDecl.h" 9 | 10 | namespace ShaderGraph 11 | { 12 | void registerToTemplateConverters(std::shared_ptr registry); 13 | 14 | class BoolToTemplate 15 | { 16 | public: 17 | PIN operator()(const PIN data); 18 | 19 | private: 20 | PIN m_out; 21 | }; 22 | 23 | class FloatToTemplate 24 | { 25 | public: 26 | PIN operator()(const PIN data); 27 | 28 | private: 29 | PIN m_out; 30 | }; 31 | 32 | class Vec2ToTemplate 33 | { 34 | public: 35 | PIN operator()(const PIN data); 36 | 37 | private: 38 | PIN m_out; 39 | }; 40 | 41 | class Vec3ToTemplate 42 | { 43 | public: 44 | PIN operator()(const PIN data); 45 | 46 | private: 47 | PIN m_out; 48 | }; 49 | 50 | class Vec4ToTemplate 51 | { 52 | public: 53 | PIN operator()(const PIN data); 54 | 55 | private: 56 | PIN m_out; 57 | }; 58 | } 59 | 60 | #endif //SHADERGRAPH_TOTEMPLATE_H 61 | -------------------------------------------------------------------------------- /source/model/input/CoordinatesExpressions.cpp: -------------------------------------------------------------------------------- 1 | #include "CoordinatesExpressions.h" 2 | 3 | namespace ShaderGraph 4 | { 5 | UVNode::UVNode() : Node("UVs", "UVs") 6 | { 7 | outputs() = std::vector{ 8 | std::make_shared("UVs", this), 9 | std::make_shared("u", this), 10 | std::make_shared("v", this) 11 | }; 12 | } 13 | } -------------------------------------------------------------------------------- /source/model/input/CoordinatesExpressions.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_COORDINATESEXPR_H 2 | #define SHADERGRAPH_COORDINATESEXPR_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "../Node.h" 9 | 10 | #define SPINBOX_STEP 0.1 11 | #define SPINBOX_VALUE_CHANGED_SLOT static_cast(&QDoubleSpinBox::valueChanged) 12 | 13 | namespace ShaderGraph 14 | { 15 | class UVNode : public Node 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | UVNode(); 21 | 22 | GLSLData nodeToGLSL() override 23 | { 24 | GLSLData buffer; 25 | GLSL_CODE(buffer.generatedCode, 26 | "// Input : UV \n" 27 | "{0} = texCoord; \n" 28 | "{1} = texCoord.x; \n" 29 | "{2} = texCoord.y; \n" 30 | "\n", 31 | autoName(outputs()[0]), 32 | autoName(outputs()[1]), 33 | autoName(outputs()[2])); 34 | return buffer; 35 | } 36 | }; 37 | } 38 | 39 | #endif //SHADERGRAPH_COORDINATESEXPR_H 40 | -------------------------------------------------------------------------------- /source/model/input/TextureNode.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_TEXTURENODE_H 2 | #define SHADERGRAPH_TEXTURENODE_H 3 | 4 | #include "model/Node.h" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace ShaderGraph 12 | { 13 | class TextureNode : public Node 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | /// Constructor. 19 | TextureNode(); 20 | 21 | /// Destructor. 22 | ~TextureNode() override = default; 23 | 24 | /// Specified the embedded widget in the Node. 25 | /// @return : the widget. 26 | QWidget * embeddedWidget() override { return m_label; } 27 | 28 | /// Make this node resizable. 29 | bool resizable() const override { return true; } 30 | 31 | /// Show all node's properties in the node panel. 32 | void showDetails(QTreeWidget * tree) override; 33 | 34 | /// Hide all node's properties from the node panel. 35 | void hideDetails(QTreeWidget * tree) override; 36 | 37 | /// Setter : The path to the image. 38 | void setPath(const QString &path); 39 | 40 | GLSLData nodeToGLSL() override; 41 | 42 | protected: 43 | /// The event filter: see Qt documentation. 44 | bool eventFilter(QObject *object, QEvent *event) override; 45 | 46 | private: 47 | /// The path to the image. 48 | QString m_path; 49 | 50 | /// Where the image will be displayed. 51 | QLabel * m_label; 52 | 53 | /// Where the image is stored. 54 | QPixmap m_pixmap; 55 | }; 56 | 57 | 58 | } 59 | 60 | 61 | #endif //SHADERGRAPH_TEXTURENODE_H 62 | -------------------------------------------------------------------------------- /source/model/math/Math.cpp: -------------------------------------------------------------------------------- 1 | #include "Math.h" 2 | 3 | namespace ShaderGraph 4 | { 5 | StepNode::StepNode() : Node("Step", "Step") 6 | { 7 | inputs() = std::vector{ 8 | std::make_shared("Value", this), 9 | std::make_shared("Step", this) 10 | }; 11 | 12 | outputs() = std::vector{ 13 | std::make_shared("Result", this) 14 | }; 15 | } 16 | } -------------------------------------------------------------------------------- /source/model/math/Math.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_MATH_H 2 | #define SHADERGRAPH_MATH_H 3 | 4 | 5 | #include 6 | 7 | #include "../Node.h" 8 | 9 | namespace ShaderGraph 10 | { 11 | class StepNode : public Node 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | StepNode(); 17 | 18 | GLSLData nodeToGLSL() override 19 | { 20 | GLSLData buffer; 21 | GLSL_CODE(buffer.generatedCode, 22 | "// Step \n" 23 | "{0} = floor({1} / {2}) * {2};\n" 24 | "\n", 25 | autoName(outputs()[0]), 26 | autoName(inputs()[0]), 27 | autoName(inputs()[1])); 28 | return buffer; 29 | } 30 | }; 31 | } 32 | 33 | 34 | #endif //SHADERGRAPH_MATH_H 35 | -------------------------------------------------------------------------------- /source/model/misc/VectorFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "VectorFunctions.h" 2 | -------------------------------------------------------------------------------- /source/model/operator/BoolOperator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-03-13. 3 | // 4 | 5 | #include "BoolOperator.h" 6 | -------------------------------------------------------------------------------- /source/model/operator/CommonOperator.cpp: -------------------------------------------------------------------------------- 1 | #include "CommonOperator.h" 2 | 3 | namespace ShaderGraph 4 | { 5 | 6 | } -------------------------------------------------------------------------------- /source/model/operator/Operator.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-03-13. 3 | // 4 | 5 | #include "Operator.h" 6 | -------------------------------------------------------------------------------- /source/model/operator/Operator.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_OPERATOR_H 2 | #define SHADERGRAPH_OPERATOR_H 3 | 4 | #include "BoolOperator.h" 5 | #include "CommonOperator.h" 6 | 7 | #endif //SHADERGRAPH_OPERATOR_H 8 | -------------------------------------------------------------------------------- /source/model/output/MasterMaterialOutput.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-03-09. 3 | // 4 | 5 | #include "MasterMaterialOutput.h" 6 | -------------------------------------------------------------------------------- /source/model/output/MasterMaterialOutput.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_MASTERMATERIALOUTPUT_H 2 | #define SHADERGRAPH_MASTERMATERIALOUTPUT_H 3 | 4 | #include "../Node.h" 5 | #include "pin/Pin.h" 6 | 7 | namespace ShaderGraph 8 | { 9 | class MasterMaterialOutput : public Node 10 | { 11 | public: 12 | MasterMaterialOutput() : Node("MasterMaterialOutput") 13 | { 14 | inputs() = std::vector { 15 | std::make_shared("Diffuse", this), 16 | std::make_shared("Normal", this), 17 | std::make_shared("Specular", this), 18 | 19 | std::make_shared("Metallic", this), 20 | std::make_shared("Roughness", this), 21 | std::make_shared("Emissive", this), 22 | std::make_shared("Opacity", this), 23 | 24 | std::make_shared("WorldPositionOffset", this), 25 | std::make_shared("AmbientOcclusion", this), 26 | std::make_shared("Refraction", this), 27 | std::make_shared("TextureCoordinate", this), 28 | std::make_shared("Tangent", this), 29 | std::make_shared("Depth", this) 30 | }; 31 | } 32 | 33 | inline GLSLData nodeToGLSL() override 34 | { 35 | GLSLData glslData; 36 | GLSL_CODE(glslData.generatedCode, 37 | "// End MasterMaterialOutput", 38 | autoName(inputs()[0]), 39 | autoName(inputs()[1])); 40 | return glslData; 41 | } 42 | 43 | inline GLSLData toGLSL() override 44 | { 45 | std::list nodes; 46 | GLSLData glslData = inputsToGLSL(nodes) + nodeToGLSL(); 47 | return glslData; 48 | } 49 | 50 | inline std::string autoName(PIN& pin) override 51 | { 52 | return pin->type().name.toStdString(); 53 | } 54 | }; 55 | } 56 | 57 | #endif //SHADERGRAPH_MASTERMATERIALOUTPUT_H 58 | -------------------------------------------------------------------------------- /source/nodeeditor/FlowScene.cpp: -------------------------------------------------------------------------------- 1 | #include "FlowScene.h" 2 | -------------------------------------------------------------------------------- /source/nodeeditor/FlowScene.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_FLOWSCENE_H 2 | #define SHADERGRAPH_FLOWSCENE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include "model/Node.h" 16 | 17 | namespace ShaderGraph 18 | { 19 | class FlowScene : public QtNodes::FlowScene 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | 25 | explicit FlowScene(std::shared_ptr registry, QObject * parent = Q_NULLPTR) : 26 | QtNodes::FlowScene(registry, parent) 27 | { 28 | 29 | } 30 | 31 | explicit FlowScene(QObject * parent = Q_NULLPTR) : 32 | QtNodes::FlowScene(parent) 33 | { 34 | 35 | } 36 | 37 | ~FlowScene() override = default; 38 | }; 39 | 40 | } 41 | 42 | #endif //SHADERGRAPH_FLOWSCENE_H 43 | -------------------------------------------------------------------------------- /source/nodeeditor/FlowView.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_FLOWVIEW_H 2 | #define SHADERGRAPH_FLOWVIEW_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "model/Node.h" 25 | #include "FlowScene.h" 26 | 27 | namespace ShaderGraph 28 | { 29 | class FlowView : public QtNodes::FlowView 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit FlowView(QWidget *parent = Q_NULLPTR); 35 | 36 | explicit FlowView(QtNodes::FlowScene *scene, QWidget *parent = Q_NULLPTR); 37 | 38 | inline void setDetailsTree(QTreeWidget * tree) { m_detailsTree = tree; } 39 | 40 | public Q_SLOTS: 41 | 42 | void onNodeDeleted(QtNodes::Node &n); 43 | 44 | void deleteSelectedNodes() override ; 45 | 46 | protected: 47 | 48 | void mousePressEvent(QMouseEvent *event) override; 49 | 50 | void contextMenuEvent(QContextMenuEvent *event) override ; 51 | 52 | private: 53 | QTreeWidget * m_detailsTree; 54 | ShaderGraph::Node * m_detailedNode = nullptr; 55 | 56 | }; 57 | } 58 | 59 | #endif // SHADERGRAPH_FLOWVIEW_H 60 | -------------------------------------------------------------------------------- /source/nodeeditor/NodeManager.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-02-06. 3 | // 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "NodeManager.h" 13 | 14 | bool ShaderGraph::NodeManager::loadNodeStyle(const QString filename) 15 | { 16 | QFile file; 17 | 18 | if (!filename.isEmpty()) // check if the file exist 19 | { 20 | QString variable; 21 | file.setFileName(filename); 22 | 23 | if (!file.open(QFile::ReadOnly | QFile::Text)) // the file cannot be read 24 | { 25 | // LOG_ERROR << "Unable to open the file : " << filename.toStdString() << NEWLINE; 26 | return false; 27 | 28 | } else { // file opened and ready to read from 29 | QTextStream in(&file); 30 | const QString text = in.readAll(); 31 | m_codeStyleFilename = filename; 32 | setNodeStyle(text); 33 | } 34 | return true; 35 | } 36 | 37 | // LOG_ERROR << "Unable to find the file : " << filename.toStdString() << NEWLINE; 38 | return false; 39 | } 40 | -------------------------------------------------------------------------------- /source/nodeeditor/NodeManager.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_NODEMANAGER_H 2 | #define SHADERGRAPH_NODEMANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | // TODO : put here the list of each of node 14 | 15 | // see -- https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/ExpressionReference 16 | 17 | namespace ShaderGraph 18 | { 19 | class NodeManager 20 | { 21 | public: 22 | 23 | inline NodeManager() 24 | { 25 | m_dataModelRegistry = std::make_shared(); 26 | } 27 | 28 | ~NodeManager() = default; 29 | 30 | /// Load the code style from a file 31 | bool loadNodeStyle(const QString filename); 32 | 33 | /// Set the style of the editor 34 | inline void setNodeStyle(const QString& codeStyle) const 35 | { 36 | QtNodes::ConnectionStyle::setConnectionStyle(codeStyle); 37 | } 38 | 39 | /// Getter and Setter of m_dataModelRegistry 40 | inline std::shared_ptr registry() 41 | { 42 | return m_dataModelRegistry; 43 | } 44 | 45 | /// Getter and Setter of m_codeStyleFilename 46 | inline const QString& getCodeStyleFilename() const 47 | { 48 | return m_codeStyleFilename; 49 | } 50 | 51 | 52 | private: 53 | 54 | QString m_codeStyleFilename = "the code style doesn't come from a file"; 55 | 56 | std::shared_ptr m_dataModelRegistry; 57 | 58 | }; 59 | } 60 | 61 | #endif //SHADERGRAPH_NODEMANAGER_H 62 | -------------------------------------------------------------------------------- /source/pin/BooleanPin.cpp: -------------------------------------------------------------------------------- 1 | #include "BooleanPin.h" 2 | -------------------------------------------------------------------------------- /source/pin/BooleanPin.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_BOOLPIN_H 2 | #define SHADERGRAPH_BOOLPIN_H 3 | 4 | #include 5 | 6 | #include "Pin.h" 7 | 8 | namespace ShaderGraph 9 | { 10 | class Boolean : public GenType 11 | { 12 | public: 13 | /// Default constructor. 14 | explicit Boolean(QString name = "Boolean", QtNodes::NodeDataModel * owner = nullptr) : 15 | GenType(false, name, owner, EPinType::BOOLEAN) 16 | { 17 | 18 | }; 19 | 20 | /// Constructor. 21 | explicit Boolean(bool value, QString name = "Boolean", QtNodes::NodeDataModel * owner = nullptr) : 22 | GenType(value, name, owner, EPinType::BOOLEAN) 23 | { 24 | 25 | }; 26 | 27 | /// @return : the id and the name of this data. 28 | QtNodes::NodeDataType type() const override 29 | { 30 | return QtNodes::NodeDataType{"Boolean", name()}; 31 | } 32 | 33 | /// @return : Get the GLSL type (in string) which represents this pin. 34 | std::string typeToGLSL() override { return "bool"; } 35 | 36 | /// @return : Get the GLSL default value in string, 37 | /// if this pin isn't connected during code generation. 38 | std::string defaultValueToGLSL() override { return "false"; } 39 | }; 40 | } 41 | 42 | #endif //SHADERGRAPH_BOOLPIN_H 43 | -------------------------------------------------------------------------------- /source/pin/FloatPin.cpp: -------------------------------------------------------------------------------- 1 | #include "FloatPin.h" 2 | -------------------------------------------------------------------------------- /source/pin/FloatPin.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_FLOATPIN_H 2 | #define SHADERGRAPH_FLOATPIN_H 3 | 4 | #include 5 | 6 | #include "Pin.h" 7 | 8 | namespace ShaderGraph 9 | { 10 | class Float : public GenType 11 | { 12 | public: 13 | /// Default constructor. 14 | explicit Float(QString name = "Float", QtNodes::NodeDataModel * owner = nullptr) : 15 | GenType(0.0f, name, owner, EPinType::FLOAT) 16 | { 17 | 18 | }; 19 | 20 | /// Constructor. 21 | explicit Float(float value, QString name = "Float", QtNodes::NodeDataModel * owner = nullptr) : 22 | GenType(value, name, owner, EPinType::FLOAT) 23 | { 24 | 25 | }; 26 | 27 | /// @return : the id and the name of this data. 28 | QtNodes::NodeDataType type() const override 29 | { 30 | return QtNodes::NodeDataType{"Float", name()}; 31 | } 32 | 33 | /// @return : Get the GLSL type (in string) which represents this pin. 34 | std::string typeToGLSL() override { return "float"; } 35 | 36 | // @return : Get the GLSL float default value (in string) in case of this pin is disconnected during code generation. 37 | std::string defaultValueToGLSL() override { return "0.0f"; } 38 | }; 39 | } 40 | 41 | #endif //SHADERGRAPH_FLOATPIN_H 42 | -------------------------------------------------------------------------------- /source/pin/PinDecl.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_PINDECL_H 2 | #define SHADERGRAPH_PINDECL_H 3 | 4 | #include "IPin.h" 5 | #include "Pin.h" 6 | 7 | #include "BooleanPin.h" 8 | #include "FloatPin.h" 9 | #include "VectorPin.h" 10 | #include "TemplatePin.h" 11 | 12 | #endif //SHADERGRAPH_PINDECL_H 13 | -------------------------------------------------------------------------------- /source/pin/VectorPin.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-04-01. 3 | // 4 | 5 | #include "VectorPin.h" 6 | -------------------------------------------------------------------------------- /source/preview/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/source/preview/.DS_Store -------------------------------------------------------------------------------- /source/preview/OpenGL.cpp: -------------------------------------------------------------------------------- 1 | #include "OpenGL.h" 2 | 3 | namespace ShaderGraph 4 | { 5 | void glClearError() 6 | { 7 | while (glGetError() != GL_NO_ERROR); 8 | } 9 | 10 | bool glDumpError(const char * function, const char * file, int line) 11 | { 12 | bool isGlErrorBufferEmpty = true; 13 | while (GLenum error = glGetError()) 14 | { 15 | isGlErrorBufferEmpty = false; // there is at least one error 16 | 17 | LOG_ERROR("OpenGL error : {0}. \n\tfile : {1} at the line : {2} \n\t common : {3}", 18 | glErrorToString(error), file, line, function); 19 | } 20 | return isGlErrorBufferEmpty; 21 | } 22 | } -------------------------------------------------------------------------------- /source/preview/OpenGL.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_OPENGL_H 2 | #define SHADERGRAPH_OPENGL_H 3 | 4 | #ifdef __APPLE__ 5 | #include 6 | #include 7 | #else 8 | #define GL_GLEXT_PROTOTYPES 1 9 | #include 10 | #include 11 | #endif 12 | 13 | #include 14 | 15 | #include 16 | 17 | #define GL_NULL_ID 0 18 | 19 | namespace ShaderGraph 20 | { 21 | /// Cast a GLError to a string 22 | inline std::string glErrorToString(GLenum Error) 23 | { 24 | switch (Error) { 25 | case GL_NO_ERROR: 26 | return " No error"; 27 | case GL_INVALID_ENUM: 28 | return " Invalid enum : An unacceptable value is specified for an enumerated argument. The offending command is ignored and has no other side effect than to set the error flag."; 29 | case GL_INVALID_VALUE: 30 | return " Invalid value : A numeric argument is out of range. The offending command is ignored and has no other side effect than to set the error flag."; 31 | case GL_INVALID_OPERATION: 32 | return " Invalid operation : The specified operation is not allowed in the current state. The offending command is ignored and has no other side effect than to set the error flag."; 33 | case GL_INVALID_FRAMEBUFFER_OPERATION: 34 | return " Invalid framebuffer operation : The framebuffer object is not complete. The offending command is ignored and has no other side effect than to set the error flag."; 35 | case GL_OUT_OF_MEMORY: 36 | return " Out of memory : There is not enough memory left to execute the command. The state of the GL is undefined, except for the state of the error flags, after this error is recorded."; 37 | default: 38 | return " Unknown OpenGL error."; 39 | } 40 | } 41 | 42 | /// Clear the errors in the GLErrorBuffer 43 | void glClearError(); 44 | 45 | /// Dump each error in the GLErrorBuffer 46 | /// @return : true if no error 47 | bool glDumpError(const char * function, const char * file, int line); 48 | 49 | #define GL_ASSERT(_function_) \ 50 | if (true) \ 51 | { \ 52 | ShaderGraph::glClearError(); \ 53 | _function_; \ 54 | ShaderGraph::glDumpError(#_function_, __FILE__, __LINE__); \ 55 | } \ 56 | // end GL_CALL 57 | } 58 | 59 | #endif //SHADERGRAPH_OPENGL_H 60 | -------------------------------------------------------------------------------- /source/preview/Texture.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Valentin on 2019-02-18. 3 | // 4 | 5 | #include "Texture.h" 6 | 7 | namespace ShaderGraph 8 | { 9 | Texture::Texture(const std::string& path, const std::string& name) : 10 | m_name(name), 11 | m_filename(path), 12 | m_slot(-1) 13 | { 14 | stbi_set_flip_vertically_on_load(1); 15 | 16 | m_localBuffer = stbi_load( 17 | path.c_str(), 18 | &m_width, 19 | &m_height, 20 | &m_bitsPerPixel, 21 | 4 /* RGBA channel */); 22 | 23 | // if the file in not found 24 | if (!m_localBuffer) 25 | { 26 | LOG_ERROR("Texture::Texture : {0} : file not found", path); 27 | } 28 | else 29 | { 30 | GL_ASSERT(glGenTextures(1, &m_id)); 31 | GL_ASSERT(glBindTexture(GL_TEXTURE_2D, m_id)); 32 | 33 | GL_ASSERT(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 34 | GL_ASSERT(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 35 | GL_ASSERT(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 36 | GL_ASSERT(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 37 | 38 | GL_ASSERT( 39 | glTexImage2D( 40 | GL_TEXTURE_2D, 41 | 0 /* No multi level texture */, 42 | GL_RGBA8, 43 | m_width, 44 | m_height, 45 | 0 /* No border */, 46 | GL_RGBA, 47 | GL_UNSIGNED_BYTE, 48 | m_localBuffer 49 | ) // glTexImage2D 50 | ); // GL_ASSERT 51 | 52 | GL_ASSERT(glBindTexture(GL_TEXTURE_2D, GL_NULL_ID)); 53 | } 54 | 55 | // free the buffer if the it's valid 56 | if (m_localBuffer) stbi_image_free(m_localBuffer); 57 | } 58 | 59 | Texture::~Texture() 60 | { 61 | GL_ASSERT(glDeleteTextures(1, &m_id)); 62 | } 63 | 64 | void Texture::bind(const int slot) 65 | { 66 | m_slot = slot; 67 | GL_ASSERT(glActiveTexture(GL_TEXTURE0 + slot)); 68 | GL_ASSERT(glBindTexture(GL_TEXTURE_2D, m_id)); 69 | } 70 | 71 | void Texture::unbind() const 72 | { 73 | GL_ASSERT(glBindTexture(GL_TEXTURE_2D, GL_NULL_ID)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /source/preview/Texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "OpenGL.h" 8 | 9 | #include "../vendor/stb/stb_image.h" 10 | 11 | namespace ShaderGraph 12 | { 13 | class Texture 14 | { 15 | public: 16 | /// Default Constructor. 17 | Texture() = default; 18 | 19 | /// Constructor. 20 | Texture(const std::string& path, const std::string& name); 21 | 22 | /// Destructor. 23 | ~Texture(); 24 | 25 | /// Bind this image. 26 | /// @warning : Only a binded image can be manipulated by OpenGL. 27 | void bind(const int slot = 0); 28 | 29 | /// Unbind this image. 30 | /// @warning : Only a binded image can be manipulated by OpenGL. 31 | void unbind() const; 32 | 33 | /// Getter : 34 | inline unsigned getId() const { return m_id; } 35 | 36 | /// Getter : 37 | inline int getSlot() const { return m_slot; } 38 | 39 | /// Getter : 40 | inline int getWidth() const { return m_width; } 41 | 42 | /// Getter : 43 | inline int getHeight() const { return m_height; } 44 | 45 | /// Getter : 46 | inline int getBitsPerPixel() const { return m_bitsPerPixel; } 47 | 48 | inline const std::string& getName() const { return m_name; } 49 | 50 | inline const std::string& getPath() const { return m_filename; } 51 | 52 | private: 53 | /// The uniform name 54 | std::string m_name; 55 | 56 | /// The (unique) id of this image. 57 | unsigned int m_id; 58 | 59 | /// The filename/path of this image. 60 | std::string m_filename; 61 | 62 | /// The openGL slot of this image. 63 | int m_slot; 64 | 65 | /// The width of the image. 66 | int m_width; 67 | 68 | /// The height of the image. 69 | int m_height; 70 | 71 | /// The number of bits per pixel. 72 | int m_bitsPerPixel; 73 | 74 | /// The buffer of pixels. 75 | unsigned char * m_localBuffer; 76 | }; 77 | } -------------------------------------------------------------------------------- /source/qt/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/source/qt/.DS_Store -------------------------------------------------------------------------------- /source/qt/GLWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "GLWidget.h" 2 | 3 | #include 4 | #include 5 | 6 | #define LAST_TIME_START_VALUE 0 7 | 8 | GLWidget::GLWidget(QWidget * parent) : 9 | QOpenGLWidget(parent), 10 | QOpenGLFunctions_4_1_Core(), 11 | m_lastTime(LAST_TIME_START_VALUE) 12 | { 13 | 14 | } 15 | 16 | void GLWidget::initializeGL() 17 | { 18 | if (!initializeOpenGLFunctions()) 19 | { 20 | LOG_CRITICAL("GLWidget::initializeGL : Cannot initialize OpenGL functions"); 21 | } 22 | m_scene = new ShaderGraph::Scene(WIDTH, HEIGHT); 23 | } 24 | 25 | void GLWidget::paintGL() 26 | { 27 | auto startTime = static_cast(QDateTime::currentMSecsSinceEpoch()); 28 | 29 | m_scene->draw(); 30 | GL_ASSERT(glFinish()); 31 | 32 | auto endTime = static_cast(QDateTime::currentMSecsSinceEpoch()); 33 | 34 | m_lastTime = endTime - startTime; 35 | } 36 | 37 | void GLWidget::resizeGL(int width, int height) 38 | { 39 | m_scene->resize(static_cast(width), static_cast(height)); 40 | } 41 | 42 | void GLWidget::mousePressEvent(QMouseEvent * event) 43 | { 44 | int buttonType; // buttons are 0 = left, 1 = right to 2 = middle 45 | Qt::MouseButton button = event->button(); 46 | 47 | if (button & Qt::LeftButton) 48 | { 49 | if ((event->modifiers() & Qt::ControlModifier)) buttonType = 2; 50 | else buttonType = 0; 51 | } 52 | else if (button & Qt::RightButton) buttonType = 1; 53 | else if (button & Qt::MiddleButton) buttonType = 2; 54 | else buttonType = 3; 55 | 56 | m_scene->mouseClick(buttonType, event->x(), event->y()); 57 | update(); 58 | } 59 | 60 | void GLWidget::mouseMoveEvent(QMouseEvent * event) 61 | { 62 | m_scene->mouseMove(event->x(), event->y()); 63 | update(); 64 | } 65 | -------------------------------------------------------------------------------- /source/qt/GLWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_GLWIDGET_H 2 | #define SHADERGRAPH_GLWIDGET_H 3 | 4 | #define WIDTH 1024 5 | #define HEIGHT 1024 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "../preview/Scene.h" 14 | #include "../preview/OpenGL.h" 15 | 16 | #include "../model/Compilation.h" 17 | 18 | class GLWidget : 19 | public QOpenGLWidget, 20 | public QOpenGLFunctions_4_1_Core 21 | { 22 | 23 | public: 24 | /// Constructor. 25 | explicit GLWidget(QWidget * parent = nullptr); 26 | 27 | /// Destructor. 28 | ~GLWidget() override = default; 29 | 30 | /// OpenGL management : Call when to init OpenGL. 31 | void initializeGL() override; 32 | 33 | /// OpenGL management : Call every tick to do the rendering. 34 | void paintGL() override; 35 | 36 | /// OpenGL management : Call when the window's dim changed. 37 | void resizeGL(int width, int height) override; 38 | 39 | /// Mouse event : Press 40 | void mousePressEvent(QMouseEvent * event) override; 41 | 42 | /// Mouse event : Move 43 | void mouseMoveEvent(QMouseEvent * event) override; 44 | 45 | /// Event call when the button "compile" is pressed. Will update the preview. 46 | inline void onShaderCompiled(const std::string& uniforms, 47 | const std::string& generatedCode, 48 | const std::list texturePaths) 49 | { 50 | m_scene->onShaderCompiled(uniforms, generatedCode, texturePaths); 51 | update(); 52 | } 53 | 54 | private: 55 | unsigned int m_lastTime; 56 | 57 | ShaderGraph::Scene * m_scene; 58 | }; 59 | 60 | #endif // SHADERGRAPH_GLWIDGET_H 61 | -------------------------------------------------------------------------------- /source/qt/WidgetNodeEditor.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_WIDGETNODEEDITOR_H 2 | #define SHADERGRAPH_WIDGETNODEEDITOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include "../model/output/MasterMaterialOutput.h" 22 | 23 | #include "nodeeditor/FlowScene.h" 24 | #include "nodeeditor/FlowView.h" 25 | 26 | class WidgetNodeEditor : public QWidget 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit WidgetNodeEditor(QWidget * parent = nullptr); 31 | 32 | ~WidgetNodeEditor() override = default; 33 | 34 | inline ShaderGraph::FlowScene * getScene() { return m_scene; } 35 | inline ShaderGraph::FlowView * getFlowView() { return m_flowView; } 36 | inline ShaderGraph::MasterMaterialOutput * getMasterMaterialOutput() { return m_masterMaterialOutput; } 37 | 38 | inline void setDetailsTree(QTreeWidget * tree) { m_flowView->setDetailsTree(tree); } 39 | 40 | private: 41 | ShaderGraph::FlowScene * m_scene; 42 | ShaderGraph::FlowView * m_flowView; 43 | QVBoxLayout * m_layout; 44 | ShaderGraph::MasterMaterialOutput * m_masterMaterialOutput; 45 | }; 46 | 47 | 48 | #endif //SHADERGRAPH_WIDGETNODEEDITOR_H 49 | -------------------------------------------------------------------------------- /source/qt/Window.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADERGRAPH_WINDOW_H 2 | #define SHADERGRAPH_WINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Ui { class Window; } 14 | 15 | class Window : public QMainWindow 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit Window(QWidget * parent = nullptr); 21 | 22 | ~Window() override; 23 | 24 | public slots: 25 | /// Compile the flow scene to GLSL code. 26 | void compile(); 27 | 28 | private: 29 | /// The user interface. 30 | Ui::Window * m_ui; 31 | 32 | /// The internal representation of the function tree/panel. 33 | QMap m_internalFunctionTree; 34 | }; 35 | 36 | #endif // SHADERGRAPH_WINDOW_H -------------------------------------------------------------------------------- /source/unittest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Unit tests via Catch framework 3 | # 4 | # For testing on the common/class level. 5 | 6 | add_executable( 7 | unittests EXCLUDE_FROM_ALL 8 | testmain.cpp) 9 | 10 | add_dependencies(unittests Catch) # Catch is needed for unit tests, located in ../external 11 | target_compile_definitions(unittests PRIVATE UNIT_TESTS) # add -DUNIT_TESTS define 12 | target_include_directories(unittests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 13 | target_include_directories(unittests SYSTEM PRIVATE 14 | ${EXTERNAL_CATCH_INCLUDE_DIR}) 15 | 16 | # convenience target for running only the unit tests 17 | add_custom_target(unit 18 | #this way we can use faux data from /test dir (if we have any): 19 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test 20 | COMMAND $ 21 | DEPENDS unittests) 22 | # Verbose printing of results 23 | add_custom_target(unitall 24 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test 25 | COMMAND $ -s -a -r=compact 26 | DEPENDS unittests) 27 | 28 | 29 | -------------------------------------------------------------------------------- /source/unittest/testmain.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do 2 | // this in one cpp file 3 | // #include "catch.hpp" 4 | -------------------------------------------------------------------------------- /source/vendor/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/source/vendor/.DS_Store -------------------------------------------------------------------------------- /source/vendor/spdlog/details/circular_q.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2018 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | // cirucal q view of std::vector. 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace spdlog { 12 | namespace details { 13 | template 14 | class circular_q 15 | { 16 | public: 17 | using item_type = T; 18 | 19 | explicit circular_q(size_t max_items) 20 | : max_items_(max_items + 1) // one item is reserved as marker for full q 21 | , v_(max_items_) 22 | { 23 | } 24 | 25 | // push back, overrun (oldest) item if no room left 26 | void push_back(T &&item) 27 | { 28 | v_[tail_] = std::move(item); 29 | tail_ = (tail_ + 1) % max_items_; 30 | 31 | if (tail_ == head_) // overrun last item if full 32 | { 33 | head_ = (head_ + 1) % max_items_; 34 | ++overrun_counter_; 35 | } 36 | } 37 | 38 | // Pop item from front. 39 | // If there are no elements in the container, the behavior is undefined. 40 | void pop_front(T &popped_item) 41 | { 42 | popped_item = std::move(v_[head_]); 43 | head_ = (head_ + 1) % max_items_; 44 | } 45 | 46 | bool empty() 47 | { 48 | return tail_ == head_; 49 | } 50 | 51 | bool full() 52 | { 53 | // head is ahead of the tail by 1 54 | return ((tail_ + 1) % max_items_) == head_; 55 | } 56 | 57 | size_t overrun_counter() const 58 | { 59 | return overrun_counter_; 60 | } 61 | 62 | private: 63 | size_t max_items_; 64 | typename std::vector::size_type head_ = 0; 65 | typename std::vector::size_type tail_ = 0; 66 | 67 | std::vector v_; 68 | 69 | size_t overrun_counter_ = 0; 70 | }; 71 | } // namespace details 72 | } // namespace spdlog 73 | -------------------------------------------------------------------------------- /source/vendor/spdlog/details/console_globals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // 3 | // Copyright(c) 2018 Gabi Melman. 4 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 5 | // 6 | 7 | #include "null_mutex.h" 8 | #include 9 | #include 10 | 11 | #ifdef _WIN32 12 | 13 | #ifndef NOMINMAX 14 | #define NOMINMAX // prevent windows redefining min/max 15 | #endif 16 | 17 | #ifndef WIN32_LEAN_AND_MEAN 18 | #define WIN32_LEAN_AND_MEAN 19 | #endif 20 | 21 | #include 22 | #endif 23 | 24 | namespace spdlog { 25 | namespace details { 26 | struct console_stdout 27 | { 28 | static std::FILE *stream() 29 | { 30 | return stdout; 31 | } 32 | #ifdef _WIN32 33 | static HANDLE handle() 34 | { 35 | return ::GetStdHandle(STD_OUTPUT_HANDLE); 36 | } 37 | #endif 38 | }; 39 | 40 | struct console_stderr 41 | { 42 | static std::FILE *stream() 43 | { 44 | return stderr; 45 | } 46 | #ifdef _WIN32 47 | static HANDLE handle() 48 | { 49 | return ::GetStdHandle(STD_ERROR_HANDLE); 50 | } 51 | #endif 52 | }; 53 | 54 | struct console_mutex 55 | { 56 | using mutex_t = std::mutex; 57 | static mutex_t &mutex() 58 | { 59 | static mutex_t s_mutex; 60 | return s_mutex; 61 | } 62 | }; 63 | 64 | struct console_nullmutex 65 | { 66 | using mutex_t = null_mutex; 67 | static mutex_t &mutex() 68 | { 69 | static mutex_t s_mutex; 70 | return s_mutex; 71 | } 72 | }; 73 | } // namespace details 74 | } // namespace spdlog 75 | -------------------------------------------------------------------------------- /source/vendor/spdlog/details/log_msg.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #include "vendor/spdlog/common.h" 9 | #include "os.h" 10 | 11 | #include 12 | #include 13 | 14 | namespace spdlog { 15 | namespace details { 16 | struct log_msg 17 | { 18 | 19 | log_msg(source_loc loc, const std::string *loggers_name, level::level_enum lvl, string_view_t view) 20 | : logger_name(loggers_name) 21 | , level(lvl) 22 | #ifndef SPDLOG_NO_DATETIME 23 | , time(os::now()) 24 | #endif 25 | 26 | #ifndef SPDLOG_NO_THREAD_ID 27 | , thread_id(os::thread_id()) 28 | #endif 29 | , source(loc) 30 | , payload(view) 31 | { 32 | } 33 | 34 | log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view) 35 | : log_msg(source_loc{}, loggers_name, lvl, view) 36 | { 37 | } 38 | 39 | log_msg(const log_msg &other) = default; 40 | 41 | const std::string *logger_name{nullptr}; 42 | level::level_enum level{level::off}; 43 | log_clock::time_point time; 44 | size_t thread_id{0}; 45 | size_t msg_id{0}; 46 | 47 | // wrapping the formatted text with color (updated by pattern_formatter). 48 | mutable size_t color_range_start{0}; 49 | mutable size_t color_range_end{0}; 50 | 51 | source_loc source; 52 | const string_view_t payload; 53 | }; 54 | } // namespace details 55 | } // namespace spdlog 56 | -------------------------------------------------------------------------------- /source/vendor/spdlog/details/null_mutex.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #include 9 | // null, no cost dummy "mutex" and dummy "atomic" int 10 | 11 | namespace spdlog { 12 | namespace details { 13 | struct null_mutex 14 | { 15 | void lock() {} 16 | void unlock() {} 17 | bool try_lock() 18 | { 19 | return true; 20 | } 21 | }; 22 | 23 | struct null_atomic_int 24 | { 25 | int value; 26 | null_atomic_int() = default; 27 | 28 | explicit null_atomic_int(int val) 29 | : value(val) 30 | { 31 | } 32 | 33 | int load(std::memory_order) const 34 | { 35 | return value; 36 | } 37 | 38 | void store(int val) 39 | { 40 | value = val; 41 | } 42 | }; 43 | 44 | } // namespace details 45 | } // namespace spdlog 46 | -------------------------------------------------------------------------------- /source/vendor/spdlog/details/periodic_worker.h: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Copyright(c) 2018 Gabi Melman. 4 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 5 | // 6 | 7 | #pragma once 8 | 9 | // periodic worker thread - periodically executes the given callback common. 10 | // 11 | // RAII over the owned thread: 12 | // creates the thread on construction. 13 | // stops and joins the thread on destruction (if the thread is executing a callback, wait for it to finish first). 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | namespace spdlog { 21 | namespace details { 22 | 23 | class periodic_worker 24 | { 25 | public: 26 | periodic_worker(const std::function &callback_fun, std::chrono::seconds interval) 27 | { 28 | active_ = (interval > std::chrono::seconds::zero()); 29 | if (!active_) 30 | { 31 | return; 32 | } 33 | 34 | worker_thread_ = std::thread([this, callback_fun, interval]() { 35 | for (;;) 36 | { 37 | std::unique_lock lock(this->mutex_); 38 | if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) 39 | { 40 | return; // active_ == false, so exit this thread 41 | } 42 | callback_fun(); 43 | } 44 | }); 45 | } 46 | 47 | periodic_worker(const periodic_worker &) = delete; 48 | periodic_worker &operator=(const periodic_worker &) = delete; 49 | 50 | // stop the worker thread and join it 51 | ~periodic_worker() 52 | { 53 | if (worker_thread_.joinable()) 54 | { 55 | { 56 | std::lock_guard lock(mutex_); 57 | active_ = false; 58 | } 59 | cv_.notify_one(); 60 | worker_thread_.join(); 61 | } 62 | } 63 | 64 | private: 65 | bool active_; 66 | std::thread worker_thread_; 67 | std::mutex mutex_; 68 | std::condition_variable cv_; 69 | }; 70 | } // namespace details 71 | } // namespace spdlog 72 | -------------------------------------------------------------------------------- /source/vendor/spdlog/fmt/bundled/LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2016, Victor Zverovich 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /source/vendor/spdlog/fmt/fmt.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016-2018 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | // 9 | // Include a bundled header-only copy of fmtlib or an external one. 10 | // By default spdlog include its own copy. 11 | // 12 | 13 | #if !defined(SPDLOG_FMT_EXTERNAL) 14 | #ifndef FMT_HEADER_ONLY 15 | #define FMT_HEADER_ONLY 16 | #endif 17 | #ifndef FMT_USE_WINDOWS_H 18 | #define FMT_USE_WINDOWS_H 0 19 | #endif 20 | #include "vendor/spdlog/fmt/bundled/core.h" 21 | #include "vendor/spdlog/fmt/bundled/format.h" 22 | #else // external fmtlib 23 | #include 24 | #include 25 | #endif 26 | -------------------------------------------------------------------------------- /source/vendor/spdlog/fmt/ostr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ostream support 9 | // 10 | #if !defined(SPDLOG_FMT_EXTERNAL) 11 | #ifndef FMT_HEADER_ONLY 12 | #define FMT_HEADER_ONLY 13 | #endif 14 | #include "vendor/spdlog/fmt/bundled/ostream.h" 15 | #include "fmt.h" 16 | #else 17 | #include 18 | #endif 19 | -------------------------------------------------------------------------------- /source/vendor/spdlog/formatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #include "vendor/spdlog/fmt/fmt.h" 9 | #include "vendor/spdlog/details/log_msg.h" 10 | 11 | namespace spdlog { 12 | 13 | class formatter 14 | { 15 | public: 16 | virtual ~formatter() = default; 17 | virtual void format(const details::log_msg &msg, fmt::memory_buffer &dest) = 0; 18 | virtual std::unique_ptr clone() const = 0; 19 | }; 20 | } // namespace spdlog 21 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/base_sink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // base sink templated over a mutex (either dummy or real) 9 | // concrete implementation should override the sink_it_() and flush_() methods. 10 | // locking is taken care of in this class - no locking needed by the 11 | // implementers.. 12 | // 13 | 14 | #include "vendor/spdlog/common.h" 15 | #include "vendor/spdlog/details/log_msg.h" 16 | #include "vendor/spdlog/formatter.h" 17 | #include "sink.h" 18 | 19 | namespace spdlog { 20 | namespace sinks { 21 | template 22 | class base_sink : public sink 23 | { 24 | public: 25 | base_sink() = default; 26 | base_sink(const base_sink &) = delete; 27 | base_sink &operator=(const base_sink &) = delete; 28 | 29 | void log(const details::log_msg &msg) final 30 | { 31 | std::lock_guard lock(mutex_); 32 | sink_it_(msg); 33 | } 34 | 35 | void flush() final 36 | { 37 | std::lock_guard lock(mutex_); 38 | flush_(); 39 | } 40 | 41 | void set_pattern(const std::string &pattern) final 42 | { 43 | std::lock_guard lock(mutex_); 44 | set_pattern_(pattern); 45 | } 46 | 47 | void set_formatter(std::unique_ptr sink_formatter) final 48 | { 49 | std::lock_guard lock(mutex_); 50 | set_formatter_(std::move(sink_formatter)); 51 | } 52 | 53 | protected: 54 | virtual void sink_it_(const details::log_msg &msg) = 0; 55 | virtual void flush_() = 0; 56 | 57 | virtual void set_pattern_(const std::string &pattern) 58 | { 59 | set_formatter_(details::make_unique(pattern)); 60 | } 61 | 62 | virtual void set_formatter_(std::unique_ptr sink_formatter) 63 | { 64 | formatter_ = std::move(sink_formatter); 65 | } 66 | Mutex mutex_; 67 | }; 68 | } // namespace sinks 69 | } // namespace spdlog 70 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/basic_file_sink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015-2018 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef SPDLOG_H 9 | #include "vendor/spdlog/spdlog.h" 10 | #endif 11 | 12 | #include "vendor/spdlog/details/file_helper.h" 13 | #include "vendor/spdlog/details/null_mutex.h" 14 | #include "base_sink.h" 15 | 16 | #include 17 | #include 18 | 19 | namespace spdlog { 20 | namespace sinks { 21 | /* 22 | * Trivial file sink with single file as target 23 | */ 24 | template 25 | class basic_file_sink final : public base_sink 26 | { 27 | public: 28 | explicit basic_file_sink(const filename_t &filename, bool truncate = false) 29 | { 30 | file_helper_.open(filename, truncate); 31 | } 32 | 33 | const filename_t &filename() const 34 | { 35 | return file_helper_.filename(); 36 | } 37 | 38 | protected: 39 | void sink_it_(const details::log_msg &msg) override 40 | { 41 | fmt::memory_buffer formatted; 42 | sink::formatter_->format(msg, formatted); 43 | file_helper_.write(formatted); 44 | } 45 | 46 | void flush_() override 47 | { 48 | file_helper_.flush(); 49 | } 50 | 51 | private: 52 | details::file_helper file_helper_; 53 | }; 54 | 55 | using basic_file_sink_mt = basic_file_sink; 56 | using basic_file_sink_st = basic_file_sink; 57 | 58 | } // namespace sinks 59 | 60 | // 61 | // factory functions 62 | // 63 | template 64 | inline std::shared_ptr basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false) 65 | { 66 | return Factory::template create(logger_name, filename, truncate); 67 | } 68 | 69 | template 70 | inline std::shared_ptr basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false) 71 | { 72 | return Factory::template create(logger_name, filename, truncate); 73 | } 74 | 75 | } // namespace spdlog 76 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/msvc_sink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Alexander Dalshov. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef SPDLOG_H 9 | #include "vendor/spdlog/spdlog.h" 10 | #endif 11 | 12 | #if defined(_WIN32) 13 | 14 | #include "spdlog/details/null_mutex.h" 15 | #include "spdlog/sinks/base_sink.h" 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | namespace spdlog { 23 | namespace sinks { 24 | /* 25 | * MSVC sink (logging using OutputDebugStringA) 26 | */ 27 | template 28 | class msvc_sink : public base_sink 29 | { 30 | public: 31 | explicit msvc_sink() {} 32 | 33 | protected: 34 | void sink_it_(const details::log_msg &msg) override 35 | { 36 | 37 | fmt::memory_buffer formatted; 38 | sink::formatter_->format(msg, formatted); 39 | OutputDebugStringA(fmt::to_string(formatted).c_str()); 40 | } 41 | 42 | void flush_() override {} 43 | }; 44 | 45 | using msvc_sink_mt = msvc_sink; 46 | using msvc_sink_st = msvc_sink; 47 | 48 | using windebug_sink_mt = msvc_sink_mt; 49 | using windebug_sink_st = msvc_sink_st; 50 | 51 | } // namespace sinks 52 | } // namespace spdlog 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/null_sink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef SPDLOG_H 9 | #include "vendor/spdlog/spdlog.h" 10 | #endif 11 | 12 | #include "vendor/spdlog/details/null_mutex.h" 13 | #include "base_sink.h" 14 | 15 | #include 16 | 17 | namespace spdlog { 18 | namespace sinks { 19 | 20 | template 21 | class null_sink : public base_sink 22 | { 23 | protected: 24 | void sink_it_(const details::log_msg &) override {} 25 | void flush_() override {} 26 | }; 27 | 28 | using null_sink_mt = null_sink; 29 | using null_sink_st = null_sink; 30 | 31 | } // namespace sinks 32 | 33 | template 34 | inline std::shared_ptr null_logger_mt(const std::string &logger_name) 35 | { 36 | auto null_logger = Factory::template create(logger_name); 37 | null_logger->set_level(level::off); 38 | return null_logger; 39 | } 40 | 41 | template 42 | inline std::shared_ptr null_logger_st(const std::string &logger_name) 43 | { 44 | auto null_logger = Factory::template create(logger_name); 45 | null_logger->set_level(level::off); 46 | return null_logger; 47 | } 48 | 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/ostream_sink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef SPDLOG_H 9 | #include "vendor/spdlog/spdlog.h" 10 | #endif 11 | 12 | #include "vendor/spdlog/details/null_mutex.h" 13 | #include "base_sink.h" 14 | 15 | #include 16 | #include 17 | 18 | namespace spdlog { 19 | namespace sinks { 20 | template 21 | class ostream_sink final : public base_sink 22 | { 23 | public: 24 | explicit ostream_sink(std::ostream &os, bool force_flush = false) 25 | : ostream_(os) 26 | , force_flush_(force_flush) 27 | { 28 | } 29 | ostream_sink(const ostream_sink &) = delete; 30 | ostream_sink &operator=(const ostream_sink &) = delete; 31 | 32 | protected: 33 | void sink_it_(const details::log_msg &msg) override 34 | { 35 | fmt::memory_buffer formatted; 36 | sink::formatter_->format(msg, formatted); 37 | ostream_.write(formatted.data(), static_cast(formatted.size())); 38 | if (force_flush_) 39 | { 40 | ostream_.flush(); 41 | } 42 | } 43 | 44 | void flush_() override 45 | { 46 | ostream_.flush(); 47 | } 48 | 49 | std::ostream &ostream_; 50 | bool force_flush_; 51 | }; 52 | 53 | using ostream_sink_mt = ostream_sink; 54 | using ostream_sink_st = ostream_sink; 55 | 56 | } // namespace sinks 57 | } // namespace spdlog 58 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/sink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #include "vendor/spdlog/details/log_msg.h" 9 | #include "vendor/spdlog/details/pattern_formatter.h" 10 | #include "vendor/spdlog/formatter.h" 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | class sink 15 | { 16 | public: 17 | sink() = default; 18 | 19 | explicit sink(std::unique_ptr formatter) 20 | : formatter_{std::move(formatter)} 21 | { 22 | } 23 | 24 | virtual ~sink() = default; 25 | virtual void log(const details::log_msg &msg) = 0; 26 | virtual void flush() = 0; 27 | virtual void set_pattern(const std::string &pattern) = 0; 28 | virtual void set_formatter(std::unique_ptr sink_formatter) = 0; 29 | 30 | bool should_log(level::level_enum msg_level) const 31 | { 32 | return msg_level >= level_.load(std::memory_order_relaxed); 33 | } 34 | 35 | void set_level(level::level_enum log_level) 36 | { 37 | level_.store(log_level); 38 | } 39 | 40 | level::level_enum level() const 41 | { 42 | return static_cast(level_.load(std::memory_order_relaxed)); 43 | } 44 | 45 | protected: 46 | // sink log level - default is all 47 | level_t level_{level::trace}; 48 | 49 | // sink formatter - default is full format 50 | std::unique_ptr formatter_{details::make_unique()}; 51 | }; 52 | 53 | } // namespace sinks 54 | } // namespace spdlog 55 | -------------------------------------------------------------------------------- /source/vendor/spdlog/sinks/stdout_color_sinks.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2018 spdlog 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef SPDLOG_H 9 | #include "vendor/spdlog/spdlog.h" 10 | #endif 11 | 12 | #ifdef _WIN32 13 | #include "spdlog/sinks/wincolor_sink.h" 14 | #else 15 | #include "ansicolor_sink.h" 16 | #endif 17 | 18 | namespace spdlog { 19 | namespace sinks { 20 | #ifdef _WIN32 21 | using stdout_color_sink_mt = wincolor_stdout_sink_mt; 22 | using stdout_color_sink_st = wincolor_stdout_sink_st; 23 | using stderr_color_sink_mt = wincolor_stderr_sink_mt; 24 | using stderr_color_sink_st = wincolor_stderr_sink_st; 25 | #else 26 | using stdout_color_sink_mt = ansicolor_stdout_sink_mt; 27 | using stdout_color_sink_st = ansicolor_stdout_sink_st; 28 | using stderr_color_sink_mt = ansicolor_stderr_sink_mt; 29 | using stderr_color_sink_st = ansicolor_stderr_sink_st; 30 | #endif 31 | } // namespace sinks 32 | 33 | template 34 | inline std::shared_ptr stdout_color_mt(const std::string &logger_name) 35 | { 36 | return Factory::template create(logger_name); 37 | } 38 | 39 | template 40 | inline std::shared_ptr stdout_color_st(const std::string &logger_name) 41 | { 42 | return Factory::template create(logger_name); 43 | } 44 | 45 | template 46 | inline std::shared_ptr stderr_color_mt(const std::string &logger_name) 47 | { 48 | return Factory::template create(logger_name); 49 | } 50 | 51 | template 52 | inline std::shared_ptr stderr_color_st(const std::string &logger_name) 53 | { 54 | return Factory::template create(logger_name); 55 | } 56 | } // namespace spdlog 57 | -------------------------------------------------------------------------------- /source/vendor/spdlog/version.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #define SPDLOG_VER_MAJOR 1 9 | #define SPDLOG_VER_MINOR 3 10 | #define SPDLOG_VER_PATCH 1 11 | 12 | #define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH) 13 | -------------------------------------------------------------------------------- /source/vendor/stb/stb_image.cpp: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_IMPLEMENTATION 2 | #include "stb_image.h" -------------------------------------------------------------------------------- /source/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | namespace Version 6 | { 7 | 8 | struct Version 9 | { 10 | /// Creates empty Version object 11 | Version(); 12 | 13 | /** 14 | * Converts number to version object. 15 | * @param version - number in format MMMMmmmmpppp (M-Major, m-minor, 16 | * p-patch) 17 | * 18 | * @return Version object 19 | */ 20 | Version(long long version); 21 | 22 | int major{0}; 23 | int minor{0}; 24 | int patch{0}; 25 | 26 | /// Type of build 27 | std::string type{""}; 28 | 29 | /// Get time of build in format like: Feb 20 2016 14:38:27 30 | std::string datetime{""}; 31 | 32 | /// Machine where it was built 33 | std::string machine{""}; 34 | 35 | /** 36 | * Returns version in one big number with format: 37 | * 38 | * * MMMMmmmmpppp (M-Major, m-minor, p-patch) 39 | * 40 | * So 1.2.3 will be 100020003 (leading zeroes are not displayed) 41 | * @return long integer with version 42 | */ 43 | long long asNumber() const; 44 | 45 | /** 46 | * Returns version string with version in format: 47 | * * Major.Minor.Patch VersionType 48 | * * 1.2.3 beta 49 | */ 50 | std::string asShortStr() const; 51 | 52 | /** 53 | * Returns Version + Date + Build machine 54 | * 55 | * Will produce result similar to: 56 | * 1.2.6 beta / Feb 20 2016 14:42:41 / buildMachine 57 | */ 58 | std::string asLongStr() const; 59 | 60 | // Operators 61 | bool operator<(const Version& other); 62 | bool operator>(const Version& other); 63 | bool operator<=(const Version& other); 64 | bool operator>=(const Version& other); 65 | bool operator==(const Version& other); 66 | bool operator!=(const Version& other); 67 | }; 68 | 69 | /// Get current version 70 | const Version& current(); 71 | 72 | 73 | } // namespace Version 74 | -------------------------------------------------------------------------------- /test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SylvainDeker/Shader-Graph/c572928b75c9fb2d8294254995259f153707c34b/test/.DS_Store -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # https://cmake.org/cmake/help/latest/manual/ctest.1.html 2 | # https://cmake.org/Wiki/CMake/Testing_With_CTest 3 | # https://cmake.org/cmake/help/latest/command/add_test.html? 4 | 5 | include(CTest) 6 | 7 | # Convenience targets for fast testing, they depends on binaries (so the build 8 | # is triggered, when sources were changed). 9 | add_custom_target(check 10 | COMMAND echo [----] Running tests 11 | USES_TERMINAL 12 | COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C Debug 13 | DEPENDS ShaderGraph unittests) 14 | 15 | add_custom_target(checkVerbose 16 | COMMAND echo [----] Running tests 17 | USES_TERMINAL 18 | COMMAND ${CMAKE_CTEST_COMMAND} -V --output-on-failure -C Debug 19 | DEPENDS ShaderGraph unittests) 20 | 21 | #------------------------------------------------------------------------------ 22 | # CTest test suite 23 | # 24 | # Test suite is defined here, when executed test fails (returns not 0), test 25 | # failed. There are more options, check CMake documentation. 26 | # 27 | # Good to use to integration test, run whole program with parameters, 28 | # check if it will crash, produce correct results, etc. 29 | 30 | 31 | # Basic runable tests (will not crash) 32 | add_test(NAME "Is_Runable " 33 | COMMAND $) 34 | 35 | add_test(NAME "Is_Runable-v" 36 | COMMAND $ -v) 37 | 38 | add_test(NAME "Is_Runable-h" 39 | COMMAND $ -h) 40 | 41 | 42 | 43 | # Add unit test to CTest suite as one of the tests 44 | # unit test build is located in source/unittest/CMakeLists.txt 45 | add_test(NAME "catch_unit_tests" 46 | COMMAND $ 47 | USES_TERMINAL 48 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 49 | 50 | --------------------------------------------------------------------------------