Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
QRootContextMenu.cpp
Go to the documentation of this file.
1// Author: Sergey Linev 2/07/2026
2
3/*************************************************************************
4 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11
12/** \class QRootContextMenu
13 \ingroup qt6canvas
14
15This class provides an interface to context-sensitive popup menus.
16These menus pop up when the user hits the right mouse button, and
17are destroyed when the menu pops downs.
18*/
19
20
21#include "QRootContextMenu.h"
22
23#include "TROOT.h"
24#include "TContextMenu.h"
25#include "TCanvas.h"
26#include "TColor.h"
27#include "TMethod.h"
28#include "TDataMember.h"
29#include "TToggle.h"
30#include "TClassMenuItem.h"
31#include "TAttText.h"
32#include "TAttMarker.h"
33
34#include "QRootMethodDialog.h"
35#include "QPaintWidget.h"
36#include "TQt6Canvas.h"
37
38#include <QtCore/QSignalMapper>
39#include <QMenu>
40#include <QAction>
41#include <QDialog>
42#include <QVBoxLayout>
43#include <QHBoxLayout>
44#include <QFormLayout>
45#include <QComboBox>
46#include <QSpinBox>
47#include <QPushButton>
48#include <QLabel>
49#include <QColorDialog>
50#include <QDoubleSpinBox>
51
53 kToggleStart = 1000, // first id of toggle menu items
54 kToggleListStart = 2000, // first id of toggle list menu items
55 kUserFunctionStart = 3000 // first id of user added functions/methods, etc...
56};
57
58////////////////////////////////////////////////////////////////////////////////
59/// Create context menu.
60
63{
64 gROOT->GetListOfCleanups()->Add(this);
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// Delete a context menu.
69
71{
72 gROOT->GetListOfCleanups()->Remove(this);
73 fTrash.Delete();
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Display context popup menu for currently selected object.
78
80{
81 // add menu items to popup menu
82 // CreateMenu(fContextMenu->GetSelectedObject());
83
84 auto object = fContextMenu->GetSelectedObject();
85 if (!object)
86 return;
87
88 fCustomArg.clear();
89 fTrash.Delete();
90
91
92 auto canv = dynamic_cast<TCanvas *>(fContextMenu->GetSelectedCanvas());
93 auto canvimp = dynamic_cast<ROOT::Experimental::TQt6Canvas *>(canv->GetCanvasImp());
94 auto widget = canvimp->GetPaintWidget();
95
96 QPoint screenPos = widget->mapToGlobal(widget->rect().topLeft());
97
98 QMenu menu;
99 QSignalMapper map;
100
101 QObject::connect(&map, &QSignalMapper::mappedInt,
103
104 // Add a title
105 QString buffer = fContextMenu->CreatePopupTitle(object);
106 addMenuAction(&menu, &map, buffer, -1, nullptr);
107 menu.addSeparator();
108 bool last_separ = true;
109
112
113 // Get list of menu items from the selected object's class
114 TList *menuItemList = object->IsA()->GetMenuList();
115
117
118 while (auto menuItem = (TClassMenuItem*) nextItem()) {
119 switch (menuItem->GetType()) {
121 if (!last_separ)
122 menu.addSeparator();
123 last_separ = true;
124 break;
125 }
127 // Standard list of class methods. Rebuild from scratch.
128 // Get linked list of objects menu items (i.e. member functions
129 // with the token *MENU in their comment fields.
130 TList *methodList = new TList;
131 object->IsA()->GetMenuItems(methodList);
132
134 TClass *classPtr = nullptr;
135 TIter next(methodList);
137
138 while ((method = (TMethod*) next())) {
139 if (classPtr != method->GetClass()) {
140 needSep = kTRUE;
141 classPtr = method->GetClass();
142 }
143
144 EMenuItemKind menuKind = method->IsMenuItem();
146
147 switch (menuKind) {
148 case kMenuDialog:
149 // search for arguments to the MENU statement
150 if (needSep) {
151 menu.addSeparator();
152 needSep = kFALSE;
153 }
154 addMenuAction(&menu, &map, method->GetName(), entry++, method);
155 break;
156 case kMenuSubMenu:
157 if (auto m = method->FindDataMember()) {
158 if (needSep) {
159 menu.addSeparator();
160 needSep = kFALSE;
161 }
162
163 if (m->GetterMethod()) {
164
165 QMenu *r = menu.addMenu(method->GetName());
166 TIter nxt(m->GetOptions());
167 while (auto it = (TOptionListItem*) nxt()) {
168 const char *name = it->fOptName;
169 Long_t val = it->fValue;
170
171 TToggle *t = new TToggle;
172 t->SetToggledObject(object, method);
173 t->SetOnValue(val);
174 fTrash.Add(t);
175
176 auto act = addMenuAction(r, &map, name, togglelist++, t);
177 act->setCheckable(true);
178 if (t->GetState())
179 act->setChecked(true);
180 }
181 } else {
182 addMenuAction(&menu, &map, method->GetName(), entry++, method);
183 }
184 }
185 break;
186
187 case kMenuToggle: {
188 if (needSep) {
189 menu.addSeparator();
190 needSep = kFALSE;
191 }
192
193 TToggle *t = new TToggle;
194 t->SetToggledObject(object, method);
195 t->SetOnValue(1);
196 fTrash.Add(t);
197
198 auto act = addMenuAction(&menu, &map, method->GetName(), toggle++, t);
199 act->setCheckable(true);
200 if (t->GetState())
201 act->setChecked(true);
202 break;
203 }
204 default:
205 break;
206 }
207 }
208 delete methodList;
209 }
210 break;
212 const char* menuItemTitle = menuItem->GetTitle();
213 if (menuItem->IsToggle()) {
214 TMethod* method = object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),menuItem->GetArgs());
215 if (method) {
216 TToggle *t = new TToggle;
217 t->SetToggledObject(object, method);
218 t->SetOnValue(1);
219 fTrash.Add(t);
220
221 if (strlen(menuItemTitle)==0)
222 menuItemTitle = method->GetName();
223 auto act = addMenuAction(&menu, &map, menuItemTitle, toggle++, t);
224 act->setCheckable(true);
225 if (t->GetState())
226 act->setChecked(true);
227 }
228 } else {
229 if (strlen(menuItemTitle)==0)
230 menuItemTitle = menuItem->GetFunctionName();
232 }
233 break;
234 }
235
236 default:
237 break;
238 }
239 }
240
241 menu.exec(screenPos + QPoint(x, y));
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Create dialog object with OK and Cancel buttons. This dialog
246/// prompts for the arguments of "method".
247
249{
250 Dialog(object, (TFunction *)method);
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Create dialog object with OK and Cancel buttons. This dialog
255/// prompts for the arguments of "function".
256/// function may be a global function or a method
257
259{
261 dlg.methodDialog(fContextMenu, object, func);
262}
263
264////////////////////////////////////////////////////////////////////////////////
265/// Handle remove of some ROOT objects
266
268{
269 if (obj == fContextMenu->GetSelectedCanvas())
270 fContextMenu->SetCanvas(nullptr);
271 if (obj == fContextMenu->GetSelectedPad())
272 fContextMenu->SetPad(nullptr);
273 if (obj == fContextMenu->GetSelectedObject()) {
274 // if the object being deleted is the one selected,
275 // ungrab the mouse pointer and terminate (close) the menu
276 fContextMenu->SetObject(nullptr);
277 }
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Register menu action in signal map
282
283QAction* QRootContextMenu::addMenuAction(QMenu* menu, QSignalMapper *map, const QString& text, int id, void *arg)
284{
285 bool enabled = true;
286
287 QAction* act = new QAction(text, menu);
288
289 if (!enabled)
290 if ((text.compare("DrawClone") == 0) || (text.compare("DrawClass") == 0) || (text.compare("Inspect") == 0) ||
291 (text.compare("SetShowProjectionX") == 0) || (text.compare("SetShowProjectionY") == 0) ||
292 (text.compare("DrawPanel") == 0) || (text.compare("FitPanel") == 0))
293 act->setEnabled(false);
294
295 QObject::connect(act, &QAction::triggered, [id, map]() {
296 map->mappedInt(id);
297 });
298
299 menu->addAction(act);
300 map->setMapping(act, id);
301
302 fCustomArg[id] = arg;
303
304 return act;
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Add color elements to attributes editor dialog
309
311{
312 TColor *rootColor = gROOT->GetColor(colindx);
313 QColor initialColor = Qt::black;
314 int initialAlpha255 = 255; // Default fully opaque
315
316 if (rootColor) {
317 initialColor = QColor(rootColor->GetRed() * 255, rootColor->GetGreen() * 255, rootColor->GetBlue() * 255);
318 initialAlpha255 = static_cast<int>(rootColor->GetAlpha() * 255);
319 }
321
323 fColorButton->setFixedWidth(80);
324
325 QSlider *alphaSlider = new QSlider(Qt::Horizontal);
326 alphaSlider->setRange(0, 255);
327 alphaSlider->setValue(initialAlpha255);
328
329 // Visual preview of current color
332
333 QObject::connect(fColorButton, &QPushButton::clicked, [&, this]() {
334 QColor col = QColorDialog::getColor(fSelectedColor, nullptr, "Select Color");
335 if (col.isValid()) {
336 fSelectedColor.setRed(col.red());
337 fSelectedColor.setGreen(col.green());
338 fSelectedColor.setBlue(col.blue());
340 }
341 });
342
343 // --- Slider Shift Connection ---
344 QObject::connect(alphaSlider, &QSlider::valueChanged, [&](int value) {
345 fSelectedColor.setAlpha(value);
347 });
348
349 layout->addRow("Color:", fColorButton);
350
351 layout->addRow("Opacity:", alphaSlider);
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Update color button with currently selected color
356
358{
359 QString qss = QString("background-color: rgba(%1, %2, %3, %4); border: 1px solid gray;")
360 .arg(fSelectedColor.red())
361 .arg(fSelectedColor.green())
362 .arg(fSelectedColor.blue())
363 .arg(fSelectedColor.alpha() / 255.0);
364 fColorButton->setStyleSheet(qss);
365}
366
367////////////////////////////////////////////////////////////////////////////////
368/// Start TAttLine editor
369
371{
372 auto attline = dynamic_cast<TAttLine *>(fContextMenu->GetSelectedObject());
373 if (!attline)
374 return;
375
377 dialog.setWindowTitle("Edit Line Attributes");
378 dialog.setModal(true);
379
382
383 // --- Color Selector ---
384 AddColorElements(attline->GetLineColor(), formLayout);
385
386 // --- Line Style Selector ---
387 // ROOT Styles: 1=Solid, 2=Dashed, 3=Dotted, 4=Dash-Dot
389 styleCombo->addItem("None (0)", 0);
390 styleCombo->addItem("Solid (1)", 1);
391 styleCombo->addItem("Dashed (2)", 2);
392 styleCombo->addItem("Dotted (3)", 3);
393 styleCombo->addItem("Dash-Dot (4)", 4);
394 styleCombo->addItem("Dash-Dot (5)", 5);
395 styleCombo->addItem("Dash-Dot-Dot-Dot (6)", 6);
396 styleCombo->addItem("Dashed medium (7)", 7);
397 styleCombo->addItem("Dash-Dot-Dot (8)", 8);
398 styleCombo->addItem("Dashed long (9)", 9);
399 styleCombo->addItem("Dash-Dot long (10)", 10);
400
401 // Find and set current style
402 int currentStyle = attline->GetLineStyle();
403 int styleIdx = styleCombo->findData(currentStyle);
404 if (styleIdx != -1)
405 styleCombo->setCurrentIndex(styleIdx);
406 else
407 styleCombo->addItem(QString("Custom (%1)").arg(currentStyle), currentStyle);
408
409 formLayout->addRow("Style:", styleCombo);
410
411 // --- Line Width Selector ---
412 QSpinBox *widthSpin = new QSpinBox();
413 widthSpin->setRange(1, 20);
414 widthSpin->setValue(attline->GetLineWidth());
415 formLayout->addRow("Width:", widthSpin);
416
417 mainLayout->addLayout(formLayout);
418
419 // --- Dialog Buttons (OK / Cancel) ---
421 QPushButton *okButton = new QPushButton("OK");
422 QPushButton *cancelButton = new QPushButton("Cancel");
423 buttonLayout->addStretch();
424 buttonLayout->addWidget(okButton);
425 buttonLayout->addWidget(cancelButton);
426 mainLayout->addLayout(buttonLayout);
427
428 QObject::connect(okButton, &QPushButton::clicked, &dialog, &QDialog::accept);
429 QObject::connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject);
430
431 // 2. Execute Dialog and apply properties if accepted
432 if (dialog.exec() == QDialog::Accepted) {
433 // Update ROOT Color Index
435 fSelectedColor.green(),
436 fSelectedColor.blue(),
437 fSelectedColor.alpha() / 255.0);
438 attline->SetLineColor(newColorIdx);
439
440 // Update Line Style
441 Style_t newStyle = styleCombo->currentData().toInt();
442 attline->SetLineStyle(newStyle);
443
444 // Update Line Width
445 Width_t newWidth = widthSpin->value();
446 attline->SetLineWidth(newWidth);
447 }
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Start TAttFill editor
452
454{
455 auto attfill = dynamic_cast<TAttFill *>(fContextMenu->GetSelectedObject());
456 if (!attfill)
457 return;
458
460 dialog.setWindowTitle("Edit Fill Attributes");
461 dialog.setModal(true);
462
465
466 // --- Color Selector ---
467 AddColorElements(attfill->GetFillColor(), formLayout);
468
469 // --- Fill Style Selector ---
470 // ROOT Styles: 1=Solid, 2=Dashed, 3=Dotted, 4=Dash-Dot
472 styleCombo->addItem("None (0)", 0);
473 styleCombo->addItem("Solid (1001)", 1001);
474 for (int s = 3001; s <= 3025; ++s)
475 styleCombo->addItem(QString("Style %1").arg(s), s);
476 for (int s = 3144; s <= 3944; s += 100)
477 styleCombo->addItem(QString("Style %1").arg(s), s);
478 for (int s = 3305; s <= 3395; s += 10)
479 styleCombo->addItem(QString("Style %1").arg(s), s);
480 for (int s = 3350; s <= 3359; s += 1)
481 styleCombo->addItem(QString("Style %1").arg(s), s);
482 for (int s = 3409; s <= 3490; s += 9)
483 styleCombo->addItem(QString("Style %1").arg(s), s);
484 for (int s = 3609; s <= 3690; s += 9)
485 styleCombo->addItem(QString("Style %1").arg(s), s);
486
487 // Find and set current style
488 int currentStyle = attfill->GetFillStyle();
489 int styleIdx = styleCombo->findData(currentStyle);
490 if (styleIdx != -1)
491 styleCombo->setCurrentIndex(styleIdx);
492 else
493 styleCombo->addItem(QString("Style %1").arg(currentStyle), currentStyle);
494
495 formLayout->addRow("Style:", styleCombo);
496
497 mainLayout->addLayout(formLayout);
498
499 // --- Dialog Buttons (OK / Cancel) ---
501 QPushButton *okButton = new QPushButton("OK");
502 QPushButton *cancelButton = new QPushButton("Cancel");
503 buttonLayout->addStretch();
504 buttonLayout->addWidget(okButton);
505 buttonLayout->addWidget(cancelButton);
506 mainLayout->addLayout(buttonLayout);
507
508 QObject::connect(okButton, &QPushButton::clicked, &dialog, &QDialog::accept);
509 QObject::connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject);
510
511 // 2. Execute Dialog and apply properties if accepted
512 if (dialog.exec() == QDialog::Accepted) {
513 // Update ROOT Color Index
515 fSelectedColor.green(),
516 fSelectedColor.blue(),
517 fSelectedColor.alpha() / 255.0);
518 attfill->SetFillColor(newColorIdx);
519
520 // Update fill Style
521 Style_t newStyle = styleCombo->currentData().toInt();
522 attfill->SetFillStyle(newStyle);
523 }
524}
525
526
528protected:
529 QString textFromValue(double value) const override {
530 if (value == 0) return "Default";
531 return QDoubleSpinBox::textFromValue(value);
532 }
533
534 double valueFromText(const QString &text) const override {
535 if (text == "Default") return 0.;
536 return QDoubleSpinBox::valueFromText(text);
537 }
538};
539
540class CustomSpinBox : public QSpinBox {
541protected:
542 QString textFromValue(int value) const override {
543 if (value == 0) return "Default";
544 return QSpinBox::textFromValue(value);
545 }
546
547 int valueFromText(const QString &text) const override {
548 if (text == "Default") return 0;
549 return QSpinBox::valueFromText(text);
550 }
551};
552
553
554////////////////////////////////////////////////////////////////////////////////
555/// Start TAttText editor
556
558{
559 auto atttext = dynamic_cast<TAttText *>(fContextMenu->GetSelectedObject());
560 if (!atttext)
561 return;
562
564 dialog.setWindowTitle("Edit Text Attributes");
565 dialog.setModal(true);
566
569
570 // --- Color Selector ---
571 AddColorElements(atttext->GetTextColor(), formLayout);
572
574 fontCombo->addItem("1. Times italic", 1);
575 fontCombo->addItem("2. Times bold", 2);
576 fontCombo->addItem("3. Times bold italic", 3);
577 fontCombo->addItem("4. Helvetica", 4);
578 fontCombo->addItem("5. Helvetica italic", 5);
579 fontCombo->addItem("6. Helvetica bold", 6);
580 fontCombo->addItem("7. Helvetica bold italic", 7);
581 fontCombo->addItem("8. Courier", 8);
582 fontCombo->addItem("9. Courier italic", 9);
583 fontCombo->addItem("10. Courier bold", 10);
584 fontCombo->addItem("11. Courier bold italic", 11);
585 fontCombo->addItem("12. Symbol", 12);
586 fontCombo->addItem("13. Times", 13);
587 fontCombo->addItem("14. Wingdings", 14);
588 fontCombo->addItem("15. Symbol italic", 15);
589
590 // Find and set current style
591 int currentPrec = atttext->GetTextFont() % 10;
592 int currentFont = atttext->GetTextFont() / 10;
593 int styleIdx = fontCombo->findData(currentFont);
594 if (styleIdx >= 0)
595 fontCombo->setCurrentIndex(styleIdx);
596 else
597 fontCombo->addItem(QString("Font %1").arg(currentFont), currentFont);
598
599 formLayout->addRow("Font:", fontCombo);
600
601 QDoubleSpinBox* floatSpinBox = nullptr;
602 QSpinBox *intSpinBox = nullptr;
603
604 if (currentPrec == 2) {
606 floatSpinBox->setRange(0.0, 1.0); // Set your minimum and maximum limits
607 floatSpinBox->setSingleStep(0.01); // Set step size to 00.1
608 floatSpinBox->setDecimals(3); // Force it to show exactly 3 decimal places
609 floatSpinBox->setValue(atttext->GetTextSize());
610 formLayout->addRow("Size:", floatSpinBox);
611 } else {
613 intSpinBox->setRange(0, 128);
614 intSpinBox->setValue(atttext->GetTextSize());
615 formLayout->addRow("Size:", intSpinBox);
616 }
617
619 alignCombo->addItem("11. Left Bottom", 11);
620 alignCombo->addItem("12. Left Center", 12);
621 alignCombo->addItem("13. Left Top", 13);
622 alignCombo->addItem("21. Middle Bottom", 21);
623 alignCombo->addItem("22. Middle Center", 22);
624 alignCombo->addItem("23. Middle Top", 23);
625 alignCombo->addItem("31. Right Bottom", 31);
626 alignCombo->addItem("32. Right Center", 32);
627 alignCombo->addItem("33. Right Top", 33);
628
629 // Find and set current style
630 int alignIdx = alignCombo->findData(atttext->GetTextAlign());
631 if (alignIdx < 0)
632 alignIdx = alignCombo->findData(11);
633 alignCombo->setCurrentIndex(alignIdx);
634
635 formLayout->addRow("Align:", alignCombo);
636
637 mainLayout->addLayout(formLayout);
638
639 // --- Dialog Buttons (OK / Cancel) ---
641 QPushButton *okButton = new QPushButton("OK");
642 QPushButton *cancelButton = new QPushButton("Cancel");
643 buttonLayout->addStretch();
644 buttonLayout->addWidget(okButton);
645 buttonLayout->addWidget(cancelButton);
646 mainLayout->addLayout(buttonLayout);
647
648 QObject::connect(okButton, &QPushButton::clicked, &dialog, &QDialog::accept);
649 QObject::connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject);
650
651 // 2. Execute Dialog and apply properties if accepted
652 if (dialog.exec() == QDialog::Accepted) {
653 // Update ROOT Color Index
655 fSelectedColor.green(),
656 fSelectedColor.blue(),
657 fSelectedColor.alpha() / 255.0);
658 atttext->SetTextColor(newColorIdx);
659
660 // Update font Style
661 Int_t newFont = fontCombo->currentData().toInt();
662 atttext->SetTextFont(newFont * 10 + currentPrec);
663
664 if (floatSpinBox)
665 atttext->SetTextSize(floatSpinBox->value());
666 else if (intSpinBox)
667 atttext->SetTextSize(intSpinBox->value());
668
669 atttext->SetTextAlign(alignCombo->currentData().toInt());
670 }
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Start TAttMarker editor
675
677{
678 auto attmarker = dynamic_cast<TAttMarker *>(fContextMenu->GetSelectedObject());
679 if (!attmarker)
680 return;
681
683 dialog.setWindowTitle("Edit Marker Attributes");
684 dialog.setModal(true);
685
688
689 // --- Color Selector ---
690 AddColorElements(attmarker->GetMarkerColor(), formLayout);
691
692 // --- Marker Style Selector ---
694 for (int s = 1; s <= 49; ++s)
695 styleCombo->addItem(QString("Style %1").arg(s), s);
696
697 // Find and set current style
698 int currentStyle = attmarker->GetMarkerStyle();
699 int styleIdx = styleCombo->findData(currentStyle);
700 if (styleIdx != -1)
701 styleCombo->setCurrentIndex(styleIdx);
702 else
703 styleCombo->addItem(QString("Style %1").arg(currentStyle), currentStyle);
704
705 formLayout->addRow("Style:", styleCombo);
706
707
709
710 // 2. Configure its ranges and step parameters
711 floatSpinBox->setRange(0.0, 10.0); // Set your minimum and maximum limits
712 floatSpinBox->setSingleStep(0.1); // Set step size to 0.1
713 floatSpinBox->setDecimals(1); // Force it to show exactly 1 decimal place (e.g., 1.5)
714 floatSpinBox->setValue(attmarker->GetMarkerSize());
715 formLayout->addRow("Size:", floatSpinBox);
716
717 mainLayout->addLayout(formLayout);
718
719 // --- Dialog Buttons (OK / Cancel) ---
721 QPushButton *okButton = new QPushButton("OK");
722 QPushButton *cancelButton = new QPushButton("Cancel");
723 buttonLayout->addStretch();
724 buttonLayout->addWidget(okButton);
725 buttonLayout->addWidget(cancelButton);
726 mainLayout->addLayout(buttonLayout);
727
728 QObject::connect(okButton, &QPushButton::clicked, &dialog, &QDialog::accept);
729 QObject::connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject);
730
731 // 2. Execute Dialog and apply properties if accepted
732 if (dialog.exec() == QDialog::Accepted) {
733 // Update ROOT Color Index
735 fSelectedColor.green(),
736 fSelectedColor.blue(),
737 fSelectedColor.alpha() / 255.0);
738 attmarker->SetMarkerColor(newColorIdx);
739
740 // Update Style
741 Style_t newStyle = styleCombo->currentData().toInt();
742 attmarker->SetMarkerStyle(newStyle);
743
744 float newsize = floatSpinBox->value();
745 attmarker->SetMarkerSize(newsize);
746 }
747
748}
749
750////////////////////////////////////////////////////////////////////////////////
751/// Execute specified menu item
752
754{
755 if (id < 0)
756 return;
757 void *ud = fCustomArg[id];
758
759 if (ud) {
760 // retrieve the highlighted function
761 TFunction *function = nullptr;
762 if (id < kToggleStart) {
763 TMethod *m = (TMethod *)ud;
764 function = (TFunction *)m;
765 } else if (id >= kToggleStart && id < kUserFunctionStart) {
766 TToggle *t = (TToggle *)ud;
768 function = (TFunction *)mc->GetMethod();
769 } else {
771 function = gROOT->GetGlobalFunctionWithPrototype(mi->GetFunctionName());
772 }
773 if (function)
774 fContextMenu->SetMethod(function);
775 }
776
777 if (id < kToggleStart) {
778 auto m = (TMethod *) ud;
779
780 if (!strcmp(m->GetName(), "SetLineAttributes")) {
782 } else if (!strcmp(m->GetName(), "SetFillAttributes")) {
784 } else if (!strcmp(m->GetName(), "SetTextAttributes")) {
786 } else if (!strcmp(m->GetName(), "SetMarkerAttributes")) {
788 } else {
790 }
791 } else if (id >= kToggleStart && id < kToggleListStart) {
792 TToggle *t = (TToggle *) ud;
794 } else if (id >= kToggleListStart && id < kUserFunctionStart) {
795 TToggle *t = (TToggle *) ud;
796 if (t->GetState() == 0)
797 t->SetState(1);
798 } else {
801 }
802}
@ kToggleStart
@ kToggleListStart
@ kUserFunctionStart
#define c(i)
Definition RSha256.hxx:101
short Style_t
Style number (short)
Definition RtypesCore.h:97
short Color_t
Color number (short)
Definition RtypesCore.h:100
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
short Width_t
Line width (short)
Definition RtypesCore.h:99
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:142
EMenuItemKind
Definition TMethod.h:31
@ kMenuSubMenu
Definition TMethod.h:35
@ kMenuDialog
Definition TMethod.h:33
@ kMenuToggle
Definition TMethod.h:34
#define gROOT
Definition TROOT.h:417
@ kToggleStart
@ kToggleListStart
@ kUserFunctionStart
QString textFromValue(double value) const override
double valueFromText(const QString &text) const override
QString textFromValue(int value) const override
int valueFromText(const QString &text) const override
QPushButton * fColorButton
void executeMenu(int id)
Execute specified menu item.
void UpdateColorElements()
Update color button with currently selected color.
void SetTextAttributesDialog()
Start TAttText editor.
void SetFillAttributesDialog()
Start TAttFill editor.
void SetLineAttributesDialog()
Start TAttLine editor.
void Dialog(TObject *object, TMethod *method) override
Create dialog object with OK and Cancel buttons.
void RecursiveRemove(TObject *obj) override
Handle remove of some ROOT objects.
QRootContextMenu(TContextMenu *c=nullptr, const char *name="ROOT Context Menu")
Create context menu.
QAction * addMenuAction(QMenu *menu, QSignalMapper *map, const QString &text, int id, void *arg=nullptr)
Register menu action in signal map.
~QRootContextMenu() override
Delete a context menu.
void AddColorElements(int colindx, QFormLayout *layout)
Add color elements to attributes editor dialog.
std::map< int, void * > fCustomArg
void SetMarkerAttributesDialog()
Start TAttMarker editor.
void DisplayPopup(Int_t x, Int_t y) override
Display context popup menu for currently selected object.
Specialized dialog to enter arguments for method exection.
Fill Area Attributes class.
Definition TAttFill.h:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:22
Text Attributes class.
Definition TAttText.h:21
The Canvas class.
Definition TCanvas.h:23
Describes one element of the context menu associated to a class The menu item may describe.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Definition TClass.cxx:3937
The color creation and management class.
Definition TColor.h:22
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1939
This class provides an interface to GUI independent context sensitive popup menus.
TContextMenu * fContextMenu
This class provides an interface to context sensitive popup menus.
virtual void SetCanvas(TVirtualPad *c)
virtual TVirtualPad * GetSelectedCanvas()
virtual void Action(TObject *object, TMethod *method)
Action to be performed when this menu item is selected.
virtual TVirtualPad * GetSelectedPad()
virtual void SetPad(TVirtualPad *p)
virtual void SetMethod(TFunction *m)
virtual void SetObject(TObject *o)
virtual TObject * GetSelectedObject()
virtual const char * CreatePopupTitle(TObject *object)
Create title for popup menu.
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
TClass * IsA() const override
Definition TList.h:115
Method or function calling interface.
Definition TMethodCall.h:37
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
Mother of all ROOT objects.
Definition TObject.h:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
Basic string class.
Definition TString.h:137
This class defines toggling facility for both - object's method or variables.
Definition TToggle.h:47
virtual void SetOnValue(Long_t lon)
Definition TToggle.h:78
TMethodCall * GetSetter() const
Definition TToggle.h:87
virtual void SetToggledObject(TObject *obj, TMethod *anymethod)
Initializes it to toggle an object's datamember using this object's method.
Definition TToggle.cxx:134
virtual void SetState(Bool_t state)
Sets the value of toggle to fOnValue or fOffValue according to passed argument.
Definition TToggle.cxx:79
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.
Definition TToggle.cxx:68
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TMarker m
Definition textangle.C:8