/*! Constructs a QtColorPicker widget. The popup will display a grid with \a cols columns, or if \a cols is -1, the number of columns will be calculated automatically. If \a enableColorDialog is true, the popup will also have a "More" button (signified by an ellipsis "...") that presents a QColorDialog when clicked. After constructing a QtColorPicker, call insertColor() to add individual colors to the popup grid, or call setStandardColors() to add all the standard colors in one go. The \a parent argument is passed to QFrame's constructor. \sa QFrame */ QtColorPicker::QtColorPicker(QWidget *parent, int cols, bool enableColorDialog) : QPushButton(parent), popup(0), withColorDialog(enableColorDialog), _labels(false) { setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setAutoDefault(false); setAutoFillBackground(true); setCheckable(true); // Set text setText(tr("Black")); firstInserted = false; // Create and set icon col = Qt::black; dirty = true; // Create color grid popup and connect to it. popup = new ColorPickerPopup(this, cols, withColorDialog, this); connect(popup, SIGNAL(selected(const QColor &)), SLOT(setCurrentColor(const QColor &))); connect(popup, SIGNAL(hid()), SLOT(popupClosed())); // Connect this push button's pressed() signal. connect(this, SIGNAL(toggled(bool)), SLOT(buttonPressed(bool))); }
void lcQColorPicker::buttonPressed(bool toggled) { if (!toggled) return; lcQColorPickerPopup *popup = new lcQColorPickerPopup(this, currentColorIndex); connect(popup, SIGNAL(changed(int)), SLOT(changed(int))); connect(popup, SIGNAL(selected(int)), SLOT(selected(int))); connect(popup, SIGNAL(hid()), SLOT(popupClosed())); popup->setMinimumSize(300, 200); const QRect desktop = QApplication::desktop()->geometry(); QPoint pos = mapToGlobal(rect().bottomLeft()); if (pos.x() < desktop.left()) pos.setX(desktop.left()); if (pos.y() < desktop.top()) pos.setY(desktop.top()); if ((pos.x() + popup->width()) > desktop.width()) pos.setX(desktop.width() - popup->width()); if ((pos.y() + popup->height()) > desktop.bottom()) pos.setY(desktop.bottom() - popup->height()); popup->move(pos); clearFocus(); update(); popup->setFocus(); popup->show(); }
void lcQColorPickerPopup::hideEvent(QHideEvent *e) { if (eventLoop) eventLoop->exit(); emit hid(); QFrame::hideEvent(e); }
/*! \internal */ void ColorPickerPopup::hideEvent(QHideEvent *e) { if (eventLoop) { eventLoop->exit(); } setFocus(); emit hid(); QFrame::hideEvent(e); }
// ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void starsim( Int_t nevents=1, Int_t rngSeed=4321 ) { gROOT->ProcessLine(".L bfc.C"); { TString simple = "y2012 geant gstar usexgeom agml "; bfc(0, simple ); } gSystem->Load( "libVMC.so"); gSystem->Load( "StarGeneratorUtil.so" ); gSystem->Load( "StarGeneratorEvent.so" ); gSystem->Load( "StarGeneratorBase.so" ); gSystem->Load( "libMathMore.so" ); gSystem->Load( "libHijing1_383.so"); gSystem->Load( "libKinematics.so"); gSystem->Load( "xgeometry.so" ); // force gstar load/call gSystem->Load( "gstar.so" ); command("call gstar"); // Setup RNG seed and map all ROOT TRandom here StarRandom::seed( rngSeed ); StarRandom::capture(); // Load STAR Particle DataBase and add the hypertriton definitions (as defined in gstar_part.g) StarParticleData &pdb = StarParticleData::instance(); pdb.AddParticle("HyperTriton", new TParticlePDG( "HyperTriton", "HyperTriton --> He3 pi-", 2.99131, false, 0.0, +3.0, "hypernucleus", +hid(1,1,1), 0, 61054 )); pdb.AddParticle("AntiHyperTriton", new TParticlePDG( "AntiHyperTriton", "AntiHyperTriton --> He3bar pi+", 2.99131, false, 0.0, -3.0, "hypernucleus", -hid(1,1,1), 0, 61055 )); // // Create the primary event generator and insert it // before the geant maker // _primary = new StarPrimaryMaker(); { _primary -> SetFileName( "hijing.starsim.root"); chain -> AddBefore( "geant", _primary ); } // Setup an event generator // Hijing(); // // Setup single hypertritons // HyperTritons(); // // Initialize primary event generator and all sub makers // _primary -> Init(); // // Setup geometry and set starsim to use agusread for input // //geometry("y2012"); command("gkine -4 0"); command("gfile o hijing.starsim.fzd"); // // Trigger on nevents // trig( nevents ); _primary->event()->Print(); // command("gprint kine"); command("call agexit"); // Make sure that STARSIM exits properly }