void ContactListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { doSetOptions(option, index); // prepare painter->save(); // if (hasClipping()) // painter->setClipRect(d->opt.rect); QVariant value; d->iconMode = ::iconMode(opt().state); d->iconState = ::iconState(opt().state); switch (ContactListModel::indexType(index)) { case ContactListModel::ContactType: drawContact(painter, opt(), index); break; case ContactListModel::GroupType: drawGroup(painter, opt(), index); break; case ContactListModel::AccountType: drawAccount(painter, opt(), index); break; case ContactListModel::InvalidType: painter->fillRect(option.rect, Qt::red); break; default: QItemDelegate::paint(painter, option, index); } painter->restore(); }
void drawElement(e2dElement* elem) { glPushMatrix(); multMatrix(&elem->localTransform); switch(elem->type) { case(E2D_GROUP): drawGroup((e2dGroup*)elem); break; case(E2D_PATH): drawPath((e2dPath*)elem); break; case(E2D_IMAGE): drawImage((e2dImage*)elem); break; case(E2D_CLONE): drawClone((e2dClone*)elem); break; default: break; } drawAxis(); drawRect(elem->bboxPosition, elem->bboxWidth, elem->bboxHeight); glPopMatrix(); }
void QtTreeViewDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { //VOXOX - JRT - 2009.08.10 - TODO: move this and drawGroup to QtContact class if (!index.parent().isValid()) { drawGroup(painter, option, index); } else { //VOXOX - JRT - 2009.08.10 QtContact* qtContact = getItemData( index ); if ( qtContact ) { // if ( qtContact->isOpen() ) // { // QWidget * parent = const_cast<QWidget*>(_parent); //// QtContactWidget * widget = new QtContactWidget( qtContact->getId().toStdString(), qtContact->getKey().toStdString(), _cWengoPhone, _qtContactManager, parent); //VOXOX - JRT - 2009.08.10 - multiple groups. // QtContactWidget * widget = new QtContactWidget( qtContact->getId().toStdString(), qtContact->getKey().toStdString(), _cWengoPhone, parent); //VOXOX - JRT - 2009.10.15 //// setSizeHint( 0, QSize(-1, getHeight() ) ); // } // else { qtContact->paint( painter, option ); } } else { int xxx = 1; } } }
void QgsPointDisplacementRenderer::stopRender( QgsRenderContext& context ) { QgsDebugMsg( "QgsPointDisplacementRenderer::stopRender" ); //printInfoDisplacementGroups(); //just for debugging Q_FOREACH ( const DisplacementGroup& group, mDisplacementGroups ) { drawGroup( group, context ); }
void QgsPointDisplacementRenderer::stopRender( QgsRenderContext& context ) { QgsDebugMsg( "QgsPointDisplacementRenderer::stopRender" ); //printInfoDisplacementGroups(); //just for debugging for ( QList<DisplacementGroup>::const_iterator it = mDisplacementGroups.begin(); it != mDisplacementGroups.end(); ++it ) drawGroup( *it, context ); mDisplacementGroups.clear(); mGroupIndex.clear(); delete mSpatialIndex; mSpatialIndex = 0; mSelectedFeatures.clear(); mRenderer->stopRender( context ); if ( mCenterSymbol ) { mCenterSymbol->stopRender( context ); } }
void OneMinusClPlot::Draw() { bool plotSimple = false;//arg->debug; ///< set to true to use a simpler plot function ///< which directly plots the 1-CL histograms without beautification if ( m_mainCanvas==0 ){ m_mainCanvas = newNoWarnTCanvas(name+getUniqueRootName(), title, 800, 600); // put this in for exponent xaxes m_mainCanvas->SetRightMargin(0.1); } if ( arg->plotlog ){ m_mainCanvas->SetLogy(); if ( !this->name.EndsWith("_log") ) this->name = this->name + "_log"; } m_mainCanvas->cd(); // plot the CLs for ( int i = 0; i < scanners.size(); i++ ) if (do_CLs[i]==2) scan1dCLsPlot(scanners[i],arg->nsmooth); // Legend: // make the legend short, the text will extend over the boundary, but the symbol will be shorter float legendXmin = arg->plotlegx!=-1. ? arg->plotlegx : 0.19 ; float legendYmin = arg->plotlegy!=-1. ? arg->plotlegy : 0.78 ; float legendXmax = legendXmin + ( arg->plotlegsizex!=-1. ? arg->plotlegsizex : 0.31 ) ; float legendYmax = legendYmin + ( arg->plotlegsizey!=-1. ? arg->plotlegsizey : 0.1640559 ) ; TLegend* leg = new TLegend(legendXmin,legendYmin,legendXmax,legendYmax); leg->SetFillColor(kWhite); leg->SetFillStyle(0); leg->SetLineColor(kWhite); leg->SetBorderSize(0); leg->SetTextFont(font); leg->SetTextSize(legendsize*0.75); for ( int i = 0; i < scanners.size(); i++ ) { TString legDrawOption = "lf"; if ( plotPluginMarkers && ( scanners[i]->getMethodName()=="Plugin" || scanners[i]->getMethodName()=="BergerBoos" || scanners[i]->getMethodName()=="DatasetsPlugin" ) ) { legDrawOption = "lep"; } if ( arg->plotlegstyle != "default" ) legDrawOption = arg->plotlegstyle; TString legTitle = scanners[i]->getTitle(); if ( legTitle=="default" ) { if ( scanners[i]->getMethodName().Contains("Prob") ) legTitle = do_CLs[i] ? "Prob CLs" : "Prob"; if ( scanners[i]->getMethodName().Contains("Plugin") ) { if ( do_CLs[i]==0 ) legTitle = "Plugin"; else if (do_CLs[i]==1) legTitle = "Plugin CLs"; else if (do_CLs[i]==2) legTitle = "Mixed CLs"; } } else if ( !arg->isQuickhack(29) ) { if ( scanners[i]->getMethodName().Contains("Prob") ) legTitle += do_CLs[i] ? " (Prob CLs)" : " (Prob)"; if ( scanners[i]->getMethodName().Contains("Plugin") ) { if ( do_CLs[i]==0 ) legTitle += " (Plugin)"; else if (do_CLs[i]==1) legTitle += " (Plugin CLs)"; else if (do_CLs[i]==2) legTitle += " (Mixed CLs)"; } } if ( plotSimple ) { scan1dPlotSimple(scanners[i], i==0, do_CLs[i]); if(do_CLs[i]) leg->AddEntry(scanners[i]->getHCL(), legTitle, legDrawOption); else leg->AddEntry(scanners[i]->getHCL(), legTitle, legDrawOption); } else { TGraph* g = scan1dPlot(scanners[i], i==0, false, scanners[i]->getFilled(), do_CLs[i]); if(do_CLs[i] && scanners[i]->getTitle() != "noleg") leg->AddEntry(g, legTitle, legDrawOption); else if ( scanners[i]->getTitle() != "noleg" ) leg->AddEntry(g, legTitle, legDrawOption); } } // lines only if ( !plotSimple ) for ( int i = 0; i < scanners.size(); i++ ) { bool last = i==scanners.size()-1; scan1dPlot(scanners[i], false, last, false, do_CLs[i]); } drawSolutions(); if ( plotLegend ) leg->Draw(); if ( arg->isQuickhack(22) ) leg->Draw(); m_mainCanvas->Update(); drawCLguideLines(); // draw the logo float yGroup = 0.6; if ( plotLegend ){ // we have a legend if ( arg->plotlog ) yGroup = 0.775; else yGroup = 0.60; } else{ // no legend if ( arg->plotlog ) yGroup = 0.3; else yGroup = 0.775; } drawGroup(yGroup); m_mainCanvas->Update(); m_mainCanvas->Show(); }
/// /// Make a plot for the CLs stuff. /// The strategy is to convert the hCLExp and hCLErr histogrms /// into TGraphs and TGraphAsymmErrors /// We can then provide some smoothing options as well /// /// \param s The scanner to plot. /// \param smooth /// void OneMinusClPlot::scan1dCLsPlot(MethodAbsScan *s, bool smooth, bool obsError) { if ( arg->debug ){ cout << "OneMinusClPlot::scan1dCLsPlot() : plotting "; cout << s->getName() << " (" << s->getMethodName() << ")" << endl; } m_mainCanvas->cd(); s->checkCLs(); TH1F *hObs = (TH1F*)s->getHCLsFreq()->Clone(getUniqueRootName()); TH1F *hExp = (TH1F*)s->getHCLsExp()->Clone(getUniqueRootName()); TH1F *hErr1Up = (TH1F*)s->getHCLsErr1Up()->Clone(getUniqueRootName()); TH1F *hErr1Dn = (TH1F*)s->getHCLsErr1Dn()->Clone(getUniqueRootName()); TH1F *hErr2Up = (TH1F*)s->getHCLsErr2Up()->Clone(getUniqueRootName()); TH1F *hErr2Dn = (TH1F*)s->getHCLsErr2Dn()->Clone(getUniqueRootName()); if ( !hObs ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - can't find histogram hObs" << endl; if ( !hExp ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - can't find histogram hExp" << endl; if ( !hErr1Up ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - can't find histogram hErr1Up" << endl; if ( !hErr1Dn ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - can't find histogram hErr1Dn" << endl; if ( !hErr2Up ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - can't find histogram hErr2Up" << endl; if ( !hErr2Dn ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - can't find histogram hErr2Dn" << endl; // convert obs to graph TGraph *gObs = convertTH1ToTGraph(hObs,obsError); // convert others to raw graphs TGraph *gExpRaw = convertTH1ToTGraph(hExp); TGraph *gErr1UpRaw = convertTH1ToTGraph(hErr1Up); TGraph *gErr1DnRaw = convertTH1ToTGraph(hErr1Dn); TGraph *gErr2UpRaw = convertTH1ToTGraph(hErr2Up); TGraph *gErr2DnRaw = convertTH1ToTGraph(hErr2Dn); // smoothing if needed TGraph *gExp; TGraph *gErr1Up; TGraph *gErr1Dn; TGraph *gErr2Up; TGraph *gErr2Dn; TGraphSmooth *smoother = new TGraphSmooth(); if (smooth) { if ( arg->debug ) cout << "OneMinusClPlot::scan1dCLsPlot() : smoothing graphs" << endl; gExp = (TGraph*)smoother->SmoothSuper( gExpRaw )->Clone("gExp"); gErr1Up = (TGraph*)smoother->SmoothSuper( gErr1UpRaw )->Clone("gErr1Up"); gErr1Dn = (TGraph*)smoother->SmoothSuper( gErr1DnRaw )->Clone("gErr1Dn"); gErr2Up = (TGraph*)smoother->SmoothSuper( gErr2UpRaw )->Clone("gErr2Up"); gErr2Dn = (TGraph*)smoother->SmoothSuper( gErr2DnRaw )->Clone("gErr2Dn"); if ( arg->debug ) cout << "OneMinusClPlot::scan1dCLsPlot() : done smoothing graphs" << endl; } else { gExp = gExpRaw; gErr1Up = gErr1UpRaw; gErr1Dn = gErr1DnRaw; gErr2Up = gErr2UpRaw; gErr2Dn = gErr2DnRaw; } if ( !gObs ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - null graph gObs" << endl; if ( !gExp ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - null graph gExp" << endl; if ( !gErr1Up ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - null graph gErr1Up" << endl; if ( !gErr1Dn ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - null graph gErr1Dn" << endl; if ( !gErr2Up ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - null graph gErr2Up" << endl; if ( !gErr2Dn ) cout << "OneMinusClPlot::scan1dCLsPlot() : problem - null graph gErr2Dn" << endl; gObs->SetName("gObs"); gExp->SetName("gExp"); gErr1Up->SetName("gErr1Up"); gErr1Dn->SetName("gErr1Dn"); gErr2Up->SetName("gErr2Up"); gErr2Dn->SetName("gErr2Dn"); // now make the graphs for the error bands TGraphAsymmErrors *gErr1 = new TGraphAsymmErrors( gExp->GetN() ); gErr1->SetName("gErr1"); TGraphAsymmErrors *gErr2 = new TGraphAsymmErrors( gExp->GetN() ); gErr2->SetName("gErr2"); double x,y,yerrUp,yerrDn; double xerr = (hExp->GetBinCenter(2)-hExp->GetBinCenter(1))/2.; // protect against smoothing over 1 for (int i=0; i<gExp->GetN(); i++) { gExp->GetPoint(i,x,y); gExp->SetPoint(i,x,TMath::Min(y,1.)); gErr1Up->GetPoint(i,x,y); gErr1Up->SetPoint(i,x,TMath::Min(y,1.)); gErr1Dn->GetPoint(i,x,y); gErr1Dn->SetPoint(i,x,TMath::Min(y,1.)); gErr2Up->GetPoint(i,x,y); gErr2Up->SetPoint(i,x,TMath::Min(y,1.)); gErr2Dn->GetPoint(i,x,y); gErr2Dn->SetPoint(i,x,TMath::Min(y,1.)); } for (int i=0; i<gExp->GetN(); i++) { gExp->GetPoint(i,x,y); gErr1->SetPoint(i,x,y); gErr2->SetPoint(i,x,y); gErr1Up->GetPoint(i,x,yerrUp); gErr1Dn->GetPoint(i,x,yerrDn); gErr1->SetPointError(i, xerr, xerr, y-yerrDn, yerrUp-y ); gErr2Up->GetPoint(i,x,yerrUp); gErr2Dn->GetPoint(i,x,yerrDn); gErr2->SetPointError(i, xerr, xerr, y-yerrDn, yerrUp-y ); } gErr2->SetFillColor( TColor::GetColor("#3182bd") ); gErr2->SetLineColor( TColor::GetColor("#3182bd") ); gErr1->SetFillColor( TColor::GetColor("#9ecae1") ); gErr1->SetLineColor( TColor::GetColor("#9ecae1") ); gExp->SetLineColor(kRed); gExp->SetLineWidth(3); gObs->SetLineColor(kBlack); gObs->SetMarkerColor(kBlack); gObs->SetLineWidth(3); gObs->SetMarkerSize(1); gObs->SetMarkerStyle(20); float min = arg->scanrangeMin == arg->scanrangeMax ? hObs->GetXaxis()->GetXmin() : arg->scanrangeMin; float max = arg->scanrangeMin == arg->scanrangeMax ? hObs->GetXaxis()->GetXmax() : arg->scanrangeMax; TH1F *haxes = new TH1F("haxes"+getUniqueRootName(), "", 100, min, max); haxes->SetStats(0); haxes->GetXaxis()->SetTitle(s->getScanVar1()->GetTitle()); haxes->GetYaxis()->SetTitle("CL_{S}"); haxes->GetXaxis()->SetLabelFont(font); haxes->GetYaxis()->SetLabelFont(font); haxes->GetXaxis()->SetTitleFont(font); haxes->GetYaxis()->SetTitleFont(font); haxes->GetXaxis()->SetTitleOffset(0.9); haxes->GetYaxis()->SetTitleOffset(0.85); haxes->GetXaxis()->SetLabelSize(labelsize); haxes->GetYaxis()->SetLabelSize(labelsize); haxes->GetXaxis()->SetTitleSize(titlesize); haxes->GetYaxis()->SetTitleSize(titlesize); int xndiv = arg->ndiv==-1 ? 407 : abs(arg->ndiv); bool optimizeNdiv = arg->ndiv<0 ? true : false; haxes->GetXaxis()->SetNdivisions(xndiv, optimizeNdiv); haxes->GetYaxis()->SetNdivisions(407, true); haxes->GetYaxis()->SetRangeUser(0.,1.); // Legend: // make the legend short, the text will extend over the boundary, but the symbol will be shorter float legendXmin = 0.68 ; float legendYmin = 0.58 ; float legendXmax = legendXmin + 0.25 ; float legendYmax = legendYmin + 0.22 ; TLegend* leg = new TLegend(legendXmin,legendYmin,legendXmax,legendYmax); leg->SetFillColor(kWhite); leg->SetFillStyle(0); leg->SetLineColor(kWhite); leg->SetBorderSize(0); leg->SetTextFont(font); leg->SetTextSize(legendsize*0.75); if (obsError) leg->AddEntry( gObs, "Observed", "LEP" ); else leg->AddEntry( gObs, "Observed", "LP" ); leg->AddEntry( gExp, "Expected", "L" ); leg->AddEntry( gErr1, "#pm 1#sigma", "F"); leg->AddEntry( gErr2, "#pm 2#sigma", "F"); haxes->Draw("AXIS+"); gErr2->Draw("E3same"); gErr1->Draw("E3same"); gExp->Draw("Lsame"); if (obsError) gObs->Draw("LEPsame"); else gObs->Draw("LPsame"); leg->Draw("same"); drawCLguideLine(0.1); double yGroup = 0.83; if ( arg->plotprelim || arg->plotunoff ) yGroup = 0.8; drawGroup(yGroup); m_mainCanvas->SetTicks(); m_mainCanvas->RedrawAxis(); m_mainCanvas->Update(); m_mainCanvas->Modified(); m_mainCanvas->Show(); savePlot( m_mainCanvas, name+"_cls"+arg->plotext ); m_mainCanvas->SetTicks(false); }