diff --git a/.travis.yml b/.travis.yml index 2e40c09..6adfb3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,17 +13,7 @@ notifications: before_install: - sudo apt-get update -qq - - sudo apt-get install -y libopenscenegraph-dev - - sudo apt-get install -y libqt4-dev - - sudo apt-get install -y libqt4-opengl-dev - - sudo apt-get install -y python-qt4-gl - - sudo apt-get install -y python-qt4-dev - - sudo apt-get install -y python-sip-dev - - sudo apt-get install -y python-numpy - - sudo apt-get install -y libopenscenegraph-dev - - sudo apt-get install -y python-matplotlib cmake g++ - - sudo pip install pymoose - - sudo pip install numpy --upgrade + - sudo ./.travis_prepare_linux.sh script: - ./.travis_build.sh diff --git a/.travis_prepare_linux.sh b/.travis_prepare_linux.sh new file mode 100755 index 0000000..2fca351 --- /dev/null +++ b/.travis_prepare_linux.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +apt-get install -y libopenscenegraph-dev +apt-get install -y libqt5-dev +apt-get install -y libqt5-opengl-dev +apt-get install -y python3-sip-dev +apt-get install -y python3-numpy +apt-get install -y python3-matplotlib cmake g++ +python3 -m pip install pymoose +python3 -m pip install numpy --upgrade + diff --git a/CMakeLists.txt b/CMakeLists.txt index a6fbf94..f3cc1ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,14 +7,14 @@ project(MOOGLI) set(CMAKE_POLICY CMP0017 ON) + # Create a TOP-LEVEL target to dependencies can be set up properly. set(MOOGLI_MAIN_OUTFILE ${MOOGLI_SRC_DIR}/core/_moogli.so) add_custom_target(build_moogli ALL - DEPENDS ${MOOGLI_MAIN_OUTFILE} - ) + DEPENDS ${MOOGLI_MAIN_OUTFILE}) # VERSION. -set(MOOGLI_VERSION 0.5.0) +set(MOOGLI_VERSION 0.6.0) file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/VERSION "${MOOGLI_VERSION}") set(MOOGLI_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/moogli) @@ -83,25 +83,36 @@ add_custom_command( OUTPUT ${MOOGLI_MAIN_OUTFILE} ) # BDIST, install depends on it. -set(MOOGLI_BDIST_FILE ${MOOGLI_BDIST_DIR}/moogli-${MOOGLI_VERSION}*.CMAKE.tar.gz) +set(MOOGLI_BDIST_FILE ${MOOGLI_BDIST_DIR}/moogli-${MOOGLI_VERSION}.CMAKE.tar.gz) add_custom_target(bdist ALL DEPENDS ${MOOGLI_BDIST_FILE}) add_custom_command( OUTPUT ${MOOGLI_BDIST_FILE} DEPENDS ${MOOGLI_MAIN_OUTFILE} COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} setup.py - bdist -d ${MOOGLI_BDIST_DIR} -p CMAKE + bdist_dumb -d ${MOOGLI_BDIST_DIR} -p CMAKE --relative WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building bdist" VERBATIM ) add_custom_command( TARGET bdist POST_BUILD - COMMAND ${CMAKE_COMMAND} -E chdir ${MOOGLI_BDIST_INSTALL_DIR} - tar xvf ${MOOGLI_BDIST_DIR}/moogli-${MOOGLI_VERSION}*.tar.gz - COMMENT "Extracting tar.gz to install directory" + COMMAND tar xvf ${MOOGLI_BDIST_DIR}/moogli-${MOOGLI_VERSION}.CMAKE.tar.gz + -C ${MOOGLI_BDIST_INSTALL_DIR} + COMMENT "Extracting tar.gz to ${MOOGLI_BDIST_INSTALL_DIR}" + WORKING_DIRECTORY ${MOOGLI_BDIST_INSTALL_DIR} + VERBATIM # NOT VERBATIM ELSE glob won't work ) add_dependencies( bdist build_moogli ) # Install the unarchived bdist -install(DIRECTORY ${MOOGLI_BDIST_INSTALL_DIR}/usr/ +set(CMAKE_INSTALL_PREFIX $ENV{HOME}/.local) +install(DIRECTORY ${MOOGLI_BDIST_INSTALL_DIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX} ) + +# enable_testing +enable_testing() +add_test(NAME test_sanity COMMAND ${PYTHON_EXECUTABLE} -c "import moogli") + +set_property(TEST test_sanity + PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/moogli + ) diff --git a/README.md b/README.md index b0ba4d1..dfa3cc6 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ Install MOOGLI from PyPI: pip install moogli -MOOGLI can be built and installed from sources (in current directory) -using python distutils: +MOOGLI can be built and installed from sources (in current directory) using python distutils: sudo python setup.py install @@ -49,13 +48,12 @@ and some patches from prior attempts here: https://cygwin.com/ml/cygwin-apps/2009-06/msg00134.html -**Error** +## Error sip: Unable to find file "QtGui/QtGuimod.sip" -**Solution** +**Solution** pyqt5-dev or python-qt4-dev . - Install python-qt4-dev **Error** @@ -64,3 +62,7 @@ https://cygwin.com/ml/cygwin-apps/2009-06/msg00134.html **Solution** Install libopenscenegraph-dev + +# Arch Linux + +Install `openscanegraph` and `osgqt`. diff --git a/__init__.py b/__init__.py deleted file mode 100644 index 06fbf5f..0000000 --- a/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -from PyQt4 import QtGui -from PyQt4 import QtCore -from PyQt4 import Qt -from PyQt4 import QtOpenGL - - -# from PyQt4.QtGui import * -from ._moogli import * -from main import * - -class DynamicMorphologyViewerWidget(MorphologyViewerWidget): - _timer = QtCore.QTimer() - - def set_callback(self,callback, idletime = 0): - self.callback = callback - self.idletime = idletime - self._timer.timeout.connect(self.start_cycle) - self.start_cycle() - - def start_cycle(self): - if self.isVisible(): - if self.callback(self.get_morphology(), self): - self._timer.start(self.idletime) - else: - self._timer.timeout.disconnect(self.start_cycle) - self.update() - else: - self._timer.start(self.idletime) - - -__all__ = [ "Morphology" - , "MorphologyViewer" - , "MorphologyViewerWidget" - , "DynamicMorphologyViewerWidget" - ] diff --git a/moogli/CMakeLists.txt b/moogli/CMakeLists.txt index b2ce1b9..4d38668 100644 --- a/moogli/CMakeLists.txt +++ b/moogli/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 2.8) -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") -## Options +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") option(BUILD_STATIC "Link osg statically. Useful for creating standalone packages" OFF) add_definitions(-std=c++11) @@ -11,18 +10,19 @@ if(APPLE) endif(APPLE) add_definitions(-fPIC) -FIND_PACKAGE(PythonDev REQUIRED) -INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) +find_package(PythonDev REQUIRED) +find_package(SIP REQUIRED) +include_directories(${PYTHON_INCLUDE_DIRS}) -FIND_PACKAGE(PyQt4 REQUIRED) -MESSAGE("++ Found SIP flags: ${PYQT4_SIP_FLAGS}") -SEPARATE_ARGUMENTS(PYQT4_SIP_FLAGS) # convert space separated values to a list +find_package(PyQt5 REQUIRED) +message("++ Found SIP flags: ${PYQT5_SIP_FLAGS}") +separate_arguments(PYQT5_SIP_FLAGS) # convert space separated values to a list SET(SIP_CONCAT_PARTS 4) -SET(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS}) +SET(SIP_EXTRA_OPTIONS ${PYQT5_SIP_FLAGS}) -IF("${PYQT4_SIP_FLAGS}" STREQUAL "") - MESSAGE(FATAL_ERROR "++ No PYQT4_SIP_FLAGS found. Can't continue") +IF("${PYQT5_SIP_FLAGS}" STREQUAL "") + MESSAGE(FATAL_ERROR "++ No PYQT5_SIP_FLAGS found. Can't continue") ENDIF() MESSAGE("++ Using sip flags: ${SIP_EXTRA_OPTIONS}") @@ -31,14 +31,20 @@ IF (NOT BINDINGS_GLOBAL_INSTALL) SET(PYTHON_SITE_PACKAGES_DIR ${QGIS_DATA_DIR}/python) ENDIF (NOT BINDINGS_GLOBAL_INSTALL) IF (WITH_CUSTOM_WIDGETS) - SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT4_MOD_DIR}/uic/widget-plugins/) + SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT5_MOD_DIR}/uic/widget-plugins/) ENDIF (WITH_CUSTOM_WIDGETS) -FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) -FIND_PACKAGE(OpenSceneGraph 3.0.2 REQUIRED - osgFX osgGA - osgAnimation osgViewer - osgManipulator osgSim osgText +find_package(Qt5Widgets CONFIG REQUIRED) +find_package(Qt5OpenGL) + +find_package(OpenSceneGraph 3.0.2 REQUIRED + osgFX + osgGA + osgAnimation + osgViewer + osgManipulator + osgSim + osgText osgDB osgUtil OpenThreads @@ -46,7 +52,9 @@ FIND_PACKAGE(OpenSceneGraph 3.0.2 REQUIRED MESSAGE(STATUS "OSG LIBRARIES: ${OPENSCENEGRAPH_LIBRARIES}") -INCLUDE(${QT_USE_FILE}) +if(QT_USE_FILE) + include(${QT_USE_FILE}) +endif() FIND_PROGRAM(SIP_EXECUTABLE sip) MESSAGE("++ SIP ${SIP_EXECUTABLE}") @@ -57,30 +65,51 @@ include_directories(${SIP_INCLUDES} ${PYTHON_INCLUDE_DIRS}) include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}) include_directories(${OSGANIMATION_INCLUDE_DIR}) +#qt5 paths. +include_directories(${Qt5Widgets_INCLUDE_DIRS}) +include_directories(${Qt5Core_INCLUDE_DIRS}) +include_directories(${Qt5OpenGL_INCLUDE_DIRS}) + add_subdirectory(${PROJECT_SOURCE_DIR}/bin/sip) add_subdirectory(${PROJECT_SOURCE_DIR}/bin/src) -ADD_LIBRARY(_moogli SHARED - ${PROJECT_SOURCE_DIR}/bin/moc/Viewer.moc.cpp - ) +# NOTE: moc should be run to genrate these files. +set(MOC_HEADERS ${PROJECT_SOURCE_DIR}/bin/include/view/Viewer.hpp) +set(MOC_SOURCES "") +foreach(_MOC_HEADER ${MOC_HEADERS}) + get_filename_component(_TGT_NAME ${MOC_HEADERS} NAME_WE) + set(_MOC_SOURCE ${_TGT_NAME}.moc.cpp) + message(STATUS "Adding target: ${_MOC_HEADER} -> ${_MOC_SOURCE} using MOC") + add_custom_command(OUTPUT ${_MOC_SOURCE} + COMMAND moc ${_MOC_HEADER} -o ${_MOC_SOURCE} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating ${_MOC_SOURCE} from ${_MOC_HEADER}" + ) + add_custom_target(${_TGT_NAME} ALL DEPENDS ${_MOC_SOURCE}) + list(APPEND MOC_SOURCES ${_MOC_SOURCE}) +endforeach() +set_source_files_properties(${MOC_SOURCES} GENERATED) -IF(APPLE) +add_library(_moogli SHARED ${MOC_SOURCES}) + + +if(APPLE) SET_TARGET_PROPERTIES(_moogli PROPERTIES OUTPUT_NAME "_moogli.so" LINK_FLAGS "-undefined dynamic_lookup" SUFFIX "" ) -ELSE(APPLE) +else(APPLE) SET_TARGET_PROPERTIES(_moogli PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/core" PREFIX "" ) -ENDIF(APPLE) +endif(APPLE) ## Link the following libraries to moogli. SET(STATIC_LIBRARIES sip src) -SET(DYNAMIC_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtOpenGL) +SET(DYNAMIC_LIBRARIES Qt5::Core Qt5::OpenGL) IF(BUILD_STATIC) LIST(APPEND STATIC_LIBRARIES ${OPENSCENEGRAPH_LIBRARIES}) @@ -97,4 +126,5 @@ ELSE(APPLE) "-Wl,--no-whole-archive" ) ENDIF(APPLE) -TARGET_LINK_LIBRARIES(_moogli ${DYNAMIC_LIBRARIES}) + +target_link_libraries(_moogli ${DYNAMIC_LIBRARIES}) diff --git a/moogli/__init__.py b/moogli/__init__.py index ab4fedc..245cee4 100644 --- a/moogli/__init__.py +++ b/moogli/__init__.py @@ -1,28 +1,24 @@ -import core -import utilities -import shapes -import geometry -import colors +import moogli.core +import moogli.utilities +import moogli.shapes +import moogli.geometry +import moogli.colors +import moogli.widgets +import moogli.extensions +import moogli.extensions.moose + +from .main import * from .group import Group from .viewers import View from .viewers import Viewer -import widgets -# import constants -# import visualization -import extensions -from main import * __all__ = ["core", - "utilities", - "shapes", - "geometry", - "colors", - "widgets", - "Group", - "View", - "Viewer", - "extensions"] - # "constants", - # "visualization", - # "extensions"] - + "utilities", + "shapes", + "geometry", + "colors", + "widgets", + "Group", + "View", + "Viewer", + "extensions"] diff --git a/moogli/bin/include/utility/PythonWrapper.h b/moogli/bin/include/utility/PythonWrapper.h new file mode 100644 index 0000000..0f02f61 --- /dev/null +++ b/moogli/bin/include/utility/PythonWrapper.h @@ -0,0 +1,29 @@ +// ===================================================================================== +// +// Filename: PythonWrapper.h +// +// Description: Wrapper around python: https://stackoverflow.com/a/49359288/1805129 +// +// Version: 1.0 +// Created: 03/06/19 05:12:01 PM IST +// Revision: none +// Compiler: g++ +// +// Author: Dilawar Singh (), dilawar.s.rajput@gmail.com +// Organization: NCBS Bangalore +// +// ===================================================================================== + +#ifndef PYTHONWRAPPER_H +#define PYTHONWRAPPER_H + + +#pragma push_macro("slots") +#undef slots +#include "Python.h" +#pragma pop_macro("slots") + + + + +#endif /* end of include guard: PYTHONWRAPPER_H */ diff --git a/moogli/bin/include/utility/conversions.hpp b/moogli/bin/include/utility/conversions.hpp index 53f9f42..616ef52 100644 --- a/moogli/bin/include/utility/conversions.hpp +++ b/moogli/bin/include/utility/conversions.hpp @@ -1,7 +1,7 @@ #ifndef __CONVERSIONS_HPP__ #define __CONVERSIONS_HPP__ -#include "Python.h" +#include "PythonWrapper.h" #include "osg/Vec3f" #include "osg/Vec4f" #include "osg/Vec3d" diff --git a/moogli/bin/moc/NetworkViewer.moc.cpp b/moogli/bin/moc/NetworkViewer.moc.cpp deleted file mode 100644 index 2fd42e5..0000000 --- a/moogli/bin/moc/NetworkViewer.moc.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'NetworkViewer.hpp' -** -** Created: Sat May 9 07:29:34 2015 -** by: The Qt Meta Object Compiler version 63 (Qt 4.8.4) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "view/NetworkViewer.hpp" -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'NetworkViewer.hpp' doesn't include ." -#elif Q_MOC_OUTPUT_REVISION != 63 -#error "This file was generated using the moc from 4.8.4. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -static const uint qt_meta_data_NetworkViewer[] = { - - // content: - 6, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 1, // signalCount - - // signals: signature, parameters, type, tag, flags - 18, 15, 14, 14, 0x05, - - 0 // eod -}; - -static const char qt_meta_stringdata_NetworkViewer[] = { - "NetworkViewer\0\0id\0selected(const char*)\0" -}; - -void NetworkViewer::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - Q_ASSERT(staticMetaObject.cast(_o)); - NetworkViewer *_t = static_cast(_o); - switch (_id) { - case 0: _t->selected((*reinterpret_cast< const char*(*)>(_a[1]))); break; - default: ; - } - } -} - -const QMetaObjectExtraData NetworkViewer::staticMetaObjectExtraData = { - 0, qt_static_metacall -}; - -const QMetaObject NetworkViewer::staticMetaObject = { - { &QGLWidget::staticMetaObject, qt_meta_stringdata_NetworkViewer, - qt_meta_data_NetworkViewer, &staticMetaObjectExtraData } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &NetworkViewer::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *NetworkViewer::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *NetworkViewer::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_NetworkViewer)) - return static_cast(const_cast< NetworkViewer*>(this)); - return QGLWidget::qt_metacast(_clname); -} - -int NetworkViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QGLWidget::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 1) - qt_static_metacall(this, _c, _id, _a); - _id -= 1; - } - return _id; -} - -// SIGNAL 0 -void NetworkViewer::selected(const char * _t1) -{ - void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); -} -QT_END_MOC_NAMESPACE diff --git a/moogli/bin/moc/Viewer.moc.cpp b/moogli/bin/moc/Viewer.moc.cpp deleted file mode 100644 index aa2f77f..0000000 --- a/moogli/bin/moc/Viewer.moc.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'Viewer.hpp' -** -** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.6) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "view/Viewer.hpp" -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'Viewer.hpp' doesn't include ." -#elif Q_MOC_OUTPUT_REVISION != 63 -#error "This file was generated using the moc from 4.8.6. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -static const uint qt_meta_data_Viewer[] = { - - // content: - 6, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 1, // signalCount - - // signals: signature, parameters, type, tag, flags - 11, 8, 7, 7, 0x05, - - 0 // eod -}; - -static const char qt_meta_stringdata_Viewer[] = { - "Viewer\0\0id\0selected(const char*)\0" -}; - -void Viewer::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - Q_ASSERT(staticMetaObject.cast(_o)); - Viewer *_t = static_cast(_o); - switch (_id) { - case 0: _t->selected((*reinterpret_cast< const char*(*)>(_a[1]))); break; - default: ; - } - } -} - -const QMetaObjectExtraData Viewer::staticMetaObjectExtraData = { - 0, qt_static_metacall -}; - -const QMetaObject Viewer::staticMetaObject = { - { &QGLWidget::staticMetaObject, qt_meta_stringdata_Viewer, - qt_meta_data_Viewer, &staticMetaObjectExtraData } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &Viewer::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *Viewer::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *Viewer::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_Viewer)) - return static_cast(const_cast< Viewer*>(this)); - return QGLWidget::qt_metacast(_clname); -} - -int Viewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QGLWidget::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 1) - qt_static_metacall(this, _c, _id, _a); - _id -= 1; - } - return _id; -} - -// SIGNAL 0 -void Viewer::selected(const char * _t1) -{ - void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); -} -QT_END_MOC_NAMESPACE diff --git a/moogli/bin/sip/CMakeLists.txt b/moogli/bin/sip/CMakeLists.txt index 5c183ee..6ff019a 100644 --- a/moogli/bin/sip/CMakeLists.txt +++ b/moogli/bin/sip/CMakeLists.txt @@ -18,7 +18,7 @@ SET(GENERATED_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/sip_moogliViewer.cpp ) -SET(SIP_INCLUDES ${PYQT4_SIP_DIR}) +SET(SIP_INCLUDES ${PYQT5_SIP_DIR}) MESSAGE("++ Using SIP includes: ${SIP_INCLUDES}") add_custom_command(OUTPUT ${GENERATED_SRCS} diff --git a/moogli/bin/sip/moogli.sip b/moogli/bin/sip/moogli.sip index 754309d..04be094 100644 --- a/moogli/bin/sip/moogli.sip +++ b/moogli/bin/sip/moogli.sip @@ -242,7 +242,7 @@ public: PyObject * id() const; %MethodCode - sipRes = PyString_FromString(sipCpp -> id().c_str()); + sipRes = PyBytes_FromString(sipCpp -> id().c_str()); %End // Mesh * @@ -683,7 +683,7 @@ public: PyObject * get_title () const; %MethodCode - sipRes = PyString_FromString(sipCpp -> get_title().c_str()); + sipRes = PyBytes_FromString(sipCpp -> get_title().c_str()); %End void @@ -710,7 +710,7 @@ public: PyObject * get_text_font() const; %MethodCode - sipRes = PyString_FromString(sipCpp -> get_text_font().c_str()); + sipRes = PyBytes_FromString(sipCpp -> get_text_font().c_str()); %End void @@ -827,7 +827,7 @@ public: PyObject * get_view_with_focus(); %MethodCode - sipRes = PyString_FromString(sipCpp -> get_view_with_focus() -> getName().c_str()); + sipRes = PyBytes_FromString(sipCpp -> get_view_with_focus() -> getName().c_str()); %End void diff --git a/moogli/bin/src/shapes/Shape.cpp b/moogli/bin/src/shapes/Shape.cpp index 7313839..307939e 100644 --- a/moogli/bin/src/shapes/Shape.cpp +++ b/moogli/bin/src/shapes/Shape.cpp @@ -403,8 +403,7 @@ MoogliShape::get_specular_highlights_effect_color() const } -MoogliShape::MoogliShapeUpdateCallback::MoogliShapeUpdateCallback(MoogliShape * shape): UpdateCallback() - , shape(shape) +MoogliShape::MoogliShapeUpdateCallback::MoogliShapeUpdateCallback(MoogliShape * shape): shape(shape) { } void diff --git a/moogli/cmake_modules/FindPyQt5.cmake b/moogli/cmake_modules/FindPyQt5.cmake new file mode 100644 index 0000000..b4a52e1 --- /dev/null +++ b/moogli/cmake_modules/FindPyQt5.cmake @@ -0,0 +1,53 @@ +# Find PyQt5 +# ~~~~~~~~~~ +# Copyright (c) 2014, Simon Edwards +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# +# PyQt5 website: http://www.riverbankcomputing.co.uk/pyqt/index.php +# +# Find the installed version of PyQt5. FindPyQt5 should only be called after +# Python has been found. +# +# This file defines the following variables: +# +# PYQT5_VERSION - The version of PyQt5 found expressed as a 6 digit hex number +# suitable for comparison as a string +# +# PYQT5_VERSION_STR - The version of PyQt5 as a human readable string. +# +# PYQT5_VERSION_TAG - The PyQt version tag using by PyQt's sip files. +# +# PYQT5_SIP_DIR - The directory holding the PyQt5 .sip files. +# +# PYQT5_SIP_FLAGS - The SIP flags used to build PyQt. + +IF(EXISTS PYQT5_VERSION) + # Already in cache, be silent + SET(PYQT5_FOUND TRUE) +ELSE(EXISTS PYQT5_VERSION) + + FIND_FILE(_find_pyqt5_py FindPyQt5.py PATHS ${CMAKE_MODULE_PATH}) + + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt5_py} OUTPUT_VARIABLE pyqt5_config) + IF(pyqt5_config) + STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT5_VERSION ${pyqt5_config}) + STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT5_VERSION_STR ${pyqt5_config}) + STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT5_VERSION_TAG ${pyqt5_config}) + STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT5_SIP_DIR ${pyqt5_config}) + STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT5_SIP_FLAGS ${pyqt5_config}) + + SET(PYQT5_FOUND TRUE) + ENDIF(pyqt5_config) + + IF(PYQT5_FOUND) + IF(NOT PYQT5_FIND_QUIETLY) + MESSAGE(STATUS "Found PyQt5 version: ${PYQT5_VERSION_STR}") + ENDIF(NOT PYQT5_FIND_QUIETLY) + ELSE(PYQT5_FOUND) + IF(PYQT5_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find PyQt5.") + ENDIF(PYQT5_FIND_REQUIRED) + ENDIF(PYQT5_FOUND) + +ENDIF(EXISTS PYQT5_VERSION) diff --git a/moogli/cmake_modules/FindPyQt5.py b/moogli/cmake_modules/FindPyQt5.py new file mode 100644 index 0000000..318b9a3 --- /dev/null +++ b/moogli/cmake_modules/FindPyQt5.py @@ -0,0 +1,28 @@ +# Copyright (c) 2014, Simon Edwards +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +import PyQt5.Qt +import sys +import os.path + +print("pyqt_version:%06.0x" % PyQt5.Qt.PYQT_VERSION) +print("pyqt_version_str:%s" % PyQt5.Qt.PYQT_VERSION_STR) + +pyqt_version_tag = "" +in_t = False +for item in PyQt5.Qt.PYQT_CONFIGURATION["sip_flags"].split(' '): + if item=="-t": + in_t = True + elif in_t: + if item.startswith("Qt_5"): + pyqt_version_tag = item + else: + in_t = False +print("pyqt_version_tag:%s" % pyqt_version_tag) + +# FIXME This next line is just a little bit too crude. +pyqt_sip_dir = os.path.join(sys.prefix, "share", "sip", "PyQt5") +print("pyqt_sip_dir:%s" % pyqt_sip_dir) + +print("pyqt_sip_flags:%s" % PyQt5.Qt.PYQT_CONFIGURATION["sip_flags"]) diff --git a/moogli/core/__init__.py b/moogli/core/__init__.py deleted file mode 100644 index 9a71dde..0000000 --- a/moogli/core/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -#import _moogli - -#__all__ = ["_moogli"] diff --git a/moogli/core/viewer.py b/moogli/core/viewer.py index 7fbabd9..f2808e5 100644 --- a/moogli/core/viewer.py +++ b/moogli/core/viewer.py @@ -1,6 +1,4 @@ -import PyQt4 -from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import Qt +from PyQt5.QtCore import Qt import math import _moogli diff --git a/moogli/extensions/__init__.py b/moogli/extensions/__init__.py deleted file mode 100644 index fbc0705..0000000 --- a/moogli/extensions/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -#import nsdf -#import table -#import swc -#import neuroml -import moose - -__all__ = ["moose"] -#"nsdf", -# "table", -# "swc", -# "neuroml", -# "moose"] diff --git a/moogli/extensions/moose/__init__.py b/moogli/extensions/moose/__init__.py index 025f854..d7065f0 100644 --- a/moogli/extensions/moose/__init__.py +++ b/moogli/extensions/moose/__init__.py @@ -1,3 +1,2 @@ from .network import read - __all__ = ["read"] diff --git a/moogli/extensions/moose/network.py b/moogli/extensions/moose/network.py index a7d0374..f47c298 100644 --- a/moogli/extensions/moose/network.py +++ b/moogli/extensions/moose/network.py @@ -1,25 +1,6 @@ import moogli import moose -# class MooseSpineHead(moogli.core.Frustum): -# pass - -# class MooseSpineShaft(moogli.core.Frustum): -# pass - -# class MooseSoma(moogli.core.Sphere): -# pass - -# class MooseDendrite(moogli.core.Frustum): -# def __init__(self, moose_element): -# self.parent = pass - -# class MooseChemicalCompartment(moogli.core.Frustum): -# pass - -# class MooseNetwork() - - def read(path="", vertices=10, track_parent_radius=False): network = moogli.Group(path) neuron = moogli.Group("neuron") diff --git a/moogli/extensions/neuroml/__init__.py b/moogli/extensions/neuroml/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/moogli/extensions/nsdf/__init__.py b/moogli/extensions/nsdf/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/moogli/extensions/swc/__init__.py b/moogli/extensions/swc/__init__.py deleted file mode 100644 index ca6c228..0000000 --- a/moogli/extensions/swc/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .network import SwcNetwork - -__all__ = ["SwcNetwork"] diff --git a/moogli/extensions/swc/network.py b/moogli/extensions/swc/network.py index 4abdbe3..1298eab 100644 --- a/moogli/extensions/swc/network.py +++ b/moogli/extensions/swc/network.py @@ -20,7 +20,6 @@ def __init__(self, filename): swc_data = numpy.genfromtxt(filename, dtype=dtype) neuron = Neuron(neuron_name) self.visualizables[neuron_name] = neuron - print swc_data for (cid, ctype, cx, cy, cz, cr, cpid) in swc_data: # if cid > 200 : break cid = str(cid) diff --git a/moogli/extensions/table/__init__.py b/moogli/extensions/table/__init__.py deleted file mode 100644 index 49bdeaa..0000000 --- a/moogli/extensions/table/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .producer import TableEventDataProducer -from .producer import TableContinuousDataProducer - - -__all__ = ["TableEventDataProducer", - "TableContinuousDataProducer"] diff --git a/moogli/geometry.py b/moogli/geometry.py index 6179298..0abfb2b 100644 --- a/moogli/geometry.py +++ b/moogli/geometry.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import moogli.core._moogli diff --git a/moogli/group.py b/moogli/group.py index f7b26a3..b303c88 100644 --- a/moogli/group.py +++ b/moogli/group.py @@ -91,7 +91,7 @@ def set(self, property, values, mapper=lambda x: x, try: setter = getattr(shape, "set_" + property) setter(mapper(value)) - except AttributeError, e: + except AttributeError as e: if permissive: continue else: @@ -110,7 +110,7 @@ def get(self, property, mapper=lambda x: x, permissive=False): try: getter = getattr(shape, "get_" + property) values.append(mapper(getter())) - except AttributeError, e: + except AttributeError as e: if permissive: values.append(None) else: diff --git a/moogli/main.py b/moogli/main.py index c4c272c..d87038c 100644 --- a/moogli/main.py +++ b/moogli/main.py @@ -1,78 +1,9 @@ -""" -class Visualizer(MorphologyViewer): - - def __init__(parent = None, callback = None): - self.callback = callback - self.morphology = moogli.Morphology("morph", 1) - desktop = QtGui.QApplication.desktop() - self.visualizer = MorphologyEditor( self.morphology - , desktop.screenGeometry().width() - , desktop.screenGeometry().height() - ) - self._timer = QtCore.QTimer(self) - self._update() - - def read_morphology_from_moose(path = ""): - import moose - compartments = moose.wildcardFind(path + "/##[ISA=CompartmentBase]") - for compartment in compartments: - try: - parent_compartment = compartment.neighbors["raxial"][0] - proximal_diameter = parent_compartment.diameter - except IndexError: - proximal_diameter = compartment.diameter - self.morphology.add_compartment( compartment.path - , compartment.parent.path - , compartment.x0 * 10000000 - , compartment.y0 * 10000000 - , compartment.z0 * 10000000 - , proximal_diameter * 10000000 - , compartment.x * 10000000 - , compartment.y * 10000000 - , compartment.z * 10000000 - , compartment.diameter * 10000000 - ) - - def _update(self): - if self.callback is not None: - self.callback(morphology, self) - self.frame() - self._timer.timeout.connect(self._update) - self._timer.start(0) - -def main(): - app = QtGui.QApplication(sys.argv) - filename = os.path.join( os.path.split(os.path.realpath(__file__))[0] - , "../../Demos/neuroml/CA1/CA1.morph.pop.xml") - - - # filename = os.path.join( os.path.split(os.path.realpath(__file__))[0] - # , "../neuroml/PurkinjeCellPassivePulseInput/PurkinjePassive.net.xml") - # filename = os.path.join( os.path.split(os.path.realpath(__file__))[0] - # , "../neuroml/OlfactoryBulbPassive/OBpassive_numgloms3_seed750.0.xml") - - - visualizer = Visualizer() - visualizer.read_morphology_from_moose() - visualizer.show() - return app.exec_() - # popdict, projdict = moose.neuroml.loadNeuroML_L123(filename) - # modelRoot = moose.Neutral("/" + os.path.splitext(os.path.basename(filename))[0]) - # element = moose.Neutral(modelRoot.path + "/model") - # if(moose.exists("/cells")) : moose.move("/cells" , element.path) - # if(moose.exists("/elec")) : moose.move("/elec" , modelRoot.path) - # if(moose.exists("/library")): moose.move("/library", modelRoot.path) - -if __name__ == "__main__": - main() -""" +from moogli.core import _moogli DISTAL = 0 AVERAGED = 1 PROXIMAL_DISTAL = 2 -from core import _moogli - def read_morphology_from_moose(name = "", path = "", radius = DISTAL): import moose @@ -94,14 +25,14 @@ def read_morphology_from_moose(name = "", path = "", radius = DISTAL): ) / 2.0 morphology.add_compartment( compartment.path - , compartment.parent.path - , compartment.x0 * 10000000 - , compartment.y0 * 10000000 - , compartment.z0 * 10000000 - , proximal_diameter * 10000000 - , compartment.x * 10000000 - , compartment.y * 10000000 - , compartment.z * 10000000 - , distal_diameter * 10000000 - ) + , compartment.parent.path + , compartment.x0 * 10000000 + , compartment.y0 * 10000000 + , compartment.z0 * 10000000 + , proximal_diameter * 10000000 + , compartment.x * 10000000 + , compartment.y * 10000000 + , compartment.z * 10000000 + , distal_diameter * 10000000 + ) return morphology diff --git a/moogli/parser/__init__.py b/moogli/parser/__init__.py deleted file mode 100644 index 912230b..0000000 --- a/moogli/parser/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -import swc -import csv -import tsv -import dat -import txt -import nsdf -import nml -import table - -__all__ = [ "swc" - , "csv" - , "tsv" - , "dat" - , "txt" - , "nsdf" - , "nml" - , "table" - ] diff --git a/moogli/parser/csv.py b/moogli/parser/csv.py index 37d16e1..57aa288 100644 --- a/moogli/parser/csv.py +++ b/moogli/parser/csv.py @@ -14,7 +14,7 @@ """ https://en.wikipedia.org/wiki/Comma-separated_values """ -import .table +import moogli.parser.table LINE_SEPARATOR_REGEX = r"[\n\r]*" # Windows or Unix style newline character COLUMN_SEPARATOR_REGEX = r"," # Any number of spaces followed by comma followed by any number of spaces diff --git a/moogli/parser/dat.py b/moogli/parser/dat.py index 1ae930c..e97e932 100644 --- a/moogli/parser/dat.py +++ b/moogli/parser/dat.py @@ -1,9 +1,4 @@ -""" -dat -=== - -""" -import .table +import moogli.parser.table LINE_SEPARATOR_REGEX = r"[\n\r]*" # Windows or Unix style newline character COLUMN_SEPARATOR_REGEX = r"[\t ]*,?[\t ]*" # Any number of tabs or spaces followed by @@ -11,10 +6,10 @@ def parse(filename): return table.parse( filename - , LINE_SEPARATOR_REGEX - , COLUMN_SEPARATOR_REGEX - , COMMENT_REGEX - , lambda line: ( table.to_string(line[0]) - , map(table.to_float, line[1:]) - ) - ) + , LINE_SEPARATOR_REGEX + , COLUMN_SEPARATOR_REGEX + , COMMENT_REGEX + , lambda line: ( table.to_string(line[0]) + , map(table.to_float, line[1:]) + ) + ) diff --git a/moogli/parser/tsv.py b/moogli/parser/tsv.py index 4c1f3b9..76f07e5 100644 --- a/moogli/parser/tsv.py +++ b/moogli/parser/tsv.py @@ -1,4 +1,4 @@ -import .table +import moogli.parser.table LINE_SEPARATOR_REGEX = r"[\n\r]*" # Windows or Unix style newline character COLUMN_SEPARATOR_REGEX = r"\t" # Any number of tabs @@ -6,10 +6,10 @@ def parse(filename): return table.parse( filename - , LINE_SEPARATOR_REGEX - , COLUMN_SEPARATOR_REGEX - , COMMENT_REGEX - , lambda line: ( table.to_string(line[0]) - , map(table.to_float, line[1:]) - ) - ) + , LINE_SEPARATOR_REGEX + , COLUMN_SEPARATOR_REGEX + , COMMENT_REGEX + , lambda line: ( table.to_string(line[0]) + , map(table.to_float, line[1:]) + ) + ) diff --git a/moogli/parser/txt.py b/moogli/parser/txt.py index 47ac6cd..2d9fcf6 100644 --- a/moogli/parser/txt.py +++ b/moogli/parser/txt.py @@ -1,4 +1,4 @@ -import .table +import moogli.parser.table LINE_SEPARATOR_REGEX = r"[\n\r]*" # Windows or Unix style newline character COLUMN_SEPARATOR_REGEX = r"[\t ]*,?[\t ]*" # Any number of tabs or spaces followed by @@ -6,42 +6,34 @@ def parse(filename): return table.parse( filename - , LINE_SEPARATOR_REGEX - , COLUMN_SEPARATOR_REGEX - , COMMENT_REGEX - , lambda line: ( table.to_string(line[0]) - , map(table.to_float, line[1:]) - ) - ) + , LINE_SEPARATOR_REGEX + , COLUMN_SEPARATOR_REGEX + , COMMENT_REGEX + , lambda line: ( table.to_string(line[0]) + , map(table.to_float, line[1:]) ) + ) def create_morphology(data): if len(data[0]) is 7: return map( lambda line: ( table.to_string(line[0]) - , table.to_string(line[1]) - , table.to_string(line[2]) - , table.to_float(line[3]) - , table.to_float(line[4]) - , table.to_float(line[5]) - , table.to_float(line[6]) - ) - , data - ) + , table.to_string(line[1]) + , table.to_string(line[2]) + , table.to_float(line[3]) + , table.to_float(line[4]) + , table.to_float(line[5]) + , table.to_float(line[6]) + ) , data) elif len(data[0]) is 6: return map( lambda line: ( table.to_string(line[0]) - , table.to_string(line[1]) - , table.to_float(line[2]) - , table.to_float(line[3]) - , table.to_float(line[4]) - , table.to_float(line[5]) - ) - , data - ) + , table.to_string(line[1]) + , table.to_float(line[2]) + , table.to_float(line[3]) + , table.to_float(line[4]) + , table.to_float(line[5]) + ) , data) def create_simulationdata(data): return map( lambda line: ( table.to_string(line[0]) - , map(table.to_float, line[1:]) - ) - , data - ) + , map(table.to_float, line[1:]) + ) , data) -class Simulation diff --git a/moogli/shapes.py b/moogli/shapes.py index 0254da7..a8480be 100644 --- a/moogli/shapes.py +++ b/moogli/shapes.py @@ -1,5 +1,5 @@ -from core import _moogli import moogli +from moogli.core import _moogli import collections class Frustum(_moogli.Frustum): diff --git a/moogli/simulator/__init__.py b/moogli/simulator/__init__.py deleted file mode 100644 index 4003f9c..0000000 --- a/moogli/simulator/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from . import moose - -__all__ = [ "moose" - ] diff --git a/moogli/simulator/moose.py b/moogli/simulator/moose.py index 0b79650..412c516 100644 --- a/moogli/simulator/moose.py +++ b/moogli/simulator/moose.py @@ -7,36 +7,9 @@ import moogli from moogli.utils import * import operator -import PyQt4 +from PyQt5.QtWidgets import QApplication import math import time -# def _handle_spinemesh(network, spinemesh, moose = moose): -# group = moogli.Group(spinemesh.path) - -# moose_neuron = moose.element(spinemesh.cell) -# moogli_neuron = network.get_neuron(moose_neuron.path) -# compartment_paths = mesh.elecComptList -# voxel_start_indices = neuromesh.startVoxelInCompt -# voxel_end_indices = neuromesh.endVoxelInCompt -# voxel_counts = map( operator.sub -# , voxel_end_indices -# , voxel_start_indices -# ) -# voxel_id_template = "{electrical_compartment_id}/{voxel_index}" -# for (compartment_path, voxel_start_index, voxel_end_index) in -# zip(compartment_paths, voxel_start_indices, voxel_end_indices): -# moogli_compartment = neuron.get_compartment(compartment_path) -# moogli_neuron.create_chemical_compartments( moogli_compartment -# , voxel_count -# , map( lambda voxel_index: voxel_id_template.format( voxel_index = voxel_index -# , -# ) -# , range( voxel_start_index -# , voxel_end_index -# ) -# ) -# , repeat() -# ) def colorstyle(visualizable): return (1.0, 0.0, 1.0, 1.0) @@ -524,7 +497,7 @@ def create_viewer( moose_network return viewer def view(path="", callbacks = [(id, id, id)]): - application = PyQt4.QtGui.QApplication([]) + application = QApplication([]) viewers = [] for (prelude, interlude, postlude) in callbacks: network = read_network(path = path, track_parent = False) diff --git a/moogli/viewers.py b/moogli/viewers.py index 43d4018..f3e9ab2 100644 --- a/moogli/viewers.py +++ b/moogli/viewers.py @@ -1,6 +1,5 @@ -import PyQt4 -from PyQt4 import QtGui -from PyQt4.QtCore import Qt +from PyQt5.QtCore import Qt +from PyQt5.QtCore import QTimer import math import moogli.core._moogli @@ -58,7 +57,7 @@ def run(self): self.viewer().update() if self._done: return if self._pause: return - PyQt4.QtCore.QTimer.singleShot(self.idletime, self.run) + QTimer.singleShot(self.idletime, self.run) def attach_color_bar(self, color_bar): if color_bar in self._color_bars: return @@ -238,13 +237,3 @@ def keyPressEvent(self, event): def get_view_with_focus(self): view_id = super(Viewer, self).get_view_with_focus() return self._views[view_id] - - # @QtCore.pyqtSlot(str) - # def printme(self, name): - # # cursor = QtGui.QCursor().pos() - # menu = QtGui.QMenu() - # menu.addAction("a") - # menu.addAction("b") - # menu.addAction("c") - # menu.exec_(QtGui.QCursor().pos()) - # print("Selected = > ", name) diff --git a/moogli/visualization/__init__.py b/moogli/visualization/__init__.py deleted file mode 100644 index 058deb6..0000000 --- a/moogli/visualization/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -import pipeline -import plots -from .main import NetworkVisualizer -from .main import NetworkVisualizationEnvironment - -__all__ = ["NetworkVisualizer", - "NetworkVisualizationEnvironment", - "pipeline", - "plots"] diff --git a/moogli/visualization/main.py b/moogli/visualization/main.py index 9133091..baf36ca 100644 --- a/moogli/visualization/main.py +++ b/moogli/visualization/main.py @@ -1,7 +1,8 @@ from .pipeline import SimulationDataConsumer from moogli.core import NetworkViewer -from PyQt4.QtGui import QWidget, QGridLayout -from PyQt4.QtCore import QTimer + +from PyQt5.QtWidgets import QWidget, QGridLayout +from PyQt5.QtCore import QTimer class NetworkVisualizer(SimulationDataConsumer, NetworkViewer): @@ -14,7 +15,6 @@ def consume(self): for mediator in self.mediators: for (visualizable, value) in mediator.output.items(): self.network.visualizables[visualizable].set_color(value) - # print self.network.visualizables[visualizable] self.update() def reinit(self): @@ -52,7 +52,6 @@ def stop(self): def run(self): self.advance() - print self.clock.now() # self.interlude(self) # self.update() # if self._done: diff --git a/moogli/visualization/pipeline/__init__.py b/moogli/visualization/pipeline/__init__.py deleted file mode 100644 index f8aafc0..0000000 --- a/moogli/visualization/pipeline/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -from .producer import SimulationDataProducer -from .mediator import SimulationDataMediator -from .consumer import SimulationDataConsumer -from .data import SimulationData -from .data import VisualizationData -from .clock import Clock -from .main import Pipeline - -__all__ = ["SimulationDataProducer", - "SimulationDataMediator", - "SimulationDataConsumer", - "SimulationData", - "VisualizationData", - "Clock", - "Pipeline"] diff --git a/moogli/visualization/plots/__init__.py b/moogli/visualization/plots/__init__.py deleted file mode 100644 index d3ac58d..0000000 --- a/moogli/visualization/plots/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .line import LinePlotter - - -__all__ = ["LinePlotter"] diff --git a/moogli/visualization/plots/line.py b/moogli/visualization/plots/line.py index f87db98..64c6df0 100644 --- a/moogli/visualization/plots/line.py +++ b/moogli/visualization/plots/line.py @@ -1,19 +1,17 @@ from moogli import constants from moogli.visualization.pipeline import SimulationDataConsumer -from PyQt4.QtGui import QWidget -from PyQt4.QtGui import QMenu -from PyQt4.QtGui import QAction -from PyQt4.QtGui import QGridLayout -from PyQt4.QtCore import pyqtSlot -from PyQt4 import QtCore +from PyQt5.QtWidgets import QWidget, QMenu, QAction, QGridLayout +from PyQt5.QtCore import pyqtSlot +from PyQt5.QtCore import SLOT, SIGNAL + from matplotlib.lines import Line2D from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar from matplotlib.figure import Figure + import numpy import csv import time -from PyQt4.QtCore import SLOT, SIGNAL class LinePlotter(SimulationDataConsumer, QWidget): @@ -254,7 +252,7 @@ def consume(self): for line in self.axes.lines: for mediator in self.mediators: try: - print "gid", line.get_gid() + print( "gid", line.get_gid() ) yvalue = mediator.output[line.get_gid()] ydata = numpy.append(line.get_ydata(), yvalue) diff --git a/moogli/widgets/__init__.py b/moogli/widgets/__init__.py deleted file mode 100644 index 0d714e6..0000000 --- a/moogli/widgets/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .colorbar import ColorBar - -__all__ = ["ColorBar"] diff --git a/setup.py b/setup.py index c8248d8..7f96f08 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,6 @@ # -*- coding: utf-8 -*- """setup.py: - This script is used with cmake to install moogli. - -This must be called as - - python cmake_modules/setup.py install - -NOTE: This repository is clone of `https://github.com/aviralg/moogli`. - """ __author__ = "Dilawar Singh" @@ -23,10 +15,11 @@ import sys import os -from distutils.core import setup, Extension +import setuptools + long_description = open(os.path.join('.', "README.md")).read() -_version = '0.5.git' +_version = '0.6.1' if os.path.exists( 'VERSION' ): with open( 'VERSION', 'r' ) as f: _version = f.read( ) @@ -38,37 +31,18 @@ print("We are in %s" % os.getcwd()) quit() -setup(name='moogli', - author='Aviral Goel', +setuptools.setup(name='moogli', + author='Aviral Goel, Dilawar Singh', author_email='aviralg@ncbs.res.in', maintainer='Dilawar Singh', maintainer_email='dilawars@ncbs.res.in', version=_version, url='https://github.com/BhallaLab/moogli', - download_url='https://github.com/aviralg/moogli', + download_url='https://github.com/BhallaLab/moogli', description="A 3D visualizer for neuronal networks", long_description=long_description, - classifiers=['Development Status :: 3 - Alpha', - 'Environment :: X11 Applications :: Qt', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: C++', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Topic :: Scientific/Engineering'], license='GPLv2', include_package_data = True, - packages=[ - "moogli", - "moogli.core", - "moogli.widgets", - "moogli.extensions", - "moogli.extensions.moose", - "moogli.visualization", - "moogli.visualization.pipeline" - ], - package_dir = { 'moogli.core' : 'moogli/core' }, + packages= setuptools.find_packages(), package_data = { 'moogli.core' : [ '_moogli.so' ] }, ) diff --git a/test/test.py b/test/test.py index 15556f6..1fdaefb 100644 --- a/test/test.py +++ b/test/test.py @@ -1,56 +1,4 @@ import moogli -import unittest - -# network1 = moogli.Network("Network-1") -# network2 = moogli.Network("Network-2") - -# print(network1) -# print(network2) - -# assert network1 != network2 - -# for i in range(0, 10): -# neuron = moogli.Neuron("Neuron-" + str(i)) -# network1.attach(neuron) -# print(neuron) - -# for i in range(10, 20): -# neuron = moogli.Neuron("Neuron-" + str(i)) -# network2.attach(neuron) -# print(neuron) - -# assert(network1.size() == 10) -# assert(network2.size() == 10) - -class NetworkTests(unittest.TestCase): - def setUp(self): - self.networks = [] - self.network = moogli.Network("network") - for i in range(10): - self.networks.append(moogli.Network(str(i))) - - def tearDown(self): - self.networks = None - - def test_id(self): - for i in range(10): - self.assertTrue(self.networks[i].id, str(i)) - - def test_visibility(self): - self.network.show() - self.assertTrue(self.network.visible()) - self.network.hide() - self.assertFalse(self.network.visible()) - - def test_length(self): - self.assertTrue(len(self.network), 0) - self.network.attach(moogli.Neuron("a")) - self.assertTrue(len(self.network), 1) - self.network.attach(moogli.Neuron("b")) - self.assertTrue(len(self.network), 2) - -def main(): - unittest.main() - -if __name__ == "__main__": - main() +print( 'Using moogli from %s' % moogli.__file__) +print( dir(moogli) ) +print( moogli.extensions.moose )