diff --git a/examples/code_fragments/surf/test_surf_clip.py b/examples/code_fragments/surf/test_surf_clip.py new file mode 100644 index 0000000000000000000000000000000000000000..6cdfdf3c5f2f39f8f24096c0fb5b7bb569fcea05 --- /dev/null +++ b/examples/code_fragments/surf/test_surf_clip.py @@ -0,0 +1,18 @@ +struct=io.LoadEntity("sdh.pdb") +surf=io.LoadSurface("sdh","msms") +surf.Attach(struct,5.0) +go=gfx.Surface("surf",surf) +# this is broken +#go.clip=True +#go.clip_plane=geom.Vec4(0,0,-1,-130) +# this works, z offset to near clipping plane, must be >0 +go.clip_offset=1 +go.solid=True +go.solid_color=gfx.RGB(1,1,0) + +scene.rtc=geom.Mat4(0.914075, -0.355397, 0.195293, 29.688, 0.405471, 0.7934, -0.45397, 19.9405, 0.00639453, 0.494153, 0.869337, 73.0075, 0, 0, -143.077, 1) + +scene.Add(go) +scene.SetCenter(go.GetCenter()) +scene.Autoslab() +scene.auto_autoslab=False diff --git a/modules/gui/pymod/CMakeLists.txt b/modules/gui/pymod/CMakeLists.txt index 4ac7f7cfe75a5fe6a0e843a4389e64e02e8228ed..50ee931414a4f8262ea542f879956299d006f362 100644 --- a/modules/gui/pymod/CMakeLists.txt +++ b/modules/gui/pymod/CMakeLists.txt @@ -86,6 +86,7 @@ set(OST_GUI_PYMOD_MODULES traj.py helpwidget.py table.py + gosty_startup.py ) set(OST_GUI_PYMOD_DNG_MODULES diff --git a/modules/gui/pymod/gosty_startup.py b/modules/gui/pymod/gosty_startup.py new file mode 100644 index 0000000000000000000000000000000000000000..029dc19704fc62a4165c0e4ca8f90e01be7d7ee4 --- /dev/null +++ b/modules/gui/pymod/gosty_startup.py @@ -0,0 +1,6 @@ +from ost import * +from ost import gui +gui_mode=True +scene=gfx.Scene() +scene.Stereo=gfx.Stereo + diff --git a/modules/gui/src/gosty.cc b/modules/gui/src/gosty.cc index a0be0fae0762c45d1ae9596cdf57f65c168d8d5a..4fa44a3b4e4cb49b744a4e5d5ecc0bf6f0b65c76 100644 --- a/modules/gui/src/gosty.cc +++ b/modules/gui/src/gosty.cc @@ -106,25 +106,23 @@ String get_ost_root() return dir.path().toStdString(); } -void setup_python_search_path(const String& root, PythonInterpreter& pi) +String setup_python_search_path(const String& root, PythonInterpreter& pi) { std::stringstream site_pkgs; site_pkgs << "python" << PY_MAJOR_VERSION << "." << PY_MINOR_VERSION; #ifdef _MSC_VER - pi.AppendModulePath(QString::fromStdString(root+"\\lib\\"+site_pkgs.str() - +"\\site-packages")); + String loc=root+"\\lib\\"+site_pkgs.str()+"\\site-packages"; #else -# if (defined(__ppc64__) || defined(__x86_64__)) && !defined(__APPLE__) - pi.AppendModulePath(QString::fromStdString(root+"/lib64/"+ - site_pkgs.str()+ - "/site-packages")); -# else - pi.AppendModulePath(QString::fromStdString(root+"/lib/"+ - site_pkgs.str()+ - "/site-packages")); -# endif +# if (defined(__ppc64__) || defined(__x86_64__)) && !defined(__APPLE__) + String loc=root+"/lib64/"+site_pkgs.str()+"/site-packages"; +# else + String loc=root+"/lib/"+site_pkgs.str()+"/site-packages"; +# endif #endif + pi.AppendModulePath(QString::fromStdString(loc)); + // dng is an interactive python session, so add '.' to search path pi.AppendModulePath("."); + return loc; } int setup_resources(QApplication& app) @@ -186,9 +184,18 @@ int init_python_interpreter() console_logger, SLOT(AppendOutput(unsigned int, const QString &))); } - setup_python_search_path(root, py); - py.RunCommand("from ost import *"); - py.RunCommand("gui_mode=True"); + String python_loc=setup_python_search_path(root, py); + //py.RunCommand("from ost import *"); + //py.RunCommand("gui_mode=True"); + std::stringstream cmd; + cmd << "execfile('" << python_loc; +#ifdef _MSC_VER + cmd << "\\ost\\gui\\"; +#else + cmd << "/ost/gui/"; +#endif + cmd << "gosty_startup.py')"; + py.RunCommand(QString::fromStdString(cmd.str())); return 0; } diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 12b81a310b570f6888852d04864af183022ce4f3..9d47c8e0b1766050490d93e2765c1b57696195af 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -31,11 +31,11 @@ if (NOT ENABLE_STATIC) endif() set(INIT_SCRIPTS - init_cl.py + ost_startup.py ) - set(SPD "${LIB_DIR}/python${PYTHON_VERSION}/site-packages") + set(SPD "${LIB_DIR}/python${PYTHON_VERSION}/site-packages/ost") if (ENABLE_GUI) - list(APPEND INIT_SCRIPTS init.py) + list(APPEND INIT_SCRIPTS dng_startup.py) endif() copy_if_different("${CMAKE_CURRENT_SOURCE_DIR}" "${STAGE_DIR}/${SPD}" "${INIT_SCRIPTS}" "python init scripts" ost_scripts) diff --git a/scripts/dng.bat.in b/scripts/dng.bat.in index fba653b9389f646f6ebac54f3c62b38851658808..e6c2c7c7a85d30411f6de75a34830424d59fb08c 100644 --- a/scripts/dng.bat.in +++ b/scripts/dng.bat.in @@ -27,5 +27,4 @@ echo Starting DNG in %BIN_DIR% set DNG_ROOT=%BIN_DIR%\.. set PATH=%BIN_DIR%;%DNG_ROOT%\@LIBDIR@\@BUILD_TYPE@;%DNG_ROOT%\@LIBDIR@;%DNG_ROOT%\bin\@BUILD_TYPE@;%PATH% -REM "%BIN_DIR%\@BUILD_TYPE@\gosty.exe" %DNG_ROOT%\@LIBDIR@\openstructure\init.py ost %* -"%BIN_DIR%\@BUILD_TYPE@\gosty.exe" "%DNG_ROOT%\@LIBDIR@\openstructure\init.py" ost %* +"%BIN_DIR%\@BUILD_TYPE@\gosty.exe" "%DNG_ROOT%\@LIBDIR@\openstructure\dng_startup" ost %* diff --git a/scripts/dng.in b/scripts/dng.in index d1d7096fca8c777e211d61e462b9d5709844f5f4..d431535382c1b077fa2517f0e0d809dc887df526 100755 --- a/scripts/dng.in +++ b/scripts/dng.in @@ -28,4 +28,4 @@ fi BIN_DIR=`dirname "$SCRIPT_NAME"` source "$BIN_DIR/../@LIBEXEC_PATH@/ost_config" -$BIN_DIR/../@LIBEXEC_PATH@/gosty $DNG_INITDIR/init.py dng $opts +$BIN_DIR/../@LIBEXEC_PATH@/gosty $DNG_INITDIR/dng_startup.py dng $opts diff --git a/scripts/init.py b/scripts/dng_startup.py similarity index 100% rename from scripts/init.py rename to scripts/dng_startup.py diff --git a/scripts/ost.bat.in b/scripts/ost.bat.in index 27fb91247bebdd5327d5cf9c6855b3c29570fd8b..006fffe522ce9ef072e3283ee87361e309e8a11e 100644 --- a/scripts/ost.bat.in +++ b/scripts/ost.bat.in @@ -50,6 +50,6 @@ if "%1" == "" ( echo passing commandline options %opts% to ost ) -call "%pyexec%" %interact_% "%DNG_ROOT%\@LIBDIR@\openstructure\init_cl.py" %opts% +call "%pyexec%" %interact_% "%DNG_ROOT%\@LIBDIR@\openstructure\ost_startup.py" %opts% diff --git a/scripts/ost.in b/scripts/ost.in index bea69d9ec23a36cc1912b9457938c31e8d898ea6..dcbe81d4e86773c4d165b36666d9b8e9a8545d9d 100755 --- a/scripts/ost.in +++ b/scripts/ost.in @@ -31,6 +31,6 @@ BIN_DIR=`dirname "$SCRIPT_NAME"` source "$BIN_DIR/../@LIBEXEC_PATH@/ost_config" -$pyexec $interactive "$DNG_ROOT/@LIBDIR@/python@PYTHON_VERSION@/site-packages/init_cl.py" $opts +$pyexec $interactive "$DNG_ROOT/@LIBDIR@/python@PYTHON_VERSION@/site-packages/ost/ost_startup.py" $opts RC=$? exit $RC diff --git a/scripts/ost_config.in b/scripts/ost_config.in index f756d7cd30c29db720aeba659643c18bb872e4c9..1b84852e949c41287d8b659b762c9bc61de8e49b 100644 --- a/scripts/ost_config.in +++ b/scripts/ost_config.in @@ -24,7 +24,7 @@ export DNG_ROOT=`cd "$BIN_DIR/..";pwd` export DNG_BINDIR="$DNG_ROOT/bin" export DNG_LIBDIR="$DNG_ROOT/@LIBDIR@" -export DNG_INITDIR="$DNG_LIBDIR/python@PYTHON_VERSION@/site-packages" +export DNG_INITDIR="$DNG_LIBDIR/python@PYTHON_VERSION@/site-packages/ost/" export PATH="$DNG_BINDIR:${PATH}" export DYLD_FRAMEWORK_PATH="$DNG_LIBDIR:${DYLD_FRAMEWORK_PATH}" diff --git a/scripts/init_cl.py b/scripts/ost_startup.py similarity index 88% rename from scripts/init_cl.py rename to scripts/ost_startup.py index 2c7a048109f132aa4428b208cbd37a97ac237615..1287ec1fbd256b63e81fcf9d3d929986f5dc1078 100644 --- a/scripts/init_cl.py +++ b/scripts/ost_startup.py @@ -27,21 +27,25 @@ parser.disable_interspersed_args() (options, args) = parser.parse_args() _site_packs='python%d.%d/site-packages' % sys.version_info[0:2] +_base_dir=os.getenv('DNG_ROOT') if platform.machine()=='x86_64': - sys.path.insert(0, os.path.join(os.getenv('DNG_ROOT'), 'lib64', _site_packs)) + sys.path.insert(0, os.path.join(_base_dir, 'lib64', _site_packs)) else: - sys.path.insert(0,os.path.join(os.getenv('DNG_ROOT'), 'lib', _site_packs)) + sys.path.insert(0,os.path.join(_base_dir, 'lib', _site_packs)) from ost import * import ost try: from ost import gfx ost.scene = gfx.Scene() + scene=gfx.Scene() ost.scene.Stereo=gfx.Stereo + scene.Stereo=gfx.Stereo except ImportError: + print "ost build without gfx" pass -ost.SetPrefixPath(os.getenv('DNG_ROOT')) +ost.SetPrefixPath(_base_dir) def _InitRuleBasedBuilder(): compound_lib_path=os.path.join(ost.GetSharedDataPath(), 'compounds.chemlib') if os.path.exists(compound_lib_path): @@ -79,6 +83,7 @@ else: PushVerbosityLevel(options.vlevel) +# this should probably only be added when running an interactive shell sys.path.append(".") if len(parser.rargs)>0 :