mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
Don't load gui libraries when importing netgen
This commit is contained in:
parent
81b22633cd
commit
22e57a1159
@ -1538,6 +1538,32 @@ project_boundaries : Optional[str] = None
|
|||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
;
|
;
|
||||||
m.def("SetParallelPickling", [](bool par) { parallel_pickling = par; });
|
m.def("SetParallelPickling", [](bool par) { parallel_pickling = par; });
|
||||||
|
m.def ("_Redraw",
|
||||||
|
([](bool blocking, double fr)
|
||||||
|
{
|
||||||
|
static auto last_time = std::chrono::system_clock::now()-std::chrono::seconds(10);
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
double elapsed = std::chrono::duration<double>(now-last_time).count();
|
||||||
|
if (blocking || elapsed * fr > 1)
|
||||||
|
{
|
||||||
|
Ng_Redraw(blocking);
|
||||||
|
last_time = std::chrono::system_clock::now();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}),
|
||||||
|
py::arg("blocking")=false, py::arg("fr") = 25, R"raw_string(
|
||||||
|
Redraw all
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
blocking : bool
|
||||||
|
input blocking
|
||||||
|
|
||||||
|
fr : double
|
||||||
|
input framerate
|
||||||
|
|
||||||
|
)raw_string");
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_MODULE(libmesh, m) {
|
PYBIND11_MODULE(libmesh, m) {
|
||||||
|
@ -3580,32 +3580,6 @@ NGGUI_API void ExportMeshVis(py::module &m)
|
|||||||
([] () {
|
([] () {
|
||||||
return vsmesh.GetMesh();
|
return vsmesh.GetMesh();
|
||||||
}));
|
}));
|
||||||
m.def ("_Redraw",
|
|
||||||
([](bool blocking, double fr)
|
|
||||||
{
|
|
||||||
static auto last_time = std::chrono::system_clock::now()-std::chrono::seconds(10);
|
|
||||||
auto now = std::chrono::system_clock::now();
|
|
||||||
double elapsed = std::chrono::duration<double>(now-last_time).count();
|
|
||||||
if (blocking || elapsed * fr > 1)
|
|
||||||
{
|
|
||||||
Ng_Redraw(blocking);
|
|
||||||
last_time = std::chrono::system_clock::now();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}),
|
|
||||||
py::arg("blocking")=false, py::arg("fr") = 25, R"raw_string(
|
|
||||||
Redraw all
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
blocking : bool
|
|
||||||
input blocking
|
|
||||||
|
|
||||||
fr : double
|
|
||||||
input framerate
|
|
||||||
|
|
||||||
)raw_string");
|
|
||||||
}
|
}
|
||||||
// BOOST_PYTHON_MODULE(libvisual)
|
// BOOST_PYTHON_MODULE(libvisual)
|
||||||
// {
|
// {
|
||||||
|
@ -5,12 +5,9 @@
|
|||||||
#include <core/ngcore_api.hpp>
|
#include <core/ngcore_api.hpp>
|
||||||
|
|
||||||
void NGCORE_API_IMPORT ExportNetgenMeshing(py::module &m);
|
void NGCORE_API_IMPORT ExportNetgenMeshing(py::module &m);
|
||||||
void NGCORE_API_IMPORT ExportMeshVis(py::module &m);
|
|
||||||
void NGCORE_API_IMPORT ExportCSG(py::module &m);
|
void NGCORE_API_IMPORT ExportCSG(py::module &m);
|
||||||
void NGCORE_API_IMPORT ExportCSGVis(py::module &m);
|
|
||||||
void NGCORE_API_IMPORT ExportGeom2d(py::module &m);
|
void NGCORE_API_IMPORT ExportGeom2d(py::module &m);
|
||||||
void NGCORE_API_IMPORT ExportSTL(py::module &m);
|
void NGCORE_API_IMPORT ExportSTL(py::module &m);
|
||||||
void NGCORE_API_IMPORT ExportSTLVis(py::module &m);
|
|
||||||
#ifdef OCCGEOMETRY
|
#ifdef OCCGEOMETRY
|
||||||
void NGCORE_API_IMPORT ExportNgOCC(py::module &m);
|
void NGCORE_API_IMPORT ExportNgOCC(py::module &m);
|
||||||
#endif // OCCGEOMETRY
|
#endif // OCCGEOMETRY
|
||||||
|
@ -16,23 +16,7 @@ del os
|
|||||||
|
|
||||||
from . import libngpy
|
from . import libngpy
|
||||||
|
|
||||||
if config.USE_GUI:
|
from netgen.libngpy._meshing import _Redraw
|
||||||
from . import libngguipy
|
|
||||||
global _Redraw, Redraw
|
|
||||||
_Redraw = libngguipy.meshvis._Redraw
|
|
||||||
|
|
||||||
def RedrawWithEventHandling(*args, **kwargs):
|
def Redraw(*args, **kwargs):
|
||||||
try:
|
return _Redraw(*args, **kwargs)
|
||||||
if libngguipy.meshvis._Redraw(*args, **kwargs):
|
|
||||||
import netgen
|
|
||||||
import tkinter
|
|
||||||
cnt = 0
|
|
||||||
while(netgen.gui.win.tk.dooneevent(tkinter._tkinter.DONT_WAIT) and cnt < 100):
|
|
||||||
cnt += 1
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
Redraw = RedrawWithEventHandling
|
|
||||||
else:
|
|
||||||
def Redraw(*args, **kwargs):
|
|
||||||
pass
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import netgen
|
import netgen
|
||||||
|
|
||||||
|
from . import libngguipy
|
||||||
|
from . import libngpy
|
||||||
|
|
||||||
def StartGUI():
|
def StartGUI():
|
||||||
from tkinter import Tk
|
from tkinter import Tk
|
||||||
from netgen import config
|
from netgen import config
|
||||||
@ -18,7 +21,7 @@ def StartGUI():
|
|||||||
win.tk.eval('lappend ::auto_path ' + netgen._netgen_lib_dir)
|
win.tk.eval('lappend ::auto_path ' + netgen._netgen_lib_dir)
|
||||||
win.tk.eval('lappend ::auto_path ' + netgen._netgen_bin_dir)
|
win.tk.eval('lappend ::auto_path ' + netgen._netgen_bin_dir)
|
||||||
# load with absolute path to avoid issues on MacOS
|
# load with absolute path to avoid issues on MacOS
|
||||||
win.tk.eval('load "'+netgen._netgen_lib_dir.replace('\\','/')+'/libgui[info sharedlibextension]" gui')
|
win.tk.eval('load "'+netgen._netgen_lib_dir.replace('\\','/')+'/libnggui[info sharedlibextension]" gui')
|
||||||
|
|
||||||
if config.is_python_package and 'darwin' in sys.platform:
|
if config.is_python_package and 'darwin' in sys.platform:
|
||||||
# libngsolve and other libraries are installed into netgen python dir to keep relative installation paths, but tcl won't find them there automatically
|
# libngsolve and other libraries are installed into netgen python dir to keep relative installation paths, but tcl won't find them there automatically
|
||||||
@ -27,6 +30,17 @@ def StartGUI():
|
|||||||
|
|
||||||
win.tk.eval( netgen.libngpy._meshing._ngscript)
|
win.tk.eval( netgen.libngpy._meshing._ngscript)
|
||||||
|
|
||||||
|
def _Redraw(*args, **kwargs):
|
||||||
|
if libngpy._meshing._Redraw(*args, **kwargs):
|
||||||
|
import netgen
|
||||||
|
import tkinter
|
||||||
|
cnt = 0
|
||||||
|
while(win.tk.dooneevent(tkinter._tkinter.DONT_WAIT) and cnt < 100):
|
||||||
|
cnt += 1
|
||||||
|
|
||||||
|
netgen._Redraw = _Redraw
|
||||||
|
_Redraw(blocking=True)
|
||||||
|
|
||||||
|
|
||||||
if not netgen.libngpy._meshing._netgen_executable_started:
|
if not netgen.libngpy._meshing._netgen_executable_started:
|
||||||
import os
|
import os
|
||||||
|
Loading…
Reference in New Issue
Block a user