ATLAS Offline Software
IVP13DSystemSimple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // Implementation of class IVP13DSystemSimple //
8 // //
9 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10 // //
11 // Initial version: April 2007 //
12 // //
14 
17 #include "VP1Base/VP1Msg.h"
18 #include "Inventor/SoPath.h"
19 #include "Inventor/nodes/SoSeparator.h"
20 #include <iostream>
21 
22 // These have defaults that dont do anything:
24 QWidget * IVP13DSystemSimple::buildController() { return 0; }
26 void IVP13DSystemSimple::userPickedNode(SoNode*, SoPath *){}
29 {
30  // messageVerbose("WARNING: Did not reimplement systemerase!");
31 }
32 
34 public:
37  SoSeparator *rootR; // Present for the whole run.
38  SoSeparator *rootE; // Present for one event;
39  void getNodesWithDisabledNotifications(SoGroup*, QList<SoNode*>&) const;
41  bool wascreated;
43  bool first;
44  //Due to userPickedNode() this class has its own callback (we disable the ones from the baseclass below by setUserSelectionNotificationsEnabled, to avoid duplication)
45  static void made_selection( void * userdata, SoPath * path );
46 
47 };
48 
49 //___________________________________________________________
50 IVP13DSystemSimple::IVP13DSystemSimple(const QString & name, const QString & information, const QString & contact_info)
51  : IVP13DSystem(name,information,contact_info), m_d(new Imp())
52 {
53  m_d->theclass = this;
54  m_d->controllerBuilt = false;
55  m_d->first = true;
56  //Root node is selection node for default selections causing invocations of userPickedNode:
59  selection->policy = SoSelection::SINGLE;
62  selection->addSelectionCallback( Imp::made_selection, this );
63 
64  m_d->root = selection;
65  m_d->rootR = new SoSeparator();
66  m_d->rootE = new SoSeparator();
67  m_d->root->addChild(m_d->rootR);
68  m_d->root->addChild(m_d->rootE);
69  m_d->root->ref();
70  m_d->rootR->ref();
71  m_d->rootE->ref();
72  m_d->root->setName(QString(name+"_SceneGraph").replace(' ','_').toStdString().c_str());
73  m_d->rootE->setName(QString(name+"_EventSceneGraph").replace(' ','_').toStdString().c_str());
74  m_d->rootR->setName(QString(name+"_PermanentSceneGraph").replace(' ','_').toStdString().c_str());
75  m_d->wasrefreshed=false;
76  m_d->wascreated=false;
77 }
78 
79 //___________________________________________________________
82  m_d->root->unref();
83  m_d->rootR->unref();
84  m_d->rootE->unref();
85  delete m_d;
86  m_d=0;
87 }
88 
89 //___________________________________________________________________________________________________________
91 {
92  if (m_d->controllerBuilt)
93  return;
94  m_d->controllerBuilt=true;
95  if(VP1Msg::verbose()){
96  messageVerbose("IVP13DSystemSimple build controller");
97  }
98  QWidget * controller = buildController();
99  if (controller)
100  registerController(controller);
101  if(VP1Msg::verbose()){
102  messageVerbose("IVP13DSystemSimple controller was = "+str(controller));
103  }
104 }
105 
106 //___________________________________________________________________________________________________________
107 void IVP13DSystemSimple::Imp::made_selection( void * userdata, SoPath * path )
108 {
109  IVP13DSystemSimple * system = static_cast<IVP13DSystemSimple *>(userdata);
110  if (!system) {
111  std::cout<<"IVP13DSystemSimple::Imp::made_selection Error: Could not find system pointer!"<<std::endl;
112  return;
113  }
114 
115  SoFullPath *fPath = static_cast<SoFullPath *>(path);
116  if (!fPath)
117  return;
118  SoNode *selectedNode = fPath->getTail();
119  if (!selectedNode)
120  return;
121 
122  system->userPickedNode(selectedNode, path);
123  std::cout << "selected nodes: " << system->m_d->root->getNumSelected() << ", " << system->m_d->root->getPath(0) << std::endl;
124 }
125 
126 //___________________________________________________________
128 {
129  return static_cast<SoSeparator*>(m_d->root);
130 }
131 
132 //___________________________________________________________
134 {
135  if(VP1Msg::verbose()){
136  messageVerbose("IVP13DSystemSimple create");
137  }
138  assert(!m_d->wasrefreshed);
139  assert(!m_d->wascreated);
140  ensureBuildController();//TODO: Move to refresh.
141  m_d->wascreated=true;
142  m_d->wasrefreshed=false;
143 }
144 
145 //___________________________________________________________
147 {
148  assert(m_d->wascreated);
149  assert(!m_d->wasrefreshed);
150 
151  if (m_d->first) {
152  if(VP1Msg::verbose()){
153  messageVerbose("IVP13DSystemSimple first refresh - so calling create methods (i.e. delayed create).");
154  }
156  m_d->first = false;
157  m_d->root->removeChild(m_d->rootR);
159  m_d->root->addChild(m_d->rootR);
160  }
161 
162  m_d->root->removeChild(m_d->rootE);
163  updateGUI();
165  updateGUI();
166  m_d->root->addChild(m_d->rootE);
167 
168  m_d->wasrefreshed=true;
169 
170 }
171 
172 //___________________________________________________________
174 {
175  if(VP1Msg::verbose()){
176  messageVerbose("IVP13DSystemSimple::erase() start");
177  }
178  assert(m_d->wascreated);
179  assert(m_d->wasrefreshed);
180 
181  bool saveE = m_d->rootE->enableNotify(false);
182 
183  systemerase();
184  if(VP1Msg::verbose()){
185  messageVerbose("IVP13DSystemSimple::erase() Removing all event objects from scene");
187  }
188  m_d->rootE->removeAllChildren();
189 
190  if (saveE) {
191  m_d->rootE->enableNotify(true);
192  m_d->rootE->touch();
193  }
194 
195  m_d->wasrefreshed=false;
196  if(VP1Msg::verbose()){
197  messageVerbose("IVP13DSystemSimple::erase() end");
198  }
199 }
200 
201 //___________________________________________________________
203 {
204 
205  if(VP1Msg::verbose()){
206  messageDebug("uncreate()...");
207  }
208 
209  assert(m_d->wascreated);
210  assert(!m_d->wasrefreshed);
211  m_d->rootE->enableNotify(false);
212  m_d->rootR->enableNotify(false);
213  systemuncreate();
214  m_d->root->removeAllChildren();
215  m_d->rootE->removeAllChildren();
216  m_d->rootR->removeAllChildren();
217  m_d->wascreated=false;
218 }
219 
220 //___________________________________________________________
222 {
223  QList<SoNode*> nodesR;
224  QList<SoNode*> nodesE;
227  if (!nodesR.isEmpty()) {
228  message("WARNING: Found "+str(nodesR.count())+" node"+QString(nodesR.count()>1?"s":0)+" with disabled notifications in permanent scenegraph:");
229  for (SoNode * node : nodesR)
230  message(" => Node ("+str(node)+") of type "+QString(node->getTypeId().getName().getString())+", named "+QString(node->getName().getString()));
231  }
232  if (!nodesE.isEmpty()) {
233  message("WARNING: Found "+str(nodesE.count())+" node"+QString(nodesE.count()>1?"s":0)+" with disabled notifications in event scenegraph:");
234  for (SoNode * node : nodesE)
235  message(" => Node ("+str(node)+") of type "+QString(node->getTypeId().getName().getString())+", named "+QString(node->getName().getString()));
236  }
237 }
238 
239 //___________________________________________________________
241 {
242  const int n = gr->getNumChildren();
243  for (int i = 0; i < n; ++i) {
244  SoNode * child = gr->getChild(i);
245  if (!child->isNotifyEnabled())
246  l << child;
247  if (child->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
248  getNodesWithDisabledNotifications(static_cast<SoGroup*>(child),l);
249  }
250 }
IVP13DSystemSimple::systemuncreate
virtual void systemuncreate()
Definition: IVP13DSystemSimple.cxx:27
IVP13DSystem::setUserSelectionNotificationsEnabled
void setUserSelectionNotificationsEnabled(SoCooperativeSelection *sel, bool enabled)
Definition: IVP13DSystem.cxx:310
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
IVP13DSystemSimple
Definition: IVP13DSystemSimple.h:24
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
IVP13DSystemSimple::uncreate
void uncreate()
Definition: IVP13DSystemSimple.cxx:202
IVP13DSystemSimple::IVP13DSystemSimple
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
Definition: IVP13DSystemSimple.cxx:50
IVP13DSystemSimple::buildController
virtual QWidget * buildController()
Definition: IVP13DSystemSimple.cxx:24
VP1Msg.h
IVP13DSystemSimple::Imp::made_selection
static void made_selection(void *userdata, SoPath *path)
Definition: IVP13DSystemSimple.cxx:107
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
IVP13DSystemSimple::Imp::rootR
SoSeparator * rootR
Definition: IVP13DSystemSimple.cxx:37
IVP13DSystemSimple::Imp::rootE
SoSeparator * rootE
Definition: IVP13DSystemSimple.cxx:38
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
gr
#define gr
IVP13DSystemSimple.h
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
IVP13DSystemSimple::buildPermanentSceneGraph
virtual void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
Definition: IVP13DSystemSimple.cxx:25
IVP13DSystemSimple::Imp::root
SoCooperativeSelection * root
Definition: IVP13DSystemSimple.cxx:36
IVP13DSystemSimple::buildEventSceneGraph
virtual void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)=0
IVP13DSystem::registerSelectionNode
void registerSelectionNode(SoCooperativeSelection *)
Definition: IVP13DSystem.cxx:257
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
IVP13DSystemSimple::refresh
void refresh(StoreGateSvc *storegate)
Definition: IVP13DSystemSimple.cxx:146
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
IVP13DSystemSimple::Imp::theclass
IVP13DSystemSimple * theclass
Definition: IVP13DSystemSimple.cxx:35
IVP13DSystemSimple::systemerase
virtual void systemerase()
Definition: IVP13DSystemSimple.cxx:28
IVP13DSystemSimple::userPickedNode
virtual void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Definition: IVP13DSystemSimple.cxx:26
IVP13DSystemSimple::create
void create(StoreGateSvc *detstore)
Definition: IVP13DSystemSimple.cxx:133
IVP1System::name
const QString & name() const
Definition: IVP1System.cxx:50
IVP13DSystemSimple::systemcreate
virtual void systemcreate(StoreGateSvc *detstore)
Definition: IVP13DSystemSimple.cxx:23
IVP13DSystemSimple::ensureBuildController
void ensureBuildController()
Definition: IVP13DSystemSimple.cxx:90
IVP13DSystemSimple::Imp::first
bool first
Definition: IVP13DSystemSimple.cxx:43
SoCooperativeSelection::ensureInitClass
static void ensureInitClass()
Definition: SoCooperativeSelection.cxx:26
selection
const std::string selection
Definition: fbtTestBasics.cxx:74
SoCooperativeSelection.h
IVP1System::messageDebug
void messageDebug(const QString &) const
Definition: IVP1System.cxx:347
IVP1System::detectorStore
StoreGateSvc * detectorStore() const
Definition: IVP1System.cxx:318
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IVP13DSystemSimple::Imp::controllerBuilt
bool controllerBuilt
Definition: IVP13DSystemSimple.cxx:42
IVP13DSystemSimple::Imp::getNodesWithDisabledNotifications
void getNodesWithDisabledNotifications(SoGroup *, QList< SoNode * > &) const
Definition: IVP13DSystemSimple.cxx:240
IVP13DSystemSimple::erase
void erase()
Definition: IVP13DSystemSimple.cxx:173
IVP1System::registerController
void registerController(QWidget *)
Definition: IVP1System.cxx:224
IVP13DSystemSimple::getSceneGraph
SoSeparator * getSceneGraph() const
Definition: IVP13DSystemSimple.cxx:127
IVP13DSystemSimple::updateGUI
void updateGUI()
Definition: IVP13DSystemSimple.h:89
IVP13DSystem::unregisterSelectionNode
void unregisterSelectionNode(SoCooperativeSelection *)
Definition: IVP13DSystem.cxx:281
IVP13DSystemSimple::warnOnDisabledNotifications
void warnOnDisabledNotifications() const
Definition: IVP13DSystemSimple.cxx:221
IVP13DSystem
Definition: IVP13DSystem.h:31
IVP13DSystemSimple::Imp
Definition: IVP13DSystemSimple.cxx:33
IVP13DSystemSimple::m_d
Imp * m_d
Definition: IVP13DSystemSimple.h:79
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
IVP13DSystemSimple::Imp::wascreated
bool wascreated
Definition: IVP13DSystemSimple.cxx:41
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
IVP1System::messageVerbose
void messageVerbose(const QString &) const
Definition: IVP1System.cxx:354
node
Definition: memory_hooks-stdcmalloc.h:74
IVP13DSystemSimple::~IVP13DSystemSimple
virtual ~IVP13DSystemSimple()
Definition: IVP13DSystemSimple.cxx:80
SoCooperativeSelection
Definition: SoCooperativeSelection.h:29
IVP13DSystemSimple::Imp::wasrefreshed
bool wasrefreshed
Definition: IVP13DSystemSimple.cxx:40