Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决打开文件时可能造成的野指针问题 #27

Merged
merged 33 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
837cd65
增加macOS支持cmake编译
DaChengTechnology Jan 13, 2022
ac1aa98
Merge branch 'main' of https://github.com/scarsty/node-editor into sc…
DaChengTechnology Jan 13, 2022
94bea9b
修复Cannot create __weak reference
DaChengTechnology Jan 13, 2022
d5d78ec
a
DaChengTechnology Jan 13, 2022
dc72952
Merge branch 'main' into main
DaChengTechnology Jan 13, 2022
5a317e1
add MRC
DaChengTechnology Jan 13, 2022
820082c
Merge branch 'main' of https://github.com/scarsty/node-editor into sc…
DaChengTechnology Jan 13, 2022
3b02201
fix yaml
DaChengTechnology Jan 13, 2022
09ffe10
可以生成app 但是 会报空指针
DaChengTechnology Jan 19, 2022
da7a303
Merge remote-tracking branch 'upstream/main'
DaChengTechnology Jan 19, 2022
fde185d
macOS 运行成功
DaChengTechnology Jan 20, 2022
56fbbf8
改名
DaChengTechnology Jan 20, 2022
493d57d
nn
DaChengTechnology Jan 20, 2022
ee6d266
Merge branch 'main' of https://github.com/DaChengTechnology/node-editor
DaChengTechnology Jan 20, 2022
1cdd9cd
修改名字
DaChengTechnology Jan 20, 2022
cb66d4d
Merge branch 'main' of https://github.com/scarsty/nn-editor into scar…
DaChengTechnology Jan 20, 2022
d16013e
1
DaChengTechnology Jan 20, 2022
2109d10
修改cmake
DaChengTechnology Jan 20, 2022
355bf5c
fix 25ad188654dd93c1e6cb562999874d5f83da57e3
DaChengTechnology Jan 20, 2022
fe81310
Merge branch 'main' into main
DaChengTechnology Jan 20, 2022
401f3e2
修复 info位置
DaChengTechnology Jan 20, 2022
b2f4a3b
修复info
DaChengTechnology Jan 20, 2022
962cdf6
Merge branch 'main' of https://github.com/DaChengTechnology/node-editor
DaChengTechnology Jan 20, 2022
825aa51
Merge branch 'main' into main
DaChengTechnology Jan 20, 2022
52d2bbc
Merge branch 'scarsty:main' into main
DaChengTechnology Jan 21, 2022
e60ea8a
修复编译
DaChengTechnology Jan 21, 2022
986ca84
fix install
DaChengTechnology Jan 21, 2022
ac83292
fix resouce
DaChengTechnology Jan 21, 2022
0e62fe9
review main
DaChengTechnology Jan 21, 2022
a69ce7a
fix arc
DaChengTechnology Jan 21, 2022
c0fc3f0
修复node内存
DaChengTechnology Jan 24, 2022
8c549be
Merge branch 'main' of https://github.com/scarsty/nn-editor into scar…
DaChengTechnology Jan 24, 2022
9d2a209
修改node
DaChengTechnology Jan 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.vs/
node-editor/x64/
nn-editor/x64/
x64/
node-editor/imgui.ini
nn-editor/imgui.ini
build
cmake-build-debug
cmake-build-release
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ if (NOT DEFINED CMAKE_INSTALL_PREFIX)
endif()

# project name
project(node-editor)
project(nn-editor)

option(NETEDIT_LOADER_CCCC "support cccc model loader" ON)
option(NETEDIT_LOADER_NCNN "support ncnn model loader" ON)
option(NETEDIT_LOADER_YAML_YOLO "support yaml yolo model loader" ON)

# import IMGUI
include(${CMAKE_SOURCE_DIR}/cmake/imgui.cmake)
Expand All @@ -23,7 +27,29 @@ add_executable(${PROJECT_NAME})
set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS NDEBUG)
set_target_properties (${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)


# collect the source files
list (APPEND NODE_EDITOR_SRCS nn-editor/nn_editor.cpp)
list (APPEND NODE_EDITOR_SRCS nn-editor/loader.cpp)

# cccc is always loaded. qing zhi chi cccc.
list (APPEND NODE_EDITOR_SRCS nn-editor/ccccloader.cpp)
add_definitions(-DNETEDIT_LOADER_CCCC)

if(NETEDIT_LOADER_NCNN)
list (APPEND NODE_EDITOR_SRCS nn-editor/ncnnloader.cpp)
add_definitions(-DNETEDIT_LOADER_NCNN)
endif()

if(NETEDIT_LOADER_YAML_YOLO)
list (APPEND NODE_EDITOR_SRCS nn-editor/yamlyololoader.cpp)
add_definitions(-DNETEDIT_LOADER_YAML_YOLO)

find_package(YAML-CPP)
target_include_directories(${PROJECT_NAME} PRIVATE ${YAML_CPP_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${YAML_CPP_LIBRARIES})
endif()

if(APPLE)
set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR})
enable_language(OBJC)
Expand Down Expand Up @@ -65,7 +91,7 @@ target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty

