diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5e7572d4a69515c0449c993aea33cecdb22e8d44 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +backup* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6bc30a6546e8f40714e0a8d72314a5cf44b36852..e2a2ee747ff891e091622bf2ac7bc0a5b0112189 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,7 @@ configure-linux: script: - mkdir -p build - cd build - - cmake -DCMAKE_BUILD_TYPE=Debug .. + - cmake -DCMAKE_BUILD_TYPE=Debug -DDESIRED_QT_VERSION=4 .. - echo "configure | ${CI_PROJECT_DIR}" stage: configure tags: diff --git a/CHANGELOG.md b/CHANGELOG.md index 167a2a2d7189a0e3739f906d63d8c55514c40b72..b815b3d666f70dd964086ed06b475a8adc11f0e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,23 @@ # Change Log All notable changes to this project will be documented in this file. +## v0.8.5 [02.11.2018] +## Added +- Add Auto Saving function #67 + +- Better Panning Mode #100 + +## Changed +- Update Shortcuts #92 + +- Design new origin and axis #99 + +## Bugs fixed +- Esc doesn't work while drawing #98 + +- SegFault: Delete all Rooms #91 + + ## v0.8.4 [05.10.2018] ## Added - In menu bar, under "Edit" you will find "Clear Rooms and Doors button" to clear all defined rooms and doors. #54 diff --git a/CMakeLists.txt b/CMakeLists.txt index 47f4a1e13428941bf35f43e9662a89dc9c48d6e9..b9604e05d9fcc52d68328b5a65e9e7cdc4ba533e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,27 +9,29 @@ # 2. DESIRED_QT_VERSION=5 (default 4) # example: >> cmake -DDESIRED_QT_VERSION=5 -DCMAKE_PREFIX_PATH=~/Qt/5.5/clang_64 .. # Flags for VS: -G "Visual Studio ..." -DCMAKE_PREFIX_PATH=... -DCMAKE_C_FLAGS="-mwindows" - -cmake_minimum_required(VERSION 2.8.9) -IF (POLICY CMP0048) # in CMake 3.0.0+ - CMAKE_POLICY (SET CMP0048 OLD) # keep PROJECT() from clearing VERSION variables -ENDIF (POLICY CMP0048) -IF (POLICY CMP0043) # in CMake 3.0.0+ - CMAKE_POLICY (SET CMP0043 OLD) # keep PROJECT() from clearing VERSION variables -ENDIF (POLICY CMP0043) -IF (POLICY CMP0020) - CMAKE_POLICY (SET CMP0020 OLD) # keep old POLICY (2.8.10 and lower) The OLD behavior for this policy is not to link executables to -ENDIF (POLICY CMP0020) #qtmain.lib automatically when they link to the QtCore IMPORTEDtarget - -IF (POLICY CMP0025) - cmake_policy(SET CMP0025 NEW) #fixes error No known features for CXX compiler (on mac) -ENDIF (POLICY CMP0025) - -project(JPSeditor) +# Qt5_DIR:PATH +cmake_minimum_required(VERSION 3.2) +# IF (POLICY CMP0048) # in CMake 3.0.0+ +# CMAKE_POLICY (SET CMP0048 OLD) # keep PROJECT() from clearing VERSION variables +# ENDIF (POLICY CMP0048) +# IF (POLICY CMP0043) # in CMake 3.0.0+ +# CMAKE_POLICY (SET CMP0043 OLD) # keep PROJECT() from clearing VERSION variables +# ENDIF (POLICY CMP0043) +# IF (POLICY CMP0020) +# CMAKE_POLICY (SET CMP0020 OLD) # keep old POLICY (2.8.10 and lower) The OLD behavior for this policy is not to link executables to +# ENDIF (POLICY CMP0020) #qtmain.lib automatically when they link to the QtCore IMPORTEDtarget + +# IF (POLICY CMP0025) +# cmake_policy(SET CMP0025 NEW) #fixes error No known features for CXX compiler (on mac) +# ENDIF (POLICY CMP0025) + +project(JPSeditor LANGUAGES CXX) +set (CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) MESSAGE( STATUS "System ........................................ ${CMAKE_SYSTEM_NAME} (${CMAKE_SYSTEM_VERSION}, ${CMAKE_SYSTEM_PROCESSOR})" ) - set(README_FILE "${CMAKE_SOURCE_DIR}/README.md") set(CMAKE_COLOR_MAKEFILE ON) set(JPSEDITOR_MAJOR_VERSION 0) @@ -43,6 +45,10 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "") endif() message( STATUS "Generating ................................... ${PROJECT_NAME} (${JPSEDITOR_VERSION}) -- ${CMAKE_BUILD_TYPE}") +if(APPLE ) + set(CMAKE_INSTALL_PREFIX "/Applications") +endif() +message(STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}") # ------------------------- Begin Generic CMake Variable Logging ------------------ @@ -74,13 +80,6 @@ message( STATUS "EXECUTABLE_OUTPUT_PATH ........................ " ${EXECUTABLE_ include_directories( ${CMAKE_BINARY_DIR} ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) - -if(APPLE AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local") - set(CMAKE_INSTALL_PREFIX "/Applications") -endif() -message(STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}") - - #-------------------- if (NOT MSVC) include(CheckCXXCompilerFlag) @@ -121,6 +120,7 @@ set( SRCS src/UndoFramework/lineaction.cpp src/AutomaticRoomIdentification/roomdefinition.cpp src/AutomaticRoomIdentification/roomidentification.cpp + src/settingdialog.cpp ) # all header files that should be treated with moc set( HDR @@ -158,6 +158,7 @@ set( HDR src/AutomaticRoomIdentification/roomdefinition.h src/AutomaticRoomIdentification/roomidentification.h src/dtrace.h + src/settingdialog.h ) @@ -167,6 +168,7 @@ set( UIS forms/roomwidget.ui forms/widgetlandmark.ui forms/widgetsettings.ui + forms/settingdialog.ui ) # and finally a resource file @@ -185,53 +187,39 @@ IF (WIN32) ENDIF (WIN32) #--------------- here comes QT. Version problem (4 or 5?) -# cmake does not provide findqt5-modules - -if("${QT_QMAKE_EXECUTABLE}" STREQUAL "") - FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake) - if ("${QT_QMAKE_EXECUTABLE}" STREQUAL "") - message(FATTAL_ERROR "QT not found - abort.") - endif() -endif() -message(STATUS "QT_Qmake_executable ........................... " ${QT_QMAKE_EXECUTABLE}) -execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_VERSION OUTPUT_VARIABLE QT_VERSION) -message(STATUS "QT_VERSION .................................... " ${QT_VERSION}) -# qt version > 5 or qt version < 3 are not supported -if( ${QT_VERSION} VERSION_GREATER 6 OR ${QT_VERSION} VERSION_LESS 3) - message(FATAL_ERROR "QT version " ${DESIRED_QT_VERSION} " not supported. Try 4 or 5") -endif() - - if("${DESIRED_QT_VERSION}" STREQUAL "") - if( ${QT_VERSION} VERSION_GREATER 4.99 AND ${QT_VERSION} VERSION_LESS 6) set(DESIRED_QT_VERSION 5) - endif() - - if( ${QT_VERSION} VERSION_GREATER 3.99 AND ${QT_VERSION} VERSION_LESS 5) +else() set(DESIRED_QT_VERSION 4) - endif() endif() +message(STATUS "Searching for Qt version ...................... " ${DESIRED_QT_VERSION}) # find packages according to qt version if("${DESIRED_QT_VERSION}" STREQUAL "5") find_package(Qt5Widgets REQUIRED) -# - these find_packages are not necessary? ----------- + # - these find_packages are not necessary? ----------- FIND_PACKAGE(Qt5Core REQUIRED) FIND_PACKAGE(Qt5Gui REQUIRED) FIND_PACKAGE(Qt5Network REQUIRED) FIND_PACKAGE(Qt5Xml REQUIRED) -#----------------------------------------------------- + #----------------------------------------------------- set(QT5_INSTALLED TRUE) - # MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}") -elseif("${DESIRED_QT_VERSION}" STREQUAL "4") + set(QTVERSION 5) + MESSAGE(STATUS "Found Qt version .............................. ${Qt5Core_VERSION_STRING}") - # QT4_INSTALLED is set to TRUE if qt4 is found and - # QT3_INSTALLED is set to TRUE if qt3 is found. - FIND_PACKAGE(Qt COMPONENTS QtXml QT_USE_QTNETWORK QtXmlPatterns REQUIRED) +elseif("${DESIRED_QT_VERSION}" STREQUAL "4") + find_package(Qt COMPONENTS QtXml QT_USE_QTNETWORK QtXmlPatterns REQUIRED) set(QT4_INSTALLED TRUE) + set(QTVERSION 4) endif() -message(STATUS "DESIRED_QT_VERSION ............................ " ${DESIRED_QT_VERSION}) +execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_VERSION OUTPUT_VARIABLE QT_VERSION) +# qt version > 5 or qt version < 3 are not supported +if( ${QTVERSION} VERSION_GREATER 6 OR ${QTVERSION} VERSION_LESS 3) + message(FATAL_ERROR "QT version " ${QTVERSION} " not supported. Try 4 or 5") +endif() + + # if(QT5_INSTALLED) # message(STATUS "QT5_INSTALLED: " ${QT5_INSTALLED}) # elseif(QT4_INSTALLED ) @@ -246,7 +234,7 @@ message(STATUS "DESIRED_QT_VERSION ............................ " ${DESIRED_QT_V if(APPLE) ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII) # include the icns file in the target - SET(SRCS ${SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/icons/jupedsim.icns) + SET(SRCS ${SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/Resources/jpseditor.icns) endif() # this command will generate rules that will run rcc on all files from RCS @@ -259,13 +247,13 @@ if(${QT4_INSTALLED}) QT4_WRAP_UI( UI_HDRS ${UIS} ) QT4_ADD_RESOURCES( RCS ${RCS} ) include( ${QT_USE_FILE} ) - ADD_EXECUTABLE( jpseditor MACOSX_BUNDLE WIN32 + ADD_EXECUTABLE( ${PROJECT_NAME} MACOSX_BUNDLE WIN32 ${SRCS} ${MOC_HDRS} ${UI_HDRS} ${RCS} ) - TARGET_LINK_LIBRARIES( jpseditor ${QT_LIBRARIES}) + TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${QT_LIBRARIES}) elseif( ${QT5_INSTALLED}) message(STATUS "Working with Qt5") # http://www.kdab.com/using-cmake-with-qt-5/ @@ -275,16 +263,16 @@ elseif( ${QT5_INSTALLED}) qt5_add_resources( RCS ${RCS} ) #qt5_use_package(JPSeditor Widgets) - ADD_EXECUTABLE( jpseditor MACOSX_BUNDLE WIN32 + ADD_EXECUTABLE( ${PROJECT_NAME} MACOSX_BUNDLE WIN32 ${SRCS} ${MOC_HDRS} ${UI_HDRS} ${RCS} ) - qt5_use_modules(jpseditor Widgets) - target_link_libraries(jpseditor ${Qt5Widgets_LIBRARIES}) + qt5_use_modules(${PROJECT_NAME} Widgets) + target_link_libraries(${PROJECT_NAME} ${Qt5Widgets_LIBRARIES}) else() - message(FATAL_ERROR "QT NOT BE FOUND - ABORT") + message(FATAL_ERROR "QT NOT FOUND - ABORT") endif() IF(APPLE) @@ -293,7 +281,7 @@ IF(APPLE) ENDIF(APPLE) -SET_TARGET_PROPERTIES( jpseditor PROPERTIES MACOSX_BUNDLE TRUE) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE) #---------------------------------------------------------------------- # enable as many warnings as possible set(warning_flags "-Wall -Wextra") @@ -333,52 +321,35 @@ endif() #-------------------------------------------------------------------------------- # Now the installation stuff below #-------------------------------------------------------------------------------- -SET(plugin_dest_dir bin) -SET(qtconf_dest_dir bin) -SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/jpseditor") -IF(APPLE) - SET(plugin_dest_dir jpseditor.app/Contents/MacOS) - SET(qtconf_dest_dir jpseditor.app/Contents/Resources) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/jpseditor.app") -ENDIF(APPLE) - -IF(WIN32) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/jpseditor.exe") -ENDIF(WIN32) - -INSTALL(TARGETS jpseditor - BUNDLE DESTINATION . COMPONENT Runtime +INSTALL(TARGETS ${PROJECT_NAME} + BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime RUNTIME DESTINATION bin COMPONENT Runtime # PERMISSIONS OWNER_EXECUTE 600 ) +set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_INSTALL_DIR}") +include(InstallRequiredSystemLibraries) -#-------------------------------------------------------------------------------- -# Install needed Qt plugins by copying directories from the qt installation -# One can cull what gets copied by using 'REGEX "..." EXCLUDE' -# todo should we check qt version here? if(APPLE) -INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${plugin_dest_dir}/plugins - # DIRECTORY_PERMISSIONS - # OWNER_WRITE OWNER_READ OWNER_EXECUTE - # GROUP_WRITE GROUP_READ GROUP_EXECUTE - # WORLD_WRITE WORLD_READ WORLD_EXECUTE - COMPONENT Runtime) -endif() -#-------------------------------------------------------------------------------- -# install a qt.conf file -# this inserts some cmake code into the install script to write the file -if(APPLE) -INSTALL(CODE " - file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\") - " COMPONENT Runtime) + set(EXECUTABLE "${PROJECT_NAME}.app") +elseif(WIN32) + set(EXECUTABLE "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") +else() + set(EXECUTABLE "${BIN_INSTALL_DIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") endif() -#-------------------------------------------------------------------------------- -# Use BundleUtilities to get all other dependencies for the application to work. -# It takes a bundle or executable along with possible plugins and inspects it -# for dependencies. If they are not system dependencies, they are copied. -# directories to look for dependencies +SET(plugin_dest_dir bin) +SET(qtconf_dest_dir bin) +SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}") +IF(APPLE) + SET(plugin_dest_dir ${PROJECT_NAME}.app/Contents/MacOS) + SET(qtconf_dest_dir ${PROJECT_NAME}/Contents/Resources) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}") +ENDIF(APPLE) + +IF(WIN32) + SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}.exe") +ENDIF(WIN32) if( ${QT5_INSTALLED}) SET(DIRS ${QT_LIBRARIES}) @@ -386,37 +357,20 @@ elseif( ${QT5_INSTALLED}) SET(DIRS ${QT_LIBRARY_DIRS}) endif() -# Now the work of copying dependencies into the bundle/package -# The quotes are escaped and variables to use at install time have their $ escaped -# An alternative is the do a configure_file() on a script and use install(SCRIPT ...). -# Note that the image plugins depend on QtSvg and QtXml, and it got those copied -# over. -# -if(APPLE) -INSTALL(CODE " - file(GLOB_RECURSE QTPLUGINS - \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") - image - fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") - " COMPONENT Runtime) -endif() - - #================================================ APPLE Stuff ====================== IF(APPLE) # set how it shows up in the Info.plist file SET(MACOSX_EDIT_ICON jupedsim.icns) - set_target_properties(jpseditor PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist.in) - SET(MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2015 Forschungszentrum Juelich. All rights reserved.") - SET(MACOSX_BUNDLE_BUNDLE_NAME "jpseditor") + SET(MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2015-2018 Forschungszentrum Juelich. All rights reserved.") + SET(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}") SET(MACOSX_BUNDLE_BUNDLE_VERSION "${JPSEDITOR_VERSION}") SET(MACOSX_BUNDLE_LONG_VERSION_STRING "version ${JPSEDITOR_VERSION}") SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${JPSEDITOR_VERSION}") - SET(MACOSX_EDIT_COPYRIGHT "Copyright (c) 2015 Forschungszentrum Juelich. All rights reserved.") - SET(MACOSX_BUNDLE_EDIT_IDENTIFIER "www.jupedsim.org") + SET(MACOSX_BUNDLE_EDIT_IDENTIFIER "https://www.jupedsim.org") # set where in the bundle to put the icns file + # set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist.in) ENDIF(APPLE) @@ -426,82 +380,54 @@ ENDIF(APPLE) # https://github.com/mikemcquaid/Fabula set(CPACK_BINARY_DRAGNDROP ON) set(CPACK_GENERATOR "TBZ2") -set(CPACK_PACKAGE_VERSION_MAJOR "${JPSEDITOR_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${JPSEDITOR_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${JPSEDITOR_version_patch}") +set(CPACK_PACKAGE_VERSION_MAJOR "${JPSEDITOR_MAJOR_VERSION}") +set(CPACK_PACKAGE_VERSION_MINOR "${JPSEDITOR_MINOR_VERSION}") +set(CPACK_PACKAGE_VERSION_PATCH "${JPSEDITOR_PATCH_VERSION}") set(CPACK_PACKAGE_VERSION "${JPSEDITOR_VERSION}") set(CPACK_PACKAGE_VENDOR "${JPSEDITOR_VENDOR}") set(CPACK_RESOURCE_FILE_README "${README_FILE}") if(WIN32) # todo test this for windows - set(CPACK_GENERATOR "NSIS") - set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}") - set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME} ${JPSEDITOR_VERSION}") - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/${LICENSE_FILE}") - set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${BIN_INSTALL_DIR}") - #set(CPACK_NSIS_MUI_ICON "${PROJECT_ICONS_DIRECTORY}/NSIS.ico") - #set(CPACK_PACKAGE_ICON "${PROJECT_ICONS_DIRECTORY}\\\\NSISHeader.bmp") - set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") -# set(CPACK_NSIS_MENU_LINKS "${LICENSE_FILE}" "License" "${README_FILE}" "Readme") - # set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CPACK_NSIS_INSTALLED_ICON_NAME}") + set(CPACK_GENERATOR "NSIS") + set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}") + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME} ${JPSEDITOR_VERSION}") + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/${LICENSE_FILE}") + set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${BIN_INSTALL_DIR}") + #set(CPACK_NSIS_MUI_ICON "${PROJECT_ICONS_DIRECTORY}/NSIS.ico") + #set(CPACK_PACKAGE_ICON "${PROJECT_ICONS_DIRECTORY}\\\\NSISHeader.bmp") + set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + # set(CPACK_NSIS_MENU_LINKS "${LICENSE_FILE}" "License" "${README_FILE}" "Readme") + # set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CPACK_NSIS_INSTALLED_ICON_NAME}") elseif(APPLE) # todo test this for apple - set(CMAKE_INSTALL_PREFIX "/Applications/") - set(CPACK_GENERATOR "DragNDrop") - set(CPACK_DMG_FORMAT "UDBZ") - set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") - set(CPACK_SYSTEM_NAME "OSX") - set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${JPSEDITOR_VERSION}") - #set(CPACK_PACKAGE_ICON "${ICONS_DIR}/DMG.icns") - #set(CPACK_DMG_DS_STORE "${ICONS_DIR}/DMGDSStore") - #set(CPACK_DMG_BACKGROUND_IMAGE "${ICONS_DIR}/DMGBackground.png") - elseif(UNIX) - # tested with success in - # Linux dhcppc5 3.2.0-4-686-pae #1 SMP Debian 3.2.68-1+deb7u2 i686 GNU/Linux - set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") - SET(CPACK_GENERATOR "DEB") - - SET(CPACK_PACKAGE_DESCRIPTION "simulation core of JuPedSim") - SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Geometry editor of JuPedSim, a framework for simulation and analysis of pedestrian dynamics") - #SET(CPACK_PACKAGE_VENDOR "nowardev") - SET(CPACK_PACKAGE_CONTACT "m.chraibi@fz-juelich.de") - SET(CPACK_PACKAGE_VERSION_MAJOR "${JPSEDITOR_MAJOR_VERSION}") - SET(CPACK_PACKAGE_VERSION_MINOR "${JPSEDITOR_MINOR_VERSION}") - SET(CPACK_PACKAGE_VERSION_PATCH "${JPSEDITOR_PATCH_VERSION}") - SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${JPSEDITOR_VERSION}") - SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${JPSEDITOR_VERSION}") - #SET(CPACK_DEBIAN_PACKAGE_DEPENDS " Boost (>= 1.59) ") - SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) - SET( CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://jupedsim.org") - SET(CPACK_DEBIAN_PACKAGE_SUGGESTS, "jpsvis, jpsreport, jpscor") - SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") - SET(CPACK_DEBIAN_PACKAGE_SECTION "science") - SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) - - - - endif() - include(CPack) - - -# message (STATUS "bin ins" ${BIN_INSTALL_DIR}) -set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_INSTALL_DIR}") -include(InstallRequiredSystemLibraries) - -if(APPLE) - set(EXECUTABLE "${PROJECT_NAME}.app") -elseif(WIN32) - set(EXECUTABLE "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") -else() - set(EXECUTABLE "${BIN_INSTALL_DIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(CPACK_GENERATOR "DragNDrop") + set(CPACK_DMG_FORMAT "UDBZ") + set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") + set(CPACK_SYSTEM_NAME "OSX") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${JPSEDITOR_VERSION}") + #set(CPACK_PACKAGE_ICON "${ICONS_DIR}/DMG.icns") + #set(CPACK_DMG_DS_STORE "${ICONS_DIR}/DMGDSStore") + #set(CPACK_DMG_BACKGROUND_IMAGE "${ICONS_DIR}/DMGBackground.png") +elseif(UNIX) + # tested with success in + # Linux dhcppc5 3.2.0-4-686-pae #1 SMP Debian 3.2.68-1+deb7u2 i686 GNU/Linux + set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + SET(CPACK_GENERATOR "DEB") + + SET(CPACK_PACKAGE_DESCRIPTION "simulation core of JuPedSim") + SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Geometry editor of JuPedSim, a framework for simulation and analysis of pedestrian dynamics") + #SET(CPACK_PACKAGE_VENDOR "nowardev") + SET(CPACK_PACKAGE_CONTACT "m.chraibi@fz-juelich.de") + SET(CPACK_PACKAGE_VERSION_MAJOR "${JPSEDITOR_MAJOR_VERSION}") + SET(CPACK_PACKAGE_VERSION_MINOR "${JPSEDITOR_MINOR_VERSION}") + SET(CPACK_PACKAGE_VERSION_PATCH "${JPSEDITOR_PATCH_VERSION}") + SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${JPSEDITOR_VERSION}") + SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${JPSEDITOR_VERSION}") + #SET(CPACK_DEBIAN_PACKAGE_DEPENDS " Boost (>= 1.59) ") + SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + SET( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://jupedsim.org") + SET(CPACK_DEBIAN_PACKAGE_SUGGESTS, "jpsvis, jpsreport, jpscore") + SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + SET(CPACK_DEBIAN_PACKAGE_SECTION "science") + SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) endif() - -# if(APPLE OR WIN32) -# if(${QT4_INSTALLED}) -# include(DeployQt4) -# install_qt4_executable("${EXECUTABLE}" "qsqlite") - -# elseif(${QT5_INSTALLED}) -# include(DeployQt5) -# install_qt5_executable("${EXECUTABLE}" "qsqlite") -# endif() -# endif() +include(CPack) diff --git a/Resources/Icons/moved_hand.svg b/Resources/Icons/moved_hand.svg new file mode 100644 index 0000000000000000000000000000000000000000..3282752a04652a3605a354c63b70a09c61ce4fd1 --- /dev/null +++ b/Resources/Icons/moved_hand.svg @@ -0,0 +1 @@ +<?xml version="1.0" ?><svg height="32px" version="1.1" viewBox="0 0 32 32" width="32px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#000000" id="icon-44-one-finger-swipe"><path d="M20.9719734,14 L27.049999,14 L23.799999,10.75 L24.549999,10 L29.049999,14.5 L24.549999,19 L23.799999,18.25 L27.049999,15 L27.049999,15 L21,15 L21,31 L12,31 L12,15 L5.950001,15 L5.950001,15 L9.200001,18.25 L8.450001,19 L3.950001,14.5 L8.450001,10 L9.200001,10.75 L5.950001,14 L12.0278925,14 C12.2600811,11.9115065 13.9154776,10.2577821 16,10.0274511 L16,3.950001 L16,3.950001 L12.75,7.200001 L12,6.450001 L16.5,1.950001 L21,6.450001 L20.25,7.200001 L17,3.950001 L17,10.0275945 C19.0806613,10.2586377 20.7390274,11.9142645 20.9719734,14 L20.9719734,14 L20.9719734,14 Z M16.5,11 C14.5670034,11 13,12.5710144 13,14.5070349 L13,30 L20,30 L20,14.5070349 C20,12.570153 18.4290634,11 16.5,11 L16.5,11 Z M16.5,12 C15.1192881,12 14,13.1285541 14,14.5097752 L14,18 L19,18 L19,14.5097752 C19,13.1236646 17.8903379,12 16.5,12 L16.5,12 Z M16.5,13 C15.6715729,13 15,13.6785455 15,14.5008327 L15,17 L18,17 L18,14.5008327 C18,13.6719457 17.3342028,13 16.5,13 L16.5,13 Z M14,21 L14,22 L19,22 L19,21 L14,21 L14,21 Z M14,23 L14,24 L19,24 L19,23 L14,23 L14,23 Z" id="one-finger-swipe"/></g></g></svg> \ No newline at end of file diff --git a/Resources/jpseditor.icns b/Resources/jpseditor.icns new file mode 100644 index 0000000000000000000000000000000000000000..8a6a7ed7f4700ae49ac21a90df2b14b5bbbd70ef Binary files /dev/null and b/Resources/jpseditor.icns differ diff --git a/Resources/jpseditor.ico b/Resources/jpseditor.ico new file mode 100644 index 0000000000000000000000000000000000000000..056fe80b2ebf61becfb9cc12412021f2a0247f0d Binary files /dev/null and b/Resources/jpseditor.ico differ diff --git a/Resources/resources.qrc b/Resources/resources.qrc index e45c0b82276344c6b699f422fa1ee9824e7e9f60..8dee5e823a6bd9231233d4bc9bee808d340d9754 100644 --- a/Resources/resources.qrc +++ b/Resources/resources.qrc @@ -57,5 +57,6 @@ <file>Icons/rotate.png</file> <file>Icons/plus.svg</file> <file>Icons/landmark.svg</file> + <file>Icons/moved_hand.svg</file> </qresource> </RCC> diff --git a/deployAPPLE.sh b/deployAPPLE.sh index ab973650df36b8443eba08e666f4f87fb586421e..8a237e880575ae00d48d5d6ee12d13a511edc81e 100755 --- a/deployAPPLE.sh +++ b/deployAPPLE.sh @@ -4,10 +4,12 @@ RED='\033[0;31m' NC='\033[0m' # No Color #Version=0.8.4 -CMD=jpseditor +#Change Build folder before running script + +release=Repos/jpseditor/qmake-build-release #echo "INFO: running dynlibbundler .." #dylibbundler -od -b -x ../bin/${CMD}.app/Contents/MacOS/${CMD} -d ../bin/${CMD}.app/Contents/libs/ echo "INFO: running macdeployqt .." -macdeployqt ./qmake-build-release//${CMD}.app -dmg +macdeployqt ${release}/JPSeditor.app -dmg diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 119a6475ce94a69c892a7261e7a66f5509af791c..4756e9556f2fb3ede465c7f33f26798194e7fabc 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -65,6 +65,7 @@ <addaction name="actiongridmode"/> <addaction name="actionShow_Point_of_Origin"/> <addaction name="actionRotate_90_deg_clockwise"/> + <addaction name="actionPanning_Mode"/> <addaction name="separator"/> <addaction name="actionanglesnap"/> <addaction name="actionObjectsnap"/> @@ -123,6 +124,7 @@ <addaction name="separator"/> <addaction name="actiongridmode"/> <addaction name="actionObjectsnap"/> + <addaction name="actionPanning_Mode"/> <addaction name="separator"/> <addaction name="actionRoom"/> </widget> @@ -370,6 +372,9 @@ <property name="toolTip"> <string>Select Mode</string> </property> + <property name="shortcut"> + <string>Meta+S</string> + </property> <property name="iconVisibleInMenu"> <bool>true</bool> </property> @@ -484,7 +489,7 @@ <string>Orthomode</string> </property> <property name="shortcut"> - <string>Meta+S</string> + <string>Meta+A</string> </property> <property name="iconVisibleInMenu"> <bool>true</bool> @@ -684,6 +689,21 @@ <string>Online Help</string> </property> </action> + <action name="actionPanning_Mode"> + <property name="icon"> + <iconset resource="../Resources/resources.qrc"> + <normaloff>:/inAppIcons/Icons/moved_hand.svg</normaloff>:/inAppIcons/Icons/moved_hand.svg</iconset> + </property> + <property name="text"> + <string>Panning Mode</string> + </property> + <property name="shortcut"> + <string>Ctrl+Shift+P</string> + </property> + <property name="iconVisibleInMenu"> + <bool>true</bool> + </property> + </action> </widget> <resources> <include location="../Resources/resources.qrc"/> diff --git a/forms/settingdialog.ui b/forms/settingdialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..62f5422dcd061d4ba5a69b49b09cd0871038251a --- /dev/null +++ b/forms/settingdialog.ui @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SettingDialog</class> + <widget class="QDialog" name="SettingDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>318</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>Setting</string> + </property> + <widget class="QTabWidget" name="tabWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>301</width> + <height>461</height> + </rect> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="backupTab"> + <attribute name="title"> + <string>Backup</string> + </attribute> + <widget class="QWidget" name="horizontalLayoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>0</y> + <width>271</width> + <height>31</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Backup Interval: </string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="timeLine"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Minutes</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QPushButton" name="chooseButton"> + <property name="geometry"> + <rect> + <x>5</x> + <y>100</y> + <width>121</width> + <height>32</height> + </rect> + </property> + <property name="text"> + <string>Choose Folder</string> + </property> + </widget> + <widget class="QLineEdit" name="locationLine"> + <property name="geometry"> + <rect> + <x>11</x> + <y>70</y> + <width>271</width> + <height>21</height> + </rect> + </property> + </widget> + <widget class="QLabel" name="label_3"> + <property name="geometry"> + <rect> + <x>11</x> + <y>41</y> + <width>89</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>Backup folder:</string> + </property> + </widget> + <widget class="QWidget" name="horizontalLayoutWidget_2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>400</y> + <width>291</width> + <height>32</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="applyButton"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="confirmButton"> + <property name="text"> + <string>Ok</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/jpseditor.pro b/jpseditor.pro index 5403201fcbfe07b38c5b650fe4d4aaa5f6218369..91ec8fc6a81377a80656290a66e53a1b47171331 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -14,7 +14,7 @@ # along with JuPedSim. If not, see <http://www.gnu.org/licenses/>. # # copyright <2009-2018> Forschungszentrum Juelich GmbH. - + # Compatibility with Qt4 and Qt5 greaterThan(QT_MAJOR_VERSION, 4):QT += widgets @@ -31,7 +31,8 @@ FORMS += \ forms/mainwindow.ui \ forms/roomwidget.ui \ forms/widgetlandmark.ui \ - forms/widgetsettings.ui + forms/widgetsettings.ui \ + forms/settingdialog.ui \ HEADERS += \ src/mainWindow.h \ @@ -66,7 +67,8 @@ HEADERS += \ src/AutomaticRoomIdentification/roomID.h\ src/AutomaticRoomIdentification/roomdefinition.h \ src/AutomaticRoomIdentification/roomidentification.h \ - src/dtrace.h + src/dtrace.h \ + src/settingdialog.h SOURCES += \ @@ -92,17 +94,36 @@ SOURCES += \ src/UndoFramework/lineaction.cpp \ src/jpsregion.cpp \ src/AutomaticRoomIdentification/roomdefinition.cpp \ - src/AutomaticRoomIdentification/roomidentification.cpp + src/AutomaticRoomIdentification/roomidentification.cpp \ + src/settingdialog.cpp #INCLUDEPATH += D:/boost_1_59_0/boost_1_59_0 -RESOURCES += \ +RESOURCES += \ Resources/resources.qrc RC_FILE = Resources/jpseditor.rc #osx fix -ICON = Resources/jupedsim.icns +ICON = Resources/jpseditor.icns + + +CONFIG(debug, debug|release) { + DESTDIR = build/debug +} +CONFIG(release, debug|release) { + DESTDIR = build/release +} + +OBJECTS_DIR = $$DESTDIR/.obj +MOC_DIR = $$DESTDIR/.moc +RCC_DIR = $$DESTDIR/.qrc +UI_DIR = $$DESTDIR/.u +demos.path = /usr/local/bin/jpseditor +demos.files = examples/* +INSTALLS += demos +target.path = /usr/local/bin/jpseditor +INSTALLS += target diff --git a/jpseditor.rb b/jpseditor.rb new file mode 100644 index 0000000000000000000000000000000000000000..2922cef2c1b867c67a6dea1a2d666f2d76cb4c81 --- /dev/null +++ b/jpseditor.rb @@ -0,0 +1,21 @@ +class Jpseditor < Formula + desc "A graphical user interface to create the geometry of a scenario simulated by JuPedSim" + homepage "https://www.jupedsim.org/" + head "https://github.com/JuPedSim/jpseditor.git" :branch => "develop" + + depends_on "cmake" => :build + depends_on "qt" + + def install + Dir.pwd + Dir.mkdir "build" + Dir.chdir "build" + system "cmake", "..", *std_cmake_args + system "make", "install" + puts "" + puts "------------------------------------" + puts "JPSeditor installed in /tmp" + puts "open /tmp/JPSeditor.app" + puts "------------------------------------" + end +end diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 372305eaa39be0a6f09d83441322168f3f7a6770..2a60cdcc6e4b8a50b031c4838962bd181b609be0 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -67,6 +67,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent, jpsDatamanager *datamanager):Q statDoor=false; statExit=false; _statHLine=false; + statPanning=false; _statCopy=0; statLandmark=false; markedLandmark=nullptr; @@ -178,7 +179,7 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) } - if (midbutton_hold) + if (midbutton_hold && statPanning) { translations(old_pos); } @@ -303,6 +304,11 @@ void jpsGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) { midbutton_hold=true; } + else if (mouseEvent->button()==Qt::RightButton) + { + disable_drawing(); + emit no_drawing(); + } update(); } @@ -922,6 +928,8 @@ void jpsGraphicsView::disable_drawing() _statLineEdit=false; _statHLine=false; _statCopy=0; + + // if drawing was canceled by pushing ESC if (current_line!=nullptr) { @@ -935,7 +943,6 @@ void jpsGraphicsView::disable_drawing() delete _currentVLine; _currentVLine=nullptr; } - } jpsLineItem* jpsGraphicsView::addLineItem(const qreal &x1,const qreal &y1,const qreal &x2,const qreal &y2,const QString &type) @@ -1549,12 +1556,12 @@ void jpsGraphicsView::ShowOrigin() if (_origin.isEmpty()) { //Scene->DrawOrigin(); - _origin.push_back(Scene->addLine(0,0,0,0+gl_scale_f*100,QPen(Qt::black,gl_scale_f*2))); - _origin.push_back(Scene->addLine(0,0+gl_scale_f*100,0-gl_scale_f*10,0+gl_scale_f*100-gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); - _origin.push_back(Scene->addLine(0,0+gl_scale_f*100,0+gl_scale_f*10,0+gl_scale_f*100-gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); - _origin.push_back(Scene->addLine(0,0,0+gl_scale_f*100,0,QPen(Qt::black,gl_scale_f*2))); - _origin.push_back(Scene->addLine(0+gl_scale_f*100,0,gl_scale_f*100-gl_scale_f*10,-gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); - _origin.push_back(Scene->addLine(0+gl_scale_f*100,0,gl_scale_f*100-gl_scale_f*10,+gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0,0,0+gl_scale_f*100,QPen(Qt::red,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0+gl_scale_f*100,0-gl_scale_f*10,0+gl_scale_f*100-gl_scale_f*10,QPen(Qt::red,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0+gl_scale_f*100,0+gl_scale_f*10,0+gl_scale_f*100-gl_scale_f*10,QPen(Qt::red,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0,0+gl_scale_f*100,0,QPen(Qt::red,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0+gl_scale_f*100,0,gl_scale_f*100-gl_scale_f*10,-gl_scale_f*10,QPen(Qt::red,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0+gl_scale_f*100,0,gl_scale_f*100-gl_scale_f*10,+gl_scale_f*10,QPen(Qt::red,gl_scale_f*2))); //Y _origin.push_back(Scene->addLine(0-gl_scale_f*10,gl_scale_f*100-gl_scale_f*50,0-gl_scale_f*5,gl_scale_f*100-gl_scale_f*45,QPen(Qt::black,gl_scale_f*2))); _origin.push_back(Scene->addLine(0-gl_scale_f*10,gl_scale_f*100-gl_scale_f*50,0-gl_scale_f*15,gl_scale_f*100-gl_scale_f*45,QPen(Qt::black,gl_scale_f*2))); @@ -1576,6 +1583,8 @@ void jpsGraphicsView::ShowOrigin() } _origin.clear(); } + + } void jpsGraphicsView::StatPositionDef() @@ -1861,6 +1870,41 @@ void jpsGraphicsView::en_disableWall() } +bool jpsGraphicsView::statusPanning() +{ + return statPanning; +} + +void jpsGraphicsView::en_disablePanning() +{ + statPanning=!statPanning; + + statWall=false; + statDoor=false; + statExit=false; + _statHLine=false; + statLandmark=false; + + if (statPanning==false) + { + QString info = "Panning Mode is off!"; + + QMessageBox messageBox; + messageBox.information(0,tr("Panning Mode"),info); + } + else + { + QString info = "\ + Panning Mode is on!\n\ + Press middle button to move view"; + + QMessageBox messageBox; + messageBox.information(0,tr("Panning Mode"),info); + } + +} + + bool jpsGraphicsView::statusWall() { return statWall; diff --git a/src/GraphicView.h b/src/GraphicView.h index 71217a804d8ca6a8a278be638f7557afe3701300..95c4378f623afdb2d69a2b819b556ceae4567b03 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -82,6 +82,9 @@ public: bool statusLandmark(); void en_disableLandmark(); + bool statusPanning(); + void en_disablePanning(); + // global functions qreal get_scale_f(); void take_l_from_lineEdit(const qreal &length); @@ -202,6 +205,7 @@ private: bool statDoor; bool statExit; bool statLandmark; + bool statPanning; bool _statHLine; int _statCopy; QPointF _copyOrigin; diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp index 84f3eed1f82619a6c108bf383aecb80099c6a945..a30fc465f9c0d93e8108abb46d8cf442bf879f3b 100644 --- a/src/graphicscene.cpp +++ b/src/graphicscene.cpp @@ -100,11 +100,11 @@ void GraphicScene::DrawLineGrid(QPainter *painter, const QRectF &rect) painter->drawLines(lines.data(), lines.size()); //draw orgin and x y axis - painter->setPen(QPen(Qt::red,0)); - painter->drawRect(origin); - painter->fillRect(origin, Qt::red); - painter->drawLine(xaxis); - painter->drawLine(yaxis); +// painter->setPen(QPen(Qt::red,0)); +// painter->drawRect(origin); +// painter->fillRect(origin, Qt::red); +// painter->drawLine(xaxis); +// painter->drawLine(yaxis); } void GraphicScene::DrawPointGrid(QPainter *painter, const QRectF &rect) diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index eaa98015e2ea2572722b2d93cb29f44f50f1b648..749c1484a0e597d7d02f3da0e909d927925d2852 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -36,6 +36,8 @@ #include <QShortcut> #include <QDesktopServices> #include <QUrl> +#include <QDebug> +#include <QSettings> MWindow :: MWindow() { @@ -43,7 +45,6 @@ MWindow :: MWindow() { //Signal/Slot //VBox= new QVBoxLayout; - mview = new jpsGraphicsView(this); dmanager = new jpsDatamanager(this,mview); mview->SetDatamanager(dmanager); @@ -52,8 +53,7 @@ MWindow :: MWindow() { rwidget=nullptr; //Landmarkwidget lwidget=nullptr; - //WidgetSettings - _settings=nullptr; + //StaturBar @@ -95,6 +95,7 @@ MWindow :: MWindow() { setCentralWidget(mview); //this->setMaximumSize(1920,1080); this->showMaximized(); + statusBar()->addPermanentWidget(infoLabel); statusBar()->addPermanentWidget(label_x); statusBar()->addPermanentWidget(x_edit); @@ -104,10 +105,10 @@ MWindow :: MWindow() { // statusBar()->addPermanentWidget(length_edit); // statusBar()->addPermanentWidget(label2); - //Timer needed for autosave function + //Timer needed for autosaving function // timer will trigger autosave every 5th minute timer = new QTimer(this); - timer->setInterval(300000); + timer->setInterval(60000); timer->start(); _cMapTimer = new QTimer(this); @@ -144,9 +145,14 @@ MWindow :: MWindow() { connect(actionDoor,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode())); connect(actionExit,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode())); connect(actionScale,SIGNAL(triggered(bool)),this,SLOT(enableScale())); + // Tab View connect(actionRotate_90_deg_clockwise,SIGNAL(triggered(bool)),this,SLOT(rotate())); connect(actionShow_Point_of_Origin,SIGNAL(triggered(bool)),this,SLOT(ShowOrigin())); + + // Panning mode + connect(actionPanning_Mode,SIGNAL(triggered(bool)),this,SLOT(en_disablePanning())); + // Length edit // connect(length_edit,SIGNAL(returnPressed()),this,SLOT(send_length())); // connect(length_edit,SIGNAL(returnPressed()),this,SLOT(ScaleLines())); @@ -161,6 +167,11 @@ MWindow :: MWindow() { connect(mview,SIGNAL(set_focus_textedit()),length_edit,SLOT(setFocus())); connect(mview,SIGNAL(mouse_moved()),this,SLOT(show_coords())); connect(mview,SIGNAL(LineLengthChanged()),this,SLOT(ShowLineLength())); + +// QAction *str_escape = new QAction(this); +// str_escape->setShortcut(Qt::Key_Escape); +// connect(str_escape, SIGNAL(triggered(bool)), mview, SLOT(disableDrawing())); + // Mark all lines QAction *str_a = new QAction(this); str_a->setShortcut(Qt::Key_A | Qt::CTRL); @@ -188,6 +199,7 @@ MWindow :: MWindow() { // room type data gathering connect(actionGather_data,SIGNAL(triggered(bool)),this, SLOT(GatherData())); + } MWindow::~MWindow() @@ -204,32 +216,24 @@ MWindow::~MWindow() void MWindow::AutoSave() { - QFile file("Name"); - if (_filename!="") - { - QString fN="backup_"+_filename+".xml"; - file.setFileName(fN); - } - else - { - QString fN="backup_untitled.xml"; - file.setFileName(fN); - } + QMap<QString, QString> settingsmap = loadSettings(); + QString backupfolder = settingsmap["backupfolder"]; + QString filename = backupfolder + "/backup_untitled.xml"; + QFile file(filename); - if(file.open(QIODevice::WriteOnly|QIODevice::Text)) - { + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { //QString coord_string=mview->build_coordString(); - dmanager->AutoSaveXML(file); + dmanager->writeXML(file); //file.write(coord_string.toUtf8());//textEdit->toPlainText().toUtf8()); - statusBar()->showMessage(tr("Backup file generated!"),10000); + statusBar()->showMessage(tr("Backup file generated!"), 10000); //routing (hlines) QString fileNameRouting = file.fileName(); - fileNameRouting=fileNameRouting.split(".").first()+"_routing.xml"; + fileNameRouting = fileNameRouting.split(".").first() + "_routing.xml"; QFile routingFile(fileNameRouting); - if (routingFile.open(QIODevice::WriteOnly|QIODevice::Text)) + if (routingFile.open(QIODevice::WriteOnly | QIODevice::Text)) dmanager->writeRoutingXML(routingFile); } } @@ -286,20 +290,25 @@ void MWindow::GatherData() void MWindow::Settings() { - if (_settings==nullptr) - { - _settings = new WidgetSettings(this,mview); - _settings->setAttribute(Qt::WA_DeleteOnClose); - _settings->setGeometry(QRect(QPoint(5,75), _settings->size())); - _settings->show(); - } + settingDialog = new SettingDialog; - else - { - _settings->close(); - _settings=nullptr; - } +// QString backupfolder = settings.value("backupfolder").toString(); +// QString interval = settings.value("interval").toString(); +// +// qDebug()<< settings.value("backupfolder"); +// qDebug()<< settings.value("interval"); +// +// QMap<QString, QString> defaultsetting; +// defaultsetting["backupfolder"] = backupfolder; +// defaultsetting["interval"] = interval; + + QMap<QString, QString> defaultsetting = loadSettings(); + connect(settingDialog,SIGNAL(sendSetting(QMap<QString, QString>)), + this,SLOT(saveSettings(QMap<QString, QString>))); + settingDialog->setCurrentSetting(defaultsetting); + settingDialog->setModal(true); + settingDialog->exec(); } void MWindow::ShowOrigin() @@ -683,6 +692,7 @@ void MWindow::en_selectMode() mview->disable_drawing(); actionSelect_Mode->setChecked(true); + actionWall->setChecked(false); actionDoor->setChecked(false); actionExit->setChecked(false); @@ -771,8 +781,62 @@ void MWindow::on_actionOnline_Help_triggered() void MWindow::on_actionClear_all_Rooms_and_Doors_triggered() { dmanager->remove_all(); - rwidget->show_rooms(); - rwidget->show_crossings(); - rwidget->show_exits(); - rwidget->show_obstacles(); + + if(rwidget!= nullptr){ + rwidget->show_rooms(); + rwidget->show_crossings(); + rwidget->show_obstacles(); + } + +} + +void MWindow::keyPressEvent(QKeyEvent *event) +{ + switch(event->key()) + { + case Qt::Key_Escape: + mview->disable_drawing(); + en_selectMode(); + break; + default: + QWidget::keyPressEvent(event); + } +} + +// Default settings +void MWindow::saveSettings(QMap<QString, QString> settingsmap) +{ + QSettings settings("FZJ","JPSeditor"); + settings.beginGroup("backup"); + settings.setValue("backupfolder", settingsmap["backupfolder"]); + settings.setValue("interval", settingsmap["interval"]); + + timer->setInterval(settingsmap["interval"].toInt()); + + settings.endGroup(); } + +QMap<QString, QString> MWindow::loadSettings() +{ + QSettings settings("FZJ","JPSeditor"); + + settings.beginGroup("backup"); + QString value = settings.value("backupfolder", "../").toString(); + QString interval = settings.value("interval", "60000").toString(); + settings.endGroup(); + + QMap<QString, QString> settingsmap; + settingsmap["backupfolder"] = value; + settingsmap["interval"] = interval; + + return settingsmap; +} + +// Panning mode +void MWindow::en_disablePanning() +{ + this->disableDrawing(); + mview->en_disablePanning(); +} + + diff --git a/src/mainWindow.h b/src/mainWindow.h index 9203d7d89661da74689b8126bfbf67fdda3d0cd6..d10777fe65b17b200c777926ecdcc43a56a4286b 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -41,7 +41,7 @@ #include "GraphicView.h" #include "datamanager.h" #include "rooms.h" - +#include "src/settingdialog.h" class MWindow : public QMainWindow, private Ui::MainWindow { @@ -54,7 +54,7 @@ public: private: roomWidget* rwidget; widgetLandmark* lwidget; - WidgetSettings* _settings; +// WidgetSettings* _settings; jpsDatamanager* dmanager; jpsGraphicsView* mview; //QVBoxLayout* VBox; @@ -67,14 +67,22 @@ private: QLabel* label_y; QLabel* infoLabel; QString _filename; - QTimer *timer; //CMap QTimer *_cMapTimer; int _cMapFrame; - bool _statScale; + //default setting + SettingDialog *settingDialog; + QTimer *timer; + QSettings settings; + +// QString backupfolder; +// QString defaultjpscore; +// QString defaultjpsvis; +// QMap<QString, QString> defaultsetting; + bool _statScale; protected slots: @@ -99,6 +107,7 @@ protected slots: void en_disableExit(); void en_disableLandmark(); void en_disableHLine(); + void en_disablePanning(); void disableDrawing(); void objectsnap(); @@ -127,6 +136,7 @@ protected slots: void rotate(); void Settings(); void ShowOrigin(); + //autosave void AutoSave(); @@ -141,12 +151,19 @@ protected slots: //quit void closeEvent(QCloseEvent *event); + //ESCAPE + void keyPressEvent(QKeyEvent *event); + + private slots: void on_actionCopy_triggered(); void on_actionOnline_Help_triggered(); void on_actionClear_all_Rooms_and_Doors_triggered(); -}; + //default setting + void saveSettings(QMap<QString, QString> settingsmap); + QMap<QString, QString> loadSettings(); +}; #endif // MAINWINDOW_H diff --git a/src/roomwidget.cpp b/src/roomwidget.cpp index 1f5e960bb4b988827517ab3fd72e115a41259c6c..678d2c56005a1b1f508891202b864854a2cae262 100644 --- a/src/roomwidget.cpp +++ b/src/roomwidget.cpp @@ -133,6 +133,7 @@ void roomWidget::show_rooms() { dtrace("Enter roomWidget::show_rooms"); ui->list_rooms->clear(); + QList<jpsRoom*> roomlist=datamanager->get_roomlist(); for (int i=0; i<roomlist.size(); i++) { @@ -144,7 +145,7 @@ void roomWidget::show_rooms() void roomWidget::show_crossings() { - dtrace("Enter roomWidget::show_crossings"); + dtrace("Enter roomWidget::show_crossings"); ui->crossingList->clear(); for (jpsCrossing* crossing:datamanager->get_crossingList()) @@ -193,8 +194,10 @@ void roomWidget::show_exits() void roomWidget::show_obstacles() { - dtrace("Enter roomWidget::show_obstacles"); - ui->list_obstacles->clear(); + dtrace("Enter roomWidget::show_obstacles"); + + ui->list_obstacles->clear(); + QList<jpsObstacle*> obslist=datamanager->get_obstaclelist(); for (int i=0; i<obslist.size(); i++) { diff --git a/src/settingdialog.cpp b/src/settingdialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..854d62b691cd1227881367f63a1f33a1fb159c1f --- /dev/null +++ b/src/settingdialog.cpp @@ -0,0 +1,116 @@ +#include "settingdialog.h" +#include "ui_settingdialog.h" +#include <QFileDialog> +#include <QDebug> + +SettingDialog::SettingDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SettingDialog) +{ + ui->setupUi(this); + ui->locationLine->setReadOnly(true); +} + +SettingDialog::~SettingDialog() +{ + delete ui; +} + +void SettingDialog::on_cancelButton_clicked() +{ + this->close(); +} + +void SettingDialog::on_chooseButton_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + "/Users", + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + + ui->locationLine->setText(dir); +} + + +void SettingDialog::on_confirmButton_clicked() +{ + int interval = ui->timeLine->text().toInt()*60000; + QString interval_String = QString::number(interval); + + QString dir = ui->locationLine->text(); + +// QString jpscore = ui->jpscoreLine->text(); +// QString jpsvis = ui->jpsvisLine->text(); + + QMap<QString, QString> settingsmap; + settingsmap["backupfolder"] = dir; + settingsmap["interval"] = interval_String; + +// setting["defaultjpscore"] = jpscore; +// setting["defaultjpsvis"] = jpsvis; + + emit sendSetting(settingsmap); + + this->close(); +} + +void SettingDialog::setCurrentSetting(QMap<QString, QString> settingsmap) +{ + ui->locationLine->setText(settingsmap["backupfolder"]); + + QString minutes = QString::number(settingsmap["interval"].toInt()/60000, 10); + ui->timeLine->setText(minutes); + +// ui->jpscoreLine->setText(settingsmap["defaultjpscore"]); +// ui->jpsvisLine->setText(settingsmap["defaultjpsvis"]); +} + +void SettingDialog::on_choosejpsButton_clicked() +{ +// QString programm = QFileDialog::getOpenFileName( +// this, +// tr("Choose JPScore"), +// "/Users", +// "Programm (jpscore *.exe *.*)"); + +// ui->jpscoreLine->setText(programm); +} + +void SettingDialog::on_jpsvisButton_clicked() +{ +// QString programm = QFileDialog::getOpenFileName( +// this, +// tr("Choose JPSvis"), +// "/Users", +// "Programm (*.app *.exe *.*)"); + +// ui->jpsvisLine->setText(programm); +} + +void SettingDialog::on_cancelButton_page2_clicked() +{ + this->close(); +} + +void SettingDialog::on_confirmButton_page2_clicked() +{ + on_confirmButton_clicked(); +} + +void SettingDialog::on_applyButton_clicked() +{ + int interval = ui->timeLine->text().toInt()*60000; + QString interval_String = QString::number(interval); + + QString dir = ui->locationLine->text(); + +// QString jpscore = ui->jpscoreLine->text(); +// QString jpsvis = ui->jpsvisLine->text(); + + QMap<QString, QString> settingsmap; + settingsmap["backupfolder"] = dir; + settingsmap["interval"] = interval_String; + + emit sendSetting(settingsmap); + +} diff --git a/src/settingdialog.h b/src/settingdialog.h new file mode 100644 index 0000000000000000000000000000000000000000..6534496a91251dfd18dc51eeda31be794c695819 --- /dev/null +++ b/src/settingdialog.h @@ -0,0 +1,46 @@ +#ifndef SETTINGDIALOG_H +#define SETTINGDIALOG_H + +#include <QDialog> +#include <QList> +#include <QMap> + +namespace Ui { +class SettingDialog; +} + +class SettingDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SettingDialog(QWidget *parent = nullptr); + ~SettingDialog(); + + void setCurrentSetting(QMap<QString, QString> settingsmap); + +signals: + void sendSetting(QMap<QString, QString>); + +private slots: + void on_cancelButton_clicked(); + + void on_chooseButton_clicked(); + + void on_confirmButton_clicked(); + + void on_choosejpsButton_clicked(); + + void on_jpsvisButton_clicked(); + + void on_cancelButton_page2_clicked(); + + void on_confirmButton_page2_clicked(); + + void on_applyButton_clicked(); + +private: + Ui::SettingDialog *ui; +}; + +#endif // SETTINGDIALOG_H