frame->CreateStatusBar(2);
void WXPowderPattern::OnMenuAddCompBackgd(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuAddCompBackgd()",6)   WXCrystValidateAllUserInput();   PowderPatternBackground *backgdData= new PowderPatternBackground;   mpPowderPattern->AddPowderPatternComponent(*backgdData);   if(mpGraph!=0) mpPowderPattern->Prepare();//else this will be done when opening the graph   this->Layout();}void WXPowderPattern::OnMenuAddCompCryst(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuAddCompCryst()",6)   WXCrystValidateAllUserInput();   PowderPatternDiffraction * diffData=new PowderPatternDiffraction;   int choice;   Crystal *cryst=dynamic_cast<Crystal*>      ( WXDialogChooseFromRegistry(gCrystalRegistry,(wxWindow*)this,         "Choose a Crystal Structure:",choice));   if(0==cryst) return;   diffData->SetCrystal(*cryst);   mpPowderPattern->AddPowderPatternComponent(*diffData);   if(mpGraph!=0) mpPowderPattern->Prepare();//else this will be done when opening the graph   this->Layout();}void WXPowderPattern::OnMenuShowGraph(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuShowGraph()"<<mpGraph,6)   if(mpPowderPattern->GetPowderPatternObs().numElements()==0)   {      wxMessageDialog dumbUser(this,"Import a powder pattern or use simulation",                               "No observed pattern !",wxOK|wxICON_EXCLAMATION);      dumbUser.ShowModal();      return;   }   if(mpGraph!=0) return;   WXCrystValidateAllUserInput();   mpPowderPattern->Prepare();   wxFrame *frame= new wxFrame(this,-1,mpPowderPattern->GetName().c_str(),                               wxDefaultPosition,wxSize(500,300));   mpGraph = new WXPowderPatternGraph(frame,this);   frame->Show(true);   frame->CreateStatusBar(2);   this->CrystUpdate();   //frame->SetStatusText("");}void WXPowderPattern::OnMenuSaveText(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuSaveText()",6)   WXCrystValidateAllUserInput();   wxFileDialog save(this,"Choose a file","","","*.txt",wxSAVE | wxOVERWRITE_PROMPT);   if(save.ShowModal() != wxID_OK) return;      ofstream out(save.GetPath().c_str());   if(!out) return;//:TODO:   mpPowderPattern->PrintObsCalcData(out);   out.close();}void WXPowderPattern::OnMenuSimulate(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_ENTRY("WXPowderPattern::OnMenuSimulate()",6)   WXCrystValidateAllUserInput();   double min=0.,max=120.;   long nbPoints=6000;   {      wxTextEntryDialog dialog(this,"2Theta Min",                              "Enter minimum 2Theta (degrees)","0",wxOK | wxCANCEL);      if(wxID_OK!=dialog.ShowModal())      {         VFN_DEBUG_EXIT("WXPowderPattern::OnMenuSimulate():Cancelled",6)         return;      }      dialog.GetValue().ToDouble(&min);   }   {      wxTextEntryDialog dialog(this,"2Theta Max",                              "Enter maximum 2Theta (degrees)","100",wxOK | wxCANCEL);      if(wxID_OK!=dialog.ShowModal())      {         VFN_DEBUG_EXIT("WXPowderPattern::OnMenuSimulate():Cancelled",6)         return;      }      dialog.GetValue().ToDouble(&max);   }   {      wxTextEntryDialog dialog(this,"Number of points",                              "Enter the number of points","1000",wxOK | wxCANCEL);      if(wxID_OK!=dialog.ShowModal())      {         VFN_DEBUG_EXIT("WXPowderPattern::OnMenuSimulate():Cancelled",6)         return;      }      dialog.GetValue().ToLong(&nbPoints);   }   CrystVector_REAL newObs(nbPoints);   mpPowderPattern->SetPowderPatternPar(min*DEG2RAD,(max-min)/(nbPoints-1)*DEG2RAD,nbPoints);   newObs=1;//we must not have 0 in case a scale factor is fitted...   mpPowderPattern->SetPowderPatternObs(newObs);   VFN_DEBUG_EXIT("WXPowderPattern::OnMenuSimulate()",6)}void WXPowderPattern::OnMenuImportFullProf(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportFullProf()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternFullprof(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImportPSI(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportPSI()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternPSI_DMC(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImportILL(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportPSI()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternILL_D1A5(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImportXdd(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportXdd()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.xdd",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternXdd(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImportCPI(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportCPI()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.cpi",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternSietronicsCPI(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImportFullProf4(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportFullProf4()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternFullprof4(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImportMultiDetectorLLBG42(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImportMultiDetectorLLBG42()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPatternMultiDetectorLLBG42(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImport2ThetaObsSigma(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImport2ThetaObsSigma()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPattern2ThetaObsSigma(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuImport2ThetaObs(wxCommandEvent & WXUNUSED(event)){   VFN_DEBUG_MESSAGE("WXPowderPattern::OnMenuImport2ThetaObs()",6)   wxFileDialog *open= new wxFileDialog(this,"Choose a file","","","*.*",                                        wxOPEN | wxFILE_MUST_EXIST);   if(open->ShowModal() != wxID_OK) return;      mpPowderPattern->ImportPowderPattern2ThetaObs(open->GetPath().c_str());   open->Destroy();}void WXPowderPattern::OnMenuFitScaleForR(wxCommandEvent & WXUNUSED(event)){   if(0==mpGraph) return;   WXCrystValidateAllUserInput();   mpPowderPattern->FitScaleFactorForR();//FitScaleFactorForIntegratedR   this->CrystUpdate();}void WXPowderPattern::OnMenuFitScaleForRw(wxCommandEvent & WXUNUSED(event)){   if(0==mpGraph) return;   WXCrystValidateAllUserInput();   mpPowderPattern->FitScaleFactorForRw();//FitScaleFactorForIntegratedRw   this->CrystUpdate();}void WXPowderPattern::OnMenuSetWavelength(wxCommandEvent & event){   WXCrystValidateAllUserInput();   // this looks stupid. In fact, if a user changed the wavelength in the   // corresponding field, this is (unfortunately) not applied to the   // components automagically. So we need this function to do the job...   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_XRAY)      mpPowderPattern->SetRadiationType(RAD_XRAY);   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_NEUTRON)      mpPowderPattern->SetRadiationType(RAD_NEUTRON);   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET)   {      double lambda;      wxTextEntryDialog dialog(this,"new Wavelength)",                              "Enter new Wavelength (Angstroems)","1",wxOK | wxCANCEL);      if(wxID_OK!=dialog.ShowModal())      {         VFN_DEBUG_EXIT("WXPowderPattern))OnMenuSetWavelength())Monochromatic)Cancelled",6)         return;      }      dialog.GetValue().ToDouble(&lambda);      mpPowderPattern->SetWavelength(lambda);   }   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_AG)      mpPowderPattern->SetWavelength("Ag");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_MO)      mpPowderPattern->SetWavelength("Mo");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_CU)      mpPowderPattern->SetWavelength("Cu");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_FE)      mpPowderPattern->SetWavelength("Fe");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_CR)      mpPowderPattern->SetWavelength("Cr");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_AGA1)      mpPowderPattern->SetWavelength("AgA1");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_MOA1)      mpPowderPattern->SetWavelength("MoA1");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_CUA1)      mpPowderPattern->SetWavelength("CuA1");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_FEA1)      mpPowderPattern->SetWavelength("FeA1");   if(event.GetId()== ID_POWDERSPECTRUM_MENU_WAVELENGTH_SET_CRA1)      mpPowderPattern->SetWavelength("CrA1");   this->CrystUpdate();}