diff --git a/graphics/VP1/VP1Systems/VP1BanksSystems/VP1BanksSystems/VP1BanksSystem.h b/graphics/VP1/VP1Systems/VP1BanksSystems/VP1BanksSystems/VP1BanksSystem.h new file mode 100755 index 0000000000000000000000000000000000000000..5db0552e395ca96410098b3c879bcd85a94f8c15 --- /dev/null +++ b/graphics/VP1/VP1Systems/VP1BanksSystems/VP1BanksSystems/VP1BanksSystem.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VP1BANKSSYSTEM_H +#define VP1BANKSSYSTEM_H + +///////////////////////////////////////////////////////////////////////// +// // +// Header file for class VP1BanksSystem // +// // +// Author: Joe Boudreau <boudreau@pitt.edu> // +// VP1 implementation: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> // +// // +// Initial VP1 version: May 2007 // +// // +///////////////////////////////////////////////////////////////////////// + +#include "VP1Base/IVP1System.h" + +class VP1BanksSystem : public IVP1System { + + Q_OBJECT + +public: + VP1BanksSystem(); + virtual ~VP1BanksSystem(); + + void create( StoreGateSvc* detstore ); + void refresh( StoreGateSvc* storegate ); + void erase(); + + QByteArray saveState(); + void restoreFromState(QByteArray); + +signals: + void entriesChanged(const QStringList& entry_key,const QStringList& entry_type,const QStringList& entry_id); + +public slots: + void refreshList(); + +protected: + class Imp; + Imp * d; +}; + +#endif diff --git a/graphics/VP1/VP1Systems/VP1BanksSystems/cmt/requirements b/graphics/VP1/VP1Systems/VP1BanksSystems/cmt/requirements new file mode 100755 index 0000000000000000000000000000000000000000..38213fcc3e9c6f7e46ae582f80758599e5886fee --- /dev/null +++ b/graphics/VP1/VP1Systems/VP1BanksSystems/cmt/requirements @@ -0,0 +1,16 @@ +package VP1BanksSystems + +author Thomas Kittelmann <Thomas.Kittelmann@cern.ch> +manager Thomas Kittelmann <Thomas.Kittelmann@cern.ch> + +use AtlasPolicy AtlasPolicy-* +use VP1Base VP1Base-* graphics/VP1 +private +use VP1Utils VP1Utils-* graphics/VP1 +use AthenaKernel AthenaKernel-* Control +#use GaudiKernel GaudiKernel-* +use CLIDSvc CLIDSvc-* Control +use GaudiInterface GaudiInterface-* External +public + +apply_pattern qt4based_library diff --git a/graphics/VP1/VP1Systems/VP1BanksSystems/src/VP1BanksSystem.cxx b/graphics/VP1/VP1Systems/VP1BanksSystems/src/VP1BanksSystem.cxx new file mode 100755 index 0000000000000000000000000000000000000000..38b849fb0236dafa2bc07f2f34d9574fbda4166e --- /dev/null +++ b/graphics/VP1/VP1Systems/VP1BanksSystems/src/VP1BanksSystem.cxx @@ -0,0 +1,178 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VP1BanksSystems/VP1BanksSystem.h" +#include "ui_vp1bankscontroller.h" +#include "VP1Utils/VP1SGContentsHelper.h" +#include "VP1Base/VP1Serialise.h" +#include "VP1Base/VP1Deserialise.h" + +#include "AthenaKernel/IClassIDSvc.h" +#include "GaudiKernel/ISvcLocator.h" + +//____________________________________________________________________ +class VP1BanksSystem::Imp { +public: + Imp(VP1BanksSystem*tc) : theclass(tc), allowRefresh(false), clidSvc(0) {} + VP1BanksSystem * theclass; + bool useDetStore(); + bool allowRefresh; + Ui::VP1BanksSystemControllerForm ui; + + QString idToName(const CLID&) const; + IClassIDSvc *clidSvc; + + QStringList lastEmitted_keys; + QStringList lastEmitted_types; + QStringList lastEmitted_ids; + + // void emitIfChanged(const QStringList& keys, const QStringList& types, const QStringList& ids) { + void emitIfChanged(QStringList keys, QStringList types, QStringList ids) { + if (lastEmitted_keys==keys&&lastEmitted_types==types&&lastEmitted_ids==ids) + return; + lastEmitted_keys=keys; + lastEmitted_types=types; + lastEmitted_ids=ids; + theclass->messageVerbose("emitting entriesChanged(..) with "+str(keys.count())+" entries"); + theclass->entriesChanged(keys,types,ids); + } + +}; + + +//____________________________________________________________________ +VP1BanksSystem::VP1BanksSystem() + : IVP1System("Banks", + "System for browsing the contents of StoreGate", + "Joe Boudreau <boudreau@pitt.edu> (original), Thomas.Kittelmann@cern.ch (VP1 implementation)"), + d(new Imp(this)) +{ + d->clidSvc=0; + d->ui.radioButton_store_event = 0; + d->ui.radioButton_store_detector = 0; + d->ui.pushButton_refresh = 0; +} + + +//____________________________________________________________________ +VP1BanksSystem::~VP1BanksSystem() +{ + delete d; d=0; +} + +//____________________________________________________________________ +QString VP1BanksSystem::Imp::idToName( const CLID& id ) const +{ + if (!clidSvc) + return ""; + std::string n; + if (clidSvc->getTypeNameOfID(id, n).isFailure()) + return "<unknown>"; + return n.c_str(); +} + +//____________________________________________________________________ +bool VP1BanksSystem::Imp::useDetStore() +{ + return ui.radioButton_store_event && !ui.radioButton_store_event->isChecked(); +} + + +//____________________________________________________________________ +void VP1BanksSystem::create( StoreGateSvc* /*detstore*/ ) +{ + QWidget * controller = new QWidget; + d->ui.setupUi(controller); + connect(d->ui.radioButton_store_event,SIGNAL(toggled(bool)),this,SLOT(refreshList())); + connect(d->ui.pushButton_refresh,SIGNAL(clicked()),this,SLOT(refreshList())); + registerController(controller); + + ISvcLocator* svcLoc = serviceLocator(); + if (!svcLoc) { + message("Error: Got NULL pointer to the service locator!"); + return; + } + StatusCode status = svcLoc->service( "ClassIDSvc",d->clidSvc ); + if(!status.isSuccess()) { + d->clidSvc=0; + message("Error: Could not retrieve ClassIDSvc!!"); + return; + } + + +} + +//____________________________________________________________________ +void VP1BanksSystem::refresh( StoreGateSvc* ) +{ + d->allowRefresh = true; + refreshList(); +} + +//____________________________________________________________________ +void VP1BanksSystem::refreshList() +{ + if (!d->allowRefresh) + return; + messageVerbose("Refreshing list for "+QString(d->useDetStore()?"detector":"event")+" store"); + + QStringList entry_key; + QStringList entry_type; + QStringList entry_id; + + VP1SGContentsHelper sgcont(this,d->useDetStore()); + + int i(0); + foreach (CLID id, sgcont.getPossibleCLIDs()) { + QStringList keys = sgcont.getKeys(id); + if (!keys.isEmpty()) { + QString typeName = d->idToName(id); + QString idstr = QString::number(id); + foreach (QString key,keys) { + entry_key << key; + entry_type << typeName; + entry_id << idstr; + } + } + if (!i++%20) + updateGUI(); + } + d->emitIfChanged(entry_key,entry_type,entry_id); +} + +//____________________________________________________________________ +void VP1BanksSystem::erase() +{ + d->allowRefresh = false; + d->emitIfChanged(QStringList(),QStringList(),QStringList()); +} + + +//____________________________________________________________________ +QByteArray VP1BanksSystem::saveState() +{ + VP1Serialise serialise(0/*version*/,this); + serialise.save(IVP1System::saveState());//Info from base class + + serialise.save(d->ui.radioButton_store_event,d->ui.radioButton_store_detector); + + serialise.warnUnsaved(controllerWidget()); + return serialise.result(); + +} + +//____________________________________________________________________ +void VP1BanksSystem::restoreFromState(QByteArray ba) +{ + VP1Deserialise state(ba,this); + if (state.version()!=0) { + message("Warning: State data in .vp1 file is in wrong format - ignoring!"); + return; + } + IVP1System::restoreFromState(state.restoreByteArray()); + + state.restore(d->ui.radioButton_store_event,d->ui.radioButton_store_detector); + + state.warnUnrestored(controllerWidget()); +} diff --git a/graphics/VP1/VP1Systems/VP1BanksSystems/src/vp1bankscontroller.ui b/graphics/VP1/VP1Systems/VP1BanksSystems/src/vp1bankscontroller.ui new file mode 100644 index 0000000000000000000000000000000000000000..952ebd62f9062429043251e71ca71eec2f4e39ce --- /dev/null +++ b/graphics/VP1/VP1Systems/VP1BanksSystems/src/vp1bankscontroller.ui @@ -0,0 +1,105 @@ +<ui version="4.0" > + <class>VP1BanksSystemControllerForm</class> + <widget class="QWidget" name="VP1BanksSystemControllerForm" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>176</width> + <height>156</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Displayed store:</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <layout class="QHBoxLayout" > + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" > + <item> + <widget class="QRadioButton" name="radioButton_store_event" > + <property name="text" > + <string>Event store</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="radioButton_store_detector" > + <property name="text" > + <string>Detector store</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="2" column="0" > + <widget class="QPushButton" name="pushButton_refresh" > + <property name="text" > + <string>Refresh</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>1</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui>