mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
GUI support from Python and some cleanup
Squashed commit of the following: commit 5058ceb9351548937487aa94073e7f59236ae9fe Merge: d37f0af2da1465
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 19:33:55 2017 +0200 Merge remote-tracking branch 'origin/master' into native_tcl_macos commit d37f0afcc1389c0c3ec0899da9c1af158c926ca5 Author: Matthias <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 19:27:12 2017 +0200 link gui to netgen, some fixes commit 297141455cd4fab81709c13d6253ad8114beee4a Author: Matthias <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 19:02:47 2017 +0200 windows fixes commit 9bf290a60835f29762b15ee3b722da132678f90c Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 18:59:53 2017 +0200 More cleanup, proper code separation ... between netgen exectuable and gui library commit f46d438d3c9dd32f9f94642b4ec00b85611ef1dd Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 14:03:53 2017 +0200 fix typos commit b3d301ff4e321189aef469bff77f7cffa7b69e98 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 13:32:57 2017 +0200 also link tk to togl on windows... commit c3519abee7b041e45c913a45999ed2d29d4ff325 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 13:30:16 2017 +0200 link TCL to togl on windows commit 80b607436b45f38f4bac2708a78ef03561ad44e5 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 13:26:45 2017 +0200 linkt TCL only to netgen executable commit 080139a431e949e14cb9f05194e19c5129aca3d3 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 13:20:36 2017 +0200 fix dll ex/import commit dd68efacb01fbbbe3f136168f12fed41fa3c3c8a Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 13:15:39 2017 +0200 fix dll export commit 9023b9ca49b4c2b99f228f64564990e2d0246b8c Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 12:06:14 2017 +0200 use system tcl/tk on MacOS, but download tcl/tk for windows commit 16eb4c1b01eb5229f93274791187b2c666bb8b8e Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 12:01:36 2017 +0200 more cleanup commit 6df5b82a7d9a1177a755446d563d6c4b98ff6329 Merge: af237862b0d3f0
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 11:45:42 2017 +0200 Merge remote-tracking branch 'origin/master' into native_tcl_macos commit af2378637a6513de3b50841ed6314cd7e12f7205 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Wed May 10 11:45:40 2017 +0200 some cleanup commit 81bbe117efe25df53c71f9ae603c50ee4557703a Author: Joachim Schöberl <joachim.schoeberl@tuwien.ac.at> Date: Tue May 9 20:14:46 2017 +0200 tk-gui commit 387e6da678661dd3b9d75d696733f46fe43d789a Merge: e658b5b e653d8e Author: Joachim Schöberl <joachim.schoeberl@tuwien.ac.at> Date: Tue May 9 18:49:20 2017 +0200 Merge remote-tracking branch 'origin/gui_from_python' into native_tcl_macos commit e658b5b2c1ac3264f4165b5f6d2b821b3b1b0926 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Tue May 9 18:30:35 2017 +0200 use native tcl on macos commit e653d8e6789d20e24b16a68bf760415940e881f8 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Mon May 8 16:37:23 2017 +0200 next fix commit f663c80b00754d141a02fa6abde2077c841bbafb Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Mon May 8 16:23:21 2017 +0200 Fix symbol export on windows commit 70d99782423d33d3fa6f80e758a7377d0cb52840 Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> Date: Mon May 8 15:14:56 2017 +0200 GUI support from Python Enables experimental support for starting the Netgen GUI from Python directly. To use it, just import the gui module: > import netgen.gui
This commit is contained in:
parent
2da1465d52
commit
025f8750be
@ -1,56 +1,58 @@
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(HOME $ENV{HOME})
|
# use system tcl/tk
|
||||||
set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../)
|
find_package(TCL 8.5 REQUIRED)
|
||||||
ExternalProject_Add(project_tcl
|
# set(HOME $ENV{HOME})
|
||||||
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tcl8.6.4-src.tar.gz"
|
# set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../)
|
||||||
URL_MD5 d7cbb91f1ded1919370a30edd1534304
|
# ExternalProject_Add(project_tcl
|
||||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
# URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tcl8.6.4-src.tar.gz"
|
||||||
UPDATE_COMMAND "" # Disable update
|
# URL_MD5 d7cbb91f1ded1919370a30edd1534304
|
||||||
CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
|
# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||||
BUILD_COMMAND make -j4 binaries libraries
|
# UPDATE_COMMAND "" # Disable update
|
||||||
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
# CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
|
||||||
LOG_DOWNLOAD 1
|
# BUILD_COMMAND make -j4 binaries libraries
|
||||||
LOG_BUILD 1
|
# INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||||
LOG_CONFIGURE 1
|
# LOG_DOWNLOAD 1
|
||||||
LOG_INSTALL 1
|
# LOG_BUILD 1
|
||||||
)
|
# LOG_CONFIGURE 1
|
||||||
|
# LOG_INSTALL 1
|
||||||
ExternalProject_Add(project_tk
|
# )
|
||||||
DEPENDS project_tcl
|
#
|
||||||
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tk8.6.4-src.tar.gz"
|
# ExternalProject_Add(project_tk
|
||||||
URL_MD5 261754d7dc2a582f00e35547777e1fea
|
# DEPENDS project_tcl
|
||||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
# URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tk8.6.4-src.tar.gz"
|
||||||
UPDATE_COMMAND "" # Disable update
|
# URL_MD5 261754d7dc2a582f00e35547777e1fea
|
||||||
CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
|
# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||||
BUILD_COMMAND make -j4 binaries libraries
|
# UPDATE_COMMAND "" # Disable update
|
||||||
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
# CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
|
||||||
LOG_DOWNLOAD 1
|
# BUILD_COMMAND make -j4 binaries libraries
|
||||||
LOG_BUILD 1
|
# INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||||
LOG_CONFIGURE 1
|
# LOG_DOWNLOAD 1
|
||||||
LOG_INSTALL 1
|
# LOG_BUILD 1
|
||||||
)
|
# LOG_CONFIGURE 1
|
||||||
|
# LOG_INSTALL 1
|
||||||
ExternalProject_Add(project_tkdnd
|
# )
|
||||||
URL "https://sourceforge.net/projects/tkdnd/files/OS%20X%20Binaries/TkDND%202.8/tkdnd2.8-OSX-MountainLion.tar.gz"
|
#
|
||||||
URL_MD5 2dbb471b1d66c5f391f3c3c5b71548fb
|
# ExternalProject_Add(project_tkdnd
|
||||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
# URL "https://sourceforge.net/projects/tkdnd/files/OS%20X%20Binaries/TkDND%202.8/tkdnd2.8-OSX-MountainLion.tar.gz"
|
||||||
BUILD_IN_SOURCE 1
|
# URL_MD5 2dbb471b1d66c5f391f3c3c5b71548fb
|
||||||
CONFIGURE_COMMAND ""
|
# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||||
BUILD_COMMAND ""
|
# BUILD_IN_SOURCE 1
|
||||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}/../MacOS
|
# CONFIGURE_COMMAND ""
|
||||||
LOG_DOWNLOAD 1
|
# BUILD_COMMAND ""
|
||||||
LOG_CONFIGURE 1
|
# INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}/../MacOS
|
||||||
LOG_BUILD 1
|
# LOG_DOWNLOAD 1
|
||||||
LOG_INSTALL 1
|
# LOG_CONFIGURE 1
|
||||||
)
|
# LOG_BUILD 1
|
||||||
|
# LOG_INSTALL 1
|
||||||
list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk project_tkdnd)
|
# )
|
||||||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}../Frameworks)
|
#
|
||||||
set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework/Headers)
|
# list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk project_tkdnd)
|
||||||
set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework)
|
# list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}../Frameworks)
|
||||||
set(TK_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework)
|
# set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework/Headers)
|
||||||
set(TK_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework/Headers)
|
# set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework)
|
||||||
|
# set(TK_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework)
|
||||||
|
# set(TK_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework/Headers)
|
||||||
|
#
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
|
|
||||||
ExternalProject_Add(project_win_extlibs
|
ExternalProject_Add(project_win_extlibs
|
||||||
|
@ -12,7 +12,7 @@ endif(USE_GUI)
|
|||||||
add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
|
add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( visual ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TCL_LIBRARY} )
|
target_link_libraries( visual ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
|
||||||
install( TARGETS visual ${ng_install_dir})
|
install( TARGETS visual ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
set(netgen_sources demoview.cpp ngappinit.cpp onetcl.cpp parallelfunc.cpp ngpkg.cpp ../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp ../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp ../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp)
|
set(gui_sources
|
||||||
|
gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp
|
||||||
|
../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp
|
||||||
|
../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp
|
||||||
|
../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(netgen_sources ngappinit.cpp onetcl.cpp )
|
||||||
|
|
||||||
if(USE_GUI)
|
if(USE_GUI)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -10,21 +17,26 @@ if(USE_GUI)
|
|||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
add_executable(netgen ${netgen_sources})
|
add_executable(netgen ${netgen_sources})
|
||||||
target_link_libraries( netgen nglib ${ZLIB_LIBRARIES} ${LIBTOGL} ${TK_LIBRARY} ${TCL_LIBRARY} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES})
|
add_library(gui SHARED ${gui_sources})
|
||||||
add_library(gui SHARED ${netgen_sources} gui.cpp)
|
|
||||||
target_link_libraries( gui nglib ${ZLIB_LIBRARIES} ${LIBTOGL} ${TK_LIBRARY} ${TCL_LIBRARY} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES})
|
target_link_libraries( netgen nglib gui ${ZLIB_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES})
|
||||||
|
target_link_libraries( gui PUBLIC nglib ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES} )
|
||||||
|
target_link_libraries( gui PRIVATE ${LIBTOGL})
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( netgen mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
target_link_libraries( netgen mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||||
target_link_libraries( gui mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
install(TARGETS netgen ${ng_install_dir})
|
install(TARGETS netgen ${ng_install_dir})
|
||||||
install(TARGETS gui DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen)
|
install(TARGETS gui ${ng_install_dir})
|
||||||
set_target_properties( gui PROPERTIES PREFIX "") # name output file gui.so instead of libgui.so
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
|
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
if(WIN32)
|
||||||
|
set_target_properties( gui PROPERTIES OUTPUT_NAME libgui )
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
|
|
||||||
|
@ -8,12 +8,13 @@ if(WIN32)
|
|||||||
add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER")
|
add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER")
|
||||||
add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c)
|
add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c)
|
||||||
install(TARGETS togl DESTINATION ${ng_install_dir} COMPONENT netgen)
|
install(TARGETS togl DESTINATION ${ng_install_dir} COMPONENT netgen)
|
||||||
|
target_link_libraries(togl ${TCL_LIBRARY} ${TK_LIBRARY})
|
||||||
else(WIN32)
|
else(WIN32)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int")
|
||||||
add_definitions("-DPACKAGE_NAME=\"Togl\" -DPACKAGE_TARNAME=\"togl\" -DPACKAGE_VERSION=\"2.1\" -DPACKAGE_STRING=\"Togl\ 2.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 -DAUTOSTEREOD=\"\"")
|
add_definitions("-DPACKAGE_NAME=\"Togl\" -DPACKAGE_TARNAME=\"togl\" -DPACKAGE_VERSION=\"2.1\" -DPACKAGE_STRING=\"Togl\ 2.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 -DAUTOSTEREOD=\"\"")
|
||||||
|
|
||||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tcl-private/generic" "${TCL_INCLUDE_PATH}/tcl-private/unix")
|
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tcl-private/generic" "${TCL_INCLUDE_PATH}/tcl-private/unix")
|
||||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tk-private/generic" "${TCL_INCLUDE_PATH}/tk-private/unix")
|
include_directories(BEFORE "${TK_INCLUDE_PATH}/tk-private/generic" "${TK_INCLUDE_PATH}/tk-private/unix" "${TK_INCLUDE_PATH}/tk-private")
|
||||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tk-private/generic/ttk")
|
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tk-private/generic/ttk")
|
||||||
include_directories(BEFORE "${TK_INCLUDE_PATH}/../PrivateHeaders")
|
include_directories(BEFORE "${TK_INCLUDE_PATH}/../PrivateHeaders")
|
||||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}")
|
include_directories(BEFORE "${TCL_INCLUDE_PATH}")
|
||||||
@ -23,5 +24,5 @@ else(WIN32)
|
|||||||
target_link_libraries(togl -ldl)
|
target_link_libraries(togl -ldl)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
target_link_libraries(togl ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} )
|
target_link_libraries(togl ${OPENGL_LIBRARIES})
|
||||||
set_target_properties(togl PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
set_target_properties(togl PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
||||||
|
@ -165,11 +165,12 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* TOGL_AGL */
|
#endif /* TOGL_AGL */
|
||||||
|
|
||||||
#if defined(TOGL_NSOPENGL)
|
// Seems to work with Apple Tcl 8.5 too....
|
||||||
# if TK_MAJOR_VERSION < 8 || (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 6)
|
// #if defined(TOGL_NSOPENGL)
|
||||||
# error Sorry Mac Cocoa version requires Tcl/Tk ver 8.6.0 or higher.
|
// # if TK_MAJOR_VERSION < 8 || (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 6)
|
||||||
# endif
|
// # error Sorry Mac Cocoa version requires Tcl/Tk ver 8.6.0 or higher.
|
||||||
#endif /* TOGL_NSOPENGL */
|
// # endif
|
||||||
|
// #endif /* TOGL_NSOPENGL */
|
||||||
|
|
||||||
#if defined(TOGL_WGL) && defined(_MSC_VER)
|
#if defined(TOGL_WGL) && defined(_MSC_VER)
|
||||||
# define snprintf _snprintf
|
# define snprintf _snprintf
|
||||||
|
229
ng/gui.cpp
229
ng/gui.cpp
@ -2,221 +2,40 @@
|
|||||||
#include <inctcl.hpp>
|
#include <inctcl.hpp>
|
||||||
#include <meshing.hpp>
|
#include <meshing.hpp>
|
||||||
|
|
||||||
#include "../libsrc/interface/writeuser.hpp"
|
#ifdef WIN32
|
||||||
#include <pybind11/pybind11.h>
|
#define DLL_HEADER_IMPORT __declspec(dllimport)
|
||||||
|
#define DLL_HEADER_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define DLL_HEADER_IMPORT
|
||||||
|
#define DLL_HEADER_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
DLL_HEADER extern Flags parameters;
|
DLL_HEADER_EXPORT Flags parameters;
|
||||||
DLL_HEADER extern bool netgen_executable_started;
|
|
||||||
DLL_HEADER extern int printmessage_importance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using netgen::parameters;
|
DLL_HEADER_EXPORT bool nodisplay = false;
|
||||||
using netgen::ngdir;
|
|
||||||
using netgen::verbose;
|
|
||||||
using netgen::Array;
|
|
||||||
using netgen::RegisterUserFormats;
|
|
||||||
|
|
||||||
extern "C" int Ng_ServerSocketManagerInit (int port);
|
|
||||||
extern "C" int Ng_ServerSocketManagerRun (void);
|
|
||||||
|
|
||||||
int Tcl_AppInit(Tcl_Interp * interp);
|
|
||||||
|
|
||||||
extern bool nodisplay;
|
|
||||||
extern bool shellmode;
|
|
||||||
|
|
||||||
void main_gui()
|
|
||||||
{
|
|
||||||
if(netgen::netgen_executable_started)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( netgen::id == 0 )
|
|
||||||
{
|
|
||||||
cout << "NETGEN-" << PACKAGE_VERSION << endl;
|
|
||||||
|
|
||||||
cout << "Developed by Joachim Schoeberl at" << endl
|
|
||||||
<< "2010-xxxx Vienna University of Technology" << endl
|
|
||||||
<< "2006-2010 RWTH Aachen University" << endl
|
|
||||||
<< "1996-2006 Johannes Kepler University Linz" << endl;
|
|
||||||
|
|
||||||
#ifdef OCCGEOMETRY
|
|
||||||
cout << "Including OpenCascade geometry kernel" << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ACIS
|
|
||||||
cout << "Including ACIS geometry kernel" << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
cout << "You are running the debug version !" << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// netgen::h_argc = argc;
|
|
||||||
// netgen::h_argv = argv;
|
|
||||||
|
|
||||||
if (getenv ("NETGENDIR") && strlen (getenv ("NETGENDIR")))
|
|
||||||
ngdir = getenv ("NETGENDIR");
|
|
||||||
else
|
|
||||||
ngdir = ".";
|
|
||||||
|
|
||||||
verbose = parameters.GetDefineFlag ("V");
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
cout << "NETGENDIR = " << ngdir << endl;
|
|
||||||
|
|
||||||
|
|
||||||
if ( netgen::id == 0 )
|
|
||||||
{
|
|
||||||
if (parameters.StringFlagDefined ("testout"))
|
|
||||||
netgen::testout = new ofstream (parameters.GetStringFlag ("testout", "test.out"));
|
|
||||||
|
|
||||||
|
|
||||||
if(parameters.GetDefineFlag("batchmode"))
|
|
||||||
nodisplay = true;
|
|
||||||
|
|
||||||
|
|
||||||
if(parameters.GetDefineFlag("shellmode"))
|
|
||||||
{
|
|
||||||
nodisplay = true;
|
|
||||||
shellmode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tcl_FindExecutable(NULL);
|
|
||||||
|
|
||||||
// initialize application
|
|
||||||
Tcl_Interp * myinterp = Tcl_CreateInterp ();
|
|
||||||
if (Tcl_AppInit (myinterp) == TCL_ERROR)
|
|
||||||
{
|
|
||||||
cerr << "Exit Netgen due to initialization problem" << endl;
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// parse tcl-script
|
|
||||||
int errcode;
|
|
||||||
|
|
||||||
bool internaltcl = false;
|
|
||||||
if (shellmode)
|
|
||||||
internaltcl = false;
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
cout << "Tcl header version = " << TCL_PATCH_LEVEL << endl;
|
|
||||||
Tcl_Eval (myinterp, "puts \"Tcl runtime version = [info patchlevel] \";");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters.GetDefineFlag ("internaltcl"))
|
|
||||||
internaltcl=true;
|
|
||||||
if (parameters.GetDefineFlag ("externaltcl"))
|
|
||||||
internaltcl=false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (internaltcl)
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
cout << "using internal Tcl-script" << endl;
|
|
||||||
|
|
||||||
// connect to one string
|
|
||||||
extern const char * ngscript[];
|
|
||||||
const char ** hcp = ngscript;
|
|
||||||
int len = 0;
|
|
||||||
while (*hcp)
|
|
||||||
len += strlen (*hcp++);
|
|
||||||
|
|
||||||
char * tr1 = new char[len+1];
|
|
||||||
*tr1 = 0;
|
|
||||||
hcp = ngscript;
|
|
||||||
|
|
||||||
char * tt1 = tr1;
|
|
||||||
while (*hcp)
|
|
||||||
{
|
|
||||||
strcat (tt1, *hcp);
|
|
||||||
tt1 += strlen (*hcp++);
|
|
||||||
}
|
|
||||||
|
|
||||||
errcode = Tcl_Eval (myinterp, tr1);
|
|
||||||
delete [] tr1;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
{
|
|
||||||
string startfile = ngdir + "/ng.tcl";
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
cout << "Load Tcl-script from " << startfile << endl;
|
|
||||||
|
|
||||||
errcode = Tcl_EvalFile (myinterp, (char*)startfile.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errcode)
|
|
||||||
{
|
|
||||||
cout << "Error in Tcl-Script:" << endl;
|
|
||||||
// cout << "result = " << myinterp->result << endl;
|
|
||||||
cout << "result = " << Tcl_GetStringResult (myinterp) << endl;
|
|
||||||
// cout << "in line " << myinterp->errorLine << endl;
|
|
||||||
|
|
||||||
cout << "\nMake sure to set environment variable NETGENDIR to directory containing ng.tcl" << endl;
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// lookup user file formats and insert into format list:
|
|
||||||
Array<const char*> userformats;
|
|
||||||
Array<const char*> extensions;
|
|
||||||
RegisterUserFormats (userformats, extensions);
|
|
||||||
|
|
||||||
ostringstream fstr;
|
|
||||||
|
|
||||||
tcl_const char * exportft = Tcl_GetVar (myinterp, "exportfiletype", 0);
|
|
||||||
for (int i = 1; i <= userformats.Size(); i++)
|
|
||||||
{
|
|
||||||
fstr << ".ngmenu.file.filetype add radio -label \""
|
|
||||||
<< userformats.Get(i) << "\" -variable exportfiletype\n";
|
|
||||||
fstr << "lappend meshexportformats { {" << userformats.Get(i) << "} {" << extensions.Get(i) << "} }\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
Tcl_Eval (myinterp, (char*)fstr.str().c_str());
|
|
||||||
Tcl_SetVar (myinterp, "exportfiletype", exportft, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// start event-loop
|
|
||||||
Tk_MainLoop();
|
|
||||||
Tcl_DeleteInterp (myinterp);
|
|
||||||
// Tcl_Exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" int Ng_Init (Tcl_Interp * interp);
|
extern "C" int Ng_Init (Tcl_Interp * interp);
|
||||||
extern "C" int Ng_Vis_Init (Tcl_Interp * interp);
|
extern "C" int Ng_Vis_Init (Tcl_Interp * interp);
|
||||||
|
|
||||||
extern "C" void Ng_TclCmd(string);
|
extern "C" void Ng_TclCmd(string);
|
||||||
|
|
||||||
struct GuiThread {
|
// tcl package dynamic load
|
||||||
std::thread t;
|
extern "C" int DLL_HEADER_EXPORT Gui_Init (Tcl_Interp * interp)
|
||||||
~GuiThread() {
|
{
|
||||||
Ng_TclCmd(".ngmenu.file invoke \"Quit\";");
|
if (Ng_Init(interp) == TCL_ERROR) {
|
||||||
if(netgen::printmessage_importance>2)
|
cerr << "Problem in Ng_Init: " << endl;
|
||||||
cout << "waiting for GUI to finish..." << endl;
|
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||||
t.join();
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
static GuiThread gui_thread;
|
if (!nodisplay && Ng_Vis_Init(interp) == TCL_ERROR) {
|
||||||
|
cerr << "Problem in Ng_Vis_Init: " << endl;
|
||||||
|
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
PYBIND11_PLUGIN(gui) {
|
return TCL_OK;
|
||||||
pybind11::module m("gui", "pybind gui");
|
|
||||||
gui_thread.t = std::thread([]()
|
|
||||||
{
|
|
||||||
main_gui();
|
|
||||||
});
|
|
||||||
return m.ptr();
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
catch {lappend auto_path $env(NETGENDIR) }
|
catch {lappend auto_path $env(NETGENDIR) }
|
||||||
|
catch {lappend auto_path $env(NETGENDIR)/../lib }
|
||||||
|
|
||||||
|
load libgui[info sharedlibextension] gui
|
||||||
|
|
||||||
set batchmode [Ng_GetCommandLineParameter batchmode]
|
set batchmode [Ng_GetCommandLineParameter batchmode]
|
||||||
if {$batchmode=="undefined"} {
|
if {$batchmode=="undefined"} {
|
||||||
|
@ -7,17 +7,6 @@
|
|||||||
#include <inctcl.hpp>
|
#include <inctcl.hpp>
|
||||||
#include <meshing.hpp>
|
#include <meshing.hpp>
|
||||||
|
|
||||||
#ifdef NGPYTHON
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
namespace netgen
|
|
||||||
{
|
|
||||||
int id = 0, ntasks = 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef PARALLEL
|
#ifdef PARALLEL
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
|
||||||
@ -33,10 +22,11 @@ namespace netgen
|
|||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
Flags parameters;
|
DLL_HEADER extern Flags parameters;
|
||||||
DLL_HEADER extern bool netgen_executable_started;
|
DLL_HEADER extern bool netgen_executable_started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DLL_HEADER extern bool nodisplay;
|
||||||
|
|
||||||
|
|
||||||
using netgen::parameters;
|
using netgen::parameters;
|
||||||
@ -59,7 +49,6 @@ using netgen::RegisterUserFormats;
|
|||||||
extern "C" int Ng_ServerSocketManagerInit (int port);
|
extern "C" int Ng_ServerSocketManagerInit (int port);
|
||||||
extern "C" int Ng_ServerSocketManagerRun (void);
|
extern "C" int Ng_ServerSocketManagerRun (void);
|
||||||
|
|
||||||
bool nodisplay = false;
|
|
||||||
bool shellmode = false;
|
bool shellmode = false;
|
||||||
|
|
||||||
|
|
||||||
@ -350,26 +339,6 @@ int Tcl_AppInit(Tcl_Interp * interp)
|
|||||||
// return TCL_ERROR;
|
// return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Ng_Init(interp) == TCL_ERROR) {
|
|
||||||
cerr << "Problem in Ng_Init: " << endl;
|
|
||||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
|
||||||
// cerr << interp->result << endl;
|
|
||||||
// return TCL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nodisplay && Ng_Vis_Init(interp) == TCL_ERROR) {
|
|
||||||
cerr << "Problem in Ng_Vis_Init: " << endl;
|
|
||||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
|
||||||
// cerr << interp->result << endl;
|
|
||||||
// return TCL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TRAFO
|
#ifdef TRAFO
|
||||||
// extern int Trafo_Init (Tcl_Interp * interp);
|
// extern int Trafo_Init (Tcl_Interp * interp);
|
||||||
// if (Trafo_Init(interp) == TCL_ERROR)
|
// if (Trafo_Init(interp) == TCL_ERROR)
|
||||||
@ -429,21 +398,3 @@ int Tcl_AppInit(Tcl_Interp * interp)
|
|||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// link MKL with netgen
|
|
||||||
// necessary for MKL 11.x, since MKL complains if started
|
|
||||||
// from the ngsolve shared library
|
|
||||||
|
|
||||||
#ifdef LINKMKL
|
|
||||||
extern "C" double ddot_(int *n, double *dx, int *incx, double *dy,
|
|
||||||
int *incy);
|
|
||||||
void mkldummy()
|
|
||||||
{
|
|
||||||
int n = 1, one = 1;
|
|
||||||
double a = 1, b = 1;
|
|
||||||
ddot_(&n, &a, &one, &b, &one);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -28,7 +28,7 @@ if(NOT WIN32)
|
|||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
target_link_libraries( nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} )
|
target_link_libraries( nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} )
|
||||||
|
|
||||||
if(USE_OCC AND NOT WIN32)
|
if(USE_OCC AND NOT WIN32)
|
||||||
target_link_libraries(nglib occ)
|
target_link_libraries(nglib occ)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
install(FILES __init__.py meshing.py csg.py geom2d.py stl.py
|
install(FILES __init__.py meshing.py csg.py geom2d.py stl.py gui.py
|
||||||
DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen
|
DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen
|
||||||
COMPONENT netgen
|
COMPONENT netgen
|
||||||
)
|
)
|
||||||
|
@ -3,11 +3,17 @@ from sys import path
|
|||||||
from sys import platform as __platform
|
from sys import platform as __platform
|
||||||
|
|
||||||
if __platform.startswith('linux'):
|
if __platform.startswith('linux'):
|
||||||
path.append(os.path.dirname(__file__) + '/../../..')
|
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'../../../../bin'))
|
||||||
|
_netgen_lib_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'../../../../lib'))
|
||||||
if __platform.startswith('win'):
|
if __platform.startswith('win'):
|
||||||
path.append(os.path.dirname(__file__) + '/../../../bin')
|
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__) + '/../../../bin'))
|
||||||
|
_netgen_lib_dir=_netgen_bin_dir
|
||||||
if __platform.startswith('darwin'):
|
if __platform.startswith('darwin'):
|
||||||
path.append(os.path.dirname(__file__) + '/../../../../../MacOS')
|
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__) + '/../../../../../MacOS'))
|
||||||
|
_netgen_lib_dir=_netgen_bin_dir
|
||||||
|
|
||||||
|
path.append(_netgen_lib_dir)
|
||||||
|
path.append(_netgen_bin_dir)
|
||||||
|
|
||||||
import libngpy
|
import libngpy
|
||||||
del path
|
del path
|
||||||
|
11
python/gui.py
Normal file
11
python/gui.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from tkinter import Tk
|
||||||
|
|
||||||
|
from . import _netgen_lib_dir
|
||||||
|
from . import _netgen_bin_dir
|
||||||
|
|
||||||
|
win = Tk()
|
||||||
|
import os
|
||||||
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
win.tk.eval("source "+os.path.realpath(os.path.join(_netgen_bin_dir, 'ng.tcl')).replace('\\','/'))
|
||||||
|
|
||||||
|
# %gui tk
|
Loading…
Reference in New Issue
Block a user