Exemple #1
0
void fw_simGeo_set_material_titles(Double_t fraction=0, Bool_t long_names=false)
{
   TGeoMaterial *m;
   TIter it(FWGeometryTableViewManager_GetGeoManager()->GetListOfMaterials());
   while ((m = (TGeoMaterial*) it()) != 0)
   {
      TString tit(":");
      TGeoMixture *mix = dynamic_cast<TGeoMixture*>(m);

      if (mix == 0)
      {
         TGeoElement *e = m->GetBaseElement();
         tit += long_names ? e->GetTitle() : e->GetName();
         tit += ":";
      }
      else
      {
         Double_t *ww = mix->GetWmixt();
         for (Int_t i = 0; i < mix->GetNelements(); ++i)
         {
            if (ww[i] >= fraction)
            {
               TGeoElement *e = mix->GetElement(i);
               tit += long_names ? e->GetTitle() : e->GetName();
               tit += ":";
            }
         }
      }
      if (tit == ":") tit += ":";
      m->SetTitle(tit);
   }
}
Exemple #2
0
  /** 
   * Create ratios to other data 
   * 
   * @param ib      Bin number  
   * @param res     Result
   * @param alice   ALICE result if any
   * @param cms     CMS result if any
   * @param all     Stack to add ratio to 
   */
  void Ratio2Stack(Int_t ib, TH1* res, TGraph* alice, TGraph* cms, THStack* all)
  {
    if (!all || !res || !(alice || cms)) return;

    Int_t        off  = 5*ib;
    TGraph*      gs[] = { (alice ? alice : cms), (alice ? cms : 0), 0 };
    TGraph**     pg   = gs;
    while (*pg) { 
      TGraph*     g = *pg;
      const char* n = (g == alice ? "ALICE" : "CMS");

      TH1*    r = static_cast<TH1*>(res->Clone(Form("ratio%s", n)));
      TString tit(r->GetTitle());
      tit.ReplaceAll("Corrected", Form("Ratio to %s", n));
      r->SetTitle(tit);
      r->SetMarkerColor(g->GetMarkerColor());
      r->SetLineColor(g->GetLineColor());

      TObject* tst = r->FindObject("legend");
      if (tst) r->GetListOfFunctions()->Remove(tst);

      for (Int_t i = 1; i <= r->GetNbinsX(); i++) {
	Double_t c = r->GetBinContent(i);
	Double_t e = r->GetBinError(i);
	Double_t o = g->Eval(r->GetBinCenter(i));
	if (o < 1e-12) { 
	  r->SetBinContent(i, 0);
	  r->SetBinError(i, 0);
	  continue;
	}
	r->SetBinContent(i, (c - o) / o + off);
	r->SetBinError(i, e / o);
      }
      all->Add(r);
      pg++;
    }
    TLegend* leg = StackLegend(all);
    if (!leg) return;
      
    TString   txt      = res->GetTitle();
    txt.ReplaceAll("Corrected P(#it{N}_{ch}) in ", "");
    if      (ib == 0) txt.Append(" "); // (#times1)");
    // else if (ib == 1) txt.Append(" (#times10)");
    else              txt.Append(Form(" (+%d)", off));

    TObject* dummy = 0;
    TLegendEntry* e = leg->AddEntry(dummy, txt, "p");
    e->SetMarkerStyle(res->GetMarkerStyle());
    e->SetMarkerSize(res->GetMarkerSize());
    e->SetMarkerColor(kBlack);
    e->SetFillColor(0);
    e->SetFillStyle(0);
    e->SetLineColor(kBlack);
  }
