23 #include "wx/wxprec.h"
31 #include "ObjCryst/wxCryst/wxDiffractionSingleCrystal.h"
32 #include "ObjCryst/wxCryst/wxRadiation.h"
55 class WXDiffractionSingleCrystalGraph:
public WXMultiGraph
58 WXDiffractionSingleCrystalGraph(wxFrame *frame,WXDiffractionSingleCrystal *parent):
63 virtual ~WXDiffractionSingleCrystalGraph()
65 mpParent->NotifyDeleteGraph();
68 WXDiffractionSingleCrystal *mpParent;
75 static long ID_DIFFSINGLECRYST_MENU_SAVEHKLIOBSICALC= WXCRYST_ID();
76 static long ID_DIFFSINGLECRYST_MENU_SAVEHKLFCALC= WXCRYST_ID();
77 static long ID_DIFFSINGLECRYST_MENU_SIMULATE= WXCRYST_ID();
78 static long ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBS= WXCRYST_ID();
79 static long ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSSIGMA= WXCRYST_ID();
80 static long ID_DIFFSINGLECRYST_MENU_IMPORT_SHELXHKLF4= WXCRYST_ID();
81 static long ID_DIFFSINGLECRYST_MENU_IMPORT_CIF= WXCRYST_ID();
82 static long ID_DIFFSINGLECRYST_MENU_IMPORT_JANAM91= WXCRYST_ID();
83 static long ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSGROUP= WXCRYST_ID();
84 static long ID_DIFFSINGLECRYST_MENU_FITSCALE_R= WXCRYST_ID();
85 static long ID_DIFFSINGLECRYST_MENU_FITSCALE_RW= WXCRYST_ID();
86 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH= WXCRYST_ID();
87 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_XRAY= WXCRYST_ID();
88 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_NEUTRON= WXCRYST_ID();
89 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_ELECTRON= WXCRYST_ID();
90 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET= WXCRYST_ID();
91 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AG= WXCRYST_ID();
92 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MO= WXCRYST_ID();
93 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CU= WXCRYST_ID();
94 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FE= WXCRYST_ID();
95 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CO= WXCRYST_ID();
96 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CR= WXCRYST_ID();
97 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AGA1= WXCRYST_ID();
98 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MOA1= WXCRYST_ID();
99 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CUA1= WXCRYST_ID();
100 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FEA1= WXCRYST_ID();
101 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_COA1= WXCRYST_ID();
102 static long ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CRA1= WXCRYST_ID();
103 static long ID_DIFFSINGLECRYST_CRYSTAL= WXCRYST_ID();
104 static long ID_DIFFSINGLECRYST_MENU_DATA= WXCRYST_ID();
105 static long ID_DIFFSINGLECRYST_MENU_DATA_GRAPH= WXCRYST_ID();
107 BEGIN_EVENT_TABLE(WXDiffractionSingleCrystal, wxWindow)
108 EVT_BUTTON(ID_WXOBJ_COLLAPSE, WXCrystObj::OnToggleCollapse)
109 EVT_MENU(ID_REFOBJ_MENU_OBJ_SAVE, WXRefinableObj::OnMenuSave)
110 EVT_MENU(ID_REFOBJ_MENU_OBJ_LOAD, WXRefinableObj::OnMenuLoad)
111 EVT_MENU(ID_REFOBJ_MENU_PAR_FIXALL, WXRefinableObj::OnMenuFixAllPar)
112 EVT_MENU(ID_REFOBJ_MENU_PAR_UNFIXALL, WXRefinableObj::OnMenuUnFixAllPar)
113 EVT_MENU(ID_DIFFSINGLECRYST_MENU_SAVEHKLIOBSICALC, WXDiffractionSingleCrystal::OnMenuSaveHKLIobsIcalc)
114 EVT_MENU(ID_DIFFSINGLECRYST_MENU_SAVEHKLFCALC, WXDiffractionSingleCrystal::OnMenuSaveHKLFcalc)
115 EVT_MENU(ID_DIFFSINGLECRYST_MENU_SIMULATE, WXDiffractionSingleCrystal::OnMenuSimulate)
116 EVT_MENU(ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBS, WXDiffractionSingleCrystal::OnMenuImport)
117 EVT_MENU(ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSSIGMA,WXDiffractionSingleCrystal::OnMenuImport)
118 EVT_MENU(ID_DIFFSINGLECRYST_MENU_IMPORT_SHELXHKLF4, WXDiffractionSingleCrystal::OnMenuImport)
119 EVT_MENU(ID_DIFFSINGLECRYST_MENU_IMPORT_CIF , WXDiffractionSingleCrystal::OnMenuImport)
120 EVT_MENU(ID_DIFFSINGLECRYST_MENU_IMPORT_JANAM91, WXDiffractionSingleCrystal::OnMenuImport)
121 EVT_MENU(ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSGROUP,WXDiffractionSingleCrystal::OnMenuImport)
122 EVT_BUTTON(ID_DIFFSINGLECRYST_CRYSTAL, WXDiffractionSingleCrystal::OnChangeCrystal)
125 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET, WXDiffractionSingleCrystal::OnMenuSetWavelength)
126 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_XRAY, WXDiffractionSingleCrystal::OnMenuSetWavelength)
127 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_NEUTRON, WXDiffractionSingleCrystal::OnMenuSetWavelength)
128 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_ELECTRON,WXDiffractionSingleCrystal::OnMenuSetWavelength)
129 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AG, WXDiffractionSingleCrystal::OnMenuSetWavelength)
130 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MO, WXDiffractionSingleCrystal::OnMenuSetWavelength)
131 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CU, WXDiffractionSingleCrystal::OnMenuSetWavelength)
132 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FE, WXDiffractionSingleCrystal::OnMenuSetWavelength)
133 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CO, WXDiffractionSingleCrystal::OnMenuSetWavelength)
134 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CR, WXDiffractionSingleCrystal::OnMenuSetWavelength)
135 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AGA1,WXDiffractionSingleCrystal::OnMenuSetWavelength)
136 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MOA1,WXDiffractionSingleCrystal::OnMenuSetWavelength)
137 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CUA1,WXDiffractionSingleCrystal::OnMenuSetWavelength)
138 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FEA1,WXDiffractionSingleCrystal::OnMenuSetWavelength)
139 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_COA1,WXDiffractionSingleCrystal::OnMenuSetWavelength)
140 EVT_MENU(ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CRA1,WXDiffractionSingleCrystal::OnMenuSetWavelength)
141 EVT_MENU(ID_DIFFSINGLECRYST_MENU_DATA_GRAPH, WXDiffractionSingleCrystal::OnMenuShowGraph)
142 EVT_UPDATE_UI(ID_CRYST_UPDATEUI, WXRefinableObj::OnUpdateUI)
145 WXDiffractionSingleCrystal::WXDiffractionSingleCrystal(wxWindow *parent,
146 DiffractionDataSingleCrystal* data):
147 WXRefinableObj(parent,data),mpData(data),mpGraph(0),mGrapIdObs(0),mGrapIdCalc(0)
149 VFN_DEBUG_MESSAGE(
"WXDiffractionSingleCrystal::WXDiffractionSingleCrystal()",6)
150 mpWXTitle->SetForegroundColour(wxColour(255,0,0));
151 mpWXTitle->SetSize(400,-1);
153 mpMenuBar->AddMenu("File",ID_REFOBJ_MENU_OBJ);
157 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_SAVEHKLIOBSICALC,
158 "Save HKL Iobs Icalc (text)");
159 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_SAVEHKLFCALC,
160 "Save HKL Fcalc (text)");
161 mpMenuBar->GetMenu(ID_REFOBJ_MENU_OBJ).AppendSeparator();
162 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_SIMULATE,
163 "Simulation mode (generate HKL list)");
164 mpMenuBar->GetMenu(ID_REFOBJ_MENU_OBJ).AppendSeparator();
165 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBS,
167 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSSIGMA,
168 "Import HKL Iobs Sigma (space or tab-separated)");
169 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_IMPORT_SHELXHKLF4,
170 "Import HKL Iobs Sigma (HKLF 4 Shelx format)");
171 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_IMPORT_CIF,
172 "Import CIF single crystal data");
175 mpMenuBar->AddMenuItem(ID_REFOBJ_MENU_OBJ,ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSGROUP,
176 "Import Reflections with group intensity");
178 mpMenuBar->AddMenu("Radiation",ID_DIFFSINGLECRYST_MENU_WAVELENGTH);
179 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
180 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_NEUTRON,
182 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
183 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_XRAY,
185 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
186 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_ELECTRON,
188 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
189 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET,
190 "Monochromatic Wavelength");
191 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
192 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AG,
193 "X-Ray Tube Ag Ka12");
194 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
195 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AGA1,
196 "X-Ray Tube Ag Ka1");
197 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
198 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MO,
199 "X-Ray Tube Mo Ka12");
200 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
201 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MOA1,
202 "X-Ray Tube Mo Ka1");
203 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
204 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CU,
205 "X-Ray Tube Cu Ka12");
206 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
207 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CUA1,
208 "X-Ray Tube Cu Ka1");
209 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
210 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FE,
211 "X-Ray Tube Fe Ka12");
212 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
213 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FEA1,
214 "X-Ray Tube Fe Ka1");
215 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
216 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CO,
217 "X-Ray Tube Co Ka12");
218 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
219 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_COA1,
220 "X-Ray Tube Co Ka1");
221 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
222 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CR,
223 "X-Ray Tube Cr Ka12");
224 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_WAVELENGTH,
225 ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CRA1,
226 "X-Ray Tube Cr Ka1");
232 mpMenuBar->AddMenu("Data",ID_DIFFSINGLECRYST_MENU_DATA);
233 mpMenuBar->AddMenuItem(ID_DIFFSINGLECRYST_MENU_DATA,ID_DIFFSINGLECRYST_MENU_DATA_GRAPH,
239 mpSizer->Add(mpData->mRadiation.WXCreate(this),0);
240 mList.Add(mpData->mRadiation.WXGet());
242 mpFieldCrystal=new WXFieldChoice(this,ID_DIFFSINGLECRYST_CRYSTAL,"Crystal:",300);
243 mpSizer->Add(mpFieldCrystal,0,wxALIGN_LEFT);
244 mList.Add(mpFieldCrystal);
246 WXFieldPar<REAL> *maxSiThOvLa=
247 new WXFieldPar<REAL>(this,"Max Sin(theta)/lambda:",-1,&(mpData->mMaxSinThetaOvLambda));
248 mpSizer->Add(maxSiThOvLa,0,wxALIGN_LEFT);
249 mList.Add(maxSiThOvLa);
251 wxBoxSizer* pStats=new wxBoxSizer(wxHORIZONTAL);
253 WXFieldPar<REAL> *pWXFieldChi2=new WXFieldPar<REAL>(this,"Chi^2",-1,&mChi2,100);
254 pStats->Add(pWXFieldChi2 ,0,wxALIGN_CENTER);
255 mList.Add(pWXFieldChi2);
257 WXFieldPar<REAL> *pWXFieldGof=new WXFieldPar<REAL>(this,"GoF",-1,&mGoF,70);
258 pStats->Add(pWXFieldGof ,0,wxALIGN_CENTER);
259 mList.Add(pWXFieldGof);
261 WXFieldPar<REAL> *pWXFieldRwp=new WXFieldPar<REAL>(this,"Rwp",-1,&mRwp,70);
262 pStats->Add(pWXFieldRwp ,0,wxALIGN_CENTER);
263 mList.Add(pWXFieldRwp);
265 WXFieldPar<REAL> *pWXFieldRp=new WXFieldPar<REAL>(this,"Rp",-1,&mRp,70);
266 pStats->Add(pWXFieldRp ,0,wxALIGN_CENTER);
267 mList.Add(pWXFieldRp);
269 mpSizer->Add(pStats);
271 this->CrystUpdate(true);
272 VFN_DEBUG_MESSAGE("WXDiffractionSingleCrystal::WXDiffractionSingleCrystal():End",6)
277 VFN_DEBUG_ENTRY(
"WXDiffractionSingleCrystal::CrystUpdate()",6)
278 if(lock) mMutex.Lock();
281 mChi2=mpData->GetChi2();
282 if(0==mpData->GetIobs().numElements()) mGoF=0;
283 else mGoF=mpData->GetChi2()/mpData->GetIobs().numElements();
284 mRwp=mpData->GetRw();
288 const CrystVector_REAL *mpCalc=&(mpData->GetIcalc());
289 const CrystVector_REAL *mpObs =&(mpData->GetIobs());
290 const CrystVector_REAL *mpSinThetaOverLambda=&(mpData->GetSinThetaOverLambda());
291 const unsigned long nb=mpCalc->numElements();
295 for(
unsigned long i=0;i<nb;i++)
297 mX[i]=(*mpSinThetaOverLambda)(i)*2;
298 mIobs[i] =(*mpObs)(i);
299 mIcalc[i]=(*mpCalc)(i);
302 if(lock) mMutex.Unlock();
304 VFN_DEBUG_EXIT(
"WXDiffractionSingleCrystal::CrystUpdate()",6)
312 void WXDiffractionSingleCrystal::OnMenuSimulate(wxCommandEvent & WXUNUSED(event))
317 wxTextEntryDialog dialog(
this,_T(
"Theta Max"),
318 _T(
"Enter maximum Theta (degrees)"),_T(
"50"),wxOK | wxCANCEL);
319 if(wxID_OK!=dialog.ShowModal())
321 VFN_DEBUG_EXIT(
"WXDiffractionSingleCrystal::OnMenuSimulate():Cancelled",6)
324 dialog.GetValue().ToDouble(&theta);
327 choices[0]=_T("all reflections (keep Friedel&Bijvoet mates)");
328 choices[1]=_T("only unique reflections");
329 wxSingleChoiceDialog dialog(this,_T("Choose method"),
330 _T("Choose method for Reflection generation"),
331 2,choices,(
void **)NULL,wxOK | wxCANCEL);
332 if(wxID_OK!=dialog.ShowModal()) return;
333 const
int choice=dialog.GetSelection();
334 if(0==choice) mpData->GenHKLFullSpace(theta*DEG2RAD,false);
335 else mpData->GenHKLFullSpace(theta*DEG2RAD,true);
339 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBS)
341 wxFileDialog open(
this,_T(
"Choose file to import from"),
342 _T(
""),_T(
""),_T(
"*.*"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
343 if(open.ShowModal() != wxID_OK)
return;
346 wxTextEntryDialog dialog(
this,_T(
"Number of reflections"),
347 _T(
"Enter The number of reflections to import"),_T(
"50"),
349 if(wxID_OK!=dialog.ShowModal())
351 VFN_DEBUG_EXIT(
"WXDiffractionSingleCrystal))OnMenuImport())Cancelled",6)
354 dialog.GetValue().ToLong(&nb);
356 mpData->ImportHklIobs(
string(open.GetPath().ToAscii()),nb);
357 mpData->UpdateDisplay();
360 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSSIGMA)
362 wxFileDialog open(
this,_T(
"Choose file to import from"),
363 _T(
""),_T(
""),_T(
"*.*"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
364 if(open.ShowModal() != wxID_OK)
return;
367 wxTextEntryDialog dialog(
this,_T(
"Number of reflections"),
368 _T(
"Enter The number of reflections to import"),_T(
"50"),
370 if(wxID_OK!=dialog.ShowModal())
372 VFN_DEBUG_EXIT(
"WXDiffractionSingleCrystal))OnMenuImport())Cancelled",6)
375 dialog.GetValue().ToLong(&nb);
377 mpData->ImportHklIobsSigma(
string(open.GetPath().ToAscii()),nb);
378 mpData->UpdateDisplay();
381 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_IMPORT_SHELXHKLF4)
383 wxFileDialog open(
this,_T(
"Choose Shelx file to import from"),
384 _T(
""),_T(
""),_T(
"*.hkl"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
385 if(open.ShowModal() != wxID_OK)
return;
390 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_IMPORT_CIF)
392 wxFileDialog open(
this,_T(
"Choose CIF file to import from"),
393 _T(
""),_T(
""),_T(
"*.cif"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
394 if(open.ShowModal() != wxID_OK)
return;
395 mpData->
ImportCIF(
string(open.GetPath().ToAscii()));
399 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_IMPORT_HKLIOBSGROUP)
401 wxFileDialog open(
this,_T(
"Choose data file"),
402 _T(
""),_T(
""),_T(
"*.*"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
403 if(open.ShowModal() != wxID_OK)
return;
408 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_IMPORT_JANAM91)
410 wxFileDialog open(
this,_T(
"Choose data file"),
411 _T(
""),_T(
""),_T(
"*.*"),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
412 if(open.ShowModal() != wxID_OK)
return;
418 void WXDiffractionSingleCrystal::OnMenuSaveHKLIobsIcalc(wxCommandEvent & WXUNUSED(event))
420 VFN_DEBUG_MESSAGE(
"WXDiffractionSingleCrystal::OnMenuSaveHKLIobsIcalc()",6)
422 wxFileDialog save(this,_T("Choose a file"),_T(""),_T(""),_T("*.txt"),wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
423 if(save.ShowModal() != wxID_OK) return;
424 mpData->SaveHKLIobsIcalc(
string(save.GetPath().ToAscii()));
426 void WXDiffractionSingleCrystal::OnMenuSaveHKLFcalc(wxCommandEvent & WXUNUSED(event))
428 VFN_DEBUG_MESSAGE(
"WXDiffractionSingleCrystal::OnMenuSaveHKLFcalc()",6)
430 wxFileDialog save(this,_T("Choose a file"),_T(""),_T(""),_T("*.txt"),wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
431 if(save.ShowModal() != wxID_OK) return;
432 ofstream os(save.GetPath().ToAscii());
433 mpData->PrintFhklCalcDetail(os);
435 mpData->GetCrystal().GetScatteringComponentList().Print();
437 void WXDiffractionSingleCrystal::OnMenuSetWavelength(wxCommandEvent &event)
441 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_XRAY)
443 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_NEUTRON)
445 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_ELECTRON)
447 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET)
450 wxTextEntryDialog dialog(
this,_T(
"new Wavelength)"),
451 _T(
"Enter new Wavelength (Angstroems)"),_T(
"1"),wxOK | wxCANCEL);
452 if(wxID_OK!=dialog.ShowModal())
454 VFN_DEBUG_EXIT(
"WXDiffractionSingleCrystal))OnMenuSetWavelength())Monochromatic)Cancelled",6)
457 dialog.GetValue().ToDouble(&lambda);
458 mpData->SetWavelength(lambda);
460 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AG)
461 mpData->SetWavelength("Ag");
462 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MO)
463 mpData->SetWavelength("Mo");
464 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CU)
465 mpData->SetWavelength("Cu");
466 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FE)
467 mpData->SetWavelength("Fe");
468 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CO)
469 mpData->SetWavelength("Co");
470 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CR)
471 mpData->SetWavelength("Cr");
472 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_AGA1)
473 mpData->SetWavelength("AgA1");
474 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_MOA1)
475 mpData->SetWavelength("MoA1");
476 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CUA1)
477 mpData->SetWavelength("CuA1");
478 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_FEA1)
479 mpData->SetWavelength("FeA1");
480 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_COA1)
481 mpData->SetWavelength("CoA1");
482 if(event.GetId()== ID_DIFFSINGLECRYST_MENU_WAVELENGTH_SET_CRA1)
483 mpData->SetWavelength("CrA1");
487 void WXDiffractionSingleCrystal::OnMenuShowGraph(wxCommandEvent &event)
489 VFN_DEBUG_MESSAGE(
"WXDiffractionSingleCrystal::OnMenuShowGraph()"<<mpGraph,6)
490 if(mpGraph!=0) return;
491 if(mpData->GetNbRefl()<=0) return;
493 std::
string s=mpData->GetName();
494 if(s.size()==0) s=mpData->GetCrystal().GetName();
495 s="Single Crystal data:"+s;
496 wxFrame *frame= new wxFrame(this,-1,wxString::FromAscii(s.c_str()),
497 wxDefaultPosition,wxSize(500,300),wxCLOSE_BOX|wxRESIZE_BORDER|wxCAPTION);
498 frame->CreateStatusBar(1);
499 mpGraph = new WXDiffractionSingleCrystalGraph(frame,this);
500 mpGraph->SetXLabel(_T("1/d (A)"));
501 mpGraph->SetYLabel(_T("Intensity"));
502 mGrapIdObs =mpGraph->AddGraph("Iobs");
503 mGrapIdCalc=mpGraph->AddGraph("Icalc");
505 wxSizer *ps=new wxBoxSizer(wxHORIZONTAL);
506 ps->Add(mpGraph,1,wxEXPAND);
508 frame->SetAutoLayout(true);
516 void WXDiffractionSingleCrystal::OnChangeCrystal(wxCommandEvent & WXUNUSED(event))
518 VFN_DEBUG_MESSAGE(
"WXDiffractionSingleCrystal::OnChangeCrystal()",6)
521 Crystal *cryst=dynamic_cast<Crystal*>
523 "Choose a Crystal Structure:",choice));
525 mpData->SetCrystal(*cryst);
534 mpGraph->SetGraphData(mGrapIdObs,mX,
mIobs);
535 mpGraph->SetGraphData(mGrapIdCalc,mX,mIcalc);
536 mpGraph->UpdateDisplay();
T * WXDialogChooseFromRegistry(ObjRegistry< T > ®, wxWindow *parent, const string &message, int &choice)
This function allows to pick up one object in a registry.
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new...
void ImportHklIobsSigmaJanaM91(const string &fileName)
Import h,k,l,I,Sigma from a Jana98 '*.m91' file.
valarray< float > mIobs
Copy of the data for graph display.
void WXCrystValidateAllUserInput()
This function validates all user input (in a WXField) not yet taken into account, if needs be...
CrystMutex mMutex
Mutex used to lock data when preparing to update the UI in non-main thread.
void SetValue(const string &)
Used by the owner to change the name of the choice.
bool HasCrystal() const
Has a Crystal structure associated yet ?
ObjRegistry< Crystal > gCrystalRegistry("List of all Crystals")
Global registry for all Crystal objects.
virtual void SetRadiationType(const RadiationType radiation)
Set : neutron or x-ray experiment ? Wavelength ?
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Get new values to be displayed from the underlying object, and raise flag if an UI update is necessar...
void NotifyDeleteGraph()
For the mpGraph to tell its owner it was deleted.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
const Crystal & GetCrystal() const
Const access to the data's crystal.
WX Class for DiffractionDataSingleCrystal objects.
void ImportShelxHKLF4(const string &fileName)
Import h,k,l,I,Sigma from a file using shelx HKLF 4 format.
void ImportHklIobsGroup(const string &fileName, const unsigned int skipLines=0)
Import h,k,l and grouped intensities from a file.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
virtual const string & GetName() const
Name of the object.
virtual void CrystUpdate(const bool updateUI=false, const bool mutexlock=false)
Get new values to be displayed from the underlying object, and raise flag if an UI update is necessar...
void ImportCIF(const string &fileName)
Import diffraction data from a CIF file.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.