void OSyntaxHighlighter :: highlightBlock (const QString &qscText )
{
  logical                    term = NO;
  int                        iStart = 0;
  setCurrentBlockState(0);
  if(previousBlockState() > 0) // in block
    FindEndBlock(qscText,iStart,elements[previousBlockState()]);
  
  if(iStart>=0)
    FindElements(qscText,iStart);


}
Ejemplo n.º 2
0
size_t ChannelServer::GetRWChannels (const string& chID, std::vector<RWChannel*>& channels)
{
	CHPath chpath(chID);
	vector<ModelElement*> elements;
	elements.reserve(8);

	FindElements(chpath.eid(),elements);
	if(elements.empty())
	{
		MerlinIO::warning()<<"ChannelServer: No elements matching "<<chpath.eid()<<" found"<<endl;
		return 0;
	}

	set<ChannelCtor*> ctors;
	string etype="";
	int count=0;
	for(vector<ModelElement*>::iterator ei = elements.begin(); ei!=elements.end(); ei++)
	{

		// If we have a new type, get the corresponding constructors
		if(etype!=(*ei)->GetType())
		{
			etype=(*ei)->GetType();
			FindCtors(etype,chpath.key,ctors);
			if(ctors.empty())
			{
				MerlinIO::warning()<<"ChannelServer: No channel constructors for "<<chpath.type<<" found"<<endl;
				break;
			}
		}

		// Now construct the channels
		for(set<ChannelCtor*>::iterator ci = ctors.begin(); ci!=ctors.end(); ci++)
		{
			RWChannel* ch = (*ci)->ConstructRW(*ei);
			assert(ch!=0); // if(ch==0) throw ChannelIsRO(ch->GetID());
			channels.push_back(ch);
			count++;
		}
	}

	return count;
}
Ejemplo n.º 3
0
/**
 * @brief Function used to query the tool for all Elements that were
 * selected in the last interaction
 *
 * Function used to query the tool for all Elements that were
 * selected in the last interaction.
 *
 * @return A vector of pointers to all selected Elements
 */
std::vector<Element*> CircleTool::GetSelectedElements()
{
	FindElements();
	return selectedElements;
}
Ejemplo n.º 4
0
void Plot_survey(Ntuple* nt,unsigned int verbose,double xmin,double xmax,double zmin,double zmax)
{
  // unsigned int verbose=2; // locally increase verbose
  IPpos *ips_b1=new IPpos(nt,verbose); // in Apertures.C
  ips_b1->Print();

  double xip=0,zip=0;

  if(verbose>1) cout << "Plot_survey ips_b1->IPVec.size()=" << ips_b1->IPVec.size() << '\n';

  if(ips_b1->IPVec.size()>0)
  {
	unsigned int IP=1;
    unsigned int IPind=ips_b1->ind(IP);
    xip=ips_b1->x[IPind];
    zip=ips_b1->z[IPind];
    cout << "ips_b1->ind(IP)=" << IPind
    << " xip=" << xip
    << " zip=" << zip
    << '\n';
  }


  if(xmin==0 && xmax==0 && zmin==0 && zmax==00)
  { // all limites zero,  plot the full ring
    xmin=1.1*nt->Min("X_2");
    xmax=1.1*nt->Max("X_2");
    zmin=1.1*nt->Min("Z");
    zmax=1.1*nt->Max("Z");
  }
  else // plot around IP with limits given
  {
    xmin=xip+xmin;
	xmax=xip+xmax;
	zmin=zip+zmin;
	zmax=zip+zmax;
    cout << " zmin=" << zmin << " zmax=" << zmax << '\n';
    cout << " xmin=" << xmin << " xmax=" << xmax << '\n';
  }


  Apertures* RING_aper_b1 = new Apertures(nt,verbose);
  Apertures* RING_aper_b2 = new Apertures(nt,verbose); // for the moment identical

  // RING_aper_b1->Print(); // show non zero apertures
  RING_aper_b1->PlotFrame(zmin,zmax,xmin,xmax); // plot frame and keep limits in Apertures class

  if(RING_aper_b1->zvec.size()==0) // no aperture info
  {
	cout << " no aperture info, just plot beam" << '\n';
	valarray<double> z_beam  =nt->GetVar("Z");
	valarray<double> x_2_beam=nt->GetVar("X_2");
	MyBeamGraph(z_beam.size(),kBlue,z_beam,x_2_beam);
  }
  else MyApertureGraph(RING_aper_b1->zvec.size(),kBlue,RING_aper_b1->zvec,RING_aper_b2->x_2_vec,RING_aper_b2->aper_1_vec); // myGraph.C

  vector<unsigned int> i_IP_List  =FindElements(*nt,"IP" ,verbose,"NAME",0);  // IPs, name starting with IP      FindElements in Twiss_util.C
  vector<unsigned int> i_Bend_List=FindElements(*nt,"B"  ,verbose,"NAME",0);  // Bends
  vector<unsigned int> i_Quad_List=FindElements(*nt,"Q"  ,verbose,"NAME",0);  // Quads
  vector<unsigned int> i_Cav_List =FindElements(*nt,"CAV" ,verbose,"NAME",0); // Cavities

  vector<unsigned int> i_all;
  i_all.reserve( i_IP_List.size()+ i_Bend_List.size()+ i_Quad_List.size()+ i_Cav_List.size());
  i_all.insert( i_all.end(), i_IP_List.begin(),   i_IP_List.end() );
  i_all.insert( i_all.end(), i_Bend_List.begin(), i_Bend_List.end() );
  i_all.insert( i_all.end(), i_Quad_List.begin(), i_Quad_List.end() );
  i_all.insert( i_all.end(), i_Cav_List.begin(),  i_Cav_List.end() );

  PlotNames(nt,i_all,xmax,verbose); // Plot.C

  if(verbose) // write filename, date on plot
  {
	cout << __FILE__<< " " << __FUNCTION__ << " line " << setw(4) << __LINE__ << " verbose=" << verbose << " write extra info on the plot  nt->GetFname()=" << nt->GetFname() << '\n';

    TText* tt0=new TText(); tt0->SetTextFont(kTimes); tt0->SetTextSize(k8pt);
    string DirName=nt->GetFname();
    tt0->SetTextAlign(12); // left adjusted and vertically centered
    tt0->DrawTextNDC(.05,.98,DirName.c_str());

	gStyle->SetOptDate(23); // datefl=23 top right, date + time, use 0 to turn off use datefl=0
	gStyle->GetAttDate()->SetTextSize(k12pt); gStyle->GetAttDate()->SetTextFont(kTimes);
  }

  TCanvas* c2=RING_aper_b1->GetCanvas();
  c2->SaveAs("/tmp/$LOGNAME/ring_o_s.eps");
}