FOX/ObjCryst++  2022
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 OnMenuRemoveComp(wxCommandEvent & WXUNUSED(event));
43  void OnMenuShowGraph(wxCommandEvent & WXUNUSED(event));
44  void OnMenuSaveText(wxCommandEvent & WXUNUSED(event));
45  void OnMenuSimulate(wxCommandEvent & WXUNUSED(event));
46  void OnMenuImportPattern(wxCommandEvent & WXUNUSED(event));
47  void OnMenuFitScaleForR(wxCommandEvent & WXUNUSED(event));
48  void OnMenuFitScaleForRw(wxCommandEvent & WXUNUSED(event));
49  void OnMenuSavePattern(wxCommandEvent & WXUNUSED(event));
50  void OnMenuSetWavelength(wxCommandEvent &event);
51  void OnMenuAddExclude(wxCommandEvent & WXUNUSED(event));
53  void OnMenuLeBail(wxCommandEvent &event);
54  void OnMenuExport(wxCommandEvent &event);
55  void NotifyDeleteGraph();
56  const PowderPattern& GetPowderPattern()const;
57  PowderPattern& GetPowderPattern();
58  void UpdateUI(const bool mutexlock=false);
59  private:
60  PowderPattern *mpPowderPattern;
62  WXPowderPatternGraph *mpGraph;
63  // Store statistics for display
64  REAL mChi2;
65  REAL mGoF;
66  REAL mRwp;
67  REAL mRp;
70  DECLARE_EVENT_TABLE()
71 };
78 class WXPowderPatternGraph: public wxWindow
79 {
80  public:
82  WXPowderPatternGraph(wxFrame *frame, WXPowderPattern* parent);
85  void OnPaint(wxPaintEvent& WXUNUSED(event));
87  void OnMouse(wxMouseEvent &event);
89  void OnMouseWheel(wxMouseEvent &event);
92  void OnUpdate(wxCommandEvent & WXUNUSED(event));
98  void SetPattern(const CrystVector_REAL &obs,
99  const CrystVector_REAL &calc,
100  const REAL tthetaMin,const REAL tthetaStep,
101  const CrystVector_REAL &sigma,
102  const CrystVector_REAL &chi2Cumul);
106  void SetPattern(const CrystVector_REAL &x,
107  const CrystVector_REAL &obs,
108  const CrystVector_REAL &calc,
109  const CrystVector_REAL &sigma,
110  const CrystVector_REAL &chi2Cumul);
112  void OnRedrawNewPattern(wxUpdateUIEvent& WXUNUSED(event));
113  void OnToggleLabel(wxCommandEvent& WXUNUSED(event));
114  void OnFindPeaks(wxCommandEvent& WXUNUSED(event));
115  void OnLoadPeaks(wxCommandEvent& WXUNUSED(event));
116  void OnSavePeaks(wxCommandEvent& WXUNUSED(event));
118  void OnChangePeak(wxCommandEvent& WXUNUSED(event));
119  void OnIndex(wxCommandEvent& WXUNUSED(event));
120  void OnChangeScale(wxCommandEvent &event);
122  void OnLeBail(wxCommandEvent &event);
123  void OnKeyDown(wxKeyEvent& event);
124  void OnSize(wxSizeEvent& event);
125  WXPowderPattern& GetWXPowderPattern();
126  const WXPowderPattern& GetWXPowderPattern()const;
127  private:
129  void ResetAxisLimits();
131  long Data2ScreenX(const REAL x)const;
133  long Point2ScreenX(const long x)const;
135  long Data2ScreenY(const REAL y)const;
137  REAL Screen2DataX(const long x)const;
139  REAL Screen2DataY(const long y)const;
140  WXPowderPattern *mpPattern;
142  CrystVector_REAL mX,mObs,mCalc,m2theta,mSigma,mChi2Cumul;
143  const long mMargin;
144  const REAL mDiffPercentShift;
145  REAL mMaxIntensity,mMinIntensity,mMinX,mMaxX;
148  wxFrame *mpParentFrame;
150  CrystMutex mMutex;
152  wxMenu* mpPopUpMenu;
156  REAL mDraggingX0,mDraggingIntensity0;
166  list<list<pair<const REAL ,const string > > > mvLabelList;
172  long mXScale,mYScale;
173  DECLARE_EVENT_TABLE()
174 };
175 
184 {
185  public:
187  void OnMenuImportUserBackground(wxCommandEvent & WXUNUSED(event));
188  void OnMenuOptimizeBayesianBackground(wxCommandEvent & WXUNUSED(event));
189  void OnMenuAutomaticBayesianBackground(wxCommandEvent & WXUNUSED(event));
190  void OnEditGridBackgroundPoint(wxGridEvent &e);
191  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
192  virtual void UpdateUI(const bool mutexlock=false);
193  virtual bool Enable(bool enable=true);
194  private:
195  PowderPatternBackground *mpPowderPatternBackground;
196  wxGrid *mpGridBackgroundPoint;
198  mutable CrystVector_REAL mBackgroundInterpPointX,mBackgroundInterpPointIntensity;
201  bool mIsSelfUpdating;
202  DECLARE_EVENT_TABLE()
203 };
209 {
210  public:
213  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
214  virtual void UpdateUI(const bool mutexlock=false);
215  private:
216  wxBoxSizer *mpSizer;
217  WXCrystObjBasicList mList;
218  TexturePhaseMarchDollase* mpTexturePhaseMarchDollase;
219 };
220 
227 {
228  public:
229  WXTextureMarchDollase(wxWindow *parent, TextureMarchDollase*);
230  void OnAddTexturePhase(wxCommandEvent & WXUNUSED(event));
231  void OnDeleteTexturePhase(wxCommandEvent & WXUNUSED(event));
232  private:
233  TextureMarchDollase* mpTextureMarchDollase;
234  DECLARE_EVENT_TABLE()
235 };
236 
242 {
243  public:
244  WXTextureEllipsoid(wxWindow *parent, TextureEllipsoid *prof);
245  virtual ~WXTextureEllipsoid();
246  virtual bool OnChangeName(const int id);
247  private:
248  TextureEllipsoid* mpTextureEllipsoid;
249 };
250 
257 {
258  public:
260  void OnChangeCrystal(wxCommandEvent & WXUNUSED(event));
261  void OnMenuSaveHKLFcalc(wxCommandEvent & WXUNUSED(event));
262  void OnChangeProfile(wxCommandEvent & event);
263  virtual void CrystUpdate(const bool updateUI=false,const bool mutexlock=false);
264  virtual void UpdateUI(const bool mutexlock=false);
265  virtual bool Enable(bool enable=true);
267  void OnLeBail(wxCommandEvent &event);
269  void OnFreezeLatticePar(wxCommandEvent &event);
270  private:
271  PowderPatternDiffraction *mpPowderPatternDiffraction;
272  WXFieldChoice* mpFieldCrystal;
273  wxCheckBox *mpProfileFittingMode;
274  wxCheckBox *mpFreezeLatticePar;
275  wxGrid *mpGridFrozenLatticePar;
276  bool mFreezeLatticePar;
277  CrystVector_REAL mFrozenLatticePar;
278  //Need Layout if we show/hide frozen lattice parameters
279  bool mNeedLayout;
280  DECLARE_EVENT_TABLE()
281 };
282 
287 {
288  public:
289  WXProfilePseudoVoigt(wxWindow *parent, ReflectionProfilePseudoVoigt *prof);
290  virtual ~WXProfilePseudoVoigt();
291  virtual bool OnChangeName(const int id);
292  private:
293  ReflectionProfilePseudoVoigt *mpProfile;
294 };
295 
300 {
301  public:
304  virtual bool OnChangeName(const int id);
305  private:
307 };
308 
313 {
314  public:
316  (wxWindow *parent, ReflectionProfileDoubleExponentialPseudoVoigt *prof);
318  virtual bool OnChangeName(const int id);
319  private:
321 };
322 
323 } //namespace
324 
325 #endif //_VFN_WX_POWDERPATTERN_H_
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: doc-main.h:25
Class to store positions of observed reflections.
Definition: Indexing.h:117
Phase to compute a background contribution to a powder pattern using an interpolation.
Class to compute the contribution to a powder pattern from a crystalline phase.
Powder pattern class, with an observed pattern and several calculated components to modelize the patt...
Pseudo-Voigt reflection profile.
Pseudo-Voigt reflection profile, with 6-parameters anisotropic Lorentzian broadening and Toraya asymm...
Double-Exponential Pseudo-Voigt profile for TOF.
One texture phase for the March-Dollase model.
Texture correction using the March-Dollase model.
Texture correction using the Ellipsoidal preferred orientation function.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:140
Abstract base class for all objects in wxCryst.
Definition: wxCryst.h:128
A List of WXCrystObjBasic.
Definition: wxCryst.h:197
Base class for all displayed ObjCryst objects (with a title, and a sizer to stack objects).
Definition: wxCryst.h:249
Class to pick one choice...
Definition: wxCryst.h:483
WX Class for PowderPattern objects.
void OnMenuLeBail(wxCommandEvent &event)
Profile fitting & Le Bail intensity extraction.
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 UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
bool mPowderPatternWasPreviouslyEmpty
This flag is used to automatically open the powder pattern graph once data has been loaded.
Class to display a Powder Pattern (calc,obs) in a graphic window.
bool mDisplayPeak
Display peaks ?
CrystMutex mMutex
Mutex to lock the pattern and associated data.
PeakList mPeakList
List of observed peak positions.
REAL mDraggingX0
Remember coordinates at the beginning of the dragging.
list< list< pair< const REAL,const string > > > mvLabelList
The lists of labels for all components of the powder pattern.
bool mIsDragging
Are we within a dragging event ?
void OnMouse(wxMouseEvent &event)
Display the Theta and intensity values at the mouse position, in the status bar.
void OnChangePeak(wxCommandEvent &WXUNUSED(event))
Add or remove peak.
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.
long Data2ScreenY(const REAL y) const
Convert Y data (intensity) coordinate to screen coordinate (pixel)
void OnPaint(wxPaintEvent &WXUNUSED(event))
Redraw the spectrum.
REAL Screen2DataX(const long x) const
Convert X screen coordinate (pixel) to data (2theta) coordinate.
void OnUpdate(wxCommandEvent &WXUNUSED(event))
Update the powder spectrum, at the user's request.
void OnLeBail(wxCommandEvent &event)
Profile fitting & Le Bail intensity extraction.
REAL Screen2DataY(const long y) const
Convert Y screen coordinate (pixel) to data (intensity) coordinate.
void OnRedrawNewPattern(wxUpdateUIEvent &WXUNUSED(event))
Redraw the pattern (special function to ensure complete redrawing under windows......
long Data2ScreenX(const REAL x) const
Convert X data (2theta) coordinate to screen coordinate (pixel)
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)...
RefinableObjClock mClockAxisLimits
Clock corresponding to when the graph limits where last changed.
bool mDisplayLabel
Display labels ?
long Point2ScreenX(const long x) const
Convert X data (as data point index) to screen coordinate (pixel)
void ResetAxisLimits()
Reset the limits of the axis to full range.
wxMenu * mpPopUpMenu
Pop-up menu.
WXPowderPatternGraph(wxFrame *frame, WXPowderPattern *parent)
Constructor. The top frame should have a Status bar with two fields (at least)
void OnMouseWheel(wxMouseEvent &event)
Wheel wan be used to scroll the pattern.
CrystVector_REAL mX
Data vectors (Note that when x coordinates are 2theta, they are stored in degrees here)
bool mDefaultIntensityScale
True if no vertical zoom has been used.
Class to display a Powder Pattern Background.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
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...
bool mNeedUpdateUI
True if the list of points has changed since last displayed.
CrystVector_REAL mBackgroundInterpPointX
Copy of the list of points and intensity.
Class to display one Preferred Orientation phase using the March-Dollase parametrization.
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...
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
Class to display the Preferred Orientation Correction using the March-Dollase parametrization.
Class to display one Preferred Orientation phase using the Ellipsoid model.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
Class to display a Powder Pattern for a crystalline phase.
void OnLeBail(wxCommandEvent &event)
Perform Le Bail extraction.
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 OnFreezeLatticePar(wxCommandEvent &event)
Freeze lattice parameter, which will not follow anymore the Crystal Unitcell values.
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
Class to display a Powder Pattern Pseudo-Voigt Profile.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
Class to display a Powder Pattern Pseudo-Voigt Profile with Anisotropic broadening.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
Class to display a Powder Pattern Pseudo-Voigt Profile.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
This displays all components of a ObjCryst++ Registry.
The base wxCryst class for all RefinableObj objects.