Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions .travis_prepare_linux.sh
Original file line number Diff line number Diff line change
@@ -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

29 changes: 20 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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**

Expand All @@ -64,3 +62,7 @@ https://cygwin.com/ml/cygwin-apps/2009-06/msg00134.html
**Solution**

Install libopenscenegraph-dev

# Arch Linux

Install `openscanegraph` and `osgqt`.
35 changes: 0 additions & 35 deletions __init__.py

This file was deleted.

80 changes: 55 additions & 25 deletions moogli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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}")

Expand All @@ -31,22 +31,30 @@ 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
)

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}")
Expand All @@ -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})
Expand All @@ -97,4 +126,5 @@ ELSE(APPLE)
"-Wl,--no-whole-archive"
)
ENDIF(APPLE)
TARGET_LINK_LIBRARIES(_moogli ${DYNAMIC_LIBRARIES})

target_link_libraries(_moogli ${DYNAMIC_LIBRARIES})
42 changes: 19 additions & 23 deletions moogli/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
29 changes: 29 additions & 0 deletions moogli/bin/include/utility/PythonWrapper.h
Original file line number Diff line number Diff line change
@@ -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 */
2 changes: 1 addition & 1 deletion moogli/bin/include/utility/conversions.hpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Loading