ATLAS Offline Software
VP12DExaminerViewer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // Implementation of class VP12DExaminerViewer //
8 // //
9 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10 // //
11 // Initial version: April 2007 //
12 // Major update to support multiple views: July 2007 //
13 // //
15 
18 #include "ui_vp12dexaminerviewerform.h"
19 #include <iostream>
20 
21 //Fixme: If you set seekmode in one view, then even after you use it
22 //up, the other views will still be in seek mode. I guess we need a
23 //seekmodedone signal and an endSeekMode slot in vp1graphicsview.
24 
25 //____________________________________________________________________
27 public:
29  Ui::VP12DExaminerViewerForm * ui;
31 
32  //Common init stuff for the constructors:
33  void init1();//Before the views are setup in the stackwidget
34  void init2();//After the views are setup in the stackwidget
35 
36  //For some pushbuttons, only the visible view should be
37  //connected. Thus use the following when changing view:
40 
41  //Extra info for multi-view mode:
42  QList<QPair<QString,QString> > multiviews_viewidAndIconUrl;
43  QMap<QString,VP1GraphicsView*> multiviews_viewid2view;
44  QMap<QPushButton*,QString> button2viewid;
45 
46 
47  //Helpers
49 
50 
51 };
52 
53 
54 //____________________________________________________________________
56 {
57  ui = new Ui::VP12DExaminerViewerForm;
58  ui->setupUi(theclass);
59 
60  //Clear stack widget:
61 
62  while (ui->stackedWidget_views->count())
63  ui->stackedWidget_views->removeWidget(ui->stackedWidget_views->currentWidget());
64 
65  //Setup mode buttons:
66  connect(ui->pushButton_pick,SIGNAL(clicked()),theclass,SLOT(setPickMode()));
67  connect(ui->pushButton_changeview,SIGNAL(clicked()),theclass,SLOT(setChangeViewMode()));
68  connect(ui->pushButton_seek,SIGNAL(clicked()),theclass,SLOT(setSeekMode()));
69 
70  //Hide unused buttons:
71  ui->pushButton_zoomplus->hide();
72  ui->pushButton_zoomminus->hide();
73 }
74 
75 //____________________________________________________________________
77 {
78  if (theclass->view())
79  connectButtonsToView(theclass->view());
80  else
81  std::cout<<"VP12DExaminerViewer::Imp::init2 WARNING: Current View is NULL"<<std::endl;
82  //Start in pick mode:
83  theclass->setPickMode();
84 
85 }
86 
87 
88 //____________________________________________________________________
90  : QWidget(parent,f), m_d(new Imp)
91 {
92  m_d->theclass=this;
93  m_d->singleviewmode = true;
94 
95  m_d->init1();
96 
97  //Add graphicsview:
98  m_d->ui->stackedWidget_views->insertWidget(m_d->ui->stackedWidget_views->count(),new VP1GraphicsView);
99 
100  //Setup viewchangebuttons:
101  m_d->ui->widget_viewchangebuttons->hide();
102 
103  m_d->init2();
104 }
105 
106 //____________________________________________________________________
107 VP12DExaminerViewer::VP12DExaminerViewer(const QList<QPair<QString,QString> >& views,
108  QWidget * parent, Qt::WindowFlags f)
109  : QWidget(parent,f), m_d(new Imp)
110 {
111  if (!views.count())
112  std::cout<<"VP12DExaminerViewer ERROR: Using multimode constructor with empty list of requested views!"<<std::endl;
113 
114 
115  m_d->theclass=this;
116  m_d->singleviewmode = false;
117 
118  m_d->init1();
119 
120  //Setup layout for the buttons used to change the views:
121  QVBoxLayout *layout = new QVBoxLayout;
122  layout->setSpacing(0);
123  layout->setContentsMargins(0, 0, 0, 0);
124  QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
125  sizePolicy.setHorizontalStretch(0);
126  sizePolicy.setVerticalStretch(0);
127  m_d->ui->widget_viewchangebuttons->setLayout(layout);
128 
129  //Add graphicsviews:
131  VP1GraphicsView * firstview(0);
132  for (int i = 0; i<views.count();++i) {
133 
135  if (!firstview)
136  firstview=view;
137 
138  m_d->multiviews_viewid2view.insert(views.at(i).first,view);
139 
140  m_d->ui->stackedWidget_views->insertWidget(m_d->ui->stackedWidget_views->count(),view);
141  //Add button:
142  QPushButton* button = new QPushButton(m_d->ui->widget_viewchangebuttons);
143  button->setToolTip(views.at(i).first);
144  button->setSizePolicy(sizePolicy);
145  button->setMinimumSize(QSize(30, 30));
146  button->setMaximumSize(QSize(30, 30));
147  button->setFocusPolicy(Qt::NoFocus);
148  button->setIcon(QIcon(views.at(i).second));
149  button->setIconSize(QSize(30, 30));
150  button->setCheckable(false);
151  layout->addWidget(button);
152  //connect button here and put it in button -> view_id map:
153  connect(button,SIGNAL(clicked()),this,SLOT(changeViewButtonClicked()));
154  m_d->button2viewid.insert(button,views.at(i).first);
155  }
156 
157  QSpacerItem * spacerItem = new QSpacerItem(20, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
158  layout->addItem(spacerItem);
159 
160  if (firstview)
161  m_d->ui->stackedWidget_views->setCurrentWidget(firstview);
162  else
163  std::cout<<"VP12DExaminerViewer WARNING: View is NULL"<<std::endl;
164 
165  m_d->init2();
166 
167 // VP1GraphicsView a(a);
168 }
169 
170 //____________________________________________________________________
172 {
173  connect(ui->pushButton_sethome,SIGNAL(clicked()),view,SLOT(setHome()));
174  connect(ui->pushButton_home,SIGNAL(clicked()),view,SLOT(viewHome()));
175  connect(ui->pushButton_viewall,SIGNAL(clicked()),view,SLOT(fitViewToContents()));
176  connect(ui->pushButton_print,SIGNAL(clicked()),view,SLOT(print()));
177 }
178 
179 //____________________________________________________________________
181 {
182  disconnect(ui->pushButton_sethome,SIGNAL(clicked()),view,SLOT(setHome()));
183  disconnect(ui->pushButton_home,SIGNAL(clicked()),view,SLOT(viewHome()));
184  disconnect(ui->pushButton_viewall,SIGNAL(clicked()),view,SLOT(fitViewToContents()));
185  disconnect(ui->pushButton_print,SIGNAL(clicked()),view,SLOT(print()));
186 }
187 
188 //____________________________________________________________________
190 {
191  delete m_d; m_d=0;
192 }
193 
194 //____________________________________________________________________
196  return static_cast<VP1GraphicsView *>(m_d->ui->stackedWidget_views->currentWidget());
197  // return m_d->view;
198 }
199 
200 //____________________________________________________________________
201 VP1GraphicsView * VP12DExaminerViewer::view(const QString& view_id) const
202 {
203  if (m_d->singleviewmode||!m_d->multiviews_viewid2view.contains(view_id))
204  return 0;
205 
206  return m_d->multiviews_viewid2view[view_id];
207 }
208 
209 //____________________________________________________________________
211 {
212  //Change viewmode for all the views:
213  if (singleviewmode) {
214  theclass->view()->setMode(m);
215  } else {
216  QMap<QString,VP1GraphicsView*>::iterator it, itE = multiviews_viewid2view.end();
217  for(it = multiviews_viewid2view.begin(); it!=itE; ++it) {
218  it.value()->setMode(m);
219  }
220  }
221 }
222 
223 //____________________________________________________________________
225 {
226  m_d->ui->pushButton_pick->setChecked(true);
227  m_d->ui->pushButton_changeview->setChecked(false);
229 }
230 
231 //____________________________________________________________________
233 {
234  m_d->ui->pushButton_pick->setChecked(false);
235  m_d->ui->pushButton_changeview->setChecked(true);
237 }
238 
239 //____________________________________________________________________
241 {
243 }
244 
245 //____________________________________________________________________
246 QStringList VP12DExaminerViewer::viewIDs() const
247 {
248  if (m_d->singleviewmode)
249  return QStringList();
250 
251  QStringList l;
253  for(it = m_d->multiviews_viewid2view.begin(); it!=itE; ++it) {
254  l << it.key();
255  }
256 
257  return l;
258 }
259 
260 //____________________________________________________________________
261 QList<QPair<QString,QString> > VP12DExaminerViewer::viewIDsAndIconUrls() const
262 {
263  if (m_d->singleviewmode)
264  return QList<QPair<QString,QString> >();
265 
267 }
268 
269 //____________________________________________________________________
271 {
272  return m_d->singleviewmode;
273 }
274 
275 //____________________________________________________________________
277 {
278  if (m_d->singleviewmode)
279  return "";
280 
281  VP1GraphicsView* currentview = view();
282  if (!currentview)
283  return "";
284 
286  for(it = m_d->multiviews_viewid2view.begin(); it!=itE; ++it) {
287  if (it.value()==currentview)
288  return it.key();
289  }
290 
291  return "";
292 }
293 
294 //____________________________________________________________________
296 {
297  if (m_d->singleviewmode)
298  return;
299 
300  if (!m_d->multiviews_viewid2view.contains(viewid))
301  return;
302 
303  VP1GraphicsView* oldview = view();
304  VP1GraphicsView* newview = m_d->multiviews_viewid2view[viewid];
305  if (!oldview||!newview)
306  return;
307  if (oldview==newview)
308  return;
309 
310  currentViewAboutToChange(newview);
311 
312  m_d->disconnectButtonsFromView(oldview);
313  m_d->ui->stackedWidget_views->setCurrentWidget(newview);
314  m_d->connectButtonsToView(newview);
315 
317 }
318 
319 //____________________________________________________________________
321 {
322  QPushButton * button = static_cast<QPushButton*>(sender());
323  if (!button||!m_d->button2viewid.contains(button))
324  return;
325  setShownView(m_d->button2viewid[button]);
326 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VP12DExaminerViewer::Imp::theclass
VP12DExaminerViewer * theclass
Definition: VP12DExaminerViewer.cxx:28
VP12DExaminerViewer::Imp::disconnectButtonsFromView
void disconnectButtonsFromView(VP1GraphicsView *)
Definition: VP12DExaminerViewer.cxx:180
VP12DExaminerViewer::setSeekMode
void setSeekMode()
Definition: VP12DExaminerViewer.cxx:240
VP12DExaminerViewer::~VP12DExaminerViewer
virtual ~VP12DExaminerViewer()
Definition: VP12DExaminerViewer.cxx:189
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
VP12DExaminerViewer::setShownView
void setShownView(QString)
Definition: VP12DExaminerViewer.cxx:295
VP12DExaminerViewer::currentView
QString currentView() const
Definition: VP12DExaminerViewer.cxx:276
VP12DExaminerViewer::viewIDsAndIconUrls
QList< QPair< QString, QString > > viewIDsAndIconUrls() const
Definition: VP12DExaminerViewer.cxx:261
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP12DExaminerViewer.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP12DExaminerViewer::view
VP1GraphicsView * view() const
Definition: VP12DExaminerViewer.cxx:195
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP12DExaminerViewer::currentViewChanged
void currentViewChanged()
VP12DExaminerViewer::Imp::init1
void init1()
Definition: VP12DExaminerViewer.cxx:55
VP12DExaminerViewer::isSingleViewMode
bool isSingleViewMode() const
Definition: VP12DExaminerViewer.cxx:270
TruthTest.itE
itE
Definition: TruthTest.py:25
VP1GraphicsView::PICK
@ PICK
Definition: VP1GraphicsView.h:37
VP1GraphicsView::SEEK
@ SEEK
Definition: VP1GraphicsView.h:37
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP12DExaminerViewer::Imp::ui
Ui::VP12DExaminerViewerForm * ui
Definition: VP12DExaminerViewer.cxx:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP12DExaminerViewer::Imp
Definition: VP12DExaminerViewer.cxx:26
VP12DExaminerViewer::changeViewButtonClicked
void changeViewButtonClicked()
Definition: VP12DExaminerViewer.cxx:320
hist_file_dump.f
f
Definition: hist_file_dump.py:135
VP12DExaminerViewer::m_d
Imp * m_d
Definition: VP12DExaminerViewer.h:65
VP12DExaminerViewer::Imp::button2viewid
QMap< QPushButton *, QString > button2viewid
Definition: VP12DExaminerViewer.cxx:44
VP12DExaminerViewer::Imp::init2
void init2()
Definition: VP12DExaminerViewer.cxx:76
VP12DExaminerViewer::setPickMode
void setPickMode()
Definition: VP12DExaminerViewer.cxx:224
VP12DExaminerViewer::Imp::singleviewmode
bool singleviewmode
Definition: VP12DExaminerViewer.cxx:30
VP12DExaminerViewer::Imp::setModeAllViews
void setModeAllViews(VP1GraphicsView::Mode)
Definition: VP12DExaminerViewer.cxx:210
VP12DExaminerViewer::Imp::connectButtonsToView
void connectButtonsToView(VP1GraphicsView *)
Definition: VP12DExaminerViewer.cxx:171
VP12DExaminerViewer::currentViewAboutToChange
void currentViewAboutToChange(VP1GraphicsView *)
VP1GraphicsView::Mode
Mode
Definition: VP1GraphicsView.h:37
VP1GraphicsView.h
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
VP12DExaminerViewer::Imp::multiviews_viewidAndIconUrl
QList< QPair< QString, QString > > multiviews_viewidAndIconUrl
Definition: VP12DExaminerViewer.cxx:42
VP12DExaminerViewer
Definition: VP12DExaminerViewer.h:26
VP12DExaminerViewer::VP12DExaminerViewer
VP12DExaminerViewer(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
Definition: VP12DExaminerViewer.cxx:89
VP12DExaminerViewer::viewIDs
QStringList viewIDs() const
Definition: VP12DExaminerViewer.cxx:246
VP12DExaminerViewer::Imp::multiviews_viewid2view
QMap< QString, VP1GraphicsView * > multiviews_viewid2view
Definition: VP12DExaminerViewer.cxx:43
VP1GraphicsView
Definition: VP1GraphicsView.h:22
VP1GraphicsView::CHANGEVIEW
@ CHANGEVIEW
Definition: VP1GraphicsView.h:37
VP12DExaminerViewer::setChangeViewMode
void setChangeViewMode()
Definition: VP12DExaminerViewer.cxx:232
drawFromPickle.view
view
Definition: drawFromPickle.py:294