diff --git a/CMakeLists.txt b/CMakeLists.txt index 2300d7f6633ad4dd98791ea24fc1c481010363c7..769d48c3094afaa9af301070de6e5d8f92158c4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,13 +59,18 @@ option(GEOMODEL_BUILD_FULLSIMLIGHT "Enable the build of FullSimLight" OFF) option(GEOMODEL_BUILD_FULLSIMLIGHT_PROFILING "Enable FullSimLight profiling targets" OFF) option(GEOMODEL_BUILD_FSL "Enable the build of FSL and FullSimLight" OFF) option(GEOMODEL_BUILD_ATLASEXTENSIONS "Build the Custom ATLAS Extensions" OFF) - +option(GEOMODEL_USE_QT6 "Use QT6 for Visualization and FSL" OFF) if(GEOMODEL_BUILD_FSL AND GEOMODEL_BUILD_FULLSIMLIGHT) message(STATUS "==> NOTE: You enabled both BUILD_FSL and BUILD_FULLSIMLIGHT. Since BUILD_FSL triggers the build of the FullSimLight package as well, I set BUILD_FULLSIMLIGHT to FALSE to avoid errors of 'double inclusion'") set(GEOMODEL_BUILD_FULLSIMLIGHT FALSE) endif() +if (GEOMODEL_USE_QT6) + set (QT_VERSION 6) +else() + set (QT_VERSION 5) +endif() if(GEOMODEL_BUILD_FULLSIMLIGHT_PROFILING) set(GEOMODEL_BUILD_FULLSIMLIGHT ON CACHE BOOL "Enable the build of FullSimLight" FORCE) diff --git a/FSL/CMakeLists.txt b/FSL/CMakeLists.txt index a29c004cfcec657409a953b916747913c51448c4..71e3a7131b3beff559728b327abc4cf44d08b387 100644 --- a/FSL/CMakeLists.txt +++ b/FSL/CMakeLists.txt @@ -10,6 +10,18 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) include( GeoModel-version ) # set the project, with the version taken from the GeoModel parent project project( "fsl" VERSION ${GeoModel_VERSION} LANGUAGES CXX ) + + #Choose QT version here: + option (GEOMODEL_USE_QT6 "Use Qt6 for Visualization" OFF) + + if (GEOMODEL_USE_QT6) + set (QT_VERSION 6) + else() + set (QT_VERSION 5) + endif() + + + # Define color codes for CMake messages include( cmake_colors_defs ) # Warn the users about what they are doing @@ -58,9 +70,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Find the dependencies of the project. -find_package( Qt5 COMPONENTS Core Gui Widgets Sql PrintSupport OpenGL REQUIRED ) +find_package( Qt${QT_VERSION} COMPONENTS Core Gui Widgets Sql PrintSupport OpenGL REQUIRED ) -# Qt5 settings. +# Qt${QT_VERSION} settings. set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -76,7 +88,7 @@ set(PROJECT_SOURCES ${sources} ${headers} ${uis} ) add_executable(fsl ${PROJECT_SOURCES} ) -target_link_libraries(fsl PRIVATE Qt5::Widgets nlohmann_json::nlohmann_json) +target_link_libraries(fsl PRIVATE Qt${QT_VERSION}::Widgets nlohmann_json::nlohmann_json) # Install the executable. install( TARGETS fsl diff --git a/GeoModelVisualization/CMakeLists.txt b/GeoModelVisualization/CMakeLists.txt index 583c96311b237276c79ab280cc7cc4695f85b353..bd48e96958c9c4e4cf1bba3f72538118a08fc38e 100644 --- a/GeoModelVisualization/CMakeLists.txt +++ b/GeoModelVisualization/CMakeLists.txt @@ -9,6 +9,7 @@ project( "GeoModelTools" ) #Set up the project. Check if we build it with GeoModel or individually project( "GeoModelVisualization" ) + # Set the OpenGL flag requested by CMake set( OpenGL_GL_PREFERENCE GLVND ) @@ -20,6 +21,17 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) include( GeoModel-version ) # set the project, with the version taken from the GeoModel parent project project( "GeoModelVisualization" VERSION ${GeoModel_VERSION} LANGUAGES CXX ) + + #Choose QT version here: + option (GEOMODEL_USE_QT6 "Use Qt6 for Visualization" OFF) + + if (GEOMODEL_USE_QT6) + set (QT_VERSION 6) + else() + set (QT_VERSION 5) + endif() + + # Define color codes for CMake messages include( cmake_colors_defs ) # Warn the users about what they are doing @@ -43,7 +55,11 @@ else() endif() # Find the dependencies of the project. -find_package( Qt5 COMPONENTS Core Gui Widgets Sql PrintSupport OpenGL REQUIRED ) +if (GEOMODEL_USE_QT6) + find_package( Qt${QT_VERSION} COMPONENTS Core Gui Widgets Sql PrintSupport OpenGL Core5Compat REQUIRED ) +else () + find_package( Qt${QT_VERSION} COMPONENTS Core Gui Widgets Sql PrintSupport OpenGL REQUIRED ) +endif() find_package( OpenGL REQUIRED ) find_package( HDF5 REQUIRED COMPONENTS CXX ) # Set up how the project should handle some of its dependenices. Either by @@ -51,7 +67,7 @@ find_package( HDF5 REQUIRED COMPONENTS CXX ) include( SetupCoin3D ) include( SetupJSON ) -# Qt5 settings. +# Qt${QT_VERSION} settings. set( CMAKE_AUTOMOC ON ) set( CMAKE_AUTOUIC ON ) set( CMAKE_AUTORCC ON ) diff --git a/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt b/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt index 662b24a95cbe16967c12c98f8e282b6359e74c13..33c91f302076873b65ae865c164fe8ce28036cf8 100644 --- a/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt +++ b/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt @@ -9,7 +9,7 @@ file( GLOB UIS src/*.ui ) add_library( GXClashPointSystems SHARED ${SOURCES} ${HEADERS} ${UIS} ) target_link_libraries( GXClashPointSystems PUBLIC Coin::Coin GXBase - PRIVATE Qt5::Core Qt5::Widgets nlohmann_json::nlohmann_json ) + PRIVATE Qt${QT_VERSION}::Core Qt${QT_VERSION}::Widgets nlohmann_json::nlohmann_json ) target_include_directories( GXClashPointSystems PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include> ) diff --git a/GeoModelVisualization/GXHitDisplaySystems/CMakeLists.txt b/GeoModelVisualization/GXHitDisplaySystems/CMakeLists.txt index 6637e020d8f1144db3c3632cbf85051d6c462fb9..e1e2c7d83af1ec32068af5a2fb2726219f93bd0f 100644 --- a/GeoModelVisualization/GXHitDisplaySystems/CMakeLists.txt +++ b/GeoModelVisualization/GXHitDisplaySystems/CMakeLists.txt @@ -9,7 +9,7 @@ find_package (HDF5 REQUIRED) add_library( GXHitDisplaySystems SHARED ${SOURCES} ${HEADERS} ${UIS} ) target_link_libraries( GXHitDisplaySystems PUBLIC Coin::Coin GXBase - PRIVATE Qt5::Core Qt5::Widgets ${HDF5_CXX_LIBRARIES} ${HDF5_LIBRARIES} ) + PRIVATE Qt${QT_VERSION}::Core Qt${QT_VERSION}::Widgets ${HDF5_CXX_LIBRARIES} ${HDF5_LIBRARIES} ) target_include_directories( GXHitDisplaySystems PUBLIC ${HDF5_CXX_INCLUDE_DIRS} $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> diff --git a/GeoModelVisualization/GXTrackDisplaySystems/CMakeLists.txt b/GeoModelVisualization/GXTrackDisplaySystems/CMakeLists.txt index 475be0827a58bae7633a2681c79b5c20aba6b463..bc690cd322d977679d27a1ff98a6734f35dc6c00 100644 --- a/GeoModelVisualization/GXTrackDisplaySystems/CMakeLists.txt +++ b/GeoModelVisualization/GXTrackDisplaySystems/CMakeLists.txt @@ -9,7 +9,7 @@ file( GLOB UIS src/*.ui ) add_library( GXTrackDisplaySystems SHARED ${SOURCES} ${HEADERS} ${UIS} ) target_link_libraries( GXTrackDisplaySystems PUBLIC Coin::Coin GXBase - PRIVATE Qt5::Core Qt5::Widgets ${HDF5_LIBRARIES} ) + PRIVATE Qt${QT_VERSION}::Core Qt${QT_VERSION}::Widgets ${HDF5_LIBRARIES} ) target_include_directories( GXTrackDisplaySystems PUBLIC ${HDF5_CXX_INCLUDE_DIRS} $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> diff --git a/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt b/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt index b41741b94c974c1a56ac2c1b06536f1636494bb0..695376de66e41b81e109f7e6d6b10e884b1497c2 100644 --- a/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt +++ b/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable( gmex src/main.cxx ) add_definitions (-DGXPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/gxplugins" ) -target_link_libraries( gmex PRIVATE GXGui Qt5::Core ) +target_link_libraries( gmex PRIVATE GXGui Qt${QT_VERSION}::Core ) target_compile_definitions( gmex PRIVATE GEOMODEL_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" ) source_group( "src" FILES "src/main.cxx" ) diff --git a/GeoModelVisualization/VP1Base/CMakeLists.txt b/GeoModelVisualization/VP1Base/CMakeLists.txt index 4297266813d9d1220a75c553dfa1aaccfaec0a7a..ca2b6aba0e2e94d3986fa6d37a0d12773f78334c 100644 --- a/GeoModelVisualization/VP1Base/CMakeLists.txt +++ b/GeoModelVisualization/VP1Base/CMakeLists.txt @@ -8,9 +8,16 @@ file( GLOB RCS src/*.qrc ) # Add the library. add_library( GXBase SHARED ${SOURCES} ${HEADERS} ${UIS} ${RCS} ) -target_link_libraries( GXBase - PUBLIC Coin::Coin Qt5::Core Qt5::Gui Qt5::Widgets SoQt::SoQt - PRIVATE Qt5::PrintSupport Qt5::OpenGL GXHEPVis ) +if (GEOMODEL_USE_QT6) + target_link_libraries( GXBase + PUBLIC Coin::Coin Qt${QT_VERSION}::Core Qt${QT_VERSION}::Gui Qt${QT_VERSION}::Widgets Qt${QT_VERSION}::Core5Compat SoQt::SoQt + PRIVATE Qt${QT_VERSION}::PrintSupport Qt${QT_VERSION}::OpenGL GXHEPVis ) +else() + target_link_libraries( GXBase + PUBLIC Coin::Coin Qt${QT_VERSION}::Core Qt${QT_VERSION}::Gui Qt${QT_VERSION}::Widgets SoQt::SoQt + PRIVATE Qt${QT_VERSION}::PrintSupport Qt${QT_VERSION}::OpenGL GXHEPVis ) +endif() + target_include_directories( GXBase PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include> ) diff --git a/GeoModelVisualization/VP1Base/VP1Base/AnimationSequencer.h b/GeoModelVisualization/VP1Base/VP1Base/AnimationSequencer.h index 6931c748486ad8a6b6046336ac467b9ad191393a..d29dc8ff35f4f96341548161a93ca2ce11bb855e 100644 --- a/GeoModelVisualization/VP1Base/VP1Base/AnimationSequencer.h +++ b/GeoModelVisualization/VP1Base/VP1Base/AnimationSequencer.h @@ -13,7 +13,7 @@ #include "VP1Base/AnimationSequence.h" #include <QObject> - +#include <QGraphicsItem> class VP1ExaminerViewer; class AnimationSequencer : public QObject { diff --git a/GeoModelVisualization/VP1Base/VP1Base/IVP12DDetViewsChannelWidget.h b/GeoModelVisualization/VP1Base/VP1Base/IVP12DDetViewsChannelWidget.h deleted file mode 100644 index a377e984118faffadcf007bf48b6bfda84903191..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/IVP12DDetViewsChannelWidget.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class IVP12DDetViewsChannelWidget // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: July 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef IVP12DDETVIEWSCHANNELWIDGET_H -#define IVP12DDETVIEWSCHANNELWIDGET_H - -#include "VP1Base/IVP1ChannelWidget.h" - - -//This type of channel widget displays itemcollections in two -//different graphicsviews - one for each of XY and RZ -//projections. -// -//The normal way to add data from systems into these views is to add a -//number of IVP12DDetViewsSystem's to the channel (using the addSystem -//method) methods. Since IVP12DDetViewsSystem's specifically provide -//item collections for each of the different projections, everything -//should be taken care of automatically. It is, however, possible to -//add collections from any IVP12DSystem to the views. To do this, one -//must use the addGeneralSystem method and specify as a parameter in -//which of the two projections all of the item collections provided -//by this system should be presented. - -//fixme/TODO: Actually use the z-factor!! - -class IVP12DSystem; -class IVP12DDetViewsSystem; - -class IVP12DDetViewsChannelWidget : public IVP1ChannelWidget { - - Q_OBJECT - -public: - IVP12DDetViewsChannelWidget(const QString & name, const QString & information, const QString & contact_info); - //Fixme: Pass along default backgroundcolor as an option? - -protected: - enum SystemOption { - AllowAll = 0x0000, - DisallowSelections = 0x0100,//User can not interact with items from this system (movable though, is handled separately) - DisallowSwitchable = 0x0400,//User can not turn items from this system on/off. - DisallowController = 0x0800,//Custom controllers provided by this wont be present in the GUI - DisallowMovable = 0x1000,//Items from this systems are never movable - StartDisabled = 0x0010 - }; -public: //public instead of protected due to compilation problems on SLC3 - Q_DECLARE_FLAGS(SystemOptions, SystemOption) -protected: - //Call the following in constructor of a derived class to add 2D systems. Never delete the systems in the derived class. - - //Zfactor determines which systems are on top of each other (higher values are in the foreground) //FIXME - NOT USED!!! - - void addSystem(IVP12DDetViewsSystem*, double zfactor, const SystemOptions& options = AllowAll ); - - //Other types of systems can only be used by adding all of their collections into a single given projection view: - enum PROJECTION { XY, RZ }; - void addGeneralSystem(IVP12DSystem*, const PROJECTION& projection, double zfactor, const SystemOptions& options = AllowAll );//FIXME: NOT IMPLEMENTED YET!!!!!! - - //////////////////// The following is for internal use /////////////////////// - -public: - Type type() const { return TWODIMENSIONAL; }; - - void create(); - void systemRefreshed(IVP1System*); - void systemErased(IVP1System*); - virtual ~IVP12DDetViewsChannelWidget(); - virtual QByteArray saveState(); - virtual void restoreFromState(QByteArray); - -protected slots: - void showControlsForSystem(); - -private: - class Imp; - Imp * m_d; -private slots: - void toggleSystemActive(); - void setBackgroundColor(const QColor &); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(IVP12DDetViewsChannelWidget::SystemOptions) - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/IVP12DDetViewsSystem.h b/GeoModelVisualization/VP1Base/VP1Base/IVP12DDetViewsSystem.h deleted file mode 100644 index 764746986cfa0fc7f17972547c5b5ee9821fe3e4..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/IVP12DDetViewsSystem.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class IVP12DDetViewsSystem // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: July 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef IVP12DDETVIEWSSYSTEM_H -#define IVP12DDETVIEWSSYSTEM_H - -#include "VP1Base/IVP12DSystem.h" - -#include <QSet> - -class VP1GraphicsItemCollection; - -class IVP12DDetViewsSystem : public IVP12DSystem { - - Q_OBJECT - -public: - - //////////////////////////////////////////////////////////////////////// - ////////////// This is the interesting bit for those ////////////// - ////////////// who are deriving from this class... ////////////// - //////////////////////////////////////////////////////////////////////// - - IVP12DDetViewsSystem(const QString & name, const QString & information, const QString & contact_info); - - virtual void systemcreate(StoreGateSvc* detstore);//Optional. - - //If you need a controller - create it and return it from a reimplementation of this method (it will only be called once). - virtual QWidget * buildController(); - - //If some items should be visible for the entire run, reimplement: - virtual void buildPermanentItemCollections( StoreGateSvc* detstore, - VP1GraphicsItemCollection* ic_xy, - VP1GraphicsItemCollection* ic_rz ); - - //Reimplement and add the items for a given event, based on the contents of storegate: - virtual void buildEventItemCollections( StoreGateSvc *sg, - VP1GraphicsItemCollection* ic_xy, - VP1GraphicsItemCollection* ic_rz ); - - virtual void systemerase();//Optional - for erasing maps etc. with event data. - - virtual void systemuncreate();//Optional. - - - //This is the interesting bit for channels using this system: - QSet<VP1GraphicsItemCollection*> getItemCollections_XY() const; - QSet<VP1GraphicsItemCollection*> getItemCollections_RZ() const; - - //////////////////////////////////////////////////////////////////////// - //////////// The rest of this file is just internal stuff //////////// - //////////// - dont worry about it - //////////// - //////////////////////////////////////////////////////////////////////// - - virtual ~IVP12DDetViewsSystem(); -private: - class Imp; - Imp * m_d; - void create(StoreGateSvc* detstore); - void refresh(StoreGateSvc* storegate); - void erase(); - void uncreate(); -}; - - - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/IVP12DStandardChannelWidget.h b/GeoModelVisualization/VP1Base/VP1Base/IVP12DStandardChannelWidget.h deleted file mode 100644 index 190b0fa6441bc8c59bbf4d43a6e0b7ea5fab36aa..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/IVP12DStandardChannelWidget.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class IVP12DStandardChannelWidget // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef IVP12DSTANDARDCHANNELWIDGET_H -#define IVP12DSTANDARDCHANNELWIDGET_H - -#include "VP1Base/IVP1ChannelWidget.h" -class IVP12DSystem; -class IVP12DSystemSimple; - -class IVP12DStandardChannelWidget : public IVP1ChannelWidget { - - Q_OBJECT - -public: - IVP12DStandardChannelWidget(const QString & name, const QString & information, const QString & contact_info); - //Fixme: Pass along default backgroundcolor as an option? - -protected: - enum SystemOption { - AllowAll = 0x0000, - DisallowSelections = 0x0100,//User can not interact with items from this system (movable though, is handled separately) - DisallowSwitchable = 0x0400,//User can not turn items from this system on/off. - DisallowController = 0x0800,//Custom controllers provided by this wont be present in the GUI - DisallowMovable = 0x1000,//Items from this systems are never movable - StartDisabled = 0x0010 - }; -public: //public instead of protected due to compilation problems on SLC3 - Q_DECLARE_FLAGS(SystemOptions, SystemOption) -protected: - //Call the following in constructor of a derived class. Do not delete the systems in the derived class. - void addSystem(IVP12DSystem*, const SystemOptions& options = AllowAll ); - - //////////////////// The following is for internal use /////////////////////// - - //Convenience so users dont need to cast themselves (needed due to private inheritance in IVP12DSystemSimple): - void addSystem(IVP12DSystemSimple*, const SystemOptions& options = AllowAll ); -public: - Type type() const { return TWODIMENSIONAL; }; - - void create(); - void systemRefreshed(IVP1System*); - void systemErased(IVP1System*); - virtual ~IVP12DStandardChannelWidget(); - virtual QByteArray saveState(); - virtual void restoreFromState(QByteArray); - -protected slots: - void showControlsForSystem(); - -private: - class Imp; - Imp * m_d; -private slots: - void toggleSystemActive(); - void setBackgroundColor(const QColor &); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(IVP12DStandardChannelWidget::SystemOptions) - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/IVP12DSystem.h b/GeoModelVisualization/VP1Base/VP1Base/IVP12DSystem.h deleted file mode 100644 index 27248e540c5cfca346bec004dbc036fb60b6fa7d..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/IVP12DSystem.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class IVP12DSystem // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef IVP12DSYSTEM_H -#define IVP12DSYSTEM_H - -#include "VP1Base/IVP1System.h" - -#include <QSet> - -class VP1GraphicsItemCollection; -class QGraphicsItem; - -class IVP12DSystem : public IVP1System { - - Q_OBJECT - -public: - - //////////////////////////////////////////////////////////////////////// - /////////// This is the interesting bit for those /////////// - /////////// who are deriving from, or using, this class... /////////// - //////////////////////////////////////////////////////////////////////// - - IVP12DSystem(const QString & name, const QString & information, const QString & contact_info); - - //Derived classes must call the following method exactly once on - //each item collection they provide: - void registerItemCollection(VP1GraphicsItemCollection*); - - //Reimplement if you need to catch user picks, selections or events (you need to enable the item collections for this!): - - virtual void itemPicked(VP1GraphicsItemCollection*,QGraphicsItem*); - virtual void itemGotEvent(VP1GraphicsItemCollection*,QGraphicsItem*,QEvent*); - virtual void selectionChanged(VP1GraphicsItemCollection*,QList<QGraphicsItem*>); - - //This is for use by the channels: - QSet<VP1GraphicsItemCollection*> getItemCollections(); - - //////////////////////////////////////////////////////////////////////// - //////////// The rest of this file is just internal stuff //////////// - //////////// - dont worry about it - //////////// - //////////////////////////////////////////////////////////////////////// - - virtual ~IVP12DSystem(); - -signals: - void itemFromSystemSelected();//Should be emitted whenever item in this system is selected (mainly to give channel chance to show the system controller) - -private: - IVP12DSystem( const IVP12DSystem & ); - IVP12DSystem & operator= ( const IVP12DSystem & ); - class Imp; - Imp * m_d; - -private slots: - void itemPickedPrivate(QGraphicsItem*); - void itemGotEventPrivate(QGraphicsItem*,QEvent*); - void selectionChangedPrivate(QList<QGraphicsItem*>); -}; - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/IVP12DSystemSimple.h b/GeoModelVisualization/VP1Base/VP1Base/IVP12DSystemSimple.h deleted file mode 100644 index 01eb22002cf9472169c5ce04ee840d3c63d40285..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/IVP12DSystemSimple.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class IVP12DSystemSimple // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef IVP12DSYSTEMSIMPLE_H -#define IVP12DSYSTEMSIMPLE_H - -#include "VP1Base/IVP12DSystem.h" - -class VP1GraphicsItemCollection; - -class IVP12DSystemSimple : public IVP12DSystem { - - Q_OBJECT - -public: - - //////////////////////////////////////////////////////////////////////// - ////////////// This is the interesting bit for those ////////////// - ////////////// who are deriving from this class... ////////////// - //////////////////////////////////////////////////////////////////////// - - IVP12DSystemSimple(const QString & name, const QString & information, const QString & contact_info); - - virtual void systemcreate(StoreGateSvc* detstore);//Optional. - - //If you need a controller - create it and return it from a reimplementation of this method (it will only be called once). - virtual QWidget * buildController(); - - //If some items should be visible for the entire run, reimplement: - virtual void buildPermanentItemCollection(StoreGateSvc* detstore,VP1GraphicsItemCollection*); - - //Reimplement and add the items for a given event, based on the contents of storegate: - virtual void buildEventItemCollection(StoreGateSvc *sg, VP1GraphicsItemCollection*); - - void updateGUI();//Call this occasionally in buildEventSceneGraph(...) to avoid GUI freezing. - - virtual void systemerase();//Optional - for erasing maps etc. with event data. - - virtual void systemuncreate();//Optional. - - //////////////////////////////////////////////////////////////////////// - //////////// The rest of this file is just internal stuff //////////// - //////////// - dont worry about it - //////////// - //////////////////////////////////////////////////////////////////////// - - virtual ~IVP12DSystemSimple(); -private: - IVP12DSystemSimple( const IVP12DSystemSimple & ); - IVP12DSystemSimple & operator= ( const IVP12DSystemSimple & ); - class Imp; - Imp * m_d; - void create(StoreGateSvc* detstore); - void refresh(StoreGateSvc* storegate); - void erase(); - void uncreate(); -}; - -/////////// Inlines ///////////// -inline void IVP12DSystemSimple::updateGUI() { IVP12DSystem::updateGUI(); } - - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/IVP1ChannelWidgetFactory.h b/GeoModelVisualization/VP1Base/VP1Base/IVP1ChannelWidgetFactory.h index dcde843453abdea2e5e55ca5134c656739866308..259d8cc327f9e7a0ab1a11c5a557c94dab1ec3b4 100644 --- a/GeoModelVisualization/VP1Base/VP1Base/IVP1ChannelWidgetFactory.h +++ b/GeoModelVisualization/VP1Base/VP1Base/IVP1ChannelWidgetFactory.h @@ -18,7 +18,6 @@ #include <QtPlugin> class QString; -class QStringList; class IVP1ChannelWidget; class IVP1ChannelWidgetFactory diff --git a/GeoModelVisualization/VP1Base/VP1Base/VP12DExaminerViewer.h b/GeoModelVisualization/VP1Base/VP1Base/VP12DExaminerViewer.h deleted file mode 100644 index 2b93ed308889da71f069e5f7413043bb655d4881..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/VP12DExaminerViewer.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class VP12DExaminerViewer // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// Major update to support multiple views: July 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef VP12DEXAMINERVIEWER_H -#define VP12DEXAMINERVIEWER_H - -#include <QList> -#include <QPair> -#include <QStringList> -#include <QWidget> - -class VP1GraphicsView; - -class VP12DExaminerViewer : public QWidget { - - Q_OBJECT - -public: - - //The choice of constructor will determine whether this view is in single or multi view mode: - - //An examinerviewer with just one VP1GraphicsView: - VP12DExaminerViewer(QWidget * parent = 0, Qt::WindowFlags f = 0); - //An examinerviewer with several VP1GraphicsView's. First argument is a list of view_id's and icon urls for the views: - VP12DExaminerViewer(const QList<QPair<QString,QString> >& views, QWidget * parent = 0, Qt::WindowFlags f = 0); - virtual ~VP12DExaminerViewer(); - - bool isSingleViewMode() const; - - VP1GraphicsView * view() const;//Returns the pointer to the view which is currently shown. - VP1GraphicsView * view(const QString& view_id) const;//Returns pointer to view with a given view_id (0 if view_id not found or single view mode). - QString currentView() const;//Only relevant in multiview mode (returns empty string otherwise) - - //These two return empty stringlists if we are in the mode with just one VP1GraphicsView: - QStringList viewIDs() const; - QList<QPair<QString,QString> > viewIDsAndIconUrls() const; - -public slots: - void setPickMode(); - void setChangeViewMode(); - void setSeekMode(); - void setShownView(QString);//Only relevant in multiview mode - -signals: - void currentViewAboutToChange(VP1GraphicsView*);//Emitted just before the view changes. Parameter is the view which will be shown. - void currentViewChanged();//Just after the view changed. - -private slots: - void changeViewButtonClicked(); -private: - VP12DExaminerViewer( const VP12DExaminerViewer & ); - VP12DExaminerViewer & operator= ( const VP12DExaminerViewer & ); - class Imp; - Imp * m_d; - -}; - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/VP1CollectionWidget.h b/GeoModelVisualization/VP1Base/VP1Base/VP1CollectionWidget.h index 7b40aa28e1487a20e98ba38b8e47d5d276658392..d42f35f9e038d0c83cac7f0bdf0265714bbef04e 100644 --- a/GeoModelVisualization/VP1Base/VP1Base/VP1CollectionWidget.h +++ b/GeoModelVisualization/VP1Base/VP1Base/VP1CollectionWidget.h @@ -20,6 +20,7 @@ #define VP1COLLECTIONWIDGET_H #include "VP1Base/VP1Collection.h" +#include "VP1Base/VP1StdCollection.h" #include "VP1Base/VP1HelperClassBase.h" #include <QWidget> @@ -27,7 +28,6 @@ #include <QString> -class VP1StdCollection; class VP1CollectionWidget : public QWidget, public VP1HelperClassBase { diff --git a/GeoModelVisualization/VP1Base/VP1Base/VP1GraphicsItemCollection.h b/GeoModelVisualization/VP1Base/VP1Base/VP1GraphicsItemCollection.h deleted file mode 100644 index ed6855c302b3a6f75efae2cdc19997b4d7400573..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/VP1GraphicsItemCollection.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class VP1GraphicsItemCollection // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef VP1GRAPHICSITEMCOLLECTION_H -#define VP1GRAPHICSITEMCOLLECTION_H - -//Policy: It is forbidden for systems/channels to install -// eventhandlers or to set flags on QGraphicsItems!!!!! -// -// Each item is marked as either ACTIVE or PASSIVE [+movable] -// (internally an ic knows whether it has any active items at all of -// course). An IC can be in exactly one of the following modes, -// governing how its active items respond (this state is set at -// initialisation by the system and is not changeable later - if so, -// warn if INACTIVE system has active elements and vice versa?): -// -// INERT, SINGLEPICKS, SINGLEEVENTS, SELECTIONS (+UNSET) -// -// It must be set BEFORE a scene is attached for the first time. -// -// Furthermore, each IC has a temporary ignore state, which makes it -// temporarily work (i.e. respond to questions such as "is this item -// presently active") just as if it was inert -// -// -// In graphicsview: Any click or event gets passed to the topmost -// active item in a non-inert system. -// -// If there was a previous selection: -// If the new item is not in the same IC as the previous selection: clear selection. -// Else: If shift was down: Add to selection. Else: Set selection to the new item. -// -// Future: Special selection tool which lets you draw a path and select anything inside it (needs to know which system it is selecting from) -// -// Any change of selection or occurrence of picks/events makes the GV ask the appropriate IC to emit a signal. - -#include <QObject> - -class VP1GraphicsView; -class QGraphicsItem; - -class VP1GraphicsItemCollection : public QObject { - - Q_OBJECT - -public: - - VP1GraphicsItemCollection( QObject * parent=0 ); - virtual ~VP1GraphicsItemCollection(); - - enum INTERACTIONMODE { INERT, SINGLEPICKS, EVENTS, SELECTIONS }; - void setInteractionMode( const INTERACTIONMODE& ); //Can only be called while not attached to a view. - //Default is INERT. - INTERACTIONMODE interactionMode() const; - - void addItem( QGraphicsItem*, const bool& active = false, const bool&movable=false ); - //Beware: All items added will be owned by this class - but if you call removeItem below, you will own them again. - - //The next methods returns false if the item has not been previously added to the collection: - bool setActive(QGraphicsItem*, const bool& active = true); - bool setMovable(QGraphicsItem* item, const bool& movable=true); - bool removeItem(QGraphicsItem*);//Does not delete item. - bool hasItem(QGraphicsItem*) const; - - void clear(const bool& deleteitems = true);//Removes and possibly deletes all items. - - //These two can be called from e.g. the systems to avoid updates during intensive work: - void detachFromView();//If was not attached, do nothing - void reattachToView();//Only does something if it has been previously attached. - bool isAttachedToView(); - - //These three gives the same answer irrespective of the temporary ignore state - int nItems() const; - int nActiveItems() const; - int nMovableItems() const; - //These two always returns 0 if there is a temporary ignore state: - int nPresentlyActiveItems() const; - int nPresentlyMovableItems() const; - - bool itemBelongsAndIsPresentlyActive(QGraphicsItem*) const; - -signals: - void itemPicked(QGraphicsItem*) const;//Emitted for active items when in SINGLEPICK mode. - void itemGotEvent(QGraphicsItem*,QEvent*) const;//Emitted for active items when in EVENTS mode. - void selectionChanged(QList<QGraphicsItem*>) const;//Emitted for active items when in SELECTIONS mode. - -private: - VP1GraphicsItemCollection( const VP1GraphicsItemCollection & ); - VP1GraphicsItemCollection & operator= ( const VP1GraphicsItemCollection & ); - class Imp; - Imp * m_d; -private: - friend class VP1GraphicsView; - void attachToView(VP1GraphicsView*); - void real_detachFromView(); - void setTemporaryIgnoreInteractions( const bool& ); - void setTemporaryIgnoreMovable( const bool& ); - void itemPickedPrivate(QGraphicsItem*) const; - void itemGotEventPrivate(QGraphicsItem*,QEvent*) const; - void selectionChangedPrivate(QList<QGraphicsItem*>) const; -}; - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/VP1GraphicsView.h b/GeoModelVisualization/VP1Base/VP1Base/VP1GraphicsView.h deleted file mode 100644 index 36515a7c27799a115ad4e75d367ef4c0464b707a..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/VP1Base/VP1GraphicsView.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Header file for class VP1GraphicsView // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#ifndef VP1GRAPHICSVIEW_H -#define VP1GRAPHICSVIEW_H - -#include <QGraphicsView> - -class VP1GraphicsItemCollection; - -class VP1GraphicsView : public QGraphicsView { - - Q_OBJECT - -public: - - //////////////////////////////////////////////////////////////////////// - /////////////// This is the interesting bit for those //////////////// - /////////////// who are using this class... //////////////// - //////////////////////////////////////////////////////////////////////// - - VP1GraphicsView ( QWidget * parent = 0 ); - VP1GraphicsView ( QGraphicsScene * scene, QWidget * parent = 0 ); - - //Get interaction mode: - enum Mode { PICK, CHANGEVIEW, SEEK, DRAGZOOM, DRAGZOOMHOLD }; - Mode mode() const; - -public slots: - - //What collections to show: - void addItemCollection(VP1GraphicsItemCollection*); - void removeItemCollection(VP1GraphicsItemCollection*); - - //Set interaction mode for the view: - void setMode(const Mode&); - - //Potentially limit the interactive capabilities of given itemcollections: - void setDisallowInteractions(VP1GraphicsItemCollection*, const bool& disallow=true );//If true, the ic will act as INERT - void setDisallowMovable(VP1GraphicsItemCollection*, const bool& disallow=true );//If true, items will never be movable. - - //Zoom: - void scaleView(qreal scaleFactor); - void fitViewToContents(); - void viewHome(); - void setHome(); - - //Animated zoom: - void initiateAnimatedZoomTo(QRectF); - void setAnimatedZoomSteps(int); - void setAnimatedZoomTime(double);//ms - void setZoomFactorOnSeek(double); - void abortZoomAnimation(); - void seekToPoint(QPointF); - - //Selections: - void clearSelections(); - - //Print: - void print(); - void saveImage(); - - //////////////////////////////////////////////////////////////////////// - //////////// The rest of this file is just internal stuff //////////// - //////////// - dont worry about it - //////////// - //////////////////////////////////////////////////////////////////////// - -public: - virtual ~VP1GraphicsView(); - -protected: - void keyPressEvent(QKeyEvent *); - void wheelEvent(QWheelEvent *); - void mouseDoubleClickEvent(QMouseEvent * event); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void drawItems(QPainter *painter, int numItems, - QGraphicsItem *items[], - const QStyleOptionGraphicsItem options[]); - void drawForeground ( QPainter * painter, const QRectF & rect ); -private: - - class Imp; - Imp * m_d; - class HighLightItem; - friend class HighLightItem; - void emitSelectionChanged(VP1GraphicsItemCollection*); - -private slots: - void updateZoomAnimation(); -}; - -#endif diff --git a/GeoModelVisualization/VP1Base/VP1Base/VP1TabWidget.h b/GeoModelVisualization/VP1Base/VP1Base/VP1TabWidget.h index 072f011b9144012d9f859ebfc9c959810ec2452d..29b47160dc448a34765690f5f8204857e097d51c 100644 --- a/GeoModelVisualization/VP1Base/VP1Base/VP1TabWidget.h +++ b/GeoModelVisualization/VP1Base/VP1Base/VP1TabWidget.h @@ -52,7 +52,7 @@ class VP1TabWidget : public QTabWidget VP1TabBar* getVP1TabBar();//Added by TK. - explicit VP1TabWidget( QWidget *parent = 0, Qt::WindowFlags flags = 0 ); + explicit VP1TabWidget( QWidget *parent = 0, Qt::WindowFlags flags = Qt::Widget ); virtual ~VP1TabWidget(); diff --git a/GeoModelVisualization/VP1Base/src/IVP12DDetViewsChannelWidget.cxx b/GeoModelVisualization/VP1Base/src/IVP12DDetViewsChannelWidget.cxx deleted file mode 100644 index c36401a592b0e728a267ed83e4b973e1ebc62d50..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/IVP12DDetViewsChannelWidget.cxx +++ /dev/null @@ -1,387 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class IVP12DDetViewsChannelWidget // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: July 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/IVP12DDetViewsChannelWidget.h" - -#include "VP1Base/IVP12DSystem.h" -#include "VP1Base/IVP12DDetViewsSystem.h" -#include "VP1Base/VP1Msg.h" - -#include "VP1Base/VP1GraphicsItemCollection.h" -#include "VP1Base/VP1GraphicsView.h" -#include "VP1Base/VP12DExaminerViewer.h" -#include "VP1Base/VP1TabWidget.h" - -#include "VP1Base/VP1ControllerHelper.h" -#include "VP1Base/VP1ColorSelectButton.h" - -#include <QCheckBox> -#include <QGraphicsScene> -#include <QVBoxLayout> -#include <QByteArray> -#include <QBuffer> -#include <QMap> - -#include <cassert> - - -class IVP12DDetViewsChannelWidget::Imp { -public: - IVP12DDetViewsChannelWidget*channel; - VP1GraphicsView * view_xy; - VP1GraphicsView * view_rz; - bool first; - - QMap<IVP12DSystem*,QSet<VP1GraphicsItemCollection*> > system2itemcols; - - QMap<QCheckBox*,IVP1System*> checkbox2system; - QList<IVP1System*> systemsAllowedControllers; - QList<QPair<IVP1System*,bool> > system2switchable; - QMap<IVP1System*,bool> system2startdisabled; - - void updateSystemState(QCheckBox*); - - QMap<IVP1System*,QWidget*> sys2tabpage; - VP1TabWidget*tabwidget; - - VP1ColorSelectButton * colorselectbutton; -}; - -//___________________________________________________________________________ -IVP12DDetViewsChannelWidget::IVP12DDetViewsChannelWidget(const QString & name, const QString & information, const QString & contact_info) - : IVP1ChannelWidget(name,information,contact_info), m_d(new Imp()) -{ - m_d->channel=this; - m_d->first=true; - setMinimumSize(150,240);//minimum y size is to avoid absurd squeezing of buttons. - - //Tight layout: - QVBoxLayout * vboxLayout = new QVBoxLayout(this); - vboxLayout->setSpacing(0); - vboxLayout->setMargin(0); - - //Setup examiner viewer: - QList<QPair<QString,QString> > views; - views << QPair<QString,QString>("X-Y",":/icons/icons/xy.png"); - views << QPair<QString,QString>("R-Z",":/icons/icons/rz.png"); - VP12DExaminerViewer * examiner = new VP12DExaminerViewer(views, this); - - vboxLayout->addWidget(examiner); - - //Get pointers to the different views: - m_d->view_xy = examiner->view("X-Y"); - m_d->view_rz = examiner->view("R-Z"); - assert(m_d->view_xy&&m_d->view_rz); - - m_d->tabwidget = 0; - m_d->colorselectbutton = 0; -} - -//___________________________________________________________________________ -IVP12DDetViewsChannelWidget::~IVP12DDetViewsChannelWidget() -{ - delete m_d; -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::addSystem( IVP12DDetViewsSystem*system, double /*zfactor*/, const SystemOptions& options ) { - - //Apart from the attachment of ic's to view's, this method is quite similar to the ones in addGeneralSystem - bool handleSelections = ! (options & DisallowSelections); - bool switchable = ! (options & DisallowSwitchable); - bool allowController = ! (options & DisallowController); - bool allowMovable = ! (options & DisallowMovable); - bool startDisabled = (options & StartDisabled); - - registerSystem(system); - - //Fixme: Attach to the relevant view instead. - assert(!m_d->system2itemcols.contains(system)); - - m_d->system2itemcols.insert(system,system->getItemCollections_XY()+system->getItemCollections_RZ()); - - foreach (VP1GraphicsItemCollection*ic,system->getItemCollections_XY()) - m_d->view_xy->addItemCollection(ic); - foreach (VP1GraphicsItemCollection*ic,system->getItemCollections_RZ()) - m_d->view_rz->addItemCollection(ic); - - foreach (VP1GraphicsItemCollection* ic,system->getItemCollections_XY()) - m_d->view_xy->setDisallowInteractions(ic, !handleSelections ); - foreach (VP1GraphicsItemCollection* ic,system->getItemCollections_RZ()) - m_d->view_rz->setDisallowInteractions(ic, !handleSelections ); - - foreach (VP1GraphicsItemCollection* ic,system->getItemCollections_XY()) - m_d->view_xy->setDisallowMovable(ic, !allowMovable ); - foreach (VP1GraphicsItemCollection* ic,system->getItemCollections_RZ()) - m_d->view_rz->setDisallowMovable(ic, !allowMovable ); - - m_d->system2switchable << QPair<IVP1System*,bool>(system,switchable); - - assert(!m_d->system2startdisabled.contains(system)); - m_d->system2startdisabled.insert(system,startDisabled); - assert(m_d->system2startdisabled.contains(system)); - - if (allowController) { - m_d->systemsAllowedControllers << system; - connect(system,SIGNAL(itemFromSystemSelected()),this,SLOT(showControlsForSystem())); - } - -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::create() { - //Fixme: Less code should be replicated here and in IVP12DStandardChannelWidget+IVP13DStandardChannelWidget. - - //Set up the controller. - registerController(VP1ControllerHelper::compositionController( m_d->systemsAllowedControllers, - m_d->sys2tabpage,m_d->tabwidget, - m_d->system2switchable, - m_d->checkbox2system, - m_d->colorselectbutton )); - connect(m_d->colorselectbutton,SIGNAL(colorChanged(const QColor&)),this,SLOT(setBackgroundColor(const QColor&))); - m_d->system2switchable.clear(); - - QMapIterator<QCheckBox*,IVP1System*> it(m_d->checkbox2system); - while (it.hasNext()) { - it.next(); - - assert(m_d->system2startdisabled.contains(it.value())); - if (m_d->system2startdisabled[it.value()]) { - it.key()->setChecked(false); - m_d->updateSystemState(it.key()); - } - - connect(it.key(),SIGNAL(toggled(bool)),this,SLOT(toggleSystemActive())); - } -} - - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::systemRefreshed(IVP1System*) { - if (m_d->first) { - //This is not perfect, but usually it gives acceptable results. - //Todo: An improvement would be to keep track of the first time - //separately, and then only call fitViewToContents on the views - //where this system provides collections. - m_d->view_xy->fitViewToContents(); - m_d->view_rz->fitViewToContents(); - m_d->first=false; - } -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::systemErased(IVP1System*) { - m_d->view_xy->clearSelections(); - m_d->view_rz->clearSelections(); -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::toggleSystemActive() -{ - QCheckBox * cb = static_cast<QCheckBox*>(sender()); assert(cb); - m_d->updateSystemState(cb); -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::Imp::updateSystemState(QCheckBox* cb) -{ - assert(checkbox2system.contains(cb)); - IVP12DSystem*sys = static_cast<IVP12DSystem*>(checkbox2system.value(cb)); assert(sys); - - assert(system2itemcols.contains(sys)); - if (cb->isChecked()) { - channel->turnOn(sys); - foreach(VP1GraphicsItemCollection*ic,system2itemcols.value(sys)) { - ic->reattachToView(); - } - if (tabwidget&&sys2tabpage.contains(sys)) { - int sysindex = systemsAllowedControllers.indexOf(sys); - if (sysindex>=0) { - IVP1System*nextsystem(0); - for (int i=sysindex+1;i<systemsAllowedControllers.count();++i) { - //Loop through latter systems with controllers in order and - //find the first of those which currently has an active - //controller: - IVP1System* testsys = systemsAllowedControllers.at(i); - if (sys2tabpage.contains(testsys)&&tabwidget->indexOf(sys2tabpage[testsys])>-1) { - nextsystem=testsys; - break; - } - } - //put before tab of "nextsystem" (or at the end if no nextsystem): - int index = (nextsystem?tabwidget->indexOf(sys2tabpage[nextsystem]):99999); - tabwidget->insertTab(index,sys2tabpage[sys],sys->name()); - int index2 = tabwidget->indexOf(sys2tabpage[sys]); - if (index2!=-1) { - tabwidget->setTabEnabled(index2,true); - } - } - } - } else { - //Fixme: if system being turned off has selections, we should deselect!! - channel->turnOff(sys,false); - foreach(VP1GraphicsItemCollection*ic,system2itemcols.value(sys)) { - ic->detachFromView(); - } - if (tabwidget&&sys2tabpage.contains(sys)) { - int index = tabwidget->indexOf(sys2tabpage[sys]); - if (index!=-1) { - tabwidget->setTabEnabled(index,false); - tabwidget->removeTab(index); - } - } - } - - view_xy->scene()->update(); - view_rz->scene()->update(); - -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::addGeneralSystem(IVP12DSystem*, const PROJECTION& /*projection*/, double /*zfactor*/, const SystemOptions& /*options*/ ) -{ - message("IVP12DDetViewsChannelWidget::addGeneralSystem ERROR: Method not implemented yet!!");//fixme -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::setBackgroundColor(const QColor & col) -{ - if (!col.isValid()) - return; - m_d->view_xy->setBackgroundBrush(col); - m_d->view_rz->setBackgroundBrush(col); -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::showControlsForSystem( ) -{ - if (!m_d->tabwidget) - return; - IVP1System * sys = static_cast<IVP1System*>(sender()); - if (!sys) { - message("showControlsForSystem Error: Unable to determine system identity."); - return; - } - if (!m_d->sys2tabpage.contains(sys)) { - //Dont send warning here. The system in question might simply not have a controller! - return; - } - - int index = m_d->tabwidget->indexOf(m_d->sys2tabpage[sys]); - if (index<0||!m_d->tabwidget->isTabEnabled(index)) { - message("Warning: Asked to show controller for a disabled system. Surely you jest?"); - return; - } - m_d->tabwidget->setCurrentIndex(index); -} - -//___________________________________________________________________________ -QByteArray IVP12DDetViewsChannelWidget::saveState() -{ - VP1Msg::messageVerbose("IVP12DDetViewsChannelWidget::saveState"); - // ===> Setup stream writing to a byteArray: - QByteArray byteArray; - QBuffer buffer(&byteArray); - buffer.open(QIODevice::WriteOnly); - QDataStream out(&buffer); - - // ===> Write Data: - - //Version & base state: - out << (qint32)0; //version - out << IVP1ChannelWidget::saveState();//Always include state info from the base class. - - //Background color: - out << m_d->colorselectbutton->color(); - - //Systems turned on/off: - //Fixme: Make sure that if you have two copies of the same system, - //that the text in the checkbox gets appended some stuff like [1], - //[2], etc., so that the strings used here will be unique. - QMap<QString, bool> sysname2turnedon; - QMap<QCheckBox*,IVP1System*>::const_iterator it = m_d->checkbox2system.constBegin(); - while (it != m_d->checkbox2system.constEnd()) { - sysname2turnedon.insert(it.key()->text(),it.key()->isChecked()); - ++it; - } - - out << sysname2turnedon; - - //Current system tab: - if (m_d->tabwidget) - out << m_d->tabwidget->tabText(m_d->tabwidget->currentIndex()); - else - out << QString(""); - - // ===> Finish up: - buffer.close(); - return byteArray; -} - -//___________________________________________________________________________ -void IVP12DDetViewsChannelWidget::restoreFromState(QByteArray ba) -{ - VP1Msg::messageVerbose("IVP12DDetViewsChannelWidget::restoreFromState"); - - // ===> Setup stream for getting the contents of the byteArray: - QBuffer buffer(&ba); - buffer.open(QIODevice::ReadOnly); - QDataStream state(&buffer); - // ===> Check version and pass on state info to base class: - qint32 version; - state >> version; - if (version!=0) { - message("Warning: State data in .vp1 file is in wrong format - ignoring!"); - return; - } - QByteArray basestate; - state >> basestate; - IVP1ChannelWidget::restoreFromState(basestate); - // ===> Decode the state info: - - QColor bgdcol; - state >> bgdcol; - if (bgdcol!=m_d->colorselectbutton->color()) - m_d->colorselectbutton->setColor(bgdcol); - setBackgroundColor(bgdcol); - - //Switch systems on/off: - QMap<QString, bool> sysname2turnedon; - state >> sysname2turnedon; - QMap<QCheckBox*,IVP1System*>::const_iterator it = m_d->checkbox2system.constBegin(); - while (it != m_d->checkbox2system.constEnd()) { - if (sysname2turnedon.contains(it.key()->text())) { - if (sysname2turnedon[it.key()->text()]!=it.key()->isChecked()) - it.key()->setChecked(sysname2turnedon[it.key()->text()]); - } else { - message("Warning: Config data does not contain information about switched state of subsystem '"+it.key()->text()+"'"); - } - ++it; - } - - //Current system tab - QString tabname; - state >> tabname; - if (m_d->tabwidget) { - for (int i = 0; i < m_d->tabwidget->count(); ++i) { - if (m_d->tabwidget->tabText(i) == tabname) { - m_d->tabwidget->setCurrentIndex(i); - break; - } - } - } - - // ===> Finish up: - buffer.close(); -} diff --git a/GeoModelVisualization/VP1Base/src/IVP12DDetViewsSystem.cxx b/GeoModelVisualization/VP1Base/src/IVP12DDetViewsSystem.cxx deleted file mode 100644 index 70de6fe20a8771fa4a68f3398c48f5366b0031df..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/IVP12DDetViewsSystem.cxx +++ /dev/null @@ -1,172 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class IVP12DDetViewsSystem // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: July 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/IVP12DDetViewsSystem.h" -#include "VP1Base/VP1GraphicsItemCollection.h" -#include <cassert> - -void IVP12DDetViewsSystem::systemcreate(StoreGateSvc*) {} -QWidget * IVP12DDetViewsSystem::buildController() { return 0; } -void IVP12DDetViewsSystem::buildPermanentItemCollections(StoreGateSvc*,VP1GraphicsItemCollection*, - VP1GraphicsItemCollection*){} -void IVP12DDetViewsSystem::buildEventItemCollections(StoreGateSvc*,VP1GraphicsItemCollection*, - VP1GraphicsItemCollection*){} -void IVP12DDetViewsSystem::systemuncreate() {} -void IVP12DDetViewsSystem::systemerase() {} - -//____________________________________________________________________ -class IVP12DDetViewsSystem::Imp { -public: - VP1GraphicsItemCollection* itemcollectionPermanent_xy; - VP1GraphicsItemCollection* itemcollectionPermanent_rz; - VP1GraphicsItemCollection* itemcollectionEvent_xy; - VP1GraphicsItemCollection* itemcollectionEvent_rz; - bool wasrefreshed; - bool wascreated; -}; - -//____________________________________________________________________ -IVP12DDetViewsSystem::IVP12DDetViewsSystem(const QString & name, const QString & information, const QString & contact_info) - : IVP12DSystem(name,information,contact_info), m_d(new Imp) -{ - m_d->itemcollectionPermanent_xy = new VP1GraphicsItemCollection(this); - m_d->itemcollectionPermanent_rz = new VP1GraphicsItemCollection(this); - m_d->itemcollectionEvent_xy = new VP1GraphicsItemCollection(this); - m_d->itemcollectionEvent_rz = new VP1GraphicsItemCollection(this); - - registerItemCollection(m_d->itemcollectionPermanent_xy); - registerItemCollection(m_d->itemcollectionPermanent_rz); - registerItemCollection(m_d->itemcollectionEvent_xy); - registerItemCollection(m_d->itemcollectionEvent_rz); - - m_d->wasrefreshed=false; - m_d->wascreated=false; -} - -//____________________________________________________________________ -IVP12DDetViewsSystem::~IVP12DDetViewsSystem() -{ - delete m_d; m_d=0; -} - -//____________________________________________________________________ -void IVP12DDetViewsSystem::create(StoreGateSvc* detstore) -{ - assert(!m_d->wascreated); - systemcreate(detstore); - - QWidget * controller = buildController(); - if (controller) - registerController(controller); - - bool hasview_xy = m_d->itemcollectionPermanent_xy->isAttachedToView(); - if (hasview_xy) - m_d->itemcollectionPermanent_xy->detachFromView(); - bool hasview_rz = m_d->itemcollectionPermanent_rz->isAttachedToView(); - if (hasview_rz) - m_d->itemcollectionPermanent_rz->detachFromView(); - - buildPermanentItemCollections(detstore, - m_d->itemcollectionPermanent_xy, - m_d->itemcollectionPermanent_rz ); - - if (hasview_xy) - m_d->itemcollectionPermanent_xy->reattachToView(); - if (hasview_rz) - m_d->itemcollectionPermanent_rz->reattachToView(); - - m_d->wascreated=true; -} - -//____________________________________________________________________ -void IVP12DDetViewsSystem::refresh(StoreGateSvc* sg) -{ - assert(m_d->wascreated); - assert(!m_d->wasrefreshed); - - bool hasview_xy = m_d->itemcollectionEvent_xy->isAttachedToView(); - if (hasview_xy) - m_d->itemcollectionEvent_xy->detachFromView(); - updateGUI(); - bool hasview_rz = m_d->itemcollectionEvent_rz->isAttachedToView(); - if (hasview_rz) - m_d->itemcollectionEvent_rz->detachFromView(); - updateGUI(); - - buildEventItemCollections( sg, - m_d->itemcollectionEvent_xy, - m_d->itemcollectionEvent_rz ); - - updateGUI(); - if (hasview_xy) - m_d->itemcollectionEvent_xy->reattachToView(); - updateGUI(); - if (hasview_rz) - m_d->itemcollectionEvent_rz->reattachToView(); - - m_d->wasrefreshed=true; -} - -//____________________________________________________________________ -void IVP12DDetViewsSystem::erase() -{ - assert(m_d->wascreated); - assert(m_d->wasrefreshed); - systemerase(); - m_d->itemcollectionEvent_xy->clear(); - m_d->itemcollectionEvent_rz->clear(); - m_d->wasrefreshed=false; -} - -//____________________________________________________________________ -void IVP12DDetViewsSystem::uncreate() -{ - messageDebug("uncreate()..."); - - assert(m_d->wascreated); - assert(!m_d->wasrefreshed); - - if (m_d->itemcollectionEvent_xy->isAttachedToView()) - m_d->itemcollectionEvent_xy->detachFromView(); - if (m_d->itemcollectionEvent_rz->isAttachedToView()) - m_d->itemcollectionEvent_rz->detachFromView(); - - if (m_d->itemcollectionPermanent_xy->isAttachedToView()) - m_d->itemcollectionPermanent_xy->detachFromView(); - if (m_d->itemcollectionPermanent_rz->isAttachedToView()) - m_d->itemcollectionPermanent_rz->detachFromView(); - - systemuncreate(); - m_d->itemcollectionPermanent_xy->clear(); - m_d->itemcollectionPermanent_rz->clear(); - m_d->wascreated=false; -} - -//____________________________________________________________________ -QSet<VP1GraphicsItemCollection*> IVP12DDetViewsSystem::getItemCollections_XY() const -{ - QSet<VP1GraphicsItemCollection*> l; - l << m_d->itemcollectionPermanent_xy; - l << m_d->itemcollectionEvent_xy; - return l; -} - -//____________________________________________________________________ -QSet<VP1GraphicsItemCollection*> IVP12DDetViewsSystem::getItemCollections_RZ() const -{ - QSet<VP1GraphicsItemCollection*> l; - l << m_d->itemcollectionPermanent_rz; - l << m_d->itemcollectionEvent_rz; - return l; -} diff --git a/GeoModelVisualization/VP1Base/src/IVP12DStandardChannelWidget.cxx b/GeoModelVisualization/VP1Base/src/IVP12DStandardChannelWidget.cxx deleted file mode 100644 index 3be196558f6ed3df92845e041b1340fa6123a8ab..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/IVP12DStandardChannelWidget.cxx +++ /dev/null @@ -1,359 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class IVP12DStandardChannelWidget // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/IVP12DStandardChannelWidget.h" -#include "VP1Base/IVP12DSystem.h" -#include "VP1Base/IVP12DSystemSimple.h" -#include "VP1Base/VP1GraphicsItemCollection.h" -#include "VP1Base/VP1GraphicsView.h" -#include "VP1Base/VP12DExaminerViewer.h" -#include "VP1Base/VP1TabWidget.h" -#include "VP1Base/VP1ControllerHelper.h" -#include "VP1Base/VP1ColorSelectButton.h" -#include "VP1Base/VP1Msg.h" - -#include <QVBoxLayout> -#include <QGraphicsScene> -#include <QCheckBox> -#include <QMap> -#include <QBuffer> -#include <QByteArray> - - -#include <cassert> - - -class IVP12DStandardChannelWidget::Imp { -public: - IVP12DStandardChannelWidget*channel; - VP1GraphicsView * view; - bool first; - QMap<IVP12DSystem*,QSet<VP1GraphicsItemCollection*> > system2itemcols; - - QMap<QCheckBox*,IVP1System*> checkbox2system; - QList<IVP1System*> systemsAllowedControllers; - QList<QPair<IVP1System*,bool> > system2switchable; - QMap<IVP1System*,bool> system2startdisabled; - - void updateSystemState(QCheckBox*); - - QMap<IVP1System*,QWidget*> sys2tabpage; - VP1TabWidget*tabwidget; - - VP1ColorSelectButton * colorselectbutton; - -}; - -//___________________________________________________________________________ -IVP12DStandardChannelWidget::IVP12DStandardChannelWidget(const QString & name, const QString & information, const QString & contact_info) - : IVP1ChannelWidget(name,information,contact_info), m_d(new Imp()) -{ - m_d->channel=this; - m_d->first=true; - setMinimumSize(150,240);//minimum y size is to avoid absurd squeezing of buttons. - - QVBoxLayout * vboxLayout = new QVBoxLayout(this); - vboxLayout->setSpacing(0); - vboxLayout->setMargin(0); - VP12DExaminerViewer * examiner = new VP12DExaminerViewer(this); - vboxLayout->addWidget(examiner); - m_d->colorselectbutton = 0; - - m_d->view = examiner->view(); - - m_d->tabwidget = 0; -} - -//___________________________________________________________________________ -IVP12DStandardChannelWidget::~IVP12DStandardChannelWidget() -{ - delete m_d; -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::addSystem( IVP12DSystem*system, const SystemOptions& options ) { - - bool handleSelections = ! (options & DisallowSelections); - bool switchable = ! (options & DisallowSwitchable); - bool allowController = ! (options & DisallowController); - bool allowMovable = ! (options & DisallowMovable); - bool startDisabled = (options & StartDisabled); - - registerSystem(system); - - assert(!m_d->system2itemcols.contains(system)); - m_d->system2itemcols.insert(system,system->getItemCollections()); - foreach (VP1GraphicsItemCollection*ic,system->getItemCollections()) { - m_d->view->addItemCollection(ic); - } - - foreach (VP1GraphicsItemCollection* ic,system->getItemCollections()){ - m_d->view->setDisallowInteractions(ic, !handleSelections ); - } - foreach (VP1GraphicsItemCollection* ic,system->getItemCollections()){ - m_d->view->setDisallowMovable(ic, !allowMovable ); - } - - m_d->system2switchable << QPair<IVP1System*,bool>(system,switchable); - - assert(!m_d->system2startdisabled.contains(system)); - m_d->system2startdisabled.insert(system,startDisabled); - assert(m_d->system2startdisabled.contains(system)); - - if (allowController) { - m_d->systemsAllowedControllers << system; - connect(system,SIGNAL(itemFromSystemSelected()),this,SLOT(showControlsForSystem())); - } -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::create() { - //Fixme: Less code should be replicated here and in IVP13DStandardChannelWidget+IVP12DDetViewsChannelWidget - - //Set up the controller. - registerController(VP1ControllerHelper::compositionController( m_d->systemsAllowedControllers, - m_d->sys2tabpage,m_d->tabwidget, - m_d->system2switchable, - m_d->checkbox2system, - m_d->colorselectbutton )); - connect(m_d->colorselectbutton,SIGNAL(colorChanged(const QColor&)),this,SLOT(setBackgroundColor(const QColor&))); - m_d->system2switchable.clear(); - - QMapIterator<QCheckBox*,IVP1System*> it(m_d->checkbox2system); - while (it.hasNext()) { - it.next(); - - assert(m_d->system2startdisabled.contains(it.value())); - if (m_d->system2startdisabled[it.value()]) { - it.key()->setChecked(false); - m_d->updateSystemState(it.key()); - } - - connect(it.key(),SIGNAL(toggled(bool)),this,SLOT(toggleSystemActive())); - } -} - - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::systemRefreshed(IVP1System*) { - if (m_d->first) { - m_d->view->fitViewToContents(); - m_d->first=false; - } -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::systemErased(IVP1System*) { - m_d->view->clearSelections(); -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::toggleSystemActive() -{ - QCheckBox * cb = static_cast<QCheckBox*>(sender()); assert(cb); - m_d->updateSystemState(cb); -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::Imp::updateSystemState(QCheckBox* cb) -{ - assert(checkbox2system.contains(cb)); - IVP12DSystem*sys = static_cast<IVP12DSystem*>(checkbox2system.value(cb)); assert(sys); - - assert(system2itemcols.contains(sys)); - if (cb->isChecked()) { - channel->turnOn(sys); - foreach(VP1GraphicsItemCollection*ic,system2itemcols.value(sys)) { - ic->reattachToView(); - } - if (tabwidget&&sys2tabpage.contains(sys)) { - int sysindex = systemsAllowedControllers.indexOf(sys); - if (sysindex>=0) { - IVP1System*nextsystem(0); - for (int i=sysindex+1;i<systemsAllowedControllers.count();++i) { - //Loop through latter systems with controllers in order and - //find the first of those which currently has an active - //controller: - IVP1System* testsys = systemsAllowedControllers.at(i); - if (sys2tabpage.contains(testsys)&&tabwidget->indexOf(sys2tabpage[testsys])>-1) { - nextsystem=testsys; - break; - } - } - //put before tab of "nextsystem" (or at the end if no nextsystem): - int index = (nextsystem?tabwidget->indexOf(sys2tabpage[nextsystem]):99999); - tabwidget->insertTab(index,sys2tabpage[sys],sys->name()); - int index2 = tabwidget->indexOf(sys2tabpage[sys]); - if (index2!=-1) { - tabwidget->setTabEnabled(index2,true); - } - } - } - } else { - //Fixme: if system being turned off has selections, we should deselect!! - channel->turnOff(sys,false); - foreach(VP1GraphicsItemCollection*ic,system2itemcols.value(sys)) { - ic->detachFromView(); - } - if (tabwidget&&sys2tabpage.contains(sys)) { - int index = tabwidget->indexOf(sys2tabpage[sys]); - if (index!=-1) { - tabwidget->setTabEnabled(index,false); - tabwidget->removeTab(index); - } - } - } - - view->scene()->update(); - -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::addSystem(IVP12DSystemSimple* sys, const SystemOptions& options ) -{ - addSystem((IVP12DSystem*)sys,options); -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::setBackgroundColor(const QColor & col) -{ - if (!col.isValid()) - return; - m_d->view->setBackgroundBrush(col); -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::showControlsForSystem( ) -{ - if (!m_d->tabwidget) - return; - IVP1System * sys = static_cast<IVP1System*>(sender()); - if (!sys) { - message("showControlsForSystem Error: Unable to determine system identity."); - return; - } - if (!m_d->sys2tabpage.contains(sys)) { - //Dont send warning here. The system in question might simply not have a controller! - return; - } - - int index = m_d->tabwidget->indexOf(m_d->sys2tabpage[sys]); - if (index<0||!m_d->tabwidget->isTabEnabled(index)) { - message("Warning: Asked to show controller for a disabled system. Surely you jest?"); - return; - } - - m_d->tabwidget->setCurrentIndex(index); -} - - -//___________________________________________________________________________ -QByteArray IVP12DStandardChannelWidget::saveState() -{ - VP1Msg::messageVerbose("IVP12DStandardChannelWidget::saveState"); - // ===> Setup stream writing to a byteArray: - QByteArray byteArray; - QBuffer buffer(&byteArray); - buffer.open(QIODevice::WriteOnly); - QDataStream out(&buffer); - - // ===> Write Data: - - //Version & base state: - out << (qint32)0; //version - out << IVP1ChannelWidget::saveState();//Always include state info from the base class. - - //Background color: - out << m_d->colorselectbutton->color(); - - //Systems turned on/off: - //Fixme: Make sure that if you have two copies of the same system, - //that the text in the checkbox gets appended some stuff like [1], - //[2], etc., so that the strings used here will be unique. - QMap<QString, bool> sysname2turnedon; - QMap<QCheckBox*,IVP1System*>::const_iterator it = m_d->checkbox2system.constBegin(); - while (it != m_d->checkbox2system.constEnd()) { - sysname2turnedon.insert(it.key()->text(),it.key()->isChecked()); - ++it; - } - - out << sysname2turnedon; - - //Current system tab: - if (m_d->tabwidget) - out << m_d->tabwidget->tabText(m_d->tabwidget->currentIndex()); - else - out << QString(""); - - // ===> Finish up: - buffer.close(); - return byteArray; -} - -//___________________________________________________________________________ -void IVP12DStandardChannelWidget::restoreFromState(QByteArray ba) -{ - VP1Msg::messageVerbose("IVP12DStandardChannelWidget::restoreFromState"); - - // ===> Setup stream for getting the contents of the byteArray: - QBuffer buffer(&ba); - buffer.open(QIODevice::ReadOnly); - QDataStream state(&buffer); - // ===> Check version and pass on state info to base class: - qint32 version; - state >> version; - if (version!=0) { - message("Warning: State data in .vp1 file is in wrong format - ignoring!"); - return; - } - QByteArray basestate; - state >> basestate; - IVP1ChannelWidget::restoreFromState(basestate); - // ===> Decode the state info: - - QColor bgdcol; - state >> bgdcol; - if (bgdcol!=m_d->colorselectbutton->color()) - m_d->colorselectbutton->setColor(bgdcol); - setBackgroundColor(bgdcol); - - //Switch systems on/off: - QMap<QString, bool> sysname2turnedon; - state >> sysname2turnedon; - QMap<QCheckBox*,IVP1System*>::const_iterator it = m_d->checkbox2system.constBegin(); - while (it != m_d->checkbox2system.constEnd()) { - if (sysname2turnedon.contains(it.key()->text())) { - if (sysname2turnedon[it.key()->text()]!=it.key()->isChecked()) - it.key()->setChecked(sysname2turnedon[it.key()->text()]); - } else { - message("Warning: Config data does not contain information about switched state of subsystem '"+it.key()->text()+"'"); - } - ++it; - } - - //Current system tab - QString tabname; - state >> tabname; - if (m_d->tabwidget) { - for (int i = 0; i < m_d->tabwidget->count(); ++i) { - if (m_d->tabwidget->tabText(i) == tabname) { - m_d->tabwidget->setCurrentIndex(i); - break; - } - } - } - - // ===> Finish up: - buffer.close(); -} diff --git a/GeoModelVisualization/VP1Base/src/IVP12DSystem.cxx b/GeoModelVisualization/VP1Base/src/IVP12DSystem.cxx deleted file mode 100644 index b7358070117b597c713c390bdc3489d6f0ebdd3a..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/IVP12DSystem.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class IVP12DSystem // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/IVP12DSystem.h" -#include "VP1Base/VP1GraphicsItemCollection.h" -#include <cassert> - -//Default implementations that do not do anything: -void IVP12DSystem::itemPicked(VP1GraphicsItemCollection*,QGraphicsItem*) {} -void IVP12DSystem::itemGotEvent(VP1GraphicsItemCollection*,QGraphicsItem*,QEvent*) {} -void IVP12DSystem::selectionChanged(VP1GraphicsItemCollection*,QList<QGraphicsItem*>) {} - -//____________________________________________________________________ -class IVP12DSystem::Imp { -public: - QSet<VP1GraphicsItemCollection*> collections; -}; - - -//____________________________________________________________________ -IVP12DSystem::IVP12DSystem(const QString & name, const QString & information, const QString & contact_info) - : IVP1System(name,information,contact_info), m_d(new Imp) -{ -} - -//____________________________________________________________________ -IVP12DSystem::~IVP12DSystem() -{ - delete m_d; m_d=0; -} - -//____________________________________________________________________ -void IVP12DSystem::registerItemCollection(VP1GraphicsItemCollection*ic) -{ - assert(!m_d->collections.contains(ic) - &&"IVP12DSystem::registerItemCollection Error: Item collection registered twice"); - m_d->collections<<ic; - connect(ic,SIGNAL(itemPicked(QGraphicsItem*)),this,SLOT(itemPickedPrivate(QGraphicsItem*))); - connect(ic,SIGNAL(itemGotEvent(QGraphicsItem*,QEvent*)),this,SLOT(itemGotEventPrivate(QGraphicsItem*,QEvent*))); - connect(ic,SIGNAL(selectionChanged(QList<QGraphicsItem*>)),this,SLOT(selectionChangedPrivate(QList<QGraphicsItem*>))); -} - -//____________________________________________________________________ -QSet<VP1GraphicsItemCollection*> IVP12DSystem::getItemCollections() -{ - return m_d->collections; -} - -//____________________________________________________________________ -void IVP12DSystem::itemPickedPrivate(QGraphicsItem*item) -{ - VP1GraphicsItemCollection * ic = static_cast<VP1GraphicsItemCollection*>(sender()); - assert(ic&&ic->interactionMode()==VP1GraphicsItemCollection::SINGLEPICKS); - itemPicked(ic,item); - itemFromSystemSelected(); -} - -//____________________________________________________________________ -void IVP12DSystem::itemGotEventPrivate(QGraphicsItem*item,QEvent*event) -{ - VP1GraphicsItemCollection * ic = static_cast<VP1GraphicsItemCollection*>(sender()); - assert(ic&&ic->interactionMode()==VP1GraphicsItemCollection::EVENTS); - itemGotEvent(ic,item,event); - itemFromSystemSelected(); -} - -//____________________________________________________________________ -void IVP12DSystem::selectionChangedPrivate(QList<QGraphicsItem*> items) -{ - VP1GraphicsItemCollection * ic = static_cast<VP1GraphicsItemCollection*>(sender()); - assert(ic&&ic->interactionMode()==VP1GraphicsItemCollection::SELECTIONS); - selectionChanged(ic,items); - itemFromSystemSelected(); -} diff --git a/GeoModelVisualization/VP1Base/src/IVP12DSystemSimple.cxx b/GeoModelVisualization/VP1Base/src/IVP12DSystemSimple.cxx deleted file mode 100644 index 3510522b7b1339721a507c41f37f8e83d46c2831..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/IVP12DSystemSimple.cxx +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class IVP12DSystemSimple // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/IVP12DSystemSimple.h" -#include "VP1Base/VP1GraphicsItemCollection.h" -#include <cassert> - -void IVP12DSystemSimple::systemcreate(StoreGateSvc*) {} -QWidget * IVP12DSystemSimple::buildController() { return 0; } -void IVP12DSystemSimple::buildPermanentItemCollection(StoreGateSvc*,VP1GraphicsItemCollection*){} -void IVP12DSystemSimple::buildEventItemCollection(StoreGateSvc *, VP1GraphicsItemCollection*) {} -void IVP12DSystemSimple::systemuncreate() {} -void IVP12DSystemSimple::systemerase() {} - -//____________________________________________________________________ -class IVP12DSystemSimple::Imp { -public: - VP1GraphicsItemCollection* itemcollectionPermanent; - VP1GraphicsItemCollection* itemcollectionEvent; - bool wasrefreshed; - bool wascreated; -}; - -//____________________________________________________________________ -IVP12DSystemSimple::IVP12DSystemSimple(const QString & name, const QString & information, const QString & contact_info) - : IVP12DSystem(name,information,contact_info), m_d(new Imp) -{ - m_d->itemcollectionPermanent = new VP1GraphicsItemCollection(this); - m_d->itemcollectionEvent = new VP1GraphicsItemCollection(this); - - registerItemCollection(m_d->itemcollectionPermanent); - registerItemCollection(m_d->itemcollectionEvent); - - m_d->wasrefreshed=false; - m_d->wascreated=false; -} - -//____________________________________________________________________ -IVP12DSystemSimple::~IVP12DSystemSimple() -{ - delete m_d; m_d=0; -} - -//____________________________________________________________________ -void IVP12DSystemSimple::create(StoreGateSvc* detstore) -{ - assert(!m_d->wascreated); - systemcreate(detstore); - - QWidget * controller = buildController(); - if (controller) - registerController(controller); - - bool hasview = m_d->itemcollectionPermanent->isAttachedToView(); - if (hasview) - m_d->itemcollectionPermanent->detachFromView(); - buildPermanentItemCollection(detstore,m_d->itemcollectionPermanent); - if (hasview) - m_d->itemcollectionPermanent->reattachToView(); - m_d->wascreated=true; -} - -//____________________________________________________________________ -void IVP12DSystemSimple::refresh(StoreGateSvc* sg) -{ - assert(m_d->wascreated); - assert(!m_d->wasrefreshed); - - bool hasview = m_d->itemcollectionEvent->isAttachedToView(); - if (hasview) - m_d->itemcollectionEvent->detachFromView(); - updateGUI(); - buildEventItemCollection(sg, m_d->itemcollectionEvent); - updateGUI(); - if (hasview) - m_d->itemcollectionEvent->reattachToView(); - updateGUI(); - - m_d->wasrefreshed=true; -} - -//____________________________________________________________________ -void IVP12DSystemSimple::erase() -{ - assert(m_d->wascreated); - assert(m_d->wasrefreshed); - systemerase(); - m_d->itemcollectionEvent->clear(); - m_d->wasrefreshed=false; -} - -//____________________________________________________________________ -void IVP12DSystemSimple::uncreate() -{ - messageDebug("uncreate()..."); - - assert(m_d->wascreated); - assert(!m_d->wasrefreshed); - if (m_d->itemcollectionEvent->isAttachedToView()) - m_d->itemcollectionEvent->detachFromView(); - if (m_d->itemcollectionPermanent->isAttachedToView()) - m_d->itemcollectionPermanent->detachFromView(); - systemuncreate(); - m_d->itemcollectionPermanent->clear(); - m_d->wascreated=false; -} diff --git a/GeoModelVisualization/VP1Base/src/IVP13DChannelWidget.cxx b/GeoModelVisualization/VP1Base/src/IVP13DChannelWidget.cxx index 712bf77bf0dc720556f7f0d856a08d82e01da7f9..21444fddab44cee52f1d85928dca49b8bef1c728 100644 --- a/GeoModelVisualization/VP1Base/src/IVP13DChannelWidget.cxx +++ b/GeoModelVisualization/VP1Base/src/IVP13DChannelWidget.cxx @@ -96,11 +96,10 @@ void IVP13DChannelWidget::setUpdatesEnabled ( bool enable ) //void IVP13DChannelWidget::registerRenderArea(SoQtRenderArea* ra) void IVP13DChannelWidget::registerRenderArea(VP1ExaminerViewer* ra) { - if (!ra) { + if (!ra) { message("Error - tried to register NULL render area!"); return; } - VP1QtInventorUtils::ensureInitLineWidthAndPointSize(ra); m_d->renderareas.push_back(ra); diff --git a/GeoModelVisualization/VP1Base/src/IVP1ChannelWidget.cxx b/GeoModelVisualization/VP1Base/src/IVP1ChannelWidget.cxx index 35639124ceb9898103805b44ddbb0701c3b01823..3ba915a0f225a4ee2c52224bb3fcb80463e3f272 100644 --- a/GeoModelVisualization/VP1Base/src/IVP1ChannelWidget.cxx +++ b/GeoModelVisualization/VP1Base/src/IVP1ChannelWidget.cxx @@ -306,9 +306,10 @@ void IVP1ChannelWidget::setCanRegister(const bool&c,const bool&s) QPixmap IVP1ChannelWidget::getSnapshot(bool transp, int width, bool batch) { VP1Msg::messageVerbose("IVP1ChannelWidget::getSnapshot() - using QPixmap::grabWidget()"); - VP1Msg::messageVerbose("(and so, not using the values - transp: "+QString::number(transp)+" - width: "+QString::number(width)+" - batch: " + batch +")"); + VP1Msg::messageVerbose("(and so, not using the values - transp: "+QString::number(transp)+" - width: "+QString::number(width)+" - batch: " + (char) batch +")"); - return QPixmap::grabWidget( this ); + // return QPixmap::grabWidget( this ); + return grab(); } //_______________________________________________________ diff --git a/GeoModelVisualization/VP1Base/src/IVP1System.cxx b/GeoModelVisualization/VP1Base/src/IVP1System.cxx index b7c6fffe4bb12cf991b399f8adf744b633a20c36..79f59b7cbecdad8b5acf745147fc780f84001fd4 100644 --- a/GeoModelVisualization/VP1Base/src/IVP1System.cxx +++ b/GeoModelVisualization/VP1Base/src/IVP1System.cxx @@ -266,7 +266,7 @@ void IVP1System::updateGUI() { //assert(m_d->allowupdategui); //assert(m_d->state==ERASED); - if ( m_d->allowupdategui && qApp->hasPendingEvents() ) { + if ( m_d->allowupdategui /*&& qApp->hasPendingEvents() deprecated in Qt6*/ ) { qApp->processEvents(); } diff --git a/GeoModelVisualization/VP1Base/src/PhiSectionWidget.cxx b/GeoModelVisualization/VP1Base/src/PhiSectionWidget.cxx index 9fbff1d81051e0ddfb3da4e1a7a455d76bb5d7cb..58483d893fe2857abf0244b5c05ecc365c07085f 100644 --- a/GeoModelVisualization/VP1Base/src/PhiSectionWidget.cxx +++ b/GeoModelVisualization/VP1Base/src/PhiSectionWidget.cxx @@ -834,7 +834,7 @@ void PhiSectionWidget::setAllowedNumberOfSectors(QList<int> allowedNSectors, boo m_d->allowCustomNSectors = allowCustom; - qSort(allowedNSectors); + std::sort(allowedNSectors.begin(), allowedNSectors.end()); if (m_d->allowedNSectors==allowedNSectors) { return; } diff --git a/GeoModelVisualization/VP1Base/src/VP12DExaminerViewer.cxx b/GeoModelVisualization/VP1Base/src/VP12DExaminerViewer.cxx deleted file mode 100644 index c85595cfa5a4517213180054cc91e02f1678bc38..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/VP12DExaminerViewer.cxx +++ /dev/null @@ -1,326 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class VP12DExaminerViewer // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// Major update to support multiple views: July 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/VP12DExaminerViewer.h" -#include "VP1Base/VP1GraphicsView.h" -#include "ui_vp12dexaminerviewerform.h" -#include <iostream> - -//Fixme: If you set seekmode in one view, then even after you use it -//up, the other views will still be in seek mode. I guess we need a -//seekmodedone signal and an endSeekMode slot in vp1graphicsview. - -//____________________________________________________________________ -class VP12DExaminerViewer::Imp { -public: - VP12DExaminerViewer * theclass; - Ui::VP12DExaminerViewerForm * ui; - bool singleviewmode; - - //Common init stuff for the constructors: - void init1();//Before the views are setup in the stackwidget - void init2();//After the views are setup in the stackwidget - - //For some pushbuttons, only the visible view should be - //connected. Thus use the following when changing view: - void connectButtonsToView(VP1GraphicsView*); - void disconnectButtonsFromView(VP1GraphicsView*); - - //Extra info for multi-view mode: - QList<QPair<QString,QString> > multiviews_viewidAndIconUrl; - QMap<QString,VP1GraphicsView*> multiviews_viewid2view; - QMap<QPushButton*,QString> button2viewid; - - - //Helpers - void setModeAllViews(VP1GraphicsView::Mode); - - -}; - - -//____________________________________________________________________ -void VP12DExaminerViewer::Imp::init1() -{ - ui = new Ui::VP12DExaminerViewerForm; - ui->setupUi(theclass); - - //Clear stack widget: - - while (ui->stackedWidget_views->count()) - ui->stackedWidget_views->removeWidget(ui->stackedWidget_views->currentWidget()); - - //Setup mode buttons: - connect(ui->pushButton_pick,SIGNAL(clicked()),theclass,SLOT(setPickMode())); - connect(ui->pushButton_changeview,SIGNAL(clicked()),theclass,SLOT(setChangeViewMode())); - connect(ui->pushButton_seek,SIGNAL(clicked()),theclass,SLOT(setSeekMode())); - - //Hide unused buttons: - ui->pushButton_zoomplus->hide(); - ui->pushButton_zoomminus->hide(); -} - -//____________________________________________________________________ -void VP12DExaminerViewer::Imp::init2() -{ - if (theclass->view()) - connectButtonsToView(theclass->view()); - else - std::cout<<"VP12DExaminerViewer::Imp::init2 WARNING: Current View is NULL"<<std::endl; - //Start in pick mode: - theclass->setPickMode(); - -} - - -//____________________________________________________________________ -VP12DExaminerViewer::VP12DExaminerViewer(QWidget * parent, Qt::WindowFlags f) - : QWidget(parent,f), m_d(new Imp) -{ - m_d->theclass=this; - m_d->singleviewmode = true; - - m_d->init1(); - - //Add graphicsview: - m_d->ui->stackedWidget_views->insertWidget(m_d->ui->stackedWidget_views->count(),new VP1GraphicsView); - - //Setup viewchangebuttons: - m_d->ui->widget_viewchangebuttons->hide(); - - m_d->init2(); -} - -//____________________________________________________________________ -VP12DExaminerViewer::VP12DExaminerViewer(const QList<QPair<QString,QString> >& views, - QWidget * parent, Qt::WindowFlags f) - : QWidget(parent,f), m_d(new Imp) -{ - if (!views.count()) - std::cout<<"VP12DExaminerViewer ERROR: Using multimode constructor with empty list of requested views!"<<std::endl; - - - m_d->theclass=this; - m_d->singleviewmode = false; - - m_d->init1(); - - //Setup layout for the buttons used to change the views: - QVBoxLayout *layout = new QVBoxLayout; - layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); - QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - m_d->ui->widget_viewchangebuttons->setLayout(layout); - - //Add graphicsviews: - m_d->multiviews_viewidAndIconUrl = views; - VP1GraphicsView * firstview(0); - for (int i = 0; i<views.count();++i) { - - VP1GraphicsView * view = new VP1GraphicsView; - if (!firstview) - firstview=view; - - m_d->multiviews_viewid2view.insert(views.at(i).first,view); - - m_d->ui->stackedWidget_views->insertWidget(m_d->ui->stackedWidget_views->count(),view); - //Add button: - QPushButton* button = new QPushButton(m_d->ui->widget_viewchangebuttons); - button->setToolTip(views.at(i).first); - button->setSizePolicy(sizePolicy); - button->setMinimumSize(QSize(30, 30)); - button->setMaximumSize(QSize(30, 30)); - button->setFocusPolicy(Qt::NoFocus); - button->setIcon(QIcon(views.at(i).second)); - button->setIconSize(QSize(30, 30)); - button->setCheckable(false); - layout->addWidget(button); - //connect button here and put it in button -> view_id map: - connect(button,SIGNAL(clicked()),this,SLOT(changeViewButtonClicked())); - m_d->button2viewid.insert(button,views.at(i).first); - } - - QSpacerItem * spacerItem = new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding); - layout->addItem(spacerItem); - - if (firstview) - m_d->ui->stackedWidget_views->setCurrentWidget(firstview); - else - std::cout<<"VP12DExaminerViewer WARNING: View is NULL"<<std::endl; - - m_d->init2(); - -// VP1GraphicsView a(a); -} - -//____________________________________________________________________ -void VP12DExaminerViewer::Imp::connectButtonsToView(VP1GraphicsView* view) -{ - connect(ui->pushButton_sethome,SIGNAL(clicked()),view,SLOT(setHome())); - connect(ui->pushButton_home,SIGNAL(clicked()),view,SLOT(viewHome())); - connect(ui->pushButton_viewall,SIGNAL(clicked()),view,SLOT(fitViewToContents())); - connect(ui->pushButton_print,SIGNAL(clicked()),view,SLOT(print())); -} - -//____________________________________________________________________ -void VP12DExaminerViewer::Imp::disconnectButtonsFromView(VP1GraphicsView*view) -{ - disconnect(ui->pushButton_sethome,SIGNAL(clicked()),view,SLOT(setHome())); - disconnect(ui->pushButton_home,SIGNAL(clicked()),view,SLOT(viewHome())); - disconnect(ui->pushButton_viewall,SIGNAL(clicked()),view,SLOT(fitViewToContents())); - disconnect(ui->pushButton_print,SIGNAL(clicked()),view,SLOT(print())); -} - -//____________________________________________________________________ -VP12DExaminerViewer::~VP12DExaminerViewer() -{ - delete m_d; m_d=0; -} - -//____________________________________________________________________ -VP1GraphicsView * VP12DExaminerViewer::view() const { - return static_cast<VP1GraphicsView *>(m_d->ui->stackedWidget_views->currentWidget()); - // return m_d->view; -} - -//____________________________________________________________________ -VP1GraphicsView * VP12DExaminerViewer::view(const QString& view_id) const -{ - if (m_d->singleviewmode||!m_d->multiviews_viewid2view.contains(view_id)) - return 0; - - return m_d->multiviews_viewid2view[view_id]; -} - -//____________________________________________________________________ -void VP12DExaminerViewer::Imp::setModeAllViews(VP1GraphicsView::Mode m) -{ - //Change viewmode for all the views: - if (singleviewmode) { - theclass->view()->setMode(m); - } else { - QMap<QString,VP1GraphicsView*>::iterator it, itE = multiviews_viewid2view.end(); - for(it = multiviews_viewid2view.begin(); it!=itE; ++it) { - it.value()->setMode(m); - } - } -} - -//____________________________________________________________________ -void VP12DExaminerViewer::setPickMode() -{ - m_d->ui->pushButton_pick->setChecked(true); - m_d->ui->pushButton_changeview->setChecked(false); - m_d->setModeAllViews(VP1GraphicsView::PICK); -} - -//____________________________________________________________________ -void VP12DExaminerViewer::setChangeViewMode() -{ - m_d->ui->pushButton_pick->setChecked(false); - m_d->ui->pushButton_changeview->setChecked(true); - m_d->setModeAllViews(VP1GraphicsView::CHANGEVIEW); -} - -//____________________________________________________________________ -void VP12DExaminerViewer::setSeekMode() -{ - m_d->setModeAllViews(VP1GraphicsView::SEEK); -} - -//____________________________________________________________________ -QStringList VP12DExaminerViewer::viewIDs() const -{ - if (m_d->singleviewmode) - return QStringList(); - - QStringList l; - QMap<QString,VP1GraphicsView*>::iterator it, itE = m_d->multiviews_viewid2view.end(); - for(it = m_d->multiviews_viewid2view.begin(); it!=itE; ++it) { - l << it.key(); - } - - return l; -} - -//____________________________________________________________________ -QList<QPair<QString,QString> > VP12DExaminerViewer::viewIDsAndIconUrls() const -{ - if (m_d->singleviewmode) - return QList<QPair<QString,QString> >(); - - return m_d->multiviews_viewidAndIconUrl; -} - -//____________________________________________________________________ -bool VP12DExaminerViewer::isSingleViewMode() const -{ - return m_d->singleviewmode; -} - -//____________________________________________________________________ -QString VP12DExaminerViewer::currentView() const -{ - if (m_d->singleviewmode) - return ""; - - VP1GraphicsView* currentview = view(); - if (!currentview) - return ""; - - QMap<QString,VP1GraphicsView*>::iterator it, itE = m_d->multiviews_viewid2view.end(); - for(it = m_d->multiviews_viewid2view.begin(); it!=itE; ++it) { - if (it.value()==currentview) - return it.key(); - } - - return ""; -} - -//____________________________________________________________________ -void VP12DExaminerViewer::setShownView(QString viewid) -{ - if (m_d->singleviewmode) - return; - - if (!m_d->multiviews_viewid2view.contains(viewid)) - return; - - VP1GraphicsView* oldview = view(); - VP1GraphicsView* newview = m_d->multiviews_viewid2view[viewid]; - if (!oldview||!newview) - return; - if (oldview==newview) - return; - - currentViewAboutToChange(newview); - - m_d->disconnectButtonsFromView(oldview); - m_d->ui->stackedWidget_views->setCurrentWidget(newview); - m_d->connectButtonsToView(newview); - - currentViewChanged(); -} - -//____________________________________________________________________ -void VP12DExaminerViewer::changeViewButtonClicked() -{ - QPushButton * button = static_cast<QPushButton*>(sender()); - if (!button||!m_d->button2viewid.contains(button)) - return; - setShownView(m_d->button2viewid[button]); -} diff --git a/GeoModelVisualization/VP1Base/src/VP1CollectionWidget.cxx b/GeoModelVisualization/VP1Base/src/VP1CollectionWidget.cxx index 65f36028b536a466a84ad4dcdf958a8e1dd9b856..4ca0117158cf6aa6c70b404232d0dc8c15956034 100644 --- a/GeoModelVisualization/VP1Base/src/VP1CollectionWidget.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1CollectionWidget.cxx @@ -110,7 +110,7 @@ void VP1CollectionWidget::Imp::repopulateGUIFromCollections() QVBoxLayout * vlayout = new QVBoxLayout; vlayout->setSpacing(0); - vlayout->setMargin(0); + // vlayout->setMargin(0); if (collections.isEmpty()) { QHBoxLayout * labellayout = new QHBoxLayout; labellayout->setSpacing(0); @@ -122,8 +122,8 @@ void VP1CollectionWidget::Imp::repopulateGUIFromCollections() QSet<QString> sections; foreach (VP1Collection* col,collections) sections.insert(col->section()); - QList<QString> sectionsSorted = sections.toList(); - qSort(sectionsSorted); + QList<QString> sectionsSorted(sections.begin(),sections.end());// = sections.toList(); + std::sort(sectionsSorted.begin(), sectionsSorted.end()); theclass->sortSections(sectionsSorted); const bool nosectionlabels = sectionsSorted.count() == 1 && sectionsSorted.at(0).isEmpty(); @@ -149,7 +149,7 @@ void VP1CollectionWidget::Imp::repopulateGUIFromCollections() QGridLayout * gridLayout = new QGridLayout; gridLayout->setHorizontalSpacing(6); gridLayout->setVerticalSpacing(0); - gridLayout->setMargin(0); + //gridLayout->setMargin(0); if (!nosectionlabels) gridLayout->addItem(new QSpacerItem(10, 1, QSizePolicy::Fixed, QSizePolicy::Fixed),0,0); vlayout->addLayout(gridLayout); @@ -207,7 +207,7 @@ void VP1CollectionWidget::Imp::repopulateGUIFromCollections() vlayout->addStretch(1); QHBoxLayout * hlayout = new QHBoxLayout; - hlayout->setMargin(0); + //hlayout->setMargin(0); hlayout->setSpacing(0); hlayout->addLayout(vlayout); hlayout->addStretch(1); @@ -316,8 +316,8 @@ QList<qint32> VP1CollectionWidget::Imp::visibleStdCollectionTypesFromVisStdCols( QSet<qint32> vt; foreach(VP1StdCollection* stdcol,l) vt.insert(stdcol->collTypeID()); - QList<qint32> vistypes = vt.toList(); - qSort(vistypes); + QList<qint32> vistypes(vt.begin(),vt.end());// = vt.toList(); + std::sort(vistypes.begin(),vistypes.end()); return vistypes; } diff --git a/GeoModelVisualization/VP1Base/src/VP1Controller.cxx b/GeoModelVisualization/VP1Base/src/VP1Controller.cxx index 0c8a219d51c4da7c63e8b162d9aab45e1080429f..e3f9deef6cdca241999f05c97a2a7d37b90e30fd 100644 --- a/GeoModelVisualization/VP1Base/src/VP1Controller.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1Controller.cxx @@ -290,7 +290,7 @@ QButtonGroup * VP1Controller::defineRadioButtonGroup( QRadioButton * rb0, QRadio { QList<QRadioButton *> l; l << rb0 << rb1 << rb2 << rb3 << rb4 << rb5 << rb6 << rb7 << rb8 << rb9; - l.removeAll(0); + l.removeAll(nullptr); return defineRadioButtonGroup(l); } diff --git a/GeoModelVisualization/VP1Base/src/VP1ControllerHelper.cxx b/GeoModelVisualization/VP1Base/src/VP1ControllerHelper.cxx index 52379f79978780c27634ed5a2dece0e16fdb4696..46e44e9e721fbbcb5f89af4a6195ffcbd7adf0ab 100644 --- a/GeoModelVisualization/VP1Base/src/VP1ControllerHelper.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1ControllerHelper.cxx @@ -49,10 +49,10 @@ QWidget * VP1ControllerHelper::compositionController( const QList<IVP1System*>& QWidget * tab_general = new QWidget(0); QVBoxLayout * vboxLayout1 = new QVBoxLayout(tab_general); vboxLayout1->setSpacing(6); - vboxLayout1->setMargin(9); + // vboxLayout1->setMargin(9); QHBoxLayout * hboxLayout = new QHBoxLayout(); hboxLayout->setSpacing(6); - hboxLayout->setMargin(0); + //hboxLayout->setMargin(0); QLabel * tab_general_label = new QLabel(tab_general); tab_general_label->setText("No systems can be switched on/off in this channel."); hboxLayout->addWidget(tab_general_label); @@ -61,12 +61,12 @@ QWidget * VP1ControllerHelper::compositionController( const QList<IVP1System*>& vboxLayout1->addLayout(hboxLayout); QHBoxLayout * hboxLayout1 = new QHBoxLayout(); hboxLayout1->setSpacing(0); - hboxLayout1->setMargin(0); + //hboxLayout1->setMargin(0); QSpacerItem * spacerItem1 = new QSpacerItem(25, 2, QSizePolicy::Fixed, QSizePolicy::Fixed); hboxLayout1->addItem(spacerItem1); QVBoxLayout *vboxLayout_checkboxes = new QVBoxLayout(); vboxLayout_checkboxes->setSpacing(6); - vboxLayout_checkboxes->setMargin(0); + //vboxLayout_checkboxes->setMargin(0); hboxLayout1->addLayout(vboxLayout_checkboxes); QSpacerItem * spacerItem2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxLayout1->addItem(spacerItem2); @@ -94,7 +94,7 @@ QWidget * VP1ControllerHelper::compositionController( const QList<IVP1System*>& colorselectbutton = new VP1ColorSelectButton(tab_general,Qt::black); QHBoxLayout * hboxLayout2 = new QHBoxLayout(); hboxLayout2->setSpacing(6); - hboxLayout2->setMargin(0); + //hboxLayout2->setMargin(0); hboxLayout2->addWidget(colorselectbutton); hboxLayout2->addWidget(new QLabel("Set background")); QSpacerItem * spacerItem4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -109,7 +109,7 @@ QWidget * VP1ControllerHelper::compositionController( const QList<IVP1System*>& extrawidget->setParent(tab_general); QHBoxLayout * hboxLayout_extra = new QHBoxLayout(); hboxLayout_extra->setSpacing(6); - hboxLayout_extra->setMargin(0); + //hboxLayout_extra->setMargin(0); hboxLayout_extra->addWidget(extrawidget); QSpacerItem * spacerItem_extra1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxLayout_extra->addItem(spacerItem_extra1); diff --git a/GeoModelVisualization/VP1Base/src/VP1CustomTourEditor.cxx b/GeoModelVisualization/VP1Base/src/VP1CustomTourEditor.cxx index 8bbc68ca0a75800a10f22e758c23f1d97ae36044..e7fb913d63872a50bc02eda797ab626bdea3ca4b 100644 --- a/GeoModelVisualization/VP1Base/src/VP1CustomTourEditor.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1CustomTourEditor.cxx @@ -192,7 +192,7 @@ void VP1CustomTourEditor::frameStepToEarlier() int iframe(m_d->frames.indexOf(dynamic_cast<VP1CustomTourFrameWidget*>(sender()))); if (iframe<=0) return;//not found or already at start - m_d->frames.swap(iframe-1,iframe); + m_d->frames.swapItemsAt(iframe-1,iframe); m_d->updateFrameListVisuals(); } @@ -204,7 +204,7 @@ void VP1CustomTourEditor::frameStepToLater() return; if (iframe>=m_d->frames.count()-1) return;//already at end - m_d->frames.swap(iframe,iframe+1); + m_d->frames.swapItemsAt(iframe,iframe+1); m_d->updateFrameListVisuals(); } @@ -279,7 +279,7 @@ void VP1CustomTourEditor::swap( VP1CustomTourFrameWidget * frame1, ||iframe1>=m_d->frames.count() ||iframe2>=m_d->frames.count() ) return; - m_d->frames.swap(iframe1,iframe2); + m_d->frames.swapItemsAt(iframe1,iframe2); m_d->updateFrameListVisuals(); } diff --git a/GeoModelVisualization/VP1Base/src/VP1CustomTourFrameWidget.cxx b/GeoModelVisualization/VP1Base/src/VP1CustomTourFrameWidget.cxx index 506f7693f8c6b4adc980b590cbb42a8cb6a71d12..ef07468298aa60c84bccc5b97031cd8eceae7afa 100644 --- a/GeoModelVisualization/VP1Base/src/VP1CustomTourFrameWidget.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1CustomTourFrameWidget.cxx @@ -116,7 +116,7 @@ QByteArray VP1CustomTourFrameWidget::serialise() const s.save(m_d->ui.doubleSpinBox_clipVolumePercentOfATLAS); s.save(m_d->ui.comboBox_approachMethod); s.save(m_d->ui.checkBox_frameEnabled); - s.save(m_d->ui.label_snapshot->pixmap() ? *(m_d->ui.label_snapshot->pixmap()) : QPixmap()); + s.save(m_d->ui.label_snapshot->pixmap()); s.warnUnsaved(this); return s.result(); } @@ -220,10 +220,15 @@ void VP1CustomTourFrameWidget::mouseMoveEvent(QMouseEvent *event) QMimeData *mimeData = new QMimeData; mimeData->setData("vp1/customtourframe", QByteArray() ); drag->setMimeData(mimeData);//drag assumes ownership of mimeData + +#if QT_VERSION >= 0x060000 + QPixmap pm =m_d->ui.label_snapshot->pixmap(); +#else QPixmap pm = m_d->ui.label_snapshot->pixmap() ? *(m_d->ui.label_snapshot->pixmap()) : QPixmap(); - if (!pm.isNull()) - drag->setPixmap(pm ); +#endif + if (!pm.isNull()) drag->setPixmap(pm ); drag->exec(Qt::CopyAction | Qt::MoveAction); + } //____________________________________________________________________ diff --git a/GeoModelVisualization/VP1Base/src/VP1ExaminerViewer.cxx b/GeoModelVisualization/VP1Base/src/VP1ExaminerViewer.cxx index 9f300c4d26ba572e52ae367462706e5f3ac864bd..f5fee1fbdaf804545816d5888e0144aeee01cfd9 100644 --- a/GeoModelVisualization/VP1Base/src/VP1ExaminerViewer.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1ExaminerViewer.cxx @@ -52,7 +52,8 @@ #include <QFileDialog> #include <QInputDialog> #include <QPushButton> -#include <QGLFormat> +#include <QActionGroup> +//#include <QGLFormat> #include <map> #include <iostream> @@ -563,7 +564,7 @@ VP1ExaminerViewer::VP1ExaminerViewer(QWidget * parent, } // test Ric - VP1Msg::messageVerbose("is stereo: " + QString(isStereoViewing()) + " - offset: " + QString::number(getStereoOffsetSlot()) + " - type: " + QString::number(getStereoType()) ); + VP1Msg::messageVerbose("is stereo: " + QString((char) isStereoViewing()) + " - offset: " + QString::number(getStereoOffsetSlot()) + " - type: " + QString::number(getStereoType()) ); } @@ -1282,7 +1283,7 @@ void VP1ExaminerViewer::Imp::detectorZoomButtonClicked(std::pair<REGION,VIEW> p) { grabFocus(); - VP1Msg::messageVerbose("detectorZoomButtonClicked region = " + toString(p.first) + ", from " + QString(p.second) + " Z axis" ); + VP1Msg::messageVerbose("detectorZoomButtonClicked region = " + toString(p.first) + ", from " + QString((char) p.second) + " Z axis" ); SoNode * rootnode = theclass->getSceneGraph(); if (!rootnode) { diff --git a/GeoModelVisualization/VP1Base/src/VP1GraphicsItemCollection.cxx b/GeoModelVisualization/VP1Base/src/VP1GraphicsItemCollection.cxx deleted file mode 100644 index 6e0cb417f92c3530661dfaf3fc247f7a7542b08e..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/VP1GraphicsItemCollection.cxx +++ /dev/null @@ -1,359 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class VP1GraphicsItemCollection // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -#include "VP1Base/VP1GraphicsItemCollection.h" -#include "VP1Base/VP1GraphicsView.h" - -#include <QGraphicsItem> -#include <QGraphicsScene> -#include <QHash> -#include <QSet> - -#include <iostream> -#include <cassert> - -//____________________________________________________________________ -class VP1GraphicsItemCollection::Imp { -public: - - QGraphicsScene *scene; - VP1GraphicsView *lastview; - VP1GraphicsView *view; - bool ignoreall_int; - bool ignoreall_move; - int nactiveitems; - - void setEnabledMovableItems(const bool& enabled); - bool ignoresInteractions() const; - - - QHash<QGraphicsItem*,bool> items2active; - typedef QHash<QGraphicsItem*,bool>::iterator ItemDataMapItr;//fixme: optimise flag. - - //For performance reasons, we keep a separate list of the items that - //are movable (anyone making a collection with 100000 movable items - //will be the first against the wall when the revolution comes): - QSet<QGraphicsItem*> movableitems; - - VP1GraphicsItemCollection::INTERACTIONMODE interactionmode; - -}; - - -//____________________________________________________________________ -VP1GraphicsItemCollection::VP1GraphicsItemCollection( QObject * parent) - : QObject(parent), m_d(new Imp) -{ - m_d->view=0; - m_d->lastview=0; - m_d->scene=0; - m_d->ignoreall_int=false; - m_d->ignoreall_move=false; - m_d->interactionmode=INERT; - m_d->nactiveitems=0; -} - -//____________________________________________________________________ -VP1GraphicsItemCollection::~VP1GraphicsItemCollection() -{ - if (m_d->view) - detachFromView(); - clear(); - delete m_d; -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::setInteractionMode( const VP1GraphicsItemCollection::INTERACTIONMODE& im ) -{ - assert(!m_d->scene&&"VP1GraphicsItemCollection::setInteractionMode can not be called while a scene is attached."); - if (m_d->scene) { - std::cout<<"VP1GraphicsItemCollection::setInteractionMode can not be called while a scene is attached."<<std::endl; - return; - } - m_d->interactionmode = im; -} - -//____________________________________________________________________ -VP1GraphicsItemCollection::INTERACTIONMODE VP1GraphicsItemCollection::interactionMode() const -{ - return m_d->interactionmode; -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::addItem(QGraphicsItem*item, const bool& active,const bool&movable) -{ - assert(!m_d->items2active.contains(item)&&"Please do not add the same item twice"); - assert(!item->flags()&&"Please do not add any flags to your items!!"); - - if (m_d->scene) { - //The following must postponed if there is no scene: - m_d->scene->addItem(item); - item->setFlag(QGraphicsItem::ItemIsMovable,(movable&&(!m_d->ignoreall_move))); - } - assert(!m_d->items2active.contains(item)); - m_d->items2active.insert(item,active); - if (active) - ++m_d->nactiveitems; - if (movable) - m_d->movableitems<<item; -} - -//Fixme: Make VP1GraphicsView setScene() private so it is the same throughout a GV lifetime. - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::removeItem(QGraphicsItem*item) -{ - Imp::ItemDataMapItr it = m_d->items2active.find( item ); - if (it==m_d->items2active.end()) - return false; - if (it.value()) - --m_d->nactiveitems; - if (m_d->scene) { - m_d->scene->removeItem(item); - } - m_d->items2active.erase(it); - assert(!m_d->items2active.contains(item)); - - if (!m_d->movableitems.empty()) { - QSet<QGraphicsItem*>::iterator it2 = m_d->movableitems.find(item); - if (it2!=m_d->movableitems.end()) { - assert(m_d->movableitems.contains(item)); - m_d->movableitems.erase(it2); - } - } - assert(!m_d->movableitems.contains(item)); - return true; -} - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::setMovable(QGraphicsItem* item, const bool& movable) -{ - Imp::ItemDataMapItr it = m_d->items2active.find( item ); - if (it==m_d->items2active.end()) - return false; - if (movable==m_d->movableitems.contains(item))//Nothing needs to be done: - return true; - if (movable) { - assert(!m_d->movableitems.contains(item)); - m_d->movableitems<<item; - } else { - assert(m_d->movableitems.contains(item)); - m_d->movableitems.remove(item); - assert(!m_d->movableitems.contains(item)); - } - if (!m_d->ignoreall_move) - item->setFlag(QGraphicsItem::ItemIsMovable,movable); - return true; -} - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::setActive(QGraphicsItem* item, const bool& active) -{ - Imp::ItemDataMapItr it = m_d->items2active.find( item ); - if (it==m_d->items2active.end()) - return false; - it.value()=active; - if (active) - ++m_d->nactiveitems; - else - --m_d->nactiveitems; - return true; -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::clear(const bool& deleteitems) -{ - //Clear selections before deleting items in order to only get one selectionchanged signal. - if (m_d->view) - m_d->view->clearSelections(); - - Imp::ItemDataMapItr it,itE=m_d->items2active.end(); - if (m_d->scene) { - //Remove item from scene and possible also remove event filter. - for (it=m_d->items2active.begin();it!=itE;++it) - m_d->scene->removeItem(it.key()); - } - if (deleteitems) { - //Delete the items: - for (it=m_d->items2active.begin();it!=itE;++it) { - delete it.key(); - } - } - m_d->items2active.clear(); - m_d->movableitems.clear(); - m_d->nactiveitems=0; -} - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::hasItem(QGraphicsItem* item) const -{ - return m_d->items2active.contains(item); -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::Imp::setEnabledMovableItems(const bool& enabled) { - if (movableitems.empty()) - return; - QSet<QGraphicsItem*>::iterator it,itE=movableitems.end(); - for (it=movableitems.begin();it!=itE;++it) { - (*it)->setFlag(QGraphicsItem::ItemIsMovable,enabled); - } - -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::setTemporaryIgnoreInteractions( const bool& b ) -{ - if (m_d->ignoreall_int==b) - return; - m_d->ignoreall_int=b; -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::setTemporaryIgnoreMovable( const bool& b ) -{ - if (m_d->ignoreall_move==b) - return; - m_d->ignoreall_move=b; - if (m_d->scene) - m_d->setEnabledMovableItems(!b); -} - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::Imp::ignoresInteractions() const -{ - return ( interactionmode==INERT || ignoreall_int ); -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::attachToView(VP1GraphicsView*view) -{ - assert(!m_d->scene); - assert(!m_d->view); - m_d->scene=view->scene(); - // m_d->lastscene=m_d->scene; - m_d->view=view; - m_d->lastview=m_d->view; - Imp::ItemDataMapItr it,itE=m_d->items2active.end(); - for (it=m_d->items2active.begin();it!=itE;++it) { - m_d->scene->addItem(it.key()); - } - //Update this, since we didnt do any updates while there was no scene: - m_d->setEnabledMovableItems(!m_d->ignoreall_move); -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::detachFromView() -{ - if (!m_d->view) - return; - m_d->view->removeItemCollection(this); - //NB. The call to removeItemCollection ends up by calling - //VP1GraphicsItemCollection::real_detachFromView(). -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::real_detachFromView() -{ - //This method is called after the collection has been removed from the the view. - if (!m_d->view) - return; - //Remove item from scene: - Imp::ItemDataMapItr it,itE=m_d->items2active.end(); - for (it=m_d->items2active.begin();it!=itE;++it) { - m_d->scene->removeItem(it.key()); - } - m_d->view=0; - m_d->scene=0; -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::reattachToView() -{ - if (m_d->view) - return; - assert(m_d->lastview); - m_d->lastview->addItemCollection(this); - //NB. The call to addItemCollection ends up by calling - //VP1GraphicsItemCollection::attachToView(). -} - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::isAttachedToView() -{ - return m_d->view; -} - - -//____________________________________________________________________ -int VP1GraphicsItemCollection::nItems() const -{ - return m_d->items2active.count(); -} - -//____________________________________________________________________ -int VP1GraphicsItemCollection::nActiveItems() const -{ - return m_d->nactiveitems; -} - -//____________________________________________________________________ -int VP1GraphicsItemCollection::nMovableItems() const -{ - return m_d->movableitems.count(); -} - -//____________________________________________________________________ -int VP1GraphicsItemCollection::nPresentlyActiveItems() const -{ - return m_d->ignoresInteractions() ? 0 : m_d->nactiveitems; -} - -//____________________________________________________________________ -int VP1GraphicsItemCollection::nPresentlyMovableItems() const -{ - return m_d->ignoresInteractions() ? 0 : m_d->movableitems.count(); -} - -//____________________________________________________________________ -bool VP1GraphicsItemCollection::itemBelongsAndIsPresentlyActive(QGraphicsItem*item) const -{ - if (!nPresentlyActiveItems()) - return false; - QHash<QGraphicsItem*,bool>::const_iterator it = m_d->items2active.find(item); - - - if (it==m_d->items2active.constEnd()) - return false; - else - return it.value(); -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::itemPickedPrivate(QGraphicsItem* item) const -{ - itemPicked(item); -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::itemGotEventPrivate(QGraphicsItem*item,QEvent*event) const -{ - itemGotEvent(item,event); -} - -//____________________________________________________________________ -void VP1GraphicsItemCollection::selectionChangedPrivate(QList<QGraphicsItem*> items) const -{ - selectionChanged(items); -} diff --git a/GeoModelVisualization/VP1Base/src/VP1GraphicsView.cxx b/GeoModelVisualization/VP1Base/src/VP1GraphicsView.cxx deleted file mode 100644 index 81f126709211191abf79585576d0953e3064312b..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Base/src/VP1GraphicsView.cxx +++ /dev/null @@ -1,1116 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -///////////////////////////////////////////////////////////// -// // -// Implementation of class VP1GraphicsView // -// // -// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // -// // -// Initial version: April 2007 // -// // -///////////////////////////////////////////////////////////// - -//Todo: Mouse zoom mode (updown...). -// left+middle:zoom. left+middle+right: keep. -// left+right:drag keep mode until click. -// Zoom by rubberband mode. -// Add zoom in/out slots to be like Key_Plus/Key_Minus? -// A changeview drag does not abort a zoom! -// Adjust zoom nsteps based on number of items in view. - - -#include "VP1Base/VP1GraphicsView.h" -#include "VP1Base/VP1GraphicsItemCollection.h" - -#include "VP1Base/IVP12DViewTransformation.h" -#include "VP1Base/VP12DViewRZFishEyeTransformation.h"//fixme -#include "VP1Base/VP12DViewRPhiFishEyeTransformation.h"//fixme - -#include "VP1Base/VP1Settings.h" -#include "VP1Base/VP1Msg.h" - -// QtCore -#include <QTimer> -#include <QQueue> -#include <QSet> -#include <QDir> - -// QtGui -#include <QWheelEvent> -#include <QMouseEvent> -#include <QGraphicsScene> -#include <QScrollBar> -#include <QGraphicsPathItem> -#include <QPrinter> -#include <QPrintDialog> -#include <QPixmap> -#include <QFileDialog> -#include <QTextDocument> -#include <QAbstractTextDocumentLayout> - -// Qt OpenGL -#include <QGLWidget> -#include <QGLFormat> - -#include<iostream>//fixme -#include <cassert> - -//____________________________________________________________________ -class VP1GraphicsView::Imp { -public: - - void init(VP1GraphicsView*); - QGraphicsScene * scene; - VP1GraphicsView * view; - - Mode mode; - Mode lastmajormode;//To go back to the previous major mode when exiting a seek. - - QList<VP1GraphicsItemCollection*> cols_act;//All item collections not inherently INERT - QList<VP1GraphicsItemCollection*> cols_all;//Needed since event inactive collections might have movable items. - - //The following two lists may contain pointers to ic's not presently - //attached to the view since we need to remember settings: - QSet<VP1GraphicsItemCollection*> cols_override_inactive; - QSet<VP1GraphicsItemCollection*> cols_override_unmovable; - - QRectF home; - - QTimer * zoomanim_timer; - int zoomanim_nsteps; - double zoomanim_totaltime; - double zoomfactoronseek; - QQueue<QRectF> zoomanim_queue; - QPainter::RenderHints savedrenderhints; - - QPoint dragzoom_startpoint; - - void setNewSelected(QGraphicsItem*,const bool& multimode=false); - QMap<QGraphicsItem*,HighLightItem*> selecteditems; - -// QList<QGraphicsItem*> selecteditems;//Fixme more than one item!! -// QList<QGraphicsPathItem*> selectionoutlines; - VP1GraphicsItemCollection * ic_multiselection;//Holds the ic when a multiselection is taking place. - void locateActiveItemAtPoint(QGraphicsItem*&,VP1GraphicsItemCollection*& ic, - const QPoint& pos, - VP1GraphicsItemCollection * searchic=0); - void select(QGraphicsItem*item); - void deselect(QGraphicsItem*item); - void HighLightItemBeingDeleted(HighLightItem*); - bool clearselectionsemitsignals; - QList<QGraphicsItem*> lastemittedselecteditems; - - - QString currentsaveimagefile; - void paintDescription(QPainter *painter); - QTextDocument helptext; - QImage *helptextimage; - void createNewHelptextImage(const QRect& imrect); - bool showhelptext; - - //transformation: - IVP12DViewTransformation * transform; - bool transformactive; -}; - -//We make a slightly modified pathitem for highlight item - because we -//need to know when it is killed (which it will be when the user -//removes an item): -//____________________________________________________________________ -class VP1GraphicsView::HighLightItem : public QGraphicsPathItem { -public: - HighLightItem ( const QPainterPath & path, QGraphicsItem * parent, VP1GraphicsView*v) - : QGraphicsPathItem(path,parent),view(v),sendsignalondelete(true) {} - virtual ~HighLightItem() { - std::cout<<"dying"<<std::endl; - if (sendsignalondelete) - view->m_d->HighLightItemBeingDeleted(this); - } - VP1GraphicsView* view; - bool sendsignalondelete; -}; - -//____________________________________________________________________ -VP1GraphicsView::VP1GraphicsView ( QWidget * parent ) - :QGraphicsView(parent), m_d(new Imp) -{ - m_d->init(this); -} - -//____________________________________________________________________ -VP1GraphicsView::VP1GraphicsView ( QGraphicsScene * scene, QWidget * parent ) - : QGraphicsView(scene,parent), m_d(new Imp) -{ - m_d->init(this); -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::init(VP1GraphicsView*v) -{ - view=v; - view->setTransformationAnchor(AnchorUnderMouse); - view->setResizeAnchor(AnchorViewCenter); - if (QGLFormat::hasOpenGL())//It turns out that when doing x-forward (at least from lxplus) GLX, and thus OpenGL support is not present. - view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers),view)); - view->setRenderHint(QPainter::Antialiasing);//QPainter::SmoothPixmapTransform - view->setBackgroundBrush(Qt::black); - if (!view->scene()) - view->setScene(new QGraphicsScene()); - scene=view->scene(); - lastmajormode = mode = PICK; - view->setMode(PICK); - - view->setFrameStyle(QFrame::NoFrame); - - zoomanim_timer = new QTimer(); - QObject::connect(zoomanim_timer, SIGNAL(timeout()), view, SLOT(updateZoomAnimation())); - zoomfactoronseek = 10.0; - //Like this to set the correct timer interval: - zoomanim_nsteps = 24; - view->setAnimatedZoomTime(1500.0);//ms - - // Due to a bug in Qt 4.3.0 (not present in 4.2.3 and supposedly - // fixed in 4.3.1), we have to show the scrollbars if we want to - // have proper scrollhanddrag and seek modes. Therefore we uncomment - // the next two lines - and we should reenable them for Qt4.3.1 (fixme). - // view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - //Make sure that animation aborts if user moves a scrollbar (in case someone turns them on): - QObject::connect(view->horizontalScrollBar(),SIGNAL(sliderMoved(int)),view,SLOT(abortZoomAnimation())); - QObject::connect(view->verticalScrollBar(),SIGNAL(sliderMoved(int)),view,SLOT(abortZoomAnimation())); - clearselectionsemitsignals=true; - ic_multiselection=0; -// selecteditem=0; -// selectionoutline=0; - helptextimage=0; - showhelptext=false; - - transform = 0; - transformactive = false; - //fixme: - if (false) { - transformactive = true; - // transform = new VP12DViewRZFishEyeTransformation(); - transform = new VP12DViewRPhiFishEyeTransformation(); - view->setInteractive ( false ); - } - -} - -//____________________________________________________________________ -VP1GraphicsView::~VP1GraphicsView() -{ - delete m_d->transform; - delete m_d; m_d=0; -} - -//____________________________________________________________________ -void VP1GraphicsView::scaleView(qreal scaleFactor) -{ - abortZoomAnimation(); - qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); - if (factor < 1e-5 || factor > 1e5)//Fixme:Set as options! - return; - scale(scaleFactor, scaleFactor); -} - -//____________________________________________________________________ -void VP1GraphicsView::fitViewToContents() -{ - if (m_d->transform&&m_d->transformactive) - fitInView( m_d->transform->transform(scene()->sceneRect()), Qt::KeepAspectRatio ); - else - fitInView( scene()->sceneRect(), Qt::KeepAspectRatio ); -} - -//____________________________________________________________________ -void VP1GraphicsView::wheelEvent(QWheelEvent *event) -{ - if (m_d->showhelptext) { - m_d->showhelptext=false; - viewport()->update(); - }; - double ratefact = 0.8; - if (event->modifiers() & Qt::ControlModifier) - ratefact = 0.1; - if (event->modifiers() & Qt::ShiftModifier) - ratefact = 0.01; - scaleView(pow((double)2, -event->delta() / (240.0/ratefact))); -} - -//____________________________________________________________________ -void VP1GraphicsView::keyPressEvent(QKeyEvent *event) -{ -// VP1Msg::messageDebug("VP1GraphicsView::keyPressEvent"); - -// std::string keyText = (event->text()).toStdString(); -// VP1Msg::messageDebug(keyText.c_str()); - - if (m_d->showhelptext&&!(event->key()==Qt::Key_F1||event->key()==Qt::Key_H)) { - m_d->showhelptext=false; - viewport()->update(); - }; - - switch (event->key()) { - case Qt::Key_Home: - if (event->modifiers() & Qt::ControlModifier) - setHome(); - else - viewHome(); - break; - case Qt::Key_F1: - case Qt::Key_H: - m_d->showhelptext=!m_d->showhelptext; - viewport()->update(); - break; - case Qt::Key_1: - fitViewToContents(); - break; - case Qt::Key_Escape: - if (m_d->mode==SEEK) - setMode(m_d->lastmajormode); - else if (m_d->mode==PICK) - setMode(CHANGEVIEW); - else - setMode(PICK); - break; - case Qt::Key_S: - if (m_d->mode!=SEEK) - setMode(SEEK); - else - setMode(m_d->lastmajormode); - break; - case Qt::Key_Plus: - case Qt::Key_Equal: - scaleView(1.2); - break; - case Qt::Key_Minus: - scaleView(1 / 1.2); - break; - case Qt::Key_P: - if (event->modifiers() & Qt::ControlModifier) - saveImage(); - else - print(); - break; - default: - // QGraphicsView::keyPressEvent(event); - break; - } - -// if (m_d->mode==PICK) { -// foreach (QGraphicsItem*item,items(event->pos())) { -// foreach(VP1GraphicsItemCollection* ic,m_d->cols_act) { -// if (ic->itemBelongsAndIsPresentlyActive(item)) { -// event->accept(); -// //EMIT [event] SIGNALS. -// } -// } -// } -// } - - - QGraphicsView::keyPressEvent(event); -} - -//____________________________________________________________________ -void VP1GraphicsView::setMode(const Mode& m) -{ - if (m_d->mode==m) - return; - m_d->mode=m; - if (m==PICK||m==CHANGEVIEW) - m_d->lastmajormode=m; - - if (m!=DRAGZOOM&&m!=DRAGZOOMHOLD) - m_d->dragzoom_startpoint=QPoint(); - - //Dragmode: - if (m==CHANGEVIEW) { - setDragMode(QGraphicsView::ScrollHandDrag); - } else { - setDragMode(QGraphicsView::NoDrag); - } - - //Cursor: - switch (m) { - case PICK: - setCursor(Qt::ArrowCursor); - break; - case CHANGEVIEW: - setCursor(Qt::OpenHandCursor); - break; - case DRAGZOOM: - case DRAGZOOMHOLD: - setCursor(Qt::SizeVerCursor); - break; - case SEEK: - setCursor(Qt::CrossCursor); - break; - default: - assert(0); - break; - } - - //Interactions/movable: - if (m==PICK) { - foreach (VP1GraphicsItemCollection*ic,m_d->cols_act) - if (!m_d->cols_override_inactive.contains(ic)) - ic->setTemporaryIgnoreInteractions(false); - foreach (VP1GraphicsItemCollection*ic,m_d->cols_all) - if (!m_d->cols_override_unmovable.contains(ic)) - ic->setTemporaryIgnoreMovable(false); - } else { - foreach (VP1GraphicsItemCollection*ic,m_d->cols_all) - ic->setTemporaryIgnoreMovable(true); - foreach (VP1GraphicsItemCollection*ic,m_d->cols_act) - ic->setTemporaryIgnoreInteractions(true); - } -} - -//____________________________________________________________________ -VP1GraphicsView::Mode VP1GraphicsView::mode() const -{ - return m_d->mode; -} - -//____________________________________________________________________ -void VP1GraphicsView::addItemCollection(VP1GraphicsItemCollection*ic) { - assert(!m_d->cols_all.contains(ic)); - assert(!m_d->cols_act.contains(ic)); - m_d->cols_all << ic; - if (ic->interactionMode()!=VP1GraphicsItemCollection::INERT) { - m_d->cols_act << ic; - ic->setTemporaryIgnoreInteractions( m_d->mode!=PICK || m_d->cols_override_inactive.contains(ic) ); - ic->setTemporaryIgnoreMovable( m_d->mode!=PICK || m_d->cols_override_unmovable.contains(ic) ); - } - ic->attachToView(this); -} - -//____________________________________________________________________ -void VP1GraphicsView::removeItemCollection(VP1GraphicsItemCollection*ic) { - assert(m_d->cols_all.contains(ic)); - m_d->cols_all.removeAll(ic); - if (m_d->cols_act.contains(ic)) - m_d->cols_act.removeAll(ic); - ic->setTemporaryIgnoreInteractions(false); - ic->setTemporaryIgnoreMovable(false); - ic->real_detachFromView(); - //Fixme: When user calls the detach/attach/... methods on the ic, these methods must also be invoked! - //Fixme: use groupnode in each ic. This also allows an easy hide/unhide action as well as z values... (ic have external setZValue() method). -} - -//____________________________________________________________________ -void VP1GraphicsView::mouseDoubleClickEvent(QMouseEvent * event) { - - if (m_d->showhelptext) { - m_d->showhelptext=false; - viewport()->update(); - }; - - if (m_d->mode!=PICK) { - QGraphicsView::mouseDoubleClickEvent(event); - return; - } - //Fixme: transformed pos - foreach (QGraphicsItem*item,items(event->pos())) { - foreach(VP1GraphicsItemCollection* ic,m_d->cols_act) { - if (ic->itemBelongsAndIsPresentlyActive(item)) { - event->accept(); - //EMIT SIGNALS. CHANGE SELECTION. - } - } - } - QGraphicsView::mouseDoubleClickEvent(event); - return; -} - - -//____________________________________________________________________ -void VP1GraphicsView::mouseMoveEvent(QMouseEvent *event) -{ - - //Fixme: transformed pos - - if ((m_d->mode==DRAGZOOM||m_d->mode==DRAGZOOMHOLD) && m_d->dragzoom_startpoint!=QPoint() ) { - double delta = event->pos().y()-m_d->dragzoom_startpoint.y(); - m_d->dragzoom_startpoint=event->pos(); - ViewportAnchor save = transformationAnchor(); - setTransformationAnchor(AnchorViewCenter); - scaleView(pow((double)2, -delta / (240.0/0.8)));//FIXME!! Dont have this equation more than once! - setTransformationAnchor(save); - event->accept(); - return; - } - if (m_d->mode==PICK) { - foreach (QGraphicsItem*item,items(event->pos())) { - foreach(VP1GraphicsItemCollection* ic,m_d->cols_act) { - if (ic->itemBelongsAndIsPresentlyActive(item)) { - event->accept(); - //EMIT [event] SIGNALS. - } - } - } - } - QGraphicsView::mouseMoveEvent(event); - return; -} - -//____________________________________________________________________ -void VP1GraphicsView::mousePressEvent(QMouseEvent *event) -{ - setFocus(Qt::MouseFocusReason);//Fixme: also doubleclick event! - - if (m_d->showhelptext) { - m_d->showhelptext=false; - viewport()->update(); - }; - - if (m_d->mode==SEEK) { - event->accept(); - setMode(m_d->lastmajormode); - seekToPoint(mapToScene(event->pos())); - return; - } - - if (m_d->mode==CHANGEVIEW&&event->buttons()==(Qt::LeftButton|Qt::MidButton)) { - event->accept(); - m_d->dragzoom_startpoint=event->pos(); - setMode(DRAGZOOM); - return; - } - - if (m_d->mode==DRAGZOOM&&event->buttons()!=(Qt::LeftButton|Qt::MidButton)) { - if (event->buttons()==(Qt::LeftButton|Qt::MidButton|Qt::RightButton)) { - setMode(DRAGZOOMHOLD); - } else { - setMode(CHANGEVIEW); - } - event->accept(); - return; - } - - if (m_d->mode==DRAGZOOMHOLD) {//Fixme: also doubleclick event! - setMode(CHANGEVIEW); - event->accept(); - return; - } - - - if (m_d->mode==PICK) { - if (event->buttons()!=Qt::LeftButton) { - QGraphicsView::mousePressEvent(event); - return; - } - //If we have previous selections already, and the mult select key - //is down, then we will only consider items in the same collection - //as active. - // std::cout<<"pick mouse press. Multiselection stored:"<<m_d->ic_multiselection<<std::endl; - bool continueselection = m_d->ic_multiselection && (event->modifiers() & Qt::ShiftModifier); - QGraphicsItem*item(0);VP1GraphicsItemCollection*ic(0); - -// QPoint pickpoint = m_d->transform ? -// mapFromScene(m_d->transform->inverseTransform( mapToScene(event->pos()))) -// : event->pos(); - QPoint pickpoint = event->pos(); - if (continueselection) { - assert(m_d->ic_multiselection); - m_d->locateActiveItemAtPoint(item,ic,pickpoint,m_d->ic_multiselection); - if (!item) { - //shift was down, and the user did not hit anything - QGraphicsView::mousePressEvent(event); - return; - } - } else { - m_d->locateActiveItemAtPoint(item,ic,pickpoint); - } - - if (item) { - assert(ic); - if (ic->interactionMode()==VP1GraphicsItemCollection::SINGLEPICKS) { - clearSelections(); - m_d->setNewSelected(item); - ic->itemPickedPrivate(item); - } else if (ic->interactionMode()==VP1GraphicsItemCollection::EVENTS) { - clearSelections(); - event->accept(); - ic->itemGotEventPrivate(item,event); - return; - } else if (ic->interactionMode()==VP1GraphicsItemCollection::SELECTIONS) { - assert(ic); - VP1GraphicsItemCollection * tmpic = ic; - m_d->ic_multiselection=ic; - m_d->setNewSelected(item,continueselection); - emitSelectionChanged(tmpic); - } else { - assert(0); - } - } else { - clearSelections(); - } - } - - QGraphicsView::mousePressEvent(event); - return; -} - -//____________________________________________________________________ -void VP1GraphicsView::mouseReleaseEvent(QMouseEvent *event) -{ - - //Fixme: transformed pos - if (m_d->mode==CHANGEVIEW&&event->buttons()==(Qt::LeftButton|Qt::MidButton)) { - event->accept(); - m_d->dragzoom_startpoint=event->pos(); - setMode(DRAGZOOM); - return; - } - - if (m_d->mode==DRAGZOOM&&event->buttons()!=(Qt::LeftButton|Qt::MidButton)) { - event->accept(); - setMode(CHANGEVIEW); - return; - } - - if (m_d->mode==PICK) { -// foreach (QGraphicsItem*item,items(event->pos())) { -// if (item==static_cast<QGraphicsItem*>(m_d->selectionoutline))//Fixme: Dont do the cast here. -// continue; -// foreach(VP1GraphicsItemCollection* ic,m_d->cols_act) { -// if (ic->itemBelongsAndIsPresentlyActive(item)) { -// event->accept(); -// if (ic->interactionMode()==VP1GraphicsItemCollection::EVENTS) { -// //EMIT EVENT SIGNAL! -// return; -// } -// if (m_d->selecteditem==item) { -// QGraphicsView::mouseReleaseEvent(event); -// return; -// } -// m_d->setNewSelected(item); -// //EMIT pick/selection signals. -// } -// } -// } - } - QGraphicsView::mouseReleaseEvent(event); - return; - -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::locateActiveItemAtPoint(QGraphicsItem*&item, - VP1GraphicsItemCollection*& ic, - const QPoint& pos, - VP1GraphicsItemCollection * searchic) { - - //We turn the point into a small circle - to get some chance of picking lines, degenerate rectangles, etc. - const double tol = 2.0; - QRectF tolrect( pos.x()-tol, pos.y()-tol, 2*tol, 2*tol ); - - QPainterPath p; - if (transform&&transformactive) { - QPainterPath ptmp; - ptmp.addEllipse(tolrect); - QPainterPath ptmp2; - transform->inverseTransformPath(view->mapToScene(ptmp),ptmp2); - QPainterPath p = view->mapFromScene(ptmp2); - } else { - p.addEllipse(tolrect); - } - - //Fixme: use faster stl style iterators. - foreach(QGraphicsItem* item2,view->items(p)) { - if (searchic) { - if (searchic->itemBelongsAndIsPresentlyActive(item2)) { - item=item2; - ic=searchic; - return; - } - } else { - foreach(VP1GraphicsItemCollection* ic2,cols_act) { - if (ic2->itemBelongsAndIsPresentlyActive(item2)) { - item=item2; - ic=ic2; - return; - } - } - } - } - assert(!item&&!ic); - return; -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::HighLightItemBeingDeleted(HighLightItem*hlitem) -{ - -#ifndef NDEBUG - QMapIterator<QGraphicsItem*,HighLightItem*> ittest(selecteditems); - assert(ittest.findNext(hlitem)); -#endif - - QMap<QGraphicsItem*,HighLightItem*>::iterator - it = selecteditems.begin(), itE = selecteditems.end(); - for (;it!=itE;++it) { - if (it.value()==hlitem) { - std::cout<<"lala1"<<std::endl; - selecteditems.erase(it); - std::cout<<"lala2"<<std::endl; - break; - } - } - std::cout<<"hej"<<std::endl; - - if (ic_multiselection) { - view->emitSelectionChanged(ic_multiselection); - } - std::cout<<"dav"<<std::endl; -#ifndef NDEBUG - QMapIterator<QGraphicsItem*,HighLightItem*> ittest2(selecteditems); - assert(!ittest2.findNext(hlitem)); -#endif -} - -//____________________________________________________________________ -void VP1GraphicsView::clearSelections() {//Fixme: only clear - //selections of certain - //collections? (so the - //permanent items stay - //selected?) - - bool haditemsinselection = m_d->ic_multiselection && !m_d->selecteditems.empty(); - - //Remove highlight items: - QMapIterator<QGraphicsItem*,HighLightItem*> it(m_d->selecteditems); - while (it.hasNext()) { - it.next(); - it.value()->sendsignalondelete = false; - //assert(!m_d->scene->items().contains(it.key())); - if (m_d->scene->items().contains(it.value())) { - m_d->scene->removeItem(it.value()); - // delete it.value(); - } - } - - //Clear lists - possibly emit a signal: - m_d->selecteditems.clear(); - if (m_d->clearselectionsemitsignals&&haditemsinselection) { - emitSelectionChanged(m_d->ic_multiselection); - m_d->ic_multiselection = 0;//TEST - } - m_d->clearselectionsemitsignals=true; -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::deselect(QGraphicsItem*item) -{ - if (selecteditems.count()==1) { - view->clearSelections(); - return; - } - - assert(selecteditems.contains(item)); - QMap<QGraphicsItem*,HighLightItem*>::iterator it = selecteditems.find(item); - if (scene->items().contains(it.value())) { - assert(scene->items().contains(it.value())); - scene->removeItem(it.value()); - it.value()->sendsignalondelete = false; - delete it.value(); - } - assert(selecteditems.contains(item)); - selecteditems.erase(it); - assert(!selecteditems.contains(item)); -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::select(QGraphicsItem*item) -{ - assert(!selecteditems.contains(item)); - - QPainterPath path = item->shape(); - - HighLightItem* outline = new HighLightItem(path,item,view); - outline->setBrush(QColor(250,0,250,100)); - outline->setPen(QPen(Qt::red,0,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); - scene->addItem(outline); - - selecteditems.insert(item,outline); - -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::setNewSelected(QGraphicsItem*item,const bool& continueselection) { - - assert(item); - - if (continueselection) { - if (selecteditems.contains(item)) - deselect(item); - else - select(item); - return; - } else { - if (!selecteditems.empty()) { - clearselectionsemitsignals=false; - view->clearSelections(); - } - select(item); - } - -// if (selecteditems.contains(item)) -// view->addselect(item); -// view->removeselect(item); - -// if (!continueselection&&!selecteditems.empty()) { -// view->clearSelections(); -// } - - -} - -//____________________________________________________________________ -void VP1GraphicsView::seekToPoint(QPointF targetpoint) { - abortZoomAnimation();//In case there is already an animation running we abort it. - QRectF currentview = mapToScene(viewport()->rect()).boundingRect(); - double w1= currentview.width(), h1= currentview.height(); - double w2 = w1/m_d->zoomfactoronseek, h2 = h1/m_d->zoomfactoronseek; - double x2 = targetpoint.x()-0.5*w2, y2 = targetpoint.y()-0.5*h2; - initiateAnimatedZoomTo( QRectF(x2,y2,w2,h2) ); -} - -//____________________________________________________________________ -void VP1GraphicsView::initiateAnimatedZoomTo( QRectF goal ) -{ - abortZoomAnimation(); - if (m_d->zoomanim_nsteps==1) { - fitInView(goal); - return; - } - - QRectF currentview = mapToScene(viewport()->rect()).boundingRect(); - - double w1 = currentview.width(), h1 = currentview.height(); - double x1 = currentview.x(), y1 = currentview.y(); - - double w2 = goal.width(), h2 = goal.height(); - double x2 = goal.x(), y2 = goal.y(); - - const double eps = 1.0/m_d->zoomanim_nsteps; - for (double f = eps; f < 1.0+0.5*eps; f+=eps ) { - //f values are spaced linearly between eps and 1.0. Let us - //construct something which has values packed closer near 1.0 (for - //that nice smooth slow-down feel): - double f2 = sqrt(f); - m_d->zoomanim_queue.enqueue(QRectF( x1*(1.0-f2)+x2*f2, y1*(1.0-f2)+y2*f2, - w1*(1.0-f2)+w2*f2, h1*(1.0-f2)+h2*f2 )); - } - - m_d->savedrenderhints=renderHints(); - setRenderHints(0); - m_d->zoomanim_timer->start(); -} - -//____________________________________________________________________ -void VP1GraphicsView::updateZoomAnimation() -{ - assert(!m_d->zoomanim_queue.empty()); - //For testing: - // QGraphicsRectItem * item = new QGraphicsRectItem(m_d->zoomanim_queue.dequeue()); - // item->setPen(QPen(Qt::blue,0,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); - // scene()->addItem(item); - fitInView( m_d->zoomanim_queue.dequeue(), Qt::KeepAspectRatio ); - if (m_d->zoomanim_queue.empty()) - m_d->zoomanim_timer->stop(); -} - -//____________________________________________________________________ -void VP1GraphicsView::abortZoomAnimation() -{ - if (m_d->zoomanim_timer->isActive()) - m_d->zoomanim_timer->stop(); - if (!m_d->zoomanim_queue.empty()) - m_d->zoomanim_queue.clear(); - if (m_d->savedrenderhints) - setRenderHints(m_d->savedrenderhints); - m_d->savedrenderhints=0;//Fixme: renderhints changed during an - //animation cycle might not be saved... Should - //override the renderhints methods to avoid - //this. -} - - -//____________________________________________________________________ -void VP1GraphicsView::setAnimatedZoomSteps( int n ) -{ - assert(n>=1); - m_d->zoomanim_nsteps = n; - m_d->zoomanim_timer->setInterval(std::max(1,static_cast<int>(m_d->zoomanim_totaltime/m_d->zoomanim_nsteps+0.5))); - //Same as just below. -} - -//____________________________________________________________________ -void VP1GraphicsView::setAnimatedZoomTime( double t ) -{ - m_d->zoomanim_totaltime = t; - m_d->zoomanim_timer->setInterval(std::max(1,static_cast<int>(m_d->zoomanim_totaltime/m_d->zoomanim_nsteps+0.5))); - //Same as just above. -} - -//____________________________________________________________________ -void VP1GraphicsView::setZoomFactorOnSeek( double zf ) -{ - m_d->zoomfactoronseek = zf; -} - -//____________________________________________________________________ -void VP1GraphicsView::viewHome() { - - const bool animatedhome = true;//Fixme: option? - if (m_d->home == QRect()) { - if (animatedhome) { - if (m_d->transform&&m_d->transformactive) - initiateAnimatedZoomTo(m_d->transform->transform(scene()->sceneRect())); - else - initiateAnimatedZoomTo(scene()->sceneRect()); - } else { - fitViewToContents(); - } - } else { - if (animatedhome) { - initiateAnimatedZoomTo(m_d->home); - } else { - fitInView( m_d->home, Qt::KeepAspectRatio ); - } - } -} - -//____________________________________________________________________ -void VP1GraphicsView::setHome() { - m_d->home=mapToScene(viewport()->rect()).boundingRect(); -} - -//____________________________________________________________________ -void VP1GraphicsView::emitSelectionChanged(VP1GraphicsItemCollection *ic) { - QList<QGraphicsItem*> emitlist = m_d->selecteditems.keys(); - if (emitlist==m_d->lastemittedselecteditems) - return; - m_d->lastemittedselecteditems=emitlist; - ic->selectionChangedPrivate(emitlist); -} - -//____________________________________________________________________ -void VP1GraphicsView::setDisallowInteractions(VP1GraphicsItemCollection*ic, const bool& disallow ) -{ - if (m_d->cols_override_inactive.contains(ic)==disallow) - return; - - if ( disallow ) { - m_d->cols_override_inactive.insert(ic); - if ( m_d->cols_all.contains(ic) ) - ic->setTemporaryIgnoreInteractions(true); - } else { - m_d->cols_override_inactive.remove(ic); - if ( m_d->cols_all.contains(ic) && m_d->mode != PICK ) - ic->setTemporaryIgnoreInteractions(false); - } -} - -//____________________________________________________________________ -void VP1GraphicsView::setDisallowMovable(VP1GraphicsItemCollection*ic, const bool& disallow ) -{ - if (m_d->cols_override_unmovable.contains(ic)==disallow) - return; - - if (disallow) { - m_d->cols_override_unmovable.insert(ic); - if (m_d->cols_all.contains(ic)) - ic->setTemporaryIgnoreMovable(true); - } else { - m_d->cols_override_unmovable.remove(ic); - if ( m_d->cols_all.contains(ic) && m_d->mode != PICK ) - ic->setTemporaryIgnoreMovable(false); - } -} - -//____________________________________________________________________ -void VP1GraphicsView::print() -{ - //Fixme: This does not really work well... Check again in QT 4.3? - QPrinter printer; - QPrintDialog dialog(&printer, this); - if (dialog.exec() == QDialog::Accepted) { - QPainter painter(&printer); - render(&painter); - } -} - -//____________________________________________________________________ -void VP1GraphicsView::saveImage() -{ - QString guess; - if (m_d->currentsaveimagefile.isEmpty()) { - QString base=VP1Settings::defaultFileSelectDirectory()+QDir::separator()+"vp1_capture"; - guess=base; - int i(2); - while (QFile::exists(guess+".png")) - guess=base+"_"+QString::number(i++); - guess+=".png"; - } else { - guess=m_d->currentsaveimagefile; - } - - QString filename = QFileDialog::getSaveFileName(0, "Select target image file", guess, - "Image (*.png *.bmp)", - 0,QFileDialog::DontResolveSymlinks); - if(filename.isEmpty()) - return; - - QPixmap pm = QPixmap::grabWidget ( viewport() ); - if (!(filename.endsWith(".png",Qt::CaseInsensitive)||filename.endsWith(".bmp",Qt::CaseInsensitive))) - filename += ".png"; - - pm.save(filename); - m_d->currentsaveimagefile = filename; -} - -// //____________________________________________________________________ -// void VP1GraphicsView::paintEvent ( QPaintEvent * event ) -// { -// //Fixme: Reimplementing the paintEvent like this is supposedly -// //helpful in some circumstances... I have not really benchmarked -// //whether it actually helps though... -// // QPaintEvent * newEvent = new QPaintEvent(event->region().boundingRect()); -// // QGraphicsView::paintEvent(newEvent); -// // delete newEvent; -// } - -//____________________________________________________________________ -void VP1GraphicsView::drawForeground ( QPainter * painter, const QRectF & /*rect*/ ) { - - //Fixme: use rect? - if (!m_d->showhelptext) - return; - QRect imgrect = viewport()->rect(); - imgrect.setWidth(imgrect.width()*3); - imgrect.setHeight(imgrect.height()*3); - if (!m_d->helptextimage||m_d->helptextimage->size()!=imgrect.size()) - m_d->createNewHelptextImage(imgrect);//viewport()->rect()); - painter->setRenderHint(QPainter::Antialiasing, false); - painter->drawImage(mapToScene(viewport()->rect()).boundingRect(),*(m_d->helptextimage), - imgrect); -} - -//____________________________________________________________________ -void VP1GraphicsView::Imp::createNewHelptextImage(const QRect& imrect) -{ - if(helptext.isEmpty()) { - helptext.setHtml ("<html>\n" - "\n" - "<h2>How to navigate a VP1GraphicsView</h2>\n" - "\n" - " <p>\n <b>H/F1</b> Show this help." - " \n <b>S</b> Seek mode.\n" - " \n <b>+/-</b> Zoom.\n" - " \n <b>CTRL+HOME</b> Set home.\n" - " \n <b>HOME</b> View home.\n" - " \n <b>1</b> View all.\n" - " \n <b>ESC</b> Switch between view and pick mode.\n" - " \n <b>P</b> Print view.\n" - " \n <b>CTRL+P</b> Save snapshot to image file.</p>\n" - " <p>\n <b>Mouse wheel</b> zoom. Use <b>CTRL</b> and <b>SHIFT</b> for finegrained control.</p>\n" - " <p>\n To select items (in pick mode), click on them. Selected multiple by holding down <b>SHIFT</b>.</p>\n" - "\n" - "<p>\n" - " Please report any bugs to <i>Thomas.Kittelmann@cern.ch</i>.\n" - "</p>\n" - "\n" - "\n" - "</html>" ); - QFont myfont("Helvetica",36); - // myfont.setPointSize(400); - helptext.setDefaultFont ( myfont ); - // helptext.defaultFont().setPointSize(400); - } - - delete helptextimage; - helptextimage = new QImage(imrect.size(), QImage::Format_ARGB32);//Fixme delete in destructor!! - - QPainter painter; - painter.begin(helptextimage); - - int pageWidth = qMax(imrect.width() - 100, 100); - int pageHeight = qMax(imrect.height() - 100, 100); - if (pageWidth != helptext.pageSize().width()) { - helptext.setPageSize(QSize(pageWidth, pageHeight)); - } - - QRect textRect(imrect.width() / 2 - pageWidth / 2, - imrect.height() / 2 - pageHeight / 2, - pageWidth, - pageHeight); - int pad = 10; - QRect clearRect = textRect.adjusted(-pad, -pad, pad, pad); - painter.setPen(Qt::NoPen); - painter.setBrush(QColor(0, 0, 0, 63)); - int shade = 10; - painter.drawRect(clearRect.x() + clearRect.width() + 1, - clearRect.y() + shade, - shade, - clearRect.height() + 1); - painter.drawRect(clearRect.x() + shade, - clearRect.y() + clearRect.height() + 1, - clearRect.width() - shade + 1, - shade); - - painter.setRenderHint(QPainter::Antialiasing, false); - painter.setBrush(QColor(255, 255, 255, 220)); - painter.setPen(Qt::black); - painter.drawRect(clearRect); - - painter.setClipRegion(textRect, Qt::IntersectClip); - painter.translate(textRect.topLeft()); - - QAbstractTextDocumentLayout::PaintContext ctx; - - QLinearGradient g(0, 0, 0, textRect.height()); - g.setColorAt(0, Qt::black); - g.setColorAt(0.9, Qt::black); - g.setColorAt(1, Qt::transparent); - - QPalette pal = view->viewport()->palette(); - pal.setBrush(QPalette::Text, g); - - ctx.palette = pal; - ctx.clip = QRect(0, 0, textRect.width(), textRect.height()); - helptext.documentLayout()->draw(&painter, ctx); - - painter.end(); - -} - -//____________________________________________________________________ -void VP1GraphicsView::drawItems(QPainter *painter, int numItems, - QGraphicsItem *items[], - const QStyleOptionGraphicsItem options[]) -{ - - if (!(m_d->transform&&m_d->transformactive)) { - QGraphicsView::drawItems(painter,numItems,items,options); - //Fixme: implement own drawing here also - to make sure inbuilt selection stuff is never shown? - return; - } - - for (int i = 0; i < numItems; ++i) { - QGraphicsItem *item = items[i]; - painter->save(); - painter->setMatrix(item->sceneMatrix(), true);//?? - // std::cout<< item->sceneMatrix().isIdentity()<<std::endl; - // std::cout<< item->sceneMatrix().dx()<<" : "<<item->sceneMatrix().dy()<<std::endl; - m_d->transform->paintItem(painter, item); - painter->restore(); - } -} diff --git a/GeoModelVisualization/VP1Base/src/VP1MaterialButton.cxx b/GeoModelVisualization/VP1Base/src/VP1MaterialButton.cxx index 929fb13c504f26a929984bcbc4c2f589e05bea6f..69cbbcf17c06e671a9a133690c136e00cfffde0b 100644 --- a/GeoModelVisualization/VP1Base/src/VP1MaterialButton.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1MaterialButton.cxx @@ -327,6 +327,10 @@ void VP1MaterialButton::Imp::initEditWindow() editwindow_ui.label_num_simple_brightness->setNum(lastapplied_brightness); editwindow_ui.colbutton_simple_colour->setColor(lastapplied_diffuse); + QObject::connect(editwindow_ui.slider_shininess, SIGNAL(valueChanged (int)), editwindow_ui.label_num_shininess, SLOT(setNum(int))); + QObject::connect(editwindow_ui.slider_simple_brightness, SIGNAL(valueChanged(int)), editwindow_ui.label_num_simple_brightness, SLOT(setNum(int))); + + #if defined BUILDVP1LIGHT bool checkDisallowMultipleChannels = VP1QtUtils::expertSettingIsOn("general","ExpertSettings/VP1_DISALLOW_MULTIPLE_CHANNELS"); #else diff --git a/GeoModelVisualization/VP1Base/src/VP1QtInventorUtils.cxx b/GeoModelVisualization/VP1Base/src/VP1QtInventorUtils.cxx index 3ad0dd37918f415893ac03386271591bdf885670..e89ee75e2678ec68df3aaaf06b41070a997f620e 100644 --- a/GeoModelVisualization/VP1Base/src/VP1QtInventorUtils.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1QtInventorUtils.cxx @@ -46,7 +46,7 @@ #include <QByteArray> #include <QTextStream> #include <QSlider> -#include <QGLFormat> +//#include <QGLFormat> #include <iostream> @@ -522,11 +522,11 @@ QImage VP1QtInventorUtils::renderToImage(VP1ExaminerViewer *ra, int pixels_x, in myViewport.setWindowSize(SbVec2s(pixels_x,pixels_y)); // init the random number generator a get a random filename for the temp file - qsrand(QTime::currentTime().msecsTo(QTime(0,0))); + srand(QTime::currentTime().msecsTo(QTime(0,0))); QString tmppath(QDir::tempPath()); if (!tmppath.endsWith(QDir::separator())) tmppath+=QDir::separator(); - QString tmpfile = tmppath+"vp1tmpfile" +QString::number(qrand())+QString::number(qrand())+".rgb"; + QString tmpfile = tmppath+"vp1tmpfile" +QString::number(rand())+QString::number(rand())+".rgb"; // declare a new renderer with the viewport created above SoOffscreenRenderer *myRenderer = new SoOffscreenRenderer(myViewport); @@ -1434,7 +1434,7 @@ bool VP1QtInventorUtils::writeGraphToFile(SoNode*root, const QString& filename) QFile data(filename); if (data.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&data); - out << s << endl; + out << s << Qt::endl; return true; } else { return false; diff --git a/GeoModelVisualization/VP1Base/src/VP1TabBar.cxx b/GeoModelVisualization/VP1Base/src/VP1TabBar.cxx index 5b9a63ea69833beedc226cbbe93462e78a3c8f60..7e40294ed8a05d6126029580b7a3a0b0645355c8 100644 --- a/GeoModelVisualization/VP1Base/src/VP1TabBar.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1TabBar.cxx @@ -133,7 +133,7 @@ void VP1TabBar::mouseMoveEvent( QMouseEvent *event ) return; } } - } else if ( event->buttons() == Qt::MidButton ) { + } else if ( event->buttons() == Qt::MiddleButton ) { if ( m_d->mReorderStartTab == -1 ) { int delay = 5;//TK fixme KGlobalSettings::dndEventDelay(); QPoint newPos = event->pos(); @@ -178,7 +178,7 @@ void VP1TabBar::activateDragSwitchTab() void VP1TabBar::mouseReleaseEvent( QMouseEvent *event ) { - if ( event->button() == Qt::MidButton ) { + if ( event->button() == Qt::MiddleButton ) { if ( m_d->mReorderStartTab == -1 ) { int tab = selectTab( event->pos() ); if ( tab != -1 ) { @@ -239,10 +239,7 @@ void VP1TabBar::dropEvent( QDropEvent *event ) #ifndef QT_NO_WHEELEVENT void VP1TabBar::wheelEvent( QWheelEvent *event ) { - if ( event->orientation() == Qt::Horizontal ) - return; - - emit( wheelDelta( event->delta() ) ); + emit( wheelDelta( event->pixelDelta().x() ) ); } #endif diff --git a/GeoModelVisualization/VP1Base/src/VP1TabWidget.cxx b/GeoModelVisualization/VP1Base/src/VP1TabWidget.cxx index b2e2bb470d82314edb106de4ba78afdb6d8900da..8ce7ed0daac5810691bff3f4c4685eda74695de4 100644 --- a/GeoModelVisualization/VP1Base/src/VP1TabWidget.cxx +++ b/GeoModelVisualization/VP1Base/src/VP1TabWidget.cxx @@ -274,13 +274,13 @@ int VP1TabWidget::tabBarWidthForMaxChars( int /*maxLength*/ ) //TK-fixme. Just use elide here? //TK-fixme newTitle = KStringHandler::rsqueeze( newTitle, maxLength ).leftJustified( m_d->m_minLength, ' ' ); - int lw = fm.width( newTitle ); + int lw = fm.boundingRect( newTitle ).width(); int iw = 0; if ( !tabBar()->tabIcon( i ).isNull() ){ iw = tabBar()->tabIcon( i ).pixmap( style()->pixelMetric( QStyle::PM_SmallIconSize ), QIcon::Normal ).width() + 4; } x += ( tabBar()->style()->sizeFromContents( QStyle::CT_TabBarTab, 0L, - QSize( qMax( lw + hframe + iw, QApplication::globalStrut().width() ), 0 ), + QSize(lw + hframe + iw, 0 ), this ) ).width(); } @@ -346,11 +346,9 @@ void VP1TabWidget::dropEvent( QDropEvent *event ) #ifndef QT_NO_WHEELEVENT void VP1TabWidget::wheelEvent( QWheelEvent *event ) { - if ( event->orientation() == Qt::Horizontal ) - return; - if ( m_d->isEmptyTabbarSpace( event->pos() ) ) - wheelDelta( event->delta() ); + if ( m_d->isEmptyTabbarSpace(event->position().toPoint() ) ) + wheelDelta( event->pixelDelta().x() ); else event->ignore(); } @@ -392,7 +390,7 @@ void VP1TabWidget::mousePressEvent( QMouseEvent *event ) emit( contextMenu( mapToGlobal( event->pos() ) ) ); return; } - } else if ( event->button() == Qt::MidButton ) { + } else if ( event->button() == Qt::MiddleButton ) { if ( m_d->isEmptyTabbarSpace( event->pos() ) ) { emit( mouseMiddleClick() ); return; diff --git a/GeoModelVisualization/VP1Base/src/vp1materialbuttonform.ui b/GeoModelVisualization/VP1Base/src/vp1materialbuttonform.ui index 60d143485e85cd2bf5a0489d2c3cf86299d43e34..6012d89b7bcfb75aad5caec516bd57ba8deed8a3 100644 --- a/GeoModelVisualization/VP1Base/src/vp1materialbuttonform.ui +++ b/GeoModelVisualization/VP1Base/src/vp1materialbuttonform.ui @@ -1,58 +1,59 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>VP1MaterialButtonForm</class> - <widget class="QWidget" name="VP1MaterialButtonForm" > - <property name="geometry" > + <widget class="QWidget" name="VP1MaterialButtonForm"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>545</width> + <width>580</width> <height>292</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Edit Material</string> </property> - <layout class="QVBoxLayout" > + <layout class="QVBoxLayout"> <item> - <layout class="QGridLayout" > - <item row="0" column="0" > - <widget class="QStackedWidget" name="stackedWidget" > - <property name="currentIndex" > - <number>0</number> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QStackedWidget" name="stackedWidget"> + <property name="currentIndex"> + <number>1</number> </property> - <widget class="QWidget" name="page_simple" > - <layout class="QVBoxLayout" > + <widget class="QWidget" name="page_simple"> + <layout class="QVBoxLayout"> <item> - <layout class="QHBoxLayout" > + <layout class="QHBoxLayout"> <item> - <widget class="QLabel" name="label_10" > - <property name="toolTip" > + <widget class="QLabel" name="label_10"> + <property name="toolTip"> <string>Material colour</string> </property> - <property name="text" > + <property name="text"> <string>Colo&ur:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>colbutton_simple_colour</cstring> </property> </widget> </item> <item> - <widget class="VP1ColorSelectButton" name="colbutton_simple_colour" > - <property name="toolTip" > + <widget class="VP1ColorSelectButton" name="colbutton_simple_colour"> + <property name="toolTip"> <string>Material colour</string> </property> - <property name="text" > + <property name="text"> <string/> </property> </widget> </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> @@ -63,123 +64,123 @@ </layout> </item> <item> - <layout class="QGridLayout" > - <item row="0" column="1" > - <widget class="QSlider" name="slider_simple_brightness" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <layout class="QGridLayout"> + <item row="0" column="1"> + <widget class="QSlider" name="slider_simple_brightness"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>120</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Material brightness</string> </property> - <property name="maximum" > + <property name="maximum"> <number>100</number> </property> - <property name="value" > + <property name="value"> <number>20</number> </property> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="0" column="2" > - <widget class="QLabel" name="label_num_simple_brightness" > - <property name="minimumSize" > + <item row="0" column="2"> + <widget class="QLabel" name="label_num_simple_brightness"> + <property name="minimumSize"> <size> <width>20</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Material brightness</string> </property> - <property name="text" > + <property name="text"> <string>20</string> </property> - <property name="alignment" > + <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="label_15" > - <property name="toolTip" > + <item row="1" column="0"> + <widget class="QLabel" name="label_15"> + <property name="toolTip"> <string>Transparency of the material</string> </property> - <property name="text" > + <property name="text"> <string>&Transparency:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>slider_simple_transparency</cstring> </property> </widget> </item> - <item row="1" column="1" > - <widget class="QSlider" name="slider_simple_transparency" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <item row="1" column="1"> + <widget class="QSlider" name="slider_simple_transparency"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>120</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Transparency of the material</string> </property> - <property name="maximum" > + <property name="maximum"> <number>100</number> </property> - <property name="value" > + <property name="value"> <number>0</number> </property> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="1" column="2" > - <widget class="QLabel" name="label_num_simple_transparency" > - <property name="minimumSize" > + <item row="1" column="2"> + <widget class="QLabel" name="label_num_simple_transparency"> + <property name="minimumSize"> <size> <width>20</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Transparency of the material</string> </property> - <property name="text" > + <property name="text"> <string>0</string> </property> - <property name="alignment" > + <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> - <item row="0" column="0" > - <widget class="QLabel" name="label_13" > - <property name="toolTip" > + <item row="0" column="0"> + <widget class="QLabel" name="label_13"> + <property name="toolTip"> <string>Material brightness</string> </property> - <property name="text" > + <property name="text"> <string>Br&ightness:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>slider_simple_brightness</cstring> </property> </widget> @@ -188,10 +189,10 @@ </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> @@ -201,100 +202,100 @@ </item> </layout> </widget> - <widget class="QWidget" name="page_detailed" > - <layout class="QVBoxLayout" > + <widget class="QWidget" name="page_detailed"> + <layout class="QVBoxLayout"> <item> - <layout class="QHBoxLayout" > + <layout class="QHBoxLayout"> <item> - <layout class="QGridLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="label_3" > - <property name="toolTip" > + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="toolTip"> <string>Base colour of the material.</string> </property> - <property name="text" > + <property name="text"> <string>D&iffuse colour:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>colbutton_diffuse</cstring> </property> </widget> </item> - <item row="0" column="1" > - <widget class="VP1ColorSelectButton" name="colbutton_diffuse" > - <property name="toolTip" > + <item row="0" column="1"> + <widget class="VP1ColorSelectButton" name="colbutton_diffuse"> + <property name="toolTip"> <string>Base colour of the material.</string> </property> - <property name="text" > + <property name="text"> <string/> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="label_5" > - <property name="toolTip" > + <item row="1" column="0"> + <widget class="QLabel" name="label_5"> + <property name="toolTip"> <string>Reflected colour in response to the ambient lighting in the scene</string> </property> - <property name="text" > + <property name="text"> <string>A&mbient colour:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>colbutton_ambient</cstring> </property> </widget> </item> - <item row="1" column="1" > - <widget class="VP1ColorSelectButton" name="colbutton_ambient" > - <property name="toolTip" > + <item row="1" column="1"> + <widget class="VP1ColorSelectButton" name="colbutton_ambient"> + <property name="toolTip"> <string>Reflected colour in response to the ambient lighting in the scene</string> </property> - <property name="text" > + <property name="text"> <string/> </property> </widget> </item> - <item row="2" column="0" > - <widget class="QLabel" name="label_8" > - <property name="toolTip" > + <item row="2" column="0"> + <widget class="QLabel" name="label_8"> + <property name="toolTip"> <string>Reflective quality of highlights</string> </property> - <property name="text" > + <property name="text"> <string>S&pecular colour:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>colbutton_specular</cstring> </property> </widget> </item> - <item row="2" column="1" > - <widget class="VP1ColorSelectButton" name="colbutton_specular" > - <property name="toolTip" > + <item row="2" column="1"> + <widget class="VP1ColorSelectButton" name="colbutton_specular"> + <property name="toolTip"> <string>Reflective quality of highlights</string> </property> - <property name="text" > + <property name="text"> <string/> </property> </widget> </item> - <item row="3" column="0" > - <widget class="QLabel" name="label_9" > - <property name="toolTip" > + <item row="3" column="0"> + <widget class="QLabel" name="label_9"> + <property name="toolTip"> <string>Colour emitted by the material</string> </property> - <property name="text" > + <property name="text"> <string>&Emissive colour:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>colbutton_emissive</cstring> </property> </widget> </item> - <item row="3" column="1" > - <widget class="VP1ColorSelectButton" name="colbutton_emissive" > - <property name="toolTip" > + <item row="3" column="1"> + <widget class="VP1ColorSelectButton" name="colbutton_emissive"> + <property name="toolTip"> <string>Colour emitted by the material</string> </property> - <property name="text" > + <property name="text"> <string/> </property> </widget> @@ -303,10 +304,10 @@ </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> @@ -317,123 +318,123 @@ </layout> </item> <item> - <layout class="QGridLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="label" > - <property name="toolTip" > + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="toolTip"> <string>Degree of shininess, ranging from 0 for a diffuse surface with no shininess to 100 for a highly polished surface</string> </property> - <property name="text" > + <property name="text"> <string>S&hininess:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>slider_shininess</cstring> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QSlider" name="slider_shininess" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <item row="0" column="1"> + <widget class="QSlider" name="slider_shininess"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>120</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Degree of shininess, ranging from 0 for a diffuse surface with no shininess to 100 for a highly polished surface</string> </property> - <property name="maximum" > + <property name="maximum"> <number>100</number> </property> - <property name="value" > + <property name="value"> <number>20</number> </property> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="0" column="2" > - <widget class="QLabel" name="label_num_shininess" > - <property name="minimumSize" > + <item row="0" column="2"> + <widget class="QLabel" name="label_num_shininess"> + <property name="minimumSize"> <size> <width>20</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Degree of shininess, ranging from 0 for a diffuse surface with no shininess to 100 for a highly polished surface</string> </property> - <property name="text" > + <property name="text"> <string>20</string> </property> - <property name="alignment" > + <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="label_2" > - <property name="toolTip" > + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="toolTip"> <string>Transparency of the material</string> </property> - <property name="text" > + <property name="text"> <string>&Transparency:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>slider_transparency</cstring> </property> </widget> </item> - <item row="1" column="1" > - <widget class="QSlider" name="slider_transparency" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <item row="1" column="1"> + <widget class="QSlider" name="slider_transparency"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>120</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Transparency of the material</string> </property> - <property name="maximum" > + <property name="maximum"> <number>100</number> </property> - <property name="value" > + <property name="value"> <number>0</number> </property> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="1" column="2" > - <widget class="QLabel" name="label_num_transparency" > - <property name="minimumSize" > + <item row="1" column="2"> + <widget class="QLabel" name="label_num_transparency"> + <property name="minimumSize"> <size> <width>20</width> <height>0</height> </size> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Transparency of the material</string> </property> - <property name="text" > + <property name="text"> <string>0</string> </property> - <property name="alignment" > + <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> @@ -444,15 +445,15 @@ </widget> </widget> </item> - <item row="0" column="1" > + <item row="0" column="1"> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeType" > + <property name="sizeType"> <enum>QSizePolicy::Fixed</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>16</width> <height>20</height> @@ -460,9 +461,9 @@ </property> </spacer> </item> - <item row="0" column="2" > - <widget class="QWidget" native="1" name="widget_3dpreview" > - <property name="minimumSize" > + <item row="0" column="2"> + <widget class="QWidget" name="widget_3dpreview" native="true"> + <property name="minimumSize"> <size> <width>200</width> <height>200</height> @@ -470,54 +471,54 @@ </property> </widget> </item> - <item row="1" column="2" > - <layout class="QHBoxLayout" > + <item row="1" column="2"> + <layout class="QHBoxLayout"> <item> - <widget class="QLabel" name="label_4" > - <property name="text" > + <widget class="QLabel" name="label_4"> + <property name="text"> <string>Preview:</string> </property> </widget> </item> <item> - <widget class="QRadioButton" name="radioButton_cone" > - <property name="toolTip" > + <widget class="QRadioButton" name="radioButton_cone"> + <property name="toolTip"> <string>Use a cone for the preview above</string> </property> - <property name="text" > + <property name="text"> <string>C&one</string> </property> </widget> </item> <item> - <widget class="QRadioButton" name="radioButton_box" > - <property name="toolTip" > + <widget class="QRadioButton" name="radioButton_box"> + <property name="toolTip"> <string>Use a box for the preview above</string> </property> - <property name="text" > + <property name="text"> <string>&Box</string> </property> </widget> </item> <item> - <widget class="QRadioButton" name="radioButton_lines" > - <property name="toolTip" > + <widget class="QRadioButton" name="radioButton_lines"> + <property name="toolTip"> <string>Use lines for the preview above</string> </property> - <property name="text" > + <property name="text"> <string>&Lines</string> </property> </widget> </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeType" > + <property name="sizeType"> <enum>QSizePolicy::MinimumExpanding</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>1</width> <height>20</height> @@ -531,10 +532,10 @@ </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>527</width> <height>16</height> @@ -543,20 +544,20 @@ </spacer> </item> <item> - <layout class="QHBoxLayout" > + <layout class="QHBoxLayout"> <item> - <widget class="QPushButton" name="pushButton_switch_mode" > - <property name="text" > + <widget class="QPushButton" name="pushButton_switch_mode"> + <property name="text"> <string>&Switch to xxxxxx mode</string> </property> </widget> </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" > + <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> @@ -565,31 +566,31 @@ </spacer> </item> <item> - <widget class="QPushButton" name="pushButton_apply" > - <property name="toolTip" > + <widget class="QPushButton" name="pushButton_apply"> + <property name="toolTip"> <string>Apply current settings</string> </property> - <property name="text" > + <property name="text"> <string>&Apply</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pushButton_reset" > - <property name="toolTip" > + <widget class="QPushButton" name="pushButton_reset"> + <property name="toolTip"> <string>Reset to last applied settings</string> </property> - <property name="text" > + <property name="text"> <string>&Reset</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pushButton_close" > - <property name="toolTip" > + <widget class="QPushButton" name="pushButton_close"> + <property name="toolTip"> <string>Close material editor [Esc]</string> </property> - <property name="text" > + <property name="text"> <string>&Close</string> </property> </widget> @@ -625,53 +626,21 @@ </tabstops> <resources/> <connections> - <connection> - <sender>slider_shininess</sender> - <signal>valueChanged(int)</signal> - <receiver>label_num_shininess</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel" > - <x>213</x> - <y>171</y> - </hint> - <hint type="destinationlabel" > - <x>231</x> - <y>175</y> - </hint> - </hints> - </connection> <connection> <sender>pushButton_close</sender> <signal>clicked()</signal> <receiver>VP1MaterialButtonForm</receiver> <slot>hide()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>534</x> <y>285</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>544</x> <y>265</y> </hint> </hints> </connection> - <connection> - <sender>slider_simple_brightness</sender> - <signal>valueChanged(int)</signal> - <receiver>label_num_simple_brightness</receiver> - <slot>setNum(int)</slot> - <hints> - <hint type="sourcelabel" > - <x>177</x> - <y>64</y> - </hint> - <hint type="destinationlabel" > - <x>223</x> - <y>68</y> - </hint> - </hints> - </connection> </connections> </ui> diff --git a/GeoModelVisualization/VP1GeometryPlugin/CMakeLists.txt b/GeoModelVisualization/VP1GeometryPlugin/CMakeLists.txt index 4f4889e36606dc321efec033e86e9ebc295dec5f..488841c6cf9c6a1a9bc195155b330ef233ad21b4 100644 --- a/GeoModelVisualization/VP1GeometryPlugin/CMakeLists.txt +++ b/GeoModelVisualization/VP1GeometryPlugin/CMakeLists.txt @@ -7,7 +7,7 @@ file( GLOB HEADERS VP1GeometryPlugin/*.h ) # Add the library. add_library( GXGeometryPlugin MODULE ${SOURCES} ${HEADERS} ) target_link_libraries( GXGeometryPlugin - PUBLIC Qt5::Core GXBase + PUBLIC Qt${QT_VERSION}::Core GXBase PRIVATE GXGeometrySystems GXGuideLineSystems GXClashPointSystems GXHitDisplaySystems GXTrackDisplaySystems) target_include_directories( GXGeometryPlugin PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> diff --git a/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt b/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt index cdbaa073c9f8ea56c3f1cb43e4dcb3c8940945f3..a912560a308193c94e82447bcd5d3dc301478962 100644 --- a/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt +++ b/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt @@ -9,7 +9,7 @@ file( GLOB DATA share/*.jpg share/*.json ) # Add the library. add_library( GXGeometrySystems SHARED ${SOURCES} ${HEADERS} ${UIS} ) target_link_libraries( GXGeometrySystems - PUBLIC Coin::Coin Qt5::Core Qt5::Gui Qt5::Widgets + PUBLIC Coin::Coin Qt${QT_VERSION}::Core Qt${QT_VERSION}::Gui Qt${QT_VERSION}::Widgets GeoModelCore::GeoModelKernel GXBase PRIVATE nlohmann_json::nlohmann_json GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite GeoModelIO::GeoModelDBManager GXHEPVis ) diff --git a/GeoModelVisualization/VP1GeometrySystems/src/VolumeTreeModel.cxx b/GeoModelVisualization/VP1GeometrySystems/src/VolumeTreeModel.cxx index 4da1b981b50409805d4da5edf5c05cf388d13c27..511b78df6106ff80ca3846c4f57768c0bf2fc96f 100644 --- a/GeoModelVisualization/VP1GeometrySystems/src/VolumeTreeModel.cxx +++ b/GeoModelVisualization/VP1GeometrySystems/src/VolumeTreeModel.cxx @@ -326,12 +326,12 @@ int VolumeTreeModel::rowCount(const QModelIndex& parent) const //____________________________________________________________________ QVariant VolumeTreeModel::data(const QModelIndex& index, int role) const { - if ((role!=Qt::DisplayRole&&role!=Qt::TextColorRole)||!index.isValid()) + if ((role!=Qt::DisplayRole&&role!=Qt::ForegroundRole)||!index.isValid()) return QVariant(); VolumeHandle *volumeHandle = Imp::handlePointer(index); if (Imp::isRegularVolumeHandle(volumeHandle)) { - if (role==Qt::TextColorRole) { + if (role==Qt::ForegroundRole) { if (volumeHandle->isAttached()) return QVariant(); else @@ -350,7 +350,7 @@ QVariant VolumeTreeModel::data(const QModelIndex& index, int role) const return volumeHandle->getName() + " (" + QString::fromStdString(volumeHandle->geoMaterial()->getName()) + ") ("+ volState + ")" ; } - if (role==Qt::TextColorRole) + if (role==Qt::ForegroundRole) return QVariant(); if (Imp::isSubSystemPointer(volumeHandle)) @@ -365,7 +365,7 @@ QVariant VolumeTreeModel::data(const QModelIndex& index, int role) const Qt::ItemFlags VolumeTreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return Qt::NoItemFlags; if (Imp::isRegularVolumeHandle(Imp::handlePointer(index))) return Qt::ItemIsEnabled | Qt::ItemIsSelectable; diff --git a/GeoModelVisualization/VP1Gui/CMakeLists.txt b/GeoModelVisualization/VP1Gui/CMakeLists.txt index 6cd58de442fca559050898be14ceac172200e314..6cc53cc91b5f5cd6b66b40b36d8d9e610e442989 100644 --- a/GeoModelVisualization/VP1Gui/CMakeLists.txt +++ b/GeoModelVisualization/VP1Gui/CMakeLists.txt @@ -9,8 +9,8 @@ file( GLOB RCS src/*.qrc ) # Add the library. add_library( GXGui SHARED ${SOURCES} ${HEADERS} ${UIS} ${RCS} ) target_link_libraries( GXGui - PUBLIC Coin::Coin Qt5::Core Qt5::Gui Qt5::Widgets SoQt::SoQt GXBase - PRIVATE Qt5::PrintSupport Qt5::OpenGL ) + PUBLIC Coin::Coin Qt${QT_VERSION}::Core Qt${QT_VERSION}::Gui Qt${QT_VERSION}::Widgets SoQt::SoQt GXBase + PRIVATE Qt${QT_VERSION}::PrintSupport Qt${QT_VERSION}::OpenGL ) target_include_directories( GXGui PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include> ) diff --git a/GeoModelVisualization/VP1Gui/VP1Gui/GXExecutionScheduler.h b/GeoModelVisualization/VP1Gui/VP1Gui/GXExecutionScheduler.h index 41b9a4805f47e0cc0eb10654954bb298ca3174c4..50e789ba8d04d56f3f1b30e637e9d536483aac74 100644 --- a/GeoModelVisualization/VP1Gui/VP1Gui/GXExecutionScheduler.h +++ b/GeoModelVisualization/VP1Gui/VP1Gui/GXExecutionScheduler.h @@ -20,14 +20,16 @@ // include VP1 #include "VP1Gui/VP1QtApplication.h" +#include "VP1Base/IVP1ChannelWidget.h" // include Qt #include <QObject> #include <QStringList> - +#include <QTime> +#include <QDir> class IVP1System; -class IVP1ChannelWidget; + class GXExecutionScheduler : public QObject { diff --git a/GeoModelVisualization/VP1Gui/VP1Gui/GXMainWindow.h b/GeoModelVisualization/VP1Gui/VP1Gui/GXMainWindow.h index 8cc8b3444e8618ee602cabb15253638d1765efd3..29879847f8b4a49b15100608bac0f479119af5be 100644 --- a/GeoModelVisualization/VP1Gui/VP1Gui/GXMainWindow.h +++ b/GeoModelVisualization/VP1Gui/VP1Gui/GXMainWindow.h @@ -19,7 +19,6 @@ #include "ui_gxmainwindow.h" // include VP1 -#include "VP1Gui/VP1EventDisplayEditor.h" // include Qt #include <QQueue> @@ -28,7 +27,6 @@ class VP1ChannelManager; class VP1TabManager; -class QStringList; class IVP1ChannelWidget; class GXExecutionScheduler; class VP1PluginDialog; @@ -179,8 +177,6 @@ protected: QMutex* m_mutex; - // Event display editor - VP1EventDisplayEditor* m_edEditor; }; diff --git a/GeoModelVisualization/VP1Gui/VP1Gui/VP1EventDisplayEditor.h b/GeoModelVisualization/VP1Gui/VP1Gui/VP1EventDisplayEditor.h deleted file mode 100644 index 9328c3c6f859043bc18e56a63b413b95cd97253d..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Gui/VP1Gui/VP1EventDisplayEditor.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -//////////////////////////////////////////////////////////////// -// // -// Header file for class VP1EventDisplayEditor // -// // -// Description: Event display editor. // -// // -// Author: Riccardo-Maria BIANCHI (rbianchi@cern.ch) // -// Initial version: September 2013 // -// // -//////////////////////////////////////////////////////////////// - -#ifndef VP1CUSTOMTOUREDITOR_H -#define VP1CUSTOMTOUREDITOR_H - -#include "VP1Gui/VP1EventDisplaySceneView.h" - -#include "VP1Base/IVP1ChannelWidget.h" -#include "VP1Base/VP1Msg.h" - -#include <QWidget> -#include <QGraphicsView> -#include <QGraphicsScene> -#include <QGraphicsPixmapItem> -#include <QSplitter> - -class GXMainWindow; - - -class VP1EventDisplayEditor : public QWidget { - - Q_OBJECT - -public: - - VP1EventDisplayEditor(GXMainWindow* mainWindow, QList<unsigned long long> listRunEventNumberTimestamp); - virtual ~VP1EventDisplayEditor(); - -// QGraphicsView* getView(); - - void addPixmapList(QList<QPixmap>& list, QStringList& listNames); - void setTabsList(QStringList listNames); - - // void setState(QByteArray); - // QByteArray state() const; - - -protected: - void closeEvent(QCloseEvent*); - -private slots: - // void buttonClicked(); - void setTextLabel(); - void removeObject(); - void addLogo(); - void setBackgroundColor(); - void savePicture(); - void printPicture(); - void getTabSnapshot(); - void enableCustomTextField(bool checked); - -private: - - QString getEventDetailsLabel(); - void addTextLabel(QString text, QFont font); - - class Imp; - Imp * m_d; - QGraphicsScene* m_scene; -// QGraphicsScene* scene_preview; - QList< QGraphicsItem* > m_sceneItems; -// QGraphicsItem *itemPreview; - - VP1EventDisplaySceneView* m_preview; - - QStringList m_listTabNames; - QList<IVP1ChannelWidget*> m_allTabs; - - GXMainWindow* m_mainWindow; - - int m_runNumber; - unsigned long long m_eventNumber; - unsigned m_eventTimestamp; - -// QSplitter *h1Splitter; -// QSplitter *h2Splitter; -}; - -#endif diff --git a/GeoModelVisualization/VP1Gui/VP1Gui/VP1EventDisplaySceneView.h b/GeoModelVisualization/VP1Gui/VP1Gui/VP1EventDisplaySceneView.h deleted file mode 100644 index 37825e4a9addb78da0deaa79af60f8746cbdaf1d..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Gui/VP1Gui/VP1EventDisplaySceneView.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/* - * jira_1 - * VP1EventDisplaySceneView.h - * - * Created on: Sep 26, 2013 - * Author: rbianchi <Riccardo.Maria.Bianchi@cern.ch> - * - */ - -#ifndef VP1EVENTDISPLAYSCENEVIEW_H_ -#define VP1EVENTDISPLAYSCENEVIEW_H_ - - -#include <QtGui> -#include <QFrame> -#include <QHBoxLayout> -#include <QVBoxLayout> -#include <QGraphicsView> - -QT_FORWARD_DECLARE_CLASS(QLabel) -QT_FORWARD_DECLARE_CLASS(QSlider) -QT_FORWARD_DECLARE_CLASS(QToolButton) - -class VP1EventDisplaySceneView; - - -/* - * we create a new class inheriting from QGraphicsView, - * to reimplement the wheel event in order to use the wheel - * to zoom the image, when used over the zoom sliders - */ -class GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(VP1EventDisplaySceneView *v) : QGraphicsView(), m_view(v) { } - -protected: - void wheelEvent(QWheelEvent *); - -private: - VP1EventDisplaySceneView *m_view; -}; - - - -/* - * The QFrame which contains the graphicsView and all other widgets. - * - * If the 'preview' argument is set to true, then a 'preview' view is built - * without rotation sliders and the zoom set to see the whole scene. - */ -class VP1EventDisplaySceneView : public QFrame -{ - Q_OBJECT -public: - VP1EventDisplaySceneView(const QString &name, bool preview = false, QWidget *parent = 0); - ~VP1EventDisplaySceneView(); - - QGraphicsView *view() const; - void setPreviewZoom(qreal xx); - void addRenderingFrame(); - void showRenderingFrame(); - void hideRenderingFrame(); - - public slots: - void zoomIn(int level = 1); - void zoomOut(int level = 1); - void print(); - - private slots: - void resetView(); - void setResetButtonEnabled(); - void setupMatrix(); - void togglePointerMode(); - void toggleOpenGL(); - void toggleAntialiasing(); - void rotateLeft(); - void rotateRight(); - - private: - GraphicsView *m_graphicsView; - - bool m_preview; - - QGraphicsRectItem* m_frame; - QGraphicsLineItem * m_line; - - QLabel *m_label; - QLabel *m_label2; - - QToolButton *m_selectModeButton; - QToolButton *m_dragModeButton; - QToolButton *m_openGlButton; - QToolButton *m_antialiasButton; - QToolButton *m_printButton; - QToolButton *m_resetButton; - - QVBoxLayout *m_zoomSliderLayout; - QSlider *m_zoomSlider; - QToolButton *m_zoomInIcon; - QToolButton *m_zoomOutIcon; - - QHBoxLayout *m_rotateSliderLayout; - QSlider *m_rotateSlider; - QToolButton *m_rotateLeftIcon; - QToolButton *m_rotateRightIcon; - -}; - - -#endif /* VP1EVENTDISPLAYSCENEVIEW_H_ */ diff --git a/GeoModelVisualization/VP1Gui/VP1Gui/VP1TabManager.h b/GeoModelVisualization/VP1Gui/VP1Gui/VP1TabManager.h index 8f21ea43185c1561a162776f32188d58ff264449..98b2e0198ce18a03491a5502fba5b39c19522f9c 100644 --- a/GeoModelVisualization/VP1Gui/VP1Gui/VP1TabManager.h +++ b/GeoModelVisualization/VP1Gui/VP1Gui/VP1TabManager.h @@ -71,10 +71,11 @@ public slots: void cloneTab(QString oldtabname,QString newtabname); void removeAllTabs(); - +#ifdef SAVEANDRESTORE void saveConfigurationToFile(QString filename,const bool& askonoverride=true); void loadConfigurationFromFile(QString filename,const QMap<QString,QString>& availableplugins); - +#endif + void showChannelFullScreen(IVP1ChannelWidget*); void showCurrentChannelFullScreen(); void showTabFullScreen(QString tabname); @@ -101,9 +102,11 @@ protected: bool eventFilter ( QObject *, QEvent * ); typedef QPair<QByteArray,QMultiMap<QString,QByteArray> > ChanState; +#ifdef SAVEANDRESTORE void serializeChannelState(IVP1ChannelWidget*,ChanState&state); void unserializeChannelState(IVP1ChannelWidget*cw,ChanState tate); - +#endif + protected slots: void currentVisibleChanged(); void executePendingChannelRemoval(); diff --git a/GeoModelVisualization/VP1Gui/src/GXExecutionScheduler.cxx b/GeoModelVisualization/VP1Gui/src/GXExecutionScheduler.cxx index e637803b6dbb3824e1e3f976517a24c3c978da38..20d3664d4ac8566331678035f37a88a43b8bcf35 100644 --- a/GeoModelVisualization/VP1Gui/src/GXExecutionScheduler.cxx +++ b/GeoModelVisualization/VP1Gui/src/GXExecutionScheduler.cxx @@ -51,7 +51,7 @@ #include <QApplication> #include <QProgressBar> -#include <QDesktopWidget> +//#include <QDesktopWidget> #include <QMouseEvent> #include <QWheelEvent> #include <QCursor> @@ -60,7 +60,7 @@ #include <QStringList> #include <QMessageBox> #include <QCommandLineParser> - +#include <QDebug> #include <Inventor/C/errors/debugerror.h> #include <Inventor/Qt/SoQt.h> @@ -222,7 +222,7 @@ public: */ qDebug() << "key pressed (code):" << keyEvent->key() << "key pressed (text):" << keyEvent->text(); if (keyEvent->text() != "") txt = txt + "+" + keyEvent->text(); - else txt = txt + "+" + keyEvent->key(); + else txt = txt + "+" + (char) keyEvent->key(); } // std::cout<<"Popup (dt="<<timediff<<") "<<txt.toStdString()<<". watched = "<<watched @@ -611,7 +611,6 @@ bool GXExecutionScheduler::isRefreshing() const { return m_d->currentsystemrefreshing; } - //___________________________________________________________________ void GXExecutionScheduler::refreshSystem(IVP1System*s) { @@ -888,8 +887,8 @@ void GXExecutionScheduler::actualUncreateAndDelete(IVP1ChannelWidget*cw) //___________________________________________________________________ void GXExecutionScheduler::Imp::warnIfWidgetsAlive() { - QSet<QWidget*> w_ignore, wl = QApplication::allWidgets().toSet(); - w_ignore<<qApp->desktop(); + QSet<QWidget*> w_ignore, wl(QApplication::allWidgets().begin(), QApplication::allWidgets().end());// = QApplication::allWidgets().toSet(); + //w_ignore<<qApp->desktop(); foreach (QObject*o,qApp->children()) { if (o->isWidgetType()) w_ignore << static_cast<QWidget*>(o); diff --git a/GeoModelVisualization/VP1Gui/src/GXMainWindow.cxx b/GeoModelVisualization/VP1Gui/src/GXMainWindow.cxx index 56b758c2edd7c465288767024d5f5e782f328c5c..78ac78f3479f87ee18f9b4cefc04d2cc87bb33d7 100644 --- a/GeoModelVisualization/VP1Gui/src/GXMainWindow.cxx +++ b/GeoModelVisualization/VP1Gui/src/GXMainWindow.cxx @@ -81,11 +81,9 @@ GXMainWindow::GXMainWindow(GXExecutionScheduler*sched,QWidget * parent) m_scheduler(sched), m_settingsfile(QDir::homePath()+QDir::separator()+".atlasvp1"), m_userRequestedExit(false), - m_mutex(new QMutex()), - m_edEditor(0) + m_mutex(new QMutex()) { setupUi(this); // this sets up the GUI - setupStatusBar(); // @@ -258,6 +256,7 @@ GXMainWindow::GXMainWindow(GXExecutionScheduler*sched,QWidget * parent) menuConfiguration->setVisible(false); menuConfiguration->setEnabled(false); menuConfiguration->setTitle(""); + } //_________________________________________________________________________________ @@ -346,10 +345,6 @@ void GXMainWindow::setupStatusBar() { //_________________________________________________________________________________ GXMainWindow::~GXMainWindow() { - if (m_edEditor) { - VP1Msg::messageDebug("deleting the editor"); - delete m_edEditor; - } VP1Msg::messageDebug("deleting the tab manager"); delete m_tabmanager; VP1Msg::messageDebug("deleting the channel manager"); @@ -463,7 +458,7 @@ void GXMainWindow::request_saveasConfig() { if (!filename.endsWith(".vp1")) filename += ".vp1"; - m_tabmanager->saveConfigurationToFile(filename,false/*Since the filedialog already asks*/); + //m_tabmanager->saveConfigurationToFile(filename,false/*Since the filedialog already asks*/); m_currentconfigfile=filename; } @@ -474,7 +469,7 @@ void GXMainWindow::request_saveConfig() request_saveasConfig(); return; } - m_tabmanager->saveConfigurationToFile(m_currentconfigfile,false); + //m_tabmanager->saveConfigurationToFile(m_currentconfigfile,false); } //_________________________________________________________________________________ @@ -485,7 +480,7 @@ void GXMainWindow::request_loadConfig() "VP1 configuration files (*.vp1)",0,QFileDialog::DontResolveSymlinks); if(filename.isEmpty()) return; - m_tabmanager->loadConfigurationFromFile(filename,availablePluginFiles()); + //m_tabmanager->loadConfigurationFromFile(filename,availablePluginFiles()); m_currentconfigfile=filename; } @@ -525,7 +520,7 @@ QMap<QString,QString> GXMainWindow::availableFiles(const QString& extension, //Add directories from extradirenvvar (e.g. $GXPLUGINPATH) qDebug() << "GXPLUGINPATH: " << QString(::getenv(extradirenvvar.toStdString().c_str())); - QStringList vp1pluginpath = extradirenvvar.isEmpty() ? QStringList() : QString(::getenv(extradirenvvar.toStdString().c_str())).split(":",QString::SkipEmptyParts); + QStringList vp1pluginpath = extradirenvvar.isEmpty() ? QStringList() : QString(::getenv(extradirenvvar.toStdString().c_str())).split(":",Qt::SkipEmptyParts); if(VP1Msg::debug()){ qDebug() << "extradirenvvar:" << extradirenvvar; qDebug() << "vp1pluginpath A :" << vp1pluginpath; @@ -554,7 +549,7 @@ QMap<QString,QString> GXMainWindow::availableFiles(const QString& extension, QString path = QString(::getenv(pathvar.toStdString().c_str())); if (!path.isEmpty()) { //!instareasubdir.isEmpty()&& - QStringList tmp = path.split(":",QString::SkipEmptyParts);//This 'tmp' is for SLC3 compilation. + QStringList tmp = path.split(":",Qt::SkipEmptyParts);//This 'tmp' is for SLC3 compilation. foreach (QString dir,tmp) { vp1pluginpath << ( instareasubdir.isEmpty() ? dir : dir+QDir::separator()+QDir::separator()+instareasubdir ); } @@ -766,16 +761,6 @@ void GXMainWindow::makeAllChannelsEventDisplay() getAllChannelsIntoSnapshots(list, listNames); - // create a new editor window - m_edEditor = new VP1EventDisplayEditor(this, listRunEventNumberTimestamp); - - m_edEditor->addPixmapList(list, listNames); - - // pass the lists of all tabs and their names to the editor - m_edEditor->setTabsList( listNames); - - m_edEditor->show(); - } @@ -1085,7 +1070,7 @@ void GXMainWindow::request_printChannel() { //_________________________________________________________________________________ void GXMainWindow::loadConfigurationFromFile(QString file) { - m_tabmanager->loadConfigurationFromFile(file,availablePluginFiles()); + //m_tabmanager->loadConfigurationFromFile(file,availablePluginFiles()); } //_________________________________________________________________________________ @@ -1093,7 +1078,7 @@ void GXMainWindow::replaceConfigurationFile(QString file) { VP1Msg::messageDebug("GXMainWindow::replaceConfigurationFile() : " + file); m_tabmanager->removeAllTabs(); - m_tabmanager->loadConfigurationFromFile(file,availablePluginFiles()); + // m_tabmanager->loadConfigurationFromFile(file,availablePluginFiles()); } diff --git a/GeoModelVisualization/VP1Gui/src/VP1ChannelManager.cxx b/GeoModelVisualization/VP1Gui/src/VP1ChannelManager.cxx index 6502f1d17237a267dff7ef9ef026e0aa99299c58..1d487d7ef4b0bf1e2e9a33cdc3e0f057f36bb6d2 100644 --- a/GeoModelVisualization/VP1Gui/src/VP1ChannelManager.cxx +++ b/GeoModelVisualization/VP1Gui/src/VP1ChannelManager.cxx @@ -63,7 +63,7 @@ #include <QFileInfo> #include <QMap> #include <QScrollArea> - +#include <QLibraryInfo> #include <map> #include <set> #include <cassert> diff --git a/GeoModelVisualization/VP1Gui/src/VP1DockWidget.cxx b/GeoModelVisualization/VP1Gui/src/VP1DockWidget.cxx index d2a36b219f0ce38465c948c9830cef0b97d6c99b..2261983eee32241591f0b3ee4d5355903d9e3669 100644 --- a/GeoModelVisualization/VP1Gui/src/VP1DockWidget.cxx +++ b/GeoModelVisualization/VP1Gui/src/VP1DockWidget.cxx @@ -144,9 +144,9 @@ VP1DockWidget::VP1DockWidget ( IVP1ChannelWidget * cw, VP1TabManager* tm ) //Figure out what margin our drawn frame imposes: setSelected(); int marg_left, marg_top, marg_right, marg_bottom; - m_d->frame->getContentsMargins ( &marg_left, &marg_top, &marg_right, &marg_bottom ); - Q_ASSERT(marg_left==marg_top&&marg_left==marg_right&&marg_left==marg_bottom&&"Qt changed its margin behaviour for QFrame!!"); - m_d->unselectedmargin=marg_left; + QMargins margins=m_d->frame->contentsMargins (); + Q_ASSERT(margins.left()==margins.top() &&margins.left()==margins.right()&&margins.left()==margins.bottom() &&"Qt changed its margin behaviour for QFrame!!"); + m_d->unselectedmargin=margins.left(); //Channel starts unselected: setUnselected(); @@ -226,7 +226,7 @@ void VP1DockWidget::setSelected() m_d->selected=true; m_d->frame->setStyleSheet(m_d->selectedstylesheet); assert(m_d->vboxLayout); - m_d->vboxLayout->setMargin(0); + // m_d->vboxLayout->setMargin(0); m_d->frame->setFrameShape(QFrame::StyledPanel); updateTitle(); } @@ -239,7 +239,7 @@ void VP1DockWidget::setUnselected() m_d->selected=false; m_d->frame->setStyleSheet(""); assert(m_d->vboxLayout); - m_d->vboxLayout->setMargin(m_d->unselectedmargin); + // m_d->vboxLayout->setMargin(m_d->unselectedmargin); m_d->frame->setFrameShape(QFrame::NoFrame); updateTitle(); } diff --git a/GeoModelVisualization/VP1Gui/src/VP1EventDisplayEditor.cxx b/GeoModelVisualization/VP1Gui/src/VP1EventDisplayEditor.cxx deleted file mode 100644 index 78325dd50a9e276971e33c5eaeb52764a4adf705..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Gui/src/VP1EventDisplayEditor.cxx +++ /dev/null @@ -1,730 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -//////////////////////////////////////////////////////////////// -// // -// Header file for class VP1EventDisplayEditor // -// // -// Description: Event display editor. // -// // -// Author: Riccardo-Maria BIANCHI (rbianchi@cern.ch) // -// Initial version: September 2013 // -// // -//////////////////////////////////////////////////////////////// - -#include "VP1Gui/VP1EventDisplayEditor.h" -#include "ui_vp1eventdisplayeditor.h" - -#include "VP1Base/VP1ExaminerViewer.h" -#include "VP1Base/VP1QtInventorUtils.h" -#include "VP1Base/VP1Serialise.h" -#include "VP1Base/VP1Deserialise.h" -#include "VP1Gui/GXMainWindow.h" - -#include <QRectF> -#include <QShortcut> -#include <QCloseEvent> -#include <QFileDialog> - -#include <iostream> - - -//____________________________________________________________________ -class VP1EventDisplayEditor::Imp { - -public: - - VP1EventDisplayEditor * theclass; - Ui::VP1EventDisplayEditorForm ui; - - // VP1ExaminerViewer* viewer; - - // QGraphicsScene* scene; - - // QWidget * frameHolderWidget; - -}; - - -////____________________________________________________________________ -//QByteArray VP1EventDisplayEditor::state() const -//{ -// VP1Serialise s(0/*version*/); -// QList<QByteArray> frameStates; -// foreach(VP1CustomTourFrameWidget*frame,d->frames) { -// frameStates << frame->serialise(); -// s.ignoreWidget(frame); -// } -// s.save(frameStates); -// s.save(d->ui.doubleSpinBox_theta); -// s.save(d->ui.doubleSpinBox_radius); -// s.save(d->ui.groupBox_utilityZoom); -// s.warnUnsaved(this); -// return s.result(); -//} - -////____________________________________________________________________ -//void VP1EventDisplayEditor::setState(QByteArray ba) -//{ -// foreach(VP1CustomTourFrameWidget*frame,d->frames) -// frame->deleteLater(); -// d->frames.clear(); -// -// VP1Deserialise s(ba); -// if (s.version()!=0) -// return; -// QList<QByteArray> frameStates = s.restore<QList<QByteArray> >(); -// s.restore(d->ui.doubleSpinBox_theta); -// s.restore(d->ui.doubleSpinBox_radius); -// s.restore(d->ui.groupBox_utilityZoom); -// s.warnUnrestored(this); -// -// d->ui.widget_utilityZoomContents->setVisible(d->ui.groupBox_utilityZoom->isChecked()); -// -// foreach(QByteArray ba2, frameStates) -// d->addFrame(new VP1CustomTourFrameWidget(ba2)); -// d->updateFrameListVisuals(); -// enabledFrameListChanged(); -//} - - -/* - * My first, old version - */ -////____________________________________________________________________ -////VP1EventDisplayEditor::VP1EventDisplayEditor(VP1ExaminerViewer* viewer) -//VP1EventDisplayEditor::VP1EventDisplayEditor() -//: QWidget(0,Qt::WindowStaysOnTopHint), d(new Imp) -//{ -// d->theclass = this; -// d->ui.setupUi(this); -// -// scene = new QGraphicsScene(); // the size of the scene is by default infinite. But we will limit the view, here below -// scene->setSceneRect(QRectF(0.0, 0.0, 4000., 2641.)); -// -// scene_preview = new QGraphicsScene(); -// -// -// d->ui.graphicsView->setScene(scene); -// d->ui.graphicsView->setSceneRect(0, 0, 4000, 2641); // the size of a final ATLAS event display -// d->ui.graphicsView->setMaximumSize(1000, 660); // the size of the view window on the screen -// -// d->ui.graphicsView_preview->setScene(scene_preview); -// d->ui.graphicsView_preview->setSceneRect(0, 0, 333, 220); // the size of the preview scene -// d->ui.graphicsView_preview->setMaximumSize(333, 220); // the size of the preview window -// -// // set the default bkg color: black -// setBackgroundColor(); -// -// setWindowIcon(QIcon(QString(":/vp1/icons/icons/3d_32x32.png"))); -// -// connect(d->ui.pushButton_addText,SIGNAL(clicked()), this,SLOT(addTextLabel())); -// connect(d->ui.pushButton_removeObj,SIGNAL(clicked()), this,SLOT(removeObject())); -// connect(d->ui.pushButton_addLogo,SIGNAL(clicked()), this,SLOT(addLogo())); -// -// connect(d->ui.radioButton_black,SIGNAL(clicked()), this,SLOT(setBackgroundColor())); -// connect(d->ui.radioButton_white,SIGNAL(clicked()), this,SLOT(setBackgroundColor())); -// connect(d->ui.radioButton_transparent,SIGNAL(clicked()), this,SLOT(setBackgroundColor())); -// -// connect(scene,SIGNAL(changed(const QList<QRectF>&)), this,SLOT(updatePreview(const QList<QRectF>&))); -// -//} - - -/* - * new version - */ -//____________________________________________________________________ -VP1EventDisplayEditor::VP1EventDisplayEditor(GXMainWindow* mainWindow, QList<unsigned long long> listRunEventNumberTimestamp) -//: QWidget(0,Qt::WindowStaysOnTopHint), d(new Imp) -: QWidget(0), m_d(new Imp) -{ - m_mainWindow = mainWindow; - - m_runNumber = listRunEventNumberTimestamp.size()>0 ? listRunEventNumberTimestamp[0]:0; - m_eventNumber = listRunEventNumberTimestamp.size()>1 ? listRunEventNumberTimestamp[1]:0; - m_eventTimestamp = listRunEventNumberTimestamp.size()>2 ? listRunEventNumberTimestamp[2]:0; - - - m_d->theclass = this; - m_d->ui.setupUi(this); - - /* initialize the scene - * - * this is the scene that will be rendered and saved to the file. - * By default the scene dimension is 4000x2641 pixels. - * - */ - m_scene = new QGraphicsScene(); - m_scene->setSceneRect(QRectF(0.0, 0.0, 4000., 2641.)); - - - VP1EventDisplaySceneView *view = new VP1EventDisplaySceneView("Full-size view"); - view->view()->setScene(m_scene); - - m_preview = new VP1EventDisplaySceneView("Preview", true); - m_preview->view()->setScene(m_scene); - - // the right splitter, containing the list of objects in the scene and the preview - QSplitter *previewSplitter = new QSplitter; - previewSplitter->setOrientation(Qt::Vertical); - - // the center splitter, containing the main view and the preview splitter - QSplitter *viewSplitter = new QSplitter; - viewSplitter->setOrientation(Qt::Horizontal); - - // the center splitter, containing the main view and the preview splitter - QSplitter *toolsSplitter = new QSplitter; - toolsSplitter->setOrientation(Qt::Vertical); - - // the main splitter, containing all views - QSplitter *mainSplitter = new QSplitter; - mainSplitter->setOrientation(Qt::Horizontal); - - - previewSplitter->addWidget(m_d->ui.groupBox_objectList); - previewSplitter->addWidget(m_preview); - previewSplitter->addWidget(m_d->ui.groupBox_actions); - - - QWidget *containerPreview = new QWidget; - QVBoxLayout *containerPreview_layout = new QVBoxLayout; - - containerPreview_layout->addWidget(previewSplitter); - containerPreview->setLayout(containerPreview_layout); - - viewSplitter->addWidget(view); - viewSplitter->addWidget(containerPreview); - - QWidget *containerAllViews = new QWidget; - QHBoxLayout *containerAllViews_layout = new QHBoxLayout; - containerAllViews_layout->addWidget(viewSplitter); - containerAllViews->setLayout(containerAllViews_layout); - - - toolsSplitter->addWidget(m_d->ui.groupBox_getTab); - toolsSplitter->addWidget(m_d->ui.groupBox_bkg); - toolsSplitter->addWidget(m_d->ui.groupBox_logo); - toolsSplitter->addWidget(m_d->ui.groupBox_labels); - - QWidget *containerTools = new QWidget; - QVBoxLayout *containerTools_layout = new QVBoxLayout; - containerTools_layout->addWidget(toolsSplitter); - containerTools_layout->addStretch(1); - containerTools->setLayout(containerTools_layout); - - - // mainSplitter->addWidget(containerTools); - mainSplitter->addWidget(containerAllViews); - - QGridLayout* grid = static_cast<QGridLayout*>(this->layout()); - grid->addWidget(containerTools); - grid->addWidget(mainSplitter); - - - - /* - * setting the size of the preview window - */ - //m_preview->view()->setFixedSize(450,302); - /* - * this triggers a better fitInView() but not enough for our purpose. - * See: http://stackoverflow.com/a/17085612 - */ - //m_preview->show(); - - /* - * setting the size of the viewport - * - * Details: - * The QGraphicsView is not the widget that actually contains the scene, - * because the QGraphicsView also manages the scrollbars. - * The scene is drawn in the viewport widget, - * which is a little smaller than the QGraphicsView. - * (http://qt-project.org/forums/viewthread/17504) - * - * Update: useful, but it's useless here, because we want to use fitInView() - * from the view, and that does not match with the viewport size. - */ - // m_preview->view()->viewport()->setFixedSize(400,265); - - - QSize size = m_preview->view()->maximumViewportSize(); - VP1Msg::message("scene rect: " + QString::number(m_scene->sceneRect().width()) + " - " + QString::number(m_scene->sceneRect().height()) ); - VP1Msg::message("max preview size: " + QString::number(size.width()) + " - " + QString::number(size.height()) ); - - m_preview->view()->ensureVisible ( m_scene->sceneRect(), 0, 0 ); - m_preview->view()->fitInView( m_scene->sceneRect(), Qt::KeepAspectRatio); - - // add a frame to preview to define the the rendering area - m_preview->addRenderingFrame(); - - // set the default m_scene bkg color: black - this->setBackgroundColor(); // the "black" checkbox is checked by default in the GUI - - setWindowIcon(QIcon(QString(":/vp1/icons/icons/3d_32x32.png"))); - - connect(m_d->ui.pushButton_get,SIGNAL(clicked()), this,SLOT(getTabSnapshot())); - -// connect(m_d->ui.pushButton_eventDetailsLabel,SIGNAL(clicked()), this,SLOT(getEventDetailsLabel())); - - - connect(m_d->ui.radioButton_eventDetails,SIGNAL(toggled(bool)), this,SLOT(enableCustomTextField(bool))); - // connect(m_d->ui.radioButton_customText,SIGNAL(toggled()), this,SLOT(showCustomTextField())); - - connect(m_d->ui.pushButton_addText,SIGNAL(clicked()), this,SLOT(setTextLabel())); - connect(m_d->ui.pushButton_removeObj,SIGNAL(clicked()), this,SLOT(removeObject())); - connect(m_d->ui.pushButton_addLogo,SIGNAL(clicked()), this,SLOT(addLogo())); - - connect(m_d->ui.pushButton_save,SIGNAL(clicked()), this,SLOT(savePicture())); - connect(m_d->ui.pushButton_print,SIGNAL(clicked()), this,SLOT(printPicture())); - - - connect(m_d->ui.radioButton_black,SIGNAL(clicked()), this,SLOT(setBackgroundColor())); - connect(m_d->ui.radioButton_white,SIGNAL(clicked()), this,SLOT(setBackgroundColor())); - connect(m_d->ui.radioButton_transparent,SIGNAL(clicked()), this,SLOT(setBackgroundColor())); - - this->setWindowTitle(tr("ATLAS VP1 Event Display Editor")); - - this->getEventDetailsLabel(); - - -} - -/* - * Qt example - */ -//VP1EventDisplayEditor::VP1EventDisplayEditor() -////: QWidget(0,Qt::WindowStaysOnTopHint), m_d(new Imp) -//: QWidget(0), m_d(new Imp) -//{ -// m_d->theclass = this; -// m_d->ui.setupUi(this); -// -// m_scene = new QGraphicsScene(); -// -// h1Splitter = new QSplitter; -// h2Splitter = new QSplitter; -// -// QSplitter *vSplitter = new QSplitter; -// vSplitter->setOrientation(Qt::Vertical); -// vSplitter->addWidget(h1Splitter); -// vSplitter->addWidget(h2Splitter); -// -// VP1EventDisplaySceneView *view = new VP1EventDisplaySceneView("Top left view"); -// view->view()->setScene(m_scene); -// h1Splitter->addWidget(view); -// -// view = new VP1EventDisplaySceneView("Top right view"); -// view->view()->setScene(m_scene); -// h1Splitter->addWidget(view); -// -// view = new VP1EventDisplaySceneView("Bottom left view"); -// view->view()->setScene(m_scene); -// h2Splitter->addWidget(view); -// -// view = new VP1EventDisplaySceneView("Bottom right view"); -// view->view()->setScene(m_scene); -// h2Splitter->addWidget(view); -// -// QLayout *layout = this->layout(); -// layout->addWidget(vSplitter); -//// setLayout(layout); -// -// setWindowTitle(tr("Chip Demo")); -// -// -//} - - - -//____________________________________________________________________ -VP1EventDisplayEditor::~VP1EventDisplayEditor() -{ - // m_d->frameHolderWidget->deleteLater(); - // foreach(VP1CustomTourFrameWidget*frame,m_d->frames) - // frame->deleteLater(); - delete m_d; - delete m_scene; - // delete scene_preview; -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::enableCustomTextField(bool checked) -{ -// if (m_d->ui.radioButton_eventDetails->isChecked()) - if (checked) - m_d->ui.lineEdit_customLabelText->setEnabled(false); - else - m_d->ui.lineEdit_customLabelText->setEnabled(true); -} - - -//____________________________________________________________________ -QString VP1EventDisplayEditor::getEventDetailsLabel() -{ - - QString evtstr = "Run: "+QString::number(m_runNumber)+"\n" - + "Event: "+QString::number(m_eventNumber)+"\n" - + QString(m_eventTimestamp>0 ? QDateTime::fromTime_t(m_eventTimestamp).toString(Qt::ISODate).replace('T',' ')+ " CEST" : ""); - - //VP1Msg::messageVerbose(evtstr); - - return evtstr; -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::printPicture() -{ - m_preview->print(); -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::savePicture() -{ - VP1Msg::messageVerbose("VP1EventDisplayEditor::savePicture()"); - - // hide the rendering frame, cause we do not want it in the final picture - m_preview->hideRenderingFrame(); - - QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), - "event_display.png", - tr("Images (*.png *.jpg)")); - - QImage image(m_scene->sceneRect().size().toSize(), QImage::Format_ARGB32); - image.fill(Qt::transparent); - - QPainter painter(&image); - painter.setRenderHint(QPainter::Antialiasing); - - m_scene->render(&painter); - - image.save(fileName); - - // show the rendering frame again - m_preview->showRenderingFrame(); - -} - - - - - - -//____________________________________________________________________ -void VP1EventDisplayEditor::addPixmapList(QList<QPixmap>& list, QStringList& listNames) -{ - VP1Msg::messageVerbose("VP1EventDisplayEditor::addPixmapList()"); - - if (!list.isEmpty()) { - foreach (QPixmap img, list) { - // add and set it movableimage to the scene - QGraphicsPixmapItem* item = m_scene->addPixmap(img); - item->setFlags(QGraphicsItem::ItemIsMovable); - m_sceneItems << item; - } - } - - if (!listNames.isEmpty()) { - foreach (QString name, listNames) { - // add image name to the list - new QListWidgetItem(name, m_d->ui.listWidget); - } - } -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::removeObject() -{ - QListWidgetItem * currentItem = m_d->ui.listWidget->currentItem(); - QString text = currentItem->text(); - int currentPos = m_d->ui.listWidget->row( currentItem ); - - // remove the object from the scene - m_scene->removeItem( m_sceneItems[currentPos] ); - // remove its associated pointer in our list - m_sceneItems.removeAt( currentPos ); - // remove its associated label - QListWidgetItem * item = m_d->ui.listWidget->takeItem(currentPos); - delete item; - - VP1Msg::message("Successfully removed the object: " + text); -} - -//// SLOT -////____________________________________________________________________ -//void VP1EventDisplayEditor::addTextLabelSlot() -//{ -// this->addTextLabel(); -//} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::setTextLabel() -{ - QString text; - QFont font; - -// /* if we use this function programmatically, -// * passing text directly -// */ -// if (!textString.isEmpty()) { -// -// text = textString; -// -// // default settings -// int size = 32; -// int weight = QFont::Normal; -// bool italics = false; -// QString typeface = "Courier"; -// -// // default font -// font = QFont(typeface, size, weight, italics); -// -// // default font family, if Courier is not available -// font.setStyleHint(QFont::TypeWriter); -// -// } - -// /* if we use this function from the GUI, -// * then we get all user's settings from the GUI itself -// */ -// else { - - if (m_d->ui.radioButton_eventDetails->isChecked()) { - // get the event details - text = this->getEventDetailsLabel(); - } - else { - // get the user's text - text = m_d->ui.lineEdit_customLabelText->text(); - } - - - // get users' settings - int size = 0; - if (m_d->ui.radioButton_size12->isChecked()) size = 12; - else if (m_d->ui.radioButton_size24->isChecked()) size = 24; - else if (m_d->ui.radioButton_size32->isChecked()) size = 32; - else if (m_d->ui.radioButton_size44->isChecked()) size = 44; - else if (m_d->ui.radioButton_sizeCustom->isChecked()) { - size = m_d->ui.spinBox_size->value(); - } - - QString typeface = "Courier"; // default typeface - - int weight = QFont::Normal; - if (m_d->ui.radioButton_light->isChecked()) weight = QFont::Light; - else if (m_d->ui.radioButton_normal->isChecked()) weight = QFont::Normal; - else if (m_d->ui.radioButton_bold->isChecked()) weight = QFont::Bold; - else if (m_d->ui.radioButton_black_2->isChecked()) weight = QFont::Black; - - bool italics = false; - if (m_d->ui.radioButton_italics->isChecked()) italics = true; - - font = QFont(typeface, size, weight, italics); - - if (m_d->ui.radioButton_monaco->isChecked()) { - // typeface = "Monaco"; - typeface = "Courier"; - font.setStyleHint(QFont::TypeWriter); // this defines the family to choose from, if the preferred typeface is not available on the host system - } - else if (m_d->ui.radioButton_helvetica->isChecked()) { - typeface = "Helvetica"; - font.setStyleHint(QFont::SansSerif); - } - else if (m_d->ui.radioButton_times->isChecked()) { - typeface = "Times"; - font.setStyleHint(QFont::Serif); - } - font.setFamily(typeface); - -// } - - this->addTextLabel(text, font); -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::addTextLabel(QString text, QFont font) -{ -// adding the label to the m_scene -QGraphicsTextItem* item = m_scene->addText(text, font); -item->setFlags(QGraphicsItem::ItemIsMovable); - -// set the user's preferred color -if (m_d->ui.radioButton_whiteText->isChecked()) { - item->setDefaultTextColor(Qt::white); -} else if (m_d->ui.radioButton_blackText->isChecked()) { - item->setDefaultTextColor(Qt::black); -} - -// adding the label to the list of objects -QString strippedText = text.replace('\n',' ').replace('\t', ' ').simplified(); -new QListWidgetItem(strippedText, m_d->ui.listWidget); - -// adding the label to list of object pointers -m_sceneItems << item; -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::getTabSnapshot() -{ - int tabN = m_d->ui.comboBox_tabNumber->currentIndex(); - QString tabName = m_d->ui.comboBox_tabNumber->currentText(); - VP1Msg::messageVerbose("Got tab: " + tabName + " at idx: " + QString::number(tabN) ); - - int imageWidth = m_d->ui.spinBox_imageWidth->value(); - VP1Msg::messageVerbose("width: " + QString::number(imageWidth) ); - - QPixmap snap = m_mainWindow->getSingleChannelCustomSnapshot( tabName, imageWidth ); - - tabName = tabName + "_" + QString::number(imageWidth); - - - QList<QPixmap> listPixmap; - QStringList listNamesPixmap; - - listPixmap << snap; - listNamesPixmap << tabName; - - this->addPixmapList(listPixmap, listNamesPixmap); - -} - -//____________________________________________________________________ -void VP1EventDisplayEditor::setTabsList( QStringList listNames ) -{ - VP1Msg::messageVerbose("VP1EventDisplayEditor::setTabsList()"); - - m_d->ui.comboBox_tabNumber->addItems(listNames); - -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::addLogo() -{ - QPixmap pix; - QString name; - - // load the right version of the ATLAS logo - if ( m_d->ui.radioButton_300px->isChecked() ) { - if ( m_d->ui.radioButton_gray->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-Logo-New_300pixels.png"); - if (m_d->ui.radioButton_blue->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-chrome-logo-URL-blue_300px.png"); - name = "logo_300px"; - } - else if ( m_d->ui.radioButton_450px->isChecked() ) { - if ( m_d->ui.radioButton_gray->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-Logo-New_450pixels.png"); - if (m_d->ui.radioButton_blue->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-chrome-logo-URL-blue_450px.png"); - name = "logo_450px"; - } - else if ( m_d->ui.radioButton_600px->isChecked() ) { - if ( m_d->ui.radioButton_gray->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-Logo-New_600pixels.png"); - if (m_d->ui.radioButton_blue->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-chrome-logo-URL-blue_600px.png"); - name = "logo_600px"; - } - else if ( m_d->ui.radioButton_800px->isChecked() ) { - if ( m_d->ui.radioButton_gray->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-Logo-New_800pixels.png"); -// if (m_d->ui.radioButton_blue->isChecked() ) -// pix.load(":/vp1/images/images/ATLAS-chrome-logo-URL-blue_600px.png"); - name = "logo_800px"; - } - else if ( m_d->ui.radioButton_1000px->isChecked() ) { - if ( m_d->ui.radioButton_gray->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-Logo-New_1000pixels.png"); -// if (m_d->ui.radioButton_blue->isChecked() ) -// pix.load(":/vp1/images/images/ATLAS-chrome-logo-URL-blue_600px.png"); - name = "logo_1000px"; - } - else if ( m_d->ui.radioButton_1200px->isChecked() ) { - if ( m_d->ui.radioButton_gray->isChecked() ) - pix.load(":/vp1/images/images/ATLAS-Logo-New_1200pixels.png"); -// if (m_d->ui.radioButton_blue->isChecked() ) -// pix.load(":/vp1/images/images/ATLAS-chrome-logo-URL-blue_600px.png"); - name = "logo_1200px"; - } - - // add the logo to the m_scene - QGraphicsPixmapItem* item = m_scene->addPixmap(pix); - item->setFlags(QGraphicsItem::ItemIsMovable); - // add to the list of pointers - m_sceneItems << item; - // add to the list of object labels - new QListWidgetItem(name, m_d->ui.listWidget); -} - - -//____________________________________________________________________ -void VP1EventDisplayEditor::setBackgroundColor() -{ - - // a white background - if ( m_d->ui.radioButton_white->isChecked() ) - m_scene->setBackgroundBrush(Qt::white); - // a black background - else if ( m_d->ui.radioButton_black->isChecked() ) - m_scene->setBackgroundBrush(Qt::black); - // a transparent background - else if ( m_d->ui.radioButton_transparent->isChecked() ) { - m_scene->setBackgroundBrush(Qt::NoBrush); - // // a gradient background - // QRadialGradient gradient(0, 0, 10); - // gradient.setSpread(QGradient::RepeatSpread); - // m_scene->setBackgroundBrush(gradient); - } -} - - - -//____________________________________________________________________ -void VP1EventDisplayEditor::closeEvent(QCloseEvent*ev) -{ - // if you want to just hide the window when closed, uncomment the lines below - ev->ignore(); - hide(); - - // this, instead, will close the window - // ev->accept(); -} - -//QGraphicsView* VP1EventDisplayEditor::getView() -//{ -// return m_d->ui.graphicsView; -//} - - - - -////____________________________________________________________________ -//void VP1EventDisplayEditor::buttonClicked() -//{ -// if (m_d->ui.pushButton_addCurrentView==sender()) { -// VP1CustomTourFrameWidget * frame = new VP1CustomTourFrameWidget(m_d->viewer->currentCamIsPerspective(), -// m_d->viewer->currentCameraState()); -// m_d->addFrame(frame); -// m_d->updateFrameSnapshot(frame); -// m_d->updateFrameListVisuals(); -// } else if (m_d->ui.pushButton_refreshPreviews==sender()) { -// foreach(VP1CustomTourFrameWidget*frame,m_d->frames) -// m_d->updateFrameSnapshot(frame); -// } else if (m_d->ui.pushButton_execute==sender()) { -// m_d->viewer->startCustomTour(); -// } else if (m_d->ui.pushButton_utilityZoomShow==sender()) { -// } -//} - diff --git a/GeoModelVisualization/VP1Gui/src/VP1EventDisplaySceneView.cxx b/GeoModelVisualization/VP1Gui/src/VP1EventDisplaySceneView.cxx deleted file mode 100644 index 0c297f71035f5ae92dccbb7e9b36db36acd96bfd..0000000000000000000000000000000000000000 --- a/GeoModelVisualization/VP1Gui/src/VP1EventDisplaySceneView.cxx +++ /dev/null @@ -1,373 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/* - * jira_1 - * VP1EventDisplaySceneView.cxx - * - * Created on: Sep 26, 2013 - * Author: rbianchi <Riccardo.Maria.Bianchi@cern.ch> - * - */ - -#include "VP1Gui/VP1EventDisplaySceneView.h" -#include "VP1Base/VP1Msg.h" - -#include <QtGui> -#include <QPrinter> -#include <QPrintDialog> - -#ifndef QT_NO_OPENGL - #include <QtOpenGL> -#endif - -#include <qmath.h> - -// with this we can use the mouse central wheel on the zoom sliders -void GraphicsView::wheelEvent(QWheelEvent *e) -{ - if (e->modifiers() & Qt::ControlModifier) { - if (e->delta() > 0) - m_view->zoomIn(6); - else - m_view->zoomOut(6); - e->accept(); - } else { - QGraphicsView::wheelEvent(e); - } -} - -VP1EventDisplaySceneView::VP1EventDisplaySceneView(const QString &name, bool preview, QWidget *parent) -: QFrame(parent),m_frame(nullptr),m_line(nullptr) -{ - m_preview = preview; - - - setFrameStyle(Sunken | StyledPanel); - - m_graphicsView = new GraphicsView(this); - m_graphicsView->setRenderHint(QPainter::Antialiasing, false); - m_graphicsView->setDragMode(QGraphicsView::RubberBandDrag); - m_graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState); - m_graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); - m_graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - - int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize); - QSize iconSize(size, size); - - - // ZOOM BUTTONS - - m_zoomInIcon = new QToolButton; - m_zoomInIcon->setAutoRepeat(true); - m_zoomInIcon->setAutoRepeatInterval(33); - m_zoomInIcon->setAutoRepeatDelay(0); - m_zoomInIcon->setIcon(QPixmap(":/vp1/icons/icons/zoomin.png")); - m_zoomInIcon->setIconSize(iconSize); - - m_zoomOutIcon = new QToolButton; - m_zoomOutIcon->setAutoRepeat(true); - m_zoomOutIcon->setAutoRepeatInterval(33); - m_zoomOutIcon->setAutoRepeatDelay(0); - m_zoomOutIcon->setIcon(QPixmap(":/vp1/icons/icons/zoomout.png")); - m_zoomOutIcon->setIconSize(iconSize); - - m_zoomSlider = new QSlider(); - m_zoomSlider->setMinimum(0); - m_zoomSlider->setMaximum(500); - m_zoomSlider->setValue(250); - m_zoomSlider->setTickPosition(QSlider::TicksRight); - - // Zoom slider layout - m_zoomSliderLayout = new QVBoxLayout; - m_zoomSliderLayout->addWidget(m_zoomInIcon); - m_zoomSliderLayout->addWidget(m_zoomSlider); - m_zoomSliderLayout->addWidget(m_zoomOutIcon); - - - // ROTATION BUTTONS - m_rotateLeftIcon = new QToolButton(); - m_rotateLeftIcon->setIcon(QPixmap(":/vp1/icons/icons/rotateleft.png")); - m_rotateLeftIcon->setIconSize(iconSize); - - m_rotateRightIcon = new QToolButton(); - m_rotateRightIcon->setIcon(QPixmap(":/vp1/icons/icons/rotateright.png")); - m_rotateRightIcon->setIconSize(iconSize); - - m_rotateSlider = new QSlider(); - m_rotateSlider->setOrientation(Qt::Horizontal); - m_rotateSlider->setMinimum(-360); - m_rotateSlider->setMaximum(360); - m_rotateSlider->setValue(0); - m_rotateSlider->setTickPosition(QSlider::TicksBelow); - - // Rotate slider layout - m_rotateSliderLayout = new QHBoxLayout; - m_rotateSliderLayout->addWidget(m_rotateLeftIcon); - m_rotateSliderLayout->addWidget(m_rotateSlider); - m_rotateSliderLayout->addWidget(m_rotateRightIcon); - - m_resetButton = new QToolButton; - m_resetButton->setText(tr("Reset")); - m_resetButton->setEnabled(false); - - // Label layout - QHBoxLayout *labelLayout = new QHBoxLayout; - m_label = new QLabel(name); - m_label2 = new QLabel(tr("Pointer Mode")); - - m_selectModeButton = new QToolButton; - m_selectModeButton->setText(tr("Select & Move items")); - m_selectModeButton->setCheckable(true); - m_selectModeButton->setChecked(true); - - m_dragModeButton = new QToolButton; - m_dragModeButton->setText(tr("Drag View")); - m_dragModeButton->setCheckable(true); - m_dragModeButton->setChecked(false); - - m_antialiasButton = new QToolButton; - m_antialiasButton->setText(tr("Antialiasing")); - m_antialiasButton->setCheckable(true); - m_antialiasButton->setChecked(false); - - m_openGlButton = new QToolButton; - m_openGlButton->setText(tr("OpenGL")); - m_openGlButton->setCheckable(true); -#ifndef QT_NO_OPENGL - m_openGlButton->setEnabled(QGLFormat::hasOpenGL()); -#else - m_openGlButton->setEnabled(false); -#endif - m_printButton = new QToolButton; - m_printButton->setIcon(QIcon(QPixmap(":/vp1/icons/icons/fileprint.png"))); - - QButtonGroup *pointerModeGroup = new QButtonGroup; - pointerModeGroup->setExclusive(true); - pointerModeGroup->addButton(m_selectModeButton); - pointerModeGroup->addButton(m_dragModeButton); - - labelLayout->addWidget(m_label); - labelLayout->addStretch(); - - if (!preview) { - labelLayout->addWidget(m_label2); - labelLayout->addWidget(m_selectModeButton); - labelLayout->addWidget(m_dragModeButton); - labelLayout->addStretch(); -// labelLayout->addWidget(m_antialiasButton); // we don't use these buttons -// labelLayout->addWidget(m_openGlButton); -// labelLayout->addWidget(m_printButton); - } - - QGridLayout *topLayout = new QGridLayout; - topLayout->addLayout(labelLayout, 0, 0); - topLayout->addWidget(m_graphicsView, 1, 0); - /* - * PREVIEW WINDOW - * we don't need the rotation or zoom buttons for the "preview" view - * and we put the reset button just below the zoom buttons - */ - if (preview) { - // m_zoomSliderLayout->addWidget(m_resetButton); - } - /* - * FULL SIZE WINDOW - */ - else { - topLayout->addLayout(m_zoomSliderLayout, 1, 1); - topLayout->addLayout(m_rotateSliderLayout, 2, 0); - topLayout->addWidget(m_resetButton, 2, 1); - } - - setLayout(topLayout); - - - - - connect(m_resetButton, SIGNAL(clicked()), this, SLOT(resetView())); - - connect(m_graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled())); - connect(m_graphicsView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled())); - - connect(m_selectModeButton, SIGNAL(toggled(bool)), this, SLOT(togglePointerMode())); - connect(m_dragModeButton, SIGNAL(toggled(bool)), this, SLOT(togglePointerMode())); - - connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setupMatrix())); - connect(m_zoomInIcon, SIGNAL(clicked()), this, SLOT(zoomIn())); - connect(m_zoomOutIcon, SIGNAL(clicked()), this, SLOT(zoomOut())); - - connect(m_rotateSlider, SIGNAL(valueChanged(int)), this, SLOT(setupMatrix())); - connect(m_rotateLeftIcon, SIGNAL(clicked()), this, SLOT(rotateLeft())); - connect(m_rotateRightIcon, SIGNAL(clicked()), this, SLOT(rotateRight())); - - - // we do not use these three buttons now... -// connect(m_printButton, SIGNAL(clicked()), this, SLOT(print())); -// connect(m_antialiasButton, SIGNAL(toggled(bool)), this, SLOT(toggleAntialiasing())); -// connect(m_openGlButton, SIGNAL(toggled(bool)), this, SLOT(toggleOpenGL())); - - setupMatrix(); // only useful for the full-view window -} - -VP1EventDisplaySceneView::~VP1EventDisplaySceneView() -{ - /* if preview, many buttons are not added to any widget or layout, - * so we have to destroy them by hand - */ - if (m_preview) { - delete m_rotateSlider; - delete m_rotateLeftIcon; - delete m_rotateRightIcon; - delete m_rotateSliderLayout; - delete m_zoomSlider; - delete m_zoomInIcon; - delete m_zoomOutIcon; - delete m_zoomSliderLayout; - delete m_resetButton; - delete m_label2; - delete m_selectModeButton; - delete m_dragModeButton; - } - /* - * we have to destroy them by hand, because we do not use them in this version of the GUI - */ - delete m_antialiasButton; - delete m_openGlButton; - delete m_printButton; -} - -QGraphicsView *VP1EventDisplaySceneView::view() const -{ - return static_cast<QGraphicsView *>(m_graphicsView); -} - -void VP1EventDisplaySceneView::addRenderingFrame() -{ -// adding a rect to the preview to define the rendering area -// QPen pen2(Qt::green, 5, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin); - QPen pen(Qt::red, 5, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin); - QRectF sceneRect = m_graphicsView->scene()->sceneRect(); - m_frame = m_graphicsView->scene()->addRect( sceneRect, pen ); - - /* we also have to add a line on the bottom of the scene, - * since the bottom side of the frame will go out of the view, - * due to the thickness of the frame lines. - */ - qreal x1 = sceneRect.left(); - qreal y1 = sceneRect.bottom(); - qreal y2 = y1; - qreal x2 = sceneRect.right(); - - m_line = m_graphicsView->scene()->addLine( x1, y1, x2, y2, pen); -} - -void VP1EventDisplaySceneView::showRenderingFrame() -{ - m_frame->show(); - m_line->show(); -} - -void VP1EventDisplaySceneView::hideRenderingFrame() -{ - m_frame->hide(); - m_line->hide(); -} - - - -void VP1EventDisplaySceneView::resetView() -{ - m_zoomSlider->setValue(250); - m_rotateSlider->setValue(0); - setupMatrix(); - m_graphicsView->ensureVisible(QRectF(0, 0, 0, 0)); - - m_resetButton->setEnabled(false); -} - -void VP1EventDisplaySceneView::setResetButtonEnabled() -{ - m_resetButton->setEnabled(true); -} - -void VP1EventDisplaySceneView::setPreviewZoom(qreal xx) -{ - if (m_preview) { - QMatrix matrix; - matrix.scale(xx, xx); - m_graphicsView->setMatrix(matrix); - } else { - VP1Msg::message("Warning!! using setPreviewZoom() on a full-size view has no effect."); - } - -} - -void VP1EventDisplaySceneView::setupMatrix() -{ - if (!m_preview) { - QMatrix matrix; - qreal scale = qPow(qreal(2), (m_zoomSlider->value() - 250) / qreal(50)); - matrix.scale(scale, scale); - matrix.rotate(m_rotateSlider->value()); - - m_graphicsView->setMatrix(matrix); - setResetButtonEnabled(); - } - -} - -void VP1EventDisplaySceneView::togglePointerMode() -{ - m_graphicsView->setDragMode(m_selectModeButton->isChecked() - ? QGraphicsView::RubberBandDrag - : QGraphicsView::ScrollHandDrag); - m_graphicsView->setInteractive(m_selectModeButton->isChecked()); -} - -void VP1EventDisplaySceneView::toggleOpenGL() -{ -#ifndef QT_NO_OPENGL - m_graphicsView->setViewport(m_openGlButton->isChecked() ? new QGLWidget(QGLFormat(QGL::SampleBuffers)) : new QWidget); -#endif -} - -void VP1EventDisplaySceneView::toggleAntialiasing() -{ - m_graphicsView->setRenderHint(QPainter::Antialiasing, m_antialiasButton->isChecked()); -} - -void VP1EventDisplaySceneView::print() -{ -#ifndef QT_NO_PRINTER - QPrinter printer; - QPrintDialog dialog(&printer, this); - if (dialog.exec() == QDialog::Accepted) { - QPainter painter(&printer); - m_graphicsView->render(&painter); - } -#endif -} - -void VP1EventDisplaySceneView::zoomIn(int level) -{ - m_zoomSlider->setValue(m_zoomSlider->value() + level); -} - -void VP1EventDisplaySceneView::zoomOut(int level) -{ - m_zoomSlider->setValue(m_zoomSlider->value() - level); -} - -void VP1EventDisplaySceneView::rotateLeft() -{ - m_rotateSlider->setValue(m_rotateSlider->value() - 10); -} - -void VP1EventDisplaySceneView::rotateRight() -{ - m_rotateSlider->setValue(m_rotateSlider->value() + 10); -} - - diff --git a/GeoModelVisualization/VP1Gui/src/VP1Prioritiser.cxx b/GeoModelVisualization/VP1Gui/src/VP1Prioritiser.cxx index 7078c6977c225d13a8937bd23eeb40e972833723..5182c4ff4fd2ea430f97a1215f4ad848ec829e4c 100644 --- a/GeoModelVisualization/VP1Gui/src/VP1Prioritiser.cxx +++ b/GeoModelVisualization/VP1Gui/src/VP1Prioritiser.cxx @@ -20,6 +20,7 @@ #include <QSet> #include <map> #include <cassert> +#include <unistd.h> ///////////////////////////////////////////////////////////////////// //////////////////// Class VP1Prioritiser::Imp //////////////////// @@ -59,7 +60,7 @@ public: QHash<IVP1System*,SystemInfo*> sys2info; - QTime * stopwatch; + QTime stopwatch; IVP1System* currenttimedsystem; void updateSysinfoWithVisibilityState(const QSet<IVP1ChannelWidget*>& channels, @@ -128,7 +129,7 @@ inline void VP1Prioritiser::Imp::SystemInfo::addTimeMeasurement(const double&t) m_timemeasurements.dequeue(); QList<double> tmplist = m_timemeasurements; - qSort(tmplist.begin(), tmplist.end()); + std::sort(tmplist.begin(), tmplist.end()); switch(tmplist.count()) { case 1: m_timing = tmplist.at(0); break; @@ -191,7 +192,6 @@ VP1Prioritiser::VP1Prioritiser(QObject*parent) : QObject(parent), m_d(new Imp) { m_d->prioritiser=this; - m_d->stopwatch = new QTime(); m_d->currenttimedsystem=0; m_d->soonvisbonus=0; } @@ -199,7 +199,6 @@ VP1Prioritiser::VP1Prioritiser(QObject*parent) //____________________________________________________________________ VP1Prioritiser::~VP1Prioritiser() { - delete m_d->stopwatch; delete m_d; m_d=0; } @@ -236,12 +235,12 @@ double VP1Prioritiser::estimateRemainingCalcTime() const } return tmp; } - +#include <iostream> //___________________________________________________________________ double VP1Prioritiser::beginTiming_Refresh(IVP1System*s) { assert(!m_d->currenttimedsystem); - m_d->stopwatch->start(); + m_d->stopwatch = QTime::currentTime(); m_d->currenttimedsystem=s; assert(m_d->sys2info.contains(s)); return m_d->sys2info[s]->refreshtime(); @@ -251,14 +250,17 @@ double VP1Prioritiser::beginTiming_Refresh(IVP1System*s) //___________________________________________________________________ double VP1Prioritiser::elapsedTiming_Refresh() { - return static_cast<double>(m_d->stopwatch->elapsed()); + QTime t=QTime::currentTime(); + double ms=static_cast<double>(m_d->stopwatch.msecsTo(t)); + return ms; } //___________________________________________________________________ double VP1Prioritiser::endTiming_Refresh() { assert(m_d->currenttimedsystem); - double timing = static_cast<double>(m_d->stopwatch->elapsed()); + QTime t=QTime::currentTime(); + double timing = static_cast<double>(m_d->stopwatch.msecsTo(t)); if (m_d->sys2info.contains(m_d->currenttimedsystem)) {//This check, since the corresponding channel might have become uncreated in the meantime. m_d->sys2info[m_d->currenttimedsystem]->addTimeMeasurement(timing); } diff --git a/GeoModelVisualization/VP1Gui/src/VP1TabManager.cxx b/GeoModelVisualization/VP1Gui/src/VP1TabManager.cxx index 73d8e3d8cc53a9bc58bc4b5a49e335e805b861ef..c79023a67fc4f6dcd268f71f206228ce8a5579ff 100644 --- a/GeoModelVisualization/VP1Gui/src/VP1TabManager.cxx +++ b/GeoModelVisualization/VP1Gui/src/VP1TabManager.cxx @@ -31,6 +31,7 @@ #include <QSet> #include <QFileInfo> #include <QMap> +#include <QMultiMap> #include <QTimer> #include <QBuffer> #include <QByteArray> @@ -723,9 +724,11 @@ void VP1TabManager::cloneChannelToTab(QString channeluniquename,QString tabname) assert(cw); IVP1ChannelWidget * newcw = addChannelToTab(cw->name(),tabname); if (newcw) { +#ifdef SAVEANDRESTORE ChanState state; serializeChannelState(cw,state); unserializeChannelState(newcw,state); +#endif } } @@ -748,9 +751,11 @@ void VP1TabManager::cloneTab(QString oldtabname,QString newtabname) for (;it!=itE;++it) { IVP1ChannelWidget * newcw = addChannelToTab((*it)->name(),newtabname); if (newcw) { +#ifdef SAVEANDRESTORE ChanState state; serializeChannelState(*it,state); unserializeChannelState(newcw,state); +#endif } } @@ -763,6 +768,8 @@ void VP1TabManager::cloneTab(QString oldtabname,QString newtabname) +#ifdef SAVEANDRESTORE + //___________________________________________________________________________________ void VP1TabManager::saveConfigurationToFile(QString filename,const bool& askonoverride) { if (filename.isEmpty()) { @@ -819,7 +826,6 @@ void VP1TabManager::saveConfigurationToFile(QString filename,const bool& askonov } - //___________________________________________________________________________________ void VP1TabManager::loadConfigurationFromFile(QString filename,const QMap<QString,QString>& availableplugins) { if (filename.isEmpty()) { @@ -954,8 +960,9 @@ void VP1TabManager::loadConfigurationFromFile(QString filename,const QMap<QStrin return; lastaddedtab=newtabname; - QMapIterator<QString,ChanState> it( tab2channels.value(newtabname_infile) ); - + // QMapIterator<QString,ChanState> + // auto + QMultiMap<QString, std::pair<QByteArray, QMultiMap<QString, QByteArray> > >it=( tab2channels.value(newtabname_infile) ); while (it.hasNext()) { it.next(); //it.key(): Channel base name. @@ -995,6 +1002,7 @@ void VP1TabManager::loadConfigurationFromFile(QString filename,const QMap<QStrin if (!lastaddedtab.isEmpty()) showTab(lastaddedtab); } +#endif //___________________________________________________________________________________ void VP1TabManager::Imp::serializeTabAndChannelConfigInfo(QMap<QString,QMultiMap<QString,ChanState> >& tab2channels, @@ -1012,9 +1020,11 @@ void VP1TabManager::Imp::serializeTabAndChannelConfigInfo(QMap<QString,QMultiMap std::set<IVP1ChannelWidget*>::const_iterator it = itcws->second.begin(); std::set<IVP1ChannelWidget*>::const_iterator itE = itcws->second.end(); for (;it!=itE;++it) { +#ifdef SAVEANDRESTORE ChanState chanstate; tabmanager->serializeChannelState(*it,chanstate); channelsinfo.insert((*it)->name(),chanstate); +#endif } tab2channels.insert(tabname,channelsinfo); @@ -1023,6 +1033,7 @@ void VP1TabManager::Imp::serializeTabAndChannelConfigInfo(QMap<QString,QMultiMap } } + //___________________________________________________________________________________ QString VP1TabManager::suggestNewTabName(QString oldtabname) const { QString newtabname=oldtabname; @@ -1521,6 +1532,7 @@ void VP1TabManager::executePendingChannelRemoval() m_d->channelWithPendingRemoval=""; } +#ifdef SAVEANDRESTORE //___________________________________________________________________________________ void VP1TabManager::serializeChannelState(IVP1ChannelWidget*cw,ChanState&state) { @@ -1578,3 +1590,4 @@ void VP1TabManager::unserializeChannelState(IVP1ChannelWidget*cw,ChanState state foreach (QString name,storedSystems) std::cout<<"VP1TabManager::unserializeChannelState Warning: Did not use stored configuration for system "<<name.toStdString()<<std::endl; } +#endif diff --git a/GeoModelVisualization/VP1GuideLineSystems/CMakeLists.txt b/GeoModelVisualization/VP1GuideLineSystems/CMakeLists.txt index d98bda0f416b421d68ec3c748961307cca883585..100e56767a93500eba655ffca38b6ce7b69346c0 100644 --- a/GeoModelVisualization/VP1GuideLineSystems/CMakeLists.txt +++ b/GeoModelVisualization/VP1GuideLineSystems/CMakeLists.txt @@ -8,7 +8,7 @@ file( GLOB UIS src/*.ui ) # Add the library. add_library( GXGuideLineSystems SHARED ${SOURCES} ${HEADERS} ${UIS} ) target_link_libraries( GXGuideLineSystems - PUBLIC Coin::Coin Qt5::Core Qt5::Gui Qt5::Widgets GXBase + PUBLIC Coin::Coin Qt${QT_VERSION}::Core Qt${QT_VERSION}::Gui Qt${QT_VERSION}::Widgets GXBase PRIVATE GeoModelCore::GeoModelKernel GXHEPVis ) target_include_directories( GXGuideLineSystems PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> diff --git a/GeoModelVisualization/cmake/GeoModelVisualizationConfig.cmake.in b/GeoModelVisualization/cmake/GeoModelVisualizationConfig.cmake.in index b81d6030b6bf7ffe0f58f59d9b820cb7198de50b..17d42aeaa69849264dc1464e8100a01cab608055 100644 --- a/GeoModelVisualization/cmake/GeoModelVisualizationConfig.cmake.in +++ b/GeoModelVisualization/cmake/GeoModelVisualizationConfig.cmake.in @@ -6,7 +6,7 @@ find_dependency( GeoModelCore @GeoModel_VERSION@ CONFIG EXACT ) find_dependency( GeoModelIO @GeoModel_VERSION@ CONFIG EXACT ) find_dependency( Coin3D ) find_dependency( SoQt ) -find_dependency( Qt5 @Qt5_VERSION@ +find_dependency( Qt6 @Qt6_VERSION@ COMPONENTS Core Gui Widgets Sql PrintSupport EXACT ) find_dependency( OpenGL )