diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b2944c74463997e54f3aca900d654b7ea987ca7..a67298e7770a1445c38221ac4996499ef083d879 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,79 +6,6 @@ stages: - test -# CentOS6 STAGE -test:centos6.6: - stage: test - image: centos:6.6 - before_script: - - echo "Running centos6.6 'before_script'..." - - yum -y -q -e 0 install tcl - - yum -y -q -e 0 install glibc-common - - yum -y -q -e 0 install glibc-devel - - yum -y -q -e 0 install libjpeg-turbo - - yum -y -q -e 0 install freetype - - yum -y -q -e 0 install libpng - - yum -y -q -e 0 install mesa-libGL-devel - - yum -y -q -e 0 install mesa-libGLU-devel - - mkdir -p /scicore/soft/modules - - ln -s /export/soft/apps/centos6/generic /scicore/soft/apps - - ln -s /export/soft/modules/centos6/generic/all /scicore/soft/modules - - source /export/soft/lua_lmod/centos6/lmod/lmod/init/bash - - module use /scicore/soft/modules/all - - module load CMake/2.8.12-goolf-1.4.10 - - module load Python/2.7.5-goolf-1.4.10 - - module load OpenBLAS/0.2.6-gompi-1.4.10-LAPACK-3.4.2 - - module load Eigen/3.2.1-goolf-1.4.10 - - module load numpy/1.9.1-goolf-1.4.10-Python-2.7.5 - - module load Boost/1.53.0-goolf-1.4.10-Python-2.7.5 - - module load OpenMM/6.1-Linux64 - - module load PyQt/4.11.4-goolf-1.4.10-Python-2.7.5 - - module load LibTIFF/4.0.3-goolf-1.4.10 - - module load libpng/1.6.17-goolf-1.4.10 - - module load zlib/1.2.8-goolf-1.4.10 - - module load Perl/5.16.3-goolf-1.4.10 - - module load HH-suite/2.0.16-goolf-1.4.10-Boost-1.53.0 - - module load SQLite/3.9.2-goolf-1.7.20 - - echo "... done running centos6.6 'before_script'." - script: - - echo "Testing on CentOS 6..." - - echo " Building OST..." - - mkdir build-ci - - cd build-ci - - cmake .. -DENABLE_MM=1 - -DOPEN_MM_LIBRARY=$EBROOTOPENMM/lib/libOpenMM.so - -DOPEN_MM_PLUGIN_DIR=$EBROOTOPENMM/lib/plugins - -DOPEN_MM_INCLUDE_DIR=$EBROOTOPENMM/include - -DCOMPILE_TMTOOLS=1 - -DENABLE_GFX=ON - -DENABLE_GUI=OFF - -DUSE_NUMPY=1 - -DUSE_RPATH=1 - -DPYTHON_ROOT=$EBROOTPYTHON - -DEIGEN3_INCLUDE_DIR=$EBROOTEIGEN/include - -DFFTW_LIBRARY=$EBROOTFFTW/lib/libfftw3f.a - -DFFTW_INCLUDE_DIR=$EBROOTFFTW/include - -DSQLITE3_LIBRARY=$EBROOTSQLITE/lib/libsqlite3.so - -DSQLITE3_INCLUDE_DIR=$EBROOTSQLITE/include - -DBOOST_ROOT=$EBROOTBOOST - -DQT_QMAKE_EXECUTABLE=$EBROOTQT/bin/qmake - -DPNG_LIBRARY=$EBROOTLIBPNG/lib/libpng.so - -DPNG_INCLUDE_DIR=$EBROOTLIBPNG/include - -DPNG_PNG_INCLUDE_DIR=$EBROOTLIBPNG/include - -DZLIB_LIBRARY=$EBROOTZLIB/lib/libz.so - -DZLIB_INCLUDE_DIR=$EBROOTZLIB/include - -DTIFF_INCLUDE_DIR=$EBROOTLIBTIFF/include - -DTIFF_LIBRARY=$EBROOTLIBTIFF/lib/libtiff.so - -DOPTIMIZE=1 - -DCMAKE_C_FLAGS='-Wno-unused-local-typedefs' - -DCMAKE_CXX_FLAGS='-Wno-unused-local-typedefs' - - make -j 2 - - echo " ... done building OST." - - echo " Running unit tests for OST..." - - make check - - echo " ... done running unit tests for OST..." - - echo "... done testing on CentOS 6." - # CentOS7 STAGE test:centos7.3: stage: test @@ -106,7 +33,7 @@ test:centos7.3: - module load Eigen/3.2.8-goolf-1.7.20 - module load numpy/1.10.1-goolf-1.7.20-Python-2.7.11 - module load Boost/1.53.0-goolf-1.7.20-Python-2.7.11 - - module load PyQt/4.11.4-goolf-1.7.20-Python-2.7.11 + - module load Qt5/5.9.3-goolf-1.7.20 - module load LibTIFF/.4.0.4-goolf-1.7.20 - module load Perl/5.22.2-goolf-1.7.20 - module load HH-suite/2.0.16-goolf-1.7.20-Boost-1.53.0-Python-2.7.11 @@ -134,7 +61,7 @@ test:centos7.3: -DSQLITE3_LIBRARY=$EBROOTSQLITE/lib/libsqlite3.so -DSQLITE3_INCLUDE_DIR=$EBROOTSQLITE/include -DBOOST_ROOT=$EBROOTBOOST - -DQT_QMAKE_EXECUTABLE=$EBROOTQT/bin/qmake + -DQT_QMAKE_EXECUTABLE=$EBROOTQT5/bin/qmake -DPNG_LIBRARY=$EBROOTLIBPNG/lib/libpng.so -DPNG_INCLUDE_DIR=$EBROOTLIBPNG/include -DPNG_PNG_INCLUDE_DIR=$EBROOTLIBPNG/include @@ -143,8 +70,8 @@ test:centos7.3: -DTIFF_INCLUDE_DIR=$EBROOTLIBTIFF/include -DTIFF_LIBRARY=$EBROOTLIBTIFF/lib/libtiff.so -DOPTIMIZE=1 - -DCMAKE_C_FLAGS='-L/scicore/soft/apps/LibTIFF/4.0.4-goolf-1.7.20/lib/ -L/scicore/soft/apps/libpng/1.6.18-goolf-1.7.20/lib/ -L/scicore/soft/apps/Boost/1.53.0-goolf-1.7.20-Python-2.7.11/lib/ -L/scicore/soft/apps/Qt/4.8.6-goolf-1.7.20/lib/ -Wno-unused-local-typedefs' - -DCMAKE_CXX_FLAGS='-L/scicore/soft/apps/LibTIFF/4.0.4-goolf-1.7.20/lib/ -L/scicore/soft/apps/libpng/1.6.18-goolf-1.7.20/lib/ -L/scicore/soft/apps/Boost/1.53.0-goolf-1.7.20-Python-2.7.11/lib/ -L/scicore/soft/apps/Qt/4.8.6-goolf-1.7.20/lib/ -Wno-unused-local-typedefs' + -DCMAKE_C_FLAGS='-L/scicore/soft/apps/LibTIFF/4.0.4-goolf-1.7.20/lib/ -L/scicore/soft/apps/libpng/1.6.18-goolf-1.7.20/lib/ -L/scicore/soft/apps/Boost/1.53.0-goolf-1.7.20-Python-2.7.11/lib/ -L/scicore/soft/apps/Qt5/5.9.3-goolf-1.7.20/lib/ -Wno-unused-local-typedefs' + -DCMAKE_CXX_FLAGS='-L/scicore/soft/apps/LibTIFF/4.0.4-goolf-1.7.20/lib/ -L/scicore/soft/apps/libpng/1.6.18-goolf-1.7.20/lib/ -L/scicore/soft/apps/Boost/1.53.0-goolf-1.7.20-Python-2.7.11/lib/ -L/scicore/soft/apps/Qt5/5.9.3-goolf-1.7.20/lib/ -Wno-unused-local-typedefs' - make -j 2 - echo " ... done building OST." - echo " Running unit tests for OST..." diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f0f8504a88dc5c42e50a8dafbcfcc7276f39e0d4..2bf42f24a7114df591e71881b158a7aba9fcb1e6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,11 +1,15 @@ Changes in Release 1.x.x -------------------------------------------------------------------------------- - * Use system provided SQLite3 library - * C++ wrapper around C++ implementation of TMalign - * Database for efficient in-memory lookup of coordinates and sequences + * Use system provided SQLite3 library. + * Port from Qt4 to Qt5. + * C++ wrapper around C++ implementation of TMalign. + * Database for efficient in-memory lookup of coordinates and sequences. * Updated CAD score binding with change in result format, check documentation - for further details + for further details. + * Improved support for recent compilers and libraries. + * Removed support for USE_MESA. + * Several minor bug fixes and improvements. Changes in Release 1.9.0 -------------------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index f4e1d2c9829173ba97fc6e8a792bad42140f832f..e976dce27a4832c2d059df8f7829cab4446ba155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,6 @@ option(ENABLE_GUI "whether the graphical user interface should be enabled" ON) option(ENABLE_GFX "whether graphics support should be enabled" ON) -option(USE_MESA "use software rendered Mesa instead of hardware GL" - OFF) option(ENABLE_IMG "whether the image processing module should be compiled" ON) option(ENABLE_INFO "whether openstructure should be compiled with support for the info library" @@ -205,7 +203,8 @@ if (WIN32) endif() if (ENABLE_INFO) - find_package(Qt4 4.5.0 REQUIRED) + find_package(Qt5Xml REQUIRED) + set(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Xml) endif() if (OPTIMIZE) @@ -224,13 +223,7 @@ else() endif() endif() if (ENABLE_GFX) - if(USE_MESA) - find_package(Mesa REQUIRED) - set(_USE_MESA ON) - else() - find_package(OpenGL REQUIRED) - set(_USE_MESA OFF) - endif() + find_package(OpenGL REQUIRED) endif() if (ENABLE_IMG OR ENABLE_GFX) @@ -276,8 +269,11 @@ if (ENABLE_STATIC) endif() if (ENABLE_GUI) + find_package(Qt5Widgets REQUIRED) + find_package(Qt5OpenGL REQUIRED) + set(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::Widgets Qt5::Core) ost_find_python_module(sip) - ost_find_python_module(PyQt4) + ost_find_python_module(PyQt5) endif() if (ENABLE_SPNAV) @@ -361,7 +357,6 @@ message(STATUS " Info support (-DENABLE_INFO) : ${_INFO}\n" " Graphical interface (-DENABLE_GUI) : ${_UI}\n" " OpenGL support (-DENABLE_GFX) : ${_OPENGL}\n" - " OpenGL via Mesa (-DUSE_MESA) : ${_USE_MESA}\n" " Image Processing support (-DENABLE_IMG) : ${_IMG}\n" " Shader support (-DUSE_SHADER) : ${_SHADER}\n" " Numpy support (-DUSE_NUMPY) : ${_NUMPY}\n" diff --git a/build_configs/darwin_macports.txt b/build_configs/darwin_macports.txt index 821e0c792aa36718fa7e773f82be8b0b8156b4df..5d5aefe2dd738d0a2b6f9f6370b82d95bf8e4bff 100644 --- a/build_configs/darwin_macports.txt +++ b/build_configs/darwin_macports.txt @@ -1,4 +1,4 @@ -# this file contains a list of settings to be used on MacOS X with +# this file contains a list of settings to be used on macOS with # the dependencies installed over MacPorts set(BOOST_ROOT "/opt/local" CACHE PATH "prefix for the boost") set(PYTHON_ROOT "/opt/local" CACHE PATH "prefix for python") diff --git a/cmake_support/FindPython.cmake b/cmake_support/FindPython.cmake index e1ba2b78830213e3696b602693c42d2dfa228dff..673a802199b94de7b43a08b38a549eec275ae85e 100644 --- a/cmake_support/FindPython.cmake +++ b/cmake_support/FindPython.cmake @@ -2,7 +2,7 @@ # Check for Python Libraries # # PYTHON_IGNORE_FRAMEWORKS if set, do not check for python frameworks. -# has meaning on MacOS X only +# has meaning on macOS only # PYTHON_ROOT Prefix for python libraries # PYTHON_MIN_VERSION minimal python version required # diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake index 22e7746563005ee7fb9faeebe66c46a498910555..4ee0d944049fed084c53ea42b9977132c3f51d37 100644 --- a/cmake_support/OST.cmake +++ b/cmake_support/OST.cmake @@ -702,9 +702,9 @@ macro(ost_unittest) foreach(py_test ${PY_TESTS}) set(python_path $ENV{PYTHONPATH}) if(python_path) - set(python_path "${python_path}:") + set(python_path ":${python_path}") endif(python_path) - set(python_path "${python_path}${LIB_STAGE_PATH}/python${PYTHON_VERSION}/site-packages") + set(python_path "${LIB_STAGE_PATH}/python${PYTHON_VERSION}/site-packages${python_path}") if(WIN32) set (PY_TESTS_CMD "PYTHONPATH=${python_path} ${PYTHON_BINARY}") # todo fix python unit test running for Windows @@ -896,6 +896,12 @@ macro(setup_compiler_flags) # -fno-strict-aliasing set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing" ) endif() + #message(STATUS "GCC VERSION " ${_GCC_VERSION}) + if ((ENABLE_INFO OR ENABLE_GUI) AND _GCC_VERSION LESS "60") + # for older compilers we need to enable C++11 for Qt5 + #message(STATUS "ADDING C++11 FLAG") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif() endif() endmacro() set(_BOOST_MIN_VERSION 1.31) diff --git a/deployment/macos/pack.py b/deployment/macos/pack.py index d849446be5d0f2e01d2ff27bed4c958cf5e7d16d..beb7d7d74932339475945cee35ccc59048e9f5e1 100644 --- a/deployment/macos/pack.py +++ b/deployment/macos/pack.py @@ -1,7 +1,7 @@ """ deploy.py helps you package your code into a standalone application. -for now, MacOS X and Linux are supported... +for now, macOS and Linux are supported... """ import os import subprocess diff --git a/doc/conf/conf.py b/doc/conf/conf.py index 5dd3d83e3fb5ee27ae9f7598213270f1fd5ae204..7600179f94620b1470c6d8452d913d7b597d8073 100644 --- a/doc/conf/conf.py +++ b/doc/conf/conf.py @@ -14,11 +14,18 @@ import sys, os site_packs='python%d.%d/site-packages' % sys.version_info[0:2] -sys.path.append(os.path.join(os.path.abspath('../..'), - 'stage/lib', site_packs)) -sys.path.append(os.path.join(os.path.abspath('../..'), - 'stage/lib64', site_packs)) -print site_packs +# here we make sure that these paths are checked first... +# note that we probably should use cmake to set these paths (see PM3) +sys.path.insert(0, os.path.join(os.path.abspath('../../build'), + 'stage/lib', site_packs)) +sys.path.insert(0, os.path.join(os.path.abspath('../../build'), + 'stage/lib64', site_packs)) +sys.path.insert(0, os.path.join(os.path.abspath('../..'), + 'stage/lib', site_packs)) +sys.path.insert(0, os.path.join(os.path.abspath('../..'), + 'stage/lib64', site_packs)) +# print site_packs +# print os.path.abspath('../..') import ost # -- General configuration ----------------------------------------------------- @@ -42,7 +49,7 @@ master_doc = 'index' # General information about the project. project = u'OpenStructure' -copyright = u'2018, OpenStructure authors' +copyright = u'2019, OpenStructure authors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -93,6 +100,13 @@ modindex_common_prefix = ['ost.'] # -- Options for HTML output --------------------------------------------------- +# Since we use sphinx.ext.mathjax to render formulas on HTML pages: The +# MathJax web-page deprecated their own CDN to serve JavaScript but it is +# still the default for Sphinx. Here we redirect to the CDN recommended by +# MathJax. +mathjax_path = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' +# Look for "math" markup (e.g. ost.table.Table.GetOptimalPrefactors) to test + # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. html_theme = 'sphinxdoc' diff --git a/docker/Dockerfile b/docker/Dockerfile index 12c3fd65249ea915d7aa75aae238933e2dde8052..a02301453bc4c02b5cbb0de4a2948d64f2d15d0e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,16 +1,9 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 # ARGUMENTS ########### -# OBLIGATORY -ARG OPENSTRUCTURE_VERSION -RUN if [ -z "${OPENSTRUCTURE_VERSION}" ]; then \ - echo "OPENSTRUCTURE_VERSION argument is obligatory. Run with --build-arg OPENSTRUCTURE_VERSION=<VERSION>"; \ - exit 1; \ - else : ; fi - -# OPTIONAL +ARG OPENSTRUCTURE_VERSION="1.10.0" ARG SRC_FOLDER="/usr/local/src" ARG CPUS_FOR_MAKE=8 ARG PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" @@ -24,6 +17,7 @@ ARG OPENMM_LIB_PATH="/usr/local/openmm/lib/" # INSTALL SYSTEM DEPS ##################### RUN apt-get update -y && apt-get install -y cmake \ + g++ \ sip-dev \ libtiff-dev \ libfftw3-dev \ @@ -32,11 +26,9 @@ RUN apt-get update -y && apt-get install -y cmake \ libpng-dev \ python-all \ python2.7 \ - python-qt4 \ - qt4-qtconfig \ - qt4-qmake \ - libqt4-dev \ - libpng-dev \ + python-pyqt5 \ + qt5-qmake \ + qtbase5-dev \ wget \ git \ gfortran \ @@ -48,9 +40,12 @@ RUN apt-get update -y && apt-get install -y cmake \ clustalw \ python-virtualenv \ libsqlite3-dev \ + dssp \ + python-enum34 \ locales && \ - # CLEANUP - rm -rf /var/lib/apt/lists/* + # CLEANUP + rm -rf /var/lib/apt/lists/* + # INSTALL SOME PYTHON PACKAGES GLOBALY ###################################### RUN pip install -U pip==9.0.3 && \ @@ -92,18 +87,6 @@ RUN cd ${SRC_FOLDER} && \ rm -rf ${SRC_FOLDER}/openmm-${OPENMM_VERSION}.tar.gz && \ rm -rf ${SRC_FOLDER}/openmm-${OPENMM_VERSION} - -# COMPILE AND INSTALL DSSP -########################## -RUN cd ${SRC_FOLDER} && \ - wget ftp://ftp.cmbi.umcn.nl/pub/molbio/software/dssp-2/dssp-${DSSP_VERSION}.tgz && \ - tar -xvzf dssp-${DSSP_VERSION}.tgz && \ - cd dssp-${DSSP_VERSION} && \ - make -j ${CPUS_FOR_MAKE} && \ - make install && \ - rm -rf ${SRC_FOLDER}/dssp-${DSSP_VERSION}.tgz && \ - rm -rf ${SRC_FOLDER}/dssp-${DSSP_VERSION} - # INSTALL OST ############# RUN cd ${SRC_FOLDER} && \ @@ -112,6 +95,7 @@ RUN cd ${SRC_FOLDER} && \ mkdir openstructure-${OPENSTRUCTURE_VERSION} && \ tar xf openstructure-${OPENSTRUCTURE_VERSION}.tar.gz -C ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION} --strip-components=1 && \ mkdir -p ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build + WORKDIR ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build # cmake ost diff --git a/docker/README.rst b/docker/README.rst index ebed4e994c2aac8045b0f1171fb38948bb19d849..bc6efa1ae0f062bcf78f78a6f426d1acff8bb7ae 100644 --- a/docker/README.rst +++ b/docker/README.rst @@ -15,22 +15,19 @@ In order to build OST image: .. code-block:: bash cd <PATH TO OST>/docker - docker build --tag <IMAGE NAME> --build-arg OPENSTRUCTURE_VERSION=<VERSION> -f Dockerfile . + docker build --tag <IMAGE NAME> -f Dockerfile . or if you downloaded the Dockerfile directly: .. code-block:: bash - docker build --tag <IMAGE NAME> --build-arg OPENSTRUCTURE_VERSION=<VERSION> -f <DOCKERFILE NAME> <PATH TO DOCKERFILE DIR> + docker build --tag <IMAGE NAME> -f <DOCKERFILE NAME> <PATH TO DOCKERFILE DIR> -You can chose any image name (tag) eg. ost. The ``OPENSTRUCTURE_VERSION`` -build argument is mandatory and image will not built without it. See -`CHANGELOG <https://git.scicore.unibas.ch/schwede/openstructure/blob/master/CHANGELOG.txt>`_ -for current list of available releases. This is not expected to work for -versions which are much older than the most recent one since the dependencies -might have changed, but it should work for a few versions. If you need the -recipe for an older version, we suggest to get an older recipe from the git -history. +You can chose any image name (tag) eg. ost. +Here we only keep the recipe for the most recent version of OpenStructure. To +build an image for a different version, you can either adapt the +``OPENSTRUCTURE_VERSION`` variable in the recipe or look in the git history for +an older recipe. Testing the image ----------------- diff --git a/examples/code_fragments/harmony/glwin.py b/examples/code_fragments/harmony/glwin.py deleted file mode 100644 index 8e0549cecff82838bf418055fcf6f5792b022dfc..0000000000000000000000000000000000000000 --- a/examples/code_fragments/harmony/glwin.py +++ /dev/null @@ -1,91 +0,0 @@ -import math -from ost import gfx, geom, mol -from PyQt4.QtGui import * -from PyQt4.QtCore import * -from PyQt4.QtOpenGL import * - -TRANS_VAL = 20 - -class DokkGLCanvas(QGLWidget): - - def __init__(self, format, parent=None): - QGLWidget.__init__(self, format, parent) - self.last_pos_=QPoint() - self.setAutoFillBackground(False) - #self.setAttribute(Qt.WA_KeyCompression,True) - self.resize(800, 800) - self.atom=mol.AtomHandle() - def initializeGL(self): - gfx.Scene().InitGL() - self.startTimer(10) - def paintGL(self): - gfx.Scene().RenderGL() - def paintEvent(self, event): - self.makeCurrent() - self.paintGL() - #painter=QPainter(self) - #self.RenderHUD(painter) - self.swapBuffers() - - def RenderHUD(self, painter): - painter.setPen(QColor(100, 100, 100, 50)) - painter.setBrush(QColor(200, 200, 200, 50)) - painter.drawRect(QRect(QPoint(0, 0), QSize(self.width(), 25))) - painter.setPen(QPen(QColor(255,255,255), Qt.SolidLine)) - painter.setFont(QFont("Verdana")) - def resizeGL(self, w, h): - gfx.Scene().Resize(w, h) - - def mousePressEvent(self, event): - self.last_point_=QPoint(event.x(), event.y()) - v1=gfx.Scene().UnProject(geom.Vec3(event.x(), self.height()-event.y(), 0.0)); - v2=gfx.Scene().UnProject(geom.Vec3(event.x(), self.height()-event.y(), 1.0)); - self.atom=self.world.go.PickAtom(geom.Line3(v1, v2), 0.1) - self.world.go.SetColor(gfx.WHITE, '') - if self.atom.IsValid(): - self.world.go.SetColorForAtom(gfx.RED, self.atom) - def mouseReleaseEvent(self, event): - self.world.go.SetColor(gfx.WHITE, '') - self.atom=mol.AtomHandle() - def mouseMoveEvent(self, event): - delta=QPoint(event.x(), event.y())-self.last_point_ - self.last_point_=QPoint(event.x(), event.y()) - if event.buttons() & Qt.LeftButton: - if self.atom.IsValid(): - rot=gfx.Scene().GetTransform().GetRot() - force=-rot.GetRow(1)*delta.y()+rot.GetRow(0)*delta.x() - self.world.AddForce(self.atom, force*2) - def wheelEvent(self, event): - self.OnTransform(gfx.INPUT_COMMAND_TRANSZ,0,gfx.TRANSFORM_VIEW, - 0.1*(-event.delta())) - - def timerEvent(self, event): - self.world.Update() - self.update() - def OnTransform(self,com, indx, trg, val): - gfx.Scene().Apply(gfx.InputEvent(gfx.INPUT_DEVICE_MOUSE, - com, indx,trg,val*0.5),False) - - def keyReleaseEvent(self, event): - if event.key() == Qt.Key_Escape: - QApplication.exit() - -class DokkGLWin(gfx.GLWinBase): - def _CreateFormat(self): - fmt=QGLFormat() - fmt.setAlpha(True) - return fmt - def __init__(self): - gfx.GLWinBase.__init__(self) - self.canvas_=DokkGLCanvas(self._CreateFormat()) - def DoRefresh(self): - self.refresh_=True - def SetLevel(self, level): - self.canvas_.SetLevel(level) - def Show(self, fullscreen): - if fullscreen: - self.canvas_.showFullScreen() - else: - self.canvas_.show() - def SetStereo(): - pass diff --git a/examples/code_fragments/harmony/harmony b/examples/code_fragments/harmony/harmony deleted file mode 100755 index c315b3f085f5fd3e0ad977c5618d8fffec8fd2cc..0000000000000000000000000000000000000000 --- a/examples/code_fragments/harmony/harmony +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -dng -s harmony.py diff --git a/examples/code_fragments/harmony/harmony.py b/examples/code_fragments/harmony/harmony.py deleted file mode 100644 index d9f98316d49d295e71f5d8f488b8b7052df5e392..0000000000000000000000000000000000000000 --- a/examples/code_fragments/harmony/harmony.py +++ /dev/null @@ -1,65 +0,0 @@ -import glwin -from ost import io, geom, gfx, mol - -class World: - def __init__(self): - self.atom_string=mol.CreateEntity() - edi=self.atom_string.EditXCS(mol.EditMode.BUFFERED_EDIT) - chain=edi.InsertChain("A") - r=edi.AppendResidue(chain, "STRING") - prev_atom=mol.AtomHandle() - for i in range(-5, 5): - atom=edi.InsertAtom(r, "X%02d" % (i+5), geom.Vec3(i, 0, 0)) - if prev_atom.IsValid(): - edi.Connect(prev_atom, atom) - prev_atom=atom - self.go=gfx.Entity("GO", gfx.CUSTOM, self.atom_string) - self.go.custom_options.SetBondRad(0.1) - self.go.custom_options.SetSphereRad(0.4) - scene.Add(self.go) - scene.CenterOn(self.go) - self.last_positions=[] - for atom in self.atom_string.atoms: - self.last_positions.append(atom.pos) - self.forces=[] - for i in range(len(self.last_positions)): - self.forces.append(geom.Vec3()) - def AddForce(self, atom, force): - for index, aa in enumerate(self.atom_string.atoms): - if aa==atom: - self.forces[index]+=force - break - def Update(self): - last_atom=mol.AtomHandle() - atoms=self.atom_string.atoms - for index, atom in enumerate(atoms): - if last_atom.IsValid(): - diff=last_atom.pos-atom.pos - length=geom.Length(diff) - diff/=length - force=(length-1)**2*diff*100 - if length<1.0: - force*=-1 - self.forces[index-1]-=force - self.forces[index]+=force - last_atom=atom - for i in range(len(atoms)): - for j in range(i+2, len(atoms)): - diff=atoms[i].pos-atoms[j].pos - length=geom.Length(diff) - diff/=length - force=((1.0/length)**12-(1.0/length)**6)*diff - self.forces[i]+=force - self.forces[j]-=force - edi=self.atom_string.EditXCS(mol.EditMode.BUFFERED_EDIT) - for force, atom in zip(self.forces, self.atom_string.atoms): - edi.SetAtomPos(atom, atom.pos+force*0.004) - self.go.Rebuild() - for i in range(len(self.last_positions)): - self.forces[i]=geom.Vec3() - -dokk_win=glwin.DokkGLWin() - -world=World() -dokk_win.canvas_.world=world -dokk_win.Show(fullscreen=('--fullscreen' in sys.argv)) diff --git a/examples/code_fragments/mm/ethanol_example.py b/examples/code_fragments/mm/ethanol_example.py index 1f8988d384b37763a1a97099959a604b0da2df1c..398be2be8be5c5f74d4785cacbb4d54495aa8d41 100644 --- a/examples/code_fragments/mm/ethanol_example.py +++ b/examples/code_fragments/mm/ethanol_example.py @@ -1,5 +1,5 @@ from ost.mol.mm import * -from PyQt4 import QtCore +from PyQt5 import QtCore """ MM - Demo @@ -17,8 +17,7 @@ class Anim(QtCore.QTimer): self.sim=sim self.go = go self.ed = ent.EditXCS() - QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer) - + self.timeout.connect(self.OnTimer) def OnTimer(self): self.sim.Steps(1) diff --git a/examples/code_fragments/mm/ethanol_example_using_topology.py b/examples/code_fragments/mm/ethanol_example_using_topology.py index 5587a07f988d3d9c9f7fe957b500b8b1eab22154..553ef88609ea77c1e172c60b6e064078d07885c9 100644 --- a/examples/code_fragments/mm/ethanol_example_using_topology.py +++ b/examples/code_fragments/mm/ethanol_example_using_topology.py @@ -1,5 +1,5 @@ from ost.mol.mm import * -from PyQt4 import QtCore +from PyQt5 import QtCore from math import sqrt from math import sin @@ -28,7 +28,7 @@ class Anim(QtCore.QTimer): self.force_constant = param[3] self.steps = 0 self.counter = 0 - QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer) + self.timeout.connect(self.OnTimer) def OnTimer(self): if self.steps % 20 == 0: diff --git a/examples/code_fragments/mm/gb_example.py b/examples/code_fragments/mm/gb_example.py index 99a55343c6d4b0873ac0b71922eebf41fb9ae491..6859e29c7ccf6153f8599decce4cc8c3af642a14 100644 --- a/examples/code_fragments/mm/gb_example.py +++ b/examples/code_fragments/mm/gb_example.py @@ -1,5 +1,5 @@ from ost.mol import mm -from PyQt4 import QtCore +from PyQt5 import QtCore """ MM - Demo @@ -17,7 +17,7 @@ class Anim(QtCore.QTimer): self.sim=sim self.go = go self.ed = ent.EditXCS(ost.mol.BUFFERED_EDIT) - QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer) + self.timeout.connect(self.OnTimer) def OnTimer(self): diff --git a/examples/code_fragments/trj/test_trj.py b/examples/code_fragments/trj/test_trj.py index a1625996c109ed4272a2d8439219b9e7d583db61..5cee12d026633ca61a6b6b119167b0035cae6a1b 100644 --- a/examples/code_fragments/trj/test_trj.py +++ b/examples/code_fragments/trj/test_trj.py @@ -1,5 +1,5 @@ # trajectory generated by Raimund Dutzler -from PyQt4 import QtCore +from PyQt5 import QtCore class Anim(QtCore.QTimer): def __init__(self,cg,go): @@ -7,8 +7,7 @@ class Anim(QtCore.QTimer): self.cg_=cg self.go_=go self.frame_=0 - QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer) - + self.timeout.connect(self.OnTimer) def OnTimer(self): self.frame_=(self.frame_+1)%self.cg_.GetFrameCount() diff --git a/examples/code_fragments/ui/board.py b/examples/code_fragments/ui/board.py index 4a45ce1d31606a07f81783fb217c9beb4ecf243e..6717d72911f1c3fba5490fc5dfb2738324157e4b 100644 --- a/examples/code_fragments/ui/board.py +++ b/examples/code_fragments/ui/board.py @@ -4,15 +4,16 @@ import sys import random -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets -class Board(QtGui.QFrame): +class Board(QtWidgets.QFrame): BoardWidth = 10 BoardHeight = 22 Speed = 300 + messageToStatusBar = QtCore.pyqtSignal(str) def __init__(self, parent=None): - QtGui.QFrame.__init__(self, parent) + QtWidgets.QFrame.__init__(self, parent) self.resize(180, 380) self.setMinimumHeight(380) self.setMinimumWidth(180) @@ -32,6 +33,7 @@ class Board(QtGui.QFrame): self.nextPiece.setRandomShape() + def shapeAt(self, x, y): return self.board[(y * Board.BoardWidth) + x] @@ -52,9 +54,8 @@ class Board(QtGui.QFrame): self.isWaitingAfterLine = False self.numLinesRemoved = 0 self.clearBoard() - - self.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), - str(self.numLinesRemoved)) + + self.messageToStatusBar.emit(str(self.numLinesRemoved)) self.newPiece() self.timer.start(Board.Speed, self) @@ -66,12 +67,10 @@ class Board(QtGui.QFrame): self.isPaused = not self.isPaused if self.isPaused: self.timer.stop() - self.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), "paused") + self.messageToStatusBar.emit("paused") else: self.timer.start(Board.Speed, self) - self.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), - str(self.numLinesRemoved)) - + self.messageToStatusBar.emit(str(self.numLinesRemoved)) self.update() def paintEvent(self, event): @@ -98,7 +97,7 @@ class Board(QtGui.QFrame): def keyPressEvent(self, event): if not self.isStarted or self.curPiece.shape() == Tetrominoes.NoShape: - QtGui.QWidget.keyPressEvent(self, event) + QtWidgets.QWidget.keyPressEvent(self, event) return key = event.key() @@ -120,7 +119,7 @@ class Board(QtGui.QFrame): elif key == QtCore.Qt.Key_D: self.oneLineDown() else: - QtGui.QWidget.keyPressEvent(self, event) + QtWidgets.QWidget.keyPressEvent(self, event) def timerEvent(self, event): if event.timerId() == self.timer.timerId(): @@ -185,8 +184,7 @@ class Board(QtGui.QFrame): if numFullLines > 0: self.numLinesRemoved = self.numLinesRemoved + numFullLines - self.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), - str(self.numLinesRemoved)) + self.messageToStatusBar.emit(str(self.LinesRemoved)) self.isWaitingAfterLine = True self.curPiece.setShape(Tetrominoes.NoShape) self.update() @@ -201,9 +199,7 @@ class Board(QtGui.QFrame): self.curPiece.setShape(Tetrominoes.NoShape) self.timer.stop() self.isStarted = False - self.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), "Game over") - - + self.messageToStatusBar.emit("Game over") def tryMove(self, newPiece, newX, newY): for i in range(4): @@ -228,11 +224,11 @@ class Board(QtGui.QFrame): painter.fillRect(x + 1, y + 1, self.squareWidth() - 2, self.squareHeight() - 2, color) - painter.setPen(color.light()) + painter.setPen(color.lighter()) painter.drawLine(x, y + self.squareHeight() - 1, x, y) painter.drawLine(x, y, x + self.squareWidth() - 1, y) - painter.setPen(color.dark()) + painter.setPen(color.darker()) painter.drawLine(x + 1, y + self.squareHeight() - 1, x + self.squareWidth() - 1, y + self.squareHeight() - 1) painter.drawLine(x + self.squareWidth() - 1, diff --git a/examples/code_fragments/ui/mdi_example.py b/examples/code_fragments/ui/mdi_example.py index ba8b14d8c1ce63b169b0a040bf817ee250bab74a..d6cd2abe2ebe3a9ad3498cd35e0f1bf650c89efe 100644 --- a/examples/code_fragments/ui/mdi_example.py +++ b/examples/code_fragments/ui/mdi_example.py @@ -16,14 +16,14 @@ # along with this library; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #------------------------------------------------------------------------------ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtGui, QtCore, QtWidgets from ost import gui import sys, random -class Points(QtGui.QWidget): +class Points(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.setWindowTitle('Some Points') def paintEvent(self, event): diff --git a/examples/code_fragments/ui/menubar_example.py b/examples/code_fragments/ui/menubar_example.py index fc953b7ad497f1ce027f0f10c58d2ce37a2293df..52000903c445c972388c30bc11922e0304bb670a 100644 --- a/examples/code_fragments/ui/menubar_example.py +++ b/examples/code_fragments/ui/menubar_example.py @@ -19,24 +19,23 @@ from ost import gui from ost.gui import FileLoader -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets class InitMenuBar(QtCore.QObject): def __init__(self, menu_bar=None): QtCore.QObject.__init__(self, menu_bar) self.scene_selection_ = gui.SceneSelection.Instance() - test_action = QtGui.QAction('Test Menu Point', self) + test_action = QtWidgets.QAction('Test Menu Point', self) test_action.setStatusTip('Print Hello World') test_action.setShortcut('Ctrl+T') - - self.connect(test_action, QtCore.SIGNAL('triggered()'), self.TestMethod) + test_action.triggered.connect(self.TestMethod) test = menu_bar.addMenu('&Test') test.addAction(test_action) def TestMethod(self): - reply = QtGui.QMessageBox() + reply = QtWidgets.QMessageBox() node_count = self.scene_selection_.GetActiveNodeCount() if(node_count > 0): @@ -47,7 +46,7 @@ class InitMenuBar(QtCore.QObject): reply.setText("Oh, there are selected entities: %s" % string) else: reply.setText("This is a test!") - reply.addButton(QtGui.QMessageBox.Yes) + reply.addButton(QtWidgets.QMessageBox.Yes) reply.exec_() menu_bar=gui.GostyApp.Instance().perspective.GetMenuBar() diff --git a/examples/code_fragments/ui/widget_example.py b/examples/code_fragments/ui/widget_example.py index 80aee7d5e6bbcf30d666ce30e9d258850318dc71..ced1d02fa6b3422b41016a8fd8487c3f6479810b 100644 --- a/examples/code_fragments/ui/widget_example.py +++ b/examples/code_fragments/ui/widget_example.py @@ -19,14 +19,14 @@ from ost import gui -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui from board import Board #Get Panels (Class which manages widgets) panels=gui.GostyApp.Instance().perspective.panels #Create Widget -tetris=Board(panels.qobject) +tetris=Board() #Wrap widget to Qt Widget wid=gui.Widget(tetris) diff --git a/examples/demos/charmm_trj_blur.py b/examples/demos/charmm_trj_blur.py index 8edfdc0c2768007b83698acf22cd8f2caa012da7..f65d0dbccb9f7fb51c4329b5668ec35fd66be378 100644 --- a/examples/demos/charmm_trj_blur.py +++ b/examples/demos/charmm_trj_blur.py @@ -1,5 +1,5 @@ # trajectory generated by Raimund Dutzler -from PyQt4 import QtCore +from PyQt5 import QtCore scene.RemoveAll() @@ -14,7 +14,7 @@ class Anim(QtCore.QTimer): self.cg_=cg self.go_=go self.frame_=0 - QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer) + self.timeout.connect(self.OnTimer) def OnTimer(self): self.frame_=(self.frame_+1)%self.cg_.GetFrameCount() diff --git a/examples/demos/the_hammer.py b/examples/demos/the_hammer.py index 4f6266d287430788fa99d3b56647bba48c9d9588..1c308b2d7ae8ad20d3b0413d783e07b2db3dfd43 100644 --- a/examples/demos/the_hammer.py +++ b/examples/demos/the_hammer.py @@ -1,4 +1,4 @@ -from PyQt4 import QtCore +from PyQt5 import QtCore import math # remove all objects from scene, just in case scene.RemoveAll() @@ -11,8 +11,7 @@ class Anim(QtCore.QTimer): self.angle=0.0 self.dir=0.01 self.edi=self.a.view.handle.EditXCS(mol.UNBUFFERED_EDIT) - QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer) - + self.timeout.connect(self.OnTimer) def OnTimer(self): self.angle+=self.dir diff --git a/modules/config/CMakeLists.txt b/modules/config/CMakeLists.txt index 391a70c9a3ba2a2906e9985924666aa56120ad01..e6588b170dd743186cc19253d0a4e14c78539e0e 100644 --- a/modules/config/CMakeLists.txt +++ b/modules/config/CMakeLists.txt @@ -16,12 +16,6 @@ else() set(shader_support 0) endif() -if (USE_MESA) - set(mesa_support 1) -else() - set(mesa_support 0) -endif() - if (USE_NUMPY) set(numpy_support 1) else() diff --git a/modules/config/config.hh.in b/modules/config/config.hh.in index 5a5b2bb4c25e8c1d6116b2d6d7326274562b73bf..7e8a96579478b0d1010ffe3197618d7cbd076619 100644 --- a/modules/config/config.hh.in +++ b/modules/config/config.hh.in @@ -24,7 +24,6 @@ */ #define OST_SHADER_SUPPORT_ENABLED @shader_support@ -#define OST_MESA_SUPPORT_ENABLED @mesa_support@ #define OST_PROFILING_ENABLED @profiling_enabled@ #define OST_ANIMATIONS_ENABLED @animations_enabled@ #define OST_IMG_ENABLED @img_enabled@ diff --git a/modules/conop/src/processor.cc b/modules/conop/src/processor.cc index 141003c654d1008070bd1700fd2b5f613ecb8df0..7727bd704d8e09e54573ac517275d8d8d0f3e0a3 100644 --- a/modules/conop/src/processor.cc +++ b/modules/conop/src/processor.cc @@ -344,9 +344,7 @@ bool Processor::HasUnknownAtoms(mol::ResidueHandle res, CompoundPtr compound, bool strict_hydrogens) const { - AtomSpecList::const_iterator j=compound->GetAtomSpecs().begin(); mol::AtomHandleList atoms=res.GetAtomList(); - mol::AtomHandleList::iterator i=atoms.begin(); for (mol::AtomHandleList::iterator i=atoms.begin(), e=atoms.end(); i!=e; ++i) { if ((*i).Impl()->GetState()==std::numeric_limits<unsigned int>::max()) { diff --git a/modules/doc/install.rst b/modules/doc/install.rst index 978e937614727f9821352e684858a3f546bc865e..d9b3580ccc25a2c4a68386357db85f0257920048 100644 --- a/modules/doc/install.rst +++ b/modules/doc/install.rst @@ -24,8 +24,8 @@ the steps which we describe in detail below. In essence, these steps are: Installing the Dependencies -------------------------------------------------------------------------------- -OpenStructure uses a bunch of OpenSource libraries. If you haven't already -installed them, please install them now! Where appropriate the minimally +OpenStructure uses a bunch of open-source libraries. If you haven't already +installed them, please install them now! Where appropriate, the minimally required version is given in parentheses. * `CMake <http://cmake.org>`_ (2.6.4) @@ -46,12 +46,12 @@ When you enable support for image processing, you will need: If you would like to use the info module, also install: -* `Qt4 <http://qt-project.org/>`_ (4.5, Qt5 is not supported yet) +* `Qt5 <http://qt-project.org/>`_ and a C++11 compatible compiler If you would like to use the graphical user interface (GUI), also install: * `SIP <http://www.riverbankcomputing.co.uk/software/sip/download>`_ -* `PyQt4 <http://www.riverbankcomputing.co.uk/software/pyqt/download>`_ +* `PyQt5 <http://www.riverbankcomputing.co.uk/software/pyqt/download>`_ If you would like to use the :mod:`molecular mechanics <ost.mol.mm>` module: @@ -116,16 +116,16 @@ cmake. You can do that by invoking `cmake` in the project directory. There are two kinds of options: Options that let you control the building behaviour, enabling and disabling the compilation of certain modules and options that let you tell CMake where to find the dependencies. All of them are passed -to CMake with via `-D<opt>=<value>`. +to CMake via `-D<opt>=<value>`. Flag to choose build generator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -CMake supports different build generators. On UNIX, i.e. MacOS X and Linux, the +CMake supports different build generators. On UNIX, i.e. macOS and Linux, the default build generator is Makefiles, but it is also possible to use other -programs. For a list of supported build generators on your platform, start cmake -without parameters. +programs. For a list of supported build generators on your platform, run +`cmake` without parameters. .. _cmake-flags: @@ -227,7 +227,7 @@ can influence it. Build Options ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* `OPTIMIZE` can be switched on to build an optimized (-O3 -DNDEBUG) version of +* `OPTIMIZE` can be switched on to build an optimised (-O3 -DNDEBUG) version of OpenStructure. By default, this is switched off. * `USE_DOUBLE_PRECISION` will switch on double precision within OpenStructure. @@ -247,8 +247,6 @@ Build Options * Experimental settings (only change if you know what you are doing): - * `USE_MESA` to use software rendered Mesa instead of hardware GL. By default, - this is turned off. * `USE_SHADER` controls whether to compile with shader support. By default, this is turned off. * `ENABLE_SPNAV` controls whether 3DConnexion devices should be supported. By @@ -264,10 +262,10 @@ Build Options Example Configurations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -**Generic linux without GUI** +**Generic Linux without GUI** The simplest way to compile OpenStructure is to disable the GUI and any -dependency to Qt4. You can build an optimized OpenStructure without GUI as +dependency to Qt5. You can build an optimised OpenStructure without GUI as follows: .. code-block:: bash @@ -291,26 +289,21 @@ observed for OpenMM versions 6.1 until 7.1.1 when compiling with gcc versions >= 5.1. In those cases, you cannot use the binaries and will have to install OpenMM from source. -On some Linux distributions, there are issues with Qt4 and hence it may not be -possible to build OpenStructure with GUI support at all. This is for instance -known to be an issue with boost versions >= 1.62. We hope to support Qt5 in the -next OpenStructure release. - -**Ubuntu 16.04 with GUI** +**Ubuntu 18.04 LTS / Debian 9 with GUI** All the dependencies can be installed from the package manager as follows: .. code-block:: bash - sudo apt-get install cmake sip-dev libtiff-dev libfftw3-dev libeigen3-dev \ - libpng-dev python-all python2.7 python-qt4 libboost-all-dev \ - qt4-qtconfig qt4-qmake libqt4-dev libpng-dev libsqlite3-dev + sudo apt-get install cmake g++ sip-dev libtiff-dev libfftw3-dev libeigen3-dev \ + libpng-dev python-all python2.7 python-pyqt5 libboost-all-dev \ + qt5-qmake qtbase5-dev libpng-dev libsqlite3-dev Now, all dependencies are located in standard locations and cmake will automatically find them without the need to pass any additional parameters. The only exception is the Python library which is put in a different path than -expected. Also, we add -DOPTIMIZE, which will tell cmake to build an optimized +expected. Also, we add -DOPTIMIZE, which will tell cmake to build an optimised version of OpenStructure. .. code-block:: bash @@ -319,22 +312,42 @@ version of OpenStructure. -DOPTIMIZE=ON -**macOS with Homebrew without GUI** +**macOS (Mojave/ High Sierra) with Homebrew** + +`Homebrew <https://brew.sh/>`_ can be used to conveniently install all +dependencies. The current Boost version, as of writing these instructions, is +1.70.0 but works so far. Do not forget to also install `boost-python`. + +If you want to build the info module or the graphical user interface, make sure +you have the Xcode app installed. Just the Xcode command line tools which are +sufficient for Homebrew, will not work with Qt5. + +Before running CMake, some environment variables need to be set on the command +line. If omitted, the linker will throw a bunch of warnings later: + +.. code-block:: bash + + export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk + +If building the info module or with graphical user interface, get the Qt +binaries in your Path for CMake to determine its configuration: + +.. code-block:: bash + + export PATH="/usr/local/opt/qt/bin:$PATH" -`Homebrew <https://brew.sh/>`_ can be used to conveniently install all packages -on macOS. Unfortunately, Qt4 is not (officially) supported on macOS Sierra (and -newer). Hence, it is not possible to build OpenStructure with GUI support there. Homebrew installs all the software under /usr/local. Thus we have to tell cmake where to find Boost and Python. Also the Python headers and libraries are not -located as they are on linux and hence they must be specified too: +located as they are on Linux and hence they must be specified too: .. code-block:: bash - - cmake . -DPYTHON_INCLUDE_PATH=/usr/local/opt/python/Frameworks/Python.framework/Headers \ - -DPYTHON_LIBRARIES=/usr/local/opt/python/Frameworks/Python.framework/Python \ - -DBOOST_ROOT=/usr/local -DPYTHON_ROOT=/usr/local \ - -DSYS_ROOT=/usr/local -DENABLE_INFO=OFF -DOPTIMIZE=ON + cmake . -DPYTHON_INCLUDE_PATH=/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/include/python2.7 \ + -DPYTHON_LIBRARIES=/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib \ + -DPYTHON_ROOT=/usr/local/ \ + -DBOOST_ROOT=/usr/local \ + -DSYS_ROOT=/usr/local \ + -DOPTIMIZE=ON Building the Project -------------------------------------------------------------------------------- @@ -346,7 +359,7 @@ to run multiple jobs at once. What's next? -------------------------------------------------------------------------------- -On Linux and MacOS X, you can start dng from the command-line. The binaries are all located in stage/bin: +On Linux and macOS, you can start dng from the command-line. The binaries are all located in stage/bin: .. code-block:: bash @@ -371,3 +384,8 @@ To get the newest changes from the central git repository, enter in your terminal. This will fetch the newest changes. + +.. LocalWords: Homebrew cmake CMake zlib SQLite FFTW libtiff libpng PyQt +.. LocalWords: SSL macOS Makefiles PDB qmake PNG libz libsqlite OPTIMIZE +.. LocalWords: DNDEBUG RPATH rpath SHADER shader SPNAV DConnexion profiler +.. LocalWords: DOPTIMIZE DENABLE DOPEN DPYTHON DBOOST DSYS Xcode diff --git a/modules/doc/intro.rst b/modules/doc/intro.rst index 457d995cfcc19341227e75a1eedfd9a7883377b9..25abc3c3dad1412718e0aed499abe9bf2305416a 100644 --- a/modules/doc/intro.rst +++ b/modules/doc/intro.rst @@ -30,7 +30,7 @@ The files we will be using in the tutorial are available in the examples directory that comes with OpenStructure. Depending on your platform, the examples are located at a different location: - * on *MacOS X* the files are located inside the application bundle (DNG.app). + * on *macOS* the files are located inside the application bundle (DNG.app). The file browser will automatically point to the examples. * on *Linux* the files are located at PREFIX/share/openstructure/examples, where PREFIX is the path to the directory containing OpenStructure. @@ -41,7 +41,7 @@ Starting DNG The graphical user interface of OpenStructure is called DNG (Dino/DeepView Next Generation). To start it, - * on *MacOS X* double click DNG.app + * on *macOS* double click DNG.app * on *Linux* fire up a terminal change into the OpenStructure installation directory and type 'bin/dng'. If you have the binary directory in the PATH, typing *dng* is sufficient. diff --git a/modules/doc/newmodule.rst b/modules/doc/newmodule.rst index 8c4864cb4e0145f4ce8916f1384e7a92bf13f391..f4d86014ea2db36132d1bca2fff7202cb55b1ddb 100644 --- a/modules/doc/newmodule.rst +++ b/modules/doc/newmodule.rst @@ -117,7 +117,7 @@ The line containing the `DEPENDS_ON` directive lists all the modules on which the new module depends (in this case :mod:`mol` and :mod:`ost.mol.alg`). The `module` macro will take care of staging the headers, in this case into `ost/mod` and compiling, linking and staging of a library with the name -`libost_mod.so` (`libost_gmod.dylib` on MacOS X). +`libost_mod.so` (`libost_gmod.dylib` on macOS). .. note:: diff --git a/modules/doc/sel.png b/modules/doc/sel.png index e5b3c80252ac121d9ec3a56f3730dbda8e91356d..ef7323d941764890f2f885862bafe18ac35793de 100644 Binary files a/modules/doc/sel.png and b/modules/doc/sel.png differ diff --git a/modules/gfx/pymod/export_gradient.cc b/modules/gfx/pymod/export_gradient.cc index 03eeb5401314968c1dba50967224846c11aa7ad7..fa09e623bdcb139da989f295174d8ce25c11ef56 100644 --- a/modules/gfx/pymod/export_gradient.cc +++ b/modules/gfx/pymod/export_gradient.cc @@ -33,7 +33,7 @@ using namespace ost::gfx; namespace { Gradient* make_gradient_d(const dict& d) { - std::auto_ptr<Gradient> grad(new Gradient); + std::unique_ptr<Gradient> grad(new Gradient); list keys = d.keys(); for(int i=0;i<len(keys);++i) { extract<float> fex(keys[i]); @@ -65,7 +65,7 @@ namespace { Gradient* make_gradient_l(const list& l) { - std::auto_ptr<Gradient> grad(new Gradient); + std::unique_ptr<Gradient> grad(new Gradient); float mf = len(l)<2 ? 0.0 : 1.0/static_cast<float>(len(l)-1); for(int i=0;i<len(l);++i) { float mark = static_cast<float>(i)*mf; diff --git a/modules/gfx/pymod/export_primlist.cc b/modules/gfx/pymod/export_primlist.cc index 8cdaf32303ae80ff65d787642d2e9a01b8d5bc0d..d11d7465625d24a9f849fb7b916b4c4f703bc508 100644 --- a/modules/gfx/pymod/export_primlist.cc +++ b/modules/gfx/pymod/export_primlist.cc @@ -26,6 +26,36 @@ using namespace boost::python; using namespace ost; using namespace ost::gfx; +/* The following #include triggers a deprecation warning upon compilation: + +In file included from /unibas/lcs-software/software/Python/2.7.11-goolf-1.7.20/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0, + from /unibas/lcs-software/software/Python/2.7.11-goolf-1.7.20/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, + from /unibas/lcs-software/software/Python/2.7.11-goolf-1.7.20/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4, + from /home/zohixe92/build/ost-develop/modules/gfx/pymod/export_primlist.cc:30: +/unibas/lcs-software/software/Python/2.7.11-goolf-1.7.20/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] + #warning "Using deprecated NumPy API, disable it by " \ + ^ + +It looks like just including <numpy/arrayobject.h>, without actually using anything from it, already triggers the +warning. This could be a side effect of other includes in export_primlist.cc though, such as boost. + +The Numpy C API documentation <https://docs.scipy.org/doc/numpy-1.15.1/reference/c-api.deprecations.html> is very +unclear about what is deprecated exactly (the whole API or only direct data access?) The Array API doc +<https://docs.scipy.org/doc/numpy-1.16.0/reference/c-api.array.html> doesn't clearly state what to import instead, +and while some functions are marked as deprecated I couldn't see that we are using any of them. Last, the migration sed +script <https://github.com/numpy/numpy/blob/master/tools/replace_old_macros.sed> didn't trigger any changes. + +The warnings appear to be safe though, behavior has been checked in <https://jira.biozentrum.unibas.ch/browse/SCHWED-3149> +and Numpy guarantees to maintain them until the next major release (2.0). So it is safe to ignore them for now. +They can be silenced with the following #define, however it was decided to keep them for now as functionality *will* +disappear in the future. + +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION + +In the future it might be desirable to move to the newer API in Boost::Python::NumPy +which uses modern C++ instead of old-style C macros. +<https://www.boost.org/doc/libs/1_64_0/libs/python/doc/html/numpy/reference/ndarray.html> +*/ #if OST_NUMPY_SUPPORT_ENABLED #include <numpy/arrayobject.h> #endif @@ -41,7 +71,7 @@ namespace { if(!PyArray_ISCONTIGUOUS(va)) { throw Error("expected vertex array to be contiguous"); } - if(!PyArray_TYPE(va)==NPY_FLOAT) { + if(PyArray_TYPE(va)!=NPY_FLOAT) { throw Error("expected vertex array to be of dtype=float32"); } size_t v_size=PyArray_SIZE(va); @@ -52,7 +82,7 @@ namespace { float* vp=reinterpret_cast<float*>(PyArray_DATA(va)); float* np=0; float* cp=0; - if(ona!=object()) { + if(!ona.is_none()) { if(!PyArray_Check(ona.ptr())) { throw Error("ona is not a numpy array"); } @@ -60,7 +90,7 @@ namespace { if(!PyArray_ISCONTIGUOUS(na)) { throw Error("expected normal array to be contiguous"); } - if(!PyArray_TYPE(na)==NPY_FLOAT) { + if(PyArray_TYPE(na)!=NPY_FLOAT) { throw Error("expected normal array to be of dtype=float32"); } if((size_t)PyArray_SIZE(na)!=v_size) { @@ -68,7 +98,7 @@ namespace { } np=reinterpret_cast<float*>(PyArray_DATA(na)); } - if(oca!=object()) { + if(!oca.is_none()) { if(!PyArray_Check(oca.ptr())) { throw Error("oca is not a numpy array"); } @@ -76,7 +106,7 @@ namespace { if(!PyArray_ISCONTIGUOUS(ca)) { throw Error("expected color array to be contiguous"); } - if(!PyArray_TYPE(ca)==NPY_FLOAT) { + if(PyArray_TYPE(ca)!=NPY_FLOAT) { throw Error("expected color array to be of dtype=float32"); } if((size_t)PyArray_SIZE(ca)!=v_count*4) { @@ -91,7 +121,7 @@ namespace { if(!PyArray_ISCONTIGUOUS(ia)) { throw Error("expected vertex array to be contiguous"); } - if(!PyArray_TYPE(ia)==NPY_UINT) { + if(PyArray_TYPE(ia)!=NPY_UINT) { throw Error("expected vertex array to be of dtype=uint32"); } size_t i_size=PyArray_SIZE(ia); diff --git a/modules/gfx/pymod/export_scene.cc b/modules/gfx/pymod/export_scene.cc index 0c4ff6b870f7f7097f944f5fccca51346856ac25..746c958f7c8ee041252b79687e2cfb0c4a029342 100644 --- a/modules/gfx/pymod/export_scene.cc +++ b/modules/gfx/pymod/export_scene.cc @@ -108,8 +108,6 @@ void export_Scene() void (Scene::*remove2)(const String&) = &Scene::Remove; void (Scene::*center_on1)(const String&) = &Scene::CenterOn; void (Scene::*center_on2)(const GfxObjP&) = &Scene::CenterOn; - bool (Scene::*start_offscreen_mode1)(unsigned int, unsigned int) = &Scene::StartOffscreenMode; - bool (Scene::*start_offscreen_mode2)(unsigned int, unsigned int, int) = &Scene::StartOffscreenMode; class_<Viewport>("Viewport", init<>()) .def_readwrite("x", &Viewport::x) .def_readwrite("y", &Viewport::y) @@ -249,9 +247,6 @@ void export_Scene() .add_property("ao_quality",&Scene::GetAmbientOcclusionQuality,&Scene::SetAmbientOcclusionQuality) .add_property("ao_size",&Scene::GetAmbientOcclusionSize,&Scene::SetAmbientOcclusionSize) .def("AttachObserver",&Scene::AttachObserver) - .def("StartOffscreenMode",start_offscreen_mode1) - .def("StartOffscreenMode",start_offscreen_mode2) - .def("StopOffscreenMode",&Scene::StopOffscreenMode) .def("SetShadingMode",&Scene::SetShadingMode) .def("SetBeacon",&Scene::SetBeacon) .add_property("root_node", &Scene::GetRootNode) @@ -279,4 +274,3 @@ void export_Scene() scope().attr("atexit").attr("register")(r); } - diff --git a/modules/gfx/src/CMakeLists.txt b/modules/gfx/src/CMakeLists.txt index bb60b35f1081586e5b3bbe65137b2e7a51dc181d..acd3f9eb4bf94f4fe29b2e4dccd863a0659f8ecc 100644 --- a/modules/gfx/src/CMakeLists.txt +++ b/modules/gfx/src/CMakeLists.txt @@ -27,7 +27,6 @@ texture.hh vertex_array.hh vertex_array_helper.hh scene_observer.hh -offscreen_buffer.hh gl_include.hh glext_include.hh render_mode.hh @@ -182,41 +181,19 @@ else() set(OST_GFX_MAP_SOURCES "") endif() -if (UNIX AND NOT APPLE) - if(USE_MESA) - list(APPEND OST_GFX_SOURCES impl/mesa_offscreen_buffer.cc) - list(APPEND OST_GFX_IMPL_HEADERS mesa_offscreen_buffer.hh) - else() - list(APPEND OST_GFX_SOURCES impl/glx_offscreen_buffer.cc) - list(APPEND OST_GFX_IMPL_HEADERS glx_offscreen_buffer.hh) - endif() -endif() - -if (APPLE) - list(APPEND OST_GFX_SOURCES impl/cgl_offscreen_buffer.cc) - list(APPEND OST_GFX_IMPL_HEADERS cgl_offscreen_buffer.hh) -endif() - -if(WIN32) - list(APPEND OST_GFX_SOURCES impl/wgl_offscreen_buffer.cc) - list(APPEND OST_GFX_IMPL_HEADERS wgl_offscreen_buffer.hh) -endif() - if (USE_SHADER) list(APPEND OST_GFX_SOURCES shader.cc) list(APPEND OST_GFX_HEADERS shader.hh) list(APPEND OST_GFX_SOURCES impl/scene_fx.cc) list(APPEND OST_GFX_IMPL_HEADERS scene_fx.hh) if (NOT APPLE) - if (NOT USE_MESA) - set(OST_GLEW_HEADERS - glew.h - glxew.h - wglew.h IN_DIR GL - ) - list(APPEND OST_GFX_SOURCES GL/glew.c) - include_directories("${STAGE_DIR}/include/ost/gfx") - endif() + set(OST_GLEW_HEADERS + glew.h + glxew.h + wglew.h IN_DIR GL + ) + list(APPEND OST_GFX_SOURCES GL/glew.c) + include_directories("${STAGE_DIR}/include/ost/gfx") endif() endif() @@ -236,9 +213,6 @@ module(NAME gfx SOURCES ${OST_GFX_SOURCES} ${OST_GFX_MAP_SOURCES} include_directories(${PNG_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) # link against OpenGL and PNG libraries -if(USE_MESA) - link_directories(${OPENGL_LIBRARY_DIR}) -endif() target_link_libraries(ost_gfx ${OPENGL_LIBRARIES} ${PNG_LIBRARIES}) if (USE_SHADER) diff --git a/modules/gfx/src/gfx_object.cc b/modules/gfx/src/gfx_object.cc index 90c82ca1cdfec297a7d6ee077e00076d7522668f..97e235f418f2e50dee56a33d55f285919d138175 100644 --- a/modules/gfx/src/gfx_object.cc +++ b/modules/gfx/src/gfx_object.cc @@ -151,13 +151,8 @@ void GfxObj::RenderGL(RenderPass pass) glMatrixMode(GL_MODELVIEW); glPushMatrix(); glMultMatrix(transform_.GetTransposedMatrix().Data()); - if(Scene::Instance().InOffscreenMode()) { - LOG_TRACE("applying material"); - mat_.RenderGL(); - } else { - LOG_TRACE("applying material display list"); - glCallList(mat_dlist_); - } + LOG_TRACE("applying material display list"); + glCallList(mat_dlist_); LOG_TRACE("calling custom render gl pass " << pass); /* @@ -679,10 +674,14 @@ void GfxObj::SmoothVertices(float smoothf) namespace { +/* +commented out to silence compiler warning, as it is not needed anywhere float normalize(float v, float min_v, float max_v) { return (v-min_v)/(max_v-min_v); } +*/ + } void GfxObj::render_labels() const diff --git a/modules/gfx/src/glext_include.hh b/modules/gfx/src/glext_include.hh index 557dcb36045c75542d1fa9df5d24edecfc47a1f5..874b70a31137e6839574c48f712e7ec4978bb7fb 100644 --- a/modules/gfx/src/glext_include.hh +++ b/modules/gfx/src/glext_include.hh @@ -29,12 +29,6 @@ #include <ost/config.hh> #if OST_SHADER_SUPPORT_ENABLED -#if OST_MESA_SUPPORT_ENABLED -# define OST_GL_VERSION_2_0 1 -# define GL_GLEXT_PROTOTYPES 1 -# include <GL/gl.h> -# include <GL/glext.h> -#else # if OST_MODULE==OST_GFX # define GLEW_BUILD # endif @@ -45,12 +39,11 @@ # include <ost/gfx/GL/wglew.h> # endif #endif -#endif #include <ost/gfx/gl_include.hh> #if defined(__APPLE__) -// On all MacOS X version we support, OpenGL 2.0 is available, so it's safe to +// On all macOS version we support, OpenGL 2.0 is available, so it's safe to // hardcode the value here... //same for windows vista and above, XP only has 1.1 #define OST_GL_VERSION_2_0 1 diff --git a/modules/gfx/src/glwin_base.hh b/modules/gfx/src/glwin_base.hh index 7486540d5a8e8807ec4cacfd63366fd50a1d0372..77d30ee76ea8cedb30a80d615b74e968439b65a8 100644 --- a/modules/gfx/src/glwin_base.hh +++ b/modules/gfx/src/glwin_base.hh @@ -26,6 +26,7 @@ */ #include <ost/gfx/module_config.hh> +#include <ost/message.hh> namespace ost { namespace gfx { @@ -42,6 +43,25 @@ public: virtual bool HasStereo() const = 0; virtual bool HasMultisample() const = 0; + + // The GLWin is supposed to setup the OpenGL resources. To avoid implementing + // our own offscreen buffers, image export from OpenGL also happens here + virtual void Export(const String& fname, unsigned int width, + unsigned int height, bool transparent) { + throw ost::Error("Image export not implemented for this GLWin"); + } + + virtual void Export(const String& fname, unsigned int width, + unsigned int height, int max_samples, + bool transparent) { + throw ost::Error("Image export with multi-sampling not implemented for " + "this GLWin"); + } + + virtual void Export(const String& fname, bool transparent) { + throw ost::Error("Image export not implemented for this GLWin"); + } + }; }} diff --git a/modules/gfx/src/glyph_texture.png b/modules/gfx/src/glyph_texture.png index 53bd642ded6bdb9c32d9640da7c8a807e8c3ace9..ee3b725091bf85c4ec60a8b99d121553c26a4c34 100644 Binary files a/modules/gfx/src/glyph_texture.png and b/modules/gfx/src/glyph_texture.png differ diff --git a/modules/gfx/src/impl/cartoon_renderer.cc b/modules/gfx/src/impl/cartoon_renderer.cc index 00894483df3e7c0e3433463810fb403a80a84a46..3dfedd48460b8ca116341a6b4b5d2aab8ab7696b 100644 --- a/modules/gfx/src/impl/cartoon_renderer.cc +++ b/modules/gfx/src/impl/cartoon_renderer.cc @@ -476,11 +476,14 @@ TraceProfile CartoonRenderer::transform_and_add_profile(const std::vector<TraceP namespace { + /* + commented out to silence compiler warning, as it is not needed anywhere float spread(const geom::Vec3& v1, geom::Vec3& v2, geom::Vec3& v3, geom::Vec3& v4) { return geom::Dot(geom::Normalize(geom::Cross(geom::Normalize(v3-v1),geom::Normalize(v2-v1))), geom::Normalize(geom::Cross(geom::Normalize(v3-v4),geom::Normalize(v2-v4)))); } + */ } diff --git a/modules/gfx/src/impl/map_iso_gen_s.cc b/modules/gfx/src/impl/map_iso_gen_s.cc index e1fe9818a8c4bfc554fc7669c90a875ba823f746..c16461c691c6888725c392978e8b2709a2a4781d 100644 --- a/modules/gfx/src/impl/map_iso_gen_s.cc +++ b/modules/gfx/src/impl/map_iso_gen_s.cc @@ -30,7 +30,6 @@ #if OST_SHADER_SUPPORT_ENABLED # define MAP_ISO_USE_SHADER 0 # include <ost/gfx/shader.hh> -# include <ost/gfx/offscreen_buffer.hh> # include <ost/gfx/scene.hh> #endif diff --git a/modules/gfx/src/offscreen_buffer.hh b/modules/gfx/src/offscreen_buffer.hh index 7b716c2f6610bf4e98d01450e3abd347a43d48ac..f623190621c66c2f3f151edff06a8c4ec5b7f539 100644 --- a/modules/gfx/src/offscreen_buffer.hh +++ b/modules/gfx/src/offscreen_buffer.hh @@ -19,6 +19,17 @@ #ifndef OST_GFX_OFFSCREEN_BUFFER_HH #define OST_GFX_OFFSCREEN_BUFFER_HH + + +/* + THE OFFSCREEN BUFFER IS DEPRECATED AND CURRENTLY NOT USED + Offscreen rendering for image export is now performed in a QT managed + offscreen buffer (e.g. gui/src/gl_canvas.hh). Reason for that is maintenance, + as there are platform dependent buffer implementations. +*/ + + + /* Wraps GL offscreen rendering per platform diff --git a/modules/gfx/src/render_options/render_options.cc b/modules/gfx/src/render_options/render_options.cc index 5d8e7a72c5a1c11c034d1c2ac4e4a83667d8070f..12690d8207402fe96557347b168a8b717e11eb68 100644 --- a/modules/gfx/src/render_options/render_options.cc +++ b/modules/gfx/src/render_options/render_options.cc @@ -41,11 +41,13 @@ bool RenderOptions::AddObserver(EntityP entity) bool RenderOptions::RemoveObserver(EntityP entity) { - for (EntityWObservers::iterator - i = observers_.begin(), e = observers_.end(); i != e; ++i) { - if (i->lock() == entity) + for (EntityWObservers::iterator i = observers_.begin(), e = observers_.end(); + i != e; ++i) { + if (i->lock() == entity) { observers_.erase(i); return true; + } + } return false; } diff --git a/modules/gfx/src/scene.cc b/modules/gfx/src/scene.cc index 98b47c9cbb16ed2477cb5fb0fd001bcaee8f0c57..1ce2a44ebfa553a035c5cb285fa9f97b5c493409 100644 --- a/modules/gfx/src/scene.cc +++ b/modules/gfx/src/scene.cc @@ -52,7 +52,6 @@ #include "entity.hh" #include "exporter.hh" #include "povray.hh" -#include "offscreen_buffer.hh" #if OST_SHADER_SUPPORT_ENABLED # include "shader.hh" @@ -117,9 +116,6 @@ Scene::Scene(): auto_autoslab_(true), do_autoslab_(true), autoslab_mode_(0), - offscreen_flag_(false), - main_offscreen_buffer_(0), - old_vp_(), def_shading_mode_("default"), selection_mode_(1), test_flag_(false), @@ -151,10 +147,20 @@ Scene::Scene(): transform_.SetTrans(Vec3(0,0,-100)); } +Scene::~Scene() +{ + // cleanup all observers / gfx_nodes when scene is destructed + observers_.clear(); + this->RemoveAll(); +} + void Scene::SetFog(bool f) { fog_flag_=f; if(!gl_init_) return; + + this->ActivateGLContext(); + if(f) { glEnable(GL_FOG); } else { @@ -173,6 +179,9 @@ void Scene::SetFogColor(const Color& c) GLfloat fogc[]={c.Red(),c.Green(),c.Blue(),1.0}; fog_color_=c; if(!gl_init_) return; + + this->ActivateGLContext(); + glFogfv(GL_FOG_COLOR,fogc); RequestRedraw(); } @@ -411,6 +420,8 @@ void Scene::InitGL(bool full) { LOG_VERBOSE("Scene: initializing GL state"); + this->ActivateGLContext(); + check_gl_error(); // clear error flag if(full) { @@ -577,7 +588,7 @@ void Scene::InitGL(bool full) void Scene::RequestRedraw() { - if (win_ && !offscreen_flag_) { + if (win_) { win_->DoRefresh(); } } @@ -587,18 +598,6 @@ void Scene::StatusMessage(const String& s) if(win_) win_->StatusMessage(s); } -void Scene::SetBackground(const Color& c) -{ - background_=c; - bg_mode_=0; - if(gl_init_) { - //glClearColor(c.Red(),c.Green(),c.Blue(),c.Alpha()); - glClearColor(c.Red(),c.Green(),c.Blue(),0.0); - SetFogColor(c); - RequestRedraw(); - } -} - namespace { void c2d(const Color& c, unsigned char* d) { d[0]=static_cast<unsigned char>(c.GetRed()*255.0); @@ -609,6 +608,7 @@ namespace { void Scene::set_bg() { + this->ActivateGLContext(); static std::vector<unsigned char> data; static const unsigned int grad_steps=64; if(bg_mode_==1) { @@ -638,6 +638,19 @@ void Scene::set_bg() } } +void Scene::SetBackground(const Color& c) +{ + + background_=c; + bg_mode_=0; + if(gl_init_) { + this->ActivateGLContext(); + glClearColor(c.Red(),c.Green(),c.Blue(),0.0); + SetFogColor(c); + RequestRedraw(); + } +} + void Scene::SetBackground(const Gradient& g) { bg_grad_=g; @@ -681,6 +694,7 @@ Viewport Scene::GetViewport() const { Viewport vp; if(gl_init_) { + this->ActivateGLContext(); glGetIntegerv(GL_VIEWPORT, reinterpret_cast<GLint*>(&vp)); } return vp; @@ -692,6 +706,7 @@ void Scene::SetViewport(int w, int h) vp_height_=std::max<unsigned int>(1,h); aspect_ratio_=static_cast<float>(w)/static_cast<float>(h); if(!gl_init_) return; + this->ActivateGLContext(); glViewport(0,0,w,h); ResetProjection(); #if OST_SHADER_SUPPORT_ENABLED @@ -736,6 +751,9 @@ void Scene::CenterOn(const GfxObjP& go) void Scene::RenderText(const TextPrim& t) { if(!gl_init_) return; + + this->ActivateGLContext(); + if(t.str.empty() || t.points<=0.0) return; Vec3 ppos = Project(t.position,false); @@ -806,35 +824,9 @@ float Scene::GetDefaultTextSize() return def_text_size_; } -namespace { - -void draw_lightdir(const Vec3& ldir, const geom::Transform& tf) -{ - glPushAttrib(GL_ENABLE_BIT); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - geom::Transform tmpt(tf); - tmpt.SetRot(Mat3::Identity()); - glMultMatrix(tmpt.GetTransposedMatrix().Data()); - glDisable(GL_NORMALIZE); - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - glColor3f(1.0,0.0,1.0); - glLineWidth(2.0); - glBegin(GL_LINES); - glVertex3v(tmpt.GetCenter().Data()); - glVertex3v((tmpt.GetCenter()-50.0*ldir).Data()); - glEnd(); - glPopMatrix(); - glPopAttrib(); -} - -} - void Scene::RenderGL() { + this->ActivateGLContext(); check_gl_error(); // clear error flag if(auto_autoslab_ || do_autoslab_) { do_autoslab(); @@ -1153,6 +1145,9 @@ void Scene::OnInput(const InputEvent& e) 0,1,0,0, 0,0,1,0, trans[0],trans[1],trans[2],1}; + + this->ActivateGLContext(); + double pm[16]; glGetDoublev(GL_PROJECTION_MATRIX,pm); GLint vp[4]; @@ -1293,6 +1288,7 @@ void Scene::DetachObserver(SceneObserver* o) { Vec3 Scene::Project(const Vec3& v, bool ignore_vp) const { if(!gl_init_) return Vec3(); + this->ActivateGLContext(); GLdouble gl_mmat[16]; glGetDoublev(GL_MODELVIEW_MATRIX,gl_mmat); GLdouble gl_pmat[16]; @@ -1314,6 +1310,7 @@ Vec3 Scene::Project(const Vec3& v, bool ignore_vp) const Vec3 Scene::UnProject(const Vec3& v, bool ignore_vp) const { if(!gl_init_) return Vec3(); + this->ActivateGLContext(); GLdouble gl_mmat[16]; glGetDoublev(GL_MODELVIEW_MATRIX,gl_mmat); GLdouble gl_pmat[16]; @@ -1580,6 +1577,7 @@ void Scene::SetLightDir(const Vec3& dir) if(Length2(dir)>0.0) { light_dir_=Normalize(dir); light_rot_=calc_light_rot(light_dir_); + this->ActivateGLContext(); set_light_dir(light_dir_); RequestRedraw(); } @@ -1592,6 +1590,7 @@ void Scene::SetLightProp(const Color& amb, const Color& diff, light_diff_=diff; light_spec_=spec; if(!gl_init_) return; + this->ActivateGLContext(); glLightfv(GL_LIGHT0, GL_AMBIENT, light_amb_); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diff_); glLightfv(GL_LIGHT0, GL_SPECULAR, light_spec_); @@ -1604,6 +1603,7 @@ void Scene::SetLightProp(float amb, float diff, float spec) light_diff_=Color(diff,diff,diff,1.0); light_spec_=Color(spec,spec,spec,1.0); if(!gl_init_) return; + this->ActivateGLContext(); glLightfv(GL_LIGHT0, GL_AMBIENT, light_amb_); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diff_); glLightfv(GL_LIGHT0, GL_SPECULAR, light_spec_); @@ -1625,180 +1625,38 @@ uint Scene::GetSelectionMode() const return selection_mode_; } -bool Scene::StartOffscreenMode(unsigned int width, unsigned int height) { - return StartOffscreenMode(width,height,2); -} - -bool Scene::StartOffscreenMode(unsigned int width, unsigned int height, int max_samples) -{ - LOG_DEBUG("Scene: starting offscreen rendering mode " << width << "x" << height); - if(main_offscreen_buffer_) return false; - OffscreenBufferFormat obf; - if(max_samples>0) { - obf.multisample=true; - obf.samples=max_samples; - } else { - obf.multisample=false; - } - main_offscreen_buffer_ = new OffscreenBuffer(width,height,obf,true); - - if(!main_offscreen_buffer_->IsValid()) { - LOG_ERROR("Scene: error during offscreen buffer creation"); - delete main_offscreen_buffer_; - main_offscreen_buffer_=0; - return false; - } - old_vp_[0]=vp_width_; - old_vp_[1]=vp_height_; - main_offscreen_buffer_->MakeActive(); - offscreen_flag_=true; - root_node_->ContextSwitch(); - -#if OST_SHADER_SUPPORT_ENABLED - String shader_name = !def_shading_mode_.empty() ? def_shading_mode_ : Shader::Instance().GetCurrentName(); -#endif - - LOG_DEBUG("Scene: initializing GL"); - if(gl_init_) { - this->InitGL(false); - } else { - this->InitGL(true); - } - LOG_DEBUG("Scene: setting viewport"); - Resize(width,height); - LOG_DEBUG("Scene: updating fog settings"); - update_fog(); - glDrawBuffer(GL_FRONT); -#if OST_SHADER_SUPPORT_ENABLED - LOG_DEBUG("Scene: activating shader " << shader_name); - Shader::Instance().Activate(shader_name); -#endif - return true; -} - -void Scene::StopOffscreenMode() +void Scene::Export(const String& fname, bool transparent) { - if(main_offscreen_buffer_) { - if (win_) { - win_->MakeActive(); - } - delete main_offscreen_buffer_; - main_offscreen_buffer_=0; - Scene::Instance().SetViewport(old_vp_[0],old_vp_[1]); - offscreen_flag_=false; - root_node_->ContextSwitch(); - glDrawBuffer(GL_BACK); - update_fog(); + if(!win_) { + LOG_ERROR("Scene: Image export requires registered GLWin"); } + + win_->Export(fname, transparent); } void Scene::Export(const String& fname, unsigned int width, unsigned int height, bool transparent) { - Export(fname,width,height,0,transparent); -} - -void Scene::Export(const String& fname, unsigned int width, - unsigned int height, int max_samples, bool transparent) -{ - int d_index=fname.rfind('.'); - if (d_index==-1) { - LOG_ERROR("Scene: no file extension specified"); - return; - } - String ext = fname.substr(d_index+1); - if(ext!="png") { - LOG_ERROR("Scene::Export: unknown file format (" << ext << ")"); - return; - } - - bool of_flag = (main_offscreen_buffer_==0); - - // only switch if offscreen mode is not active - if(of_flag) { - if(max_samples<0) { - int msamples=0; -#if OST_SHADER_SUPPORT_ENABLED - if(OST_GL_VERSION_2_0) { - glGetIntegerv(GL_SAMPLES, &msamples); - } -#endif - max_samples=msamples; - } - if(!StartOffscreenMode(width,height, max_samples)) { - return; - } - } - LOG_DEBUG("Scene: rendering into offscreen buffer"); - this->RenderGL(); - // make sure drawing operations are finished - glFlush(); - glFinish(); - - boost::shared_array<uchar> img_data(new uchar[width*height*4]); - - LOG_DEBUG("Scene: setting background transparency"); - if (transparent) { - glPixelTransferf(GL_ALPHA_BIAS, 0.0); - } else { - // shift alpha channel by one to make sure pixels are read out as opaque - glPixelTransferf(GL_ALPHA_BIAS, 1.0); + if(!win_) { + LOG_ERROR("Scene: Image export requires registered GLWin"); } - LOG_DEBUG("Scene: reading framebuffer pixels"); - glReadBuffer(GL_FRONT); - glReadPixels(0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,img_data.get()); - glReadBuffer(GL_BACK); - - LOG_DEBUG("Scene: calling bitmap export"); - ExportBitmap(fname,ext,width,height,img_data.get()); - - // only switch back if it was not on to begin with - if(of_flag) { - StopOffscreenMode(); - } + win_->Export(fname, width, height, transparent); } -void Scene::Export(const String& fname, bool transparent) +void Scene::Export(const String& fname, unsigned int width, + unsigned int height, int max_samples, bool transparent) { - if(!win_ && !main_offscreen_buffer_) { - LOG_ERROR("Scene: Export without dimensions either requires an interactive session \nor an active offscreen mode (scene.StartOffscreenMode(W,H))"); - return; - } - int d_index=fname.rfind('.'); - if (d_index==-1) { - LOG_ERROR("Scene: no file extension specified"); - return; - } - String ext = fname.substr(d_index+1); - if(ext!="png") { - LOG_ERROR("Scene: unknown file format (" << ext << ")"); - return; - } - GLint vp[4]; - glGetIntegerv(GL_VIEWPORT,vp); - - if(main_offscreen_buffer_) { - this->RenderGL(); - glFlush(); - glFinish(); + if(!win_) { + LOG_ERROR("Scene: Image export requires registered GLWin"); } - if (transparent) { - glPixelTransferf(GL_ALPHA_BIAS, 0.0); - } else { - // shift alpha channel by one to make sure pixels are read out as opaque - glPixelTransferf(GL_ALPHA_BIAS, 1.0); - } - boost::shared_array<uchar> img_data(new uchar[vp[2]*vp[3]*4]); - glReadPixels(0,0,vp[2],vp[3],GL_RGBA,GL_UNSIGNED_BYTE,img_data.get()); - glFinish(); - ExportBitmap(fname,ext,vp[2],vp[3],img_data.get()); - glPixelTransferf(GL_ALPHA_BIAS, 0.0); + win_->Export(fname, width, height, max_samples, transparent); } void Scene::ExportPov(const std::string& fname, const std::string& wdir) { + this->ActivateGLContext(); std::string wdir2=wdir; if(wdir2=="") wdir2="."; PovState pov(fname+".pov",fname+".inc",wdir2+"/"); @@ -1818,6 +1676,7 @@ void Scene::ExportPov(const std::string& fname, const std::string& wdir) void Scene::Export(Exporter* ex) const { + this->ActivateGLContext(); ex->SetupTransform(this); ex->SceneStart(this); root_node_->Export(ex); @@ -1834,6 +1693,7 @@ void Scene::SetBlur(uint n) { blur_count_=std::min(n,3u); if(!gl_init_) return; + this->ActivateGLContext(); glClearAccum(0.0,0.0,0.0,0.0); glClear(GL_ACCUM_BUFFER_BIT); RequestRedraw(); @@ -1843,6 +1703,7 @@ void Scene::BlurSnapshot() { if(!gl_init_) return; if(blur_count_==0) return; + this->ActivateGLContext(); glFinish(); glAccum(GL_MULT, 0.5); glAccum(GL_ACCUM, 0.5); @@ -1952,6 +1813,7 @@ void Scene::set_far(float f) void Scene::update_fog() { if(gl_init_) { + this->ActivateGLContext(); glFogf(GL_FOG_START,znear_+fnear_); glFogf(GL_FOG_END,zfar_+ffar_); } @@ -1978,11 +1840,6 @@ GfxNodeP Scene::GetRootNode() const return root_node_; } -bool Scene::InOffscreenMode() const -{ - return offscreen_flag_; -} - float Scene::ElapsedTime() const { #ifndef _MSC_VER @@ -2013,6 +1870,7 @@ void Scene::SetShowCenter(bool f) void Scene::prep_glyphs() { + this->ActivateGLContext(); glGenTextures(1,&glyph_tex_id_); String ost_root =GetSharedDataPath(); bf::path ost_root_dir(ost_root); @@ -2054,6 +1912,7 @@ void Scene::prep_glyphs() void Scene::prep_blur() { if(blur_count_==0) return; + this->ActivateGLContext(); glAccum(GL_RETURN, 0.5); glFlush(); } @@ -2149,6 +2008,9 @@ namespace { } }; + /* + commented out to silence compiler warning, as it is not needed anywhere + double unproj_x() { GLdouble gl_mmat[]={1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1}; GLdouble gl_pmat[16]; @@ -2161,12 +2023,14 @@ namespace { &res[0],&res[1],&res[2]); return res[0]; } + */ } // anon ns void Scene::render_bg() { if(!gl_init_) return; if(bg_mode_!=1 && bg_mode_!=2) return; + this->ActivateGLContext(); if(update_bg_) { set_bg(); check_gl_error("set_bg()"); @@ -2193,6 +2057,7 @@ void Scene::render_export_aspect() { unsigned int a_width=static_cast<int>(static_cast<float>(vp_height_)*export_aspect_); if(a_width<vp_width_) { + this->ActivateGLContext(); // need to draw horizontal boundaries unsigned int o1=(vp_width_-a_width)>>1; unsigned int o2=a_width+o1; @@ -2212,6 +2077,7 @@ void Scene::render_export_aspect() glEnd(); // vpr dtor does gl cleanup } else if(a_width>vp_width_) { + this->ActivateGLContext(); unsigned int a_height=static_cast<int>(static_cast<float>(vp_width_)/export_aspect_); // need to draw vertical boundaries unsigned int o1=(vp_height_-a_height)>>1; @@ -2238,6 +2104,8 @@ void Scene::render_export_aspect() void Scene::render_scene() { + this->ActivateGLContext(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); @@ -2295,6 +2163,7 @@ void Scene::render_scene() void Scene::render_glow() { + this->ActivateGLContext(); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_COLOR_MATERIAL); glShadeModel(GL_FLAT); @@ -2354,6 +2223,7 @@ namespace { void Scene::stereo_projection(int view) { if(!gl_init_) return; + this->ActivateGLContext(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -2413,6 +2283,7 @@ void Scene::stereo_projection(int view) void Scene::render_stereo() { + this->ActivateGLContext(); glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(GL_ALL_ATTRIB_BITS); @@ -2649,4 +2520,22 @@ void Scene::SetShowExportAspect(bool f) } } +void Scene::ActivateGLContext() const{ + + if(!gl_init_) { + return; + } + + win_->MakeActive(); +} + +void Scene::SetAlphaBias(Real bias) { + this->ActivateGLContext(); + glPixelTransferf(GL_ALPHA_BIAS, bias); +} + +void Scene::ContextSwitch() { + root_node_->ContextSwitch(); +} + }} // ns diff --git a/modules/gfx/src/scene.hh b/modules/gfx/src/scene.hh index 53a935c10f8ff5d21e959f231646d27e8b26c242..c10bec64dd15d022017c1324c6c9bd3d76f59c12 100644 --- a/modules/gfx/src/scene.hh +++ b/modules/gfx/src/scene.hh @@ -49,7 +49,6 @@ namespace ost { namespace gfx { class InputEvent; -class OffscreenBuffer; typedef std::vector<SceneObserver*> SceneObserverList; @@ -290,11 +289,7 @@ class DLLEXPORT_OST_GFX Scene { void SetSelectionMode(uint m); uint GetSelectionMode() const; - /// \name Export - //@} - /// \brief export scene into a bitmap, rendering into offscreen of given size - /// if a main offscreen buffer is active (\sa StartOffscreenMode), then the - /// dimensions here are ignored + void Export(const String& fname, unsigned int w, unsigned int h, bool transparent=false); /// \brief export into bitmap, using multisample anti-aliasing @@ -459,8 +454,6 @@ class DLLEXPORT_OST_GFX Scene { void AttachObserver(SceneObserver* o); /// \brief observer interface (internal use) void DetachObserver(SceneObserver* o); - - bool InOffscreenMode() const; /// \brief switch into test mode (internal use) void SetTestMode(bool t); @@ -469,31 +462,6 @@ class DLLEXPORT_OST_GFX Scene { Viewport GetViewport() const; - /*! - This method has two different tasks. - - During interactive rendering, it facilitates export - into an offscreen buffer with Scene::Export(file,width,height) - by avoiding repeated initializations of the GL state, e.g. - during animation rendering. - - During batch mode, this is the only way to get meaningful - functionality with the gfx module - - Returns true upon success and false upon failure - - You can ask for multisampling to be enabled by giving the - max_samples a value larger than zero; in this case, the framebuffer - with at most this many samplebuffers will be used. The recommended - value here is 4; going to 8 or 16 may give you higher export times - with usually no marked increase in quality. - - */ - bool StartOffscreenMode(unsigned int w, unsigned int h, int max_samples); - bool StartOffscreenMode(unsigned int w, unsigned int h); - - /// \brief stops offline rendering in interactive mode - void StopOffscreenMode(); /// \brief show center of rotation of true void SetShowCenter(bool f); @@ -525,6 +493,11 @@ class DLLEXPORT_OST_GFX Scene { bool GetShowExportAspect() const {return show_export_aspect_;} bool HasMultisample() const {return ms_flag_;} + + void SetAlphaBias(Real bias); + + void ContextSwitch(); + protected: friend class GfxObj; friend class GfxNode; @@ -538,7 +511,6 @@ protected: void NodeAdded(const GfxNodeP& node); void RenderModeChanged(const String& name); - private: template <typename ACTION> @@ -548,6 +520,13 @@ private: Scene(); Scene(const Scene&) {} Scene& operator=(const Scene&) {return *this;} + ~Scene(); + + // The GL Context gets typically handled externally, e.g. using QT when + // calling InitGL(), RenderGL() etc. However, there is no guarantee that the + // desired GLContext is active when calling gl related functions in other + // occasions. This can be enforced by ActivateGLContext() + void ActivateGLContext() const; GLWinBase* win_; // target gl window @@ -586,9 +565,6 @@ private: bool do_autoslab_; // run autoslab on next scene update int autoslab_mode_; // 0: fast, 1:precise, 2: max - bool offscreen_flag_; // a simple indicator whether in offscreen mode or not - OffscreenBuffer* main_offscreen_buffer_; // not null if a main offscreen buffer is present - uint old_vp_[2]; // used by the offline rendering code std::string def_shading_mode_; uint selection_mode_; diff --git a/modules/gfx/src/shader.cc b/modules/gfx/src/shader.cc index f514aeebf3e0a401da2bfde639a5ecc6f66fcfaa..03f88696bb5abeccd334cef35608b88fcca1eac5 100644 --- a/modules/gfx/src/shader.cc +++ b/modules/gfx/src/shader.cc @@ -59,15 +59,11 @@ Shader::Shader(): void Shader::PreGLInit() { #if !defined(__APPLE__) -#if OST_MESA_SUPPORT_ENABLED - // skip glew initialization -#else - GLenum err = glewInit(); - if (GLEW_OK != err) { - LOG_ERROR("glew failure: " << glewGetErrorString(err)); - assert(false); - } -#endif +GLenum err = glewInit(); +if (GLEW_OK != err) { + LOG_ERROR("glew failure: " << glewGetErrorString(err)); + assert(false); +} #endif } diff --git a/modules/gfx/src/vertex_array.cc b/modules/gfx/src/vertex_array.cc index 847e38d14a0bcc1163ffcb383f9d7ce179a65353..89dbaa728405ab3b0adf50fb3a21a60ba7d195e3 100644 --- a/modules/gfx/src/vertex_array.cc +++ b/modules/gfx/src/vertex_array.cc @@ -316,9 +316,7 @@ void IndexedVertexArray::RenderGL() if(!initialized_) { LOG_DEBUG("initializing vertex array lists"); #if OST_SHADER_SUPPORT_ENABLED - if(!Scene::Instance().InOffscreenMode()) { - glGenBuffers(7,buffer_id_); - } + glGenBuffers(7,buffer_id_); #endif outline_mat_dlist_=glGenLists(1); initialized_=true; @@ -1025,7 +1023,6 @@ void IndexedVertexArray::copy(const IndexedVertexArray& va) bool IndexedVertexArray::prep_buff() { - if(Scene::Instance().InOffscreenMode()) return false; #if OST_SHADER_SUPPORT_ENABLED glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); @@ -1106,7 +1103,7 @@ void IndexedVertexArray::draw_ltq(bool use_buff) glStencilOp(GL_KEEP,GL_INVERT,GL_INVERT); } - if(use_buff && !Scene::Instance().InOffscreenMode()) { + if(use_buff) { #if OST_SHADER_SUPPORT_ENABLED #if 0 /* @@ -1198,7 +1195,7 @@ void IndexedVertexArray::draw_ltq(bool use_buff) void IndexedVertexArray::draw_p(bool use_buff) { - if(use_buff && !Scene::Instance().InOffscreenMode()) { + if(use_buff) { #if OST_SHADER_SUPPORT_ENABLED glBindBuffer(GL_ARRAY_BUFFER, buffer_id_[VA_VERTEX_BUFFER]); glVertexPointer(3, GL_FLOAT, sizeof(Entry), reinterpret_cast<void*>(sizeof(float)*9)); @@ -1418,7 +1415,6 @@ void IndexedVertexArray::set_clip_offset(float o) #if OST_SHADER_SUPPORT_ENABLED float n=Scene::Instance().GetNear(); float f=Scene::Instance().GetFar(); - float z=n+o; float t=(f*(-n+o)+n*(n+o))/((f-n)*(n+o)); t=(t+1.0)*0.5; glUniform1f(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"clip_offset"),t); diff --git a/modules/gfx/tests/test_gfx.py b/modules/gfx/tests/test_gfx.py index ffca3b507ebbc6dfc8fe3d50c1701af75d0f0574..fcd0f8510660904a4f07459fa4f28c6391b8489d 100644 --- a/modules/gfx/tests/test_gfx.py +++ b/modules/gfx/tests/test_gfx.py @@ -129,6 +129,28 @@ class TestGfx(unittest.TestCase): None, None, numpy.zeros((4,3),dtype=numpy.uint32)) + + # Passing wrong data type should fail + with self.assertRaises(Exception): + pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.uint32), + numpy.zeros((5, 3), dtype=numpy.float32), + numpy.zeros((5, 4), dtype=numpy.float32), + numpy.zeros((2, 3), dtype=numpy.uint32)) + with self.assertRaises(Exception): + pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.float32), + numpy.zeros((5, 3), dtype=numpy.uint32), + numpy.zeros((5, 4), dtype=numpy.float32), + numpy.zeros((2, 3), dtype=numpy.uint32)) + with self.assertRaises(Exception): + pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.float32), + numpy.zeros((5, 3), dtype=numpy.float32), + numpy.zeros((5, 4), dtype=numpy.uint32), + numpy.zeros((2, 3), dtype=numpy.uint32)) + with self.assertRaises(Exception): + pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.float32), + numpy.zeros((5, 3), dtype=numpy.float32), + numpy.zeros((5, 4), dtype=numpy.float32), + numpy.zeros((2, 3), dtype=numpy.float32)) if __name__== '__main__': diff --git a/modules/gui/doc/layout.rst b/modules/gui/doc/layout.rst index 9a45cbd1908a5801b0279bbccb3d8fb3787c60b5..5906dd96480480eb231af83ddf2ecdf146bba269 100644 --- a/modules/gui/doc/layout.rst +++ b/modules/gui/doc/layout.rst @@ -47,13 +47,13 @@ Perspective :param name: The name of the menu :type arg2: :class:`str` - :rtype: :class:`QtCore.QMenu` + :rtype: :class:`QMenu` .. method:: GetMenuBar() Returns the Menubar of the Application. Can be used to add some menupoints. - :rtype: :class:`QtCore.QMenuBar` + :rtype: :class:`QMenuBar` .. method:: GetPanels() @@ -86,9 +86,10 @@ how to add a widget to the MDI area: .. code-block:: python + from PyQt5 import QtWidgets app = gui.GostyApp.Instance() main_area = app.perspective.main_area - label = QtGui.QLabel("Hello World") + label = QtWidgets.QLabel("Hello World") main_area.AddWidget("The beginning..", label) .. class:: MainArea @@ -106,7 +107,7 @@ how to add a widget to the MDI area: :param name: is the unique name (within the scope of the main area) for the widget that is used to restore and save the widget geometry. :type name: :class:`str` :param widget: is the widget to be added to the main area. - :type widget: :class:`QtCore.QWidget` + :type widget: :class:`QWidget` :param window_state: custom window_state for the widget. See Qt Documentation to learn more about WindowStates. :type name: :class:`QWindowState` @@ -121,7 +122,7 @@ how to add a widget to the MDI area: :param name: is the unique name (within the scope of the main area) for the widget that is used to restore and save the widget geometry. :type name: :class:`str` :param widget: is the widget to be added to the main area - :type widget: :class:`QtCore.QWidget` + :type widget: :class:`QWidget` :param width: width of the widget inside the mdi :type width: :class:`int` :param height: height of the widget inside the mdi @@ -138,7 +139,7 @@ how to add a widget to the MDI area: :param title: string that is displayed in the gui. :type title: :class:`str` :param widget: is the widget to be added to the main area. - :type widget: :class:`QtCore.QWidget` + :type widget: :class:`QWidget` .. method:: ShowSubWindow(widget) @@ -149,7 +150,7 @@ how to add a widget to the MDI area: behavior! :param widget: widget which you want to make visible - :type widget: :class:`QtCore.QWidget` + :type widget: :class:`QWidget` .. method:: HideSubWindow(widget) @@ -161,7 +162,7 @@ how to add a widget to the MDI area: behavior! :param widget: widget which you want to hide - :type widget: :class:`QtCore.QWidget` + :type widget: :class:`QWidget` .. method:: EnableTabbedMode(tabbed_mode) @@ -207,12 +208,12 @@ and finally display it in the right side bar: .. code-block:: python - qwidget = QtGui.QLabel("Test") - widget = gui.WrappedWidget(qwidget) + from PyQt5 import QtWidgets + qwidget = QtWidgets.QLabel("Test") + widget = gui.Widget(qwidget) panels = gui.GostyApp.Instance().perspective.GetPanels() panels.AddWidgetToPool("Test Label",widget) panels.AddWidget(gui.PanelPosition.RIGHT_PANEL, widget) - qwidget.show() .. class:: PanelManager @@ -263,7 +264,7 @@ and finally display it in the right side bar: :param name: Name which is displayed in the gui. :type name: :class:`str` :param widget: Widget which will be added to the WidgetPool of this class and the WidgetRegistry. - :type widget: :class:`WrappedWidget` + :type widget: :class:`Widget` .. method:: GetMenu() @@ -276,7 +277,7 @@ and finally display it in the right side bar: Get the SIP-QObject (QObject), learn more about :doc:`python_cpp`. - :rtype: PyQt4.QObject + :rtype: :class:`QObject` .. method:: RemoveWidget(widget) @@ -284,7 +285,7 @@ and finally display it in the right side bar: The widget will be removed if it is in a PanelBar :param arg2: widget which should be removed - :type arg2: :class:`WrappedWidget` + :type arg2: :class:`Widget` .. data:: PanelPosition @@ -307,8 +308,9 @@ describes how this is done within Python and PyQt: .. code-block:: python + from PyQt5 import QtWidgets menu_bar = gui.GostyApp.Instance().perspective.GetMenuBar() - test_action = QtGui.QAction('Test Menu Point', menu_bar) + test_action = QtWidgets.QAction('Test Menu Point', menu_bar) test = menu_bar.addMenu('&Test') test.addAction(test_action) diff --git a/modules/gui/doc/python_cpp.rst b/modules/gui/doc/python_cpp.rst index e6dab30196592a6e2ade46968b21134d54da7b71..0f4be50a63797040a7965daa68b143f9b9b8204c 100644 --- a/modules/gui/doc/python_cpp.rst +++ b/modules/gui/doc/python_cpp.rst @@ -2,7 +2,7 @@ Mixing PyQt and C++ Widgets ================================================================================ .. currentmodule:: ost.gui -PyQt4 is a set of Python bindings for Qt4. The exposure from C++ to Python is +PyQt5 is a set of Python bindings for Qt5. The exposure from C++ to Python is done with SIP, which has a different mechanism than boost::python. To access a exported boost::python Qt-Object from Python we provide a method @@ -19,7 +19,8 @@ input for Qt Objects. It handles the cast to a C++ Qt Object internally. .. code-block:: python + from PyQt5 import QtWidgets persp = gui.GostyApp.Instance().perspective test = persp.GetMenu("Test") #Get boost::python qobject - test_action = QtGui.QAction('&Test me', test) #Create Python SIP Object + test_action = QtWidgets.QAction('&Test me', test) #Create Python SIP Object test.addAction(test_action) #Add Action to boost::python object diff --git a/modules/gui/doc/scene_win.rst b/modules/gui/doc/scene_win.rst index 8d3f5f69833973b614ca27cf32def17baf87daac..e10c81e6572db08b40b3c0364e81ca740d801719 100644 --- a/modules/gui/doc/scene_win.rst +++ b/modules/gui/doc/scene_win.rst @@ -24,7 +24,7 @@ selected objects. Get the SIP-QObject (QWidget), learn more about :doc:`python_cpp`. - :rtype: PyQt4.QWidget + :rtype: QWidget .. method:: Hide() @@ -53,8 +53,9 @@ be shown. .. code-block:: python + from PyQt5 import QtWidgets cm = gui.GostyApp.Instance().scene_win.GetContextMenu() - action = QtGui.QAction("Test single entity", cm.qobject) + action = QtWidgets.QAction("Test single entity", cm.qobject) cm.AddAction(action, gui.ContextActionType.ENTITY | gui.ContextActionType.SINGLE) .. class:: ContextMenu @@ -67,7 +68,7 @@ be shown. :param action: The Action which should be displayed in the context menu - :type action: :class:`QtCore.QAction` + :type action: :class:`QAction` :param flags: Flags that indicates, when the context_menu should be active. The action will be shown, when all flags are true. @@ -79,7 +80,7 @@ be shown. Get the SIP-QObject (QObject), learn more about :doc:`python_cpp`. - :rtype: PyQt4.QObject + :rtype: QObject .. data:: ContextActionType diff --git a/modules/gui/doc/sequence_viewer.rst b/modules/gui/doc/sequence_viewer.rst index 8b654a1c7cdd1fe3eb03445f83f63467a8c3b3a4..cdc2fbbd76723de43e3fae5cc7e4d19c98563424 100644 --- a/modules/gui/doc/sequence_viewer.rst +++ b/modules/gui/doc/sequence_viewer.rst @@ -180,7 +180,7 @@ can use the :meth:`AddEntity` method. If you want to load an alignment, the :met Get the SIP-QObject (QWidget), learn more about :doc:`python_cpp`. - :rtype: PyQt4.QWidget + :rtype: QWidget .. method:: Hide() diff --git a/modules/gui/doc/tools.rst b/modules/gui/doc/tools.rst index 8b4d6eaee4c1e9316f113b0da1118e6eeddd4054..87c6097213c483827604ce69a20ea48c316ac0de 100644 --- a/modules/gui/doc/tools.rst +++ b/modules/gui/doc/tools.rst @@ -25,7 +25,7 @@ The example `Write a Tool in Python` demonstrates how to add a simple tool input_events Input Events - Tools receive input events when the Control key (Command on MacOS X) is + Tools receive input events when the Control key (Command on macOS) is pressed. This includes both keyboard events and mouse events such as mouse move events, clicks and Real clicks. diff --git a/modules/gui/pymod/CMakeLists.txt b/modules/gui/pymod/CMakeLists.txt index 2d0690f015eefcb85a5b7ac1a4bfba0dba1b023d..0f3b63b94fdec661fa1cb122c8754cb94a6b18ef 100644 --- a/modules/gui/pymod/CMakeLists.txt +++ b/modules/gui/pymod/CMakeLists.txt @@ -17,6 +17,7 @@ set(OST_GUI_PYMOD_SOURCES export_file_loader.cc export_file_viewer.cc export_widget.cc + export_gl_canvas.cc ) set(OST_GUI_SCENE_PYMOD_MODULES __init__.py @@ -117,6 +118,5 @@ install(FILES ${INSPECTOR_ICONS} DESTINATION "share/openstructure/scene/icons") set(QT_USE_QTOPENGL 1) set(QT_USE_QTNETWORK 1) -include(${QT_USE_FILE}) target_link_libraries(_ost_gui ${QT_LIBRARIES}) diff --git a/modules/gui/pymod/__init__.py b/modules/gui/pymod/__init__.py index 227a0db3b969c4cf6f2b8ee91085874cb0b8d9ca..da6b1599a0b8378ba6153054c1ce72d0ca5f1581 100644 --- a/modules/gui/pymod/__init__.py +++ b/modules/gui/pymod/__init__.py @@ -42,8 +42,9 @@ def ClearMessageWidget(): gosty.message_widget.Clear() -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +from PyQt5.QtCore import * from ost import gfx def PickColor(default=gfx.WHITE): @@ -110,7 +111,7 @@ def AddMenuAction(*args, **kwargs): AddMenuAction('Scene', 'Background Color', SetBackgroundColor, shortcut='Ctrl+B') - Whenever you press Ctrl+B (Cmd+B on MacOS X), the action will be executed. + Whenever you press Ctrl+B (Cmd+B on macOS), the action will be executed. Very often menu actions are coupled to the current selected objects in the scene menu. These menu actions are either enabled or disabled depending on the @@ -135,8 +136,7 @@ def AddMenuAction(*args, **kwargs): self.predicate=predicate self.action=action app=GostyApp.Instance() - QObject.connect(app.scene_win.qobject, SIGNAL('ActiveNodesChanged()'), - self.TestEnable) + app.scene_win.qobject.ActiveNodesChanged.connect(self.TestEnable) self.TestEnable() def TestEnable(self): @@ -168,7 +168,7 @@ def AddMenuAction(*args, **kwargs): enabler=MenuActionEnabler(kwargs['enabled'], action) else: action.setEnabled(kwargs['enabled']) - QObject.connect(action, SIGNAL('triggered()'), function) + action.triggered.connect(function) return action diff --git a/modules/gui/pymod/dng/init.py b/modules/gui/pymod/dng/init.py index 4be7ed291f886c072dc9198d2ddbaf11dac9f438..070cace7b8fbca2f9a157c1236490ebbcb605704 100644 --- a/modules/gui/pymod/dng/init.py +++ b/modules/gui/pymod/dng/init.py @@ -15,7 +15,7 @@ except ImportError: import httplib -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtWidgets, QtCore from ost.gui.scene.init_inspector import _InitInspector from ost.gui.init_menubar import _InitMenuBar from ost.gui.init_spacenav import _InitSpaceNav @@ -26,9 +26,9 @@ from ost.gui.dng import superpositiondialog from ost.gui.scene.remote import RemoteLoader import ost.gui.dng.menu -from PyQt4.QtGui import * + def _my_exit(code): - QtGui.QApplication.instance().quit() + QtWidgets.QApplication.instance().quit() gui.GostyApp.Instance().ProcessEvents() sys._exit(code) @@ -49,7 +49,7 @@ _InitRuleBasedProcessor() def _CheckRestore(): settings = QtCore.QSettings() - restore = settings.value("restore_settings",QtCore.QVariant(False)).toBool() + restore = settings.value("restore_settings",QtCore.QVariant(False)) if not restore: settings.clear() settings.setValue("restore_settings",QtCore.QVariant(True)) @@ -96,11 +96,6 @@ def _InitFrontEnd(try_stereo): _InitSplash() def _load_files(): - for pdb_id in options.pdb_ids: - pdb_id, sel=_SplitIDSel(pdb_id) - selection=_get_selection_query(sel) - gui.FileLoader.LoadFrom(pdb_id,"pdb.org",selection) - input_files=[_SplitIDSel(arg) for arg in loading_list] for f in input_files: selection=_get_selection_query(f[1]) @@ -127,7 +122,7 @@ def _execute_script(): def show_help(option, opt, value, parser): parser.print_help() - QtGui.QApplication.instance().exit() + QtWidgets.QApplication.instance().exit() sys.exit(-1) def parse_script_option(option, opt, value, parser): @@ -156,7 +151,7 @@ class OstOptionParser(optparse.OptionParser): optparse.OptionParser.__init__(self, **kwargs) def exit(self, status_code, error_message): print error_message, - QtGui.QApplication.instance().exit() + QtWidgets.QApplication.instance().exit() sys.exit(-1) parser=OstOptionParser(usage=usage,conflict_handler="resolve") @@ -164,10 +159,9 @@ parser.add_option("-h", "--help", action="callback", callback=show_help, help="s parser.add_option("-v", "--verbosity_level", action="store", type="int", dest="vlevel", default=2, help="sets the verbosity level [default: %default]") parser.add_option("-s", "--script", action="callback", default=[], dest="script", type="string", callback=parse_script_option, help="executes a script (syntax: -s SCRIPT [options] [args]) Anything that follows this option is passed to the script") -parser.add_option("-p", "--pdb_id", dest="pdb_ids", default=[],action="append", help="PDB file ID. The file will be retrieved from PDB") -parser.add_option("-b", "--processor", dest="processor", default="HEURISTIC", help="Type of processor used by the progam (either RULE_BASED or HEURISTIC) [default: %default]") +parser.add_option("-p", "--processor", dest="processor", default="HEURISTIC", help="Type of processor used by the progam (either RULE_BASED or HEURISTIC) [default: %default]") parser.add_option("-c", "--compound_library", dest="complib", default="compounds.chemlib", help="Compound library for the RULE_BASED processor (only used if --processor option is set to RULE_BASED, otherwise ignored [default: %default]") -parser.add_option("-q", "--query", dest="query", default="", help="Selection query to be highlighted automatically upon loading (only used together with -p option or when a PDB file is loaded, otherwise ignored [default: None]") +parser.add_option("-q", "--query", dest="query", default="", help="Selection query to be highlighted automatically upon loading (only used when a PDB file is loaded, otherwise ignored [default: None]") parser.add_option("-S","--stereo", dest="try_stereo", default=False, action="store_true",help="try to get a quad-buffer stereo visual") parser.disable_interspersed_args() (options, args) = parser.parse_args() @@ -178,7 +172,7 @@ if len(parser.rargs)!=0: loading_list.append(rargs_string) else: print 'Error: one of the files to load is a Python script, use -s flag to execute it\n' - QtGui.QApplication.instance().exit() + QtWidgets.QApplication.instance().exit() sys.exit(-1) if len(options.script)!=0: @@ -215,7 +209,7 @@ if working_dir != None and os.path.isdir(working_dir): _InitFrontEnd(options.try_stereo) -if len(loading_list)!=0 or len(options.pdb_ids)!=0: +if len(loading_list)!=0: _load_files() gfx.Scene().Autoslab() if len(script_argv)!=0: diff --git a/modules/gui/pymod/dng/menu.py b/modules/gui/pymod/dng/menu.py index 875d43cf2a4fd213839a3f292f91f30a39d43670..425cf6ca75ff6666938fa2cc1d45e4b754f5275e 100644 --- a/modules/gui/pymod/dng/menu.py +++ b/modules/gui/pymod/dng/menu.py @@ -1,5 +1,6 @@ -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * from ost import * from ost import gui from ost.gui.init_splash import _InitSplash @@ -16,7 +17,7 @@ class FileMenu(QMenu): shortcut='Ctrl+Shift+S', enabled=gui.OneOf(gfx.Entity)) def _Open(self): - filename=QFileDialog.getOpenFileName(None, 'Open file','') + filename,_=QFileDialog.getOpenFileName(None, 'Open file','') if(QFileInfo(filename).isFile()): gui.FileLoader.LoadObject(str(filename)) @@ -60,11 +61,11 @@ class ClipWidget(QWidget): l.addWidget(self.near_, 0, 2) l.addWidget(self.far_, 1, 2) l.addWidget(self.auto_, 2, 0, 1, 4) - self.connect(self.near_, SIGNAL('valueChanged(int)'), self.SetNear) - self.connect(self.far_, SIGNAL('valueChanged(int)'), self.SetFar) - self.connect(self.auto_, SIGNAL('stateChanged(int)'), self.SetAuto) - self.connect(bounds_near, SIGNAL('textEdited(QString)'), self.SetNearBounds) - self.connect(bounds_far, SIGNAL('textEdited(QString)'), self.SetFarBounds) + self.near_.valueChanged.connect(self.SetNear) + self.far_.valueChanged.connect(self.SetFar) + self.auto_.stateChanged.connect(self.SetAuto) + bounds_near.textEdited.connect(self.SetNearBounds) + bounds_far.textEdited.connect(self.SetFarBounds) def SetNear(self, val): gfx.Scene().near = val @@ -104,13 +105,13 @@ class ExportSceneDialog(QDialog): l.addWidget(self.opaque_, 2, 1) hbox=QHBoxLayout() cancel=QPushButton("Cancel") - QObject.connect(cancel, SIGNAL('clicked()'), self.reject) + cancel.clicked.connect(self.reject) hbox.addWidget(cancel) export=QPushButton("Export") hbox.addWidget(export) export.setDefault(True) l.addLayout(hbox, 3, 1, 2, 1) - QObject.connect(export, SIGNAL('clicked()'), self.accept) + export.clicked.connect(self.accept) @property def transparent(self): return not self.opaque_.isChecked() @@ -127,7 +128,7 @@ class SceneMenu(QMenu): def __init__(self, parent=None): QMenu.__init__(self, parent) self.setTitle('Scene') - QObject.connect(self, SIGNAL('aboutToShow()'), self._AboutToShow) + self.aboutToShow.connect(self._AboutToShow) gui.AddMenuAction(self, 'Background Color', self._SetSceneBackground) self.fog_action=gui.AddMenuAction(self, 'Depth Cueing', self._ToggleFog, shortcut='Ctrl+Shift+F', checkable=True, @@ -145,8 +146,11 @@ class SceneMenu(QMenu): qd=ExportSceneDialog() if not qd.exec_(): return - filename=QFileDialog.getSaveFileName(None, 'Save Snapshot', - 'snapshot.png') + + options = QFileDialog.Options() + options |= QFileDialog.DontUseNativeDialog + filename, _ = QFileDialog.getSaveFileName(self,"Save Snapshot","snapshot.png", "", options=options) + if filename: gfx.Scene().Export(str(filename), qd.width, qd.height, qd.transparent) @@ -214,7 +218,7 @@ class WindowMenu(QMenu): QMenu.__init__(self, parent) self.setTitle('Window') gosty=gui.GostyApp.Instance() - QObject.connect(self, SIGNAL('aboutToShow()'), self._AboutToShow) + self.aboutToShow.connect(self._AboutToShow) inspector_visible=gosty.GetWidget('InspectorDialog').isVisible() self._gl_win_action=gui.AddMenuAction(self, 'GL Window', self._ToggleShowGLWindow, checkable=True, diff --git a/modules/gui/pymod/dng/superpositiondialog.py b/modules/gui/pymod/dng/superpositiondialog.py index 7eb3918038f74ab47302c27011770e5c04b69e5d..a6851c372899b6e4c73f91f08fac1e8fd13e2cc2 100644 --- a/modules/gui/pymod/dng/superpositiondialog.py +++ b/modules/gui/pymod/dng/superpositiondialog.py @@ -19,16 +19,15 @@ # # Authors: Stefan Bienert # -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5 import QtCore, QtGui, QtWidgets from ost.mol.alg import Superpose from ost import mol -class ChainComboBox(QComboBox): +class ChainComboBox(QtWidgets.QComboBox): def __init__(self, ent, gfx, parent=None): # class variables self.all_chains = 'All' - QComboBox.__init__(self, parent) + QtWidgets.QComboBox.__init__(self, parent) self.entity = ent self.addItem(self.all_chains) for chain in self.entity.chains: @@ -37,9 +36,7 @@ class ChainComboBox(QComboBox): self.setCurrentIndex(0) if gfx: self.gfx = gfx - QObject.connect(self, - SIGNAL('highlighted (const QString&)'), - self._HighlightChain) + self.highlighted.connect(self._HighlightChain) else: self.gfx = None @@ -58,8 +55,9 @@ class ChainComboBox(QComboBox): if gfx: self.gfx = gfx - def _HighlightChain(self, chain): - if str(chain) != 'All': + def _HighlightChain(self, chain_idx): + chain = self.itemText(chain_idx) + if chain != 'All': self.gfx.SetSelection(self.entity.Select('cname="%s"' % str(chain))) else: self.gfx.SetSelection(self.entity.Select('')) @@ -82,7 +80,7 @@ class ChainComboBox(QComboBox): break selected_chain = property(_GetSelectedChain, _SetSelectedChain) -class SuperpositionDialog(QDialog): +class SuperpositionDialog(QtWidgets.QDialog): """ Provides a graphical user interface to structurally superpose two entities. Uses function :func:`~ost.mol.alg.Superpose`. The RMSD of two superposed @@ -132,8 +130,8 @@ class SuperpositionDialog(QDialog): self.gfx_two = None self.gfx_select_one = None self.gfx_select_two = None - QDialog.__init__(self, parent) - self.setWindowTitle('Superpose structures') + QtWidgets.QDialog.__init__(self, parent) + self.setWindowTitle('Superpose Structures') if not isinstance(ent_one, mol.EntityHandle) and \ not isinstance(ent_one, mol.EntityView): n_one = ent_one.GetName() @@ -165,30 +163,28 @@ class SuperpositionDialog(QDialog): if n_one == n_two: n_one = n_one + ' 1' n_two = n_two + ' 2' - layout = QGridLayout(self) + layout = QtWidgets.QGridLayout(self) # select reference molecule self.reference = 0; self._reference = self._ReferenceSelection(n_one, n_two) grow = 0 - layout.addWidget(QLabel("reference"), grow, 0) + layout.addWidget(QtWidgets.QLabel("reference"), grow, 0) layout.addWidget(self._reference, grow, 1) grow += 1 # chains self._chain_one = ChainComboBox(self.ent_one, self.gfx_one, self) self._chain_two = ChainComboBox(self.ent_two, self.gfx_two, self) - layout.addWidget(QLabel("reference chain"), grow, 0) + layout.addWidget(QtWidgets.QLabel("reference chain"), grow, 0) layout.addWidget(self._chain_one, grow, 1) grow += 1 - layout.addWidget(QLabel("chain"), grow, 0) + layout.addWidget(QtWidgets.QLabel("chain"), grow, 0) layout.addWidget(self._chain_two, grow, 1) grow += 1 # link chain and reference selection - QObject.connect(self._reference, - SIGNAL('currentIndexChanged(int)'), - self._ChangeChainSelection) + self._reference.currentIndexChanged.connect(self._ChangeChainSelection) # match methods self._methods = self._MatchMethods() - layout.addWidget(QLabel('match residues by'), grow, 0) + layout.addWidget(QtWidgets.QLabel('match residues by'), grow, 0) grow += 1 layout.addWidget(self._methods) @@ -204,15 +200,15 @@ class SuperpositionDialog(QDialog): layout.addWidget(self._atmselectbx, grow, 1) grow += 1 # buttons - ok_button = QPushButton("Superpose") - QObject.connect(ok_button, SIGNAL('clicked()'), self.accept) - cancel_button = QPushButton("Cancel") - hbox_layout = QHBoxLayout() + ok_button = QtWidgets.QPushButton("Superpose") + ok_button.clicked.connect(self.accept) + cancel_button = QtWidgets.QPushButton("Cancel") + hbox_layout = QtWidgets.QHBoxLayout() hbox_layout.addStretch(1) layout.addLayout(hbox_layout, grow, 0, 1, 2) grow += 1 - QObject.connect(cancel_button, SIGNAL('clicked()'), self.reject) - QObject.connect(self, SIGNAL('accepted()'), self._Superpose) + cancel_button.clicked.connect(self.reject) + self.accepted.connect(self._Superpose) hbox_layout.addWidget(cancel_button, 0) hbox_layout.addWidget(ok_button, 0) ok_button.setDefault(True) @@ -230,7 +226,8 @@ class SuperpositionDialog(QDialog): sp = Superpose(view_two, view_one, self._mmethod_dict[str(self._methods.currentText())], atoms, iterative=self._iterative, - max_iterations=self._it_in.value(), distance_threshold=self._dist_in.value()) + max_iterations=self._it_in.value(), + distance_threshold=self._dist_in.value()) self.rmsd = sp.rmsd if self._iterative: self.rmsd_superposed_atoms = sp.rmsd_superposed_atoms @@ -243,25 +240,25 @@ class SuperpositionDialog(QDialog): self._atoms.setEnabled(False) def _AtomSelectionBox(self): - bt1 = QRadioButton('All') - bt2 = QRadioButton('Backbone') - bt3 = QRadioButton('CA') + bt1 = QtWidgets.QRadioButton('All') + bt2 = QtWidgets.QRadioButton('Backbone') + bt3 = QtWidgets.QRadioButton('CA') self.cstmbtntxt = 'Custom' - custom_rbutton = QRadioButton(self.cstmbtntxt) - group = QButtonGroup() + custom_rbutton = QtWidgets.QRadioButton(self.cstmbtntxt) + group = QtWidgets.QButtonGroup() group.addButton(bt1) group.addButton(bt2) group.addButton(bt3) group.addButton(custom_rbutton) bt1.setChecked(True) - vbox_layout = QVBoxLayout() + vbox_layout = QtWidgets.QVBoxLayout() vbox_layout.addWidget(bt1) vbox_layout.addWidget(bt2) vbox_layout.addWidget(bt3) vbox_layout.addWidget(custom_rbutton) vbox_layout.addWidget(self._atoms) - QObject.connect(custom_rbutton, SIGNAL('toggled(bool)'), self._toggle_atoms) - box = QGroupBox("atom selection") + custom_rbutton.toggled.connect(self._toggle_atoms) + box = QtWidgets.QGroupBox("atom selection") box.setLayout(vbox_layout) return box, group @@ -285,22 +282,22 @@ class SuperpositionDialog(QDialog): for atm in ent_b.GetAtomList(): if atm.name in atm_dict: atm_dict[atm.name] = 1 - atmlst = QStringList() + atmlst = list() for atm in sorted(atm_dict.keys()): if atm_dict[atm]: atmlst.append(atm) - elems = QStringListModel(atmlst) - atoms = QListView(self) + elems = QtCore.QStringListModel(atmlst) + atoms = QtWidgets.QListView(self) dim.setHeight(3*dim.height()) atoms.setFixedSize(dim) atoms.setModel(elems) - atoms.setSelectionMode(QAbstractItemView.MultiSelection) - atoms.setEditTriggers(QAbstractItemView.NoEditTriggers) + atoms.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) + atoms.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) atoms.setEnabled(False) return atoms def _ReferenceSelection(self, name_a, name_b): - cbox = QComboBox() + cbox = QtWidgets.QComboBox() cbox.addItem(name_a) cbox.addItem(name_b) if cbox.count() > 0: @@ -318,13 +315,13 @@ class SuperpositionDialog(QDialog): self._iterative=False def _ItBox(self): - bt1 = QRadioButton("On") - iteration_label=QLabel("Max Iterations: ") - distance_label=QLabel("Dist Thresh: ") - iteration_in=QSpinBox() + bt1 = QtWidgets.QRadioButton("On") + iteration_label=QtWidgets.QLabel("Max Iterations: ") + distance_label=QtWidgets.QLabel("Dist Thresh: ") + iteration_in=QtWidgets.QSpinBox() iteration_in.setRange(1,30) iteration_in.setValue(8) - distance_in=QDoubleSpinBox() + distance_in=QtWidgets.QDoubleSpinBox() distance_in.setRange(1.0,10.0) distance_in.setValue(3.0) distance_in.setDecimals(1) @@ -333,15 +330,15 @@ class SuperpositionDialog(QDialog): distance_in.setEnabled(False) bt1.setChecked(False) self._iterative=False - vbox_layout = QVBoxLayout() + vbox_layout = QtWidgets.QVBoxLayout() vbox_layout.addWidget(bt1) vbox_layout.addWidget(iteration_label) vbox_layout.addWidget(iteration_in) vbox_layout.addWidget(distance_label) vbox_layout.addWidget(distance_in) vbox_layout.addSpacing(50) - QObject.connect(bt1, SIGNAL('toggled(bool)'), self._toggle_iterative) - box = QGroupBox("Iterative") + bt1.toggled.connect(self._toggle_iterative) + box = QtWidgets.QGroupBox("Iterative") box.setLayout(vbox_layout) return box,iteration_in, distance_in @@ -356,7 +353,7 @@ class SuperpositionDialog(QDialog): self.reference = 1; def _MatchMethods(self): - methods=QComboBox(self) + methods=QtWidgets.QComboBox(self) for method in sorted(self._mmethod_dict): methods.addItem(method) return methods diff --git a/modules/gui/pymod/dng/termuse.py b/modules/gui/pymod/dng/termuse.py index a1fed90ddf2c9fdbc7bc74c2e172ebd9edcc43c8..68a937c5ee4dc17a9876adcfb25d244c52de16b9 100644 --- a/modules/gui/pymod/dng/termuse.py +++ b/modules/gui/pymod/dng/termuse.py @@ -1,5 +1,4 @@ -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from PyQt5 import QtGui, QtCore, QtWidgets from ost.gui import AdminRights import ost import os @@ -7,9 +6,9 @@ import os usage='''The DNG application bundle contains two shell commands ('ost' and 'dng') that lets you use the OpenStructure command-line interpreter and dng from the terminal. If you want to use these commands, it is recommended that a symbolic link is created. ''' -class TerminalUsageDialog(QDialog): +class TerminalUsageDialog(QtWidgets.QDialog): def __init__(self, parent=None): - QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle('Enhanced Terminal Usage') self.setFixedSize(QSize(480, 300)) l=QVBoxLayout(self) diff --git a/modules/gui/pymod/export_gl_canvas.cc b/modules/gui/pymod/export_gl_canvas.cc new file mode 100644 index 0000000000000000000000000000000000000000..daf2eec4ef6fd6b482c5ec9ef4d685ac8f8b6d90 --- /dev/null +++ b/modules/gui/pymod/export_gl_canvas.cc @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2011 by the OpenStructure authors +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License as published by the Free +// Software Foundation; either version 3.0 of the License, or (at your option) +// any later version. +// This library is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +// details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ +#include <boost/python.hpp> + +#include <ost/gui/gl_canvas.hh> +#include "sip_handler.hh" + +using namespace boost::python; +using namespace ost; +using namespace ost::gui; + +void WrapSetGLCanvasFormat(GLCanvas& canvas, object py_obj) { + QSurfaceFormat* f = get_cpp_qobject<QSurfaceFormat>(py_obj); + canvas.setFormat(*f); +} + +void export_GLCanvas() { + + class_<GLCanvas, boost::noncopyable>("GLCanvas", init<>()) + .def("Show", &GLCanvas::show) + .def("SetFormat", &WrapSetGLCanvasFormat) + .def("SetDefaultFormat", &GLCanvas::SetDefaultFormat) + .def("SetStereoFormat", &GLCanvas::SetStereoFormat) + .def("GetQObject",&get_py_qobject<GLCanvas>) + .add_property("qobject", &get_py_qobject<GLCanvas>) + ; +} diff --git a/modules/gui/pymod/export_input.cc b/modules/gui/pymod/export_input.cc index 8906e944b9821b8720b003039cfb3282b572a9e9..b6ecb5c0b5787264315354848db56c723e93adb7 100644 --- a/modules/gui/pymod/export_input.cc +++ b/modules/gui/pymod/export_input.cc @@ -31,7 +31,7 @@ namespace { object spnav_get_instance() { static object sip_module=import("sip"); - static object pyqt4_module=import("PyQt4.QtCore"); + static object pyqt5_module=import("PyQt5.QtCore"); SpnavInput* si = SpnavInput::Instance(); if(si->isValid()) { return ost::gui::get_py_qobject<SpnavInput>(si); diff --git a/modules/gui/pymod/export_perspective.cc b/modules/gui/pymod/export_perspective.cc index 720ef3200b84eca113dfac31778ace720000d607..fbc5b6c5902a057ae84934c846f7d0518874375c 100644 --- a/modules/gui/pymod/export_perspective.cc +++ b/modules/gui/pymod/export_perspective.cc @@ -45,8 +45,7 @@ object app_get_menu(Perspective* pers, const QString& name) void export_Perspective() { - class_<Perspective, std::auto_ptr<Perspective>, - boost::noncopyable>("Perspective", no_init) + class_<Perspective, boost::noncopyable>("Perspective", no_init) .def("GetPanels", &Perspective::GetPanels, return_value_policy<reference_existing_object>()) .def("GetMainArea", &Perspective::GetMainArea, diff --git a/modules/gui/pymod/export_tool.cc b/modules/gui/pymod/export_tool.cc index c5165570e5cf113da1392e422488dbf9acb5feb7..3d968fd8840e2369699aed3da179418e9dc6f18b 100644 --- a/modules/gui/pymod/export_tool.cc +++ b/modules/gui/pymod/export_tool.cc @@ -103,7 +103,7 @@ void to_add_option_b(ToolOptions& to, const String& name, object qpoint_to_bp_object (QPoint& p) { - static object bp_module =import("PyQt4.QtCore"); + static object bp_module =import("PyQt5.QtCore"); return bp_module.attr("QPoint")(p.x(),p.y()); } diff --git a/modules/gui/pymod/helpwidget.py b/modules/gui/pymod/helpwidget.py index 39e8602a8c70060a987193b6d0b0ad26dc8ee906..9ac28e2059c2805d276b798572f48b4ecd5ebb83 100644 --- a/modules/gui/pymod/helpwidget.py +++ b/modules/gui/pymod/helpwidget.py @@ -1,19 +1,17 @@ -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from PyQt5 import QtWidgets from ost import gui -class DocWidget(QWidget): +class DocWidget(QtWidgets.QWidget): def __init__(self, parent=None): - QWidget.__init__(self, parent) - l=QVBoxLayout(self) - l.setMargin(0) + QtWidgets.QWidget.__init__(self, parent) + l=QtWidgets.QVBoxLayout(self) + l.setContentsMargins(0,0,0,0) self.setWindowTitle('OpenStructure Help') - self.searchbox=QLineEdit(self) + self.searchbox=QtWidgets.QLineEdit(self) l.addWidget(self.searchbox) - self.doctext=QTextEdit('', self) + self.doctext=QtWidgets.QTextEdit('', self) l.addWidget(self.doctext) self.setLayout(l) - QObject.connect(self.searchbox, SIGNAL('returnPressed()'), - self.OnReturnPressed) + self.searchbox.returnPressed.connect(self.OnReturnPressed) def OnReturnPressed(self): help(str(self.searchbox.text())) doc_widget=DocWidget() diff --git a/modules/gui/pymod/init_context_menu.py b/modules/gui/pymod/init_context_menu.py index e911645c0044ea2585c4fa5e168cee7b36352103..568241a3a35d7737230fe65f16a4e83319dd519e 100644 --- a/modules/gui/pymod/init_context_menu.py +++ b/modules/gui/pymod/init_context_menu.py @@ -1,64 +1,64 @@ import platform -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets import sip from ost import geom, gfx, gui, seq from ost import settings from ost import LogError, mol -from ost.bindings import tmtools +from ost.bindings import WrappedTMAlign from ost.bindings import msms from ost.seq import alg import ost from ost.gui.scene.query_editor import QueryEditorWidget,QueryDialog -class SelectRefDialog(QtGui.QDialog): +class SelectRefDialog(QtWidgets.QDialog): def __init__(self, ent_list, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.ent_list_ = ent_list - vb = QtGui.QVBoxLayout() + vb = QtWidgets.QVBoxLayout() self.setLayout(vb) self.setWindowTitle("Select Reference Object") - self.label = QtGui.QLabel("Please Select the Reference Object") - self.list = QtGui.QTableWidget(self) + self.label = QtWidgets.QLabel("Please Select the Reference Object") + self.list = QtWidgets.QTableWidget(self) self.list.horizontalHeader().setStretchLastSection(True) self.list.setColumnCount(2) self.list.verticalHeader().setVisible(False) self.list.horizontalHeader().setVisible(False) - self.list.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) - self.list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) + self.list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) + self.list.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) vb.addWidget(self.label) vb.addWidget(self.list) - self.show_scores = QtGui.QCheckBox(self) + self.show_scores = QtWidgets.QCheckBox(self) self.show_scores.setText("Show Scores") self.show_scores.setChecked(True) vb.addWidget(self.show_scores) - self.show_alignment = QtGui.QCheckBox(self) + self.show_alignment = QtWidgets.QCheckBox(self) self.show_alignment.setText("Display Alignment") self.show_alignment.setChecked(False) vb.addWidget(self.show_alignment) - hb = QtGui.QHBoxLayout() - hb.setDirection(QtGui.QBoxLayout.LeftToRight) - cancel_btn = QtGui.QPushButton("Cancel", self) - load_btn = QtGui.QPushButton("Select", self) + hb = QtWidgets.QHBoxLayout() + hb.setDirection(QtWidgets.QBoxLayout.LeftToRight) + cancel_btn = QtWidgets.QPushButton("Cancel", self) + load_btn = QtWidgets.QPushButton("Select", self) hb.addStretch(1) hb.addWidget(cancel_btn) hb.addWidget(load_btn) vb.addItem(hb) load_btn.setDefault(True) - QtCore.QObject.connect(load_btn, QtCore.SIGNAL("clicked()"), self.Select) - QtCore.QObject.connect(cancel_btn, QtCore.SIGNAL("clicked()"), self.reject) + load_btn.clicked.connect(self.Select) + cancel_btn.clicked.connect(self.reject) row = 0 for ent in self.ent_list_: variant = QtCore.QVariant(ent) self.list.insertRow(row) - new_item = QtGui.QTableWidgetItem("%i"%(row+1)) + new_item = QtWidgets.QTableWidgetItem("%i"%(row+1)) new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled) new_item.setData(QtCore.Qt.UserRole,variant) self.list.setItem(row, 0, new_item) - new_item = QtGui.QTableWidgetItem(ent.GetName()) + new_item = QtWidgets.QTableWidgetItem(ent.GetName()) new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled) self.list.setItem(row, 1, new_item) row += 1 @@ -69,7 +69,7 @@ class SelectRefDialog(QtGui.QDialog): items = self.list.selectedItems() for item in items: if(item.column()==0): - ent = item.data(QtCore.Qt.UserRole).toPyObject() + ent = item.data(QtCore.Qt.UserRole) self.ent_list_.remove(ent) self.ent_list_.insert(0,ent) self.accept() @@ -83,103 +83,103 @@ class SelectRefDialog(QtGui.QDialog): def GetEntities(self): return self.ent_list_ -class ShowResultDialog(QtGui.QDialog): +class ShowResultDialog(QtWidgets.QDialog): def __init__(self, ent_list, res_list, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.ent_list_ = ent_list - vb = QtGui.QVBoxLayout() + vb = QtWidgets.QVBoxLayout() self.setLayout(vb) self.setWindowTitle("Alignment result") - self.label = QtGui.QLabel("Alignment results with %s as reference"%ent_list[0].GetName()) - self.list = QtGui.QTableWidget(self) + self.label = QtWidgets.QLabel("Alignment results with %s as reference"%ent_list[0].GetName()) + self.list = QtWidgets.QTableWidget(self) self.list.horizontalHeader().setStretchLastSection(True) self.list.setColumnCount(4) self.list.verticalHeader().setVisible(False) self.list.setHorizontalHeaderLabels (["Name","RMSD","TMScore",""]) - self.list.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) + self.list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) vb.addWidget(self.label) vb.addWidget(self.list) - hb = QtGui.QHBoxLayout() - hb.setDirection(QtGui.QBoxLayout.LeftToRight) - ok_btn = QtGui.QPushButton("OK", self) + hb = QtWidgets.QHBoxLayout() + hb.setDirection(QtWidgets.QBoxLayout.LeftToRight) + ok_btn = QtWidgets.QPushButton("OK", self) hb.addStretch(1) hb.addWidget(ok_btn) vb.addItem(hb) ok_btn.setDefault(True) - QtCore.QObject.connect(ok_btn, QtCore.SIGNAL("clicked()"), self.accept) + ok_btn.clicked.connect(self.accept) for i in range(0, len(res_list)): self.list.insertRow(i) - new_item = QtGui.QTableWidgetItem(ent_list[i+1].GetName()) + new_item = QtWidgets.QTableWidgetItem(ent_list[i+1].GetName()) new_item.setFlags(QtCore.Qt.ItemIsEnabled) self.list.setItem(i, 0, new_item) - new_item = QtGui.QTableWidgetItem("%.2f"%res_list[i].rmsd) + new_item = QtWidgets.QTableWidgetItem("%.2f"%res_list[i].rmsd) new_item.setFlags(QtCore.Qt.ItemIsEnabled) self.list.setItem(i, 1, new_item) - new_item = QtGui.QTableWidgetItem("%i"%res_list[i].tm_score) + new_item = QtWidgets.QTableWidgetItem("%.2f"%res_list[i].tm_score) new_item.setFlags(QtCore.Qt.ItemIsEnabled) self.list.setItem(i, 2, new_item) - new_item = QtGui.QTableWidgetItem() + new_item = QtWidgets.QTableWidgetItem() new_item.setFlags(QtCore.Qt.ItemIsEnabled) self.list.setItem(i, 3, new_item) self.list.resizeColumnsToContents() -class CalculateSurfaceSettingsDialog(QtGui.QDialog): +class CalculateSurfaceSettingsDialog(QtWidgets.QDialog): def __init__(self, executable, parent=None): - QtGui.QDialog.__init__(self, parent) - vb = QtGui.QGridLayout() + QtWidgets.QDialog.__init__(self, parent) + vb = QtWidgets.QGridLayout() self.setLayout(vb) self.setWindowTitle("MSMS Surface Settings") - msmsexe_label=QtGui.QLabel("executable") - self.msmsexe_field=QtGui.QLineEdit() + msmsexe_label=QtWidgets.QLabel("executable") + self.msmsexe_field=QtWidgets.QLineEdit() self.msmsexe_field.setText(executable) - msmsexe_browsebutton=QtGui.QPushButton("Browse") + msmsexe_browsebutton=QtWidgets.QPushButton("Browse") vb.addWidget(msmsexe_label, 0, 0) vb.addWidget(self.msmsexe_field, 0, 1) vb.addWidget(msmsexe_browsebutton, 0, 2) - surfname_label=QtGui.QLabel("surface name") - self.surfname_field=QtGui.QLineEdit() + surfname_label=QtWidgets.QLabel("surface name") + self.surfname_field=QtWidgets.QLineEdit() self.surfname_field.setText("surface") vb.addWidget(surfname_label, 1, 0) vb.addWidget(self.surfname_field, 1, 1, 1, 2) - density_label=QtGui.QLabel("density") - self.density_spinbox=QtGui.QSpinBox() + density_label=QtWidgets.QLabel("density") + self.density_spinbox=QtWidgets.QSpinBox() self.density_spinbox.setRange(1, 10) self.density_spinbox.setValue(4) vb.addWidget(density_label, 2, 0) vb.addWidget(self.density_spinbox, 2, 1, 1, 2) - probe_label=QtGui.QLabel("probe radius") - self.probe_spinbox=QtGui.QDoubleSpinBox() + probe_label=QtWidgets.QLabel("probe radius") + self.probe_spinbox=QtWidgets.QDoubleSpinBox() self.probe_spinbox.setDecimals(1) self.probe_spinbox.setSingleStep(0.1) self.probe_spinbox.setRange(0.3, 5.0) self.probe_spinbox.setValue(1.4) vb.addWidget(probe_label, 3, 0) vb.addWidget(self.probe_spinbox, 3, 1, 1, 2) - selection_label=QtGui.QLabel("selection") - self.selection_field=QtGui.QLineEdit() + selection_label=QtWidgets.QLabel("selection") + self.selection_field=QtWidgets.QLineEdit() self.selection_field.setText("") vb.addWidget(selection_label, 4, 0) vb.addWidget(self.selection_field, 4, 1, 1, 2) - self.noh_box=QtGui.QCheckBox("no hydrogens") + self.noh_box=QtWidgets.QCheckBox("no hydrogens") vb.addWidget(self.noh_box, 5, 0) - self.nohet_box=QtGui.QCheckBox("no hetatoms") + self.nohet_box=QtWidgets.QCheckBox("no hetatoms") vb.addWidget(self.nohet_box, 5, 1) - self.nowat_box=QtGui.QCheckBox("no waters") + self.nowat_box=QtWidgets.QCheckBox("no waters") vb.addWidget(self.nowat_box, 5, 2) - cancel_btn = QtGui.QPushButton("Cancel", self) - ok_btn = QtGui.QPushButton("OK", self) + cancel_btn = QtWidgets.QPushButton("Cancel", self) + ok_btn = QtWidgets.QPushButton("OK", self) vb.addWidget(cancel_btn, 6, 1) vb.addWidget(ok_btn, 6, 2) - QtCore.QObject.connect(msmsexe_browsebutton, QtCore.SIGNAL("clicked()"), self.GetPath) - QtCore.QObject.connect(ok_btn, QtCore.SIGNAL("clicked()"), self.accept) - QtCore.QObject.connect(cancel_btn, QtCore.SIGNAL("clicked()"), self.reject) + msmsexe_browsebutton.clicked.connect(self.GetPath) + ok_btn.clicked.connect(self.accept) + cancel_btn.clicked.connect(self.reject) def GetPath(self): - path=QtGui.QFileDialog().getOpenFileName(self, "Choose MSMS Executable") + path, _ =QtWidgets.QFileDialog.getOpenFileName(self, "Choose MSMS Executable") if path!='': self.msmsexe_field.setText(path) @@ -191,9 +191,8 @@ class SurfaceContextMenu(QtCore.QObject): except settings.FileNotFound: self.executable="" QtCore.QObject.__init__(self, context_menu.qobject) - self.action = QtGui.QAction("Calculate Surface", self) - QtCore.QObject.connect(self.action, QtCore.SIGNAL("triggered()"), - self.CalculateSurface) + self.action = QtWidgets.QAction("Calculate Surface", self) + self.action.triggered.connect(self.CalculateSurface) context_menu.AddAction(self.action, gui.ContextActionType.ENTITY) def CalculateSurface(self): @@ -233,30 +232,33 @@ class SurfaceContextMenu(QtCore.QObject): except UserWarning: LogError("WARNING: Entry with the same name already present in scene") return - -class AlignmentContextMenu(QtCore.QObject): + +class SecStructContextMenu(QtCore.QObject): def __init__(self, context_menu): - try: - try: # workaround for interrupted system call bug on OSX - if platform.system() == "Windows": - settings_name="tmalign.exe" - else: - settings_name="tmalign" - except IOError: - # if platform.system() fails with an IOError we are most likely on a buggy mac an therefore - # use "tmalign" - settings_name="tmalign" + QtCore.QObject.__init__(self, context_menu.qobject) + self.action = QtWidgets.QAction("Assign Secondary Structure", self) + self.action.triggered.connect(self.AssignSecondaryStructure) + context_menu.AddAction(self.action, gui.ContextActionType.ENTITY) + + def AssignSecondaryStructure(self): + scene_selection = gui.SceneSelection.Instance() + ent_list = list() + for i in range(0,scene_selection.GetActiveNodeCount()): + node = scene_selection.GetActiveNode(i) + mol.alg.AssignSecStruct(node.view) + node.UpdateView() - settings.Locate(settings_name) - QtCore.QObject.__init__(self, context_menu.qobject) + +class AlignmentContextMenu(QtCore.QObject): - self.action = QtGui.QAction("Align", self) - QtCore.QObject.connect(self.action,QtCore.SIGNAL("triggered()"), self.Align) - context_menu.AddAction(self.action, gui.ContextActionType.ENTITY | gui.ContextActionType.MULTI) - self.seq_viewer = None - except settings.FileNotFound: - return + def __init__(self, context_menu): + + QtCore.QObject.__init__(self, context_menu.qobject) + self.action = QtWidgets.QAction("Align", self) + self.action.triggered.connect(self.Align) + context_menu.AddAction(self.action, gui.ContextActionType.ENTITY | gui.ContextActionType.MULTI) + self.seq_viewer = None def Align(self): scene_selection = gui.SceneSelection.Instance() @@ -271,11 +273,11 @@ class AlignmentContextMenu(QtCore.QObject): node = ent_list[0] res_list = list() if isinstance(node, gfx.Entity): - ref = node.view.handle + ref = node.view.chains[0] for i in range(1,len(ent_list)): node = ent_list[i] if isinstance(node, gfx.Entity): - res_list.append(tmtools.TMAlign(node.view.handle, ref)) + res_list.append(WrappedTMAlign(node.view.chains[0], ref)) node.UpdatePositions() if show_scores: self.__ShowScore(ent_list, res_list) @@ -285,19 +287,25 @@ class AlignmentContextMenu(QtCore.QObject): def __ShowScore(self, ent_list, res_list): if(len(res_list)==1): res = res_list[0] - string = "RMSD: %.2f, TMScore: %i"%(res.rmsd, res.tm_score) + string = "RMSD: %.2f, TMScore: %.2f"%(res.rmsd, res.tm_score) gui.GostyApp.Instance().perspective.StatusMessage(string) elif(len(res_list)>1): ShowResultDialog(ent_list, res_list).exec_() def __DisplayAlignment(self, ent_list, res_list): if(len(res_list)>0): - ref_seq = seq.CreateSequence("%s (ref)"%ent_list[0].GetName(),res_list[0].ref_sequence.GetGaplessString()) + ref_seq = seq.CreateSequence("%s (ref)"%ent_list[0].GetName(), + res_list[0].alignment.GetSequence(1).GetGaplessString()) aln_list = seq.AlignmentList() if(ref_seq.IsValid()): for i in range(0, len(res_list)): - res_list[i].alignment.SetSequenceName(1,ent_list[i+1].GetName()) - aln_list.append(res_list[i].alignment) + # WrappedTMAlign returns an alignment with second sequence + # being reference... let's swap... + new_aln = seq.CreateAlignment() + new_aln.AddSequence(res_list[i].alignment.GetSequence(1)) + new_aln.AddSequence(res_list[i].alignment.GetSequence(0)) + new_aln.SetSequenceName(1, ent_list[i+1].GetName()) + aln_list.append(new_aln) alignment = alg.MergePairwiseAlignments(aln_list, ref_seq) gosty = gui.GostyApp.Instance() main_area = gosty.perspective.GetMainArea() @@ -311,17 +319,14 @@ class AlignmentContextMenu(QtCore.QObject): class SelectMenuPoints(QtCore.QObject): def __init__(self, context_menu): QtCore.QObject.__init__(self, context_menu.qobject) - action=QtGui.QAction("Select...", self) - QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), - self._Select) + action=QtWidgets.QAction("Select...", self) + action.triggered.connect(self._Select) context_menu.AddAction(action, gui.ENTITY) - action=QtGui.QAction("Copy Selection...", self) - QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), - self._CopyViews) + action=QtWidgets.QAction("Copy Selection...", self) + action.triggered.connect(self._CopyViews) context_menu.AddAction(action, gui.ENTITY) - action=QtGui.QAction('Select...', self) - QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), - self._SelectViewsSameEntity) + action=QtWidgets.QAction('Select...', self) + action.triggered.connect(self._SelectViewsSameEntity) context_menu.AddAction(action, gui.ENTITY_VIEW|gui.VIEWS_SAME_OBJECT) def _Select(self): scene_selection=gui.SceneSelection.Instance() @@ -377,5 +382,6 @@ class SelectMenuPoints(QtCore.QObject): def _InitContextMenu(app): _InitContextMenu.cm=app.scene_win.GetContextMenu() _InitContextMenu.am=AlignmentContextMenu(_InitContextMenu.cm) + _InitContextMenu.sec=SecStructContextMenu(_InitContextMenu.cm) _InitContextMenu.sc=SurfaceContextMenu(_InitContextMenu.cm) _InitContextMenu.sm=SelectMenuPoints(_InitContextMenu.cm) diff --git a/modules/gui/pymod/init_menubar.py b/modules/gui/pymod/init_menubar.py index 761e483bb3493284a4078904dd24113a5011ddc2..03930fc53230a7c94f93e1bce6bb9b081466ed3b 100644 --- a/modules/gui/pymod/init_menubar.py +++ b/modules/gui/pymod/init_menubar.py @@ -23,7 +23,7 @@ import sip from ost import gfx import ost -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui from ost.gui import FileLoader from ost.gui.init_splash import _InitSplash from ost.gui.dng import termuse diff --git a/modules/gui/pymod/init_spacenav.py b/modules/gui/pymod/init_spacenav.py index f94b569f97d8c943fc2fd2ee5f369fd5c976961e..86154534b514b6a30881e48276f4bc74cf1b0187 100644 --- a/modules/gui/pymod/init_spacenav.py +++ b/modules/gui/pymod/init_spacenav.py @@ -1,6 +1,6 @@ import math,traceback -from PyQt4 import QtCore +from PyQt5 import QtCore import ost from ost import gfx, gui diff --git a/modules/gui/pymod/init_splash.py b/modules/gui/pymod/init_splash.py index ec5e3667cd23e8625b9bc29fcb811bd6eda0e3d5..dd34cd4b0f1ca0001c5ce89026af1f0610c35264 100644 --- a/modules/gui/pymod/init_splash.py +++ b/modules/gui/pymod/init_splash.py @@ -1,4 +1,4 @@ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets import os import ost @@ -12,19 +12,19 @@ You are running version %s<br /><br />If you are new to OpenStructure, we invite you to run the demos from the examples directory. Scripts can be displayed by right clicking on the file and selecting 'Show source'.<br/><br/> Feel free visit our website at:<br /> -<a href='http://www.openstructure.org'>http://www.openstructure.org</a> +<a href='https://www.openstructure.org'>https://www.openstructure.org</a> """ % ost.VERSION -class SplashDialog(QtGui.QDialog): +class SplashDialog(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) - layout = QtGui.QHBoxLayout(self) + QtWidgets.QDialog.__init__(self, parent) + layout = QtWidgets.QHBoxLayout(self) self.setLayout(layout) - imageLabel = QtGui.QLabel(); + imageLabel = QtWidgets.QLabel(); self.pix_map = QtGui.QPixmap(LOGO_PATH); imageLabel.setPixmap(self.pix_map); layout.addWidget(imageLabel) - self.label = QtGui.QTextBrowser() + self.label = QtWidgets.QTextBrowser() self.label.setReadOnly(True) self.label.setOpenExternalLinks(True) self.label.setHtml(SPLASH_TEXT) diff --git a/modules/gui/pymod/scene/color_options_widget.py b/modules/gui/pymod/scene/color_options_widget.py index 1d8e95cf6ec5ff9402daec6b917dcc5ea2d06742..c99eb41e2993459d5fb062353b15e7cc278af9a9 100644 --- a/modules/gui/pymod/scene/color_options_widget.py +++ b/modules/gui/pymod/scene/color_options_widget.py @@ -29,7 +29,7 @@ except ImportError: _img_present=False pass -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtWidgets from scene_selection_helper import SelHelper from gradient_editor_widget import GradientEditor from uniform_color_widget import UniformColorWidget @@ -41,8 +41,8 @@ class ColorOptionsWidget(ComboOptionsWidget): #Title self.text_ = "Color Options" - conly_label_ = QtGui.QLabel('carbons only') - self.conly_box_ = QtGui.QCheckBox() + conly_label_ = QtWidgets.QLabel('carbons only') + self.conly_box_ = QtWidgets.QCheckBox() #Add options to menu self.entity_widgets_ = list() @@ -55,8 +55,8 @@ class ColorOptionsWidget(ComboOptionsWidget): self.img_widgets_ = list() self.img_widgets_.append(["Uniform",UniformColorWidget()]) - qw = QtGui.QWidget(self) - gl = QtGui.QGridLayout(qw) + qw = QtWidgets.QWidget(self) + gl = QtWidgets.QGridLayout(qw) gl.addWidget(self.conly_box_, 0, 0, 1, 1) gl.addWidget(conly_label_, 0, 1, 1, 4) self.grid_layout_.addWidget(qw, 2, 0, 1, 1) @@ -112,9 +112,9 @@ class ColorOptionsWidget(ComboOptionsWidget): return self.conly_box_.isChecked() -class ByElementWidget(QtGui.QWidget): +class ByElementWidget(QtWidgets.QWidget): def __init__(self, text, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.parent_ = parent @@ -122,13 +122,13 @@ class ByElementWidget(QtGui.QWidget): self.text_ = text #UI - text_label = QtGui.QLabel(text) + text_label = QtWidgets.QLabel(text) font = text_label.font() font.setBold(True) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(text_label,0,0,1,1) - grid.addWidget(QtGui.QLabel("No Settings available"), 1, 0, 1, 3) + grid.addWidget(QtWidgets.QLabel("No Settings available"), 1, 0, 1, 3) grid.setRowStretch(2,1) self.setLayout(grid) self.setMinimumSize(250,60) @@ -156,20 +156,20 @@ class ByElementWidget(QtGui.QWidget): return self.text_ -class ByChainWidget(QtGui.QWidget): +class ByChainWidget(QtWidgets.QWidget): def __init__(self, text, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.parent_ = parent #Title self.text_ = text #UI - text_label = QtGui.QLabel(text) + text_label = QtWidgets.QLabel(text) font = text_label.font() font.setBold(True) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(text_label,0,0,1,1) grid.setRowStretch(2,1) self.setLayout(grid) @@ -197,20 +197,20 @@ class ByChainWidget(QtGui.QWidget): def GetText(self): return self.text_ -class ByEntityWidget(QtGui.QWidget): +class ByEntityWidget(QtWidgets.QWidget): def __init__(self, text, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.parent_ = parent #Title self.text_ = text #UI - text_label = QtGui.QLabel(text) + text_label = QtWidgets.QLabel(text) font = text_label.font() font.setBold(True) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(text_label,0,0,1,1) grid.setRowStretch(2,1) self.setLayout(grid) diff --git a/modules/gui/pymod/scene/color_select_widget.py b/modules/gui/pymod/scene/color_select_widget.py index 110108e6340c1078268169fa369e3f9c7364e152..737fd8c48db892a48510e8fb2f86d8afe0e3bba4 100644 --- a/modules/gui/pymod/scene/color_select_widget.py +++ b/modules/gui/pymod/scene/color_select_widget.py @@ -20,28 +20,31 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui #Gradient Stop -class ColorSelectWidget(QtGui.QWidget): +class ColorSelectWidget(QtWidgets.QWidget): + + colorChanged = QtCore.pyqtSignal() + def __init__(self, width, height, color, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Membervars self.width_ = width self.height_ = height if(color is None): - self.color_ = QtGui.QColor("White") + self.color_ = QtWidgets.QColor("White") else: self.color_ = color self.show() #ContextMenu - self.change_color_ = QtGui.QAction('ChangeColor', self) + self.change_color_ = QtWidgets.QAction('ChangeColor', self) - QtCore.QObject.connect(self.change_color_, QtCore.SIGNAL('triggered()'), self.ChangeColor) + self.change_color_.triggered.connect(self.ChangeColor) self.addAction(self.change_color_) self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) @@ -49,11 +52,12 @@ class ColorSelectWidget(QtGui.QWidget): self.Resize() def ChangeColor(self): - color = QtGui.QColorDialog.getColor(self.color_, self) + color = QtWidgets.QColorDialog.getColor(initial = self.color_, parent = self, + title = "Select Color") if(color != self.color_ and color.isValid()): self.color_ = color - self.emit(QtCore.SIGNAL("colorChanged")) + self.colorChanged.emit() self.update() def GetColor(self): @@ -66,11 +70,11 @@ class ColorSelectWidget(QtGui.QWidget): def SetColor(self, color): if(self.color_ != color): self.color_ = color - self.emit(QtCore.SIGNAL("colorChanged")) + self.colorChanged.emit() self.update() def SetGfxColor(self, color): - qcolor= QtGui.QColor(color.Red()*255,color.Green()*255,color.Blue()*255,color.Alpha()*255) + qcolor= QtWidgets.QColor(color.Red()*255,color.Green()*255,color.Blue()*255,color.Alpha()*255) self.SetColor(qcolor) def paintEvent(self, event): diff --git a/modules/gui/pymod/scene/combo_options_widget.py b/modules/gui/pymod/scene/combo_options_widget.py index 8961c04a263db4877ad2bb5385ce0e6283cafc1e..28bacce3f156cfc6ecde2bb4d23d7db8a78a15d3 100644 --- a/modules/gui/pymod/scene/combo_options_widget.py +++ b/modules/gui/pymod/scene/combo_options_widget.py @@ -21,9 +21,9 @@ import sys from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets -class ComboOptionsWidget(QtGui.QWidget): +class ComboOptionsWidget(QtWidgets.QWidget): """QWidget with a Combobox and a show area. This abstract QWidget has a Combobox and a show area. Whenever the value of @@ -31,22 +31,21 @@ class ComboOptionsWidget(QtGui.QWidget): shown in the show area. """ def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Setup ui_ self.parent_ = parent - self.grid_layout_ = QtGui.QGridLayout(self) + self.grid_layout_ = QtWidgets.QGridLayout(self) self.grid_layout_.setHorizontalSpacing(0) self.grid_layout_.setVerticalSpacing(0) self.grid_layout_.setContentsMargins(0,0,0,0) - self.combo_box_ = QtGui.QComboBox(self) + self.combo_box_ = QtWidgets.QComboBox(self) self.grid_layout_.addWidget(self.combo_box_, 0, 0, 1, 1) - self.stacked_widget_ = QtGui.QStackedWidget(self) + self.stacked_widget_ = QtWidgets.QStackedWidget(self) self.grid_layout_.addWidget(self.stacked_widget_, 1, 0, 1, 1) self.__UpdateView(self.combo_box_.currentIndex()) - QtCore.QObject.connect(self.combo_box_, QtCore.SIGNAL("activated(int)"), - self.__UpdateView) + self.combo_box_.activated.connect(self.__UpdateView) self.setEnabled(False) @@ -66,11 +65,11 @@ class ComboOptionsWidget(QtGui.QWidget): the old widget will be removed and the new widget gets the identifier. Returns True, if widget is added. Otherwise it returns False """ - if isinstance(widget, QtGui.QWidget) and ident is not None: + if isinstance(widget, QtWidgets.QWidget) and ident is not None: if hasattr(widget, "GetText"): - string = QtCore.QString(widget.GetText()) + string = widget.GetText() else: - string = QtCore.QString(ident) + string = ident self.RemoveWidget(ident) self.stacked_widget_.addWidget(widget) @@ -82,7 +81,7 @@ class ComboOptionsWidget(QtGui.QWidget): def RemoveWidget(self,ident): index = self.__GetIndex(ident) if(index >= 0): - self.stacked_widget_.removeWidget(self.combo_box_.itemData(index).toPyObject()[1]) + self.stacked_widget_.removeWidget(self.combo_box_.itemData(index)[1]) self.combo_box_.removeItem(index) def OnComboChange(self, item): @@ -137,18 +136,18 @@ class ComboOptionsWidget(QtGui.QWidget): def __GetIndex(self, ident): for i in range(self.combo_box_.count()): - pair = self.combo_box_.itemData(i).toPyObject() + pair = self.combo_box_.itemData(i) if ident == pair[0]: return i return -1 def __GetCurrentPair(self): current_index = self.combo_box_.currentIndex() - return self.combo_box_.itemData(current_index).toPyObject() + return self.combo_box_.itemData(current_index) #Overwritten Methods def setEnabled(self, bool): - QtGui.QWidget.setEnabled(self, bool) + QtWidgets.QWidget.setEnabled(self, bool) for i in range(self.combo_box_.count()): - pair = self.combo_box_.itemData(i).toPyObject() + pair = self.combo_box_.itemData(i) pair[1].setEnabled(bool) diff --git a/modules/gui/pymod/scene/cpk_widget.py b/modules/gui/pymod/scene/cpk_widget.py index 038476597374ba254bf4ae709720f5ff195562fb..c40819abe636a81a94279b3f14fa96d6e3f08cd7 100644 --- a/modules/gui/pymod/scene/cpk_widget.py +++ b/modules/gui/pymod/scene/cpk_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #CPK Render Options @@ -40,26 +40,26 @@ class CPKWidget(RenderModeWidget): #Create Ui elements - self.sphere_spinbox_ = QtGui.QSpinBox() + self.sphere_spinbox_ = QtWidgets.QSpinBox() self.sphere_spinbox_.setRange(min_sphere_detail, max_sphere_detail) - cpk_mode_label = QtGui.QLabel("Rendering Mode") - self.cpk_mode_ = QtGui.QComboBox() + cpk_mode_label = QtWidgets.QLabel("Rendering Mode") + self.cpk_mode_ = QtWidgets.QComboBox() self.cpk_mode_.addItem("Triangles") self.cpk_mode_.addItem("3D Sprites") - cpk_label = QtGui.QLabel(self.text_) + cpk_label = QtWidgets.QLabel(self.text_) font = cpk_label.font() font.setBold(True) - sphere_label = QtGui.QLabel("Sphere Detail") - grid = QtGui.QGridLayout() + sphere_label = QtWidgets.QLabel("Sphere Detail") + grid = QtWidgets.QGridLayout() grid.addWidget(cpk_label,0,0,1,1) grid.addWidget(sphere_label, 1, 0, 1, 3) grid.addWidget(self.sphere_spinbox_, 1, 2, 1, 1) grid.setRowStretch(2,1) self.setLayout(grid) - QtCore.QObject.connect(self.sphere_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSphereDetail) - QtCore.QObject.connect(self.cpk_mode_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdateSphereMode) + self.sphere_spinbox_.valueChanged.connect(self.UpdateSphereDetail) + self.cpk_mode_.currentIndexChanged.connect(self.UpdateSphereMode) self.setMinimumSize(250,60) diff --git a/modules/gui/pymod/scene/custom_widget.py b/modules/gui/pymod/scene/custom_widget.py index a0413862db119dd0e0fce07c3534ad889617f436..e94eabd2d1bb9dafb173f8db951ef21b4d5ba7d1 100644 --- a/modules/gui/pymod/scene/custom_widget.py +++ b/modules/gui/pymod/scene/custom_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Custom Render Options @@ -49,46 +49,46 @@ class CustomWidget(RenderModeWidget): #Create Ui elements - self.sphere_spinbox_ = QtGui.QSpinBox() + self.sphere_spinbox_ = QtWidgets.QSpinBox() self.sphere_spinbox_.setRange(min_sphere_detail, max_sphere_detail) - self.arc_spinbox_ = QtGui.QSpinBox() + self.arc_spinbox_ = QtWidgets.QSpinBox() self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail) #Bond Radius - radius_bond_label = QtGui.QLabel("Bond Radius") + radius_bond_label = QtWidgets.QLabel("Bond Radius") - self.radius_bond_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_bond_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_bond_spinbox_.setRange(min_rad, max_bond_rad) self.radius_bond_spinbox_.setDecimals(2) self.radius_bond_spinbox_.setSingleStep(0.05) - self.radius_bond_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.radius_bond_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.radius_bond_slider_.setRange(min_rad*100.0, max_bond_rad*100.0) - self.radius_bond_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.radius_bond_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.radius_bond_slider_.setTickInterval(5) #Sphere Radius - radius_sphere_label = QtGui.QLabel("Sphere Radius") + radius_sphere_label = QtWidgets.QLabel("Sphere Radius") - self.radius_sphere_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_sphere_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_sphere_spinbox_.setRange(min_rad, max_sphere_rad) self.radius_sphere_spinbox_.setDecimals(2) self.radius_sphere_spinbox_.setSingleStep(0.05) - self.radius_sphere_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.radius_sphere_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.radius_sphere_slider_.setRange(min_rad*100.0, max_sphere_rad*100.0) - self.radius_sphere_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.radius_sphere_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.radius_sphere_slider_.setTickInterval(5) - custom_label = QtGui.QLabel(self.text_) + custom_label = QtWidgets.QLabel(self.text_) font = custom_label.font() font.setBold(True) - sphere_label = QtGui.QLabel("Sphere Detail") - arc_label = QtGui.QLabel("Arc Detail") - grid = QtGui.QGridLayout() + sphere_label = QtWidgets.QLabel("Sphere Detail") + arc_label = QtWidgets.QLabel("Arc Detail") + grid = QtWidgets.QGridLayout() grid.addWidget(custom_label,0,0,1,1) grid.addWidget(sphere_label, 1, 0, 1, 3) grid.addWidget(self.sphere_spinbox_, 1, 2, 1, 1) @@ -106,22 +106,14 @@ class CustomWidget(RenderModeWidget): grid.setRowStretch(3,1) self.setLayout(grid) - QtCore.QObject.connect(self.sphere_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSphereDetail) - QtCore.QObject.connect(self.arc_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateArcDetail) - - QtCore.QObject.connect(self.radius_bond_spinbox_, - QtCore.SIGNAL("valueChanged(double)"), - self.UpdateBondRadius) - QtCore.QObject.connect(self.radius_bond_slider_, - QtCore.SIGNAL("valueChanged(int)"), - self.UpdateSliderBondRadius) - - QtCore.QObject.connect(self.radius_sphere_spinbox_, - QtCore.SIGNAL("valueChanged(double)"), - self.UpdateSphereRadius) - QtCore.QObject.connect(self.radius_sphere_slider_, - QtCore.SIGNAL("valueChanged(int)"), - self.UpdateSliderSphereRadius) + self.sphere_spinbox_.valueChanged.connect(self.UpdateSphereDetail) + self.arc_spinbox_.valueChanged.connect(self.UpdateArcDetail) + + self.radius_bond_spinbox_.valueChanged.connect(self.UpdateBondRadius) + self.radius_bond_slider_.valueChanged.connect(self.UpdateSliderBondRadius) + + self.radius_sphere_spinbox_.valueChanged.connect(self.UpdateSphereRadius) + self.radius_sphere_slider_.valueChanged.connect(self.UpdateSliderSphereRadius) self.setMinimumSize(250,150) diff --git a/modules/gui/pymod/scene/file_loader.py b/modules/gui/pymod/scene/file_loader.py index a0acf4140669bee32e6c4e34c6ec44ea2c1888a5..fedca454330ce6a5c006cdc0ac32bd610781c373 100644 --- a/modules/gui/pymod/scene/file_loader.py +++ b/modules/gui/pymod/scene/file_loader.py @@ -23,7 +23,7 @@ import ost import sip import re -from PyQt4 import QtCore, QtGui, QtNetwork +from PyQt5 import QtCore, QtGui, QtNetwork from ost.gui import FileLoader """ diff --git a/modules/gui/pymod/scene/gradient_editor_widget.py b/modules/gui/pymod/scene/gradient_editor_widget.py index d4b93071b3e6b0b4085dfb0672ee00baf235e09c..370bd51cd21eb5029e60bee9bf26c05f4fd669ca 100644 --- a/modules/gui/pymod/scene/gradient_editor_widget.py +++ b/modules/gui/pymod/scene/gradient_editor_widget.py @@ -21,22 +21,22 @@ from ost import gui from ost import gfx from ost import mol -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from color_select_widget import ColorSelectWidget from gradient_preset_widget import GradientPresetWidget #Gradient Editor -class GradientEditor(QtGui.QWidget): +class GradientEditor(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.parent_ = parent #Create Ui elements - gradient_label = QtGui.QLabel("Gradient Editor") + gradient_label = QtWidgets.QLabel("Gradient Editor") font = gradient_label.font() font.setBold(True) - self.prop_combo_box_ = QtGui.QComboBox() + self.prop_combo_box_ = QtWidgets.QComboBox() self.gradient_preview_ = GradientPreview() self.gradient_edit_ = GradientEdit(self.gradient_preview_,self) self.gradient_preset_ = GradientPresetWidget(self.gradient_edit_) @@ -51,7 +51,7 @@ class GradientEditor(QtGui.QWidget): self.props=["abfac","rbfac","x","y","z","rnum","acharge"] - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(gradient_label, 0, 0, 1, 1) grid.addWidget(self.prop_combo_box_, 1, 0, 1, 1) @@ -61,9 +61,9 @@ class GradientEditor(QtGui.QWidget): grid.addWidget(self.gradient_preset_, 5, 0, 1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.prop_combo_box_, QtCore.SIGNAL("currentIndexChanged(int)"), self.Update) - QtCore.QObject.connect(self.gradient_edit_, QtCore.SIGNAL("gradientUpdated"), self.Update) - QtCore.QObject.connect(self.gradient_preset_, QtCore.SIGNAL("gradientSelected"), self.gradient_edit_.LoadGradient) + self.prop_combo_box_.currentIndexChanged.connect(self.Update) + self.gradient_edit_.gradientUpdated.connect(self.Update) + self.gradient_preset_.gradientSelected.connect(self.gradient_edit_.LoadGradient) self.setMinimumSize(250,300) @@ -97,14 +97,14 @@ class GradientEditor(QtGui.QWidget): entity.Apply(glco) #Gradient Preview -class GradientPreview(QtGui.QWidget): +class GradientPreview(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Defaults self.border_offset_ = 3 self.preview_height_ = 25 - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.gradient_ = QtGui.QLinearGradient() @@ -129,9 +129,12 @@ class GradientPreview(QtGui.QWidget): paint.end() #Gradient Edit -class GradientEdit(QtGui.QWidget): +class GradientEdit(QtWidgets.QWidget): + + gradientUpdated = QtCore.pyqtSignal() + def __init__(self, gradient_preview, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Defaults self.gradient_preview_ = gradient_preview @@ -143,8 +146,8 @@ class GradientEdit(QtGui.QWidget): #ContextMenu - self.add_ = QtGui.QAction("Add", self) - QtCore.QObject.connect(self.add_, QtCore.SIGNAL("triggered()"), self.Add) + self.add_ = QtWidgets.QAction("Add", self) + self.add_.triggered.connect(self.Add) self.addAction(self.add_) self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) @@ -165,33 +168,34 @@ class GradientEdit(QtGui.QWidget): self.width_ = self.width() def RemoveStop(self, stop): - self.stops.remove(stop) - stop.hide() - del(stop) + self.stops.remove(stop) + stop.hide() + del(stop) - self.UpdateGradient() - self.emit(QtCore.SIGNAL("gradientUpdated"),(self)) + self.UpdateGradient() + self.gradientUpdated.emit() def RemoveStopGui(self, stop): if(len(self.stops)>2): self.RemoveStop(stop) else: - QtGui.QMessageBox.question(self, "Information", "Please keep in mind, at least two stops are needed for a gradient!") + QtWidgets.QMessageBox.question(self, "Information", "Please keep in mind, at least two stops are needed for a gradient!") def AddStop(self, pos, color=None): stop = MyGradientStop(pos, self.border_offset_, self, color) - QtCore.QObject.connect(stop, QtCore.SIGNAL("gradientChanged"), self.UpdateGradient) - QtCore.QObject.connect(stop, QtCore.SIGNAL("colorChanged"), self.UpdateGradient) - QtCore.QObject.connect(stop, QtCore.SIGNAL("colorChanged"), self.parent().Update) - QtCore.QObject.connect(stop, QtCore.SIGNAL("gradientUpdated"), self.parent().Update) - QtCore.QObject.connect(stop, QtCore.SIGNAL("removeStop"), self.RemoveStopGui) + stop.gradientChanged.connect(self.UpdateGradient) + stop.colorChanged.connect(self.UpdateGradient) + stop.colorChanged.connect(self.parent().Update) + stop.gradientUpdated.connect(self.parent().Update) + stop.removeStop.connect(self.RemoveStopGui) + stop.MoveToNewPos() self.stops.append(stop) - self.UpdateGradient() - self.emit(QtCore.SIGNAL("gradientUpdated"),(self)) + self.UpdateGradient() + self.gradientUpdated.emit() def Add(self): - self.AddStop(QtGui.QCursor.pos().x() - self.mapToGlobal(QtCore.QPoint(0, 0)).x()) + self.AddStop(QtWidgets.QCursor.pos().x() - self.mapToGlobal(QtCore.QPoint(0, 0)).x()) def UpdateGradient(self): self.gradient_preview_.SetGradient(self.GetGradient()) @@ -235,6 +239,11 @@ class GradientEdit(QtGui.QWidget): #Gradient Stop class MyGradientStop(ColorSelectWidget): + + removeStop = QtCore.pyqtSignal() + gradientChanged = QtCore.pyqtSignal() + gradientUpdated = QtCore.pyqtSignal() + def __init__(self, pos, offset, parent, color=None): #Defaults self.length_ = 20 @@ -245,8 +254,6 @@ class MyGradientStop(ColorSelectWidget): ColorSelectWidget.__init__(self, self.length_,self.length_, color, parent) - self.MoveToNewPos() - if(color is None): self.color_ = QtGui.QColor("White") self.ChangeColor() @@ -254,12 +261,12 @@ class MyGradientStop(ColorSelectWidget): self.color_ = color #ContextMenu - self.remove_ = QtGui.QAction("Remove", self) - QtCore.QObject.connect(self.remove_, QtCore.SIGNAL("triggered()"), self.Remove) + self.remove_ = QtWidgets.QAction("Remove", self) + self.remove_.triggered.connect(self.Remove) self.addAction(self.remove_) def Remove(self): - self.emit(QtCore.SIGNAL("removeStop"),(self)) + self.removeStop.emit() def GetPos(self): return self.pos_ @@ -279,7 +286,7 @@ class MyGradientStop(ColorSelectWidget): def MoveToNewPos(self): self.move(self.pos_ - self.halflength_, 0) self.update() - self.emit(QtCore.SIGNAL("gradientChanged")) + self.gradientChanged.emit() def mouseMoveEvent(self, event): self.pos_ += event.pos().x() - self.halflength_ @@ -294,4 +301,4 @@ class MyGradientStop(ColorSelectWidget): def mouseReleaseEvent(self, entity): if entity.button() == QtCore.Qt.LeftButton: - self.emit(QtCore.SIGNAL("gradientUpdated")) + self.gradientUpdated.emit() diff --git a/modules/gui/pymod/scene/gradient_info_handler.py b/modules/gui/pymod/scene/gradient_info_handler.py index 951dcd6685ac18a08a15fa6115ff97c8d8730f9b..747b058605f243e20c71310e5383e1f5b2ae3d42 100644 --- a/modules/gui/pymod/scene/gradient_info_handler.py +++ b/modules/gui/pymod/scene/gradient_info_handler.py @@ -21,7 +21,7 @@ from ost import gui from ost import gfx from ost import info -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore from immutable_gradient_info_handler import ImmutableGradientInfoHandler #Gradient Info Handler @@ -57,4 +57,4 @@ class GradientInfoHandler(ImmutableGradientInfoHandler): groupname = group.GetAttribute(self.NAME_ATTRIBUTE_NAME) if old == groupname: group.SetAttribute(self.NAME_ATTRIBUTE_NAME, new) - self.handle_.Export(self.FILE_NAME) \ No newline at end of file + self.handle_.Export(self.FILE_NAME) diff --git a/modules/gui/pymod/scene/gradient_list_model.py b/modules/gui/pymod/scene/gradient_list_model.py index 8e859f4d7e964f92d14a80094314cdcee9de6a30..43f3f95dbdaea38bc37d7c5a6bfdcd75a379d402 100644 --- a/modules/gui/pymod/scene/gradient_list_model.py +++ b/modules/gui/pymod/scene/gradient_list_model.py @@ -2,7 +2,7 @@ from ost import gui from ost import gfx import os import ost -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui from immutable_gradient_info_handler import ImmutableGradientInfoHandler from gradient_info_handler import GradientInfoHandler @@ -11,6 +11,8 @@ class GradientListModel(QtCore.QAbstractListModel): IMMUTABLE_GRADIENTS_PATH = os.path.join(ost.GetSharedDataPath(),"scene", "gradients.xml") MUTABLE_GRADIENTS_PATH = "user_gradients.xml" + + dataChanged = QtCore.pyqtSignal(int, int, name="dataChanged") def __init__(self, parent=None, *args): QtCore.QAbstractListModel.__init__(self, parent, *args) @@ -32,7 +34,7 @@ class GradientListModel(QtCore.QAbstractListModel): end_index = self.createIndex(self.rowCount(),0) if save: self.AddGradientToInfo(gradient,name) - self.emit(QtCore.SIGNAL("dataChanged"),model_index, end_index) + self.dataChanged.emit(model_index, end_index) return True return False @@ -45,7 +47,7 @@ class GradientListModel(QtCore.QAbstractListModel): self.removeRow(row, QtCore.QModelIndex()) model_index = self.createIndex(row,0) self.infoh_.RemoveGradient(name) - self.emit(QtCore.SIGNAL("dataChanged"),model_index, model_index) + self.dataChanged.emit(model_index, model_index) return True return False @@ -115,12 +117,12 @@ class GradientListModel(QtCore.QAbstractListModel): new_name = value.toString() self.data_[row][0] = new_name self.infoh_.RenameGradient(old_name,str(new_name)) - self.emit(QtCore.SIGNAL("dataChanged"),index, index) + self.dataChanged.emit(index, index) return True elif role == QtCore.Qt.DisplayRole: self.data_[row][0] = value.toString() elif role == QtCore.Qt.DecorationRole: - self.dat_[row][2] = value.toPyObject() + self.data_[row][2] = value.toPyObject() return False def flags(self, index): @@ -146,4 +148,4 @@ class GradientListModel(QtCore.QAbstractListModel): - \ No newline at end of file + diff --git a/modules/gui/pymod/scene/gradient_preset_widget.py b/modules/gui/pymod/scene/gradient_preset_widget.py index ebbfc942f0a569ff80e39ee0a31d0d5329985bbc..998714befd2ad9c900d634bfc55f37cfce1873cd 100644 --- a/modules/gui/pymod/scene/gradient_preset_widget.py +++ b/modules/gui/pymod/scene/gradient_preset_widget.py @@ -26,85 +26,88 @@ from ost import info from datetime import datetime from datetime import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui from gradient_info_handler import GradientInfoHandler from gradient_list_model import GradientListModel #Gradient Preset Widget -class GradientPresetWidget(QtGui.QWidget): +class GradientPresetWidget(QtWidgets.QWidget): ICONS_DIR = os.path.join(ost.GetSharedDataPath(), "gui", "icons/") + + gradientSelected = QtCore.pyqtSignal(object, name="gradientSelected") + def __init__(self, gradient_edit, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Title self.text_ = "Gradient Presets" #Refrences - self.gradient_edit_ = gradient_edit - + self.gradient_edit_ = gradient_edit + #Create Ui elements - self.list_view_ = QtGui.QListView() + self.list_view_ = QtWidgets.QListView() #Create Model self.list_model_ = GradientListModel(self) self.list_view_.setModel(self.list_model_) - self.list_view_.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) - preset_label = QtGui.QLabel(self.text_) + preset_label = QtWidgets.QLabel(self.text_) font = preset_label.font() font.setBold(True) - self.add_action = QtGui.QAction("+",self) + self.add_action = QtWidgets.QAction("+",self) self.add_action.setIcon(QtGui.QIcon(GradientPresetWidget.ICONS_DIR+"add_icon.png")) - QtCore.QObject.connect(self.add_action, QtCore.SIGNAL("triggered()"), self.Add) + self.add_action.triggered.connect(self.Add) - self.add_button_ = QtGui.QToolButton(self) + self.add_button_ = QtWidgets.QToolButton(self) self.add_button_.setIconSize(QtCore.QSize(20,20)) self.add_button_.setDefaultAction(self.add_action) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(preset_label, 0, 0, 1, 1) - qhbox = QtGui.QHBoxLayout() + qhbox = QtWidgets.QHBoxLayout() grid.addWidget(self.list_view_,1,0,3,3) grid.addWidget(self.add_button_,4,0,1,1) self.setLayout(grid) self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - QtCore.QObject.connect(self.list_view_, QtCore.SIGNAL("customContextMenuRequested(const QPoint)"), self.contextMenuEvent) + self.list_view_.customContextMenuRequested.connect(self.contextMenuEvent) self.CreateImmutableContextMenu() self.CreateContextMenu() - QtCore.QObject.connect(self.list_view_, QtCore.SIGNAL("doubleClicked(const QModelIndex)"), self.Load) + self.list_view_.doubleClicked.connect(self.Load) def CreateImmutableContextMenu(self): - self.immucontextMenu_ = QtGui.QMenu("Context menu", self) - self.load_ = QtGui.QAction("Load", self.list_view_) + self.immucontextMenu_ = QtWidgets.QMenu("Context menu", self) + self.load_ = QtWidgets.QAction("Load", self.list_view_) self.immucontextMenu_.addAction(self.load_) #Connect Signal with Slot - QtCore.QObject.connect(self.load_, QtCore.SIGNAL("triggered()"), self.LoadCurrentIndex) + self.load_.triggered.connect(self.LoadCurrentIndex) def CreateContextMenu(self): - self.contextMenu_ = QtGui.QMenu("Context menu", self) - self.remove_ = QtGui.QAction("Remove", self.list_view_) - self.rename_ = QtGui.QAction("Rename", self.list_view_) + self.contextMenu_ = QtWidgets.QMenu("Context menu", self) + self.remove_ = QtWidgets.QAction("Remove", self.list_view_) + self.rename_ = QtWidgets.QAction("Rename", self.list_view_) self.contextMenu_.addAction(self.load_) self.contextMenu_.addAction(self.remove_) self.contextMenu_.addAction(self.rename_) #Connect Signals with Slots - QtCore.QObject.connect(self.remove_, QtCore.SIGNAL("triggered()"), self.Remove) - QtCore.QObject.connect(self.rename_, QtCore.SIGNAL("triggered()"), self.Rename) + self.remove_.triggered.connect(self.Remove) + self.rename_.triggered.connect(self.Rename) def contextMenuEvent(self, pos): #ContextMenu index = self.list_view_.indexAt(pos) if index.isValid(): if self.list_model_.IsEditable(index.row()): - self.contextMenu_.popup(QtGui.QCursor.pos()) + self.contextMenu_.popup(QtWidgets.QCursor.pos()) else: - self.immucontextMenu_.popup(QtGui.QCursor.pos()) + self.immucontextMenu_.popup(QtWidgets.QCursor.pos()) def Add(self): if(self.list_view_.currentIndex().isValid()): @@ -115,14 +118,14 @@ class GradientPresetWidget(QtGui.QWidget): self.list_view_.setCurrentIndex(index) self.Rename() else: - QtGui.QMessageBox.information(self, "Gradient not added", "The gradient could not be added!") + QtWidgets.QMessageBox.information(self, "Gradient not added", "The gradient could not be added!") def Remove(self): if(self.list_view_.currentIndex().isValid()): - ret = QtGui.QMessageBox.warning(self, "Delete Gradient", + ret = QtWidgets.QMessageBox.warning(self, "Delete Gradient", "Delete Gradient?", - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) - if ret == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) + if ret == QtWidgets.QMessageBox.Yes: self.list_model_.RemoveItem(self.list_view_.currentIndex().row()) def LoadCurrentIndex(self): @@ -131,7 +134,7 @@ class GradientPresetWidget(QtGui.QWidget): def Load(self, index): if(index.isValid()): - self.emit(QtCore.SIGNAL("gradientSelected"),self.list_model_.GetGradient(index)) + self.gradientSelected.emit(self.list_model_.GetGradient(index)) def Rename(self): if(self.list_view_.currentIndex().isValid()): diff --git a/modules/gui/pymod/scene/hsc_widget.py b/modules/gui/pymod/scene/hsc_widget.py index c67dc97214fdf7531c23b7b703212baf9564e30c..442639a7107e82e1224135ddfa4197e14079c24b 100644 --- a/modules/gui/pymod/scene/hsc_widget.py +++ b/modules/gui/pymod/scene/hsc_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Tube Render Options @@ -59,172 +59,172 @@ class HSCWidget(RenderModeWidget): #########UI########## #Poly Mode - poly_mode_label = QtGui.QLabel("Poly Mode") + poly_mode_label = QtWidgets.QLabel("Poly Mode") - self.poly_mode_cb_ = QtGui.QComboBox() + self.poly_mode_cb_ = QtWidgets.QComboBox() self.poly_mode_cb_.addItem("Points") self.poly_mode_cb_.addItem("Wireframe") self.poly_mode_cb_.addItem("Surface") #Sphere Label - spline_label = QtGui.QLabel("Spline Detail") + spline_label = QtWidgets.QLabel("Spline Detail") - self.spline_spinbox_ = QtGui.QSpinBox() + self.spline_spinbox_ = QtWidgets.QSpinBox() self.spline_spinbox_.setRange(min_spline_detail, max_spline_detail) #Arc Label - arc_label = QtGui.QLabel("Arc Detail") + arc_label = QtWidgets.QLabel("Arc Detail") - self.arc_spinbox_ = QtGui.QSpinBox() + self.arc_spinbox_ = QtWidgets.QSpinBox() self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail) #Tube - tube_label = QtGui.QLabel("Tube") + tube_label = QtWidgets.QLabel("Tube") font = tube_label.font() font.setBold(True) #Tube Radius - radius_tube_label = QtGui.QLabel("Radius") + radius_tube_label = QtWidgets.QLabel("Radius") - self.width_tube_spinbox_ = QtGui.QDoubleSpinBox() + self.width_tube_spinbox_ = QtWidgets.QDoubleSpinBox() self.width_tube_spinbox_.setRange(min_width, max_tube_width) self.width_tube_spinbox_.setDecimals(1) self.width_tube_spinbox_.setSingleStep(0.1) - self.width_tube_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.width_tube_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.width_tube_slider_.setRange(min_width*10.0, max_tube_width*10.0) - self.width_tube_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.width_tube_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.width_tube_slider_.setTickInterval(1) #Tube Ratio - ratio_tube_label = QtGui.QLabel("Ratio") + ratio_tube_label = QtWidgets.QLabel("Ratio") - self.thickness_tube_spinbox_ = QtGui.QDoubleSpinBox() + self.thickness_tube_spinbox_ = QtWidgets.QDoubleSpinBox() self.thickness_tube_spinbox_.setRange(min_tube_ratio, max_tube_ratio) self.thickness_tube_spinbox_.setDecimals(1) self.thickness_tube_spinbox_.setSingleStep(0.1) - self.thickness_tube_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.thickness_tube_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.thickness_tube_slider_.setRange(min_tube_ratio*10.0, max_tube_ratio*10) - self.thickness_tube_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.thickness_tube_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.thickness_tube_slider_.setTickInterval(1) # Tube Profile Type - tube_profile_label = QtGui.QLabel("Tube Profile Type") - self.tube_profile_spinbox_ = QtGui.QSpinBox() + tube_profile_label = QtWidgets.QLabel("Tube Profile Type") + self.tube_profile_spinbox_ = QtWidgets.QSpinBox() self.tube_profile_spinbox_.setRange(min_profile, max_profile) # Helix - helix_label = QtGui.QLabel("Helix") + helix_label = QtWidgets.QLabel("Helix") font = helix_label.font() font.setBold(True) #Helix Radius - radius_helix_label = QtGui.QLabel("Width") + radius_helix_label = QtWidgets.QLabel("Width") - self.width_helix_spinbox_ = QtGui.QDoubleSpinBox() + self.width_helix_spinbox_ = QtWidgets.QDoubleSpinBox() self.width_helix_spinbox_.setRange(min_width, max_width) self.width_helix_spinbox_.setDecimals(1) self.width_helix_spinbox_.setSingleStep(0.1) - self.width_helix_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.width_helix_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.width_helix_slider_.setRange(min_width*10.0, max_width*10.0) - self.width_helix_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.width_helix_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.width_helix_slider_.setTickInterval(1) #Helix Ratio - ratio_helix_label = QtGui.QLabel("Thickness") + ratio_helix_label = QtWidgets.QLabel("Thickness") - self.thickness_helix_spinbox_ = QtGui.QDoubleSpinBox() + self.thickness_helix_spinbox_ = QtWidgets.QDoubleSpinBox() self.thickness_helix_spinbox_.setRange(min_ratio,max_ratio) self.thickness_helix_spinbox_.setDecimals(1) self.thickness_helix_spinbox_.setSingleStep(0.1) - self.thickness_helix_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.thickness_helix_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.thickness_helix_slider_.setRange(min_ratio*10.0,max_ratio*10.0) - self.thickness_helix_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.thickness_helix_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.thickness_helix_slider_.setTickInterval(1) #Helix ECC - ecc_helix_label = QtGui.QLabel("ECC") + ecc_helix_label = QtWidgets.QLabel("ECC") - self.ecc_helix_spinbox_ = QtGui.QDoubleSpinBox() + self.ecc_helix_spinbox_ = QtWidgets.QDoubleSpinBox() self.ecc_helix_spinbox_.setRange(min_ecc,max_ecc) self.ecc_helix_spinbox_.setDecimals(1) self.ecc_helix_spinbox_.setSingleStep(0.1) - self.ecc_helix_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.ecc_helix_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.ecc_helix_slider_.setRange(min_ecc*10,max_ecc*10) - self.ecc_helix_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.ecc_helix_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.ecc_helix_slider_.setTickInterval(1) # Helix Profile Type - helix_profile_label = QtGui.QLabel("Helix Profile Type") - self.helix_profile_spinbox_ = QtGui.QSpinBox() + helix_profile_label = QtWidgets.QLabel("Helix Profile Type") + self.helix_profile_spinbox_ = QtWidgets.QSpinBox() self.helix_profile_spinbox_.setRange(min_profile, max_profile) # Helix Rendering Mode - helix_mode_label = QtGui.QLabel("Helix Render Mode") - self.helix_mode_spinbox_ = QtGui.QSpinBox() + helix_mode_label = QtWidgets.QLabel("Helix Render Mode") + self.helix_mode_spinbox_ = QtWidgets.QSpinBox() self.helix_mode_spinbox_.setRange(0, 1) #Strand - strand_label = QtGui.QLabel("Strand") + strand_label = QtWidgets.QLabel("Strand") font = strand_label.font() font.setBold(1) #Strand Radius - radius_strand_label = QtGui.QLabel("Width") + radius_strand_label = QtWidgets.QLabel("Width") - self.width_strand_spinbox_ = QtGui.QDoubleSpinBox() + self.width_strand_spinbox_ = QtWidgets.QDoubleSpinBox() self.width_strand_spinbox_.setRange(min_width, max_width) self.width_strand_spinbox_.setDecimals(1) self.width_strand_spinbox_.setSingleStep(0.1) - self.width_strand_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.width_strand_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.width_strand_slider_.setRange(min_width*10, max_width*10) - self.width_strand_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.width_strand_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.width_strand_slider_.setTickInterval(1) #Strand Ratio - ratio_strand_label = QtGui.QLabel("Thickness") + ratio_strand_label = QtWidgets.QLabel("Thickness") - self.thickness_strand_spinbox_ = QtGui.QDoubleSpinBox() + self.thickness_strand_spinbox_ = QtWidgets.QDoubleSpinBox() self.thickness_strand_spinbox_.setRange(min_ratio,max_ratio) self.thickness_strand_spinbox_.setDecimals(1) self.thickness_strand_spinbox_.setSingleStep(0.1) - self.thickness_strand_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.thickness_strand_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.thickness_strand_slider_.setRange(min_ratio*10,max_ratio*10) - self.thickness_strand_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.thickness_strand_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.thickness_strand_slider_.setTickInterval(1) #Strand ECC - ecc_strand_label = QtGui.QLabel("ECC") + ecc_strand_label = QtWidgets.QLabel("ECC") - self.ecc_strand_spinbox_ = QtGui.QDoubleSpinBox() + self.ecc_strand_spinbox_ = QtWidgets.QDoubleSpinBox() self.ecc_strand_spinbox_.setRange(min_ecc,max_ecc) self.ecc_strand_spinbox_.setDecimals(1) self.ecc_strand_spinbox_.setSingleStep(0.1) - self.ecc_strand_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.ecc_strand_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.ecc_strand_slider_.setRange(min_ecc*10,max_ecc*10) - self.ecc_strand_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.ecc_strand_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.ecc_strand_slider_.setTickInterval(1) # Strand Profile Type - strand_profile_label = QtGui.QLabel("Strand Profile Type") - self.strand_profile_spinbox_ = QtGui.QSpinBox() + strand_profile_label = QtWidgets.QLabel("Strand Profile Type") + self.strand_profile_spinbox_ = QtWidgets.QSpinBox() self.strand_profile_spinbox_.setRange(min_profile, max_profile) # Strand Rendering Mode - strand_mode_label = QtGui.QLabel("Strand Render Mode") - self.strand_mode_spinbox_ = QtGui.QSpinBox() + strand_mode_label = QtWidgets.QLabel("Strand Render Mode") + self.strand_mode_spinbox_ = QtWidgets.QSpinBox() self.strand_mode_spinbox_.setRange(0, 1) # row=1 - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(poly_mode_label,row,0,1,1) grid.addWidget(self.poly_mode_cb_,row,3,1,2) row+=1 @@ -290,33 +290,33 @@ class HSCWidget(RenderModeWidget): grid.setRowStretch(row+1,1) self.setLayout(grid) - QtCore.QObject.connect(self.spline_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSplineDetail) - QtCore.QObject.connect(self.arc_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateArcDetail) - QtCore.QObject.connect(self.poly_mode_cb_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdatePolyMode) - - QtCore.QObject.connect(self.width_tube_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateTubeRadius) - QtCore.QObject.connect(self.width_tube_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderTubeRadius) - QtCore.QObject.connect(self.thickness_tube_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateTubeRatio) - QtCore.QObject.connect(self.thickness_tube_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderTubeRatio) - QtCore.QObject.connect(self.tube_profile_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateTubeProfileType) - - QtCore.QObject.connect(self.width_helix_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateHelixWidth) - QtCore.QObject.connect(self.width_helix_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderHelixWidth) - QtCore.QObject.connect(self.thickness_helix_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateHelixThickness) - QtCore.QObject.connect(self.thickness_helix_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderHelixThickness) - QtCore.QObject.connect(self.ecc_helix_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateHelixEcc) - QtCore.QObject.connect(self.ecc_helix_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderHelixEcc) - QtCore.QObject.connect(self.helix_profile_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateHelixProfileType) - QtCore.QObject.connect(self.helix_mode_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateHelixMode) + self.spline_spinbox_.valueChanged.connect(self.UpdateSplineDetail) + self.arc_spinbox_.valueChanged.connect(self.UpdateArcDetail) + self.poly_mode_cb_.currentIndexChanged.connect(self.UpdatePolyMode) + + self.width_tube_spinbox_.valueChanged.connect(self.UpdateTubeRadius) + self.width_tube_slider_.valueChanged.connect(self.UpdateSliderTubeRadius) + self.thickness_tube_spinbox_.valueChanged.connect(self.UpdateTubeRatio) + self.thickness_tube_slider_.valueChanged.connect(self.UpdateSliderTubeRatio) + self.tube_profile_spinbox_.valueChanged.connect(self.UpdateTubeProfileType) + + self.width_helix_spinbox_.valueChanged.connect(self.UpdateHelixWidth) + self.width_helix_slider_.valueChanged.connect(self.UpdateSliderHelixWidth) + self.thickness_helix_spinbox_.valueChanged.connect(self.UpdateHelixThickness) + self.thickness_helix_slider_.valueChanged.connect(self.UpdateSliderHelixThickness) + self.ecc_helix_spinbox_.valueChanged.connect(self.UpdateHelixEcc) + self.ecc_helix_slider_.valueChanged.connect(self.UpdateSliderHelixEcc) + self.helix_profile_spinbox_.valueChanged.connect(self.UpdateHelixProfileType) + self.helix_mode_spinbox_.valueChanged.connect(self.UpdateHelixMode) - QtCore.QObject.connect(self.width_strand_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateStrandWidth) - QtCore.QObject.connect(self.width_strand_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderStrandWidth) - QtCore.QObject.connect(self.thickness_strand_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateStrandThickness) - QtCore.QObject.connect(self.thickness_strand_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderStrandThickness) - QtCore.QObject.connect(self.ecc_strand_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateStrandEcc) - QtCore.QObject.connect(self.ecc_strand_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderStrandEcc) - QtCore.QObject.connect(self.strand_profile_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateStrandProfileType) - QtCore.QObject.connect(self.strand_mode_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateStrandMode) + self.width_strand_spinbox_.valueChanged.connect(self.UpdateStrandWidth) + self.width_strand_slider_.valueChanged.connect(self.UpdateSliderStrandWidth) + self.thickness_strand_spinbox_.valueChanged.connect(self.UpdateStrandThickness) + self.thickness_strand_slider_.valueChanged.connect(self.UpdateSliderStrandThickness) + self.ecc_strand_spinbox_.valueChanged.connect(self.UpdateStrandEcc) + self.ecc_strand_slider_.valueChanged.connect(self.UpdateSliderStrandEcc) + self.strand_profile_spinbox_.valueChanged.connect(self.UpdateStrandProfileType) + self.strand_mode_spinbox_.valueChanged.connect(self.UpdateStrandMode) self.setMinimumSize(250,550) ########/UI######## diff --git a/modules/gui/pymod/scene/immutable_gradient_info_handler.py b/modules/gui/pymod/scene/immutable_gradient_info_handler.py index c70b041e9bfa3818a2c8df552f7cde9b241029dd..65ecf0d9c935f129ffe08f47f122d48f426055d0 100644 --- a/modules/gui/pymod/scene/immutable_gradient_info_handler.py +++ b/modules/gui/pymod/scene/immutable_gradient_info_handler.py @@ -21,7 +21,7 @@ from ost import gui from ost import gfx from ost import info -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui #Gradient Editor class ImmutableGradientInfoHandler: diff --git a/modules/gui/pymod/scene/immutable_info_handler.py b/modules/gui/pymod/scene/immutable_info_handler.py index 600fd393dbec78da4d28a3f2c8718dda9d1adf89..e766c840267f60300567351728a4d748c229eb2c 100644 --- a/modules/gui/pymod/scene/immutable_info_handler.py +++ b/modules/gui/pymod/scene/immutable_info_handler.py @@ -21,7 +21,7 @@ from ost import gui from ost import gfx from ost import info -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets #Gradient Editor class ImmutableInfoHandler: @@ -50,13 +50,13 @@ class ImmutableInfoHandler: def ConvertToQGradient(self, gfxGradient): stops = gfxGradient.GetStops() - qgrad = QtGui.QLinearGradient() + qgrad = QtWidgets.QLinearGradient() for stop in stops: color = stop.GetColor() - qcolor = QtGui.QColor(color.Red()*255, - color.Green()*255, - color.Blue()*255, - color.Alpha()*255) + qcolor = QtWidgets.QColor(color.Red()*255, + color.Green()*255, + color.Blue()*255, + color.Alpha()*255) qgrad.setColorAt(stop.GetRel(), qcolor) return qgrad diff --git a/modules/gui/pymod/scene/immutable_preset_info_handler.py b/modules/gui/pymod/scene/immutable_preset_info_handler.py index 5b1fb7c12f6049b8cfbc0ccd2d844eb29199a0b6..83dd1c741bee02f4560bf152b59cec6eeef22dc0 100644 --- a/modules/gui/pymod/scene/immutable_preset_info_handler.py +++ b/modules/gui/pymod/scene/immutable_preset_info_handler.py @@ -21,7 +21,6 @@ from ost import gui from ost import gfx from ost import info -from PyQt4 import QtCore, QtGui from ost.gui.scene.preset import Preset #Gradient Editor diff --git a/modules/gui/pymod/scene/init_inspector.py b/modules/gui/pymod/scene/init_inspector.py index 72b35454d8ef65dae3e3511341ff08ded5d70d9f..0e2803daea72e4ab6f4dd7b86a65e5025c4412a1 100644 --- a/modules/gui/pymod/scene/init_inspector.py +++ b/modules/gui/pymod/scene/init_inspector.py @@ -21,7 +21,7 @@ import sip from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore from ost.gui.scene.inspector_widget import InspectorDialog def _InitInspector(app): diff --git a/modules/gui/pymod/scene/inspector_widget.py b/modules/gui/pymod/scene/inspector_widget.py index 4a976841ba8e20939418df3cb08b384e668f1369..503d3acdceddf27afb5248f5d842706a66e530a6 100644 --- a/modules/gui/pymod/scene/inspector_widget.py +++ b/modules/gui/pymod/scene/inspector_widget.py @@ -23,7 +23,7 @@ import sip from ost import gfx import ost import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from toolbar_options_widget import ToolBarOptionsWidget from render_options_widget import RenderOptionsWidget from color_options_widget import ColorOptionsWidget @@ -48,8 +48,7 @@ class InspectorWidget(ToolBarOptionsWidget): self.obs = SceneObserverImpl() self.obs.AttachObserver(self) ost.scene.AttachObserver(self.obs) - QtCore.QObject.connect(app.scene_win.qobject,QtCore.SIGNAL("ActiveNodesChanged()"), - self.ActiveNodesChanged) + app.scene_win.qobject.ActiveNodesChanged.connect(self.ActiveNodesChanged) self.setMinimumSize(250,215) #ToolBarOptionsWidget Method @@ -73,19 +72,22 @@ class InspectorWidget(ToolBarOptionsWidget): SelHelper().Update() ToolBarOptionsWidget.Update(self) -class InspectorDialog(QtGui.QDialog): +class InspectorDialog(QtWidgets.QDialog): + + visible = QtCore.pyqtSignal(bool, name="visible") + def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle("Inspector Gadget") self.setAttribute(QtCore.Qt.WA_MacSmallSize) - self.layout=QtGui.QHBoxLayout() - self.layout.setMargin(0) + self.layout=QtWidgets.QHBoxLayout() + self.layout.setContentsMargins(0,0,0,0) self.layout.setSpacing(0) self.setLayout(self.layout) self.mywidget_ = InspectorWidget(self) self.layout.addWidget(self.mywidget_) - size_pol = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, - QtGui.QSizePolicy.Expanding) + size_pol = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, + QtWidgets.QSizePolicy.Expanding) self.setSizePolicy(size_pol) self.DoResize() @@ -100,9 +102,9 @@ class InspectorDialog(QtGui.QDialog): self.setHidden(not self.isHidden()) def hideEvent(self, event): - self.emit(QtCore.SIGNAL("visible"),False) - QtGui.QDialog.hideEvent(self,event) + self.visible.emit(False) + QtWidgets.QDialog.hideEvent(self,event) def showEvent(self, event): - self.emit(QtCore.SIGNAL("visible"),True) - QtGui.QDialog.showEvent(self,event) \ No newline at end of file + self.visible.emit(True) + QtWidgets.QDialog.showEvent(self,event) diff --git a/modules/gui/pymod/scene/line_trace_widget.py b/modules/gui/pymod/scene/line_trace_widget.py index 5b1133e729d94bb355519b62a50340648fed30b5..569f6dfcc904cce41a41e0177000e685c6b99f05 100644 --- a/modules/gui/pymod/scene/line_trace_widget.py +++ b/modules/gui/pymod/scene/line_trace_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Simple Render Options @@ -39,20 +39,20 @@ class LineTraceWidget(RenderModeWidget): max_line_width = 20 #Create Ui elements - self.radius_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_spinbox_.setRange(min_line_width, max_line_width) self.radius_spinbox_.setDecimals(2) self.radius_spinbox_.setSingleStep(0.1) - self.aa_rendering_cb_ = QtGui.QCheckBox() + self.aa_rendering_cb_ = QtWidgets.QCheckBox() - sline_label = QtGui.QLabel("Trace Settings") + sline_label = QtWidgets.QLabel("Trace Settings") font = sline_label.font() font.setBold(True) - radius_label = QtGui.QLabel("Line Width") - aa_label = QtGui.QLabel("AA-Lines") - grid = QtGui.QGridLayout() + radius_label = QtWidgets.QLabel("Line Width") + aa_label = QtWidgets.QLabel("AA-Lines") + grid = QtWidgets.QGridLayout() grid.addWidget(sline_label, 0, 0, 1, 1) grid.addWidget(radius_label, 1, 0, 1, 3) grid.addWidget(self.radius_spinbox_, 1, 2, 1, 1) @@ -61,12 +61,8 @@ class LineTraceWidget(RenderModeWidget): grid.setRowStretch(3,1) self.setLayout(grid) - QtCore.QObject.connect(self.radius_spinbox_, - QtCore.SIGNAL("valueChanged(double)"), - self.UpdateLineWidth) - QtCore.QObject.connect(self.aa_rendering_cb_, - QtCore.SIGNAL("stateChanged(int)"), - self.UpdateAA) + self.radius_spinbox_.valueChanged.connect(self.UpdateLineWidth) + self.aa_rendering_cb_.stateChanged.connect(self.UpdateAA) self.setMinimumSize(250,90) diff --git a/modules/gui/pymod/scene/map_level_widget.py b/modules/gui/pymod/scene/map_level_widget.py index 02851b76146c1e106c79688e691df8765d8d8dd9..b5c0905de1472dc4dbef3d122caaa3cda608074b 100644 --- a/modules/gui/pymod/scene/map_level_widget.py +++ b/modules/gui/pymod/scene/map_level_widget.py @@ -26,13 +26,13 @@ try: except ImportError: _img_present=False pass -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from preset_widget import PresetWidget -class AdditionalSettingsWidget(QtGui.QStackedWidget): +class AdditionalSettingsWidget(QtWidgets.QStackedWidget): def __init__(self, parent=None): - QtGui.QStackedWidget.__init__(self, parent) + QtWidgets.QStackedWidget.__init__(self, parent) self.map_widget_ = MapLevelWidget(self) self.preset_widget_ = PresetWidget(self) self.addWidget(self.preset_widget_); @@ -67,22 +67,22 @@ class AdditionalSettingsWidget(QtGui.QStackedWidget): self.setEnabled(False) #Map Level Widget -class MapLevelWidget(QtGui.QWidget): +class MapLevelWidget(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Create Ui elements - self.map_level_label_ = QtGui.QLabel("Map Contour Level") + self.map_level_label_ = QtWidgets.QLabel("Map Contour Level") self.font = self.map_level_label_.font() self.font.setBold(True) self.level_preview_ = LevelPreview() - self.level_spinbox_ = QtGui.QDoubleSpinBox() + self.level_spinbox_ = QtWidgets.QDoubleSpinBox() self.level_spinbox_.setDecimals(3) self.level_spinbox_.setSingleStep(0.05) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.level_preview_, 0, 0, 1, 4) grid.addWidget(self.map_level_label_, 1, 0, 1, 3) @@ -90,9 +90,9 @@ class MapLevelWidget(QtGui.QWidget): grid.setRowStretch(3, 1) self.setLayout(grid) - QtCore.QObject.connect(self.level_preview_, QtCore.SIGNAL("levelUpdated"), self.UpdateLevel) - QtCore.QObject.connect(self.level_preview_, QtCore.SIGNAL("levelModified"), self.ModifySpinBox) - QtCore.QObject.connect(self.level_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLevel) + self.level_preview_.levelUpdated.connect(self.UpdateLevel) + self.level_preview_.levelModified.connect(self.ModifySpinBox) + self.level_spinbox_.valueChanged.connect(self.UpdateLevel) self.setMinimumSize(250,200) @@ -129,19 +129,23 @@ class MapLevelWidget(QtGui.QWidget): node.SetLevel(level) def ModifySpinBox(self, level): - QtCore.QObject.disconnect(self.level_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLevel) + self.level_spinbox_.valueChanged.disconnect(self.UpdateLevel) self.level_spinbox_.setValue(level) - QtCore.QObject.connect(self.level_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLevel) + self.level_spinbox_.valueChanged.connect(self.UpdateLevel) #Level Preview -class LevelPreview(QtGui.QWidget): +class LevelPreview(QtWidgets.QWidget): + + levelUpdated = QtCore.pyqtSignal(int, name="levelUpdated") + levelModified = QtCore.pyqtSignal(int, name="levelModified") + def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Defaults self.border_offset_ = 3 self.preview_height_ = 150 - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Ui self.setMinimumSize(0, self.preview_height_ + 4) @@ -171,7 +175,7 @@ class LevelPreview(QtGui.QWidget): def paintEvent(self, event): if self.isEnabled() and self.bins_ is not None: - painter = QtGui.QPainter() + painter = QtWidgets.QPainter() if painter.begin(self): self.PaintBackground(painter) self.PaintBins(painter) @@ -228,7 +232,7 @@ class LevelPreview(QtGui.QWidget): width = size.width()-(2* self.border_offset_) painter.setBrush(QtCore.Qt.gray) painter.setPen(QtCore.Qt.gray) - pos=self.mapFromGlobal(QtGui.QCursor.pos()) + pos=self.mapFromGlobal(QtWidgets.QCursor.pos()) painter.drawRect(pos.x(), self.border_offset_, 1, @@ -241,7 +245,7 @@ class LevelPreview(QtGui.QWidget): tot_len = self.maximum_-self.minimum_ self.level_ = self.minimum_ + float(event.x())/width * tot_len self.update() - self.emit(QtCore.SIGNAL("levelUpdated"),(self.level_)) + self.levelUpdated.emit(self.level_) def mousePressEvent(self,event): self.paint_mouse_=True @@ -251,5 +255,5 @@ class LevelPreview(QtGui.QWidget): width = size.width()-(2* self.border_offset_) tot_len = self.maximum_-self.minimum_ level = self.minimum_ + float(event.x())/width * tot_len - self.emit(QtCore.SIGNAL("levelModified"),(level)) - self.update() \ No newline at end of file + self.levelModified.emit(level) + self.update() diff --git a/modules/gui/pymod/scene/preset.py b/modules/gui/pymod/scene/preset.py index 4628f8248df0e7c96939a94b7580069a7beb2f47..279765d7cb6f609c93a44a68e4ccdb02c66b6620 100644 --- a/modules/gui/pymod/scene/preset.py +++ b/modules/gui/pymod/scene/preset.py @@ -20,7 +20,6 @@ from ost import info from ost import gfx -from PyQt4 import QtGui from ost.gfx import ColorOp diff --git a/modules/gui/pymod/scene/preset_editor_list_model.py b/modules/gui/pymod/scene/preset_editor_list_model.py index a30fc13c31f098081f587978d9c0039110fcec42..35fac9836008178d43be9e80849bcbdc907f8249 100644 --- a/modules/gui/pymod/scene/preset_editor_list_model.py +++ b/modules/gui/pymod/scene/preset_editor_list_model.py @@ -2,7 +2,7 @@ from ost import gui from ost import gfx import os import ost -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore from preset import Preset class PresetEditorListModel(QtCore.QAbstractListModel): diff --git a/modules/gui/pymod/scene/preset_editor_widget.py b/modules/gui/pymod/scene/preset_editor_widget.py index 97d7e7723d07284033826560317ae7f17f6657c5..c5a314efb6129d1db2d3b24d7b1da9f326d9c034 100644 --- a/modules/gui/pymod/scene/preset_editor_widget.py +++ b/modules/gui/pymod/scene/preset_editor_widget.py @@ -23,7 +23,7 @@ from ost import gfx from ost import mol from datetime import datetime from datetime import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui from color_select_widget import ColorSelectWidget from gradient_preset_widget import GradientPresetWidget from gradient_editor_widget import GradientPreview @@ -41,16 +41,16 @@ from render_op import RenderOp from visibility_op import VisibilityOp #Preset Editor -class PresetEditor(QtGui.QDialog): +class PresetEditor(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle("Preset Editor") #Create Ui Elements - self.list_view_ = QtGui.QListView() + self.list_view_ = QtWidgets.QListView() - self.combo_box_ = QtGui.QComboBox() + self.combo_box_ = QtWidgets.QComboBox() self.ufcow_=UniformColorOpWidget(self) self.glcow_=GradientLevelColorOpWidget(self) @@ -65,22 +65,22 @@ class PresetEditor(QtGui.QDialog): self.combo_box_.addItem("RenderMode Operation", QtCore.QVariant(self.row_)) self.combo_box_.addItem("Visibility Operation", QtCore.QVariant(self.vow_)) - self.add_button_ = QtGui.QPushButton("Add") + self.add_button_ = QtWidgets.QPushButton("Add") #Create Model - self.list_view_.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - QtCore.QObject.connect(self.list_view_, QtCore.SIGNAL("customContextMenuRequested(const QPoint)"), self.contextMenuEvent) + self.list_view_.customContextMenuRequested.connect(self.contextMenuEvent) - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.combo_box_,0,0,1,1) grid.addWidget(self.add_button_,0,1,1,1) @@ -89,9 +89,9 @@ class PresetEditor(QtGui.QDialog): grid.setRowStretch(1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.add_button_, QtCore.SIGNAL("clicked()"), self.Add) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) + self.add_button_.clicked.connect(self.Add) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) self.CreateContextMenu() @@ -100,26 +100,26 @@ class PresetEditor(QtGui.QDialog): self.list_view_.setModel(self.list_model_) def CreateContextMenu(self): - self.context_menu_ = QtGui.QMenu("Context menu", self) - self.edit_ = QtGui.QAction("Edit", self.list_view_) - self.remove_ = QtGui.QAction("Remove", self.list_view_) - self.moveup_ = QtGui.QAction("Move Up", self.list_view_) - self.movedown_ = QtGui.QAction("Move Down", self.list_view_) + self.context_menu_ = QtWidgets.QMenu("Context menu", self) + self.edit_ = QtWidgets.QAction("Edit", self.list_view_) + self.remove_ = QtWidgets.QAction("Remove", self.list_view_) + self.moveup_ = QtWidgets.QAction("Move Up", self.list_view_) + self.movedown_ = QtWidgets.QAction("Move Down", self.list_view_) self.context_menu_.addAction(self.edit_) self.context_menu_.addAction(self.remove_) self.context_menu_.addAction(self.moveup_) self.context_menu_.addAction(self.movedown_) #Connect Signals with Slots - QtCore.QObject.connect(self.edit_, QtCore.SIGNAL("triggered()"), self.Edit) - QtCore.QObject.connect(self.remove_, QtCore.SIGNAL("triggered()"), self.Remove) - QtCore.QObject.connect(self.moveup_, QtCore.SIGNAL("triggered()"), self.MoveUp) - QtCore.QObject.connect(self.movedown_, QtCore.SIGNAL("triggered()"), self.MoveDown) + self.edit_.triggered.connect(self.Edit) + self.remove_.triggered.connect(self.Remove) + self.moveup_.triggered.connect(self.MoveUp) + self.movedown_.triggered.connect(self.MoveDown) def contextMenuEvent(self, pos): #ContextMenu index = self.list_view_.indexAt(pos) if index.isValid(): - self.context_menu_.popup(QtGui.QCursor.pos()) + self.context_menu_.popup(QtWidgets.QCursor.pos()) def Add(self): dialog = self.combo_box_.itemData(self.combo_box_.currentIndex()).toPyObject() @@ -180,29 +180,29 @@ class PresetEditor(QtGui.QDialog): def Cancel(self): self.reject() -class UniformColorOpWidget(QtGui.QDialog): +class UniformColorOpWidget(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.query_editor_ = QueryEditorWidget(self) - detail_label = QtGui.QLabel("Parts") - self.detail_selection_cb_ = QtGui.QComboBox() + detail_label = QtWidgets.QLabel("Parts") + self.detail_selection_cb_ = QtWidgets.QComboBox() self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3)) self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2)) self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1)) - color_label = QtGui.QLabel("Color") + color_label = QtWidgets.QLabel("Color") self.color_select_widget_ = ColorSelectWidget(30,30,QtGui.QColor("White")) - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.query_editor_, 0, 0, 1, 2) grid.addWidget(detail_label, 1, 0, 1, 1) @@ -213,8 +213,8 @@ class UniformColorOpWidget(QtGui.QDialog): grid.setRowStretch(2, 1) self.setLayout(grid) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) def GetOp(self): qv=mol.QueryViewWrapper(self.query_editor_.GetQuery(),self.query_editor_.GetQueryFlags()) @@ -250,22 +250,22 @@ class UniformColorOpWidget(QtGui.QDialog): def Cancel(self): self.reject() -class GradientLevelColorOpWidget(QtGui.QDialog): +class GradientLevelColorOpWidget(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.query_editor_ = QueryEditorWidget(self) - detail_label = QtGui.QLabel("Parts") - self.detail_selection_cb_ = QtGui.QComboBox() + detail_label = QtWidgets.QLabel("Parts") + self.detail_selection_cb_ = QtWidgets.QComboBox() self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3)) self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2)) self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1)) - property_label = QtGui.QLabel("Property") - self.property_edit_ = QtGui.QLineEdit() + property_label = QtWidgets.QLabel("Property") + self.property_edit_ = QtWidgets.QLineEdit() - self.prop_combo_box_ = QtGui.QComboBox() + self.prop_combo_box_ = QtWidgets.QComboBox() self.prop_combo_box_.addItem("atom B-factor",QtCore.QVariant("abfac")) self.prop_combo_box_.addItem("average residue B-factor",QtCore.QVariant("rbfac")) self.prop_combo_box_.addItem("X-Coordinate",QtCore.QVariant("x")) @@ -276,42 +276,42 @@ class GradientLevelColorOpWidget(QtGui.QDialog): self.prop_combo_box_.addItem("Custom",QtCore.QVariant("custom")) - level_label = QtGui.QLabel("Level") - self.combo_box_ = QtGui.QComboBox(self); + level_label = QtWidgets.QLabel("Level") + self.combo_box_ = QtWidgets.QComboBox(self); self.combo_box_.addItem("Atom",QtCore.QVariant(Prop.Level.ATOM)) self.combo_box_.addItem("Residue",QtCore.QVariant(Prop.Level.RESIDUE)) self.combo_box_.addItem("Chain",QtCore.QVariant(Prop.Level.CHAIN)) self.combo_box_.addItem("Unspecified",QtCore.QVariant(Prop.Level.UNSPECIFIED)) - gradient_label = QtGui.QLabel("Gradient") + gradient_label = QtWidgets.QLabel("Gradient") self.gradient_preview_ = GradientPreview() self.gradient_edit_ = GradientEdit(self.gradient_preview_,self) - self.minmax_label_ = QtGui.QLabel("Min Max") - self.auto_calc_ = QtGui.QCheckBox("Auto calculate") + self.minmax_label_ = QtWidgets.QLabel("Min Max") + self.auto_calc_ = QtWidgets.QCheckBox("Auto calculate") self.auto_calc_.setChecked(True) - self.minv_label_ = QtGui.QLabel("Min Value") - self.maxv_label_ = QtGui.QLabel("Max Value") + self.minv_label_ = QtWidgets.QLabel("Min Value") + self.maxv_label_ = QtWidgets.QLabel("Max Value") - self.minv_ = QtGui.QDoubleSpinBox(self) + self.minv_ = QtWidgets.QDoubleSpinBox(self) self.minv_.setDecimals(2) self.minv_.setMinimum(-9999.99) self.minv_.setValue(0) - self.maxv_ = QtGui.QDoubleSpinBox(self) + self.maxv_ = QtWidgets.QDoubleSpinBox(self) self.maxv_.setDecimals(2) self.maxv_.setValue(1) self.maxv_.setMinimum(-9999.99) - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.query_editor_, 0, 0, 1, 2) grid.addWidget(detail_label, 1, 0, 1, 1) @@ -335,10 +335,10 @@ class GradientLevelColorOpWidget(QtGui.QDialog): grid.setRowStretch(1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.prop_combo_box_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdateGui) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) - QtCore.QObject.connect(self.auto_calc_, QtCore.SIGNAL("stateChanged (int)"), self.UpdateGui) + self.prop_combo_box_.currentIndexChanged.connect(self.UpdateGui) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) + self.auto_calc_.stateChanged.connect(self.UpdateGui) self.UpdateGui() @@ -395,7 +395,7 @@ class GradientLevelColorOpWidget(QtGui.QDialog): self.UpdateGui() def UpdateGui(self): - prop = self.prop_combo_box_.itemData(self.prop_combo_box_.currentIndex()).toPyObject() + prop = str(self.prop_combo_box_.itemData(self.prop_combo_box_.currentIndex())) if(prop == "custom"): self.combo_box_.setEnabled(True) self.property_edit_.setEnabled(True) @@ -419,25 +419,25 @@ class GradientLevelColorOpWidget(QtGui.QDialog): def Update(self): pass #Do Nothing -class ByElementColorOpWidget(QtGui.QDialog): +class ByElementColorOpWidget(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.query_editor_ = QueryEditorWidget(self) - detail_label = QtGui.QLabel("Parts") - self.detail_selection_cb_ = QtGui.QComboBox() + detail_label = QtWidgets.QLabel("Parts") + self.detail_selection_cb_ = QtWidgets.QComboBox() self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3)) self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2)) self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1)) - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.query_editor_, 0, 0, 1, 2) grid.addWidget(detail_label, 1, 0, 1, 1) @@ -446,8 +446,8 @@ class ByElementColorOpWidget(QtGui.QDialog): grid.setRowStretch(1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) def GetOp(self): detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject() @@ -475,25 +475,25 @@ class ByElementColorOpWidget(QtGui.QDialog): self.reject() -class ByChainColorOpWidget(QtGui.QDialog): +class ByChainColorOpWidget(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.query_editor_ = QueryEditorWidget(self) - detail_label = QtGui.QLabel("Parts") - self.detail_selection_cb_ = QtGui.QComboBox() + detail_label = QtWidgets.QLabel("Parts") + self.detail_selection_cb_ = QtWidgets.QComboBox() self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3)) self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2)) self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1)) - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.query_editor_, 0, 0, 1, 2) grid.addWidget(detail_label, 1, 0, 1, 1) @@ -502,8 +502,8 @@ class ByChainColorOpWidget(QtGui.QDialog): grid.setRowStretch(1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) def GetOp(self): detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject() @@ -531,16 +531,16 @@ class ByChainColorOpWidget(QtGui.QDialog): self.reject() -class RenderOpWidget(QtGui.QDialog): +class RenderOpWidget(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.query_editor_ = QueryEditorWidget(self) - self.keep_ = QtGui.QCheckBox("Keep") + self.keep_ = QtWidgets.QCheckBox("Keep") self.keep_.setChecked(False) - render_label = QtGui.QLabel("Rendermode") - self.render_modes_ = QtGui.QComboBox() + render_label = QtWidgets.QLabel("Rendermode") + self.render_modes_ = QtWidgets.QComboBox() self.render_modes_.addItem("Fast Bonds") self.render_modes_.addItem("Ball & Stick") self.render_modes_.addItem("Spheres") @@ -559,14 +559,14 @@ class RenderOpWidget(QtGui.QDialog): gfx.RenderMode.TUBE, gfx.RenderMode.HSC] - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.query_editor_, 0, 0, 1, 2) grid.addWidget(self.keep_, 1, 1, 1, 1) @@ -576,8 +576,8 @@ class RenderOpWidget(QtGui.QDialog): grid.setRowStretch(1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) def GetOp(self): selection = self.query_editor_.GetQueryText() @@ -606,22 +606,22 @@ class RenderOpWidget(QtGui.QDialog): def Cancel(self): self.reject() -class VisibilityOpWidget(QtGui.QDialog): +class VisibilityOpWidget(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.query_editor_ = QueryEditorWidget(self) - self.visible_ = QtGui.QCheckBox("Visible") + self.visible_ = QtWidgets.QCheckBox("Visible") self.visible_.setChecked(True) - self.hbox_ = QtGui.QHBoxLayout() - self.ok_button_ = QtGui.QPushButton("OK") - self.cancel_button_ = QtGui.QPushButton("Cancel") + self.hbox_ = QtWidgets.QHBoxLayout() + self.ok_button_ = QtWidgets.QPushButton("OK") + self.cancel_button_ = QtWidgets.QPushButton("Cancel") self.hbox_.addWidget(self.ok_button_) self.hbox_.addStretch() self.hbox_.addWidget(self.cancel_button_) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.query_editor_, 0, 0, 1, 2) grid.addWidget(self.visible_, 1, 1, 1, 1) @@ -629,8 +629,8 @@ class VisibilityOpWidget(QtGui.QDialog): grid.setRowStretch(1, 1) self.setLayout(grid) - QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok) - QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel) + self.ok_button_.clicked.connect(self.Ok) + self.cancel_button_.clicked.connect(self.Cancel) def GetOp(self): selection = self.query_editor_.GetQueryText() diff --git a/modules/gui/pymod/scene/preset_info_handler.py b/modules/gui/pymod/scene/preset_info_handler.py index ba77aaff877b1b4e9178cf234becc2669e5282f8..25237b3bd96072905b4578791d1177b71614345e 100644 --- a/modules/gui/pymod/scene/preset_info_handler.py +++ b/modules/gui/pymod/scene/preset_info_handler.py @@ -21,7 +21,6 @@ from ost import gui from ost import gfx from ost import info -from PyQt4 import QtCore, QtGui from immutable_preset_info_handler import ImmutablePresetInfoHandler #Preset Info Handler @@ -55,4 +54,4 @@ class PresetInfoHandler(ImmutablePresetInfoHandler): groupname = group.GetAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME) if old == groupname: group.SetAttribute(ImmutablePresetInfoHandler.NAME_ATTRIBUTE_NAME, new) - self.handle_.Export(self.file_name_) \ No newline at end of file + self.handle_.Export(self.file_name_) diff --git a/modules/gui/pymod/scene/preset_list_model.py b/modules/gui/pymod/scene/preset_list_model.py index c35aa453f84ae45610933f91edbaea3bed3f0c9a..dbe1926ade00e007ccffa8fb051d4a5f4730b81d 100644 --- a/modules/gui/pymod/scene/preset_list_model.py +++ b/modules/gui/pymod/scene/preset_list_model.py @@ -2,15 +2,16 @@ from ost import gui from ost import gfx import os import ost -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui from immutable_preset_info_handler import ImmutablePresetInfoHandler from preset_info_handler import PresetInfoHandler -from PyQt4.QtGui import QDesktopServices class PresetListModel(QtCore.QAbstractListModel): IMMUTABLE_PRESET_PATH = os.path.join(ost.GetSharedDataPath(),"scene", "presets.xml") MUTABLE_PRESET_PATH = "user_presets.xml" + + dataChanged = QtCore.pyqtSignal(int, int, name="dataChanged") def __init__(self, parent=None, *args): QtCore.QAbstractListModel.__init__(self, parent, *args) @@ -20,7 +21,8 @@ class PresetListModel(QtCore.QAbstractListModel): #Info Handler self.immutable_infoh_=ImmutablePresetInfoHandler(PresetListModel.IMMUTABLE_PRESET_PATH) - data_loc=QDesktopServices.storageLocation(QDesktopServices.DataLocation) + data_loc=str(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.DataLocation)) + mutable_path=os.path.join(str(data_loc), 'config', PresetListModel.MUTABLE_PRESET_PATH) qdir=QtCore.QDir(data_loc) @@ -39,7 +41,7 @@ class PresetListModel(QtCore.QAbstractListModel): end_index = self.createIndex(self.rowCount(),0) if save: self.AddPresetToInfo(preset) - self.emit(QtCore.SIGNAL("dataChanged"),model_index, end_index) + self.dataChanged.emit(model_index, end_index) return True return False @@ -52,7 +54,7 @@ class PresetListModel(QtCore.QAbstractListModel): self.removeRow(row, QtCore.QModelIndex()) model_index = self.createIndex(row,0) self.infoh_.RemovePreset(name) - self.emit(QtCore.SIGNAL("dataChanged"),model_index, model_index) + self.dataChanged.emit(model_index, model_index) return True return False @@ -113,7 +115,7 @@ class PresetListModel(QtCore.QAbstractListModel): new_name = value.toString() self.data_[row][0].SetName(str(new_name)) self.infoh_.RenamePreset(old_name,str(new_name)) - self.emit(QtCore.SIGNAL("dataChanged"),index, index) + self.dataChanged.emit(index, index) return True elif role == QtCore.Qt.DisplayRole: self.data_[row][0].SetName(value.toString()) @@ -144,4 +146,4 @@ class PresetListModel(QtCore.QAbstractListModel): - \ No newline at end of file + diff --git a/modules/gui/pymod/scene/preset_widget.py b/modules/gui/pymod/scene/preset_widget.py index 87e8ea7cce5b6262a82cb23c399b04dd0de36a21..aec2f2d29e1bc8ef51c39f5357a7d4d6f15c6c5c 100644 --- a/modules/gui/pymod/scene/preset_widget.py +++ b/modules/gui/pymod/scene/preset_widget.py @@ -22,83 +22,83 @@ from ost import gfx import ost import os from datetime import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui from scene_selection_helper import SelHelper from preset_list_model import PresetListModel from preset_editor_widget import PresetEditor from preset import Preset -class PresetWidget(QtGui.QWidget): +class PresetWidget(QtWidgets.QWidget): PRESET_XML_FILE = os.path.join(ost.GetSharedDataPath(), "scene", "presets.xml") ICONS_DIR = os.path.join(ost.GetSharedDataPath(), "gui", "icons/") def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.text_ = "Presets" #Create Ui elements - self.list_view_ = QtGui.QListView() + self.list_view_ = QtWidgets.QListView() #Create Model self.list_model_ = PresetListModel(self) self.list_view_.setModel(self.list_model_) - self.list_view_.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) - self.add_action = QtGui.QAction("+",self) + self.add_action = QtWidgets.QAction("+",self) self.add_action.setIcon(QtGui.QIcon(PresetWidget.ICONS_DIR+"add_icon.png")) - QtCore.QObject.connect(self.add_action, QtCore.SIGNAL("triggered()"), self.Add) + self.add_action.triggered.connect(self.Add) - self.add_button_ = QtGui.QToolButton(self) + self.add_button_ = QtWidgets.QToolButton(self) self.add_button_.setIconSize(QtCore.QSize(20,20)) self.add_button_.setDefaultAction(self.add_action) self.preset_editor_ = PresetEditor(self) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setContentsMargins(0,5,0,0) grid.addWidget(self.list_view_,0,0,3,3) grid.addWidget(self.add_button_,3,0,1,1) self.setLayout(grid) self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - QtCore.QObject.connect(self.list_view_, QtCore.SIGNAL("customContextMenuRequested(const QPoint)"), self.contextMenuEvent) + self.list_view_.customContextMenuRequested.connect(self.contextMenuEvent) self.CreateImmutableContextMenu() self.CreateContextMenu() - QtCore.QObject.connect(self.list_view_, QtCore.SIGNAL("doubleClicked(const QModelIndex)"), self.Load) + self.list_view_.doubleClicked.connect(self.Load) self.setMinimumSize(250,200) def CreateImmutableContextMenu(self): - self.immucontext_menu_ = QtGui.QMenu("Context menu", self) - self.load_ = QtGui.QAction("Load", self.list_view_) + self.immucontext_menu_ = QtWidgets.QMenu("Context menu", self) + self.load_ = QtWidgets.QAction("Load", self.list_view_) self.immucontext_menu_.addAction(self.load_) #Connect Signal with Slot - QtCore.QObject.connect(self.load_, QtCore.SIGNAL("triggered()"), self.LoadCurrentIndex) + self.load_.triggered.connect(self.LoadCurrentIndex) def CreateContextMenu(self): - self.context_menu_ = QtGui.QMenu("Context menu", self) - self.remove_ = QtGui.QAction("Remove", self.list_view_) - self.rename_ = QtGui.QAction("Rename", self.list_view_) - self.edit_ = QtGui.QAction("Edit", self.list_view_) + self.context_menu_ = QtWidgets.QMenu("Context menu", self) + self.remove_ = QtWidgets.QAction("Remove", self.list_view_) + self.rename_ = QtWidgets.QAction("Rename", self.list_view_) + self.edit_ = QtWidgets.QAction("Edit", self.list_view_) self.context_menu_.addAction(self.load_) self.context_menu_.addAction(self.remove_) self.context_menu_.addAction(self.rename_) self.context_menu_.addAction(self.edit_) #Connect Signals with Slots - QtCore.QObject.connect(self.remove_, QtCore.SIGNAL("triggered()"), self.Remove) - QtCore.QObject.connect(self.rename_, QtCore.SIGNAL("triggered()"), self.Rename) - QtCore.QObject.connect(self.edit_, QtCore.SIGNAL("triggered()"), self.Edit) + self.remove_.triggered.connect(self.Remove) + self.rename_.triggered.connect(self.Rename) + self.edit_.triggered.connect(self.Edit) def contextMenuEvent(self, pos): #ContextMenu index = self.list_view_.indexAt(pos) if index.isValid(): if self.list_model_.IsEditable(index.row()): - self.context_menu_.popup(QtGui.QCursor.pos()) + self.context_menu_.popup(QtWidgets.QCursor.pos()) else: - self.immucontext_menu_.popup(QtGui.QCursor.pos()) + self.immucontext_menu_.popup(QtWidgets.QCursor.pos()) def Add(self): row = self.list_model_.GetLastRow() @@ -112,10 +112,10 @@ class PresetWidget(QtGui.QWidget): def Remove(self): if(self.list_view_.currentIndex().isValid()): - ret = QtGui.QMessageBox.warning(self, "Delete Preset", + ret = QtWidgets.QMessageBox.warning(self, "Delete Preset", "Delete Preset?", - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) - if ret == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) + if ret == QtWidgets.QMessageBox.Yes: self.list_model_.RemoveItem(self.list_view_.currentIndex().row()) def Edit(self): diff --git a/modules/gui/pymod/scene/query_editor.py b/modules/gui/pymod/scene/query_editor.py index fcdfc43395dd383503f796c734641e987622c8cc..6cebc3ea56c64812bfcfc4ce25881abe69265b2a 100644 --- a/modules/gui/pymod/scene/query_editor.py +++ b/modules/gui/pymod/scene/query_editor.py @@ -1,36 +1,36 @@ from ost import mol -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui -class QueryEditorWidget(QtGui.QWidget): +class QueryEditorWidget(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.default_font_=QtGui.QTextCharFormat() self.default_font_.setForeground(QtGui.QBrush(QtGui.QColor(0,0,0))) self.error_font_=QtGui.QTextCharFormat() self.error_font_.setForeground(QtGui.QBrush(QtGui.QColor(255,0,0))) - self.selection_edit_=QtGui.QTextEdit(self) + self.selection_edit_=QtWidgets.QTextEdit(self) self.selection_edit_.setFixedHeight(40) self.selection_edit_.updateGeometry() - self.status_=QtGui.QLabel(" ",self); + self.status_=QtWidgets.QLabel(" ",self); self.status_.setWordWrap(True) self.status_.setMargin(0) self.status_.setAlignment(QtCore.Qt.AlignRight) - self.status_.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Expanding)) - vl=QtGui.QVBoxLayout() + self.status_.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, + QtWidgets.QSizePolicy.Expanding)) + vl=QtWidgets.QVBoxLayout() vl.addWidget(self.selection_edit_) - self.no_bonds_=QtGui.QRadioButton('none') - self.ex_bonds_=QtGui.QRadioButton('exclusive') - self.in_bonds_=QtGui.QRadioButton('inclusive') + self.no_bonds_=QtWidgets.QRadioButton('none') + self.ex_bonds_=QtWidgets.QRadioButton('exclusive') + self.in_bonds_=QtWidgets.QRadioButton('inclusive') self.in_bonds_.setChecked(True) - self.match_res_=QtGui.QCheckBox('match residues') + self.match_res_=QtWidgets.QCheckBox('match residues') - vl.setMargin(0) + vl.setContentsMargins(0,0,0,0) vl.setSpacing(0) self.setLayout(vl) vl.addWidget(self.status_) - hl=QtGui.QHBoxLayout() - l=QtGui.QLabel("bonds:") + hl=QtWidgets.QHBoxLayout() + l=QtWidgets.QLabel("bonds:") hl.addWidget(l) hl.addSpacing(5) @@ -42,11 +42,9 @@ class QueryEditorWidget(QtGui.QWidget): vl.addWidget(self.match_res_) self.changing_text_=False; - self.connect(self.selection_edit_,QtCore.SIGNAL("textChanged()"), - self._StartTimer) + self.selection_edit_.textChanged.connect(self._StartTimer) self.timer_=QtCore.QTimer() - QtCore.QObject.connect(self.timer_, QtCore.SIGNAL('timeout()'), - self._UpdateMessage) + self.timer_.timeout.connect(self._UpdateMessage) def GetQueryFlags(self): flags=0 @@ -103,25 +101,25 @@ class QueryEditorWidget(QtGui.QWidget): cursor.setCharFormat(self.error_font_) self.changing_text_=False -class QueryDialog(QtGui.QDialog): +class QueryDialog(QtWidgets.QDialog): def __init__(self, title, parent=None): - QtGui.QDialog.__init__(self, parent) - l=QtGui.QVBoxLayout(self) + QtWidgets.QDialog.__init__(self, parent) + l=QtWidgets.QVBoxLayout(self) self.setWindowTitle(title) self.editor=QueryEditorWidget(self) l.addWidget(self.editor) l.addSpacing(10) - l3=QtGui.QHBoxLayout() - ab=QtGui.QPushButton('OK') + l3=QtWidgets.QHBoxLayout() + ab=QtWidgets.QPushButton('OK') ab.setDefault(True) - cb=QtGui.QPushButton('Cancel') + cb=QtWidgets.QPushButton('Cancel') l3.addStretch(1) l3.addWidget(cb, 0) l3.addWidget(ab, 0) l.addLayout(l3) - QtCore.QObject.connect(cb, QtCore.SIGNAL('clicked()'), self.reject) - QtCore.QObject.connect(ab, QtCore.SIGNAL('clicked()'), self.accept) - self.connect(self.editor.selection_edit_,QtCore.SIGNAL("textChanged()"),self._CheckNewline) + cb.clicked.connect(self.reject) + ab.clicked.connect(self.accept) + self.editor.selection_edit_.textChanged.connect(self._CheckNewline) @property def query_flags(self): @@ -135,8 +133,8 @@ class QueryDialog(QtGui.QDialog): self.accept() return True else: - return QtGui.QDialog.event(self, e) + return QtWidgets.QDialog.event(self, e) def _CheckNewline(self): if self.editor.GetQueryText().endswith("\n"): - self.accept() \ No newline at end of file + self.accept() diff --git a/modules/gui/pymod/scene/remote.py b/modules/gui/pymod/scene/remote.py index 46a7553b41a1c6b12ae43f6f6d99aead520ea0bd..3f4459914957e68e201f163d6a880726fd51102a 100644 --- a/modules/gui/pymod/scene/remote.py +++ b/modules/gui/pymod/scene/remote.py @@ -1,53 +1,48 @@ -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5 import QtCore, QtWidgets import threading from ost import LogError from ost import gui, gfx from ost.io.remote import RemoteLoad, REMOTE_REPOSITORIES import re -class RemoteLoader(QWidget): +class RemoteLoader(QtWidgets.QWidget): def __init__(self): - QWidget.__init__(self) - self._line = QLineEdit(self) - self._load = QToolButton(self) - self._load.setAttribute(Qt.WA_MacSmallSize) - QObject.connect(self._line, SIGNAL('returnPressed()'), - self._DoLoad) - QObject.connect(self._load, SIGNAL('clicked()'), - self._DoLoad) - hbox = QHBoxLayout(self) + QtWidgets.QWidget.__init__(self) + self._line = QtWidgets.QLineEdit(self) + self._load = QtWidgets.QToolButton(self) + self._line.returnPressed.connect(self._DoLoad) + self._load.clicked.connect(self._DoLoad) + hbox = QtWidgets.QHBoxLayout(self) hbox.addWidget(self._line,1) hbox.addWidget(self._load,0) self.setLayout(hbox) - hbox.setMargin(3) + hbox.setContentsMargins(3,3,3,3) hbox.setSpacing(3) self._menu = self._RemoteMenu() self._load.setMenu(self._menu) self._current_repo = 'pdb' self._UpdateLoadButton(self._current_repo) self.setFixedHeight(self._load.height()) - self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) + self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) def _RemoteMenu(self): - menu = QMenu() - action_group = QActionGroup(menu) + menu = QtWidgets.QMenu() + action_group = QtWidgets.QActionGroup(menu) for k,v in REMOTE_REPOSITORIES.iteritems(): action = menu.addAction(v.name) action.setCheckable(True) if k == 'pdb': action.setChecked(True) - action.setData(QVariant(k)) + action.setData(QtCore.QVariant(k)) action_group.addAction(action) - QObject.connect(menu, SIGNAL('triggered(QAction*)'), - self._ToggleRepo) + menu.triggered.connect(self._ToggleRepo) return menu def _UpdateLoadButton(self, current): name = REMOTE_REPOSITORIES[current].name self._load.setText('load from %s ' % name) def _ToggleRepo(self, action): - self._current_repo = str(action.data().toString()) + self._current_repo = str(action.data()) self._UpdateLoadButton(self._current_repo) @@ -72,7 +67,7 @@ class RemoteLoader(QWidget): remote_loader=RemoteLoader() remote_loader_for_panel=gui.Widget(remote_loader) -remote_loader_for_panel.qobject.setSizePolicy(QSizePolicy.Expanding, - QSizePolicy.Fixed) +remote_loader_for_panel.qobject.setSizePolicy(QtWidgets.QSizePolicy.Expanding, + QtWidgets.QSizePolicy.Fixed) panels=gui.GostyApp.Instance().perspective.panels panels.AddWidgetToPool("Remote Loader",remote_loader_for_panel) diff --git a/modules/gui/pymod/scene/render_mode_widget.py b/modules/gui/pymod/scene/render_mode_widget.py index 038e0950eaa699cd4e89ea1b36aeaed7dfa4e030..31b33ddd7ce25071f0387d460e2b04a3dfead903 100644 --- a/modules/gui/pymod/scene/render_mode_widget.py +++ b/modules/gui/pymod/scene/render_mode_widget.py @@ -20,13 +20,13 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets #Tube Render Options -class RenderModeWidget(QtGui.QWidget): +class RenderModeWidget(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.options_ = None self.entities_ = set() @@ -64,13 +64,13 @@ class RenderModeWidget(QtGui.QWidget): entity = self.entities_.pop() self.options_=entity.GetOptions(self.GetRenderMode()) self.UpdateGui(self.options_) - QtGui.QWidget.setEnabled(self,True) + QtWidgets.QWidget.setEnabled(self,True) else: - QtGui.QWidget.setEnabled(self,False) + QtWidgets.QWidget.setEnabled(self,False) def ApplyOptions(self): for entity in self.entities_: entity.ApplyOptions(self.GetRenderMode(), self.GetOptions()) def GetOptions(self): - return self.options_ \ No newline at end of file + return self.options_ diff --git a/modules/gui/pymod/scene/render_op.py b/modules/gui/pymod/scene/render_op.py index cdbb7e036e089ede7fa72f19bba756cb18362c5d..ea2b54263e1a9a17da6f51e42d5c406fa0e1c5cb 100644 --- a/modules/gui/pymod/scene/render_op.py +++ b/modules/gui/pymod/scene/render_op.py @@ -20,7 +20,6 @@ from ost import info from ost import gfx -from PyQt4 import QtGui class RenderOp: RENDERMODE_ATTRIBUTE_NAME = "RenderMode" diff --git a/modules/gui/pymod/scene/render_options_widget.py b/modules/gui/pymod/scene/render_options_widget.py index f1d9929ee605b5b507d2b9689d232f1dfcaee67c..90cc213e827c648244487c9e23737a37d43ad635 100644 --- a/modules/gui/pymod/scene/render_options_widget.py +++ b/modules/gui/pymod/scene/render_options_widget.py @@ -28,7 +28,7 @@ try: except ImportError: _img_present=False pass -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from scene_selection_helper import SelHelper from combo_options_widget import ComboOptionsWidget from custom_widget import CustomWidget @@ -47,11 +47,11 @@ class RenderOptionsWidget(ComboOptionsWidget): #Title self.text_ = "Render Options" - self.keep_action_ = QtGui.QAction("K",self) + self.keep_action_ = QtWidgets.QAction("K",self) self.keep_action_.setCheckable(True); self.keep_action_.setChecked(False) self.keep_action_.setToolTip("Keep rendermodes and add current") - self.keep_button_ = QtGui.QToolButton(self) + self.keep_button_ = QtWidgets.QToolButton(self) self.keep_button_.setDefaultAction(self.keep_action_) self.grid_layout_.addWidget(self.keep_button_, 0, 1, 1, 1) @@ -157,19 +157,19 @@ class RenderOptionsWidget(ComboOptionsWidget): def GetText(self): return self.text_ -class EmptyMode(QtGui.QWidget): +class EmptyMode(QtWidgets.QWidget): def __init__(self, text="", render_mode=None, parent=None): - QtGui.QLabel.__init__(self, parent) + QtWidgets.QLabel.__init__(self, parent) self.setMinimumSize(250,30) self.text = text self.render_mode = render_mode if(render_mode): - text_label = QtGui.QLabel(text) + text_label = QtWidgets.QLabel(text) font = text_label.font() font.setBold(True) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(text_label,0,0,1,1) - grid.addWidget(QtGui.QLabel("No Settings available"), 1, 0, 1, 3) + grid.addWidget(QtWidgets.QLabel("No Settings available"), 1, 0, 1, 3) grid.setRowStretch(2,1) self.setLayout(grid) self.setMinimumSize(250,60) diff --git a/modules/gui/pymod/scene/simple_widget.py b/modules/gui/pymod/scene/simple_widget.py index 1c9c337e9dbe74573e0aae29887d80fd2dafe485..53e172afd94d9b9620830dc9dd841c3f8d702478 100644 --- a/modules/gui/pymod/scene/simple_widget.py +++ b/modules/gui/pymod/scene/simple_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Simple Render Options @@ -41,30 +41,30 @@ class SimpleWidget(RenderModeWidget): self.mode_ = gfx.RenderMode.SIMPLE #Create Ui elements - self.aa_rendering_cb_ = QtGui.QCheckBox() + self.aa_rendering_cb_ = QtWidgets.QCheckBox() - self.radius_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_spinbox_.setRange(min_line_width, max_line_width) self.radius_spinbox_.setDecimals(2) self.radius_spinbox_.setSingleStep(0.1) - self.bo_rendering_cb_ = QtGui.QCheckBox() + self.bo_rendering_cb_ = QtWidgets.QCheckBox() - self.bo_distance_spinbox_ = QtGui.QDoubleSpinBox() + self.bo_distance_spinbox_ = QtWidgets.QDoubleSpinBox() self.bo_distance_spinbox_.setRange(min_bo_dist, max_bo_dist) self.bo_distance_spinbox_.setDecimals(2) self.bo_distance_spinbox_.setSingleStep(0.01) - simple_label = QtGui.QLabel("Fast Bonds Simple Settings") + simple_label = QtWidgets.QLabel("Fast Bonds Simple Settings") font = simple_label.font() font.setBold(True) - radius_label = QtGui.QLabel("Line Width") - aa_label = QtGui.QLabel("AA-Lines") - bo_label = QtGui.QLabel("Show Bond Order") - bo_distance = QtGui.QLabel("Bond Order Distance") + radius_label = QtWidgets.QLabel("Line Width") + aa_label = QtWidgets.QLabel("AA-Lines") + bo_label = QtWidgets.QLabel("Show Bond Order") + bo_distance = QtWidgets.QLabel("Bond Order Distance") - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(simple_label,0,0,1,3) grid.addWidget(aa_label, 1, 0, 1, 3) grid.addWidget(self.aa_rendering_cb_, 1, 2, 1, 1) @@ -77,10 +77,10 @@ class SimpleWidget(RenderModeWidget): grid.setRowStretch(5,1) self.setLayout(grid) - QtCore.QObject.connect(self.radius_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLineWidth) - QtCore.QObject.connect(self.aa_rendering_cb_, QtCore.SIGNAL("stateChanged(int)"), self.UpdateAA) - QtCore.QObject.connect(self.bo_distance_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateBODistance) - QtCore.QObject.connect(self.bo_rendering_cb_, QtCore.SIGNAL("stateChanged(int)"), self.UpdateBO) + self.radius_spinbox_.valueChanged.connect(self.UpdateLineWidth) + self.aa_rendering_cb_.stateChanged.connect(self.UpdateAA) + self.bo_distance_spinbox_.valueChanged.connect(self.UpdateBODistance) + self.bo_rendering_cb_.stateChanged.connect(self.UpdateBO) self.setMinimumSize(250,140) self.setMinimumSize(250,140) @@ -111,4 +111,4 @@ class SimpleWidget(RenderModeWidget): return self.text_ def GetRenderMode(self): - return self.mode_ \ No newline at end of file + return self.mode_ diff --git a/modules/gui/pymod/scene/sline_widget.py b/modules/gui/pymod/scene/sline_widget.py index 063a81e330a65492c25f1cdfcf04c5019c017fd0..c42f2f98ffd5875ab7501110beeb552a03d26a5c 100644 --- a/modules/gui/pymod/scene/sline_widget.py +++ b/modules/gui/pymod/scene/sline_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Simple Render Options @@ -42,25 +42,25 @@ class SlineWidget(RenderModeWidget): max_line_width = 20 #Create Ui elements - self.detail_spinbox_ = QtGui.QSpinBox() + self.detail_spinbox_ = QtWidgets.QSpinBox() self.detail_spinbox_.setRange(min_detail, max_detail) self.detail_spinbox_.setSingleStep(1) - self.aa_rendering_cb_ = QtGui.QCheckBox() + self.aa_rendering_cb_ = QtWidgets.QCheckBox() - self.radius_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_spinbox_.setRange(min_line_width, max_line_width) self.radius_spinbox_.setDecimals(2) self.radius_spinbox_.setSingleStep(0.1) - sline_label = QtGui.QLabel("Spline Settings") + sline_label = QtWidgets.QLabel("Spline Settings") font = sline_label.font() font.setBold(True) - detail_label = QtGui.QLabel("Spline Detail") - aa_label = QtGui.QLabel("AA-Lines") - radius_label = QtGui.QLabel("Line Width") - grid = QtGui.QGridLayout() + detail_label = QtWidgets.QLabel("Spline Detail") + aa_label = QtWidgets.QLabel("AA-Lines") + radius_label = QtWidgets.QLabel("Line Width") + grid = QtWidgets.QGridLayout() grid.addWidget(sline_label, 0, 0, 1, 1) grid.addWidget(detail_label, 1, 0, 1, 3) grid.addWidget(self.detail_spinbox_, 1, 2, 1, 1) @@ -71,9 +71,9 @@ class SlineWidget(RenderModeWidget): grid.setRowStretch(4,1) self.setLayout(grid) - QtCore.QObject.connect(self.detail_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateDetail) - QtCore.QObject.connect(self.aa_rendering_cb_, QtCore.SIGNAL("stateChanged(int)"), self.UpdateAA) - QtCore.QObject.connect(self.radius_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLineWidth) + self.detail_spinbox_.valueChanged.connect(self.UpdateDetail) + self.aa_rendering_cb_.stateChanged.connect(self.UpdateAA) + self.radius_spinbox_.valueChanged.connect(self.UpdateLineWidth) self.setMinimumSize(250,120) diff --git a/modules/gui/pymod/scene/toolbar_options_widget.py b/modules/gui/pymod/scene/toolbar_options_widget.py index fc4720493f026e2f7f64c91c17d6542f710d1ffc..55e45b04652bd35f57e7a89983fb346bd7c0f663 100644 --- a/modules/gui/pymod/scene/toolbar_options_widget.py +++ b/modules/gui/pymod/scene/toolbar_options_widget.py @@ -21,36 +21,35 @@ import sys from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui -class ToolBarOptionsWidget(QtGui.QWidget): +class ToolBarOptionsWidget(QtWidgets.QWidget): """QWidget with a ToolBar and a show area. This abstract QWidget has a toolbar and a show area. Whenever a button of the tool bar is pressed, the Widget corresponding to the button's value is shown in the show area. """ def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Setup ui_ self.parent_=parent self.resize(400, 300) self.setMinimumSize(QtCore.QSize(250, 200)) - self.gridLayout = QtGui.QGridLayout(self) + self.gridLayout = QtWidgets.QGridLayout(self) self.gridLayout.setHorizontalSpacing(0) self.gridLayout.setVerticalSpacing(0) self.gridLayout.setContentsMargins(0,0,0,0) - self.gridLayout.setMargin(0) self.gridLayout.setSpacing(0) - self.tool_bar_ = QtGui.QToolBar(self) + self.tool_bar_ = QtWidgets.QToolBar(self) self.tool_bar_.setIconSize(QtCore.QSize(16, 16)) self.gridLayout.addWidget(self.tool_bar_, 0, 0, 1, 1) - self.stackedWidget = QtGui.QStackedWidget(self) + self.stackedWidget = QtWidgets.QStackedWidget(self) self.gridLayout.addWidget(self.stackedWidget, 1, 0, 1, 1) self.current_action_ = None self.actions_ = list() - QtCore.QObject.connect(self.tool_bar_, QtCore.SIGNAL("actionTriggered(QAction*)"), self.ChangeSelectedItem) + self.tool_bar_.actionTriggered.connect(self.ChangeSelectedItem) self.setEnabled(False) @@ -74,13 +73,13 @@ class ToolBarOptionsWidget(QtGui.QWidget): the old widget will be removed and the new widget gets the identifier. Returns True, if widget is added. Otherwise it returns False """ - if isinstance(widget, QtGui.QWidget) and ident is not None: + if isinstance(widget, QtWidgets.QWidget) and ident is not None: if text is not None: - string = QtCore.QString(text) + string = text elif hasattr(widget, "GetText"): - string = QtCore.QString(widget.GetText()) + string = widget.GetText() else: - string = QtCore.QString(ident) + string = ident self.stackedWidget.addWidget(widget) action = self.tool_bar_.addAction(ident) @@ -124,7 +123,7 @@ class ToolBarOptionsWidget(QtGui.QWidget): self.current_action_.setChecked(False) else: self.current_action_ = action - widget = action.data().toPyObject()[1] + widget = action.data()[1] self.stackedWidget.setCurrentWidget(widget) if hasattr(widget, "Update"): widget.Update() @@ -139,5 +138,5 @@ class ToolBarOptionsWidget(QtGui.QWidget): #Overwritten Methods def setEnabled(self, bool): - QtGui.QWidget.setEnabled(self, bool) + QtWidgets.QWidget.setEnabled(self, bool) diff --git a/modules/gui/pymod/scene/trace_widget.py b/modules/gui/pymod/scene/trace_widget.py index 7dcb0342a3a9f76f94e3c5eb3ddf3cf776ccbf38..8705d18d8628e92c7a7d1d4ed6033883c02feb5f 100644 --- a/modules/gui/pymod/scene/trace_widget.py +++ b/modules/gui/pymod/scene/trace_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Trace Render Options @@ -44,25 +44,25 @@ class TraceWidget(RenderModeWidget): #########UI########## #Arc Label - arc_label = QtGui.QLabel("Arc Detail") + arc_label = QtWidgets.QLabel("Arc Detail") - self.arc_spinbox_ = QtGui.QSpinBox() + self.arc_spinbox_ = QtWidgets.QSpinBox() self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail) #Tube Radius - radius_tube_label = QtGui.QLabel("Radius") + radius_tube_label = QtWidgets.QLabel("Radius") - self.width_tube_spinbox_ = QtGui.QDoubleSpinBox() + self.width_tube_spinbox_ = QtWidgets.QDoubleSpinBox() self.width_tube_spinbox_.setRange(min_width, max_tube_width) self.width_tube_spinbox_.setDecimals(1) self.width_tube_spinbox_.setSingleStep(0.1) - self.width_tube_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.width_tube_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.width_tube_slider_.setRange(min_width*10.0, max_tube_width*10.0) - self.width_tube_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.width_tube_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.width_tube_slider_.setTickInterval(1) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(arc_label,3,0,1,3) grid.addWidget(self.arc_spinbox_,3,4,1,1) @@ -73,15 +73,9 @@ class TraceWidget(RenderModeWidget): grid.setRowStretch(15,1) self.setLayout(grid) - QtCore.QObject.connect(self.arc_spinbox_, QtCore.SIGNAL("valueChanged(int)"), - self.UpdateArcDetail) - - QtCore.QObject.connect(self.width_tube_spinbox_, - QtCore.SIGNAL("valueChanged(double)"), - self.UpdateTubeRadius) - QtCore.QObject.connect(self.width_tube_slider_, - QtCore.SIGNAL("valueChanged(int)"), - self.UpdateSliderTubeRadius) + self.arc_spinbox_.valueChanged.connect(self.UpdateArcDetail) + self.width_tube_spinbox_.valueChanged.connect(self.UpdateTubeRadius) + self.width_tube_slider_.valueChanged.connect(self.UpdateSliderTubeRadius) self.setMinimumSize(250,60) #2*30 ########/UI######## diff --git a/modules/gui/pymod/scene/tube_widget.py b/modules/gui/pymod/scene/tube_widget.py index 561728800025d751e125820b2edd8e943270724e..682fd0b05796c8bec84639204d0b3faf95eb4b85 100644 --- a/modules/gui/pymod/scene/tube_widget.py +++ b/modules/gui/pymod/scene/tube_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from render_mode_widget import RenderModeWidget #Tube Render Options @@ -48,57 +48,57 @@ class TubeWidget(RenderModeWidget): max_ratio = 4 #UI - tube_label = QtGui.QLabel("Tube Settings") + tube_label = QtWidgets.QLabel("Tube Settings") font = tube_label.font() font.setBold(True) #Poly Mode - poly_mode_label = QtGui.QLabel("Poly Mode") + poly_mode_label = QtWidgets.QLabel("Poly Mode") - self.poly_mode_cb_ = QtGui.QComboBox() + self.poly_mode_cb_ = QtWidgets.QComboBox() self.poly_mode_cb_.addItem("Points") self.poly_mode_cb_.addItem("Wireframe") self.poly_mode_cb_.addItem("Surface") #Sphere Label - spline_label = QtGui.QLabel("Spline Detail") + spline_label = QtWidgets.QLabel("Spline Detail") - self.spline_spinbox_ = QtGui.QSpinBox() + self.spline_spinbox_ = QtWidgets.QSpinBox() self.spline_spinbox_.setRange(min_spline_detail, max_spline_detail) #Arc Label - arc_label = QtGui.QLabel("Arc Detail") + arc_label = QtWidgets.QLabel("Arc Detail") - self.arc_spinbox_ = QtGui.QSpinBox() + self.arc_spinbox_ = QtWidgets.QSpinBox() self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail) #Radius - radius_label = QtGui.QLabel("Tube radius") + radius_label = QtWidgets.QLabel("Tube radius") - self.radius_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_spinbox_.setRange(min_radius, max_radius) self.radius_spinbox_.setDecimals(1) self.radius_spinbox_.setSingleStep(0.1) - self.radius_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.radius_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.radius_slider_.setRange(min_radius*10.0, max_radius*10.0) - self.radius_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.radius_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.radius_slider_.setTickInterval(1) #Ratio - ratio_label = QtGui.QLabel("Tube ratio") + ratio_label = QtWidgets.QLabel("Tube ratio") - self.ratio_spinbox_ = QtGui.QDoubleSpinBox() + self.ratio_spinbox_ = QtWidgets.QDoubleSpinBox() self.ratio_spinbox_.setRange(min_ratio, max_ratio) self.ratio_spinbox_.setDecimals(1) self.ratio_spinbox_.setSingleStep(0.1) - self.ratio_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.ratio_slider_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.ratio_slider_.setRange(min_ratio*10.0, max_ratio*10.0) - self.ratio_slider_.setTickPosition(QtGui.QSlider.NoTicks) + self.ratio_slider_.setTickPosition(QtWidgets.QSlider.NoTicks) self.ratio_slider_.setTickInterval(2) - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(tube_label,0,0,1,3) grid.addWidget(poly_mode_label,1,0,1,3) grid.addWidget(self.poly_mode_cb_,1,3,1,2) @@ -115,13 +115,13 @@ class TubeWidget(RenderModeWidget): grid.setRowStretch(6,1) self.setLayout(grid) - QtCore.QObject.connect(self.spline_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSplineDetail) - QtCore.QObject.connect(self.arc_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateArcDetail) - QtCore.QObject.connect(self.poly_mode_cb_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdatePolyMode) - QtCore.QObject.connect(self.radius_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateRadius) - QtCore.QObject.connect(self.radius_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderRadius) - QtCore.QObject.connect(self.ratio_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateRatio) - QtCore.QObject.connect(self.ratio_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderRatio) + self.spline_spinbox_.valueChanged.connect(self.UpdateSplineDetail) + self.arc_spinbox_.valueChanged.connect(self.UpdateArcDetail) + self.poly_mode_cb_.currentIndexChanged.connect(self.UpdatePolyMode) + self.radius_spinbox_.valueChanged.connect(self.UpdateRadius) + self.radius_slider_.valueChanged.connect(self.UpdateSliderRadius) + self.ratio_spinbox_.valueChanged.connect(self.UpdateRatio) + self.ratio_slider_.valueChanged.connect(self.UpdateSliderRatio) self.setMinimumSize(250,200) diff --git a/modules/gui/pymod/scene/uniform_color_widget.py b/modules/gui/pymod/scene/uniform_color_widget.py index 66461dcff9c391e926e47d77eaa1458fb1f1ce63..2459cbc4c1a3db3e8b01cb5b6abe7e250145630e 100644 --- a/modules/gui/pymod/scene/uniform_color_widget.py +++ b/modules/gui/pymod/scene/uniform_color_widget.py @@ -27,27 +27,27 @@ try: except ImportError: _img_present=False pass -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtGui from color_select_widget import ColorSelectWidget #Uniform Color Widget -class UniformColorWidget(QtGui.QWidget): +class UniformColorWidget(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.parent_ = parent self.text_ = "Uniform Color" #Create Ui elements - uniform_label = QtGui.QLabel(self.text_) + uniform_label = QtWidgets.QLabel(self.text_) font = uniform_label.font() font.setBold(True) self.color_select_widget_ = ColorSelectWidget(1,1,QtGui.QColor("White")) - top_layout = QtGui.QVBoxLayout() + top_layout = QtWidgets.QVBoxLayout() - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(self.color_select_widget_, 2, 1, 1, 1) grid.setRowStretch(1, 1) grid.setRowStretch(3, 1) @@ -58,7 +58,7 @@ class UniformColorWidget(QtGui.QWidget): top_layout.addLayout(grid) self.setLayout(top_layout) - QtCore.QObject.connect(self.color_select_widget_, QtCore.SIGNAL("colorChanged"), self.ChangeColors) + self.color_select_widget_.colorChanged.connect(self.ChangeColors) self.setMinimumSize(250,150) diff --git a/modules/gui/pymod/scene/visibility_op.py b/modules/gui/pymod/scene/visibility_op.py index 9e7402dc198344935c6930e2e4adfae802fcdb59..4b5fc7fb88b2164048057efc8e2bc895685baf18 100644 --- a/modules/gui/pymod/scene/visibility_op.py +++ b/modules/gui/pymod/scene/visibility_op.py @@ -20,7 +20,6 @@ from ost import info from ost import gfx -from PyQt4 import QtGui class VisibilityOp: VISIBLE_ATTRIBUTE_NAME = "Visible" diff --git a/modules/gui/pymod/scene/wireframe_widget.py b/modules/gui/pymod/scene/wireframe_widget.py index 35175222ad703023ef032784d9fa3b75db701afa..458a8f09b1d466b36b75e92a482626f16c9adb73 100644 --- a/modules/gui/pymod/scene/wireframe_widget.py +++ b/modules/gui/pymod/scene/wireframe_widget.py @@ -20,7 +20,7 @@ from ost import gui from ost import gfx -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets try: from ost import img _img_present=True @@ -30,9 +30,9 @@ except ImportError: from scene_selection_helper import SelHelper #Wireframe Options -class WireframeWidget(QtGui.QWidget): +class WireframeWidget(QtWidgets.QWidget): def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) #Title self.text_ = "Wireframe" @@ -45,21 +45,21 @@ class WireframeWidget(QtGui.QWidget): self.mode_ = gfx.RenderMode.SIMPLE #Create Ui elements - self.aa_rendering_cb_ = QtGui.QCheckBox() + self.aa_rendering_cb_ = QtWidgets.QCheckBox() - self.radius_spinbox_ = QtGui.QDoubleSpinBox() + self.radius_spinbox_ = QtWidgets.QDoubleSpinBox() self.radius_spinbox_.setRange(min_line_width, max_line_width) self.radius_spinbox_.setDecimals(2) self.radius_spinbox_.setSingleStep(0.1) - simple_label = QtGui.QLabel("Wireframe Settings") + simple_label = QtWidgets.QLabel("Wireframe Settings") font = simple_label.font() font.setBold(True) - radius_label = QtGui.QLabel("Line Width") - aa_label = QtGui.QLabel("AA-Lines") + radius_label = QtWidgets.QLabel("Line Width") + aa_label = QtWidgets.QLabel("AA-Lines") - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.addWidget(simple_label,0,0,1,3) grid.addWidget(aa_label, 1, 0, 1, 3) grid.addWidget(self.aa_rendering_cb_, 1, 2, 1, 1) @@ -68,8 +68,8 @@ class WireframeWidget(QtGui.QWidget): grid.setRowStretch(5,1) self.setLayout(grid) - QtCore.QObject.connect(self.radius_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLineWidth) - QtCore.QObject.connect(self.aa_rendering_cb_, QtCore.SIGNAL("stateChanged(int)"), self.UpdateAA) + self.radius_spinbox_.valueChanged.connect(self.UpdateLineWidth) + self.aa_rendering_cb_.stateChanged.connect(self.UpdateAA) self.setMinimumSize(250,100) @@ -100,4 +100,4 @@ class WireframeWidget(QtGui.QWidget): return self.text_ def GetRenderMode(self): - return self.mode_ \ No newline at end of file + return self.mode_ diff --git a/modules/gui/pymod/sip_handler.hh b/modules/gui/pymod/sip_handler.hh index bdc43461f9d2bd39b25b4a66ccaed6c6af37b10e..a244bdf82a076a4c17c58cb3645d20538eb8d20d 100644 --- a/modules/gui/pymod/sip_handler.hh +++ b/modules/gui/pymod/sip_handler.hh @@ -38,10 +38,10 @@ template <class O> object get_py_qobject(O* cpp_object) { if (cpp_object != NULL){ static object sip_module=import("sip"); - static object pyqt4_module=import("PyQt4.QtCore"); + static object pyqt5_module=import("PyQt5.QtCore"); QObject* qobject = qobject_cast<QObject*>(cpp_object); unsigned long addr = reinterpret_cast<unsigned long>(qobject); - object py_qobject = pyqt4_module.attr("QObject"); + object py_qobject = pyqt5_module.attr("QObject"); object object = sip_module.attr("wrapinstance")(addr, py_qobject); return object; } diff --git a/modules/gui/pymod/table.py b/modules/gui/pymod/table.py index 94f1c64182bda5bde67b5ed5bd8a7541878851b7..d45b5d74e2b98c928f139273f4fc0ef9e8170b49 100644 --- a/modules/gui/pymod/table.py +++ b/modules/gui/pymod/table.py @@ -1,5 +1,5 @@ -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtCore import * from ost import table __all__=('Table', ) diff --git a/modules/gui/pymod/trajectory_viewer.py b/modules/gui/pymod/trajectory_viewer.py index 0741f98fb10214f3add38c767d24a3d647293f4c..133091fce1b3b1a4c7b6e876f7789c1c3a8b846c 100644 --- a/modules/gui/pymod/trajectory_viewer.py +++ b/modules/gui/pymod/trajectory_viewer.py @@ -23,16 +23,12 @@ __all__=('TrajWidget','SetTimeUnit','AddTrajectory','RemoveTrajectory','SetSpeed # along with this library; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #------------------------------------------------------------------------------- -#from PyQt4.QtCore import * -#from PyQt4.QtGui import * -import PyQt4 as _PyQt4 -from PyQt4.QtCore import Qt as _Qt -from PyQt4.QtCore import QObject as _QObject -from PyQt4.QtGui import QWidget as _QWidget -from PyQt4.QtGui import QLabel as _QLabel -from PyQt4.QtGui import QPushButton as _QPushButton -from PyQt4.QtCore import SIGNAL as _SIGNAL -from PyQt4.QtCore import QString as _QString + +import PyQt5 as _PyQt5 +from PyQt5.QtCore import Qt as _Qt +from PyQt5.QtWidgets import QWidget as _QWidget +from PyQt5.QtWidgets import QLabel as _QLabel +from PyQt5.QtWidgets import QPushButton as _QPushButton import ost as _ost import math as _math @@ -50,22 +46,22 @@ class TrajWidget(_QWidget): self.modifiers=None for i,go in enumerate(self.golist_): self.index_dict[go.name]=i - vb=_PyQt4.QtGui.QVBoxLayout() - hb=_PyQt4.QtGui.QHBoxLayout() - hb1=_PyQt4.QtGui.QHBoxLayout() - hb2=_PyQt4.QtGui.QHBoxLayout() - hb3=_PyQt4.QtGui.QHBoxLayout() - hb4=_PyQt4.QtGui.QHBoxLayout() + vb=_PyQt5.QtWidgets.QVBoxLayout() + hb=_PyQt5.QtWidgets.QHBoxLayout() + hb1=_PyQt5.QtWidgets.QHBoxLayout() + hb2=_PyQt5.QtWidgets.QHBoxLayout() + hb3=_PyQt5.QtWidgets.QHBoxLayout() + hb4=_PyQt5.QtWidgets.QHBoxLayout() self.callback=None - self._slider=_PyQt4.QtGui.QSlider(self) + self._slider=_PyQt5.QtWidgets.QSlider(self) self._slider.setOrientation(_Qt.Horizontal) - self._speed_slider=_PyQt4.QtGui.QSlider(self) + self._speed_slider=_PyQt5.QtWidgets.QSlider(self) self._speed_slider.setOrientation(_Qt.Horizontal) self._speedLabel=_QLabel(self) self._speedLabel.setText('Speed:') self._speedLabel.setAlignment(_Qt.AlignLeft) - self._play=_PyQt4.QtGui.QToolButton(self) - self._repeat=_PyQt4.QtGui.QCheckBox(self) + self._play=_PyQt5.QtWidgets.QToolButton(self) + self._repeat=_PyQt5.QtWidgets.QCheckBox(self) self._frame=_QLabel(self) self._frameNo=_QLabel(self) self._frameEnd=_QLabel(self) @@ -96,11 +92,11 @@ class TrajWidget(_QWidget): self._left_arrow=_QPushButton("<") self._left_arrow2=_QPushButton("<<") self._left_end=_QPushButton("|<") - self._align_selection=_PyQt4.QtGui.QLineEdit() + self._align_selection=_PyQt5.QtWidgets.QLineEdit() self._align=_QPushButton("Align") self._align_label=_QLabel(self) self._align_label.setText('Selection:') - self._ref_entity_selection=_PyQt4.QtGui.QComboBox() + self._ref_entity_selection=_PyQt5.QtWidgets.QComboBox() for go in self.golist_:self._ref_entity_selection.addItem(go.name) self._ref_entity_selection_label=_QLabel(self) self._ref_entity_selection_label.setText('Ref. Entity:') @@ -134,19 +130,17 @@ class TrajWidget(_QWidget): vb.addLayout(hb3) vb.addLayout(hb4) self._SetSpeedSliderPos(self._speed_slider_min+0.5*(self._speed_slider_max-self._speed_slider_min)) - _QObject.connect(self._play, _SIGNAL('toggled(bool)'), - self._TogglePlay) - _QObject.connect(self._slider, _SIGNAL('valueChanged(int)'), - self._SliderValueChanged) - _QObject.connect(self._speed_slider,_SIGNAL('valueChanged(int)'),self._SpeedSliderValChanged) - _QObject.connect(self._right_end,_SIGNAL('clicked()'),self._RightEndClicked) - _QObject.connect(self._right_arrow2,_SIGNAL('clicked()'),self._Right2Clicked) - _QObject.connect(self._right_arrow,_SIGNAL('clicked()'),self._RightClicked) - _QObject.connect(self._left_arrow2,_SIGNAL('clicked()'),self._Left2Clicked) - _QObject.connect(self._left_arrow,_SIGNAL('clicked()'),self._LeftClicked) - _QObject.connect(self._left_end,_SIGNAL('clicked()'),self._LeftEndClicked) - _QObject.connect(self._align, _SIGNAL('clicked()'), self._AlignClicked) - _QObject.connect(self._ref_entity_selection, _SIGNAL('currentIndexChanged(int)'), self._EntitySelected) + self._play.toggled.connect(self._TogglePlay) + self._slider.valueChanged.connect(self._SliderValueChanged) + self._speed_slider.valueChanged.connect(self._SpeedSliderValChanged) + self._right_end.clicked.connect(self._RightEndClicked) + self._right_arrow2.clicked.connect(self._Right2Clicked) + self._right_arrow.clicked.connect(self._RightClicked) + self._left_arrow2.clicked.connect(self._Left2Clicked) + self._left_arrow.clicked.connect(self._LeftClicked) + self._left_end.clicked.connect(self._LeftEndClicked) + self._align.clicked.connect(self._AlignClicked) + self._ref_entity_selection.currentIndexChanged.connect(self._EntitySelected) self._slider.setMinimum(0) self.frame_number_=self.traj_.GetFrameCount()-1 self.timestep_=self.traj_.GetDelta() diff --git a/modules/gui/pymod/transfer_ownership.hh b/modules/gui/pymod/transfer_ownership.hh index 5146c065b56c893b198996e342e8151ffdde5955..63da0b4c768a19bbc0686e76dd998dd5b5e7c47c 100644 --- a/modules/gui/pymod/transfer_ownership.hh +++ b/modules/gui/pymod/transfer_ownership.hh @@ -13,7 +13,7 @@ namespace ost { namespace gui { inline void TransferOwnership(QWidget* obj) { boost::python::object main_module=boost::python::import("__main__"); - boost::python::object qt_gui=boost::python::import("PyQt4.QtGui"); + boost::python::object qt_gui=boost::python::import("PyQt5.QtGui"); boost::python::object pobj(reinterpret_cast<unsigned long>(obj)); boost::python::object sip=main_module.attr("sip"); boost::python::object type=qt_gui.attr("QWidget"); diff --git a/modules/gui/pymod/wrap_gui.cc b/modules/gui/pymod/wrap_gui.cc index 6e4baae550ea669ab9e9ee79781f1b2c86d4ea12..b24863ca8b04e04d9b6125e77e4074fb988c57e2 100644 --- a/modules/gui/pymod/wrap_gui.cc +++ b/modules/gui/pymod/wrap_gui.cc @@ -41,6 +41,7 @@ void export_MenuBar(); void export_FileLoader(); void export_FileViewer(); void export_Widget(); +void export_GLCanvas(); #if OST_SPNAV_ENABLED void export_Input(); @@ -120,6 +121,7 @@ BOOST_PYTHON_MODULE(_ost_gui) export_FileLoader(); export_FileViewer(); export_Widget(); + export_GLCanvas(); #if OST_SPNAV_ENABLED export_Input(); diff --git a/modules/gui/share/icons/close_icon.png b/modules/gui/share/icons/close_icon.png index 376f51609396dca265f9c591af173f8dfe8153a6..b6bff85d2dc3c10ef7328e4a4e2483d2fefbb0d2 100644 Binary files a/modules/gui/share/icons/close_icon.png and b/modules/gui/share/icons/close_icon.png differ diff --git a/modules/gui/share/icons/split_icon.png b/modules/gui/share/icons/split_icon.png index 783e6afe9ba0f398104140472f3e198ae1257681..8f96f61ce7433fbf4423416866ed2f5abc8b14ea 100644 Binary files a/modules/gui/share/icons/split_icon.png and b/modules/gui/share/icons/split_icon.png differ diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index 858a64fec80c0502e2ce2e5d3d8c8fe3a0d17941..a23a530d65e3eda79c18712e63067bf125684c66 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -443,8 +443,8 @@ if (APPLE) endif() set(QT_USE_QTOPENGL 1) set(QT_USE_QTNETWORK 1) -include(${QT_USE_FILE}) -qt4_wrap_cpp(OST_GUI_MOCS "${HEADERS_TO_BE_MOCCED}" + +qt5_wrap_cpp(OST_GUI_MOCS "${HEADERS_TO_BE_MOCCED}" OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) module(NAME gui SOURCES ${OST_GUI_MOCS} ${OST_GUI_SOURCES} @@ -458,24 +458,28 @@ module(NAME gui SOURCES ${OST_GUI_MOCS} ${OST_GUI_SOURCES} ${OST_GUI_DATA_VIEWER_HEADERS} ${OST_GUI_HEADERS} DEPENDS_ON ost_gfx ost_io ost_mol_alg ost_seq_alg - LINK ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${BOOST_PYTHON_LIBRARIES} + LINK ${QT_LIBRARIES} + ${PYTHON_LIBRARIES} + ${BOOST_PYTHON_LIBRARIES} ${SPNAV_LIBRARIES} NO_STATIC) - + + + if (ADDITIONAL_LIBRARIES) target_link_libraries(ost_gui "${ADDITIONAL_LIBRARIES}") endif() include_directories(${PYTHON_INCLUDE_PATH}) -qt4_add_resources(OST_QT_RESOURCE dngr.qrc) -qt4_wrap_cpp(OST_GOSTY_MOC "gosty.hh" +qt5_add_resources(OST_QT_RESOURCE dngr.qrc) +qt5_wrap_cpp(OST_GOSTY_MOC "gosty.hh" OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) -set(LINK LINK ${BOOST_PROGRAM_OPTIONS_LIBRARIES}) +set(LINK LINK ${QT_LIBRARIES} ${BOOST_PROGRAM_OPTIONS_LIBRARIES}) -executable_libexec(NAME gosty SOURCES gosty.cc ${OST_GOSTY_MOC} ${OST_QT_RESOURCE} - DEPENDS_ON ost_gui ${LINK}) +executable_libexec(NAME gosty SOURCES gosty.cc ${OST_GOSTY_MOC} + ${OST_QT_RESOURCE} DEPENDS_ON ost_gui ${LINK}) file(GLOB MOC_CXX_FILES moc_*.cxx) diff --git a/modules/gui/src/data_viewer/argand.cc b/modules/gui/src/data_viewer/argand.cc index 585283e2f4ecb3e8fc93c56875b2845431ffee09..f53fb0fed48900a1de6a4cec734bb1ddf9c478a6 100644 --- a/modules/gui/src/data_viewer/argand.cc +++ b/modules/gui/src/data_viewer/argand.cc @@ -103,7 +103,7 @@ void Argand::update_buffer() pnt.drawLine(0,p0.y(),size().width(),p0.y()); if (!has_data_ || GetObservedData().GetType()!=COMPLEX) return; - Real maxlen; + Real maxlen = 0.0; std::vector<Complex> data_list; for(ExtentIterator it(extent_); !it.AtEnd(); ++it) { Complex v = GetObservedData().GetComplex(it); @@ -113,6 +113,10 @@ void Argand::update_buffer() data_list.push_back(v); } + if(maxlen == 0.0) { + return; // return to avoid zero division + } + int dim=std::min(size().width(),size().height()); sf_=0.5*(Real)(dim-10)/maxlen; diff --git a/modules/gui/src/file_viewer.cc b/modules/gui/src/file_viewer.cc index a5c5d727157dee2a6d7516032c5200717850bca2..3d64433a96b5898a6df8886dd6b1c5d6a2facce4 100644 --- a/modules/gui/src/file_viewer.cc +++ b/modules/gui/src/file_viewer.cc @@ -24,7 +24,7 @@ #include <QMainWindow> #include <QSyntaxHighlighter> #include <QTextEdit> -#include <QtGui> +#include <QVBoxLayout> namespace ost { namespace gui { diff --git a/modules/gui/src/gl_canvas.cc b/modules/gui/src/gl_canvas.cc index 9e39789b90bbf9d57dbf04f1da02f8563de73215..8bec7a90773e7e5bbd8851a661ab7d0da8b97057 100644 --- a/modules/gui/src/gl_canvas.cc +++ b/modules/gui/src/gl_canvas.cc @@ -16,179 +16,136 @@ // along with this library; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ -#include <ost/gui/python_shell/python_interpreter.hh> -#ifndef _MSC_VER -#include <sys/time.h> -#endif + +#include <chrono> #include "gl_canvas.hh" -#include "gl_win.hh" #include <ost/log.hh> -#include <ost/dyn_cast.hh> -#include <ost/mol/view_op.hh> - -#include <ost/seq/alignment_handle.hh> - - - #include <ost/gfx/scene.hh> -#include <ost/gfx/entity.hh> -#include <QTimer> -#include <QStatusBar> -#include <QApplication> -#include <QClipboard> -#include <QTime> -#include <QBasicTimer> +#include <ost/gui/tools/tool_manager.hh> +#include <ost/gui/perspective.hh> +#include <ost/gui/gosty_app.hh> + +#include <QResizeEvent> #include <QMouseEvent> -#include <QMenu> +#include <QImage> +#include <QString> +#include <QOpenGLFramebufferObject> +#include <QOffscreenSurface> +#include <QOpenGLContext> +#include <QOpenGLFunctions> -#if QT_VERSION >= 0x040600 -# include <QGesture> -#endif -#include "tools/tool_manager.hh" namespace ost { namespace gui { -using gfx::Scene; - -GLCanvas::GLCanvas(GLWin* gl_win, QWidget* parent, const QGLFormat& f): - QGLWidget(f,parent), - glwin_(gl_win), - mouse_key_mask_(), - refresh_(true), - master_timer_(), - bench_flag_(false), - last_pos_(), - scene_menu_(NULL), - show_beacon_(false), - angular_speed_(0.0) -{ - if(!isValid()) return; - master_timer_.start(10,this); - setFocusPolicy(Qt::StrongFocus); - setMouseTracking(true); - scene_menu_=new SceneMenu(); - this->setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, - SLOT(RequestContextMenu(const QPoint&))); -#if QT_VERSION >= 0x040600 - this->grabGesture(Qt::PinchGesture); -#endif +ost::gui::GLCanvas::GLCanvas(): QOpenGLWindow(), + last_pos_(), + show_beacon_(false), + bench_flag_(false), + offscreen_flag_(false), + offscreen_context_(NULL), + offscreen_surface_(NULL), + offscreen_fbo_(NULL) { + LOG_DEBUG("GLCanvas::registering with scene"); + gfx::Scene::Instance().Register(this); } -bool GLCanvas::event(QEvent* event) -{ -#if QT_VERSION >= 0x040600 - if (event->type()==QEvent::Gesture) { - return this->GestureEvent(static_cast<QGestureEvent*>(event)); +ost::gui::GLCanvas::~GLCanvas() { + gfx::Scene::Instance().Unregister(this); + if(offscreen_fbo_ != NULL) { + // all other offscreen rendering objects are also != NULL + // cleanup done as in QT threadrenderer example, not sure whether + // offscreen context must be made current to delete offscreen buffer... + offscreen_context_->makeCurrent(offscreen_surface_); + delete offscreen_fbo_; + offscreen_context_->doneCurrent(); + delete offscreen_context_; + delete offscreen_surface_; + offscreen_flag_ = false; } -#endif - return QGLWidget::event(event); } - -#if QT_VERSION >= 0x040600 - -bool GLCanvas::GestureEvent(QGestureEvent* event) -{ - if (QGesture* pinch=event->gesture(Qt::PinchGesture)) { - QPinchGesture* pinch_gesture=static_cast<QPinchGesture*>(pinch); - QPinchGesture::ChangeFlags changeFlags = pinch_gesture->changeFlags(); - if (changeFlags & QPinchGesture::RotationAngleChanged) { - qreal value=pinch_gesture->rotationAngle(); - qreal lastValue=pinch_gesture->lastRotationAngle(); - this->OnTransform(gfx::INPUT_COMMAND_ROTZ, 0, gfx::TRANSFORM_VIEW, - static_cast<Real>(value - lastValue)); - this->update(); - event->accept(); - if (pinch_gesture->state()==Qt::GestureFinished) { - angular_speed_=value-lastValue; - if (!gesture_timer_.isActive()) - gesture_timer_.start(10, this); - } - return true; - } +void GLCanvas::MakeActive() { + if(offscreen_flag_) { + offscreen_context_->makeCurrent(offscreen_surface_); + } else { + this->makeCurrent(); } - return false; } -#endif - - - - -void GLCanvas::MakeActive() -{ - makeCurrent(); +void GLCanvas::StatusMessage(const String& m) { + // This Window can also be displayed without a full blown GostyApp. + // We therefore only feed the message into Gosty if there's already + // a valid instance. + if(GostyApp::ValidInstance()) { + GostyApp::Instance()->GetPerspective()->StatusMessage(m); + } } -void GLCanvas::DoRefresh() -{ - refresh_=true; +void GLCanvas::SetDefaultFormat() { + QSurfaceFormat f = QSurfaceFormat::defaultFormat(); + f.setRedBufferSize(8); + f.setGreenBufferSize(8); + f.setBlueBufferSize(8); + f.setAlphaBufferSize(8); + f.setDepthBufferSize(24); + this->setFormat(f); } -void GLCanvas::StatusMessage(const String& m) -{ - glwin_->StatusMessage(m); +void GLCanvas::SetStereoFormat() { + QSurfaceFormat f = QSurfaceFormat::defaultFormat(); + f.setRedBufferSize(8); + f.setGreenBufferSize(8); + f.setBlueBufferSize(8); + // QOpenGLWindow seems to dislike alphabuffer in stereo rendering... + //f.setAlphaBufferSize(8); + f.setDepthBufferSize(24); + f.setStereo(true); + this->setFormat(f); } -void GLCanvas::OnTransform(gfx::InputCommand com, int indx, - gfx::TransformTarget trg, Real val) -{ - // does not request a redraw on purpose, in order to chain OnTransform calls - Scene::Instance().Apply(gfx::InputEvent(gfx::INPUT_DEVICE_MOUSE,com,indx, - trg,val*0.5),false); +void GLCanvas::initializeGL() { + LOG_DEBUG("GLCanvas::initializeGL()"); + gfx::Scene::Instance().InitGL(); } -void GLCanvas::initializeGL() -{ - static bool init=false; - if(!init) { - init=true; - } +void GLCanvas::paintGL() { - LOG_DEBUG("GLCanvas::initializeGL()"); - Scene::Instance().InitGL(); - LOG_DEBUG("GLCanvas::registering with scene"); - Scene::Instance().Register(this); -} + // static variables for benchmarking + static int benchmark_count = 0; + static std::chrono::steady_clock::time_point timer; -void GLCanvas::resizeGL(int w, int h) -{ - LOG_DEBUG("GLCanvas::resizeGL("<<w<<","<<h<<")"); - Scene::Instance().Resize(w,h); -} + if(bench_flag_) { + ++benchmark_count; + if(benchmark_count == 20) { + benchmark_count = 0; + int ms = std::chrono::duration_cast<std::chrono::milliseconds>( + std::chrono::steady_clock::now() - timer).count(); + Real fps = Real(20) / (Real(ms) * 0.001); + LOG_ERROR(fps << " fps"); + timer = std::chrono::steady_clock::now(); + } + this->update(); + } -void GLCanvas::paintGL() -{ - Scene::Instance().RenderGL(); + gfx::Scene::Instance().RenderGL(); Tool* tool=ToolManager::Instance().GetActiveTool(); if (tool) { tool->RenderGL(); } } -void GLCanvas::wheelEvent(QWheelEvent* event) -{ - OnTransform(gfx::INPUT_COMMAND_TRANSZ,0,gfx::TRANSFORM_VIEW, - 0.2*static_cast<Real>(-event->delta())); -} -bool GLCanvas::IsToolEvent(QInputEvent* event) const -{ - return event->modifiers() & Qt::ControlModifier; +void GLCanvas::resizeGL(int w, int h) { + gfx::Scene::Instance().Resize(w, h); } -MouseEvent::Buttons GLCanvas::TranslateButtons(Qt::MouseButtons buttons) const -{ - return MouseEvent::Buttons(buttons); -} +void GLCanvas::mouseMoveEvent(QMouseEvent* event) { -void GLCanvas::mouseMoveEvent(QMouseEvent* event) -{ if (!(show_beacon_ || event->buttons())) { return; } + if (this->IsToolEvent(event)) { if (ToolManager::Instance().GetActiveTool()) { MouseEvent mouse_event(this->TranslateButtons(event->buttons()), @@ -204,8 +161,8 @@ void GLCanvas::mouseMoveEvent(QMouseEvent* event) this->DoRefresh(); } -void GLCanvas::mousePressEvent(QMouseEvent* event) -{ +void GLCanvas::mousePressEvent(QMouseEvent* event) { + if (this->IsToolEvent(event)) { if (ToolManager::Instance().GetActiveTool()) { MouseEvent mouse_event(this->TranslateButtons(event->button()), @@ -221,8 +178,8 @@ void GLCanvas::mousePressEvent(QMouseEvent* event) this->DoRefresh(); } -void GLCanvas::mouseReleaseEvent(QMouseEvent* event) -{ +void GLCanvas::mouseReleaseEvent(QMouseEvent* event) { + if (this->IsToolEvent(event)) { if (ToolManager::Instance().GetActiveTool()) { MouseEvent mouse_event(this->TranslateButtons(event->button()), @@ -239,8 +196,8 @@ void GLCanvas::mouseReleaseEvent(QMouseEvent* event) this->DoRefresh(); } -void GLCanvas::mouseDoubleClickEvent(QMouseEvent* event) -{ +void GLCanvas::mouseDoubleClickEvent(QMouseEvent* event) { + if (this->IsToolEvent(event)) { if (ToolManager::Instance().GetActiveTool()) { MouseEvent mouse_event(this->TranslateButtons(event->button()), @@ -263,32 +220,151 @@ void GLCanvas::mouseDoubleClickEvent(QMouseEvent* event) } } -void GLCanvas::RequestContextMenu(const QPoint& pos) -{ - QPoint pick_pos(pos.x(),this->height()-pos.y()); - scene_menu_->SetPickPoint(pick_pos); - scene_menu_->ShowMenu(this->mapToGlobal(pos)); +void GLCanvas::OnTransform(gfx::InputCommand com, int indx, + gfx::TransformTarget trg, Real val) { + // does not request a redraw on purpose, in order to chain OnTransform calls + ost::gfx::Scene::Instance().Apply(gfx::InputEvent(gfx::INPUT_DEVICE_MOUSE, com, indx, + trg, val*0.5),false); } -void GLCanvas::HandleMousePressEvent(QMouseEvent* event) -{ +void GLCanvas::SetTestMode(bool f) { + gfx::Scene::Instance().SetTestMode(f); +} + +void GLCanvas::Export(const String& fname, unsigned int width, + unsigned int height, bool transparent) { + this->Export(fname, width, height, 0, transparent); +} + +void GLCanvas::Export(const String& fname, unsigned int width, + unsigned int height, int max_samples, bool transparent) { + + // setup of context, surface, fbo etc are implemented as in the QT + // threadrenderer example + + gfx::Viewport old_vp = gfx::Scene::Instance().GetViewport(); + + if(old_vp.width == static_cast<int>(width) && + old_vp.height == static_cast<int>(height) && max_samples <= 0) { + // just grab the framebuffer, no need for fancy offscreen rendering... + this->Export(fname, transparent); + return; + } + + offscreen_flag_ = true; + + if(offscreen_surface_ == NULL) { + offscreen_surface_ = new QOffscreenSurface(); + QSurfaceFormat f = this->context()->format(); + if(max_samples > 0) { + f.setSamples(max_samples); + } + offscreen_surface_->setFormat(f); + offscreen_surface_->create(); + } + + if(offscreen_context_ == NULL) { + QOpenGLContext *current = this->context(); + // Some GL implementations require that the currently bound context is + // made non-current before we set up sharing, so we doneCurrent here + // and makeCurrent down below while setting up our own context. + current->doneCurrent(); + offscreen_context_ = new QOpenGLContext(); + QSurfaceFormat f = this->context()->format(); + if(max_samples > 0) { + f.setSamples(max_samples); + } + offscreen_context_->setFormat(f); + offscreen_context_->setShareContext(current); + offscreen_context_->create(); + offscreen_context_->makeCurrent(offscreen_surface_); + gfx::Scene::Instance().ContextSwitch(); + gfx::Scene::Instance().InitGL(false); + } else { + offscreen_context_->makeCurrent(offscreen_surface_); + gfx::Scene::Instance().ContextSwitch(); + // the following InitGL sets potentially changed glClearcolor etc + // could be made more efficient... + gfx::Scene::Instance().InitGL(false); + } + + if(offscreen_fbo_ == NULL || + offscreen_fbo_->width() != static_cast<int>(width) || + offscreen_fbo_->height() != static_cast<int>(height)) { + if(offscreen_fbo_ != NULL) { + delete offscreen_fbo_; + } + QOpenGLFramebufferObjectFormat fbo_format; + // the following flag is required for OpenGL depth testing + fbo_format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + offscreen_fbo_ = new QOpenGLFramebufferObject(width, height, fbo_format); + } + + offscreen_fbo_->bind(); + gfx::Scene::Instance().Resize(width, height); + this->paintGL(); + + if(!transparent) { + gfx::Scene::Instance().SetAlphaBias(1.0); + } + + offscreen_context_->functions()->glFlush(); + QImage image = offscreen_fbo_->toImage(); + offscreen_fbo_->release(); + + if(!transparent) { + gfx::Scene::Instance().SetAlphaBias(0.0); + } + + image.save(QString(fname.c_str())); + offscreen_flag_ = false; + this->MakeActive(); + gfx::Scene::Instance().Resize(old_vp.width, old_vp.height); + gfx::Scene::Instance().ContextSwitch(); +} + +void GLCanvas::Export(const String& fname, bool transparent) { + + if(!transparent) { + gfx::Scene::Instance().SetAlphaBias(1.0); + } + QImage image = this->grabFramebuffer(); + if(!transparent) { + gfx::Scene::Instance().SetAlphaBias(0.0); + } + image.save(QString(fname.c_str())); +} + +bool GLCanvas::IsToolEvent(QInputEvent* event) const { + return event->modifiers() & Qt::ControlModifier; +} + +MouseEvent::Buttons GLCanvas::TranslateButtons(Qt::MouseButtons buttons) const { + return MouseEvent::Buttons(buttons); +} + +void GLCanvas::HandleMousePressEvent(QMouseEvent* event) { gfx::Scene& scene=gfx::Scene::Instance(); scene.Pick(event->x(), scene.GetViewport().height-event->y(), 0); event->accept(); + + // if its a right click, we emit the ContextMenu signal, + // maybe someone wants to implement something interactive on top... + if(event->buttons() == Qt::RightButton) { + emit CustomContextMenuRequested(event->pos()); + } } -void GLCanvas::HandleMouseReleaseEvent(QMouseEvent* event) -{ +void GLCanvas::HandleMouseReleaseEvent(QMouseEvent* event) { event->accept(); } -void GLCanvas::HandleMouseMoveEvent(QMouseEvent* event) -{ +void GLCanvas::HandleMouseMoveEvent(QMouseEvent* event) { int indx=0; gfx::TransformTarget trg=gfx::TRANSFORM_VIEW; if(show_beacon_) { - Scene::Instance().SetBeacon(event->x(),size().height()-event->y()); + ost::gfx::Scene::Instance().SetBeacon(event->x(),size().height()-event->y()); } QPoint delta=QPoint(event->x(), event->y())-last_pos_; @@ -333,62 +409,10 @@ void GLCanvas::HandleMouseMoveEvent(QMouseEvent* event) event->accept(); } - -void GLCanvas::CopySelectionToClipboard() -{ - gfx::EntityP ent; - - // TODO: this needs a re-write based on the new GfxNodeVisitor -#if 0 - // find first entity connect with non-empty selection - gfx::GfxObjList& obj=gfx::Scene::Instance().SceneObjects(); - for (gfx::GfxObjList::iterator i=obj.begin(), e=obj.end(); i!=e; ++i) { - if (ent=dyn_cast<gfx::Entity>(*i)) { - if (ent->GetView().GetAtomCount()>0) { - break; - } else { - ent=gfx::EntityP(); - } - } - } -#endif - - if (!ent) - return; - - mol::EntityView sel=ent->GetSelection(); - mol::EntityView view=ent->GetView(); - mol::ChainViewList chains=view.GetChainList(); - QString pretty; - for (mol::ChainViewList::iterator c=chains.begin(), ec=chains.end(); c!=ec; ++c) { - mol::ResidueViewList res=c->GetResidueList(); - std::stringstream seq1; - std::stringstream seq2; - for (mol::ResidueViewList::iterator r=res.begin(), er=res.end(); r!=er; ++r) { - mol::ResidueView rv=*r; - if (!rv.IsPeptideLinking() || rv.GetOneLetterCode()=='?') - continue; - seq1 << rv.GetOneLetterCode(); - if (sel.ViewForHandle(rv.GetHandle()).IsValid()) { - seq2 << rv.GetOneLetterCode(); - } else { - seq2 << '-'; - } - } - seq::AlignmentHandle a=seq::CreateAlignment(); - a.AddSequence(seq::CreateSequence(ent->GetName(), seq1.str())); - a.AddSequence(seq::CreateSequence(ent->GetName()+" SEL", seq2.str())); - pretty+=QString(a.ToString(80).c_str()); - } - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(pretty); -} - -void GLCanvas::keyPressEvent(QKeyEvent* event) -{ +void GLCanvas::keyPressEvent(QKeyEvent* event) { if(event->key()==Qt::Key_Space) { show_beacon_=true; - Scene::Instance().SetBeacon(last_pos_.x(),size().height()-last_pos_.y()); + gfx::Scene::Instance().SetBeacon(last_pos_.x(),size().height()-last_pos_.y()); DoRefresh(); setCursor(Qt::BlankCursor); } @@ -400,12 +424,9 @@ void GLCanvas::keyPressEvent(QKeyEvent* event) } else if(event->key()==Qt::Key_F) { OnTransform(gfx::INPUT_COMMAND_TOGGLE_FOG,0,gfx::TRANSFORM_VIEW,0.0); return; - } else if(event->key()==Qt::Key_B) { + } else if(event->key()==Qt::Key_B) { bench_flag_=!bench_flag_; return; - } else if (event->key()==Qt::Key_C) { - this->CopySelectionToClipboard(); - return; } else if(event->key()==Qt::Key_1) { gfx::Scene::Instance().SetShadingMode("fallback"); DoRefresh(); @@ -451,75 +472,23 @@ void GLCanvas::keyPressEvent(QKeyEvent* event) event->ignore(); } -void GLCanvas::keyReleaseEvent(QKeyEvent* event) -{ +void GLCanvas::keyReleaseEvent(QKeyEvent* event) { if(event->key()==Qt::Key_Space) { show_beacon_=false; - Scene::Instance().SetBeaconOff(); + gfx::Scene::Instance().SetBeaconOff(); DoRefresh(); setCursor(Qt::ArrowCursor); return; } - if(event->key()==Qt::Key_Alt){ - emit ReleaseFocus(); - return; - } - QGLWidget::keyReleaseEvent(event); } -#ifndef _MSC_VER -Real delta_time(const timeval& t1, const timeval& t2) -{ - return 1e-6*static_cast<Real>((t2.tv_sec*1e6+t2.tv_usec)-(t1.tv_sec*1e6+t1.tv_usec)); -} -#endif - -void GLCanvas::timerEvent(QTimerEvent * event) -{ - -#if QT_VERSION>= 0x040600 - // gesture support - if (gesture_timer_.timerId()==event->timerId()) { - if (angular_speed_!=0.0) { - angular_speed_*=0.95; - this->OnTransform(gfx::INPUT_COMMAND_ROTZ, 0, gfx::TRANSFORM_VIEW, - static_cast<Real>(angular_speed_)); - if (std::abs(angular_speed_)<0.001) { - angular_speed_=0.0; - gesture_timer_.stop(); - } - this->update(); - } - return; - } -#endif -#ifndef _MSC_VER - static struct timeval time0,time1; - static int count=0; -#endif - if(refresh_ || bench_flag_) { - refresh_=false; - master_timer_.stop(); - this->updateGL(); - master_timer_.start(10,this); - } - -#ifndef _MSC_VER - if(bench_flag_) { - ++count; - if(count==20) { - count=0; - gettimeofday(&time1,NULL); - LOG_ERROR(20.0/delta_time(time0,time1) << " fps"); - gettimeofday(&time0,NULL); - } - } -#endif +void GLCanvas::wheelEvent(QWheelEvent* event) { + OnTransform(gfx::INPUT_COMMAND_TRANSZ,0,gfx::TRANSFORM_VIEW, + 0.2*static_cast<Real>(-event->delta())); } -void GLCanvas::SetTestMode(bool f) -{ - Scene::Instance().SetTestMode(f); +bool GLCanvas::event(QEvent* event) { + return QOpenGLWindow::event(event); } }} // ns diff --git a/modules/gui/src/gl_canvas.hh b/modules/gui/src/gl_canvas.hh index dbc879e913ee53e17aa57c7d48defb094dfad53e..36d74b2a77bcb582e22dbf58c7a27b5ca241a254 100644 --- a/modules/gui/src/gl_canvas.hh +++ b/modules/gui/src/gl_canvas.hh @@ -19,94 +19,93 @@ #ifndef OST_GUI_GL_CANVAS_HH #define OST_GUI_GL_CANVAS_HH - - -#include <ost/gui/tools/tool.hh> -#include <ost/gui/scene_menu.hh> #include <ost/gfx/glwin_base.hh> +#include <ost/gui/tools/tool.hh> #include <ost/gfx/input.hh> -#include <ost/gfx/gfx_object_fw.hh> - // Qt includes must come last -#include <QGLWidget> -#include <QBasicTimer> -class QMenu; -class QMouseEvent; - -namespace ost { namespace gui { +#include <QOpenGLWindow> +#include <QSurfaceFormat> -class GLCanvas; +// forward declaration +class QResizeEvent; +class QOpenGLFramebufferObject; +class QOpenGLContext; +class QOffscreenSurface; -class GLWin; +namespace ost { namespace gui { -class DLLEXPORT_OST_GUI GLCanvas : public QGLWidget, public gfx::GLWinBase -{ +class GLCanvas : public QOpenGLWindow, public gfx::GLWinBase { Q_OBJECT; + public: - GLCanvas(GLWin *gl_win, QWidget* parent, - const QGLFormat& f = QGLFormat::defaultFormat()); + GLCanvas(); + virtual ~GLCanvas(); // gfx::GLWinBase interface virtual void MakeActive(); - virtual void DoRefresh(); + virtual void DoRefresh() {this->update(); } virtual void StatusMessage(const String& m); virtual bool HasStereo() const {return format().stereo();}; - virtual bool HasMultisample() const {return format().sampleBuffers();} + virtual bool HasMultisample() const {return format().samples() > 1;} + + // QSurfaceFormat for GL context setup + void SetDefaultFormat(); + void SetStereoFormat(); // central point for sending input to the gfx layer void OnTransform(gfx::InputCommand, int indx, gfx::TransformTarget, Real val); void SetTestMode(bool f); - + + // Grab images from framebuffer and dump to disk + virtual void Export(const String& fname, unsigned int width, + unsigned int height, bool transparent); + + virtual void Export(const String& fname, unsigned int width, + unsigned int height, int max_samples, bool transparent); + + virtual void Export(const String& fname, bool transparent); + signals: - void ReleaseFocus(); - + void CustomContextMenuRequested(const QPoint& point); + protected: - void Select(const String& query); - void CopySelectionToClipboard(); - // QGLWidget interface + + // QOpenGLWindow interface virtual void initializeGL(); - virtual void resizeGL(int w, int h); virtual void paintGL(); + virtual void resizeGL(int w, int h); + // event handling virtual void mouseMoveEvent(QMouseEvent* event); virtual void mousePressEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event); - virtual void mouseDoubleClickEvent(QMouseEvent* event); - + virtual void mouseDoubleClickEvent(QMouseEvent* event); + virtual void keyPressEvent(QKeyEvent* event); virtual void keyReleaseEvent(QKeyEvent* event); - virtual void timerEvent(QTimerEvent * event); virtual void wheelEvent(QWheelEvent* event); virtual bool event(QEvent* event); -private slots: - virtual void RequestContextMenu(const QPoint& pos); private: -#if QT_VERSION >= 0x040600 - bool GestureEvent(QGestureEvent* event); -#endif + bool IsToolEvent(QInputEvent* event) const; MouseEvent::Buttons TranslateButtons(Qt::MouseButtons buttons) const; void HandleMousePressEvent(QMouseEvent* event); void HandleMouseReleaseEvent(QMouseEvent* event); void HandleMouseMoveEvent(QMouseEvent* event); - void build_context_menu(); - void prepare_context_menu(const QPoint& pos); - GLWin* glwin_; - int mouse_key_mask_; - bool refresh_; - QBasicTimer master_timer_; - bool bench_flag_; + QPoint last_pos_; - SceneMenu* scene_menu_; - bool show_beacon_; - float angular_speed_; -#if QT_VERSION>=0x04600 - QBasicTimer gesture_timer_; -#endif + bool show_beacon_; + bool bench_flag_; + + // for image export + bool offscreen_flag_; + QOpenGLContext* offscreen_context_; + QOffscreenSurface* offscreen_surface_; + QOpenGLFramebufferObject* offscreen_fbo_; }; }} // ns diff --git a/modules/gui/src/gl_win.cc b/modules/gui/src/gl_win.cc index fc584da9b937abeb26c2eb282cc34d8781fef517..ee29b1f719014bbb291b0a2b617d9440fb758738 100644 --- a/modules/gui/src/gl_win.cc +++ b/modules/gui/src/gl_win.cc @@ -22,193 +22,91 @@ #include <ost/gfx/scene.hh> #include <ost/gui/gl_win.hh> +#include <ost/gui/gl_canvas.hh> #include <ost/gui/tools/tool_manager.hh> #include <ost/gui/tools/selection_tool.hh> #include <ost/gui/tools/manipulator.hh> #include <ost/gui/tools/measure_tool.hh> #include <ost/gui/perspective.hh> -#include <ost/gui/gl_canvas.hh> #include <ost/gui/tools/tool.hh> #include <ost/gui/tools/tool_bar.hh> +#include <ost/gui/scene_menu.hh> #if OST_IMG_ENABLED # include <ost/gui/tools/map_tool.hh> #endif -#include <QApplication> -#include <QDesktopWidget> -#include <QIcon> -#include <QActionGroup> -#include <QLabel> -#include <QStatusBar> -#include <QVBoxLayout> -#include <QStatusBar> - /* Authors: Ansgar Philippsen, Marco Biasini */ namespace ost { namespace gui { -GLWin::GLWin(QWidget* p, bool try_stereo): -Widget(NULL, p), -gl_canvas_(NULL) -{ - QMainWindow* main=new QMainWindow; - - if(try_stereo) { - LOG_VERBOSE("GLCanvas: trying stereo visuals first"); - for(int format_id=4;format_id>=0;--format_id) { - QGLFormat format=GLWin::CreateFormat(format_id); - if (try_stereo) { - format.setStereo(true); - } - gl_canvas_=new GLCanvas(this, main, format); - if(gl_canvas_->isValid() && gl_canvas_->format().stereo()) { - break; // format is fine - } else { - delete gl_canvas_; // delete this canvas and try a less sophisticated format - gl_canvas_=0; - } - } - } - if(!gl_canvas_) { - if(try_stereo) { - LOG_VERBOSE("GLCanvas: no stereo visual found, trying normal ones"); - } - for(int format_id=4;format_id>=0;--format_id) { - QGLFormat format=GLWin::CreateFormat(format_id); - gl_canvas_=new GLCanvas(this, main, format); - if(gl_canvas_->isValid()) { - break; // format is fine - } else { - delete gl_canvas_; // delete this canvas and try a less sophisticated format - gl_canvas_=0; - } - } - } +GLWin::GLWin(QWidget* p, bool try_stereo): Widget(NULL, p) { - if(!gl_canvas_ || !gl_canvas_->isValid()) { - LOG_ERROR("GLCanvas: no valid GL context found, this is pretty fatal"); - return; - } - this->SetInternalWidget(main); - gfx::Scene::Instance().AttachObserver(this); - QGLFormat format = gl_canvas_->format(); - - - LOG_VERBOSE("GLCanvas: using " << format.redBufferSize() << "." - << format.greenBufferSize() << "." - << format.blueBufferSize() << "." - << format.alphaBufferSize() << " RGBA bits, " - << format.depthBufferSize() << " depth bits, " - << format.accumBufferSize() << " accum bits, and " - << format.stencilBufferSize() << " stencil bits") - if(gl_canvas_->format().stereo()) { - LOG_VERBOSE("GLCanvas: using stereo visual"); - } else { - LOG_VERBOSE("GLCanvas: no stereo visual found"); - } - if(format.sampleBuffers()) { - LOG_VERBOSE("GLCanvas: using multisampling with " << format.samples() << " samples per pixel"); - } else { - LOG_VERBOSE("GLCanvas: no multisampling"); + gl_canvas_ = new GLCanvas; + + if(try_stereo) { + gl_canvas_->SetStereoFormat(); + } else{ + gl_canvas_->SetDefaultFormat(); } - main->setCentralWidget(gl_canvas_); - connect(gl_canvas_, SIGNAL(ReleaseFocus()), this, SIGNAL(ReleaseFocus())); - connect(&ToolManager::Instance(), SIGNAL(ActiveToolChanged(Tool*)), this, SLOT(ActiveToolChanged(Tool*))); - toolbar_=build_toolbar(); - main->addToolBar(Qt::LeftToolBarArea, toolbar_); + + gl_canvas_widget_ = QWidget::createWindowContainer(gl_canvas_); + gl_canvas_widget_->setFocusPolicy(Qt::StrongFocus); + gl_canvas_widget_->setMouseTracking(true); + + toolbar_ = new ToolBar(this); ToolManager::Instance().AddTool(new SelectionTool); ToolManager::Instance().AddTool(new Manipulator); ToolManager::Instance().AddTool(new MeasureTool); #if OST_IMG_ENABLED ToolManager::Instance().AddTool(new MapTool); #endif -} -void GLWin::ActiveToolChanged(Tool* t) -{ - gfx::Scene::Instance().RequestRedraw(); + scene_menu_ = new SceneMenu(); + + QMainWindow* main = new QMainWindow; + main->setCentralWidget(gl_canvas_widget_); + main->addToolBar(Qt::LeftToolBarArea, toolbar_); + this->SetInternalWidget(main); + gfx::Scene::Instance().AttachObserver(this); + + connect(gl_canvas_, SIGNAL(CustomContextMenuRequested(const QPoint&)), + this, SLOT(RequestContextMenu(const QPoint&))); + connect(&ToolManager::Instance(), SIGNAL(ActiveToolChanged(Tool*)), + this, SLOT(ActiveToolChanged(Tool*))); } -QGLFormat GLWin::CreateFormat(int fid) -{ - QGLFormat format = QGLFormat::defaultFormat(); - if(fid==4) { - format.setDepthBufferSize(24); - format.setRedBufferSize(8); - format.setGreenBufferSize(8); - format.setBlueBufferSize(8); - format.setAlpha(true); - format.setAlphaBufferSize(8); - format.setAccum(true); - format.setStencil(true); - format.setSampleBuffers(true); - } else if(fid==3) { - format.setDepthBufferSize(24); - format.setRedBufferSize(8); - format.setGreenBufferSize(8); - format.setBlueBufferSize(8); - format.setAlpha(true); - format.setAlphaBufferSize(8); - format.setAccum(true); - format.setSampleBuffers(true); - } else if(fid==2) { - format.setDepthBufferSize(12); - format.setRedBufferSize(8); - format.setGreenBufferSize(8); - format.setBlueBufferSize(8); - format.setAlpha(true); - format.setAlphaBufferSize(8); - format.setAccum(true); - format.setSampleBuffers(true); - } else if(fid==1) { - format.setDepthBufferSize(12); - format.setRedBufferSize(8); - format.setGreenBufferSize(8); - format.setBlueBufferSize(8); - format.setAlpha(true); - format.setAlphaBufferSize(8); - } else { - format.setDepthBufferSize(6); - format.setRedBufferSize(4); - format.setGreenBufferSize(4); - format.setBlueBufferSize(4); - } - return format; +void GLWin::ActiveToolChanged(Tool* t) { + gfx::Scene::Instance().RequestRedraw(); } -GLWin::~GLWin() -{ +GLWin::~GLWin() { gfx::Scene::Instance().DetachObserver(this); } -void GLWin::SetTestMode(bool f) -{ +void GLWin::SetTestMode(bool f) { gl_canvas_->SetTestMode(f); } -ToolBar* GLWin::build_toolbar() -{ - ToolBar* tb=new ToolBar(this); - return tb; -} - -void GLWin::StatusMessage(const String& m) -{ +void GLWin::StatusMessage(const String& m) { GostyApp::Instance()->GetPerspective()->StatusMessage(m); } -bool GLWin::Restore(const QString& prefix) -{ +bool GLWin::Restore(const QString& prefix) { return true; } -bool GLWin::Save(const QString& prefix) -{ +bool GLWin::Save(const QString& prefix) { return true; } +void GLWin::RequestContextMenu(const QPoint& pos) { + QPoint pick_pos(pos.x(), gl_canvas_->height()-pos.y()); + scene_menu_->SetPickPoint(pick_pos); + scene_menu_->ShowMenu(gl_canvas_->mapToGlobal(pos)); +} + }} // ns diff --git a/modules/gui/src/gl_win.hh b/modules/gui/src/gl_win.hh index 3e32df5c2b1b56c22ce7297ec9687dff124b4dcc..2daf43d3d876a715b9f7b6969c65155c503c556c 100644 --- a/modules/gui/src/gl_win.hh +++ b/modules/gui/src/gl_win.hh @@ -21,25 +21,20 @@ #include <ost/gfx/scene_observer.hh> - #include <ost/gui/module_config.hh> #include <ost/gui/widget.hh> -#include <QGLFormat> -#include <QActionGroup> - -class QStatusBar; -class QAction; - /* Authors: Ansgar Philippsen, Marco Biasini */ + namespace ost { namespace gui { class GLCanvas; class ToolBar; class Tool; +class SceneMenu; class DLLEXPORT_OST_GUI GLWin: public Widget, public gfx::SceneObserver { @@ -49,9 +44,6 @@ public: ~GLWin(); void SetTestMode(bool f); -signals: - void ReleaseFocus(); - public: virtual bool Restore(const QString& prefix); virtual bool Save(const QString& prefix); @@ -59,21 +51,15 @@ public: public slots: void StatusMessage(const String& m); void ActiveToolChanged(Tool* t); -private: - static QGLFormat CreateFormat(int fid); - GLCanvas* gl_canvas_; - QAction* edit_rigid_action_; - QAction* edit_torsion_action_; - QAction* edit_angle_action_; - QAction* edit_rotamer_action_; - QAction* smode_atom_action_; - QAction* smode_residue_action_; - QAction* smode_chain_action_; - - ToolBar* toolbar_; - QStatusBar* status_bar_; - ToolBar* build_toolbar(); +private slots: + virtual void RequestContextMenu(const QPoint& pos); + +private: + GLCanvas* gl_canvas_; + QWidget* gl_canvas_widget_; + ToolBar* toolbar_; + SceneMenu* scene_menu_; }; }} // ns diff --git a/modules/gui/src/gosty_app.cc b/modules/gui/src/gosty_app.cc index 949c764910e16d957ccec9bd1edba5e9c24b6ec5..de0b008cc42957e2f5a60efd975d1f86935b5231 100644 --- a/modules/gui/src/gosty_app.cc +++ b/modules/gui/src/gosty_app.cc @@ -66,6 +66,10 @@ GostyApp* GostyApp::Instance() { return GostyApp::app_; } +bool GostyApp::ValidInstance() { + return GostyApp::app_ != NULL; +} + void GostyApp::SetAppTitle(const QString& app_title) { main_->setWindowTitle(app_title); @@ -118,17 +122,8 @@ ost::img::gui::DataViewer* GostyApp::CreateDataViewer(const ost::img::ImageHandl } else { - viewer=new ost::img::gui::DataViewer(main_,d,name); - QMdiSubWindow* mdi=new QMdiSubWindow(this->GetPerspective()->GetMainArea()); - mdi->setWindowTitle(name); - mdi->setWidget(viewer); - mdi->setFocusProxy(viewer); - viewer->setAttribute(Qt::WA_DeleteOnClose); - mdi->setAttribute(Qt::WA_DeleteOnClose); - viewer->setParent(mdi); - this->GetPerspective()->GetMainArea()->addSubWindow(mdi); - mdi->showMaximized(); - connect(viewer,SIGNAL(released()),mdi,SLOT(close())); + viewer=new ost::img::gui::DataViewer(NULL,d,name); + this->GetPerspective()->GetMainArea()->AddWidget(name, viewer); } return viewer; diff --git a/modules/gui/src/gosty_app.hh b/modules/gui/src/gosty_app.hh index 47b0f23fadfe151a262e25f39910b5da9eda1c24..5398c01c83a71474a29cf9c3c394bb600f0c83b9 100644 --- a/modules/gui/src/gosty_app.hh +++ b/modules/gui/src/gosty_app.hh @@ -157,6 +157,11 @@ public: /// \return the GostyApp instance static GostyApp* Instance(); + /// \brief + /// GostyApp is implemented as Singleton. This returns whether there is + /// already a valid instance around + static bool ValidInstance(); + /// \brief This methods sets the Title of this Application /// \param app_title Title that will be displayed in the title bar void SetAppTitle(const QString& app_title); diff --git a/modules/gui/src/main.cc b/modules/gui/src/main.cc index f3b1c6f6e76f005ab2701a976980bd5af5cfb3a9..e68f5fcf8e68dab588048543c8e19f3b93588028 100644 --- a/modules/gui/src/main.cc +++ b/modules/gui/src/main.cc @@ -50,6 +50,7 @@ #include <QFile> #include <QDragEnterEvent> #include <QDropEvent> +#include <QMimeData> namespace ost { namespace gui { diff --git a/modules/gui/src/panels/event_button.cc b/modules/gui/src/panels/event_button.cc index f541dcc87b8dd22150a6a976e980201248396244..3c789644068865af3cd69966d29d58e763a0bc96 100644 --- a/modules/gui/src/panels/event_button.cc +++ b/modules/gui/src/panels/event_button.cc @@ -18,7 +18,8 @@ //------------------------------------------------------------------------------ #include "event_button.hh" - +#include <QMimeData> +#include <QDrag> namespace ost { namespace gui { diff --git a/modules/gui/src/panels/panel_bar_widget_holder.cc b/modules/gui/src/panels/panel_bar_widget_holder.cc index 358f86eef565b82f586c3b1003b49f58a40e3ad4..0d979e8221710c8ced9ea8466249c6d091aadd3a 100644 --- a/modules/gui/src/panels/panel_bar_widget_holder.cc +++ b/modules/gui/src/panels/panel_bar_widget_holder.cc @@ -42,6 +42,9 @@ #include <QAction> #include <QComboBox> #include <QDebug> +#include <QMimeData> +#include <QDrag> + /* Author: Marco Biasini, Stefan Scheuber */ diff --git a/modules/gui/src/panels/tabbed_panel_bar.cc b/modules/gui/src/panels/tabbed_panel_bar.cc index aacb5cb3d0b52205c7eb84f61e67860dd9ee508a..b025507622dec5fd425576d279379416fc70b430 100644 --- a/modules/gui/src/panels/tabbed_panel_bar.cc +++ b/modules/gui/src/panels/tabbed_panel_bar.cc @@ -27,6 +27,8 @@ #include <QApplication> #include <QSettings> #include <QDir> +#include <QMimeData> +#include <QDrag> namespace ost { namespace gui { diff --git a/modules/gui/src/python_shell/python_namespace_tree_model.hh b/modules/gui/src/python_shell/python_namespace_tree_model.hh index da21a394f9bb38671bc52116ce1d588ebdcd152e..21b283e6b57616237f84bb2d3f52dc05cd89b81b 100644 --- a/modules/gui/src/python_shell/python_namespace_tree_model.hh +++ b/modules/gui/src/python_shell/python_namespace_tree_model.hh @@ -50,7 +50,8 @@ public: int columnCount(const QModelIndex&parent=QModelIndex()) const; QModelIndex index(int row, int column, const QModelIndex& parent=QModelIndex()) const; QModelIndex parent(const QModelIndex &index) const; - void Reset() { this->reset(); } + void Reset() {this->beginResetModel(); + this->endResetModel(); } public slots: void NamespaceChanged(); diff --git a/modules/gui/src/python_shell/python_shell_widget.cc b/modules/gui/src/python_shell/python_shell_widget.cc index 9c816f5dcb6585bfba7af6ec202bae17e08ad75a..93d3f3896713216902cb5b3ac37deb324ed17202 100644 --- a/modules/gui/src/python_shell/python_shell_widget.cc +++ b/modules/gui/src/python_shell/python_shell_widget.cc @@ -42,6 +42,7 @@ #include <QDirModel> #include <QStringList> #include <QDebug> +#include <QMimeData> /* Authors: Marco Biasini, Andreas Schenk diff --git a/modules/gui/src/scene_win/scene_win_model.cc b/modules/gui/src/scene_win/scene_win_model.cc index 2acc15eb393a8abc7b55669caf08faa1b5235572..c9cf6d681304cc733a079344b440d810bc8d2e51 100644 --- a/modules/gui/src/scene_win/scene_win_model.cc +++ b/modules/gui/src/scene_win/scene_win_model.cc @@ -36,6 +36,7 @@ #include <QSize> #include <QFont> #include <QDebug> +#include <QDataStream> namespace ost { namespace gui { diff --git a/modules/gui/src/sequence_viewer/alignment_view_object.cc b/modules/gui/src/sequence_viewer/alignment_view_object.cc index a12a2e54b48b012285a523db7527b21536002148..9084ee7fa74c76efa22992d547b964e27ca416b4 100644 --- a/modules/gui/src/sequence_viewer/alignment_view_object.cc +++ b/modules/gui/src/sequence_viewer/alignment_view_object.cc @@ -143,19 +143,19 @@ QVariant AlignmentViewObject::GetData(int row, int column, int role) if(column -1 < conservation_1_.size()){ return QVariant(conservation_1_[column-1]); } - return QVariant(Qt::transparent); + return QVariant(QColor(Qt::transparent)); } if(role == Qt::ForegroundRole){ if(column -1 < conservation_1_.size()){ if(conservation_1_[column-1].red()>128){ - return QVariant(Qt::black); + return QVariant(QColor(Qt::black)); } else{ - return QVariant(Qt::white); + return QVariant(QColor(Qt::white)); } } - return QVariant(Qt::transparent); + return QVariant(QColor(Qt::transparent)); } } else if(this->GetCurrentDisplayMode() == conservation_mode_2){ @@ -163,13 +163,13 @@ QVariant AlignmentViewObject::GetData(int row, int column, int role) if(column -1 < conservation_2_.size()){ return QVariant(conservation_2_[column-1]); } - return QVariant(Qt::transparent); + return QVariant(QColor(Qt::transparent)); } if(role == Qt::ForegroundRole){ if(column -1 < conservation_2_.size()){ - return QVariant(Qt::black); + return QVariant(QColor(Qt::black)); } - return QVariant(Qt::transparent); + return QVariant(QColor(Qt::transparent)); } } } diff --git a/modules/gui/src/tools/measure_tool.cc b/modules/gui/src/tools/measure_tool.cc index 5b4cc3d2cd039fb59cbf3bbe0bc6326bb2a8e2e6..730fffa94a086a7d789570d71446ecb0f7b06ad4 100644 --- a/modules/gui/src/tools/measure_tool.cc +++ b/modules/gui/src/tools/measure_tool.cc @@ -31,8 +31,6 @@ #include <ost/platform.hh> #include <ost/gfx/scene.hh> -#include <ost/gui/gl_canvas.hh> - #include <ost/geom/vec3.hh> #include <QDir> diff --git a/modules/gui/src/tools/tool.hh b/modules/gui/src/tools/tool.hh index 3d79931cbddde29657a9d9f181b5392d9a302029..945855cca912d657573e8a1d236da68712e26cdc 100644 --- a/modules/gui/src/tools/tool.hh +++ b/modules/gui/src/tools/tool.hh @@ -47,7 +47,7 @@ class GLCanvas; /// /// \section input_events Input Events /// -/// Tools receive input events when the Control key (Command on MacOS X) is +/// Tools receive input events when the Control key (Command on macOS) is /// pressed. This includes both keyboard events and mouse events such as mouse /// move events, clicks and Real clicks. /// diff --git a/modules/gui/src/tools/tool_manager.cc b/modules/gui/src/tools/tool_manager.cc index 249c3a0cee51e94383434c725016065eb7d9cc39..55cd23137718132713e340713dff29f1fc89d8ab 100644 --- a/modules/gui/src/tools/tool_manager.cc +++ b/modules/gui/src/tools/tool_manager.cc @@ -68,8 +68,7 @@ Tool* ToolManager::GetActiveTool() const return active_tool_; } -ToolManager::ToolManager() -{ +ToolManager::ToolManager(): active_tool_(NULL) { } diff --git a/modules/img/alg/src/CMakeLists.txt b/modules/img/alg/src/CMakeLists.txt index 5df3fd55852d08aad58d14147fdf1b7d7c9ec0da..692f96f5c8efbde5ee50ebf8b322274e1fc2f50e 100644 --- a/modules/img/alg/src/CMakeLists.txt +++ b/modules/img/alg/src/CMakeLists.txt @@ -92,9 +92,6 @@ line_average.hh rscrosscorr.hh ) -if(ENABLE_INFO) -include(${QT_USE_FILE}) -endif() module(NAME img_alg SOURCES "${OST_IMG_ALG_SOURCES}" HEADERS "${OST_IMG_ALG_HEADERS}" HEADER_OUTPUT_DIR ost/img/alg diff --git a/modules/img/alg/src/correlate.cc b/modules/img/alg/src/correlate.cc index f9ba508480516818a296ca88d4666d9ef2f163d7..b473e20c09f1aa089709c53a555846631e740303 100644 --- a/modules/img/alg/src/correlate.cc +++ b/modules/img/alg/src/correlate.cc @@ -86,6 +86,6 @@ ImageStateBasePtr ExplicitCorrelateFnc::VisitState(const ImageStateImpl<V,D>& is } } -template class TEMPLATE_DEF_EXPORT ImageStateConstModOPAlgorithm<alg::ExplicitCorrelateFnc>; +template class TEMPLATE_DEF_EXPORT image_state::ImageStateConstModOPAlgorithm<alg::ExplicitCorrelateFnc>; }} // ns diff --git a/modules/img/alg/src/density_slice.cc b/modules/img/alg/src/density_slice.cc index 2b54526bec69622e258bc34996be0b220191e78b..dc5cedf7f53c903a8c8bea23f2670c1e052cadb0 100644 --- a/modules/img/alg/src/density_slice.cc +++ b/modules/img/alg/src/density_slice.cc @@ -54,5 +54,5 @@ void SliceFnc::VisitState(ImageStateImpl<T,D>& isi) const } } -template class TEMPLATE_DEF_EXPORT ImageStateConstModIPAlgorithm<alg::SliceFnc>; +template class TEMPLATE_DEF_EXPORT image_state::ImageStateConstModIPAlgorithm<alg::SliceFnc>; }} // ns diff --git a/modules/img/alg/src/fourier_filters.cc b/modules/img/alg/src/fourier_filters.cc index 57462ecfeae38dc26f31a210e5fd8b63b334506e..a130b6f4cf27275aee648e9aa1974e5fc1ef64b7 100644 --- a/modules/img/alg/src/fourier_filters.cc +++ b/modules/img/alg/src/fourier_filters.cc @@ -254,12 +254,14 @@ typedef ImageStateConstModIPAlgorithm<ButterworthLPBase> ButterworthLP; }}}} // ns #ifndef NO_EXPL_INST -template class ost::img::ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::LPBase>; -template class ost::img::ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::HPBase>; -template class ost::img::ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::GaussianLPBase>; -template class ost::img::ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::GaussianHPBase>; -template class ost::img::ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::FermiLPBase>; -template class ost::img::ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::ButterworthLPBase>; +namespace ost { namespace img { namespace image_state { +template class ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::LPBase>; +template class ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::HPBase>; +template class ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::GaussianLPBase>; +template class ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::GaussianHPBase>; +template class ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::FermiLPBase>; +template class ImageStateConstModIPAlgorithm<ost::img::alg::filter_detail::ButterworthLPBase>; +}}} // ns #endif diff --git a/modules/img/alg/src/gaussian_gradient_magnitude.cc b/modules/img/alg/src/gaussian_gradient_magnitude.cc index ad3c32702d7ded48bea1358375be5f0aaaceda4a..b8c760be613d5627e416c2d25bd24d622adb8a59 100644 --- a/modules/img/alg/src/gaussian_gradient_magnitude.cc +++ b/modules/img/alg/src/gaussian_gradient_magnitude.cc @@ -143,6 +143,6 @@ void GaussianGradientMagnitudeFilterBase::calcBVals( Real q ) } // ns -template class TEMPLATE_DEF_EXPORT ImageStateModIPAlgorithm<alg::GaussianGradientMagnitudeFilterBase>; +template class TEMPLATE_DEF_EXPORT image_state::ImageStateModIPAlgorithm<alg::GaussianGradientMagnitudeFilterBase>; }} diff --git a/modules/img/alg/src/gaussian_laplacian.cc b/modules/img/alg/src/gaussian_laplacian.cc index 1a05a568db8eab412fccb1fc86b0e59bca2a5a5b..fbe0426448d4d3a7e8fbf6cdd4348304cfb32105 100644 --- a/modules/img/alg/src/gaussian_laplacian.cc +++ b/modules/img/alg/src/gaussian_laplacian.cc @@ -137,5 +137,5 @@ void GaussianLaplacianFilterBase::calcBVals( Real q ) } // ns -template class TEMPLATE_DEF_EXPORT ImageStateModIPAlgorithm<alg::GaussianLaplacianFilterBase>; +template class TEMPLATE_DEF_EXPORT image_state::ImageStateModIPAlgorithm<alg::GaussianLaplacianFilterBase>; }} diff --git a/modules/img/alg/src/highest_peak_search_3d.cc b/modules/img/alg/src/highest_peak_search_3d.cc index 913586a08a631285f7991f133be8d1890beb5b33..a4a80e78e7e066ef576545a5d9f974bdf587ccc4 100644 --- a/modules/img/alg/src/highest_peak_search_3d.cc +++ b/modules/img/alg/src/highest_peak_search_3d.cc @@ -177,7 +177,7 @@ template <typename T, class D> } // ns -template class TEMPLATE_DEF_EXPORT ImageStateNonModAlgorithm<alg::HighestPeakSearch3DBase>; +template class TEMPLATE_DEF_EXPORT image_state::ImageStateNonModAlgorithm<alg::HighestPeakSearch3DBase>; }} // ns diff --git a/modules/img/base/src/composite_mask.cc b/modules/img/base/src/composite_mask.cc index 97591d2727a2684e0c5a2a41f9383924a7617868..80a0a57cd8c19635825510399d63ca6f7a795ec7 100644 --- a/modules/img/base/src/composite_mask.cc +++ b/modules/img/base/src/composite_mask.cc @@ -105,7 +105,8 @@ OpBase* CompositeMask::create_op_(const String& name) if(name=="AND") return new AndOp; else if(name=="OR") return new OrOp; else if(name=="XOR") return new XorOp; - else throw("Unknown Operator");return new AndOp; + else throw("Unknown Operator"); + return new AndOp; } diff --git a/modules/info/src/CMakeLists.txt b/modules/info/src/CMakeLists.txt index 31d6db3b4ee3cc1247905272818769af7ea10a88..9242a005d85b2b483bcd8fc2a15070088341d88b 100644 --- a/modules/info/src/CMakeLists.txt +++ b/modules/info/src/CMakeLists.txt @@ -27,9 +27,8 @@ item_type.hh geom_info_conversion.hh item_type_cast.hh) -set(QT_DONT_USE_QTGUI 1) set(QT_USE_QTXML 1) -include(${QT_USE_FILE}) + module(NAME info SOURCES ${OST_INFO_SOURCES} HEADERS ${OST_INFO_HEADERS} DEPENDS_ON ost_base LINK ${BOOST_REGEX_LIBRARIES} ${QT_LIBRARIES}) diff --git a/modules/info/src/info_impl.cc b/modules/info/src/info_impl.cc index 0f6415504f761fd9a25fa4b2168f9d1c82145dce..e556e79ba9bb76cbfb4b1f3ce141fde9833b6e20 100644 --- a/modules/info/src/info_impl.cc +++ b/modules/info/src/info_impl.cc @@ -31,8 +31,7 @@ #include <boost/filesystem/operations.hpp> -#include <QFile> -#include <QtCore> +#include <QtCore/QFile> #include "info_error.hh" #include "info_impl.hh" @@ -228,7 +227,7 @@ const QDomElement& EleImpl::GetElement() const ElePtr EleImpl::GetSub(const String& name) const { QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isElement()) { QDomElement en = n.toElement(); @@ -244,7 +243,7 @@ EleList EleImpl::GetSubs(const String& name) const { EleList eles; QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isElement()) { QDomElement en = n.toElement(); @@ -267,7 +266,7 @@ ElePtr EleImpl::CreateSub(const String& name) bool EleImpl::HasSub(const String& name) const { QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isElement()) { QDomElement en = n.toElement(); @@ -282,7 +281,7 @@ bool EleImpl::HasSub(const String& name) const void EleImpl::RemoveSub(const String& name) { QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isElement()) { QDomElement en = n.toElement(); @@ -296,7 +295,7 @@ void EleImpl::RemoveSub(const String& name) void EleImpl::RemoveSub(const ElePtr& ele) { QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isElement()) { QDomElement en = n.toElement(); @@ -312,7 +311,7 @@ std::vector<ElePtr> EleImpl::GetSubList() const std::vector<ElePtr> epl; QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isElement()) { QDomElement ne = n.toElement(); @@ -335,7 +334,7 @@ ElePtr EleImpl::GetParent() const String EleImpl::GetTextData() const { QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isText()) { return QS(n.toText().data()); @@ -348,7 +347,7 @@ void EleImpl::SetTextData(const String& td) { bool succ=false; QDomNodeList list = ele_.childNodes(); - for(uint i=0;i<list.length();++i) { + for(int i=0;i<list.length();++i) { QDomNode n = list.item(i); if(n.isText()) { n.toText().setData(QS(td)); @@ -405,7 +404,7 @@ std::vector<String> EleImpl::GetAttributeList() const { std::vector<String> result; QDomNamedNodeMap nmap = ele_.attributes(); - for(uint i=0;i<nmap.length();++i) { + for(int i=0;i<nmap.length();++i) { QDomNode n = nmap.item(i); if(n.isAttr()) { QDomAttr attr = n.toAttr(); diff --git a/modules/info/src/info_impl.hh b/modules/info/src/info_impl.hh index fd84d96ed1e6519d0478afd180be40dead48e176..4b3c46be3be1953f79812b0ce892a3f7eb6468fc 100644 --- a/modules/info/src/info_impl.hh +++ b/modules/info/src/info_impl.hh @@ -32,10 +32,10 @@ #include <vector> #include <iostream> -#include <QDomElement> -#include <QDomDocument> -#include <QDomAttr> -#include <QDomText> +#include <QtXml/QDomElement> +#include <QtXml/QDomDocument> +#include <QtXml/QDomAttr> +#include <QtXml/QDomText> #include <ost/base.hh> #include <ost/geom/geom.hh> diff --git a/modules/io/pymod/remote.py b/modules/io/pymod/remote.py index 8820604ec932b826c09a97bd3cd8ff1b17fbe577..1f593060f1f0b583996253be6e8015db11bc4aa0 100644 --- a/modules/io/pymod/remote.py +++ b/modules/io/pymod/remote.py @@ -73,13 +73,13 @@ class RemoteRepository: return LoadMMCIF(tmp_file.name) REMOTE_REPOSITORIES = { - 'pdb' : RemoteRepository('pdb.org (PDB)', 'http://www.pdb.org/pdb/files/$ID.pdb.gz', + 'pdb' : RemoteRepository('pdb.org (PDB)', 'https://www.pdb.org/pdb/files/$ID.pdb.gz', type='pdb', id_transform='upper'), - 'smtl' : RemoteRepository('SMTL', 'http://swissmodel.expasy.org/templates/$ID.pdb', + 'smtl' : RemoteRepository('SMTL', 'https://swissmodel.expasy.org/templates/$ID.pdb', type='pdb', id_transform='lower'), - 'cif' : RemoteRepository('pdb.org (mmCIF)', 'http://www.pdb.org/pdb/files/$ID.cif.gz', + 'cif' : RemoteRepository('pdb.org (mmCIF)', 'https://www.pdb.org/pdb/files/$ID.cif.gz', type='cif', id_transform='lower'), - 'pdb_redo' : RemoteRepository('pdbredo', 'http://pdb-redo.eu/db/$ID/$ID_besttls.pdb.gz', + 'pdb_redo' : RemoteRepository('pdbredo', 'https://pdb-redo.eu/db/$ID/$ID_besttls.pdb.gz', type='pdb', id_transform='lower'), } diff --git a/modules/io/src/img/map_io_dx_handler.cc b/modules/io/src/img/map_io_dx_handler.cc index 5ecaab90479a1f878a151ccf3af10e6f2da14bca..4c823edc1497e80a156ab273cafd3eaa67af9357 100644 --- a/modules/io/src/img/map_io_dx_handler.cc +++ b/modules/io/src/img/map_io_dx_handler.cc @@ -48,6 +48,10 @@ using boost::format; namespace { +/* + +commented out to silence compiler warning, as it is not needed anywhere + bool IEquals(const StringRef& a, const StringRef& b) { if (a.size()!=b.size()) { @@ -60,6 +64,7 @@ bool IEquals(const StringRef& a, const StringRef& b) } return true; } +*/ } diff --git a/modules/io/tests/test_io_sequence_profile.cc b/modules/io/tests/test_io_sequence_profile.cc index afddf8d3f1429db4782ce717c02ec6b9c123c285..05a02345e2536e50fd976ba941ed80e71126bce3 100644 --- a/modules/io/tests/test_io_sequence_profile.cc +++ b/modules/io/tests/test_io_sequence_profile.cc @@ -85,16 +85,26 @@ BOOST_AUTO_TEST_CASE(hhm_loading) String olc = "ACDEFGHIKLMNPQRSTVWY"; - Real correct_aa_freqs[] = {pow(2.0,-0.001*3706), pow(2.0,-0.001*5728), - pow(2.0,-0.001*4211), pow(2.0,-0.001*4064), - pow(2.0,-0.001*4839), pow(2.0,-0.001*3729), - pow(2.0,-0.001*4763), pow(2.0,-0.001*4308), - pow(2.0,-0.001*4069), pow(2.0,-0.001*3323), - pow(2.0,-0.001*5509), pow(2.0,-0.001*4640), - pow(2.0,-0.001*4464), pow(2.0,-0.001*4937), - pow(2.0,-0.001*4285), pow(2.0,-0.001*4423), - pow(2.0,-0.001*3815), pow(2.0,-0.001*3783), - pow(2.0,-0.001*6325), pow(2.0,-0.001*4665)}; + Real correct_aa_freqs[] = {static_cast<Real>(pow(2.0, -0.001*3706)), + static_cast<Real>(pow(2.0, -0.001*5728)), + static_cast<Real>(pow(2.0, -0.001*4211)), + static_cast<Real>(pow(2.0, -0.001*4064)), + static_cast<Real>(pow(2.0, -0.001*4839)), + static_cast<Real>(pow(2.0, -0.001*3729)), + static_cast<Real>(pow(2.0, -0.001*4763)), + static_cast<Real>(pow(2.0, -0.001*4308)), + static_cast<Real>(pow(2.0, -0.001*4069)), + static_cast<Real>(pow(2.0, -0.001*3323)), + static_cast<Real>(pow(2.0, -0.001*5509)), + static_cast<Real>(pow(2.0, -0.001*4640)), + static_cast<Real>(pow(2.0, -0.001*4464)), + static_cast<Real>(pow(2.0, -0.001*4937)), + static_cast<Real>(pow(2.0, -0.001*4285)), + static_cast<Real>(pow(2.0, -0.001*4423)), + static_cast<Real>(pow(2.0, -0.001*3815)), + static_cast<Real>(pow(2.0, -0.001*3783)), + static_cast<Real>(pow(2.0, -0.001*6325)), + static_cast<Real>(pow(2.0, -0.001*4665))}; for (int i = 0; i < 20; ++i) { BOOST_CHECK_CLOSE(null_model.GetFreq(olc[i]), correct_aa_freqs[i], @@ -105,17 +115,17 @@ BOOST_AUTO_TEST_CASE(hhm_loading) ProfileColumn col = (*prof)[2]; memset(correct_aa_freqs, 0, 20*sizeof(Real)); - correct_aa_freqs[0] = pow(2.0,-0.001*3676); - correct_aa_freqs[1] = pow(2.0,-0.001*2597); - correct_aa_freqs[5] = pow(2.0,-0.001*5359); - correct_aa_freqs[6] = pow(2.0,-0.001*3275); - correct_aa_freqs[11] = pow(2.0,-0.001*3292); - correct_aa_freqs[12] = pow(2.0,-0.001*5077); - correct_aa_freqs[13] = pow(2.0,-0.001*3826); - correct_aa_freqs[15] = pow(2.0,-0.001*2409); - correct_aa_freqs[16] = pow(2.0,-0.001*3733); - correct_aa_freqs[17] = pow(2.0,-0.001*4503); - correct_aa_freqs[19] = pow(2.0,-0.001*3070); + correct_aa_freqs[0] = static_cast<Real>(pow(2.0, -0.001*3676)); + correct_aa_freqs[1] = static_cast<Real>(pow(2.0, -0.001*2597)); + correct_aa_freqs[5] = static_cast<Real>(pow(2.0, -0.001*5359)); + correct_aa_freqs[6] = static_cast<Real>(pow(2.0, -0.001*3275)); + correct_aa_freqs[11] = static_cast<Real>(pow(2.0, -0.001*3292)); + correct_aa_freqs[12] = static_cast<Real>(pow(2.0, -0.001*5077)); + correct_aa_freqs[13] = static_cast<Real>(pow(2.0, -0.001*3826)); + correct_aa_freqs[15] = static_cast<Real>(pow(2.0, -0.001*2409)); + correct_aa_freqs[16] = static_cast<Real>(pow(2.0, -0.001*3733)); + correct_aa_freqs[17] = static_cast<Real>(pow(2.0, -0.001*4503)); + correct_aa_freqs[19] = static_cast<Real>(pow(2.0, -0.001*3070)); for(int i = 0; i < 20; ++i){ BOOST_CHECK_CLOSE(col.GetFreq(olc[i]), correct_aa_freqs[i], Real(1e-5)); diff --git a/modules/mol/alg/src/lddt.cc b/modules/mol/alg/src/lddt.cc index dbe122d80d0b13e250edaec00291ea268bfa2bc6..8f592a37ff2c395fc063d13d81e6d1f1d009532c 100644 --- a/modules/mol/alg/src/lddt.cc +++ b/modules/mol/alg/src/lddt.cc @@ -87,7 +87,7 @@ EntityHandle load(const String& file, const IOProfile& profile) void usage() { std::cerr << "usage: lddt [options] <mod1> [mod1 [mod2]] <re1>[,ref2,ref3]" << std::endl; - std::cerr << " -s selection performed on ref" << std::endl; + std::cerr << " -s <sel> selection performed on ref" << std::endl; std::cerr << " -c use Calphas only" << std::endl; std::cerr << " -f perform structural checks and filter input data" << std::endl; std::cerr << " -t fault tolerant parsing" << std::endl; @@ -99,7 +99,7 @@ void usage() std::cerr << " -i <value> sequence separation" << std::endl; std::cerr << " -e print version" << std::endl; std::cerr << " -x ignore residue name consistency checks" << std::endl; - + std::cerr << " -l <path> location of the compound library file" << std::endl; } CompoundLibPtr load_compound_lib(const String& custom_path) @@ -178,7 +178,7 @@ int main (int argc, char **argv) ("parameter-file,p", po::value<String>(), "stereo-chemical parameter file") ("verbosity,v", po::value<int>(), "verbosity level") ("bond_tolerance,b", po::value<Real>(), "tolerance in stddev for bonds") - ("complib", po::value<String>(&custom_path)->default_value(""),"location of the compound library file") + ("complib,l", po::value<String>(&custom_path)->default_value(""), "location of the compound library file") ("angle_tolerance,a", po::value<Real>(), "tolerance in stddev for angles") ("inclusion_radius,r", po::value<Real>(), "distance inclusion radius") ("sequence_separation,i", po::value<int>(), "sequence separation") @@ -197,13 +197,13 @@ int main (int argc, char **argv) usage(); exit(-1); } + po::notify(vm); conop::CompoundLibPtr lib = load_compound_lib(custom_path); if (!lib) { exit(0); } profile.processor = conop::RuleBasedProcessorPtr(new conop::RuleBasedProcessor(lib)); profile.processor->SetCheckBondFeasibility(false); - po::notify(vm); if (vm.count("version")) { std::cout << "Version: " << version << std::endl; exit(0); diff --git a/modules/mol/base/src/impl/entity_impl.cc b/modules/mol/base/src/impl/entity_impl.cc index 2eeaf86cd6d116c797feb902284a8119f9171806..90ef2ad75d3411d5ba105f97d5756ebce1031910 100644 --- a/modules/mol/base/src/impl/entity_impl.cc +++ b/modules/mol/base/src/impl/entity_impl.cc @@ -774,6 +774,10 @@ void EntityImpl::AttachObserver(const EntityObserverPtr& o) void EntityImpl::DetachObserver(const EntityObserverPtr& o) { EntityObserverMap::iterator it=observer_map_.find(o.get()); + + if(it != observer_map_.end()) { + observer_map_.erase(it); + } } void EntityImpl::NotifyObserver() diff --git a/modules/mol/base/src/impl/query_impl.cc b/modules/mol/base/src/impl/query_impl.cc index 618d579a60b6a9bb0a3f9cdd507b3732029a427a..733999f26ef6b2a3eeee7255c89db667c5825d08 100644 --- a/modules/mol/base/src/impl/query_impl.cc +++ b/modules/mol/base/src/impl/query_impl.cc @@ -35,8 +35,19 @@ #include <ost/mol/impl/chain_impl.hh> #include <ost/mol/mol.hh> +#include <memory> +#include <cstddef> + namespace ost { namespace mol { namespace impl { - + +// portable solution for use of unique ptr in this file +// -> use C++11 unique_ptr if possible and old auto_ptr otherwise +#if __cplusplus >= 201103L +typedef std::unique_ptr<Node> NodeUniquePtr; +#else +typedef std::auto_ptr<Node> NodeUniquePtr; +#endif + using namespace boost::spirit; namespace { @@ -744,7 +755,7 @@ Node* QueryImpl::ParsePropValueExpr(QueryLexer& lexer) { return NULL; } } - std::auto_ptr<Node> root_value(NULL); + NodeUniquePtr root_value; do { Node* sel_node=this->ParseValueOrRange(property, op, lexer); if (sel_node==NULL) { @@ -815,10 +826,10 @@ Node* QueryImpl::ParseBracketSubExpr(QueryLexer& lexer) { } Node* QueryImpl::ParseSubExpr(QueryLexer& lexer, bool paren) { - // Use auto_ptr to protect against memory leaks. In case of early exit, i.e. + // Use unique ptr to protect against memory leaks. In case of early exit, i.e. // exceptions, the memory associated with root_node and its child nodes will // be freed. - std::auto_ptr<Node> root_node(NULL); + NodeUniquePtr root_node; Node* new_node=NULL; QueryToken t=lexer.CurrentToken(); LogicOP logic_op=LOP_AND; diff --git a/modules/mol/base/src/query_state.cc b/modules/mol/base/src/query_state.cc index 64874cb82669d35f9f7b364bfec80f4c8e5c3bd1..639306c903372a4b1b49b25d4dc79d7aee5c769f 100644 --- a/modules/mol/base/src/query_state.cc +++ b/modules/mol/base/src/query_state.cc @@ -407,7 +407,9 @@ bool QueryState::IsAtomSelected(const AtomHandle& h) if(ret==false) return false; ret = this->EvalResidue(h.GetResidue().Impl()); if(ret==false) return false; - return this->EvalAtom(h.Impl()); + ret = this->EvalAtom(h.Impl()); + if(ret==false) return false; + return true; } bool QueryState::IsResidueSelected(const ResidueHandle& r) diff --git a/scripts/dng.in b/scripts/dng.in index d431535382c1b077fa2517f0e0d809dc887df526..c04f6b3073fafe9ae03d20e649673dcbc1fd77df 100755 --- a/scripts/dng.in +++ b/scripts/dng.in @@ -28,4 +28,16 @@ fi BIN_DIR=`dirname "$SCRIPT_NAME"` source "$BIN_DIR/../@LIBEXEC_PATH@/ost_config" + +opts="" + +for argument in "$@";do + if [ -n "$opts" ]; then + opts=$opts"#""$argument" + else + opts="$argument" + fi +done +IFS="#" + $BIN_DIR/../@LIBEXEC_PATH@/gosty $DNG_INITDIR/dng_startup.py dng $opts diff --git a/singularity/Singularity.1.10.0 b/singularity/Singularity.1.10.0 new file mode 100644 index 0000000000000000000000000000000000000000..0a6c58eaac787d83b890f85426ae91c69b7fa918 --- /dev/null +++ b/singularity/Singularity.1.10.0 @@ -0,0 +1,425 @@ +BootStrap: docker +From: ubuntu:18.04 + +%post +############################################################################## +# POST +############################################################################## + +# CHANGE DASH TO BASH +rm /bin/sh +ln -sf /bin/bash /bin/sh + +# DEFINE SOME ENV VARS USED DURING THE IMAGE BUILD +########################## +export SRC_FOLDER="/usr/local/src" +export CPUS_FOR_MAKE=8 +export PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" +# When changing OPENSTRUCTURE_VERSION make sure to change it also in the +# environment section of singularity recipe (this file). +export OPENSTRUCTURE_VERSION="1.10.0" +export OPENSTRUCTURE_SHARE="/usr/local/share/ost" +export MSMS_VERSION="2.6.1" +export OPENMM_VERSION="7.1.1" +export OPENMM_INCLUDE_PATH=/usr/local/openmm/include/ +export OPENMM_LIB_PATH=/usr/local/openmm/lib/ +export JUPYTER_CONFIG_DIR="/usr/local/etc/jupyter" +export JUPYTER_PATH="/usr/local/share/jupyter" +export JUPYTER_RUNTIME_DIR="$JUPYTER_PATH/runtime" +export VIRTUALENV_DIR="/usr/local/share/ost_venv" + + +# INSTALL SYSTEM DEPS +##################### +apt-get update -y && apt-get install -y cmake \ + g++ \ + sip-dev \ + libtiff-dev \ + libfftw3-dev \ + libeigen3-dev \ + libboost-all-dev \ + libpng-dev \ + python-all \ + python2.7 \ + python-pyqt5 \ + qt5-qmake \ + qtbase5-dev \ + wget \ + git \ + gfortran \ + python-pip \ + tar \ + libbz2-dev \ + doxygen \ + swig \ + clustalw \ + python-virtualenv \ + libsqlite3-dev \ + dssp \ + python-enum34 \ + python-ipaddress \ + locales + +# SET LOCALE +############ +echo "LC_ALL=en_US.UTF-8" >> /etc/environment +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +echo "LANG=en_US.UTF-8" > /etc/locale.conf +locale-gen en_US.UTF-8 + +# INSTALL SOME PYTHON PACKAGES GLOBALY +###################################### +pip install --no-cache-dir numpy==1.10.4 \ + scipy==1.0.0 \ + pandas==0.22.0 + + +# SET UP VIRTUALENV +################### +virtualenv --system-site-packages $VIRTUALENV_DIR +. $VIRTUALENV_DIR/bin/activate + + +# INSTALL REQUIRED PYTHON PACKAGES +################################## +pip install jupyter==1.0.0 \ + nglview==1.1.6 + +# DOWNLOAD AND INSTALL MSMS +############## +cd ${SRC_FOLDER} +if [ ! -f msms_i86_64Linux2_${MSMS_VERSION}.tar.gz ]; then + mkdir -p msms + cd msms + wget http://mgltools.scripps.edu/downloads/tars/releases/MSMSRELEASE/REL${MSMS_VERSION}/msms_i86_64Linux2_${MSMS_VERSION}.tar.gz + tar -xvzf msms_i86_64Linux2_${MSMS_VERSION}.tar.gz + cp -v ${SRC_FOLDER}/msms/msms.x86_64Linux2.${MSMS_VERSION} /usr/local/bin/msms + cp -v ${SRC_FOLDER}/msms/pdb_to_xyzr /usr/local/bin/pdb_to_xyzr + cp -v ${SRC_FOLDER}/msms/pdb_to_xyzrn /usr/local/bin/pdb_to_xyzrn +fi + +# COMPILE OPENMM FROM SOURCES. INSTALL TO /usr/local +############################ +cd ${SRC_FOLDER} +if [ ! -f openmm-${OPENMM_VERSION}.tar.gz ]; then + wget -O openmm-${OPENMM_VERSION}.tar.gz -nc https://github.com/pandegroup/openmm/archive/${OPENMM_VERSION}.tar.gz + mkdir ${SRC_FOLDER}/openmm-${OPENMM_VERSION} + tar xf openmm-${OPENMM_VERSION}.tar.gz -C ${SRC_FOLDER}/openmm-${OPENMM_VERSION} --strip-components=1 + mkdir -p ${SRC_FOLDER}/openmm-${OPENMM_VERSION}/build && cd ${SRC_FOLDER}/openmm-${OPENMM_VERSION}/build + cmake .. && make -j $CPUS_FOR_MAKE && make install + cd ${SRC_FOLDER}/openmm-${OPENMM_VERSION}/build/python && python setup.py build && python setup.py install +fi + +# INSTALL OST +############# + +cd ${SRC_FOLDER} +if [ ! -f openstructure-${OPENSTRUCTURE_VERSION}.tar.gz ]; then + # copy ost release + wget -O openstructure-${OPENSTRUCTURE_VERSION}.tar.gz -nc https://git.scicore.unibas.ch/schwede/openstructure/repository/${OPENSTRUCTURE_VERSION}/archive.tar.gz + mkdir openstructure-${OPENSTRUCTURE_VERSION} + tar xf openstructure-${OPENSTRUCTURE_VERSION}.tar.gz -C ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION} --strip-components=1 + mkdir -p ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build && cd ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build + + # cmake ost + cmake .. -DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython2.7.so \ + -DOPTIMIZE=ON \ + -DENABLE_MM=ON \ + -DCOMPILE_TMTOOLS=1 \ + -DUSE_NUMPY=1 \ + -DOPEN_MM_LIBRARY=$OPENMM_LIB_PATH/libOpenMM.so \ + -DOPEN_MM_INCLUDE_DIR=$OPENMM_INCLUDE_PATH \ + -DOPEN_MM_PLUGIN_DIR=$OPENMM_LIB_PATH/plugins \ + -DENABLE_GFX=ON \ + -DENABLE_GUI=ON + + # Build chemdict_tool + make -j ${CPUS_FOR_MAKE} chemdict_tool + + # get the compound library + wget ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz + stage/bin/chemdict_tool create components.cif.gz compounds.chemlib pdb + stage/bin/chemdict_tool update ../modules/conop/data/charmm.cif compounds.chemlib charmm + mkdir -p $OPENSTRUCTURE_SHARE + chmod a+rw -R $OPENSTRUCTURE_SHARE + mv compounds.chemlib $OPENSTRUCTURE_SHARE + + # Build and install OST + cmake .. -DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython2.7.so \ + -DOPTIMIZE=ON \ + -DENABLE_MM=ON \ + -DCOMPILE_TMTOOLS=1 \ + -DUSE_NUMPY=1 \ + -DOPEN_MM_LIBRARY=$OPENMM_LIB_PATH/libOpenMM.so \ + -DOPEN_MM_INCLUDE_DIR=$OPENMM_INCLUDE_PATH \ + -DOPEN_MM_PLUGIN_DIR=$OPENMM_LIB_PATH/plugins \ + -DENABLE_GFX=ON \ + -DENABLE_GUI=ON \ + -DCOMPOUND_LIB=$OPENSTRUCTURE_SHARE/compounds.chemlib + + # Build chemdict_tool + make -j ${CPUS_FOR_MAKE} + make check + make install +fi + +# SETUP JUPYTER +############### +mkdir -p /usr/local/share/ipython +mkdir -p $JUPYTER_PATH +mkdir -p $JUPYTER_RUNTIME_DIR +mkdir -p $JUPYTER_CONFIG_DIR +mkdir -p $JUPYTER_PATH/kernels/ost-kernel +chmod a+rw -R /usr/local/share/ipython +chmod a+rw -R $JUPYTER_PATH +chmod a+rw -R $JUPYTER_CONFIG_DIR +chmod a+rw -R $JUPYTER_RUNTIME_DIR +cat > $JUPYTER_PATH/kernels/ost-kernel/kernel.json <<EOF +{ + "display_name": "OST", + "language": "python", + "argv": [ + "python", + "-m", "ipykernel", + "-f", "{connection_file}", + "--InteractiveShellApp.exec_PYTHONSTARTUP=False", + "--InteractiveShellApp.exec_files=['/usr/local/lib64/python2.7/site-packages/ost/ost_startup.py']" + ], + "env": { + } +} +EOF + +jupyter nbextension enable nglview --py --sys-prefix + +# GO HOME AND CLEANUP +##################### +apt-get purge -y cmake \ + wget \ + git \ + gfortran \ + python-pip \ + libbz2-dev \ + doxygen \ + swig +apt-get clean +apt-get autoremove -y + +cd $SRC_FOLDER && rm -rf $SRC_FOLDER/* + +cd /home + +%environment +############################################################################## +# ENVIRONMENT +############################################################################## +export OST_ROOT="/usr/local" +export OPENSTRUCTURE_VERSION="1.9.0" +export OPENMM_LIB_PATH=/usr/local/openmm/lib/ +export PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64:${OPENMM_LIB_PATH}" +export QT_X11_NO_MITSHM=1 +export IPYTHONDIR="/usr/local/share/ipython" +export JUPYTER_CONFIG_DIR="/usr/local/etc/jupyter" +export JUPYTER_PATH="/usr/local/share/jupyter" +export JUPYTER_RUNTIME_DIR="$JUPYTER_PATH/runtime" +export VIRTUALENV_DIR="/usr/local/share/ost_venv" + +%apprun ChemdictTool +############################################################################## +# CHEMDICT TOOL APP +############################################################################## +$OST_ROOT/bin/chemdict_tool "$@" + +%apprun lDDT +############################################################################## +# lDDT APP +############################################################################## +$OST_ROOT/bin/lddt "$@" + +%apphelp lDDT +The Local Distance Difference Test. + +Usage: + + singularity run --app lDDT <IMAGE> [options] <mod1> [mod1 [mod2]] <re1>[,ref2,ref3] + +Options: + -s selection performed on ref + -c use Calphas only + -f perform structural checks and filter input data + -t fault tolerant parsing + -p <file> use specified parmeter file. Mandatory + -v <level> verbosity level (0=results only,1=problems reported, 2=full report) + -b <value> tolerance in stddevs for bonds + -a <value> tolerance in stddevs for angles + -r <value> distance inclusion radius + -i <value> sequence separation + -e print version + -x ignore residue name consistency checks + +%apprun Molck +############################################################################## +# MOLCK APP +############################################################################## +$OST_ROOT/bin/molck "$@" + +%apphelp Molck +This is molck - the molecule checker + +Usage: + singularity run --app Molck <IMAGE> [options] file1.pdb [file2.pdb [...]] + +Options: + --complib=path location of the compound library file. If not provided, the + following locations are searched in this order: + 1. Working directory, 2. OpenStructure standard library location (if the + executable is part of a standard OpenStructure installation) + --rm=<a>,<b> remove atoms and residues matching some criteria + zeroocc - Remove atoms with zero occupancy + hyd - Remove hydrogen atoms + oxt - Remove terminal oxygens + nonstd - Remove all residues not one of the 20 standard amino acids + unk - Remove unknown and atoms not following the nomenclature + --fix-ele clean up element column + --stdout write cleaned file(s) to stdout + --out=filename write cleaned file(s) to disk. % characters in the filename are + replaced with the basename of the input file without extension. + Default: %-molcked.pdb + --color=auto|on|off + whether output should be colored + --map-nonstd maps modified residues back to the parent amino acid, for example + MSE -> MET, SEP -> SER. + +%apprun OST +############################################################################## +# OST APP +############################################################################## +$OST_ROOT/bin/ost "$@" + +%apphelp OST +The OST app exposes OpenStructure binary and can be used to run interactive shell +and scripts. + +Usage: + singularity run --app OST <IMAGE> [ost options] [script to execute] [script parameters] + +Options: + -i, --interactive start interpreter interactively (must be first + parameter, ignored otherwise) + -h, --help show this help message and exit + -v VLEVEL, --verbosity_level=VLEVEL + sets the verbosity level [default: 2] + +If script requires some external files eg. PDBs, they have to be located in the +path accessible via mounted volumes. By default Singularity mounts $HOME and +goes to CWD. Thus this sould work as expected out of the box. + + +%appenv IPython +############################################################################## +# NOTEBOOK ENV +############################################################################## +export DNG_ROOT=$OST_ROOT +export DNG_INITDIR=${DNG_ROOT}/lib64/python2.7/site-packages/ost + +%apprun IPython +############################################################################## +# OST IPYTON APP +############################################################################## +. $VIRTUALENV_DIR/bin/activate && ipython -i $DNG_INITDIR/ost_startup.py "$@" + +%apphelp IPython +OST-powered iPython shell. + +Usage: + + singularity run --app IPython <IMAGE> [options] + +Detailed help: + + singularity run --app IPython <IMAGE> --help + +%appenv Notebook +############################################################################## +# NOTEBOOK ENV +############################################################################## +export BIN_DIR=$OST_ROOT/bin +export XDG_RUNTIME_DIR="" +. $OST_ROOT/libexec/openstructure/ost_config + +%apprun Notebook +############################################################################## +# NOTEBOOK APP +############################################################################## +. $VIRTUALENV_DIR/bin/activate && jupyter notebook --NotebookApp.iopub_data_rate_limit=10000000 --no-browser "$@" + +%apphelp Notebook +A Jupyter notebook palyground with OST and nglview. + +Usage: + + singularity run --app Notebook <IMAGE> [options] + +The Jupyter notebook is run by default with `--NotebookApp.iopub_data_rate_limit=10000000` +and `--no-browser` options. + +Useful options when running on remote server: + --ip=<Unicode> (NotebookApp.ip) + Default: 'localhost' + The IP address the notebook server will listen on. + --port=<Integer> (NotebookApp.port) + Default: 8888 + The port the notebook server will listen on. + +Copy the URL to the browser and launch the notebook with OST kernel. This will +load all necessary OST components just like in the OST shell. We also enabled +the nglview widget to interactively view molecular structures and trajectories. +For more details on how to use nglview see http://nglviewer.org/nglview/latest/. + +As the Singularity mounts $HOME by default Jupyter and Ipython config files +are moved to separate directories. Proper environmental variables are also set. +In addition, Jupyter is run in a separate virtualenv to not interact with possibly +installed host version. + +To list of all available options: + + singularity run --app Notebook <IMAGE> --help + + +%runscript +############################################################################## +# RUNSCRIPT +############################################################################## +cat << EOF +Singularity container for OST $OPENSTRUCTURE_VERSION. + +This container includes the following apps: + * OST - OpenStructure binary + * IPython - OST-powered iPython shell + * Notebook - A Jupyter notebook palyground with OST and nglview + * lDDT - The Local Distance Difference Test + * Molck - Molecular checker + * ChemdictTool - Creating or update a compound library + +To see the help for each individual app run: + + singularity help --app <APP NAME> <IMAGE NAME> +EOF + +%help +Singularity container for OST. + +This container includes the following apps: + * OST - OpenStructure binary + * IPython - OST-powered iPython shell + * Notebook - A Jupyter notebook palyground with OST and nglview + * lDDT - The Local Distance Difference Test + * Molck - Molecular checker + * ChemdictTool - Creating or update a compound library + +To see the help for each individual app run: + + singularity help --app <APP NAME> <IMAGE NAME> + + diff --git a/singularity/Singularity.1.9.0 b/singularity/Singularity.1.9.0 index 58a4bd97a10ffecd310f45d490a6381b00edf525..c890b6e93a71b4350d48304b6fd4b175fd98b61a 100644 --- a/singularity/Singularity.1.9.0 +++ b/singularity/Singularity.1.9.0 @@ -33,31 +33,31 @@ export VIRTUALENV_DIR="/usr/local/share/ost_venv" # INSTALL SYSTEM DEPS ##################### apt-get update -y && apt-get install -y cmake \ - sip-dev \ - libtiff-dev \ - libfftw3-dev \ - libeigen3-dev \ - libboost-all-dev \ - libpng-dev \ - python-all \ - python2.7 \ - python-qt4 \ - qt4-qtconfig \ - qt4-qmake \ - libqt4-dev \ - libpng-dev \ - wget \ - git \ - gfortran \ - python-pip \ - tar \ - libbz2-dev \ - doxygen \ - swig \ - clustalw \ - python-virtualenv \ - libsqlite3-dev \ - locales + sip-dev \ + libtiff-dev \ + libfftw3-dev \ + libeigen3-dev \ + libboost-all-dev \ + libpng-dev \ + python-all \ + python2.7 \ + python-qt4 \ + qt4-qtconfig \ + qt4-qmake \ + libqt4-dev \ + libpng-dev \ + wget \ + git \ + gfortran \ + python-pip \ + tar \ + libbz2-dev \ + doxygen \ + swig \ + clustalw \ + python-virtualenv \ + libsqlite3-dev \ + locales # SET LOCALE ############