26 #ifndef _VFN_WX_CRYSTAL_H_
27 #define _VFN_WX_CRYSTAL_H_
30 #include "boost/shared_ptr.hpp"
32 #include "ObjCryst/wxCryst/wxRefinableObj.h"
34 #include "wx/glcanvas.h"
36 #include "wx/clrpicker.h"
38 #include "ObjCryst/ObjCryst/Crystal.h"
41 #include "ObjCryst/wxCryst/MC.h"
64 class WXGLCrystalCanvas;
85 virtual void CrystUpdate(
const bool updateUI=
false,
const bool mutexlock=
false);
87 void UpdateGL(
const bool onlyIndependentAtoms=
false,
89 const REAL xMin=-.1,
const REAL xMax=1.1,
90 const REAL yMin=-.1,
const REAL yMax=1.1,
91 const REAL zMin=-.1,
const REAL zMax=1.1);
95 int GetCrystalGLDisplayList(
const bool atomName=
false)
const;
97 void OnMenuCrystalGL(wxCommandEvent & WXUNUSED(event));
99 void NotifyCrystalGLDelete();
101 WXGLCrystalCanvas * GetCrystalGL();
103 void OnMenuSaveCIF(wxCommandEvent & WXUNUSED(event));
104 void OnMenuSaveText(wxCommandEvent & WXUNUSED(event));
105 void OnMenuAddScattPowAtom(wxCommandEvent & WXUNUSED(event));
106 void OnMenuAddScattPowSphere(wxCommandEvent & WXUNUSED(event));
107 void OnMenuRemoveScattPow(wxCommandEvent & WXUNUSED(event));
108 void OnMenuAddScatterer(wxCommandEvent & event);
109 void OnMenuRemoveScatterer(wxCommandEvent & WXUNUSED(event));
110 void OnMenuDuplicateScatterer(wxCommandEvent & WXUNUSED(event));
111 void OnMenuImportMoleculeFromFenskeHallZMatrix(wxCommandEvent &event);
112 void OnMenuAtoms2Molecule(wxCommandEvent &event);
113 void OnMenuSetRelativeXYZLimits(wxCommandEvent & WXUNUSED(event));
114 void OnMenuTestRandomMoves(wxCommandEvent &event);
116 void UpdateUI(
const bool mutexlock=
false);
118 const Crystal& GetCrystal()
const;
119 void OnMenuShowScattPowWindow(wxCommandEvent &event);
120 void OnEditGridScattPow(wxGridEvent &e);
121 void OnEditGridScattPowAntiBump(wxGridEvent &e);
122 void OnEditGridScattPowBondValence(wxGridEvent &e);
125 virtual bool Enable(
bool enable=
true);
141 REAL
mBiso,mFormalCharge,mR,mG,mB,mMaximumLikelihoodError,mNbGhostAtoms;
156 std::map<ScatteringPowerAtom*,RowScattPow> mvpRowScattPow;
165 unsigned int mCrystalGLDisplayList;
168 unsigned int mCrystalGLNameDisplayList;
170 WXGLCrystalCanvas* mpCrystalGL;
179 DECLARE_EVENT_TABLE()
192 UnitCellMap(
const Crystal&crystal);
197 void GLInitDisplayList(
const float contourValue,
198 WXGLCrystalCanvas * parentCrystal)
const;
200 void POVRayDescription(ostream &os,
const float contourValue,
206 int ImportGRD(
const string&filename);
211 int ImportDSN6(
const string&filename);
219 int CalcFourierMap(
const ScatteringData& data,
unsigned int type=0,
const bool normalized_sf=
false);
221 const string & GetName()
const;
224 REAL GetValue(
const REAL x,
const REAL y,
const REAL z)
const;
232 REAL StandardDeviation()
const;
236 const Crystal &GetCrystal()
const;
246 CrystArray3D_REAL mPoints;
254 REAL mStandardDeviation;
261 struct UnitCellMapGLList
264 UnitCellMapGLList(
const UnitCellMap &ucmap,WXGLCrystalCanvas * parent,
265 const bool showWire=
true,
float contour=1.0,
266 const float r=1.0,
const float g=0.0,
const float b=0.0,
const float t=0.5);
267 ~UnitCellMapGLList();
271 void SetName(
const string &name);
273 const string &GetName()
const;
275 void SetColour(
const float r=1.0,
const float g=0.0,
const float b=0.0,
278 const float* GetColour()
const;
280 void ToggleShowWire();
282 bool ShowWire()
const;
286 void SetShow(
bool show);
290 void SetContour(
float contour);
292 float GetContour()
const;
294 const UnitCellMap & GetMap()
const;
297 unsigned int mGLDisplayList;
309 const UnitCellMap *mpUCMap;
311 WXGLCrystalCanvas *mpParent;
315 class WXGLCrystalCanvas :
public wxGLCanvas
318 WXGLCrystalCanvas(WXCrystal *wxcryst,
319 wxFrame *parent, wxWindowID
id=-1,
320 const wxPoint &pos=wxDefaultPosition,
321 const wxSize &size=wxDefaultSize);
322 ~WXGLCrystalCanvas();
323 void OnExit(wxCommandEvent &event);
324 void OnPaint(wxPaintEvent &event);
326 void OnEraseBackground(wxEraseEvent& event);
327 void OnKeyDown(wxKeyEvent& event);
328 void OnKeyUp(wxKeyEvent& event);
329 void OnEnterWindow( wxMouseEvent& event );
330 void OnMouse( wxMouseEvent& event );
332 void OnUpdate(wxCommandEvent & WXUNUSED(event));
335 void OnChangeLimits(wxCommandEvent &event);
337 void OnUpdateUI(wxUpdateUIEvent& WXUNUSED(event));
338 void OnShowCrystal(wxCommandEvent & WXUNUSED(event));
339 void OnShowAtomLabel(wxCommandEvent & WXUNUSED(event));
340 void OnShowHydrogens(wxCommandEvent & WXUNUSED(event));
342 bool GetShowHydrogens()
const;
343 void OnShowCursor(wxCommandEvent & WXUNUSED(event));
344 void OnSetCursor(wxCommandEvent & WXUNUSED(event));
346 void OnFourier(wxCommandEvent &event);
348 void OnLoadFourierGRD(wxCommandEvent & WXUNUSED(event));
349 void OnLoadFourierDSN6(wxCommandEvent & WXUNUSED(event));
350 void AddFourier(UnitCellMap*);
351 void OnAddContour(wxCommandEvent & WXUNUSED(event));
352 void OnChangeContour(wxCommandEvent & WXUNUSED(event));
353 void OnShowFourier(wxCommandEvent & WXUNUSED(event));
354 void OnFourierChangeColour(wxColourPickerEvent & event);
355 void OnUnloadFourier(wxCommandEvent & WXUNUSED(event));
356 void OnShowWire(wxCommandEvent & WXUNUSED(event));
357 void OnFourierChangeBbox(wxCommandEvent & WXUNUSED(event));
359 void OnPOVRay(wxCommandEvent & WXUNUSED(event));
361 void POVRayOutput(
const std::string &filename);
366 virtual void SetCurrent();
367 void NotifyDeleteFourierWin();
372 int UserSelectUnitCellMapGLList()
const;
375 int UserSelectUnitCellMap()
const;
388 void UnProject(REAL &x, REAL &y, REAL &z);
392 void DeleteGLFont()
const;
394 wxFrame* mpParentFrame;
396 WXCrystal* mpWXCrystal;
398 wxGLContext *mpwxGLContext;
404 float mTrackBallLastX,mTrackBallLastY;
414 bool mShowFourier, mShowCrystal, mShowAtomName, mShowHydrogens, mShowCursor,mSharpenMap;
427 vector<boost::shared_ptr<UnitCellMap> > mvpUnitCellMap;
431 vector<boost::shared_ptr<UnitCellMapGLList> > mvpUnitCellMapGLList;
434 mutable bool mIsGLFontBuilt;
435 mutable int mGLFontDisplayListBase;
437 class WXFourierMapList:
public wxWindow
440 WXFourierMapList(WXGLCrystalCanvas *pGLCrystalCanvas,wxWindow *parent);
442 wxCheckBox *mpWireFrame;
443 wxCheckBox *mpShowFourier;
444 wxCheckBox *mpSharpenMap;
445 wxListBox *mpAvailableMapList;
446 wxListBox *mpDisplayedMapList;
447 wxStaticText *mpMapInfo;
448 wxTextCtrl *mpNewContourValue;
449 wxTextCtrl *mpContourValue;
450 wxColourPickerCtrl *mpColourPicker;
451 WXGLCrystalCanvas *mpGLCrystalCanvas;
455 WXFourierMapList *mpFourierMapListWin;
456 DECLARE_EVENT_TABLE()
463 #endif //_VFN_WX_CRYSTAL_H_
WXCrystal * mpWXCrystal
The WXCrystal window which created this window, and who should be told if it is destroyed.
bool mIsSelfUpdating
Flag to indicate that we are updating values in the wxGrid data, and that it is not the user inputing...
int mIdx
Current position in the list of rows or columns.
std::vector< REAL > mvAntiBumpDistance
Last displayed values for antibump.
bool mNeedUpdateUI
True if we need to update the displayed values.
bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
Structure to store the scattering power parameters.
REAL mBiso
Last displayed values.
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...
A field with the name of a WXCrystObj.
wxMutex mMutexGLUpdate
Mutex used when updating the OpenGL display List, between background and main thread.
This displays all components of a ObjCryst++ Registry.
Class to compute structure factors for a set of reflections and a Crystal.
WXRegistry< Scatterer > * mpWXScattererRegistry
Scatterers.
Class to store POV-Ray output options.
wxCryst class for Crystals
WXFieldName * mpFieldSpacegroup
SpaceGroup.
The base wxCryst class for all RefinableObj objects.
WXRegistry< ScatteringPower > * mpWXScatteringPowerRegistry
Scattering Powers.
std::vector< REAL > mvBondValenceRo
Last displayed values for bond valence.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
wxCondition * mpConditionGLUpdate
wxCondition used when updating the OpenGL display List, between background and main thread ...
Crystal class: Unit cell, spacegroup, scatterers.
void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.