FOX/ObjCryst++  1.10.X (development)
wxPowderPattern.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000-2002 Vincent Favre-Nicolin vincefn@users.sourceforge.net
3  2000-2001 University of Geneva (Switzerland)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 #ifndef _VFN_WX_POWDERPATTERN_H_
21 #define _VFN_WX_POWDERPATTERN_H_
22 
23 #include "wx/grid.h"
24 
25 #include "ObjCryst/wxCryst/wxRefinableObj.h"
26 #include "ObjCryst/ObjCryst/ScatteringCorr.h"
27 #include "ObjCryst/ObjCryst/PowderPattern.h"
28 #include "ObjCryst/ObjCryst/Indexing.h"
29 namespace ObjCryst
30 {
31 class WXPowderPatternGraph;
32 
35 {
36  public:
37  WXPowderPattern(wxWindow *parent, PowderPattern*);
38  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
39  void OnMenuAddCompBackgd(wxCommandEvent & WXUNUSED(event));
40  void OnMenuAddCompBackgdBayesian(wxCommandEvent & WXUNUSED(event));
41  void OnMenuAddCompCryst(wxCommandEvent & WXUNUSED(event));
42  void OnMenuShowGraph(wxCommandEvent & WXUNUSED(event));
43  void OnMenuSaveText(wxCommandEvent & WXUNUSED(event));
44  void OnMenuSimulate(wxCommandEvent & WXUNUSED(event));
45  void OnMenuImportPattern(wxCommandEvent & WXUNUSED(event));
46  void OnMenuFitScaleForR(wxCommandEvent & WXUNUSED(event));
47  void OnMenuFitScaleForRw(wxCommandEvent & WXUNUSED(event));
48  void OnMenuSavePattern(wxCommandEvent & WXUNUSED(event));
49  void OnMenuSetWavelength(wxCommandEvent &event);
50  void OnMenuAddExclude(wxCommandEvent & WXUNUSED(event));
52  void OnMenuLeBail(wxCommandEvent &event);
53  void OnMenuExport(wxCommandEvent &event);
54  void NotifyDeleteGraph();
55  const PowderPattern& GetPowderPattern()const;
56  PowderPattern& GetPowderPattern();
57  void UpdateUI(const bool mutexlock=false);
58  private:
59  PowderPattern *mpPowderPattern;
61  WXPowderPatternGraph *mpGraph;
62  // Store statistics for display
63  REAL mChi2;
64  REAL mGoF;
65  REAL mRwp;
66  REAL mRp;
67  DECLARE_EVENT_TABLE()
68 };
75 class WXPowderPatternGraph: public wxWindow
76 {
77  public:
79  WXPowderPatternGraph(wxFrame *frame, WXPowderPattern* parent);
82  void OnPaint(wxPaintEvent& WXUNUSED(event));
84  void OnMouse(wxMouseEvent &event);
86  void OnMouseWheel(wxMouseEvent &event);
89  void OnUpdate(wxCommandEvent & WXUNUSED(event));
95  void SetPattern(const CrystVector_REAL &obs,
96  const CrystVector_REAL &calc,
97  const REAL tthetaMin,const REAL tthetaStep,
98  const CrystVector_REAL &sigma,
99  const CrystVector_REAL &chi2Cumul);
103  void SetPattern(const CrystVector_REAL &x,
104  const CrystVector_REAL &obs,
105  const CrystVector_REAL &calc,
106  const CrystVector_REAL &sigma,
107  const CrystVector_REAL &chi2Cumul);
109  void OnRedrawNewPattern(wxUpdateUIEvent& WXUNUSED(event));
110  void OnToggleLabel(wxCommandEvent& WXUNUSED(event));
111  void OnFindPeaks(wxCommandEvent& WXUNUSED(event));
112  void OnLoadPeaks(wxCommandEvent& WXUNUSED(event));
113  void OnSavePeaks(wxCommandEvent& WXUNUSED(event));
115  void OnChangePeak(wxCommandEvent& WXUNUSED(event));
116  void OnIndex(wxCommandEvent& WXUNUSED(event));
117  void OnChangeScale(wxCommandEvent &event);
119  void OnLeBail(wxCommandEvent &event);
120  void OnKeyDown(wxKeyEvent& event);
121  void OnSize(wxSizeEvent& event);
122  WXPowderPattern& GetWXPowderPattern();
123  const WXPowderPattern& GetWXPowderPattern()const;
124  private:
126  void ResetAxisLimits();
128  long Data2ScreenX(const REAL x)const;
130  long Point2ScreenX(const long x)const;
132  long Data2ScreenY(const REAL y)const;
134  REAL Screen2DataX(const long x)const;
136  REAL Screen2DataY(const long y)const;
137  WXPowderPattern *mpPattern;
139  CrystVector_REAL mX,mObs,mCalc,m2theta,mSigma,mChi2Cumul;
140  const long mMargin;
141  const REAL mDiffPercentShift;
142  REAL mMaxIntensity,mMinIntensity,mMinX,mMaxX;
145  wxFrame *mpParentFrame;
147  CrystMutex mMutex;
149  wxMenu* mpPopUpMenu;
153  REAL mDraggingX0,mDraggingIntensity0;
163  list<list<pair<const REAL ,const string > > > mvLabelList;
169  long mXScale,mYScale;
170  DECLARE_EVENT_TABLE()
171 };
172 
181 {
182  public:
184  void OnMenuImportUserBackground(wxCommandEvent & WXUNUSED(event));
185  void OnMenuOptimizeBayesianBackground(wxCommandEvent & WXUNUSED(event));
186  void OnMenuAutomaticBayesianBackground(wxCommandEvent & WXUNUSED(event));
187  void OnEditGridBackgroundPoint(wxGridEvent &e);
188  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
189  virtual void UpdateUI(const bool mutexlock=false);
190  virtual bool Enable(bool enable=true);
191  private:
192  PowderPatternBackground *mpPowderPatternBackground;
193  wxGrid *mpGridBackgroundPoint;
195  mutable CrystVector_REAL mBackgroundInterpPointX,mBackgroundInterpPointIntensity;
198  bool mIsSelfUpdating;
199  DECLARE_EVENT_TABLE()
200 };
206 {
207  public:
210  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
211  virtual void UpdateUI(const bool mutexlock=false);
212  private:
213  wxBoxSizer *mpSizer;
214  WXCrystObjBasicList mList;
215  TexturePhaseMarchDollase* mpTexturePhaseMarchDollase;
216 };
217 
224 {
225  public:
226  WXTextureMarchDollase(wxWindow *parent, TextureMarchDollase*);
227  void OnAddTexturePhase(wxCommandEvent & WXUNUSED(event));
228  void OnDeleteTexturePhase(wxCommandEvent & WXUNUSED(event));
229  private:
230  TextureMarchDollase* mpTextureMarchDollase;
231  DECLARE_EVENT_TABLE()
232 };
233 
239 {
240  public:
241  WXTextureEllipsoid(wxWindow *parent, TextureEllipsoid *prof);
242  virtual ~WXTextureEllipsoid();
243  virtual bool OnChangeName(const int id);
244  private:
245  TextureEllipsoid* mpTextureEllipsoid;
246 };
247 
254 {
255  public:
257  void OnChangeCrystal(wxCommandEvent & WXUNUSED(event));
258  void OnMenuSaveHKLFcalc(wxCommandEvent & WXUNUSED(event));
259  void OnChangeProfile(wxCommandEvent & event);
260  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
261  virtual void UpdateUI(const bool mutexlock=false);
262  virtual bool Enable(bool enable=true);
264  void OnLeBail(wxCommandEvent &event);
266  void OnFreezeLatticePar(wxCommandEvent &event);
267  private:
268  PowderPatternDiffraction *mpPowderPatternDiffraction;
269  WXFieldChoice* mpFieldCrystal;
270  wxCheckBox *mpProfileFittingMode;
271  wxCheckBox *mpFreezeLatticePar;
272  wxGrid *mpGridFrozenLatticePar;
273  bool mFreezeLatticePar;
274  CrystVector_REAL mFrozenLatticePar;
275  //Need Layout if we show/hide frozen lattice parameters
276  bool mNeedLayout;
277  DECLARE_EVENT_TABLE()
278 };
279 
284 {
285  public:
286  WXProfilePseudoVoigt(wxWindow *parent, ReflectionProfilePseudoVoigt *prof);
287  virtual ~WXProfilePseudoVoigt();
288  virtual bool OnChangeName(const int id);
289  private:
290  ReflectionProfilePseudoVoigt *mpProfile;
291 };
292 
297 {
298  public:
301  virtual bool OnChangeName(const int id);
302  private:
304 };
305 
310 {
311  public:
313  (wxWindow *parent, ReflectionProfileDoubleExponentialPseudoVoigt *prof);
315  virtual bool OnChangeName(const int id);
316  private:
318 };
319 
320 } //namespace
321 
322 #endif //_VFN_WX_POWDERPATTERN_H_
bool mNeedUpdateUI
True if the list of points has changed since last displayed.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
void OnUpdate(wxCommandEvent &WXUNUSED(event))
Update the powder spectrum, at the user's request.
list< list< pair< const REAL,const string > > > mvLabelList
The lists of labels for all components of the powder pattern.
Texture correction using the March-Dollase model.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
long Data2ScreenY(const REAL y) const
Convert Y data (intensity) coordinate to screen coordinate (pixel)
Pseudo-Voigt reflection profile, with 6-parameters anisotropic Lorentzian broadening and Toraya asymm...
A List of WXCrystObjBasic.
Definition: wxCryst.h:196
Double-Exponential Pseudo-Voigt profile for TOF.
Class to pick one choice...
Definition: wxCryst.h:482
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
bool mDisplayLabel
Display labels ?
void OnRedrawNewPattern(wxUpdateUIEvent &WXUNUSED(event))
Redraw the pattern (special function to ensure complete redrawing under windows...)
void OnLeBail(wxCommandEvent &event)
Perform Le Bail extraction.
Class to display one Preferred Orientation phase using the March-Dollase parametrization.
Class to display a Powder Pattern (calc,obs) in a graphic window.
void ResetAxisLimits()
Reset the limits of the axis to full range.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
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...
Class to display a Powder Pattern Background.
One texture phase for the March-Dollase model.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
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...
Texture correction using the Ellipsoidal preferred orientation function.
void OnChangePeak(wxCommandEvent &WXUNUSED(event))
Add or remove peak.
Phase to compute a background contribution to a powder pattern using an interpolation.
Class to display a Powder Pattern Pseudo-Voigt Profile with Anisotropic broadening.
WXPowderPatternGraph(wxFrame *frame, WXPowderPattern *parent)
Constructor. The top frame should have a Status bar with two fields (at least)
Class to compute the contribution to a powder pattern from a crystalline phase.
This displays all components of a ObjCryst++ Registry.
void OnMenuLeBail(wxCommandEvent &event)
Profile fitting & Le Bail intensity extraction.
Class to store positions of observed reflections.
Definition: Indexing.h:114
PeakList mPeakList
List of observed peak positions.
Class to display the Preferred Orientation Correction using the March-Dollase parametrization.
Class to display a Powder Pattern for a crystalline phase.
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:127
void OnPaint(wxPaintEvent &WXUNUSED(event))
Redraw the spectrum.
WX Class for PowderPattern objects.
CrystMutex mMutex
Mutex to lock the pattern and associated data.
REAL mDraggingX0
Remember coordinates at the beginning of the dragging.
bool mDefaultIntensityScale
True if no vertical zoom has been used.
REAL Screen2DataY(const long y) const
Convert Y screen coordinate (pixel) to data (intensity) coordinate.
bool mDisplayPeak
Display peaks ?
void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
long Point2ScreenX(const long x) const
Convert X data (as data point index) to screen coordinate (pixel)
Powder pattern class, with an observed pattern and several calculated components to modelize the patt...
void OnMouseWheel(wxMouseEvent &event)
Wheel wan be used to scroll the pattern.
Class to display a Powder Pattern Pseudo-Voigt Profile.
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects)...
Definition: wxCryst.h:248
RefinableObjClock mClockAxisLimits
Clock corresponding to when the graph limits where last changed.
long Data2ScreenX(const REAL x) const
Convert X data (2theta) coordinate to screen coordinate (pixel)
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 SetPattern(const CrystVector_REAL &obs, const CrystVector_REAL &calc, const REAL tthetaMin, const REAL tthetaStep, const CrystVector_REAL &sigma, const CrystVector_REAL &chi2Cumul)
Update the pattern.
The base wxCryst class for all RefinableObj objects.
long mXScale
Scaling options for x and y axis x: 0 data (2theta, tof) ; 1: 1/d ; 2: 2pi/d y: 0 linear ; 1: sqrt(I)...
REAL Screen2DataX(const long x) const
Convert X screen coordinate (pixel) to data (2theta) coordinate.
CrystVector_REAL mX
Data vectors (Note that when x coordinates are 2theta, they are stored in degrees here) ...
Class to display one Preferred Orientation phase using the Ellipsoid model.
bool mIsDragging
Are we within a dragging event ?
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
wxMenu * mpPopUpMenu
Pop-up menu.
void OnFreezeLatticePar(wxCommandEvent &event)
Freeze lattice parameter, which will not follow anymore the Crystal Unitcell values.
CrystVector_REAL mBackgroundInterpPointX
Copy of the list of points and intensity.
Class to display a Powder Pattern Pseudo-Voigt Profile.
Pseudo-Voigt reflection profile.
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 OnLeBail(wxCommandEvent &event)
Profile fitting & Le Bail intensity extraction.
void OnMouse(wxMouseEvent &event)
Display the Theta and intensity values at the mouse position, in the status bar.