diff --git a/.cproject b/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..07c99a6e2211cd5fa76ade7b1f9504b97b903690 --- /dev/null +++ b/.cproject @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="org.eclipse.cdt.core.default.config.1531484750"> + <storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="org.eclipse.cdt.core.default.config.1531484750" moduleId="org.eclipse.cdt.core.settings" name="Configuration"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/> + </extensions> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> + <buildTargets> + <target name="Qt Release Build" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> + <buildCommand>make</buildCommand> + <buildArguments/> + <buildTarget>release</buildTarget> + <stopOnError>false</stopOnError> + <useDefaultCommand>false</useDefaultCommand> + <runAllBuilders>false</runAllBuilders> + </target> + <target name="Qt Debug Build" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> + <buildCommand>make</buildCommand> + <buildArguments/> + <buildTarget>debug</buildTarget> + <stopOnError>false</stopOnError> + <useDefaultCommand>false</useDefaultCommand> + <runAllBuilders>false</runAllBuilders> + </target> + </buildTargets> + </storageModule> + <storageModule moduleId="refreshScope"/> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> + <storageModule moduleId="org.eclipse.cdt.core.pathentry"> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="ActiveQt" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="phonon" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="Qt" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="Qt3Support" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtCore" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtDeclarative" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtDesigner" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtGui" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtHelp" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtMultimedia" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtNetwork" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtOpenGL" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtScript" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtScriptTools" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtSql" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtSvg" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtTest" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtUiTools" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtWebKit" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtXml" kind="inc" path="" system="true"/> + <pathentry base-path="C:/QtSDK/Desktop/Qt/4.8.1/mingw/include" include="QtXmlPatterns" kind="inc" path="" system="true"/> + <pathentry include="C:/VTK/include/vtk-5.10" kind="inc" path="" system="true"/> + <pathentry include="C:/QtSDK/mingw/mingw32/include" kind="inc" path="" system="true"/> + <pathentry include="C:/QtSDK/mingw/lib/gcc/mingw32/4.4.0/include/c++" kind="inc" path="" system="true"/> + <pathentry kind="src" path=""/> + <pathentry kind="out" path=""/> + </storageModule> +</cproject> diff --git a/.project b/.project new file mode 100644 index 0000000000000000000000000000000000000000..8e86c4e64fbb3b2c16ddb0115caeaa212591e15a --- /dev/null +++ b/.project @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>TraVisTo</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.trolltech.qtcppproject.QtMakefileGenerator</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.make.core.makeBuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + <dictionary> + <key>org.eclipse.cdt.core.errorOutputParser</key> + <value>org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.VCErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.MakeErrorParser;</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.append_environment</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.build.arguments</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.build.command</key> + <value>make</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.build.target.auto</key> + <value>debug</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.build.target.clean</key> + <value>clean</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.build.target.inc</key> + <value>debug</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableAutoBuild</key> + <value>false</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableCleanBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableFullBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.environment</key> + <value>PATH=C:\\QtSDK\\Desktop\\Qt\\4.8.1\\mingw\\bin;${env_var:PATH}|</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.stopOnError</key> + <value>false</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> + <value>false</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.make.core.makeNature</nature> + <nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature> + <nature>com.trolltech.qtcppproject.QtNature</nature> + </natures> +</projectDescription> diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..0e5b9d86513b500e9056ae49fe53ca0e887da6b4 --- /dev/null +++ b/Makefile @@ -0,0 +1,147 @@ +############################################################################# +# Makefile for building: TraVisTo +# Generated by qmake (2.01a) (Qt 4.8.1) on: Mo 9. Jul 15:51:53 2012 +# Project: TraVisTo.pro +# Template: app +# Command: c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\qmake -o Makefile TraVisTo.pro +############################################################################# + +first: debug +install: debug-install +uninstall: debug-uninstall +MAKEFILE = Makefile +QMAKE = c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\qmake +DEL_FILE = del +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +COPY = copy /y +COPY_FILE = $(COPY) +COPY_DIR = xcopy /s /q /y /i +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) +DEL_FILE = del +SYMLINK = +DEL_DIR = rmdir +MOVE = move +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +SUBTARGETS = \ + debug \ + release + +debug: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_default: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_first: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug first +debug-all: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug all +debug-clean: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug clean +debug-distclean: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug distclean +debug-install: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug install +debug-uninstall: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug uninstall +release: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_default: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_first: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release first +release-all: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release all +release-clean: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release clean +release-distclean: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release distclean +release-install: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release install +release-uninstall: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release uninstall + +Makefile: TraVisTo.pro c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/default/qmake.conf c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/qconfig.pri \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/modules/qt_webkit_version.pri \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/qt_functions.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/qt_config.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/exclusive_builds.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/default_pre.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/default_pre.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/debug.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/debug_and_release.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/default_post.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/default_post.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/qt.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/thread.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/moc.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/rtti.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/exceptions.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/stl.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/shared.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/warn_on.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/win32/windows.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/resources.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/uic.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/yacc.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/lex.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/mkspecs/features/include_source_dir.prf \ + c:/QtSDK/Desktop/Qt/4.8.1/mingw/lib/qtmaind.prl + $(QMAKE) -o Makefile TraVisTo.pro +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\qconfig.pri: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\modules\qt_webkit_version.pri: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_functions.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_config.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\exclusive_builds.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_pre.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_pre.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug_and_release.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_post.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_post.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\thread.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\moc.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\rtti.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\exceptions.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\stl.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\shared.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\warn_on.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\windows.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\resources.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\uic.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\yacc.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\lex.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\include_source_dir.prf: +c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib\qtmaind.prl: +qmake: qmake_all FORCE + @$(QMAKE) -o Makefile TraVisTo.pro + +qmake_all: FORCE + +make_default: debug-make_default release-make_default FORCE +make_first: debug-make_first release-make_first FORCE +all: debug-all release-all FORCE +clean: debug-clean release-clean FORCE +distclean: debug-distclean release-distclean FORCE + -$(DEL_FILE) Makefile + +check: first + +debug-mocclean: $(MAKEFILE).Debug + $(MAKE) -f $(MAKEFILE).Debug mocclean +release-mocclean: $(MAKEFILE).Release + $(MAKE) -f $(MAKEFILE).Release mocclean +mocclean: debug-mocclean release-mocclean + +debug-mocables: $(MAKEFILE).Debug + $(MAKE) -f $(MAKEFILE).Debug mocables +release-mocables: $(MAKEFILE).Release + $(MAKE) -f $(MAKEFILE).Release mocables +mocables: debug-mocables release-mocables +FORCE: + +$(MAKEFILE).Debug: Makefile +$(MAKEFILE).Release: Makefile diff --git a/Makefile.Debug b/Makefile.Debug new file mode 100644 index 0000000000000000000000000000000000000000..7c129e5fa26a14c09fd757214dddc61e3d1902c6 --- /dev/null +++ b/Makefile.Debug @@ -0,0 +1,553 @@ +############################################################################# +# Makefile for building: TraVisTo +# Generated by qmake (2.01a) (Qt 4.8.1) on: Mo 9. Jul 15:51:53 2012 +# Project: TraVisTo.pro +# Template: app +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN +CFLAGS = -g -Wall $(DEFINES) +CXXFLAGS = -g -frtti -fexceptions -mthreads -Wall $(DEFINES) +INCPATH = -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtNetwork" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtXml" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include" -I"c:\VTK\include\vtk-5.10" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\ActiveQt" -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\default" +LINK = g++ +LFLAGS = -mthreads -Wl,-subsystem,windows +LIBS = -L"c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" -lmingw32 -lqtmaind debug\travisto_res.o -LC:/VTK/bin -lvtksys -lvtkzlib -lvtkjpeg -lvtkpng -lvtktiff -lvtkexpat -lvtkfreetype -lvtklibxml2 -lvtkDICOMParser -lvtkverdict -lvtkNetCDF -lvtkmetaio -lvtkexoIIc -lvtkalglib -lvtkftgl -lvtkCommon -lvtkFiltering -lvtkImaging -lvtkGraphics -lvtkIO -lvtkRendering -lvtkParallel -lvtkHybrid -lvtkWidgets -lvtkInfovis -lvtkViews -lwsock32 -lQtXmld4 -lQtGuid4 -lQtNetworkd4 -lQtCored4 +QMAKE = c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\qmake +IDC = c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\idc.exe +IDL = midl +ZIP = zip -r -9 +DEF_FILE = +RES_FILE = debug\travisto_res.o +COPY = copy /y +SED = +COPY_FILE = $(COPY) +COPY_DIR = xcopy /s /q /y /i +DEL_FILE = del +DEL_DIR = rmdir +MOVE = move +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) + +####### Output directory + +OBJECTS_DIR = debug + +####### Files + +SOURCES = forms\Settings.cpp \ + src\SaxParser.cpp \ + src\Debug.cpp \ + src\main.cpp \ + src\travisto.cpp \ + src\Frame.cpp \ + src\InteractorStyle.cpp \ + src\Pedestrian.cpp \ + src\SimpleVisualisationWindow.cpp \ + src\SyncData.cpp \ + src\SystemSettings.cpp \ + src\ThreadDataTransfert.cpp \ + src\ThreadVisualisation.cpp \ + src\TimerCallback.cpp \ + src\TrajectoryPoint.cpp \ + src\geometry\LinePlotter2D.cpp \ + src\geometry\PointPlotter2D.cpp \ + src\geometry\FacilityGeometry.cpp \ + src\geometry\LinePlotter.cpp \ + src\geometry\Point.cpp \ + src\geometry\PointPlotter.cpp \ + src\geometry\jul\Building.cpp \ + src\geometry\jul\Room.cpp \ + src\geometry\jul\Line.cpp \ + src\geometry\jul\Transition.cpp \ + src\geometry\jul\Wall.cpp \ + src\geometry\jul\CPoint.cpp \ + src\geometry\pg3\CLine.cpp \ + src\geometry\pg3\CBuilding.cpp \ + src\geometry\pg3\CRoom.cpp \ + src\geometry\pg3\CCell.cpp \ + src\geometry\pg3\CCoordsList.cpp \ + src\geometry\pg3\Common.cpp \ + src\geometry\pg3\CTextLog.cpp \ + src\geometry\pg3\CTransition.cpp \ + src\network\TraVisToServer.cpp debug\moc_Settings.cpp \ + debug\moc_travisto.cpp \ + debug\moc_SyncData.cpp \ + debug\moc_ThreadDataTransfert.cpp \ + debug\moc_ThreadVisualisation.cpp \ + debug\moc_TimerCallback.cpp \ + debug\moc_TraVisToServer.cpp \ + debug\qrc_icons.cpp +OBJECTS = debug/Settings.o \ + debug/SaxParser.o \ + debug/Debug.o \ + debug/main.o \ + debug/travisto.o \ + debug/Frame.o \ + debug/InteractorStyle.o \ + debug/Pedestrian.o \ + debug/SimpleVisualisationWindow.o \ + debug/SyncData.o \ + debug/SystemSettings.o \ + debug/ThreadDataTransfert.o \ + debug/ThreadVisualisation.o \ + debug/TimerCallback.o \ + debug/TrajectoryPoint.o \ + debug/LinePlotter2D.o \ + debug/PointPlotter2D.o \ + debug/FacilityGeometry.o \ + debug/LinePlotter.o \ + debug/Point.o \ + debug/PointPlotter.o \ + debug/Building.o \ + debug/Room.o \ + debug/Line.o \ + debug/Transition.o \ + debug/Wall.o \ + debug/CPoint.o \ + debug/CLine.o \ + debug/CBuilding.o \ + debug/CRoom.o \ + debug/CCell.o \ + debug/CCoordsList.o \ + debug/Common.o \ + debug/CTextLog.o \ + debug/CTransition.o \ + debug/TraVisToServer.o \ + debug/moc_Settings.o \ + debug/moc_travisto.o \ + debug/moc_SyncData.o \ + debug/moc_ThreadDataTransfert.o \ + debug/moc_ThreadVisualisation.o \ + debug/moc_TimerCallback.o \ + debug/moc_TraVisToServer.o \ + debug/qrc_icons.o +DIST = +QMAKE_TARGET = TraVisTo +DESTDIR = debug\ #avoid trailing-slash linebreak +TARGET = TraVisTo.exe +DESTDIR_TARGET = debug\TraVisTo.exe + +####### Implicit rules + +.SUFFIXES: .cpp .cc .cxx .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +first: all +all: Makefile.Debug $(DESTDIR_TARGET) + +$(DESTDIR_TARGET): ui_settings.h ui_travisto.h $(OBJECTS) debug/travisto_res.o + $(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) object_script.TraVisTo.Debug $(LIBS) + +debug/travisto_res.o: forms\travisto.rc + windres -i forms\travisto.rc -o debug\travisto_res.o --include-dir=./forms $(DEFINES) + +qmake: FORCE + @$(QMAKE) -o Makefile.Debug TraVisTo.pro + +dist: + $(ZIP) TraVisTo.zip $(SOURCES) $(DIST) TraVisTo.pro c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\qconfig.pri c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\modules\qt_webkit_version.pri c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_functions.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_config.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\exclusive_builds.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_pre.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_pre.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug_and_release.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_post.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_post.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\build_pass.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\thread.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\moc.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\rtti.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\exceptions.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\stl.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\shared.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\warn_on.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\windows.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\resources.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\uic.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\yacc.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\lex.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\include_source_dir.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib\qtmaind.prl HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES + +clean: compiler_clean + -$(DEL_FILE) debug\Settings.o debug\SaxParser.o debug\Debug.o debug\main.o debug\travisto.o debug\Frame.o debug\InteractorStyle.o debug\Pedestrian.o debug\SimpleVisualisationWindow.o debug\SyncData.o debug\SystemSettings.o debug\ThreadDataTransfert.o debug\ThreadVisualisation.o debug\TimerCallback.o debug\TrajectoryPoint.o debug\LinePlotter2D.o debug\PointPlotter2D.o debug\FacilityGeometry.o debug\LinePlotter.o debug\Point.o debug\PointPlotter.o debug\Building.o debug\Room.o debug\Line.o debug\Transition.o debug\Wall.o debug\CPoint.o debug\CLine.o debug\CBuilding.o debug\CRoom.o debug\CCell.o debug\CCoordsList.o debug\Common.o debug\CTextLog.o debug\CTransition.o debug\TraVisToServer.o debug\moc_Settings.o debug\moc_travisto.o debug\moc_SyncData.o debug\moc_ThreadDataTransfert.o debug\moc_ThreadVisualisation.o debug\moc_TimerCallback.o debug\moc_TraVisToServer.o debug\qrc_icons.o + -$(DEL_FILE) debug\travisto_res.o + +distclean: clean + -$(DEL_FILE) $(DESTDIR_TARGET) + -$(DEL_FILE) Makefile.Debug + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: debug/moc_Settings.cpp debug/moc_travisto.cpp debug/moc_SyncData.cpp debug/moc_ThreadDataTransfert.cpp debug/moc_ThreadVisualisation.cpp debug/moc_TimerCallback.cpp debug/moc_TraVisToServer.cpp +compiler_moc_header_clean: + -$(DEL_FILE) debug\moc_Settings.cpp debug\moc_travisto.cpp debug\moc_SyncData.cpp debug\moc_ThreadDataTransfert.cpp debug\moc_ThreadVisualisation.cpp debug\moc_TimerCallback.cpp debug\moc_TraVisToServer.cpp +debug/moc_Settings.cpp: ui_settings.h \ + src/SystemSettings.h \ + forms/Settings.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 forms\Settings.h -o debug\moc_Settings.cpp + +debug/moc_travisto.cpp: ui_travisto.h \ + src/travisto.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\travisto.h -o debug\moc_travisto.cpp + +debug/moc_SyncData.cpp: src/SyncData.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\SyncData.h -o debug\moc_SyncData.cpp + +debug/moc_ThreadDataTransfert.cpp: src/ThreadDataTransfert.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\ThreadDataTransfert.h -o debug\moc_ThreadDataTransfert.cpp + +debug/moc_ThreadVisualisation.cpp: src/ThreadVisualisation.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\ThreadVisualisation.h -o debug\moc_ThreadVisualisation.cpp + +debug/moc_TimerCallback.cpp: src/SyncData.h \ + src/TimerCallback.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\TimerCallback.h -o debug\moc_TimerCallback.cpp + +debug/moc_TraVisToServer.cpp: src/network/TraVisToServer.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\network\TraVisToServer.h -o debug\moc_TraVisToServer.cpp + +compiler_rcc_make_all: debug/qrc_icons.cpp debug/qrc_icons.cpp debug/qrc_icons.cpp +compiler_rcc_clean: + -$(DEL_FILE) debug\qrc_icons.cpp debug\qrc_icons.cpp debug\qrc_icons.cpp +debug/qrc_icons.cpp: forms/icons.qrc \ + forms/icons/Play1Hot.png \ + forms/icons/fullscreen.PNG \ + forms/icons/window_fullscreen-64.png \ + forms/icons/PauseHot.png \ + forms/icons/fullscreen.jpeg \ + forms/icons/Stop1PressedBlue.png \ + forms/icons/RecordPressed.png + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\rcc.exe -name icons forms\icons.qrc -o debug\qrc_icons.cpp + +debug/qrc_icons.cpp: forms/icons.qrc \ + forms/icons/Play1Hot.png \ + forms/icons/fullscreen.PNG \ + forms/icons/window_fullscreen-64.png \ + forms/icons/PauseHot.png \ + forms/icons/fullscreen.jpeg \ + forms/icons/Stop1PressedBlue.png \ + forms/icons/RecordPressed.png + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\rcc.exe -name icons forms\icons.qrc -o debug\qrc_icons.cpp + +debug/qrc_icons.cpp: forms/icons.qrc \ + forms/icons/Play1Hot.png \ + forms/icons/fullscreen.PNG \ + forms/icons/window_fullscreen-64.png \ + forms/icons/PauseHot.png \ + forms/icons/fullscreen.jpeg \ + forms/icons/Stop1PressedBlue.png \ + forms/icons/RecordPressed.png + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\rcc.exe -name icons forms\icons.qrc -o debug\qrc_icons.cpp + +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_settings.h ui_travisto.h +compiler_uic_clean: + -$(DEL_FILE) ui_settings.h ui_travisto.h +ui_settings.h: forms/settings.ui + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\uic.exe forms\settings.ui -o ui_settings.h + +ui_travisto.h: forms/travisto.ui + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\uic.exe forms\travisto.ui -o ui_travisto.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_uic_clean + + + +####### Compile + +debug/Settings.o: forms/Settings.cpp forms/Settings.h \ + ui_settings.h \ + src/SystemSettings.h \ + src/geometry/LinePlotter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Settings.o forms\Settings.cpp + +debug/SaxParser.o: src/SaxParser.cpp src/SaxParser.h \ + src/SyncData.h \ + src/TrajectoryPoint.h \ + src/Frame.h \ + src/Debug.h \ + src/geometry/Point.h \ + src/geometry/FacilityGeometry.h \ + src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h \ + src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/CTransition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\SaxParser.o src\SaxParser.cpp + +debug/Debug.o: src/Debug.cpp src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Debug.o src\Debug.cpp + +debug/main.o: src/main.cpp src/travisto.h \ + ui_travisto.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\main.o src\main.cpp + +debug/travisto.o: src/travisto.cpp src/travisto.h \ + ui_travisto.h \ + src/SaxParser.h \ + src/SyncData.h \ + src/SystemSettings.h \ + forms/Settings.h \ + ui_settings.h \ + src/extern_var.h \ + src/Pedestrian.h \ + src/TrajectoryPoint.h \ + src/Frame.h \ + src/Debug.h \ + src/ThreadVisualisation.h \ + src/ThreadDataTransfert.h \ + src/SimpleVisualisationWindow.h \ + src/geometry/FacilityGeometry.h \ + src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h \ + src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/CTransition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\travisto.o src\travisto.cpp + +debug/Frame.o: src/Frame.cpp src/TrajectoryPoint.h \ + src/Frame.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Frame.o src\Frame.cpp + +debug/InteractorStyle.o: src/InteractorStyle.cpp src/SystemSettings.h \ + src/InteractorStyle.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\InteractorStyle.o src\InteractorStyle.cpp + +debug/Pedestrian.o: src/Pedestrian.cpp src/Pedestrian.h \ + src/geometry/Point.h \ + src/geometry/PointPlotter.h \ + src/geometry/LinePlotter.h \ + forms/Settings.h \ + ui_settings.h \ + src/SystemSettings.h \ + src/TrajectoryPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Pedestrian.o src\Pedestrian.cpp + +debug/SimpleVisualisationWindow.o: src/SimpleVisualisationWindow.cpp src/SimpleVisualisationWindow.h \ + src/geometry/LinePlotter.h \ + src/geometry/PointPlotter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\SimpleVisualisationWindow.o src\SimpleVisualisationWindow.cpp + +debug/SyncData.o: src/SyncData.cpp src/SyncData.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/Message.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\SyncData.o src\SyncData.cpp + +debug/SystemSettings.o: src/SystemSettings.cpp src/SystemSettings.h \ + src/Debug.h \ + forms/Settings.h \ + ui_settings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\SystemSettings.o src\SystemSettings.cpp + +debug/ThreadDataTransfert.o: src/ThreadDataTransfert.cpp src/SystemSettings.h \ + src/ThreadDataTransfert.h \ + src/SyncData.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/network/TraVisToServer.h \ + src/geometry/FacilityGeometry.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ThreadDataTransfert.o src\ThreadDataTransfert.cpp + +debug/ThreadVisualisation.o: src/ThreadVisualisation.cpp src/geometry/FacilityGeometry.h \ + src/geometry/LinePlotter2D.h \ + src/ThreadVisualisation.h \ + src/Pedestrian.h \ + src/TimerCallback.h \ + src/SyncData.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/InteractorStyle.h \ + src/SystemSettings.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ThreadVisualisation.o src\ThreadVisualisation.cpp + +debug/TimerCallback.o: src/TimerCallback.cpp src/geometry/FacilityGeometry.h \ + src/geometry/Point.h \ + src/Pedestrian.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/SyncData.h \ + src/SystemSettings.h \ + src/TimerCallback.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TimerCallback.o src\TimerCallback.cpp + +debug/TrajectoryPoint.o: src/TrajectoryPoint.cpp src/TrajectoryPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TrajectoryPoint.o src\TrajectoryPoint.cpp + +debug/LinePlotter2D.o: src/geometry/LinePlotter2D.cpp src/geometry/LinePlotter2D.h \ + src/SystemSettings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\LinePlotter2D.o src\geometry\LinePlotter2D.cpp + +debug/PointPlotter2D.o: src/geometry/PointPlotter2D.cpp src/geometry/PointPlotter2D.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\PointPlotter2D.o src\geometry\PointPlotter2D.cpp + +debug/FacilityGeometry.o: src/geometry/FacilityGeometry.cpp src/geometry/FacilityGeometry.h \ + src/geometry/Point.h \ + src/SystemSettings.h \ + src/geometry/LinePlotter2D.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\FacilityGeometry.o src\geometry\FacilityGeometry.cpp + +debug/LinePlotter.o: src/geometry/LinePlotter.cpp src/geometry/Point.h \ + src/SystemSettings.h \ + src/geometry/LinePlotter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\LinePlotter.o src\geometry\LinePlotter.cpp + +debug/Point.o: src/geometry/Point.cpp src/geometry/Point.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Point.o src\geometry\Point.cpp + +debug/PointPlotter.o: src/geometry/PointPlotter.cpp src/geometry/Point.h \ + src/geometry/PointPlotter.h \ + src/SystemSettings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\PointPlotter.o src\geometry\PointPlotter.cpp + +debug/Building.o: src/geometry/jul/Building.cpp src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Building.o src\geometry\jul\Building.cpp + +debug/Room.o: src/geometry/jul/Room.cpp src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Room.o src\geometry\jul\Room.cpp + +debug/Line.o: src/geometry/jul/Line.cpp src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Line.o src\geometry\jul\Line.cpp + +debug/Transition.o: src/geometry/jul/Transition.cpp src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Transition.o src\geometry\jul\Transition.cpp + +debug/Wall.o: src/geometry/jul/Wall.cpp src/geometry/jul/Wall.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Wall.o src\geometry\jul\Wall.cpp + +debug/CPoint.o: src/geometry/jul/CPoint.cpp src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CPoint.o src\geometry\jul\CPoint.cpp + +debug/CLine.o: src/geometry/pg3/CLine.cpp src/geometry/pg3/CLine.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CLine.o src\geometry\pg3\CLine.cpp + +debug/CBuilding.o: src/geometry/pg3/CBuilding.cpp src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/jul/CPoint.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/CTransition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CBuilding.o src\geometry\pg3\CBuilding.cpp + +debug/CRoom.o: src/geometry/pg3/CRoom.cpp src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/jul/CPoint.h \ + src/geometry/pg3/CCoordsList.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CRoom.o src\geometry\pg3\CRoom.cpp + +debug/CCell.o: src/geometry/pg3/CCell.cpp src/geometry/pg3/CCell.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CCell.o src\geometry\pg3\CCell.cpp + +debug/CCoordsList.o: src/geometry/pg3/CCoordsList.cpp src/geometry/pg3/CCoordsList.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CCoordsList.o src\geometry\pg3\CCoordsList.cpp + +debug/Common.o: src/geometry/pg3/Common.cpp src/geometry/pg3/Common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Common.o src\geometry\pg3\Common.cpp + +debug/CTextLog.o: src/geometry/pg3/CTextLog.cpp src/geometry/pg3/CTextLog.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CTextLog.o src\geometry\pg3\CTextLog.cpp + +debug/CTransition.o: src/geometry/pg3/CTransition.cpp src/geometry/pg3/CTransition.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/Common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\CTransition.o src\geometry\pg3\CTransition.cpp + +debug/TraVisToServer.o: src/network/TraVisToServer.cpp src/network/TraVisToServer.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TraVisToServer.o src\network\TraVisToServer.cpp + +debug/moc_Settings.o: debug/moc_Settings.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_Settings.o debug\moc_Settings.cpp + +debug/moc_travisto.o: debug/moc_travisto.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_travisto.o debug\moc_travisto.cpp + +debug/moc_SyncData.o: debug/moc_SyncData.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_SyncData.o debug\moc_SyncData.cpp + +debug/moc_ThreadDataTransfert.o: debug/moc_ThreadDataTransfert.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ThreadDataTransfert.o debug\moc_ThreadDataTransfert.cpp + +debug/moc_ThreadVisualisation.o: debug/moc_ThreadVisualisation.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ThreadVisualisation.o debug\moc_ThreadVisualisation.cpp + +debug/moc_TimerCallback.o: debug/moc_TimerCallback.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_TimerCallback.o debug\moc_TimerCallback.cpp + +debug/moc_TraVisToServer.o: debug/moc_TraVisToServer.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_TraVisToServer.o debug\moc_TraVisToServer.cpp + +debug/qrc_icons.o: debug/qrc_icons.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\qrc_icons.o debug\qrc_icons.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/Makefile.Release b/Makefile.Release new file mode 100644 index 0000000000000000000000000000000000000000..ab86825ce1d11ef8fbcb10d1cb9db473e99718f4 --- /dev/null +++ b/Makefile.Release @@ -0,0 +1,553 @@ +############################################################################# +# Makefile for building: TraVisTo +# Generated by qmake (2.01a) (Qt 4.8.1) on: Mo 9. Jul 15:51:53 2012 +# Project: TraVisTo.pro +# Template: app +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN +CFLAGS = -O2 -Wall $(DEFINES) +CXXFLAGS = -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES) +INCPATH = -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtNetwork" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtXml" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include" -I"c:\VTK\include\vtk-5.10" -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\include\ActiveQt" -I"release" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\default" +LINK = g++ +LFLAGS = -Wl,-s -mthreads -Wl,-subsystem,windows +LIBS = -L"c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" -lmingw32 -lqtmain release\travisto_res.o -LC:/VTK/bin -lvtksys -lvtkzlib -lvtkjpeg -lvtkpng -lvtktiff -lvtkexpat -lvtkfreetype -lvtklibxml2 -lvtkDICOMParser -lvtkverdict -lvtkNetCDF -lvtkmetaio -lvtkexoIIc -lvtkalglib -lvtkftgl -lvtkCommon -lvtkFiltering -lvtkImaging -lvtkGraphics -lvtkIO -lvtkRendering -lvtkParallel -lvtkHybrid -lvtkWidgets -lvtkInfovis -lvtkViews -lwsock32 -lQtXml4 -lQtGui4 -lQtNetwork4 -lQtCore4 +QMAKE = c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\qmake +IDC = c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\idc.exe +IDL = midl +ZIP = zip -r -9 +DEF_FILE = +RES_FILE = release\travisto_res.o +COPY = copy /y +SED = +COPY_FILE = $(COPY) +COPY_DIR = xcopy /s /q /y /i +DEL_FILE = del +DEL_DIR = rmdir +MOVE = move +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) + +####### Output directory + +OBJECTS_DIR = release + +####### Files + +SOURCES = forms\Settings.cpp \ + src\SaxParser.cpp \ + src\Debug.cpp \ + src\main.cpp \ + src\travisto.cpp \ + src\Frame.cpp \ + src\InteractorStyle.cpp \ + src\Pedestrian.cpp \ + src\SimpleVisualisationWindow.cpp \ + src\SyncData.cpp \ + src\SystemSettings.cpp \ + src\ThreadDataTransfert.cpp \ + src\ThreadVisualisation.cpp \ + src\TimerCallback.cpp \ + src\TrajectoryPoint.cpp \ + src\geometry\LinePlotter2D.cpp \ + src\geometry\PointPlotter2D.cpp \ + src\geometry\FacilityGeometry.cpp \ + src\geometry\LinePlotter.cpp \ + src\geometry\Point.cpp \ + src\geometry\PointPlotter.cpp \ + src\geometry\jul\Building.cpp \ + src\geometry\jul\Room.cpp \ + src\geometry\jul\Line.cpp \ + src\geometry\jul\Transition.cpp \ + src\geometry\jul\Wall.cpp \ + src\geometry\jul\CPoint.cpp \ + src\geometry\pg3\CLine.cpp \ + src\geometry\pg3\CBuilding.cpp \ + src\geometry\pg3\CRoom.cpp \ + src\geometry\pg3\CCell.cpp \ + src\geometry\pg3\CCoordsList.cpp \ + src\geometry\pg3\Common.cpp \ + src\geometry\pg3\CTextLog.cpp \ + src\geometry\pg3\CTransition.cpp \ + src\network\TraVisToServer.cpp release\moc_Settings.cpp \ + release\moc_travisto.cpp \ + release\moc_SyncData.cpp \ + release\moc_ThreadDataTransfert.cpp \ + release\moc_ThreadVisualisation.cpp \ + release\moc_TimerCallback.cpp \ + release\moc_TraVisToServer.cpp \ + release\qrc_icons.cpp +OBJECTS = release/Settings.o \ + release/SaxParser.o \ + release/Debug.o \ + release/main.o \ + release/travisto.o \ + release/Frame.o \ + release/InteractorStyle.o \ + release/Pedestrian.o \ + release/SimpleVisualisationWindow.o \ + release/SyncData.o \ + release/SystemSettings.o \ + release/ThreadDataTransfert.o \ + release/ThreadVisualisation.o \ + release/TimerCallback.o \ + release/TrajectoryPoint.o \ + release/LinePlotter2D.o \ + release/PointPlotter2D.o \ + release/FacilityGeometry.o \ + release/LinePlotter.o \ + release/Point.o \ + release/PointPlotter.o \ + release/Building.o \ + release/Room.o \ + release/Line.o \ + release/Transition.o \ + release/Wall.o \ + release/CPoint.o \ + release/CLine.o \ + release/CBuilding.o \ + release/CRoom.o \ + release/CCell.o \ + release/CCoordsList.o \ + release/Common.o \ + release/CTextLog.o \ + release/CTransition.o \ + release/TraVisToServer.o \ + release/moc_Settings.o \ + release/moc_travisto.o \ + release/moc_SyncData.o \ + release/moc_ThreadDataTransfert.o \ + release/moc_ThreadVisualisation.o \ + release/moc_TimerCallback.o \ + release/moc_TraVisToServer.o \ + release/qrc_icons.o +DIST = +QMAKE_TARGET = TraVisTo +DESTDIR = release\ #avoid trailing-slash linebreak +TARGET = TraVisTo.exe +DESTDIR_TARGET = release\TraVisTo.exe + +####### Implicit rules + +.SUFFIXES: .cpp .cc .cxx .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +first: all +all: Makefile.Release $(DESTDIR_TARGET) + +$(DESTDIR_TARGET): ui_settings.h ui_travisto.h $(OBJECTS) release/travisto_res.o + $(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) object_script.TraVisTo.Release $(LIBS) + +release/travisto_res.o: forms\travisto.rc + windres -i forms\travisto.rc -o release\travisto_res.o --include-dir=./forms $(DEFINES) + +qmake: FORCE + @$(QMAKE) -o Makefile.Release TraVisTo.pro + +dist: + $(ZIP) TraVisTo.zip $(SOURCES) $(DIST) TraVisTo.pro c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\qconfig.pri c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\modules\qt_webkit_version.pri c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_functions.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_config.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\exclusive_builds.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_pre.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_pre.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\release.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug_and_release.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_post.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_post.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\build_pass.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\thread.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\moc.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\rtti.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\exceptions.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\stl.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\shared.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\warn_on.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\windows.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\resources.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\uic.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\yacc.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\lex.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\include_source_dir.prf c:\QtSDK\Desktop\Qt\4.8.1\mingw\lib\qtmain.prl HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES + +clean: compiler_clean + -$(DEL_FILE) release\Settings.o release\SaxParser.o release\Debug.o release\main.o release\travisto.o release\Frame.o release\InteractorStyle.o release\Pedestrian.o release\SimpleVisualisationWindow.o release\SyncData.o release\SystemSettings.o release\ThreadDataTransfert.o release\ThreadVisualisation.o release\TimerCallback.o release\TrajectoryPoint.o release\LinePlotter2D.o release\PointPlotter2D.o release\FacilityGeometry.o release\LinePlotter.o release\Point.o release\PointPlotter.o release\Building.o release\Room.o release\Line.o release\Transition.o release\Wall.o release\CPoint.o release\CLine.o release\CBuilding.o release\CRoom.o release\CCell.o release\CCoordsList.o release\Common.o release\CTextLog.o release\CTransition.o release\TraVisToServer.o release\moc_Settings.o release\moc_travisto.o release\moc_SyncData.o release\moc_ThreadDataTransfert.o release\moc_ThreadVisualisation.o release\moc_TimerCallback.o release\moc_TraVisToServer.o release\qrc_icons.o + -$(DEL_FILE) release\travisto_res.o + +distclean: clean + -$(DEL_FILE) $(DESTDIR_TARGET) + -$(DEL_FILE) Makefile.Release + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: release/moc_Settings.cpp release/moc_travisto.cpp release/moc_SyncData.cpp release/moc_ThreadDataTransfert.cpp release/moc_ThreadVisualisation.cpp release/moc_TimerCallback.cpp release/moc_TraVisToServer.cpp +compiler_moc_header_clean: + -$(DEL_FILE) release\moc_Settings.cpp release\moc_travisto.cpp release\moc_SyncData.cpp release\moc_ThreadDataTransfert.cpp release\moc_ThreadVisualisation.cpp release\moc_TimerCallback.cpp release\moc_TraVisToServer.cpp +release/moc_Settings.cpp: ui_settings.h \ + src/SystemSettings.h \ + forms/Settings.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 forms\Settings.h -o release\moc_Settings.cpp + +release/moc_travisto.cpp: ui_travisto.h \ + src/travisto.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\travisto.h -o release\moc_travisto.cpp + +release/moc_SyncData.cpp: src/SyncData.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\SyncData.h -o release\moc_SyncData.cpp + +release/moc_ThreadDataTransfert.cpp: src/ThreadDataTransfert.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\ThreadDataTransfert.h -o release\moc_ThreadDataTransfert.cpp + +release/moc_ThreadVisualisation.cpp: src/ThreadVisualisation.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\ThreadVisualisation.h -o release\moc_ThreadVisualisation.cpp + +release/moc_TimerCallback.cpp: src/SyncData.h \ + src/TimerCallback.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\TimerCallback.h -o release\moc_TimerCallback.cpp + +release/moc_TraVisToServer.cpp: src/network/TraVisToServer.h + C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 src\network\TraVisToServer.h -o release\moc_TraVisToServer.cpp + +compiler_rcc_make_all: release/qrc_icons.cpp release/qrc_icons.cpp release/qrc_icons.cpp +compiler_rcc_clean: + -$(DEL_FILE) release\qrc_icons.cpp release\qrc_icons.cpp release\qrc_icons.cpp +release/qrc_icons.cpp: forms/icons.qrc \ + forms/icons/Play1Hot.png \ + forms/icons/fullscreen.PNG \ + forms/icons/window_fullscreen-64.png \ + forms/icons/PauseHot.png \ + forms/icons/fullscreen.jpeg \ + forms/icons/Stop1PressedBlue.png \ + forms/icons/RecordPressed.png + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\rcc.exe -name icons forms\icons.qrc -o release\qrc_icons.cpp + +release/qrc_icons.cpp: forms/icons.qrc \ + forms/icons/Play1Hot.png \ + forms/icons/fullscreen.PNG \ + forms/icons/window_fullscreen-64.png \ + forms/icons/PauseHot.png \ + forms/icons/fullscreen.jpeg \ + forms/icons/Stop1PressedBlue.png \ + forms/icons/RecordPressed.png + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\rcc.exe -name icons forms\icons.qrc -o release\qrc_icons.cpp + +release/qrc_icons.cpp: forms/icons.qrc \ + forms/icons/Play1Hot.png \ + forms/icons/fullscreen.PNG \ + forms/icons/window_fullscreen-64.png \ + forms/icons/PauseHot.png \ + forms/icons/fullscreen.jpeg \ + forms/icons/Stop1PressedBlue.png \ + forms/icons/RecordPressed.png + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\rcc.exe -name icons forms\icons.qrc -o release\qrc_icons.cpp + +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_settings.h ui_travisto.h +compiler_uic_clean: + -$(DEL_FILE) ui_settings.h ui_travisto.h +ui_settings.h: forms/settings.ui + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\uic.exe forms\settings.ui -o ui_settings.h + +ui_travisto.h: forms/travisto.ui + c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\uic.exe forms\travisto.ui -o ui_travisto.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_uic_clean + + + +####### Compile + +release/Settings.o: forms/Settings.cpp forms/Settings.h \ + ui_settings.h \ + src/SystemSettings.h \ + src/geometry/LinePlotter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Settings.o forms\Settings.cpp + +release/SaxParser.o: src/SaxParser.cpp src/SaxParser.h \ + src/SyncData.h \ + src/TrajectoryPoint.h \ + src/Frame.h \ + src/Debug.h \ + src/geometry/Point.h \ + src/geometry/FacilityGeometry.h \ + src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h \ + src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/CTransition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\SaxParser.o src\SaxParser.cpp + +release/Debug.o: src/Debug.cpp src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Debug.o src\Debug.cpp + +release/main.o: src/main.cpp src/travisto.h \ + ui_travisto.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\main.o src\main.cpp + +release/travisto.o: src/travisto.cpp src/travisto.h \ + ui_travisto.h \ + src/SaxParser.h \ + src/SyncData.h \ + src/SystemSettings.h \ + forms/Settings.h \ + ui_settings.h \ + src/extern_var.h \ + src/Pedestrian.h \ + src/TrajectoryPoint.h \ + src/Frame.h \ + src/Debug.h \ + src/ThreadVisualisation.h \ + src/ThreadDataTransfert.h \ + src/SimpleVisualisationWindow.h \ + src/geometry/FacilityGeometry.h \ + src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h \ + src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/CTransition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\travisto.o src\travisto.cpp + +release/Frame.o: src/Frame.cpp src/TrajectoryPoint.h \ + src/Frame.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Frame.o src\Frame.cpp + +release/InteractorStyle.o: src/InteractorStyle.cpp src/SystemSettings.h \ + src/InteractorStyle.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\InteractorStyle.o src\InteractorStyle.cpp + +release/Pedestrian.o: src/Pedestrian.cpp src/Pedestrian.h \ + src/geometry/Point.h \ + src/geometry/PointPlotter.h \ + src/geometry/LinePlotter.h \ + forms/Settings.h \ + ui_settings.h \ + src/SystemSettings.h \ + src/TrajectoryPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Pedestrian.o src\Pedestrian.cpp + +release/SimpleVisualisationWindow.o: src/SimpleVisualisationWindow.cpp src/SimpleVisualisationWindow.h \ + src/geometry/LinePlotter.h \ + src/geometry/PointPlotter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\SimpleVisualisationWindow.o src\SimpleVisualisationWindow.cpp + +release/SyncData.o: src/SyncData.cpp src/SyncData.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/Message.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\SyncData.o src\SyncData.cpp + +release/SystemSettings.o: src/SystemSettings.cpp src/SystemSettings.h \ + src/Debug.h \ + forms/Settings.h \ + ui_settings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\SystemSettings.o src\SystemSettings.cpp + +release/ThreadDataTransfert.o: src/ThreadDataTransfert.cpp src/SystemSettings.h \ + src/ThreadDataTransfert.h \ + src/SyncData.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/network/TraVisToServer.h \ + src/geometry/FacilityGeometry.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ThreadDataTransfert.o src\ThreadDataTransfert.cpp + +release/ThreadVisualisation.o: src/ThreadVisualisation.cpp src/geometry/FacilityGeometry.h \ + src/geometry/LinePlotter2D.h \ + src/ThreadVisualisation.h \ + src/Pedestrian.h \ + src/TimerCallback.h \ + src/SyncData.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/InteractorStyle.h \ + src/SystemSettings.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ThreadVisualisation.o src\ThreadVisualisation.cpp + +release/TimerCallback.o: src/TimerCallback.cpp src/geometry/FacilityGeometry.h \ + src/geometry/Point.h \ + src/Pedestrian.h \ + src/Frame.h \ + src/TrajectoryPoint.h \ + src/SyncData.h \ + src/SystemSettings.h \ + src/TimerCallback.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TimerCallback.o src\TimerCallback.cpp + +release/TrajectoryPoint.o: src/TrajectoryPoint.cpp src/TrajectoryPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TrajectoryPoint.o src\TrajectoryPoint.cpp + +release/LinePlotter2D.o: src/geometry/LinePlotter2D.cpp src/geometry/LinePlotter2D.h \ + src/SystemSettings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\LinePlotter2D.o src\geometry\LinePlotter2D.cpp + +release/PointPlotter2D.o: src/geometry/PointPlotter2D.cpp src/geometry/PointPlotter2D.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\PointPlotter2D.o src\geometry\PointPlotter2D.cpp + +release/FacilityGeometry.o: src/geometry/FacilityGeometry.cpp src/geometry/FacilityGeometry.h \ + src/geometry/Point.h \ + src/SystemSettings.h \ + src/geometry/LinePlotter2D.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\FacilityGeometry.o src\geometry\FacilityGeometry.cpp + +release/LinePlotter.o: src/geometry/LinePlotter.cpp src/geometry/Point.h \ + src/SystemSettings.h \ + src/geometry/LinePlotter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\LinePlotter.o src\geometry\LinePlotter.cpp + +release/Point.o: src/geometry/Point.cpp src/geometry/Point.h \ + src/Debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Point.o src\geometry\Point.cpp + +release/PointPlotter.o: src/geometry/PointPlotter.cpp src/geometry/Point.h \ + src/geometry/PointPlotter.h \ + src/SystemSettings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\PointPlotter.o src\geometry\PointPlotter.cpp + +release/Building.o: src/geometry/jul/Building.cpp src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Building.o src\geometry\jul\Building.cpp + +release/Room.o: src/geometry/jul/Room.cpp src/geometry/jul/Room.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/Macros.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Room.o src\geometry\jul\Room.cpp + +release/Line.o: src/geometry/jul/Line.cpp src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Line.o src\geometry\jul\Line.cpp + +release/Transition.o: src/geometry/jul/Transition.cpp src/geometry/jul/Transition.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Transition.o src\geometry\jul\Transition.cpp + +release/Wall.o: src/geometry/jul/Wall.cpp src/geometry/jul/Wall.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Wall.o src\geometry\jul\Wall.cpp + +release/CPoint.o: src/geometry/jul/CPoint.cpp src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CPoint.o src\geometry\jul\CPoint.cpp + +release/CLine.o: src/geometry/pg3/CLine.cpp src/geometry/pg3/CLine.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/jul/CPoint.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CLine.o src\geometry\pg3\CLine.cpp + +release/CBuilding.o: src/geometry/pg3/CBuilding.cpp src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/jul/CPoint.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/CTransition.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CBuilding.o src\geometry\pg3\CBuilding.cpp + +release/CRoom.o: src/geometry/pg3/CRoom.cpp src/geometry/pg3/CRoom.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CLine.h \ + src/geometry/jul/CPoint.h \ + src/geometry/pg3/CCoordsList.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CRoom.o src\geometry\pg3\CRoom.cpp + +release/CCell.o: src/geometry/pg3/CCell.cpp src/geometry/pg3/CCell.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CCell.o src\geometry\pg3\CCell.cpp + +release/CCoordsList.o: src/geometry/pg3/CCoordsList.cpp src/geometry/pg3/CCoordsList.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CCoordsList.o src\geometry\pg3\CCoordsList.cpp + +release/Common.o: src/geometry/pg3/Common.cpp src/geometry/pg3/Common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Common.o src\geometry\pg3\Common.cpp + +release/CTextLog.o: src/geometry/pg3/CTextLog.cpp src/geometry/pg3/CTextLog.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CTextLog.o src\geometry\pg3\CTextLog.cpp + +release/CTransition.o: src/geometry/pg3/CTransition.cpp src/geometry/pg3/CTransition.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/Common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\CTransition.o src\geometry\pg3\CTransition.cpp + +release/TraVisToServer.o: src/network/TraVisToServer.cpp src/network/TraVisToServer.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TraVisToServer.o src\network\TraVisToServer.cpp + +release/moc_Settings.o: release/moc_Settings.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_Settings.o release\moc_Settings.cpp + +release/moc_travisto.o: release/moc_travisto.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_travisto.o release\moc_travisto.cpp + +release/moc_SyncData.o: release/moc_SyncData.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_SyncData.o release\moc_SyncData.cpp + +release/moc_ThreadDataTransfert.o: release/moc_ThreadDataTransfert.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ThreadDataTransfert.o release\moc_ThreadDataTransfert.cpp + +release/moc_ThreadVisualisation.o: release/moc_ThreadVisualisation.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ThreadVisualisation.o release\moc_ThreadVisualisation.cpp + +release/moc_TimerCallback.o: release/moc_TimerCallback.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_TimerCallback.o release\moc_TimerCallback.cpp + +release/moc_TraVisToServer.o: release/moc_TraVisToServer.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_TraVisToServer.o release\moc_TraVisToServer.cpp + +release/qrc_icons.o: release/qrc_icons.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\qrc_icons.o release\qrc_icons.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/TraVisTo.pro b/TraVisTo.pro new file mode 100644 index 0000000000000000000000000000000000000000..d06fe1cd27d1febb3fdec4f85ad7f4c243307465 --- /dev/null +++ b/TraVisTo.pro @@ -0,0 +1,143 @@ +TEMPLATE = app +TARGET = TraVisTo +CONFIG += qt +QT += xml \ + network + +win32 { + INCLUDEPATH += C:/VTK/include/vtk-5.10 + + LIBS += -LC:/VTK/bin \ + -lvtksys \ + -lvtkzlib \ + -lvtkjpeg \ + -lvtkpng \ + -lvtktiff \ + -lvtkexpat \ + -lvtkfreetype \ + -lvtklibxml2 \ + -lvtkDICOMParser \ + -lvtkverdict \ + -lvtkNetCDF \ + -lvtkmetaio \ + -lvtkexoIIc \ + -lvtkalglib \ + -lvtkftgl \ + -lvtkCommon \ + -lvtkFiltering \ + -lvtkImaging \ + -lvtkGraphics \ + -lvtkIO \ + -lvtkRendering \ + -lvtkParallel \ + -lvtkHybrid \ + -lvtkWidgets \ + -lvtkInfovis\ + -lvtkViews\ + -lwsock32\ +} + +unix { + INCLUDEPATH += /usr/include/vtk-5.8 + + LIBS += -L/usr/lib/ \ + -lvtkCommon \ + -lvtkDICOMParser \ + -lvtkFiltering \ + -lvtkGenericFiltering \ + -lvtkGraphics \ + -lvtkHybrid \ + -lvtkIO \ + -lvtkImaging \ + -lvtkRendering \ + -lvtkVolumeRendering \ + -lvtkWidgets \ + -lvtkexoIIc \ + -lvtkftgl \ + -lvtksys \ + -lvtkverdict \ + -lvtkParallel \ + -lvtkmetaio +} + + HEADERS += forms/Settings.h \ + src/SaxParser.h \ + src/Debug.h \ + src/travisto.h \ + src/Frame.h \ + src/InteractorStyle.h \ + src/Message.h \ + src/Pedestrian.h \ + src/SimpleVisualisationWindow.h \ + src/SyncData.h \ + src/SystemSettings.h \ + src/ThreadDataTransfert.h \ + src/ThreadVisualisation.h \ + src/TimerCallback.h \ + src/TrajectoryPoint.h \ + src/extern_var.h \ + src/geometry/FacilityGeometry.h \ + src/geometry/LinePlotter.h \ + src/geometry/Point.h \ + src/geometry/PointPlotter.h \ + src/geometry/LinePlotter2D.h \ + src/geometry/PointPlotter2D.h \ + src/geometry/jul/Building.h \ + src/geometry/jul/Room.h \ + src/geometry/jul/Line.h \ + src/geometry/jul/Transition.h \ + src/geometry/jul/Wall.h \ + src/geometry/jul/CPoint.h \ + src/geometry/jul/Macros.h \ + src/geometry/pg3/CLine.h \ + src/geometry/pg3/CBuilding.h \ + src/geometry/pg3/CRoom.h \ + src/geometry/pg3/CCell.h \ + src/geometry/pg3/CCoordsList.h \ + src/geometry/pg3/Common.h \ + src/geometry/pg3/CTextLog.h \ + src/geometry/pg3/CTransition.h \ + src/network/TraVisToServer.h + + SOURCES += forms/Settings.cpp \ + src/SaxParser.cpp \ + src/Debug.cpp \ + src/main.cpp \ + src/travisto.cpp \ + src/Frame.cpp \ + src/InteractorStyle.cpp \ + src/Pedestrian.cpp \ + src/SimpleVisualisationWindow.cpp \ + src/SyncData.cpp \ + src/SystemSettings.cpp \ + src/ThreadDataTransfert.cpp \ + src/ThreadVisualisation.cpp \ + src/TimerCallback.cpp \ + src/TrajectoryPoint.cpp \ + src/geometry/LinePlotter2D.cpp \ + src/geometry/PointPlotter2D.cpp \ + src/geometry/FacilityGeometry.cpp \ + src/geometry/LinePlotter.cpp \ + src/geometry/Point.cpp \ + src/geometry/PointPlotter.cpp \ + src/geometry/jul/Building.cpp \ + src/geometry/jul/Room.cpp \ + src/geometry/jul/Line.cpp \ + src/geometry/jul/Transition.cpp \ + src/geometry/jul/Wall.cpp \ + src/geometry/jul/CPoint.cpp \ + src/geometry/pg3/CLine.cpp \ + src/geometry/pg3/CBuilding.cpp \ + src/geometry/pg3/CRoom.cpp \ + src/geometry/pg3/CCell.cpp \ + src/geometry/pg3/CCoordsList.cpp \ + src/geometry/pg3/Common.cpp \ + src/geometry/pg3/CTextLog.cpp \ + src/geometry/pg3/CTransition.cpp \ + src/network/TraVisToServer.cpp + FORMS += forms/settings.ui \ + forms/travisto.ui + RESOURCES += forms/icons.qrc \ + forms/icons.qrc \ + forms/icons.qrc + RC_FILE = forms/travisto.rc diff --git a/TraVisToProjet.xml b/TraVisToProjet.xml new file mode 100644 index 0000000000000000000000000000000000000000..a33e5ba9fd59b738bb42cfa1447660d57bd5e778 --- /dev/null +++ b/TraVisToProjet.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE TraVisToProject SYSTEM "TraVisToProject.dtd"> +<TraVisToProject> + <visualisation_mode> + <mode>online</mode> + <server>localhost</server> + <port>14009</port> + </visualisation_mode> + <files> + <trajectories> + e:/workspace/TraVisTo/data/evacuationTime.dat + </trajectories> + <trajectories> + e:/workspace/TraVisTo/data/evacuationTime2.dat + </trajectories> + <geometry> + e:/workspace/TraVisTo/data/geometry.dat + </geometry> + </files> + <settings> + <mode>2D</mode> + <showAgent>true</showAgent> + <showGeometry>true</showGeometry> + <showLegend>true</showLegend> + <showCaption>true</showCaption> + <showAxis>true</showAxis> + <cameraView>top</cameraView> + <trails> + <type>polygones</type> + <points>100</points> + </trails> + + </settings> + +</TraVisToProject> diff --git a/debug/TraVisTo.exe b/debug/TraVisTo.exe new file mode 100644 index 0000000000000000000000000000000000000000..6bf16681f2e6ae50097de5408c5153ebe10c516d Binary files /dev/null and b/debug/TraVisTo.exe differ diff --git a/forms/Settings.cpp b/forms/Settings.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fdadc40816ba3c51ee53b8e9e2133b8714b90282 --- /dev/null +++ b/forms/Settings.cpp @@ -0,0 +1,271 @@ +/** +* @file Settings.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief +* +* +* Created on: 05.05.2009 +* +*/ + +#include <iostream> +#include <QFileDialog> +#include <QMessageBox> +#include <QColorDialog> + +#include "Settings.h" +#include "./src/geometry/LinePlotter.h" + +using namespace std; + +QColor Settings::tmpCaptionColor=QColor(); + +Settings::Settings(QWidget *parent) +: QWidget(parent) +{ + ui.setupUi(this); + + // initialize the output directory + QString dir; + SystemSettings::getOutputDirectory(dir); + ui.LEditOutputDir->setText(dir); + + //restore the caption color parameter + char bgcolor[50]; + sprintf(bgcolor,"background-color: rgb(%d, %d, %d);",tmpCaptionColor.red(),tmpCaptionColor.green(),tmpCaptionColor.blue()); + ui.frameCaptionColorPreview->setStyleSheet(bgcolor); + +} + +Settings::~Settings() +{ + +} + +void Settings::slotChangePedestrianShape() +{ + int resolution=ui.CbEllipseResolution->currentText().toInt(); + SystemSettings::setEllipseResolution(resolution); + extern_force_system_update=true; +} + + + +void Settings::slotUpdateTrailSettings(){ + + + bool ok=false; + int count=ui.CbTrailPointsCount->currentText().toInt(&ok); + if(ok==false){ + //FIXME: +// ui.CbTrailPointsCount->removeItem(ui.CbEllipseRadiusA->currentIndex()); + return; + } + int type=ui.CbTrailType->currentIndex(); + int form=ui.CbTrailGeometry->currentIndex(); + + if(form==1) + ui.CbTrailPolygoneWidth->setEnabled(true); + else + ui.CbTrailPolygoneWidth->setEnabled(false); + SystemSettings::setTrailsInfo(count,type,form); +} + +/// @todo use the QColorDialog instead +/// @todo make the whole thing live by connecting signal + +void Settings::slotPickPedestrianColor(){ + + QColorDialog* colorDialog = new QColorDialog(this); + QColor col=colorDialog->getColor("choose the new pedestrian color"); + + // the user may have cancelled the process + if(col.isValid()==false) return; + slotChangePedestrianColor(col); + + delete colorDialog; + +} +void Settings::slotChangePedestrianColor(const QColor & color){ + int r=0.0,g=0.0,b=0.0; + color.getRgb(&r,&g,&b); + int bkcolor[3]={r ,g,b}; + + SystemSettings::setPedestrianColor(ui.CbPedestrianGroup->currentIndex(),bkcolor); + extern_force_system_update=true; +} + +void Settings::slotChangeVerticesWidth(){ + bool ok=false; + + double width=ui.CbTrailPolygoneWidth->currentText().toDouble(&ok); + if(ok==false){ + //fixme: + //ui.CbEllipseRadiusA->removeItem(ui.CbTrailPolygoneWidth->currentIndex()); + return; + } + LinePlotter::setLineWidth((int)width); +} + + + + +/// choose a new directory +void Settings::slotChangeOutputDir(){ + + QString dir = QFileDialog::getExistingDirectory(this, tr("Select a Directory for saving your files (screenshots, video,...)"), + "", + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + + // in the case the selection was aborted + if(!QFileInfo(dir).isWritable()) { + slotErrorOutput("I cant write to that directory"); + dir=""; + } + if(dir.isEmpty()){ + SystemSettings::getOutputDirectory(dir); + ui.LEditOutputDir->setText(dir); + }else{ + ui.LEditOutputDir->setText(dir); + SystemSettings::setOutputDirectory(dir); + } +} + +void Settings::slotErrorOutput(QString err) { + QMessageBox msgBox; + msgBox.setText("Error"); + msgBox.setInformativeText(err); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); +} + +void Settings::slotChangePedestrianColorProfile(){ + + if(!ui.chBpedestrianDefaultColor->isChecked()){ + ui.CbPedestrianGroup->setEnabled(true); + ui.pushButtonChangePedestrianColor->setEnabled(true); + SystemSettings::setPedestrianColorProfileFromFile(false); + }else{ + ui.CbPedestrianGroup->setEnabled(false); + ui.pushButtonChangePedestrianColor->setEnabled(false); + SystemSettings::setPedestrianColorProfileFromFile(true); + } +} + +void Settings::slotChangeCaptionSize(){ + bool ok=false; + + int size =ui.CbCaptionSize->currentText().toInt(&ok); + if( (ok==false)|| (size >=200)){ + ui.CbCaptionSize->removeItem(ui.CbCaptionSize->currentIndex()); + return; + } + + int orientation= ui.ComboCaptionOrientation->currentIndex(); + bool automaticRotation=ui.checkBoxCaptionAutoRotate->isChecked(); + + SystemSettings::setCaptionsParameters(size, tmpCaptionColor,orientation, automaticRotation); + + extern_force_system_update=true; +} + + +void Settings::slotPickCaptionColor(){ + + QColorDialog* colorDialog = new QColorDialog(this); + + tmpCaptionColor=colorDialog->getColor(); + + // the user may have cancelled the process + if(tmpCaptionColor.isValid()==false) return; + + int size =ui.CbCaptionSize->currentText().toInt(); + int orientation= ui.ComboCaptionOrientation->currentText().toInt(); + bool automaticRotation=ui.checkBoxCaptionAutoRotate->isChecked(); + + SystemSettings::setCaptionsParameters(size, tmpCaptionColor,orientation, automaticRotation); + + //update the color marker defined by a frame + char bgcolor[50]; + sprintf(bgcolor,"background-color: rgb(%d, %d, %d);",tmpCaptionColor.red(),tmpCaptionColor.green(),tmpCaptionColor.blue()); + ui.frameCaptionColorPreview->setStyleSheet(bgcolor); + + extern_force_system_update=true; + + delete colorDialog; +} + + +void Settings::slotChangeCaptionOrientation(){ + int size =ui.CbCaptionSize->currentText().toInt(); + int orientation= ui.ComboCaptionOrientation->currentIndex(); + bool automaticRotation=ui.checkBoxCaptionAutoRotate->isChecked(); + + SystemSettings::setCaptionsParameters(size, tmpCaptionColor,orientation, automaticRotation); + extern_force_system_update=true; +} + +void Settings::slotChangeCaptionAutoRotation(){ + int size =ui.CbCaptionSize->currentText().toInt(); + int orientation= ui.ComboCaptionOrientation->currentText().toInt(); + bool automaticRotation=ui.checkBoxCaptionAutoRotate->isChecked(); + + SystemSettings::setCaptionsParameters(size, tmpCaptionColor,orientation, automaticRotation); + extern_force_system_update=true; +} + +void Settings::slotChangeCaptionColorMode(){ + + if(ui.comboCaptionColorMode->currentText().compare("Auto")==0){ + int size =ui.CbCaptionSize->currentText().toInt(); + int orientation= ui.ComboCaptionOrientation->currentText().toInt(); + bool automaticRotation=ui.checkBoxCaptionAutoRotate->isChecked(); + + SystemSettings::setCaptionsParameters(size, QColor() ,orientation, automaticRotation); + extern_force_system_update=true; + + }else if(ui.comboCaptionColorMode->currentText().compare("Custom")==0){ + slotPickCaptionColor(); + } +} + +//ugly, I had no choice :) +void Settings::closeEvent(QCloseEvent* event){ + hide(); + ///@FIXME +// event->ignore(); +} + +void Settings::slotControlSequence(QString msg){ + + if(msg.compare("CAPTION_AUTO")==0){ + ui.comboCaptionColorMode->setCurrentIndex(0); //should be auto + }else + if (msg.compare("CAPTION_CUSTOM")==0){ + ui.comboCaptionColorMode->setCurrentIndex(1); //should be custom + } + slotChangeCaptionColorMode(); +} diff --git a/forms/Settings.h b/forms/Settings.h new file mode 100644 index 0000000000000000000000000000000000000000..4853fc9e8515fbc9a1f3689e203bbeb1c99e58bd --- /dev/null +++ b/forms/Settings.h @@ -0,0 +1,103 @@ +/** +* @file Settings.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief +* +* +* Created on: 05.05.2009 +* +*/ + +#ifndef PEDESTRIANSHAPE_H +#define PEDESTRIANSHAPE_H + +#include <QtGui/QWidget> +#include "ui_settings.h" +#include "./src/SystemSettings.h" + +extern bool extern_force_system_update; + +class Settings : public QWidget +{ + Q_OBJECT + +public: + enum Shape {DEFAULT=1,ELLIPSE,PINGUINS}; + Settings(QWidget *parent = 0); + virtual ~Settings(); + + public Q_SLOTS: + + /// change the resolution of the ellipse representing the pedestrian + void slotChangePedestrianShape(); + + + /// change the trails settings + void slotUpdateTrailSettings(); + + /// customize pedestrian color + void slotPickPedestrianColor(); + + void slotChangePedestrianColor(const QColor& color); + + /// set the width of the lines defining the vertices + void slotChangeVerticesWidth(); + + /// change the output directory + void slotChangeOutputDir(); + + /// change the size of the pedestrian caption + /// The maximal size is limited to 200 + void slotChangeCaptionSize(); + + + ///change the caption orientation + void slotChangeCaptionOrientation(); + + ///change the caption auto rotation policy + void slotChangeCaptionAutoRotation(); + + /// change pedestrian color profile + void slotChangePedestrianColorProfile(); + + /// choose a new caption color + void slotPickCaptionColor(); + + ///change the caption color mode, auto or custom + void slotChangeCaptionColorMode(); + + /// execute a control sequence + void slotControlSequence(QString msg); + +protected: + virtual void closeEvent(QCloseEvent* event); + +private: + void updateCaptionSetting(); + Ui::SettingsClass ui; + static QColor tmpCaptionColor; + void slotErrorOutput(QString err); +}; + +#endif // PEDESTRIANSHAPE_H diff --git a/forms/icons.qrc b/forms/icons.qrc new file mode 100644 index 0000000000000000000000000000000000000000..5a7522a59523597fdaf33f7b6e1f783c5a0ab0d8 --- /dev/null +++ b/forms/icons.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/new/iconsS" lang="english" > + <file>icons/fullscreen.PNG</file> + <file>icons/window_fullscreen-64.png</file> + <file>icons/Play1Hot.png</file> + <file>icons/Stop1PressedBlue.png</file> + <file>icons/fullscreen.jpeg</file> + <file>icons/PauseHot.png</file> + <file>icons/RecordPressed.png</file> + </qresource> +</RCC> diff --git a/forms/icons/PauseHot.png b/forms/icons/PauseHot.png new file mode 100644 index 0000000000000000000000000000000000000000..3db09c776000c8669c4fbf329fe2dcda00ef6a88 Binary files /dev/null and b/forms/icons/PauseHot.png differ diff --git a/forms/icons/Play1Hot.png b/forms/icons/Play1Hot.png new file mode 100644 index 0000000000000000000000000000000000000000..2a1684ce8167a054c0cd613179e005b5303bd3d4 Binary files /dev/null and b/forms/icons/Play1Hot.png differ diff --git a/forms/icons/RecordPressed.png b/forms/icons/RecordPressed.png new file mode 100644 index 0000000000000000000000000000000000000000..fa4495809821ed6d8a352e64133251fc17adc420 Binary files /dev/null and b/forms/icons/RecordPressed.png differ diff --git a/forms/icons/Stop1PressedBlue.png b/forms/icons/Stop1PressedBlue.png new file mode 100644 index 0000000000000000000000000000000000000000..4e240f4712da538fda4cca5cecdec0c80edf374f Binary files /dev/null and b/forms/icons/Stop1PressedBlue.png differ diff --git a/forms/icons/fullscreen.PNG b/forms/icons/fullscreen.PNG new file mode 100644 index 0000000000000000000000000000000000000000..e3ad4954bcb16f2b7b61ee58f680dacbf2c3c402 Binary files /dev/null and b/forms/icons/fullscreen.PNG differ diff --git a/forms/icons/fullscreen.jpeg b/forms/icons/fullscreen.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..98d614198857fd5ee110a25360c8f7363a9765a1 Binary files /dev/null and b/forms/icons/fullscreen.jpeg differ diff --git a/forms/icons/window_fullscreen-64.png b/forms/icons/window_fullscreen-64.png new file mode 100644 index 0000000000000000000000000000000000000000..cc1c51b83b78f2be9526363305e76e155f7d62e6 Binary files /dev/null and b/forms/icons/window_fullscreen-64.png differ diff --git a/forms/settings.ui b/forms/settings.ui new file mode 100644 index 0000000000000000000000000000000000000000..5f4661b7b3e1ee022f0f4f49cb2ba05f62ebb107 --- /dev/null +++ b/forms/settings.ui @@ -0,0 +1,883 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SettingsClass</class> + <widget class="QWidget" name="SettingsClass"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>387</width> + <height>438</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>227</width> + <height>231</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>2270</width> + <height>2310</height> + </size> + </property> + <property name="windowTitle"> + <string>PedestrianShape</string> + </property> + <widget class="QTabWidget" name="tabWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>10</y> + <width>391</width> + <height>411</height> + </rect> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Pedestrian Shape</string> + </attribute> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>20</x> + <y>20</y> + <width>201</width> + <height>111</height> + </rect> + </property> + <property name="title"> + <string>Shape</string> + </property> + <widget class="QWidget" name="layoutWidget"> + <property name="geometry"> + <rect> + <x>20</x> + <y>50</y> + <width>142</width> + <height>31</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Ellipse Resolution</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="CbEllipseResolution"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>5</number> + </property> + <item> + <property name="text"> + <string>3</string> + </property> + </item> + <item> + <property name="text"> + <string>4</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>6</string> + </property> + </item> + <item> + <property name="text"> + <string>8</string> + </property> + </item> + <item> + <property name="text"> + <string>10</string> + </property> + </item> + <item> + <property name="text"> + <string>15</string> + </property> + </item> + <item> + <property name="text"> + <string>20</string> + </property> + </item> + <item> + <property name="text"> + <string>30</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </widget> + <widget class="QGroupBox" name="groupBox_2"> + <property name="geometry"> + <rect> + <x>20</x> + <y>190</y> + <width>201</width> + <height>131</height> + </rect> + </property> + <property name="title"> + <string>Color</string> + </property> + <widget class="QWidget" name="layoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>50</y> + <width>178</width> + <height>52</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QComboBox" name="CbPedestrianGroup"> + <property name="enabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>First Group</string> + </property> + </item> + <item> + <property name="text"> + <string>Second Group</string> + </property> + </item> + <item> + <property name="text"> + <string>Third Group</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButtonChangePedestrianColor"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>change</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QCheckBox" name="chBpedestrianDefaultColor"> + <property name="geometry"> + <rect> + <x>20</x> + <y>20</y> + <width>174</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>Default (read from file)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </widget> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>Trails/Captions</string> + </attribute> + <widget class="QWidget" name="layoutWidget"> + <property name="geometry"> + <rect> + <x>70</x> + <y>50</y> + <width>182</width> + <height>104</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Number of Points</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="CbTrailPointsCount"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <item> + <property name="text"> + <string>30</string> + </property> + </item> + <item> + <property name="text"> + <string>40</string> + </property> + </item> + <item> + <property name="text"> + <string>50</string> + </property> + </item> + <item> + <property name="text"> + <string>60</string> + </property> + </item> + <item> + <property name="text"> + <string>70</string> + </property> + </item> + <item> + <property name="text"> + <string>100</string> + </property> + </item> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Type</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="CbTrailType"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>1</number> + </property> + <item> + <property name="text"> + <string>Backward</string> + </property> + </item> + <item> + <property name="text"> + <string>Symetric</string> + </property> + </item> + <item> + <property name="text"> + <string>Forward</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Geometry</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="CbTrailGeometry"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>1</number> + </property> + <item> + <property name="text"> + <string>Points</string> + </property> + </item> + <item> + <property name="text"> + <string>Polygone</string> + </property> + </item> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_8"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Vertex width</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QComboBox" name="CbTrailPolygoneWidth"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="currentIndex"> + <number>1</number> + </property> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>3</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>6</string> + </property> + </item> + <item> + <property name="text"> + <string>7</string> + </property> + </item> + <item> + <property name="text"> + <string>10</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + <widget class="QLabel" name="label_15"> + <property name="geometry"> + <rect> + <x>40</x> + <y>20</y> + <width>61</width> + <height>21</height> + </rect> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Trails</string> + </property> + </widget> + <widget class="QWidget" name="layoutWidget_4"> + <property name="geometry"> + <rect> + <x>70</x> + <y>200</y> + <width>182</width> + <height>104</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>Size</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string>Color</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboCaptionColorMode"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <item> + <property name="text"> + <string>Auto</string> + </property> + </item> + <item> + <property name="text"> + <string>Custom</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_18"> + <property name="text"> + <string>Orientation</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="ComboCaptionOrientation"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="editable"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <item> + <property name="text"> + <string>Custom</string> + </property> + </item> + <item> + <property name="text"> + <string>Billboard</string> + </property> + </item> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_19"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Automatic Rotation</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="CbCaptionSize"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="maxCount"> + <number>200</number> + </property> + <item> + <property name="text"> + <string>30</string> + </property> + </item> + <item> + <property name="text"> + <string>40</string> + </property> + </item> + <item> + <property name="text"> + <string>50</string> + </property> + </item> + <item> + <property name="text"> + <string>70</string> + </property> + </item> + <item> + <property name="text"> + <string>80</string> + </property> + </item> + <item> + <property name="text"> + <string>100</string> + </property> + </item> + <item> + <property name="text"> + <string>200</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="checkBoxCaptionAutoRotate"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QLabel" name="label_20"> + <property name="geometry"> + <rect> + <x>40</x> + <y>170</y> + <width>61</width> + <height>16</height> + </rect> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Captions</string> + </property> + </widget> + <widget class="QFrame" name="frameCaptionColorPreview"> + <property name="geometry"> + <rect> + <x>260</x> + <y>230</y> + <width>41</width> + <height>21</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">background-color: rgb(0, 255, 127);</string> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + </widget> + </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Network</string> + </attribute> + <widget class="QLabel" name="label_9"> + <property name="geometry"> + <rect> + <x>40</x> + <y>40</y> + <width>53</width> + <height>15</height> + </rect> + </property> + <property name="text"> + <string>Host:</string> + </property> + </widget> + <widget class="QLabel" name="label_10"> + <property name="geometry"> + <rect> + <x>40</x> + <y>60</y> + <width>53</width> + <height>15</height> + </rect> + </property> + <property name="text"> + <string>Port:</string> + </property> + </widget> + </widget> + <widget class="QWidget" name="Locations"> + <attribute name="title"> + <string>Locations</string> + </attribute> + <widget class="QWidget" name="layoutWidget"> + <property name="geometry"> + <rect> + <x>20</x> + <y>40</y> + <width>219</width> + <height>51</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <widget class="QLabel" name="label_11"> + <property name="toolTip"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Directory in wich all generated screenshots and video will be saved. Default on the <span style=" font-weight:600;">Desktop</span></p></body></html></string> + </property> + <property name="text"> + <string>output directory</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="LEditOutputDir"> + <property name="toolTip"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Directory in wich all generated screenshots and video will be saved. Default on the <span style=" font-weight:600;">Desktop</span></p></body></html></string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="PBChangeOutputDir"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>163</height> + </size> + </property> + <property name="toolTip"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Change directory in wich all generated screenshots and video will be saved. Default on the <span style=" font-weight:600;">Desktop</span></p></body></html></string> + </property> + <property name="text"> + <string>Change</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </widget> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>CbTrailPointsCount</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotUpdateTrailSettings()</slot> + <hints> + <hint type="sourcelabel"> + <x>166</x> + <y>83</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>207</y> + </hint> + </hints> + </connection> + <connection> + <sender>CbTrailGeometry</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotUpdateTrailSettings()</slot> + <hints> + <hint type="sourcelabel"> + <x>166</x> + <y>135</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>207</y> + </hint> + </hints> + </connection> + <connection> + <sender>CbTrailType</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotUpdateTrailSettings()</slot> + <hints> + <hint type="sourcelabel"> + <x>166</x> + <y>109</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>207</y> + </hint> + </hints> + </connection> + <connection> + <sender>CbTrailPolygoneWidth</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangeVerticesWidth()</slot> + <hints> + <hint type="sourcelabel"> + <x>166</x> + <y>161</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>218</y> + </hint> + </hints> + </connection> + <connection> + <sender>PBChangeOutputDir</sender> + <signal>clicked()</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangeOutputDir()</slot> + <hints> + <hint type="sourcelabel"> + <x>136</x> + <y>110</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>218</y> + </hint> + </hints> + </connection> + <connection> + <sender>CbCaptionSize</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangeCaptionSize()</slot> + <hints> + <hint type="sourcelabel"> + <x>211</x> + <y>244</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>218</y> + </hint> + </hints> + </connection> + <connection> + <sender>comboCaptionColorMode</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangeCaptionColorMode()</slot> + <hints> + <hint type="sourcelabel"> + <x>211</x> + <y>272</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>218</y> + </hint> + </hints> + </connection> + <connection> + <sender>ComboCaptionOrientation</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangeCaptionOrientation()</slot> + <hints> + <hint type="sourcelabel"> + <x>211</x> + <y>300</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>218</y> + </hint> + </hints> + </connection> + <connection> + <sender>checkBoxCaptionAutoRotate</sender> + <signal>clicked()</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangeCaptionAutoRotation()</slot> + <hints> + <hint type="sourcelabel"> + <x>211</x> + <y>325</y> + </hint> + <hint type="destinationlabel"> + <x>193</x> + <y>218</y> + </hint> + </hints> + </connection> + <connection> + <sender>CbEllipseResolution</sender> + <signal>activated(QString)</signal> + <receiver>SettingsClass</receiver> + <slot>slotChangePedestrianShape()</slot> + <hints> + <hint type="sourcelabel"> + <x>78</x> + <y>102</y> + </hint> + <hint type="destinationlabel"> + <x>113</x> + <y>115</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>slotChangePedestrianShape()</slot> + <slot>slotUpdateTrailSettings()</slot> + <slot>slotPickPedestrianColor()</slot> + <slot>slotChangeVerticesWidth()</slot> + <slot>slotChangeOutputDir()</slot> + <slot>slotChangeCaptionSize()</slot> + <slot>slotChangeCaptionColorMode()</slot> + <slot>slotChangeCaptionOrientation()</slot> + <slot>slotChangeCaptionAutoRotation()</slot> + </slots> +</ui> diff --git a/forms/travisto.ico b/forms/travisto.ico new file mode 100644 index 0000000000000000000000000000000000000000..ede08f4467b5d1c85853b91f5ff55eb79fca461d Binary files /dev/null and b/forms/travisto.ico differ diff --git a/forms/travisto.rc b/forms/travisto.rc new file mode 100644 index 0000000000000000000000000000000000000000..1ac2d8df2939cea7864127fd363efb8242f76565 --- /dev/null +++ b/forms/travisto.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "travisto.ico" diff --git a/forms/travisto.ui b/forms/travisto.ui new file mode 100644 index 0000000000000000000000000000000000000000..fbcc70bc9bfc4e56d4869441b28e4c9bc854f7b5 --- /dev/null +++ b/forms/travisto.ui @@ -0,0 +1,2077 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TraVisToClass</class> + <widget class="QMainWindow" name="TraVisToClass"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>450</width> + <height>400</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>450</width> + <height>400</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>450</width> + <height>400</height> + </size> + </property> + <property name="mouseTracking"> + <bool>true</bool> + </property> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <property name="windowTitle"> + <string>TraVisTo</string> + </property> + <property name="windowIcon"> + <iconset resource="icons.qrc"> + <normaloff>:/new/iconsS/icons/fullscreen.PNG</normaloff>:/new/iconsS/icons/fullscreen.PNG</iconset> + </property> + <property name="toolTip"> + <string>Visualise Pedestrian Motions</string> + </property> + <property name="whatsThis"> + <string>a Software....</string> + </property> + <widget class="QWidget" name="centralwidget"> + <property name="sizeIncrement"> + <size> + <width>3</width> + <height>3</height> + </size> + </property> + <widget class="QGroupBox" name="parameters"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>160</x> + <y>30</y> + <width>271</width> + <height>151</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="mouseTracking"> + <bool>false</bool> + </property> + <property name="title"> + <string>Settings</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="speedSliderLabel"> + <property name="text"> + <string>Speed (1X)</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="speedSettingSlider"> + <property name="minimum"> + <number>-20</number> + </property> + <property name="maximum"> + <number>20</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>1</number> + </property> + <property name="sliderPosition"> + <number>1</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="invertedControls"> + <bool>false</bool> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>2</number> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>50</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="framePerSecondSliderLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Frames per Sec</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="contrastSettingSlider"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(255, 149, 107);</string> + </property> + <property name="maximum"> + <number>10</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="sliderPosition"> + <number>0</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>5</number> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QGroupBox" name="Controls"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>30</x> + <y>30</y> + <width>111</width> + <height>201</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Control</string> + </property> + <widget class="QPushButton" name="BtStart"> + <property name="geometry"> + <rect> + <x>10</x> + <y>24</y> + <width>81</width> + <height>28</height> + </rect> + </property> + <property name="toolTip"> + <string>Start Visualisation</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="icons.qrc"> + <normaloff>:/new/iconsS/icons/Play1Hot.png</normaloff>:/new/iconsS/icons/Play1Hot.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + <widget class="QPushButton" name="BtStop"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>58</y> + <width>81</width> + <height>28</height> + </rect> + </property> + <property name="toolTip"> + <string>Stop Visualisation</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="icons.qrc"> + <normaloff>:/new/iconsS/icons/Stop1PressedBlue.png</normaloff>:/new/iconsS/icons/Stop1PressedBlue.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + <widget class="QPushButton" name="BtRecord"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>92</y> + <width>81</width> + <height>28</height> + </rect> + </property> + <property name="toolTip"> + <string>Start Recording</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="icons.qrc"> + <normaloff>:/new/iconsS/icons/RecordPressed.png</normaloff>:/new/iconsS/icons/RecordPressed.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + <widget class="QPushButton" name="BtFullscreen"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>126</y> + <width>81</width> + <height>28</height> + </rect> + </property> + <property name="toolTip"> + <string>Fullscreen</string> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="icons.qrc"> + <normaloff>:/new/iconsS/icons/window_fullscreen-64.png</normaloff>:/new/iconsS/icons/window_fullscreen-64.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + <widget class="QPushButton" name="BtReset"> + <property name="geometry"> + <rect> + <x>10</x> + <y>160</y> + <width>81</width> + <height>23</height> + </rect> + </property> + <property name="toolTip"> + <string>Reset the simulation and clear all datasets loaded</string> + </property> + <property name="text"> + <string>Reset</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + </widget> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>30</x> + <y>250</y> + <width>401</width> + <height>63</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="title"> + <string/> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="frameSliderLabel"> + <property name="text"> + <string>Frames</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QSlider" name="framesIndicatorSlider"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="mouseTracking"> + <bool>true</bool> + </property> + <property name="maximum"> + <number>20000</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QLCDNumber" name="lcdRunningTime"> + <property name="geometry"> + <rect> + <x>160</x> + <y>200</y> + <width>91</width> + <height>23</height> + </rect> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>255</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>255</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>118</red> + <green>116</green> + <blue>108</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="font"> + <font> + <family>MS Sans Serif</family> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true"> +border-color: rgb(255, 255, 255);</string> + </property> + <property name="smallDecimalPoint"> + <bool>false</bool> + </property> + <property name="numDigits"> + <number>10</number> + </property> + <property name="segmentStyle"> + <enum>QLCDNumber::Filled</enum> + </property> + <property name="intValue" stdset="0"> + <number>0</number> + </property> + </widget> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>290</x> + <y>201</y> + <width>51</width> + <height>20</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="text"> + <string>millisec</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + <widget class="QPushButton" name="BtNextFrame"> + <property name="geometry"> + <rect> + <x>350</x> + <y>190</y> + <width>81</width> + <height>23</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="text"> + <string>Next Frame</string> + </property> + </widget> + <widget class="QPushButton" name="BtPreviousFrame"> + <property name="geometry"> + <rect> + <x>350</x> + <y>220</y> + <width>81</width> + <height>23</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="text"> + <string>Previous</string> + </property> + </widget> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>450</width> + <height>25</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionLoad_File"/> + <addaction name="separator"/> + <addaction name="actionLoad_Geometry"/> + <addaction name="actionClear_Geometry"/> + <addaction name="actionAdd_Trajectories_File"/> + <addaction name="actionClear_Trajectories_Files"/> + <addaction name="separator"/> + <addaction name="actionOpen"/> + <addaction name="separator"/> + <addaction name="actionExit"/> + </widget> + <widget class="QMenu" name="menuApplication"> + <property name="title"> + <string>Visualisation</string> + </property> + <addaction name="separator"/> + <addaction name="actionReset"/> + <addaction name="actionStart"/> + <addaction name="actionRecord"/> + <addaction name="actionStop"/> + <addaction name="actionPause_Resume"/> + <addaction name="actionFullscreen"/> + <addaction name="separator"/> + <addaction name="actionOnline"/> + <addaction name="actionOffline"/> + <addaction name="separator"/> + <addaction name="actionFrames_Navigation"/> + </widget> + <widget class="QMenu" name="menuHelp"> + <property name="title"> + <string>Help</string> + </property> + <addaction name="actionTutorial"/> + <addaction name="separator"/> + <addaction name="actionAbout"/> + <addaction name="separator"/> + </widget> + <widget class="QMenu" name="menuOptions"> + <property name="title"> + <string>Options</string> + </property> + <widget class="QMenu" name="menuCaption_Color"> + <property name="title"> + <string>Caption Color</string> + </property> + <addaction name="actionCaptionAuto"/> + <addaction name="actionCaptionCustom"/> + </widget> + <addaction name="actionBackground_Color"/> + <addaction name="menuCaption_Color"/> + <addaction name="actionWalls_Color"/> + <addaction name="actionExits_Color"/> + <addaction name="separator"/> + <addaction name="actionPedestrian_Shape"/> + <addaction name="actionNetwork_settings"/> + </widget> + <widget class="QMenu" name="menuView"> + <property name="title"> + <string>View</string> + </property> + <widget class="QMenu" name="menuCamera_View"> + <property name="title"> + <string>Camera View</string> + </property> + <addaction name="actionCameraViewTop"/> + <addaction name="actionCameraViewSide"/> + <addaction name="actionCameraViewFront"/> + <addaction name="actionCameraViewAgent"/> + </widget> + <addaction name="action2_D"/> + <addaction name="action3_D"/> + <addaction name="separator"/> + <addaction name="actionShow_Agents"/> + <addaction name="actionShow_Trajectories"/> + <addaction name="actionShow_Geometry"/> + <addaction name="actionShow_Exits"/> + <addaction name="actionShow_Walls"/> + <addaction name="actionShow_Legend"/> + <addaction name="actionShow_Captions"/> + <addaction name="actionShow_Axis"/> + <addaction name="actionShow_Wall_Caption"/> + <addaction name="actionShow_Room_Caption"/> + <addaction name="actionShow_Door_Caption"/> + <addaction name="actionShow_Geometry_Captions"/> + <addaction name="separator"/> + <addaction name="actionFirst_Group"/> + <addaction name="actionSecond_Group"/> + <addaction name="actionThird_Group"/> + <addaction name="separator"/> + <addaction name="menuCamera_View"/> + <addaction name="separator"/> + <addaction name="actionShow_Onscreen_Infos"/> + <addaction name="separator"/> + </widget> + <widget class="QMenu" name="menuTools"> + <property name="title"> + <string>Tools</string> + </property> + <addaction name="actionSnapshot"/> + <addaction name="separator"/> + <addaction name="actionRecord_PNG_sequences"/> + <addaction name="actionRender_PNG_to_AVI"/> + </widget> + <addaction name="menuFile"/> + <addaction name="menuApplication"/> + <addaction name="menuView"/> + <addaction name="menuOptions"/> + <addaction name="menuTools"/> + <addaction name="menuHelp"/> + </widget> + <widget class="QStatusBar" name="statusbar"> + <property name="mouseTracking"> + <bool>true</bool> + </property> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> + </widget> + <action name="actionExit"> + <property name="text"> + <string>Exit</string> + </property> + <property name="toolTip"> + <string>Quit the application</string> + </property> + <property name="shortcut"> + <string>Ctrl+Q</string> + </property> + </action> + <action name="actionReset"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Reset</string> + </property> + <property name="shortcut"> + <string>Ctrl+R</string> + </property> + </action> + <action name="actionStart"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Start</string> + </property> + <property name="shortcut"> + <string>Ctrl+P</string> + </property> + </action> + <action name="actionStop"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Stop</string> + </property> + </action> + <action name="actionPause_Resume"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Pause/Resume</string> + </property> + </action> + <action name="actionAbout"> + <property name="text"> + <string>About TraVisTo</string> + </property> + <property name="shortcut"> + <string>F1</string> + </property> + </action> + <action name="actionTutorial"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Tutorial</string> + </property> + </action> + <action name="actionNetwork_settings"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Network settings</string> + </property> + </action> + <action name="actionOnline"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Online</string> + </property> + <property name="shortcut"> + <string>Ctrl+N</string> + </property> + </action> + <action name="actionOffline"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Offline</string> + </property> + <property name="shortcut"> + <string>Ctrl+F</string> + </property> + </action> + <action name="actionFullscreen"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Fullscreen</string> + </property> + </action> + <action name="actionRecord"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Record</string> + </property> + <property name="shortcut"> + <string>Ctrl+L</string> + </property> + </action> + <action name="actionOpen"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Load Project</string> + </property> + </action> + <action name="action2_D"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>2-D</string> + </property> + <property name="shortcut"> + <string>Ctrl+2</string> + </property> + </action> + <action name="actionReset_All"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Reset All</string> + </property> + </action> + <action name="actionAdd_Trajectories_File"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Add Trajectories File</string> + </property> + <property name="shortcut"> + <string>Ctrl+A</string> + </property> + </action> + <action name="actionClear_Trajectories_Files"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Clear Trajectories Files</string> + </property> + <property name="shortcut"> + <string>Ctrl+C</string> + </property> + </action> + <action name="actionLoad_Geometry"> + <property name="text"> + <string>Load Geometry</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> + <action name="actionLoad_File"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Load File</string> + </property> + <property name="shortcut"> + <string>Ctrl+O</string> + </property> + </action> + <action name="actionClear_Geometry"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Clear Geometry</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> + <action name="actionFirst_Group"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>First Group</string> + </property> + </action> + <action name="actionSecond_Group"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Second Group</string> + </property> + </action> + <action name="actionThird_Group"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Third Group</string> + </property> + </action> + <action name="actionShow_Legend"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Legend</string> + </property> + <property name="statusTip"> + <string>Add a legend to the plot</string> + </property> + <property name="shortcut"> + <string>S, L</string> + </property> + </action> + <action name="action3_D"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>3-D</string> + </property> + <property name="shortcut"> + <string>Ctrl+3</string> + </property> + </action> + <action name="actionShow_Agents"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Show Agents</string> + </property> + </action> + <action name="actionShow_Trajectories"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Trajectories</string> + </property> + <property name="shortcut"> + <string>S, T</string> + </property> + </action> + <action name="actionShow_Geometry"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Geometry</string> + </property> + <property name="shortcut"> + <string>S, G</string> + </property> + </action> + <action name="actionDEBUG_MODE"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>DEBUG MODE</string> + </property> + </action> + <action name="actionShow_Captions"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="text"> + <string>Show Captions</string> + </property> + <property name="shortcut"> + <string>S, C</string> + </property> + </action> + <action name="actionBackground_Color"> + <property name="text"> + <string>Background Color</string> + </property> + <property name="shortcut"> + <string>Ctrl+K</string> + </property> + </action> + <action name="actionFrames_Navigation"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Frames Navigation</string> + </property> + <property name="shortcut"> + <string>Ctrl+U</string> + </property> + </action> + <action name="actionShow_Axis"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Show Axis</string> + </property> + <property name="shortcut"> + <string>S, A</string> + </property> + </action> + <action name="actionCameraViewTop"> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="text"> + <string>Top</string> + </property> + </action> + <action name="actionCameraViewSide"> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Side</string> + </property> + </action> + <action name="actionCameraViewFront"> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Front</string> + </property> + </action> + <action name="actionPedestrian_Shape"> + <property name="text"> + <string>Settings</string> + </property> + <property name="shortcut"> + <string>Ctrl+,</string> + </property> + </action> + <action name="actionSnapshot"> + <property name="text"> + <string>Snapshot</string> + </property> + <property name="shortcut"> + <string>F5</string> + </property> + </action> + <action name="actionRecord_PNG_sequences"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Record PNG sequences</string> + </property> + <property name="shortcut"> + <string>F6</string> + </property> + </action> + <action name="actionRender_PNG_to_AVI"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Render PNG to AVI</string> + </property> + </action> + <action name="actionCameraViewAgent"> + <property name="text"> + <string>Agent View</string> + </property> + <property name="toolTip"> + <string>to see the scene through the eyes of an agent. You will hve to select the ID of the agent next.</string> + </property> + </action> + <action name="actionCaptionAuto"> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="text"> + <string>Auto</string> + </property> + </action> + <action name="actionCaptionCustom"> + <property name="text"> + <string>Choose...</string> + </property> + </action> + <action name="actionWalls_Color"> + <property name="text"> + <string>Walls Color</string> + </property> + </action> + <action name="actionExits_Color"> + <property name="text"> + <string>Exits Color</string> + </property> + </action> + <action name="actionShow_Onscreen_Infos"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Onscreen Infos</string> + </property> + </action> + <action name="actionShow_Exits"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Exits</string> + </property> + </action> + <action name="actionShow_Walls"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Walls</string> + </property> + </action> + <action name="actionShow_Wall_Caption"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Show Wall Caption</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> + <action name="actionShow_Room_Caption"> + <property name="text"> + <string>Show Room Caption</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> + <action name="actionShow_Door_Caption"> + <property name="text"> + <string>Show Door Caption</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> + <action name="actionShow_Geometry_Captions"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Geometry Captions</string> + </property> + </action> + </widget> + <resources> + <include location="icons.qrc"/> + </resources> + <connections> + <connection> + <sender>actionAbout</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotHelpAbout()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>246</x> + <y>189</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionExit</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotExit()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>246</x> + <y>189</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtStart</sender> + <signal>clicked()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotStartPlaying()</slot> + <hints> + <hint type="sourcelabel"> + <x>61</x> + <y>89</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtFullscreen</sender> + <signal>clicked(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotFullScreen(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>81</x> + <y>204</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtRecord</sender> + <signal>clicked()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotRecord()</slot> + <hints> + <hint type="sourcelabel"> + <x>61</x> + <y>157</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtReset</sender> + <signal>clicked()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotReset()</slot> + <hints> + <hint type="sourcelabel"> + <x>81</x> + <y>233</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtStop</sender> + <signal>clicked()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotStopPlaying()</slot> + <hints> + <hint type="sourcelabel"> + <x>61</x> + <y>123</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionNetwork_settings</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotNetworkSettings()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionOnline</sender> + <signal>toggled(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotSetOnlineMode(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionOffline</sender> + <signal>toggled(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotSetOfflineMode(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>261</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionLoad_File</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotLoadFile()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionFirst_Group</sender> + <signal>toggled(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToggleFirstPedestrianGroup()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionSecond_Group</sender> + <signal>toggled(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToggleSecondPedestrianGroup()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionThird_Group</sender> + <signal>toggled(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToggleThirdPedestrianGroup()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionAdd_Trajectories_File</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotAddDataSet()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionClear_Trajectories_Files</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotClearAllDataset()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Trajectories</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowTrajectoryOnly()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Agents</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowPedestrianOnly()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>contrastSettingSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotUpdateContrastSlider(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>201</x> + <y>191</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>speedSettingSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotUpdateSpeedSlider(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>201</x> + <y>116</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Geometry</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowGeometry()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>action2_D</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToogle2D()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>action3_D</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToogle3D()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Legend</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToogleShowLegend()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>framesIndicatorSlider</sender> + <signal>sliderMoved(int)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotUpdateFrameSlider(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>303</x> + <y>323</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>framesIndicatorSlider</sender> + <signal>sliderPressed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotFrameSliderPressed()</slot> + <hints> + <hint type="sourcelabel"> + <x>303</x> + <y>323</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>framesIndicatorSlider</sender> + <signal>sliderReleased()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotFrameSliderReleased()</slot> + <hints> + <hint type="sourcelabel"> + <x>303</x> + <y>323</y> + </hint> + <hint type="destinationlabel"> + <x>318</x> + <y>264</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionFrames_Navigation</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotFramesByFramesNavigation()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtNextFrame</sender> + <signal>clicked()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotNextFrame()</slot> + <hints> + <hint type="sourcelabel"> + <x>395</x> + <y>222</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>BtPreviousFrame</sender> + <signal>clicked()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotPreviousFrame()</slot> + <hints> + <hint type="sourcelabel"> + <x>395</x> + <y>252</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Captions</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowPedestrianCaption()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Axis</sender> + <signal>changed()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotToogleShowAxis()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCameraViewFront</sender> + <signal>triggered(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotSetCameraPerspectiveToFront()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCameraViewSide</sender> + <signal>triggered(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotSetCameraPerspectiveToSide()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCameraViewTop</sender> + <signal>triggered(bool)</signal> + <receiver>TraVisToClass</receiver> + <slot>slotSetCameraPerspectiveToTop()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionBackground_Color</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotChangeBackgroundColor()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionPedestrian_Shape</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotChangePedestrianShape()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionClear_Geometry</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotClearGeometry()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionSnapshot</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotTakeScreenShot()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionRecord_PNG_sequences</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotRecordPNGsequence()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionRender_PNG_to_AVI</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotRenderPNG2AVI()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCameraViewAgent</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotSetCameraPerspectiveToVirtualAgent()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCaptionAuto</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotCaptionColorAuto()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCaptionCustom</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotCaptionColorCustom()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionWalls_Color</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotChangeWallsColor()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionExits_Color</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotChangeExitsColor()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Onscreen_Infos</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowOnScreenInfos()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Exits</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowHideExits()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Walls</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowHideWalls()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionShow_Geometry_Captions</sender> + <signal>triggered()</signal> + <receiver>TraVisToClass</receiver> + <slot>slotShowHideGeometryCaptions()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>slotHelpAbout()</slot> + <slot>slotExit()</slot> + <slot>slotStartPlaying()</slot> + <slot>slotStopPlaying()</slot> + <slot>slotRecord()</slot> + <slot>slotReset()</slot> + <slot>slotFullScreen(bool)</slot> + <slot>slotLoadFile()</slot> + <slot>slotNetworkSettings()</slot> + <slot>slotToggleVisualisationMode()</slot> + <slot>slotFrameNumber()</slot> + <slot>slotRunningTime()</slot> + <slot>slotSetOfflineMode(bool)</slot> + <slot>slotSetOnlineMode(bool)</slot> + <slot>slotLoadGeometry()</slot> + <slot>slotToggleFirstPedestrianGroup()</slot> + <slot>slotToggleSecondPedestrianGroup()</slot> + <slot>slotToggleThirdPedestrianGroup()</slot> + <slot>slotClearAllDataset()</slot> + <slot>slotAddDataSet()</slot> + <slot>slotShowTrajectoryOnly()</slot> + <slot>slotShowPedestrianOnly()</slot> + <slot>slotUpdateSpeedSlider(int)</slot> + <slot>slotUpdateFrameSlider(int)</slot> + <slot>slotUpdateContrastSlider(int)</slot> + <slot>slotShowGeometry()</slot> + <slot>slotToogle2D()</slot> + <slot>slotToogle3D()</slot> + <slot>slotFrameSliderPressed()</slot> + <slot>slotFrameSliderReleased()</slot> + <slot>slotFrameSliderChanged()</slot> + <slot>slotToogleShowLegend()</slot> + <slot>slotFramesByFramesNavigation()</slot> + <slot>slotNextFrame()</slot> + <slot>slotPreviousFrame()</slot> + <slot>slotShowPedestrianCaption()</slot> + <slot>slotToogleShowAxis()</slot> + <slot>slotSetCameraViewAngle(bool)</slot> + <slot>slotPickBackgroundColor()</slot> + <slot>slotChangePedestrianShape()</slot> + <slot>slotUpdatePedestrianShape()</slot> + <slot>slotSetCameraPerspectiveToTop()</slot> + <slot>slotSetCameraPerspectiveToFront()</slot> + <slot>slotSetCameraPerspectiveToSide()</slot> + <slot>slotClearGeometry()</slot> + <slot>slotTakeScreenShot()</slot> + <slot>slotRecordPNGsequence()</slot> + <slot>slotRenderPNG2AVI()</slot> + <slot>slotSetCameraPerspectiveToVirtualAgent()</slot> + <slot>slotCaptionColorAuto()</slot> + <slot>slotChangeBackgroundColor()</slot> + <slot>slotChangeExitsColor()</slot> + <slot>slotChangeWallsColor()</slot> + <slot>slotShowOnScreenInfos()</slot> + <slot>slotShowHideExits()</slot> + <slot>slotShowHideWalls()</slot> + <slot>slotShowHideGeometryCaptions()</slot> + </slots> +</ui> diff --git a/object_script.TraVisTo.Debug b/object_script.TraVisTo.Debug new file mode 100644 index 0000000000000000000000000000000000000000..8ebeb9e4277eddb0cdd6f56be074ce386529ef55 --- /dev/null +++ b/object_script.TraVisTo.Debug @@ -0,0 +1,46 @@ +INPUT( +./debug\Settings.o +./debug\SaxParser.o +./debug\Debug.o +./debug\main.o +./debug\travisto.o +./debug\Frame.o +./debug\InteractorStyle.o +./debug\Pedestrian.o +./debug\SimpleVisualisationWindow.o +./debug\SyncData.o +./debug\SystemSettings.o +./debug\ThreadDataTransfert.o +./debug\ThreadVisualisation.o +./debug\TimerCallback.o +./debug\TrajectoryPoint.o +./debug\LinePlotter2D.o +./debug\PointPlotter2D.o +./debug\FacilityGeometry.o +./debug\LinePlotter.o +./debug\Point.o +./debug\PointPlotter.o +./debug\Building.o +./debug\Room.o +./debug\Line.o +./debug\Transition.o +./debug\Wall.o +./debug\CPoint.o +./debug\CLine.o +./debug\CBuilding.o +./debug\CRoom.o +./debug\CCell.o +./debug\CCoordsList.o +./debug\Common.o +./debug\CTextLog.o +./debug\CTransition.o +./debug\TraVisToServer.o +./debug\moc_Settings.o +./debug\moc_travisto.o +./debug\moc_SyncData.o +./debug\moc_ThreadDataTransfert.o +./debug\moc_ThreadVisualisation.o +./debug\moc_TimerCallback.o +./debug\moc_TraVisToServer.o +./debug\qrc_icons.o +); diff --git a/object_script.TraVisTo.Release b/object_script.TraVisTo.Release new file mode 100644 index 0000000000000000000000000000000000000000..e5593b7344cace882d790cca938d4d7c2f44362b --- /dev/null +++ b/object_script.TraVisTo.Release @@ -0,0 +1,46 @@ +INPUT( +./release\Settings.o +./release\SaxParser.o +./release\Debug.o +./release\main.o +./release\travisto.o +./release\Frame.o +./release\InteractorStyle.o +./release\Pedestrian.o +./release\SimpleVisualisationWindow.o +./release\SyncData.o +./release\SystemSettings.o +./release\ThreadDataTransfert.o +./release\ThreadVisualisation.o +./release\TimerCallback.o +./release\TrajectoryPoint.o +./release\LinePlotter2D.o +./release\PointPlotter2D.o +./release\FacilityGeometry.o +./release\LinePlotter.o +./release\Point.o +./release\PointPlotter.o +./release\Building.o +./release\Room.o +./release\Line.o +./release\Transition.o +./release\Wall.o +./release\CPoint.o +./release\CLine.o +./release\CBuilding.o +./release\CRoom.o +./release\CCell.o +./release\CCoordsList.o +./release\Common.o +./release\CTextLog.o +./release\CTransition.o +./release\TraVisToServer.o +./release\moc_Settings.o +./release\moc_travisto.o +./release\moc_SyncData.o +./release\moc_ThreadDataTransfert.o +./release\moc_ThreadVisualisation.o +./release\moc_TimerCallback.o +./release\moc_TraVisToServer.o +./release\qrc_icons.o +); diff --git a/release/TraVisTo.exe b/release/TraVisTo.exe new file mode 100644 index 0000000000000000000000000000000000000000..e45b603fde372783c53260530b0858afc16b414e Binary files /dev/null and b/release/TraVisTo.exe differ diff --git a/src/Debug.cpp b/src/Debug.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c49c7c68caf321158b46314a1cc0e376d4a2075 --- /dev/null +++ b/src/Debug.cpp @@ -0,0 +1,141 @@ +/** +* @file Debug.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief This class defines a debug output with different debug levels (similar to python). +* The message sent to the output are printed or not depending on the debug level set. +* +* +* Created on: 31.04.2010 +* +*/ + + +#include "Debug.h" + +#include <fstream> +#include <iostream> + +#include <stdio.h> +#include <stdarg.h> + +using namespace std; + +std::ostream& Debug::os=std::cerr; +Debug::LEVEL Debug::debugLevel=Debug::ERROR; +int Debug::MSG_Count=0; +int Debug::ERR_Count=0; +int Debug::WAR_Count=0; + +Debug::Debug() { + +} + +Debug::~Debug() { + +} + + +void Debug::setOutputStream(std::ostream &osl ){ + os.rdbuf(osl.rdbuf()); +} + +void Debug::setDebugLevel(Debug::LEVEL level){ + debugLevel=level; +} + +void Debug::Messages(const char *format, ...){ + + switch (debugLevel){ + + case ALL: + case INFO: + { + MSG_Count++; + char msg[256]; + va_list ap; + va_start (ap, format); + vsprintf (msg,format ,ap); + va_end (ap); + + os<<"Info["<<MSG_Count<<"]"<<msg<<endl; + } + break; + + case ERROR: + case WARNING: + case NONE: + break; + } + +} + +void Debug::Warning(const char *format, ...){ + + switch (debugLevel){ + + case WARNING: + case ALL: + { + WAR_Count++; + char msg[256]; + va_list ap; + va_start (ap, format); + vsprintf (msg,format ,ap); + va_end (ap); + os<<"Warning["<<WAR_Count<<"]"<<msg<<endl; + } + break; + + case ERROR: + case INFO: + case NONE: + break; + } +} + + +void Debug::Error(const char *format, ...){ + + switch (debugLevel){ + + case WARNING: + case ERROR : + case ALL: + { + ERR_Count++; + char msg[256]; + va_list ap; + va_start (ap, format); + vsprintf (msg,format ,ap); + va_end (ap); + os<<"Error["<<ERR_Count<<"]"<<msg<<endl; + } + break; + + case INFO: + case NONE: + break; + } + +} diff --git a/src/Debug.h b/src/Debug.h new file mode 100644 index 0000000000000000000000000000000000000000..1c647c18920ad90dca955b398f31cacfd4430ec5 --- /dev/null +++ b/src/Debug.h @@ -0,0 +1,111 @@ +/** +* @headerfile Debug.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 1.0 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief This class defines a debug output with different debug levels (similar to python). +* The message sent to the output are printed or not depending on the debug level set. +* +* +* Created on: 31.04.2010 +* +*/ + +#ifndef DEBUG_H_ +#define DEBUG_H_ + +#include <fstream> + +class Debug { +public: + + /** + * different debug levels + */ + enum LEVEL{ + NONE, //!< NONE The logger is switched off + INFO, //!< INFO debug messages only are output + WARNING, //!< WARNING warning and Errors are output + //CRITICAL,//!< CRITICAL + ERROR, //!< ERROR Only errors are output + ALL //!< ALL Performs a full logging + }; + + /** + * Constructor + */ + Debug(); + + /** + * Destructor + */ + virtual ~Debug(); + + /** + * set the debug output stream. can be a file as well + * as one of the cout, cerr, clog, ... + * Default output stream if std::cout. + * + * @param os, the output stream + */ + static void setOutputStream(std::ostream &os ); + + /** + * set the desired debug level. + * + * @see LEVEL + * + * @param level, the desired debug level + */ + static void setDebugLevel(Debug::LEVEL level); + + /** + * send a message (information) to the output stream + * + * @param string, the message + */ + static void Messages(const char *string, ...); + + /** + * add a warning to the output stream + * + * @param string, the warning message + */ + static void Warning(const char *string, ...); + + + /** + * add an error message to the output stream + * + * @param string, the error message + */ + static void Error(const char *string, ...); + +private: + static std::ostream &os; + static Debug::LEVEL debugLevel; + static int MSG_Count; + static int ERR_Count; + static int WAR_Count; +}; + +#endif /* DEBUG_H_ */ diff --git a/src/Frame.cpp b/src/Frame.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe3eee6fb0c3c4587822d8ee51b1d604b2993a84 --- /dev/null +++ b/src/Frame.cpp @@ -0,0 +1,109 @@ +/** +* @file Frame.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* this class contains the collection of all +* pedestrians coordinates (trajectoryPoint) belonging to the same frame(i.e at the same time) +* +* @brief Hold all information that will be displayed on the screen (one frame) +* +* Created on: 10.07.2009 +* +*/ + +#include <vector> +#include <iostream> + +#include "TrajectoryPoint.h" +#include "Frame.h" + +Frame::Frame() { + elementCursor=0; +} + +Frame::~Frame() { + while (!framePoints.empty()){ + delete framePoints.back(); + framePoints.pop_back(); + } + framePoints.clear(); +} + +int Frame::getSize(){ + return this->framePoints.size(); +} + +void Frame::addElement(TrajectoryPoint* point){ + framePoints.push_back(point); +} + +void Frame::clear(){ + while (!framePoints.empty()){ + delete framePoints.back(); + framePoints.pop_back(); + } + framePoints.clear(); + + elementCursor=0; +} + +TrajectoryPoint* Frame::getNextElement(){ +/* + TrajectoryPoint* res; + if(framePoints.empty()) { + return NULL; + } + else{ + res= framePoints.front(); + // dont delete the elements..... + framePoints.erase(framePoints.begin()); + return res; + } +*/ + + + + //The navigation is only allowed in one direction + // so elementCursor cannot be negative + if (elementCursor<0) { + //Debug::Messages("CURSOR VALUE(NULL): %d" ,elementCursor); + return NULL; + } + + if(elementCursor>=framePoints.size()) { + return NULL; + + }else{ + return framePoints.at(elementCursor++); + } + +} + + +unsigned int Frame::getElementCursor(){ + + return elementCursor; +} + +void Frame::resetCursor(){ + elementCursor=0; +} diff --git a/src/Frame.h b/src/Frame.h new file mode 100644 index 0000000000000000000000000000000000000000..daea38d0430c9555490b67a8737c5e0ba51490b4 --- /dev/null +++ b/src/Frame.h @@ -0,0 +1,65 @@ +/** +* @headerfile Frame.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief contains the collection of all +* pedestrians coordinates (trajectoryPoint) belonging to the same frame(i.e at the same time) +* +* Created on: 10.07.2009 +* +*/ + +#ifndef Frame_H_ +#define Frame_H_ + +class TrajectoryPoint; + +class Frame { +public: + Frame(); + virtual ~Frame(); + + /// add an element to the Frame + void addElement(TrajectoryPoint* point); + + ///clear all Points in the frame + void clear(); + + ///return the next object in the frame + TrajectoryPoint* getNextElement(); + + int getSize(); + + unsigned int getElementCursor(); + + void resetCursor(); + + +private: + std::vector <TrajectoryPoint *> framePoints; + + /// points to the actual element in the frame + unsigned int elementCursor; +}; + +#endif /* Frame_H_ */ diff --git a/src/InteractorStyle.cpp b/src/InteractorStyle.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73407d175d2893d86c9fbdf059e13f1735d7fc83 --- /dev/null +++ b/src/InteractorStyle.cpp @@ -0,0 +1,301 @@ +/** + * @file InteractorStyle.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * @brief Catch some mouse and keyboard events and redirect them (vtk stuff) + * + * + * Created on: Aug 18, 2009 + */ + +#include <vtkInteractorStyleTrackballCamera.h> +#include <vtkRenderWindowInteractor.h> +#include <vtkRenderWindow.h> +#include <vtkRendererCollection.h> +#include <vtkRenderer.h> +#include <vtkCamera.h> +#include <vtkSmartPointer.h> +#include <vtkCoordinate.h> + + +#include "SystemSettings.h" +#include "InteractorStyle.h" + +#include <iostream> + +using namespace std; + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + +InteractorStyle::InteractorStyle() { + +} + +InteractorStyle::~InteractorStyle() { + +} + +///static constructor +InteractorStyle* InteractorStyle::New() { + return new InteractorStyle(); +} + +void InteractorStyle::SetActor() { +} +; + +void InteractorStyle::SetSource() { +} +; + +//forward the event only if not in 2d mode +void InteractorStyle::Rotate() { + if(!SystemSettings::get2D()) + vtkInteractorStyleTrackballCamera::Rotate(); +} + +void InteractorStyle::Spin() { + vtkInteractorStyleTrackballCamera::Spin(); +} + +void InteractorStyle::Pan() { + vtkInteractorStyleTrackballCamera::Pan(); +} + +void InteractorStyle::Dolly() { + vtkInteractorStyleTrackballCamera::Dolly(); +} + +void InteractorStyle::OnChar() { + + vtkRenderWindowInteractor *rwi = this->Interactor; + //this->Interactor->GetRenderWindow()->GetScreenSize(); + //rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Print(std::cout); + + char ch = rwi->GetKeyCode(); + + + switch (ch) { + + case '+': + case '-': + rwi->Render(); // render - update the screen + break; + + //escape + case 27: + extern_fullscreen_enable = false; + extern_force_system_update = true; + std::cout << "esc pressed" << std::endl; + break; + + case 'a': { + double para[3]; + vtkCamera + * cam = + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera(); + cam->GetPosition(para); + //std::cout<<endl<<; + //cam->Roll(90-cam->GetRoll()); + //cam->Yaw(0); + //cam->Pitch(0); + //cam->Roll(-90); + //cam->Elevation(0); + //cam->Azimuth(0); + //std::cout <<"roll [ "<< cam->GetRoll()<<" ]"<<std::endl; + //std::cout <<"azimuth [ "<< cam->GetRoll()<<" ]"<<std::endl; + //std::cout <<"elevation [ "<< cam->GetRoll()<<" ]"<<std::endl; + //std::cout <<"roll [ "<<para[0]<<" " <<para[1] <<" "<<para[2]<<" ]"<<std::endl; + } + break; + + //zoom in + case 'n': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(1.05); + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(1.05); + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(1.05); + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(1.05); + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(1.05); + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(1.05); + break; + //zoom out + case 'N': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Zoom(0.95); + break; + + //pan + case 'b': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Roll(5.0); + //Pan(); + break; + case 'B': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Roll(-5.0); + break; + + //rotate + case 'v': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Pitch(5); + break; + case 'V': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Pitch(-5); + break; + + //dolly + case 'c': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Yaw(5); + break; + case 'C': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Yaw(-5); + break; + + //Spin + case 'x': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Elevation(5); + rwi->GetRenderWindow()->Modified(); + rwi->Render(); + break; + case 'X': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Elevation(-5); + rwi->GetRenderWindow()->Modified(); + rwi->Render(); + break; + + //Spin + case 'm': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Azimuth(5); + rwi->GetRenderWindow()->Modified(); + break; + case 'M': + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->Azimuth(-5); + rwi->GetRenderWindow()->Modified(); + break; + + + case 'h': // display camera settings + { + double para[3]; + vtkCamera + * cam = + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera(); + cam->GetPosition(para); + std::cout << endl << endl; + std::cout << "position [ " << para[0] << " " << para[1] << " " + << para[2] << " ]" << std::endl; + cam->GetFocalPoint(para); + std::cout << "focal point [ " << para[0] << " " << para[1] << " " + << para[2] << " ]" << std::endl; + cam->GetClippingRange(para); + std::cout << "clipping range [ " << para[0] << " " << para[1] << " " + << para[2] << " ]" << std::endl; + cam->GetViewPlaneNormal(para); + std::cout << "viewplan norm [ " << para[0] << " " << para[1] << " " + << para[2] << " ]" << std::endl; + + } + break; + + default: + { + std::string key = rwi->GetKeySym(); + int sensitivity=2; + double pos[3]; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->GetPosition(pos); +// printf("[%f,%f,%f]\n",pos[0],pos[1],pos[2]); + + + if(key=="Up"){ + pos[1]=pos[1]-sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],1); + + } + else if(key=="Down"){ + pos[1]=pos[1]+sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],1); + + }else if(key=="Left"){ + pos[0]=pos[0]+sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],10); + + }else if(key=="Right"){ + pos[0]=pos[0]-sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],10); + + }else if(key=="k"){ + pos[0]=pos[0]-sensitivity*10; + pos[1]=pos[1]-sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],10); + + }else if(key=="K"){ + pos[0]=pos[0]+sensitivity*10; + pos[1]=pos[1]+sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],10); + + }else if(key=="l"){ + pos[0]=pos[0]-sensitivity*10; + pos[1]=pos[1]+sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],10); + + }else if(key=="L"){ + pos[0]=pos[0]+sensitivity*10; + pos[1]=pos[1]-sensitivity*10; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetPosition(pos);; + rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->SetFocalPoint(pos[0],pos[1],10); + } + } + break; + + } + + // forward events + vtkInteractorStyleTrackballCamera::OnChar(); +} + +//http://vtk.1045678.n5.nabble.com/Coordinate-conversions-World-Display-td2808312.html +void InteractorStyle::OnLeftButtonUp(){ + + vtkRenderWindowInteractor *rwi = this->Interactor; + + int pos_x=0; + int pos_y=0; + rwi->GetMousePosition(&pos_x, &pos_y); + + VTK_CREATE(vtkCoordinate,coordinate); + coordinate->SetCoordinateSystemToDisplay(); + coordinate->SetValue(pos_x,pos_y,0); + double* world = coordinate->GetComputedWorldValue(this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()); + + std::cout<<"mouse position: " <<endl; + std::cout<<"\t screen: " <<pos_x<<" "<<pos_y<<endl; + std::cout<<"\t world : " <<world[0] << " " << world[1] << " " << world[2] << std::endl; + + // forward events for who ever needs it + vtkInteractorStyleTrackballCamera::OnLeftButtonUp(); +} diff --git a/src/InteractorStyle.h b/src/InteractorStyle.h new file mode 100644 index 0000000000000000000000000000000000000000..34cb7ca5b44c36398646329d6d9ce15015bb29a3 --- /dev/null +++ b/src/InteractorStyle.h @@ -0,0 +1,71 @@ +/** +* @headerfile InteractorStyle.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief Catch some mouse and keyboard events and redirect them (vtk stuff) +* +* +* Created on: Aug 18, 2009 +*/ + + +#ifndef INTERACTORSTYLE_H_ +#define INTERACTORSTYLE_H_ + +// Extern variables; +extern bool extern_fullscreen_enable; +extern bool extern_force_system_update; + +/// This defines the interactions between the user and the visualisation window. + +class InteractorStyle: public vtkInteractorStyleTrackballCamera { + +public: + InteractorStyle(); + virtual ~InteractorStyle(); + + /// static constructor + static InteractorStyle* New(); + + ///set the actor + void SetActor(/*vtkActor* actor*/); + ///set the source + void SetSource(/*some source*/); + + ///override + virtual void OnChar(); + virtual void Rotate(); + virtual void Spin(); + virtual void Pan(); + virtual void Dolly(); + virtual void OnLeftButtonUp(); + + + + +private: + //vtkActor* mActor ; + //vtkSphereSource* mSrc ; +}; + +#endif /* INTERACTORSTYLE_H_ */ diff --git a/src/Message.h b/src/Message.h new file mode 100644 index 0000000000000000000000000000000000000000..ad140935646c1cb9f344dc9237deefd25273f91c --- /dev/null +++ b/src/Message.h @@ -0,0 +1,47 @@ +/** +* @headerfile Message.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief contains messages that are exchanged between the different modules +* +* +* Created on: 24.08.2009 +* +*/ + +#ifndef MESSAGE_H_ +#define MESSAGE_H_ + +class Message { + +public : + enum message {STACK_EMPTY=1, + STACK_REACHS_BEGINNING, + STACK_REACHS_END, + RESET, + VISUALISATION_TERMINATED + + }; +}; + +#endif /* MESSAGE_H_ */ diff --git a/src/Pedestrian.cpp b/src/Pedestrian.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2cad38822516e7021732c6e475a9520314fbfd83 --- /dev/null +++ b/src/Pedestrian.cpp @@ -0,0 +1,1611 @@ +/** + * @file Pedestrian.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * @brief + * + * Created on: 05.05.2009 + * + */ + +// paraview tutorial for glyph +//http://www.mail-archive.com/paraview@paraview.org/msg02142.html + +#include "Pedestrian.h" +#include "geometry/Point.h" +#include "geometry/PointPlotter.h" +#include "geometry/LinePlotter.h" +#include "forms/Settings.h" +#include "SystemSettings.h" +#include "TrajectoryPoint.h" + + +#include <vtkActor.h> +#include <vtkCylinderSource.h> +#include <vtkPolyDataMapper.h> +#include <vtkSphereSource.h> +#include <vtkDiskSource.h> +#include <vtkConeSource.h> +#include <vtkProperty.h> +#include <vtkAssembly.h> +#include <vtkMath.h> +#include <vtkLookupTable.h> +#include <vtkTextActor3D.h> +#include <vtkTextProperty.h> +#include <vtkCamera.h> +#include <vtkSmartPointer.h> + +#include <cmath> + + + +vtkCamera* Pedestrian::virtualCam; + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + +using namespace std; +/** + * class Constructor + * @param ID the pedestrian ID + * @param posX the initial x coordinate + * @param posY the initial y coordinate + * @param posZ the initial z coordinate + */ +Pedestrian::Pedestrian(int ID,double posX, double posY, double posZ) { + this->ID = ID; + this->posZ=posZ; + this->posX=posX; + this->posY=posY; + this->pedSize=160; // 160 cm + + this->spaceNeeded=NULL; + //this->assembly=NULL; + this->ellipseActor=NULL; + this->trailActor=NULL; + this->pedestrianAssembly=NULL; + this->assembly3D=NULL; + this->assembly2D=NULL; + this->groupVisibilityStatus=true; + this->trailPlotterLine=NULL; + this->trailPlotterPoint=NULL; + this->caption=NULL; + this->bodyActor=NULL; + this->autoCaptionColorMode=true; + trailPoint.reserve(100); + +} + +/** + * Parameters less constructor + */ + +Pedestrian::Pedestrian(int ID){ + + Pedestrian(ID,0,0,0); +} + +/** + * class Destructor + * + */ +Pedestrian::~Pedestrian() { + + if(assembly2D) + assembly2D->Delete(); + + if(assembly3D) + assembly3D->Delete(); + + if(spaceNeeded) + spaceNeeded->Delete(); + + if(ellipseActor) + ellipseActor->Delete(); + + if(trailActor) + trailActor->Delete(); + + + + // int i=0; + //free all memory + + //virtualCam->Delete(); + if(bodyActor) + bodyActor->Delete(); + if(caption) + caption->Delete(); + + while(!trailPoint.isEmpty()){ + delete trailPoint.pop(); + } + if(trailPlotterPoint) + delete trailPlotterPoint; + if(trailPlotterLine) + delete trailPlotterLine; +} + +/** + * + * @return the pedestrian ID + */ +int Pedestrian::getID() { + return ID; +} + +/** + * + * @return the x-coordinate of the pedestrians + */ +double Pedestrian::getX() { + return posX; +} +/** + * + * @return the y-coordinate of the pedestrian + */ +double Pedestrian::getY() { + return posY; +} +/** + * + * @return the z-coordinate of the pedestrian + */ +double Pedestrian::getZ() { + return posZ; +} + +/*** + * create the trail and its actor + */ +void Pedestrian::createTrailActor() { + trailPlotterPoint = new PointPlotter(); + trailPlotterLine = new LinePlotter(); + trailActor = vtkAssembly::New(); + //VTK_CREATE(vtkAssembly,trailActor); + trailActor->AddPart(trailPlotterPoint->getActor()); + trailActor->AddPart(trailPlotterLine->getActor()); +} + +/** + * creates and returns a plot actor for the actual + * pedestrian + * + */ +void Pedestrian::createActor(){ + //createSnowMan(); + //return; + + if(SystemSettings::get2D()){ + CreateActor2D(); + pedestrianAssembly=assembly2D; + } + else + { + CreateActor3D(); + pedestrianAssembly=assembly3D; + } +} + +//create the 2D assembly +void Pedestrian::CreateActor2D(){ + double headRadius = 10.0; + double ambient=0.15; + double diffuse=1; + double specular=1; + + assembly2D = vtkAssembly::New(); + + {//private sphere + spaceNeeded = vtkDiskSource::New(); + //spaceNeeded->SetRadialResolution(30); + spaceNeeded->SetCircumferentialResolution(5); + spaceNeeded->SetInnerRadius(0); + //spaceNeeded->SetOuterRadius(bodyRadius); + spaceNeeded->SetOuterRadius(2); + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(spaceNeeded->GetOutputPort()); + //spaceNeeded->Delete(); + ellipseActor = vtkActor::New(); + ellipseActor->SetMapper(mapper); + mapper->Delete(); + // they all start with red color. + ellipseActor->GetProperty()->SetColor(1.0,0.0,0.0); + + //set the ellipse a little bit higher than the ground to + // eliminate interaction with the floor color. + ellipseActor->SetPosition(0,0,7); + // actor->GetProperty()->SetSpecular(specular); + // actor->GetProperty()->SetDiffuse(diffuse); + // actor->GetProperty()->SetAmbient(ambient); + + // this actor belongs to both 2D and 3D + //assembly3D->AddPart(ellipseActor); + assembly2D->AddPart(ellipseActor); + //ellipseActor->Delete(); + + //lookup table + vtkLookupTable* lut = vtkLookupTable::New(); + lut->SetHueRange(0.0,0.470); + //lut->SetSaturationRange(0,0); + lut->SetValueRange(1.0,1.0); + lut->SetNumberOfTableValues(256); + lut->Build(); + mapper->SetLookupTable(lut); + lut->Delete(); + } + +// {//head +// {//face +// // vtkSphereSource* head = vtkSphereSource::New(); +// VTK_CREATE(vtkSphereSource,head); +// head->SetThetaResolution(20); +// head->SetStartTheta(270); +// head->SetEndTheta(90); +// head->SetRadius(headRadius); +// //head->SetCenter(0,0,bodyRadius+2); +// //head->SetCenter(0,0,pedSize+2); +// // create mapper +// VTK_CREATE(vtkPolyDataMapper,mapper); +// // vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); +// mapper->SetInputConnection(head->GetOutputPort()); +// //head->Delete(); +// //mapper->SetColorModeToMapScalars(); +// //mapper->SetScalarModeToUsePointData(); +// +// // create actor +// // vtkActor* actor = vtkActor::New(); +// VTK_CREATE(vtkActor,actor); +// actor->SetMapper(mapper); +// //mapper->Delete(); +// actor->GetProperty()->SetColor(.90,.90,1.0); +// actor->GetProperty()->SetSpecular(specular); +// actor->GetProperty()->SetDiffuse(diffuse); +// actor->GetProperty()->SetAmbient(ambient-.10); +// +// assembly2D->AddPart(actor); +// //actor->Delete(); +// } +// //back +// { +// //vtkSphereSource* head = vtkSphereSource::New(); +// VTK_CREATE(vtkSphereSource,head); +// head->SetThetaResolution(20); +// head->SetStartTheta(90); +// head->SetEndTheta(270); +// head->SetRadius(headRadius); +// //head->SetCenter(0,0,pedSize+2); +// // create mapper +// VTK_CREATE(vtkPolyDataMapper,mapper); +// +// // vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); +// mapper->SetInputConnection(head->GetOutputPort()); +// //head->Delete(); +// //mapper->SetColorModeToMapScalars(); +// //mapper->SetScalarModeToUsePointData(); +// +// // create actor +// // vtkActor* actor = vtkActor::New(); +// VTK_CREATE(vtkActor,actor); +// +// actor->SetMapper(mapper); +// //mapper->Delete(); +// actor->GetProperty()->SetColor(0.35,0.35,0.35); +// actor->GetProperty()->SetSpecular(specular); +// actor->GetProperty()->SetDiffuse(diffuse); +// actor->GetProperty()->SetAmbient(ambient-.10); +// +// assembly2D->AddPart(actor); +// //actor->Delete(); +// } +//} + {//caption + + char txt[10]; + sprintf(txt,"%d",this->ID+1); + caption = vtkTextActor3D ::New(); + caption->SetVisibility(false); + caption->SetInput(txt); + // set the properties of the caption + //FARBE + vtkTextProperty* tprop = caption->GetTextProperty(); + tprop->SetFontFamilyToArial(); + tprop->BoldOn(); + //tprop->ShadowOn(); + tprop->SetLineSpacing(1.0); + tprop->SetFontSize(SystemSettings::getPedestrianCaptionSize()); + + tprop->SetColor(0.0,0.0,0.0); + //tprop->SetShadowOffset(2,2); + + caption->SetPosition( 0, 0,20); //20 cm on the ground + assembly2D->AddPart(caption); + + } + assembly2D->SetPosition( posX, posY, posZ); +} + +void Pedestrian::CreateActor3D(){ + double bodyRadius = 20.0; + double headRadius = 8.0; + double chestThikness=20.0/1.0; + double ambient=0.15; + double diffuse=1; + double specular=1; + + assembly3D = vtkAssembly::New(); + + + { //body + vtkSphereSource* body = vtkSphereSource::New(); + body->SetEndPhi(90.0); + body->SetStartPhi(0); + body->SetThetaResolution(10); + body->SetRadius(bodyRadius); + + // create mapper + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(body->GetOutputPort()); + body->Delete(); + // create actor + double er[]={chestThikness/bodyRadius,1,pedSize/bodyRadius}; + //double er[]={bodyRadius/bodyRadius,pedSize/bodyRadius,chestThikness/bodyRadius}; + + bodyActor = vtkActor::New(); + bodyActor->SetMapper(mapper); + mapper->Delete(); + bodyActor->SetScale(er); + //bodyActor->GetProperty()->SetColor(pedsColors); + bodyActor->GetProperty()->SetColor(pedsColors[0]/255.0,pedsColors[1]/255.0,pedsColors[2]/255.0); + + //actor->GetProperty()->SetLighting(true); + bodyActor->GetProperty()->SetSpecular(specular); + bodyActor->GetProperty()->SetDiffuse(diffuse); + bodyActor->GetProperty()->SetAmbient(ambient); + + //cout << "diffuse: "<<actor->GetProperty()->GetDiffuse()<<" [" << actor->GetProperty()->GetDiffuseMinValue()<<" , "<<actor->GetProperty()->GetDiffuseMaxValue() << " ]"<<endl; + //cout << "ambiant: "<<actor->GetProperty()->GetAmbient()<<" [" << actor->GetProperty()->GetAmbientMinValue()<<" , "<<actor->GetProperty()->GetAmbientMaxValue() << " ]"<<endl; + //cout << "specular:"<<actor->GetProperty()->GetSpecular()<<" [" << actor->GetProperty()->GetSpecularMinValue()<<" , "<<actor->GetProperty()->GetSpecularMaxValue()<< " ]"<<endl; + assembly3D->AddPart(bodyActor); + //bodyActor->Delete(); + } + {//caption + + char txt[10]; + sprintf(txt,"%d",this->ID+1); + caption = vtkTextActor3D ::New(); + caption->SetVisibility(false); + caption->SetInput(txt); + // set the properties of the caption + //FARBE + vtkTextProperty* tprop = caption->GetTextProperty(); + tprop->SetFontFamilyToArial(); + tprop->BoldOn(); + //tprop->ShadowOn(); + tprop->SetLineSpacing(1.0); + tprop->SetFontSize(SystemSettings::getPedestrianCaptionSize()); + + tprop->SetColor(0.0,0.0,0.0); + //tprop->SetShadowOffset(2,2); + + //vtkActor2D* test=vtkActor2D::New(); + //assembly3D->AddPart(test); + //rotate the caption + //caption->RotateX(90); + caption->SetPosition( 0, 0,pedSize+20); + assembly3D->AddPart(caption); + + } + { //head + {//face + vtkSphereSource* head = vtkSphereSource::New(); + head->SetThetaResolution(5); + head->SetStartTheta(270); + head->SetEndTheta(90); + head->SetRadius(headRadius); + //head->SetCenter(0,0,bodyRadius+2); + head->SetCenter(0,0,pedSize+2); + // create mapper + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(head->GetOutputPort()); + head->Delete(); + //mapper->SetColorModeToMapScalars(); + //mapper->SetScalarModeToUsePointData(); + + // create actor + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(.90,.90,1.0); + actor->GetProperty()->SetSpecular(specular); + actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient-.10); + + assembly3D->AddPart(actor); + actor->Delete(); + } + //back + { + vtkSphereSource* head = vtkSphereSource::New(); + head->SetThetaResolution(5); + head->SetStartTheta(90); + head->SetEndTheta(270); + head->SetRadius(headRadius); + head->SetCenter(0,0,pedSize+2); + // create mapper + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(head->GetOutputPort()); + head->Delete(); + //mapper->SetColorModeToMapScalars(); + //mapper->SetScalarModeToUsePointData(); + + // create actor + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(0.35,0.35,0.35); + actor->GetProperty()->SetSpecular(specular); + actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient-.10); + + assembly3D->AddPart(actor); + actor->Delete(); + } + + } + { //Nose + vtkConeSource* nose = vtkConeSource::New(); + nose->SetCenter((headRadius+nose->GetHeight()/2) ,0,pedSize+2); + nose->SetHeight(2); + nose->SetRadius(.5); + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(nose->GetOutputPort()); + nose->Delete(); + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(1.0,1.0,0.0); + actor->GetProperty()->SetSpecular(specular); + actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient); + + assembly3D->AddPart(actor); + actor->Delete(); + } + + //assembly3D->SetScale(2.500); + assembly3D->RotateZ(0.0); + assembly3D->SetPosition( posX, posY, posZ); +} + +/** + * creates a snow man :) + * pedestrian + * + */ +void Pedestrian::createSnowMan(){ + this->pedSize=100; // very small snowman + double bodyRadius = 30.0; + double headRadius = 10.0; + double headCenter[3]={0,0,pedSize-headRadius+5}; + double chestCenter[3]={0,0,0}; + double bodyCenter[3]={0,0,0}; + double chestRadius= 20.0; + double ambient=0.15; + double diffuse=1; + double specular=1; + + //double eyeColor[3]={217.0/255,110.0/255,163.0/255}; + + double eyeColor[3]={100.0/255,100.0/255,100.0/255}; + + double mouthColor[3]={204.0/255,51.0/255,51.0/255}; + double hatColor[3]={0.8,0.8,0.8}; + + assembly3D = vtkAssembly::New(); + assembly2D = vtkAssembly::New(); + + { // hat + double pos[3]; + { + VTK_CREATE(vtkCylinderSource,src); + src->SetHeight(20); + src->SetRadius(8); + src->SetResolution(20); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->SetPosition(0, 0,pedSize+(src->GetHeight()/2)); + actor->GetProperty()->SetColor(hatColor); + actor->RotateX(90); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + actor->GetPosition(pos); + } + { + VTK_CREATE(vtkCylinderSource,src); + src->SetHeight(2); + src->SetRadius(8.1); + src->SetResolution(20); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->SetPosition(pos); + actor->GetProperty()->SetColor(1,0.1,0.1); + actor->RotateX(90); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + { + VTK_CREATE(vtkCylinderSource,src); + src->SetHeight(1); + src->SetRadius(15); + src->SetResolution(20); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->SetPosition(0, 0, pedSize); + actor->GetProperty()->SetColor(hatColor); + actor->RotateX(90); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + } + + + { //head + {//face + vtkSphereSource* head = vtkSphereSource::New(); + head->SetThetaResolution(5); + head->SetStartTheta(270); + head->SetEndTheta(90); + head->SetRadius(headRadius); + // create mapper + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(head->GetOutputPort()); + head->Delete(); + + // create actor + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(.90,.90,1.0); + actor->SetPosition(headCenter); + //actor->GetProperty()->SetSpecular(specular); + //actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient); + + assembly3D->AddPart(actor); + actor->Delete(); + } + //back + { + vtkSphereSource* head = vtkSphereSource::New(); + head->SetThetaResolution(5); + head->SetStartTheta(90); + head->SetEndTheta(270); + head->SetRadius(headRadius); + // create mapper + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(head->GetOutputPort()); + head->Delete(); + + // create actor + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(0.935,0.935,0.935); + //actor->GetProperty()->SetSpecular(specular); + //actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient); + actor->SetPosition(headCenter); + + assembly3D->AddPart(actor); + actor->Delete(); + } + + { // eyes + float pi_over_4=0.6; + float radius=headRadius-2; + + {//left eye + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(2); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(eyeColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(radius*cos(pi_over_4),radius*sin(pi_over_4),headCenter[2]); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + + {//right eye + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(2); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(eyeColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + //actor->SetPosition(radius*sin(3*pi_over_4),radius*cos(3*pi_over_4),headCenter[2]); + + actor->SetPosition(radius*cos(-pi_over_4),radius*sin(-pi_over_4),headCenter[2]); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + + } + + { //Nose + vtkConeSource* nose = vtkConeSource::New(); + nose->SetHeight(8); + nose->SetRadius(2); + nose->SetResolution(30); + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(nose->GetOutputPort()); + nose->Delete(); + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(1.0,154.0/255.0,0.0); + //actor->GetProperty()->SetSpecular(specular); + //actor->GetProperty()->SetDiffuse(diffuse); + //actor->GetProperty()->SetAmbient(ambient); + actor->SetPosition((headRadius) ,0,pedSize-headRadius+2); + + assembly3D->AddPart(actor); + actor->Delete(); + } + + {//mouth + + {//first + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(0.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(135.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {//second + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(10.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(130.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {//third + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(-10.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(130.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {//fourth + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(20.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(125.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {//fifth + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(-20.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(125.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {//sixth + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(25.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(115.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {//seventh + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(-25.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(115.0); // 0 to 180 + + pos[0]=headCenter[0]+headRadius*sin(theta)*cos(phi); + pos[1]=headCenter[1]+headRadius*sin(theta)*sin(phi); + pos[2]=headCenter[2]+headRadius*cos(theta); + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(1); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(mouthColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + + } + } + + {// chest + { + vtkSphereSource* src = vtkSphereSource::New(); + src->SetRadius(chestRadius); + src->SetThetaResolution(10); + src->SetPhiResolution(10); + + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(src->GetOutputPort()); + src->Delete(); + + vtkActor* actor = vtkActor::New(); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(1,1,1); + actor->GetProperty()->SetAmbient(ambient); + //actor->GetProperty()->SetDiffuse(0.0); + float scale=0.90; + actor->SetScale(1,1,scale); + actor->SetPosition(0,0,headCenter[2]-headRadius-chestRadius*scale+2); + actor->GetPosition(chestCenter); + + actor->SetMapper(mapper); + mapper->Delete(); + assembly3D->AddPart(actor); + actor->Delete(); + } + {// first knob 1 + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(0.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(30.0); // 0 to 180 + + pos[0]=chestCenter[0]+chestRadius*sin(theta)*cos(phi); + pos[1]=chestCenter[1]+chestRadius*sin(theta)*sin(phi); + pos[2]=chestCenter[2]+chestRadius*cos(theta)-2; + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(2); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(eyeColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {// first knob 2 + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(0.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(60.0); // 0 to 180 + + pos[0]=chestCenter[0]+chestRadius*sin(theta)*cos(phi); + pos[1]=chestCenter[1]+chestRadius*sin(theta)*sin(phi); + pos[2]=chestCenter[2]+chestRadius*cos(theta)-2; + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(2); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(eyeColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {// first knob 3 + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(0.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(90.0); // 0 to 180 + + pos[0]=chestCenter[0]+chestRadius*sin(theta)*cos(phi); + pos[1]=chestCenter[1]+chestRadius*sin(theta)*sin(phi); + pos[2]=chestCenter[2]+chestRadius*cos(theta)-0; + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(2); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(eyeColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + {// first knob 4 + double pos[3]; + float phi=vtkMath::RadiansFromDegrees(0.0); // 0 to 360 + float theta=vtkMath::RadiansFromDegrees(120.0); // 0 to 180 + + pos[0]=chestCenter[0]+chestRadius*sin(theta)*cos(phi); + pos[1]=chestCenter[1]+chestRadius*sin(theta)*sin(phi); + pos[2]=chestCenter[2]+chestRadius*cos(theta)-0; + + VTK_CREATE(vtkSphereSource,src); + src->SetRadius(2); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->GetProperty()->SetColor(eyeColor); + //actor->GetProperty()->SetAmbient(0.2); + //actor->GetProperty()->SetDiffuse(0.8); + actor->SetPosition(pos); + + actor->SetMapper(mapper); + assembly3D->AddPart(actor); + } + + } + { //body + vtkSphereSource* body = vtkSphereSource::New(); + //body->SetEndPhi(90.0); + //body->SetStartPhi(0); + body->SetThetaResolution(10); + body->SetThetaResolution(10); + + body->SetRadius(bodyRadius); + + // create mapper + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(body->GetOutputPort()); + body->Delete(); + // create actor + //double er[]={chestThikness/bodyRadius,1,pedSize/bodyRadius}; + //double er[]={bodyRadius/bodyRadius,pedSize/bodyRadius,chestThikness/bodyRadius}; + + bodyCenter[2]=chestCenter[2]-chestRadius-body->GetRadius()+10; + + bodyActor = vtkActor::New(); + bodyActor->SetMapper(mapper); + mapper->Delete(); + bodyActor->SetScale(1,1,0.90); + // bodyActor->GetProperty()->SetColor(pedsColors[0]/255.0,pedsColors[1]/255.0,pedsColors[2]/255.0); + bodyActor->GetProperty()->SetColor(1,1,1); + + //actor->GetProperty()->SetLighting(true); + //bodyActor->GetProperty()->SetSpecular(specular); + //bodyActor->GetProperty()->SetDiffuse(diffuse); + bodyActor->GetProperty()->SetAmbient(ambient); + bodyActor->SetPosition(0,0,bodyCenter[2]); + + assembly3D->AddPart(bodyActor); + } + + + + assembly3D->SetPosition( posX, posY, posZ); + + //create the 2D assembly + {//private sphere + spaceNeeded = vtkDiskSource::New(); + //spaceNeeded->SetRadialResolution(30); + spaceNeeded->SetCircumferentialResolution(5); + spaceNeeded->SetInnerRadius(0); + //spaceNeeded->SetOuterRadius(bodyRadius); + spaceNeeded->SetOuterRadius(2); + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(spaceNeeded->GetOutputPort()); + //spaceNeeded->Delete(); + ellipseActor = vtkActor::New(); + ellipseActor->SetMapper(mapper); + mapper->Delete(); + // they all start with red color. + ellipseActor->GetProperty()->SetColor(1.0,0.0,0.0); + + //set the ellipse a little bit higher than the ground to + // eliminate interaction with the floor color. + ellipseActor->SetPosition(0,0,47); + + // this actor belongs to both 2D and 3D + //assembly3D->AddPart(ellipseActor); + assembly2D->AddPart(ellipseActor); + //ellipseActor->Delete(); + + //lookup table + vtkLookupTable* lut = vtkLookupTable::New(); + lut->SetHueRange(0.0,0.470); + //lut->SetSaturationRange(0,0); + lut->SetValueRange(1.0,1.0); + lut->SetNumberOfTableValues(256); + lut->Build(); + mapper->SetLookupTable(lut); + lut->Delete(); + } + + {//head + {//face + VTK_CREATE(vtkSphereSource,head); + head->SetThetaResolution(20); + head->SetStartTheta(270); + head->SetEndTheta(90); + head->SetRadius(headRadius); + //head->SetCenter(0,0,bodyRadius+2); + //head->SetCenter(0,0,pedSize+2); + // create mapper + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(head->GetOutputPort()); + + // create actor + VTK_CREATE(vtkActor,actor); + actor->SetMapper(mapper); + //mapper->Delete(); + actor->GetProperty()->SetColor(.90,.90,1.0); + actor->GetProperty()->SetSpecular(specular); + actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient-.10); + + //assembly2D->AddPart(actor); + //actor->Delete(); + } + //back + { + VTK_CREATE(vtkSphereSource,head); + head->SetThetaResolution(20); + head->SetStartTheta(90); + head->SetEndTheta(270); + head->SetRadius(headRadius); + //head->SetCenter(0,0,pedSize+2); + // create mapper + VTK_CREATE(vtkPolyDataMapper,mapper); + + mapper->SetInputConnection(head->GetOutputPort()); + + // create actor + VTK_CREATE(vtkActor,actor); + + actor->SetMapper(mapper); + //mapper->Delete(); + actor->GetProperty()->SetColor(0.35,0.35,0.35); + actor->GetProperty()->SetSpecular(specular); + actor->GetProperty()->SetDiffuse(diffuse); + actor->GetProperty()->SetAmbient(ambient-.10); + + //assembly2D->AddPart(actor); + //actor->Delete(); + } + + assembly2D->SetPosition( posX, posY, posZ); + } + + {//caption + + char txt[10]; + sprintf(txt,"%d",this->ID+1); + caption = vtkTextActor3D ::New(); + caption->SetVisibility(false); + caption->SetInput(txt); + // set the properties of the caption + //FARBE + vtkTextProperty* tprop = caption->GetTextProperty(); + tprop->SetFontFamilyToArial(); + tprop->BoldOn(); + //tprop->ShadowOn(); + tprop->SetLineSpacing(1.0); + tprop->SetFontSize(SystemSettings::getPedestrianCaptionSize()); + + tprop->SetColor(0.0,0.0,0.0); + //tprop->SetShadowOffset(2,2); + if(SystemSettings::get2D()){ + caption->SetPosition( 0, 0,20); //20 cm on the ground + //assembly2D->AddPart(caption); + + }else{ + //vtkActor2D* test=vtkActor2D::New(); + //assembly3D->AddPart(test); + + //rotate the caption + //caption->RotateX(90); + caption->SetPosition( 0, 0,pedSize+20); + //assembly3D->AddPart(caption); + } + + } + if(SystemSettings::get2D())pedestrianAssembly=assembly2D; + else pedestrianAssembly=assembly3D; +} + + +void Pedestrian::setColor(int color[3]){ + pedsColors[0]=color[0]; + pedsColors[1]=color[1]; + pedsColors[2]=color[2]; + + if(bodyActor!=NULL) + // bodyActor->GetProperty()->SetColor(pedsColors); + bodyActor->GetProperty()->SetColor(pedsColors[0]/255.0,pedsColors[1]/255.0,pedsColors[2]/255.0); + +} + +void Pedestrian::setColor(int color){ + // ich klaue mal die Farbe von der Ellipse + if(bodyActor!=NULL){ + double *col =ellipseActor->GetMapper()->GetLookupTable()->GetColor((double)color/255.0); + bodyActor->GetProperty()->SetColor(col); + }else{ + //lookup table + vtkLookupTable* lut = vtkLookupTable::New(); + lut->SetHueRange(0.0,0.470); + //lut->SetSaturationRange(0,0); + lut->SetValueRange(1.0,1.0); + lut->SetNumberOfTableValues(256); + lut->Build(); + + lut->GetColor((double)color/255.0,pedsColors); + pedsColors[0]*=255; + pedsColors[1]*=255; + pedsColors[2]*=255; + } +} + +/// returns the actor to the pedestrians. +/// creates one if not existing +vtkAssembly * Pedestrian::getActor(){ + if(pedestrianAssembly==NULL) createActor(); + //if(pedestrianAssembly==NULL) createSnowMan(); + return pedestrianAssembly; + +} +/// returns the actor to the pedestrians trail. +/// creates one if inexisting +vtkAssembly * Pedestrian::getTrailActor(){ + if(trailActor==NULL) createTrailActor(); + return trailActor; + +} + +/** + * + * move the pedestrian to its new position + */ + +void Pedestrian::moveTo(TrajectoryPoint *point) { + + double xNew = point->getX(); + double yNew = point->getY(); + double zNew = point->getZ(); + double ellipse[7]; + double agentColorAngle[2]; + + point->getEllipse(ellipse); + point->getAgentInfo(agentColorAngle); + + // this are radius + double ellipseColor=1; //red + + // scaling the disk to an ellipse + // radiusA and radiusB are given + if( !( isnan(ellipse[3])|| isnan(ellipse[4])) ){ + + //TODO: this wont be necessary when they stop explode + // dont allow ellipse greater than 1 meter + ellipse[3]= (ellipse[3]>100)?100:ellipse[3]; + ellipse[4]= (ellipse[4]>100)?100:ellipse[4]; + + double radius = spaceNeeded->GetOuterRadius(); + double scale[3] = { ellipse[3] / radius, ellipse[4] / radius, 1 }; + ellipseActor->SetScale(scale); + + //color is not given + if( isnan(ellipse[6])){ + double maxEllipseDiameter = 40; + double minEllipseDiameter = 1; + + ellipseColor= (ellipse[4]+ellipse[3])/2.0; + ellipseColor = (ellipseColor - minEllipseDiameter) / (maxEllipseDiameter - minEllipseDiameter); + }else{ + ellipseColor=ellipse[6]/255; + } + } + + //todo: could make this variable global to use with trails + double *elColorRGB = ellipseActor->GetMapper()->GetLookupTable()->GetColor(ellipseColor); + ellipseActor->GetProperty()->SetColor(elColorRGB); + + + //default agent orientation + double pedestrianOrientation = vtkMath::DegreesFromRadians(atan2((yNew - posY), (xNew + - posX)));//-lastRotationAngle; + if (pedestrianOrientation < 0) + pedestrianOrientation += 360.0; + + if(isnan(agentColorAngle[1])==false){ //agent orientation + pedestrianOrientation=agentColorAngle[1]; + } + + // this is useful when the system is paused. + // cuz moveTo is still called, just with the same coordinates + if ((posX != xNew) || (posY != yNew) || (posZ!=zNew)) { + double ori[3]; + pedestrianAssembly->GetOrientation(ori); + pedestrianAssembly->RotateZ(pedestrianOrientation-ori[2]); + + //adjust the caption + if(autoCaptionColorMode){ + vtkTextProperty* tprop = caption->GetTextProperty(); + tprop->SetColor(1-elColorRGB[0],1-elColorRGB[1],1-elColorRGB[2]); + } + } + //set the new position + pedestrianAssembly->SetPosition(xNew, yNew, zNew); + + // ellipse are only available in 2D mode and the centre coordinates may be different + // from the head\s one + if(SystemSettings::get2D()){ + //the ellipses are not "on" the floor, but slightly over , thats why +1 is added to z; + ellipseActor->SetPosition(ellipse[0]-xNew,ellipse[1]-yNew,ellipse[2]-zNew+2); + } + + + + //adjust the camera + if(ID==SystemSettings::getVirtualAgent()){ + + static bool cam=true; + virtualCam->SetPosition(posX+15,posY,posZ+pedSize+8); + + //new focal point + float eyeRange=150;//15m + + //float angle=vtkMath::RadiansFromDegrees(pedestrianOrienation); + //float x=posX+eyeRange*cos(angle); + // float y=posY+eyeRange*sin(angle); + virtualCam->SetFocalPoint(xNew+15,yNew,zNew+pedSize+8); + //virtualCam->SetFocalPoint(x,y,zNew+pedSize+8); + //virtualCam->Azimuth(pedestrianOrienation); + //virtualCam->Azimuth(pedestrianOrienation); + //virtualCam->Yaw(pedestrianOrienation); + virtualCam->SetDistance(eyeRange); + //virtualCam->SetDir + if(cam)virtualCam->SetRoll(90); + cam=false; + virtualCam->Modified(); + + } + // save the actual position + // needed for computing the rotation angle if missing + posX = xNew; + posY = yNew; + posZ = zNew; + pedestrianAssembly->SetVisibility(groupVisibilityStatus); + + trailActor->SetVisibility(groupVisibilityStatus & extern_tracking_enable); + triggerPlotTrail(); + +} +///** +// * +// * move the pedestrian to its new position +// */ +// +//void Pedestrian::moveTo(TrajectoryPoint *point) { +// +// double xNew = point->getX(); +// double yNew = point->getY(); +// double zNew = point->getZ(); +// double ellipse[7]; +// double agentColorAngle[2]; +// +// point->getEllipse(ellipse); +// point->getAgentInfo(agentColorAngle); +// +// // this are radius +// const double maxEllipseDiameter = 40; +// const double minEllipseDiameter = 1; +// double ellipseColor=1; //red +// +// +// // scaling the disk to an ellipse +// // radiusA and radiusB are given +// if( !( isnan(ellipse[3])|| isnan(ellipse[4])) ){ +// +// //TODO: FIXME: this wont be necessary when they stop explode +// ellipse[3]= (ellipse[3]>100)?100:ellipse[3]; +// ellipse[4]= (ellipse[4]>100)?100:ellipse[4]; +// +// double radius = spaceNeeded->GetOuterRadius(); +// double scale[3] = { ellipse[3] / radius, ellipse[4] / radius, 1 }; +// ellipseActor->SetScale(scale); +// +// //color is not given +// if( isnan(ellipse[6])){ +// ellipseColor= (ellipse[4]+ellipse[3])/2.0; +// ellipseColor = (ellipseColor - minEllipseDiameter) / (maxEllipseDiameter - minEllipseDiameter); +// }else{ +// ellipseColor=ellipse[6]/255; +// } +// } +// +// //todo: could make this variable global to use with trails +// double *elColorRGB = ellipseActor->GetMapper()->GetLookupTable()->GetColor(ellipseColor); +// ellipseActor->GetProperty()->SetColor(elColorRGB); +// +// +// //default agent orientation +// double defaultOrientation = vtkMath::DegreesFromRadians(atan2((yNew - posY), (xNew +// - posX)));//-lastRotationAngle; +// if (defaultOrientation < 0) +// defaultOrientation += 360.0; +// +// double pedestrianOrienation=defaultOrientation-lastPedestrianOrientation; +// if(! isnan(agentColorAngle[1])) //agent orientation +// pedestrianOrienation=agentColorAngle[1]; +// +// double ellipseOrientation =pedestrianOrienation;//default +// if(!( isnan(ellipse[5]))) //ellipse orientation +// ellipseOrientation= ellipse[5]; +// +// // this is useful when the system is paused. +// // cuz moveTo is still called, just with the same coordinates +// if ((posX != xNew) || (posY != yNew) || (posZ!=zNew)) { +// pedestrianAssembly->RotateZ(pedestrianOrienation); +// //the ellipse should rotate independently to the agent +// lastPedestrianOrientation=defaultOrientation; +// ellipseActor->RotateZ(ellipseOrientation-pedestrianOrienation-lastEllipseOrientation); +// lastEllipseOrientation=ellipseOrientation; +// +// //adjust the caption +// caption->RotateZ(-pedestrianOrienation); +// if(autoCaptionColorMode){ +// vtkTextProperty* tprop = caption->GetTextProperty(); +// tprop->SetColor(1-elColorRGB[0],1-elColorRGB[1],1-elColorRGB[2]); +// } +// } +// //set the new position +// pedestrianAssembly->SetPosition(xNew, yNew, zNew); +// +// // ellipse are only available in 2D mode and the centre coordinates may be different +// // from the head\s one +// if(SystemSettings::get2D()){ +// //the ellipses are not "on" the floor, but slightly over , thats why +1 is added to z; +// ellipseActor->SetPosition(ellipse[0]-xNew,ellipse[1]-yNew,ellipse[2]-zNew+2); +// } +// +// +// +// //adjust the camera +// if(ID==SystemSettings::getVirtualAgent()){ +// +// static bool cam=true; +// virtualCam->SetPosition(posX+15,posY,posZ+pedSize+8); +// +// //new focal point +// float eyeRange=150;//15m +// +// //float angle=vtkMath::RadiansFromDegrees(pedestrianOrienation); +// //float x=posX+eyeRange*cos(angle); +// // float y=posY+eyeRange*sin(angle); +// virtualCam->SetFocalPoint(xNew+15,yNew,zNew+pedSize+8); +// //virtualCam->SetFocalPoint(x,y,zNew+pedSize+8); +// //virtualCam->Azimuth(pedestrianOrienation); +// //virtualCam->Azimuth(pedestrianOrienation); +// //virtualCam->Yaw(pedestrianOrienation); +// virtualCam->SetDistance(eyeRange); +// //virtualCam->SetDir +// if(cam)virtualCam->SetRoll(90); +// cam=false; +// virtualCam->Modified(); +// +// } +// // save the actual position +// // needed for computing the rotation angle if missing +// posX = xNew; +// posY = yNew; +// posZ = zNew; +// pedestrianAssembly->SetVisibility(groupVisibilityStatus); +// +// trailActor->SetVisibility(groupVisibilityStatus & extern_tracking_enable); +// triggerPlotTrail(); +// +//} + +bool Pedestrian::isVisible(){ + return pedestrianAssembly->GetVisibility(); +} + +void Pedestrian::setVisibility(bool status){ + if(pedestrianAssembly==NULL){ + createActor(); + createTrailActor(); + } + + pedestrianAssembly->SetVisibility(status); + trailActor->SetVisibility(status); +} + +void Pedestrian::setVisualModeTo2D(bool mode){ + + if(mode){ //2D + pedestrianAssembly=assembly2D; + assembly3D->SetVisibility(false); + } + else{ // 3D + pedestrianAssembly=assembly3D; + assembly2D->SetVisibility(false); + } + pedestrianAssembly->Modified(); +} + + +/// set the group visibility status +void Pedestrian::setGroupVisibility(bool status){ + groupVisibilityStatus=status; +} + +/// get the group visibility +bool Pedestrian::getGroupVisibility(){ + return groupVisibilityStatus; +} + +void Pedestrian::setSize(double size){ + this->pedSize=size; +} + +void Pedestrian::enableCaption(bool status){ + if(caption!=NULL) + this->caption->SetVisibility(status); +} + + +void Pedestrian::plotTrail(double x, double y, double z){ + + trailPoint.push(new Point (x,y,z)); + +} + +void Pedestrian::setTrailGeometry(int type){ + switch(type){ + case 0: // points + //trailPlotterLine->getActor()->SetVisibility(0); + trailPlotterPoint->getActor()->SetVisibility(1); + break; + + case 1: // polygone + //trailPlotterLine->getActor()->SetVisibility(1); + trailPlotterPoint->getActor()->SetVisibility(0); + + break; + } + +} + + +void Pedestrian::triggerPlotTrail() { + + if(trailPoint.isEmpty()) return; + if(trailPoint.size()<2) return; + + // make color uniform and use only [0,255] + //double color[3]={pedsColors[0],255*pedsColors[1],255*pedsColors[2]}; + + trailPlotterLine->clear(); + trailPlotterLine->SetNumberOfPoints(trailPoint.size()); + + // Point * first = trailPoint.pop(); + // first->setColorRGB(color[0],color[1],color[2]); + // trailPlotterPoint->PlotPoint(first); + // trailPlotterLine->addVertex(first); + + while (!trailPoint.isEmpty()){ + Point * next = trailPoint.pop(); + next->setColorRGB(pedsColors[0],pedsColors[1],pedsColors[2]); + + //trailPlotterLine->PlotLine(first, next); + trailPlotterPoint->PlotPoint(next); + trailPlotterLine->addVertex(next); + delete(next); + } + trailPoint.clear(); +} + +void Pedestrian::setCaptionSize(int size){ + vtkTextProperty* tprop = caption->GetTextProperty(); + //tprop->SetFontFamilyToArial(); + //tprop->BoldOn(); + //tprop->ShadowOn(); + //tprop->SetLineSpacing(1.0); + //tprop->SetColor(1.0,0.0,0.0); + tprop->SetFontSize(size); +} + + +void Pedestrian::setCamera(vtkCamera* cam){ + virtualCam=cam; +} + +void Pedestrian::setCaptionsColor(QColor& col){ + double captionColors[3]; + captionColors[0]=(double)col.red()/255; + captionColors[1]=(double)col.green()/255; + captionColors[2]=(double)col.blue()/255; + vtkTextProperty* tprop = caption->GetTextProperty(); + //tprop->SetFontFamilyToArial(); + //tprop->BoldOn(); + //tprop->ShadowOn(); + //tprop->SetLineSpacing(1.0); + tprop->SetColor(captionColors); + // tprop->SetFontSize(size); +} + +void Pedestrian::setCaptionsColorModeToAuto(bool status){ + autoCaptionColorMode=status; +} + +void Pedestrian::setResolution(int pts){ + spaceNeeded->SetRadialResolution(pts); + spaceNeeded->SetCircumferentialResolution(pts); +} diff --git a/src/Pedestrian.h b/src/Pedestrian.h new file mode 100644 index 0000000000000000000000000000000000000000..4d699a2d0cf8acca5f8f161639296b2d0cd4c312 --- /dev/null +++ b/src/Pedestrian.h @@ -0,0 +1,240 @@ +/** + * @headerfile Pedestrian.h + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * + * @section LICENSE + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details at + * http://www.gnu.org/copyleft/gpl.html + * + * @section DESCRIPTION + * + * @brief The Pedestrian class represents pedestrian with all their parameters. + * + * Created on: 05.05.2009 + * + */ + + +#ifndef PEDESTRIAN_H_ +#define PEDESTRIAN_H_ + +#include <QStack> +#include <QColor> + + +//extern variables +//TODO: pipe my through the setting class +extern bool extern_tracking_enable; + +//forwarded classes +class vtkDiskSource; +class vtkAssembly; +class vtkActor; +class vtkDataArray; +class vtkTextActor3D ; +class PointPlotter; +class LinePlotter; +class Point; +class vtkPoints; +class TrajectoryPoint; +class vtkCamera; +//class QRgb; + +class Pedestrian { +public: + /** + * constructor + * @param ID + * @return + */ + Pedestrian(int ID); + /** + * constructor + * + * @param ID + * @param x + * @param y + * @param z + * @return + */ + Pedestrian(int ID, double x ,double y, double z); + + /** + * Class destructor + * + */ + virtual ~Pedestrian(); + + /** + * \brief to provide a virtual reality-like impression + * @param cam a vtkcamera object + */ + static void setCamera(vtkCamera* cam); + + /** + * set the agent id, whose eyes you want to see the scene through, -1 + * will reset to world/scene camera + * + * @param agent, the ID of the agent you want to see the world through + */ + //static void setVirtualRealityAgent(int agent); + + ///returns the pedestrian ID + int getID(); + + ///returns the pedestrians Y coordinate + double getY(); + + ///returns the pedestrians X coordinate + double getX(); + + ///returns the pedestrians Z coordinate + double getZ(); + + + /// return the actor to the pedestrians trail/trace + vtkAssembly* getTrailActor(); + + /// call after the pedestrian has been created + vtkAssembly* getActor(); + + /// move the pedestrian to the next position + /// @param [x y z] coordinates and the velocities + void moveTo(TrajectoryPoint *Point ); + + /// change the size of the caption + /// @todo: also change size and orientation + void setCaptionSize(int size); + + /// enable/disable the pedestrians captions + void enableCaption(bool status); + + + /// set the pedestrian individual visibility status + void setVisibility(bool isVisible); + + /// get the individual visibility status + bool isVisible(); + + /// set the group visibility status + void setGroupVisibility(bool status); + + /// get the group visibility + bool getGroupVisibility(); + + /// set the initial visibility status + /// this may be useful because, all pedestrians are created at the beginning. + /// and placed at the coordinates [ 0 0 0 ] + void initVisibility(bool status); + + + /// switch to 2 Dimensional + /// FIXME not working when visualisation is already started + void setVisualModeTo2D(bool mode); + + /// true if the pedestrian is out of the system + /// it might be deleted + ///void setOutOfTheSystem(bool isOut); + + /// set the pedestrian size, height in cm + void setSize(double size); + + /// plot the pedestrian trails + void plotTrail(double x, double y, double z); + //void plotTrail(double* points,int size); + + /// set the trail types + /// 0 points, 1 polygon + void setTrailGeometry(int type); + + //tODO???? what is todo? + void setColor(int color[3]); + void setColor(int color); + + + /// set the pedestrian resolution. + /// 3 will results in a triangle + void setResolution(int pts); + + + /** + * Set the caption colour. If not specified,<br> + * colour will be set to automatic mode. + * + * @brief set the caption colour + * @param a value between 0 and 255 specifying the desired colour + */ + void setCaptionsColor(QColor& col); + + /// enable or disable automatic caption color + void setCaptionsColorModeToAuto(bool status); + +private: + void createActor(); + void CreateActor2D(); + void CreateActor3D(); + void createSnowMan(); + void createTrailActor(); + void triggerPlotTrail(); + +private : + // pedestrian properties + int ID; + int type; + double posX; + double posY; + double posZ; + + bool groupVisibilityStatus; + double pedSize; + double pedsColors[3]; + bool autoCaptionColorMode; + + /// the virtual reality camera + static vtkCamera * virtualCam; + + /// throug its eyes you will see the world + //static int virtualRealityAgent; + + /// define the pedestrian body; + vtkActor* bodyActor; + + ///define the pedestrian structure + vtkAssembly* pedestrianAssembly; + + /// define the pedestrian structure 3D + vtkAssembly* assembly3D; + + /// define the pedestrian structure 2D + + vtkAssembly* assembly2D; + + /// to increase the radius, the actor could be scale up or down. + vtkDiskSource* spaceNeeded ; //private sphere needed by agents for moving + + /// private sphere actor needed by the pedestrian. It is a function of the velocity + vtkActor* ellipseActor; + + /// trail actor left by the pedestrian + vtkAssembly* trailActor; + + /// caption actor + vtkTextActor3D* caption; + + /// trails plotter + QStack<Point*> trailPoint; + PointPlotter* trailPlotterPoint; + LinePlotter* trailPlotterLine; +}; + +#endif /* PEDESTRIAN_H_ */ diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6279414181619ae8223d07c745bd6a83a59383c2 --- /dev/null +++ b/src/SaxParser.cpp @@ -0,0 +1,872 @@ +/** + * @file SaxParser.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Created on: 6 Sep 2010 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * + * + */ + +#include "SaxParser.h" +#include "TrajectoryPoint.h" +#include "Frame.h" +#include "SyncData.h" +#include "Debug.h" + +#include "geometry/Point.h" +#include "geometry/FacilityGeometry.h" +#include "geometry/jul/Building.h" +#include "geometry/pg3/CBuilding.h" + +#include <QMessageBox> +#include <QString> +#include <limits> +#include <iostream> + + +using namespace std; + +/** + * constructor + * + * @param geo + * @param data + * @param par 0=fps, 1=agents + * @param roomCaption + * @return + */ +SaxParser::SaxParser(FacilityGeometry* geo, SyncData* data, double* fps){ + geometry=geo; + dataset=data; + para=fps; + + dataset->clearFrames(); + + parsingWalls=false; +} + +SaxParser::~SaxParser() { + +} + +bool SaxParser::startElement(const QString & /* namespaceURI */, + const QString & /* localName */, const QString &qName, + const QXmlAttributes &at) +{ + + if (qName == "header") { + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="version") + { + //cout<<"version: "<<at.value(i).toStdString()<<endl; + } + } + }else if (qName == "file") { + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="location") + { + QString fileName=at.value(i); + if(!fileName.isEmpty()) + { + if(fileName.endsWith(".jul",Qt::CaseInsensitive)) + { + SaxParser::parseGeometryJUL(fileName,geometry); + } + else if (fileName.endsWith(".pg3",Qt::CaseInsensitive)) + { + SaxParser::parseGeometryPG3(fileName,geometry); + } + else if (fileName.endsWith(".trav",Qt::CaseInsensitive)) + { + SaxParser::parseGeometryTRAV(fileName,geometry); + } + } + } + } + } + else if (qName == "floor") { + double xMin=0, + xMax=0, + yMin=0, + yMax=0; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="xMin") + { + xMin=at.value(i).toDouble(); + } + else if(at.localName(i)=="xMax") + { + xMax=at.value(i).toDouble(); + } + else if(at.localName(i)=="yMin") + { + yMin=at.value(i).toDouble(); + } + else if(at.localName(i)=="yMax") + { + yMax=at.value(i).toDouble(); + } + + } + geometry->addFloor(xMin,yMin,xMax,yMax); + } + else if (qName == "cuboid") { + double length=0, height=0, + width=0, color=0; + double center[3]={0,0,0}; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="centerX") + { + center[0]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerY") + { + center[1]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerZ") + { + center[2]=at.value(i).toDouble(); + } + else if(at.localName(i)=="length") + { + length=at.value(i).toDouble(); + } + else if(at.localName(i)=="height") + { + height=at.value(i).toDouble(); + } + else if(at.localName(i)=="width") + { + width=at.value(i).toDouble(); + } + else if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + } + geometry->addObjectBox(center,height,width,length,color); + + } + else if (qName == "sphere") { + double radius=0, color=0; + double center[3]={0,0,0}; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="centerX") + { + center[0]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerY") + { + center[1]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerZ") + { + center[2]=at.value(i).toDouble(); + } + else if(at.localName(i)=="radius") + { + radius=at.value(i).toDouble(); + } + else if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + } + geometry->addObjectSphere(center,radius,color); + } + else if (qName == "label") { + double color=0; + double center[3]={0,0,0}; + QString text; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="centerX") + { + center[0]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerY") + { + center[1]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerZ") + { + center[2]=at.value(i).toDouble(); + } + else if(at.localName(i)=="text") + { + text=at.value(i); + } + else if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + } + geometry->addObjectLabel(center,center,text.toStdString(),color); + } + else if (qName == "cylinder") { + double height=0, radius=0, color=0; + double center[3]={0,0,0}; + double rotation[3]={0,0,0}; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="centerX") + { + center[0]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerY") + { + center[1]=at.value(i).toDouble(); + } + else if(at.localName(i)=="centerZ") + { + center[2]=at.value(i).toDouble(); + } + else if(at.localName(i)=="height") + { + height=at.value(i).toDouble(); + } + else if(at.localName(i)=="radius") + { + radius=at.value(i).toDouble(); + } + else if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + else if(at.localName(i)=="angleX") + { + rotation[0]=at.value(i).toDouble(); + } + else if(at.localName(i)=="angleY") + { + rotation[1]=at.value(i).toDouble(); + } + else if(at.localName(i)=="angleZ") + { + rotation[2]=at.value(i).toDouble(); + } + } + geometry->addObjectCylinder(center,radius,height,rotation,color); + } + else if (qName == "agents") { + } else if (qName == "roomCaption") { + } else if (qName == "frameRate") { + } else if (qName == "geometry") { + } + else if (qName == "wall") + { + parsingWalls=true; + thickness=15; + height=250; + color=0; + caption=""; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="thickness") + { + thickness=at.value(i).toDouble(); + } + else if(at.localName(i)=="height") + { + height=at.value(i).toDouble(); + } + else if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + else if(at.localName(i)=="caption") + { + caption=at.value(i); + } + } + + } + else if (qName == "door") + { + parsingWalls=false; + thickness=15; + height=250; + color=255; + caption=""; + + for(int i=0;i<at.length();i++){ + if(at.localName(i)=="thickness") + { + thickness=at.value(i).toDouble(); + } + else if(at.localName(i)=="height") + { + height=at.value(i).toDouble(); + } + else if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + else if(at.localName(i)=="caption") + { + caption=at.value(i); + } + } + + } + else if (qName == "timeFirstFrame") + { + unsigned long timeFirstFrame_us=0; + unsigned long timeFirstFrame_s=0; + + for(int i=0;i<at.length();i++) + { + if(at.localName(i)=="microsec") + { + timeFirstFrame_us=at.value(i).toULong(); + } + else if(at.localName(i)=="sec") + { + timeFirstFrame_s=at.value(i).toULong(); + } + } + dataset->setDelayAbsolute(timeFirstFrame_s,timeFirstFrame_us); + } + else if (qName == "point") + { + double xPos=0; + double yPos=0; + double zPos=0; + + for(int i=0;i<at.length();i++) + { + if(at.localName(i)=="xPos") + { + xPos=at.value(i).toDouble(); + } + else if(at.localName(i)=="yPos") + { + yPos=at.value(i).toDouble(); + } + else if(at.localName(i)=="zPos") + { + zPos=at.value(i).toDouble(); + } + } + double CHT[3]={color,height,thickness}; + + Point* pt= new Point(xPos,yPos,zPos); + pt->setColorHeightThicknes(CHT); + currentPointsList.push_back(pt); + + } else if (qName == "frame") { + + } else if (qName == "agent") { + + int id=0; + double xPos=0; + double yPos=0; + double zPos=0; + double agent_color =std::numeric_limits<double>::quiet_NaN(); + double xVel=std::numeric_limits<double>::quiet_NaN(); + double yVel=std::numeric_limits<double>::quiet_NaN(); + double zVel=std::numeric_limits<double>::quiet_NaN(); + double dia_a=std::numeric_limits<double>::quiet_NaN(); + double dia_b=std::numeric_limits<double>::quiet_NaN(); + double el_angle=std::numeric_limits<double>::quiet_NaN(); + double el_color=std::numeric_limits<double>::quiet_NaN(); + double el_x=std::numeric_limits<double>::quiet_NaN(); + double el_y=std::numeric_limits<double>::quiet_NaN(); + double el_z=std::numeric_limits<double>::quiet_NaN(); + + for(int i=0;i<at.length();i++) + { + if(at.localName(i)=="ID") + { + id=at.value(i).toInt(); + //TODO: maybe you should change ur format to take the ID 0 as first valid ID. + if (id==0){ + //slotErrorOutput("Person with ID=0 detected. ID should start with 1 !"); + return false; + } + } + else if(at.localName(i)=="xPos") + { + xPos=at.value(i).toDouble(); + } + else if(at.localName(i)=="yPos") + { + yPos=at.value(i).toDouble(); + } + else if(at.localName(i)=="zPos") + { + zPos=at.value(i).toDouble(); + } + else if(at.localName(i)=="agentColor") + { + agent_color=at.value(i).toDouble(); + } + else if(at.localName(i)=="xVel") + { + xVel=at.value(i).toDouble(); + } + else if(at.localName(i)=="yVel") + { + yVel=at.value(i).toDouble(); + } + else if(at.localName(i)=="zVel") + { + zVel=at.value(i).toDouble(); + } + + else if(at.localName(i)=="radiusA") + { + dia_a=at.value(i).toDouble(); + } + else if(at.localName(i)=="radiusB") + { + dia_b=at.value(i).toDouble(); + } + else if(at.localName(i)=="ellipseOrientation") + { + el_angle=at.value(i).toDouble(); + } + else if(at.localName(i)=="ellipseColor") + { + el_color=at.value(i).toDouble(); + } + else if(at.localName(i)=="xEll") + { + el_x=at.value(i).toDouble(); + } + else if(at.localName(i)=="yEll") + { + el_y=at.value(i).toDouble(); + } + else if(at.localName(i)=="zEll") + { + el_z=at.value(i).toDouble(); + } + } + + //coordinates of the ellipse, default to the head of the agent + if(isnan(el_x)) el_x=xPos; + if(isnan(el_y)) el_y=yPos; + if(isnan(el_z)) el_z=zPos; + + double pos[3]={xPos,yPos,zPos}; + double vel[3]={xVel,yPos,zPos}; + double ellipse[7]={el_x,el_y,el_z,dia_a,dia_b,el_angle,el_color}; + double para[2]={agent_color,el_angle}; + + TrajectoryPoint * point = new TrajectoryPoint(id-1); + point->setEllipse(ellipse); + point->setPos(pos); + point->setVel(vel); + point->setAgentInfo(para); + currentFrame.push_back(point); + } + else if (qName == "agentInfo") + { + double height=std::numeric_limits<double>::quiet_NaN(); + int color=std::numeric_limits<int>::quiet_NaN(); + int id=std::numeric_limits<int>::quiet_NaN(); + + for(int i=0;i<at.length();i++) + { + if(at.localName(i)=="ID") + { + id=at.value(i).toInt(); + } + if(at.localName(i)=="height") + { + height=at.value(i).toDouble(); + } + if(at.localName(i)=="color") + { + color=at.value(i).toDouble(); + } + } + if(isnan(id)) return true; + + if(!isnan(height)){ + initialPedestriansHeights.append(QString::number(id)); + initialPedestriansHeights.append(QString::number(height)); + } + if(!isnan(color)){ + initialPedestriansColors.append(QString::number(id)); + initialPedestriansColors.append(QString::number(color)); + } + } + return true; +} + +bool SaxParser::characters(const QString &str) { + currentText.append(str); + return true; +} + +bool SaxParser::endElement(const QString & /* namespaceURI */, + const QString & /* localName */, const QString &qName) +{ + if (qName == "header") { + + } else if (qName == "agents") { + dataset->setNumberOfAgents(currentText.toInt()); + } else if (qName == "frameRate") { + para[0]=currentText.toFloat(); + } else if (qName == "wall") { + for(unsigned int i=0;i<currentPointsList.size()-1;i++){ + geometry->addWall(currentPointsList[i],currentPointsList[i+1],caption.toStdString()); + } + clearPoints(); + } else if (qName == "door") { + for(unsigned int i=0;i<currentPointsList.size()-1;i++){ + geometry->addDoor(currentPointsList[i],currentPointsList[i+1],caption.toStdString()); + } + clearPoints(); + } else if (qName == "step") {//FIXME + for(unsigned int i=0;i<currentPointsList.size()-1;i++){ + geometry->addDoor(currentPointsList[i],currentPointsList[i+1],caption.toStdString()); + } + clearPoints(); + } else if (qName == "frame") { + Frame* frame = new Frame(); + while(!currentFrame.empty()){ + frame->addElement(currentFrame.back()); + currentFrame.pop_back(); + } + + dataset->addFrame(frame); + //to be on the safe side + currentFrame.clear(); + + } else if (qName == "agent") { + } else if (qName == "geometry") { + } else if (qName == "point") { + } else if (qName == "shape") { + dataset->setInitialHeights(initialPedestriansHeights); + dataset->setInitialColors(initialPedestriansColors); + } + currentText.clear(); + return true; +} + +bool SaxParser::fatalError(const QXmlParseException &exception) { + QMessageBox::warning(0, QObject::tr("SAX Handler"), QObject::tr( + "Parse error at line %1, column " + "%2:\n%3.") .arg(exception.lineNumber()) .arg( + exception.columnNumber()) .arg(exception.message())); + return false; +} + +bool SaxParser::attributeDecl(const QString& eName, const QString& aName, + const QString& type, const QString& valueDefault, const QString& value) { + //cout<<aName.toStdString()<<endl; + + QString dummy=eName+aName+type+valueDefault+value; + return (dummy==dummy); + //return true; +} + +void SaxParser::clearPoints(){ + + currentPointsList.clear(); + + while (!currentPointsList.empty()){ + delete currentPointsList.back(); + currentPointsList.pop_back(); + } + return; +} + + + + +/// provided for convenience and will be removed in the next version +void SaxParser::parseGeometryJUL(QString fileName, FacilityGeometry *geometry){ + + if(!fileName.endsWith(".jul",Qt::CaseInsensitive)) return ; + + Building* building = new Building(); + string geometrypath = fileName.toStdString(); + + + // read the geometry + building->LoadFromFile(geometrypath); + + int anz_rooms=building->GetAllRooms().size(); + + for(int i=0; i<anz_rooms; i++) + { + Room r = building->GetRoom(i); + int anz_walls=r.GetAllWalls().size(); + for(int j=0; j<anz_walls; j++) + { + Line l = r.GetWall(j).GetLine(); + geometry->addWall(l.GetPoint1().GetX()*100, l.GetPoint1().GetY()*100, + l.GetPoint2().GetX()*100, l.GetPoint2().GetY()*100); + } + int anz_trans = r.GetAllTransitions().size(); + for(int j=0; j<anz_trans; j++) + { + Line l = r.GetTransition(j).GetLine(); + geometry->addDoor(l.GetPoint1().GetX()*100, l.GetPoint1().GetY()*100, + l.GetPoint2().GetX()*100, l.GetPoint2().GetY()*100); + } + } + + // free memory + delete building; +} + +/// provided for convenience and will be removed in the next version +void SaxParser::parseGeometryPG3(QString fileName, FacilityGeometry *geometry){ + + CTextLog* ErrorLog = new CTextLog; + CBuilding* Building = new CBuilding(ErrorLog); + string errorlogpath = "./LogDatei.txt"; + string geometrypath = fileName.toStdString(); + + // Geometrie einlesen + ErrorLog->AddEntry("INFO: Geometry file: "+geometrypath); + Building->LoadFromFile(geometrypath); + int anz_rooms=(*Building).GetRoomCount(); + CRoom r; + + for(int i=0; i<anz_rooms; i++) + { + r.CopyData(Building->GetRoom(i)); + float x=r.GetContPos().GetX()*100; + float y=r.GetContPos().GetY()*100; + int z=r.GetZPos()*30000; + + int anz_lines=r.GetLineElementCount(); + for(int j=0; j<anz_lines; j++) + { + CLine l; + l.CopyData(r.GetLine(j)); + + if(l.GetType()==1) /* WALL */ + geometry->addWall(l.GetPoint1().GetX()*100+x+z, l.GetPoint1().GetY()*100+y, + l.GetPoint2().GetX()*100+x+z, l.GetPoint2().GetY()*100+y); + + if(l.GetType()==2) /* STEP */ + geometry->addStep(l.GetPoint1().GetX()*100+x+z, l.GetPoint1().GetY()*100+y, + l.GetPoint2().GetX()*100+x+z, l.GetPoint2().GetY()*100+y); + if(l.GetType()==3) /* TRANS */ + geometry->addDoor(l.GetPoint1().GetX()*100+x+z, l.GetPoint1().GetY()*100+y, + l.GetPoint2().GetX()*100+x+z, l.GetPoint2().GetY()*100+y); + } + } + + // Errorlog speichern + if (errorlogpath.compare("no file")!=0) + ErrorLog->SaveToFile(errorlogpath); + + // free memory + delete Building; + delete ErrorLog; +} +/// provided for convenience and will be removed in the next version +void SaxParser::parseGeometryTRAV(QString content, FacilityGeometry *geometry,QDomNode geo){ + + + //creating am empty document + // to be filled + QDomDocument doc(""); + QDomNode geoNode; + + //first try to open the file + if(content.endsWith(".trav",Qt::CaseInsensitive) ) + { + QFile file(content); + if (!file.open(QIODevice::ReadOnly)) { + //slotErrorOutput("could not open the File" ); + return ; + } + QString *errorCode = new QString(); + if (!doc.setContent(&file, errorCode)) { + file.close(); + //slotErrorOutput(*errorCode); + return ; + } + file.close(); + geoNode =doc.elementsByTagName("geometry").item(0); + } + else + { + if(content.isEmpty()){ + geoNode=geo; + cout <<"parsing the old fashion way"<<endl; + }else{ + content = "<travisto>\n" +content+ "\n</travisto>\n"; + QString errorMsg=""; + doc.setContent(content,&errorMsg); + + if(!errorMsg.isEmpty()){ + Debug::Error("%s", (const char *)errorMsg.toStdString().c_str()); + return; + } + geoNode =doc.elementsByTagName("geometry").item(0); + } + } + + // for the case there is more than just one geometry Node + while (!geoNode.isNull()) { + QDomElement e = geoNode.toElement(); + QDomNodeList walls = e.elementsByTagName("wall"); + QDomNodeList doors = e.elementsByTagName("door"); + + //objects which can be positioned everywhere in the facility + QDomNodeList spheres = e.elementsByTagName("sphere"); + QDomNodeList cuboids = e.elementsByTagName("cuboid"); + QDomNodeList floors = e.elementsByTagName("floor"); + QDomNodeList cylinders = e.elementsByTagName("cylinder"); + QDomNodeList labels = e.elementsByTagName("label"); + + + //parsing the walls + for (unsigned int i = 0; i < walls.length(); i++) { + QDomElement el = walls.item(i).toElement(); + + //wall thickness, default to 30 cm + double thickness = el.attribute("thickness","15").toDouble(); + //wall height default to 250 cm + double height = el.attribute("height","250").toDouble(); + //wall color default to blue + double color = el.attribute("color","0").toDouble(); + + //get the points defining each wall + //not that a wall is not necessarily defined by two points, could be more... + QDomNodeList points = el.elementsByTagName("point"); + for (unsigned int i = 0; i < points.length() - 1; i++) { + + double x1=points.item(i).toElement().attribute("xPos", "0").toDouble(); + double y1=points.item(i).toElement().attribute("yPos", "0").toDouble(); + double z1=points.item(i).toElement().attribute("zPos", "0").toDouble(); + + double x2=points.item(i+1).toElement().attribute("xPos", "0").toDouble(); + double y2=points.item(i+1).toElement().attribute("yPos", "0").toDouble(); + geometry->addWall(x1, y1, x2, y2,z1,thickness,height,color); + } + } + + //parsing the doors + if(doors.length()>0) + for (unsigned int i = 0; i < doors.length(); i++) { + QDomElement el = doors.item(i).toElement(); + + //door thickness, default to 15 cm + double thickness = el.attribute("thickness","15").toDouble(); + //door height default to 250 cm + double height = el.attribute("height","250").toDouble(); + //door color default to blue + double color = el.attribute("color","255").toDouble(); + + //get the points defining each wall + //not that a wall is not necesarily defined by two points, could be more... + QDomNodeList points = el.elementsByTagName("point"); + //Debug::Messages("found: " << points.length() <<" for this wall" <<endl; + for (unsigned int i = 0; i < points.length() - 1; i++) { + + double x1=points.item(i).toElement().attribute("xPos", "0").toDouble(); + double y1=points.item(i).toElement().attribute("yPos", "0").toDouble(); + double z=points.item(i).toElement().attribute("zPos", "0").toDouble(); + + double x2=points.item(i+1).toElement().attribute("xPos", "0").toDouble(); + double y2=points.item(i+1).toElement().attribute("yPos", "0").toDouble(); + z=points.item(i+1).toElement().attribute("z", "0").toDouble(); + geometry->addDoor(x1, y1, x2, y2,z,thickness,height,color); + } + } + + // parsing the objets + for (unsigned int i = 0; i < spheres.length(); i++) { + + double center[3]; + center[0] = spheres.item(i).toElement().attribute("centerX", "0").toDouble(); + center[1]= spheres.item(i).toElement().attribute("centerY", "0").toDouble(); + center[2]= spheres.item(i).toElement().attribute("centerZ", "0").toDouble(); + double color= spheres.item(i).toElement().attribute("color", "0").toDouble(); + double radius= spheres.item(i).toElement().attribute("radius", "0").toDouble(); + //double width = spheres.item(i).toElement().attribute("width", "0").toDouble(); + //double height= spheres.item(i).toElement().attribute("height", "0").toDouble(); + + geometry->addObjectSphere(center,radius,color); + } + // cubic shapes + for (unsigned int i = 0; i < cuboids.length(); i++) { + + double center[3]; + center[0] = cuboids.item(i).toElement().attribute("centerX", "0").toDouble(); + center[1]= cuboids.item(i).toElement().attribute("centerY", "0").toDouble(); + center[2]= cuboids.item(i).toElement().attribute("centerZ", "0").toDouble(); + double color= cuboids.item(i).toElement().attribute("color", "0").toDouble(); + double length= cuboids.item(i).toElement().attribute("length", "0").toDouble(); + double width = cuboids.item(i).toElement().attribute("width", "0").toDouble(); + double height= cuboids.item(i).toElement().attribute("height", "0").toDouble(); + geometry->addObjectBox(center,height,width,length,color); + // Debug::Error("cuboids: "<<length<<" || " <<width << " || "<<height<<" || "<<color<<endl; + } + // floors + for (unsigned int i = 0; i < floors.length(); i++) { + + double left =floors.item(i).toElement().attribute("xMin","0").toDouble(); + double right =floors.item(i).toElement().attribute("xMax","0").toDouble(); + double up =floors.item(i).toElement().attribute("yMax","0").toDouble(); + double down =floors.item(i).toElement().attribute("yMin","0").toDouble(); + double z =floors.item(i).toElement().attribute("z","0").toDouble(); + geometry->addFloor(left,down,right,up,z); + } + // cylinders + for (unsigned int i = 0; i < cylinders.length(); i++) { + + double center[3], rotation[3]; + center[0] = cylinders.item(i).toElement().attribute("centerX", "0").toDouble(); + center[1]= cylinders.item(i).toElement().attribute("centerY", "0").toDouble(); + center[2]= cylinders.item(i).toElement().attribute("centerZ", "0").toDouble(); + double color= cylinders.item(i).toElement().attribute("color", "0").toDouble(); + double radius= cylinders.item(i).toElement().attribute("radius", "0").toDouble(); + double height= cylinders.item(i).toElement().attribute("height", "0").toDouble(); + rotation[0] = cylinders.item(i).toElement().attribute("angleX", "90").toDouble(); + rotation[1] = cylinders.item(i).toElement().attribute("angleY", "0").toDouble(); + rotation[2] = cylinders.item(i).toElement().attribute("angleZ", "0").toDouble(); + geometry->addObjectCylinder(center,radius,height,rotation,color); + } + + //Tlabels + for (unsigned int i = 0; i < labels.length(); i++) { + + double center[3]; + center[0] = labels.item(i).toElement().attribute("centerX", "0").toDouble(); + center[1]= labels.item(i).toElement().attribute("centerY", "0").toDouble(); + center[2]= labels.item(i).toElement().attribute("centerZ", "0").toDouble(); + double color= labels.item(i).toElement().attribute("color", "0").toDouble(); + string caption= labels.item(i).toElement().attribute("text", "").toStdString(); + geometry->addObjectLabel(center,center,caption,color); + } + // you should normally have only one geometry node, but one never knows... + geoNode = geoNode.nextSiblingElement("geometry"); + } +} + + diff --git a/src/SaxParser.h b/src/SaxParser.h new file mode 100644 index 0000000000000000000000000000000000000000..83752e612fc646e26c85e28451de2d5d5ae09fb7 --- /dev/null +++ b/src/SaxParser.h @@ -0,0 +1,97 @@ +/** + * @file SaxParser.h + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Created on: 6 Sep 2010 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * + * + */ + +#ifndef SAXPARSER_H_ +#define SAXPARSER_H_ + +#include <QtXml> +#include <QTreeWidget> +#include "SyncData.h" + + + +//forwarded classes +class Point; +class TrajectoryPoint; +class SyncData; +class FacilityGeometry; + + +class SaxParser: public QXmlDefaultHandler { +public: + SaxParser(FacilityGeometry* geometry,SyncData* dataset, double * fps); + virtual ~SaxParser(); + bool startElement(const QString &namespaceURI, + const QString &localName, + const QString &qName, + const QXmlAttributes &attributes); + bool endElement(const QString &namespaceURI, + const QString &localName, + const QString &qName); + bool characters(const QString &str); + bool fatalError(const QXmlParseException &exception); + bool attributeDecl(const QString& eName, + const QString& aName, + const QString& type, + const QString& valueDefault, + const QString& value); + + /// provided for convenience and will be removed in the next version + static void parseGeometryJUL(QString content, FacilityGeometry *geo); + + /// provided for convenience and will be removed in the next version + static void parseGeometryPG3(QString content, FacilityGeometry *geo); + + /// provided for convenience and will be removed in the next version + static void parseGeometryTRAV(QString content, FacilityGeometry *geo,QDomNode geoNode=NULL); + +private: + //clear the mo + void clearPoints(); + FacilityGeometry* geometry; + SyncData* dataset; + double*para; + QString currentText; + QStringList initialPedestriansColors; + QStringList initialPedestriansHeights; + std::vector<Point *> currentPointsList; + std::vector<TrajectoryPoint *> currentFrame; + bool parsingWalls; + + //wall and door parameters + double thickness; + double height; + double color; + + //actual caption of door/wall + QString caption; + +}; + +#endif /* SAXPARSER_H_ */ diff --git a/src/SimpleVisualisationWindow.cpp b/src/SimpleVisualisationWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ef749a60bc682a1a82ab2d2225d520d7a45e13b5 --- /dev/null +++ b/src/SimpleVisualisationWindow.cpp @@ -0,0 +1,143 @@ +/** +* @file SimpleVisualisationWindow.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief Testing class +* +* +* Created on: 23.07.2009 +* +*/ + + +#include <vtkActor.h> +#include <vtkLight.h> +#include <vtkAssembly.h> +#include <vtkRenderer.h> +#include <vtkRenderWindow.h> +#include <vtkRenderWindowInteractor.h> +#include <vtkInteractorStyleTrackballCamera.h> + +#include "SimpleVisualisationWindow.h" +#include "./geometry/LinePlotter.h" +#include "./geometry/PointPlotter.h" + +SimpleVisualisationWindow::SimpleVisualisationWindow() { + assembly =NULL; + //actor=NULL; + +} + +SimpleVisualisationWindow::~SimpleVisualisationWindow() { + +} + + +void SimpleVisualisationWindow::setActor(vtkAssembly* actor){ + assembly=actor; +} + + +void SimpleVisualisationWindow::start(){ + + + // Create the renderer with black bg + vtkRenderer* renderer = vtkRenderer::New(); + renderer->SetBackground(0,0,0); + +// //add the line actor +// LinePlotter * ln = new LinePlotter(); +// ln->PlotPoint(324,34,34); +// ln->AddPoint(1,1,1); +// ln->AddPoint(11,11,171); +// ln->AddPoint(34,334,334); +// ln->AddPoint(81,821,81); +// ln->AddPoint(134,14,134); + +// ln->PlotLine(1,1,1,324,34,34,1); +// ln->PlotLine(11,11,171,34,334,334,1); +// ln->PlotLine(81,821,81,14,134,134,1); +// renderer->AddActor(ln->getActor()); + + // +// PointPlotter * pt = new PointPlotter(); +// pt->PlotPoint(324,34,34); +// pt->PlotPoint(1,1,1); +// pt->PlotPoint(11,11,171); +// pt->PlotPoint(34,334,334); +// pt->PlotPoint(81,821,81); +// pt->PlotPoint(134,14,134); +// renderer->AddActor(pt->getActor()); + + //add the different actors + renderer->AddActor(assembly); + //renderer->AddActor(actor); + + + // Set up the lighting. + vtkLight *light = vtkLight::New(); + light->SetFocalPoint(1.875,0.6125,0); + light->SetPosition(3000,3000,10); + light->SetIntensity(1); + light->SetLightTypeToCameraLight(); + // renderer->AddLight(light); +// light->Delete(); + + // Create a render window + vtkRenderWindow *renderWindow = vtkRenderWindow::New(); + renderWindow->AddRenderer( renderer ); + renderWindow->SetSize(600, 800); + + //CAUTION: this is necessary for windows to update the window name after the first render + // but this will freeze your system on linux, strange.... +#ifdef WIN32 + renderWindow->Render(); +#endif + renderWindow->SetWindowName("Visualizing a Geometry"); + + + // Create an interactor + vtkRenderWindowInteractor *renderWinInteractor = vtkRenderWindowInteractor::New(); + renderWinInteractor = vtkRenderWindowInteractor::New(); + renderWindow->SetInteractor( renderWinInteractor ); + //set full screen and catch esc to restore defaults one + //renderWindow->SetFullScreen(1); + + // Create my interactor style + vtkInteractorStyleTrackballCamera* style = vtkInteractorStyleTrackballCamera::New(); + renderWinInteractor->SetInteractorStyle( style ); + style->Delete(); + + // Initialize and enter interactive mode + renderWinInteractor->Initialize(); + renderWinInteractor->Start(); + + //cleaning up + renderWindow->Delete(); + renderWinInteractor->Delete(); + if(assembly) + assembly->Delete(); +// if(actor) +// actor->Delete(); + +} diff --git a/src/SimpleVisualisationWindow.h b/src/SimpleVisualisationWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..50bebbb1e772795f738547e9cf09dc5e6c5ef502 --- /dev/null +++ b/src/SimpleVisualisationWindow.h @@ -0,0 +1,66 @@ +/** +* @headerfile SimpleVisualisationWindow.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* This is a very simple visualisation windows for +* quick visualisation +* +* @brief testing class +* +* +* Created on: 23.07.2009 +* +*/ + + +#ifndef SIMPLEVISUALISATIONWINDOW_H_ +#define SIMPLEVISUALISATIONWINDOW_H_ + +//forwarded classes +class vtkAssembly; +class vtkActor; + + + +class SimpleVisualisationWindow { +public: + ///constructor + SimpleVisualisationWindow(); + ///destructor + virtual ~SimpleVisualisationWindow(); + + ///add an assembly actor + void setActor(vtkAssembly* actor); + +// ///add a simple (single) actor +// void setActor(vtkActor* actor); + + ///start the visualisation + //with the defaults parameters + void start(); + +private: + vtkAssembly* assembly; + //vtkActor* actor; +}; + +#endif /* SIMPLEVISUALISATIONWINDOW_H_ */ diff --git a/src/SyncData.cpp b/src/SyncData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..62056fbc6848fe767f2e933834f8732832937a09 --- /dev/null +++ b/src/SyncData.cpp @@ -0,0 +1,377 @@ +/** +* @file SyncData.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* This class contains the data (trajectories / floor field) after they have +* been parsed in the appropriate structure. They are either read from a file or obtained via a TCP socket +* +* \brief maintains the parsed data in an appropriate structure +* +* +* Created on: 02.06.2009 +* +*/ + +#include "SyncData.h" +#include "Frame.h" +#include "TrajectoryPoint.h" +#include "Message.h" +#include "Debug.h" + +#include <QMutex> +#include <QObject> +#include <QStringList> + +#include <iostream> +#include <string> +#include <vector> +#include <fstream> + +using namespace std; + +SyncData::SyncData() { + frameCursor=0; + numberOfAgents=0; + delay_ms_rel=0; //absolute + delay_s_abs=0; //relative + delay_us_abs=0; //absolute + frameCursorOffset=0; + +} + +SyncData::~SyncData() { + // trajectories.clear(); + while (!frames.empty()){ + delete frames.back(); + frames.pop_back(); + } + frames.clear(); +} + + + +void SyncData::add(std::string newData){ + // mutex.lock(); + // trajectories.push_back(newData); + // mutex.unlock(); +} + + +// and the clearframe alternative for offline visualisation +//void SyncData::clear(){ +// // mutex.lock(); +// // frameCursor=0; +// // trajectories.clear(); +// // numberOfAgents=0; +// // mutex.unlock(); +//} + +std::string SyncData::get(){ + std::string res; + // mutex.lock(); + // if(trajectories.empty()) { + // res=""; + // emit signal_controlSequences("CONTROL_STACK_EMPTY"); + // } + // else{ + // res= trajectories.front(); + // trajectories.erase(trajectories.begin()); + // } + //#ifdef _DEBUG + // std::cout<<"size: " <<trajectories.size()<<std::endl; + //#endif + // mutex.unlock(); + return res; +} + +void SyncData::setFrameCursorOffset(int offset){ + frameCursorOffset=offset; +} + +void SyncData::addFrame(Frame* frame){ + mutex.lock(); + frames.push_back(frame); + mutex.unlock(); +} + +Frame* SyncData::getFrame(unsigned int i){ + mutex.lock(); + i+=frameCursorOffset; + + if((i<0) || (i>=frames.size())){ + mutex.unlock(); + return NULL; + } + else{ + mutex.unlock(); + return frames.at(i); + } + +} + +Frame* SyncData::getNextFrame(){ + + // this may be the case if the file only contains geometry, thus no trajectories available + if(frames.empty()) return NULL; + + // Navigation in the negative direction is also possible + //review + mutex.lock(); + + frameCursor+=extern_update_step; + + //FIXME: do I really need two variables to handle this? + int cursor =frameCursor+frameCursorOffset; + + if (cursor<0) { + //frameCursor=0; + emit signal_controlSequences("STACK_REACHS_BEGINNING"); + mutex.unlock(); + return NULL; + + }else if ((unsigned)cursor>=frames.size()){ + + //if(extern_offline_mode) + emit signal_controlSequences("CONTROL_STACK_EMPTY"); + //frameCursor=frames.size()-1; + mutex.unlock(); + // FIXME: check me, return the last frame, if in o + //return frames.at(frames.size()-1); + frameCursor-=extern_update_step; + return frames.back(); + //return NULL; + } + + Frame* res =frames.at(cursor); + mutex.unlock(); + return res; +} + +/*** +* This method is for convenience only. +* The normal way to get the previous frame is: +* 1. either set the variable extern_update_step to a negative value; +* 2. using the function getFrame(int frameNumber). one may first get +* the current framecursor position using getFrameCursor() +*/ +Frame* SyncData::getPreviousFrame(){ + + mutex.lock(); + frameCursor--; + //FIXME: do I really need two variables to handle this? + int cursor =frameCursor+frameCursorOffset; + + if(cursor<0) { + //emit signal_controlSequences("STACK_REACHS_BEGINNING"); + //frameCursor=0; + mutex.unlock(); + return NULL; + }else + if((unsigned)cursor>=frames.size() ) { + //emit signal_controlSequences("CONTROL_STACK_EMPTY"); + mutex.unlock(); + //frameCursor=frames.size()-1; + return NULL; + } + + Frame* res =frames.at(cursor); + + mutex.unlock(); + + return res; +} + +void SyncData::clearFrames(){ + mutex.lock(); + + frameCursor=0; + numberOfAgents=0; + frameCursorOffset=0; + pedHeight.clear(); + pedColor.clear(); + + while (!frames.empty()){ + delete frames.back(); + frames.pop_back(); + } + frames.clear(); + + mutex.unlock(); +} + +int SyncData::getFramesNumber(){ + //mutex.lock(); //FIXME + return frames.size(); + //mutex.unlock(); +} + +void SyncData::resetFrameCursor(){ + mutex.lock(); + frameCursor=0; + mutex.unlock(); +} + + +int SyncData::getFrameCursor(){ + + return frameCursor; +} + +void SyncData::setFrameCursorTo(int position){ + + mutex.lock(); + + //TODO: check the unsigned + //if((unsigned)position>=frames.size()) frameCursor =frames.size()-1; + //else if (position<0) frameCursor =0; + //else + frameCursor=position; + + mutex.unlock(); +} + +int SyncData::getNumberOfAgents() +{ + return numberOfAgents; +} + +void SyncData::setNumberOfAgents(int numberOfAgents) +{ + mutex.lock(); + this->numberOfAgents = numberOfAgents; + mutex.unlock(); +} + +void SyncData::setDelayAbsolute(unsigned long second, unsigned long microsecond=0){ + delay_s_abs=second; + delay_us_abs=microsecond; + +} + +///@warning only handle seconds, microseconds are ignored +void SyncData::computeDelayRelative(unsigned long* delays){ + unsigned long sec = delays[0]; + unsigned long usec = delays[1]; + long double delay_a = sec*1000 + (double)usec/1000.0; + long double delay_b = delay_s_abs*1000 + (double)delay_us_abs/1000.0; + + delay_ms_rel=delay_a-delay_b; + //std::cerr <<"the delay is: " << delay_ms_rel<<std::endl; + //delay_ms_rel=(sec-delay_s_abs)*1000; + + if (delay_ms_rel<0){ + Debug::Warning("warning: negative delay found"); + } + +} + +/// @warning the old value obtained from computeDelayRelative is just overwritten +// +void SyncData::setDelayRelative(signed long milliseconds){ + delay_ms_rel=milliseconds; + +} + + +void SyncData::getDelayAbsolute(unsigned long* delays){ + delays[0]=delay_s_abs; + delays[1]=delay_us_abs; +} + +signed long SyncData::getDelayRelative(){ + return delay_ms_rel; +} + +void SyncData::setInitialHeights(const QStringList& pedHeight){ + this->pedHeight.clear(); + this->pedHeight=pedHeight; +} + +unsigned int SyncData::getSize(){ + if(frames.empty()) return 0; + else return frames.size(); +} + + +//bool SyncData::writeToFile(char* fileName,int version){ +// ofstream myfile (fileName); +// if (myfile.is_open()) +// { +// //header +// myfile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; +// myfile << "<trajectoriesDataset>"<<endl; +// myfile << "<header formatVersion= \""<<version<<"\">"<<endl; +// myfile << " <roomCaption>"<<roomCaption<<"</roomCaption>"<<endl; +// myfile << " <agents>"<<numberOfAgents<<"</agents>"<<endl; +// myfile << " <frameRate>"<<frameRate<<"</frameRate> <!--per second-->"<<endl; +// myfile << " <timeFirstFrame sec=\"\" microsec=\"\"/> "<<endl; +// myfile << "</header>"<<endl<<endl; +// +// // shape +// myfile << "<shape>"<<endl; +// for(int i=0;i<pedHeight.size()-1;i+=2){ +// bool ok=false; +// int id = pedHeight[i].toInt(&ok); +// if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} +// double size= pedHeight[i+1].toDouble(&ok); +// if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} +// myfile<<"<agentInfo ID=\""<<i<<" height=\""<<size<<"\" color =\"TBD\" "<<endl; +// } +// +// myfile << "</shape>"<<endl; +// // geometry +// +// // trajectories +// +// for (int i=0;i<getSize();i++){ +// Frame* frame = getFrame(i); +// if(frame==NULL){ +// // cerr<<"Trajectory not available in getTrail(), first data set"<<endl; +// }else { +// myfile <<"frame ID=\""<<i<<"\"> "<< endl; +// TrajectoryPoint* point=NULL; +// while(NULL!=(point=frame->getNextElement())){ +// if(version==1){ +// +// }else if (version==2){ +//// myfile <<"<agent ID=\""<<point->getIndex()<<"\""; +//// myfile <<" xPos=\""<<1311.00<<" yPos=\""<<828.00<<" zPos=\""<<0.00<<"\""; +//// myfile <<" agentOrientation =\""<<10<<"\""; +//// myfile <<" xVel=\""<<1311.00<<" yVel=\""<<828.00<<" zVel=\""<<0.00<<"\""; +//// myfile <<" diameterA=\""<<1311.00<<" diameterB=\""<<828.00<<"\""; +//// myfile <<" ellipseOrientation=\""<<1311.00<<" ellipseColor=\""<<828.00<<"\""; +// +// } +// } +// frame->resetCursor(); +// myfile <<"/frame>"<< endl; +// } +// } +// +// +// myfile << "</trajectoriesDataset>"<<endl; +// myfile.close(); +// return true; +// } +// else return false; +// +//} diff --git a/src/SyncData.h b/src/SyncData.h new file mode 100644 index 0000000000000000000000000000000000000000..411507ccf2a87bb5d6b43d3b9603be3559c84310 --- /dev/null +++ b/src/SyncData.h @@ -0,0 +1,186 @@ +/** +* @headerfile SyncData.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* This class contains the data (trajectories / floor field) after they have +* been parsed in the appropriate structure. They are either read from a file or obtained via a TCP socket +* +* \brief maintains the parsed data in an appropriate structure +* +* +* Created on: 02.06.2009 +* +*/ + +#ifndef SYNCDATA_H_ +#define SYNCDATA_H_ + +#include <QMutex> +#include <vector> +#include <QObject> +#include <QStringList> + +class QObject; +class QStringList; +class Frame; + +extern int extern_update_step; +extern bool extern_offline_mode; + +class SyncData: public QObject { + + Q_OBJECT + +public: + SyncData(); + virtual ~SyncData(); + + void add(std::string newData); + std::string get(); + //void clear(); + void resetFrameCursor(); + + + /// get the size + unsigned int getSize(); + + /// add a frame to the synchronized data + void addFrame(Frame* frame); + + /// clears all frames + void clearFrames(); + + /// returns the total number of frames + int getFramesNumber(); + + /// return the position of the actual frame + int getFrameCursor(); + + /// set to cursor position + void setFrameCursorTo(int position); + + /// return the frame at position i + Frame* getFrame(unsigned int i); + + /// return a pointer to the next frame + Frame* getNextFrame(); + + /// return a poiner to the previous frame + Frame* getPreviousFrame(); + + /// return the number of pedestrians involved in this dataset + int getNumberOfAgents(); + + /// set the number of pedestrians + void setNumberOfAgents(int numberOfAgents); + + /// set the absolute time (delay) after which, this dataset will start to play. + /// This is useful when loading several datasets, that needs to be synchronised. + /// @para second the number of seconds elapsed since midnight 1970 + /// @para microsecond the number of microsecond(in addition to the seconds) + void setDelayAbsolute(unsigned long second, unsigned long microsecond/*=0*/); + + /// returns the arguments given in setDelay. + void getDelayAbsolute(unsigned long *); + + /// get the relative delays between the dataset in millisecond. + /// the delay of the first dataset/group will typically have the delay 0 ms. + signed long getDelayRelative(); + + /// set the relative delays + + void setDelayRelative(signed long milliseconds); + + /// compute the relative relative + /// @deprecated [should use setDelayRelative] + void computeDelayRelative(unsigned long* delays); + + /// set the offset. + /// this is useful when several datasets needed + /// to be synchronized + void setFrameCursorOffset(int offset); + + /// \brief initialize the pedestrians height. + /// the initialiation is a list, where the even terms are the IDs + /// and the odd terms are the heights + void setInitialHeights(const QStringList& pedHeight); + + /// \brief get initial heights + QStringList getInitialHeights() { + return pedHeight; + } + + /** + * \brief Set the pedestrian initial colors. + * the initialiation is a list, where the even terms are the IDs + * and the odd terms are the Colors + * @param pedColor + */ + void setInitialColors(const QStringList& pedColor){this->pedColor.clear();this->pedColor=pedColor;}; + + /** + * \brief return the initial colors + */ + + QStringList getInitialColors() { + return pedColor; + } + + Q_SIGNALS: + /// send a control sequence to the main GUI. + /// a control sequence could be STACK_EMPTY. + void signal_controlSequences(const char* sex); + +private: + + //general information about this dataset + float frameRate; + char roomCaption[256]; + + // give the actual position of the frame beeing read, in the frame dataset + + // the actual position (real) of the frame + int frameCursor; + + // the offset. this is 0 when all dataets are synchronised + int frameCursorOffset; + + // relative delay in milliseconds + signed long delay_ms_rel; + // ablotute time elapsed since 1970 in sec + unsigned long delay_s_abs; + // absolute additional time in microsecond + unsigned long delay_us_abs; + + // list containing the initial heights of pedestrians + QStringList pedHeight; + + /// list containing the initial colors of pedestrians + QStringList pedColor; + + /// the number of agents + int numberOfAgents; + QMutex mutex; + std::vector<Frame*> frames; +}; + +#endif /* SYNCDATA_H_ */ diff --git a/src/SystemSettings.cpp b/src/SystemSettings.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7151f5581bd7f2f6492e5bc6c4afbf8e6c1e5e39 --- /dev/null +++ b/src/SystemSettings.cpp @@ -0,0 +1,246 @@ +/** + * @file SystemSettings.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * \brief contains travisto global settings + * + * + * + * Created on: 14.09.2009 + * + */ + + +#include <QDir> +#include <QColor> + +#include "SystemSettings.h" +#include "Debug.h" +#include "./forms/Settings.h" + +bool SystemSettings::showLegend=false; +bool SystemSettings::pedColorProfileReadFromFile=true; +bool SystemSettings::showCaption=false; +bool SystemSettings::is2D=false; +unsigned short SystemSettings::port=8989; +double SystemSettings::bgColor[]={1.0,1.0,1.0}; +//double SystemSettings::ellipseShape[]={21.0,21.0}; +//int SystemSettings::pedestriansColor[3][3]={{255 , 0, 255},{122, 255, 122},{130, 130, 130}}; +int SystemSettings::pedestriansColor[3][3]={{255 , 17, 224},{122, 255, 122},{130, 130, 130}}; +int SystemSettings::pedesShape=Settings::PINGUINS; +int SystemSettings::ellipseResolution=10; +int SystemSettings::trailCount=50; +int SystemSettings::trailingType=1; +int SystemSettings::trailingGeometry=1; +int SystemSettings::virtualAgentID=-1; + +int SystemSettings::captionSize=30; +QColor SystemSettings::captionColor=QColor(); +int SystemSettings::captionOrientaton=1; +bool SystemSettings::captionAutomaticRotation=1; +bool SystemSettings::onScreenInfos=true; + +bool SystemSettings::recordPNGsequence=false; +//QString SystemSettings::outputDir =QDir::currentPath()+"/"; +QString SystemSettings::outputDir = QDir::homePath() +"/Desktop/TraVisTo_Files/"; +QString SystemSettings::filesPrefix=""; + + + +SystemSettings::SystemSettings() {} + +SystemSettings::~SystemSettings() {} + +void SystemSettings::setShowLegend(bool legend){ + showLegend=legend; + +} + +bool SystemSettings::getShowLegend(){ + return showLegend; +} + + +void SystemSettings::setListningPort(unsigned short porta){ + port=porta; +} + +unsigned short SystemSettings::getListeningPort(){ + return port; +} + + +void SystemSettings::setShowCaptions(bool caption){ + showCaption=caption; +} + +bool SystemSettings::getShowCaption(){ + return showCaption; +} + +void SystemSettings::set2D(bool lis2D){ + is2D=lis2D; +} +bool SystemSettings::get2D(){ + return is2D; +} + + +void SystemSettings::getBackgroundColor(double* col){ + col[0]=bgColor[0]; + col[1]=bgColor[1]; + col[2]=bgColor[2]; +} + +void SystemSettings::setBackgroundColor(double* col){ + bgColor[0]=col[0]; + bgColor[1]=col[1]; + bgColor[2]=col[2]; +} + + + +/// set/get pedestrian private sphere ellipse resolution +int SystemSettings::getEllipseResolution(){ + return ellipseResolution; +} + +void SystemSettings::setEllipseResolution(int resolution){ + ellipseResolution=resolution; +} + + + +/// set/get the pedestrian shape +/// 0 for default, 1 for Ellipse, 2 for pinguins +void SystemSettings::setPedestrianShape(int shape){ + pedesShape=shape; +} +int SystemSettings::getPedestrianShape(){ + return pedesShape; +} +void SystemSettings::setTrailsInfo(int count, int type, int geo){ + trailCount=count; + trailingType=type; + trailingGeometry=geo; +} + +void SystemSettings::getTrailsInfo(int* count, int *type, int* geo){ + *count=trailCount; + *type=trailingType; + *geo=trailingGeometry; +} +void SystemSettings::setPedestrianColor(int groupID, int color[3]){ + if((groupID<0) || (groupID>3)) { + Debug::Error(" wrong pedestrian group ID %d",groupID); + return; + } + pedestriansColor[groupID][0]=color[0]; + pedestriansColor[groupID][1]=color[1]; + pedestriansColor[groupID][2]=color[2]; + +} + +void SystemSettings::getPedestrianColor(int groupID, int color[3]){ + if((groupID<0) || (groupID>3)) { + Debug::Error(" wrong pedestrian group ID %d",groupID); + return; + } + + color[0]=pedestriansColor[groupID][0]; + color[1]=pedestriansColor[groupID][1]; + color[2]=pedestriansColor[groupID][2]; + +} + +void SystemSettings::setOutputDirectory(QString dir){ + outputDir=dir; +} +void SystemSettings::getOutputDirectory(QString& dir){ + dir=QString(outputDir); +} + + +//void SystemSettings::setPedestrianCaptionSize( int size){ +// captionSize =size; +//} + +int SystemSettings::getPedestrianCaptionSize(){ + return captionSize; +} + +void SystemSettings::setRecordPNGsequence(bool status){ + recordPNGsequence=status; +} +bool SystemSettings::getRecordPNGsequence(){ + return recordPNGsequence; +} + +void SystemSettings::setFilenamePrefix(QString prefix){ + filesPrefix=prefix; +} + +QString SystemSettings::getFilenamePrefix() { + return filesPrefix; +} + +void SystemSettings::setPedestrianColorProfileFromFile(bool readFromFile) { + pedColorProfileReadFromFile = readFromFile; +} + +bool SystemSettings::getPedestrianColorProfileFromFile() { + return pedColorProfileReadFromFile; +} +void SystemSettings::setVirtualAgent(int agent){ + virtualAgentID=agent; +} + +int SystemSettings::getVirtualAgent(){ + return virtualAgentID; +} + +void SystemSettings::setCaptionsParameters(int size, const QColor& col, int orientation, + bool automaticRotation) { + captionSize=size; + captionColor=col; + captionOrientaton=orientation; + captionAutomaticRotation=automaticRotation; + +} + +void SystemSettings::getCaptionsParameters(int &size, QColor& col, int &orientation, + bool &automaticRotation) { + size=captionSize; + col=captionColor; + orientation=captionOrientaton; + automaticRotation=captionAutomaticRotation; +} + +void SystemSettings::setOnScreenInfos(bool status){ + onScreenInfos=status; +} + +bool SystemSettings::getOnScreenInfos(){ + return onScreenInfos; +} + diff --git a/src/SystemSettings.h b/src/SystemSettings.h new file mode 100644 index 0000000000000000000000000000000000000000..31cbf0469515e66e7dc364487ff386ac5a7e6ce7 --- /dev/null +++ b/src/SystemSettings.h @@ -0,0 +1,167 @@ +/** +* @headerfile SystemSettings.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief contains travisto global settings +* +* +* +* Created on: 14.09.2009 +* +*/ + + +#ifndef SYSTEMSETTINGS_H_ +#define SYSTEMSETTINGS_H_ + +class QString; +class QColor; + + +class SystemSettings { +public: + SystemSettings(); + virtual ~SystemSettings(); + + // set/get enable the legend + void static setShowLegend(bool legend); + bool static getShowLegend(); + + //set/get the caption status + void static setShowCaptions(bool caption); + bool static getShowCaption(); + + // set/get the listening port + void static setListningPort(unsigned short port); + unsigned short static getListeningPort(); + + // set/get the visio + void static set2D(bool is2D); + bool static get2D(); + + // set/get the bk color + // todo done directly in the travisto.cpp + void static getBackgroundColor(double* col); + void static setBackgroundColor(double* col); + + /// set/get pedestrian private sphere ellipse resolution + int static getEllipseResolution(); + void static setEllipseResolution(int resolution); + + + /// set/get the pedestrian shape + /// 0 for default, 1 for Ellipse, 2 for pinguins + void static setPedestrianShape(int shape); + int static getPedestrianShape(); + + /// define the pedestrian trail count and type + /// type =0, backwards, 1= symetric, 3=forward + //geometry= 0 point, polygones=1; + void static setTrailsInfo(int count, int type, int geometry); + void static getTrailsInfo(int* count, int *type, int *geometry); + + /// set the pedestrian colors + void static setPedestrianColor(int groupID, int color[3]); + void static getPedestrianColor(int groupID, int color[3]); + + /// set the pedestrian color profile + /// either read from file, or set manually + void static setPedestrianColorProfileFromFile(bool readFromFile); + bool static getPedestrianColorProfileFromFile(); + + ///set/get the file directory. where travisto will output video/screenshots etc.. + void static setOutputDirectory(QString dir); + void static getOutputDirectory(QString& dir); + + /// set/get the caption size + //void static setPedestrianCaptionSize( int size); + int static getPedestrianCaptionSize(); + + /** + * set the caption parameters + * + * @param size the caption size in point, default is 30 + * @param Col the color in rgb format + * @param orientation 0 is default, 1 is billboard + * @param automaticRotation true if the captions should keep their original orientation + */ + void static setCaptionsParameters(int size, const QColor& Col, int orientation=0, bool automaticRotation=true); + + /** + * + * retrieve the caption parameters + * + * @param size the caption size in point, default ist 30 + * @param Col the color in rgb format + * @param orientation 0 is default, 1 is billboard + * @param automaticRotation true if the captions should keep their original orientation + */ + void static getCaptionsParameters(int &size, QColor& Col, int &orientation, bool &automaticRotation); + + /// set/get the virtual reality agent id + void static setVirtualAgent(int agent); + int static getVirtualAgent(); + + /// set/get the png recording flag + void static setRecordPNGsequence(bool status); + bool static getRecordPNGsequence(); + + /// set/get the onscreen visibility + void static setOnScreenInfos(bool status); + bool static getOnScreenInfos(); + + ///\brief set the video/picture prefix name. + /// This is just the name of the input file. + void static setFilenamePrefix(QString prefix); + + ///\brief get the video/picture prefix name. + /// This is just the name of the input file. + static QString getFilenamePrefix(); + +private: + + static bool recordPNGsequence; + static bool pedColorProfileReadFromFile; + static bool showLegend; + static bool showCaption; + static bool is2D; // Toggle 2D/3D mode + static unsigned short port; + static double bgColor[3]; + //static double ellipseShape[2]; + static int ellipseResolution; + static int pedestriansColor[3][3]; // 3 groups, and 3 color per groups + static int pedesShape; + static int virtualAgentID; + static int trailCount; + static int trailingType; + static int trailingGeometry; + static QString outputDir; + static int captionSize; + static QColor captionColor; + static int captionOrientaton; + static bool captionAutomaticRotation; + static QString filesPrefix; + static bool onScreenInfos; +}; + +#endif /* SYSTEMSETTINGS_H_ */ diff --git a/src/ThreadDataTransfert.cpp b/src/ThreadDataTransfert.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55647ff405b8cb677275e26b89551d3a3b09d06d --- /dev/null +++ b/src/ThreadDataTransfert.cpp @@ -0,0 +1,415 @@ +/** + * @file ThreadDataTransfert.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * This class provides a thread utility that is charged of + * asynchronously receive trajectories (streaming) + * and put them in the adequate data structure to be read by the Visualisation Thread. + * + * \brief Thread that reads data from the socket and parse it + * + * + * + * Created on: 24.05.2009 + * + */ + + +#include <cstdlib> +#include <iostream> +#include <limits> + + +#include <QtXml/QtXml> +#include <QtNetwork/QtNetwork> +#include <QThread> +#include <QObject> +#include <QMessageBox> +#include <QString> + + +#include "SystemSettings.h" +#include "ThreadDataTransfert.h" +#include "SyncData.h" +#include "Frame.h" +#include "TrajectoryPoint.h" + +#include "network/TraVisToServer.h" +#include "geometry/FacilityGeometry.h" +#include "Debug.h" + + +using namespace std; + + +ThreadDataTransfer::ThreadDataTransfer(QObject *parent): + QThread(parent) +{ + m_port=SystemSettings::getListeningPort(); + tcpServer=NULL; + headerParsed=false; + errNr=0; + finished=false; +} + + + +ThreadDataTransfer::~ThreadDataTransfer() { + +} + +void ThreadDataTransfer::shutdown(){ + finished=true; +} + +void ThreadDataTransfer::run(){ + + finished=false; + + // + // std::cerr <<">> starting server" <<std::endl; + // + // // udpSocket = new QUdpSocket(); + // // udpSocket->bind(QHostAddress::LocalHost,SystemSettings::getListeningPort()); + // // + // // if(!connect(udpSocket, SIGNAL(readyRead()), + // // this, SLOT(slotProcessPendingDatagrams()))){ + // // cerr<<"could not create the udp connection"<<endl; + // // } + // + // tcpServer = new QTcpServer(/*this->parent()*/); + // if(!connect(tcpServer, SIGNAL(newConnection()), this, SLOT(slotHandleConnection()))){ + // cerr<<"could not create connection newconnection"<<endl; + // } + // connect(tcpServer, SIGNAL(error(QAbstractSocket::SocketError)), + // this, SLOT(displayError(QAbstractSocket::SocketError))); + // + // if (!tcpServer->listen(QHostAddress::LocalHost,SystemSettings::getListeningPort())) { + // cerr<<"\nI can't listen, sorry"<<endl; + // QMessageBox::critical(0, tr("TraVisTo Server"), + // tr("Unable to start the server: %1.") + // .arg(tcpServer->errorString())); + // quit(); + // } + // + // if(tcpServer->isListening ()) + // cout<<"\nTraVisTo is listening on port "<< tcpServer->serverPort()<<endl; + + QString data; + TraVisToServer* server = new TraVisToServer(SystemSettings::getListeningPort()); + if(!server->isListening()) { + emit signal_errorMessage("could not connect, make sure that the port is not used by another program.\n " + "Restarting the application may solve the issue!"); + emit signal_controlSequence("CONTROL_RESET"); + + }else + do{ + emit signal_CurrentAction("waiting for data"); + server->receiveMessage(data); + + if(!data.isEmpty()) + slotProcessMessage(data); + + }while(finished!=true); + + server->close(); +} + +void ThreadDataTransfer::slotHandleConnection(){ + + Debug::Messages("handling new connection"); + + QTcpSocket *clientConnection = tcpServer->nextPendingConnection(); + connect(clientConnection, SIGNAL(disconnected()), + clientConnection, SLOT(deleteLater())); + + connect(clientConnection, SIGNAL(readyRead()), this, SLOT(slotReadMessage())); + + connect(clientConnection, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(displayError(QAbstractSocket::SocketError))); + //Q_DECLARE_METATYPE( QAbstractSocket::SocketError ); + Debug::Messages("juhuuuu"); +} + +void ThreadDataTransfer::slotReadMessage(){ + Debug::Messages("new post"); + //slotProcessMessage(); +} + +void ThreadDataTransfer::slotProcessMessage(QString& data){ + QDomDocument doc(""); + + data = "<travisto>\n" +data+ "\n</travisto>\n"; + + //cout<<data.toStdString()<<endl; + + QString errorMsg=""; + doc.setContent(data,&errorMsg); + + if(!errorMsg.isEmpty()){ + errNr++; + Debug::Error(">> %s",(const char *)errorMsg.toStdString().c_str()); + Debug::Error(">> %s",(const char *)data.toStdString().c_str()); + //Debug::Error(">> %d", errNr); + //Debug::Error(">> %s", (const char *)data.toStdString().c_str()); + return; + } + + QDomNode header =doc.elementsByTagName("header").item(0); + QDomNode geometry =doc.elementsByTagName("geometry").item(0); + QDomNode shapes =doc.elementsByTagName("shape").item(0); + + QDomNodeList dataList = doc.elementsByTagName("frame"); + + if(!header.isNull()) { + parseHeaderNode(header); + Debug::Messages("header received and parsed"); + } + if(!shapes.isNull()) { + parseShapeNode(shapes); + Debug::Messages("header received and parsed"); + } + + if(!geometry.isNull()) { + //emit signal_loadGeometry(data); + geoData=data; + //parseGeometryNode(geometry); + } + if(!dataList.isEmpty()) { + parseDataNode(dataList); + } + + data.clear(); +} + +void ThreadDataTransfer::slotConnectionClosed(){ + Debug::Error("connection lost"); +} + + +void ThreadDataTransfer::parseHeaderNode(QDomNode header ){ + + + emit signal_CurrentAction("parsing new header"); + + bool ok; + numberOfAgents = getTagValueFromElement(header, "agents").toInt(&ok); + + if(!ok){ + Debug::Error("The number of agents is invalid"); + Debug::Error("The number must be between 1...65355"); + emit signal_errorMessage("The number of agents is invalid"); + numberOfAgents=1000; + } + + if(numberOfAgents==extern_trajectories_firstSet.getNumberOfAgents()){ + // only clear + emit signal_stopVisualisationThread(false); + }else{ + emit signal_stopVisualisationThread(true); + } + + + // no need + //unsigned long timeFirstFrame_us = header.toElement().elementsByTagName("timeFirstFrame").item(0) + //unsigned long timeFirstFrame_s = header.toElement().elementsByTagName("timeFirstFrame").item(0) + // .toElement().attribute("sec",0).toUInt(); + QString frameRateStr=getTagValueFromElement(header, "frameRate"); + frameRate =frameRateStr.toFloat(&ok); + + if(!ok){ + Debug::Error("The frame rate is invalid"); + Debug::Error("The number must be between 1...1000"); + QMessageBox msgBox; + msgBox.setText("The frame rate is invalid"); + msgBox.setInformativeText("The number must be between 1...1000, I will consider 25"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); + frameRate=25; + + } + headerParsed=true; +} + +QString ThreadDataTransfer::getTagValueFromElement(QDomNode node, + const char * tagName) { + if (node.isNull()) + return ""; + return node.toElement().namedItem(tagName).firstChild().nodeValue(); + +} + +void ThreadDataTransfer::parseDataNode(QDomNodeList frames){ + //static int frameNumbers=0; + + //parsing the data + // TODO: i amybe a problem + //emit signal_CurrentAction("parsing data"); + + + for (unsigned int i = 0; i < frames.length(); i++) { + Frame *newFrame = new Frame(); + QDomElement el = frames.item(i).toElement(); + QDomNodeList agents = el.elementsByTagName("agent"); + //cout << "found: " << agents.length() <<" agents" <<endl; + for (unsigned int i = 0; i < agents.length(); i++) { + + bool ok=false; + int id=agents.item(i).toElement().attribute("ID").toInt(&ok); + if(!ok) continue; // invalid ID + double xPos=agents.item(i).toElement().attribute("xPos","0").toDouble(); + double yPos=agents.item(i).toElement().attribute("yPos","0").toDouble(); + double zPos=agents.item(i).toElement().attribute("zPos","0").toDouble(); + + double agent_color =std::numeric_limits<double>::quiet_NaN(); + + double xVel=agents.item(i).toElement().attribute("xVel").toDouble(&ok); + if(!ok)xVel=std::numeric_limits<double>::quiet_NaN(); + double yVel=agents.item(i).toElement().attribute("yVel").toDouble(&ok); + if(!ok)yVel=std::numeric_limits<double>::quiet_NaN(); + double zVel=agents.item(i).toElement().attribute("zVel").toDouble(&ok); + if(!ok)zVel=std::numeric_limits<double>::quiet_NaN(); + + //coordinates of the ellipse, default to the head of the agent + double el_x=agents.item(i).toElement().attribute("xEll").toDouble(&ok); + if(!ok) el_x=xPos; + double el_y=agents.item(i).toElement().attribute("yEll").toDouble(&ok); + if(!ok) el_y=yPos; + double el_z=agents.item(i).toElement().attribute("zEll").toDouble(&ok); + if(!ok) el_z=zPos; + + double dia_a=agents.item(i).toElement().attribute("radiusA").toDouble(&ok); + if(!ok)dia_a=std::numeric_limits<double>::quiet_NaN(); + double dia_b=agents.item(i).toElement().attribute("radiusB").toDouble(&ok); + if(!ok)dia_b=std::numeric_limits<double>::quiet_NaN(); + double el_angle=agents.item(i).toElement().attribute("ellipseOrientation").toDouble(&ok); + if(!ok){el_angle=std::numeric_limits<double>::quiet_NaN(); } + double el_color=agents.item(i).toElement().attribute("ellipseColor").toDouble(&ok); + if(!ok)el_color=std::numeric_limits<double>::quiet_NaN(); + + double pos[3]={xPos,yPos,zPos}; + double vel[3]={xVel,yPos,zPos}; + double ellipse[7]={el_x,el_y,el_z,dia_a,dia_b,el_angle,el_color}; + double para[2]={agent_color,el_angle}; + + TrajectoryPoint * point = new TrajectoryPoint(id-1); + point->setEllipse(ellipse); + point->setPos(pos); + point->setVel(vel); + point->setAgentInfo(para); + newFrame->addElement(point); + } + + //adding the new frame to the right dataset + extern_trajectories_firstSet.addFrame(newFrame); + // frameNumbers++; + } + + // cout <<"frames size: "<<extern_trajectories_firstSet.getSize()<<endl; + // cout <<"frames numbes: "<<frameNumbers<<endl; + if(headerParsed==true){ + // static int count=1; + // count++; + // if (count<100) return; // start after 100 frames + emit signal_startVisualisationThread(geoData,numberOfAgents,frameRate); + headerParsed=false; + // count=0; + } +} + + +void ThreadDataTransfer::slotDisplayError(QAbstractSocket::SocketError socketError){ + + switch (socketError) { + + case QAbstractSocket::RemoteHostClosedError: + Debug::Error( "The host closes the connection "); + break; + + case QAbstractSocket::HostNotFoundError: + Debug::Error("The host was not found. Please check the "); + Debug::Error("host name and port settings."); + break; + + case QAbstractSocket::ConnectionRefusedError: + Debug::Error("The connection was refused by the peer. "); + Debug::Error("Make sure the fortune server is running"); + Debug::Error("and check that the host name and port "); + Debug::Error("settings are correct."); + break; + + default: + Debug::Error("TraVisTo Client:"); + Debug::Error("The following error occurred: "); + //cerr<< clientConnection->errorString().toStdString()<<endl; + break; + } + + +} + +void ThreadDataTransfer::slotProcessPendingDatagrams() { + Debug::Messages("connected"); + while (udpSocket->hasPendingDatagrams()) { + QByteArray datagram; + datagram.resize(udpSocket->pendingDatagramSize()); + udpSocket->readDatagram(datagram.data(), datagram.size()); + // Debug::Messages("%s",(const char *) datagram.data().c_str())); + } +} + + +void ThreadDataTransfer::parseShapeNode(QDomNode shape){ + + + QDomNodeList agents = shape.toElement().elementsByTagName("agentInfo"); + QStringList heights; + QStringList colors; + + + for (unsigned int i = 0; i < agents.length(); i++) { + + bool ok=false; + int id=agents.item(i).toElement().attribute("ID").toInt(&ok); + if(!ok) continue; // invalid ID + double height=agents.item(i).toElement().attribute("height").toDouble(&ok); + if(!ok)height=std::numeric_limits<double>::quiet_NaN(); + + int color=agents.item(i).toElement().attribute("color").toDouble(&ok); + if(!ok)color=std::numeric_limits<int>::quiet_NaN(); + //cout <<"id= " <<id <<" height= "<<height<<" color= "<<color<<endl; + + if(!isnan(height)){ + heights.append(QString::number(id)); + heights.append(QString::number(height)); + } + if(!isnan(color)){ + colors.append(QString::number(id)); + colors.append(QString::number(color)); + } + + } + + extern_trajectories_firstSet.setInitialHeights(heights); + extern_trajectories_firstSet.setInitialColors(colors); +} diff --git a/src/ThreadDataTransfert.h b/src/ThreadDataTransfert.h new file mode 100644 index 0000000000000000000000000000000000000000..e2f2a42f75226a316f96425b3f81f3e90374a93b --- /dev/null +++ b/src/ThreadDataTransfert.h @@ -0,0 +1,127 @@ +/** +* @headerfile ThreadDataTransfert.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* This class provides a thread utility that is charged of +* asynchronously receive trajectories (streaming) +* and put them in the adequate data structure to be read by the Visualisation Thread. +* +* \brief Thread that reads data from the socket and parse it +* +* +* Created on: 24.05.2009 +* +*/ + + + +#ifndef THREADDATATRANSFERT_H_ +#define THREADDATATRANSFERT_H_ + +#include <QThread> +#include <QObject> +#include <QtNetwork/QtNetwork> + +class QThread; +class QObject; +class SyncData; +class QDomNode; +class QString; +class QDomNodeList; +class FacilityGeometry; + +extern SyncData extern_trajectories_firstSet; +extern bool extern_shutdown_visual_thread; + +class ThreadDataTransfer: public QThread { + + Q_OBJECT + +public: + ThreadDataTransfer(QObject *parent = 0); + virtual ~ThreadDataTransfer(); + void run(); + void setListeningPort(int port); + + /// \brief force the thread to do some cleaning work and shutdown + void shutdown(); + + /// parse a shape node + void parseShapeNode(QDomNode shapes); + + /// parse a geometry node + void parseHeaderNode(QDomNode header); + + /// parse data node + void parseDataNode(QDomNodeList data); + +private: + QString getTagValueFromElement(QDomNode node, + const char * tagName); + + Q_SIGNALS: + void signal_start(); + void signal_stop(); + void signal_controlSequence(const char* sex); + + void signal_CurrentAction(QString msg); + + /// connect to the setFrameRateSlot + /// of the visualisation Thread + //void signal_frameRate(float fps); + + /// start the visual thread, + /// once header has been received + void signal_startVisualisationThread(QString data, int numberOfAgents,float frameRate); + + /// shutdown the visio thread + void signal_stopVisualisationThread(bool clearAndStop); + + void signal_errorMessage(QString geometry); + +public Q_SLOTS: + //udp + void slotProcessPendingDatagrams(); + //tcp + void slotHandleConnection(); + void slotReadMessage(); + void slotProcessMessage(QString& data); + void slotConnectionClosed(); + void slotDisplayError(QAbstractSocket::SocketError socketError); + //void slotConnected(); + //void slotDisconnected(); + + +private: + int m_port; + QUdpSocket* udpSocket; + QTcpServer* tcpServer; + bool headerParsed; + long errNr; + QString geoData; + int numberOfAgents; + float frameRate; + bool finished; +}; + +#endif /* THREADDATATRANSFERT_H_ */ + diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b7885261a609a28319adfbd80c35358896b701c --- /dev/null +++ b/src/ThreadVisualisation.cpp @@ -0,0 +1,996 @@ +/** + * @file ThreadDataTransfert.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * This class implements the thread that manages the main visulisation + * + * \brief visualise the data + * + * + * + * Created on: 22.05.2009 + * + */ + + +#include <QThread> +#include <QString> +#include <QObject> +#include <QMessageBox> + + +#include <vtkRenderer.h> +#include <vtkCamera.h> +#include <vtkAssembly.h> +#include <vtkRenderWindow.h> +#include <vtkRenderWindowInteractor.h> +#include <vtkInteractorStyleTrackballCamera.h> +#include <vtkAxisActor.h> +#include <vtkAxesActor.h> +#include <vtkTextActor.h> +#include <vtkLight.h> +#include <vtkScalarBarActor.h> +#include <vtkFloatArray.h> +#include <vtkPolyData.h> +#include <vtkPolyDataMapper.h> +#include <vtkLookupTable.h> +#include <vtkTextProperty.h> +#include <vtkProperty.h> +//#include <vtkMatrix4x4.h> +//#include <vtkHomogeneousTransform.h> +#include <vtkCallbackCommand.h> +#include <vtkSmartPointer.h> +#include <vtkActor2DCollection.h> +#include <vtkRegularPolygonSource.h> + + +#include "geometry/FacilityGeometry.h" +#include "geometry/LinePlotter2D.h" + +#include "ThreadVisualisation.h" +#include "Pedestrian.h" +#include "TimerCallback.h" +#include "Frame.h" +#include "TrajectoryPoint.h" +#include "SyncData.h" +#include "InteractorStyle.h" +#include "SystemSettings.h" +#include "Debug.h" +#include <vtkSphereSource.h> +#include <vtkWindowToImageFilter.h> +#include <vtkActor.h> + +//#include <vector> + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + +ThreadVisualisation::ThreadVisualisation(QObject *parent): +QThread(parent) +{ + renderer=NULL; + renderWindow=NULL; + renderWinInteractor=NULL; + framePerSecond=25; + axis=NULL; + winTitle="header without room caption"; + geometry=new FacilityGeometry(); + +} + +ThreadVisualisation::~ThreadVisualisation() { + // if(renderer) + // renderer->Delete(); + // if(renderWindow) + // renderWindow->Delete(); + // if(renderWinInteractor) + // renderWinInteractor->Delete(); + // if(geometry) + // geometry->Delete(); + + if(axis) + axis->Delete(); + delete geometry; + // vtkRenderer* renderer; + // vtkRenderWindow* renderWindow; + // vtkRenderWindowInteractor* renderWinInteractor; + +} + +void ThreadVisualisation::setFullsreen(bool status){ + renderWindow->SetFullScreen(status); +} + +void ThreadVisualisation::slotSetFrameRate(float fps){ + framePerSecond=fps; +} + + +void ThreadVisualisation::run(){ + + //emit signalStatusMessage("running"); + + // Create the renderer + renderer = vtkRenderer::New(); + // set the background + //renderer->SetBackground(.00,.00,.00); + renderer->SetBackground(1.0,1.0,1.0); + //set the view port + //renderer->SetViewport(0,.5,1.0,1.0); + //add the geometry + renderer->AddActor(geometry->getActor()); + + + //initialize the datasets + init(); + + // add axis + axis= vtkAxesActor::New(); + //axis->SetScale(10); + //axis->SetConeRadius(30); + //axis->SetXAxisLabelText("1 Meter"); + //axis->SetYAxisLabelText("1 Meter"); + //axis->SetZAxisLabelText("1 Meter"); + axis->AxisLabelsOff(); + //axis->SetCylinderRadius(100); + //axis->set + axis->SetTotalLength(1000,1000,1000); + axis->SetVisibility(true); + //renderer->AddActor(axis); + + //add big circle at null point + { + vtkSphereSource* org = vtkSphereSource::New(); + org->SetRadius(300); + + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(org->GetOutputPort()); + org->Delete(); + + // create actor + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(.90,.90,0.0); + //renderer->AddActor(actor); + } + //add another big circle at null point + { + vtkSphereSource* org = vtkSphereSource::New(); + org->SetRadius(300); + //org->SetCenter(50,80,0); + + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(org->GetOutputPort()); + org->Delete(); + + // create actor + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + mapper->Delete(); + actor->GetProperty()->SetColor(.90,.90,0.0); + actor->SetPosition(5000,8000,0); + //renderer->AddActor(actor); + } + + + // Create a real circle, not a sphere + { + + VTK_CREATE(vtkRegularPolygonSource, polygonSource); + polygonSource->GeneratePolygonOff(); + polygonSource->SetNumberOfSides(50); + polygonSource->SetRadius(700); + polygonSource->SetCenter(0,0,0); + polygonSource->Update(); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(polygonSource->GetOutputPort()); + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetColor(180.0/255,180.0/255.0,180.0/255.0); + actor->SetMapper(mapper); + + //renderer->AddActor(actor); + } + + + //cout << "diffuse: "<<actor->GetProperty()->GetDiffuse()<<" [" << actor->GetProperty()->GetDiffuseMinValue()<<" , "<<actor->GetProperty()->GetDiffuseMaxValue() << " ]"<<endl; + //cout << "ambiant: "<<actor->GetProperty()->GetAmbient()<<" [" << actor->GetProperty()->GetAmbientMinValue()<<" , "<<actor->GetProperty()->GetAmbientMaxValue() << " ]"<<endl; + //cout << "specular:"<<actor->GetProperty()->GetSpecular()<<" [" << actor->GetProperty()->GetSpecularMinValue()<<" , "<<actor->GetProperty()->GetSpecularMaxValue()<< " ]"<<endl; + + + + //compute the relatives delays + // necessary in the case several dataset were loaded + computeDelays(); + + // Create the render window + renderWindow = vtkRenderWindow::New(); + renderWindow->AddRenderer( renderer ); + renderWindow->SetSize(960, 800); + //renderWindow->SetSize(640, 480); + //renderWindow->SetSize(800, 586); + //renderWindow->SetSize(1280, 960); + + // add the legend + if(SystemSettings::getShowLegend()) + initLegend(); + + //add the running time frame + runningTime = vtkTextActor::New(); + runningTime->SetTextScaleModeToViewport(); + //runningTime->SetTextScaleModeToProp(); + //runningTime->SetMinimumSize(10,10); + //runningTime->SetMinimumSize(180,80); + //runningTime->SetInput(txt); + //runningTime->SetDisplayPosition(500,700); + runningTime->SetVisibility(SystemSettings::getOnScreenInfos()); + + // set the properties of the caption + vtkTextProperty* tprop = runningTime->GetTextProperty(); + //tprop->SetFontFamilyToArial(); + //tprop->BoldOn(); + //tprop->SetLineSpacing(1.0); + tprop->SetFontSize(10); + tprop->SetColor(1.0,0.0,0.0); + + renderer->AddActor2D(runningTime); + + //CAUTION: this is necessary for WIN32 to update the window name + // but his will freeze your system on linux +#ifdef WIN32 + renderWindow->Render(); +#endif + + renderWindow->SetWindowName(winTitle.toStdString().c_str()); + + // Create an interactor + renderWinInteractor = vtkRenderWindowInteractor::New(); + renderWindow->SetInteractor( renderWinInteractor ); + renderWinInteractor->Initialize(); + + //add at least three lights sources + { + vtkLight *light = vtkLight::New(); + light->SetIntensity(0.1); + light->SetPosition(30,30 ,500); + light->SetLightTypeToSceneLight(); + //renderer->AddLight(light); + light->Delete(); + } + { + vtkLight *light = vtkLight::New(); + light->SetIntensity(0.10); + light->SetPosition(2500,6500, 500); + light->SetLightTypeToSceneLight(); + //renderer->AddLight(light); + light->Delete(); + } + { + vtkLight *light = vtkLight::New(); + light->SetIntensity(0.1); + light->SetPosition(30,30 ,500); + light->SetLightTypeToSceneLight(); + //renderer->AddLight(light); + light->Delete(); + } + + + + if(SystemSettings::get2D()){ + renderer->GetActiveCamera()->OrthogonalizeViewUp(); + renderer->GetActiveCamera()->ParallelProjectionOn(); + renderer->ResetCamera(); + } + //renderer->GetActiveCamera()->Print(cout); + if(0){//save the actual camera settings + vtkCamera *Camera = renderer->GetActiveCamera(); + + Camera->GetPosition( camPosTop ); + //fprintf( stdout, "Position=%lg,%lg,%lg\n", camPosTop[0], camPosTop[1], camPosTop[2] ); + Camera->GetFocalPoint( camFocalPointTop ); + //fprintf( stdout, "FocalPoint=%lg,%lg,%lg\n", camFocalPointTop[0], camFocalPointTop[1], camFocalPointTop[2] ); + Camera->GetViewUp( camViewUpTop ); + //fprintf( stdout, "ViewUp=%lg,%lg,%lg\n", camViewUpTop[0], camViewUpTop[1], camViewUpTop[2] ); + camViewAngleTop = Camera->GetViewAngle(); + //fprintf( stdout, "ViewAngle=%lg\n", camViewAngleTop ); + camParallelScale = Camera->GetParallelScale(); + //fprintf( stdout, "ParallelScale=%lg\n", camParallelScale ); + + renderer->GetActiveCamera()->GetPosition(camPosTop); + renderer->GetActiveCamera()->GetClippingRange(camClipTop); + //renderer->GetActiveCamera()->GetViewPlaneNormal(camViewPlan); + renderer->GetActiveCamera()->GetFocalPoint(camFocalPointTop); + } + + //create a timer for rendering the window + TimerCallback *renderingTimer = new TimerCallback(); + int timer= renderWinInteractor->CreateRepeatingTimer(1000.0/framePerSecond); + renderingTimer->SetRenderTimerId(timer); + renderingTimer->setTextActor(runningTime); + renderWinInteractor->AddObserver(vtkCommand::TimerEvent,renderingTimer); + + // check for windows changes + + //WindowCallback* windowModified = new WindowCallback(); + //VTK_CREATE(vtkCallbackCommand,windowModified); + //windowModified->SetCallback (WindowModifiedCallback); + //renderWindow->AddObserver(vtkCommand::ModifiedEvent ,windowModified); + + + //create the necessary connections + QObject::connect(renderingTimer, SIGNAL(signalRunningTime(unsigned long )), + this->parent(), SLOT(slotRunningTime(unsigned long ))); + + QObject::connect(renderingTimer, SIGNAL(signalFrameNumber(unsigned long )), + this->parent(), SLOT(slotFrameNumber(unsigned long ))); + + QObject::connect(renderingTimer, SIGNAL(signalRenderingTime(int)), + this->parent(), SLOT(slotRenderingTime(int))); + + // Create my interactor style + InteractorStyle* style = InteractorStyle::New(); + renderWinInteractor->SetInteractorStyle( style ); + style->Delete(); + + + //create special camera for the virtual reality feeling + //renderer->GetActiveCamera()->SetRoll(90); + //renderer->GetRenderers()->GetFirstRenderer()->GetActiveCamera(); + Pedestrian::setCamera(renderer->GetActiveCamera()); + renderer->ResetCamera(); + + // just a workaround + + //if(LinePlotter2D::doorColorsToDefault) + { + //LinePlotter2D::doorColorsToDefault=false; + double col[3]={82.0/255,218.0 /255.0,255.0/255.0}; + double wallcol[3]={180.0/255,180.0/255.0,180.0/255.0}; + double exitcol[3]={175.0/255,175.0/255.0,255.0/255.0}; + setExitsColor(exitcol); + setWallsColor(wallcol); + //showDoors(false); + } + + //renderWinInteractor->Initialize(); + // Initialize and enter interactive mode + // should be called after the observer has been added + renderWinInteractor->Start(); + + + //emit signalStatusMessage("Idle"); + emit signal_controlSequences("CONTROL_RESET"); + + //renderWinInteractor->RemoveAllObservers(); + //renderWinInteractor->DestroyTimer(timer); + + //clear some stuffs + finalize(); + + renderer->Delete(); + renderWindow->Delete(); + renderWinInteractor->Delete(); + renderer=NULL; + exit(0); +} + + +void ThreadVisualisation::slotControlSequence(const char* sex){ + + //cout <<"control sequence received: " <<sex<<endl; +} + +void ThreadVisualisation::setGeometryVisibility( bool status){ + if(geometry){ + if(SystemSettings::get2D()){ + geometry->set2D(status); + }else{ + geometry->set3D(status); + } + //geometry->getActor()->SetVisibility(status); + //geometry->getActor()->Modified(); + } +} + +/// show / hide the walls +void ThreadVisualisation::showWalls(bool status){ + if(geometry){ + geometry->showWalls(status); + } +} + +/// show/ hide the exits +void ThreadVisualisation::showDoors(bool status){ + if(geometry){ + geometry->showDoors(status); + } +} + + +void ThreadVisualisation::init(){ + //get the datasets parameters. + // CAUTION: the functions will return 0 if no datasets were initialized + int numOfAgents1=extern_trajectories_firstSet.getNumberOfAgents(); + int numOfAgents2=extern_trajectories_secondSet.getNumberOfAgents(); + int numOfAgents3=extern_trajectories_thirdSet.getNumberOfAgents(); + + // super Pedestrians are declared extern + // CAUTION: the start ID is 1. + if(numOfAgents1>0){ + //get the first frame from the trajectories and initialize pedes positions + Frame * frame = extern_trajectories_firstSet.getNextFrame(); + // this is not usual, but may happen + //just get out if the frame is empty + if(frame==NULL) { + cerr<<"FATAL 1: Frame is null, the first dataset was not initialised"<<endl; + //exit(1); + + } + + //extern_pedestrians_firstSet = new Pedestrian*[numOfAgents1]; + extern_pedestrians_firstSet =(Pedestrian **)malloc(numOfAgents1*sizeof(Pedestrian*)); + + //extern_pedestrians_firstSet =(Pedestrian **)malloc(numOfAgents1*sizeof(Pedestrian*)); + if(extern_pedestrians_firstSet==NULL){ + cerr<<"could not allocate memory"<<endl; + exit(1); + } + + //The initialisation is just to avoid + // pedestrians having not defined (0,0,0) position at beginning. + + for(int i=0;i<numOfAgents1;i++){ + + TrajectoryPoint* point=NULL; + int color[3]; + SystemSettings::getPedestrianColor(0,color); + + if( (NULL!=frame) && (NULL!=(point=frame->getNextElement()))){ + extern_pedestrians_firstSet[i]=new Pedestrian(i,point->getX(),point->getY(),point->getZ()); + // they are all of type 1 (belonging to the first sets) + // extern_pedestrians_firstSet[i]->setType(1); + extern_pedestrians_firstSet[i]->setColor(color); + + }else{ + + extern_pedestrians_firstSet[i]=new Pedestrian(i,0.0,0.0,0.0); + extern_pedestrians_firstSet[i]->setVisibility(false); + + //extern_pedestrians_firstSet[i]->initVisibility(false); + //extern_pedestrians_firstSet[i]->setType(1); + extern_pedestrians_firstSet[i]->setColor(color); + } + + } + + //CAUTION: reset the fucking counter. + //TODO: include the reset cursor in the getnextFrame routine + // which shall be executed when null is returned + if (NULL!=frame) + frame->resetCursor(); + + // init the pedestrians sizes + QStringList heights=extern_trajectories_firstSet.getInitialHeights(); + for(int i=0;i<heights.size()-1;i+=2){ + bool ok=false; + int id = heights[i].toInt(&ok); + if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} + double size= heights[i+1].toDouble(&ok); + if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} + //caution: id start with 0 + extern_pedestrians_firstSet[id-1]->setSize(size); + } + + //init the pedestrians colors, + // overwrite the previously set colors + if(SystemSettings::getPedestrianColorProfileFromFile()){ + QStringList colors=extern_trajectories_firstSet.getInitialColors(); + for(int i=0;i<colors.size()-1;i+=2){ + bool ok=false; + int id = colors[i].toInt(&ok); + if(!ok) {cerr<<"skipping color arguments" <<endl;continue;} + int color= colors[i+1].toInt(&ok); + if(!ok) {cerr<<"skipping color arguments" <<endl;continue;} + //cout << id<< " :"<<size<<endl; + //caution: id start with 0 + extern_pedestrians_firstSet[id-1]->setColor(color); + + } + } + + //all initialisations are done , now create the actors + for(int i=0;i<numOfAgents1;i++){ + renderer->AddActor((vtkProp*)extern_pedestrians_firstSet[i]->getActor()); + renderer->AddActor((vtkProp*)extern_pedestrians_firstSet[i]->getTrailActor()); + + } + } + + // initialize the second dataset + if(numOfAgents2>0){ + Frame * frame = extern_trajectories_secondSet.getNextFrame(); + extern_pedestrians_secondSet =(Pedestrian **)malloc(numOfAgents2*sizeof(Pedestrian*)); + for(int i=0;i<numOfAgents2;i++){ + + // this is not usual, but may happen + //just get out if the frame is empty + if(frame==NULL) { + cerr<<"FATAL 2: Frame is null, the second dataset was not initialised"<<endl; + //exit(1); + //return; + } + + TrajectoryPoint* point=NULL; + int color[3]; + SystemSettings::getPedestrianColor(1,color); + + if( (NULL!=frame) && (NULL!=(point=frame->getNextElement()))){ + extern_pedestrians_secondSet[i]=new Pedestrian(i,point->getX(),point->getY(),point->getZ()); + // they are all of type 1 (belonging to the first sets) + extern_pedestrians_secondSet[i]->setColor(color); + //extern_pedestrians_secondSet[i]->setType(2); + //extern_pedestrians_firstSet[i]->CreateActor(); + }else{ + extern_pedestrians_secondSet[i]=new Pedestrian(i,0.0,0.0,0.0); + extern_pedestrians_secondSet[i]->setColor(color); + // extern_pedestrians_secondSet[i]->setType(2); + //extern_pedestrians_secondSet[i]->initVisibility(false); + extern_pedestrians_secondSet[i]->setVisibility(false); + } + + //renderer->AddActor((vtkProp*)extern_pedestrians_secondSet[i]->getActor()); + //renderer->AddActor((vtkProp*)extern_pedestrians_secondSet[i]->getTrailActor()); + } + //CAUTION: reset the fucking counter + // the frame objects are passed by reference, so the "cursor" stays + // at the last index used. + frame->resetCursor(); + + // init the pedestians sizes + QStringList tokens=extern_trajectories_secondSet.getInitialHeights(); + for(int i=0;i<tokens.size()-1;i+=2){ + + bool ok=false; + int id = tokens[i].toInt(&ok); + if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} + double size= tokens[i+1].toDouble(&ok); + if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} + extern_pedestrians_secondSet[id-1]->setSize(size); + } + + //init the pedestrians colors, + // overwrite the previously set colors + if(SystemSettings::getPedestrianColorProfileFromFile()){ + QStringList colors=extern_trajectories_secondSet.getInitialColors(); + for(int i=0;i<colors.size()-1;i+=2){ + bool ok=false; + int id = colors[i].toInt(&ok); + if(!ok) {cerr<<"skipping color arguments" <<endl;continue;} + int color= colors[i+1].toInt(&ok); + if(!ok) {cerr<<"skipping color arguments" <<endl;continue;} + //caution: id start with 0 + extern_pedestrians_secondSet[id-1]->setColor(color); + + } + } + + //all initialisations are done , now create the actors + for(int i=0;i<numOfAgents2;i++){ + renderer->AddActor((vtkProp*)extern_pedestrians_secondSet[i]->getActor()); + renderer->AddActor((vtkProp*)extern_pedestrians_secondSet[i]->getTrailActor()); + + } + + } + + if(numOfAgents3>0){ + + Frame * frame = extern_trajectories_thirdSet.getNextFrame(); + extern_pedestrians_thirdSet =(Pedestrian **)malloc(numOfAgents3*sizeof(Pedestrian*)); + for(int i=0;i<numOfAgents3;i++){ + + // this is not usual, but may happen + //just get out if the frame is empty + if(frame==NULL) { + cerr<<"FATAL 3: Frame is null, the third dataset was not initialised"<<endl; + //exit(1); + + } + + TrajectoryPoint* point=NULL; + int color[3]; + SystemSettings::getPedestrianColor(2,color); + + if( (NULL!=frame) && (NULL!=(point=frame->getNextElement()))){ + extern_pedestrians_thirdSet[i]=new Pedestrian(i,point->getX(),point->getY(),point->getZ()); + // they are all of type 1 (belonging to the first sets) + //extern_pedestrians_thirdSet[i]->setType(3); + extern_pedestrians_thirdSet[i]->setColor(color); + //extern_pedestrians_firstSet[i]->CreateActor(); + }else{ + extern_pedestrians_thirdSet[i]=new Pedestrian(i,0.0,0.0,0.0); + // extern_pedestrians_thirdSet[i]->setType(3); + extern_pedestrians_thirdSet[i]->setColor(color); + //extern_pedestrians_thirdSet[i]->initVisibility(false); + extern_pedestrians_thirdSet[i]->setVisibility(false); + } + + //renderer->AddActor((vtkProp*)extern_pedestrians_thirdSet[i]->getActor()); + //renderer->AddActor((vtkProp*)extern_pedestrians_thirdSet[i]->getTrailActor()); + } + //CAUTION: reset the fucking counter. + frame->resetCursor(); + + // init the pedestians sizes + QStringList tokens=extern_trajectories_thirdSet.getInitialHeights(); + for(int i=0;i<tokens.size()-1;i+=2){ + bool ok=false; + int id = tokens[i].toInt(&ok); + if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} + double size= tokens[i+1].toDouble(&ok); + if(!ok) {cerr<<"skipping size arguments" <<endl;continue;} + //cout << id<< " :"<<size<<endl; + extern_pedestrians_thirdSet[id-1]->setSize(size); + } + //init the pedestrians colors, + // overwrite the previously set colors + if(SystemSettings::getPedestrianColorProfileFromFile()){ + QStringList colors=extern_trajectories_thirdSet.getInitialColors(); + for(int i=0;i<colors.size()-1;i+=2){ + bool ok=false; + int id = colors[i].toInt(&ok); + if(!ok) {cerr<<"skipping color arguments" <<endl;continue;} + int color= colors[i+1].toInt(&ok); + if(!ok) {cerr<<"skipping color arguments" <<endl;continue;} + //caution: id start with 0 + extern_pedestrians_thirdSet[id-1]->setColor(color); + } + } + + //all initialisations are done , now create the actors + for(int i=0;i<numOfAgents3;i++){ + renderer->AddActor((vtkProp*)extern_pedestrians_thirdSet[i]->getActor()); + renderer->AddActor((vtkProp*)extern_pedestrians_thirdSet[i]->getTrailActor()); + + } + + } +} + + +void ThreadVisualisation::finalize(){ + //get the datasets parameters. + // CAUTION: the functions will return 0 if no datasets were initialized + int numOfAgents1=extern_trajectories_firstSet.getNumberOfAgents(); + int numOfAgents2=extern_trajectories_secondSet.getNumberOfAgents(); + int numOfAgents3=extern_trajectories_thirdSet.getNumberOfAgents(); + + + if(numOfAgents1>0){ + //extern_trajectories_firstSet.clear(); + for(int i=0;i<numOfAgents1;i++){ + delete(extern_pedestrians_firstSet[i]); + } + free(extern_pedestrians_firstSet); + extern_pedestrians_firstSet=NULL; + } + + if(numOfAgents2>0){ + //extern_trajectories_secondSet.clear(); + for(int i=0;i<numOfAgents2;i++){ + delete(extern_pedestrians_secondSet[i]); + } + free(extern_pedestrians_secondSet); + extern_pedestrians_secondSet=NULL; + } + + if(numOfAgents3>0){ + //extern_trajectories_thirdSet.clear(); + for(int i=0;i<numOfAgents3;i++){ + delete(extern_pedestrians_thirdSet[i]); + } + free(extern_pedestrians_thirdSet); + extern_pedestrians_thirdSet=NULL; + } + +} + +/// compute the relative delays to the datasets + +void ThreadVisualisation::computeDelays(){ + + unsigned long delay1[2]; + unsigned long delay2[2]; + unsigned long delay3[2]; + + bool first_set_loaded = (extern_trajectories_firstSet.getNumberOfAgents()>0)?true:false; + bool second_set_loaded = (extern_trajectories_secondSet.getNumberOfAgents()>0)?true:false; + bool third_set_loaded = (extern_trajectories_thirdSet.getNumberOfAgents()>0)?true:false; + + if(first_set_loaded) + extern_trajectories_firstSet.getDelayAbsolute(delay1); + if(second_set_loaded) + extern_trajectories_secondSet.getDelayAbsolute(delay2); + if(third_set_loaded) + extern_trajectories_thirdSet.getDelayAbsolute(delay3); + + // three datasets were loaded + if(first_set_loaded & second_set_loaded & third_set_loaded){ + // relative delays are computed with respect to the first dataset + extern_trajectories_secondSet.computeDelayRelative(delay1); + extern_trajectories_thirdSet.computeDelayRelative(delay1); + + signed long delay_first=extern_trajectories_firstSet.getDelayRelative(); + signed long delay_second=extern_trajectories_secondSet.getDelayRelative(); + signed long delay_third=extern_trajectories_thirdSet.getDelayRelative(); + + if(delay_first<0) { + delay_second+=-delay_first; + delay_third+=-delay_first; + delay_first=0; + } + if(delay_second<0){ + delay_first+=-delay_second; + delay_third+=-delay_second; + delay_second=0; + } + if(delay_third<0){ + delay_first+=-delay_third; + delay_second+=-delay_third; + delay_third=0; + } + Debug::Messages("delay first data set: %f \n",delay_first); + Debug::Messages("delay second data set: %f \n",delay_second); + Debug::Messages("delay third data set: %f \n",delay_third); + + //at this point all delays should be positive + // this step is no loner necessary + extern_trajectories_firstSet.setDelayRelative(delay_first); + extern_trajectories_secondSet.setDelayRelative(delay_second); + extern_trajectories_thirdSet.setDelayRelative(delay_third); + + + extern_trajectories_firstSet.setFrameCursorOffset(- (delay_first*framePerSecond/1000.0f)); + extern_trajectories_secondSet.setFrameCursorOffset(- (delay_second*framePerSecond/1000.0f)); + extern_trajectories_thirdSet.setFrameCursorOffset(- (delay_third*framePerSecond/1000.0f)); + + } + + else if (first_set_loaded & second_set_loaded){ + // relative delays are computed with respect to the first dataset + extern_trajectories_secondSet.computeDelayRelative(delay1); + + signed long delay_first=extern_trajectories_firstSet.getDelayRelative(); + signed long delay_second=extern_trajectories_secondSet.getDelayRelative(); + + //implement me in a while loop + if(delay_first<0) { + delay_second+=-delay_first; + delay_first=0; + } + if(delay_second<0){ + delay_first+=-delay_second; + delay_second=0; + } + + if(delay_first<0) { + delay_second+=-delay_first; + delay_first=0; + } + if(delay_second<0){ + delay_first+=-delay_second; + delay_second=0; + } + + Debug::Messages("delay first data set: %f \n",delay_first); + Debug::Messages("delay second data set: %f \n",delay_second); + + //at this point all delays should be positive + extern_trajectories_firstSet.setDelayRelative(delay_first); + extern_trajectories_secondSet.setDelayRelative(delay_second); + + extern_trajectories_firstSet.setFrameCursorOffset(- (delay_first*framePerSecond/1000.0f)); + extern_trajectories_secondSet.setFrameCursorOffset(- (delay_second*framePerSecond/1000.0f)); + + + }else if (first_set_loaded & third_set_loaded){ + Debug::Error("Hudston, we got a problem"); + }else if (third_set_loaded & second_set_loaded){ + Debug::Error("Hudston, the matter is serious"); + }else{ + //cerr<<"Only one dataset loaded !,no delays/offsets are computed"<<endl; + } + +} + +void ThreadVisualisation::initLegend(/*std::vector scalars*/){ + + //lookup table + vtkLookupTable* lut = vtkLookupTable::New(); + lut->SetHueRange(0.0,0.566); + lut->SetTableRange(20.0, 50.0); + //lut->SetSaturationRange(0,0); + //lut->SetValueRange(0.0,1.0); + lut->SetNumberOfTableValues(50); + lut->Build(); + + //vtkPolyData* polyData = vtkPolyData::New(); + //polyData->sets + //polyData->SetPoints(pts); + //polyData->GetPointData()->SetScalars(scalars); + //vtkPolyDataMapper* mapper =vtkPolyDataMapper::New(); + //mapper->SetLookupTable(lut); + // mapper->SetInput(polyData->GetPolyDataOutput()); + // mapper->SetScalarRange(randomColors->GetPolyDataOutput()->GetScalarRange()); + + vtkTextProperty* titleProp = vtkTextProperty::New(); + titleProp->SetFontSize(14); + + vtkTextProperty* labelProp = vtkTextProperty::New(); + labelProp->SetFontSize(10); + + // cerr<<"label: " <<labelProp->GetFontSize()<<endl; + // cerr<<" : " <<labelProp->GetFontFamilyAsString()<<endl; + // + // cerr<<"title: " <<titleProp->GetFontSize()<<endl; + // cerr<<" : " <<titleProp->GetFontFamilyAsString()<<endl; + + vtkScalarBarActor* scalarBar = vtkScalarBarActor::New(); + scalarBar->SetLookupTable(lut); + //scalarBar->SetLookupTable(mapper->GetLookupTable()); + scalarBar->SetTitle("Velocities ( cm/s )"); + scalarBar->SetTitleTextProperty(titleProp); + scalarBar->SetLabelTextProperty (labelProp); + scalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); + // scalarBar->GetPositionCoordinate()->SetValue(0.1, 0.05); + scalarBar->GetPositionCoordinate()->SetValue(0.005, 0.90075); + scalarBar->SetOrientationToVertical(); + scalarBar->SetNumberOfLabels(7); + scalarBar->SetMaximumNumberOfColors(20); + scalarBar->SetWidth(0.105); + scalarBar->SetHeight(0.10); + //scalarBar->SetPickable(1); + //scalarBar->SetTextPositionToPrecedeScalarBar(); + //scalarBar->SetLabelFormat("%-#5.1f"); + renderer->AddActor2D(scalarBar); + renderer->Render(); + +} + + +void ThreadVisualisation::setAxisVisible(bool status){ + axis->SetVisibility(status); +} + +void ThreadVisualisation::setCameraPerspective(int mode){ + if(renderer==NULL) return; + renderer->GetActiveCamera()->Print(cout); + //vtkMatrix4x4 *m = /* vtkMatrix4x4::New();*/ + // vtkHomogeneousTransform *m = /* vtkMatrix4x4::New();*/ + // renderer->GetActiveCamera()->GetViewTransformMatrix(); + //renderer->GetActiveCamera()->GetUserTransform()->GetMatrix(); + //m->Print(cout); + + + switch (mode) { + case 1: //TOP + { + vtkCamera *camera = renderer->GetActiveCamera(); + + camera->SetPosition(camPosTop); + camera->SetFocalPoint(camFocalPointTop); + camera->SetViewUp(camViewUpTop); + camera->SetViewAngle(camViewAngleTop); + //camera->SetViewPlaneNormal(camViewPlanNormalTop); + camera->SetParallelScale(camParallelScale); + camera->Modified(); + renderer->ResetCameraClippingRange(); + + } + break; + + case 2://SIDE + + break; + + case 3: + //FRONT + break; + + case 4:// agent virtual reality + { + //vtkCamera *camera = renderer->GetActiveCamera(); + //camera->SetRoll(-90); + //std::cout <<"roll [ "<< camera->GetRoll()<<" ]"<<std::endl; + //double roll=camera->GetRoll(); + //camera->Roll(-90-camera->GetRoll()); + //camera->Modified(); + } + + break; + } +} + +void ThreadVisualisation::setBackgroundColor(double* color){ + if (renderer!=NULL) + renderer->SetBackground(color); +} + +void ThreadVisualisation::setWindowTitle(QString title){ + if(title.isEmpty())return; + winTitle=title; +} + +/// @todo check this construct +void ThreadVisualisation::setGeometry(FacilityGeometry* geometry){ + this->geometry=geometry; +} + +FacilityGeometry* ThreadVisualisation::getGeometry() { + //if(geometry==NULL){ //FIXME TODO restore me + geometry=new FacilityGeometry(); + //} + return geometry; +} + +void ThreadVisualisation::setWallsColor(double* color){ + geometry->changeWallsColor(color); +} + +void ThreadVisualisation::setGeometryLabelsVisibility(int v){ + geometry->showGeometryLabels(v); +} + +void ThreadVisualisation::setExitsColor(double* color){ + geometry->changeExitsColor(color); +} + +/// enable/disable 2D +/// todo: consider disabling the 2d option in the 3d, and vice-versa +void ThreadVisualisation::setGeometryVisibility2D(bool status){ + if(geometry!=NULL) //FIXME this should never happens + geometry->set2D(status); +} + +/// enable/disable 3D +/// todo: consider disabling the 2d option in the 3d, and vice-versa +void ThreadVisualisation::setGeometryVisibility3D(bool status){ + if(geometry!=NULL) //FIXME this should never happens, seems to be called by slotReset() ! + geometry->set3D(status); +} + +void ThreadVisualisation::setOnscreenInformationVisibility(bool show){ + runningTime->SetVisibility(show); +} + +//void ThreadVisualisation::WindowModifiedCallback( vtkObject* +// caller, unsigned long eventId,void* clientData ,void* callData ) +//{ +// vtkRenderWindow* window = static_cast<vtkRenderWindow*>(caller); +// int* windowSize = window->GetSize(); +// +// +// int *pos=renderWindow->GetSize(); +// runningTime->SetPosition(pos[1]/2,pos[0]); +// +//} diff --git a/src/ThreadVisualisation.h b/src/ThreadVisualisation.h new file mode 100644 index 0000000000000000000000000000000000000000..67ee074896b4ad02d0fc4e4bd8d041363ddbfa19 --- /dev/null +++ b/src/ThreadVisualisation.h @@ -0,0 +1,182 @@ +/** +* @headerfile ThreadDataTransfert.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* This class implements the thread that manages the main visulisation +* +* \brief visualise the data +* +* +* +* Created on: 22.05.2009 +* +*/ + + +#ifndef THREADVISUALISATION_H_ +#define THREADVISUALISATION_H_ + +#include <QThread> +#include <QObject> + + +// forwarded classes +class QThread; +class QObject; + +class vtkRenderer; +class vtkAssembly; +class vtkRenderWindow; +class vtkRenderWindowInteractor; +class vtkActor; +class vtkAxesActor; +class vtkCamera; +class vtkTextActor; +class vtkObject; + +class Pedestrian; +class SyncData; +class FacilityGeometry; + +extern Pedestrian** extern_pedestrians_firstSet; +extern Pedestrian** extern_pedestrians_secondSet; +extern Pedestrian** extern_pedestrians_thirdSet; + +extern SyncData extern_trajectories_firstSet; +extern SyncData extern_trajectories_secondSet; +extern SyncData extern_trajectories_thirdSet; + +class ThreadVisualisation :public QThread { + Q_OBJECT + +public: + ThreadVisualisation(QObject *parent = 0); + virtual ~ThreadVisualisation(); + virtual void run(); + + void setAxisVisible(bool status); + + void setFullsreen(bool status); + + /// set the camera to one of TOP/FRONT/SIDE + void setCameraPerspective(int mode); + /// load the data for the legend + //void setLegendValues(); + + /// load and display the geometry where + /// the pedestrians will move + void setGeometry(FacilityGeometry* geometry); + + FacilityGeometry* getGeometry(); + + ///this is for convenience and will be delete later + void setWindowTitle(QString title); + + /// shutdown the thread + //void shutdown(); + + void setGeometryLabelsVisibility(int v); + + /// set geometry visibility + void setGeometryVisibility(bool status); + + /// enable/disable 2D + void setGeometryVisibility2D(bool status); + + /// enable/disable 3D + void setGeometryVisibility3D(bool status); + + /// set trajectories/trail visibility + void setTrailVisibility(bool status); + + /// change the background color of the rendering windows + void setBackgroundColor(double* color); + + /// change the walls color + void setWallsColor(double* color); + + /// change the exits color. + void setExitsColor(double* color); + + /// show / hide the walls + void showWalls(bool status); + + /// show/ hide the exits + void showDoors(bool status); + + /// show / hide stairs + ///not implemented + void showStairs(bool status); + + void setOnscreenInformationVisibility(bool show); + +public Q_SLOTS: + /**control sequence received*/ + void slotControlSequence(const char* sex); + + /// set the frame rate in frames per second + void slotSetFrameRate( float fps); + + +Q_SIGNALS: + void signal_controlSequences(const char* sex); + +private: + + + /// initialize the legend + void initLegend(/*std::vector scalars*/); + + /// initialize the datasets + void init(); + + //finalize the datasets + void finalize(); + + /// compute the relative delays to the datasets + void computeDelays(); + + /// window change events + //static void WindowModifiedCallback(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData ); + + +private: + FacilityGeometry* geometry; + vtkRenderer* renderer; + vtkRenderWindow* renderWindow; + vtkRenderWindowInteractor* renderWinInteractor; + vtkAxesActor* axis; + vtkTextActor* runningTime; + QString winTitle; + + float framePerSecond; + double camPosTop[3]; + double camClipTop[3]; + double camFocalPointTop[3]; + double camViewUpTop[3]; + double camViewAngleTop; + double camParallelScale; + double camViewPlanNormalTop[3]; + +}; + +#endif /* THREADVISUALISATION_H_ */ diff --git a/src/TimerCallback.cpp b/src/TimerCallback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..18e358b435e938973226b30efa7ad21cb33a0c09 --- /dev/null +++ b/src/TimerCallback.cpp @@ -0,0 +1,644 @@ +/** + * @file TimerCallback.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * This class is called by the timer and update all elements on the screen + * + * \brief Callback class for the visualisation thread. Triggered by the timer + * + * + * + * Created on: 11.05.2009 + * + */ + + +#include <string> +#include <vector> +#include <algorithm> +#include <cstdlib> +#include <iostream> + + +#ifdef WIN32 +#include <vtkAVIWriter.h> +#include <windows.h> +#endif + + +#ifdef __linux__ +#include <vtkFFMPEGWriter.h> +#endif + +#include <QObject> +#include <QString> +#include <QTime> +#include <QDir> +#include <qwaitcondition.h> + +#include <vtkCommand.h> +#include <vtkWindowToImageFilter.h> +#include <vtkRenderer.h> +#include <vtkRendererCollection.h> +#include <vtkRenderWindow.h> +#include <vtkRenderWindowInteractor.h> +#include <vtkPNGWriter.h> +#include <vtkPostScriptWriter.h> +#include <vtkActor2DCollection.h> +#include <vtkTextActor.h> +#include <vtkCamera.h> +#include <vtkTextProperty.h> + + +#include "geometry/FacilityGeometry.h" +#include "geometry/Point.h" + +#include "Pedestrian.h" +#include "Frame.h" +#include "TrajectoryPoint.h" +#include "SyncData.h" +#include "SystemSettings.h" +#include "TimerCallback.h" + +//#include <vtkPostScriptWriter.h> + +using namespace std; +TimerCallback* TimerCallback::New() +{ + TimerCallback *cb = new TimerCallback; + cb->RenderTimerId = 0; + cb->windowToImageFilter=NULL; + cb->runningTime=NULL; + return cb; +} + + +void TimerCallback::Execute(vtkObject *caller, unsigned long eventId, + void *callData){ + if (vtkCommand::TimerEvent == eventId) + { + int frameNumber=0; + int nPeds=0; + static bool isRecording =false; + int tid = * static_cast<int *>(callData); + //double renderingTime=0; + + if (tid == this->RenderTimerId) + { + //dont update anything if the system is actually paused + //if(extern_is_pause) return; + + vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::SafeDownCast(caller); + vtkRenderWindow *renderWindow = iren->GetRenderWindow(); + vtkRenderer *renderer =renderWindow->GetRenderers()->GetFirstRenderer(); + + if (iren && renderWindow && renderer) + { + // very important + setAllPedestriansInvisible(); + + //first pedestrian group + if(extern_first_dataset_loaded) { + Frame * frame=NULL; + + // return the same frame if the system is paused + // in fact you could just return, but in this case no update will be made + // e.g showing captions/trails... + + if(extern_is_pause) + frame=extern_trajectories_firstSet.getFrame(extern_trajectories_firstSet.getFrameCursor()); + else + frame = extern_trajectories_firstSet.getNextFrame(); + + if(frame==NULL){ + + }else{ + + // just take the frame number given by this dataset + frameNumber=extern_trajectories_firstSet.getFrameCursor(); + if(extern_tracking_enable) + getTrail(1,frameNumber); + + TrajectoryPoint* point=NULL; + while(NULL!=(point=frame->getNextElement())){ +// if(point->getIndex()==152) continue; +// if(point->getIndex()==60) continue; +// if(point->getIndex()==57) continue; +// if(point->getIndex()==9) continue; +// if(point->getIndex()==124) continue; +// if(point->getIndex()==81) continue; +// if(point->getIndex()==55) continue; +// +// if(point->getIndex()==158) continue; +// if(point->getIndex()==192) continue; +// if(point->getIndex()==150) continue; +// if(point->getIndex()==169) continue; +// if(point->getIndex()==113) continue; +// + //if(point->getIndex()==16) continue; + //if(point->getIndex()==17) continue; + + //point index start at 1. this may needed to be fixed + extern_pedestrians_firstSet[point->getIndex()]->moveTo(point); + nPeds++; + } + //CAUTION: reset the fucking counter + frame->resetCursor(); + } + } + + //second pedestrian group + if(extern_second_dataset_loaded){ + + Frame * frame=NULL; + if(extern_is_pause) + frame=extern_trajectories_secondSet.getFrame(extern_trajectories_secondSet.getFrameCursor()); + else + frame = extern_trajectories_secondSet.getNextFrame(); + + if(frame==NULL){ + + }else{ + // just take the frame number given by this dataset + frameNumber=extern_trajectories_secondSet.getFrameCursor(); + if(extern_tracking_enable) + getTrail(2,frameNumber); + + TrajectoryPoint* point=NULL; + while(NULL!=(point=frame->getNextElement())){ + extern_pedestrians_secondSet[point->getIndex()]->moveTo(point); + } + //CAUTION: reset the fucking counter + frame->resetCursor(); + } + } + + //third pedestrian group + if(extern_third_dataset_loaded){ + + Frame * frame=NULL; + if(extern_is_pause) + frame=extern_trajectories_thirdSet.getFrame(extern_trajectories_thirdSet.getFrameCursor()); + else + frame = extern_trajectories_thirdSet.getNextFrame(); + + if(frame==NULL){ + + }else { + // just take the frame number given by this dataset + frameNumber=extern_trajectories_thirdSet.getFrameCursor(); + if(extern_tracking_enable) + getTrail(3,frameNumber); + + TrajectoryPoint* point=NULL; + while(NULL!=(point=frame->getNextElement())){ + //point index start at 1. this may needed to be fixed + extern_pedestrians_thirdSet[point->getIndex()]->moveTo(point); + //set visible to true + } + //CAUTION: reset the fucking counter + frame->resetCursor(); + } + } + + int* winSize=renderWindow->GetSize(); + static int lastWinX=winSize[0]+1; // +1 to trigger a first change + static int lastWinY=winSize[1]; + + sprintf(runningTimeText,"Pedestrians: %d Time: %ld Sec",nPeds,frameNumber*iren->GetTimerDuration(tid)/1000); + runningTime->SetInput(runningTimeText); + runningTime->Modified(); + + if((lastWinX!=winSize[0]) || (lastWinY!=winSize[1]) || (frameNumber<10)) + { + static std::string winBaseName(renderWindow->GetWindowName()); + std::string winName=winBaseName; + std::string s; + winName.append(" [ "); + s=QString::number(winSize[0]).toStdString(); + winName.append(s); + winName.append("X"); + s=QString::number(winSize[1]).toStdString(); + winName.append(s); + winName.append(" ] "); + + int posY=winSize[1]*(1.0-30.0/536.0); + int posX=winSize[0]*(1.0-450.0/720.0); + runningTime->SetPosition(posX,posY); + renderWindow->SetWindowName(winName.c_str()); + + lastWinX=winSize[0]; + lastWinY=winSize[1]; + } + + iren->Render(); + + if(extern_force_system_update){ + updateSettings(renderWindow); + } + if(extern_take_screenshot){ + takeScreenshot(renderWindow); + } + if(SystemSettings::getRecordPNGsequence()){ + takeScreenshotSequence(renderWindow); + } + + if (frameNumber!=0) { + int desiredfps=1000.0/iren->GetTimerDuration(tid); + int effectivefps=1/(renderer->GetLastRenderTimeInSeconds()); + + effectivefps = (effectivefps>desiredfps)?desiredfps:effectivefps; + + emit signalFrameNumber(frameNumber); + emit signalRunningTime(frameNumber*iren->GetTimerDuration(tid)); + emit signalRenderingTime(effectivefps); + } + + + if(extern_launch_recording){ + extern_launch_recording=false; //reset + + windowToImageFilter=vtkWindowToImageFilter::New(); +#ifdef WIN32 + pAVIWriter=vtkAVIWriter::New(); +#endif + +#ifdef __linux__ + pAVIWriter=vtkFFMPEGWriter::New(); +#endif + + pAVIWriter->SetQuality(2);//FIXME 2 is better + pAVIWriter->SetRate(1000.0/iren->GetTimerDuration(tid)); + + //static int videoID=0; + //char filename[20]={0}; + //sprintf(filename,"travisto_video_%d.avi",videoID++); + //pAVIWriter->SetFileName(filename); + + + QString videoName; + SystemSettings::getOutputDirectory(videoName); + //create directory if not exits + if(!QDir(videoName).exists()){ + QDir dir; + if(!dir.mkpath (videoName )){ + cerr<<"could not create directory: "<< videoName.toStdString(); + videoName=""; // current + } + } + + videoName += "/tvtvid_"+QDateTime::currentDateTime().toString("yyMMdd_hh_mm_").append(SystemSettings::getFilenamePrefix()).append(".avi"); + + pAVIWriter->SetFileName(videoName.toStdString().c_str()); + + if(windowToImageFilter!=NULL) + if(windowToImageFilter->GetInput()==NULL){ //should be the case by first call + windowToImageFilter->SetInput(renderWindow); + pAVIWriter->SetInput(windowToImageFilter->GetOutput()); + pAVIWriter->Start(); + } + extern_recording_enable=true; + isRecording=true; + } + + if(isRecording){ + windowToImageFilter->Modified(); + // only write when not paused + if(!extern_is_pause) pAVIWriter->Write(); + + if(extern_recording_enable==false){ //stop the recording + pAVIWriter->End(); + windowToImageFilter->Delete(); + pAVIWriter->Delete(); + isRecording=false; + } + } + + if(extern_shutdown_visual_thread){ + emit signalFrameNumber(0); + + // this will force an update of the windows + lastWinX=0; + lastWinY=0; + //exit if and only if the recording process is terminated + if(isRecording) extern_recording_enable=false; + else iren->ExitCallback(); + + + } + } + } + } +} + +void TimerCallback::updateSettings(vtkRenderWindow* renderWindow) { + + static bool fullscreen=false; + + // check the caption colour mode + int captionSize, orientation; + bool automaticRotation, autoCaptionMode; + QColor captionColor; + SystemSettings::getCaptionsParameters(captionSize,captionColor,orientation,automaticRotation); + + autoCaptionMode= !(captionColor.isValid()); + + if(autoCaptionMode==false){ // tODO set the colour to auto mode + + } + + if(extern_first_dataset_loaded){ + int pedColor[3]; + SystemSettings::getPedestrianColor(0,pedColor); + for(int i=0;i<extern_trajectories_firstSet.getNumberOfAgents();i++){ + extern_pedestrians_firstSet[i]->enableCaption(SystemSettings::getShowCaption()); + if(SystemSettings::getPedestrianColorProfileFromFile()==false){ + extern_pedestrians_firstSet[i]->setColor(pedColor); + } + extern_pedestrians_firstSet[i]->setGroupVisibility(extern_first_dataset_visible); + extern_pedestrians_firstSet[i]->setCaptionSize(captionSize); + extern_pedestrians_firstSet[i]->setCaptionsColorModeToAuto(autoCaptionMode); + extern_pedestrians_firstSet[i]->setCaptionsColor(captionColor); + extern_pedestrians_firstSet[i]->setResolution(SystemSettings::getEllipseResolution()); + } + } + + if(extern_second_dataset_loaded){ + int pedColor[3]; + SystemSettings::getPedestrianColor(1,pedColor); + for(int i=0;i<extern_trajectories_secondSet.getNumberOfAgents();i++){ + extern_pedestrians_secondSet[i]->enableCaption(SystemSettings::getShowCaption()); + if(SystemSettings::getPedestrianColorProfileFromFile()==false){ + extern_pedestrians_secondSet[i]->setColor(pedColor); + } + extern_pedestrians_secondSet[i]->setGroupVisibility(extern_second_dataset_visible); + extern_pedestrians_secondSet[i]->setCaptionSize(captionSize); + extern_pedestrians_secondSet[i]->setCaptionsColorModeToAuto(autoCaptionMode); + extern_pedestrians_secondSet[i]->setCaptionsColor(captionColor); + extern_pedestrians_secondSet[i]->setResolution(SystemSettings::getEllipseResolution()); + + } + } + + if(extern_third_dataset_loaded){ + int pedColor[3]; + SystemSettings::getPedestrianColor(2,pedColor); + for(int i=0;i<extern_trajectories_thirdSet.getNumberOfAgents();i++){ + extern_pedestrians_thirdSet[i]->enableCaption(SystemSettings::getShowCaption()); + + if(SystemSettings::getPedestrianColorProfileFromFile()==false){ + extern_pedestrians_thirdSet[i]->setColor(pedColor); + } + extern_pedestrians_thirdSet[i]->setGroupVisibility(extern_third_dataset_visible); + extern_pedestrians_thirdSet[i]->setCaptionSize(captionSize); + extern_pedestrians_thirdSet[i]->setCaptionsColorModeToAuto(autoCaptionMode); + extern_pedestrians_thirdSet[i]->setCaptionsColor(captionColor); + extern_pedestrians_thirdSet[i]->setResolution(SystemSettings::getEllipseResolution()); + } + } + + //enable / disable full screen + if(fullscreen!=extern_fullscreen_enable){ + renderWindow->SetFullScreen(extern_fullscreen_enable); + //renderWindow->GetRenderers()->GetFirstRenderer()->ResetCamera(); + fullscreen=extern_fullscreen_enable; + } + + // take + extern_force_system_update=false; +} + + +void TimerCallback::setAllPedestriansInvisible() +{ + if(extern_first_dataset_loaded){ + for(int i=0;i<extern_trajectories_firstSet.getNumberOfAgents();i++) + extern_pedestrians_firstSet[i]->setVisibility(false); + } + + if(extern_second_dataset_loaded){ + for(int i=0;i<extern_trajectories_secondSet.getNumberOfAgents();i++) + extern_pedestrians_secondSet[i]->setVisibility(false); + } + + if(extern_third_dataset_loaded){ + for(int i=0;i<extern_trajectories_thirdSet.getNumberOfAgents();i++) + extern_pedestrians_thirdSet[i]->setVisibility(false); + } +} + + + +void TimerCallback::getTrail(int datasetID, int frameNumber){ + + int trailCount=0; + int trailType=0; + int trailForm=0; + int tcMin=0; + int tcMax=0; + + SystemSettings::getTrailsInfo(&trailCount,&trailType,&trailForm); + + switch(trailType){ + case 0://backward + tcMin=frameNumber-trailCount; + tcMax=frameNumber; + break; + + case 1://symetric + tcMin=frameNumber-trailCount/2; + tcMax=frameNumber+trailCount/2; + + break; + + case 2://forward + tcMin=frameNumber; + tcMax=frameNumber+trailCount; + break; + + } + + switch(datasetID){ + case 1: + { + for (int i=tcMin;i<tcMax;i++){ + Frame* frame = extern_trajectories_firstSet.getFrame(i); + if(frame==NULL){ + // cerr<<"Trajectory not available in getTrail(), first data set"<<endl; + }else { + TrajectoryPoint* point=NULL; + while(NULL!=(point=frame->getNextElement())){ + extern_pedestrians_firstSet[point->getIndex()]->plotTrail(point->getX(),point->getY(),point->getZ()); + extern_pedestrians_firstSet[point->getIndex()]->setTrailGeometry(trailForm); + } + frame->resetCursor(); + } + } + } + break; + + case 2: + { + for (int i=tcMin;i<tcMax;i++){ + Frame* frame = extern_trajectories_secondSet.getFrame(i); + if(frame==NULL){ + // cerr<<"Trajectory not available in getTrail(), second data set"<<endl; + }else { + + TrajectoryPoint* point=NULL; + while(NULL!=(point=frame->getNextElement())){ + extern_pedestrians_secondSet[point->getIndex()]->plotTrail(point->getX(),point->getY(),point->getZ()); + extern_pedestrians_secondSet[point->getIndex()]->setTrailGeometry(trailForm); + } + frame->resetCursor(); + } + } + } + + break; + + case 3: + { + for (int i=tcMin;i<tcMax;i++){ + Frame* frame = extern_trajectories_thirdSet.getFrame(i); + if(frame==NULL){ + // cerr<<"Trajectory not available in getTrail(), third data set"<<endl; + }else { + + TrajectoryPoint* point=NULL; + while(NULL!=(point=frame->getNextElement())){ + extern_pedestrians_thirdSet[point->getIndex()]->plotTrail(point->getX(),point->getY(),point->getZ()); + extern_pedestrians_thirdSet[point->getIndex()]->setTrailGeometry(trailForm); + } + frame->resetCursor(); + } + } + } + + break; + + } +} + + +void TimerCallback::takeScreenshot(vtkRenderWindow *renderWindow){ + static int imageID=0; + vtkWindowToImageFilter * winToImFilter = vtkWindowToImageFilter::New(); + winToImFilter->SetInput( renderWindow ); + //winToImFilter->SetMagnification(4); + //renderWindow->Delete(); + //vtkPostScriptWriter * image = vtkPostScriptWriter::New(); + vtkPNGWriter * image = vtkPNGWriter::New(); + image->SetInput( winToImFilter->GetOutput()); + winToImFilter->Delete(); + + QString screenshots; + SystemSettings::getOutputDirectory(screenshots); + //create directory if not exits + if(!QDir(screenshots).exists()){ + QDir dir; + if(!dir.mkpath (screenshots )){ + //Debug::Error("could not create directory: %s",screenshots.toStdString().c_str()); + //try with the current directory + screenshots=""; + } + } + + + char filename[256]={0}; + // sprintf(filename,"travisto_video_%d.png",imageID++); + std::string date= QString(QDateTime::currentDateTime().toString("yyMMdd_hh")).toStdString(); + + sprintf(filename,"travisto_snap_%sh_%d.png",date.c_str(),imageID++); + + //append the prefix + screenshots+=SystemSettings::getFilenamePrefix(); + screenshots+=QString(filename); + image->SetFileName(screenshots.toStdString().c_str()); + winToImFilter->Modified(); + + image->Write (); + image->Delete(); + extern_take_screenshot=false; +} + +/// take png screenshot sequence +void TimerCallback::takeScreenshotSequence(vtkRenderWindow* renderWindow){ + static int imageID=0; + vtkWindowToImageFilter * winToImFilter = vtkWindowToImageFilter::New(); + winToImFilter->SetInput( renderWindow ); + //renderWindow->Delete(); + vtkPNGWriter * image = vtkPNGWriter::New(); + //vtkPostScriptWriter * image = vtkPostScriptWriter::New(); + image->SetInput( winToImFilter->GetOutput()); + winToImFilter->Delete(); + + QString screenshots; + SystemSettings::getOutputDirectory(screenshots); + + screenshots.append("./png_seq_"+QDateTime::currentDateTime().toString("yyMMdd_hh_mm")+"_"+SystemSettings::getFilenamePrefix()); + + //create directory if not exits + if(!QDir(screenshots).exists()){ + QDir dir; + if(!dir.mkpath (screenshots )){ + cerr<<"could not create directory: "<< screenshots.toStdString(); + //try with the current directory + screenshots="./png_seq_"+QDateTime::currentDateTime().toString("yyMMdd_hh_mm")+"_"+SystemSettings::getFilenamePrefix(); + } + } + + + char filename[30]={0}; + sprintf(filename,"/tmp_%d.png",imageID++); + screenshots.append(filename); + image->SetFileName(screenshots.toStdString().c_str()); + winToImFilter->Modified(); + + image->Write (); + image->Delete(); +} + + +void TimerCallback::SetRenderTimerId(int tid) +{ + this->RenderTimerId = tid; +} + +void TimerCallback::setTextActor(vtkTextActor* ra){ + runningTime=ra; +} + + +// +//WindowCallback* WindowCallback::New() +//{ +// WindowCallback *cb = new WindowCallback; +// return cb; +//} + + +//void WindowCallback::Execute(vtkObject *caller, unsigned long eventId, +// void *callData){ +// +// +//} diff --git a/src/TimerCallback.h b/src/TimerCallback.h new file mode 100644 index 0000000000000000000000000000000000000000..96a63fb9e84d4f10188a1a545874bda7662e9895 --- /dev/null +++ b/src/TimerCallback.h @@ -0,0 +1,176 @@ +/** + * @headerfile TimerCallback.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * This class is called by the timer and update all elements on the screen + * + * \brief Callback class for the visualisation thread. Triggered by the timer + * + * + * + * Created on: 11.05.2009 + * + */ + +#ifndef TIMERCALLBACK_H_ +#define TIMERCALLBACK_H_ + +#include <iostream> +#include <vtkCommand.h> + +#include "SyncData.h" + +#ifdef WIN32 +class vtkAVIWriter; +#endif +// +#ifdef __linux__ +class vtkFFMPEGWriter; +#endif + + + +class SyncData; +class QObject; +class QString; +class Pedestrian; +class Pedestrian; +class vtkCommand; +class vtkRenderWindow; +class vtkWindowToImageFilter; +class Frame; +class vtkPNGWriter; +class vtkTextActor; + +//extern variables + +extern bool extern_force_system_update; +extern bool extern_is_pause; + +extern bool extern_shutdown_visual_thread; +extern bool extern_recording_enable; +extern bool extern_launch_recording; +extern bool extern_fullscreen_enable; +extern bool extern_take_screenshot; + +extern Pedestrian** extern_pedestrians_firstSet; +extern Pedestrian** extern_pedestrians_secondSet; +extern Pedestrian** extern_pedestrians_thirdSet; + +extern SyncData extern_trajectories_firstSet; +extern SyncData extern_trajectories_secondSet; +extern SyncData extern_trajectories_thirdSet; + +//states if the datasets are loaded. +extern bool extern_first_dataset_loaded; +extern bool extern_second_dataset_loaded; +extern bool extern_third_dataset_loaded; + +//states whether the loaded datasets are visible +extern bool extern_first_dataset_visible; +extern bool extern_second_dataset_visible; +extern bool extern_third_dataset_visible; + + + +class TimerCallback :public QObject, public vtkCommand{ + + Q_OBJECT + +private: + int RenderTimerId; + vtkWindowToImageFilter* windowToImageFilter; + vtkPNGWriter *pngWriter; + vtkTextActor* runningTime; + char runningTimeText[50]; + +#ifdef WIN32 + vtkAVIWriter* pAVIWriter; +#endif + +#ifdef __linux__ + vtkFFMPEGWriter* pAVIWriter; +#endif + + + +public: + static TimerCallback *New(); + + virtual void Execute(vtkObject *caller, unsigned long eventId, void *callData); + + void SetRenderTimerId(int tid); + + void setTextActor(vtkTextActor* runningTime); + +private: + ///updates system global changes, like fullscreen, ffw and soone + void updateSettings(vtkRenderWindow* renderWindow); + + /// make a png screenshot of the renderwindows + void takeScreenshot(vtkRenderWindow* renderWindow); + + /// take png screenshots sequence + void takeScreenshotSequence(vtkRenderWindow* renderWindow); + + /// set all pedestrians invisible. + /// this is necessary for blending the peds + /// who are not longer in the system. + void setAllPedestriansInvisible(); + + /// create directory + //bool createDirectory( const std::string& ac_sPath ); + + /// mark pedestrians as out of the system + /// when they were present in the last frame + /// but not in the current + /// @param previous Frame current Frame datasetID (1, 2 or 3) + // void checkIfOutOfSystem(Frame* previous, Frame* current,int datasetID); + + /// extract from the + //void getTrail(int datasetID,double* trailX, double* trailY, double* trailZ, int frameNumber,int trailCount); + void getTrail(int datasetID,int frameNumber); + + + Q_SIGNALS: + void signalStatusMessage(QString msg); + void signalFrameNumber(unsigned long timems); + void signalRunningTime(unsigned long timems); + void signalRenderingTime(int fps); + +}; + + +/** + * A callback for windows changes + */ + +//class WindowCallback: public vtkCommand{ +//public: +// static WindowCallback *New(); +// virtual void Execute(vtkObject *caller, unsigned long eventId, void *callData); +//}; + + +#endif /* TIMERCALLBACK_H_ */ + + diff --git a/src/TrajectoryPoint.cpp b/src/TrajectoryPoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..664df0c0d675172a10b7fe404f325fef89722165 --- /dev/null +++ b/src/TrajectoryPoint.cpp @@ -0,0 +1,141 @@ +/** +* @file TrajectoryPoint.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief +* +* +* Created on: 08.07.2009 +* +*/ + + + +#include <limits> +#include "TrajectoryPoint.h" + + + +TrajectoryPoint::TrajectoryPoint(int index){ + this->index=index; + this->x = std::numeric_limits<double>::quiet_NaN(); + this->y = std::numeric_limits<double>::quiet_NaN(); + this->z = std::numeric_limits<double>::quiet_NaN(); + this->xVel = std::numeric_limits<double>::quiet_NaN(); + this->yVel = std::numeric_limits<double>::quiet_NaN(); + this->zVel = std::numeric_limits<double>::quiet_NaN(); + + this->agentOrientation = std::numeric_limits<double>::quiet_NaN(); + this->ellipseRadiusA = std::numeric_limits<double>::quiet_NaN(); + this->ellipseRadiusB = std::numeric_limits<double>::quiet_NaN(); + this->ellipseColor = std::numeric_limits<double>::quiet_NaN(); + this->agentHeight = std::numeric_limits<double>::quiet_NaN(); + +} + +TrajectoryPoint::TrajectoryPoint(int index,double x, double y, double z) { + this->index = index; + this->x = x; + this->y = y; + this->z = z; + this->xVel = std::numeric_limits<double>::quiet_NaN(); + this->yVel = std::numeric_limits<double>::quiet_NaN(); + this->zVel = std::numeric_limits<double>::quiet_NaN(); + + this->agentOrientation = std::numeric_limits<double>::quiet_NaN(); + this->ellipseRadiusA = std::numeric_limits<double>::quiet_NaN(); + this->ellipseRadiusB = std::numeric_limits<double>::quiet_NaN(); + this->ellipseColor = std::numeric_limits<double>::quiet_NaN(); + this->agentHeight = std::numeric_limits<double>::quiet_NaN(); +} +TrajectoryPoint::~TrajectoryPoint() { + +} + + +//setter +void TrajectoryPoint::setIndex(int index) { + this->index = index; +} +void TrajectoryPoint::setPos(double pos[3]) { + x = pos[0]; + y = pos[1]; + z = pos[2]; +} +void TrajectoryPoint::setVel(double vel[3]) { + xVel = vel[0]; + yVel = vel[1]; + zVel = vel[2]; +} + +void TrajectoryPoint::setEllipse(double ellipse[7]) { + ellipseCenter[0] = ellipse[0]; + ellipseCenter[1] = ellipse[1]; + ellipseCenter[2] = ellipse[2]; + ellipseRadiusA = ellipse[3]; + ellipseRadiusB = ellipse[4]; + agentOrientation = ellipse[5]; + ellipseColor = ellipse[6]; +} + +int TrajectoryPoint::getIndex() { + return index; +} +double TrajectoryPoint::getX() { + return x; +} +double TrajectoryPoint::getY() { + return y; +} +double TrajectoryPoint::getZ() { + return z; +} +void TrajectoryPoint::getPos(double pos[3]) { + pos[0] = x; + pos[1] = y; + pos[2] = z; +} +void TrajectoryPoint::getVel(double vel[3]) { + vel[0] = xVel; + vel[1] = yVel; + vel[2] = zVel; +} +void TrajectoryPoint::getEllipse(double ellipse[7]) { + ellipse[0] = ellipseCenter[0]; + ellipse[1] = ellipseCenter[1]; + ellipse[2] = ellipseCenter[2]; + + ellipse[3] = ellipseRadiusA; + ellipse[4] = ellipseRadiusB; + ellipse[5] = agentOrientation; + ellipse[6] = ellipseColor; +} + void TrajectoryPoint::setAgentInfo(double para[2]){ + agentColor=para[0]; + agentOrientation=para[1]; + } + + void TrajectoryPoint::getAgentInfo(double para[2]){ + para[0]=agentColor; + para[1]=agentOrientation; + } diff --git a/src/TrajectoryPoint.h b/src/TrajectoryPoint.h new file mode 100644 index 0000000000000000000000000000000000000000..117a7be8ccd3f2666d42b1c5b72069332b462ed9 --- /dev/null +++ b/src/TrajectoryPoint.h @@ -0,0 +1,103 @@ +/** +* @headerfile TrajectoryPoint.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief +* +* +* Created on: 08.07.2009 +* +*/ + + +#ifndef TRAJECTORYPOINT_H_ +#define TRAJECTORYPOINT_H_ + +class TrajectoryPoint { +public: + TrajectoryPoint(int index); + TrajectoryPoint(int index, double x, double y, double z); + virtual ~TrajectoryPoint(); + + /// set/get the point ID + void setIndex(int index); + /// set/get the point ID + int getIndex(); + + /// set/get the position of the point/agent + void getPos(double pos[3]); + /// set/get the position of the point/agent + void setPos(double pos[3]); + + /// set/get the velocity of the point/agent + void getVel(double vel[3]); + /// set/get the velocity of the point/agent + void setVel(double vel[3]); + + /** + * set/get the coordinate of the modelled ellipse. + * @param ellipse, the center coordinates and the 2 semi-axes + */ + void getEllipse(double ellipse[4]); + + /** + * set/get the coordinate of the modelled ellipse. + * @param ellipse, the center coordinates , the 2 semi-axes, the color and the orientation + */ + void setEllipse(double ellipse[4]); + + /** + * set/get other agents infos: the color and the orientation. + * IF ommitted the orientation will be calculated based on the last coordinates + * + * @param param, Color[0 255] and orientation[0..360] + */ + void setAgentInfo(double param[2]); + void getAgentInfo(double para[2]); + + double getX(); + double getY(); + double getZ(); + + +private: + int index; + double x; + double y; + double z; + + double xVel; + double yVel; + double zVel; + + double agentColor; + double agentHeight; + double agentOrientation; + + double ellipseCenter[3]; + double ellipseRadiusA; + double ellipseRadiusB; + double ellipseColor; +}; + +#endif /* TRAJECTORYPOINT_H_ */ diff --git a/src/extern_var.h b/src/extern_var.h new file mode 100644 index 0000000000000000000000000000000000000000..78749d8cdd40b9c6f6d5462f40431925f9d65540 --- /dev/null +++ b/src/extern_var.h @@ -0,0 +1,96 @@ +/** +* @file extern_var.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief contains the declaration of all extern variables +* +* Created on: 08.06.2009 +*/ + +#ifndef EXTERN_VAR_H_ +#define EXTERN_VAR_H_ 1 + +#include "SyncData.h" +#include "Pedestrian.h" + + +//external variables +/// define the speed/rate/pace at which the trajectories are displayed. +/// 1 is the normal default playing rate +int extern_update_step=1; + + +///visualizing 2D or 3 D +/// true for 3D, false for 2D +bool extern_is_3D=true; + +bool extern_shutdown_visual_thread=false; +bool extern_recording_enable=false; +bool extern_is_pause =false; +bool extern_launch_recording=false; +bool extern_offline_mode = true; +bool extern_fullscreen_enable = false; +bool extern_take_screenshot = false; +/// states whether a setting has been altered +/// and force the system to update +bool extern_force_system_update=false; + +/// enables of disables tracking. +/// With this enable, moving pedestrians will leave a +/// trail behind them +bool extern_tracking_enable=false; + +///relative scale from pedestrian to the geometry (environment) +double extern_scale=0.1; +double extern_scale_pedestrian=0.1; + +// At most three pedestrians groups can be loaded +///The first pedestrian group +Pedestrian** extern_pedestrians_firstSet=NULL; +///The second pedestrian group +Pedestrian** extern_pedestrians_secondSet=NULL; +///The third pedestrian group +Pedestrian** extern_pedestrians_thirdSet=NULL; + +// and here the corresponding dataset + +///The first dataset +SyncData extern_trajectories_firstSet; +///The second dataset +SyncData extern_trajectories_secondSet; +///The third dataset +SyncData extern_trajectories_thirdSet; + + +//states if the datasets are loaded. +bool extern_first_dataset_loaded=false; +bool extern_second_dataset_loaded=false; +bool extern_third_dataset_loaded=false; + +//states whether the loaded datasets are visible +bool extern_first_dataset_visible=false; +bool extern_second_dataset_visible=false; +bool extern_third_dataset_visible=false; + + +#endif /* EXTERN_VAR_H_ */ diff --git a/src/geometry/FacilityGeometry.cpp b/src/geometry/FacilityGeometry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cf6d2f6f92404600ebe9684016910d8821707398 --- /dev/null +++ b/src/geometry/FacilityGeometry.cpp @@ -0,0 +1,613 @@ +/** + * @file FacilityGeometry.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * @brief method for plotting the different geometry/Building elements + * + * Created on: 07.05.2009 + * + */ + +#include "FacilityGeometry.h" +#include "Point.h" +#include "../SystemSettings.h" +#include "LinePlotter2D.h" + +#include <vtkActor.h> +#include <vtkPolyDataMapper.h> +#include <vtkProperty.h> +#include <vtkAssembly.h> +#include <vtkCylinderSource.h> +#include <vtkSphereSource.h> +#include <vtkDiskSource.h> +#include <vtkCubeSource.h> +#include <vtkDataSetMapper.h> +#include <vtkLookupTable.h> +#include <vtkCellData.h> +#include <vtkPointData.h> +#include <vtkImageData.h> +#include <vtkProp3DCollection.h> +#include <vtkSmartPointer.h> + +#include <vtkCaptionRepresentation.h> +#include <vtkCaptionActor2D.h> +#include <vtkTextActor.h> +#include <vtkCaptionWidget.h> +#include <vtkTextActor3D.h> +#include <vtkTextProperty.h> +#include <vtkActor2DCollection.h> + + +#define PI 3.1415926535 + +using namespace std; + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + + +FacilityGeometry::FacilityGeometry() { + + assembly = vtkAssembly::New(); + assembly2D = vtkAssembly::New(); + assemblyCaptions= vtkAssembly::New(); + + captions=vtkActor2DCollection::New(); + + linesPlotter2D = new LinePlotter2D(); + + // initializing the lookup table for the colors + // rainbow colors ranging from red to blue + lookupTable = vtkLookupTable::New(); + lookupTable->SetTableRange(0,255); + //lookupTable->SetHueRange(0.0,0.566); + //lut->SetSaturationRange(0,0); + //lut->SetValueRange(0.0,1.0); + lookupTable->SetNumberOfTableValues(256); + lookupTable->Build(); + + // geometry parameters all in cm + doorThickness = 3; + wallThickness = 3; + wallHeight=250; + doorHeight=250; + stepHeight = 40; + wallColor = 255; + stepColor = 130; + doorColor = 50; + +} + +FacilityGeometry::~FacilityGeometry() { + if(assembly) + assembly->Delete(); + + lookupTable->Delete(); + + delete linesPlotter2D; +} + +//todo: +// each time this is called, the assemblies parts are added +// very bad + +vtkAssembly* FacilityGeometry::getActor(){ + + assembly2D->AddPart(linesPlotter2D->createAssembly()); + assembly2D->AddPart(assemblyCaptions); + + return assembly2D; +} + + +//void FacilityGeometry::drawWall(Point *p1, Point *p2){ +// double scale =1; +// +// double *center = p1->centreCoordinatesWith(*p2); +// double angle =p1->angleMadeWith(*p2); +// +// vtkCylinderSource* src = vtkCylinderSource::New(); +// src->SetResolution(10); +// src->SetCenter(center[0],center[1],center[2]); +// src->SetRadius(scale*3); +// src->SetHeight(p1->distanceTo(*p2)); +// vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); +// mapper->SetInputConnection(src->GetOutputPort()); +// vtkActor* actor = vtkActor::New(); +// actor->SetMapper(mapper); +// actor->GetProperty()->SetLighting(true); +// actor->SetOrigin(center[0],center[1],center[2]); +// //actor->SetOrientation(0,0,90); +// //actor->RotateZ(90); +// actor->RotateZ(angle); +// actor->GetProperty()->SetColor(0.0,0.0,1.0); +// actor->GetProperty()->SetAmbient(0.2); +// actor->GetProperty()->SetDiffuse(0.8); +// +// assembly->AddPart(actor); +// +//} + +//void FacilityGeometry::drawDoor(Point *p1, Point *p2){ +// double *center = p1->centreCoordinatesWith(*p2); +// double angle =p1->angleMadeWith(*p2); +// +// vtkCylinderSource* src = vtkCylinderSource::New(); +// src->SetResolution(40); +// src->SetCenter(center[0],center[1],center[2]); +// src->SetRadius(4); +// src->SetHeight(p1->distanceTo(*p2)); +// vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); +// mapper->SetInputConnection(src->GetOutputPort()); +// vtkActor* actor = vtkActor::New(); +// actor->SetMapper(mapper); +// actor->GetProperty()->SetLighting(true); +// actor->SetOrigin(center[0],center[1],center[2]); +// //actor->SetOrientation(0,0,90); +// //actor->RotateZ(90); +// actor->RotateZ(angle); +// //actor->GetProperty()->SetColor(0.0,0.1,0.0); +// actor->GetProperty()->SetColor(1.0,0.41,0.72); +// //actor->GetProperty()->SetColor(0.0,0.0,0.0); +// assembly->AddPart(actor); +// +//} + +/*** + * This is the main build method and should be called by all functions + * drawing a wall or a door. Important + */ +//void FacilityGeometry::addNewElement(double center[3], double length, double orientation, ELEMENT_TYPE type){ +// +// vtkCubeSource* src = vtkCubeSource::New(); +// src->SetCenter(center[0],center[1],center[2]); +// src->SetYLength(length); +// +// vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); +// mapper->SetInputConnection(src->GetOutputPort()); +// src->Delete(); +// +// vtkActor* actor = vtkActor::New(); +// actor->SetMapper(mapper); +// mapper->Delete(); +// actor->GetProperty()->SetLighting(true); +// actor->SetOrigin(center[0],center[1],center[2]); +// actor->RotateZ(orientation); +// actor->GetProperty()->SetAmbient(0.2); +// actor->GetProperty()->SetDiffuse(0.8); +// +// // double data[3]; +// // actor->GetPosition(data); +// // actor->SetPosition(data[0],data[1],src->GetZLength()/2); +// +// switch (type) +// { +// case DOOR: +// { +// double colorRGB[3]; +// lookupTable->GetColor(doorColor, colorRGB); +// actor->GetProperty()->SetColor(colorRGB); +// src->SetXLength(doorThickness); +// src->SetZLength(doorHeight); +// //src->SetRadius(doorWidth); +// actor->GetProperty()->SetOpacity(1.00); +// assemblyDoors3D->AddPart(actor); +// } +// break; +// case WALL: +// { +// double colorRGB[3]; +// lookupTable->GetColor(wallColor, colorRGB); +// actor->GetProperty()->SetColor(colorRGB); +// //actor->GetProperty()->SetSpecular(1); +// //actor->GetProperty()->SetDiffuse(1); +// //actor->GetProperty()->SetAmbient(1); +// +// src->SetXLength(wallThickness); +// src->SetZLength(wallHeight); +// //src->SetRadius(wallWidth); +// assemblyWalls3D->AddPart(actor); +// } +// break; +// case STEP: +// { +// double colorRGB[3]; +// lookupTable->GetColor(stepColor, colorRGB); +// actor->GetProperty()->SetColor(colorRGB); +// src->SetXLength(wallThickness); //FIXME, this is wrong +// src->SetZLength(stepHeight); +// assemblyDoors3D->AddPart(actor); +// } +// break; +// +// //default behaviour not defined +// default: +// break; +// } +// +// // now adjusting the z coordinates +// double data[3]; +// actor->GetPosition(data); +// actor->SetPosition(data[0],data[1],src->GetZLength()/2); +// +// actor->Delete(); +//} + +void FacilityGeometry::addWall(double x1, double y1, double x2, double y2, double z,double thickness,double height,double color){ + + // all walls will have this parameters until changed + wallColor=color; + + // if(SystemSettings::get2D()){ + double m[]={x1,y1,z}; + double n[]={x2,y2,z}; + linesPlotter2D->PlotWall(m,n,wallColor/255.0); +} + +void FacilityGeometry::addDoor(double x1, double y1, double x2, double y2, double z,double thickness ,double height, double color){ + + // all doors will take this color upon changed + doorColor=color; + //constructing the 2D assembly + // if(SystemSettings::get2D()){ + double m[]={x1,y1,z}; + double n[]={x2,y2,z}; + + //double m[]={x1,y1,z+1}; + //double n[]={x2,y2,z+1}; + + printf("[%f %f %f]---[%f %f %f]\n",x1,y1,z,x2,y2,z); + linesPlotter2D->PlotDoor(m,n,doorColor/255.0); +} + +void FacilityGeometry::addStep(double x1, double y1, double x2, double y2, double z) +{ + double m[]={x1,y1,z}; + double n[]={x2,y2,z}; + linesPlotter2D->PlotDoor(m,n,doorColor/255.0); +} + +void FacilityGeometry::addStep(Point* p1, Point* p2){ + + double m[3]; + double n[3]; + double CHT[3]; + + p1->getXYZ(m); + p2->getXYZ(n); + p1->getColorHeightThicknes(CHT); + + stepHeight=CHT[1]; + stepColor = CHT[0]; + + linesPlotter2D->PlotDoor(m,n,doorColor/255.0); + +} + +void FacilityGeometry::addWall(Point* p1, Point* p2, string caption){ + double m[3]; + double n[3]; + double CHT[3]; + p1->getXYZ(m); + p2->getXYZ(n); + p1->getColorHeightThicknes(CHT); + + wallThickness = CHT[2]; + wallHeight=CHT[1]; + wallColor = CHT[0]; + linesPlotter2D->PlotWall(m,n,wallColor/255.0); + + + if (caption.compare("") != 0){ + + double center[3]; + center[0]=0.5*(m[0]+n[0]); + center[1]=0.5*(m[1]+n[1]); + center[2]=0.5*(m[2]+n[2]); + double orientation[3]={0,0,0}; + addNewElementText(center,orientation,caption.c_str(),50); + } + +} + +void FacilityGeometry::addDoor(Point* p1, Point* p2, string caption){ + + double m[3]; + double n[3]; + double CHT[3]; + + p1->getXYZ(m); + p2->getXYZ(n); + //to get the exits over the walls + //m[0]++; m[1]++; m[2]++; + //n[0]++; n[1]++; n[2]++; + p1->getColorHeightThicknes(CHT); + + doorThickness = CHT[2]; + doorHeight=CHT[1]; + doorColor = CHT[0]; + + linesPlotter2D->PlotDoor(m,n,doorColor/255.0); + + + + if (caption.compare("") != 0){ + + double center[3]; + center[0]=0.5*(m[0]+n[0]); + center[1]=0.5*(m[1]+n[1]); + center[2]=0.5*(m[2]+n[2]); + double orientation[3]={0,0,0}; + addNewElementText(center,orientation,caption.c_str(),0); + } + +} + + +void FacilityGeometry::addFloor(double x1, double y1, double x2, double y2, double z){ + //if(z!=1)return; + const double cellSize=40; //cm + // const int dimX=(x2-x1)/cellSize+1; + // const int dimY=(y2-y1)/cellSize+1; + const int dimX= (int)ceil((x2-x1)/cellSize) +1; + const int dimY= (int)ceil((y2-y1)/cellSize) +1; + + + const int dimZ=1; + //vtkDoubleArray *scalars = vtkDoubleArray::New(); + vtkDataArray* pData = vtkUnsignedCharArray::New(); + pData->SetNumberOfComponents(3); + + double color[2][3]={{100, 100, 100},{150,150,150}}; + bool idx=0; + bool firstIdx=1; + + // for(int i=0;i<dimX-1;i++){ + // firstIdx=!firstIdx; + // idx=firstIdx; + // for(int j=0;j<dimY-1;j++){ + // pData->InsertNextTuple3(color[idx][0],color[idx][1],color[idx][2]); + // idx=!idx; + // } + // } + // bool lastColorUsed=0; + // for(int i=0;i<dimX-1;i++){ + // + // if(idx==lastColorUsed){ + // lastColorUsed= !lastColorUsed; + // idx=lastColorUsed; + // }else{ + // lastColorUsed=idx; + // } + // + // for(int j=0;j<dimY-1;j++){ + // pData->InsertNextTuple3(color[idx][0],color[idx][1],color[idx][2]); + // idx=!idx; + // } + // } + + bool lastColorUsed=0; + for(int i=0;i<dimY-1;i++){ + + if(idx==lastColorUsed){ + lastColorUsed= !lastColorUsed; + idx=lastColorUsed; + }else{ + lastColorUsed=idx; + } + + for(int j=0;j<dimX-1;j++){ + pData->InsertNextTuple3(color[idx][0],color[idx][1],color[idx][2]); + idx=!idx; + } + } + + // data as cellData of imageData + VTK_CREATE(vtkImageData, image); + image->SetDimensions(dimX, dimY, dimZ); + image->SetSpacing(cellSize, cellSize, cellSize); + image->GetCellData()->SetScalars(pData); + + + VTK_CREATE(vtkActor, imageActor); + VTK_CREATE(vtkDataSetMapper, map); + map->SetInput(image); + //map->SetLookupTable(lookupTable); + imageActor->SetMapper(map); + imageActor->GetProperty()->SetAmbient(0.2); + //imageActor->GetProperty()->SetDiffuse(0.8); + + // move the actor in x-direction + imageActor->SetPosition(x1, y1, z); + assembly2D->AddPart(imageActor); + +} + + +void FacilityGeometry::addObjectSphere(double center[3], double radius, + double color) { + + double colorRGB[3]; + lookupTable->GetColor(color, colorRGB); + + //create a disk for the 2D world + { + VTK_CREATE(vtkDiskSource, disk); + disk->SetCircumferentialResolution(10); + disk->SetInnerRadius(0); + disk->SetOuterRadius(radius); + + VTK_CREATE(vtkPolyDataMapper, mapper); + mapper->SetInputConnection(disk->GetOutputPort()); + + VTK_CREATE(vtkActor, actor); + actor->SetMapper(mapper); + actor->GetProperty()->SetColor(colorRGB); + + actor->SetPosition(center[0], center[1], 0); + assembly2D->AddPart(actor); + } +} + + +void FacilityGeometry::addObjectCylinder(double center[3], double radius, + double height, double orientation[3],double color) { + + double colorRGB[3]; + lookupTable->GetColor(color, colorRGB); + + //create a disk for the 2D world + //TODO: this is of course a wrong projection + { + VTK_CREATE(vtkDiskSource, disk); + disk->SetCircumferentialResolution(10); + disk->SetInnerRadius(0); + disk->SetOuterRadius(radius); + + VTK_CREATE(vtkPolyDataMapper, mapper); + mapper->SetInputConnection(disk->GetOutputPort()); + + VTK_CREATE(vtkActor, actor); + actor->SetMapper(mapper); + actor->GetProperty()->SetColor(colorRGB); + + actor->SetPosition(center[0], center[1], 0); + assembly2D->AddPart(actor); + } +} + +void FacilityGeometry::addObjectBox(double center[3], double height, + double width, double length, double color) { + + double colorRGB[3]; + lookupTable->GetColor(color, colorRGB); + + { + VTK_CREATE(vtkCubeSource,src); + src->SetCenter(center[0], center[1], 0); + src->SetZLength(1); //todo: fake projection + src->SetYLength(length); + src->SetXLength(width); + + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInputConnection(src->GetOutputPort()); + + VTK_CREATE(vtkActor,actor); + actor->GetProperty()->SetLighting(true); + actor->SetOrigin(center[0], center[1], 0); + actor->GetProperty()->SetColor(colorRGB); + actor->GetProperty()->SetAmbient(0.2); + actor->GetProperty()->SetDiffuse(0.8); + actor->SetMapper(mapper); + assembly2D->AddPart(actor); + } +} + +void FacilityGeometry::changeWallsColor(double* color){ + + linesPlotter2D->changeWallsColor(color); + assembly2D->Modified(); +} + +void FacilityGeometry::changeExitsColor(double* color){ + + linesPlotter2D->changeDoorsColor(color); + assembly2D->Modified(); + +} + +void FacilityGeometry::set2D(bool status){ + assembly2D->SetVisibility(status); +} + +void FacilityGeometry::set3D(bool status){ +} + +void FacilityGeometry::showDoors(bool status){ + + linesPlotter2D->showDoors(status); + assembly2D->Modified(); +} + +void FacilityGeometry::showStairs(bool status){ + +} + +void FacilityGeometry::showWalls(bool status){ + linesPlotter2D->showWalls(status); + assembly2D->Modified(); +} + +void FacilityGeometry::addObjectLabel(double center[3], double orientation[3], std::string caption, double color){ + addNewElementText(center, orientation, caption, color); +} + +vtkActor2DCollection* FacilityGeometry::getCaptions(){ + return captions; +} +// orientation and color ignored +void FacilityGeometry::addNewElementText(double center[3], double orientation[3], + string text, double color) { + + return ; + + {//caption + VTK_CREATE(vtkTextActor3D,caption); + caption = vtkTextActor3D ::New(); + + //caption->SetVisibility(false); + caption->SetInput(text.c_str()); + // set the properties of the caption + //FARBE + vtkTextProperty* tprop = caption->GetTextProperty(); + tprop->SetFontFamilyToArial(); + tprop->BoldOn(); + //tprop->ShadowOn(); + //tprop->SetLineSpacing(1.0); + tprop->SetFontSize(SystemSettings::getPedestrianCaptionSize()); + + double colorRGB[3]; + lookupTable->GetColor(color, colorRGB); + tprop->SetColor(colorRGB); + //tprop->SetColor(1,0,0); + + caption->SetPosition(center); + assemblyCaptions->AddPart(caption); + + } +} + +void FacilityGeometry::showGeometryLabels(int status){ + + vtkProp3DCollection* col=assemblyCaptions->GetParts(); + assemblyCaptions->GetActors(col); + + int count = col->GetNumberOfItems(); + for (int i=0;i<count;i++){ + ((vtkActor*)col->GetItemAsObject(i))->SetVisibility(status); + } + assemblyCaptions->Modified(); + +} + diff --git a/src/geometry/FacilityGeometry.h b/src/geometry/FacilityGeometry.h new file mode 100644 index 0000000000000000000000000000000000000000..58abedae0f59fece81b95963568dcd03feee9f51 --- /dev/null +++ b/src/geometry/FacilityGeometry.h @@ -0,0 +1,152 @@ +/** +* @headerfile FacilityGeometry.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting the different geometry/Building elements +* +* Created on: 07.05.2009 +* +*/ + + +#ifndef FACILITYGEOMETRY_H_ +#define FACILITYGEOMETRY_H_ + +#include<string> + +//forwarded classes +class vtkPolyData; +class vtkActor; +class Point; +class vtkAssembly; +class vtkDataSet; +class vtkLookupTable; +class LinePlotter2D; +class vtkActor2DCollection; + +class FacilityGeometry{ + + +public: + + /** + * Building element types that are actually supported + */ + enum ELEMENT_TYPE{ + DOOR, //!< DOOR defined by two coordinates points are needed. + STEP, //!< STEP @todo not fully implemented + WALL, //!< WALL defined by two coordinates points are needed. + SPHERE, //!< SPHERE defined by centre[x,y,z] and radius. + CONE, //!< CONE defined by centre, radius and height + CYLINDER,//!< CYLINDER defined by centre ,radius and height + BOX //!< BOX defined by centre, length, width and height + }; + + FacilityGeometry(); + virtual ~FacilityGeometry(); + + vtkAssembly* getActor(); + + vtkActor2DCollection* getCaptions(); + + ///draw a wall + void addWall(double x1, double y1, double x2, double y2, double z=0, double thickness=15, double height=250,double col=255); + //void addWall(double center[3], double width, double orientation); + void addWall(Point* p1, Point* p2, std::string caption=""); + + ///draw a door + void addDoor(double x1, double y1, double x2, double y2, double z=0, double thickness=17, double height=250,double col=30); + //void addDoor(double center[3], double width, double orientation); + void addDoor(Point* p1, Point* p2, std::string caption=""); + + ///draw a step + ///todo: implement thickness and color + void addStep(double x1, double y1, double x2, double y2, double z=0/*, double thickness=30, double height=10,double col=50*/); + //void addStep(double center[3], double width, double orientation); + void addStep(Point* p1, Point* p2); + + /// draw a floor, divided in cells, + void addFloor(double x1, double y1, double x2, double y2, double z=0); + + /// draw other kinds of objects + void addObjectSphere(double center[3], double radius, double couleur=1); + void addObjectCone(double center[3], double height, double radius, double couleur=2); + void addObjectCylinder(double center[3],double radius, double height,double orientation[3], double couleur =3); + void addObjectBox(double center[3],double height, double width, double length, double couleur =4); + void addObjectLabel(double center[3], double orientation[3], std::string caption, double color); + + void changeWallsColor(double* color); + void changeExitsColor(double* color); + + void set2D(bool status); + void set3D(bool status); + + void showDoors(bool status); + void showStairs(bool status); + void showWalls(bool status); + void showGeometryLabels(int v); + + +private: + // TODO Check if this function is really necessary + //vtkActor* MapToActor(vtkDataSet *ds); //for drawing floor + vtkLookupTable* lookupTable; + void drawWall(Point* p1, Point* p2); + void drawDoor(Point* p1, Point* p2); + void addNewElement(double center[3], double orientation, double width, ELEMENT_TYPE type); + void addNewElementText(double center[3], double orientation[3], std::string text, double color); + + // geometry parameters + double doorThickness ; + double wallThickness ; + double wallHeight; + double doorHeight; + double stepHeight; + double wallColor; + double stepColor; + double doorColor; + + // geometry assembly + vtkAssembly* assembly; + + //2-d parts + LinePlotter2D* linesPlotter2D; + vtkAssembly* assembly2D; + +// // 3-d parts +// vtkAssembly* assemblyObjects; +// vtkAssembly* assemblyWalls3D; +// vtkAssembly* assemblyDoors3D; +// vtkAssembly* assembly3D; + + // other parts + vtkAssembly* assemblyCaptions; + + vtkActor2DCollection* captions; + + + +}; + +#endif /* FACILITYGEOMETRY_H_ */ diff --git a/src/geometry/LinePlotter.cpp b/src/geometry/LinePlotter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2ba403c6f94d85912a612c40936396434f12ea1d --- /dev/null +++ b/src/geometry/LinePlotter.cpp @@ -0,0 +1,225 @@ +/** +* @file LinePlotter.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting Plot a lot of straight lines,<br> and create a single actor to render +* +* Created on: 17.05.2009 +* +*/ + +#include <vtkLookupTable.h> +#include <vtkPoints.h> +#include <vtkCellArray.h> +#include <vtkFloatArray.h> +#include <vtkPolyData.h> +#include <vtkPolyDataMapper.h> +#include <vtkActor.h> +#include <vtkPointData.h> +#include <vtkDataArray.h> +#include <vtkProperty.h> +#include <vtkSmartPointer.h> + + +#include "Point.h" +#include "./src/SystemSettings.h" +#include "LinePlotter.h" + +int LinePlotter::m_allLineWidth = 2; + + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + + +LinePlotter::LinePlotter() +{ + m_curPointID = 0; + + m_scalars = vtkUnsignedCharArray::New(); + m_scalars->SetNumberOfComponents(3); + m_points = vtkPoints::New(); + m_lines = vtkCellArray::New(); + + //m_lineScalars = vtkFloatArray::New(); + // create a color lookup table + //m_lookupTable = vtkLookupTable::New(); + + //create the poly data +// vtkPolyData* polyData = vtkPolyData::New(); + VTK_CREATE(vtkPolyData,polyData); + polyData->SetPoints(m_points); + polyData->SetLines(m_lines); + //polyData->SetVerts(m_lines); + polyData->GetPointData()->SetScalars(m_scalars); + + // create mapper + VTK_CREATE(vtkPolyDataMapper,mapper); + //vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInput(polyData); + //polyData->Delete(); + + // mapper->SetLookupTable(m_lookupTable); + // mapper->SetColorModeToMapScalars(); + // mapper->SetScalarRange(m_scalarMin, m_scalarMax); + // mapper->SetScalarModeToUsePointData(); + + // create actor + m_lineActors = vtkActor::New(); + m_lineActors->SetMapper(mapper); + //mapper->Delete(); + m_lineActors->GetProperty()->SetLineWidth(m_allLineWidth); +} + +LinePlotter::~LinePlotter() +{ + m_points->Delete(); + m_lineActors->Delete(); + m_lines->Delete(); + m_scalars->Delete(); +} + +void LinePlotter::setLineWidth(int width) { + m_allLineWidth = width; +} + +void LinePlotter::SetNumberOfPoints(int nPoints) { + //m_lines->InsertNextCell(nPoints); + m_lines->InsertNextCell(nPoints); +} + + +void LinePlotter::PlotLine(Point* pt1, Point* pt2) { + + double m[3], n[3]; + unsigned char col[3]; + + m[0] = pt1->getX(); + m[1] = pt1->getY(); + m[2] = pt1->getZ(); + + n[0] = pt2->getX(); + n[1] = pt2->getY(); + n[2] = pt2->getZ(); + + col[0] = pt1->getR(); + col[1] = pt1->getG(); + col[2] = pt1->getB(); + PlotLine(m,n,col); + +} + + +void LinePlotter::addVertex(Point *pt1) { + double m[3]; + unsigned char col[3]; + + m[0] = pt1->getX(); + m[1] = pt1->getY(); + m[2] = pt1->getZ()+10; + + col[0] = pt1->getR(); + col[1] = pt1->getG(); + col[2] = pt1->getB(); + +// //m_points->InsertNextPoint(m); +// m_points->InsertPoint(m_curPointID,m); +// m_scalars->InsertTuple3(m_curPointID,col[0], col[1], col[2]); +// m_lines->InsertCellPoint(m_curPointID++); +// m_scalars->Modified(); +// m_points->Modified(); +// m_lines->Modified(); + + //m_points->InsertNextPoint(m); + m_points->InsertNextPoint(m); + m_scalars->InsertTuple3(m_curPointID,col[0], col[1], col[2]); + m_lines->InsertCellPoint(m_curPointID++); + m_scalars->Modified(); + m_points->Modified(); + m_lines->Modified(); + +} + +void LinePlotter::addVertex(double vertex[3],double col[3]) { + + Point *pts = new Point(); + pts->setColorRGB(col[0],col[1],col[2]); + pts->setXYZ(vertex); + addVertex(pts); + + delete pts; +} + +// caution: +// this work only for a line with 2 points. so for a line +// not a polyline +void LinePlotter::PlotLine(double m[3], double n[3], unsigned char col[3]) { + + + m_points->InsertNextPoint(m); + m_points->InsertNextPoint(n); + + m_scalars->InsertNextTuple3(col[0], col[1], col[2]); + + m_lines->InsertNextCell(2); + m_lines->InsertCellPoint(m_curPointID); + m_lines->InsertCellPoint(m_curPointID + 1); + + m_curPointID += 2; + + // force the update + m_scalars->Modified(); + m_points->Modified(); + m_lines->Modified(); + +} +void LinePlotter::PlotLine(double x, double y, double z, double x2, double y2, + double z2, unsigned char color[3]) { + double m[3], n[3]; + m[0] = x; + m[1] = y; + m[2] = z; + n[0] = x2; + n[1] = y2; + n[2] = z2; + PlotLine(m, n,color); + +} + +vtkActor* LinePlotter::getActor() { + + return m_lineActors; +} +void LinePlotter::clear() { + + m_curPointID = 0; + m_points->Squeeze(); + m_lines->Squeeze(); + + m_points->Reset(); + m_lines->Reset(); + + m_lineActors->GetProperty()->SetLineWidth(m_allLineWidth); + +} diff --git a/src/geometry/LinePlotter.h b/src/geometry/LinePlotter.h new file mode 100644 index 0000000000000000000000000000000000000000..299209269c48268ee95da3c20cc306f5e5613761 --- /dev/null +++ b/src/geometry/LinePlotter.h @@ -0,0 +1,82 @@ +/** +* @headerfile LinePlotter.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting Plot a lot of straight lines,<br> and create a single actor to render +* +* Created on: 17.05.2009 +* +*/ + + +#ifndef LINE_PLOTTER_H +#define LINE_PLOTTER_H + +class vtkLookupTable ; +class vtkPoints ; +class vtkCellArray ; +class vtkFloatArray ; +class vtkActor ; +class vtkPolyData; +class vtkDataArray; +class Point; + + +class LinePlotter +{ +public: + + LinePlotter(); + ~LinePlotter(); + + //void SetScalarRange(double minval=0.0, double maxval=1.0); + //void SetLookupTable(vtkLookupTable* table = 0); + + void PlotLine(Point* pt1, Point* pt2); + void PlotLine(double m[3], double n[3], unsigned char scalar[3]); + void PlotLine(double x, double y, double z, + double x2, double y2, double z2, unsigned char scalar[3]); + void addVertex(double vertex[3],double scalar[3]); + void addVertex(Point* pt1); + void SetNumberOfPoints(int nPoints); + void clear(); + static void setLineWidth(int width=1); + vtkActor* getActor(); + +private: + //double m_scalarMin, m_scalarMax ; + //vtkLookupTable* m_lookupTable ; + int m_curPointID ; + static int m_allLineWidth ; + //unsigned char colour[3]; + + vtkPoints* m_points; + vtkActor* m_lineActors; + vtkCellArray* m_lines; + //vtkFloatArray* m_lineScalars ; + vtkDataArray* m_scalars ; + +}; + +#endif // LINE_PLOTTER_H diff --git a/src/geometry/LinePlotter2D.cpp b/src/geometry/LinePlotter2D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0eb3ad729bd248dd0d04ee03e032aac7084c752d --- /dev/null +++ b/src/geometry/LinePlotter2D.cpp @@ -0,0 +1,289 @@ +/** + * @file LinePlotter2D.h + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * + * + * + * Created on: 22.05.2009 + * + */ + + +#include "LinePlotter2D.h" +#include "../SystemSettings.h" + +#include <vtkLookupTable.h> +#include <vtkPoints.h> +#include <vtkCellArray.h> +#include <vtkFloatArray.h> +#include <vtkPolyData.h> +#include <vtkPolyDataMapper.h> +#include <vtkActor.h> +#include <vtkPointData.h> +#include <vtkProperty.h> +#include <vtkAssembly.h> +#include <vtkSmartPointer.h> + + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + +bool LinePlotter2D::doorColorsToDefault=true; + +LinePlotter2D::LinePlotter2D() +:m_scalarMin(0.0), m_scalarMax(1.0) +{ + + assembly=vtkAssembly::New(); + + door_mapper= vtkPolyDataMapper::New(); + door_actor= vtkActor::New(); + door_points = vtkPoints::New(); + door_lines = vtkCellArray::New(); + door_lineScalars = vtkFloatArray::New(); + door_curPointID=0; + door_width=3.5; + + wall_mapper= vtkPolyDataMapper::New(); + wall_actor= vtkActor::New(); + wall_points = vtkPoints::New(); + wall_lines = vtkCellArray::New(); + wall_lineScalars = vtkFloatArray::New(); + wall_curPointID=0; + wall_width=2; + + + // create a color lookup table + m_lookupTable = vtkLookupTable::New(); + m_lookupTable->SetTableRange(0,255); + m_lookupTable->SetNumberOfTableValues(256); + + // m_lookupTable->SetHueRange(0.0,0.566); + // m_lookupTable->SetSaturationRange(0,0); + // m_lookupTable->SetValueRange(0.0,1.0); + + //m_lookupTable->SetHueRange(0.0,0.0); + //m_lookupTable->SetValueRange(0.0,1.0); + //m_lookupTable->SetSaturationRange(0.0,0.0); + m_lookupTable->Build(); + + + +} + +LinePlotter2D::~LinePlotter2D(){ + + m_lookupTable->Delete(); + assembly->Delete(); + door_points->Delete(); + door_lines->Delete(); + door_lineScalars->Delete(); + door_mapper->Delete(); + door_actor->Delete(); + wall_points->Delete(); + wall_lines->Delete(); + wall_lineScalars->Delete(); + wall_mapper->Delete(); + wall_actor->Delete(); +} + +void LinePlotter2D::SetScalarRange(double minval, double maxval) +{ + m_scalarMin = minval ; + m_scalarMax = maxval ; +} + +//void LinePlotter2D::SetLookupTable(vtkLookupTable* table) +//{ +// m_lookupTable = table ; +//} +//void LinePlotter2D::PlotLine(double m[3], double n[3], double scalar) +//{ +// +// m_lineScalars->SetNumberOfComponents(1); +// m_points->InsertNextPoint(m); +// m_lineScalars->InsertNextTuple1(scalar); +// m_points->InsertNextPoint(n); +// m_lineScalars->InsertNextTuple1(scalar); +// +// m_lines->InsertNextCell(2); +// m_lines->InsertCellPoint(m_curPointID); +// m_lines->InsertCellPoint(m_curPointID+1); +// +// m_curPointID+=2; +//} +//void LinePlotter2D::PlotLine(double x, double y, double z, +// double x2, double y2, double z2, double scalar) +//{ +// double m[3],n[3] ; +// m[0]=x; m[1]=y; m[2]=z; +// n[0]=x2; n[1]=y2; n[2]=z2; +// PlotLine(m,n,scalar); +// +//} + + +void LinePlotter2D::SetAllLineWidth(int width) +{ + //m_allLineWidth = width ; +} + +void LinePlotter2D::PlotDoor(double m[3], double n[3], double scalar) +{ + door_points->InsertNextPoint(m); + door_lineScalars->InsertNextTuple1(scalar); + door_points->InsertNextPoint(n); + door_lineScalars->InsertNextTuple1(scalar); + + door_lines->InsertNextCell(2); + door_lines->InsertCellPoint(door_curPointID); + door_lines->InsertCellPoint(door_curPointID+1); + + door_curPointID+=2; + + if(scalar!=1.0){ + doorColorsToDefault=false; + } +} + +void LinePlotter2D::changeWallsColor(double *col) +{ + //first switch off the automatic mapping + wall_mapper->SetScalarVisibility(0); + //then set the new color + wall_actor->GetProperty()->SetColor(col); +} + +void LinePlotter2D::changeDoorsColor(double *col) +{ + //first switch off the automatic mapping + door_mapper->SetScalarVisibility(0); + //then set the new color + door_actor->GetProperty()->SetColor(col); +} + +void LinePlotter2D::PlotWall(double m[3], double n[3], double scalar) +{ + wall_points->InsertNextPoint(m); + wall_lineScalars->InsertNextTuple1(scalar); + wall_points->InsertNextPoint(n); + wall_lineScalars->InsertNextTuple1(scalar); + + wall_lines->InsertNextCell(2); + wall_lines->InsertCellPoint(wall_curPointID); + wall_lines->InsertCellPoint(wall_curPointID+1); + + wall_curPointID+=2; +} + +//vtkPolyData* LinePlotter2D::CreatePolyData() +//{ +// // Create poly data +// vtkPolyData* polyData = vtkPolyData::New(); +// polyData->SetPoints(m_points); +// polyData->SetLines(m_lines); +// polyData->GetPointData()->SetScalars(m_lineScalars); +// return polyData; +//} + +//vtkActor* LinePlotter2D::CreateActor() +//{ +// // Create poly data +// vtkPolyData* polyData = CreatePolyData(); +// // create mapper +// vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); +// mapper->SetInput(polyData); +// mapper->SetLookupTable(m_lookupTable); +// mapper->SetColorModeToMapScalars(); +// //mapper->SetScalarRange(m_scalarMin, m_scalarMax); +// mapper->SetScalarModeToUsePointData(); +// +// // create actor +// vtkActor* actor = vtkActor::New(); +// actor->SetMapper(mapper); +// actor->GetProperty()->SetLineWidth(m_allLineWidth); +// +// return actor ; +//} + +vtkAssembly* LinePlotter2D::createAssembly(){ + //doors + { + // Create poly data + //vtkPolyData* polyData =vtkPolyData::New(); + VTK_CREATE(vtkPolyData,polyData); + polyData->SetPoints(door_points); + polyData->SetLines(door_lines); + polyData->GetPointData()->SetScalars(door_lineScalars); + + // create mapper + door_mapper->SetInput(polyData); + door_mapper->SetLookupTable(m_lookupTable); + door_mapper->SetColorModeToMapScalars(); + //mapper->SetScalarRange(m_scalarMin, m_scalarMax); + door_mapper->SetScalarModeToUsePointData(); + // create actor + door_actor->SetMapper(door_mapper); + door_actor->GetProperty()->SetLineWidth(door_width); + assembly->AddPart(door_actor); + + //if default, then hide all doors + // fixme: not working + if(doorColorsToDefault){ + double col[3]={1.0,1.0,1.0}; + SystemSettings::getBackgroundColor(col); + door_actor->GetProperty()->SetColor(col); + door_actor->Modified(); + } + } + + //walls + { + // Create poly data + VTK_CREATE(vtkPolyData,polyData); + polyData->SetPoints(wall_points); + polyData->SetLines(wall_lines); + polyData->GetPointData()->SetScalars(wall_lineScalars); + + // create mapper + wall_mapper->SetInput(polyData); + wall_mapper->SetLookupTable(m_lookupTable); + wall_mapper->SetColorModeToMapScalars(); + //mapper->SetScalarRange(m_scalarMin, m_scalarMax); + wall_mapper->SetScalarModeToUsePointData(); + // create actor + wall_actor->SetMapper(wall_mapper); + wall_actor->GetProperty()->SetLineWidth(wall_width); + assembly->AddPart(wall_actor); + } + + return assembly; +} + +void LinePlotter2D::showDoors(bool status){ + door_actor->SetVisibility(status); +} +void LinePlotter2D::showWalls(bool status){ + wall_actor->SetVisibility(status); +} diff --git a/src/geometry/LinePlotter2D.h b/src/geometry/LinePlotter2D.h new file mode 100644 index 0000000000000000000000000000000000000000..4304577fe695a5305085e6b4b4382b4514b05b6b --- /dev/null +++ b/src/geometry/LinePlotter2D.h @@ -0,0 +1,98 @@ +/** + * @file LinePlotter2D.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * + * + * Created on: 22.05.2009 + * + */ + + + +#ifndef LINE_PLOTTER2D_H +#define LINE_PLOTTER2D_H + +class vtkLookupTable; +class vtkPoints; +class vtkCellArray; +class vtkFloatArray; +class vtkActor; +class vtkAssembly; +class vtkPolyData; +class vtkPolyDataMapper; + + +class LinePlotter2D +{ +public: + + LinePlotter2D(); + ~LinePlotter2D(); + + void SetScalarRange(double minval=0.0, double maxval=1.0); + + void SetAllLineWidth(int width = 1); + + void PlotDoor(double m[3], double n[3], double scalar); + void changeDoorsColor(double* col); + + void PlotWall(double m[3], double n[3], double scalar); + void changeWallsColor(double *col); + + void showDoors(bool status); + void showWalls(bool status); + + vtkAssembly* createAssembly(); + static bool doorColorsToDefault; + +private: + + double m_scalarMin, m_scalarMax ; + vtkLookupTable* m_lookupTable ; + + + vtkAssembly* assembly; + + + /// doors parameters + int door_curPointID ; + float door_width; + vtkPoints* door_points; + vtkCellArray* door_lines; + vtkFloatArray* door_lineScalars ; + vtkPolyDataMapper* door_mapper; + vtkActor* door_actor; + + /// walls parameters + int wall_curPointID ; + float wall_width; + vtkPoints* wall_points; + vtkCellArray* wall_lines; + vtkFloatArray* wall_lineScalars ; + vtkPolyDataMapper* wall_mapper; + vtkActor* wall_actor; + +}; + +#endif // LINE_PLOTTER2D_H diff --git a/src/geometry/Point.cpp b/src/geometry/Point.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2a884aa038bdbb127ca17282a3072cf610d8af31 --- /dev/null +++ b/src/geometry/Point.cpp @@ -0,0 +1,157 @@ +/** + * @headerfile Point.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * @brief method for plotting Plot a lot of straight lines,<br> and create a single actor to render + * + * Created on: 17.05.2009 + * + */ + +#include "Point.h" +#include "../Debug.h" + +#include <vtkMath.h> +#include <math.h> + +#include <cstdio> +#include <cstdlib> +#include <iostream> + +Point::Point(double xyz[3], char color[]/*="abc"*/) { + x=xyz[0]; + y=xyz[1]; + z=xyz[2]; + r=color[0]; + g=color[1]; + b=color[2]; +} + + +Point::Point(double x, double y, double z, unsigned char r/*=100*/, unsigned char g/*=100*/ , unsigned char b/*=100*/){ + this->setColorRGB(r,g, b); + this->x=x; + this->y=y; + this->z=z; + +} +Point::Point(){ + x=0; + y=0; + z=0;//creates a point centered at the origin +} + +Point::~Point() { + +} + +void Point::setColorRGB(unsigned char r1, unsigned char g1,unsigned char b1){ + r=r1; + g=g1; + b=b1; +} + +void Point::setXYZ(double*xyz){ + x=xyz[0]; + y=xyz[1]; + z=xyz[2]; +} +void Point::getXYZ(double*xyz){ + xyz[0]=x; + xyz[1]=y; + xyz[2]=z; +} + +/* + * return the coordinates + */ +double Point::getX(){return x;} +double Point::getY(){return y;} +double Point::getZ(){return z;} + +/** + * return the angle of intersection between the 2 points and the x axis + * @return the angle in degree + * FIXME: why +90?? + */ +double Point::angleMadeWith(Point& pt){ + double dx=x-pt.x; + double dy=y-pt.y; + //double dist=distanceTo(pt); + + if((dx==0) && (dy==0)){ + Debug::Error("error found in geometry"); + Debug::Error("wrong angle might be returned"); + return 0; + //return vtkMath::DegreesFromRadians(asin(dx/dist)); + } + + // return vtkMath::DegreesFromRadians(asin(dx/dist)); + return vtkMath::DegreesFromRadians(atan2(dy,dx))+90 ; +} + +double Point::distanceTo(Point& pt){ + double dx=x-pt.x; dx*=dx; + double dy=y-pt.y; dy*=dy; + double dz=z-pt.z; dz*=dz; + return sqrt(dx+dy+dz); + +} +double * Point::centreCoordinatesWith(Point &pt){ + double *res= new double[3]; + res[0]=(x+pt.getX())/2; + res[1]=(y+pt.getY())/2; + res[2]=(z+pt.getZ())/2; + return res; +} + +double Point::distanceBetween(Point& pt1, Point& pt2){ + return pt1.distanceTo(pt2); +} +double Point::angleMadeBetween(Point& pt1, Point& pt2){ + return pt1.angleMadeWith(pt2); +} +double *Point::centreCoordinatesBetween(Point& pt1, Point& pt2){ + return pt1.centreCoordinatesWith(pt2); +} + +/* + * return the color + */ + +unsigned char Point::getR(){return r;} +unsigned char Point::getG(){return g;} +unsigned char Point::getB(){return b;} + + +void Point::setColorHeightThicknes(double CHT[3]){ + thickness=CHT[2]; + height=CHT[1]; + color=CHT[0]; +} +void Point::getColorHeightThicknes(double *CHT){ + CHT[0]=color; + CHT[1]=height; + CHT[2]=thickness; +} diff --git a/src/geometry/Point.h b/src/geometry/Point.h new file mode 100644 index 0000000000000000000000000000000000000000..f6f82e74608a720214d3990206aaf3b5dc0167a3 --- /dev/null +++ b/src/geometry/Point.h @@ -0,0 +1,77 @@ +/** +* @headerfile Point.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting Plot a lot of straight lines,<br> and create a single actor to render +* +* Created on: 17.05.2009 +* +*/ + + +#ifndef POINT_H_ +#define POINT_H_ + +class Point { +private: + double x,y,z; + unsigned char r,g,b; + double thickness; + double height; + double color; + +public: + Point(); //default constructor + Point(double x, double y, double z, unsigned char r='a', unsigned char g='b',unsigned char b='c'); + Point(double xyz[3], char col[]="abc"); + virtual ~Point(); + + double getX(); + double getY(); + double getZ(); + double distanceTo(Point& pt); + double angleMadeWith(Point &pt); + double* centreCoordinatesWith(Point &pt); + + static double distanceBetween(Point& pt1, Point& pt2); + static double angleMadeBetween(Point& pt1, Point& pt2); + static double *centreCoordinatesBetween(Point& pt1, Point& pt2); + + void setColorRGB(unsigned char r, unsigned char g, unsigned char b); + void getColorRGB(unsigned char *rgb); + + void setXYZ(double* xyz); + void getXYZ(double* xyz); + + unsigned char getR(); + unsigned char getG(); + unsigned char getB(); + + //methods for convenience in the case + //this is the end point of a door/wall for instance + void setColorHeightThicknes(double CHT[3]); + void getColorHeightThicknes(double *CHT); +}; + +#endif /* POINT_H_ */ diff --git a/src/geometry/PointPlotter.cpp b/src/geometry/PointPlotter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..99f25d7679f135cbec010519a492cd748a25d86a --- /dev/null +++ b/src/geometry/PointPlotter.cpp @@ -0,0 +1,127 @@ +/* + * PointPlotter.h + * + * Created on: 17.05.2009 + * Author: Ulrich Kemloh + */ + +#include <vtkPoints.h> +#include <vtkUnsignedCharArray.h> +#include <vtkPolyData.h> +#include <vtkActor.h> +#include <vtkDataArray.h> +#include <vtkGlyph3D.h> +#include <vtkDiskSource.h> +#include <vtkPolyDataMapper.h> +#include <vtkPointData.h> +#include <vtkSmartPointer.h> + +#include "Point.h" +#include "PointPlotter.h" +#include "./src/SystemSettings.h" + + +#define VTK_CREATE(type, name) \ + vtkSmartPointer<type> name = vtkSmartPointer<type>::New() + +PointPlotter::PointPlotter() +{ + + pts = vtkPoints::New(); + //pts->Allocate(30); + //pts->SetNumberOfPoints(30); + //pts->SetNumberOfPoints(MAX_POINTS); + SetPointRadius(2); + SetPointResolution(); + + scalars = vtkUnsignedCharArray::New(); + //scalars->Allocate(30); + scalars->SetNumberOfComponents(3); + //scalars->setn + + //vtkDiskSource* src = vtkDiskSource::New(); + VTK_CREATE(vtkDiskSource,src); + src->SetRadialResolution(5); + src->SetCircumferentialResolution(pt_res); + src->SetInnerRadius(0.00); + src->SetOuterRadius(pt_radius); + + + //vtkPolyData* polyData = vtkPolyData::New(); + VTK_CREATE(vtkPolyData,polyData); + polyData->SetPoints(pts); + polyData->GetPointData()->SetScalars(scalars); + +// vtkGlyph3D* glyph = vtkGlyph3D::New(); + VTK_CREATE(vtkGlyph3D,glyph); + glyph->SetSourceConnection(src->GetOutputPort()); + glyph->SetInput(polyData); + //src->Delete(); + //polyData->Delete(); + glyph->SetColorModeToColorByScalar(); + glyph->SetScaleModeToDataScalingOff() ; + + + //vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + VTK_CREATE(vtkPolyDataMapper,mapper); + mapper->SetInput(glyph->GetOutput()); + //glyph->Delete(); + + //vtkActor + pointActor = vtkActor::New(); + pointActor->SetMapper(mapper); + //mapper->Delete(); + + /// initizliae the ID + nextPointID=0; +} + +PointPlotter::~PointPlotter() +{ + if (pts) + pts->Delete(); + if (scalars) + scalars->Delete(); + if (pointActor) + pointActor->Delete(); +} + + +/*** + * add a point to the plot + */ + +void PointPlotter::PlotPoint(Point * point){ + double x=point->getX(); + double y=point->getY(); + double z=point->getZ(); + + unsigned char r=point->getR(); + unsigned char b=point->getB(); + unsigned char g=point->getG(); + PlotPoint( x, y, z, r, g, b); +} + +void PointPlotter::PlotPoint(double x, double y, double z, + unsigned char r, unsigned char g, unsigned char b) +{ + + nextPointID++; + int PointsCount=1, dummy=0,dummy1;; + + SystemSettings::getTrailsInfo(&PointsCount,&dummy,&dummy1); + + nextPointID=nextPointID%PointsCount; + pts->InsertPoint(nextPointID,x,y,z); + //pts->SetPoint(nextPointID,x,y,z); + //scalars->SetTuple3(nextPointID,r,g,b); + scalars->InsertTuple3(nextPointID,r,g,b); + //scalars->InsertNextTuple3(r,g,b); + + pts->Modified(); + scalars->Modified(); + +} + + +vtkActor * PointPlotter::getActor(){ return pointActor;} diff --git a/src/geometry/PointPlotter.h b/src/geometry/PointPlotter.h new file mode 100644 index 0000000000000000000000000000000000000000..a017f6d9c454f1d54ce2732beb9b4ccd08258bee --- /dev/null +++ b/src/geometry/PointPlotter.h @@ -0,0 +1,76 @@ +/** +* @headerfile PointPlotter.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting Plot a lot of points,<br> and create a single actor to render +* +* Created on: 07.05.2009 +* +*/ + +#ifndef POINT_PLOTTER_H +#define POINT_PLOTTER_H + +#define MAX_POINTS 30; + +#include "vtkSmartPointer.h" + +class vtkPoints ; +class vtkUnsignedCharArray ; +class vtkPolyData ; +class vtkActor ; +class vtkDataArray ; +class Point; + +class PointPlotter +{ +public: + + + PointPlotter(); + ~PointPlotter(); + + void PlotPoint(double x, double y, double z, + unsigned char r='a', unsigned char g='b', unsigned char b='c'); + + void PlotPoint(Point* pt); + void SetPointRadius(double radius = 1.0) { pt_radius = radius ; } + void SetPointResolution(int res = 15) { pt_res = res ;} + + + ///return the actors + vtkActor* getActor(); + +private: + + vtkActor* pointActor; + vtkPoints* pts ; + vtkDataArray* scalars ; + vtkIdType nextPointID; + int scalar_mode ; + double pt_radius ; + int pt_res ; +}; + +#endif // POINT_PLOTTER_H diff --git a/src/geometry/PointPlotter2D.cpp b/src/geometry/PointPlotter2D.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f93ce6222095defe12f652807b18f764e2cc104b --- /dev/null +++ b/src/geometry/PointPlotter2D.cpp @@ -0,0 +1,115 @@ +/** +* @headerfile PointPlotter2D.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting Plot a lot of points,<br> and create a single actor to render +* +* Created on: 07.05.2009 +* +*/ + +#include "PointPlotter2D.h" +#include "vtkPoints.h" +#include "vtkUnsignedCharArray.h" +#include "vtkPolyData.h" +#include "vtkActor.h" +#include "vtkDataArray.h" +#include "vtkGlyph3D.h" +#include "vtkDiskSource.h" +#include "vtkPolyDataMapper.h" +#include "vtkPointData.h" + +PointPlotter2D::PointPlotter2D() +{ + pts = NULL ; + scalars = NULL ; + + SetPointRadius(); + SetPointResolution(); + +} + +PointPlotter2D::~PointPlotter2D() +{ + if (pts) + pts->Delete(); + if (scalars) + scalars->Delete(); +} + +void PointPlotter2D::PlotPoint(double x, double y, double z, + unsigned char r, unsigned char g, unsigned char b) +{ + if (pts==NULL) + pts = vtkPoints::New(); + + if (scalars==NULL) + { + scalars = vtkUnsignedCharArray::New(); + scalars->SetNumberOfComponents(3); + } + + pts->InsertNextPoint(x,y,z); + scalars->InsertNextTuple3(r,g,b); + +} + +vtkPolyData* PointPlotter2D::CreatePolyData() +{ + vtkDiskSource* src = vtkDiskSource::New(); + src->SetRadialResolution(1); + src->SetCircumferentialResolution(pt_res); + + src->SetInnerRadius(0.0); + src->SetOuterRadius(pt_radius); + + + vtkPolyData* polyData = vtkPolyData::New(); + polyData->SetPoints(pts); + polyData->GetPointData()->SetScalars(scalars); + + vtkGlyph3D* glyph = vtkGlyph3D::New(); + glyph->SetSourceConnection(src->GetOutputPort()); + glyph->SetInput(polyData); + + glyph->SetColorModeToColorByScalar(); + glyph->SetScaleModeToDataScalingOff() ; + + + vtkPolyData* output = glyph->GetOutput(); + return output ; +} + +vtkActor* PointPlotter2D::CreateActor() +{ + vtkPolyData* polyData = CreatePolyData(); + + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + mapper->SetInput(polyData); + + vtkActor* actor = vtkActor::New(); + actor->SetMapper(mapper); + + return actor ; +} diff --git a/src/geometry/PointPlotter2D.h b/src/geometry/PointPlotter2D.h new file mode 100644 index 0000000000000000000000000000000000000000..d98d88700407ed3c60db55b1f84c5e02a15dcc9e --- /dev/null +++ b/src/geometry/PointPlotter2D.h @@ -0,0 +1,71 @@ +/** +* @headerfile PointPlotter2D.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief method for plotting Plot a lot of points(in 2D),<br> and create a single actor to render +* +* Created on: 07.05.2009 +* +*/ +#ifndef MY_VTK_POINT_PLOTTER_H +#define MY_VTK_POINT_PLOTTER_H + + +class vtkPoints ; +class vtkUnsignedCharArray ; +class vtkPolyData ; +class vtkActor ; +class vtkDataArray ; + +class PointPlotter2D +{ +public: + + + PointPlotter2D(); + ~PointPlotter2D(); + + + void PlotPoint(double x, double y, double z, + unsigned char r, unsigned char g, unsigned char b); + + void SetPointRadius(double radius = 1.0) { pt_radius = radius ; } + void SetPointResolution(int res = 15) { pt_res = res ;} + + + + vtkPolyData* CreatePolyData(); // call it after all points are plotted + vtkActor* CreateActor(); // call it after all points are plotted +private: + + + vtkPoints* pts ; + vtkDataArray* scalars ; + int scalar_mode ; + + double pt_radius ; + int pt_res ; +}; + +#endif // MY_VTK_POINT_PLOTTER_H diff --git a/src/geometry/jul/Building.cpp b/src/geometry/jul/Building.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5fac31f8b2322eb643da286da35e1ffde64dc9e3 --- /dev/null +++ b/src/geometry/jul/Building.cpp @@ -0,0 +1,350 @@ +/* + * File: Building.cpp + * Author: andrea + * + * Created on 1. Oktober 2010, 09:25 + */ + +#include "Building.h" + +/************************************************************ + Konstruktoren + ************************************************************/ + +Building::Building() { + pCaption = "no caption"; + pRooms = vector<Room > (); +} + +Building::Building(const Building& orig) { + pCaption = orig.GetCaption(); + pRooms = orig.GetAllRooms(); +} + +Building::~Building() { + if (pRooms.size() > 0) pRooms.clear(); +} + +/************************************************************* + Setter-Funktionen + ************************************************************/ +void Building::SetCaption(string s) { + pCaption = s; +} + +void Building::SetAllRooms(const vector<Room>& rooms) { + pRooms = rooms; +} + +void Building::SetRoom(const Room& room, int index) { + if ((index >= 0) && (index < (int) pRooms.size())) { + pRooms[index] = room; + } else { + printf("ERROR: \tWrong Index in CBuilding.SetRoom()"); + exit(0); + } +} + +/************************************************************* + Getter-Funktionen + ************************************************************/ + +string Building::GetCaption() const { + return pCaption; +} + +const vector<Room>& Building::GetAllRooms() const { + return pRooms; +} + +const Room& Building::GetRoom(int index) const { + if ((index >= 0) && (index < (int) pRooms.size())) { + return pRooms[index]; + } else { + printf("ERROR: Wrong 'index'=%d in CBuiling::GetRoom()\n",index); + exit(0); + } +} + +/************************************************************* + Sonstiges + ************************************************************/ +void Building::InitGeometry() { + for (int i = 0; i < pRooms.size(); i++) { + Room room = GetRoom(i); + vector<Transition> trans = room.GetAllTransitions(); + // alle Tueren öffnen + for (int j = 0; j < trans.size(); j++) { + trans[j].Open(); + room.SetTransition(trans[j], j); + } + // Polygone berechnen + room.ConvertLineToPoly(); + SetRoom(room, i); + } +} + +void Building::AddRoom(const Room& room) { + pRooms.push_back(room); +} + +int Building::RoomIndexForThisID(int ID) const { + int i; + for (i = 0; i < pRooms.size(); i++) { + if (pRooms[i].GetRoomID() == ID) + break; + } + if (i == pRooms.size()) { + printf("ERROR: \tBuilding::RoomIndexForThisID() can not find ID!"); + exit(0); + } + return i; +} + +/************************************************************* + Ein-Ausgabe + ************************************************************/ + +void Building::LoadFromFile(string filename) { + ifstream buildingfile; + string line; + + // Datei oeffnen + buildingfile.open(filename.c_str(), fstream::in); + if (!buildingfile) { + printf("ERROR: \tCannot load building file: %s", filename.c_str()); + exit(0); + } else { + int i = 0; + while (getline(buildingfile, line)) { + i++; // Zeienindex zum debuggen, nach jedem getline() erhöhen + if (line.find("<header>") != string::npos) { + LoadHeader(&buildingfile, &i); + } else if (line.find("<rooms>") != string::npos) { + LoadRooms(&buildingfile, &i); + } else if (line.find("<transitions>") != string::npos) { + LoadTransitions(&buildingfile, &i); + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file: [%s] line %d ", line.c_str(), i); + printf("%s",tmp); + exit(0); + } + } + buildingfile.close(); + buildingfile.clear(); + } +} + +void Building::WriteToErrorLog() const { + printf("GEOMETRY: "); + for (int i = 0; i < pRooms.size(); i++) { + Room r = GetRoom(i); + r.WriteToErrorLog(); + } + printf("\n"); +} + +/************************************************************* + private Funktionen + ************************************************************/ +void Building::LoadHeader(ifstream* buildingfile, int* i) { + string line; + + getline(*buildingfile, line); + (*i)++; + while (line.find("</header>") == string::npos) { + if (line.find("caption") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort, hier: "caption" + iss >> tmp >> pCaption; + } else if (line.find("version") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort, hier: "version" + double version; + iss >> tmp >> version; + if (version != 0.1) { + char tmp[100]; + sprintf(tmp, "ERROR: \tneue Version im Geometrieformat!!! %f != %f", version, VERSION); + printf(tmp); + exit(0); + } + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <header>: [%s] line %d " + , line.c_str(), *i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } +} + +void Building::LoadRooms(ifstream* buildingfile, int* i) { + string line; + getline(*buildingfile, line); + (*i)++; + int elements = 0; + while (line.find("</rooms>") == string::npos) { + if (line.find("elements") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + iss >> tmp >> elements; + } else if (line.find("<room>") != string::npos) { + LoadRoom(buildingfile, i); + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <rooms>: [%s] line %d " + , line.c_str(), i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } + if (elements != pRooms.size()) { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong number of rooms: %d != %d", elements, pRooms.size()); + printf("%s", tmp); + exit(0); + } + +} + +void Building::LoadRoom(ifstream* buildingfile, int* i) { + string line; + getline(*buildingfile, line); + (*i)++; + Room room = Room(); + while (line.find("</room>") == string::npos) { + if (line.find("caption") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp, caption; // Schlüsselwort, hier: "caption" + iss >> tmp >> caption; + room.SetCaption(caption); + } else if (line.find("index") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + int ID; + iss >> tmp >> ID; + room.SetRoomID(ID); + } else if (line.find("zpos") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + int zpos; + iss >> tmp >> zpos; + room.SetZPos(zpos); + } else if (line.find("<contdata>") != string::npos) { + room.LoadWalls(buildingfile, i); + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <room> :" + "[%s] line %d ", line.c_str(), i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } + AddRoom(room); +} + +void Building::LoadTransitions(ifstream* buildingfile, int* i) { + string line; + getline(*buildingfile, line); + (*i)++; + int elements = 0; + int anz = 0; + while (line.find("</transitions>") == string::npos) { + if (line.find("elements") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + iss >> tmp >> elements; + } else if (line.find("<transition>") != string::npos) { + anz++; + LoadTransition(buildingfile, i); + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <transition>: [%s] line %d ", + line.c_str(), i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } + if (elements != anz) { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong number of rooms: %d != %d", elements, pRooms.size()); + printf("%s", tmp); + exit(0); + } +} + +void Building::LoadTransition(ifstream* buildingfile, int* i) { + string line; + getline(*buildingfile, line); + Transition t; + (*i)++; + while (line.find("</transition>") == string::npos) { + if (line.find("index") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + int ID; + iss >> tmp >> ID; + t.SetID(ID); + } else if (line.find("caption") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp, caption; + iss >> tmp >> caption; + t.SetCaption(caption); + } else if (line.find("trans") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; + float x1, y1, x2, y2; + iss >> tmp >> x1 >> y1 >> x2 >> y2; + t.SetLine(Line(CPoint(x1, y1), CPoint(x2, y2))); + } else if (line.find("room1") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; + int room1; + iss >> tmp >> room1; + t.SetRoom1(room1); + } else if (line.find("room2") != string::npos) { + stringstream iss(line, istringstream::in); + string tmp; + int room2; + iss >> tmp >> room2; + t.SetRoom2(room2); + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <transition> <transition>: [%s] line %d ", + line.c_str(), i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } + int ID1 = t.GetRoom1(); + int ID2 = t.GetRoom2(); + if (ID1 == ID2) { // spaeter vielleicht Sondertüren einfügen + if(ID1 >=0){ + Room r = GetRoom(ID1); + r.AddTransition(t); + SetRoom(r, ID1); + } + } else { // Transition zu beiden Räumen hinzufügen + if (ID1 != -1) { // -1 bedeutet Ausgang + Room r = GetRoom(ID1); + r.AddTransition(t); + SetRoom(r, ID1); + } + if (ID2 != -1) { + Room r = GetRoom(ID2); + r.AddTransition(t); + SetRoom(r, ID2); + } + } +} diff --git a/src/geometry/jul/Building.h b/src/geometry/jul/Building.h new file mode 100644 index 0000000000000000000000000000000000000000..41b394a37aa8fe03e9daa2e6305e5ad78e45ac4f --- /dev/null +++ b/src/geometry/jul/Building.h @@ -0,0 +1,58 @@ +/* + * File: Building.h + * Author: andrea + * + * Created on 1. Oktober 2010, 09:25 + */ + +#ifndef _BUILDING_H +#define _BUILDING_H + +#include <string> +#include <vector> +#include <fstream> +#include <sstream> +using namespace std; + +#include "Room.h" +#include "Macros.h" + +class Building { +private: + string pCaption; // Name des Projekts + vector<Room> pRooms; // Liste der Räume + + // wird nur innerhalb von Building benötigt + void LoadHeader(ifstream* buildingfile, int* i); + void LoadRooms(ifstream* buildingfile, int* i); + void LoadRoom(ifstream* buildingfile, int* i); + + void LoadTransitions(ifstream* buildingfile, int* i); + void LoadTransition(ifstream* buildingfile, int* i); +public: + Building(); + Building(const Building& orig); + virtual ~Building(); + + // Setter -Funktionen + void SetCaption(string s); + void SetAllRooms(const vector<Room>& rooms); + void SetRoom(const Room& room, int index); + + // Getter - Funktionen + string GetCaption() const; + const vector<Room>& GetAllRooms() const; + const Room& GetRoom(int index) const; // Gibt Raum der Nummer "index" zurueck + + // Sonstiges + void InitGeometry(); + void AddRoom(const Room& room); + int RoomIndexForThisID(int ID) const; + + // Ein-Ausgabe + void LoadFromFile(string filename); // Laedt Geometrie-Datei + void WriteToErrorLog() const; +}; + +#endif /* _BUILDING_H */ + diff --git a/src/geometry/jul/CPoint.cpp b/src/geometry/jul/CPoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..973fe06b3108263225326859c203ce7508a493c9 --- /dev/null +++ b/src/geometry/jul/CPoint.cpp @@ -0,0 +1,142 @@ +/* + * File: CPoint.cpp + * Author: andrea + * + * Created on 30. September 2010, 09:21 + */ + +#include "CPoint.h" + +/************************************************************ + Konstruktoren + ************************************************************/ +CPoint::CPoint() { + pX = 0.0; + pY = 0.0; +} + +CPoint::CPoint(float x, float y) { + pX = x; + pY = y; +} + +CPoint::CPoint(const CPoint& orig) { + pX = orig.GetX(); + pY = orig.GetY(); +} + +CPoint::~CPoint() { +} + +/************************************************************* + Setter-Funktionen + ************************************************************/ + +void CPoint::SetX(float x) { + pX = x; +} + +void CPoint::SetY(float y) { + pY = y; +} + +/************************************************************* + Getter-Funktionen + ************************************************************/ + +float CPoint::GetX() const { + return pX; +} + +float CPoint::GetY() const { + return pY; +} + +/************************************************************* + Sonstige Funktionen + ************************************************************/ + +// Norm des Vektors + +float CPoint::Norm() const { + return sqrt(pX * pX + pY * pY); +} + +// gibt den normierten Vector zurueck + +CPoint CPoint::Normalized() const { + if (Norm() != 0) + return (CPoint(pX, pY) / Norm()); + else return CPoint(0.0, 0.0); +} + +// Skalarprodukt zweier Vektoren + +float CPoint::ScalarP(const CPoint& v) const { + return pX * v.GetX() + pY * v.GetY(); +} + +// rotiert Vektor um den Winkel theta + +CPoint CPoint::Rotate(float theta) const { + float s = sin(theta); + float c = cos(theta); + return CPoint(pX * c - pY*s, pX * s + pY * c); +} + +// Transformiert die Koordinaten in Koordinaten der Ellipse +// dazu verschieben des Koordinaten Ursprungs in Center und anschliessend drehen um phi +// alle Pnktte müssen in "normale" Koordinaten gegeben sein + +CPoint CPoint::CoordTransToEllipse(const CPoint& center, float phi) const { + CPoint p = CPoint(pX, pY); + return (p - center).Rotate(-phi); +} + +// Transformiert zurueck ins urspruengliche Koord.system + +CPoint CPoint::CoordTransToCart(const CPoint& center, float phi) const { + CPoint p = CPoint(pX, pY); + return (p.Rotate(phi) + center); +} + +/************************************************************* + überladene Operatoren + ************************************************************/ + +// Addiert zwei Vektoren + +const CPoint CPoint::operator+(const CPoint& p) const { + return CPoint(pX + p.GetX(), pY + p.GetY()); +} + +// Subtrahiert zwei Vektoren + +const CPoint CPoint::operator-(const CPoint& p) const { + return CPoint(pX - p.GetX(), pY - p.GetY()); +} + +// Vergleicht zwei Punkte/Vektoren komponentweise + +bool CPoint::operator==(const CPoint& p) const { + return (pX == p.GetX() && pY == p.GetY()); +} + +// Vergleicht zwei Punkte/Vektoren komponentweise + +bool CPoint::operator!=(const CPoint& p) const { + return (pX != p.GetX() || pY != p.GetY()); +} + + +// Multipliziert einen Vektor mit einem Skalar + +CPoint operator*(const CPoint& p, float f) { + return CPoint(p.GetX() * f, p.GetY() * f); +} + +// Dividiert einen Vektor durch einen Skalar + +CPoint operator/(const CPoint& p, float f) { + return CPoint(p.GetX() / f, p.GetY() / f); +} diff --git a/src/geometry/jul/CPoint.h b/src/geometry/jul/CPoint.h new file mode 100644 index 0000000000000000000000000000000000000000..1e23775b1c0e3e6b92c10490e27b6318e0eb740b --- /dev/null +++ b/src/geometry/jul/CPoint.h @@ -0,0 +1,52 @@ +/* + * File: CPoint.h + * Author: andrea + * + * Created on 30. September 2010, 09:21 + */ + +#ifndef _POINT_H +#define _POINT_H + +#include <cmath> + +class CPoint { +private: + float pX; + float pY; + +public: + CPoint(); + CPoint(float x, float y); + CPoint(const CPoint& orig); + virtual ~CPoint(); + + // Setter-Funktionen + void SetX(float x); // setzt x-Koordinate + void SetY(float y); // setzt y-Koordinate + + // Getter-Funktionen + float GetX() const; // gibt x-Koordinate zurück + float GetY() const; // gibt y-Koordinate zurück + + // Sonstiges + float Norm() const; // Norm des Vektors + CPoint Normalized() const; + float ScalarP(const CPoint& v) const; // Skalarprodukt zweier Vektoren + CPoint Rotate(float theta) const; // rotiert Vektor um den Winkel theta + CPoint CoordTransToEllipse(const CPoint& center, float phi) const; // Verschiebung und Drehung + CPoint CoordTransToCart(const CPoint& center, float phi) const; // Verschiebung und Drehung + + const CPoint operator+(const CPoint& p) const; // Addiert zwei Vektoren + const CPoint operator-(const CPoint& p) const; // Subtrahiert zwei Vektoren + bool operator==(const CPoint& p) const; // Vergleicht zwei Punkte/Vektoren komponentweise + bool operator!=(const CPoint& p) const; // Vergleicht zwei Punkte/Vektoren komponentweise +}; + + +// Operatoren mit float +CPoint operator*(const CPoint& p, const float f); +CPoint operator/(const CPoint& p, const float f); + +#endif /* _POINT_H */ + diff --git a/src/geometry/jul/Line.cpp b/src/geometry/jul/Line.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1eebb2e3ddc5c26fea35a9a04b6c96ce2d2cd86f --- /dev/null +++ b/src/geometry/jul/Line.cpp @@ -0,0 +1,142 @@ +/* + * File: Line.cpp + * Author: andrea + * + * Created on 30. September 2010, 09:40 + */ + +#include "Line.h" + +/************************************************************ + Konstruktoren + ************************************************************/ +Line::Line() { + SetPoint1(CPoint()); //Defaul-Constructor ist (0.0,0.0) + SetPoint2(CPoint()); +} + +Line::Line(const CPoint& p1, const CPoint& p2) { + SetPoint1(p1); + SetPoint2(p2); +} + +Line::Line(const Line& orig) { + pPoint1 = orig.GetPoint1(); + pPoint2 = orig.GetPoint2(); +} + +Line::~Line() { +} + +/************************************************************* + Setter-Funktionen + ************************************************************/ +void Line::SetPoint1(const CPoint& p) { + pPoint1 = p; +} + +void Line::SetPoint2(const CPoint& p) { + pPoint2 = p; +} + +/************************************************************* + Getter-Funktionen + ************************************************************/ +const CPoint& Line::GetPoint1(void) const { + return pPoint1; +} + +const CPoint& Line::GetPoint2(void) const { + return pPoint2; +} + +/************************************************************* + Sonstige Funktionen + ************************************************************/ +CPoint Line::NormalVec() const { + float nx, ny, norm; + CPoint r = GetPoint2() - GetPoint1(); + + if (r.GetX() == 0.0) { + nx = 1; + ny = 0; + } else { + nx = -r.GetY() / r.GetX(); + ny = 1; + /* Normieren */ + norm = sqrt(nx * nx + ny * ny); + nx /= norm; + ny /= norm; + } + return CPoint(nx, ny); +} + +float Line::NormalComp(const CPoint& v) const { + CPoint diff = GetPoint2() - GetPoint1(); + CPoint u, x; + float nu = diff.Norm(); + + if (nu < 0.0001) { + printf("ERROR: \tCLine::NormalComp(): normal_vector length==0\nstop\n"); + exit(0); + } + u = diff / nu; + + if (u.GetX() < 0.0001) + x = CPoint(1.0, 0.0); + else + x = CPoint(-u.GetY() / u.GetX(), 1.0); + + return fabs(v.ScalarP(x)); //sqrt(v.x*v.x+v.y*v.y); // +} + +CPoint Line::ShortestPoint(const CPoint& p) const { + CPoint r = GetPoint1(); + CPoint s = GetPoint2(); + CPoint t = r - s; + CPoint tmp; + float lambda; + + tmp = p - s; + lambda = tmp.ScalarP(t) / t.ScalarP(t); + CPoint f = s + t*lambda; + + /* Prüfen ob Punkt in der Linie,sonst entsprechenden Eckpunkt zurückgeben */ + if (lambda < 0) + f = s; + if (lambda > 1) + f = r; + + return f; +} + +bool Line::IsInLine(const CPoint& p) const { + float ax, ay, bx, by, px, py; + CPoint a = GetPoint1(); + CPoint b = GetPoint2(); + float lambda; + ax = a.GetX(); + ay = a.GetY(); + bx = b.GetX(); + by = b.GetY(); + px = p.GetX(); + py = p.GetY(); + if (ax != bx) + lambda = (px - ax) / (bx - ax); + else if (ay != by) + lambda = (py - ay) / (by - ay); + else { + printf("ERROR: \tIsInLine: Endpunkt = Startpunkt!!!"); + exit(0); + } + return (0 <= lambda) && (lambda <= 1); +} + +float Line::DistTo(const CPoint& p) const { + return (p - ShortestPoint(p)).Norm(); +} + +/************************************************************* + Ausgabe Funktionen + ************************************************************/ + diff --git a/src/geometry/jul/Line.h b/src/geometry/jul/Line.h new file mode 100644 index 0000000000000000000000000000000000000000..d276adeca7c414d770edbf43a082d665ce768bd1 --- /dev/null +++ b/src/geometry/jul/Line.h @@ -0,0 +1,48 @@ +/* + * File: Line.h + * Author: andrea + * + * Created on 30. September 2010, 09:40 + */ + +#ifndef _LINE_H +#define _LINE_H + +#include <stdio.h> +#include <stdlib.h> + + +#include "CPoint.h" + + +class Line { +private: + CPoint pPoint1; // (Koordinaten des ersten Punkts) + CPoint pPoint2; // (Koordinaten des zweiten Punkts) +public: + Line(); + Line(const CPoint& p1, const CPoint& p2); + Line(const Line& orig); + virtual ~Line(); + + // Setter -Funktionen + void SetPoint1(const CPoint& p); // setzt die Anfangskoordinaten + void SetPoint2(const CPoint& p); // setzt die Endkoordinaten + + // Getter - Funktionen + const CPoint& GetPoint1(void) const; // gibt die Koordinaten des Anfangspunkts zurück + const CPoint& GetPoint2(void) const; // gibt die Koordinaten des Endpunkts zurück + + // Sonstiges + CPoint NormalVec() const; /* Normalen_Vector zu Cline*/ + float NormalComp(const CPoint& v) const; /* Normale Komponente von v auf l */ + CPoint ShortestPoint(const CPoint& p) const; /* Punkt auf Cline mit kürzstem Abstand zu p */ + bool IsInLine(const CPoint& p) const; /* Prüft, ob der p in der Wand ist oder außerhalb */ + float DistTo(const CPoint& p) const; + + //Ausgabe + +}; + +#endif /* _LINE_H */ + diff --git a/src/geometry/jul/Macros.h b/src/geometry/jul/Macros.h new file mode 100644 index 0000000000000000000000000000000000000000..6bea206ea20e1cec6b0ad9043794bc38848fb99a --- /dev/null +++ b/src/geometry/jul/Macros.h @@ -0,0 +1,19 @@ +/* + * File: Macros.h + * Author: andrea + * + * Created on 16. Juni 2010, 16:59 + */ + +#ifndef _MACROS_H +#define _MACROS_H + +// Genauigkeit +#define EPS 0.001 +// zur Versionskontrolle beim Geometrieformat +#define VERSION 0.10 +#define TOLERANZ 0.10 // [m] Toleranz beim erstellen der Linien + + +#endif /* _MACROS_H */ + diff --git a/src/geometry/jul/Room.cpp b/src/geometry/jul/Room.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ce6669920b03138766e874386bc87b18d9e616b6 --- /dev/null +++ b/src/geometry/jul/Room.cpp @@ -0,0 +1,323 @@ +/* + * File: Room.cpp + * Author: andrea + * + * Created on 30. September 2010, 11:58 + */ + +#include <vector> + +#include "Room.h" +#include "Transition.h" + +/************************************************************ + Konstruktoren + ************************************************************/ + +Room::Room() { + pRoomID = -1; + pCaption = "no room caption"; + pZPos = -1; + pWalls = vector<Wall > (); + pTransitions = vector<Transition > (); + pPoly = vector<CPoint > (); +} + +Room::Room(const Room& orig) { + pRoomID = orig.GetRoomID(); + pCaption = orig.GetCaption(); + pZPos = orig.GetZPos(); + pWalls = orig.GetAllWalls(); + pTransitions = orig.GetAllTransitions(); + pPoly = orig.GetPolygon(); +} + +Room::~Room() { + if (pWalls.size() > 0) pWalls.clear(); + if (pTransitions.size() > 0) pTransitions.clear(); + if (pPoly.size() > 0) pPoly.clear(); +} + +/************************************************************* + Setter-Funktionen + ************************************************************/ +void Room::SetRoomID(int ID) { + pRoomID = ID; +} + +void Room::SetCaption(string s) { + pCaption = s; +} + +void Room::SetZPos(int z) { + pZPos = z; +} + +void Room::SetAllWalls(const vector<Wall>& walls) { + pWalls = walls; +} + +void Room::SetWall(const Wall& wall, int index) { + if ((index >= 0) && (index < (int) pWalls.size())) { + pWalls[index] = wall; + } else { + printf("ERROR: Wrong Index in CRoom::SetWall()"); + exit(0); + } +} + +void Room::SetAllTransitions(const vector<Transition>& transitions) { + pTransitions = transitions; +} + +void Room::SetTransition(const Transition& transition, int index) { + if ((index >= 0) && (index < (int) pTransitions.size())) { + pTransitions[index] = transition; + } else { + printf("ERROR: Wrong Index in CRoom::SetTransition()"); + exit(0); + } +} + +void Room::SetPolygon(const vector<CPoint>& poly) { + pPoly = poly; +} + + + +/************************************************************* + Getter-Funktionen + ************************************************************/ +int Room::GetRoomID() const { + return pRoomID; +} + +string Room::GetCaption() const { + return pCaption; +} + +int Room::GetZPos() const { + return pZPos; +} + +const vector<Wall>& Room::GetAllWalls() const { + return pWalls; +} + +const Wall Room::GetWall(int index) const { + if ((index >= 0) && (index < (int) pWalls.size())) + return pWalls[index]; + else { + printf("ERROR: Wrong 'index' in CRoom::GetWall()"); + exit(0); + } + +} + +const vector<Transition> Room::GetAllTransitions() const { + return pTransitions; +} + +const Transition Room::GetTransition(int index) const { + if ((index >= 0) && (index < (int) pTransitions.size())) + return pTransitions[index]; + else { + printf("ERROR: Wrong 'index' in CRoom::GetTransition()"); + exit(0); + } +} + +const vector<CPoint>& Room::GetPolygon() const { + return pPoly; +} + + +/************************************************************* + Sonstige Funktionen + ************************************************************/ + +void Room::AddWall(const Wall& w) { + pWalls.push_back(w); +} + +void Room::DeleteWall(int index) { + if ((index >= 0) && (index < (int) pWalls.size())) + pWalls.erase(pWalls.begin() + index); + else { + printf("ERROR: Wrong Index in CRoom::DeleteWall()"); + exit(0); + } +} + +void Room::AddTransition(const Transition& trans) { + pTransitions.push_back(trans); +} + +void Room::DeleteTransition(int index) { + if ((index >= 0) && (index < (int) pTransitions.size())) + pTransitions.erase(pTransitions.begin() + index); + else { + printf("ERROR: Wrong Index in CRoom::DeleteTransition()"); + exit(0); + } +} + +void Room::CloseTransition(int index) { + Transition tmp = GetTransition(index); + if (tmp.GetIsOpen()) { + tmp.Close(); + SetTransition(tmp, index); + } else { + printf("ERROR: Wrong Index in CRoom::CloseTransition() Transition is closed!!!"); + exit(0); + } +} + + +void Room::ConvertLineToPoly() { + vector<Line> copy; + CPoint point; + Line line; + + // Alle Linienelemente in copy speichern Wände und Transitions + for (int i = 0; i < pWalls.size(); i++) { + copy.push_back(pWalls[i].GetLine()); + } + for (int i = 0; i < pTransitions.size(); i++) { + copy.push_back(pTransitions[i].GetLine()); + } + + line = copy[0]; + pPoly.push_back(line.GetPoint1()); + point = line.GetPoint2(); + copy.erase(copy.begin()); + + for (int i = 0; i < (int) copy.size(); i++) { + line = copy[i]; + if ((point - line.GetPoint1()).Norm()< TOLERANZ) { + pPoly.push_back(line.GetPoint1()); + point = line.GetPoint2(); + copy.erase(copy.begin() + i); + // von vorne suchen + i = -1; + } else if ((point - line.GetPoint2()).Norm()< TOLERANZ) { + pPoly.push_back(line.GetPoint2()); + point = line.GetPoint1(); + copy.erase(copy.begin() + i); + // von vorne suchen + i = -1; + } + } + if ((pPoly[0] - point).Norm()>TOLERANZ) { + char tmp[100]; + sprintf(tmp,"ERROR: \tRoom::ConvertLineToPoly(): Raum %d Anfangspunkt ungleich Endpunkt!!!\n" + "(%f, %f) != (%f, %f)\n", GetRoomID(), pPoly[0].GetX(), pPoly[0].GetY(), point.GetX(), + point.GetY()); + printf("%s", tmp); + exit(0); + } +} + + +bool Room::IsStart() const { + return pCaption.find("start") != string::npos; +} + +bool Room::IsExit() const { + return pCaption.find("exit") != string::npos; +} + +CPoint Room::GetCentre() const { + //This will only work for orthogonally orientated rectangular rooms + vector<float> xs; + vector<float> ys; + vector<float>::iterator xmin, xmax, ymin, ymax; + CPoint mid; + + for (int i = 0; i < pPoly.size(); i++) { + xs.push_back(pPoly[i].GetX()); + ys.push_back(pPoly[i].GetY()); + } + xmin = min_element(xs.begin(), xs.end()); + xmax = max_element(xs.begin(), xs.end()); + ymin = min_element(ys.begin(), ys.end()); + ymax = max_element(ys.begin(), ys.end()); + mid.SetX((*xmin + *xmax) / 2); + mid.SetY((*ymin + *ymax) / 2); + return mid; + + +} + + + +/************************************************************* + Ein-Ausgabe + ************************************************************/ +void Room::LoadWalls(ifstream* buildingfile, int* i) { + string line; + getline(*buildingfile, line); + (*i)++; + int elements; + while (line.find("</contdata>") == string::npos) { + if (line.find("<elements>") != string::npos) { + getline(*buildingfile, line); + (*i)++; + while (line.find("</elements>") == string::npos) { + if (line.find("wall") != string::npos) { + Wall wall = Wall(); + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + float x1, y1, x2, y2; + iss >> tmp >> x1>> y1 >> x2 >> y2; + wall.SetLine(Line(CPoint(x1, y1), CPoint(x2, y2))); + AddWall(wall); + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <room> " + "<contdata> <element>: [%s] line %d ", line.c_str(), i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } + } else if (line.find("elements") != string::npos) { + istringstream iss(line, istringstream::in); + string tmp; // Schlüsselwort + iss >> tmp >> elements; + } else { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong object in building file <room> <contdata>:" + "[%s] line %d ", line.c_str(), i); + printf("%s", tmp); + exit(0); + } + getline(*buildingfile, line); + (*i)++; + } + if (elements != pWalls.size()) { + char tmp[100]; + sprintf(tmp, "ERROR: \tWrong number of rooms: %d != %d", elements, pWalls.size()); + printf("%s", tmp); + exit(0); + } +} + +void Room::WriteToErrorLog() const { + char tmp[300]; + string s; + sprintf(tmp, "\tRaum: %d [%s]:", pRoomID, pCaption.c_str()); + s.append(tmp); + printf("%s", tmp); + // Wände + for (int i = 0; i < pWalls.size(); i++) { + Wall w = GetWall(i); + w.WriteToErrorLog(); + } + //Übergänge + for (int i = 0; i < pTransitions.size(); i++) { + Transition t = GetTransition(i); + t.WriteToErrorLog(); + } +} diff --git a/src/geometry/jul/Room.h b/src/geometry/jul/Room.h new file mode 100644 index 0000000000000000000000000000000000000000..e5d23350552e7c1b202b451252f5ad771b241cf4 --- /dev/null +++ b/src/geometry/jul/Room.h @@ -0,0 +1,78 @@ +/* + * File: Room.h + * Author: andrea + * + * Created on 30. September 2010, 11:58 + */ + +#ifndef _ROOM_H +#define _ROOM_H + +#include <stdio.h> + + +#include <string> +#include <algorithm> +#include <fstream> +#include <sstream> +using namespace std; + +#include "Transition.h" +#include "Wall.h" +#include "Macros.h" + +class Room { +private: + int pRoomID; // Raumindex + string pCaption; // Raumname + int pZPos; // Hoehenindex, kontinuierlich vielleicht unnötig? + vector<Wall> pWalls; // Wände + vector<Transition> pTransitions; // Ausgänge + vector<CPoint> pPoly; // Alle Eckpunkte des Raums als Polygon + +public: + Room(); + Room(const Room& orig); + virtual ~Room(); + + // Setter -Funktionen + void SetRoomID(int ID); + void SetCaption(string s); + void SetZPos(int z); + void SetAllWalls(const vector<Wall>& walls); + void SetWall(const Wall& wall, int index); + void SetAllTransitions(const vector<Transition>& transitions); + void SetTransition(const Transition& transition, int index); + void SetPolygon(const vector<CPoint>& poly); + + // Getter - Funktionen + int GetRoomID() const; + string GetCaption() const; + int GetZPos() const; + const vector<Wall>& GetAllWalls() const; + const Wall GetWall(int index) const; + const vector<Transition> GetAllTransitions() const; + const Transition GetTransition(int index) const; + const vector<CPoint>& GetPolygon() const; + + // Sonstiges + void AddWall(const Wall& w); + void DeleteWall(int index); + void AddTransition(const Transition& trans); + void DeleteTransition(int index); + void CloseTransition(int index); + void ConvertLineToPoly(); // Erstellt einen Polygonzug aus pLines + bool IsInRoom(const CPoint& ped) const; + bool IsStart() const; //später ändern im Moment wird Anfang und Ende in Caption festgelegt + bool IsExit() const; //später ändern im Moment wird Anfang und Ende in Caption festgelegt + CPoint GetCentre() const; + + + // Ein-Ausgabe + void LoadWalls(ifstream* buildingfile, int* i); + void WriteToErrorLog() const; + +}; + +#endif /* _ROOM_H */ + diff --git a/src/geometry/jul/Transition.cpp b/src/geometry/jul/Transition.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa994b9ae61729adb717c9622e8726d6da323965 --- /dev/null +++ b/src/geometry/jul/Transition.cpp @@ -0,0 +1,123 @@ +/* + * File: Transition.cpp + * Author: andrea + * + * Created on 30. September 2010, 10:12 + */ + +#include "Transition.h" + +/************************************************************ + Konstruktoren + ************************************************************/ + +Transition::Transition() { + pLine = Line(); + pIsOpen = true; + pTransitionID = -1; + pCaption = "no transition caption"; + pRoom1 = -1; + pRoom2 = -1; +} + +Transition::Transition(const Transition& orig) { + pLine = orig.GetLine(); + pIsOpen = orig.GetIsOpen(); + pTransitionID = orig.GetID(); + pCaption = orig.GetCaption(); + pRoom1 = orig.GetRoom1(); + pRoom2 = orig.GetRoom2(); +} + +Transition::~Transition() { +} + +/************************************************************* + Setter-Funktionen + ************************************************************/ +void Transition::SetLine(const Line& l) { + pLine = l; +} + +void Transition::Close() { + pIsOpen = false; +} + +void Transition::Open() { + pIsOpen = true; +} + +void Transition::SetID(int ID) { + pTransitionID = ID; +} + +void Transition::SetCaption(string s) { + pCaption = s; +} + +void Transition::SetRoom1(int r1) { + pRoom1 = r1; +} + +void Transition::SetRoom2(int r2) { + pRoom2 = r2; +} + +/************************************************************* + Getter-Funktionen + ************************************************************/ +const Line& Transition::GetLine() const { + return pLine; +} + +bool Transition::GetIsOpen() const { + return pIsOpen; +} + +int Transition::GetID() const { + return pTransitionID; +} + +string Transition::GetCaption() const { + return pCaption; +} + +int Transition::GetRoom1() const { + return pRoom1; +} + +int Transition::GetRoom2() const { + return pRoom2; +} + +/************************************************************* + Sonstige Funktionen + ************************************************************/ + + +bool Transition::Connects(int r1id, int r2id) const { + bool c1 = (r1id == pRoom1) && (r2id == pRoom2); + bool c2 = (r1id == pRoom2) && (r2id == pRoom1); + return c1 | c2; +} + +int Transition::GetOtherRoom(int room_id) const { + if (room_id == pRoom1) return pRoom2; + else if (room_id == pRoom2) return pRoom1; + else { + printf("ERROR: \tNo exit found on the other side"); + exit(0); + } +} + +/************************************************************* + Ein-Ausgabe + ************************************************************/ + +void Transition::WriteToErrorLog() const { + char tmp[300]; + Line l = GetLine(); + sprintf(tmp, "\t\tTRANS: %d [%s] (%f, %f) -- (%f, %f)\n", GetID(), GetCaption().c_str(), l.GetPoint1().GetX() + , l.GetPoint1().GetY(), l.GetPoint2().GetX(), l.GetPoint2().GetY()); + printf("%s", tmp); +} diff --git a/src/geometry/jul/Transition.h b/src/geometry/jul/Transition.h new file mode 100644 index 0000000000000000000000000000000000000000..e123c622558780ecaed2b193da0685622d00bb33 --- /dev/null +++ b/src/geometry/jul/Transition.h @@ -0,0 +1,55 @@ +/* + * File: Transition.h + * Author: andrea + * + * Created on 30. September 2010, 10:12 + */ + +#ifndef _TRANSITION_H +#define _TRANSITION_H + +#include <string> +using namespace std; + +#include "Line.h" + +class Transition { +private: + Line pLine; + bool pIsOpen; + int pTransitionID; + string pCaption; + int pRoom1; + int pRoom2; +public: + Transition(); + Transition(const Transition& orig); + virtual ~Transition(); + + // Setter -Funktionen + void SetLine(const Line& l); + void Close(); // schliesst Tür + void Open(); // öffnet Tür + void SetID(int ID); + void SetCaption(string s); + void SetRoom1(int r1); + void SetRoom2(int r2); + + // Getter - Funktionen + const Line& GetLine() const; + bool GetIsOpen() const; + int GetID() const; + string GetCaption() const; + int GetRoom1() const; + int GetRoom2() const; + + // Sonstiges + bool Connects(int r1id, int r2id) const; + int GetOtherRoom(int room_id) const; + + // Ein-Ausgabe + void WriteToErrorLog() const; +}; + +#endif /* _TRANSITION_H */ + diff --git a/src/geometry/jul/Wall.cpp b/src/geometry/jul/Wall.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7fc1a6aadbd05562d008bc242bc6965f2c5c3ac0 --- /dev/null +++ b/src/geometry/jul/Wall.cpp @@ -0,0 +1,51 @@ +/* + * File: Wall.cpp + * Author: andrea + * + * Created on 30. September 2010, 11:47 + */ + +#include "Wall.h" + +/************************************************************ + Konstruktoren + ************************************************************/ + +Wall::Wall() { + pLine = Line(); +} + +Wall::Wall(const Wall& orig) { + pLine = orig.GetLine(); +} + +Wall::~Wall() { +} + +/************************************************************* + Setter-Funktionen + ************************************************************/ + +void Wall::SetLine(Line l) { + pLine = l; +} + +/************************************************************* + Getter-Funktionen + ************************************************************/ + +const Line& Wall::GetLine() const { + return pLine; +} + +/************************************************************* + Ausgabe + ************************************************************/ + +void Wall::WriteToErrorLog() const { + char tmp[300]; + Line l = GetLine(); + sprintf(tmp, "\t\tWALL: (%f, %f) -- (%f, %f)\n", l.GetPoint1().GetX() + , l.GetPoint1().GetY(), l.GetPoint2().GetX(), l.GetPoint2().GetY()); + printf("%s", tmp); +} diff --git a/src/geometry/jul/Wall.h b/src/geometry/jul/Wall.h new file mode 100644 index 0000000000000000000000000000000000000000..cbdcc2270417aa7df49d562acfb3219977655262 --- /dev/null +++ b/src/geometry/jul/Wall.h @@ -0,0 +1,33 @@ +/* + * File: Wall.h + * Author: andrea + * + * Created on 30. September 2010, 11:47 + */ + +#ifndef _WALL_H +#define _WALL_H + +#include "Line.h" + +class Wall { +private: + Line pLine; +public: + Wall(); + Wall(const Wall& orig); + virtual ~Wall(); + + // Setter -Funktionen + void SetLine(Line l); + + // Getter - Funktionen + const Line& GetLine() const; + + //Ausgabe + void WriteToErrorLog() const; + +}; + +#endif /* _WALL_H */ + diff --git a/src/geometry/pg3/CBuilding.cpp b/src/geometry/pg3/CBuilding.cpp new file mode 100644 index 0000000000000000000000000000000000000000..70170eef08106f2de4cde450bfac91d9878504d9 --- /dev/null +++ b/src/geometry/pg3/CBuilding.cpp @@ -0,0 +1,211 @@ +#include "CBuilding.h" + + +CBuilding::CBuilding(CTextLog *errorlog) +// Constructor +{ +// pRoomCount = 0; // Anzahl der Raeume +// pTransitionCount = 0; // Anzahl der Uebergaenge (Transitions) + pCaption = "no caption"; // Name des Projekts +// pRooms = 0; +// pTransitions = 0; + pCellSize = 0.0; // Kantenlaenge der Zellen + pErrorLog = errorlog; +} +//--------------------------------------------------------------------------- + +CBuilding::~CBuilding(void) +// Destructor +{ +// if (pRooms != NULL) { +// delete [] pRooms; +// } + if (pRooms.size()>0) pRooms.clear(); + if (pTransitions.size()>0) pTransitions.clear(); +} +//--------------------------------------------------------------------------- + +void CBuilding::LoadFromFile(string filename) +// Laedt Geometrie-Datei mit dem Pfad "filename" ein +{ + char line[255]; + FILE *buildingfile = NULL; + //unused??? int value; + int fileversion; + int roomamount; + int transitionamount=0; + + // Zur Sicherheit die Daten zuruecksetzen: + /* + if (pRoomCount > 0) { + delete [] pRooms; + pRoomCount = 0; + } + if (pTransitionCount > 0) { + delete [] pTransitions; + pTransitionCount = 0; + } + */ + if (pRooms.size()>0) pRooms.clear(); + if (pTransitions.size()>0) pTransitions.clear(); + pCaption = "no caption"; + + // Datei oeffnen + buildingfile = fopen(filename.c_str(), "rt"); + if (buildingfile != NULL) { + while (fscanf(buildingfile,"%s",&line[0])!=EOF) { + // Header laden + if (!strcmp(line,"<header>")) { + fscanf(buildingfile,"%s",&line[0]); + while (strcmp(line,"</header>")) { + if (!strcmp(line,"caption")) { // Caption + char value[255]; + ReadLine(buildingfile, value); + string *tempstring = new string(value); + pCaption = *tempstring; + delete tempstring; + pCaption = DelFreeSpaces(pCaption); + } + else if (!strcmp(line,"cellsize")) // CellSize + fscanf(buildingfile,"%f", &pCellSize); + else if (!strcmp(line,"version")) // Version + fscanf(buildingfile,"%i", &fileversion); + else if (!strcmp(line,"rooms")) // Version + fscanf(buildingfile,"%i", &roomamount); + else + pErrorLog->AddEntry("ERROR: Unknown entry in <header> of project file."); + // naechsten Wert lesen + fscanf(buildingfile,"%s",&line[0]); + } + pErrorLog->AddEntry("INFO: Caption = "+pCaption); + char temp[255]; + sprintf(temp, "INFO: Cell size = %f m", pCellSize); + pErrorLog->AddEntry(temp); + if (fileversion != 1) pErrorLog->AddEntry("ERROR: File version != 1"); + } + // Ende: Header laden + + // Raeume laden + else if (!strcmp(line,"<rooms>")) { + fscanf(buildingfile,"%s",&line[0]); + // Anzahl der Raeume einlesen und Zeiger anlegen + if (!strcmp(line,"elements")) { + fscanf(buildingfile,"%i",&roomamount); + // pRooms = new CRoom [pRoomCount]; + pRooms.resize(roomamount); + fscanf(buildingfile,"%s",&line[0]); + } + while (strcmp(line,"</rooms>")) { + // Raum + if (!strcmp(line,"<room>")) { + int roomindex; + fscanf(buildingfile,"%s",&line[0]); // naechsten Wert lesen + if (!strcmp(line,"index")) { + fscanf(buildingfile,"%i", &roomindex); + printf("Loading room: %i/%i\n", roomindex, roomamount); + pRooms[roomindex].Initialize(pErrorLog, roomindex); + pRooms[roomindex].LoadFromFile(buildingfile); + } // Ende: Vom Index an Raumdaten einlesen + } // Ende: einen Raum laden + fscanf(buildingfile,"%s",&line[0]); // naechsten Wert lesen + } + } // Ende: alle Raeume laden + + // Transitions laden + else if (!strcmp(line,"<transitions>")) { + fscanf(buildingfile,"%s",&line[0]); + // Anzahl der Transitions einlesen und Zeiger anlegen + if (!strcmp(line,"elements")) { + fscanf(buildingfile,"%i",&transitionamount); + // pTransitions = new CTransition [pTransitionCount]; + pTransitions.resize(transitionamount); + fscanf(buildingfile,"%s",&line[0]); + } + while (strcmp(line,"</transitions>")) { + // Transition + if (!strcmp(line,"<transition>")) { + int transitionindex; + fscanf(buildingfile,"%s",&line[0]); // naechsten Wert lesen + if (!strcmp(line,"index")) { + fscanf(buildingfile,"%i", &transitionindex); + printf("Loading transition: %i/%i\n", transitionindex, transitionamount-1); + pTransitions[transitionindex].Initialize(pErrorLog, transitionindex); + pTransitions[transitionindex].LoadFromFile(buildingfile); + } // Ende: Vom Index an Transitiondaten einlesen + } // Ende: ein Transitiondaten laden + fscanf(buildingfile,"%s",&line[0]); // naechsten Wert lesen + } + } // Ende: alle Transitiondaten laden + } // Ende: bis an das Dateiende durch buildingfile lesen + // Transitions durchgehen und in verbundenen Raeumen und entsprechende Potenziale ausbreiten + // for (int count=0; count < transitionamount; ++count) { + // printf("Spreading transition potential: %i/%i\n", count, transitionamount-1); + // pRooms[pTransitions[count].GetRoom1()].SpreadPotential(count); + // pRooms[pTransitions[count].GetRoom2()].SpreadPotential(count); + // } + + // // Fehlerpruefungen + // // =============== + + // // Hat jede Transition ein Potenzial bekommen? (wenn nein, Pot-Wert == -2) + // int potvalue = -1; + // // Alle Raeume durchgehen + // for (int roomcount=0; roomcount<(int)pRooms.size(); ++roomcount) { + // printf("Checking for errors in room %i/%i\n", roomcount, pRooms.size()-1); + // // Alle Transitions durchgehen + // for (int transcount=0; transcount<pRooms[roomcount].GetTransitionCount(); ++transcount) { + // // Alle Zellen durchsuchen + // for (int x=0; x<pRooms[roomcount].GetXCellSize(); ++x) { + // for (int y=0; y<pRooms[roomcount].GetYCellSize(); ++y) { + // if (pRooms[roomcount].GetPotValue(pRooms[roomcount].GetTransitionTableValue(transcount), x, y)<-1) + // potvalue = -2; + // } + // } + // } + // } + // if (potvalue==-2) + // pErrorLog->AddEntry("ERROR: At least one potential is not spread correctly."); + + fclose(buildingfile); + } // Ende: buildingfile != NULL + else { + pErrorLog->AddEntry("ERROR: Cannot load building file: "+filename); + printf("Datei konnte nicht geöffnet werden!!!\n"); + } +} +//--------------------------------------------------------------------------- + +CRoom CBuilding::GetRoom(int index) +// Gibt Raum der Nummer "index" zurueck +{ +// if ((index>=0) && (index<pRoomCount)) + if ((index>=0) && (index<(int)pRooms.size())) + return pRooms[index]; + else { + pErrorLog->AddEntry("ERROR: Wrong 'index' in CBuiling::GetRoom()"); + printf("ERROR: Wrong 'index' in CBuiling::GetRoom()"); + exit(0); +// return ??? + } +} +//--------------------------------------------------------------------------- + +void CBuilding::SavePotData(string filename) +// zum Debuggen die Potenzialdaten der Raeume in "filename" speichern +{ + FILE *potfile; + + potfile = fopen(filename.c_str(), "wt"); +// for (int roomcount=0; roomcount<pRoomCount; ++roomcount) { + for (int roomcount=0; roomcount<(int)pRooms.size(); ++roomcount) { + fprintf(potfile, "Room Nr. %i, %s\n", roomcount, pRooms[roomcount].GetCaption().c_str()); + pRooms[roomcount].SavePotsToFile(potfile); + } +} + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- + + + diff --git a/src/geometry/pg3/CBuilding.h b/src/geometry/pg3/CBuilding.h new file mode 100644 index 0000000000000000000000000000000000000000..d80ec2dbd12d7daec3617f57344d0fd8097dcc4e --- /dev/null +++ b/src/geometry/pg3/CBuilding.h @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------- +CGeometry: +========== +Autor: Tim Meyer-Koenig (TraffGo HT) +Beschreibung: Verwaltet die gesamte Geometrie + +---------------------------------------------------------------------------*/ + +//--------------------------------------------------------------------------- +#ifndef CBuildingH +#define CBuildingH + +// Systemheader: +#include <string> +using namespace std; + +// Eigene Header: +#include "CRoom.h" +#include "CTransition.h" +#include "CTextLog.h" + +//--------------------------------------------------------------------------- + +class CBuilding { +private: +// Variablen + float pCellSize; // Kantenlaenge der Zellen +// int pRoomCount; // Anzahl der Raeume +// int pTransitionCount; // Anzahl der uebergaenge (Transitions) + string pCaption; // Name des Projekts + vector<CRoom> pRooms; // Liste der Räume + vector<CTransition> pTransitions; // Liste der Transitions + CTextLog *pErrorLog; // Fehlerlog, in das man Fehlermeldungen schreiben kann +// Funktionen + +public: + CBuilding(CTextLog *errorlog); // Constructor + ~CBuilding(void); // Destructor + void LoadFromFile(string filename); // Laedt Geometrie-Datei + void SavePotData(string filename); // zum Debuggen die Potenzialdaten der Raeume in "filename" speichern + +// Get-Funktionen: + CRoom GetRoom(int index); // Gibt Raum der Nummer "index" zurueck +// int GetRoomCount(void) {return pRoomCount;}; + int GetRoomCount(void) {return pRooms.size();}; +// int GetTransitionCount(void) {return pTransitionCount;}; + int GetTransitionCount(void) {return pTransitions.size();}; + string GetCaption(void) {return pCaption;}; +// Set-Funktionen: +}; + +#endif diff --git a/src/geometry/pg3/CCell.cpp b/src/geometry/pg3/CCell.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c1548da126747d117ebde47246240384ad69f651 --- /dev/null +++ b/src/geometry/pg3/CCell.cpp @@ -0,0 +1,95 @@ +#include "CCell.h" + +CCell::CCell(void) +// Constructor +{ +// Werte setzen + pIsOpen = true; // default: Zellen zugaenglich + pType = tFloor; // default: Floor + pAgentID = -1; // leer +// pPotValue = NULL; // Anzahl der Potenziale, wird spaeter angelegt + pTransitionID = -1; // default: -1 = kein uebergang +} +//--------------------------------------------------------------------------- + +CCell::~CCell(void) +// Destructor +{ +// if (pPotValue != NULL) +// delete [] pPotValue; + if (pPotValue.size()>0) + pPotValue.clear(); +} +//--------------------------------------------------------------------------- + +void CCell::Initialize(CTextLog *errorlog) +// Initialisieren der Klasse +{ + pErrorLog = errorlog; +} +//--------------------------------------------------------------------------- + +int CCell::GetPotValue(int index) +// Gibt Potenzialwert des Potenzials "index" zurueck +// bei Fehlern wird -1 zurueckgegeben +{ + if (index>=0) { // Plausibilitaetspruefung + if (pType==tWall) + return -1; + else + return pPotValue[index]; + } + else { + pErrorLog->AddEntry("ERROR: Index error in CCell::GetPotValue()."); + return -1; + } +} +//--------------------------------------------------------------------------- + +void CCell::SetPotValue(int index, int value) +// Setzt den Potenzialwert "value" fuer Potenzial "index" +{ + if (index>=0) { // Plausibilitaetspruefung + pPotValue[index] = value; // uebergebenen Wert uebernehmen + } + else + pErrorLog->AddEntry("ERROR: Index error in CCell::SetPotValue()."); +} +//--------------------------------------------------------------------------- + +void CCell::CopyData(CCell cell, int potvectorsize) +// kopiert Daten aus einem Zell-Element in sich selbst +{ + int i; +// unused??? int vectorsize; + + pIsOpen = cell.GetIsOpen(); + pType = cell.GetType(); + pAgentID = cell.GetAgentID(); + pTransitionID = cell.GetTransitionID(); +// Potenzial-Zeiger anlegen und Daten uebernehmen + if (pPotValue.size() > 0) pPotValue.clear(); +// pPotValue = new int [potvectorsize]; + pPotValue.resize(potvectorsize); + for (i=0; i<potvectorsize; ++i) // Daten uebergeben + pPotValue[i] = cell.GetPotValue(i); +} +//--------------------------------------------------------------------------- + +void CCell::IniPotSize(int size) +// legt *pPotValue entsprechend "size" an und faellt sie mit dem Defaultwert "-1" +{ +// auch wieder zum Debuggen aufgeblaeht + if (size>=0) { + pPotValue.resize(size); +// pPotValue = new int [size]; + for (int count=0; count<size; ++count) + pPotValue[count] = -2; + } + else + pErrorLog->AddEntry("ERROR: wrong 'size' in CCell::IniPotSize()"); +} +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- diff --git a/src/geometry/pg3/CCell.h b/src/geometry/pg3/CCell.h new file mode 100644 index 0000000000000000000000000000000000000000..19c4dc50f258bc0e6104ade6b7dceb492336fcfa --- /dev/null +++ b/src/geometry/pg3/CCell.h @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------- +CCell: +====== +Autor: Tim Meyer-K�nig (TraffGo HT) +Beschreibung: Verwaltet die Daten einer Zelle + +---------------------------------------------------------------------------*/ + +//--------------------------------------------------------------------------- +#ifndef CCellH +#define CCellH + +// Systemheader: +#include <vector> +using namespace std; + +// Eigene Header: +#include "Common.h" +#include "CTextLog.h" +//--------------------------------------------------------------------------- + +class CCell { +private: + bool pIsOpen; // ist Zelle zug�nglich oder nicht? Genutzt bei Up, Down und Door-Zellen + char pType; // Eigenschaft + int pAgentID; // Nummer des Agenten, wenn leer = -1 + vector<int> pPotValue; // Potenzialwert der Zelle, Zeigerlaenge = Anzahl der Potenziale + int pTransitionID; // Nummer des �bergangs, ansonsten = -1 + CTextLog *pErrorLog; + +public: + CCell(void); // Constructor + ~CCell(void); // Destructor +// Get-Funktionen: + bool GetIsOpen(void) {return pIsOpen;}; + char GetType(void) {return pType;}; + int GetAgentID(void) {return pAgentID;}; + int GetPotValue(int index); // Gibt Potenzialwert des Potenzials "index" zur�ck + int GetTransitionID(void) {return pTransitionID;}; + void Initialize(CTextLog *errorlog); // Initialisieren der Klasse + void IniPotSize(int size); // legt *pPotValue entsprechend "size" an + +// Set-Funktionen: + void CopyData(CCell cell, int potvectorsize); // kopiert Daten aus einem Zell-Element in sich selbst + void SetIsOpen(bool isopen) {pIsOpen=isopen;}; + void SetType(char type) {pType=type;}; + void SetAgentID(int agentid) {pAgentID=agentid;}; + void SetPotValue(int index, int value); // Setzt den Potenzialwert "value" f�r Potenzial "index" + void SetTransitionID(int transitionid) {pTransitionID=transitionid;}; +}; + +#endif diff --git a/src/geometry/pg3/CCoordsList.cpp b/src/geometry/pg3/CCoordsList.cpp new file mode 100644 index 0000000000000000000000000000000000000000..16e7117816ad135a39b80a15110ce61b41678fe8 --- /dev/null +++ b/src/geometry/pg3/CCoordsList.cpp @@ -0,0 +1,188 @@ +#include "CCoordsList.h" + + +/* +CCoordsList::CCoordsList(int startsize, int increment) +// Constructor +// startsize = erste Anzahl an Elementen +// increment = Anzahl an Elementen um die die Liste vergroessert wird +{ + pIncrement = increment; + pElementCount = 0; + pCoordsArraySize = startsize; +// pCoordsList = (CoordsListTyp*) calloc(1, sizeof(CoordsListTyp)); +} +*/ +//--------------------------------------------------------------------------- + +CCoordsList::CCoordsList() +// Constructor ohne Parameter +{ +// pIncrement = 1; +// pElementCount = 0; +// pCoordsArraySize = 0; +// pCoordsList = NULL; +// pCoordsList = (CoordsListTyp*) calloc(1, sizeof(CoordsListTyp)); +} +//--------------------------------------------------------------------------- + +CCoordsList::~CCoordsList(void) +// Destructor +{ +// if (pCoordsList!=NULL) { +// free(pCoordsList); +// pCoordsList = NULL; +// } + if (pCoordsList.size()>0) { + pCoordsList.clear(); + } +} +//--------------------------------------------------------------------------- + +void CCoordsList::Clear() +// Loescht die gesamte Elementen-Liste +{ +// free(pCoordsList); +// pCoordsList = NULL; + pCoordsList.clear(); +// pElementCount = 0; +// pCoordsArraySize = 0; +// pCoordsList = (CoordsListTyp*) calloc(1, sizeof(CoordsListTyp)); +} + +//--------------------------------------------------------------------------- + +bool CCoordsList::AddAndCheckCoords(int x, int y) +// (x, y, z) einfuegen, wenn noch nicht enthalten +// Rueckgabe: "false" wenn nocht nicht, "true", wenn wohl schon enthalten. +{ + bool returnvalue = false; + + returnvalue = IsCoordsAdded(x, y); +// wenn (x, y, z) noch nicht enthalten + if (!returnvalue) + AddCoords(x, y); + return returnvalue; +} +//--------------------------------------------------------------------------- + +void CCoordsList::AddCoordsAt(int i, int x, int y) +// Fuegt Koordinaten (x, y, z) an Position i ein, wenn i>FElementCount, anhaengen +{ + if (i>=0) { +// if (i<pElementCount) { + if (i<(int)pCoordsList.size()) { + pCoordsList[i].x = x; + pCoordsList[i].y = y; + } + else // wenn i groesser als Anzahl der Elemente -> erweiter + AddCoords(x, y); + } +} +//--------------------------------------------------------------------------- + +bool CCoordsList::IsCoordsAdded(int x, int y) +// Pruefen, ob (x, y, z) schon enthalten ist, wenn ja, true zurueck +{ + bool returnvalue = false; + int i; + +// for (i=0; i<pElementCount; ++i) { + for (i=0; i<(int)pCoordsList.size(); ++i) { + if (x == pCoordsList[i].x) + if (y == pCoordsList[i].y) + returnvalue = true; + } + return returnvalue; +} + +//--------------------------------------------------------------------------- +void CCoordsList::GetCoords(int position, int &x, int &y) +// Koordinaten an "position" abfragen +// wenn "position" Bloedsinn, dann (-1, -1, -1) zurueckgeben +{ +// if ((position > -1) && (position < pElementCount)) { + if ((position > -1) && (position < (int)pCoordsList.size())) { + x = pCoordsList[position].x; + y = pCoordsList[position].y; + } + else { + x = -1; + y = -1; + } +} + +//--------------------------------------------------------------------------- +void CCoordsList::AddCoords(int x, int y) +// Einfuegen von Koordinaten (x, y, z) ohne Pruefung +{ +// ++pElementCount; +// einfuegen +// if (pElementCount > pCoordsArraySize) { +// pCoordsArraySize += pIncrement; +// pCoordsList = (CoordsListTyp*) realloc(pCoordsList, pCoordsArraySize*sizeof(CoordsListTyp)); +// } + CoordsListTyp coords; + coords.x = x; + coords.y = y; + pCoordsList.push_back(coords); +} + +//--------------------------------------------------------------------------- +void CCoordsList::SaveCoordsList(string filename) +// Liste in ASCII-Datei "filename" speichern (evtl. zum debuggen) +{ + FILE *file; + int i; + + file = fopen(filename.c_str(), "wt"); + fprintf(file, "Content of CCoordsList:\n"); + for (i=0; i<(int)pCoordsList.size(); ++i) { + fprintf(file, "%i, %i\n", pCoordsList[pCoordsList.size()-1].x, pCoordsList[pCoordsList.size()-1].y); + } + fclose(file); +} + +//--------------------------------------------------------------------------- +void CCoordsList::SaveCoordsList(FILE *file) +// Liste in ASCII-Datei "filename" speichern (evtl. zum debuggen) +{ + int i; + +// for (i=0; i<pElementCount; ++i) { + for (i=0; i<(int)pCoordsList.size(); ++i) { + fprintf(file, "%i, %i\n", pCoordsList[pCoordsList.size()-1].x, pCoordsList[pCoordsList.size()-1].y); + } +} + +//--------------------------------------------------------------------------- +void CCoordsList::DeleteCoords(int x, int y) +// Loescht das Element (x, y, z) +{ + int i=0; + bool isfound = false; + +// alle Elemente durchsuchen bis Koordinaten (x, y, z) gefunden sind oder alles durchsucht ist + do { + if ((pCoordsList[i].x == x) && (pCoordsList[i].y == y)) + isfound = true; + ++i; +// } while (!isfound && (i<pElementCount)); + } while (!isfound && (i<(int)pCoordsList.size())); + --i; +// Entsprechende Koordinaten loeschen, wenn sie vorhanden sind + if (isfound) + DeleteElement(i); +} + +//--------------------------------------------------------------------------- +void CCoordsList::DeleteElement(int i) +// Loescht die Koordinaten an Position i +{ +// Letzten Listeneintrag nehmen und auf Position i setzen, Groesse des +// Arrays um 1 reduzieren +// pCoordsList[i].x = pCoordsList[pElementCount-1].x; +// pCoordsList[i].y = pCoordsList[pElementCount-1].y; +// --pElementCount; + pCoordsList.erase(pCoordsList.begin()+i); +} diff --git a/src/geometry/pg3/CCoordsList.h b/src/geometry/pg3/CCoordsList.h new file mode 100644 index 0000000000000000000000000000000000000000..6af9f3a76f977c6b6764eff063d729c0940efc30 --- /dev/null +++ b/src/geometry/pg3/CCoordsList.h @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------- +CCoordsList: +============ +Autor: Tim Meyer-Koenig (TraffGo HT) +Beschreibung: CCoordsList verwaltet eine Liste zweidimensionaler Koordinaten. +---------------------------------------------------------------------------*/ + + +#ifndef CCoordsListH +#define CCoordsListH + +// Systemheader: +#include <string> +#include <stdio.h> +#include <cstdlib> +#include <vector> +using namespace std; + +// Eigene Header: + +//--------------------------------------------------------------------------- + +class CCoordsList { +private: +// int pIncrement; // Anzahl von Eintraegen, um die die Liste vergroessert wird +// int pElementCount; // Anzahl der Elemente in der Liste +// int pCoordsArraySize; // Groesse des Arrays (wird ja immer um "FIncrement" erweitert) + struct CoordsListTyp { // Koordinaten + int x; // kann mal auf beliebig viele Elemente erweitert werden. + int y; + }; + vector<CoordsListTyp> pCoordsList; +public: + CCoordsList(int startsize, int increment); // Constructor 1 + CCoordsList(); // Constructor 2 + ~CCoordsList(void); // Destructor + bool AddAndCheckCoords(int x, int y); // Einfuegen, wenn noch nicht 'drin + bool IsCoordsAdded(int x, int y); // Prueft, ob (x, y, z) enthalten ist, wenn ja, true zurueck + void GetCoords(int position, int &x, int &y); // Gibt Koordinaten zurueck + void AddCoords(int x, int y); // Einfuegen von Koordinaten + void AddCoordsAt(int i, int x, int y); // ueberschreibt Koordinaten an Stelle "i" + void SaveCoordsList(string filename); // Speichert Liste in Datei "filename" + void SaveCoordsList(FILE *file); // // Speichert Liste in Datei "file" + void DeleteCoords(int x, int y); // Loescht Koordinaten (x, y, z) + void DeleteElement(int i); // Loescht Element "i" + void Clear(); // Loescht gesamte Liste + +// int GetIncrement() {return pIncrement;}; // Wert um den Liste verlaengert wird +// int GetCoordsCount() {return pElementCount;}; // Anzahl Elemente + int GetCoordsCount() {return pCoordsList.size();}; // Anzahl Elemente +}; + +#endif diff --git a/src/geometry/pg3/CLine.cpp b/src/geometry/pg3/CLine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8942ab041e58e7eb18868d658787d9983345c105 --- /dev/null +++ b/src/geometry/pg3/CLine.cpp @@ -0,0 +1,44 @@ +#include "CLine.h" + + + +CLine::CLine(void) +// Constructor +{ +// Werte setzen: + pIsOpen = false; // Default sind Linienelemente nicht zugänglich + pType = tWall; // Default: Wand + pPoint1.SetX(0.0); + pPoint1.SetY(0.0); // erster Punkt + pPoint2.SetX(0.0); + pPoint2.SetY(0.0); // zweiter Punkt + pTransitionID = -1; // Default: kein �bergang +} + +//--------------------------------------------------------------------------- + +CLine::~CLine(void) +// Destructor +{ +} +//--------------------------------------------------------------------------- + +void CLine::Initialize(CTextLog *errorlog) +// Initialisieren +{ + pErrorLog = errorlog; +} + +//--------------------------------------------------------------------------- + +void CLine::CopyData(CLine line) +// kopiert Daten aus einem Linien-Element in sich selbst +{ +// Werte aus "line" kopieren: + pIsOpen = line.GetIsOpen(); + pType = line.GetType(); + pPoint1 = line.GetPoint1(); + pPoint2 = line.GetPoint2(); + pTransitionID = line.GetTransitionID(); +} +//--------------------------------------------------------------------------- diff --git a/src/geometry/pg3/CLine.h b/src/geometry/pg3/CLine.h new file mode 100644 index 0000000000000000000000000000000000000000..e1597fecf3d4c70ab34620ea3ef82a1a6378ff4c --- /dev/null +++ b/src/geometry/pg3/CLine.h @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------- +CLine: +====== +Autor: Tim Meyer-K�nig (TraffGo HT) +Beschreibung: Verwaltet Linienelemente, die durch ihre Eigenschaft und die +Koordinaten des Start- und Endpunkts definiert werden + +---------------------------------------------------------------------------*/ + +#ifndef CLineH +#define CLineH +// Systemheader: + +// Eigene Header: +#include "Common.h" +#include "CTextLog.h" +#include "../jul/CPoint.h" + +//--------------------------------------------------------------------------- + +class CLine { +private: + bool pIsOpen; // Ist Zelle zugänglich oder nicht + char pType; // Eigenschaft + CPoint pPoint1; // (Koordinaten des ersten Punkts) + CPoint pPoint2; // (Koordinaten des zweiten Punkts) + int pTransitionID; // Nummer des Übergangs, ansonsten "-1" + CTextLog *pErrorLog; + +public: + CLine(void); // Constructor + ~CLine(void); // Destructor + void Initialize(CTextLog *errorlog); // Initialisieren + +// Get-Funktionen: + bool GetIsOpen(void) {return pIsOpen;}; // ist Element zugänglich? + char GetType(void) {return pType;}; // gibt den Linientyp zurück + int GetTransitionID(void) {return pTransitionID;}; // gibt den Transition-Index zurück + const CPoint& GetPoint1(void) const {return pPoint1;}; // gibt die Koordinaten des Anfangspunkts zurück + const CPoint& GetPoint2(void) const {return pPoint2;}; // gibt die Koordinaten des Endpunkts zurück + +// Set-Funktionen: + void CopyData(CLine line); // kopiert Daten aus einem Linien-Element in sich selbst + void SetIsOpen(bool isopen) {pIsOpen=isopen;}; // ist Element zugänglich? + void SetType(char type) {pType=type;}; // setzt den Typ + void SetPoint1(const CPoint& p) {pPoint1=p;}; // setzt die Anfangskoordinaten + void SetPoint2(const CPoint& p) {pPoint2=p;}; // setzt die Endkoordinaten + void SetTransitionID(int &transitionid) {pTransitionID=transitionid;}; // setzt den Transition-Index +}; + + +#endif diff --git a/src/geometry/pg3/CRoom.cpp b/src/geometry/pg3/CRoom.cpp new file mode 100644 index 0000000000000000000000000000000000000000..999ccb0d9ccfecbd8acfc9157edd052b96aa94b2 --- /dev/null +++ b/src/geometry/pg3/CRoom.cpp @@ -0,0 +1,518 @@ +#include "CRoom.h" + + +CRoom::CRoom(void) +// Constructor +{ +// Allgemeine Daten: + pErrorLog = 0; + pRoomIndex = -1; // Raumindex + pCaption = "no caption"; // Raumname +// Geometriedaten: + pXCellPos = 0; + pYCellPos = 0; // Raumposition in Zellen + pZPos = 0; // Hoehenindex + pXCellSize = 0; + pYCellSize = 0; // Raumabmessung in Zellen +// pLineElementCount = 0; // Anzahl der Linienelemente + pTransitionCount = 0; // Anzahl der Transitions +// pTransitionTable = NULL; + pContPos = CPoint(); /* Default Konstruktor setzt automatisch (0,0) */ + pXContSize = 0.0; + pYContSize = 0.0; // Raumabmessung kontinuierlich in Metern +// pCells = 0; // zellulare Repraesentation des Raums [pXCellSize*pYCellSize] +// pLines = 0; // kontinuierliche Repraesentation des Raumes [pContElementCount] + +} +//--------------------------------------------------------------------------- + +CRoom::~CRoom(void) +// Destructor +{ +// if (pCells != NULL) +// delete [] pCells; + if (pCells.size()>0) pCells.clear(); +// if (pLines != NULL) +// delete [] pLines; + if (pLines.size()>0) pLines.clear(); +// if (pTransitionTable != NULL) +// free(pTransitionTable); + if (pTransitionTable.size()>0) pTransitionTable.clear(); +} +//--------------------------------------------------------------------------- + +void CRoom::Initialize(CTextLog *errorlog, int roomindex) +// weist pErrorLog zu +{ + pErrorLog = errorlog; + pRoomIndex = roomindex; +} +//--------------------------------------------------------------------------- + +bool CRoom::GetCell(int x, int y, CCell &cell) +// setzt Zeiger "cell" auf die Zelle an Position (x, y, z) +{ + bool returnvalue = false; + + if ((x>-1)&&(y>-1)) { // Pruefen ob Koordinaten innerhalb der Haupabmessung liegen + if ((x<pXCellSize)&&(y<pYCellSize)) { +// if (pCells != NULL) { + if (pCells.size()>0) { + cell = pCells[y*pXCellSize+x]; + returnvalue = true; + } + else { + pErrorLog->AddEntry("ERROR: in CRoom:GetCell(), pCells nicht angelegt"); + } + } + else { + pErrorLog->AddEntry("ERROR: in CRoom:GetCell(), x oder y > Maximalabmessungen"); + } + } + else { + pErrorLog->AddEntry("ERROR: in CRoom:GetCell(), x oder y < 0"); + } + return returnvalue; +} +//--------------------------------------------------------------------------- + +bool CRoom::GetLine(int index, CLine &line) +// setzt Zeiger "line" auf das Linienelement "index" +{ + bool returnvalue = false; + + if (index>-1) { // Pruefen ob Index innerhalb der Zeigerlaenge liegt +// if (index<pLineElementCount) { + if (index<(int)pLines.size()) { + line = pLines[index]; + returnvalue = true; + } + else { + pErrorLog->AddEntry("ERROR: in CRoom:GetLine(), index > Zeigerlaenge"); + } + } + else { + pErrorLog->AddEntry("ERROR: in CRoom:GetLine(), index < 0"); + } + return returnvalue; +} +//--------------------------------------------------------------------------- + +void CRoom::EditDoor(int index, bool isopen) +// oeffnet Tuer "index" +{ + int i; + +// Zellen durchgehen: +// if (pCells != 0) { + if (pCells.size() > 0) { + for (i=0; i<(pXCellSize*pYCellSize); ++i) { // alle Zellen durchgehen + if (pCells[i].GetTransitionID() == index) + pCells[i].SetIsOpen(isopen); + } + } + else + pErrorLog->AddEntry("ERROR: CRoom:OpenDoor(): pCells == 0"); + +// Linienelemente durchgehen: +// if (pLines != 0) { + if (pLines.size() > 0) { +// for (i=0; i<pLineElementCount; ++i) { // alle Zellen durchgehen + for (i=0; i<(int)pLines.size(); ++i) { // alle Zellen durchgehen + if (pLines[i].GetTransitionID() == index) + pLines[i].SetIsOpen(isopen); + } + } + else + pErrorLog->AddEntry("ERROR: CRoom:OpenDoor(): pLines == 0"); +} +//--------------------------------------------------------------------------- + +void CRoom::CopyData(CRoom room) +// Kopiert die Daten von "room" in sich selbst +{ + int i, x, y; + int lineelementcount = room.GetLineElementCount(); + + pRoomIndex = room.GetRoomIndex(); + pCaption = room.GetCaption(); + pXCellPos = room.GetXCellPos(); + pYCellPos = room.GetYCellPos(); + pZPos = room.GetZPos(); + pXCellSize = room.GetXCellSize(); + pYCellSize = room.GetYCellSize(); + + pTransitionCount = room.GetTransitionCount(); +// if (pTransitionTable!=NULL) free(pTransitionTable); + if (pTransitionTable.size()>0) pTransitionTable.clear(); +// pTransitionTable = (int*) calloc(pTransitionCount, sizeof(int)); + pTransitionTable.resize(pTransitionCount); + for (i=0; i<pTransitionCount; ++i) + pTransitionTable[i] = room.GetTransitionTableValue(i); + pContPos = room.GetContPos(); + pXContSize = room.GetXContSize(); + pYContSize = room.GetYContSize(); +// if (pCells!=NULL) delete [] pCells; + if (pCells.size()>0) pCells.clear(); +// pCells = new CCell [pXCellSize*pYCellSize]; + pCells.resize(pXCellSize*pYCellSize); + for (y=0; y<pYCellSize; ++y) + for (x=0; x<pXCellSize; ++x) { + CCell cell; + pCells[y*pXCellSize+x].Initialize(pErrorLog); + if (room.GetCell(x, y, cell)) + pCells[y*pXCellSize+x].CopyData(cell, pTransitionCount); + } +// if (pLines!=NULL) delete [] pLines; + if (pLines.size()>0) pLines.clear(); +// pLines = new CLine [pLineElementCount]; + pLines.resize(lineelementcount); + for (i=0; i<(int)pLines.size(); ++i) { + CLine line; + pLines[i].Initialize(pErrorLog); + if (room.GetLine(i, line)) + pLines[i].CopyData(line); + } +} +//--------------------------------------------------------------------------- + +void CRoom::LoadFromFile(FILE *buildingfile) +// Laedt Raumdaten aus Datei "buildingfile" +{ + char line[255]; + + fscanf(buildingfile,"%s",&line[0]); + while (strcmp(line,"</room>")) { + if (!strcmp(line,"caption")) { // Raumname + char value[255]; + ReadLine(buildingfile, value); + string *tempstring = new string(value); + pCaption = *tempstring; + delete tempstring; + pCaption = DelFreeSpaces(pCaption); + } + else if (!strcmp(line,"zpos")) // z-Position + fscanf(buildingfile,"%i", &pZPos); +// Zelldaten einlesen + else if (!strcmp(line,"<celldata>")) { + while (strcmp(line,"</celldata>")) { + fscanf(buildingfile,"%s",&line[0]); + if (!strcmp(line,"xpos")) // x-Position + fscanf(buildingfile,"%i", &pXCellPos); + else if (!strcmp(line,"ypos")) // y-Position + fscanf(buildingfile,"%i", &pYCellPos); + else if (!strcmp(line,"xmax")) // Abmessung in x-Richtung + fscanf(buildingfile,"%i", &pXCellSize); + else if (!strcmp(line,"ymax")) // Abmessung in y-Richtung + fscanf(buildingfile,"%i", &pYCellSize); + else if (!strcmp(line,"<cells>")) { // Zellen-Zeiger anlegen und Zellinfos einlesen + int x, y; + char cellvalue[2]; +// if (pCells != NULL) delete [] pCells; + if (pCells.size()>0) pCells.clear(); +// pCells = new CCell [pXCellSize*pYCellSize]; + pCells.resize(pXCellSize*pYCellSize); +// Zellen lesen + for (y=0; y<pYCellSize; ++y) { + for (x=0; x<pXCellSize; ++x) { + fscanf(buildingfile,"%1s", cellvalue); + if (!strcmp(cellvalue, "0")) // begehbarer Boden + pCells[y*pXCellSize+x].SetType(tFloor); + else if (!strcmp(cellvalue, "1")) // Wand + pCells[y*pXCellSize+x].SetType(tWall); + else if (!strcmp(cellvalue, "2")) // Stufe + pCells[y*pXCellSize+x].SetType(tStep); + else if (!strcmp(cellvalue, "x")) // Stufe + pCells[y*pXCellSize+x].SetType(tOutside); +// Bei Transition die Zahl zwischen den "T" einlesen und speichern + else if (!strcmp(cellvalue, "T")) { + string transition; + int count = 0; + transition.clear(); + fscanf(buildingfile,"%1s", cellvalue); + while (strcmp(cellvalue, "T")) { + transition += cellvalue[0]; + ++count; + fscanf(buildingfile,"%1s", cellvalue); + } + count = atoi(transition.c_str()); + pCells[y*pXCellSize+x].SetType(tTransition); + pCells[y*pXCellSize+x].SetTransitionID(atoi(transition.c_str())); + } + else + pErrorLog->AddEntry("ERROR: Unknown entry in <celldata> of project file."); + } + } + } + } + } // Ende: Zelldaten einlesen +// Kontinuierliche Daten einlesen: + else if (!strcmp(line,"<contdata>")) { + float xcontpos = 0.0; + float ycontpos = 0.0; + while (strcmp(line,"</contdata>")) { + fscanf(buildingfile,"%s",&line[0]); + if (!strcmp(line,"xpos")) // x-Position + fscanf(buildingfile,"%f", &xcontpos); + else if (!strcmp(line,"ypos")) // y-Position + fscanf(buildingfile,"%f", &ycontpos); + else if (!strcmp(line,"elements")) {// Elementanzahl + int lineelementcount; + fscanf(buildingfile,"%i", &lineelementcount); +// pLines = new CLine [pLineElementCount]; + pLines.resize(lineelementcount); + } + else if (!strcmp(line,"<elements>")) { // Zellen-Zeiger anlegen und Zellinfos einlesen + char type; + float x1, x2, y1, y2; + int transition = -1; +//unused??? int count; + int elementcount = 0; + while (strcmp(line,"</elements>")) { + fscanf(buildingfile,"%s",&line[0]); + if (!strcmp(line,"wall")) { // Wand-Element + fscanf(buildingfile, "%f %f %f %f", &x1, &y1, &x2, &y2); + type = tWall; + } + else if (!strcmp(line,"step")) { // Stufen-Element + fscanf(buildingfile, "%f %f %f %f", &x1, &y1, &x2, &y2); + type = tStep; + } + else if (!strcmp(line,"trans")) { // Transition-Element + fscanf(buildingfile, "%i %f %f %f %f", &transition, &x1, &y1, &x2, &y2); + type = tTransition; + } +// Linienelement der Liste hinzufuegen +// if-Abfrage um bei letztem durchlauf Speicherzugriffsfehler zu vermeiden +// if (elementcount<pLineElementCount) { + if (elementcount<(int)pLines.size()) { + pLines[elementcount].Initialize(pErrorLog); + pLines[elementcount].SetType(type); + CPoint point1(x1,y1); + pLines[elementcount].SetPoint1(point1); + CPoint point2(x2,y2); + pLines[elementcount].SetPoint2(point2); + if (transition>=0) + pLines[elementcount].SetTransitionID(transition); + } + ++elementcount; + } + } // Ende: <elements> + } + SetContPos(CPoint(xcontpos, ycontpos)); + } // Ende: Kontinuierliche Daten einlesen + fscanf(buildingfile,"%s",&line[0]); + } // Ende: <room> + +// Raum initialisieren +// Alle Zellen durchgehen und Anzahl der Transitions zaehlen, um danach alle Zellen +// zu initialisieren (Zeiger fuer Potenzial anlegen) + pTransitionCount = 0; +// if (pTransitionTable != NULL) free(pTransitionTable); + if (pTransitionTable.size()>0) pTransitionTable.clear(); +// pTransitionTable = (int*) calloc(1, sizeof(int)); + for (int count=0; count<pXCellSize*pYCellSize; ++count) { // alle Zellen durchsuchen + if (pCells[count].GetType() == tTransition) { // wenn Transition-Zelle + bool isfound = false; + for (int trans=0; trans<pTransitionCount; ++trans) { // gucken, ob diese Transition schon detektiert wurde + if (pTransitionTable[trans] == pCells[count].GetTransitionID()) + isfound = true; + } + if (!isfound) { // wenn Transition-Index noch nicht gefunden wurde, merken + ++pTransitionCount; + pTransitionTable.push_back(pCells[count].GetTransitionID()); +// pTransitionTable = (int*) realloc(pTransitionTable, pTransitionCount*sizeof(int)); +// pTransitionTable[pTransitionCount-1] = pCells[count].GetTransitionID(); + } + } + } + for (int count=0; count<pXCellSize*pYCellSize; ++count) { // alle Zellen initialisieren + pCells[count].IniPotSize(pTransitionCount); + } +} // Ende: LoadFromFile() +//--------------------------------------------------------------------------- + +CLine CRoom::GetLine(int index) +// gibt Linienelement "index" zurueck +{ +// if ((index>=0) && (index<pLineElementCount)) + if ((index>=0) && (index<(int)pLines.size())) + return pLines[index]; + else { + pErrorLog->AddEntry("ERROR: Wrong 'index' in CRoom::GetLine()"); + printf("ERROR: Wrong 'index' in CRoom::GetLine()\n"); + exit(0); + } +} +//--------------------------------------------------------------------------- + +void CRoom::SpreadPotential(int transition) +// breitet das Potenzial von "transition" im Raum aus +{ + int i, j; + int x, y; + int potvalue = 0; + int transitionindex = -1; +// CCoordsList *oldcells = new CCoordsList(0, 50); // weiterfuehrende Zellen anlegen + CCoordsList *oldcells = new CCoordsList; // weiterfuehrende Zellen anlegen + CCoordsList *newcells; + +// "transitionindex" bestimmen, d.h. den Index des Zellenarrays, in dem die Potenzialwerte +// der globalen Transition mit der Nummer "transition" gespeichert werden + for (i=0; i<pTransitionCount; ++i) { + if (pTransitionTable[i] == transition) + transitionindex = i; + } + +// alle Zellen nach Transition-Zellen von "transition" durchsuchen, in "contcells" +// merken und ihren Potenzialwert auf 0 setzen + for (y=0; y<pYCellSize; ++y) { + for (x=0; x<pXCellSize; ++x) { + if (pCells[y*pXCellSize+x].GetTransitionID() == transition) { + oldcells->AddAndCheckCoords(x, y); + pCells[y*pXCellSize+x].SetPotValue(transitionindex, potvalue); + } + } + } +// Potenzial von "contcells" aus ausbreiten + do { + ++potvalue; +// newcells = new CCoordsList(0,50); + newcells = new CCoordsList; +// alle alten Zellen durchgehen und nur ueber die Kanten neue Nachbarn suchen + for (i=0; i<oldcells->GetCoordsCount(); ++i) { + for (j=1; j<9; j+=2) { + oldcells->GetCoords(i, x, y); +// "unentdeckte" Zelle gefunden, also in "newcells" merken und Potenzialwert setzen + if (LookPotValue(transition, j, x, y)==-2) { + newcells->AddAndCheckCoords(x, y); + pCells[y*pXCellSize+x].SetPotValue(transitionindex, potvalue); + } + } // Ende 'drumherum ueber Kanten gucken + } // Ende 'oldcells[]' durchgehen +// Neue Zellen zu alten Zellen umschaufeln + for (i=0; i<newcells->GetCoordsCount(); ++i) { + newcells->GetCoords(i, x, y); + oldcells->AddCoords(x, y); + } + newcells->Clear(); + ++potvalue; +// alle alten Zellen durchgehen und ueber die Kanten & Ecken (2. Schritt) neue Nachbarn suchen + for (i=0; i<oldcells->GetCoordsCount(); ++i) { + for (j=1; j<9; j+=1) { + oldcells->GetCoords(i, x, y); +// Unentdeckte normale Zelle gefunden + if (LookPotValue(transition, j, x, y)==-2) { + newcells->AddCoords(x, y); + pCells[y*pXCellSize+x].SetPotValue(transitionindex, potvalue); + } // Ende "unentdeckte Zelle" gefunden + } // Ende 'drumherum ueber Ecken & Kanten gucken + } // Ende 'oldcells[]' durchgehen +// Neue Zellen in alte Zellen und nach neuen Nachbarzellen suchen + delete oldcells; + oldcells = NULL; + oldcells = newcells; + newcells = NULL; + } while (oldcells->GetCoordsCount() != 0); + if (oldcells != NULL) { + delete oldcells; + oldcells = NULL; + } +} +//--------------------------------------------------------------------------- + +int CRoom::LookPotValue(int transition, int direction, int &x, int &y) +// Gibt den Wert des Potenzials 'transition' in Richtung 'direction' von (x,y) aus zurueck +// x, y werden dabei entsprechend geaendert +// Wenn vor Wand oder vor Rand des Rechenfelds, dann wird -1 zurueckgegeben +// Richtung: im Uhrzeigersinn hochgezaehlt, 1 = Zelle in Richtung "oben", also (0,-1) +{ + int transitionindex = -1; + +// "transitionindex" bestimmen + for (int i=0; i<pTransitionCount; ++i) { + if (pTransitionTable[i] == transition) + transitionindex = i; + } +// Rechenrand: + if ((x==0)&&((direction==6)||(direction==7)||(direction==8))) + return -1; + else if ((x==pXCellSize-1)&&((direction==2)||(direction==3)||(direction==4))) + return -1; + else if ((y==0)&&((direction==8)||(direction==1)||(direction==2))) + return -1; + else if ((y==pYCellSize-1)&&((direction==4)||(direction==5)||(direction==6))) + return -1; +// im Rechengebiet: + else { +// jetzige Zelle + switch (direction) { + case 1: --y; break; + case 2: ++x; --y; break; + case 3: ++x; break; + case 4: ++x; ++y; break; + case 5: ++y; break; + case 6: --x; ++y; break; + case 7: --x; break; + case 8: --x; --y; break; + default: pErrorLog->AddEntry("ERROR: Direction error in CRoom::GetPotValue()"); + } + return GetPotValue(transition, x, y); // pCells[y*pXCellSize+x].GetPotValue(transitionindex); + } +} +//--------------------------------------------------------------------------- + +int CRoom::GetPotValue(int transition, int x, int y) +// Gibt den Wert des Potenzials 'transition' auf (x,y) zurueck +// Wenn Wandzelle, wird -1 zurueckgegeben +{ + int transitionindex = -1; + +// "transitionindex" bestimmen + for (int i=0; i<pTransitionCount; ++i) { + if (pTransitionTable[i] == transition) + transitionindex = i; + } +// ausserhalb des Raumes + if ((x<0)||(x>pXCellSize)||(y<0)||(y>pYCellSize)) + return -1; +// im Rechengebiet: + else if ((pCells[y*pXCellSize+x].GetType()==tFloor) || (pCells[y*pXCellSize+x].GetType()==tStep) || (pCells[y*pXCellSize+x].GetType()==tTransition)) { + return pCells[y*pXCellSize+x].GetPotValue(transitionindex); + } + else + return -1; +} +//--------------------------------------------------------------------------- + +int CRoom::GetTransitionTableValue(int index) +// gibt Wert von Position "index" zurueck +{ + if ((index>=0) && (index<pTransitionCount)) + return pTransitionTable[index]; + else { + pErrorLog->AddEntry("ERROR: Wrong Index in CRoom::GetTransitionTableValue()"); + return -1; + } +} +//--------------------------------------------------------------------------- + +void CRoom::SavePotsToFile(FILE *potfile) +// Speichert Potenziale int "potfile", zum Debuggen +{ + int x, y; + for (int transcount=0; transcount<pTransitionCount; ++transcount) { + fprintf(potfile, "Transition %i:\n", pTransitionTable[transcount]); + for (y=0; y<pYCellSize; ++y) { + for (x=0; x<pXCellSize; ++x) { + fprintf(potfile, "%4i,", pCells[y*pXCellSize+x].GetPotValue(transcount)); + } + fprintf(potfile, "\n"); + } + fprintf(potfile, "\n"); + } + fprintf(potfile, "\n"); +} +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- diff --git a/src/geometry/pg3/CRoom.h b/src/geometry/pg3/CRoom.h new file mode 100644 index 0000000000000000000000000000000000000000..1c66c6fb69fb1486a0fab831f48b9fb85eb6a8c7 --- /dev/null +++ b/src/geometry/pg3/CRoom.h @@ -0,0 +1,105 @@ +/*--------------------------------------------------------------------------- +CRoom: +====== +Autor: Tim Meyer-Koenig (TraffGo HT) +Beschreibung: Verwaltet die Daten eines Raums, der sowohl kontinuierlich (*CLine) +und zellular (*CCell) repraesentiert wird. + +---------------------------------------------------------------------------*/ + +//--------------------------------------------------------------------------- +#ifndef CRoomH +#define CRoomH + +// Systemheader: +#include <string> +#include <cstring> +#include <cstdlib> +#include <stdio.h> +using namespace std; + +// Eigene Header: +#include "Common.h" +#include "CTextLog.h" +#include "CCell.h" +#include "CLine.h" +#include "CCoordsList.h" + +//--------------------------------------------------------------------------- + +class CRoom { +private: + int pRoomIndex; // Raumindex + string pCaption; // Raumname + CTextLog *pErrorLog; // Log-Klasse fuer Fehlermeldungen + +// Geometriedaten: + int pZPos; // Hoehenindex, in meinen Augen ist hier die Unterscheidung kontunuierlich/zellular egal + int pXCellPos; + int pYCellPos; // Raumposition in Zellen + int pXCellSize; + int pYCellSize; // Raumabmessung in Zellen +// int pLineElementCount; // Anzahl der Linienelemente + int pTransitionCount; // Anzahl der Transitions (=Anzahl der Potenziale) + vector<int> pTransitionTable; // uebersetzungstabelle pTransitionsTable[0..pTransitionCount-1]=globale Transition-Nummer + CPoint pContPos; // Raumposition kontinuierlich in Metern + float pXContSize; + float pYContSize; // Raumabmessung kontinuierlich in Metern + vector<CCell> pCells; // zellulare Repraesentation des Raums [pXCellSize*pYCellSize] + vector<CLine> pLines; // kontinuierliche Repraesentation des Raumes [pContElementCount] + +/* !Agentendaten habe ich erstmal generell auskommentiert! +// Agentendaten: + int pTransAgentCount; // Anzahl der Agenten auf Transition-Zellen + int *pTransAgents; // Indizes der Agenten auf Trans-Zellen [pTransAgentCount] + int pAgentCount; // Anzahl der Agenten in diesem Raum + CAgents *pAgents; // Agenten des Raumes [pAgentCount] +*/ +public: + CRoom(void); // Constructor + ~CRoom(void); // Destructor + void Initialize(CTextLog *errorlog, int roomindex); // weist pErrorLog zu + void EditDoor(int index, bool isopen); // setzt Oeffnungszustand der Tuer "index" auf "isopen" + void CopyData(CRoom room); // kopiert die Daten von "room" in sich selbst + void LoadFromFile(FILE *buildingfile); // laedt Raumdaten aus Datei "buildingfile" + void SpreadPotential(int transition); // breitet das Potenzial von "transition" im Raum aus + void SavePotsToFile(FILE *potfile); // Speichert Potenziale int "potfile", zum Debuggen +// Get-Funktionen: + bool GetCell(int x, int y, CCell &cell); // setzt Zeiger "cell" auf die Zelle an Position (x, y) + bool GetLine(int index, CLine &line); // setzt Zeiger "line" auf das Linienelement "index" + CLine GetLine(int index); // gibt Linienelement "index" zurueck + int GetRoomIndex(void) {return pRoomIndex;}; // Raumindex + string GetCaption(void) {return pCaption;}; // Raumname + int GetXCellPos(void) {return pXCellPos;}; + int GetYCellPos(void) {return pYCellPos;}; // Raumposition in Zellen + int GetZPos(void) {return pZPos;}; // Hoehenindex + int GetXCellSize(void) {return pXCellSize;}; + int GetYCellSize(void) {return pYCellSize;}; // Raumabmessung in Zellen +// int GetLineElementCount(void) {return pLineElementCount;}; // Anzahl der Linienelemente + int GetLineElementCount(void) {return pLines.size();}; // Anzahl der Linienelemente + int LookPotValue(int transition, int direction, int &x, int &y); // gibt den Wert des Potenzials 'transition' in Richtung 'direction' von (x,y) aus zurueck + int GetPotValue(int transition, int x, int y); // gibt den Wert des Potenzials 'transition' in Richtung 'direction' von (x,y) aus zurueck + int GetTransitionCount(void) {return pTransitionCount;}; // gibt Anzahl der Transitions zurueck + int GetTransitionTableValue(int index); // gibt Wert von Position "index" zurueck + const CPoint& GetContPos(void) const {return pContPos;}; // Raumposition kontinuierlich in Metern + float GetXContSize(void) {return pXContSize;}; + float GetYContSize(void) {return pYContSize;}; // Raumabmessung kontinuierlich in Metern + +// Set-Funktionen: +/* diese hier sind vielleicht gar nicht noetig: + void SetRoomIndex(int index) {pRoomIndex = index;}; // Raumindex + void SetCaption(string caption) {pCaption = caption;}; // Raumname + void SetXCellPos(int xpos) {pXCellPos = xpos;}; + void SetYCellPos(int ypos) {pYCellPos = ypos;}; + void SetZCellPos(int zpos) {pZCellPos = zpos;}; // Raumposition in Zellen + void SetXCellSize(int xsize) {pXCellSize = xsize;}; + void SetYCellSize(int ysize) {pYCellSize = ysize;}; // Raumabmessung in Zellen + void SetContElementCount(int count) {pContElementCount = count;}; // Anzahl der Linienelemente + void SetZContPos(float zpos) {pZContPos = zpos;}; // Raumposition kontinuierlich in Metern + void GetXContSize(float xsize) {pXContSize = xsize;}; + void GetYContSize(float ysize) {pYContSize = ysize;}; // Raumabmessung kontinuierlich in Metern +*/ + void SetContPos(const CPoint& p){pContPos=p;}; // setzt die Punktkoordinaten in pContPos +}; + +#endif diff --git a/src/geometry/pg3/CTextLog.cpp b/src/geometry/pg3/CTextLog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0e0a65ca59cd7b61ea31f7b3854f026b256e9dca --- /dev/null +++ b/src/geometry/pg3/CTextLog.cpp @@ -0,0 +1,65 @@ +#include "CTextLog.h" + + + +CTextLog::CTextLog(void) +// Constructor +{ +// pTextEntries = 0; +// pTextEntryCount = 0; +} +//--------------------------------------------------------------------------- + +CTextLog::~CTextLog(void) +// Destructor +{ + if (pTextEntries.size() > 0) pTextEntries.clear(); +} +//--------------------------------------------------------------------------- + +void CTextLog::AddEntry(string text) +// fuegt einen Eintrag hinzu +{ + pTextEntries.push_back(text); +/* + string *tempvector; + int i; + + tempvector = pTextEntries; // Temp-Vektor anlegen + ++pTextEntryCount; + pTextEntries = new string [pTextEntryCount]; + for (i=0; i<pTextEntryCount-1; ++i) // Daten aus Temp-Vektor in neuen Vektor kopieren + pTextEntries[i] = tempvector[i]; + delete [] tempvector; + pTextEntries[pTextEntryCount-1] = text; // Eintrag hinten anf�gen +*/ +} +//--------------------------------------------------------------------------- + +void CTextLog::SaveToFile(string path) +// speichert alle Eintr�ge in einer txt-Datei +{ + FILE *logfile; + int i; + + logfile = fopen(path.c_str(), "wt"); + + if(logfile != NULL){ + // Header: + fprintf(logfile, "Simulator Log-Datei\n"); + fprintf(logfile, "===================\n\n"); + // Inhalt + fprintf(logfile, "Meldungen:\n"); + fprintf(logfile, "----------\n"); + for (i=0; i<(int)pTextEntries.size(); ++i) + fprintf(logfile, "%i) %s\n\n",i, pTextEntries[i].c_str()); + fclose(logfile); + } + else{ + printf("Can not open file [%s]! (errorlogfile)\n", path.c_str()); + exit(EXIT_FAILURE); + } +} +//--------------------------------------------------------------------------- + + diff --git a/src/geometry/pg3/CTextLog.h b/src/geometry/pg3/CTextLog.h new file mode 100644 index 0000000000000000000000000000000000000000..f812d36f973754c4946a5c537471a8c1496fca42 --- /dev/null +++ b/src/geometry/pg3/CTextLog.h @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------- +CTextLog: +========= +Autor: Tim Meyer-K�nig (TraffGo HT) +Beschreibung: Textlog verwaltet Text-Eintr�ge und speichert sie bei Bedarf in eine +Datei. So k�nnen z.B. Fehler mitgelogged werden. + +---------------------------------------------------------------------------*/ + +//--------------------------------------------------------------------------- +#ifndef CTextLogH +#define CTextLogH + +// Systemheader: +#include <string> +#include <vector> +using namespace std; +#include <stdio.h> +#include <cstdlib> + +// Eigene Header: + +//--------------------------------------------------------------------------- + +class CTextLog { +private: + vector<string> pTextEntries; +// int pTextEntryCount; +public: + CTextLog(void); // Constructor + ~CTextLog(void); // Destructor + void AddEntry(string text); // f�gt einen Eintrag hinzu + void SaveToFile(string path); // speichert alle Eintr�ge in einer txt-Datei +}; + +#endif + \ No newline at end of file diff --git a/src/geometry/pg3/CTransition.cpp b/src/geometry/pg3/CTransition.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c60a002b150f2cb0a4e2daab6a544f5aebb9bd7f --- /dev/null +++ b/src/geometry/pg3/CTransition.cpp @@ -0,0 +1,62 @@ +#include "CTransition.h" + + +CTransition::CTransition(void) +// Constructor +{ + pTransitionIndex = -1; // �bergangsindex + pRoom1 = -1; + pRoom2 = -1; // Indizes der R�ume, die verbunden werden + pCaption = "no caption"; // Name, z.B. bei T�ren entsprechend des Raumbuchs +} +//--------------------------------------------------------------------------- + +CTransition::~CTransition(void) +// Destructor +{ +} +//--------------------------------------------------------------------------- + +void CTransition::Initialize(CTextLog *errorlog, int i) +// Initialisieren +{ + pErrorLog = errorlog; + pTransitionIndex = i; +} +//--------------------------------------------------------------------------- + +void CTransition::CopyData(CTransition transition) +// Kopiert die Daten von "transition" in sich selbst +{ + pTransitionIndex = transition.GetTransitionIndex(); + pRoom1 = transition.GetRoom1(); + pRoom2 = transition.GetRoom2(); + pCaption = transition.GetCaption(); +} +//--------------------------------------------------------------------------- + +void CTransition::LoadFromFile(FILE *buildingfile) +// L�dt Transitiondaten aus Datei "buildingfile" +{ + char line[255]; + + fscanf(buildingfile,"%s",&line[0]); + while (strcmp(line,"</transition>")) { + if (!strcmp(line,"caption")) { // Raumname + char value[255]; + ReadLine(buildingfile, value); + string *tempstring = new string(value); + pCaption = *tempstring; + delete tempstring; + pCaption = DelFreeSpaces(pCaption); + } + else if (!strcmp(line,"room1")) // Raum 1 (auf der einen Seite des Transitionpunkts) + fscanf(buildingfile,"%i", &pRoom1); + else if (!strcmp(line,"room2")) // Raum 2 (auf der anderen Seite des Transitionpunkts) + fscanf(buildingfile,"%i", &pRoom2); + fscanf(buildingfile,"%s",&line[0]); // n�chsten Eintrag einlesen + } // Ende: <transition> +} + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- diff --git a/src/geometry/pg3/CTransition.h b/src/geometry/pg3/CTransition.h new file mode 100644 index 0000000000000000000000000000000000000000..4a90455af2d26664a31a12df105d9fb3955660b5 --- /dev/null +++ b/src/geometry/pg3/CTransition.h @@ -0,0 +1,54 @@ +/*--------------------------------------------------------------------------- +CTransition: +============ +Autor: Tim Meyer-Koenig (TraffGo HT) +Beschreibung: Verwaltet die Daten eines Uebergangs zwischen zwei Raeumen, also einer +Tuerschwelle, oder der ersten, bzw. letzten Stufe einer Treppe. Geometrisch werden +die Daten in CRoom verwaltet, doch CTransition enthaelt die Informationen darueber, +welche Raeume verbunden werden. + +---------------------------------------------------------------------------*/ + +//--------------------------------------------------------------------------- +#ifndef CTransitionH +#define CTransitionH + +// Systemheader: +#include <stdio.h> +#include <string> +using namespace std; + +// Eigene Header: +#include "CTextLog.h" +#include "Common.h" +//--------------------------------------------------------------------------- + +class CTransition { +private: + int pTransitionIndex; // Uebergangsindex + int pRoom1; + int pRoom2; // Indizes der Raeume, die verbunden werden + string pCaption; // Name, z.B. bei Tueren entsprechend des Raumbuchs + CTextLog *pErrorLog; + +public: + CTransition(void); // Constructor + ~CTransition(void); // Destructor + void Initialize(CTextLog *errorlog, int i); // Initialisieren + void CopyData(CTransition transition); // Kopiert die Daten von "transition" in sich selbst + void LoadFromFile(FILE *buildingfile); // Laedt Transitiondaten aus Datei "buildingfile" + +// Get-Funktionen: + int GetTransitionIndex(void) {return pTransitionIndex;}; // Uebergangsindex + int GetRoom1(void) {return pRoom1;}; + int GetRoom2(void) {return pRoom2;}; // Indizes der Raeume, die verbunden werden + string GetCaption(void) {return pCaption;}; // Name, z.B. bei Tueren entsprechend des Raumbuchs + +// Set-Funktionen: + void SetTransitionIndex(int index) {pTransitionIndex = index;}; // Uebergangsindex + void SetRoom1(int room1) {pRoom1 = room1;}; + void SetRoom2(int room2) {pRoom2 = room2;}; // Indizes der Raeume, die verbunden werden + void SetCaption(string caption) {pCaption = caption;}; // Name, z.B. bei Tueren entsprechend des Raumbuchs +}; + +#endif diff --git a/src/geometry/pg3/Common.cpp b/src/geometry/pg3/Common.cpp new file mode 100644 index 0000000000000000000000000000000000000000..159679eba2f098ff6b6794bd48a8893bb3a7d83b --- /dev/null +++ b/src/geometry/pg3/Common.cpp @@ -0,0 +1,27 @@ +#include "Common.h" + + +void ReadLine(FILE *file, char *line) +// Liest die gesamte Zeile aus "file" in "line" ein +{ + do { + if (fscanf (file,"%[^\r\n]\n",line) == EOF) + strcpy (line,"END"); + } while ((line[0]) == '#'); +} +//--------------------------------------------------------------------------- + +string DelFreeSpaces(string value) +// Entfernt Leerzeichen am Anfang von "value" +{ +// while (value.IsDelimiter(" ", 1)) { +// value.Delete(1, 1); +// } + while (value.compare(0, 1, " ")==0) + value.erase(0,1); + return value; +} +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- diff --git a/src/geometry/pg3/Common.h b/src/geometry/pg3/Common.h new file mode 100644 index 0000000000000000000000000000000000000000..2b4ae1a1d76a739178b778935ab1f00b5ef4b462 --- /dev/null +++ b/src/geometry/pg3/Common.h @@ -0,0 +1,31 @@ +/*--------------------------------------------------------------------------- +Common: +======= +Autor: Tim Meyer-K�nig (TraffGo HT) +Beschreibung: Enth�lt allgemeine Definitionen und Funktionen + +---------------------------------------------------------------------------*/ +#ifndef CommonH +#define CommonH +//--------------------------------------------------------------------------- + +#include <stdio.h> +#include <string> +#include <cstring> +using namespace std; + +//--------------------------------------------------------------------------- + +// Linien- und Zelltypen; +#define tFloor 0 +#define tWall 1 +#define tStep 2 +#define tTransition 3 +#define tOutside 4 +//--------------------------------------------------------------------------- + +void ReadLine(FILE *file, char *line); // Liest die gesamte Zeile aus "file" in "line" ein +string DelFreeSpaces(string value); // Entfernt Leerzeichen am Anfang von "value" + +#endif + \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5870074e37a0d61f34a8df789ce30af23d82837b --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,64 @@ +/** +* @file main.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief This is what it does... :) +* +* Created on: 05.05.2009 +* +*/ + + + +/** +* @mainpage +* +* \date 7.6.2010 +* +* TraVisTo stands for Trajectories Visualisation Tool and is part of the OPS Project. +* +* @image html travisto.png " " +* +* Some useful links: +* +* 1: <a href="http://www.openpedsim.org">www.openpedsim.org</a> <br> +* 2: <a href="http://www.vtk.org">www.vtk.org</a> <br> +* 3: <a href="http://www.trolltech.com">www.trolltech.com</a> <br> +* 4: <a href="http://www.fz-juelich.de">www.fz-juelich.de</a> <br> +* +*/ + +#include <QApplication> +#include "travisto.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + // To ensure that decimal numbers use a "point" instead of "colon" on some systems + setlocale(LC_NUMERIC, "en_US" ); + + TraVisTo w; + w.show(); + + return a.exec(); +} diff --git a/src/network/TraVisToServer.cpp b/src/network/TraVisToServer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1dd0a52dbeb2c2c74a757d1890e405d98a9585e8 --- /dev/null +++ b/src/network/TraVisToServer.cpp @@ -0,0 +1,302 @@ +/** +* @headerfile TraVisToServer.cpp +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief provide a server that listens to incoming trajectories stream +* +* Created on: 22.09.2009 +* +*/ + +#include <QMessageBox> + +#include "TraVisToServer.h" + +#include <iostream> + + +using namespace std; + +TraVisToServer::TraVisToServer(quint16 port) { + this->port=port; + isConnected=false; + listening=false; + //QObject(0); + qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); + createConnection(); + +} + +TraVisToServer::~TraVisToServer() { + if(tcpServer->isListening()){ + tcpServer->close(); + } + delete tcpServer; + +} + +void TraVisToServer::close(){ + tcpServer->close(); +} + +void TraVisToServer::slotHandleConnection(){ + + // cerr<<"handling new connection"<<endl; + // + //// while(tcpServer->waitForNewConnection(-1)){ + //// cerr<<"uuuu"<<endl; + //// } + // QTcpSocket *clientConnection = tcpServer->nextPendingConnection(); + // connect(clientConnection, SIGNAL(disconnected()), + // clientConnection, SLOT(deleteLater())); + // + // if(clientConnection->waitForReadyRead(-1)){ + // cerr<<"could somehow not read from the device"<<endl; + // } + // + // // while(1){ + //receive data until disconnected + + // cerr<<"juhuuuu"<<endl; + + //receive geometry + + // // receive trajectories + // QDataStream in(clientConnection); + // in.setVersion(QDataStream::Qt_4_0); + // + // if (blockSize == 0) { + // if (clientConnection->bytesAvailable() < (int)sizeof(quint16)) + // return; + // in >> blockSize; + // } + // + // if (clientConnection->bytesAvailable() < blockSize) + // return; + // + // QString nextFortune; + // in >> nextFortune; + // + // cerr<<nextFortune.toStdString()<<endl; + + // } + +} + + +void TraVisToServer::createConnection(){ + + tcpServer = new QTcpServer(); + tcpServer->setMaxPendingConnections(2); + + if (!tcpServer->listen(QHostAddress::Any,port)) { + cerr<<"I cant listen to ALL interfaces, sorry"<<endl; + cerr<<"I will try to listen only the LocalHost (127.0.0.1)"<<endl; + + if (!tcpServer->listen(QHostAddress::LocalHost,port)) { + cerr<<"I cant listen to LocalHost either, sorry"<<endl; + + //QMessageBox::critical(0, tr("TraVisTo Server"), + // tr("Unable to start the server: %1.").arg(tcpServer->errorString())); + // close(); + return; + } + } + if(!connect(tcpServer, SIGNAL(newConnection()), this, SLOT(slotHandleConnection()))){ + cerr<<"could not create connection newconnection"<<endl; + } + + if(tcpServer->isListening ()){ + listening=true; + cerr<<"\nTraVisTo is listening on port "<< tcpServer->serverPort()<<endl; + } + //slotHandleConnection(); +} + + +void TraVisToServer::receiveMessage(/*char* result*/ QString & result){ + + result.clear(); + + if(!isConnected){ + // pool each 1000 ms. bad idea i Know ! + if(!tcpServer->waitForNewConnection(1000)){ +// cerr<<"something went wrong, with the server"<<endl; +// cerr <<" 200 ms passed !"<<endl; + return; + } + + clientConnection = tcpServer->nextPendingConnection(); + connect(clientConnection, SIGNAL(disconnected()), + clientConnection, SLOT(deleteLater())); + + // if(!clientConnection->waitForReadyRead()){ + // cerr<<"could somehow not read from the device"<<endl; + // return; + // } + if(!connect(clientConnection, SIGNAL(readyRead()), this, SLOT(slotReadMessage()))){ + cerr<<"can't connect ready read slot"<<endl; + } + + qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); + if(!connect(clientConnection, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(slotDisplayError(QAbstractSocket::SocketError)))){ + cerr<<"cant connect error slot"<<endl; + } + + isConnected=true; + } + + if(!clientConnection->waitForReadyRead()){ + clientConnection->disconnectFromHost(); + clientConnection->abort(); + isConnected=false; // the connection is lost + cerr<<"Connection was closed"<<endl; + return; + } + + while (clientConnection->bytesAvailable() < (int)sizeof(quint16)) { + if (!clientConnection->waitForReadyRead(-1)) { + // emit error(socket.error(), socket.errorString()); + cout << "o000ooh la lalala"<<endl; + return; + } + } + // quint16 blockSize; + // QDataStream in(clientConnection); + // in.setVersion(QDataStream::Qt_4_0); + // in >> blockSize; + + //first the size of the data + char tell[10]; + clientConnection->readLine(tell,10); + // cout<<"line: "<<tell<<endl; + + blockSize = atoi(tell); + + while (clientConnection->bytesAvailable() < blockSize) { + if (!clientConnection->waitForReadyRead(-1)) { + //emit error(clientConnection->error(), clientConnection->errorString()); + cout << "ouh la lalala"<<endl; + return; + } + } + + + // QString fortune; + // in >> result; + //clientConnection->flush(); + + // blockSize =clientConnection->read(sizeof(quint16)).toUShort(); + // quint16 toRead=0; + // QString mesg; + + // while (toRead < blockSize) { + // toRead+=clientConnection->bytesAvailable(); + // QByteArray fr =clientConnection->read(toRead); + // clientConnection->flush(); + // mesg.append(fr); + // cout<<toRead <<":"<<blockSize<<endl; + // } + // cout <<"data size:"<<clientConnection->bytesAvailable() <<":" << blockSize<<endl; + QByteArray fr =clientConnection->read(blockSize); + // char *data = (char*)malloc(blockSize*sizeof(char));; + // cout<<data<<endl; + // cout<< clientConnection->read(data,blockSize)<<" read"<<endl; + // cout<<data<<endl; + result = QString(fr); + // in >> result; + // cout <<"size: "<<result.length()<<endl; + //cout <<"size: "<<result.toStdString()<<endl; + // cout <<"size: "<<fr.size()<<endl; + // QString msg(fr); + + // result=msg; + // cout << "data: "<< count++<< msg.toStdString()<<endl; + // cout << "data: "<< count++<<":" << blockSize<<endl; + // cout << "data: "<< count++<<":" << data<<endl; + // cout << "data: "<< count++<< size<<endl; + + + // //get all data + // QByteArray data = clientConnection->readAll(); + // + // //result= new char[data.size()]; + // result=data.data(); + + // //if(!data.isEmpty()) + // cout <<" size>>"<< blockSize<<endl; + // cout <<" >>"<<result.toStdString()<<endl; + // system("pause"); + // //cout <<" >>"<<result.t<<endl; + + //cout <<result.toStdString()<<endl; +} + + +void TraVisToServer::sendMessage(char* data){ + + +} + +void TraVisToServer::slotDisplayError(QAbstractSocket::SocketError socketError) +{ + switch (socketError) { + + case QAbstractSocket::RemoteHostClosedError: + cerr<< "The host closed the connection "<<endl; + break; + + case QAbstractSocket::HostNotFoundError: + cerr<< "The host was not found. Please check the "<<endl; + cerr<< "host name and port settings."<<endl; + break; + + case QAbstractSocket::ConnectionRefusedError: + cerr<<"The connection was refused by the peer. "<<endl; + cerr<< "Make sure the fortune server is running, "<<endl; + cerr<<"and check that the host name and port "<<endl; + cerr<<"settings are correct."<<endl; + break; + + default: + cerr<<"TraVisTo Client:"<<endl; + cerr<<"The following error occurred: "<<endl; + //cerr<< clientConnection->errorString().toStdString()<<endl; + break; + } + +} +void TraVisToServer::slotConnectionClosed(){ + //clientConnection->deleteLater(); + isConnected=false; + //cerr<< "connection lost"<<endl; +} + +void TraVisToServer::slotReadMessage(){ + //clientConnection->deleteLater(); + //isConnected=false; + // cerr<< "you have a post"<<endl; + +} diff --git a/src/network/TraVisToServer.h b/src/network/TraVisToServer.h new file mode 100644 index 0000000000000000000000000000000000000000..b96939378515866edd32c00e14b058b30c3eb346 --- /dev/null +++ b/src/network/TraVisToServer.h @@ -0,0 +1,82 @@ +/** +* @headerfile TraVisToServer.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* @brief provide a server that listens to incoming trajectories stream +* +* Created on: 22.09.2009 +* +*/ + + +#ifndef TRAVISTOSERVER_H_ +#define TRAVISTOSERVER_H_ + +#include<QtNetwork/QtNetwork> +#include<QObject> + + +#define PORT 8989 + +class TraVisToServer:public QObject { + + Q_OBJECT + +public: + TraVisToServer(quint16 port=PORT); + virtual ~TraVisToServer(); + + //void receiveMessage(char* data); + void receiveMessage(QString& msg); + void sendMessage(char* data); + bool isListening(){return listening;} + void close(); + +private: + void createConnection(); + void closeConnection(); + +private Q_SLOTS: + void slotHandleConnection(); + void slotReadMessage(); + void slotConnectionClosed(); + void slotDisplayError(QAbstractSocket::SocketError socketError); + //void slotConnected(); + //void slotDisconnected(); + + +private: + bool isConnected; + bool listening; + //QTcpSocket *tcpSocket; + //QTcpSocket *clientConnection; + QTcpSocket *clientConnection; + QTcpServer *tcpServer; + QString currentFortune; + int blockSize; + quint16 port; + +}; + +#endif /* TRAVISTOSERVER_H_ */ diff --git a/src/travisto.cpp b/src/travisto.cpp new file mode 100644 index 0000000000000000000000000000000000000000..57edee9d54437591f2b369f5b0b2519e94a8d424 --- /dev/null +++ b/src/travisto.cpp @@ -0,0 +1,1586 @@ +/** + * @file travisto.cpp + * @author Ulrich Kemloh <kemlohulrich@gmail.com> + * @version 0.1 + * Copyright (C) <2009-2010> + * + * @section LICENSE + * This file is part of OpenPedSim. + * + * OpenPedSim is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * OpenPedSim 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. + * + * @section DESCRIPTION + * + * \brief main program class + * + * + * Created on: 11.05.2009 + * + */ + + +#include "travisto.h" +#include "SaxParser.h" +#include "SystemSettings.h" +#include "./forms/Settings.h" + + +#include "extern_var.h" +#include "TrajectoryPoint.h" +#include "Frame.h" +#include "Debug.h" +#include "ThreadVisualisation.h" +#include "ThreadDataTransfert.h" +#include "SimpleVisualisationWindow.h" + +#include "geometry/FacilityGeometry.h" +#include "geometry/jul/Building.h" +#include "geometry/pg3/CBuilding.h" + + +#include <QtGui/QMessageBox> +#include <QtXml/QDomDocument> +#include <QTime> +#include <QApplication> +#include <QCloseEvent> +#include <QThread> +#include <QIODevice> +#include <QDir> +#include <QFile> +#include <QFileDialog> +#include <QInputDialog> +#include <QString> +#include <QColorDialog> +#include <QDebug> +#include <QtXml> + +#include <iostream> +#include <limits> +#include <string> +#include <vector> + +using namespace std; + +TraVisTo::TraVisTo(QWidget *parent) : + QMainWindow(parent) { + ui.setupUi(this); + this->setWindowTitle("TraVisTo"); + + //disable the maximize Button + setWindowFlags( Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint ); + + //create the 2 threads and connect them + dataTransferThread = new ThreadDataTransfer(this); + visualisationThread = new ThreadVisualisation(this); + + + travistoOptions = new Settings(this); + travistoOptions->setWindowTitle("Settings"); + travistoOptions->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint); + + + if(!QObject::connect(dataTransferThread, + SIGNAL(signal_controlSequence(const char*)), this, + SLOT(slotControlSequence(const char *)))){ + Debug::Error("dataTransferThread Thread: control sequence could not be connected"); + } + + if(!QObject::connect(dataTransferThread, + SIGNAL(signal_startVisualisationThread(QString,int,float )), this, + SLOT(slotStartVisualisationThread(QString,int,float )))){ + Debug::Error(" signal_startVisualisationThread not connected"); + } + + if(!QObject::connect(dataTransferThread, + SIGNAL(signal_stopVisualisationThread(bool )), this, + SLOT(slotShutdownVisualisationThread(bool )))){ + Debug::Error(" signal_stopVisualisationThread not connected "); + } + + if(!QObject::connect(dataTransferThread, + SIGNAL(signal_errorMessage(QString)), this, + SLOT(slotErrorOutput(QString)))){ + Debug::Error("signal_errorMessage not connected "); + } + + QObject::connect(visualisationThread, + SIGNAL(signal_controlSequences(const char*)), this, + SLOT(slotControlSequence(const char *))); + + QObject::connect(&extern_trajectories_firstSet, + SIGNAL(signal_controlSequences(const char*)), this, + SLOT(slotControlSequence(const char *))); + + QObject::connect(&extern_trajectories_secondSet, + SIGNAL(signal_controlSequences(const char*)), this, + SLOT(slotControlSequence(const char *))); + + QObject::connect(&extern_trajectories_thirdSet, + SIGNAL(signal_controlSequences(const char*)), this, + SLOT(slotControlSequence(const char *))); + + + QObject::connect(dataTransferThread, SIGNAL(signal_CurrentAction(QString)), + this, SLOT(slotCurrentAction(QString))); + + QObject::connect(this, SIGNAL(signal_controlSequence(QString)), + travistoOptions, SLOT(slotControlSequence(QString))); + + isPlaying = false; + isPaused = false; + numberOfDatasetLoaded=0; + frameSliderHold=false; + + + labelCurrentAction = new QLabel(); + labelCurrentAction->setFrameStyle(QFrame::Panel | QFrame::Sunken); + // currentAction->setLineWidth(5); + // currentAction->setMargin(2); + // currentAction->setMidLineWidth(2); + labelCurrentAction->setText(" Idle "); + statusBar()->addPermanentWidget(labelCurrentAction); + + labelFrameNumber = new QLabel(); + labelFrameNumber->setFrameStyle(QFrame::Panel | QFrame::Sunken); + // frameNumber->setLineWidth(5); + // frameNumber->setFixedWidth(80); + // frameNumber->setMargin(2); + // frameNumber->setMidLineWidth(2); + labelFrameNumber->setText("fps:"); + statusBar()->addPermanentWidget(labelFrameNumber); + + labelRecording = new QLabel(); + labelRecording->setFrameStyle(QFrame::Panel | QFrame::Sunken); + labelRecording->setText(" rec: off "); + statusBar()->addPermanentWidget(labelRecording); + + labelMode = new QLabel(); + labelMode->setFrameStyle(QFrame::Panel | QFrame::Sunken); + labelMode->setText(" Offline "); + statusBar()->addPermanentWidget(labelMode); + + + ui.BtNextFrame->setVisible(false); + ui.BtPreviousFrame->setVisible(false); + //TODO: Maybe this is not longer needed + ui.framePerSecondSliderLabel->setVisible(false); + ui.contrastSettingSlider->setVisible(false); + + QStringList arguments =QApplication::arguments(); + int group=1; // there are max 3 groups of pedestrians + bool mayPlay=false; + + // arguments.append("-online"); + // arguments.append("-caption"); + arguments.append("-2D"); + // parse arguments list + if(arguments.size()>1) + for(int argCount=1;argCount<arguments.size();argCount++){ + + QString argument=arguments[argCount]; + + if(argument.compare("help")==0) { + Debug::Error("Usage: ./TraVisTo [file1] [file2] [file3] [-2D] [-caption] [-online [port]]"); + } + else if(argument.compare("-2D")==0) { + ui.action2_D->setChecked(true); + slotToogle2D(); + }else if(argument.compare("-caption")==0) { + ui.actionShow_Captions->setChecked(true); + slotShowPedestrianCaption(); + + }else if(argument.compare("-online")==0) { + slotSetOnlineMode(true); + + // checking for other possible options [ port...] + if(argCount!=arguments.size()-1){ + bool ok=false; + int port = arguments[++argCount].toInt(&ok); + Debug:: + Debug::Messages(" listening port: %d",port); + + if (ok) { + SystemSettings::setListningPort(port); + }else{ // maybe that wasnt the port + argCount--; // to ensure that the "option" will be checked + } + } + mayPlay=true; + + }else if(argument.startsWith("-")) { + const char* std=argument.toStdString().c_str(); + Debug::Error(" unknown options: %s",std); + Debug::Error("Usage: ./TraVisTo [file1] [file2] [file3] [-2D] [-caption] [-online [port] ]"); + + }else if(addPedestrianGroup(group,argument)){ + //slotHelpAbout(); + group++; + mayPlay=true; + } + + } + + if(mayPlay)slotStartPlaying(); +} + +TraVisTo::~TraVisTo() { + + extern_shutdown_visual_thread=true; + extern_recording_enable=false; + + + if (visualisationThread->isRunning()) { + //std::Debug::Messages("Thread visualisation is still running" << std::endl; + waitForVisioThread(); + } + + if (dataTransferThread->isRunning()) { + //std::Debug::Messages("Thread visualisation is still running" << std::endl; + //it is your own fault if you were still recording something + waitForDataThread(); + } + + delete dataTransferThread; + delete visualisationThread; + delete travistoOptions; + delete labelCurrentAction; + delete labelFrameNumber; + delete labelRecording; + delete labelMode; + +} + +void TraVisTo::slotHelpAbout() { + + QMessageBox::about( + this, + "About TraVisTo", + "Version 0.2 build with QT 4.6 and VTK 5.4\n\n" + "TraVisTo stands for Trajectories Visualisation Tool. It is a tool for visualizing pedestrians motion\n" + "developped at the Forschungszentrum Juelich, Germany\n\n" + "Copyright 2009-2011.\n" + "Authors: Ulrich Kemloh\n\n" + "For questions, contact +49-40-246161-4193 \nor mail at \n" + "u.kemloh@fz-juelich.de\n"); + +} + + + +/** + *setup the network port to bind + * + */ + +void TraVisTo::slotNetworkSettings() { + bool ok; + + int port = QInputDialog::getInteger(this, tr("input a port "), tr( + "port(default to 8081):"), 8989, 5000, 65355, 1, &ok); + + if (ok) { + SystemSettings::setListningPort(port); + } +} + + +void TraVisTo::slotStartPlaying() { + + //first reset this variable. just for the case + // the thread was shutdown from the reset option + extern_shutdown_visual_thread = false; + + + if (!isPlaying) { + statusBar()->showMessage(QString::fromUtf8("waiting for data")); + //only start the visualisation thread if in offline modus + // otherwise both threads should be started + if (extern_offline_mode) { + if(anyDatasetLoaded()){ //at least one dataset was loaded, restarting the playback + + // starting the playback from the beginning + extern_trajectories_firstSet.resetFrameCursor(); + extern_trajectories_secondSet.resetFrameCursor(); + extern_trajectories_thirdSet.resetFrameCursor(); + + } else if (!slotAddDataSet()) { //else load a dataset + return;//could not read any data + } + visualisationThread->start(); + + } else /*if (extern_online_mode)*/ { //live visualisation + dataTransferThread->start(); + //visualisationThread->start(); + } + + //enable recording + ui.BtRecord->setEnabled(true); + labelCurrentAction->setText(" playing "); + + ui.action3_D->setEnabled(false); + ui.action2_D->setEnabled(false); + + //disable legend + ui.actionShow_Legend->setEnabled(false); + + //change Icon to Pause + QIcon icon1; + icon1.addPixmap(QPixmap(QString::fromUtf8( + ":/new/iconsS/icons/PauseHot.png")), QIcon::Normal, QIcon::Off); + ui.BtStart->setToolTip("pause the visualisation"); + ui.BtStart->setIcon(icon1); + + //anyDataLoaded=true; + isPlaying = true; + extern_is_pause = false; + + } else if (isPaused) { //resume playing + isPaused = false; + extern_is_pause = false; + //restore the play Icon + QIcon icon1; + icon1.addPixmap(QPixmap(QString::fromUtf8( + ":/new/iconsS/icons/PauseHot.png")), QIcon::Normal, QIcon::Off); + ui.BtStart->setIcon(icon1); + labelCurrentAction->setText(" playing "); + ui.BtStart->setToolTip("pause the visualisation"); + + } else { //call pause + isPaused = true; + extern_is_pause = true; + QIcon icon1; + icon1.addPixmap(QPixmap(QString::fromUtf8( + ":/new/iconsS/icons/Play1Hot.png")), QIcon::Normal, QIcon::Off); + ui.BtStart->setIcon(icon1); + ui.BtStart->setToolTip("resume the visualisation"); + labelCurrentAction->setText(" paused "); + } + + //no matter what, the stop button should be enabled + ui.BtStop->setEnabled(true); +} + +void TraVisTo::slotStopPlaying() { + + if (extern_recording_enable) { + int res = QMessageBox::question(this, "action", + "do you wish to stop the recording?", QMessageBox::Discard + | QMessageBox::Yes, QMessageBox::Yes); + if (res == QMessageBox::Yes) { + extern_recording_enable = false; + //currentAction->setText(" Idle "); + labelRecording->setText("rec: OFF"); + + } else { + return; + } + } + + //shutdown the threads + //fixme: shut the network thread as well + // maybe this is a feature ! + extern_shutdown_visual_thread=true; + waitForVisioThread(); + + //reset all frames cursors + resetAllFrameCursor(); + + //disable/reset all graphical elements + isPlaying = false; + isPaused = false; + resetGraphicalElements(); + labelCurrentAction->setText(" Idle "); +} + +/** + * open a file containing visualisation data, parse them + * and initialize the visualization + * + */ +bool TraVisTo::slotLoadFile() { + + return slotAddDataSet(); + +} + + +// This function is only used in online Mode +FacilityGeometry* TraVisTo::parseGeometry(QDomNode geoNode){ + + if(geoNode.isNull()) return NULL; + + //check if there is a tag 'file' there in + QString fileName = geoNode.toElement().elementsByTagName("file").item(0).toElement().attribute("location"); + FacilityGeometry* geometry = visualisationThread->getGeometry(); + + if(!fileName.isEmpty()) + { + if(fileName.endsWith(".jul",Qt::CaseInsensitive)) + { + //should be a file name + //return parseGeometryJUL(fileName); + SaxParser::parseGeometryJUL(fileName,geometry); + } + else if (fileName.endsWith(".pg3",Qt::CaseInsensitive)) + { + //should be a file name + //return parseGeometryPG3(fileName); + SaxParser::parseGeometryPG3(fileName,geometry); + } + else if (fileName.endsWith(".trav",Qt::CaseInsensitive)) + { + //must not be a file name + SaxParser::parseGeometryTRAV(fileName,geometry); + } + } + // I assume it is a trav format node, + //which is the only one which can directly be inserted into a file + else + { + //must not be a file name + SaxParser::parseGeometryTRAV(fileName,geometry,geoNode); + } + return geometry; +} + +// TODO: still used? +bool TraVisTo::parsePedestrianShapes(QDomNode shapeNode, int groupID){ + + if(shapeNode.isNull()) return false; + QStringList heights; + QStringList colors; + + QDomNodeList agents = shapeNode.toElement().elementsByTagName("agentInfo"); + + for (unsigned int i = 0; i < agents.length(); i++) { + + bool ok=false; + int id=agents.item(i).toElement().attribute("ID").toInt(&ok); + if(!ok) continue; // invalid ID + double height=agents.item(i).toElement().attribute("height").toDouble(&ok); + if(!ok)height=std::numeric_limits<double>::quiet_NaN(); + + int color=agents.item(i).toElement().attribute("color").toDouble(&ok); + if(!ok)color=std::numeric_limits<int>::quiet_NaN(); + Debug::Messages("id= %d height= %lf color =%d",id,height,color); + + if(!isnan(height)){ + heights.append(QString::number(id)); + heights.append(QString::number(height)); + } + if(!isnan(color)){ + colors.append(QString::number(id)); + colors.append(QString::number(color)); + } + + } + switch (groupID){ + + case 1: + extern_trajectories_firstSet.setInitialHeights(heights); + extern_trajectories_firstSet.setInitialColors(colors); + break; + + case 2: + extern_trajectories_secondSet.setInitialHeights(heights); + extern_trajectories_secondSet.setInitialColors(colors); + break; + + case 3: + extern_trajectories_thirdSet.setInitialHeights(heights); + extern_trajectories_thirdSet.setInitialColors(colors); + break; + } + + return true; + +} + + +/// add a new dataset +bool TraVisTo::slotAddDataSet(){ + + if (numberOfDatasetLoaded>=3){ + QMessageBox::information(this,"notice","You can load at most 3 datasets.\n In" + " Order to load other data, please first clear previously loaded data."); + return false; + } + // if at least one data set was loaded + if (numberOfDatasetLoaded>=1){ + int res = QMessageBox::question(this, "action", + "adding a new dataset will reset the visualisation process. Continue?", QMessageBox::Discard + | QMessageBox::Yes, QMessageBox::Yes); + + if (res == QMessageBox::Discard) return false; + + } + + // just continue + numberOfDatasetLoaded++; + if(addPedestrianGroup(numberOfDatasetLoaded)==false){ + numberOfDatasetLoaded--; + return false; + } + + QString stre(numberOfDatasetLoaded); + stre.setNum(numberOfDatasetLoaded); + stre.append(" dataset loaded"); + statusBar()->showMessage(stre); + + return true; +} + +///clear all datasets previously entered. +void TraVisTo::slotClearAllDataset(){ + + clearDataSet(1); + clearDataSet(2); + clearDataSet(3); + numberOfDatasetLoaded=0; +} + + +bool TraVisTo::addPedestrianGroup(int groupID,QString fileName){ + statusBar()->showMessage(tr("Select a file")); + + if(fileName.isEmpty()) + fileName = QFileDialog::getOpenFileName(this, + "Select the file containing data to visualize", + "F:\\workspace\\TraVisTo\\data", + "Visualisation Files (*.dat *.trav *.xml *.pg3 *.jul);;All Files (*.*)"); + + + if (fileName.isNull()) { + return false; + } + + //the geometry actor + //FacilityGeometry* geometry=NULL; + FacilityGeometry* geometry = visualisationThread->getGeometry(); + + //reading and parsing + if(fileName.endsWith(".jul",Qt::CaseInsensitive)) + { + //geometry=parseGeometryJUL(fileName); + SaxParser::parseGeometryJUL(fileName,geometry); + } + else if (fileName.endsWith(".pg3",Qt::CaseInsensitive)) + { + //geometry=parseGeometryPG3(fileName); + SaxParser::parseGeometryPG3(fileName,geometry); + + } + + // // if jul is detected, just load and show the geometry then exit + // if(fileName.endsWith(".jul",Qt::CaseInsensitive)){ + // slotLoadParseShowGeometry(fileName); + // return false; + // } + + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) { + Debug::Error("could not open the File: ",fileName.toStdString().c_str()); + return false; + } + + SyncData* dataset=NULL; + + + switch(groupID){ + case 1: + Debug::Messages("handling first set"); + dataset=&extern_trajectories_firstSet; + extern_first_dataset_loaded=true; + extern_first_dataset_visible=true; + ui.actionFirst_Group->setEnabled(true); + ui.actionFirst_Group->setChecked(true); + slotToggleFirstPedestrianGroup(); + break; + + case 2: + Debug::Messages("handling second set"); + dataset=&extern_trajectories_secondSet; + extern_second_dataset_loaded=true; + extern_second_dataset_visible=true; + ui.actionSecond_Group->setEnabled(true); + ui.actionSecond_Group->setChecked(true); + slotToggleSecondPedestrianGroup(); + break; + + case 3: + Debug::Messages("handling third set"); + dataset=&extern_trajectories_thirdSet; + extern_third_dataset_loaded=true; + extern_third_dataset_visible=true; + ui.actionThird_Group->setEnabled(true); + ui.actionThird_Group->setChecked(true); + slotToggleThirdPedestrianGroup(); + break; + + default: + Debug::Error("invalid pedestrian group: %d " ,groupID); + Debug::Error("should be 1, 2 or 3"); + return false; + break; + } + + double frameRate=15; //default frame rate + statusBar()->showMessage(tr("parsing the file")); + QXmlInputSource source(&file); + QXmlSimpleReader reader; + + // no other geometry format was detected + if(geometry==NULL) + geometry=new FacilityGeometry(); + SaxParser handler(geometry,dataset,&frameRate); + reader.setContentHandler(&handler); + reader.parse(source); + file.close(); + + QString frameRateStr=QString::number(frameRate); + SystemSettings::setFilenamePrefix(QFileInfo ( fileName ).baseName()+"_"); + + // set the visualisation window title + visualisationThread->setWindowTitle(fileName); + visualisationThread->slotSetFrameRate(frameRate); + visualisationThread->setGeometry(geometry); + //visualisationThread->setWindowTitle(caption); + labelFrameNumber->setText("fps: " + frameRateStr+"/"+frameRateStr); + + //shutdown the visio thread + extern_shutdown_visual_thread=true; + waitForVisioThread(); + + statusBar()->showMessage(tr("file loaded and parsed")); + + return true; +} + + +void TraVisTo::slotRecord() { + + if (extern_recording_enable) { + int res = QMessageBox::warning(this, "action", + "TraVisTo is already recording a video\n" + "do you wish to stop the recording?", QMessageBox::Yes + | QMessageBox::No, QMessageBox::No); + if (res == QMessageBox::Yes) { + extern_recording_enable = false; + ui.BtRecord->setToolTip("Start Recording"); + labelCurrentAction->setText(" Playing "); + return; + } + } + extern_launch_recording = true; + ui.BtRecord->setToolTip("Stop Recording"); + labelRecording->setText("recording"); + //labelCurrentAction->setText(" recording "); + +} + + +QString TraVisTo::getTagValueFromElement(QDomNode node, + const char * tagName) { + if (node.isNull()) + return ""; + return node.toElement().namedItem(tagName).firstChild().nodeValue(); + +} + +void TraVisTo::slotFullScreen(bool status) { + + Debug::Messages("changing full screen status %d",status); + extern_fullscreen_enable = true; + + //dont forget this. + extern_force_system_update=true; + +} + +void TraVisTo::slotSetOfflineMode(bool status) { + + if (status) { + ui.actionOnline->setChecked(false); + extern_offline_mode = true; + labelMode->setText(" Offline "); + } else { + ui.actionOnline->setChecked(true); + extern_offline_mode = false; + labelMode->setText(" Online "); + + } + +} + +void TraVisTo::slotSetOnlineMode(bool status) { + if (status) { + ui.actionOffline->setChecked(false); + extern_offline_mode = false; + labelMode->setText(" Online "); + } else { + ui.actionOffline->setChecked(true); + extern_offline_mode = true; + labelMode->setText(" Offline "); + + } +} + +void TraVisTo::slotReset() { + + //stop any recording + if (extern_recording_enable) { + int res = QMessageBox::question(this, "action", + "do you wish to stop the recording?", QMessageBox::Discard + | QMessageBox::Yes, QMessageBox::Yes); + if (res == QMessageBox::Yes) { + extern_recording_enable = false; + labelCurrentAction->setText(" Playing "); + }else{ + return; + } + } + + if(anyDatasetLoaded()) + { + int res = QMessageBox::question(this, "action", + "This will also clear any dataset if loaded.\n" + "Do you wish to continue?", QMessageBox::Discard + | QMessageBox::Yes, QMessageBox::Yes); + if (res == QMessageBox::No) { + return; + } + } + + + //shutdown the visual thread + extern_shutdown_visual_thread = true; + waitForVisioThread(); + waitForDataThread(); + + //reset all buttons + //anyDataLoaded = false; + slotClearAllDataset(); + isPlaying = false; + isPaused = false; + labelCurrentAction->setText(" Idle "); + resetGraphicalElements(); + +} + +void TraVisTo::slotCurrentAction(QString msg) { + msg = " " + msg + " "; + //labelCurrentAction->setText(msg); + statusBar()->showMessage(msg); + // labelMode->setText(msg); +} + +void TraVisTo::slotFrameNumber(unsigned long actualFrameCount) { + QString msg; + msg.setNum(actualFrameCount); + + ui.frameSliderLabel->setText("Frame: " + msg); + + //compute the mamixum framenumber + int maxFrameCount=1; + if(extern_first_dataset_loaded){ + maxFrameCount=extern_trajectories_firstSet.getFramesNumber(); + + } + if(extern_second_dataset_loaded){ + int frameCount=extern_trajectories_secondSet.getFramesNumber(); + if(frameCount>maxFrameCount) maxFrameCount=frameCount; + + } + if(extern_third_dataset_loaded){ + int frameCount=extern_trajectories_thirdSet.getFramesNumber(); + if(frameCount>maxFrameCount) maxFrameCount=frameCount; + } + if(!frameSliderHold)if(maxFrameCount!=0)//TODO WTF, otherwise an arrymtic exeption arises + ui.framesIndicatorSlider->setValue((ui.framesIndicatorSlider->maximum()*actualFrameCount)/maxFrameCount); +} + +void TraVisTo::slotRunningTime(unsigned long timems) { + // QString msg; + // msg.setNum(timems); + // msg.append(" milsec"); + //labelRunningTime->setText(msg); + ui.lcdRunningTime->display((int)timems); +} + +void TraVisTo::slotRenderingTime(int fps) +{ + QString msg =labelFrameNumber->text().replace(QRegExp("[0-9]+/"),QString::number(fps)+"/"); + labelFrameNumber->setText(msg); +} + + +void TraVisTo::slotExit() { + cleanUp(); + qApp->exit(); +} + +void TraVisTo::closeEvent(QCloseEvent* event) { + hide(); + cleanUp(); + event->accept(); +} + +/** + * performs the necessary cleaning such as: + * closing data + * stopping recording + */ +void TraVisTo::cleanUp() { + //stop the recording process + extern_recording_enable = false; + extern_shutdown_visual_thread = true; + + if(SystemSettings::getRecordPNGsequence()) + slotRecordPNGsequence(); + + waitForVisioThread(); + waitForDataThread(); + +} + + + +void TraVisTo::slotControlSequence(const char * sex) { + + QString str(sex); + + //todo: check wich stack is empty and disable + // the correspinding datasets. + // are all stacks empty? then stop + // visualisation adn recording if any + if (str.compare("CONTROL_STACK_EMPTY") == 0) { + + statusBar()->showMessage(tr(" stack empty ")); + extern_recording_enable = false; + ui.BtRecord->setToolTip("Start Recording"); + labelRecording->setText(" rec: off "); + + //Debug::Messages("stack empty" << endl; + // Debug::Messages("stoping the playback and recording if any" << endl; + // //extern_recording_enable = false; + // extern_shutdown_visual_thread=true; + // waitForVisioThread(); + // + // //isPlaying = true; //very important + // //isPaused = true; + // //extern_is_pause = true; + // + // + // extern_screen_contrast=1; + // extern_is_pause = false; + // isPlaying=false; + // isPaused=false; + + //pause the system + // QIcon icon1; + // icon1.addPixmap(QPixmap(QString::fromUtf8( + // ":/new/iconsS/icons/Play1Hot.png")), QIcon::Normal, QIcon::Off); + // ui.BtStart->setIcon(icon1); + // labelCurrentAction->setText("paused"); + // extern_is_pause = true; + // isPlaying = true; //very important, cuz the visio was running + // isPaused = true; + // extern_update_step=1; + + + } else if (str.compare("CONTROL_RESET") == 0) { + Debug::Messages("resetting all"); + isPlaying = false; + isPaused = false; + labelCurrentAction->setText(" Idle "); + extern_update_step=1; + //extern_screen_contrast=1; + + //reset the frames cursor + extern_trajectories_firstSet.resetFrameCursor(); + extern_trajectories_secondSet.resetFrameCursor(); + extern_trajectories_thirdSet.resetFrameCursor(); + + resetGraphicalElements(); + + } else if (str.compare("STACK_REACHS_BEGINNING")==0){ + //return to normal speed + if(extern_update_step<0){ + Debug::Messages("stack reaches beginning, resuming the playback with vel 1"); + extern_update_step=1; + ui.speedSettingSlider->setValue(1); + } + + } +} + + +void TraVisTo::resetGraphicalElements(){ + + //restore play button + QIcon icon1; + icon1.addPixmap(QPixmap( + QString::fromUtf8(":/new/iconsS/icons/Play1Hot.png")), + QIcon::Normal, QIcon::Off); + ui.BtStart->setIcon(icon1); + + //disable record button + ui.BtRecord->setEnabled(false); + + //disable fullscreen + ui.BtFullscreen->setEnabled(false); + + //disable stop button + + ui.BtStop->setEnabled(false); + //reset the slider + ui.framesIndicatorSlider->setValue(ui.framesIndicatorSlider->minimum()); + + //reset the speed cursor + ui.speedSettingSlider->setValue(1); + //reset the contrast + + // bla bla + ui.actionShow_Legend->setEnabled(true); + + //restore the play Icon + + // + ui.actionShow_Trajectories->setEnabled(true); + + ui.action3_D->setEnabled(true); + ui.action2_D->setEnabled(true); + + labelRecording->setText("rec: OFF"); + statusBar()->showMessage(tr("select a File")); + + //resetting the start/stop recording action + //check whether the a png recording sequence was playing, stop if the case + if(SystemSettings::getRecordPNGsequence()) + slotRecordPNGsequence(); + +} + + +void TraVisTo::slotToggleFirstPedestrianGroup(){ + if(ui.actionFirst_Group->isChecked()){ + extern_first_dataset_visible=true; + }else{ + extern_first_dataset_visible=false; + } + extern_force_system_update=true; + +} + +/// enable/disable the second pedestrian group +void TraVisTo::slotToggleSecondPedestrianGroup(){ + if(ui.actionSecond_Group->isChecked()){ + extern_second_dataset_visible=true; + }else{ + extern_second_dataset_visible=false; + } + extern_force_system_update=true; +} + +/// enable/disable the third pedestrian group +void TraVisTo::slotToggleThirdPedestrianGroup(){ + if(ui.actionThird_Group->isChecked()){ + extern_third_dataset_visible=true; + }else{ + extern_third_dataset_visible=false; + } + extern_force_system_update=true; +} + +bool TraVisTo::anyDatasetLoaded(){ + return + (extern_first_dataset_loaded|| + extern_second_dataset_loaded|| + extern_third_dataset_loaded); +} + +void TraVisTo::slotShowTrajectoryOnly(){ + if(ui.actionShow_Trajectories->isChecked()){ + //visualisationThread->setTrailVisibility(true); + extern_tracking_enable=true; + //ui.actionShow_Trajectories->setEnabled(false); + }else{ + extern_tracking_enable=false; + //visualisationThread->setTrailVisibility(false); + } +} + + +/// TODO: implement me +void TraVisTo::slotShowPedestrianOnly(){ + Debug::Error("Not implemented"); +} + +void TraVisTo::slotShowGeometry(){ + + if (ui.actionShow_Geometry->isChecked()){ + visualisationThread->setGeometryVisibility(true); + ui.actionShow_Exits->setEnabled(true); + ui.actionShow_Walls->setEnabled(true); + } + else{ + visualisationThread->setGeometryVisibility(false); + ui.actionShow_Exits->setEnabled(false); + ui.actionShow_Walls->setEnabled(false); + } + +} + +/// shows/hide geometry +void TraVisTo::slotShowHideExits(){ + if (ui.actionShow_Exits->isChecked()){ + visualisationThread->showDoors(true); + } + else{ + visualisationThread->showDoors(false); + } +} + +/// shows/hide geometry +void TraVisTo::slotShowHideWalls(){ + if (ui.actionShow_Walls->isChecked()){ + visualisationThread->showWalls(true); + } + else{ + visualisationThread->showWalls(false); + } +} + + +/// update the playing speed +void TraVisTo::slotUpdateSpeedSlider(int newValue){ + + QString msg; + msg.setNum(newValue); + + extern_update_step=newValue; + //Debug::Error( " speed updated to: %d", extern_update_step); + ui.speedSliderLabel->setText("Speed: " + msg + " "); + +} + +/// update the position slider +void TraVisTo::slotUpdateFrameSlider(int newValue){ + + // first get the correct position + int maxFrameCount=1; + if(extern_first_dataset_loaded){ + int t=extern_trajectories_firstSet.getFramesNumber(); + if(maxFrameCount<t) maxFrameCount=t; + } + if(extern_second_dataset_loaded){ + int t=extern_trajectories_secondSet.getFramesNumber(); + if(maxFrameCount<t) maxFrameCount=t; + + } + if(extern_third_dataset_loaded){ + int t=extern_trajectories_thirdSet.getFramesNumber(); + if(maxFrameCount<t) maxFrameCount=t; + } + + int update = ((maxFrameCount*newValue)/ui.framesIndicatorSlider->maximum()); + + // then set the correct position + if(extern_first_dataset_loaded){ + extern_trajectories_firstSet.setFrameCursorTo(update); + //Debug::Error( " first dataset frames update to [1] : " <<update<<endl; + + } + if(extern_second_dataset_loaded){ + extern_trajectories_secondSet.setFrameCursorTo(update); + //Debug::Error( " second dataset frames update to[2] : " <<update<<endl; + + } + if(extern_third_dataset_loaded){ + extern_trajectories_thirdSet.setFrameCursorTo(update); + //Debug::Error( " third dataset frames update to [3] : " <<update<<endl; + } + + +} + +/// update the contrast +/// TODO: now known as framePerScond slider +void TraVisTo::slotUpdateContrastSlider(int newValue){ + + // extern_screen_contrast=ui.contrastSettingSlider->value(); + //extern_screen_contrast=newValue; + QString msg; + msg.setNum(newValue); + ui.framePerSecondSliderLabel->setText("Frames Per Second: " +msg +" "); + Debug::Error( " contrast updated to: %d",newValue); + +} + + +///clear the corresponding dataset; +void TraVisTo::clearDataSet(int ID){ + + switch(ID){ + case 1: + //extern_trajectories_firstSet.clear(); + extern_trajectories_firstSet.clearFrames(); + extern_trajectories_firstSet.resetFrameCursor(); + extern_first_dataset_loaded=false; + extern_first_dataset_visible=false; + ui.actionFirst_Group->setEnabled(false); + ui.actionFirst_Group->setChecked(false); + slotToggleFirstPedestrianGroup(); + numberOfDatasetLoaded--; + break; + + case 2: + extern_trajectories_secondSet.clearFrames(); + //extern_trajectories_secondSet.clear(); + extern_trajectories_secondSet.resetFrameCursor(); + extern_second_dataset_visible=false; + extern_second_dataset_loaded=false; + ui.actionSecond_Group->setEnabled(false); + ui.actionSecond_Group->setChecked(false); + slotToggleSecondPedestrianGroup(); + numberOfDatasetLoaded--; + break; + + case 3: + extern_trajectories_thirdSet.clearFrames(); + //extern_trajectories_thirdSet.clear(); + extern_trajectories_thirdSet.resetFrameCursor(); + extern_third_dataset_loaded=false; + extern_third_dataset_visible=false; + ui.actionThird_Group->setEnabled(false); + ui.actionThird_Group->setChecked(false); + slotToggleThirdPedestrianGroup(); + numberOfDatasetLoaded--; + break; + + default: + break; + } + + if(numberOfDatasetLoaded<0)numberOfDatasetLoaded=0; + + //finally clear the geometry + slotClearGeometry(); +} + +void TraVisTo::resetAllFrameCursor(){ + extern_trajectories_thirdSet.resetFrameCursor(); + extern_trajectories_secondSet.resetFrameCursor(); + extern_trajectories_firstSet.resetFrameCursor(); +} + +/// wait for visualisation thread to shutdown +///@todo why two different threads shutdown procedure. +void TraVisTo::waitForVisioThread(){ + while(visualisationThread->isRunning()){ + visualisationThread->wait(200); + Debug::Messages("waiting for visualisation engine to terminate ..."); +#ifdef __linux__ + visualisationThread->quit(); +#else + visualisationThread->terminate(); +#endif + } + Debug::Messages("Visualisation Engine shutdown successfully"); + + //to avoid some sudden shutting down after resuming + extern_shutdown_visual_thread=false; +} + +/// wait for datatransfer thread to be ready +void TraVisTo::waitForDataThread(){ + + while(dataTransferThread->isRunning()){ + dataTransferThread->shutdown(); + Debug::Messages("Waiting for network engine to terminate ..."); + dataTransferThread->wait(500); + } + Debug::Messages("Network Engine shutdown successfully."); +} + + +/// set visualisation mode to 2D +void TraVisTo::slotToogle2D(){ + if(ui.action2_D->isChecked()){ + extern_is_3D=false; + ui.action3_D->setChecked(false); + SystemSettings::set2D(true); + + }else{ + extern_is_3D=true; + ui.action3_D->setChecked(true); + SystemSettings::set2D(false); + } + visualisationThread->setGeometryVisibility2D(SystemSettings::get2D()); + extern_force_system_update=true; +} + +/// set visualisation mode to 3D +void TraVisTo::slotToogle3D(){ + if(ui.action3_D->isChecked()){ + extern_is_3D=true; + ui.action2_D->setChecked(false); + SystemSettings::set2D(false); + + } else { + extern_is_3D=false; + ui.action2_D->setChecked(true); + SystemSettings::set2D(true); + } + visualisationThread->setGeometryVisibility3D(!SystemSettings::get2D()); + extern_force_system_update=true; +} + +void TraVisTo::slotFrameSliderPressed(){ + frameSliderHold=true; +} + +void TraVisTo::slotFrameSliderReleased(){ + frameSliderHold=false; +} + +void TraVisTo::slotToogleShowLegend(){ + if(ui.actionShow_Legend->isChecked()){ + SystemSettings::setShowLegend(true); + }else{ + SystemSettings::setShowLegend(false); + } +} +/*** + * + * @param geodata the geometry data received from the data transfer thread + */ +void TraVisTo::slotStartVisualisationThread(QString data,int numberOfAgents,float frameRate){ + + extern_trajectories_firstSet.setNumberOfAgents(numberOfAgents); + + labelFrameNumber->setText("fps: "+QString::number(frameRate)+"/"+QString::number(frameRate)); + + extern_first_dataset_loaded=true; + extern_first_dataset_visible=true; + ui.actionFirst_Group->setEnabled(true); + ui.actionFirst_Group->setChecked(true); + slotToggleFirstPedestrianGroup(); + + QDomDocument doc(""); + data = "<travisto>\n" +data+ "\n</travisto>\n"; + + QString errorMsg=""; + doc.setContent(data,&errorMsg); + + if(!errorMsg.isEmpty()){ + Debug::Error("%s", (const char *)errorMsg.toStdString().c_str()); + return; + } + + QDomNode geoNode =doc.elementsByTagName("geometry").item(0); + FacilityGeometry *geo = parseGeometry(geoNode); + + visualisationThread->slotSetFrameRate(frameRate); + visualisationThread->setGeometry(geo); + visualisationThread->start(); +} + +/// this method is called by the data transfer thread +/// investigate if you should shutdown the thread +void TraVisTo::slotShutdownVisualisationThread( bool clearAndStop){ + //FIXME: it could have some side effects. + //you should close this threads + if(clearAndStop){ + extern_shutdown_visual_thread=true; + waitForVisioThread(); + } + clearDataSet(1); +} + +void TraVisTo::slotFramesByFramesNavigation(){ + if(ui.actionFrames_Navigation->isChecked()){ + ui.BtNextFrame->setVisible(true); + ui.BtPreviousFrame->setVisible(true); + } + else{ + ui.BtNextFrame->setVisible(false); + ui.BtPreviousFrame->setVisible(false); + } +} + +void TraVisTo::slotNextFrame(){ + + if(extern_first_dataset_loaded){ + int newValue=extern_trajectories_firstSet.getFrameCursor()+1; + extern_trajectories_firstSet.setFrameCursorTo(newValue); + //Debug::Error( " update to : " <<newValue<<endl; + } + if(extern_second_dataset_loaded){ + int newValue=extern_trajectories_secondSet.getFrameCursor()+1; + extern_trajectories_secondSet.setFrameCursorTo(newValue); + //Debug::Error( " update to : " <<newValue<<endl; + } + if(extern_third_dataset_loaded){ + int newValue=extern_trajectories_thirdSet.getFrameCursor()+1; + extern_trajectories_thirdSet.setFrameCursorTo(newValue); + //Debug::Error( " update to : " <<newValue<<endl; + + } +} + +void TraVisTo::slotPreviousFrame(){ + if(extern_first_dataset_loaded){ + int newValue=extern_trajectories_firstSet.getFrameCursor()-1; + extern_trajectories_firstSet.setFrameCursorTo(newValue); + //Debug::Error( " update to : " <<newValue<<endl; + } + if(extern_second_dataset_loaded){ + int newValue=extern_trajectories_secondSet.getFrameCursor()-1; + extern_trajectories_secondSet.setFrameCursorTo(newValue); + //Debug::Error( " update to : " <<newValue<<endl; + } + if(extern_third_dataset_loaded){ + int newValue=extern_trajectories_thirdSet.getFrameCursor()-1; + extern_trajectories_thirdSet.setFrameCursorTo(newValue); + //Debug::Error( " update to : " <<newValue<<endl; + + } +} + +void TraVisTo::slotShowPedestrianCaption(){ + + SystemSettings::setShowCaptions(ui.actionShow_Captions->isChecked()); + extern_force_system_update=true; +} + + +void TraVisTo::slotToogleShowAxis(){ + + visualisationThread->setAxisVisible(ui.actionShow_Axis->isChecked()); +} + + +//todo: rename this to slotChangeSettting +void TraVisTo::slotChangePedestrianShape(){ + + // Qt::WindowFlags flags = Qt::Window | Qt::WindowCloseButtonHint; + // + // Settings* travistoOptions = new Settings(this); + // travistoOptions->setWindowFlags(flags); + + travistoOptions->show(); + + //shape->deleteLater(); + +} + +void TraVisTo::slotCaptionColorAuto(){ + emit signal_controlSequence("CAPTION_AUTO"); +} + +void TraVisTo::slotCaptionColorCustom(){ + emit signal_controlSequence("CAPTION_CUSTOM"); +} + +void TraVisTo::slotChangeBackgroundColor(){ + + QColorDialog* colorDialog = new QColorDialog(this); + colorDialog->setToolTip("Choose a new color for the background"); + QColor col=colorDialog->getColor(Qt::white,this,"Select new background color"); + + //the user may have cancelled the process + if(col.isValid()==false) return; + + double bkcolor[3]={(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + visualisationThread->setBackgroundColor(bkcolor); + + delete colorDialog; + +} +/// change the wall color +void TraVisTo::slotChangeWallsColor(){ + + QColorDialog* colorDialog = new QColorDialog(this); + colorDialog->setToolTip("Choose a new color for walls"); + QColor col=colorDialog->getColor(Qt::white,this,"Select new wall color"); + + //the user may have cancelled the process + if(col.isValid()==false) return; + + double bkcolor[3]={(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + + visualisationThread->setWallsColor(bkcolor); + + delete colorDialog; + +} + +/// change the exits color +void TraVisTo::slotChangeExitsColor(){ + QColorDialog* colorDialog = new QColorDialog(this); + colorDialog->setToolTip("Choose a new color for walls"); + QColor col=colorDialog->getColor(Qt::white,this,"Select new wall color"); + + //the user may have cancelled the process + if(col.isValid()==false) return; + + double bkcolor[3]={(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + + visualisationThread->setExitsColor(bkcolor); + + delete colorDialog; +} + +void TraVisTo::slotSetCameraPerspectiveToTop(){ + int p= 1; //TOP + + visualisationThread->setCameraPerspective(p); + //disable the virtual agent view + SystemSettings::setVirtualAgent(-1); + //cerr <<"Setting camera view to top"<<endl; +} + +void TraVisTo::slotSetCameraPerspectiveToFront(){ + int p= 2; //FRONT + visualisationThread->setCameraPerspective(p); + //disable the virtual agent view + SystemSettings::setVirtualAgent(-1); + // cerr <<"Setting camera view to FRONT"<<endl; +} + +void TraVisTo::slotSetCameraPerspectiveToSide(){ + int p= 3; //SIDE + visualisationThread->setCameraPerspective(p); + //disable the virtual agent view + SystemSettings::setVirtualAgent(-1); + //cerr <<"Setting camera view to Side"<<endl; +} + +void TraVisTo::slotSetCameraPerspectiveToVirtualAgent(){ + + bool ok=false; + int agent = QInputDialog::getInteger(this, tr("choose the agent you want to see the scene through"), tr( + "agent ID(default to 1):"),1,1,500, 1, &ok); + + if (ok) { + int p= 4; //virtual agent + visualisationThread->setCameraPerspective(p); + + //get the virtual agent ID + SystemSettings::setVirtualAgent(agent); + } +} + +/// @todo does it work? mem check? +void TraVisTo::slotClearGeometry(){ + visualisationThread->setGeometry(NULL); +} + +void TraVisTo::slotErrorOutput(QString err) { + QMessageBox msgBox; + msgBox.setText("Error"); + msgBox.setInformativeText(err); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); +} + +void TraVisTo::slotTakeScreenShot(){ + //extern_take_screenshot=true; + extern_take_screenshot=!extern_take_screenshot; +} + +/// load settings, parsed from the project file +void TraVisTo::loadSettings(){ + + Debug::Error("Not implemented"); + +} + +/// start/stop the recording process als png images sequences +void TraVisTo::slotRecordPNGsequence(){ + if(!isPlaying){ + slotErrorOutput("Start a video first"); + } + + // get the status from the system settings and toogle it + bool status =SystemSettings::getRecordPNGsequence(); + + if(status){ + ui.actionRecord_PNG_sequences->setText("Record PNG sequence"); + }else{ + ui.actionRecord_PNG_sequences->setText("Stop PNG Recording"); + } + + // toggle the status + SystemSettings::setRecordPNGsequence(!status); + +} + +/// render a PNG image sequence to an AVI video +void TraVisTo::slotRenderPNG2AVI(){ + slotErrorOutput("Not Implemented yet, sorry !"); + +} + +void TraVisTo::dragEnterEvent(QDragEnterEvent *event){ + if (event->mimeData()->hasFormat("text/uri-list")) + event->acceptProposedAction(); +} + +void TraVisTo::dropEvent(QDropEvent *event) { + + if (!extern_offline_mode) { + slotErrorOutput("online mode, ignoring DnD !"); + return; + } + + QList<QUrl> urls = event->mimeData()->urls(); + if (urls.isEmpty()) + return; + + slotStopPlaying(); + + bool mayPlay = false; + + for (int i = 0; i < urls.size(); i++) { + QString fileName = urls[i].toLocalFile(); + if (fileName.isEmpty()) + continue; + if (addPedestrianGroup(numberOfDatasetLoaded + i + 1, fileName)) { + mayPlay = true; + } + } + + if (mayPlay) { + slotStartPlaying(); + } +} + +/// show/hide onscreen information +/// information include Time and pedestrians left in the facility +void TraVisTo::slotShowOnScreenInfos(){ + bool value=ui.actionShow_Onscreen_Infos->isChecked(); + visualisationThread->setOnscreenInformationVisibility(value); + SystemSettings::setOnScreenInfos(value); +} + +/// show/hide the geometry captions +void TraVisTo::slotShowHideGeometryCaptions(){ + + bool value=ui.actionShow_Geometry_Captions->isChecked(); + visualisationThread->setGeometryLabelsVisibility(value); + //SystemSettings::setOnScreenInfos(value); +} diff --git a/src/travisto.h b/src/travisto.h new file mode 100644 index 0000000000000000000000000000000000000000..3302d932aecc0e41eb899b787da84ac1477ffbff --- /dev/null +++ b/src/travisto.h @@ -0,0 +1,332 @@ +/** +* @headerfile travisto.h +* @author Ulrich Kemloh <kemlohulrich@gmail.com> +* @version 0.1 +* Copyright (C) <2009-2010> +* +* @section LICENSE +* This file is part of OpenPedSim. +* +* OpenPedSim is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* OpenPedSim 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>. +* +* @section DESCRIPTION +* +* \brief main program class +* +* +* +* Created on: 11.05.2009 +* +*/ + +#ifndef TRAVISTO_H +#define TRAVISTO_H + + +#include "../ui_travisto.h" +#include <QtGui/QMainWindow> + +#include <vector> + +class vtkWindowToImageFilter; +class SyncData; +class ThreadDataTransfer; +class ThreadVisualisation; +class QString; +class QDomNode; +class FacilityGeometry; +class Building; +class Message; +class Settings; + + +extern int extern_update_step; +extern int extern_screen_contrast; +extern bool extern_is_pause; +extern bool extern_launch_recording; +extern bool extern_recording_enable; +extern bool extern_offline_mode; +extern bool extern_shutdown_visual_thread; +extern bool extern_fullscreen_enable; + +extern bool extern_pedestrians_firstSet_visible; +extern bool extern_pedestrians_secondSet_visible; +extern bool extern_pedestrians_thirdSet_visible; + +extern SyncData extern_trajectories_firstSet; +extern SyncData extern_trajectories_secondSet; +extern SyncData extern_trajectories_thirdSet; + +//states if the datasets are loaded. +extern bool extern_first_dataset_loaded; +extern bool extern_second_dataset_loaded; +extern bool extern_third_dataset_loaded; + +//states whether the loaded datasets are visible +extern bool extern_first_dataset_visible; +extern bool extern_second_dataset_visible; +extern bool extern_third_dataset_visible; + + +class TraVisTo : public QMainWindow +{ + Q_OBJECT + +public: + TraVisTo(QWidget *parent = 0); + virtual ~TraVisTo(); + + +public Q_SLOTS: + + /// display the help modus + void slotHelpAbout(); + + ///quit the program + void slotExit(); + + /// load a file + bool slotLoadFile(); + //void slotLoadProject(); + + /// output an Error + void slotErrorOutput(QString err); + + /// output a warning + //void slotWarningOutput(QString warning); + + /// start the visualisation thread + /// the signal is emitted when the + /// data transfer thread the header and at least one data set + void slotStartVisualisationThread(QString data="",int numberOfAgents=1000,float frameRate=25); + + /// shutdown the visualisation thread + void slotShutdownVisualisationThread(bool); + + /// add a new dataset to the store. + /// note that at most three (3) datasets can be loaded for a visualisation round + bool slotAddDataSet(); + + /// clear all previously added/loaded datasets + void slotClearAllDataset(); + + /// set the camera view angle to TOP/FRONT/SIDE + // TODO: high priority + void slotSetCameraPerspectiveToTop(); + void slotSetCameraPerspectiveToFront(); + void slotSetCameraPerspectiveToSide(); + void slotSetCameraPerspectiveToVirtualAgent(); + + //controls visualisation + void slotStartPlaying(); + void slotStopPlaying(); + void slotRecord(); + void slotFullScreen(bool status); + void slotReset(); + void slotNetworkSettings(); + // void slotToggleVisualisationMode(); + void slotSetOfflineMode(bool status); + void slotSetOnlineMode(bool status); + /// take a screenshot of the rendering window + void slotTakeScreenShot(); + + /// update the status message + void slotCurrentAction(QString msg); + void slotFrameNumber(unsigned long timems); + void slotRunningTime(unsigned long timems); + void slotRenderingTime(int fps); + void slotControlSequence(const char *); + + /// load a geometry file and display it + //void slotLoadGeometry( ); + void slotClearGeometry(); + //void slotLoadParseShowGeometry(QString fileName); + + /// load a geometry sent by the data transfer thread + //void slotLoadGeometryToThread(QString data); + + + /// enable/disable the first pedestrian group + void slotToggleFirstPedestrianGroup(); + /// enable/disable the second pedestrian group + void slotToggleSecondPedestrianGroup(); + /// enable/disable the third pedestrian group + void slotToggleThirdPedestrianGroup(); + + /// show/hides trajectories (leaving a trail) only + void slotShowTrajectoryOnly(); + + /// shows/hide geometry + void slotShowGeometry(); + /// shows/hide geometry + void slotShowHideExits(); + /// shows/hide geometry + void slotShowHideWalls(); + /// shows/hide geometry captions + void slotShowHideGeometryCaptions(); + + /// show pedestrians only without trail + void slotShowPedestrianOnly(); + + + /// update the playing speed + void slotUpdateSpeedSlider(int newValue); + //void slotSpeedSliderPressed(); + //void slotSpeedSliderReleased(); + //void slotSpeedSliderChanged(); + + /// update the position slider + void slotUpdateFrameSlider(int newValue); + void slotFrameSliderPressed(); + void slotFrameSliderReleased(); + //void slotFrameSliderChanged(); + + /// handle the frame by frame navigation + void slotFramesByFramesNavigation(); + void slotNextFrame(); + void slotPreviousFrame(); + + /// enable/disable the pedestrian captions + void slotShowPedestrianCaption(); + + /// set the bg color + //void slotPickBackgroundColor(); + + /// update the contrast + void slotUpdateContrastSlider(int newValue); + + /// set visualisation mode to 2D + void slotToogle2D(); + + /// set visualisation mode to 3D + void slotToogle3D(); + + /// show / hide the legend + void slotToogleShowLegend(); + + void slotToogleShowAxis(); + + /// change, choose the pedestrian shape + void slotChangePedestrianShape(); + + /// start/stop the recording process als png images sequences + void slotRecordPNGsequence(); + + /// render a PNG image sequence to an AVI video + void slotRenderPNG2AVI(); + + /// adjust the scene background color + void slotChangeBackgroundColor(); + + /// change the pedestrian caption mode to automatic + void slotCaptionColorAuto(); + + /// change he pedestrian caption color to manual + void slotCaptionColorCustom(); + + /// change the wall color + void slotChangeWallsColor(); + + /// change the exits color + void slotChangeExitsColor(); + + /// show/hide onscreen information + /// information include Time and pedestrians left in the facility + void slotShowOnScreenInfos(); + +private: + Q_SIGNALS: + void signal_controlSequence(QString); + + + +protected: + virtual void closeEvent(QCloseEvent* event); + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + +private: + + /// load settings, parsed from the project file + /// @todo not implemented + void loadSettings(); + + /// performs the necessary cleaning before shutting down the program. + void cleanUp(); + + /// reset the system to the very initial state + //void reset(); + + /// get the value of the tag <tagName> from a QDomNode + QString getTagValueFromElement(QDomNode node, const char * tagName); + + /// parse the geometry Node and return a pointer to geometry object + /// used in online mode only + FacilityGeometry* parseGeometry(QDomNode geoNode); + + + /** + * parse a shape node and get the initials heights and colors of pedestrians. + * + * @param shapeNode The node to be parsed + * @param groupID 1, 2 or 3 + * @return true if success + */ + bool parsePedestrianShapes(QDomNode shapeNode, int groupID); + + /// reset all graphic element to their initial(default) state + void resetGraphicalElements(); + + /// add a second/third dataset to the visualization data + /// groupID may be 2 or 3 + /// @return false if something went wrong. + + bool addPedestrianGroup_old(int groupID, QString fileName=""); + bool addPedestrianGroup(int groupID, QString fileName=""); + + ///return true if at least one dataset was loaded + bool anyDatasetLoaded(); + + /// clear the corresponding dataset if it exists + void clearDataSet(int ID); + + /// reset all dataset, to the beginning + void resetAllFrameCursor(); + + /// wait for visualisation thread to terminate + void waitForVisioThread(); + + /// wait for data transfer thread to terminate + void waitForDataThread(); + + + +private: + Ui::TraVisToClass ui; + + bool isPlaying; + bool isPaused; + bool frameSliderHold; + int numberOfDatasetLoaded; + + Settings* travistoOptions; + ThreadDataTransfer* dataTransferThread; + ThreadVisualisation* visualisationThread; + QLabel *labelCurrentAction; + QLabel *labelFrameNumber; + QLabel *labelRecording; + QLabel *labelMode; +}; + +#endif // TRAVISTO_H