target_link_libraries (${PROJECT_NAME} PRIVATE IMGUI)
find_package(SDL2)
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL2_LIBRARIES})

if (UNIX)
Expand Down
14 changes: 7 additions & 7 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to Build in the Linux
# Build on Linux

Install required build dependecies:
Install build dependencies:

- git
- cmake
Expand All @@ -11,15 +11,15 @@ Install required build dependecies:
- OpenGL
- [yaml-cpp](https://github.com/jbeder/yaml-cpp)

**Git clone the node-editor repo with submodule**
**Git clone the nn-editor repo with submodule**

```
git clone https://github.com/scarsty/node-editor
cd node-editor
git clone https://github.com/scarsty/nn-editor
cd nn-editor
git submodule update --init
```

**And you can use this to build this repo**
**And you can use these to build this repo**

Please modify the **CMakeLists.txt**

Expand Down Expand Up @@ -49,7 +49,7 @@ cmake -G "Xcode"

**SDL2 install**

- `download the source from the offcial website:http://www.libsdl.org/`
- `download the source from offcial website:http://www.libsdl.org/`

```
wget https://www.libsdl.org/release/SDL2-2.0.18.zip
Expand Down
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
## node-editor
# nn-editor

<img src='https://raw.githubusercontent.com/scarsty/node-editor/master/logo.jpg'/>
<div align="right">

<img src="assets/logo.png" width="100px">

</div>

基于 [imnodes](https://github.com/Nelarius/imnodes) 的流程图编辑工具。

目前的主要功能是用于神经网络结构的简单编辑,或者某些特殊流程图的编辑。

目标是老妪能训。

QQ 群: 822911263

### 操作

* 按住中键,或者Alt+左键可以拖动整个图。
Expand All @@ -23,9 +29,20 @@
* ini范例
* [ncnn](https://github.com/Tencent/ncnn/wiki/param-and-model-file-structure)
* [pnnx](https://github.com/pnnx/pnnx) 该格式与ncnn基本一致,故可以直接支持,实际因为参数列表较长体验有些问题
* yolo的简化格式(YAML)

请大佬们pr支持新格式!

<img src='https://raw.githubusercontent.com/scarsty/node-editor/master/images/lenet.png'/>
<img src='https://raw.githubusercontent.com/scarsty/node-editor/master/images/ncnn.png'/>
<img src='https://raw.githubusercontent.com/scarsty/node-editor/master/images/ncnn2.png'/>
<div align="center">

<img src="assets/lenet.png">
<img src="assets/ncnn.png">
<img src="assets/ncnn2.png">

</div>

## 授权

```bash
以 BSD 3-Clause License 授权发布。若将其商业应用,我们建议您提交一张书法照到官方 QQ 群。
```
File renamed without changes
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
14 changes: 13 additions & 1 deletion cmake/imgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ endif()
if(NOT IMGUI_RENDERER)
CHECK_PACKAGES()

# (penguinliong) SDL2 platform MUST match SDL2 renderer.
if (IMGUI_PLATFORM MATCHES SDL2)
set (IMGUI_RENDERER SDL2)
endif()

if (Vulkan_FOUND AND (NOT IMGUI_RENDERER))
set (IMGUI_RENDERER VULKAN)
endif()
Expand Down Expand Up @@ -207,6 +212,8 @@ target_sources (IMGUI INTERFACE ${IMGUI_BASE_DIR}/misc/cpp/imgui_stdlib.cpp)

# judge platform
if (IMGUI_PLATFORM)
message("-- ImGui platform is " ${IMGUI_PLATFORM})

if (IMGUI_PLATFORM MATCHES WIN32)
target_sources (IMGUI INTERFACE ${IMGUI_BASE_DIR}/backends/imgui_impl_win32.cpp)
elseif (IMGUI_PLATFORM MATCHES SDL2)
Expand All @@ -226,6 +233,8 @@ endif ()

# judge renderer
if (IMGUI_RENDERER)
message("-- ImGui renderer is " ${IMGUI_RENDERER})

if (IMGUI_RENDERER MATCHES VULKAN)
target_sources (IMGUI INTERFACE ${IMGUI_BASE_DIR}/backends/imgui_impl_vulkan.cpp)
elseif (IMGUI_RENDERER MATCHES SDL2)
Expand Down Expand Up @@ -261,6 +270,8 @@ endif()
if (IMGUI_PLATFORM MATCHES WIN32)
# TODO: link what?
elseif (IMGUI_PLATFORM MATCHES SDL2)
# TODO: (penguinliong) Remember to copy the SDL dynamic library to the
# binary dir in a future update.
target_link_libraries (IMGUI INTERFACE SDL2::SDL2)
elseif (IMGUI_PLATFORM MATCHES GLFW)
# TODO: link what? header where?
Expand All @@ -272,7 +283,8 @@ endif()

# for renderer
if (IMGUI_RENDERER MATCHES VULKAN)
target_link_libraries (IMGUI INTERFACE vulkan)
target_include_directories(IMGUI INTERFACE ${Vulkan_INCLUDE_DIR})
target_link_libraries (IMGUI INTERFACE ${Vulkan_LIBRARY})
elseif (IMGUI_RENDERER MATCHES SDL2)
# TODO: this part may not work
#target_link_libraries (IMGUI INTERFACE SDL2main)
Expand Down
19 changes: 16 additions & 3 deletions imnodes2/imnodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,14 @@ void ClickInteractionUpdate(ImNodesEditorContext& editor)
}
}
case ImNodesClickInteractionType_None:
{
const bool dragging = GImNodes->AltMouseDragging;

if (dragging)
{
editor.Panning += ImGui::GetIO().MouseDelta;
}
}
break;
default:
assert(!"Unreachable code!");
Expand Down Expand Up @@ -1923,7 +1931,7 @@ ImNodesIO::LinkDetachWithModifierClick::LinkDetachWithModifierClick() : Modifier

ImNodesIO::ImNodesIO()
: EmulateThreeButtonMouse(), LinkDetachWithModifierClick(),
AltMouseButton(ImGuiMouseButton_Middle), AutoPanningSpeed(1000.0f)
AltMouseButton(ImGuiMouseButton_Right), AutoPanningSpeed(1000.0f)
{
}

Expand Down Expand Up @@ -2018,6 +2026,11 @@ void StyleColorsDark()
GImNodes->Style.Colors[ImNodesCol_Link] = IM_COL32(61, 133, 224, 200);
GImNodes->Style.Colors[ImNodesCol_LinkHovered] = IM_COL32(66, 150, 250, 255);
GImNodes->Style.Colors[ImNodesCol_LinkSelected] = IM_COL32(66, 150, 250, 255);

GImNodes->Style.Colors[ImNodesCol_Link] = IM_COL32(66, 150, 250, 100);
GImNodes->Style.Colors[ImNodesCol_LinkHovered] = IM_COL32(99, 200, 250, 224);
GImNodes->Style.Colors[ImNodesCol_LinkSelected] = IM_COL32(255, 69, 91, 224);

// pin colors match ImGui's button colors
GImNodes->Style.Colors[ImNodesCol_Pin] = IM_COL32(53, 150, 250, 180);
GImNodes->Style.Colors[ImNodesCol_PinHovered] = IM_COL32(53, 150, 250, 255);
Expand Down Expand Up @@ -2093,8 +2106,8 @@ void StyleColorsLight()
// original imgui values: 66, 150, 250
GImNodes->Style.Colors[ImNodesCol_Link] = IM_COL32(66, 150, 250, 100);
// original imgui values: 117, 138, 204
GImNodes->Style.Colors[ImNodesCol_LinkHovered] = IM_COL32(66, 150, 250, 242);
GImNodes->Style.Colors[ImNodesCol_LinkSelected] = IM_COL32(66, 150, 250, 242);
GImNodes->Style.Colors[ImNodesCol_LinkHovered] = IM_COL32(66, 150, 250, 224);
GImNodes->Style.Colors[ImNodesCol_LinkSelected] = IM_COL32(255, 69, 91, 224);
// original imgui values: 66, 150, 250
GImNodes->Style.Colors[ImNodesCol_Pin] = IM_COL32(66, 150, 250, 160);
GImNodes->Style.Colors[ImNodesCol_PinHovered] = IM_COL32(66, 150, 250, 255);
Expand Down
Binary file removed logo.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion node-editor.sln → nn-editor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "node-editor", "node-editor\node-editor.vcxproj", "{6A66CF82-B67C-456F-BD0E-3C7E2944B6F2}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nn-editor", "nn-editor\nn-editor.vcxproj", "{6A66CF82-B67C-456F-BD0E-3C7E2944B6F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
4 changes: 0 additions & 4 deletions nn-editor/ccccloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ void ccccLoader::fileToNodes(const std::string& filename, std::deque<Node>& node

std::string prefix = "layer_";
auto sections = ini.getAllSections();
std::sort(sections.begin(), sections.end(), [&](const std::string& l, const std::string& r)
{
return ini.getSectionNo(l) < ini.getSectionNo(r);
});

int x = -1;
int y = -1;
Expand Down
Loading