ATLAS Offline Software
Loading...
Searching...
No Matches
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:
24QWidget * IVP13DSystemSimple::buildController() { return 0; }
26void IVP13DSystemSimple::userPickedNode(SoNode*, SoPath *){}
29{
30 // messageVerbose("WARNING: Did not reimplement systemerase!");
31}
32
34public:
37 SoSeparator *rootR; // Present for the whole run.
38 SoSeparator *rootE; // Present for one event;
39 void getNodesWithDisabledNotifications(SoGroup*, QList<SoNode*>&) const;
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//___________________________________________________________
50IVP13DSystemSimple::IVP13DSystemSimple(const QString & name, const QString & information, const QString & contact_info)
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//___________________________________________________________________________________________________________
107void 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();
164 buildEventSceneGraph(sg, m_d->rootE);
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);
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;
225 m_d->getNodesWithDisabledNotifications(m_d->rootR, nodesR);
226 m_d->getNodesWithDisabledNotifications(m_d->rootE, 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}
#define gr
IVP13DSystemSimple * theclass
static void made_selection(void *userdata, SoPath *path)
void getNodesWithDisabledNotifications(SoGroup *, QList< SoNode * > &) const
SoCooperativeSelection * root
virtual void systemcreate(StoreGateSvc *detstore)
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
SoSeparator * getSceneGraph() const
void create(StoreGateSvc *detstore)
void refresh(StoreGateSvc *storegate)
virtual void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
virtual void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
virtual QWidget * buildController()
void warnOnDisabledNotifications() const
virtual void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)=0
virtual void systemuncreate()
void unregisterSelectionNode(SoCooperativeSelection *)
IVP13DSystem(const QString &name, const QString &information, const QString &contact_info)
void setUserSelectionNotificationsEnabled(SoCooperativeSelection *sel, bool enabled)
void registerSelectionNode(SoCooperativeSelection *)
void messageVerbose(const QString &) const
StoreGateSvc * detectorStore() const
void messageDebug(const QString &) const
const QString & name() const
void message(const QString &) const
void registerController(QWidget *)
const QString & information() const
const QString & contact_info() const
The Athena Transient Store API.
static bool verbose()
Definition VP1Msg.h:31
Definition node.h:24
const std::string selection
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310