FOX/ObjCryst++  1.10.X (development)
wxAtom.cpp
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 //#include <sstream> //for stringstream
20 #include <fstream>
21 
22 // wx headers, with or without precompilation
23 #include "wx/wxprec.h"
24 #ifdef __BORLANDC__
25  #pragma hdrstop
26 #endif
27 #ifndef WX_PRECOMP
28  #include "wx/wx.h"
29 #endif
30 
31 #include "ObjCryst/wxCryst/wxAtom.h"
32 //Fixes for Cygwin; where do those stupid macros come from ? Somewhere in wxMSW headers
33 #ifdef max
34 #undef max
35 #endif
36 #ifdef min
37 #undef min
38 #endif
39 #ifdef DrawText
40 #undef DrawText
41 #endif
42 
43 namespace ObjCryst
44 {
46 //
47 // WXAtom
48 //
50 static const long ID_ATOM_SCATTPOW=WXCRYST_ID();
51 
52 BEGIN_EVENT_TABLE(WXAtom,wxWindow)
53  EVT_BUTTON(ID_ATOM_SCATTPOW, WXAtom::OnChangeScattPow)
54 END_EVENT_TABLE()
55 
56 WXAtom::WXAtom(wxWindow* parent, Atom *obj):
57 WXScatterer(parent,obj),mpAtom(obj)
58 {
59  VFN_DEBUG_MESSAGE("WXAtom::WXAtom()",6)
60  //mpFieldScattPower=new WXFieldName(this,"Symbol:",this,-1);
61  mpFieldScattPower=new WXFieldChoice(this,ID_ATOM_SCATTPOW,"Scattering Power:");
62  mpSizer->Add(mpFieldScattPower,0,wxALIGN_LEFT);
63  mList.Add(mpFieldScattPower);
64 
65  this->BottomLayout(0);
66  this->CrystUpdate(true,true);
67 }
68 WXAtom::~WXAtom()
69 {
70  mpAtom->WXNotifyDelete();
71 }
72 
73 void WXAtom::OnChangeScattPow(wxCommandEvent & WXUNUSED(event))
74 {
75  VFN_DEBUG_MESSAGE("WXAtom::OnChangeScattPow()",6)
76  int choice;
77  const ScatteringPower *scatt=
79  (mpAtom->GetCrystal().GetScatteringPowerRegistry(),(wxWindow*)this,
80  "Choose a new Scattering Power",choice);
81  if(0==scatt) return;
82  mpAtom->Init(mpAtom->GetX(),mpAtom->GetY(),mpAtom->GetZ(),mpAtom->GetName(),
83  scatt,mpAtom->GetOccupancy());
84  this->CrystUpdate(true,true);
85 }
86 
87 void WXAtom::UpdateUI(const bool lock)
88 {
89  mpFieldScattPower->SetValue(mpAtom->GetScatteringPower().GetName());
91 }
92 
93 
94 }// namespace
95 
T * WXDialogChooseFromRegistry(ObjRegistry< T > &reg, wxWindow *parent, const string &message, int &choice)
This function allows to pick up one object in a registry.
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.
Definition: wxAtom.cpp:87
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
virtual const string & GetName() const
Name of the object.
const ScatteringPower & GetScatteringPower() const
Get the ScatteringPowerAtom corresponding to this atom.
Definition: Atom.cpp:470