1 /*
2  Implement preferences...    -Song Li
3 */
4 
5 //Make some useful preferences related definitions
6 
7 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
8 #pragma implementation "PrefsPanes.h"
9 #endif
10 #include "Globals.h"
11 
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14 
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18 
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22 
23 //put ID definitions here later
24 #define kAtomPrefsPane		1
25 #define kBondPrefsPane		2
26 #define kDisplayPrefsPane	3
27 #define kEPrefsPane			4
28 #define kFontPrefsPane		5
29 #define kFilePrefsPane		6
30 #define kScalingPrefsPane	7
31 #define kStereoPrefsPane	8
32 #define kSurfacePrefsPane	9
33 #define kQD3DPrefsPane		10
34 
35 #define ID_SHOW_NORMAL_MODE_ANIMATION 5000
36 #define ID_SHOW_NORMAL_MODE_ROTATION 5001
37 #define ID_NORMAL_MODE_SCALING_SLIDER 5002
38 #define ID_BOND_MODE_CHOICE 5003
39 #define ID_DISPLAY_MODE_RADIOBOX 5004
40 #define ID_COLOR_BONDS_BY_ATOM_COLOR 5005
41 #define ID_ATOM_LABELS_RADIO 5006
42 #define ID_PLOT_BALL_SIZE_SLIDER 5007
43 #define ID_AUTO_BOND_PASTE_OPEN 5008
44 #define ID_GUESS_BOND_ORDER 5009
45 #define ID_PREVENT_HH_BONDS 5010
46 #define ID_LOOK_HYDROGEN_BONDS 5011
47 #define ID_SHOW_ANGLES_WHILE_ROTATING 5012
48 #define ID_USE_MAC_EOL_CHAR 5013
49 #define ID_PROMPT_SAVE_FILE 5014
50 #define ID_CREATE_CUSTOM_FILE_ICON 5015
51 #define ID_CHANGE_FILE_CREATOR 5016
52 #define ID_AUTO_BOND_TOLERANCE_SLIDER 5017
53 #define ID_ATOM_SIZE_SLIDER 5018
54 #define ID_DEPTH_CUEING_SLIDER 5019
55 #define ID_ANIM_QUALITY_SLIDER 5020
56 #define ID_FRAME_DELAY_SLIDER 5021
57 #define ID_STEREO_ACTIVE 5022
58 #define ID_NUM_GRID_POINT_SLIDER 5023
59 #define ID_3D_GRID_SIZE_SLIDER 5024
60 #define ID_SHOW_ZERO_VALUE_CONTOUR 5025
61 #define ID_SHOW_ATOM_POSITION 5026
62 #define ID_BOND_SIZE_SLIDER 5027
63 #define ID_DISPLAY_QUALITY_SLIDER 5028
64 #define ID_FILL_LIGHT_BRIGHTNESS_SLIDER 5029
65 #define ID_POINT_LIGHT_BRIGHTNESS_SLIDER 5030
66 #define ID_LINE_WIDTH_SLIDER 5031
67 #define ID_3D_AUTO_ROTATE_CHECK 5032
68 #define ID_TOTAL_ENERGY 5033
69 #define ID_MP2_ENERGY 5034
70 #define ID_POTENTIAL_ENERGY 5035
71 #define ID_UNIT_RADIOBOX 5036
72 #define ID_MISC_RADIOBOX 5037
73 #define ID_DISPLAY_DEPTH_SLIDER	5038
74 #define ID_ATOM_LABEL_SLIDER	5039
75 #define ID_ANNOTATION_SLIDER	5040
76 #define ID_SHADER_CHOICE 5041
77 #define ID_3D_AUTOROTATIONX_SPIN 5042
78 #define ID_3D_AUTOROTATIONY_SPIN 5043
79 #define ID_GRADIENT_SCALING_SLIDER 5044
80 #define ID_GRADIENT_DISPLAY_BOX 5045
81 
82 #include "GlobalExceptions.h"
83 #include "MyTypes.h"
84 #include "Prefs.h"
85 #include "PrefsPanes.h"
86 #include "colorArea.h"
87 #include "mmp_gl.h"
88 #include <stdio.h>
89 #include <string.h>
90 #include <wx/colordlg.h>
91 
92 using namespace std;
93 
94 extern short gAppResRef;
95 
96 BEGIN_EVENT_TABLE(BondPrefsPane, wxPanel)
97 	EVT_CHOICE(ID_BOND_MODE_CHOICE, BondPrefsPane::OnChoice)
98 	EVT_SLIDER(ID_NORMAL_MODE_SCALING_SLIDER, BondPrefsPane::OnSliderUpdate)
99 	EVT_SLIDER(ID_GRADIENT_SCALING_SLIDER, BondPrefsPane::OnGradientSliderUpdate)
100 	EVT_CHECKBOX(ID_SHOW_NORMAL_MODE_ANIMATION, BondPrefsPane::OnToggleAnim)
101 	EVT_CHECKBOX(ID_SHOW_NORMAL_MODE_ROTATION, BondPrefsPane::OnToggleRotation)
102 	EVT_RADIOBOX(ID_GRADIENT_DISPLAY_BOX, BondPrefsPane::OnGradientRadioUpdate)
103 END_EVENT_TABLE()
104 
105 BEGIN_EVENT_TABLE(DisplayPrefsPane, wxPanel)
106 	EVT_RADIOBOX(ID_DISPLAY_MODE_RADIOBOX, DisplayPrefsPane::OnRadio)
107 	EVT_CHECKBOX(ID_COLOR_BONDS_BY_ATOM_COLOR, DisplayPrefsPane::OnCheckBox)
108 	EVT_RADIOBOX(ID_ATOM_LABELS_RADIO, DisplayPrefsPane::OnLabelsRadio)
109 	EVT_SLIDER(ID_ATOM_LABEL_SLIDER, DisplayPrefsPane::OnAtomLabelSlider)
110 	EVT_SLIDER(ID_ANNOTATION_SLIDER, DisplayPrefsPane::OnAnnotationLabelSlider)
111 END_EVENT_TABLE()
112 
113 BEGIN_EVENT_TABLE(EnergyPrefsPane, wxPanel)
114 	EVT_SLIDER(ID_PLOT_BALL_SIZE_SLIDER, EnergyPrefsPane::OnSliderUpdate)
115 	EVT_RADIOBOX(ID_UNIT_RADIOBOX, EnergyPrefsPane::OnRadio)
116 	EVT_RADIOBOX(ID_MISC_RADIOBOX, EnergyPrefsPane::OnRadio)
117 	EVT_CHECKBOX(ID_TOTAL_ENERGY, EnergyPrefsPane::OnCheckBox)
118 	EVT_CHECKBOX(ID_MP2_ENERGY, EnergyPrefsPane::OnCheckBox)
119 	EVT_CHECKBOX(ID_POTENTIAL_ENERGY, EnergyPrefsPane::OnCheckBox)
120 END_EVENT_TABLE()
121 
122 BEGIN_EVENT_TABLE(FilePrefsPane, wxPanel)
123 	EVT_CHECKBOX(ID_AUTO_BOND_PASTE_OPEN, FilePrefsPane::OnCheckBox)
124 	EVT_CHECKBOX(ID_GUESS_BOND_ORDER, FilePrefsPane::OnCheckBox)
125 	EVT_CHECKBOX(ID_PREVENT_HH_BONDS, FilePrefsPane::OnCheckBox)
126 	EVT_CHECKBOX(ID_LOOK_HYDROGEN_BONDS, FilePrefsPane::OnCheckBox)
127 	EVT_CHECKBOX(ID_SHOW_ANGLES_WHILE_ROTATING, FilePrefsPane::OnCheckBox)
128 	EVT_CHECKBOX(ID_USE_MAC_EOL_CHAR, FilePrefsPane::OnCheckBox)
129 	EVT_CHECKBOX(ID_PROMPT_SAVE_FILE, FilePrefsPane::OnCheckBox)
130 	EVT_CHECKBOX(ID_CREATE_CUSTOM_FILE_ICON, FilePrefsPane::OnCheckBox)
131 	EVT_CHECKBOX(ID_CHANGE_FILE_CREATOR, FilePrefsPane::OnCheckBox)
132 	EVT_SLIDER(ID_AUTO_BOND_TOLERANCE_SLIDER, FilePrefsPane::OnSliderUpdate)
133 END_EVENT_TABLE()
134 
135 BEGIN_EVENT_TABLE(ScalingPrefsPane, wxPanel)
136 	EVT_SLIDER(ID_ATOM_SIZE_SLIDER, ScalingPrefsPane::OnSliderUpdate)
137 	EVT_SLIDER(ID_ANIM_QUALITY_SLIDER, ScalingPrefsPane::OnSliderUpdate)
138 	EVT_SLIDER(ID_FRAME_DELAY_SLIDER, ScalingPrefsPane::OnSliderUpdate)
139 END_EVENT_TABLE()
140 
141 BEGIN_EVENT_TABLE(StereoPrefsPane, wxPanel)
142 	EVT_CHECKBOX(ID_STEREO_ACTIVE, StereoPrefsPane::OnCheckBox)
143 END_EVENT_TABLE()
144 
145 BEGIN_EVENT_TABLE(SurfacePrefsPane, wxPanel)
146 	EVT_SLIDER(ID_NUM_GRID_POINT_SLIDER, SurfacePrefsPane::OnSliderUpdate)
147 	EVT_SLIDER(ID_3D_GRID_SIZE_SLIDER, SurfacePrefsPane::OnSliderUpdate)
148 	EVT_CHECKBOX(ID_SHOW_ZERO_VALUE_CONTOUR, SurfacePrefsPane::OnCheckBox)
149 	EVT_CHECKBOX(ID_SHOW_ATOM_POSITION, SurfacePrefsPane::OnCheckBox)
150 END_EVENT_TABLE()
151 
152 BEGIN_EVENT_TABLE(QD3DPrefsPane, wxPanel)
153 	EVT_SLIDER(ID_BOND_SIZE_SLIDER, QD3DPrefsPane::OnSliderUpdate)
154 	EVT_SLIDER(ID_DISPLAY_QUALITY_SLIDER, QD3DPrefsPane::OnSliderUpdate)
155 	EVT_SLIDER(ID_FILL_LIGHT_BRIGHTNESS_SLIDER, QD3DPrefsPane::OnSliderUpdate)
156 	EVT_SLIDER(ID_POINT_LIGHT_BRIGHTNESS_SLIDER, QD3DPrefsPane::OnSliderUpdate)
157 	EVT_SLIDER(ID_LINE_WIDTH_SLIDER, QD3DPrefsPane::OnSliderUpdate)
158 	EVT_SLIDER(ID_DEPTH_CUEING_SLIDER, QD3DPrefsPane::OnSliderUpdate)
159 	EVT_CHOICE(ID_SHADER_CHOICE, QD3DPrefsPane::OnShaderChoice)
160 	EVT_SPINCTRL(ID_3D_AUTOROTATIONX_SPIN, QD3DPrefsPane::OnSpinChange)
161 	EVT_SPINCTRL(ID_3D_AUTOROTATIONY_SPIN, QD3DPrefsPane::OnSpinChange)
162 END_EVENT_TABLE()
163 
164 PrefsPane::PrefsPane(MolDisplayWin* /*targetWindow*/,
165 					 WinPrefs* targetPrefs,
166 					 short /*PaneID*/,
167 					 Boolean GlobalPrefs,
168 					 wxBookCtrlBase *parent)
169 	: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER) {
170 
171 	isGlobalPrefs = GlobalPrefs;
172 
173 	mTargetPrefs = targetPrefs;
174 }
175 
176 PrefsPane::~PrefsPane() {
177 }
178 
179 AtomPrefsPane::AtomPrefsPane(MolDisplayWin* targetWindow,
180 							 wxBookCtrlBase *parent, WinPrefs* targetPrefs,
181 							 Boolean Global)
182 	: PrefsPane(targetWindow, targetPrefs, kAtomPrefsPane, Global, parent) {
183 
184 	scroll_win = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition,
185 									  wxDefaultSize, wxVSCROLL);
186 
187 	mLabels[0] = wxString(wxT("Atom"));
188 	mLabels[1] = wxString(wxT("#"));
189 	mLabels[2] = wxString(wxT("size(pm)"));
190 	mLabels[3] = wxString(wxT("mass"));
191 	mLabels[4] = wxString(wxT("Color"));
192 	mLabels[5] = wxString(wxT("Pattern"));
193 
194 	mMainSizer = new wxFlexGridSizer(kMaxAtomTypes+1, NUM_ATOM_LABELS, 3, 10);
195 
196 	wxFlexGridSizer *sizer = new wxFlexGridSizer(1, 1, 0, 0);
197 	sizer->AddGrowableCol(0);
198 	sizer->AddGrowableRow(0);
199 	sizer->Add(scroll_win, wxSizerFlags().Expand());
200 	SetSizerAndFit(sizer);
201 
202  	scroll_win->SetSizer(mMainSizer);
203 	scroll_win->SetScrollRate(10, 10);
204 	scroll_win->SetVirtualSize(500, 1000);
205 	mMainSizer->Layout();
206 	scroll_win->FitInside();
207 
208 }
209 
210 AtomPrefsPane::~AtomPrefsPane() {
211 
212 	// These should be deleted by wx.
213 #if 0
214   for (int i = 0; i < kMaxAtomTypes; i++) {
215       delete mEleNames[i];
216       delete mEleSizes[i];
217       delete mEleMasses[i];
218       delete mColorArea[i];
219       delete mPatternArea[i];
220     }
221 #endif
222 
223 }
224 
225 void AtomPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
226 
227 	for (int i = 0; i < NUM_ATOM_LABELS; i++) {
228 		mMainSizer->Add(new wxStaticText(scroll_win, wxID_ANY, mLabels[i],
229 										 wxDefaultPosition, wxDefaultSize,
230 										 wxALIGN_CENTER),
231 						0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
232 	}
233 
234 	for (int i = 0; i < kMaxAtomTypes; i++) {
235 		wxString tmp;
236 		mTargetPrefs->GetAtomLabel(i, tmp);
237 		mEleNames[i] = new wxTextCtrl(scroll_win, wxID_ANY, tmp, wxDefaultPosition, wxSize(30, 20));
238 		mMainSizer->Add(mEleNames[i], 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
239 		tmp.Printf(wxT("%d"), i+1);
240 		mMainSizer->Add(new wxStaticText(scroll_win, wxID_ANY, tmp,
241 										 wxDefaultPosition, wxDefaultSize,
242 										 wxALIGN_CENTER),
243 						0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
244 
245 		tmp.Printf(wxT("%ld"),mTargetPrefs->GetAtomSize(i));
246 		mEleSizes[i] = new wxTextCtrl(scroll_win, wxID_ANY, tmp, wxDefaultPosition, wxSize(40, 20));
247 		mMainSizer->Add(mEleSizes[i], 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
248 
249 		tmp.Printf(wxT("%.2f"),mTargetPrefs->GetAtomMass(i));
250 		mEleMasses[i] = new wxTextCtrl(scroll_win, wxID_ANY, tmp, wxDefaultPosition, wxSize(50, 20));
251 		mMainSizer->Add(mEleMasses[i], 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
252 
253 		mColorArea[i] = new colorArea(scroll_win, i, mTargetPrefs->GetAtomColorLoc(i));
254 		mMainSizer->Add(mColorArea[i], 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
255 
256 		mPatternArea[i] = new colorPatternArea(scroll_win, i, mTargetPrefs->GetAtomColorLoc(i), mTargetPrefs->GetAtomPattern(i));
257 
258 		mMainSizer->Add(mPatternArea[i], 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
259 		mColorArea[i]->setPeer(mPatternArea[i]);
260 		mPatternArea[i]->setPeer(mColorArea[i]); //need to synchronize color if needed
261 	}
262 
263 }
264 
265 void AtomPrefsPane::saveToTempPrefs() {
266 	long size;
267 	double mass;
268 
269 	wxString tmp;
270 
271 	for (int i = 0; i < kMaxAtomTypes; i++) {
272 		mTargetPrefs->SetAtomLabel(i, mEleNames[i]->GetValue());
273 		(mEleSizes[i]->GetValue()).ToLong(&size);
274 		mTargetPrefs->SetAtomSize(i, size);
275 		(mEleMasses[i]->GetValue()).ToDouble(&mass);
276 		mTargetPrefs->SetAtomMass(i, mass);
277 		mColorArea[i]->getColor(mTargetPrefs->GetAtomColorLoc(i));
278 		mTargetPrefs->SetAtomPattern(i, mPatternArea[i]->getPattern());
279 	}
280 }
281 
282 BondPrefsPane::BondPrefsPane(MolDisplayWin* targetWindow,
283 							 wxBookCtrlBase *parent,
284 							 WinPrefs* targetPrefs,
285 							 Boolean Global)
286 	: PrefsPane(targetWindow, targetPrefs, kBondPrefsPane, Global, parent) {
287 
288 }
289 
290 BondPrefsPane::~BondPrefsPane() {
291 }
292 
293 void BondPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
294 	wxBoxSizer* lMainSizer = new wxBoxSizer(wxVERTICAL);
295 	wxBoxSizer* lUpperSizer = new wxBoxSizer(wxVERTICAL);
296 	wxFlexGridSizer* lSldSizer = new wxFlexGridSizer(2, 2, 0, 0);
297 	wxStaticBoxSizer* lBox = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("Bond and Arrow Colors"));
298 	wxBoxSizer* lLowerSizer = new wxBoxSizer(wxVERTICAL);
299 	wxFlexGridSizer* lInnerSizer = new wxFlexGridSizer(4, 2, 0, 0);
300 
301 	SetSizer(lMainSizer);
302 
303 	mChkAnim = new wxCheckBox(this, ID_SHOW_NORMAL_MODE_ANIMATION, _T("Show Normal Mode During Animation"), wxDefaultPosition);
304 	mChkAnim->SetValue(mTargetPrefs->GetAnimateMode());
305 	mChkRotation = new wxCheckBox(this, ID_SHOW_NORMAL_MODE_ROTATION, _T("Show Normal Mode During Rotation"), wxDefaultPosition);
306 	mChkRotation->SetValue(mTargetPrefs->GetRotateMode());
307 
308 	wxString gradientheader;
309 	if (PrefsAreGlobal()) gradientheader = wxString(_T("Default Energy First Derivative Display"));
310 	else gradientheader = wxString(_T("Energy First Derivative Display"));
311 	wxString gradientchoices[] = {_T("None"), _T("Energy First Derivative (Gradient)"), _T("(-) Energy First Derivative (Force)")};
312 	mGradientBox = new wxRadioBox(this, ID_GRADIENT_DISPLAY_BOX, gradientheader, wxDefaultPosition, wxDefaultSize, WXSIZEOF(gradientchoices), gradientchoices, 0, wxRA_SPECIFY_ROWS);
313 	if (mTargetPrefs->DisplayGradient()) {
314 		if (mTargetPrefs->InvertGradient()) mGradientBox->SetSelection(2);
315 		else mGradientBox->SetSelection(1);
316 	} else {
317 		mGradientBox->SetSelection(0);
318 	}
319 
320 	mSldScale = new wxSlider(this, ID_NORMAL_MODE_SCALING_SLIDER,
321 				(int)(mTargetPrefs->GetVectorScale()*10 - 1), 0, 25,
322 							 wxDefaultPosition, wxSize(155,wxDefaultCoord));
323 	mGradientSlider = new wxSlider(this, ID_GRADIENT_SCALING_SLIDER,
324 							 (int)(mTargetPrefs->GetGradientScale() - 1), 0, 100,
325 							 wxDefaultPosition, wxSize(155,wxDefaultCoord));
326 
327 	lUpperSizer->Add(mChkAnim, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
328 	lUpperSizer->Add(mChkRotation, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
329 	lUpperSizer->Add(mGradientBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
330 	lSldSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Normal Mode Scaling:"))) ,0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
331 	lSldSizer->Add(mSldScale, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
332 	lSldSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Energy first derivative scaling:"))) ,0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
333 	lSldSizer->Add(mGradientSlider, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
334 	lUpperSizer->Add(lSldSizer);
335 
336 	wxString choices[] = { _T("Hydrogen Bonds"),
337 						_T("Single Bonds"),
338 						_T("Double Bonds"),
339 						_T("Triple Bonds") };
340 
341 	mBondChoice = new wxChoice(this, ID_BOND_MODE_CHOICE, wxPoint(10,10), wxSize(150,wxDefaultCoord), 4, choices);
342 	mBondChoice->SetSelection(1);
343 	mChoiceId = 1;
344 
345 	lInnerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT(""))), 0, wxALIGN_RIGHT | wxALL, 3);
346 	lInnerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Color"))), 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
347 	lInnerSizer->Add(mBondChoice, 0, wxALIGN_RIGHT | wxALL, 3);
348 
349 	mColorArea = new colorArea(this, 1, mTargetPrefs->GetBondColorLoc(1));
350 
351 	mNormColorArea = new colorArea(this, 3, mTargetPrefs->GetVectorColorLoc());
352 
353 	lInnerSizer->Add(mColorArea, 1, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
354 
355 	lInnerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Normal Modes:"))), 0, wxALIGN_RIGHT | wxALL, 3);
356 	lInnerSizer->Add(mNormColorArea, 1, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
357 
358 	lInnerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Energy first deriviative:"))), 0, wxALIGN_RIGHT | wxALL, 3);
359 	mGradientColorArea = new colorArea(this, 4, mTargetPrefs->GetGradientColorLoc());
360 	lInnerSizer->Add(mGradientColorArea, 1, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
361 
362 	lBox->Add(lInnerSizer);
363 	lLowerSizer->Add(lBox);
364 
365 	lMainSizer->Add(lUpperSizer, 0, wxALIGN_CENTER | wxALL, 3);
366 	lMainSizer->Add(lLowerSizer, 0, wxALIGN_CENTER | wxALL, 3);
367 }
368 
369 void BondPrefsPane::saveToTempPrefs() {
370 	mColorArea->getColor(mTargetPrefs->GetBondColorLoc(mChoiceId));
371 	mNormColorArea->getColor(mTargetPrefs->GetVectorColorLoc());
372 	mGradientColorArea->getColor(mTargetPrefs->GetGradientColorLoc());
373 }
374 
375 void BondPrefsPane::OnSliderUpdate(wxCommandEvent &WXUNUSED(event)) {
376 	mTargetPrefs->SetVectorScale((float)(0.1*(mSldScale->GetValue()+1)));
377 }
378 
379 void BondPrefsPane::OnGradientSliderUpdate(wxCommandEvent & WXUNUSED(event)) {
380 	mTargetPrefs->SetGradientScale((float)((mGradientSlider->GetValue()+1)));
381 }
382 void BondPrefsPane::OnGradientRadioUpdate(wxCommandEvent &event) {
383 	switch (event.GetSelection()) {
384 		case 0:
385 			mTargetPrefs->DisplayGradient(false);
386 			mTargetPrefs->InvertGradient(false);
387 			break;
388 		case 1:
389 			mTargetPrefs->DisplayGradient(true);
390 			mTargetPrefs->InvertGradient(false);
391 			break;
392 		case 2:
393 			mTargetPrefs->DisplayGradient(true);
394 			mTargetPrefs->InvertGradient(true);
395 			break;
396 	}
397 }
398 
399 void BondPrefsPane::OnToggleAnim(wxCommandEvent& WXUNUSED(event)) {
400 	mTargetPrefs->SetAnimateMode(mChkAnim->GetValue());
401 }
402 
403 void BondPrefsPane::OnToggleRotation(wxCommandEvent& WXUNUSED(event)) {
404 	mTargetPrefs->SetRotateMode(mChkRotation->GetValue());
405 }
406 
407 void BondPrefsPane::OnChoice(wxCommandEvent &event) {
408   //int localId = -1;
409 
410 	mColorArea->getColor(mTargetPrefs->GetBondColorLoc(mChoiceId));
411 
412 	wxString localStr = event.GetString();
413 
414 	if (localStr.Cmp(_T("Hydrogen Bonds")) == 0)
415 		mChoiceId = 0;
416 	else if (localStr.Cmp(_T("Single Bonds")) == 0)
417 		mChoiceId = 1;
418 	else if (localStr.Cmp(_T("Double Bonds")) == 0)
419 		mChoiceId = 2;
420 	else if (localStr.Cmp(_T("Triple Bonds")) == 0)
421 		mChoiceId = 3;
422 
423 	mColorArea->setColor(mTargetPrefs->GetBondColorLoc(mChoiceId));
424 }
425 
426 
427 DisplayPrefsPane::DisplayPrefsPane(MolDisplayWin* targetWindow,
428 								   wxBookCtrlBase *parent,
429 								   WinPrefs* targetPrefs,
430 								   Boolean Global)
431 	: PrefsPane(targetWindow, targetPrefs, kDisplayPrefsPane, Global, parent) {
432 	/* Create(parent, -1, wxDefaultPosition, wxDefaultSize,wxSUNKEN_BORDER); */
433 
434 	mMainSizer = new wxBoxSizer(wxVERTICAL);
435 
436 	wxString choices[] = {_T("Ball and Stick"), _T("WireFrame (Bonds only)")};
437 
438 	mRdoBox = new wxRadioBox(this, ID_DISPLAY_MODE_RADIOBOX, _T("Display Mode"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(choices), choices, 0, wxRA_SPECIFY_ROWS);
439 	mChkColor = new wxCheckBox(this, ID_COLOR_BONDS_BY_ATOM_COLOR, _T("Color bonds by atom color"), wxDefaultPosition, wxDefaultSize, 0);
440 
441 	wxString atomLabels[] = {_T("None"), _T("Atomic Symbols"), _T("Atom Numbers"), _T("Both Symbols and Numbers")};
442 
443 	mAtomLabels = new wxRadioBox(this, ID_ATOM_LABELS_RADIO, _T("Atom Labels"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(atomLabels), atomLabels, 0, wxRA_SPECIFY_ROWS);
444 
445 	mMainSizer->Add(mRdoBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
446 	mMainSizer->Add(mChkColor, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
447 	mMainSizer->Add(mAtomLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
448 
449 	wxGridSizer * lgridSizer = new wxGridSizer(2,2, 0,0);
450 	lgridSizer->Add(new wxStaticText(this, wxID_ANY, _("Size of atom labels:")), 0, wxALIGN_RIGHT | wxALL, 3);
451 	mAtomLabelSizeSlider = new wxSlider(this, ID_ATOM_LABEL_SLIDER,
452 							(int)(mTargetPrefs->GetAtomLabelSize()*100), 25, 400,
453 							wxDefaultPosition, wxSize(155,wxDefaultCoord));
454 	mAtomLabelSizeSlider->SetToolTip(_("Changes the size of the atomic labels. Move left for smaller labels, right for larger ones."));
455 	lgridSizer->Add(mAtomLabelSizeSlider, 0, wxALIGN_CENTER | wxALL, 3);
456 
457 	lgridSizer->Add(new wxStaticText(this, wxID_ANY, _("Size of annotation text:")), 0, wxALIGN_RIGHT | wxALL, 3);
458 	mAnnotationLabelSizeSlider = new wxSlider(this, ID_ANNOTATION_SLIDER,
459 										 (int)(mTargetPrefs->GetAnnotationLabelSize()*100), 25, 400,
460 										 wxDefaultPosition, wxSize(155,wxDefaultCoord));
461 	mAnnotationLabelSizeSlider->SetToolTip(_("Changes the size of the annotation text. Move left for smaller labels, right for larger ones."));
462 	lgridSizer->Add(mAnnotationLabelSizeSlider, 0, wxALIGN_CENTER | wxALL, 3);
463 	mMainSizer->Add(lgridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
464 
465 	SetSizer(mMainSizer);
466 }
467 
468 #include <iostream>
469 void DisplayPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
470 	if (mTargetPrefs->DrawBallnStick() && !mTargetPrefs->DrawWireFrame())
471 		mRdoBox->SetSelection(0);
472 	else if (!mTargetPrefs->DrawBallnStick() && mTargetPrefs->DrawWireFrame())
473 		mRdoBox->SetSelection(1);
474 	else
475 		cout<<"Something wrong! Check preference setting!"<<endl;
476 
477 
478 	mChkColor->SetValue(mTargetPrefs->ColorBondHalves());
479 
480 	if (mTargetPrefs->ShowAtomicSymbolLabels() && mTargetPrefs->ShowAtomNumberLabels())
481 		mAtomLabels->SetSelection(3);
482 	else if (mTargetPrefs->ShowAtomNumberLabels())
483 		mAtomLabels->SetSelection(2);
484 	else if (mTargetPrefs->ShowAtomicSymbolLabels())
485 		mAtomLabels->SetSelection(1);
486 	else
487 		mAtomLabels->SetSelection(0);
488 
489 	mAtomLabelSizeSlider->SetValue((int)(mTargetPrefs->GetAtomLabelSize()*100));
490 	mAnnotationLabelSizeSlider->SetValue((int)(mTargetPrefs->GetAnnotationLabelSize()*100));
491 }
492 
493 void DisplayPrefsPane::saveToTempPrefs() {
494 
495 }
496 
497 void DisplayPrefsPane::OnRadio(wxCommandEvent &event) {
498 	wxString tmpStr = event.GetString();
499 
500 	if (tmpStr.Cmp(_T("Ball and Stick")) == 0) {
501 		mTargetPrefs->DrawBallnStick(true);
502 		mTargetPrefs->DrawWireFrame(false);
503 	}
504 	else if (tmpStr.Cmp(_T("WireFrame (Bonds only)")) == 0) {
505 		mTargetPrefs->DrawWireFrame(true);
506 		mTargetPrefs->DrawBallnStick(false);
507 	}
508 }
509 
510 void DisplayPrefsPane::OnLabelsRadio(wxCommandEvent &event) {
511 	switch (event.GetSelection()) {
512 		case 0:
513 			mTargetPrefs->ShowAtomicSymbolLabels(false);
514 			mTargetPrefs->ShowAtomNumberLabels(false);
515 			break;
516 		case 1:
517 			mTargetPrefs->ShowAtomicSymbolLabels(true);
518 			mTargetPrefs->ShowAtomNumberLabels(false);
519 			break;
520 		case 2:
521 			mTargetPrefs->ShowAtomicSymbolLabels(false);
522 			mTargetPrefs->ShowAtomNumberLabels(true);
523 			break;
524 		case 3:
525 			mTargetPrefs->ShowAtomicSymbolLabels(true);
526 			mTargetPrefs->ShowAtomNumberLabels(true);
527 			break;
528 	}
529 }
530 
531 void DisplayPrefsPane::OnCheckBox(wxCommandEvent &event) {
532 	if (event.GetId() == ID_COLOR_BONDS_BY_ATOM_COLOR)
533 		mTargetPrefs->ColorBondHalves(mChkColor->GetValue());
534 }
535 void DisplayPrefsPane::OnAtomLabelSlider(wxCommandEvent &/*event*/) {
536 	mTargetPrefs->SetAtomLabelSize((float)(mAtomLabelSizeSlider->GetValue())/100.0);
537 }
538 void DisplayPrefsPane::OnAnnotationLabelSlider(wxCommandEvent &/*event*/) {
539 	mTargetPrefs->SetAnnotationLabelSize((float)(mAnnotationLabelSizeSlider->GetValue())/100.0);
540 }
541 
542 EnergyPrefsPane::EnergyPrefsPane(MolDisplayWin* targetWindow,
543 								 wxBookCtrlBase *parent,
544 								 WinPrefs* targetPrefs,
545 								 Boolean GlobalPrefs)
546 	: PrefsPane(targetWindow, targetPrefs, kEPrefsPane, GlobalPrefs, parent) {
547 	/* Create(parent, -1, wxDefaultPosition, wxDefaultSize,wxSUNKEN_BORDER); */
548 
549 	mMainSizer = new wxBoxSizer(wxVERTICAL);
550 	mUpperSizer = new wxBoxSizer(wxHORIZONTAL);
551 
552 	if (PrefsAreGlobal())
553 		mLowerSizer = new wxGridSizer(4,2, 0,0);
554 	else
555 		mLowerSizer = new wxGridSizer(6,2, 0,0);
556 
557 	if (!PrefsAreGlobal()) {
558 		mBottomSizer = new wxBoxSizer(wxHORIZONTAL);
559 		mLeftBottomSizer = new wxBoxSizer(wxVERTICAL);
560 	}
561 
562 	mRightBottomSizer = NULL;
563 	mRight1BottomSizer = NULL;
564 	mRight2BottomSizer = NULL;
565 	mAtomText[0] = NULL;
566 	mAtomText[1] = NULL;
567 	mAtomText[2] = NULL;
568 	mY1pt = NULL;
569 	mY2pt = NULL;
570 
571 	SetSizer(mMainSizer);
572 
573 }
574 
575 EnergyPrefsPane::~EnergyPrefsPane() {
576 	delete mEColor;
577 	delete mMPColor;
578 	delete mPEColor;
579 	delete mOtherColor;
580 
581 	if (mY1pt) delete mY1pt;
582 	if (mY2pt) delete mY2pt;
583 }
584 
585 void EnergyPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
586 	EnergyOptions * lEOpts = mTargetPrefs->GetEnergyOptions();
587 	GraphOptions * lPOpts = mTargetPrefs->GetGraphOptions();
588 	//Setup the slider for the E plot point size
589 
590 	mSldBallSize = new wxSlider(this, ID_PLOT_BALL_SIZE_SLIDER,
591 			(int)(lEOpts->GetEPlotPointSize()), 1, 20,
592 			wxDefaultPosition, wxSize(155,wxDefaultCoord),
593 			wxSL_AUTOTICKS | wxSL_LABELS);
594 
595 	wxString tmp;
596 	tmp.Printf(wxT("%d"), lEOpts->GetNumDigits());
597 	mNumDigitsArea = new wxTextCtrl(this, wxID_ANY, tmp, wxDefaultPosition, wxDefaultSize);
598 
599 	mUpperSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("E. Plot Ball Size:"))), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
600 	mUpperSizer->Add(mSldBallSize, 0, wxALIGN_LEFT | wxALL, 3);
601 	mUpperSizer->Add(30, 30);
602 	mUpperSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("# digits"))), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
603 	mUpperSizer->Add(mNumDigitsArea, 0, wxALIGN_CENTER | wxALL, 3);
604 
605 	mEColor = new colorArea(this, 0, lEOpts->GetTEColor());
606 	mMPColor = new colorArea(this, 1, lEOpts->GetMPColor());
607 	mPEColor = new colorArea(this, 2, lEOpts->GetPEColor());
608 	mOtherColor = new colorArea(this, 3, lEOpts->GetKEColor());
609 
610 	mLowerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("E Color"))), 0, wxALIGN_RIGHT | wxALL, 3);
611 	mLowerSizer->Add(mEColor, 0, wxALIGN_LEFT | wxALL, 3);
612 	mLowerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("MP Color"))), 0, wxALIGN_RIGHT | wxALL, 3);
613 	mLowerSizer->Add(mMPColor, 0, wxALIGN_LEFT | wxALL, 3);
614 
615 	if (!PrefsAreGlobal()) {
616 		mLowerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Y1 zero pt "))), 0, wxALIGN_RIGHT | wxALL, 3);
617 		tmp.Printf(wxT("%.4f"),lEOpts->GetY1Zero());
618 		mY1pt = new wxTextCtrl(this, wxID_ANY, tmp);
619 		mLowerSizer->Add(mY1pt, 0, wxALIGN_RIGHT | wxALL, 3);
620 	}
621 
622 	mLowerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("PE Color"))), 0, wxALIGN_RIGHT | wxALL, 3);
623 	mLowerSizer->Add(mPEColor, 0, wxALIGN_LEFT | wxALL, 3);
624 	mLowerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Other Color"))), 0, wxALIGN_RIGHT | wxALL, 3);
625 	mLowerSizer->Add(mOtherColor, 0, wxALIGN_LEFT | wxALL, 3);
626 
627 	if (!PrefsAreGlobal()) {
628 		mLowerSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Y2 zero pt "))), 0, wxALIGN_RIGHT | wxALL, 3);
629 		tmp.Printf(wxT("%.4f"),lEOpts->GetY2Zero());
630 		mY2pt = new wxTextCtrl(this, wxID_ANY, tmp);
631 		mLowerSizer->Add(mY2pt, 0, wxALIGN_RIGHT | wxALL, 3);
632 	}
633 
634 	if (!PrefsAreGlobal()) {
635 		mTotalEny = new wxCheckBox(this, ID_TOTAL_ENERGY, _T("Total Energy"));
636 		mTotalEny->SetValue(lEOpts->PlotEnergy());
637 		mMP2Eny = new wxCheckBox(this, ID_MP2_ENERGY, _T("MP2 Energy"));
638 		mMP2Eny->SetValue(lEOpts->PlotMPEnergy());
639 		mPotEny = new wxCheckBox(this, ID_POTENTIAL_ENERGY, _T("Potential Energy"));
640 		mPotEny->SetValue(lEOpts->PlotPEnergy());
641 
642 		mLeftBottomSizer->Add(mTotalEny, 0, wxALIGN_LEFT | wxALL, 3);
643 		mLeftBottomSizer->Add(mMP2Eny, 0, wxALIGN_LEFT | wxALL, 3);
644 		mLeftBottomSizer->Add(mPotEny, 0, wxALIGN_LEFT | wxALL, 3);
645 
646 		EnergyUnit lunit = lEOpts->GetDisplayUnits();
647 
648 		wxString choices[] = {_T("Default"), _T("kcal/mol")};
649 
650 		mRdoUnit = new wxRadioBox(this, ID_UNIT_RADIOBOX, _T("Unit"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS);
651 
652 		if (lunit == kDefault)
653 			mRdoUnit->SetSelection(0);
654 		else if (lunit == kKCalPerMole)
655 			mRdoUnit->SetSelection(1);
656 
657 		wxString choices2[] = {_T("None"), _T("Kinetic Energy"), _T("RMS Grad"), _T("Max. Grad"), _T("Bond Length"), _T("Bond Angle") };
658 
659 		mRdoMisc = new wxRadioBox(this, ID_MISC_RADIOBOX, _T("Secondary Axis"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_COLS);
660 
661 		if (lEOpts->PlotOther())
662 			mRdoMisc->SetSelection(0);
663 		if (lEOpts->PlotKEnergy())
664 			mRdoMisc->SetSelection(1);
665 		if (lPOpts->PlotRMSGradient())
666 			mRdoMisc->SetSelection(2);
667 		if (lPOpts->PlotMaxGradient())
668 			mRdoMisc->SetSelection(3);
669 		if (lPOpts->PlotBondLength())
670 			mRdoMisc->SetSelection(4);
671 		if (lPOpts->PlotBondAngle())
672 			mRdoMisc->SetSelection(5);
673 
674 		mLeftBottomSizer->Add(mRdoUnit, 0, wxALIGN_CENTER | wxALL, 3);
675 		mBottomSizer->Add(mLeftBottomSizer, 0, wxALL, 10);
676 		mBottomSizer->Add(mRdoMisc, 0, wxALIGN_CENTER | wxALL, 10);
677 
678 		setHiddenCtrls();
679 
680 		mRightBottomSizer->Hide(mRight1BottomSizer);
681 		mRightBottomSizer->Hide(mRight2BottomSizer);
682 		//initially hide them
683 
684 		if (lPOpts->PlotBondAngle()) {
685 			mRightBottomSizer->Show(mRight1BottomSizer, true, true);
686 			mRightBottomSizer->Show(mRight2BottomSizer, true, true);
687 			mRightBottomSizer->Layout();
688 		}
689 
690 		if (lPOpts->PlotBondLength()) {
691 			mRightBottomSizer->Show(mRight1BottomSizer, true, true);
692 			mRightBottomSizer->Layout();
693 		}
694 
695 	}
696 
697 	mMainSizer->Add(mUpperSizer);
698 	mMainSizer->Add(mLowerSizer);
699 
700 	if (!PrefsAreGlobal())
701 		mMainSizer->Add(mBottomSizer, 0, wxALL, 10);
702 
703 }
704 
705 void EnergyPrefsPane::setHiddenCtrls() {
706 	GraphOptions * lPOpts = mTargetPrefs->GetGraphOptions();
707 
708 	if (!mRightBottomSizer)
709 		mRightBottomSizer = new wxBoxSizer(wxVERTICAL);
710 
711 	if (!mRight1BottomSizer)
712 		mRight1BottomSizer = new wxGridSizer(2,2, 0,0);
713 
714 	if (!mRight2BottomSizer)
715 		mRight2BottomSizer = new wxGridSizer(1,2, 0,0);
716 
717 	wxString tmp;
718 	if (!mAtomText[0]) {
719 		tmp.Printf(wxT("%ld"), lPOpts->Get1stAtom()+1);
720 		mAtomText[0] = new wxTextCtrl(this, wxID_ANY, tmp);
721 	}
722 	if (!mAtomText[1]) {
723 		tmp.Printf(wxT("%ld"), lPOpts->Get2ndAtom()+1);
724 		mAtomText[1] = new wxTextCtrl(this, wxID_ANY, tmp);
725 	}
726 
727 	mRight1BottomSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Atom 1:"))), 0, wxALIGN_RIGHT | wxALL, 3);
728 	mRight1BottomSizer->Add(mAtomText[0], wxALIGN_LEFT | wxALL, 3);
729 	mRight1BottomSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Atom 2:"))), 0, wxALIGN_RIGHT | wxALL, 3);
730 	mRight1BottomSizer->Add(mAtomText[1], wxALIGN_LEFT | wxALL, 3);
731 
732 	if (!mAtomText[2]) {
733 		tmp.Printf(wxT("%ld"), lPOpts->Get3rdAtom()+1);
734 		mAtomText[2] = new wxTextCtrl(this, wxID_ANY, tmp);
735 	}
736 	mRight2BottomSizer->Add(new wxStaticText(this, wxID_ANY, wxString(wxT("Atom 3:"))), 0, wxALIGN_RIGHT | wxALL, 3);
737 	mRight2BottomSizer->Add(mAtomText[2], wxALIGN_LEFT | wxALL, 3);
738 
739 	mRightBottomSizer->Add(mRight1BottomSizer);
740 	mRightBottomSizer->Add(mRight2BottomSizer);
741 	mBottomSizer->Add(mRightBottomSizer);
742 }
743 
744 void EnergyPrefsPane::saveToTempPrefs() {
745 	EnergyOptions * lEOpts = mTargetPrefs->GetEnergyOptions();
746 	GraphOptions * lPOpts = mTargetPrefs->GetGraphOptions();
747 
748 	long localLong;
749 	double localDouble;
750 
751 	(mNumDigitsArea->GetValue()).ToLong(&localLong);
752 	lEOpts->SetNumDigits(localLong);
753 
754 	mEColor->getColor(lEOpts->GetTEColor());
755 	mMPColor->getColor(lEOpts->GetMPColor());
756 	mOtherColor->getColor(lEOpts->GetKEColor());
757 	mPEColor->getColor(lEOpts->GetPEColor());
758 
759 	if (!PrefsAreGlobal()) {
760 		(mY1pt->GetValue()).ToDouble(&localDouble);
761 		lEOpts->SetY1Zero(localDouble);
762 		(mY2pt->GetValue()).ToDouble(&localDouble);
763 		lEOpts->SetY2Zero(localDouble);
764 
765 		if (lPOpts->PlotBondLength() || lPOpts->PlotBondAngle()) {
766 			(mAtomText[0]->GetValue()).ToLong(&localLong);
767 			lPOpts->Set1stAtom(localLong-1);
768 			(mAtomText[1]->GetValue()).ToLong(&localLong);
769 			lPOpts->Set2ndAtom(localLong-1);
770 
771 			if (lPOpts->PlotBondAngle()) {
772 				(mAtomText[2]->GetValue()).ToLong(&localLong);
773 				lPOpts->Set3rdAtom(localLong-1);
774 			}
775 		}
776 	}
777 }
778 
779 void EnergyPrefsPane::OnSliderUpdate(wxCommandEvent &WXUNUSED(event)) {
780 	EnergyOptions * lEOpts = mTargetPrefs->GetEnergyOptions();
781 	lEOpts->SetEPlotPointSize(mSldBallSize->GetValue());
782 }
783 
784 void EnergyPrefsPane::OnCheckBox(wxCommandEvent& event) {
785 	int id = event.GetId();
786 
787 	EnergyOptions * lEOpts = mTargetPrefs->GetEnergyOptions();
788 
789 	if (id == ID_TOTAL_ENERGY)
790 		lEOpts->SetPlotEnergy(mTotalEny->GetValue());
791 	if (id == ID_MP2_ENERGY)
792 		lEOpts->SetPlotMPEnergy(mMP2Eny->GetValue());
793 	if (id == ID_POTENTIAL_ENERGY)
794 		lEOpts->SetPlotPEnergy(mPotEny->GetValue());
795 }
796 
797 void EnergyPrefsPane::OnRadio(wxCommandEvent& event) {
798 	//int id = event.GetId();
799 
800 	wxString tmpStr = event.GetString();
801 
802 	mRightBottomSizer->Hide(mRight1BottomSizer);
803 	mRightBottomSizer->Hide(mRight2BottomSizer);
804 
805 	if (tmpStr.Cmp(_T("Bond Length")) == 0 || tmpStr.Cmp(_T("Bond Angle")) == 0) {
806 		mRightBottomSizer->Show(mRight1BottomSizer, true, true);
807 
808 		if (tmpStr.Cmp(_T("Bond Angle")) == 0)
809 			mRightBottomSizer->Show(mRight2BottomSizer, true, true);
810 
811 		mRightBottomSizer->Layout();
812 		mMainSizer->Layout();
813 	}
814 
815 	EnergyOptions * lEOpts = mTargetPrefs->GetEnergyOptions();
816 	GraphOptions * lPOpts = mTargetPrefs->GetGraphOptions();
817 
818 	if (event.GetId() == ID_UNIT_RADIOBOX) {
819 		EnergyUnit lunit=kDefault;
820 
821 		if (tmpStr.Cmp(_T("Default")) == 0)
822 			lunit = kDefault;
823 		else if (tmpStr.Cmp(_T("kcal/mol")) == 0)
824 			lunit = kKCalPerMole;
825 
826 		lEOpts->SetDisplayUnits(lunit);
827 	}
828 
829 	if (event.GetId() == ID_MISC_RADIOBOX) {
830 		lEOpts->SetPlotOther(false);
831 		lEOpts->SetPlotKEnergy(false);
832 		lPOpts->SetPlotRMSGradient(false);
833 		lPOpts->SetPlotMaxGradient(false);
834 		lPOpts->SetPlotBondLength(false);
835 		lPOpts->SetPlotBondAngle(false);
836 		//set everything to false first
837 
838 		if (tmpStr.Cmp(_T("None")) == 0)
839 			lEOpts->SetPlotOther(true);
840 		else if (tmpStr.Cmp(_T("Kinetic Energy")) == 0)
841 			lEOpts->SetPlotKEnergy(true);
842 		else if (tmpStr.Cmp(_T("RMS Grad")) == 0)
843 			lPOpts->SetPlotRMSGradient(true);
844 		else if (tmpStr.Cmp(_T("Max. Grad")) == 0)
845 			lPOpts->SetPlotMaxGradient(true);
846 		else if (tmpStr.Cmp(_T("Bond Length")) == 0)
847 			lPOpts->SetPlotBondLength(true);
848 		else if (tmpStr.Cmp(_T("Bond Angle")) == 0)
849 			lPOpts->SetPlotBondAngle(true);
850 	}
851 
852 }
853 
854 FilePrefsPane::FilePrefsPane(MolDisplayWin* targetWindow, wxBookCtrlBase *parent, WinPrefs* targetPrefs, Boolean GlobalPrefs)
855 	: PrefsPane(targetWindow, targetPrefs, kFilePrefsPane, GlobalPrefs, parent) {
856 	/* Create(parent, -1, wxDefaultPosition, wxDefaultSize,wxSUNKEN_BORDER); */
857 
858 	mMainSizer = new wxBoxSizer(wxVERTICAL);
859 
860 	SetSizer(mMainSizer);
861 }
862 
863 void FilePrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
864 	wxBoxSizer* UpperSizer = new wxBoxSizer(wxVERTICAL);
865 	mMainSizer->Add(UpperSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
866 
867 	mChkBox[0] = new wxCheckBox(this, ID_AUTO_BOND_PASTE_OPEN, _T("Auto-Bond on Paste and File Open"));
868 	mChkBox[0]->SetValue(mTargetPrefs->GetAutoBond());
869 	UpperSizer->Add(mChkBox[0], 0, wxALIGN_LEFT|wxALL, 5);
870 
871 	mChkBox[1] = new wxCheckBox(this, ID_GUESS_BOND_ORDER, _T("Guess bond order"));
872 	mChkBox[1]->SetValue(mTargetPrefs->DetermineBondOrder());
873 	UpperSizer->Add(mChkBox[1], 0, wxALIGN_LEFT|wxALL, 5);
874 
875 	mChkBox[2] = new wxCheckBox(this, ID_PREVENT_HH_BONDS, _T("Prevent H-H bonds in Auto-Bond"));
876 	mChkBox[2]->SetValue(mTargetPrefs->GetHHBondFlag());
877 	UpperSizer->Add(mChkBox[2], 0, wxALIGN_LEFT|wxALL, 5);
878 
879 	mChkBox[3] = new wxCheckBox(this, ID_LOOK_HYDROGEN_BONDS, _T("Look for hydrogen bonds"));
880 	mChkBox[3]->SetValue(mTargetPrefs->AllowHydrogenBonds());
881 	UpperSizer->Add(mChkBox[3], 0, wxALIGN_LEFT|wxALL, 5);
882 
883 	mChkBox[4] = new wxCheckBox(this, ID_SHOW_ANGLES_WHILE_ROTATING, _T("Show angles while rotating"));
884 	mChkBox[4]->SetValue(mTargetPrefs->GetShowAngles());
885 	UpperSizer->Add(mChkBox[4], 0, wxALIGN_LEFT|wxALL, 5);
886 
887 #ifdef __WXMAC__
888 	if (PrefsAreGlobal()) {
889 		mChkBox[5] = new wxCheckBox(this, ID_USE_MAC_EOL_CHAR, _T("Use Mac EOL chars"));
890 		mChkBox[5]->SetValue(mTargetPrefs->NativeEOLChar());
891 		UpperSizer->Add(mChkBox[5], 0, wxALIGN_LEFT|wxALL, 5);
892 	}
893 #endif
894 
895 	mChkBox[6] = new wxCheckBox(this, ID_PROMPT_SAVE_FILE, _T("Prompt to save file"));
896 	mChkBox[6]->SetValue(mTargetPrefs->GetPrompt4Save());
897 	UpperSizer->Add(mChkBox[6], 0, wxALIGN_LEFT|wxALL, 5);
898 
899 
900 	mChkBox[7] = new wxCheckBox(this, ID_CREATE_CUSTOM_FILE_ICON, _T("create custom file icon"));
901 	mChkBox[7]->SetValue(mTargetPrefs->CreateCustomIcon());
902 	UpperSizer->Add(mChkBox[7], 0, wxALIGN_LEFT|wxALL, 5);
903 
904 #ifdef __WXMAC__
905 	if (PrefsAreGlobal()) {
906 		mChkBox[8] = new wxCheckBox(this, ID_CHANGE_FILE_CREATOR, _T("Change file creator type to wxMacMolPlt"));
907 		mChkBox[8]->SetValue(mTargetPrefs->ChangeFileType());
908 		UpperSizer->Add(mChkBox[8], 0, wxALIGN_LEFT|wxALL, 5);
909 	}
910 #endif
911 
912 	mSldTol = new wxSlider(this, ID_AUTO_BOND_TOLERANCE_SLIDER,
913 			(int)(mTargetPrefs->GetAutoBondScale()*10000+0.5),
914 			50, 150, wxDefaultPosition,
915 			wxSize(155,wxDefaultCoord));
916 
917 	wxBoxSizer* LowerSizer = new wxBoxSizer(wxHORIZONTAL);
918 	mMainSizer->Add(LowerSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
919 	LowerSizer->Add(new wxStaticText(this, wxID_ANY, _T("Auto-Bond Tolerance:")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
920 	LowerSizer->Add(mSldTol, 0, wxALIGN_LEFT | wxALL, 3);
921 
922 	wxBoxSizer* BottomSizer = new wxBoxSizer(wxHORIZONTAL);
923 	mMainSizer->Add(BottomSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
924 	wxString tmp;
925 	tmp.Printf(wxT("%ld"), mTargetPrefs->GetDRCSkip());
926 	mPointSkip = new wxTextCtrl(this, wxID_ANY, tmp);
927 
928 	BottomSizer->Add(new wxStaticText(this, wxID_ANY, _T("When reading a DRC file how many\n points should be skipped between\n points read in? (0 reads every point)")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
929 	BottomSizer->Add(mPointSkip, 0, wxALIGN_CENTER | wxALL, 3);
930 }
931 
932 void FilePrefsPane::saveToTempPrefs() {
933 	long v;
934 	(mPointSkip->GetValue()).ToLong(&v);
935 	mTargetPrefs->SetDRCSkip(v);
936 }
937 
938 void FilePrefsPane::OnCheckBox(wxCommandEvent &event) {
939 	if (event.GetId() == ID_AUTO_BOND_PASTE_OPEN) {
940 		Boolean mainStatus = mChkBox[0]->GetValue();
941 		mTargetPrefs->SetAutoBond(mainStatus);
942 
943 		if (!mainStatus) {
944 			mChkBox[1]->Disable();
945 			mChkBox[2]->Disable();
946 			mChkBox[3]->Disable();
947 		}
948 		else
949 		{
950 			mChkBox[1]->Enable();
951 			mChkBox[2]->Enable();
952 			mChkBox[3]->Enable();
953 		}
954 	}
955 	else if (event.GetId() == ID_GUESS_BOND_ORDER)
956 		mTargetPrefs->DetermineBondOrder(mChkBox[1]->GetValue());
957 	else if (event.GetId() == ID_PREVENT_HH_BONDS)
958 		mTargetPrefs->SetHHBondFlag(mChkBox[2]->GetValue());
959 	else if (event.GetId() == ID_LOOK_HYDROGEN_BONDS)
960 		mTargetPrefs->AllowHydrogenBonds(mChkBox[3]->GetValue());
961 	else if (event.GetId() == ID_SHOW_ANGLES_WHILE_ROTATING)
962 		mTargetPrefs->SetShowAngles(mChkBox[4]->GetValue());
963 #ifdef __WXMAC__
964 	else if (event.GetId() == ID_USE_MAC_EOL_CHAR && PrefsAreGlobal())
965 		mTargetPrefs->NativeEOLChar(mChkBox[5]->GetValue());
966 #endif
967 	else if (event.GetId() == ID_PROMPT_SAVE_FILE)
968 		mTargetPrefs->SetPrompt4Save(mChkBox[6]->GetValue());
969 	else if (event.GetId() == ID_CREATE_CUSTOM_FILE_ICON)
970 		mTargetPrefs->CreateCustomIcon(mChkBox[7]->GetValue());
971 #ifdef __WXMAC__
972 	else if (event.GetId() == ID_CHANGE_FILE_CREATOR)
973 		mTargetPrefs->ChangeFileType(mChkBox[8]->GetValue());
974 #endif
975 }
976 
977 void FilePrefsPane::OnSliderUpdate(wxCommandEvent &WXUNUSED(event)) {
978   mTargetPrefs->SetAutoBondScale((float)(mSldTol->GetValue())/10000);
979 }
980 
981 
982 ScalingPrefsPane::ScalingPrefsPane(MolDisplayWin* targetWindow, wxBookCtrlBase *parent, WinPrefs* targetPrefs, Boolean GlobalPrefs)
983 	: PrefsPane(targetWindow, targetPrefs, kScalingPrefsPane, GlobalPrefs, parent) {
984 
985 	wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
986 	SetSizer(itemBoxSizer4);
987 	mMainSizer = new wxFlexGridSizer(3, 2, 0,0);
988 	itemBoxSizer4->Add(mMainSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
989 
990 }
991 
992 void ScalingPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
993 	mSld[0] = new wxSlider(this, ID_ATOM_SIZE_SLIDER,
994 			(int)(mTargetPrefs->GetAtomScale()*10000+0.5),
995 			0, 250, wxDefaultPosition,
996 			wxSize(155,wxDefaultCoord));
997 
998 	mSld[1] = new wxSlider(this, ID_ANIM_QUALITY_SLIDER,
999 			(int)(mTargetPrefs->GetAnimationSpeed()-1),
1000 			0, 15, wxDefaultPosition,
1001 			wxSize(155,wxDefaultCoord));
1002 
1003 	mSld[2] = new wxSlider(this, ID_FRAME_DELAY_SLIDER,
1004 			(int)(mTargetPrefs->GetAnimateTime()),
1005 			0, 120, wxDefaultPosition,
1006 			wxSize(155,wxDefaultCoord));
1007 
1008 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("Atom Size:")), 0, wxALIGN_RIGHT | wxALL, 3);
1009 	mMainSizer->Add(mSld[0], 0, wxALIGN_LEFT | wxALL, 3);
1010 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("Mode Animation Quality:")), 0, wxALIGN_RIGHT | wxALL, 3);
1011 	mMainSizer->Add(mSld[1], 0, wxALIGN_LEFT | wxALL, 3);
1012 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("Frame Delay:")), 0, wxALIGN_RIGHT | wxALL, 3);
1013 	mMainSizer->Add(mSld[2], 0, wxALIGN_LEFT | wxALL, 3);
1014 }
1015 
1016 void ScalingPrefsPane::saveToTempPrefs() {
1017 
1018 }
1019 
1020 void ScalingPrefsPane::OnSliderUpdate(wxCommandEvent &event) {
1021 	int id = event.GetId();
1022 
1023 	if (id == ID_ATOM_SIZE_SLIDER)
1024 		mTargetPrefs->SetAtomScale((float)(mSld[0]->GetValue())/10000);
1025 	if (id == ID_ANIM_QUALITY_SLIDER)
1026 		mTargetPrefs->SetAnimationSpeed(mSld[1]->GetValue()+1);
1027 	if (id == ID_FRAME_DELAY_SLIDER)
1028 		mTargetPrefs->SetAnimateTime(mSld[2]->GetValue());
1029 }
1030 
1031 StereoPrefsPane::StereoPrefsPane(MolDisplayWin* targetWindow, wxBookCtrlBase *parent, WinPrefs* targetPrefs, Boolean GlobalPrefs)
1032 	: PrefsPane(targetWindow, targetPrefs, kStereoPrefsPane, GlobalPrefs, parent) {
1033 
1034 	mMainSizer = new wxBoxSizer(wxVERTICAL);
1035 	mMiddleSizer = new wxBoxSizer(wxHORIZONTAL);
1036 
1037 	SetSizer(mMainSizer);
1038 	if (!GlobalPrefs) {
1039 		Disable();
1040 	}
1041 }
1042 
1043 void StereoPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
1044 
1045 #if wxCHECK_VERSION(2,9,0)
1046 	int attribs[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16,
1047 					 WX_GL_STEREO, 0};
1048 	if (!wxGLCanvas::IsDisplaySupported(attribs)) {
1049 		Disable();
1050 		mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("No stereo pixel format available.")), 0, wxALIGN_LEFT | wxALL, 10);
1051 	}
1052 #else
1053 	Disable();
1054 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("wxWidgets 2.9 needed for stereo support.")), 0, wxALIGN_LEFT | wxALL, 10);
1055 #endif
1056 
1057 	mChkActive = new wxCheckBox(this, ID_STEREO_ACTIVE, _T("Stereo Active"), wxDefaultPosition);
1058 	mChkActive->SetValue(mTargetPrefs->UseStereo());
1059 	mMainSizer->Add(mChkActive, 0, wxALIGN_LEFT | wxALL, 10);
1060 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("Enabling or disabling stereo affects new windows only.")), 0, wxALIGN_LEFT | wxALL, 10);
1061 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _T("The eye separation is determined by dividing the focal length\n")
1062 				_T("by the eye separation factor. To minimize ghosting, either\n")
1063 				_T("zoom out or increase the factor below.")), 0, wxALIGN_LEFT | wxALL, 10);
1064 
1065 	mMiddleSizer->Add(new wxStaticText(this, wxID_ANY, _T("Factor ")), 0, wxALIGN_LEFT | wxALL, 10);
1066 
1067 	wxString tmp;
1068 	tmp.Printf(wxT("%d"), mTargetPrefs->GetStereoOffset());
1069 	mOffDegree = new wxTextCtrl(this, wxID_ANY, tmp);
1070 	mMiddleSizer->Add(mOffDegree, 0, wxALIGN_LEFT | wxALL, 3);
1071 
1072 	mMainSizer->Add(mMiddleSizer, 0, wxALIGN_LEFT | wxLEFT, 10);
1073 
1074 }
1075 
1076 void StereoPrefsPane::saveToTempPrefs() {
1077 	long v;
1078 	mOffDegree->GetValue().ToLong(&v);
1079 	mTargetPrefs->SetStereoOffset(v);
1080 }
1081 
1082 void StereoPrefsPane::OnCheckBox(wxCommandEvent& WXUNUSED(event)) {
1083 	mTargetPrefs->UseStereo(mChkActive->GetValue());
1084 }
1085 
1086 
1087 SurfacePrefsPane::SurfacePrefsPane(MolDisplayWin* targetWindow, wxBookCtrlBase *parent, WinPrefs* targetPrefs, Boolean GlobalPrefs)
1088 	: PrefsPane(targetWindow, targetPrefs, kSurfacePrefsPane, GlobalPrefs, parent) {
1089   /* Create(parent, -1, wxDefaultPosition, wxDefaultSize,wxSUNKEN_BORDER); */
1090 
1091 	mMainSizer = new wxBoxSizer(wxHORIZONTAL);
1092 	mLeftSizer = new wxBoxSizer(wxVERTICAL);
1093 	mRightSizer = new wxBoxSizer(wxVERTICAL);
1094 	mLeftMidSizer = new wxGridSizer(2,2, 0,0);
1095 	mRightUpperSizer = new wxBoxSizer(wxHORIZONTAL);
1096 	mRightMidSizer = new wxFlexGridSizer(2,2, 0,0);
1097 
1098 	SetSizer(mMainSizer);
1099 }
1100 
1101 SurfacePrefsPane::~SurfacePrefsPane() {
1102 	delete mSurfColor[0];
1103 	delete mSurfColor[1];
1104 }
1105 
1106 void SurfacePrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
1107 	SurfaceOptions * lSOpts = mTargetPrefs->GetSurfaceOptions();
1108 
1109 	mLeftSizer->Add(new wxStaticText(this, wxID_ANY, _T("Surface Colors:")), 0, wxALIGN_CENTER | wxALL, 3);
1110 
1111 	mLeftMidSizer->Add(new wxStaticText(this, wxID_ANY, _T("+")), 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_BOTTOM | wxALL, 1);
1112 	mLeftMidSizer->Add(new wxStaticText(this, wxID_ANY, _T("-")), 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_BOTTOM | wxALL, 1);
1113 
1114 	RGBColor tmpColor;
1115 
1116 	lSOpts->GetPosColor(&tmpColor);
1117 	mSurfColor[0] = new colorArea(this, 0, &tmpColor);
1118 	//  mSurfColor[0]->draw(tmpColor);
1119 	lSOpts->GetNegColor(&tmpColor);
1120 	mSurfColor[1] = new colorArea(this, 1, &tmpColor);
1121 	//  mSurfColor[1]->draw(tmpColor);
1122 
1123 	mLeftMidSizer->Add(mSurfColor[0], 0, wxALIGN_TOP | wxALL, 1);
1124 	mLeftMidSizer->Add(mSurfColor[1], 0, wxALIGN_TOP | wxALL, 1);
1125 
1126 	mLeftSizer->Add(mLeftMidSizer, 0, wxALIGN_CENTER | wxALL, 3);
1127 	mLeftSizer->Add(10,10);
1128 
1129 	mLeftSizer->Add(new wxStaticText(this, wxID_ANY, _T("Def. # of Grid Points")), 0, wxALIGN_LEFT | wxALL, 3);
1130 
1131 	mSldGridPoint = new wxSlider(this, ID_NUM_GRID_POINT_SLIDER,
1132 			lSOpts->GetNumGridPoints(), 10, 150,
1133 			wxDefaultPosition, wxSize(155,wxDefaultCoord),
1134 			wxSL_AUTOTICKS | wxSL_LABELS);
1135 
1136 	mLeftSizer->Add(mSldGridPoint, 0, wxALIGN_CENTER | wxALL, 3);
1137 
1138 	mRightSizer->Add(new wxStaticText(this, wxID_ANY, _T("Specific to 3D surfaces:")), 0, wxALIGN_LEFT | wxALL, 3);
1139 
1140 	mRightUpperSizer->Add(new wxStaticText(this, wxID_ANY, _T("Grid Size:")), 0, wxALIGN_CENTER | wxALL, 3);
1141 
1142 	mSldGridSize = new wxSlider(this, ID_3D_GRID_SIZE_SLIDER,
1143 			(int)(100*(lSOpts->GetGridSize())+0.5), 0, 300,
1144 			wxDefaultPosition, wxSize(155,wxDefaultCoord),
1145 			wxSL_AUTOTICKS | wxSL_LABELS);
1146 	mRightUpperSizer->Add(mSldGridSize, 0, wxALIGN_CENTER | wxALL, 3);
1147 	mRightSizer->Add(mRightUpperSizer);
1148 
1149 	mRightSizer->Add(new wxStaticText(this, wxID_ANY, _T("Specific to 2D maps:")), 0, wxALIGN_LEFT | wxALL, 3);
1150 
1151 	mRightMidSizer->Add(new wxStaticText(this, wxID_ANY, _T("# of Contours:")), 0, wxALIGN_CENTER | wxALL, 3);
1152 
1153 	wxString tmp;
1154 	tmp.Printf(wxT("%ld"), lSOpts->GetNumContours());
1155 	mNumContour = new wxTextCtrl(this, wxID_ANY, tmp);
1156 	mRightMidSizer->Add(mNumContour, 0, wxALIGN_CENTER | wxALL, 3);
1157 
1158 	mRightMidSizer->Add(new wxStaticText(this, wxID_ANY, _T("Max contour value")), 0, wxALIGN_CENTER | wxALL, 3);
1159 
1160 	tmp.Printf(wxT("%.3f"), lSOpts->GetMaxContour());
1161 	mMaxContourValue = new wxTextCtrl(this, wxID_ANY, tmp);
1162 	mRightMidSizer->Add(mMaxContourValue, 0, wxALIGN_CENTER | wxALL, 3);
1163 	mRightSizer->Add(mRightMidSizer);
1164 
1165 	mZeroContour = new wxCheckBox(this, ID_SHOW_ZERO_VALUE_CONTOUR, _T("Show Zero-value contour"));
1166 	mZeroContour->SetValue(lSOpts->GetShowZeroContour());
1167 	mAtomPosition = new wxCheckBox(this, ID_SHOW_ATOM_POSITION, _T("Show atom positions"));
1168 	mAtomPosition->SetValue(lSOpts->Get2DHashMarks());
1169 
1170 	mRightSizer->Add(mZeroContour,  0, wxALIGN_LEFT | wxALL, 3);
1171 	mRightSizer->Add(mAtomPosition,  0, wxALIGN_LEFT | wxALL, 3);
1172 
1173 	mMainSizer->Add(mLeftSizer, wxALIGN_CENTER | wxALL, 10);
1174 	mMainSizer->Add(mRightSizer, wxALIGN_CENTER | wxALL, 10);
1175 }
1176 
1177 void SurfacePrefsPane::saveToTempPrefs() {
1178 	SurfaceOptions * lSOpts = mTargetPrefs->GetSurfaceOptions();
1179 
1180 	long lv;
1181 	double dv;
1182 
1183 	(mNumContour->GetValue()).ToLong(&lv);
1184 	lSOpts->SetNumContours(lv);
1185 	(mMaxContourValue->GetValue()).ToDouble(&dv);
1186 	lSOpts->SetMaxContour(dv);
1187 
1188 	RGBColor tmpColor;
1189 	mSurfColor[0]->getColor(&tmpColor);
1190 	lSOpts->SetPosColor(tmpColor);
1191 	mSurfColor[1]->getColor(&tmpColor);
1192 	lSOpts->SetNegColor(tmpColor);
1193 }
1194 
1195 void SurfacePrefsPane::OnSliderUpdate(wxCommandEvent& event) {
1196 	SurfaceOptions * lSOpts = mTargetPrefs->GetSurfaceOptions();
1197 	int id = event.GetId();
1198 
1199 	if (id == ID_NUM_GRID_POINT_SLIDER)
1200 		lSOpts->SetNumGridPoints(mSldGridPoint->GetValue());
1201 	if (id == ID_3D_GRID_SIZE_SLIDER)
1202 		lSOpts->SetGridSize((float)(mSldGridSize->GetValue()/100));
1203 }
1204 
1205 void SurfacePrefsPane::OnCheckBox(wxCommandEvent& event) {
1206 	SurfaceOptions * lSOpts = mTargetPrefs->GetSurfaceOptions();
1207 	int id = event.GetId();
1208 
1209 	if (id == ID_SHOW_ZERO_VALUE_CONTOUR)
1210 		lSOpts->SetShowZeroContour(mZeroContour->GetValue());
1211 	if (id == ID_SHOW_ATOM_POSITION)
1212 		lSOpts->Set2DHashMarks(mAtomPosition->GetValue());
1213 }
1214 
1215 
1216 QD3DPrefsPane::QD3DPrefsPane(MolDisplayWin* targetWindow, wxBookCtrlBase *parent, WinPrefs* targetPrefs, Boolean GlobalPrefs)
1217 	: PrefsPane(targetWindow, targetPrefs, kQD3DPrefsPane, GlobalPrefs, parent) {
1218 
1219 	mMainSizer = new wxFlexGridSizer(11, 2, 5, 0);
1220 	mMainSizer->AddGrowableCol(0);
1221 	mMainSizer->AddGrowableCol(1);
1222 
1223 	SetSizer(mMainSizer);
1224 
1225 }
1226 
1227 void QD3DPrefsPane::SetupPaneItems(MolDisplayWin* /*targetWindow*/) {
1228 
1229 	int rflags = wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL;
1230 	int lflags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL;
1231 
1232 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Bond Size:")), 0,
1233 			rflags, 3);
1234 	mSld[0] = new wxSlider(this, ID_BOND_SIZE_SLIDER,
1235 			(int) (mTargetPrefs->GetQD3DBondWidth() * 500 + 0.5),
1236 			1, 100, wxDefaultPosition,
1237 			wxSize(155, wxDefaultCoord));
1238 	mMainSizer->Add(mSld[0], 0, lflags, 3);
1239 
1240 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Display Quality:")),
1241 			0, rflags, 3);
1242 	mSld[1] = new wxSlider(this, ID_DISPLAY_QUALITY_SLIDER,
1243 			(int) (mTargetPrefs->GetQD3DAtomQuality() + 0.5),
1244 			2, 40, wxDefaultPosition,
1245 			wxSize(155, wxDefaultCoord));
1246 	mMainSizer->Add(mSld[1], 0, lflags, 3);
1247 
1248 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Fill Light Brightness:")),
1249 			0, rflags, 3);
1250 	mSld[2] = new wxSlider(this, ID_FILL_LIGHT_BRIGHTNESS_SLIDER,
1251 			(int) (mTargetPrefs->GetQD3DFillBrightness() * 100 + 0.5),
1252 			0, 100, wxDefaultPosition,
1253 			wxSize(155, wxDefaultCoord));
1254 	mMainSizer->Add(mSld[2], 0, lflags, 3);
1255 
1256 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Point Light Brightness:")),
1257 			0, rflags, 3);
1258 	mSld[3] = new wxSlider(this, ID_POINT_LIGHT_BRIGHTNESS_SLIDER,
1259 			(int) (mTargetPrefs->GetQD3DPointBrightness()*100+0.5),
1260 			0, 100, wxDefaultPosition, wxSize(155, wxDefaultCoord));
1261 	mMainSizer->Add(mSld[3], 0, lflags, 3);
1262 
1263 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("High-Resolution Line Width:")),
1264 			0, rflags, 3);
1265 	mTargetPrefs->CylindersForLines(true);
1266 	mSld[4] = new wxSlider(this, ID_LINE_WIDTH_SLIDER,
1267 			(int) (mTargetPrefs->GetQD3DLineWidth()*10000+0.5),
1268 			0, 200, wxDefaultPosition, wxSize(155, wxDefaultCoord));
1269 	mTargetPrefs->CylindersForLines(false);
1270 	mMainSizer->Add(mSld[4], 0, lflags, 3);
1271 
1272 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("3D Perspective:")),
1273 			0, rflags, 3);
1274 	mSld[5] = new wxSlider(this, ID_DEPTH_CUEING_SLIDER,
1275 			(int)(mTargetPrefs->GetGLFOV()),
1276 			0, 45, wxDefaultPosition,
1277 			wxSize(155, wxDefaultCoord));
1278 	mMainSizer->Add(mSld[5], 0, lflags, 3);
1279 
1280 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Background color:")),
1281 			0, rflags, 3);
1282 	mBackgrdColor = new colorArea(this, 0, mTargetPrefs->GetBackgroundColorLoc());
1283 	mMainSizer->Add(mBackgrdColor, 0, lflags, 3);
1284 
1285 	if (GLEW_VERSION_2_0) {
1286 		mMainSizer->Add(new wxStaticText(this, wxID_ANY,
1287 					    _("Shader Mode:")), 0, rflags, 3);
1288 		wxString choices[3] = {
1289 			_("No shaders"),
1290 			_("Smooth shading"),
1291 			_("Smooth shading and shadows")
1292 		};
1293 		mShaderChooser = new wxChoice(this, ID_SHADER_CHOICE,
1294 									  wxDefaultPosition, wxDefaultSize,
1295 									  3, choices);
1296 		mShaderChooser->SetSelection(mTargetPrefs->GetShaderMode());
1297 		mMainSizer->Add(mShaderChooser, 0, lflags, 3);
1298 	}
1299 	mAutoRotateCheck = new wxCheckBox(this, ID_3D_AUTO_ROTATE_CHECK, _("Enable Auto Rotation"));
1300 	mAutoRotateCheck->SetValue(mTargetPrefs->AutoRotationEnabled());
1301 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, wxT("")), 0, rflags, 3);
1302 	mMainSizer->Add(mAutoRotateCheck, 0, lflags, 3);
1303 	mAutoRotateCheck->SetToolTip(_("Check to enable drag and release in the main display to start auto-rotation"));
1304 
1305 	int xv,yv,zv;
1306 	mTargetPrefs->GetAutoRotationVector(xv, yv, zv);
1307 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Rotation speed in X")), 0, rflags, 3);
1308 	wxSpinCtrl  * mspin = new wxSpinCtrl(this, ID_3D_AUTOROTATIONX_SPIN);
1309 	mspin->SetRange(-100, 100);
1310 	mspin->SetValue(xv);
1311 	mMainSizer->Add(mspin, 0, lflags, 3);
1312 
1313 	mMainSizer->Add(new wxStaticText(this, wxID_ANY, _("Rotation speed in Y")), 0, rflags, 3);
1314 	mspin = new wxSpinCtrl(this, ID_3D_AUTOROTATIONY_SPIN);
1315 	mspin->SetRange(-100, 100);
1316 	mspin->SetValue(yv);
1317 	mMainSizer->Add(mspin, 0, lflags, 3);
1318 }
1319 
1320 void QD3DPrefsPane::saveToTempPrefs() {
1321 	mBackgrdColor->getColor(mTargetPrefs->GetBackgroundColorLoc());
1322 	mTargetPrefs->EnableAutoRotation(mAutoRotateCheck->GetValue());
1323 }
1324 
1325 void QD3DPrefsPane::OnShaderChoice(wxCommandEvent& event) {
1326 	mTargetPrefs->SetShaderMode(event.GetInt());
1327 }
1328 
1329 void QD3DPrefsPane::OnSliderUpdate(wxCommandEvent &event) {
1330 	int id = event.GetId();
1331 
1332 	if (id == ID_BOND_SIZE_SLIDER)
1333 		mTargetPrefs->SetQD3DBondWidth((float)(mSld[0]->GetValue())/500);
1334 	if (id == ID_DISPLAY_QUALITY_SLIDER)
1335 		mTargetPrefs->SetQD3DAtomQuality(mSld[1]->GetValue());
1336 	if (id == ID_FILL_LIGHT_BRIGHTNESS_SLIDER)
1337 		mTargetPrefs->SetQD3DFillBrightness((float)(mSld[2]->GetValue())/100);
1338 	if (id == ID_POINT_LIGHT_BRIGHTNESS_SLIDER)
1339 		mTargetPrefs->SetQD3DPointBrightness((float)(mSld[3]->GetValue())/100);
1340 	if (id == ID_LINE_WIDTH_SLIDER)
1341 		mTargetPrefs->SetQD3DLineWidth((float)(mSld[4]->GetValue())/10000);
1342 	if (id == ID_DEPTH_CUEING_SLIDER)
1343 		mTargetPrefs->SetGLFOV((float)(mSld[5]->GetValue()));
1344 }
1345 
1346 void QD3DPrefsPane::OnSpinChange(wxSpinEvent & event) {
1347 	int id = event.GetId();
1348 	int val = event.GetPosition();
1349 
1350 	int xv, yv, zv;
1351 	mTargetPrefs->GetAutoRotationVector(xv, yv, zv);
1352 	if (id == ID_3D_AUTOROTATIONX_SPIN) {
1353 		xv = val;
1354 	} else { //other option is Y
1355 		yv = val;
1356 	}
1357 	mTargetPrefs->SetAutoRotationVector(xv, yv, zv);
1358 }
1359