示例#1
0
void NRLib::ReadIrapClassicAsciiSurf(const std::string & filename,
                                     RegularSurface<A> & surface,
                                     double            & angle)
{
    std::ifstream file;
    OpenRead(file, filename);

    int line = 0;
    // Header
    try {
        ReadNext<int>(file, line);   // -996
        int nj       = ReadNext<int>(file, line);
        double dx    = ReadNext<double>(file, line);
        double dy    = ReadNext<double>(file, line);
        // ----------- line shift --------------
        double x_min = ReadNext<double>(file, line);
        double x_max = ReadNext<double>(file, line);
        double y_min = ReadNext<double>(file, line);
        double y_max = ReadNext<double>(file, line);
        // ----------- line shift --------------
        int ni       = ReadNext<int>(file, line);
        angle        = ReadNext<double>(file, line);
        angle        = NRLib::Degree*angle;
        ReadNext<double>(file, line); // rotation origin - x
        ReadNext<double>(file, line); // rotation origin - y
        // ----------- line shift --------------
        ReadNext<int>(file, line);
        ReadNext<int>(file, line);
        ReadNext<int>(file, line);
        ReadNext<int>(file, line);
        ReadNext<int>(file, line);
        ReadNext<int>(file, line);
        ReadNext<int>(file, line);
        //double lx = (ni-1)*dx;
        //double ly = (nj-1)*dy;
        double lx = (x_max - x_min)*cos(angle);
        double ly = (y_max - y_min)*cos(angle);


        if (!NRLibPrivate::Equal(lx/(ni-1), dx)) {
            std::string text = "Inconsistent data in file. dx != lx/(nx-1).\n";
            text += "dx        = "+NRLib::ToString(dx,2)+"\n";
            text += "lx        = "+NRLib::ToString(lx,2)+"\n";
            text += "nx        = "+NRLib::ToString(ni,0)+"\n";
            text += "lx/(nx-1) = "+NRLib::ToString(lx/(ni - 1),2);
            throw FileFormatError(text);
        }
        if (!NRLibPrivate::Equal(ly/(nj-1), dy)) {
            std::string text = "Inconsistent data in file. dy != ly/(ny-1).\n";
            text += "dy        = "+NRLib::ToString(dy,2)+"\n";
            text += "ly        = "+NRLib::ToString(ly,2)+"\n";
            text += "ny        = "+NRLib::ToString(nj,0)+"\n";
            text += "ly/(ny-1) = "+NRLib::ToString(ly/(nj - 1),2);
            throw FileFormatError(text);
        }


        surface.Resize(ni, nj);
        surface.SetDimensions(x_min, y_min, lx, ly);

        ReadAsciiArrayFast(file, surface.begin(), surface.GetN());

        surface.SetMissingValue(static_cast<A>(IRAP_MISSING));

        surface.SetName(GetStem(filename));

        if (!CheckEndOfFile(file)) {
            throw FileFormatError("File too long.");
        }
    }
    catch (EndOfFile& ) {
        throw FileFormatError("Unexcpected end of file found while parsing "
                              " \"" + filename + "\"");
    }
    catch (Exception& e) {
        throw FileFormatError("Error parsing \"" + filename + "\" as a "
                              "IRAP ASCII surface file at line " + ToString(line) + ":" + e.what() + "\n");
    }
}
示例#2
0
/*
========================
idSWFScriptVar::AbstractEquals
========================
*/
bool idSWFScriptVar::AbstractEquals( const idSWFScriptVar& other )
{
	if( type == other.type )
	{
		switch( type )
		{
			case SWF_VAR_STRINGID:
				return ( value.i == other.value.i );
			case SWF_VAR_STRING:
				return ( *value.string == *other.value.string );
			case SWF_VAR_FLOAT:
				return ( value.f == other.value.f );
			case SWF_VAR_BOOL:
				return ( value.b == other.value.b );
			case SWF_VAR_INTEGER:
				return ( value.i == other.value.i );
			case SWF_VAR_NULL:
				return true;
			case SWF_VAR_UNDEF:
				return true;
			case SWF_VAR_OBJECT:
				return ( value.object == other.value.object );
			case SWF_VAR_FUNCTION:
				return ( value.function == other.value.function );
			default:
				assert( false );
				return false;
		}
	}
	switch( type )
	{
		case SWF_VAR_STRINGID:
			return ToString() == other.ToString();
		case SWF_VAR_STRING:
			switch( other.type )
			{
				case SWF_VAR_STRINGID:
					return *value.string == other.ToString();
				case SWF_VAR_FLOAT:
					return ToFloat() == other.value.f;
				case SWF_VAR_BOOL:
					return ToBool() == other.value.b;
				case SWF_VAR_INTEGER:
					return ToInteger() == other.value.i;
				case SWF_VAR_OBJECT:
					return *value.string == other.ToString();
				default:
					return false;
			}
		case SWF_VAR_FLOAT:
			return ( other.ToFloat() == value.f );
		case SWF_VAR_BOOL:
			return ( other.ToBool() == value.b );
		case SWF_VAR_INTEGER:
			return ( other.ToInteger() == value.i );
		case SWF_VAR_NULL:
			return ( other.type == SWF_VAR_UNDEF );
		case SWF_VAR_UNDEF:
			return ( other.type == SWF_VAR_NULL );
		case SWF_VAR_OBJECT:
			switch( other.type )
			{
				case SWF_VAR_STRING:
					return ToString() == *other.value.string;
				case SWF_VAR_FLOAT:
					return ToFloat() == other.value.f;
				case SWF_VAR_BOOL:
					return ToBool() == other.value.b;
				case SWF_VAR_INTEGER:
					return ToInteger() == other.value.i;
				default:
					return false;
			}
		case SWF_VAR_FUNCTION:
			return false;
		default:
			assert( false );
			return false;
	}
}
示例#3
0
BOOL
CNdasLogicalDevice::Recover()
{
	BOOL fSuccess(FALSE);

	ximeta::CAutoLock autolock(this);

	DBGPRT_INFO(_FT("Recovering %s\n"), ToString());

	switch(GetType())
	{
	case NDAS_LOGICALDEVICE_TYPE_DISK_RAID1:
	case NDAS_LOGICALDEVICE_TYPE_DISK_RAID4:
		break;
	default:
		return FALSE;
	}

	if (m_status == NDAS_LOGICALDEVICE_STATUS_NOT_INITIALIZED) {
		::SetLastError(NDASHLPSVC_ERROR_NDAS_LOGICALDEVICE_NOT_INITIALIZED);
		return FALSE;
	}

	if (m_status != NDAS_LOGICALDEVICE_STATUS_MOUNTED) 
	{
		::SetLastError(NDASHLPSVC_ERROR_NDAS_LOGICALDEVICE_NOT_MOUNTED);
		return FALSE;
	}

	// Do not recover if any NDAS unit device is not alive
	DWORD ldSequence = 0;
	for(ldSequence = 0; ldSequence < m_logicalDeviceGroup.nUnitDevices; ldSequence++)
	{
		if(NDAS_UNITDEVICE_STATUS_MOUNTED != m_pUnitDevices[ldSequence]->GetStatus())
		{
			::SetLastError(NDASHLPSVC_ERROR_NDAS_UNITDEVICE_NOT_MOUNTED);
			return FALSE;
		}
	}

	if(IsAnyUnitDevicesFault())
	{
		::SetLastError(NDASHLPSVC_ERROR_NDAS_UNITDEVICE_NOT_MOUNTED);
		return FALSE;
	}

	ULONG ulStatus;

	fSuccess = ::LsBusCtlQueryStatus(		
		m_NdasScsiLocation.SlotNo,
		&ulStatus);

	if (!fSuccess) {
		DBGPRT_ERR_EX(_FT("Unable to get status"));
		return FALSE;
	}

	// Do not recover if NDAS logical device is not under emergency
	// Do not recover if NDAS logical device is already recovering
	if(!ADAPTERINFO_ISSTATUSFLAG(ulStatus, ADAPTERINFO_STATUSFLAG_MEMBER_FAULT))
	{
		DBGPRT_ERR_EX(_FT("Not in emergency mode or already recovering"));
		return FALSE;
	}


	//
	// LsBusCtl is overhauled only to use SlotNo for RemoveTargetData
	//

	//
	// Remove target ejects the disk and the volume.
	//

	fSuccess = LsBusCtlRecoverTarget(m_NdasScsiLocation.SlotNo);
	if (!fSuccess) {
		DBGPRT_WARN_EX(_FT("LsBusCtlRemoveTarget failed: "));
	}

	DBGPRT_INFO(_FT("Started recovering successfully at slot %s.\n"),
		CNdasScsiLocation(m_NdasScsiLocation).ToString());

	return TRUE;

}
示例#4
0
char *Transform3::ToLeakyString()
{
  char *buffer = new char[256];
  return ToString(buffer);
}
示例#5
0
void TimedEventEditorDlg::OnokBtClick(wxCommandEvent& event)
{
    eventEdited.SetTimeoutExpression(ToString(timeoutEdit->GetValue()));
    eventEdited.SetName(ToString(nameEdit->GetValue()));
    EndModal(1);
}
示例#6
0
	/*!
	* \brief Converts this to Nz::String
	* \return The string representation of the stream
	*/
	StringStream::operator String() const
	{
		return ToString();
	}
