Commit cc7568a7 authored by Václav Šmilauer's avatar Václav Šmilauer
Browse files

1. Remove linkStrategy option. Specifying chunkSize=1 provides the per-plugin linkage.

2. Add qt4 feature, which conflicts qt3. Qt3 must be now explicitly defined. QT4DIR must be defined (defaults to /usr/share/qt4, which works for debian)
3. Add checks for python modules and prettify boost checks.
4. Remove a lot of legacy code, so that the qt4 build avoids yade::serialization completely
5. Add live inspection and modification of arbitrary sequences, for a showcase see the Inspect button on the simulation tab (Body/Interaction inspection will be rather easy as well)
6. Add common handling of number arrays (Vector3, Matrix3, Quaternion)
7. Add to-python converters for vector<vector<string>> and list<string> (only needed in Dispatchers, avoids tome exceptions)
8. Rename OpenGLRenderingEngine to OpenGLRenderer
parent 0d8ce225
......@@ -109,9 +109,9 @@ profile=env['profile']
print '@@@ Using profile',profile,'('+optsFile+') @@@'
# defaults for various profiles
if profile=='default': defOptions={'debug':0,'variant':'','optimize':1,'linkStrategy':'monolithic'}
elif profile=='dbg': defOptions={'debug':1,'variant':'-dbg','optimize':0,'linkStrategy':'per-class'}
else: defOptions={'debug':0,'optimize':0,'variant':'-'+profile,'linkStrategy':'per-class'}
if profile=='default': defOptions={'debug':0,'variant':'','optimize':1,'chunkSize':10}
elif profile=='dbg': defOptions={'debug':1,'variant':'-dbg','optimize':0,'chunkSize':1}
else: defOptions={'debug':0,'optimize':0,'variant':'-'+profile,'chunkSize':10}
opts=Variables(optsFile)
......@@ -139,13 +139,12 @@ opts.AddVariables(
BoolVariable('optimize','Turn on heavy optimizations',defOptions['optimize']),
ListVariable('exclude','Yade components that will not be built','none',names=['gui','extra','common','dem','lattice','snow']),
EnumVariable('PGO','Whether to "gen"erate or "use" Profile-Guided Optimization','',['','gen','use'],{'no':'','0':'','false':''},1),
ListVariable('features','Optional features that are turned on','log4cxx,opengl,gts,openmp,vtk',names=['opengl','log4cxx','cgal','openmp','gts','vtk','python','gl2ps','devirt-functors','noqt3','qt4','never_use_this_one']),
ListVariable('features','Optional features that are turned on','log4cxx,opengl,gts,openmp,vtk',names=['opengl','log4cxx','cgal','openmp','gts','vtk','python','gl2ps','devirt-functors','noqt3','qt3','qt4','never_use_this_one']),
('jobs','Number of jobs to run at the same time (same as -j, but saved)',2,None,int),
#('extraModules', 'Extra directories with their own SConscript files (must be in-tree) (whitespace separated)',None,None,Split),
('buildPrefix','Where to create build-[version][variant] directory for intermediary files','..'),
EnumVariable('linkStrategy','How to link plugins together',defOptions['linkStrategy'],['per-class','per-pkg[broken]','monolithic','static[broken]']),
('hotPlugins','Files (without the .cpp extension) that will be compiled separately even in the monolithic build (use for those that you modify frequently); comma-separated.',''),
('chunkSize','Maximum files to compile in one translation unit when building plugins. (unlimited if <= 0)',7,None,int),
('chunkSize','Maximum files to compile in one translation unit when building plugins. (unlimited if <= 0, per-file linkage is used if 1)',7,None,int),
('version','Yade version (if not specified, guess will be attempted)',None),
('realVersion','Revision (usually bzr revision); guessed automatically unless specified',None),
('CPPPATH', 'Additional paths for the C preprocessor (colon-separated)','/usr/include/vtk-5.0:/usr/include/vtk-5.2:/usr/include/vtk-5.4:/usr/include/eigen2'), # hardy has vtk-5.0
......@@ -167,6 +166,14 @@ if str(env['features'])=='all':
print 'ERROR: using "features=all" is illegal, since it breaks feature detection at runtime (SCons limitation). Write out all features separated by commas instead. Sorry.'
Exit(1)
if 'noqt3' in env['features']:
print 'WARNING: noqt3 feature is deprecated, use qt4 instead.'
if 'qt4' not in env['features']: env['features'].append('qt4')
if 'qt3' in env['features'] and 'qt4' in env['features']:
print 'ERROR: you specified both qt3 and qt4 features, which are mutually exclusive'
Exit(1)
opts.Save(optsFile,env)
# fix expansion in python substitution by assigning the right value if not specified
if not env.has_key('runtimePREFIX') or not env['runtimePREFIX']: env['runtimePREFIX']=env['PREFIX']
......@@ -269,37 +276,7 @@ def CheckQt(context, qtdirs):
return ret
return False
def CheckPython(context):
"Checks for functional python/c API. Sets variables if OK and returns true; otherwise returns false."
origs={'LIBS':context.env['LIBS'],'LIBPATH':context.env['LIBPATH'],'CPPPATH':context.env['CPPPATH'],'LINKFLAGS':context.env['LINKFLAGS']}
context.Message('Checking for Python development files... ')
if 1:
try:
#FIXME: once caught, exception disappears along with the actual message of what happened...
import distutils.sysconfig as ds
context.env.Append(CPPPATH=ds.get_python_inc(),LIBS=ds.get_config_var('LIBS').split() if ds.get_config_var('LIBS') else None)
context.env.Append(LINKFLAGS=ds.get_config_var('LINKFORSHARED').split()+ds.get_config_var('BLDLIBRARY').split())
ret=context.TryLink('#include<Python.h>\nint main(int argc, char **argv){Py_Initialize(); Py_Finalize();}\n','.cpp')
if not ret: raise RuntimeError
except (ImportError,RuntimeError,ds.DistutilsPlatformError):
for k in origs.keys(): context.env[k]=origs[k]
context.Result(False)
return False
else:
env.ParseConfig("python2.5-dbg-config --cflags")
env.ParseConfig("python2.5-dbg-config --ldflags")
context.Result(True)
return True
def CheckPythonModule(context,modulename):
context.Message("Checking for python module `%s' ..."%modulename)
try:
exec("import %s"%modulename)
context.Result(True); return True
except ImportError:
context.Result(False); return False
def CheckScientificPython(context): return CheckPythonModule(context,"Scientific")
def CheckIPython(context): return CheckPythonModule(context,"IPython")
def CheckCXX(context):
context.Message('Checking whether c++ compiler "%s" works...'%env['CXX'])
ret=context.TryLink('#include<iostream>\nint main(int argc, char**argv){std::cerr<<std::endl;return 0;}\n','.cpp')
......@@ -311,39 +288,81 @@ def CheckLibStdCxx(context):
context.env['libstdcxx']=ret
context.Result(ret)
return ret
def CheckPython(context):
"Checks for functional python/c API. Sets variables if OK and returns true; otherwise returns false."
origs={'LIBS':context.env['LIBS'],'LIBPATH':context.env['LIBPATH'],'CPPPATH':context.env['CPPPATH'],'LINKFLAGS':context.env['LINKFLAGS']}
context.Message('Checking for Python development files... ')
try:
#FIXME: once caught, exception disappears along with the actual message of what happened...
import distutils.sysconfig as ds
context.env.Append(CPPPATH=ds.get_python_inc(),LIBS=ds.get_config_var('LIBS').split() if ds.get_config_var('LIBS') else None)
context.env.Append(LINKFLAGS=ds.get_config_var('LINKFORSHARED').split()+ds.get_config_var('BLDLIBRARY').split())
ret=context.TryLink('#include<Python.h>\nint main(int argc, char **argv){Py_Initialize(); Py_Finalize();}\n','.cpp')
if not ret: raise RuntimeError
except (ImportError,RuntimeError,ds.DistutilsPlatformError):
for k in origs.keys(): context.env[k]=origs[k]
context.Result('error')
return False
context.Result('ok'); return True
def CheckBoost(context):
context.Message('Checking boost libraries... ')
libs=[
('boost_system','boost/system/error_code.hpp','boost::system::error_code();',False),
('boost_thread','boost/thread/thread.hpp','boost::thread();',True),
('boost_date_time','boost/date_time/posix_time/posix_time.hpp','boost::posix_time::time_duration();',True),
('boost_filesystem','boost/filesystem/path.hpp','boost::filesystem::path();',True),
('boost_iostreams','boost/iostreams/device/file.hpp','boost::iostreams::file_sink("");',True),
('boost_regex','boost/regex.hpp','boost::regex("");',True),
('boost_serialization','boost/archive/archive_exception.hpp','try{} catch (const boost::archive::archive_exception& e) {};',True),
('boost_program_options','boost/program_options.hpp','boost::program_options::options_description o;',True),
('boost_python','boost/python.hpp','boost::python::scope();',True),
]
failed=[]
def checkLib_maybeMT(lib,header,func):
for LIB in (lib,lib+'-mt'):
LIBS=env['LIBS'][:]; context.env.Append(LIBS=[LIB])
if context.TryLink('#include<'+header+'>\nint main(void){'+func+';}','.cpp'): return True
env['LIBS']=LIBS
return False
for lib,header,func,mandatory in libs:
ok=checkLib_maybeMT(lib,header,func)
if not ok and mandatory: failed.append(lib)
if failed: context.Result('Failures: '+', '.join(failed)); return False
context.Result('all ok'); return True
def CheckPythonModules(context):
context.Message("Checking for required python modules... ")
mods=[('IPython','ipython'),('numpy','python-numpy'),('matplotlib','python-matplotlib'),('Xlib','python-xlib')]
if 'qt4' in context.env['features']: mods.append(('PyQt4.QtGui','python-qt4'))
failed=[]
for m,pkg in mods:
try:
exec("import %s"%m)
except ImportError:
failed.append(m+' (package %s)'%pkg)
if failed: context.Result('Failures: '+', '.join(failed)); return False
context.Result('all ok'); return True
if not env.GetOption('clean'):
conf=env.Configure(custom_tests={'CheckLibStdCxx':CheckLibStdCxx,'CheckQt':CheckQt,'CheckCXX':CheckCXX,'CheckPython':CheckPython,'CheckScientificPython':CheckScientificPython,'CheckIPython':CheckIPython},
conf_dir='$buildDir/.sconf_temp',log_file='$buildDir/config.log')
conf=env.Configure(custom_tests={'CheckLibStdCxx':CheckLibStdCxx,'CheckQt':CheckQt,'CheckCXX':CheckCXX,'CheckBoost':CheckBoost,'CheckPython':CheckPython,'CheckPythonModules':CheckPythonModules},
conf_dir='$buildDir/.sconf_temp',log_file='$buildDir/config.log'
)
ok=True
ok&=conf.CheckCXX()
if not ok:
print "\nYour compiler is broken, no point in continuing. See `%s' for what went wrong and use the CXX/CXXFLAGS parameters to change your compiler."%(buildDir+'/config.log')
Exit(1)
conf.CheckLibStdCxx()
# check essential libs
ok&=conf.CheckLibWithHeader('pthread','pthread.h','c','pthread_exit(NULL);',autoadd=1)
# gentoo has threaded flavour named differently and it must have precedence over the non-threaded one
def CheckLib_maybeMT(conf,lib,header,lang,func): return conf.CheckLibWithHeader(lib+'-mt',['limits.h',header],'c++',func,autoadd=1) or conf.CheckLibWithHeader(lib,['limits.h',header],lang,func,autoadd=1)
# in boost::filesystem>=1.35 depends on boost::system being explicitly linked to; if not present, we are probably in <=1.34, where boost::system didn't exist and wasn't needed either
CheckLib_maybeMT(conf,'boost_system','boost/system/error_code.hpp','c++','boost::system::error_code(); /* non-essential */')
ok&=CheckLib_maybeMT(conf,'boost_thread','boost/thread/thread.hpp','c++','boost::thread();')
ok&=CheckLib_maybeMT(conf,'boost_date_time','boost/date_time/posix_time/posix_time.hpp','c++','boost::posix_time::time_duration();')
ok&=CheckLib_maybeMT(conf,'boost_filesystem','boost/filesystem/path.hpp','c++','boost::filesystem::path();')
ok&=CheckLib_maybeMT(conf,'boost_iostreams','boost/iostreams/device/file.hpp','c++','boost::iostreams::file_sink("");')
ok&=CheckLib_maybeMT(conf,'boost_regex','boost/regex.hpp','c++','boost::regex("");')
ok&=CheckLib_maybeMT(conf,'boost_serialization','boost/archive/archive_exception.hpp','c++','try{} catch (const boost::archive::archive_exception& e) {};')
ok&=CheckLib_maybeMT(conf,'boost_program_options','boost/program_options.hpp','c++','boost::program_options::options_description o;')
ok&=(conf.CheckPython() and conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h'],'<>'))
ok&=conf.CheckPythonModules()
ok&=conf.CheckBoost()
env['haveForeach']=conf.CheckCXXHeader('boost/foreach.hpp','<>')
if not env['haveForeach']: print "(OK, local version will be used instead)"
ok&=conf.CheckLibWithHeader('sqlite3','sqlite3.h','c++','sqlite3_close(0L);',autoadd=1)
ok&=(conf.CheckPython()
and conf.CheckIPython() # not needed now: and conf.CheckScientificPython()
and CheckLib_maybeMT(conf,'boost_python','boost/python.hpp','c++','boost::python::scope();')
and conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h'],'<>'))
ok&=conf.CheckCXXHeader('Eigen/Core')
# for installable stript's shebang ( http://en.wikipedia.org/wiki/Shebang_(Unix) )
env['pyExecutable']=sys.executable
......@@ -360,7 +379,7 @@ if not env.GetOption('clean'):
ok=conf.CheckLibWithHeader('glut','GL/glut.h','c++','glutGetModifiers();',autoadd=1)
# TODO ok=True for darwin platform where openGL (and glut) is native
if not ok: featureNotOK('opengl')
if not 'noqt3' in env['features'] and 'qt4' not in env['features']:
if 'qt3' in env['features']:
ok=conf.CheckQt(env['QTDIR'])
if not ok: featureNotOK('opengl','Building with OpenGL implies qt3 interface, which was not found, although OpenGL was.')
env.Tool('qt'); env.Replace(QT_LIB='qt-mt')
......@@ -371,10 +390,11 @@ if not env.GetOption('clean'):
env['ENV']['PKG_CONFIG_PATH']='/usr/bin/pkg-config'
env.Tool('qt4')
env.EnableQt4Modules(['QtGui','QtCore','QtXml','QtOpenGL'])
ok=conf.CheckLibWithHeader(['qglviewer-qt4'],'QGLViewer/qglviewer.h','c++','QGLViewer();',autoadd=0)
if not ok: featureNotOK('opengl','Building with Qt4 implies the QGLViewer library installed (libqglviewer-qt4-dev package in debian/ubuntu)')
if not conf.TryAction(env.Action('pyrcc4'),'','qrc'): featureNotOK('qt4','The pyrcc4 program is not operational (package pyqt4-dev-tools)')
if not conf.TryAction(env.Action('pyuic4'),'','ui'): featureNotOK('qt4','The pyuic4 program is not operational (package pyqt4-dev-tools)')
ok=conf.CheckLibWithHeader(['qglviewer-qt4'],'QGLViewer/qglviewer.h','c++','QGLViewer();',autoadd=1)
if not ok: featureNotOK('opengl','Building with Qt4 implies the QGLViewer library installed (package libqglviewer-qt4-dev package in debian/ubuntu)')
env['QGLVIEWER_LIB']='qglviewer-qt4';
if 'vtk' in env['features']:
ok=conf.CheckLibWithHeader(['vtkCommon'],'vtkInstantiator.h','c++','vtkInstantiator::New();',autoadd=1)
env.Append(LIBS='vtkHybrid')
......@@ -396,8 +416,6 @@ if not env.GetOption('clean'):
env.Append(LIBS='yade-support')
env.Append(CPPDEFINES=['YADE_'+f.upper().replace('-','_') for f in env['features']])
# temporary, until #ifdefs removed from the code
env.Append(CPPDEFINES=['YADE_BOOST_SERIALIZATION','YADE_SERIALIZE_USING_BOOST'])
env=conf.Finish()
......@@ -429,6 +447,7 @@ if env['brief']:
INSTALLSTR='> $TARGET',
QT_UICCOMSTR='U ${SOURCES}',
QT_MOCCOMSTR='M ${SOURCES}',
QT4_UICCOMSTR='U ${SOURCES}',
QT_MOCFROMHCOMSTR='M ${SOURCES}',
QT_MOCFROMCXXCOMSTR='M ${SOURCES}',
)
......@@ -588,7 +607,7 @@ env.Append(BUILDERS = {'Combine': env.Builder(action = SCons.Action.Action(combi
import yadeSCons
allPlugs=yadeSCons.scanAllPlugins(None,feats=env['features'])
buildPlugs=yadeSCons.getWantedPlugins(allPlugs,env['exclude'],env['features'],env['linkStrategy'],env['hotPlugins'].split(','))
buildPlugs=yadeSCons.getWantedPlugins(allPlugs,env['exclude'],env['features'],env['chunkSize'],env['hotPlugins'].split(','))
def linkPlugins(plugins):
"""Given list of plugins we need to link to, return list of real libraries that we should link to."""
ret=set()
......
......@@ -3,9 +3,7 @@
#include<yade/core/BodyContainer.hpp>
#include<yade/core/Body.hpp>
#ifdef YADE_BOOST_SERIALIZATION
BOOST_CLASS_EXPORT(BodyContainer);
#endif
BOOST_CLASS_EXPORT(BodyContainer);
unsigned int BodyContainer::findFreeId(){
unsigned int max=body.size();
......
......@@ -4,9 +4,9 @@
*
* The interface sort of emulates map string->string (which is not handled by yade-serialization).
*
* The "keys" (called displayTypes) are intended to be "OpenGLRenderingEngine" or "GLViewer" (and perhaps other).
* The "keys" (called displayTypes) are intended to be "OpenGLRenderer" or "GLViewer" (and perhaps other).
* The "values" are intended to be XML representation of display parameters, obtained either by yade-serialization
* with OpenGLRenderingEngine and saveStateToStream with QGLViewer (and GLViewer).
* with OpenGLRenderer and saveStateToStream with QGLViewer (and GLViewer).
*
*/
......
......@@ -4,7 +4,6 @@
*************************************************************************/
#include<cstdlib>
#include<yade/lib-multimethods/MultiMethodsExceptions.hpp>
#include<boost/date_time/posix_time/posix_time.hpp>
#include<yade/core/Omega.hpp>
......@@ -27,12 +26,12 @@ void FileGenerator::setFileName(const string& fileName)
outputFileName=fileName;
}
#ifndef YADE_NO_YADE_SERIALIZATION
void FileGenerator::setSerializationLibrary(const string& lib)
{
serializationDynlib=lib;
}
#endif
bool FileGenerator::generate()
{
......@@ -49,9 +48,6 @@ bool FileGenerator::generateAndSave()
try {
status=generate(); // will modify message
}
catch(SerializableError& e){message+=string("SeriazableError: ")+e.what(); return false;}
catch(FactoryError& e){message+=string("FactoryError: ")+e.what(); return false;}
catch(MultiMethodsError& e){message+=string("MultiMethodsError: ")+e.what(); return false;}
catch(std::exception& e){
LOG_FATAL("Unhandled exception: "<<typeid(e).name()<<" : "<<e.what());
//abort(); // use abort, since we may want to inspect core
......@@ -69,13 +65,9 @@ bool FileGenerator::generateAndSave()
setProgress(1.0);
try
{
#ifdef YADE_SERIALIZE_USING_BOOST
yade::ObjectIO::save(outputFileName,"scene",rootBody);
#else
IOFormatManager::saveToFile(serializationDynlib, outputFileName, "scene", rootBody);
#endif
yade::ObjectIO::save(outputFileName,"scene",rootBody);
}
catch(SerializableError& e)
catch(const std::runtime_error& e)
{
message+=std::string("File "+outputFileName+" cannot be saved: "+e.what());
return false;
......
......@@ -20,13 +20,16 @@ class FileGenerator
{
protected :
shared_ptr<Scene> rootBody;
string serializationDynlib;
#ifndef YADE_NO_YADE_SERIALIZATION
string serializationDynlib;
public:
void setSerializationLibrary(const string& lib);
std::string getSerializationLibrary() {return serializationDynlib;};
#endif
public :
bool generateAndSave();
void setFileName(const string& fileName);
void setSerializationLibrary(const string& lib);
std::string getFileName() {return outputFileName;}; // stupid? better make that variable public.. ech.
std::string getSerializationLibrary() {return serializationDynlib;};
//! Describes the result in a user-readable form.
std::string message;
......@@ -41,7 +44,10 @@ class FileGenerator
YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(FileGenerator,Serializable,"Base class for scene generators, preprocessors.",
((string,outputFileName,"./scene.xml","Filename to write resulting simulation to")),
/* ctor */ serializationDynlib="XMLFormatManager";,
#ifndef YADE_NO_YADE_SERIALIZATION
/* ctor */ serializationDynlib="XMLFormatManager";
#endif
,
.def("generate",&FileGenerator::pyGenerate,(python::arg("out")),"Generate scene, save to given file")
.def("load",&FileGenerator::pyLoad,"Generate scene, save to temporary file and load immediately");
);
......
......@@ -6,7 +6,7 @@
/*! Storage for general 3d view settings.
Is saved along with simulation and passed to every call to render(...).
Contains more or less what used to be inside OpenGLRenderingEngine.
Contains more or less what used to be inside OpenGLRenderer.
*/
class GLConfig: public Serializable{
......
......@@ -7,10 +7,8 @@
#include<omp.h>
#endif
#ifdef YADE_BOOST_SERIALIZATION
BOOST_CLASS_EXPORT(InteractionContainer);
//BOOST_SERIALIZATION_FACTORY_0(InteractionContainer);
#endif
BOOST_CLASS_EXPORT(InteractionContainer);
//BOOST_SERIALIZATION_FACTORY_0(InteractionContainer);
bool InteractionContainer::insert(const shared_ptr<Interaction>& i){
boost::mutex::scoped_lock lock(drawloopmutex);
......
......@@ -13,8 +13,10 @@
#include"TimeStepper.hpp"
#include"ThreadRunner.hpp"
#include<yade/lib-base/Math.hpp>
#include<yade/lib-serialization/IOFormatManager.hpp>
#include<yade/lib-serialization/FormatChecker.hpp>
#ifndef YADE_NO_YADE_SERIALIZATION
#include<yade/lib-serialization/IOFormatManager.hpp>
#include<yade/lib-serialization/FormatChecker.hpp>
#endif
#include<yade/lib-multimethods/FunctorWrapper.hpp>
#include<yade/lib-multimethods/Indexable.hpp>
#include<cstdlib>
......@@ -149,7 +151,7 @@ void Omega::buildDynlibDatabase(const vector<string>& dynlibsList){
}
if(dynlibs[name].isSerializable) pythonables.push_back(name);
}
catch (FactoryError& e){
catch (std::runtime_error& e){
/* FIXME: this catches all errors! Some of them are not harmful, however:
* when a class is not factorable, it is OK to skip it; */
}
......
......@@ -56,7 +56,7 @@ env.Install('$PREFIX/lib/yade$SUFFIX/lib',[
'yade-support',
'rt', # realtime lib, for clock_gettime
]+
(['qglviewer-qt3'] if not 'noqt3' in env['features'] else [])+
([env['QGLVIEWER_LIB']] if 'qt3' in env['features'] else [])+
(['yade-opengl'] if 'opengl' in env['features'] else [])
,
)
......
......@@ -83,7 +83,8 @@ def userSession(qt3=False,qt4=False):
# something to run?
if len(sys.argv)>0:
arg0=sys.argv[0]
if qt3 or qt4: yade.qt.Controller()
if qt3: yade.qt.Controller();
if qt4: _c=yade.qt.Controller(); _c.show()
if sum(bool(arg0.endswith(ext)) for ext in ('.xml','.xml.bz2','.xml.gz','.yade','.yade.gz','.yade.bz2','.bin','.bin.gz','.bin.bz2'))>0:
if len(sys.argv)>1: raise RuntimeError('Extra arguments to saved simulation to run: '+' '.join(sys.argv[1:]))
sys.stderr.write("Running simulation "+arg0+'\n')
......@@ -119,7 +120,7 @@ def userSession(qt3=False,qt4=False):
# the escape codes might not work on non-linux terminals.
]
+(['"\e[24~": "\C-Uyade.qt.Controller();\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-Uyade.qt.Controller(), yade.qt.View();\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if qt3 else []) #F12,F11,F10,F9
+(['"\e[24~": "\C-U_c=yade.qt.Controller();_c.show()\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-U_c=yade.qt.Controller(), yade.qt.View(); _c.show()\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if qt4 else []) #F12,F11,F10,F9
+(['"\e[24~": "\C-U_c=yade.qt.Controller();_c.show()\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-U_c=yade.qt.Controller(); _c.show(); yade.qt.View();\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if qt4 else []) #F12,F11,F10,F9
+['"\e[19~": "\C-Uimport yade.plot; yade.plot.plot();\C-M"', #F8
'"\e[A": history-search-backward', '"\e[B": history-search-forward', # incremental history forward/backward
]
......@@ -148,13 +149,14 @@ if gui:
if gui==None:
userSession()
elif gui=='qt3':
import yade.qt # raises exception if unable to open the display, but that should have been handled above already
# raises exception if unable to open the display, but that should have been handled above already
import yade.qt
userSession(qt3=True)
elif gui=='qt4':
import PyQt4
from PyQt4 import QtGui
from PyQt4.QtCore import *
import yade.qt4; yade.qt=yade.qt4 # module alias, mimicking the older qt(3) interface if possible
import yade.qt # this yade.qt is different from the one that comes with qt3
qapp=QtGui.QApplication(sys.argv)
userSession(qt4=True)
O.exitNoBacktrace()
......
......@@ -2,12 +2,12 @@ Source: yade@_VERSION@
Section: x11
Priority: optional
Maintainer: Václav Šmilauer <eudoxos@arcig.cz>
Build-Depends: debhelper (>= 5), scons, libqt3-mt-dev, qt3-dev-tools, freeglut3-dev, libboost-dev (>=1.35), libboost-date-time-dev (>=1.35), libboost-filesystem-dev (>=1.35), libboost-thread-dev (>=1.35), libboost-regex-dev (>=1.35), libboost-python-dev (>=1.35), libboost-iostreams-dev (>=1.35), libboost-program-options-dev, libboost-serialization-dev, liblog4cxx9-dev | liblog4cxx10-dev, docbook-to-man, ipython, libsqlite3-dev, libgts-dev, python-numpy, g++(>>4.0), libvtk5-dev, libgl1-mesa-dev, gdb, ipython, python-matplotlib, python-tk, libeigen2-dev @', libqglviewer-qt3-dev' if DISTRIBUTION!='hardy' else ''@ @', binutils-gold' if DISTRIBUTION not in ('hardy','intrepid','jaunty','lenny') else ''@ @', texlive-latex-recommended, texlive-latex-extra, lmodern, texlive-pictures, texlive-xetex, python-sphinx, python-bibtex, graphviz, dvipng' if DISTRIBUTION not in ('hardy','intrepid','jaunty','lenny') else ''@
Build-Depends: debhelper (>= 5), scons, freeglut3-dev, libboost-dev (>=1.35), libboost-date-time-dev (>=1.35), libboost-filesystem-dev (>=1.35), libboost-thread-dev (>=1.35), libboost-regex-dev (>=1.35), libboost-python-dev (>=1.35), libboost-iostreams-dev (>=1.35), libboost-program-options-dev, libboost-serialization-dev, liblog4cxx9-dev | liblog4cxx10-dev, docbook-to-man, ipython, libgts-dev, python-numpy, g++(>>4.0), libvtk5-dev, libgl1-mesa-dev, gdb, ipython, python-matplotlib, python-tk, libeigen2-dev, libqglviewer-qt4-dev @', binutils-gold' if DISTRIBUTION not in ('hardy','intrepid','jaunty','lenny') else ''@ @', texlive-latex-recommended, texlive-latex-extra, lmodern, texlive-pictures, texlive-xetex, python-sphinx, python-bibtex, graphviz, dvipng' if DISTRIBUTION not in ('hardy','intrepid','jaunty','lenny') else ''@, python-xlib, python-qt4, pyqt4-dev-tools
Standards-Version: 3.7.2
Package: yade@_VERSION@
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, python-numpy, ipython, python-matplotlib, python-tk
Depends: ${shlibs:Depends}, ${misc:Depends}, python-numpy, ipython, python-matplotlib, python-tk, python-qt4, python-xlib
Description: Platform for dynamical modeling.
Yet Another Dynamic Engine. etc.
.
......@@ -15,7 +15,7 @@ Description: Platform for dynamical modeling.
Package: yade@_VERSION@-dbg
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, python-numpy, ipython, gdb, python-matplotlib, python-tk
Depends: ${shlibs:Depends}, ${misc:Depends}, python-numpy, ipython, gdb, python-matplotlib, python-tk, python-qt4, python-xlib
Description: Platform for dynamical modeling.
Yet Another Dynamic Engine. etc.
.
......
......@@ -51,7 +51,7 @@ install: build
### (a) use fakeroot-tcp instead of fakeroot
### (b) use just 1 job
#debug build
NO_SCONS_GET_RECENT= scons profile=deb buildPrefix=debian runtimePREFIX=/usr version=${VERSION} brief=0 chunkSize=2 jobs=1 linkStrategy=monolithic features=vtk,gts,opengl,openmp PREFIX=debian/yade${_VERSION}-dbg/usr variant=-dbg optimize=0 march= debug=1 CPPPATH=/usr/include/vtk-5.0:/usr/include/vtk-5.2:/usr/include/vtk-5.4:/usr/include/eigen2
NO_SCONS_GET_RECENT= scons profile=deb buildPrefix=debian runtimePREFIX=/usr version=${VERSION} brief=0 chunkSize=2 jobs=1 linkStrategy=monolithic features=vtk,gts,opengl,openmp,qt4 PREFIX=debian/yade${_VERSION}-dbg/usr variant=-dbg optimize=0 march= debug=1 CPPPATH=/usr/include/vtk-5.0:/usr/include/vtk-5.2:/usr/include/vtk-5.4:/usr/include/eigen2 QT4DIR=/usr/share/qt4
#optimized build
NO_SCONS_GET_RECENT= scons profile=deb PREFIX=debian/yade${_VERSION}/usr variant='' optimize=1 debug=0
#install platform-independent files (docs, scripts, examples)
......
......@@ -131,7 +131,7 @@ Class reference (yade.wrapper module)
sect('Constitutive laws','',['LawFunctor','LawDispatcher'])+
sect('Callbacks','',['BodyCallback','IntrCallback'])+
sect('Preprocessors','',['FileGenerator'])+
sect('Rendering','',['OpenGLRenderingEngine','GlShapeFunctor','GlStateFunctor','GlBoundFunctor','GlInteractionGeometryFunctor','GlInteractionPhysicsFunctor'])+ # ,'GlShapeDispatcher','GlStateDispatcher','GlBoundDispatcher','GlInteractionGeometryDispatcher','GlInteractionPhysicsDispatcher'])+
sect('Rendering','',['OpenGLRenderer','GlShapeFunctor','GlStateFunctor','GlBoundFunctor','GlInteractionGeometryFunctor','GlInteractionPhysicsFunctor'])+ # ,'GlShapeDispatcher','GlStateDispatcher','GlBoundDispatcher','GlInteractionGeometryDispatcher','GlInteractionPhysicsDispatcher'])+
sect('Simulation data','',['Omega','BodyContainer','InteractionContainer','ForceContainer','MaterialContainer'])
+"""
Other classes
......
......@@ -3,21 +3,23 @@ Import('*')
linkPlugins=env['linkPlugins']
if 'qt4' in env['features']:
env.Install('$PREFIX/lib/yade$SUFFIX/py/yade/qt4',[
env.Install('$PREFIX/lib/yade$SUFFIX/py/yade/qt',[
env.File('qt4/img_rc.py'),
env.File('qt4/ui_controller.py'),
env.File('qt4/ui_SeqSerializable.py'),
env.File('qt4/SerializableEditor.py'),
env.File('qt4/__init__.py'),
env.SharedLibrary('_GLViewer',['qt4/_GLViewer.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+['GLViewer'],RPATH=env['RPATH']+[env.Literal('\\$$ORIGIN/../../../gui')])
env.SharedLibrary('_GLViewer',['qt4/_GLViewer.cpp','qt4/OpenGLManager.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+['GLViewer'],RPATH=env['RPATH']+[env.Literal('\\$$ORIGIN/../../../gui')])
])
env.Command('qt4/img_rc.py','qt4/img.qrc','pyrcc4 -o $buildDir/gui/qt4/img_rc.py gui/qt4/img.qrc')
env.Command('qt4/ui_controller.py','qt4/controller.ui','pyuic4 -o $buildDir/gui/qt4/ui_controller.py gui/qt4/controller.ui')
env.Command('qt4/ui_SeqSerializable.py','qt4/SeqSerializable.ui','pyuic4 -o $buildDir/gui/qt4/ui_SeqSerializable.py gui/qt4/SeqSerializable.ui')
env.Install('$PREFIX/lib/yade$SUFFIX/gui',[
env.SharedLibrary('GLViewer',['qt4/GLViewer.cpp'],LIBS=env['LIBS']+['qglviewer-qt4']+linkPlugins(['OpenGLRenderingEngine']))
env.SharedLibrary('GLViewer',['qt4/GLViewer.cpp'],LIBS=env['LIBS']+[env['QGLVIEWER_LIB']]+linkPlugins(['OpenGLRenderer']))
])
if 'opengl' in env['features'] and not 'noqt3' in env['features']:
if 'opengl' in env['features'] and 'qt3' in env['features']:
env.Install('$PREFIX/lib/yade$SUFFIX/gui',[
env.SharedLibrary('QtGUI',
['qt3/FileDialog.cpp',
......@@ -35,8 +37,9 @@ if 'opengl' in env['features'] and not 'noqt3' in env['features']:
'qt3/QtFileGeneratorController.ui'],
LIBS=[# 'PythonUI',
'yade-serialization-qt',
linkPlugins(['GravityEngines','OpenGLRenderingEngine']),
'qglviewer-qt3'],
linkPlugins(['GravityEngines','OpenGLRenderer']),
env['QGLVIEWER_LIB']
],
CPPPATH=env['CPPPATH']+['qt3']
),
env.SharedLibrary('SnapshotEngine',['qt3/SnapshotEngine.cpp'],LIBS=env['LIBS']+['QtGUI','qglviewer-qt3']+linkPlugins(['PeriodicEngines']),CPPPATH=env['CPPPATH']+['qt3']),
......
......@@ -59,7 +59,7 @@ void GLViewer::paintGL(void){
GLViewer::~GLViewer(){ /* get the GL mutex when closing */ GLLock lock(this); }
GLViewer::GLViewer(int id, shared_ptr<OpenGLRenderingEngine> _renderer, QWidget * parent, QGLWidget * shareWidget) : QGLViewer(parent,"glview",shareWidget)//, qglThread(this,rendererInit)
GLViewer::GLViewer(int id, shared_ptr<OpenGLRenderer> _renderer, QWidget * parent, QGLWidget * shareWidget) : QGLViewer(parent,"glview",shareWidget)//, qglThread(this,rendererInit)
{
isMoving=false;
renderer=_renderer; renderer->init();
......@@ -173,14 +173,10 @@ void GLViewer::useDisplayParameters(size_t n){
if(dispParams.size()<=(size_t)n){LOG_ERROR("Display parameters #"<<n<<" don't exist (number of entries "<<dispParams.size()<<")"); return;}
const shared_ptr<DisplayParameters>& dp=dispParams[n];
string val;
if(dp->getValue("OpenGLRenderingEngine",val)){ istringstream oglre(val);
#ifdef YADE_SERIALIZE_USING_BOOST
yade::ObjectIO::load<typeof(renderer),boost::archive::xml_iarchive>(oglre,"renderer",renderer);
#else
IOFormatManager::loadFromStream("XMLFormatManager",oglre,"renderer",renderer);
#endif
if(dp->getValue("OpenGLRenderer",val)){ istringstream oglre(val);
yade::ObjectIO::load<typeof(renderer),boost::archive::xml_iarchive>(oglre,"renderer",renderer);
}
else { LOG_WARN("OpenGLRenderingEngine configuration not found in display parameters, skipped.");}
else { LOG_WARN("OpenGLRenderer configuration not found in display parameters, skipped.");}
if(dp->getValue("GLViewer",val)){ GLViewer::setState(val);}
else { LOG_WARN("GLViewer configuration not found in display parameters, skipped."); }
}
......@@ -191,12 +187,8 @@ void GLViewer::saveDisplayParameters(size_t n){
if(dispParams.size()<=n){while(dispParams.size()<=n) dispParams.push_back(shared_ptr<DisplayParameters>(new DisplayParameters));} assert(n<dispParams.size());
shared_ptr<DisplayParameters>& dp=dispParams[n];
ostringstream oglre;
#ifdef YADE_SERIALIZE_USING_BOOST
yade::ObjectIO::save<typeof(renderer),boost::archive::xml_oarchive>(oglre,"renderer",renderer);
#else
IOFormatManager::saveToStream("XMLFormatManager",oglre,"renderer",renderer);
#endif
dp->setValue("OpenGLRenderingEngine",oglre.str());
yade::ObjectIO::save<typeof(renderer),boost::archive::xml_oarchive>(oglre,"renderer",renderer);
dp->setValue("OpenGLRenderer",oglre.str());
dp->setValue("GLViewer",GLViewer::getState());
}
......@@ -394,7 +386,7 @@ void GLViewer::centerScene(){
if(rb->isPeriodic){ centerPeriodic(); return; }
if(rb->bodies->size()<renderer->selectBodyLimit){LOG_INFO("Less than "+lexical_cast<string>(renderer->selectBodyLimit)+" bodies, moving possible. Select with shift, press 'm' to move.");}
else{LOG_INFO("More than "+lexical_cast<string>(renderer->selectBodyLimit)+" (OpenGLRenderingEngine::selectBodyLimit) bodies. Moving not possible.");}
else{LOG_INFO("More than "+lexical_cast<string>(renderer->selectBodyLimit)+" (OpenGLRenderer::selectBodyLimit) bodies. Moving not possible.");}
Vector3r min,max;
if(rb->bound){
min=rb->bound->min; max=rb->bound->max;
......@@ -601,7 +593,7 @@ void GLViewer::postDraw(){
stopScreenCoordinatesSystem();