FOX/ObjCryst++  1.10.X (development)
wxScatteringPowerSphere.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/wxScatteringPowerSphere.h"
32 
33 //Fixes for Cygwin; where do those stupid macros come from ? Somewhere in wxMSW headers
34 #ifdef max
35 #undef max
36 #endif
37 #ifdef min
38 #undef min
39 #endif
40 #ifdef DrawText
41 #undef DrawText
42 #endif
43 
44 namespace ObjCryst
45 {
47 //
48 // WXScatteringPowerSphere
49 //
51 static const long ID_SCATTPOWATOM_MENU_COLOUR=WXCRYST_ID();
52 static const long ID_SCATTPOWATOM_MENU_COLOUR_SETRGB=WXCRYST_ID();
53 
54 BEGIN_EVENT_TABLE(WXScatteringPowerSphere, wxWindow)
55  EVT_MENU(ID_SCATTPOWATOM_MENU_COLOUR_SETRGB, WXScatteringPowerSphere::OnChangeColour)
56  EVT_UPDATE_UI(ID_CRYST_UPDATEUI, WXRefinableObj::OnUpdateUI)
57 END_EVENT_TABLE()
58 
59 WXScatteringPowerSphere::WXScatteringPowerSphere(wxWindow* parent,
60  ScatteringPowerSphere *obj):
61 WXRefinableObj(parent,(RefinableObj*)obj),mpScatteringPower(obj)
62 {
63  VFN_DEBUG_MESSAGE("WXScatteringPowerSphere::ScatteringPowerSphere()",6)
64  mpWXTitle->SetForegroundColour(wxColour(0,200,0));
65  //Lattice
66  mpMenuBar->AddMenu("Colour",ID_SCATTPOWATOM_MENU_COLOUR);
67  mpMenuBar->AddMenuItem(ID_SCATTPOWATOM_MENU_COLOUR,
68  ID_SCATTPOWATOM_MENU_COLOUR_SETRGB,"Set RGB Colour");
69  WXCrystObjBasic* pFieldRadius=
70  mpScatteringPower->GetPar(&(mpScatteringPower->mRadius)).WXCreate(this);
71  WXCrystObjBasic* pFieldBiso=
72  mpScatteringPower->GetPar(&(mpScatteringPower->mBiso )).WXCreate(this);
73 
74  mpSizer->Add(pFieldRadius,0,wxALIGN_LEFT);
75  mList.Add(pFieldRadius);
76  mpSizer->Add(pFieldBiso,0,wxALIGN_LEFT);
77  mList.Add(pFieldBiso);
78  this->CrystUpdate(true);
79  this->Layout();
80 }
81 
82 bool WXScatteringPowerSphere::OnChangeName(const int id)
83 {
84  VFN_DEBUG_MESSAGE("WXScatteringPowerSphere::OnChangeName()",6)
85  if(this->WXRefinableObj::OnChangeName(id)==true) return true;
86  return false;
87 }
88 
89 void WXScatteringPowerSphere::OnChangeColour(wxCommandEvent & event)
90 {
91  const float* oldColour=mpScatteringPower->GetColourRGB();
92  double r,g,b;
93  r=oldColour[0];
94  g=oldColour[1];
95  b=oldColour[2];
96  //red
97  {
98  wxString str;
99  str<<r;
100  wxTextEntryDialog dialog(this,_T("Red"),
101  _T("Enter Red component (0.<r<1.)"),str,wxOK | wxCANCEL);
102  if(wxID_OK!=dialog.ShowModal())
103  {
104  VFN_DEBUG_EXIT("WXScatteringPowerSphere::OnChangeColour():Cancelled",6)
105  return;
106  }
107  dialog.GetValue().ToDouble(&r);
108  }
109  //green
110  {
111  wxString str;
112  str<<g;
113  wxTextEntryDialog dialog(this,_T("Green"),
114  _T("Enter Green component (0.<g<1.)"),str,wxOK | wxCANCEL);
115  if(wxID_OK!=dialog.ShowModal())
116  {
117  VFN_DEBUG_EXIT("WXScatteringPowerSphere::OnChangeColour():Cancelled",6)
118  return;
119  }
120  dialog.GetValue().ToDouble(&g);
121  }
122  //Blue
123  {
124  wxString str;
125  str<<b;
126  wxTextEntryDialog dialog(this,_T("Blue"),
127  _T("Enter Blue component (0.<b<1.)"),str,wxOK | wxCANCEL);
128  if(wxID_OK!=dialog.ShowModal())
129  {
130  VFN_DEBUG_EXIT("WXScatteringPowerSphere::OnChangeColour():Cancelled",6)
131  return;
132  }
133  dialog.GetValue().ToDouble(&b);
134  }
135  mpScatteringPower->SetColour(r,g,b);
136 }
137 
138 void WXScatteringPowerSphere::UpdateUI(const bool lock)
139 {
140  this->WXRefinableObj::UpdateUI(lock);
141 }
142 
143 }// namespace
144 
virtual void UpdateUI(const bool mutexlock=false)
Update the User Interface, if necessary.
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
wxCryst class for ScatteringPowerSphere
const float * GetColourRGB() const
Get the float[3] array of RGB components defining the colour of this scattering power.
virtual bool OnChangeName(const int id)
When a WXFieldName has been changed by the user, it is handled here.