示例#7
0
	void EmitFromEvents::OnAlias(const Mark&, anchor_t anchor)
	{
		BeginNode();
		m_emitter << Alias(ToString(anchor));
	}
示例#8
0
文件: kFSR.C 项目: karavdin/BaconJets
void kFSR(){

  gStyle->SetOptFit();

  // input DATA file
  TFile* datafile = new TFile("/nfs/dust/cms/user/mstoev/sFrame_new/JEC/run2_output/25ns_0909/uhh2.AnalysisModuleRunner.DATA.DATA_25ns_DConly_MCcorrected_v2.root","READ"); 
  // input MC file
  TFile* MCfile = new TFile("/nfs/dust/cms/user/mstoev/sFrame_new/JEC/run2_output/25ns_0909/uhh2.AnalysisModuleRunner.MC.MC_QCDpt15to7000_13TeV_25ns_MCcorrV2.root","READ");
  
  /*
  // input DATA file
  TFile* datafile = new TFile("/nfs/dust/cms/user/mstoev/sFrame_new/JEC/run2_output/40pb/uhh2.AnalysisModuleRunner.DATA.DATA_golden_JSON_40pb_morebins.root","READ"); 
  // input MC file
  TFile* MCfile = new TFile("/nfs/dust/cms/user/mstoev/sFrame_new/JEC/run2_output/40pb/uhh2.AnalysisModuleRunner.MC.QCD_Pt15to7000_morebins.root","READ");
  */


  //TFile* datafile = new TFile("/nfs/dust/cms/user/kovalch/sFrame/JEC/uhh2.AnalysisModuleRunner.DATA.data_with_golden_jsondata_13TeV_40pb_all_data_l1.root","READ"); 

  // input DATA file
  //TFile* datafile = new TFile("/nfs/dust/cms/user/kovalch/sFrame/JEC/uhh2.AnalysisModuleRunner.DATA.data_with_golden_jsondata_13TeV_40pb_all_data.root","READ"); 
  // input MC file
  //TFile* MCfile = new TFile("/nfs/dust/cms/user/kovalch/sFrame/JEC/uhh2.AnalysisModuleRunner.MC.JetResolutionSmearerrun2_QCD_JER_smearing.root","READ");

  //no weight
  //TFile* MCfile = new TFile("/nfs/dust/cms/user/kovalch/sFrame/JEC/uhh2.AnalysisModuleRunner.MC.JetResolutionSmearerrun2_QCD_no_weight.root","READ");
  //low pu reweighting
  //TFile* MCfile = new TFile("/nfs/dust/cms/user/kovalch/sFrame/JEC/uhh2.AnalysisModuleRunner.MC.JetResolutionSmearerrun2_QCD_PU_rew.root","READ");


  // choose mpf or dijet balance
  bool mpfMethod(false);


  // define number of bins
  const int n_alpha = 5;
  const int n_eta = 16;

  // define the bin ranges
  TString alpha_range[n_alpha-1] = {"a01", "a02", "a03", "a04"};
  double alpha_bins[n_alpha] = {0.000, 0.100, 0.200, 0.300, 0.400};
  /*
  double eta_bins[n_eta] = {0.000, 0.250, 0.500, 0.750, 1.000, 1.300, 1.600, 1.900, 2.200, 2.500, 2.700, 2.850, 3.000, 3.200, 5.000};
  TString eta_range[n_eta] = {"0.000", "0.250", "0.500", "0.750", "1.000", "1.300", "1.600", "1.900", "2.200", "2.500", "2.700", "2.850", "3.000", "3.200","5.000"};
  TString eta_range2[n_eta] = {"00", "025", "05", "0750", "10", "13", "16", "19", "22", "25", "27", "285", "30", "32", "50"};
  TString eta_range3[n_eta] = {"0.0", "0.25", "0.5", "0.750", "1.0", "1.3", "1.6", "1.9", "2.2", "2.5", "2.7", "2.85", "3.0", "3.2", "5.0"};
  */
  /*
  double eta_bins[n_eta] = {0.000, 0.250, 0.500, 0.750, 1.000, 1.300, 1.600, 1.900, 2.200, 2.500, 2.700, 3.000, 3.200, 5.000};
  TString eta_range[n_eta] = {"0.000", "0.250", "0.500", "0.750", "1.000", "1.300", "1.600", "1.900", "2.200", "2.500", "2.700", "3.000", "3.200","5.000"};
  TString eta_range2[n_eta] = {"00", "025", "05", "0750", "10", "13", "16", "19", "22", "25", "27", "30", "32", "50"};
  TString eta_range3[n_eta] = {"0.0", "0.25", "0.5", "0.750", "1.0", "1.3", "1.6", "1.9", "2.2", "2.5", "2.7", "3.0", "3.2", "5.0"};
  */
  /*
  double eta_bins[n_eta] = {0, 0.261, 0.522, 0.783, 1.044, 1.305, 1.653, 1.93, 2.172, 2.5, 2.853, 2.964, 3.139, 5.191};
  TString eta_range[n_eta] = {"0.000", "0.261", "0.522", "0.783", "1.044", "1.305", "1.653", "1.930", "2.172", "2.500", "2.853", "2.964", "3.139", "5.191"};
  TString eta_range2[n_eta] = {"00", "0261", "0522", "0783", "1044", "1305", "1653", "193", "2172", "25", "2853", "2964", "3139",  "5191"};
  TString eta_range3[n_eta] = {"0.0", "0.261", "0.522", "0.783", "1.044", "1.305", "1.653", "1.93", "2.172", "2.5", "2.853", "2.964", "3.139", "5.191"};
  */
  double eta_bins[n_eta] = {0, 0.261, 0.522, 0.783, 1.044, 1.305, 1.653, 1.93, 2.172, 2.322, 2.5, 2.65, 2.853, 2.964, 3.139, 5.191};
  TString eta_range[n_eta] = {"0.000", "0.261", "0.522", "0.783", "1.044", "1.305", "1.653", "1.930", "2.172", "2.322", "2.500", "2.650", "2.853", "2.964", "3.139", "5.191"};
  TString eta_range2[n_eta] = {"00", "0261", "0522", "0783", "1044", "1305", "1653", "193", "2172", "2322", "25", "2650", "2853", "2964", "3139",  "5191"};
  TString eta_range3[n_eta] = {"0.0", "0.261", "0.522", "0.783", "1.044", "1.305", "1.653", "1.93", "2.172", "2.322", "2.5", "2.65", "2.853", "2.964", "3.139", "5.191"};
 


  // get the histos 
  TH1D* data[n_alpha-1][n_eta-1];
  TH1D* mc[n_alpha-1][n_eta-1];

 

  for(int i=0; i<n_alpha-1; i++){
    for(int j=0; j<n_eta-1; j++){
      if(mpfMethod){
	data[i][j] = (TH1D*)datafile->Get(alpha_range[i]+"/eta_"+eta_range[j]+"_"+eta_range[j+1]+"/mpf");
	mc[i][j] = (TH1D*)MCfile->Get(alpha_range[i]+"/eta_"+eta_range[j]+"_"+eta_range[j+1]+"/mpf");
      }
      else{
	data[i][j] = (TH1D*)datafile->Get(alpha_range[i]+"/eta_"+eta_range[j]+"_"+eta_range[j+1]+"/r_rel");
	mc[i][j] = (TH1D*)MCfile->Get(alpha_range[i]+"/eta_"+eta_range[j]+"_"+eta_range[j+1]+"/r_rel");
      }
    }
  }

 


  // create the ratio histograms
  TH1D* ratio[n_eta-1];
  //TF1* fit_func[n_eta-1];
  for (int j=0; j<n_eta-1; j++){
    TString numstr=ToString(j);
    TString histoname="histo"+numstr;
    ratio[j] = new TH1D(histoname,histoname,n_alpha-1,alpha_bins);
  }


  // fill ratio histograms
  for(int j=0; j<n_eta-1; j++){
    for(int i=0; i<n_alpha-1; i++){
      ratio[j]->SetBinContent(i+1, (mc[i][j]->GetMean() / data[i][j]->GetMean()) / (mc[1][j]->GetMean() / data[1][j]->GetMean()) );
      //ratio[j]->SetBinError(i+1, 1/sqrt(data[i][j]->Integral()));
      ratio[j]->SetBinError(i+1, sqrt( pow(data[i][j]->GetRMS(),2)/data[i][j]->Integral()));// + pow(mc[i][j]->GetRMS(),2)/mc[i][j]->Integral() ) );
      //ratio[j]->SetBinError(i+1, sqrt( pow(data[i][j]->GetRMS(),2)/data[i][j]->Integral() + pow(mc[i][j]->GetRMS(),2)/mc[i][j]->Integral() ) );
    }
  }


  // create and fill tgrapherrors
  double xbin_tgraph[n_alpha-1] = {0.1,0.2,0.3,0.4};
  double zero[n_alpha-1] = {0, 0, 0, 0};
  TGraphErrors *graph1[n_eta-1];

  double content[n_alpha-1];
  double error[n_alpha-1];
  double content_dijet[n_alpha-1];
  double error_dijet[n_alpha-1];
  for(int j=0; j<n_eta-1; j++){
    for(int i=0; i<n_alpha-1; i++){
      content[i] = (ratio[j]->GetBinContent(i+1));
      error[i] = (ratio[j]->GetBinError(i+1));
    }
    graph1[j] = new TGraphErrors(n_alpha-1, xbin_tgraph, content , zero, error);
  }



  // create horizontal line for plotting ("ideal value")
  TLine *line = new TLine(0.,1,0.45,1);

 
  // create output .dat file, including the kFSR extrapolation (alpha->0)
  if(mpfMethod){
    FILE *fp = fopen("KFSR_MPF_extrapolation.dat","w");
    TH1D* kFSR_MPF = new TH1D("kfsr_mpf","kfsr_mpf", n_eta-1,eta_bins);
  }
  else{
    FILE *fp = fopen("KFSR_DiJet_extrapolation.dat","w");
    TH1D* kFSR_DiJet = new TH1D("kfsr_dijet","kfsr_dijet", n_eta-1,eta_bins);
  }

  TH1D* plotkfsr = new TH1D("kfsr","kfsr", n_eta-1,eta_bins);


  //create plots
  TCanvas* a[n_eta-1];
  for (int j=0; j<n_eta-1; j++){
    TString numstr=ToString(j);
    TString plotname="eta_"+eta_range[j]+"_"+eta_range[j+1];
    a[j] = new TCanvas(plotname, plotname, 800,600);
    gStyle->SetOptTitle(0);
    graph1[j]->SetMarkerColor(kBlue);
    graph1[j]->SetMarkerStyle(20);
    graph1[j]->SetLineColor(kBlue);
    graph1[j]->Draw("AP");
    graph1[j]->Fit("pol1","R");
    graph1[j]->GetXaxis()->SetTitle("#alpha");
    graph1[j]->GetXaxis()->SetTitleSize(0.05);
    //graph1[j]->GetYaxis()->SetTitle("kFSR");
    graph1[j]->GetXaxis()->SetLimits(0.,0.45);
    graph1[j]->GetYaxis()->SetRangeUser(0.90,1.10);
    line->SetLineStyle(2);
    line->Draw("SAME");
    // fill the output.dat file
    if (fp!=NULL) {
      Float_t value = pol1->GetParameter(0);
      Float_t uncert = pol1->GetParError(0);
      fprintf(fp, "%f %f\n",value,uncert);
    }
    plotkfsr->SetBinContent(j+1,pol1->GetParameter(0));
    plotkfsr->SetBinError(j+1,pol1->GetParError(0));
    if(mpfMethod){
      kFSR_MPF->SetBinContent(j+1,pol1->GetParameter(0));
      kFSR_MPF->SetBinError(j+1,pol1->GetParError(0));
    }
    else{
      kFSR_DiJet->SetBinContent(j+1,pol1->GetParameter(0));
      kFSR_DiJet->SetBinError(j+1,pol1->GetParError(0));
    }
    TLegend *leg1;
    leg1 = new TLegend(0.15,0.65,0.60,0.85,"","brNDC");//x+0.1
    leg1->SetBorderSize(0);
    leg1->SetTextSize(0.045);
    leg1->SetFillColor(10);
    leg1->SetLineColor(1);
    leg1->SetTextFont(42);
    if(mpfMethod){
      leg1->SetHeader("MPF, "+eta_range3[j]+"#leq|#eta|<"+eta_range3[j+1]);
    }
    else{
      leg1->SetHeader("dijet balance, "+eta_range3[j]+"#leq|#eta|<"+eta_range3[j+1]);
    }
    leg1->AddEntry(graph1[j], "R(MC)/R(DATA)","P");
    leg1->AddEntry(pol1, "linear fit","L");
    leg1->Draw();
    //save the plots
    if(mpfMethod){
      //a[j]->Print("morebins_kFSR_MPF_eta_"+eta_range2[j]+"_"+eta_range2[j+1]+".pdf");
    }
    else{
      //a[j]->Print("morebins_kFSR_DiJet_eta_"+eta_range2[j]+"_"+eta_range2[j+1]+".pdf");
    }

  }
  fclose(fp);


  // create output file including the kFSR plot
  if(mpfMethod){
    TFile* outputfile = new TFile("/nfs/dust/cms/user/mstoev/sFrame_new/JEC/run2_output/25ns_0909/Histo_KFSR_MPF_L1.root","RECREATE");
    kFSR_MPF->Write();
    outputfile->Write();
    outputfile->Close();
  }
  else{
    TFile* outputfile = new TFile("/nfs/dust/cms/user/mstoev/sFrame_new/JEC/run2_output/25ns_0909/Histo_KFSR_DiJet_L1.root","RECREATE");
    kFSR_DiJet->Write();
    outputfile->Write();
    outputfile->Close();
  }


}
示例#9
0
    void Mapper::Export(const std::string &file)
    {
        InputModuleOIS::LogInfo("Exporting default input mappings to file " + file + "...");

        std::fstream file_op(file.c_str(), std::ios::out);

        Poco::XML::XMLWriter writer(file_op, Poco::XML::XMLWriter::CANONICAL);
	    writer.startDocument();
	    writer.startElement("", "", "input");

        {
            const InputModuleOIS::KeyEventInfoMap &events = module_->GetRegisteredKeyEvents();
            for ( InputModuleOIS::KeyEventInfoMap::const_iterator state = events.begin() ; 
                  state != events.end() ;
                  ++state )
            {
                for ( InputModuleOIS::KeyEventInfoVector::const_iterator info = state->second.begin() ; 
                  info != state->second.end() ;
                  ++info )
                {
                    Poco::XML::AttributesImpl attrs;
                    attrs.addAttribute("", "", "state", "CDATA", ToString(static_cast<int>(state->first)));
                    attrs.addAttribute("", "", "start_event", "CDATA", ToString(info->pressed_event_id_));
                    attrs.addAttribute("", "", "end_event", "CDATA", ToString(info->released_event_id_));
	                attrs.addAttribute("", "", "modifier", "CDATA", ToString(info->modifier_));
                    attrs.addAttribute("", "", "key", "CDATA", ToString(info->key_));
	                writer.emptyElement("", "", "action", attrs);
                }
            }
        }

        {
            const InputModuleOIS::SliderInfoMap &events = module_->GetRegisteredSliderEvents();
            for ( InputModuleOIS::SliderInfoMap::const_iterator state = events.begin() ; 
                  state != events.end() ;
                  ++state )
            {
                for ( InputModuleOIS::SliderInfoVector::const_iterator info = state->second.begin() ; 
                      info != state->second.end() ;
                      ++info )
                {
                    Poco::XML::AttributesImpl attrs;
                    attrs.addAttribute("", "", "state", "CDATA", ToString(static_cast<int>(state->first)));
                    attrs.addAttribute("", "", "start_event", "CDATA", ToString(info->dragged_event_));
                    attrs.addAttribute("", "", "end_event", "CDATA", ToString(info->stopped_event_));
	                attrs.addAttribute("", "", "modifier", "CDATA", ToString(info->modifier_));
                    attrs.addAttribute("", "", "button", "CDATA", ToString(info->button_));
                    attrs.addAttribute("", "", "type", "CDATA", ToString(info->slider_));
	                writer.emptyElement("", "", "action_slider", attrs);
                }
            }
        }
        writer.endElement("", "", "input");
	    writer.endDocument();
    }
