Skip to content

Commit eff8db9

Browse files
committed
Init
1 parent 4cf6c26 commit eff8db9

File tree

334 files changed

+158696
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

334 files changed

+158696
-1
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
*.project
35+
/bin
36+
/data
37+
/source
38+
/launch*
39+
junk
40+
.thumbnails

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
11
# unigine-2.14-editor-plugin-python3scripting
2-
Pluging for scripting by python in Unigine Editor
2+
3+
Pluging for scripting by python3 in Unigine Editor https://unigine.com/get-unigine/
4+
5+
* License of plugin: MIT
6+
* For code editor used: https://github.com/Megaxela/QCodeEditor - under MIT license
7+
* Unigine SDK 2.14 - tested on `Community Free`
8+
9+
## Build instruction
10+
11+
### Linux (Ubuntu)
12+
13+
```
14+
$ sudo apt install qt5-default python3 python3-dev
15+
```
16+
17+
*`unigine_project` folder - where you can see `data` and with `bin` and with `include` and launchers*
18+
19+
- Download this project via git or as zip
20+
- Copy `UnigineEditorPlugin_Python3Scripting` to your `unigine_project` folder
21+
- Copy `build_plugin.sh` to to your `unigine_project` folder
22+
- Open terminal in your `unigine_project` folder
23+
- chmod +x build_plugin.sh
24+
- ./build_plugin.sh
25+
26+
After this call `./launch_editor.sh` or launch editor from `UNIGINE SDK Browser`
27+
28+
## Helpful links
29+
30+
- https://www.codeproject.com/Articles/820116/Embedding-Python-program-in-a-C-Cplusplus-code
31+
- https://docs.python.org/3.7/c-api/bytes.html
32+
- https://habr.com/ru/post/469043/
33+
- https://intermediate-and-advanced-software-carpentry.readthedocs.io/en/latest/c++-wrapping.html
34+
35+
Here can find wrappers:
36+
- https://github.com/Berenco/texworks
37+
38+
New type (class)
39+
- https://docs.python.org/3/c-api/typeobj.html
40+
- https://docs.python.org/3/c-api/typeobj.html#typedef-examples
41+
- https://docs.python.org/3.5/extending/newtypes.html
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright (C), UNIGINE. All rights reserved.
2+
3+
cmake_minimum_required(VERSION 3.14)
4+
project(UnigineEditorPlugin CXX)
5+
6+
set(PYTHON3SCRIPTING_VERSION "0.0.1")
7+
add_definitions(-DPYTHON3SCRIPTING_VERSION="${PYTHON3SCRIPTING_VERSION}")
8+
add_subdirectory(QCodeEditor)
9+
10+
include(${PROJECT_SOURCE_DIR}/cmake/Unigine.cmake)
11+
12+
if (EXISTS ${PROJECT_SOURCE_DIR}/UnigineEditorPlugin_Python3Scripting.json.in)
13+
set(PLUGIN_VERSION ${UNIGINE_VERSION})
14+
set(PLUGIN_COMPAT_VERSION ${PYTHON3SCRIPTING_VERSION})
15+
configure_file(
16+
${PROJECT_SOURCE_DIR}/UnigineEditorPlugin_Python3Scripting.json.in
17+
${CMAKE_CURRENT_BINARY_DIR}/Plugin.json
18+
)
19+
endif()
20+
21+
set(RESOURCES_FILE
22+
resources/UnigineEditorPlugin_Python3Scripting_resources.qrc
23+
)
24+
25+
set(CMAKE_AUTOMOC TRUE)
26+
set(CMAKE_AUTOUIC TRUE)
27+
set(CMAKE_AUTORCC TRUE)
28+
29+
find_package (Python COMPONENTS Interpreter Development REQUIRED)
30+
31+
message("Python_FOUND:${Python_FOUND}")
32+
message("Python_VERSION:${Python_VERSION}")
33+
message("Python_Development_FOUND:${Python_Development_FOUND}")
34+
message("Python_LIBRARIES:${Python_LIBRARIES}")
35+
36+
find_package(Qt5 COMPONENTS Widgets REQUIRED)
37+
38+
add_library(UnigineEditorPlugin_Python3Scripting SHARED
39+
${RESOURCES_FILE}
40+
${PROJECT_SOURCE_DIR}/src/UnigineEditorPlugin_Python3Scripting.cpp
41+
${PROJECT_SOURCE_DIR}/src/PythonExecutor.cpp
42+
${PROJECT_SOURCE_DIR}/src/CreateExtensionDialog.cpp
43+
${PROJECT_SOURCE_DIR}/src/EditExtensionDialog.cpp
44+
${PROJECT_SOURCE_DIR}/src/CollectorMenuSelected.cpp
45+
${PROJECT_SOURCE_DIR}/src/ModelExtension.cpp
46+
${PROJECT_SOURCE_DIR}/src/unigine_python_wrapper/unigine_python_material.cpp
47+
${PROJECT_SOURCE_DIR}/src/unigine_python_wrapper/unigine_python_stdout.cpp
48+
${PROJECT_SOURCE_DIR}/src/unigine_python_wrapper/unigine_python_stderr.cpp
49+
${PROJECT_SOURCE_DIR}/src/unigine_python_wrapper/unigine_python_unigine_lib.cpp
50+
)
51+
52+
target_include_directories(UnigineEditorPlugin_Python3Scripting SYSTEM
53+
PRIVATE
54+
${PROJECT_SOURCE_DIR}/QCodeEditor/include
55+
${PROJECT_SOURCE_DIR}/include
56+
${PROJECT_SOURCE_DIR}/src/
57+
${PROJECT_SOURCE_DIR}/src/unigine_python_wrapper
58+
${CMAKE_CURRENT_BINARY_DIR}
59+
${Python_INCLUDE_DIRS}
60+
)
61+
62+
target_link_libraries(UnigineEditorPlugin_Python3Scripting
63+
PRIVATE
64+
Unigine::CompilerFlags
65+
Unigine::Engine
66+
Unigine::Editor
67+
Qt5::Core
68+
Qt5::Widgets
69+
${Python_LIBRARIES}
70+
QCodeEditor
71+
)
72+
73+
set_target_properties(UnigineEditorPlugin_Python3Scripting
74+
PROPERTIES
75+
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../bin/editor/
76+
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../bin/editor/
77+
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../lib/editor/
78+
CXX_VISIBILITY_PRESET hidden
79+
)
80+
81+
if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
82+
target_compile_definitions(UnigineEditorPlugin_Python3Scripting
83+
PRIVATE
84+
QT_DEBUG
85+
)
86+
else()
87+
target_compile_definitions(UnigineEditorPlugin_Python3Scripting
88+
PRIVATE
89+
QT_NO_DEBUG
90+
)
91+
endif()
92+
93+
94+
95+
96+
97+
98+
99+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake-build-debug/
2+
cmake-build-release/
3+
.idea/
4+
*~
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
cmake_minimum_required(VERSION 3.6)
2+
project(QCodeEditor)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
6+
option(BUILD_EXAMPLE "Example building required" Off)
7+
8+
if (${BUILD_EXAMPLE})
9+
message(STATUS "QCodeEditor example will be built.")
10+
add_subdirectory(example)
11+
endif()
12+
13+
set(RESOURCES_FILE
14+
resources/qcodeeditor_resources.qrc
15+
)
16+
17+
set(INCLUDE_FILES
18+
include/QHighlightRule
19+
include/QHighlightBlockRule
20+
include/QCodeEditor
21+
include/QCXXHighlighter
22+
include/QLineNumberArea
23+
include/QStyleSyntaxHighlighter
24+
include/QSyntaxStyle
25+
include/QGLSLCompleter
26+
include/QGLSLHighlighter
27+
include/QLanguage
28+
include/QXMLHighlighter
29+
include/QJSONHighlighter
30+
include/QLuaCompleter
31+
include/QLuaHighlighter
32+
include/QPythonHighlighter
33+
include/QFramedTextAttribute
34+
include/internal/QHighlightRule.hpp
35+
include/internal/QHighlightBlockRule.hpp
36+
include/internal/QCodeEditor.hpp
37+
include/internal/QCXXHighlighter.hpp
38+
include/internal/QLineNumberArea.hpp
39+
include/internal/QStyleSyntaxHighlighter.hpp
40+
include/internal/QSyntaxStyle.hpp
41+
include/internal/QGLSLCompleter.hpp
42+
include/internal/QGLSLHighlighter.hpp
43+
include/internal/QLanguage.hpp
44+
include/internal/QXMLHighlighter.hpp
45+
include/internal/QJSONHighlighter.hpp
46+
include/internal/QLuaCompleter.hpp
47+
include/internal/QLuaHighlighter.hpp
48+
include/internal/QPythonCompleter.hpp
49+
include/internal/QPythonHighlighter.hpp
50+
include/internal/QFramedTextAttribute.hpp
51+
)
52+
53+
set(SOURCE_FILES
54+
src/internal/QCodeEditor.cpp
55+
src/internal/QLineNumberArea.cpp
56+
src/internal/QCXXHighlighter.cpp
57+
src/internal/QSyntaxStyle.cpp
58+
src/internal/QStyleSyntaxHighlighter.cpp
59+
src/internal/QGLSLCompleter.cpp
60+
src/internal/QGLSLHighlighter.cpp
61+
src/internal/QLanguage.cpp
62+
src/internal/QXMLHighlighter.cpp
63+
src/internal/QJSONHighlighter.cpp
64+
src/internal/QLuaCompleter.cpp
65+
src/internal/QLuaHighlighter.cpp
66+
src/internal/QPythonCompleter.cpp
67+
src/internal/QPythonHighlighter.cpp
68+
src/internal/QFramedTextAttribute.cpp
69+
)
70+
71+
# Create code for QObjects
72+
set(CMAKE_AUTOMOC On)
73+
74+
# Create code from resource files
75+
set(CMAKE_AUTORCC ON)
76+
77+
# Find includes in corresponding build directories
78+
find_package(Qt5Core CONFIG REQUIRED)
79+
find_package(Qt5Widgets CONFIG REQUIRED)
80+
find_package(Qt5Gui CONFIG REQUIRED)
81+
82+
add_library(QCodeEditor STATIC
83+
${RESOURCES_FILE}
84+
${SOURCE_FILES}
85+
${INCLUDE_FILES}
86+
)
87+
88+
target_include_directories(QCodeEditor PUBLIC
89+
include
90+
)
91+
92+
if(CMAKE_COMPILER_IS_GNUCXX)
93+
target_compile_options(QCodeEditor
94+
PRIVATE
95+
-ansi
96+
-pedantic
97+
-Wall
98+
-Wextra
99+
-Weffc++
100+
-Woverloaded-virtual
101+
-Winit-self
102+
-Wunreachable-code
103+
)
104+
endif(CMAKE_COMPILER_IS_GNUCXX)
105+
106+
target_link_libraries(QCodeEditor
107+
Qt5::Core
108+
Qt5::Widgets
109+
Qt5::Gui
110+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2013-2019 Megaxela
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Qt Code Editor Widget
2+
It's a widget for editing/viewing code.
3+
4+
This project uses a resource named `qcodeeditor_resources.qrc`. The main application
5+
must not use a resource file with the same name.
6+
7+
(It's not a project from a Qt example.)
8+
9+
## Requirements
10+
0. C++11 featured compiler.
11+
0. Qt 5.
12+
13+
## Abilities
14+
1. Auto parentheses.
15+
1. Different highlight rules.
16+
1. Auto indentation.
17+
1. Replace tabs with spaces.
18+
1. GLSL completion rules.
19+
1. GLSL highlight rules.
20+
1. C++ highlight rules.
21+
1. XML highlight rules.
22+
1. JSON highligh rules.
23+
1. Frame selection.
24+
1. Qt Creator styles.
25+
26+
## Build
27+
It's a CMake-based library, so it can be used as a submodule (see the example).
28+
But here are the steps to build it as a static library (for external use for example).
29+
30+
1. Clone the repository: `git clone https://github.com/Megaxela/QCodeEditor`
31+
1. Go into the repository: `cd QCodeEditor`
32+
1. Create a build folder: `mkdir build`
33+
1. Go into the build folder: `cd build`
34+
1. Generate a build file for your compiler: `cmake ..`
35+
1. If you need to build the example, specify `-DBUILD_EXAMPLE=On` on this step.
36+
1. Build the library: `cmake --build .`
37+
38+
## Example
39+
40+
By default, `QCodeEditor` uses the standard QtCreator theme. But you may specify
41+
your own by parsing it with `QSyntaxStyle`. The example uses [Dracula](https://draculatheme.com) theme.
42+
(See the example for more.)
43+
44+
<img src="https://github.com/Megaxela/QCodeEditor/blob/master/example/image/preview.png">
45+
46+
## LICENSE
47+
48+
<img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">
49+
50+
Library is licensed under the [MIT License](https://opensource.org/licenses/MIT)
51+
52+
Permission is hereby granted, free of charge, to any person obtaining a copy
53+
of this software and associated documentation files (the "Software"), to deal
54+
in the Software without restriction, including without limitation the rights
55+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
56+
copies of the Software, and to permit persons to whom the Software is
57+
furnished to do so, subject to the following conditions:
58+
59+
The above copyright notice and this permission notice shall be included in all
60+
copies or substantial portions of the Software.
61+
62+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
68+
SOFTWARE.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.6)
2+
project(QCodeEditorExample)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
set(CMAKE_AUTOMOC On)
7+
set(CMAKE_AUTORCC ON)
8+
9+
find_package(Qt5Core CONFIG REQUIRED)
10+
find_package(Qt5Widgets CONFIG REQUIRED)
11+
find_package(Qt5Gui CONFIG REQUIRED)
12+
13+
add_executable(QCodeEditorExample
14+
resources/demo_resources.qrc
15+
src/main.cpp
16+
src/MainWindow.cpp
17+
include/MainWindow.hpp
18+
)
19+
20+
target_include_directories(QCodeEditorExample PUBLIC
21+
include
22+
)
23+
24+
target_link_libraries(QCodeEditorExample
25+
Qt5::Core
26+
Qt5::Widgets
27+
Qt5::Gui
28+
QCodeEditor
29+
)
Loading

0 commit comments

Comments
 (0)