Exemple #3
0
main()
{
   clrscr();

   Tablou<int> t;
   TablouIterator<int> tit(t);
   int n;

   t.Adaug(1);
   t.Adaug(2);
   t.Adaug(5);
   t.Adaug(4);
   t.Adaug(3);

   while (tit)
   {
      n= tit();
      tit++;
      cout<<n<<' ';
   }
   cout<<"\n";

//   int a= 2;
//   t.ForEach(iterare, &a);  // De ce dam "&a"?
//   tit.Restart();

   int a= 3;
   const int *b= t.LastThat(MaiMare, &a);
   cout<<*b;

//   while (tit)
//   {
//      n= tit();
//      tit++;
//      cout<<n<<' ';
//   }

   getch();
   return 0;
}
	TestUnitIdReader::TestUnitIdReader(const std::string& names) : m_depth(0) {

		string_token_iterator tit( names, (dropped_delimeters = "/", kept_delimeters = dt_none) );

		while( tit != string_token_iterator() ) {
			m_filters.push_back(
				std::vector<single_filter>( string_token_iterator( *tit, (dropped_delimeters = ",", kept_delimeters = dt_none)  ),
											string_token_iterator() ) );

			++tit;
		}

//			printFilters();
	}
Exemple #5
0
void MovieEventHandlers::Add(int eventId, const MovieEventHandlerDictionary &h)
{
	MovieEventHandlerDictionary::const_iterator it(h.begin()), itend(h.end());
	PrepareTable();
	table_t::const_iterator titend(table.end());
	for (; it != itend; ++it) {
		table_t::const_iterator tit(table.begin());
		for (; tit != titend; ++tit) {
			if (it->first == tit->first) {
				m_handlers[tit->second].push_back(
					make_pair(eventId, it->second));
			}
		}
	}
	if (m_empty)
		UpdateEmpty();
}
Exemple #6
0
///** add a distance table to DistTables list
// * @param d_table pointer to a DistanceTableData to be added
// *
// * DistTables is a list of DistanceTables which are updated by MC moves.
// */
//void ParticleSet::addTable(DistanceTableData* d_table) {
//  int oid=d_table->origin().tag();
//  int i=0;
//  int dsize=DistTables.size();
//  while(i<dsize) {
//    if(oid == DistTables[i]->origin().tag()) //table already exists
//      return;
//    ++i;
//  }
//  DistTables.push_back(d_table);
//}
int ParticleSet::addTable(const ParticleSet& psrc)
{
  if (DistTables.empty())
  {
    DistTables.reserve(4);
    DistTables.push_back(createDistanceTable(*this));
    //add  this-this pair
    myDistTableMap.clear();
    myDistTableMap[ObjectTag]=0;
    app_log() << "  ... ParticleSet::addTable Create Table #0 " << DistTables[0]->Name << endl;
    DistTables[0]->ID=0;
    if (psrc.tag() == ObjectTag)
      return 0;
  }
  if (psrc.tag() == ObjectTag)
  {
    app_log() << "  ... ParticleSet::addTable Reuse Table #" << 0 << " " << DistTables[0]->Name <<endl;
    return 0;
  }
  int tsize=DistTables.size(),tid;
  map<int,int>::iterator tit(myDistTableMap.find(psrc.tag()));
  if (tit == myDistTableMap.end())
  {
    tid=DistTables.size();
    DistTables.push_back(createDistanceTable(psrc,*this));
    myDistTableMap[psrc.tag()]=tid;
    DistTables[tid]->ID=tid;
    app_log() << "  ... ParticleSet::addTable Create Table #" << tid << " " << DistTables[tid]->Name <<endl;
  }
  else
  {
    tid = (*tit).second;
    app_log() << "  ... ParticleSet::addTable Reuse Table #" << tid << " " << DistTables[tid]->Name << endl;
  }
  app_log().flush();
  return tid;
}
Exemple #7
0
/// Undo moving several objects.
void UndoBuffer::undoMoveMultiple(Undo* u)
{
  Project* p;
  p = u->getProject();

//  QListIterator<GState> i(*u->getSList());
//  QList<GTransition>* tl = u->getTList();
//  GState* s;
//  GTransition* t;
  double x, y;
//  QList<GObject>* sellist;
  Selection* sel;
  QList<GState*>* ssellist;
  QList<GTransition*>* tsellist;
//  bool dragmultiple;
  ScrollView* sv;

  u->getMovedBy(x, y);

  sv = project->getMain()->getScrollView();
  sel = sv->getDrawArea()->getSelection();
  sel->deselectAll(project->machine);
  
  ssellist = u->getSList2();
  tsellist = u->getTList2();

  QListIterator<GState*> sit(*ssellist);
  for(;sit.hasNext();)
    sel->select(sit.next());

  QListIterator<GTransition*> tit(*tsellist);
  for(;tit.hasNext();)
    sel->select(tit.next());

  /*
  for(; i.current(); ++i)
  {
    s = i.current();
    s->move(-x, -y, project->getMain()->getScrollView(), project->machine, FALSE);
  }
  */
//  dragmultiple = sv->getDragMultiple();

  sel->move(-x, -y, project->getMain()->getScrollView()->getDrawArea(), p->machine);

  /*
  s = project->machine->getPhantomState();
  QListIterator<GTransition> j(s->tlist);

  for(; j.current(); ++j)
  {
    t = j.current();
    if (t->getEnd()==NULL && tl->containsRef(t))
      t->move(-x, -y);
  }
  */
  /*
  sit.toFirst();
  for(;sit.current(); ++sit)
    sel->deselect(sit.current());
    */
  sel->deselectAll(p->machine);
}
Exemple #8
0
  /** 
   * Process a single eta bin 
   * 
   * @param measured     Input collection of measured data
   * @param corrections  Input collection of correction data
   * @param method       Unfolding method to use 
   * @param regParam     Regularisation parameter
   * @param out          Output directory. 
   *
   * @return Stack of histograms or null 
   */
  THStack* ProcessBin(TCollection* measured, 
		      TCollection* corrections, 
		      UInt_t       method,
		      Double_t     regParam, 
		      TDirectory*  out)
  {
    Printf("   Processing %s ...", measured->GetName());
    // Try to get the data 
    TH1* inRaw    = GetH1(measured,    "rawDist");
    TH1* inTruth  = GetH1(corrections, "truth");
    TH1* inTruthA = GetH1(corrections, "truthAccepted");
    TH1* inTrgVtx = GetH1(corrections, "triggerVertex");
    TH2* inResp   = GetH2(corrections, "response");
    if (!inRaw || !inTruth || !inTruthA || !inTrgVtx || !inResp) 
      return 0;
    
    // Make output directory
    TDirectory* dir = out->mkdir(measured->GetName());
    dir->cd();

    // Copy the input to the output 
    TH1* outRaw    = static_cast<TH1*>(inRaw    ->Clone("measured"));
    TH1* outTruth  = static_cast<TH1*>(inTruth  ->Clone("truth"));
    TH1* outTruthA = static_cast<TH1*>(inTruthA ->Clone("truthAccepted"));
    TH1* outTrgVtx = static_cast<TH1*>(inTrgVtx ->Clone("triggerVertex"));
    TH2* outResp   = static_cast<TH2*>(inResp   ->Clone("response"));

    // Make our response matrix 
    RooUnfoldResponse matrix(0, 0, inResp);
    
    // Store regularization parameter 
    Double_t             r        = regParam;
    RooUnfold::Algorithm algo     = (RooUnfold::Algorithm)method;
    RooUnfold*           unfolder = RooUnfold::New(algo, &matrix, inRaw, r);
    unfolder->SetVerbose(0);

    // Do the unfolding and get the result
    TH1* res = unfolder->Hreco();
    res->SetDirectory(0);

    // Make a copy to store on the output 
    TH1* outUnfold = static_cast<TH1*>(res->Clone("unfolded"));
    TString tit(outUnfold->GetTitle());
    tit.ReplaceAll("Unfold Reponse matrix", "Unfolded P(#it{N}_{ch})");
    outUnfold->SetTitle(tit);

    // Clone the unfolded results and divide by the trigger/vertex
    // bias correction
    TH1* outCorr   = static_cast<TH1*>(outUnfold->Clone("corrected"));
    outCorr->Divide(inTrgVtx);
    tit.ReplaceAll("Unfolded", "Corrected");
    outCorr->SetTitle(tit);

    // Now normalize the output to integral=1 
    TH1*  hists[] = { outRaw, outUnfold, outCorr, 0 };
    TH1** phist   = hists;
    while (*phist) { 
      TH1* h = *phist;
      if (h) { 
	Double_t intg = h->Integral(1, h->GetXaxis()->GetXmax());
	h->Scale(1. / intg, "width");
      }
      phist++;
    }
    
    // And make ratios
    TH1* ratioTrue = static_cast<TH1*>(outCorr->Clone("ratioCorrTruth"));
    tit = ratioTrue->GetTitle();
    tit.ReplaceAll("Corrected", "Corrected/MC 'truth'");
    ratioTrue->SetTitle(tit);
    ratioTrue->Divide(outTruth);
    ratioTrue->SetYTitle("P_{corrected}(#it{N}_{ch})/P_{truth}(#it{N}_{ch})");

    TH1* ratioAcc  = static_cast<TH1*>(outUnfold->Clone("ratioUnfAcc"));
    tit = ratioAcc->GetTitle();
    tit.ReplaceAll("Unfolded", "Unfolded/MC selected");
    ratioAcc->SetTitle(tit);
    ratioAcc->Divide(outTruthA);
    ratioAcc->SetYTitle("P_{unfolded}(#it{N}_{ch})/P_{MC}(#it{N}_{ch})");
    

    // Make a stack 
    tit = measured->GetName();
    tit.ReplaceAll("m", "-");
    tit.ReplaceAll("p", "+");
    tit.ReplaceAll("d", ".");
    tit.ReplaceAll("_", "<#it{#eta}<");
    THStack* stack = new THStack("all", tit);
    stack->Add(outTruth,  "E2");
    stack->Add(outTruthA, "E2");
    stack->Add(outRaw,    "E1");
    stack->Add(outUnfold, "E1");
    stack->Add(outCorr,   "E1");
    dir->Add(stack);

    // Rest of the function is devoted to making the output look nice 
    outRaw   ->SetDirectory(dir); 
    outTruth ->SetDirectory(dir);  
    outTruthA->SetDirectory(dir);  
    outTrgVtx->SetDirectory(dir);  
    outResp  ->SetDirectory(dir);  
    outUnfold->SetDirectory(dir);   
    outCorr  ->SetDirectory(dir); 

    outRaw   ->SetMarkerStyle(20);  // Measured is closed
    outTruth ->SetMarkerStyle(24);  // MC is open
    outTruthA->SetMarkerStyle(24);  // MC is open
    outTrgVtx->SetMarkerStyle(20);  // Derived is closed
    outUnfold->SetMarkerStyle(20);  // Derived is closed   
    outCorr  ->SetMarkerStyle(20);  // Derived is closed 

    outRaw   ->SetMarkerSize(0.9); 
    outTruth ->SetMarkerSize(1.6);  
    outTruthA->SetMarkerSize(1.4);  
    outTrgVtx->SetMarkerSize(1.0);  
    outUnfold->SetMarkerSize(0.9);   
    outCorr  ->SetMarkerSize(1.0);
 
    outRaw   ->SetMarkerColor(kColorMeasured); 
    outTruth ->SetMarkerColor(kColorTruth);  
    outTruthA->SetMarkerColor(kColorAccepted);  
    outTrgVtx->SetMarkerColor(kColorTrgVtx);  
    outUnfold->SetMarkerColor(kColorUnfolded);   
    outCorr  ->SetMarkerColor(kColorCorrected); 

    outRaw   ->SetFillColor(kColorError);     
    outTruth ->SetFillColor(kColorError);  
    outTruthA->SetFillColor(kColorError);  
    outTrgVtx->SetFillColor(kColorError);  
    outUnfold->SetFillColor(kColorError);   
    outCorr  ->SetFillColor(kColorError); 

    outRaw   ->SetFillStyle(0); 
    outTruth ->SetFillStyle(1001);  
    outTruthA->SetFillStyle(1001);  
    outTrgVtx->SetFillStyle(0);  
    outUnfold->SetFillStyle(0);   
    outCorr  ->SetFillStyle(0);

    outRaw   ->SetLineColor(kBlack); 
    outTruth ->SetLineColor(kBlack);  
    outTruthA->SetLineColor(kBlack);  
    outTrgVtx->SetLineColor(kBlack);  
    outUnfold->SetLineColor(kBlack);   
    outCorr  ->SetLineColor(kBlack); 

    // Legend 
    TLegend* l = StackLegend(stack);
    l->AddEntry(outRaw,     "Raw",                 "lp");
    l->AddEntry(outTruth,   "MC 'truth'",          "fp");
    l->AddEntry(outTruthA,  "MC 'truth' accepted", "fp");
    l->AddEntry(outUnfold,  "Unfolded",            "lp");
    l->AddEntry(outCorr,    "Corrected",           "lp");

    return stack;
  }
 void Display::setTitle(const char* title){
     string tit(title);
     SDL_WM_SetCaption(("EOSimulator - " + tit).c_str(), 0);
 }
