void Minimap::setMap(const Map *const map) { BLOCK_START("Minimap::setMap") std::string caption; if (map) caption = map->getName(); if (caption.empty()) { // TRANSLATORS: mini map window name caption = _("Map"); } setCaption(caption); deleteMapImage(); if (map) { if (config.getBoolValue("showExtMinimaps")) { SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE, map->getWidth(), map->getHeight(), 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000); if (!surface) { if (!isSticky()) setVisible(Visible_false); BLOCK_END("Minimap::setMap") return; } // I'm not sure if the locks are necessary since it's a SWSURFACE SDL_LockSurface(surface); int* data = static_cast<int*>(surface->pixels); if (!data) { if (!isSticky()) setVisible(Visible_false); BLOCK_END("Minimap::setMap") return; } const int size = surface->h * surface->w; const int mask = (BlockMask::WALL | BlockMask::AIR | BlockMask::WATER); for (int ptr = 0; ptr < size; ptr ++) *(data ++) = -!(map->mMetaTiles[ptr].blockmask & mask); SDL_UnlockSurface(surface); mMapImage = imageHelper->load(surface); mMapImage->setAlpha(settings.guiAlpha); mCustomMapImage = true; MSDL_FreeSurface(surface); } else {
bool StickyAdapter::isStickyPower() { if (isSticky()) { StickyAtypeParameters* stickyParam = getStickyParam(); return stickyParam->isPower; } else return false; }
StickyAtypeParameters* StickyAdapter::getStickyParam() { if (!isSticky()) { sprintf( painCave.errMsg, "StickyAdapter::getStickyParam was passed an atomType (%s)\n" "\tthat does not appear to be a Sticky atom.\n", at_->getName().c_str()); painCave.severity = OPENMD_ERROR; painCave.isFatal = 1; simError(); } GenericData* data = at_->getPropertyByName(StickyTypeID); if (data == NULL) { sprintf( painCave.errMsg, "StickyAdapter::getStickyParam could not find Sticky\n" "\tparameters for atomType %s.\n", at_->getName().c_str()); painCave.severity = OPENMD_ERROR; painCave.isFatal = 1; simError(); } StickyAtypeData* stickyData = dynamic_cast<StickyAtypeData*>(data); if (stickyData == NULL) { sprintf( painCave.errMsg, "StickyAdapter::getStickyParam could not convert\n" "\tGenericData to StickyAtypeData for atom type %s\n", at_->getName().c_str()); painCave.severity = OPENMD_ERROR; painCave.isFatal = 1; simError(); } return stickyData->getData(); }
QString KWM::getProperties(Window w){ QString result; QRect rect; int data[13]; int i = 0; int n = 0; data[n++]=desktop(w); rect = geometry(w); data[n++]=rect.x(); data[n++]=rect.y(); data[n++]=rect.width(); data[n++]=rect.height(); rect = geometryRestore(w); data[n++]=rect.x(); data[n++]=rect.y(); data[n++]=rect.width(); data[n++]=rect.height(); data[n++]=isIconified(w)?1:0; data[n++]=isMaximized(w)?maximizeMode(w):0; data[n++]=isSticky(w)?1:0; data[n++]=getDecoration(w); QString s; for (i=0;i<n;i++){ s.setNum(data[i]); result.append(s); if (i<n-1) result.append("+"); } return result; }
Minimap::Minimap() : // TRANSLATORS: mini map window name Window(_("Map"), Modal_false, nullptr, "map.xml"), mWidthProportion(0.5), mHeightProportion(0.5), mMapImage(nullptr), mMapOriginX(0), mMapOriginY(0), mCustomMapImage(false), mAutoResize(config.getBoolValue("autoresizeminimaps")) { setWindowName("Minimap"); mShow = config.getValueBool(getWindowName() + "Show", true); config.addListener("autoresizeminimaps", this); setDefaultSize(5, 25, 100, 100); // set this to false as the minimap window size is changed // depending on the map size setResizable(true); if (setupWindow) setupWindow->registerWindowForReset(this); setDefaultVisible(true); setSaveVisible(true); setStickyButton(true); setSticky(false); loadWindowState(); setVisible(fromBool(mShow, Visible), isSticky()); enableVisibleSound(true); }
void Window::saveWindowState() { // Saving X, Y and Width and Height for resizables in the config if (!mWindowName.empty() && mWindowName != "window") { config.setValue(mWindowName + "WinX", getX()); config.setValue(mWindowName + "WinY", getY()); if (mSaveVisible) config.setValue(mWindowName + "Visible", isVisible()); if (mStickyButton) config.setValue(mWindowName + "Sticky", isSticky()); if (mGrip) { if (getMinWidth() > getWidth()) setWidth(getMinWidth()); else if (getMaxWidth() < getWidth()) setWidth(getMaxWidth()); if (getMinHeight() > getHeight()) setHeight(getMinHeight()); else if (getMaxHeight() < getHeight()) setHeight(getMaxHeight()); config.setValue(mWindowName + "WinWidth", getWidth()); config.setValue(mWindowName + "WinHeight", getHeight()); } } }
// @mfunc Unstick this <c OMStrongReferenceSetElement>. void OMStrongReferenceSetElement::clearSticky(void) { TRACE("OMStrongReferenceSetElement::clearSticky"); if (isSticky()) { _referenceCount = 0; } }
void Minimap::setMap(Map *map) { // Set the title for the Minimap std::string caption; if (map) caption = map->getName(); if (caption.empty()) caption = _("Map"); minimap->setCaption(caption); // Adapt the image if (mMapImage) { mMapImage->decRef(); mMapImage = 0; } if (map) { ResourceManager *resman = ResourceManager::getInstance(); mMapImage = resman->getImage(map->getProperty("minimap")); } if (mMapImage) { const int offsetX = 2 * getPadding(); const int offsetY = getTitleBarHeight() + getPadding(); const int titleWidth = getFont()->getWidth(getCaption()) + 15; const int mapWidth = mMapImage->getWidth() < 100 ? mMapImage->getWidth() + offsetX : 100; const int mapHeight = mMapImage->getHeight() < 100 ? mMapImage->getHeight() + offsetY : 100; setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth); setMinHeight(mapHeight); mWidthProportion = (float) mMapImage->getWidth() / map->getWidth(); mHeightProportion = (float) mMapImage->getHeight() / map->getHeight(); setMaxWidth(mMapImage->getWidth() > titleWidth ? mMapImage->getWidth() + offsetX : titleWidth); setMaxHeight(mMapImage->getHeight() + offsetY); setDefaultSize(getX(), getY(), getWidth(), getHeight()); resetToDefaultSize(); if (mShow) setVisible(true); } else { if (!isSticky()) setVisible(false); } }
// @mfunc Decrease the count of weak references to this // <c OMStrongReferenceSetElement> by one. Return // the new value of the reference count. // @rdesc The new value of the reference count. OMUInt32 OMStrongReferenceSetElement::decreaseReferenceCount(void) { TRACE("OMStrongReferenceSetElement::decreaseReferenceCount"); if (!isSticky()) { --_referenceCount; } return _referenceCount; }
const TextureUVCoordinateSet& PistonArmTile::getTexture(signed char side, int data) { int rotation = getRotation(data); if(side == rotation) return isSticky(data)? texture_sticky : tex; int opposite[6] = {1, 0, 3, 2, 5, 4}; if(side == opposite[rotation]) return tex; return texture_side; }
void Window::setVisible(bool visible, bool forceSticky) { if (visible == isVisible()) return; // Nothing to do // Check if the window is off screen... if (visible) checkIfIsOffScreen(); gcn::Window::setVisible((!forceSticky && isSticky()) || visible); }
void Windowiki::setVisible(bool visible) { if (isSticky()) { gcn::Window::setVisible(true); } else { gcn::Window::setVisible(visible); } }
int KWM::desktop(Window w){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_WIN_DESKTOP", False); if (isSticky(w)) return currentDesktop(); long result = 1; if (!getSimpleProperty(w, a, result) || result <= 0){ result = currentDesktop(); moveToDesktop(w, (int) result); kwm_error = TRUE; // restore error } return (int) result; }
void Window::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); if (event.getButton() == gcn::MouseEvent::LEFT) { const int x = event.getX(); const int y = event.getY(); // Handle close button if (mCloseButton) { gcn::Rectangle closeButtonRect( getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), getPadding(), mSkin->getCloseImage()->getWidth(), mSkin->getCloseImage()->getHeight()); if (closeButtonRect.isPointInRect(x, y)) { close(); } } // Handle sticky button if (mStickyButton) { Image *button = mSkin->getStickyImage(mSticky); int rx = getWidth() - button->getWidth() - getPadding(); if (mCloseButton) rx -= mSkin->getCloseImage()->getWidth(); gcn::Rectangle stickyButtonRect(rx, getPadding(), button->getWidth(), button->getHeight()); if (stickyButtonRect.isPointInRect(x, y)) { setSticky(!isSticky()); } } // Handle window resizing mouseResize = getResizeHandles(event); } }
void StickyAdapter::makeSticky(RealType w0, RealType v0, RealType v0p, RealType rl, RealType ru, RealType rlp, RealType rup, bool isPower){ if (isSticky()){ at_->removeProperty(StickyTypeID); } StickyAtypeParameters* stickyParam = new StickyAtypeParameters(); stickyParam->w0 = w0; stickyParam->v0 = v0; stickyParam->v0p = v0p; stickyParam->rl = rl; stickyParam->ru = ru; stickyParam->rlp = rlp; stickyParam->rup = rup; stickyParam->isPower = isPower; at_->addProperty(new StickyAtypeData(StickyTypeID, stickyParam)); }
Minimap::Minimap(): Window(_("Map")), mMapImage(0), mWidthProportion(0.5), mHeightProportion(0.5) { setWindowName("MiniMap"); mShow = config.getValue(getWindowName() + "Show", true); setDefaultSize(5, 25, 100, 100); // set this to false as the minimap window size is changed //depending on the map size setResizable(false); setDefaultVisible(true); setSaveVisible(true); setStickyButton(true); setSticky(false); loadWindowState(); setVisible(mShow, isSticky()); }
void Window::loadWindowState() { const std::string &name = mWindowName; assert(!name.empty()); setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); if (mSaveVisible) setVisible((bool) config.getValue(name + "Visible", mDefaultVisible)); if (mStickyButton) setSticky((bool) config.getValue(name + "Sticky", isSticky())); if (mGrip) { int width = (int) config.getValue(name + "WinWidth", mDefaultWidth); int height = (int) config.getValue(name + "WinHeight", mDefaultHeight); if (getMinWidth() > width) width = getMinWidth(); else if (getMaxWidth() < width) width = getMaxWidth(); if (getMinHeight() > height) height = getMinHeight(); else if (getMaxHeight() < height) height = getMaxHeight(); setSize(width, height); } else { setSize(mDefaultWidth, mDefaultHeight); } // Check if the window is off screen... checkIfIsOffScreen(); }
void Minimap::toggle() { setVisible(!isVisible(), isSticky()); mShow = isVisible(); }
KitConfigWidget *SysRootKitInformation::createConfigWidget(Kit *k) const { return new Internal::SysRootInformationConfigWidget(k, isSticky(k)); }
//============================================== //============================================== //============================================== void fitPedBT( int itp,int run,TH2F *h2, int id1, int id2) { if(id2>18000) id2=18000; char txt[1000], txt2[1000]; sprintf(txt,"ped%s",cTile4[itp]); sprintf(txt2,"ped %s R%d; %s soft ID; pedestal +/- fit err (ADC)",cTile4[itp],run,cTile4[itp]); hPed=new TH1F(txt,txt2,mxBTiles,0.5,mxBTiles+0.5); hPed->Sumw2(); hPed->GetXaxis()->SetLabelSize(0.08); hPed->GetYaxis()->SetLabelSize(0.08); sprintf(txt,"stat%s",cTile4[itp]); sprintf(txt2,"status %s R%d; %s soft ID; jan status",cTile4[itp],run,cTile4[itp]); hStat=new TH1I(txt,txt2,mxBTiles,0.5,mxBTiles+0.5); hStat->Reset(-1); // default is bad hStat->GetXaxis()->SetLabelSize(0.08); hStat->GetYaxis()->SetLabelSize(0.08); sprintf(txt,"chi%s",cTile4[itp]); sprintf(txt2,"chi2/DOF %s R%d; %s soft ID; ped Chi2/DOF",cTile4[itp],run,cTile4[itp]); hChi=new TH1F(txt,txt2,mxBTiles,0.5,mxBTiles+0.5); hStat->Reset(-1); // default is bad hChi->GetXaxis()->SetLabelSize(0.08); hChi->GetYaxis()->SetLabelSize(0.08); hChi->GetYaxis()->SetTitleSize(0.2); sprintf(txt,"sigPed%s",cTile4[itp]); sprintf(txt2,"sigma(ped) %s R%d; %s soft ID; sig(ped) ADC",cTile4[itp],run,cTile4[itp]); hSig=new TH1F(txt,txt2,mxBTiles,0.5,mxBTiles+0.5); hStat->Reset(-1); // default is bad hSig->GetXaxis()->SetLabelSize(0.08); hSig->GetYaxis()->SetLabelSize(0.08); hPeak=new TH1F("hpedPeak", "integral of pedestal peak;soft ID", mxBTiles,0.5,mxBTiles+0.5); hPeak->GetXaxis()->SetLabelSize(0.08); hPeak->GetYaxis()->SetLabelSize(0.08); float par_nsig=3; // integration range for QA float par_rms=2; // to approximate fit range float cut_yield0=100; float cut_yieldR1=0.7; float cut_ch2min=0.1; float cut_ch2ndf=200.; float cut_pedL=105; float cut_pedH=295; float cut_pedH=295; float cut_sigPed=2.7; // float cut_minYiled=50; axX=h2->GetXaxis(); float x1=axX->GetXmin(); float x2=axX->GetXmax(); int nbX=axX->GetNbins(); printf("X-axis range --> [%.1f, %.1f], nb=%d %s\n",x1,x2,nbX,axX->GetTitle()); axY=h2->GetYaxis(); float y1=axY->GetXmin(); float y2=axY->GetXmax(); int nbY=axY->GetNbins(); printf("Y-axis range --> [%.1f, %.1f], nb=%d\n",y1,y2,nbY); TH1F*h=new TH1F("h1","h1",nbY,y1,y2); // working histo for 1-D spectrum // do projections int ih; for(ih=id1; ih<=id2; ih++) { char txt1[100], txt2[1000]; sprintf(txt1,"id%d",ih); sprintf(txt2,"%s soft id=%d;%s ",cTile4[itp],ih,axY->GetTitle()); h->SetTitle(txt2); h->Reset(); h->SetAxisRange(y1,y2); int i; int kBad=1; for(i=1;i<=nbY;i++) h->SetBinContent(i,h2->GetBinContent(ih,i)); //for(i=1;i<=nbY;i++) printf("%d %f \n",i,h2->GetBinContent(ih,i)); float mean=h->GetMean(); float yield=h->Integral(); h->SetEntries(yield); printf("******** work on %s mean=%.1f rms=%.1f yield=%.1f\n",txt1,mean,h->GetRMS(),yield); if(yield<cut_yield0) { hStat->SetBinContent(ih,kBad); continue; } kBad<<=1; if(isSticky(h,mean)) { hStat->SetBinContent(ih,kBad); continue; } kBad<<=1; // if(ih>=12367) return; float adc1=mean-par_rms*par_nsig; float adc2=mean+par_rms*par_nsig-1; h->SetAxisRange( adc1,adc2); float yield2=h->Integral(); float r1=yield2/yield; printf(" range=%d,%d r1=%.3f yield2=%.1f\n",adc1,adc2,r1,yield2); if(r1< cut_yieldR1) { hStat->SetBinContent(ih,kBad); continue; } kBad<<=1; h->Fit("gaus","Q","Rh", adc1, adc2); TF1 *ff=h->GetFunction("gaus"); assert(ff); ff->SetLineColor(kRed); ff->SetLineWidth(1.); h->Draw(); float ped=ff->GetParameter(1); float pedErr=ff->GetParError(1); float sig=ff->GetParameter(2); float chi2=ff->GetChisquare(); float ndf=ff->GetNDF(); printf("chi2=%f ndf=%f\n", chi2,ndf); if(chi2<cut_ch2min) { hStat->SetBinContent(ih,kBad); continue; } // keep the same flag hChi->SetBinContent(ih, chi2/ndf); if(chi2/ndf> cut_ch2ndf) { hStat->SetBinContent(ih,kBad); continue; } kBad<<=1; adc1=ped-sig*par_nsig; adc2=ped+sig*par_nsig; h->SetAxisRange( adc1,adc2); float yield3=h->Integral(); float r2=yield2/yield; printf("ped=%f sig=%f range=%d,%d r2=%.3f\n",ped,sig,adc1,adc2,r2); hSig->SetBinContent(ih,sig); if(sig>cut_sigPed || sig<0) { hStat->SetBinContent(ih,kBad); continue; } kBad<<=1; if(isRawAdc){ if(ped< cut_pedL) { hStat->SetBinContent(ih,kBad); continue; } if(ped> cut_pedH) { hStat->SetBinContent(ih,kBad); continue; } kBad<<=1; } hPed->SetBinContent(ih,ped); hPed->SetBinError(ih,pedErr); int np=grP->GetN(); grP->SetPoint(np,ih,ped); grP->SetPointError(np,0,pedErr); hPeak->SetBinContent(ih,r2); hStat->SetBinContent(ih,0); // good } h->SetAxisRange(y1,y2); printStat(id1,id2); fd2->cd(); h->Write(); }
} return m_modifiedKit->toHtml(tmp); } void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget) { QTC_ASSERT(widget, return); QTC_ASSERT(!m_widgets.contains(widget), return); QString name = widget->displayName(); QString toolTip = widget->toolTip(); auto action = new QAction(tr("Mark as Mutable"), 0); action->setCheckable(true); action->setChecked(widget->isMutable()); action->setEnabled(!widget->isSticky()); widget->mainWidget()->addAction(action); widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu); connect(action, &QAction::toggled, this, [this, widget, action] { widget->setMutable(action->isChecked()); emit dirty(); }); m_actions << action; int row = m_layout->rowCount(); m_layout->addWidget(widget->mainWidget(), row, WidgetColumn); if (QWidget *button = widget->buttonWidget()) m_layout->addWidget(button, row, ButtonColumn); static auto alignment