Beispiel #1
0
TObject *formatPlot(TObject *h,
                    int color, int line, int linew, int marker, int fill,
                    bool detachFromCurrentDir, bool setSumw2,
                    int linecolor, int fillcolor, int markercolor)
{
    if(h==0) return h;
    if( linecolor < 0 ) linecolor=color;
    if( fillcolor < 0 ) fillcolor=color;
    if( markercolor < 0 ) markercolor=color;
    if( h->IsA()->InheritsFrom(TAttLine::Class()) ) {
        TAttLine * l = dynamic_cast<TAttLine *>(h);
        l->SetLineStyle(line);
        l->SetLineWidth(linew);
        l->SetLineColor(linecolor);
    }
    if( h->IsA()->InheritsFrom(TAttMarker::Class()) ) {
        TAttMarker * m =  dynamic_cast<TAttMarker *>(h);
        m->SetMarkerColor(markercolor);
        m->SetMarkerStyle(marker);
    }
    if( h->IsA()->InheritsFrom(TAttFill::Class()) ) {
        TAttFill * f = dynamic_cast<TAttFill *>(h);
        f->SetFillColor(fillcolor);
        f->SetFillStyle(fill);
    }
    if( h->IsA()->InheritsFrom(TH1::Class()) ) {
        TH1 * h1 = (TH1 *) h;
        h1->SetLineStyle(line);
        h1->SetLineWidth(linew);
        h1->SetLineColor(linecolor);
        h1->SetMarkerColor(markercolor);
        h1->SetMarkerStyle(marker);
        h1->SetFillColor(fillcolor);
        h1->SetFillStyle(fill);
        if( setSumw2 && h1->GetSumw2N()<=h1->GetNbinsX()) h1->Sumw2();
        if( detachFromCurrentDir ) h1->SetDirectory(0);
        ((TH1 *)h)->SetLabelFont(42, "XYZ");
        ((TH1 *)h)->SetTitleFont(62, "XYZ");
    }


    return h;
}
void TGo4HisDrawOptionsShort::ChangeColor(int kind)
{
   TGo4ViewPanel* panel = TGo4MdiArea::Instance()->GetActivePanel();
   if (panel==0) return;

   TPad* pad = panel->GetActivePad();
   TObject* obj = panel->GetSelectedObject(pad, 0);

   Color_t icol = 0;

   switch (kind) {
      case 0: {
        TAttLine* att = dynamic_cast<TAttLine*> (obj);
        if (att==0) return;
        icol = att->GetLineColor();
        break;
      }
      case 1: {
        TAttFill* att = dynamic_cast<TAttFill*> (obj);
        if (att==0) return;
        icol = att->GetFillColor();
        break;
      }
      case 2: {
        TAttMarker* att = dynamic_cast<TAttMarker*> (obj);
        if (att==0) return;
        icol = att->GetMarkerColor();
        break;
      }
   }

   TColor* rcol = gROOT->GetColor(icol);

   QColor qcol;

   if (rcol!=0)
      qcol.setRgb(rcol->GetRed(), rcol->GetGreen(), rcol->GetBlue());

   QColor c = QColorDialog::getColor(qcol);
   if (!c.isValid()) return;

   icol = TColor::GetColor(c.red(), c.green(), c.blue());

   switch (kind) {
      case 0: {
        TAttLine* att = dynamic_cast<TAttLine*> (obj);
        if (att!=0) att->SetLineColor(icol);
        break;
      }
      case 1: {
        TAttFill* att = dynamic_cast<TAttFill*> (obj);
        if (att!=0) att->SetFillColor(icol);
        break;
      }
      case 2: {
        TAttMarker* att = dynamic_cast<TAttMarker*> (obj);
        if (att!=0) att->SetMarkerColor(icol);
        break;
      }
   }

   panel->MarkPadModified(pad);

   panel->ShootRepaintTimer(pad);

   panel->ActivateInGedEditor(obj);
}