Exemple #10
0
/**
 * Creates a DOM document of this project and returns it.
 *
 * @param onlyselected If TRUE, only selected objects are used, otherwise the whole project
 *     is used
 * @param obj If != NULL, only @a obj is used from the project
 * @returns The DOM document
 */
QDomDocument Project::getDomDocument(bool onlyselected/*=FALSE*/, GObject* obj/*=NULL*/)
{
    Machine* m = machine;
    m->correctCodes();
    QString prolog="<?xml version=\"1.0\"?>\n"
      		   "<!DOCTYPE qfsmproject SYSTEM \"qfsm.dtd\">\n\n"
                   "<qfsmproject>\n"
                   "</qfsmproject>\n";


    QDomDocument domdoc;
    QDomElement root, me, one, ine, onme, itranse;
    QDomText ontext, intext, onmtext;
    QString stmp;
    int inits;
    GState* s;
    GITransition* initt;
    GTransition* t;
    QList<GState*> slist;
    QList<GTransition*> tlist; 
    double xpos, ypos, endx, endy, c1x, c1y, c2x, c2y;
    AppInfo appinfo(qApp->mainWidget());

    domdoc.setContent(prolog);

    if (!m)
      return domdoc;

    root = domdoc.documentElement();

    // Machine

    root.setAttribute("author", "Qfsm");
    root.setAttribute("version", appinfo.getVersion());
    me = domdoc.createElement("machine");
    me.setAttribute("name", m->getName());
    me.setAttribute("version", m->getVersion());
    me.setAttribute("author", m->getAuthor());
    me.setAttribute("description", m->getDescription());
    me.setAttribute("type", m->getType());
    me.setAttribute("nummooreout", m->getNumMooreOutputs());
    me.setAttribute("numbits", m->getNumEncodingBits());
    me.setAttribute("numin", m->getNumInputs());
    me.setAttribute("numout", m->getNumOutputs());
    s = m->getInitialState();
    if (s)
    {
      inits = s->getEncoding();
      me.setAttribute("initialstate", inits);
    }
    me.setAttribute("statefont", m->getSFont().family());
    me.setAttribute("statefontsize", m->getSFont().pointSize());
    me.setAttribute("statefontweight", m->getSFont().weight());
    me.setAttribute("statefontitalic", m->getSFont().italic());
    me.setAttribute("transfont", m->getTFont().family());
    me.setAttribute("transfontsize", m->getTFont().pointSize());
    me.setAttribute("transfontweight", m->getTFont().weight());
    me.setAttribute("transfontitalic", m->getTFont().italic());
    me.setAttribute("arrowtype", m->getArrowType());
    me.setAttribute("draw_it", m->getDrawITrans());
    
    root.appendChild(me);


    // Input/Output names

    onme = domdoc.createElement("outputnames_moore");
    ine = domdoc.createElement("inputnames");
    one = domdoc.createElement("outputnames");
    intext = domdoc.createTextNode(m->getMealyInputNames());
    ontext = domdoc.createTextNode(m->getMealyOutputNames());
    onmtext = domdoc.createTextNode(m->getMooreOutputNames());
    ine.appendChild(intext);
    one.appendChild(ontext);
    onme.appendChild(onmtext);
    me.appendChild(onme);
    me.appendChild(ine);
    me.appendChild(one);


    // Initial Transition

    initt = m->getInitialTransition();
    if (initt)
    {
      initt->getPos(xpos, ypos);
      initt->getEndPos(endx, endy);
      itranse = domdoc.createElement("itransition");
      itranse.setAttribute("xpos", xpos);
      itranse.setAttribute("ypos", ypos);
      itranse.setAttribute("endx", endx);
      itranse.setAttribute("endy", endy);

      me.appendChild(itranse);
    }


    // States
    
    slist = m->getSList();
    QListIterator<GState*> sit(slist);

    for(;sit.hasNext();)
    {
      s = sit.next();
      if (!s->isDeleted() && (!onlyselected || s->isSelected() || (s==obj && s!=NULL)))
      {
	s->getPos(xpos, ypos);
	QDomElement se = domdoc.createElement("state");
	QDomText st = domdoc.createTextNode(s->getStateName());
	
	se.setAttribute("description", s->getDescription());
	se.setAttribute("code", s->getEncoding());
	se.setAttribute("moore_outputs", s->getMooreOutputsStr());
	se.setAttribute("xpos", xpos);
	se.setAttribute("ypos", ypos);
	se.setAttribute("radius", s->getRadius());
	se.setAttribute("pencolor", s->getColor().rgb() & 0xffffff);
	se.setAttribute("linewidth", s->getLineWidth());
	se.setAttribute("finalstate", s->isFinalState());
	se.setAttribute("entry_actions", s->getEntryActions());
	se.setAttribute("exit_actions", s->getExitActions());

	se.appendChild(st);

	me.appendChild(se);
      }
    }


    // Transitions

    sit.toFront();
    for(; sit.hasNext();)
    {
      s = sit.next();
      QListIterator<GTransition*> tit(s->tlist);
      GState *send;

      for(;tit.hasNext();)
      {
        t = tit.next();
        if (!t->isDeleted() && (!onlyselected || t->isSelected() || (t==obj && t!=NULL)))
        {
          t->getPos(xpos, ypos);
          t->getEndPos(endx, endy);
          t->getCPoint1(c1x, c1y);
          t->getCPoint2(c2x, c2y);
          QDomElement te = domdoc.createElement("transition");
	  
            te.setAttribute("type", t->getInfo()->getType());
            te.setAttribute("xpos", xpos);
            te.setAttribute("ypos", ypos);
            te.setAttribute("endx", endx);
            te.setAttribute("endy", endy);
            te.setAttribute("c1x", c1x);
            te.setAttribute("c1y", c1y);
            te.setAttribute("c2x", c2x);
            te.setAttribute("c2y", c2y);
            te.setAttribute("straight", t->isStraight());
            te.setAttribute("description", t->getDescription());
            
            send = (GState*)t->getEnd();
            
            if (!onlyselected || s->isSelected())
            {
            QDomElement from = domdoc.createElement("from");
            QString sfrom;
            sfrom.sprintf("%d", s->getEncoding());
            QDomText fromt = domdoc.createTextNode(sfrom);
            from.appendChild(fromt);
            te.appendChild(from);
            }
            
            if (send && (!onlyselected || send->isSelected()))
            {
            QDomElement to = domdoc.createElement("to");
            QString sto;
            sto.sprintf("%d", send->getEncoding());
            QDomText tot = domdoc.createTextNode(sto);
            to.appendChild(tot);
            te.appendChild(to);
            }

	  QDomElement inpute, outpute;
	  QDomText inputt, outputt;

	  inpute = domdoc.createElement("inputs");
	  inpute.setAttribute("invert", t->getInfo()->getInputInfo()->isInverted());
	  inpute.setAttribute("any", t->getInfo()->getInputInfo()->getAnyInput());
	  inpute.setAttribute("default", t->getInfo()->getInputInfo()->isDefault());
	  outpute = domdoc.createElement("outputs");

	  inputt = domdoc.createTextNode(t->getInfo()->getInputsStr(NULL));
	  outputt = domdoc.createTextNode(t->getInfo()->getOutputsStr(NULL));

	  inpute.appendChild(inputt);
	  outpute.appendChild(outputt);

	  te.appendChild(inpute);
	  te.appendChild(outpute);

	  me.appendChild(te);
	}
      }
    }


    // Phantom State

    s = m->getPhantomState();
    QListIterator<GTransition*> tit(s->tlist);
    GState *send;

    for(;tit.hasNext();)
    {
      t = tit.next();
      if (!t->isDeleted() && (!onlyselected || t->isSelected() || (t==obj && t!=NULL)))
      {
	t->getPos(xpos, ypos);
	t->getEndPos(endx, endy);
	t->getCPoint1(c1x, c1y);
	t->getCPoint2(c2x, c2y);
	QDomElement te = domdoc.createElement("transition");
	
	te.setAttribute("type", t->getInfo()->getType());
	te.setAttribute("xpos", xpos);
	te.setAttribute("ypos", ypos);
	te.setAttribute("endx", endx);
	te.setAttribute("endy", endy);
	te.setAttribute("c1x", c1x);
	te.setAttribute("c1y", c1y);
	te.setAttribute("c2x", c2x);
	te.setAttribute("c2y", c2y);
	te.setAttribute("straight", t->isStraight());

	send = (GState*)t->getEnd();
	if (send && (!onlyselected || send->isSelected()))
	{
	  QDomElement to = domdoc.createElement("to");
	  QString sto;
	  sto.sprintf("%d", send->getEncoding());
	  QDomText tot = domdoc.createTextNode(sto);
	  to.appendChild(tot);
	  te.appendChild(to);
	}

	QDomElement inpute, outpute;
	QDomText inputt, outputt;

	inpute = domdoc.createElement("inputs");
	outpute = domdoc.createElement("outputs");

	inputt = domdoc.createTextNode(t->getInfo()->getInputsStr(NULL));
	outputt = domdoc.createTextNode(t->getInfo()->getOutputsStr(NULL));

	inpute.appendChild(inputt);
	outpute.appendChild(outputt);

	te.appendChild(inpute);
	te.appendChild(outpute);

	me.appendChild(te);
      }
    }

  return domdoc;
}
Exemple #11
0
int PMInsertRuleSystem::canInsert( const PMObject* parentObject,
                                   const QStringList& list,
                                   const PMObject* after )
{
   if( list.size( ) == 1 )
   {
      // more efficient
      if( canInsert( parentObject, list.first( ), after ) )
         return 1;
      else
         return 0;
   }

   // find rules for target class
   QPtrList<PMRuleTargetClass> targetClassList;
   PMMetaObject* meta = parentObject->metaObject( );
   for( ; meta; meta = meta->superClass( ) )
   {
      PMRuleTargetClass* tc = m_rulesDict.find( meta->className( ) );
      if( tc )
         targetClassList.append( tc );
   }
   if( targetClassList.isEmpty( ) )
      return 0; // not rules found

   // count already inserted children
   QPtrListIterator<PMRuleTargetClass> tit( targetClassList );
   for( ; tit.current( ); ++tit ) // ... for all target classes
   {
      QPtrListIterator<PMRule> rit = tit.current( )->rules( );
      for( ; rit.current( ); ++rit ) // ... and all rules
      {
         rit.current( )->reset( );
         bool afterInsertPoint = false;
         PMObject* o = parentObject->firstChild( );
         if( !after )
            afterInsertPoint = true;
         for( ; o; o = o->nextSibling( ) )
         {
            rit.current( )->countChild( o->className( ), afterInsertPoint );
            if( o == after )
               afterInsertPoint = true;
         }
      }
   }

   int number = 0;
   QStringList::const_iterator oit;

   for( oit = list.begin( ); oit != list.end( ); ++oit )
   {
      bool possible = false;
      for( tit.toFirst( ); tit.current( ) && !possible; ++tit )
      {
         QPtrListIterator<PMRule> rit = tit.current( )->rules( );

         for( ; rit.current( ) && !possible; ++rit )
         {
            PMRule* rule = rit.current( );
            if( rule->matches( *oit ) )
               possible = rule->evaluate( parentObject );
         }
      }
      if( possible )
      {
         // object can be inserted, count it
         for( ; tit.current( ); ++tit )
         {
            QPtrListIterator<PMRule> rit = tit.current( )->rules( );
            for( ; rit.current( ); ++rit )
               rit.current( )->countChild( *oit, false );
         }
			number++;
      }
   }

   return number;
}