示例#10
0
bool CTaskFileHelper::Save(const TCHAR* szFileName) {
    if (!WayPointList) return false; // this should never happen, but just to be safe...

    CScopeLock LockTask(LockTaskData, UnlockTaskData);
    StartupStore(_T(". SaveTask : saving <%s>%s"), szFileName, NEWLINE);

    ///////////////////////////////////////////////////////////////
    // TODO : this code is temporary before rewriting task system
    if (AATEnabled || DoOptimizeRoute()) {
        for (unsigned i = 0; ValidTaskPoint(i); ++i) {
            int type = -1;
            if (i == 0) { // Start
                Task[0].AATCircleRadius = StartRadius;
                Task[0].AATSectorRadius = StartRadius;
                Task[0].OutCircle = !PGStartOut;
                type = StartLine;
            } else if (!ValidTaskPoint(i + 1)) { //Finish
                Task[i].AATCircleRadius = FinishRadius;
                Task[i].AATSectorRadius = FinishRadius;
                type = FinishLine;
            }
            if (type != -1) {
                switch (type) {
                    case 0: //circle
                        Task[i].AATType = CIRCLE;
                        break;
                    case 1: //line
                        Task[i].AATType = LINE;
                        break;
                    case 2: //sector
                        Task[i].AATType = SECTOR;
                        break;
                }
            }
        }
    }
    ///////////////////////////////////////////////////////////////


    XMLNode topNode = XMLNode::createXMLTopNode();
    XMLNode rootNode = topNode.AddChild(ToString(_T("lk-task")), false);

    if (!SaveOption(rootNode)) {
        return false;
    }

    if (!SaveTaskPointList(rootNode.AddChild(ToString(_T("taskpoints")), false))) {
        return false;
    }
    if (EnableMultipleStartPoints && ValidStartPoint(0)) {
        if (!SaveStartPointList(rootNode.AddChild(ToString(_T("startpoints")), false))) {
            return false;
        }
    }
    if (!SaveWayPointList(rootNode.AddChild(ToString(_T("waypoints")), false))) {
        return false;
    }

    int ContentSize = 0;
    LPCTSTR szContent = topNode.createXMLString(1, &ContentSize);
    Utf8File file;
    if (!file.Open(szFileName, Utf8File::io_create)) {
        return false;
    }

    file.WriteLn(szContent);
    file.Close();

    return true;
}
示例#11
0
bool CTaskFileHelper::SaveOptionDefault(XMLNode node) {
    if (!node) {
        return false;
    }

    XMLNode nodeStart = node.AddChild(ToString(_T("start")), false);
    if (nodeStart) {
        switch (StartLine) {
            case 0: //circle
                SetAttribute(nodeStart, _T("type"), _T("circle"));
                break;
            case 1: //line
                SetAttribute(nodeStart, _T("type"), _T("line"));
                break;
            case 2: //sector
                SetAttribute(nodeStart, _T("type"), _T("sector"));
                break;
        }
        SetAttribute(nodeStart, _T("radius"), StartRadius);
    } else {
        return false;
    }

    XMLNode nodeFinish = node.AddChild(ToString(_T("finish")), false);
    if (nodeFinish) {
        switch (FinishLine) {
            case 0: //circle
                SetAttribute(nodeFinish, _T("type"), _T("circle"));
                break;
            case 1: //line
                SetAttribute(nodeFinish, _T("type"), _T("line"));
                break;
            case 2: //sector
                SetAttribute(nodeFinish, _T("type"), _T("sector"));
                break;
        }
        SetAttribute(nodeFinish, _T("Radius"), FinishRadius);
    } else {
        return false;
    }

    XMLNode nodeSector = node.AddChild(ToString(_T("sector")), false);
    if (nodeSector) {
        switch (SectorType) {
            case 0: //circle
                SetAttribute(nodeSector, _T("type"), _T("circle"));
                SetAttribute(nodeSector, _T("Radius"), SectorRadius);
                break;
            case 1: //sector
                SetAttribute(nodeSector, _T("type"), _T("sector"));
                SetAttribute(nodeSector, _T("Radius"), SectorRadius);
                break;
            case 2: //DAe
                SetAttribute(nodeSector, _T("type"), _T("DAe"));
                break;
        }
    } else {
        return false;
    }

    return true;
}
示例#12
0
String StringBuilder::ToString()
{
   String str;
   ToString(&str);
   return str;
}
示例#13
0
void CCommonParm::AnalizeParameter(const TStringBuf& name, const TStringBuf& value) {
    Stroka paramName = ToString(StripString(name));
    Stroka paramValue = ToString(StripString(value));

    paramName.to_lower();
}
	FlexGridSizer3 = new wxFlexGridSizer(0, 2, 0, 0);

	okBt = new wxButton(this, ID_BUTTON1, _("Ok"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));

	FlexGridSizer3->Add(okBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
示例#15
0
//////////////////////////////////////////////////////////
//
// BeginD3DStuff
//
// Look all busy and important in case any graphic drivers are looking
//
//////////////////////////////////////////////////////////
void BeginD3DStuff( void )
{
    pD3D9 = Direct3DCreate9( D3D_SDK_VERSION );

    if ( !pD3D9 )
    {
        WriteDebugEvent( "D3DStuff - Direct3DCreate9 failed" );
        return;
    }

    WriteDebugEvent( "D3DStuff -------------------------" );
    WriteDebugEvent( SString( "D3DStuff - Direct3DCreate9: 0x%08x", pD3D9 ) );

    // Get info about each connected adapter
    uint uiNumAdapters = pD3D9->GetAdapterCount();
    WriteDebugEvent( SString( "D3DStuff - %d Adapters", uiNumAdapters ) );

    for ( uint i = 0 ; i < uiNumAdapters ; i++ )
    {
        D3DADAPTER_IDENTIFIER9 Identifier;
        D3DDISPLAYMODE DisplayMode;
        D3DCAPS9 Caps9;

        HRESULT hr1 = pD3D9->GetAdapterIdentifier( i, 0, &Identifier );
        HRESULT hr2 = pD3D9->GetAdapterDisplayMode( i, &DisplayMode );
        HRESULT hr3 = pD3D9->GetDeviceCaps( i, D3DDEVTYPE_HAL, &Caps9 );
        UINT ModeCount = pD3D9->GetAdapterModeCount( i, D3DFMT_X8R8G8B8 );
        HMONITOR hMonitor = pD3D9->GetAdapterMonitor( i );

        if ( FAILED( hr1 ) || FAILED( hr2 ) || FAILED( hr3 ) )
        {
            WriteDebugEvent( SString( "D3DStuff %d Failed GetAdapterIdentifier(%x) GetAdapterDisplayMode(%x) GetDeviceCaps(%x) ", i, hr1, hr2, hr3 ) );
            continue;
        }

        // Detect Optimus combo
        if ( SStringX( Identifier.Driver ).BeginsWithI( "nv" )
            && SStringX( Identifier.Description ).BeginsWithI( "Intel" )
            )
        {
            bDetectedOptimus = true;
            WriteDebugEvent( SString( "D3DStuff %d - Detected Optimus Combo", i ) );
        }
        if ( GetModuleHandle( "nvd3d9wrap.dll" ) != NULL )
        {
            bDetectedOptimus = true;
            WriteDebugEvent( SString( "D3DStuff %d - Detected nvd3d9wrap", i ) );
        }

        WriteDebugEvent( SString( "D3DStuff %d Identifier - %s", i, *ToString( Identifier ) ) );
        WriteDebugEvent( SString( "D3DStuff %d DisplayMode - %s", i, *ToString( DisplayMode ) ) );
        WriteDebugEvent( SString( "D3DStuff %d  hMonitor:0x%08x  ModeCount:%d", i, hMonitor, ModeCount ) );
        WriteDebugEvent( SString( "D3DStuff %d Caps9 - %s ", i, *ToString( Caps9 ) ) );
    }

    if ( GetApplicationSettingInt( "nvhacks", "optimus-force-detection" ) )
        bDetectedOptimus = true;

    SetApplicationSettingInt( "nvhacks", "optimus", bDetectedOptimus );

    if ( bDetectedOptimus )
    {
        ShowOptimusDialog ( g_hInstance );
        HideOptimusDialog ();
    }
    else
    {
        SetApplicationSettingInt( "nvhacks", "optimus-alt-startup", 0 );
        SetApplicationSettingInt( "nvhacks", "optimus-rename-exe", 0 );
        SetApplicationSettingInt( "nvhacks", "optimus-export-enablement", 0 );
        SetApplicationSettingInt( "nvhacks", "optimus-force-windowed", 0 );
    }
}
示例#16
0
BString
BNetworkAddress::HostName() const
{
	// TODO: implement host name lookup
	return ToString(false);
}
示例#17
0
void EditLayerDialog::OnaddCameraBtClick(wxCommandEvent& event)
{
    cameraChoice->Append(ToString(tempLayer.GetCameraCount()));
    tempLayer.SetCameraCount(tempLayer.GetCameraCount()+1);
}
示例#18
0
void CAddress::print() const
{
    printf("CAddress(%s)\n", ToString().c_str());
}
void EditorLevel::loadTerrain(Ogre::SceneManager *scene_manager, list<TerrainNode *> *terrain_nodes_list) {
	if (game_name == LIBGENS_LEVEL_GAME_STRING_LOST_WORLD) {
		string terrain_data_folder = resources_cache_folder;

		terrain          = new LibGens::Terrain();

		direct_light     = new LibGens::Light(terrain_data_folder + "/" + "Direct01.light");

		printf("Terrain Folder: %s\n", terrain_data_folder);

		material_library = new LibGens::MaterialLibrary(terrain_data_folder + "/");

		// Search for model files
		vector<LibGens::Model *> terrain_models;
		{
			WIN32_FIND_DATA FindFileData;
			HANDLE hFind;
			hFind = FindFirstFile((terrain_data_folder+"/*.terrain-model").c_str(), &FindFileData);
			if (hFind == INVALID_HANDLE_VALUE) {} 
			else {
				do {
					const char *name=FindFileData.cFileName;
					if (name[0]=='.') continue;

					string new_filename=resources_cache_folder+"/"+ToString(name);
					LibGens::Model *model = new LibGens::Model(new_filename);
					terrain_models.push_back(model);

					//model->changeVertexFormat(LIBGENS_VERTEX_FORMAT_PC);
					terrain->addModel(model);
				} while (FindNextFile(hFind, &FindFileData) != 0);
				FindClose(hFind);
			}
		}

		vector<LibGens::Model *> used_models;
		// Search for instance files
		{
			WIN32_FIND_DATA FindFileData;
			HANDLE hFind;
			hFind = FindFirstFile((terrain_data_folder+"/*.terrain-instanceinfo").c_str(), &FindFileData);
			if (hFind == INVALID_HANDLE_VALUE) {} 
			else {
				do {
					const char *name=FindFileData.cFileName;
					if (name[0]=='.') continue;

					string new_filename=resources_cache_folder+"/"+ToString(name);
					LibGens::TerrainInstance *instance = new LibGens::TerrainInstance(new_filename, ToString(name), &terrain_models);

					// Add to scene
					TerrainNode *terrain_node=new TerrainNode(instance, scene_manager, material_library);
					terrain_node->setGIQualityLevel(NULL, 0);
					//if (terrain_nodes_list) terrain_nodes_list->push_back(terrain_node);

					used_models.push_back(instance->getModel());
					terrain_nodes_list->push_back(terrain_node);

					terrain->addInstance(instance);

				} while (FindNextFile(hFind, &FindFileData) != 0);
				FindClose(hFind);
			}
		}

		for (size_t i=0; i<terrain_models.size(); i++) {
			bool found=false;

			for (size_t j=0; j<used_models.size(); j++) {
				if (terrain_models[i] == used_models[j]) {
					found = true;
					break;
				}
			}

			if (!found) {
				LibGens::TerrainInstance *instance = new LibGens::TerrainInstance(terrain_models[i]->getName(), terrain_models[i], LibGens::Matrix4());
				instance->setFilename(terrain_data_folder + "/" + terrain_models[i]->getName()+".terrain-instanceinfo");

				
				// Add to scene
				TerrainNode *terrain_node=new TerrainNode(instance, scene_manager, material_library);
				terrain_node->setGIQualityLevel(NULL, 0);
				terrain_nodes_list->push_back(terrain_node);

				terrain->addInstance(instance);
			}
		}
	}
	else {
		if (!level) return;

		string terrain_data_folder = resources_cache_folder;

		// Terrain-related data files are stored in the data folder on Unleashed
		if (game_name == LIBGENS_LEVEL_GAME_STRING_UNLEASHED) {
			terrain_data_folder = data_cache_folder;
		}

		string terrain_filename    = terrain_data_folder + "/" + level->getTerrainInfo() + LIBGENS_TERRAIN_EXTENSION;
		string block_filename      = terrain_data_folder + "/" + LIBGENS_TERRAIN_BLOCK_FILENAME;
		string light_list_filename = terrain_data_folder + "/" + LIBGENS_LIGHT_LIST_FILENAME;
		string groups_folder       = terrain_data_folder + "/";
		string gi_info_filename    = terrain_data_folder + "/" + LIBGENS_GI_TEXTURE_GROUP_INFO_FILE;

		string autodraw_filename   = resources_cache_folder + "/" + LIBGENS_TERRAIN_AUTODRAW_TXT;

		terrain          = new LibGens::Terrain(terrain_filename, groups_folder, resources_cache_folder + "/", terrain_cache_folder + "/", gi_cache_folder + "/", false);
		terrain_gi_info  = new LibGens::GITextureGroupInfo(gi_info_filename, terrain_cache_folder + "/");
		terrain_block    = new LibGens::TerrainBlock(block_filename);
		light_list       = new LibGens::LightList(light_list_filename);
		terrain_autodraw = new LibGens::TerrainAutodraw(autodraw_filename);

		material_library = terrain->getMaterialLibrary();

		if (light_list) {
			direct_light     = light_list->getLight(level->getDirectLight());
		}
	}
}
示例#20
0
void Print(LogPriority pr, SourceAddress const & sa, string const & msg)
{
  cout << ToString(pr) << " " << sa.ToString() << msg << endl;
}
示例#21
0
文件: Match1.cpp 项目: jakexie/micmac
int  TD_Match1_main(int argc,char ** argv)
{
	bool ByCorrel = false;
    std::string aNameI1,aNameI2;
    int aDeltaPax=100;
    int aSzW = 5;
    
    
     ElInitArgMain
    (
        argc,argv,
        LArgMain()  << EAMC(aNameI1,"Name Im1")
					<< EAMC(aNameI2,"Name Im2"),
        LArgMain()  << EAM(aDeltaPax,"DPax",true,"Delta paralax")
                    << EAM(aSzW,"SzW",true,"Size of Window, Def=5")
                    << EAM(ByCorrel,"ByCorrel",true,"By correlation")
    );
    Pt2di aP;
    // on charger nos deux images
    // image 1
    cTD_Im aI1 = cTD_Im::FromString(aNameI1);
    Pt2di aSz = aI1.Sz();
    std::string aNameMasqIm1 = std::string("Masq_") + aNameI1;
    cTD_Im aIMasq(aSz.x,aSz.y); 
    if (ELISE_fp::exist_file(aNameMasqIm1))
    {
		aIMasq = cTD_Im::FromString(aNameMasqIm1);
	}
	else
	{
	  for (aP.x=0; aP.x < aSz.x ; aP.x++)
      {
		for (aP.y=0 ; aP.y < aSz.y ; aP.y++)
		{
			aIMasq.SetVal(aP.x,aP.y,1);
		}
	  }
	}    
    
   

    
    // image 2
    cTD_Im aI2 = cTD_Im::FromString(aNameI2);
    
   //aI1 = aI1.ImageMoy(aSzW,1);
   // aI2 = aI2.ImageMoy(aSzW,1);
    
    // on crée un image pour stocker le résultat de la corrélation 
    cTD_Im aICorelMin = cTD_Im(aSz.x, aSz.y);
     // on crée la carte de profondeur
    cTD_Im aIProf = cTD_Im(aSz.x, aSz.y);
    
    for (aP.x=0; aP.x < aSz.x ; aP.x++)
    {
		if ((aP.x%50)==0) std::cout << "Reste " << aSz.x-aP.x << "\n";
		for (aP.y=0 ; aP.y < aSz.y ; aP.y++)
		{
		    float aDiffMin = Beaucoup;
		    int aPaxOpt=0;
		    Pt2di aPPax(0,0);
		    if (aIMasq.GetVal(aP.x,aP.y))
		    {
				for ( aPPax.x = -aDeltaPax ; aPPax.x<=aDeltaPax ; aPPax.x++)
				{
					Pt2di aP2 = aP+aPPax;
					if (1)
					{
						float aDiff =  ByCorrel ?
									SimilByCorrel(aSzW,aI1,aP,aI2,aP2):			                
									SimilByDif(aSzW,aI1,aP,aI2,aP2);
									
						//float aDiff =	SimilMultiW(aI1,aP,aI2,aP2);
						if  (aDiff < aDiffMin)
						{
							aDiffMin = aDiff;
							aPaxOpt = aPPax.x;
						}
					}
				}
	    	} 
			aIProf.SetVal(aP.x,aP.y,aPaxOpt);
		}
	}
	
	std::string aNameRes = "CartePax";
	aNameRes += std::string("_SzW") + ToString(aSzW);
	aNameRes +=  ByCorrel ? "Correl" :  "Dif";
	aNameRes += ".tif";
		
    aIProf.Save(aNameRes );
    
    System("to8Bits " + aNameRes + " Circ=1 Dyn=10");
    
	return EXIT_SUCCESS;
}
示例#22
0
string ProfileSettingItem::profileToString() const {
	return boost::apply_visitor(ToString(key), profileValue);
}
void FunctionFrontendFlowStep::WriteBBGraphDot(const std::string filename) const
{
   auto bb_graph_info = BBGraphInfoRef(new BBGraphInfo(AppM, function_id));
   BBGraphsCollectionRef GCC_bb_graphs_collection(new BBGraphsCollection(bb_graph_info, parameters));
   BBGraphRef GCC_bb_graph(new BBGraph(GCC_bb_graphs_collection, CFG_SELECTOR));
   std::unordered_map<vertex, unsigned int> direct_vertex_map;
   std::unordered_map<unsigned int, vertex> inverse_vertex_map;
   const tree_nodeConstRef function_tree_node = AppM->get_tree_manager()->CGetTreeNode(function_id);
   const auto fd = GetPointer<const function_decl>(function_tree_node);
   const auto sl = GetPointer<const statement_list>(GET_CONST_NODE(fd->body));
   /// add vertices
   for(auto block : sl->list_of_bloc)
   {
      inverse_vertex_map[block.first] = GCC_bb_graphs_collection->AddVertex(BBNodeInfoRef(new BBNodeInfo(block.second)));
      direct_vertex_map[inverse_vertex_map[block.first]]=block.first;
   }
   ///Set entry and exit
   if(inverse_vertex_map.find(bloc::ENTRY_BLOCK_ID) == inverse_vertex_map.end())
   {
      inverse_vertex_map[bloc::ENTRY_BLOCK_ID] = GCC_bb_graphs_collection->AddVertex(BBNodeInfoRef(new BBNodeInfo()));
      direct_vertex_map[inverse_vertex_map[bloc::ENTRY_BLOCK_ID]]=bloc::ENTRY_BLOCK_ID;
   }
   bb_graph_info->entry_vertex = inverse_vertex_map[bloc::ENTRY_BLOCK_ID];
   if(inverse_vertex_map.find(bloc::EXIT_BLOCK_ID) == inverse_vertex_map.end())
   {
      inverse_vertex_map[bloc::EXIT_BLOCK_ID] = GCC_bb_graphs_collection->AddVertex(BBNodeInfoRef(new BBNodeInfo()));
      direct_vertex_map[inverse_vertex_map[bloc::EXIT_BLOCK_ID]]=bloc::EXIT_BLOCK_ID;
   }
   bb_graph_info->exit_vertex = inverse_vertex_map[bloc::EXIT_BLOCK_ID];

   /// add edges
   for(const auto block : sl->list_of_bloc)
   {
      for(const auto pred : block.second->list_of_pred)
      {
         if(pred == bloc::ENTRY_BLOCK_ID)
         {
            GCC_bb_graphs_collection->AddEdge(inverse_vertex_map[pred], inverse_vertex_map[block.first], CFG_SELECTOR);
         }
      }
      for(const auto succ : block.second->list_of_succ)
      {
         THROW_ASSERT(inverse_vertex_map.find(block.first) != inverse_vertex_map.end(), "BB" + STR(block.first) + " does not exist");
         THROW_ASSERT(inverse_vertex_map.find(succ) != inverse_vertex_map.end(), "BB" + STR(succ) + " does not exist");
         if(block.second->CGetStmtList().size() and GET_NODE(block.second->CGetStmtList().back())->get_kind() == gimple_multi_way_if_K)
         {
            const auto gmwi = GetPointer<const gimple_multi_way_if>(GET_NODE(block.second->CGetStmtList().back()));
            CustomSet<unsigned int> conds;
            for(auto gmwi_cond : gmwi->list_of_cond)
            {
               if(gmwi_cond.second == succ)
               {
                  if(gmwi_cond.first)
                  {
                     conds.insert(gmwi_cond.first->index);
                  }
                  else
                  {
                     conds.insert(default_COND);
                  }
               }
            }
            THROW_ASSERT(conds.size(), "Inconsistency between cfg and output of gimple_multi_way_if " + gmwi->ToString() + "- condition for BB" + STR(succ) + " not found");
            const EdgeInfoRef edge_info(new BBEdgeInfo());
            for(auto cond : conds)
            {
               GetPointer<BBEdgeInfo>(edge_info)->add_nodeID(cond, CFG_SELECTOR);
            }
            GCC_bb_graphs_collection->InternalAddEdge(inverse_vertex_map[block.first], inverse_vertex_map[succ], CFG_SELECTOR, edge_info);
         }
         else
         {
            GCC_bb_graphs_collection->AddEdge(inverse_vertex_map[block.first], inverse_vertex_map[succ], CFG_SELECTOR);
         }
      }
      if(block.second->list_of_succ.empty())
      {
         GCC_bb_graphs_collection->AddEdge(inverse_vertex_map[block.first], inverse_vertex_map[bloc::EXIT_BLOCK_ID], CFG_SELECTOR);
      }
   }

   /// add a connection between entry and exit thus avoiding problems with non terminating code
   GCC_bb_graphs_collection->AddEdge(inverse_vertex_map[bloc::ENTRY_BLOCK_ID], inverse_vertex_map[bloc::EXIT_BLOCK_ID], CFG_SELECTOR);
   BBGraph(GCC_bb_graphs_collection, CFG_SELECTOR).WriteDot(filename);
   INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Written " + filename);
   /// add edges
   for(const auto block : sl->list_of_bloc)
   {
#ifndef NDEBUG
      for(const auto phi : block.second->CGetPhiList())
      {
         const auto gp = GetPointer<const gimple_phi>(GET_CONST_NODE(phi));
         THROW_ASSERT(gp->CGetDefEdgesList().size() == block.second->list_of_pred.size(), "BB" + STR(block.second->number) + " has " + STR(block.second->list_of_pred.size()) + " incoming edges but contains " + STR(phi));
      }
#endif
   }
}
示例#24
0
string SettingItem::currentToString() const {
	auto cur = getCurValue(true);
	return boost::apply_visitor(ToString(key), cur);
}
示例#25
0
void TimedEventEditorDlg::OnexpressionBtClick(wxCommandEvent& event)
{
    gd::EditExpressionDialog dialog(this, ToString( timeoutEdit->GetValue() ), game, scene);
    if ( dialog.ShowModal() == 1 ) timeoutEdit->ChangeValue(dialog.GetExpression());
}
示例#26
0
	void ScanSpec::addRowInterval( const char* startRow, bool includeStartRow, const char* endRow, bool includeEndRow ) {
		scanSpecBuilder.add_row_interval( ToString(startRow), includeStartRow, ToString(endRow), includeEndRow );
	}
示例#27
0
void CInv::print() const
{
    printf("CInv(%s)\n", ToString().c_str());
}
示例#28
0
string PhysicalDag::ToString() const {
  return ToString(DataToString, OpToString);
}
bool FActorFolders::RenameFolderInWorld(UWorld& World, FName OldPath, FName NewPath)
{
	if (OldPath.IsNone() || OldPath == NewPath || PathIsChildOf(NewPath.ToString(), OldPath.ToString()))
	{
		return false;
	}

	const FScopedTransaction Transaction(LOCTEXT("UndoAction_RenameFolder", "Rename Folder"));

	const FString OldPathString = OldPath.ToString();
	const FString NewPathString = NewPath.ToString();

	TSet<FName> RenamedFolders;

	// Move any folders we currently hold - old ones will be deleted later
	UEditorActorFolders& FoldersInWorld = GetOrCreateFoldersForWorld(World);
	FoldersInWorld.Modify();

	auto ExistingFoldersCopy = FoldersInWorld.Folders;
	for (const auto& Pair : ExistingFoldersCopy)
	{
		auto Path = Pair.Key;

		const FString FolderPath = Path.ToString();
		if (OldPath == Path || PathIsChildOf(FolderPath, OldPathString))
		{
			const FName NewFolder = OldPathToNewPath(OldPathString, NewPathString, FolderPath);
			if (!FoldersInWorld.Folders.Contains(NewFolder))
			{
				// Use the existing properties for the folder if we have them
				if (FActorFolderProps* ExistingProperties = FoldersInWorld.Folders.Find(Path))
				{
					FoldersInWorld.Folders.Add(NewFolder, *ExistingProperties);
				}
				else
				{
					// Otherwise use default properties
					FoldersInWorld.Folders.Add(NewFolder);
				}
				OnFolderCreate.Broadcast(World, NewFolder);
			}
			RenamedFolders.Add(Path);
		}
	}

	// Now that we have folders created, move any actors that ultimately reside in that folder too
	for (auto ActorIt = FActorIterator(&World); ActorIt; ++ActorIt)
	{
		const FName& OldActorPath = ActorIt->GetFolderPath();
		
		AActor* Actor = *ActorIt;
		if (OldActorPath.IsNone())
		{
			continue;
		}

		if (Actor->GetFolderPath() == OldPath || PathIsChildOf(OldActorPath.ToString(), OldPathString))
		{
			RenamedFolders.Add(OldActorPath);
			ActorIt->SetFolderPath(OldPathToNewPath(OldPathString, NewPathString, OldActorPath.ToString()));
		}
	}

	// Cleanup any old folders
	for (const auto& Path : RenamedFolders)
	{
		FoldersInWorld.Folders.Remove(Path);
		OnFolderDelete.Broadcast(World, Path);
	}

	return RenamedFolders.Num() != 0;
}
示例#30
0
wxString wxNativeFontInfo::ToUserString() const
{
    return ToString();
}