Logo ROOT   6.16/01
Reference Guide
TQRootDialog.cxx
Go to the documentation of this file.
1// @(#)root/qtgsi:$Id$
2// Author: Denis Bertini, M. Al-Turany 01/11/2000
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TQRootDialog.h"
13
14#include "TMethod.h"
15#include "TCanvas.h"
16#include "TROOT.h"
17#include "TClass.h"
18#include "TObjString.h"
19
20#include <stdlib.h>
21
22using namespace Qt;
23
25
26////////////////////////////////////////////////////////////////////////////////
27/// ctor
28
29TQRootDialog::TQRootDialog(QWidget *wparent, const QString& title, TObject* obj, TMethod *method)
30 : QWidget(wparent)
31 , fLineEdit(nullptr)
32 , fCurObj(obj)
33 , fCurMethod(method)
34 , fCurCanvas(nullptr)
35 , fParent(wparent)
36{
37 setObjectName(title);
38
39 QPushButton *apply = new QPushButton("Apply");
40 QPushButton *cancel = new QPushButton("Cancel");
41 QHBoxLayout *hbox = new QHBoxLayout(fParent);
42
43 hbox->addWidget(apply);
44 hbox->addWidget(cancel);
45
46 setLayout(hbox);
47
48 connect(apply, SIGNAL(clicked()), fParent, SLOT(ExecuteMethod()));
49 connect(cancel,SIGNAL(clicked()), fParent, SLOT(close()));
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// dtor
54
56{
57 if (fLineEdit)
58 delete fLineEdit;
59 fList.erase(fList.begin(), fList.end());
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Execute ROOT methods.
64
66{
67 Bool_t deletion = false;
68 TVirtualPad *psave = gROOT->GetSelectedPad();
69
71
72 for (auto str : fList)
73 tobjlist.AddLast((TObject*) new TObjString(str->text().toAscii().data()));
74
75 // handle command if existing object
76 if (fCurObj) {
77 if(strcmp(fCurMethod->GetName(),"Delete") == 0) {
78 delete fCurObj;
79 fCurObj = nullptr;
80 deletion = true;
81 } else if (strcmp(fCurMethod->GetName(),"SetCanvasSize") == 0 ) {
82 int i = 0, value[2] = {0, 0};
83 for (auto str : fList)
84 value[i++] = atoi(str->text().toAscii().data());
85 fParent->resize(value[0], value[1]);
86 } else {
87 // here call cint call
88 fCurObj->Execute(fCurMethod, &tobjlist);
89 }
90 } // ! fCurrent Obj
91
92 if (!deletion) {
93 gROOT->SetSelectedPad(psave);
94 gROOT->GetSelectedPad()->Modified();
95 gROOT->GetSelectedPad()->Update();
96 } else {
97 gROOT->SetSelectedPad(gPad);
98 gROOT->GetSelectedPad()->Update();
99 }
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Add widgets for arguments.
104
105void TQRootDialog::Add(const char* argname, const char* value, const char* /*type*/)
106{
107 QString s;
108 s = value;
109 new QLabel(argname, this);
110 QLineEdit* lineEdit = new QLineEdit(this);
111 if (fLineEdit) {
112 fLineEdit->setGeometry(10,10, 130, 30);
113 fLineEdit->setFocus();
114 fLineEdit->setText(s);
115 }
116 fList.append(lineEdit);
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Show the dialog.
121
123{
124 show();
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Handle close event.
129
130void TQRootDialog::closeEvent( QCloseEvent* ce )
131{
132 ce->accept();
133}
bool Bool_t
Definition: RtypesCore.h:59
#define ClassImp(name)
Definition: Rtypes.h:363
#define gROOT
Definition: TROOT.h:410
#define gPad
Definition: TVirtualPad.h:286
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:38
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
Definition: TMethod.cxx:306
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
An array of TObjects.
Definition: TObjArray.h:37
virtual void AddLast(TObject *obj)
Add object in the next empty slot in the array.
Definition: TObjArray.cxx:177
Collectable string class.
Definition: TObjString.h:28
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Execute(const char *method, const char *params, Int_t *error=0)
Execute method on this object with the given parameter string, e.g.
Definition: TObject.cxx:277
TMethod * fCurMethod
Definition: TQRootDialog.h:57
QList< QLineEdit * > fList
Definition: TQRootDialog.h:60
void ExecuteMethod()
Execute ROOT methods.
TQRootDialog(const TQRootDialog &)
QLineEdit * fLineEdit
Definition: TQRootDialog.h:55
void Add(const char *argname, const char *value, const char *type)
Add widgets for arguments.
void Popup()
Show the dialog.
TObject * fCurObj
Definition: TQRootDialog.h:56
QWidget * fParent
Definition: TQRootDialog.h:59
void closeEvent(QCloseEvent *ce)
Handle close event.
virtual ~TQRootDialog()
dtor
Int_t LastIndex() const
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
static constexpr double s
constexpr decltype(auto) apply(F &&f, Tuple &&t)