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);
88 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,
92 const REAL fadeDistance=0,
93 const bool fullMoleculeInLimits=
false);
97 int GetCrystalGLDisplayList(
const bool atomName=
false)
const;
99 void OnMenuCrystalGL(wxCommandEvent & WXUNUSED(event));
101 void NotifyCrystalGLDelete();
103 WXGLCrystalCanvas * GetCrystalGL();
105 void OnMenuSaveCIF(wxCommandEvent & WXUNUSED(event));
106 void OnMenuSaveText(wxCommandEvent & WXUNUSED(event));
107 void OnMenuAddScattPowAtom(wxCommandEvent & WXUNUSED(event));
108 void OnMenuAddScattPowSphere(wxCommandEvent & WXUNUSED(event));
109 void OnMenuRemoveScattPow(wxCommandEvent & WXUNUSED(event));
110 void OnMenuAddScatterer(wxCommandEvent & event);
111 void OnMenuAddIntermolecularDistRestr(wxCommandEvent & event);
112 void OnMenuRemoveIntermolecularDistRestr(wxCommandEvent & event);
113 void OnMenuRemoveScatterer(wxCommandEvent & WXUNUSED(event));
114 void OnMenuDuplicateScatterer(wxCommandEvent & WXUNUSED(event));
115 void OnMenuImportMoleculeFromFenskeHallZMatrix(wxCommandEvent &event);
116 void OnMenuAtoms2Molecule(wxCommandEvent &event);
117 void OnMenuSetRelativeXYZLimits(wxCommandEvent & WXUNUSED(event));
118 void OnMenuTestRandomMoves(wxCommandEvent &event);
120 void UpdateUI(
const bool mutexlock=
false);
122 const Crystal& GetCrystal()
const;
123 void OnMenuShowScattPowWindow(wxCommandEvent &event);
124 void OnMenuShowIntermoDistWindow(wxCommandEvent &event);
125 void OnEditGridIntermolDistWindow(wxGridEvent &e);
126 void OnEditGridScattPow(wxGridEvent &e);
127 void OnEditGridScattPowAntiBump(wxGridEvent &e);
128 void OnEditGridScattPowBondValence(wxGridEvent &e);
131 virtual bool Enable(
bool enable=
true);
147 REAL
mBiso,mFormalCharge,mR,mG,mB,mMaximumLikelihoodError,mNbGhostAtoms;
163 std::map<ScatteringPowerAtom*,RowScattPow> mvpRowScattPow;
172 unsigned int mCrystalGLDisplayList;
175 unsigned int mCrystalGLNameDisplayList;
177 WXGLCrystalCanvas* mpCrystalGL;
186 DECLARE_EVENT_TABLE()
199 UnitCellMap(
const Crystal&crystal);
204 void GLInitDisplayList(
const float contourValue,
205 WXGLCrystalCanvas * parentCrystal)
const;
207 void POVRayDescription(ostream &os,
const float contourValue,
213 int ImportGRD(
const string&filename);
218 int ImportDSN6(
const string&filename);
226 int CalcFourierMap(
const ScatteringData& data,
unsigned int type=0,
const bool normalized_sf=
false);
229 const string & GetName()
const;
231 REAL GetValue(
const REAL x,
const REAL y,
const REAL z)
const;
239 REAL StandardDeviation()
const;
243 const Crystal &GetCrystal()
const;
253 CrystArray3D_REAL mPoints;
261 REAL mStandardDeviation;
268 struct UnitCellMapGLList
271 UnitCellMapGLList(
const UnitCellMap &ucmap,WXGLCrystalCanvas * parent,
272 const bool showWire=
true,
float contour=1.0,
273 const float r=1.0,
const float g=0.0,
const float b=0.0,
const float t=0.5);
274 ~UnitCellMapGLList();
278 void SetName(
const string &name);
280 const string &GetName()
const;
282 void SetColour(
const float r=1.0,
const float g=0.0,
const float b=0.0,
285 const float* GetColour()
const;
287 void ToggleShowWire();
289 bool ShowWire()
const;
293 void SetShow(
bool show);
297 void SetContour(
float contour);
299 float GetContour()
const;
301 const UnitCellMap & GetMap()
const;
304 unsigned int mGLDisplayList;
316 const UnitCellMap *mpUCMap;
318 WXGLCrystalCanvas *mpParent;
322 class WXGLCrystalCanvas :
public wxGLCanvas
325 WXGLCrystalCanvas(WXCrystal *wxcryst,
326 wxFrame *parent, wxWindowID
id=-1,
327 const wxPoint &pos=wxDefaultPosition,
328 const wxSize &size=wxDefaultSize);
329 ~WXGLCrystalCanvas();
330 void OnExit(wxCommandEvent &event);
331 void OnPaint(wxPaintEvent &event);
333 void OnEraseBackground(wxEraseEvent& event);
334 void OnKeyDown(wxKeyEvent& event);
335 void OnKeyUp(wxKeyEvent& event);
336 void OnEnterWindow( wxMouseEvent& event );
337 void OnMouse( wxMouseEvent& event );
339 void OnUpdate(wxCommandEvent & WXUNUSED(event));
342 void OnChangeLimits(wxCommandEvent &event);
344 void OnUpdateUI(wxUpdateUIEvent& WXUNUSED(event));
345 void OnShowCrystal(wxCommandEvent & WXUNUSED(event));
346 void OnShowAtomLabel(wxCommandEvent & WXUNUSED(event));
347 void OnShowHydrogens(wxCommandEvent & WXUNUSED(event));
349 bool GetShowHydrogens()
const;
350 void OnShowCursor(wxCommandEvent & WXUNUSED(event));
351 void OnSetCursor(wxCommandEvent & WXUNUSED(event));
353 void OnShowHelp(wxCommandEvent & WXUNUSED(event));
355 void OnFourier(wxCommandEvent &event);
357 void OnLoadFourierGRD(wxCommandEvent & WXUNUSED(event));
358 void OnLoadFourierDSN6(wxCommandEvent & WXUNUSED(event));
359 void AddFourier(UnitCellMap*);
360 void OnAddContour(wxCommandEvent & WXUNUSED(event));
361 void OnChangeContour(wxCommandEvent & WXUNUSED(event));
362 void OnShowFourier(wxCommandEvent & WXUNUSED(event));
363 void OnFourierChangeColour(wxColourPickerEvent & event);
364 void OnUnloadFourier(wxCommandEvent & WXUNUSED(event));
365 void OnShowWire(wxCommandEvent & WXUNUSED(event));
366 void OnFourierChangeBbox(wxCommandEvent & WXUNUSED(event));
368 void OnPOVRay(wxCommandEvent & WXUNUSED(event));
370 void POVRayOutput(
const std::string &filename);
376 REAL GetFadeDistance();
377 virtual void SetCurrent();
378 void NotifyDeleteFourierWin();
383 int UserSelectUnitCellMapGLList()
const;
386 int UserSelectUnitCellMap()
const;
399 void UnProject(REAL &x, REAL &y, REAL &z);
403 void DeleteGLFont()
const;
405 wxFrame* mpParentFrame;
407 WXCrystal* mpWXCrystal;
409 wxGLContext *mpwxGLContext;
415 float mTrackBallLastX,mTrackBallLastY;
425 bool mShowFourier, mShowCrystal, mShowAtomName, mShowHydrogens, mShowCursor, mSharpenMap, mShowHelp, mShowFullMolecule, mWhiteBackground;
438 vector<boost::shared_ptr<UnitCellMap> > mvpUnitCellMap;
442 vector<boost::shared_ptr<UnitCellMapGLList> > mvpUnitCellMapGLList;
445 mutable bool mIsGLFontBuilt;
446 mutable int mGLFontDisplayListBase;
448 class WXFourierMapList:
public wxWindow
451 WXFourierMapList(WXGLCrystalCanvas *pGLCrystalCanvas,wxWindow *parent);
453 wxCheckBox *mpWireFrame;
454 wxCheckBox *mpShowFourier;
455 wxCheckBox *mpSharpenMap;
456 wxListBox *mpAvailableMapList;
457 wxListBox *mpDisplayedMapList;
458 wxStaticText *mpMapInfo;
459 wxTextCtrl *mpNewContourValue;
460 wxTextCtrl *mpContourValue;
461 wxColourPickerCtrl *mpColourPicker;
462 WXGLCrystalCanvas *mpGLCrystalCanvas;
466 WXFourierMapList *mpFourierMapListWin;
469 DECLARE_EVENT_TABLE()
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Crystal class: Unit cell, spacegroup, scatterers.
Class to store POV-Ray output options.
Class to compute structure factors for a set of reflections and a Crystal.
A field with the name of a WXCrystObj.
WXCrystal * mpWXCrystal
The WXCrystal window which created this window, and who should be told if it is destroyed.
wxCryst class for Crystals
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.
wxCondition * mpConditionGLUpdate
wxCondition used when updating the OpenGL display List, between background and main thread
WXRegistry< ScatteringPower > * mpWXScatteringPowerRegistry
Scattering Powers.
bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.
bool mIsSelfUpdating
Flag to indicate that we are updating values in the wxGrid data, and that it is not the user inputing...
WXRegistry< Scatterer > * mpWXScattererRegistry
Scatterers.
wxMutex mMutexGLUpdate
Mutex used when updating the OpenGL display List, between background and main thread.
WXFieldName * mpFieldSpacegroup
SpaceGroup.
Structure to store the scattering power parameters.
REAL mBiso
Last displayed values.
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.
std::vector< REAL > mvBondValenceRo
Last displayed values for bond valence.
This displays all components of a ObjCryst++ Registry.
The base wxCryst class for all RefinableObj objects.