Skip to content

Commit

Permalink
add Tools > XPS KE <-> BE
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Feb 23, 2016
1 parent 90ee7f4 commit 8372a6f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
User-visible changes in version 1.3.1 (unreleased):
* GUI: more options in the peak-top menu
* GUI: Tools > XPS KE <-> BE
* added utilities F.findx(), F.extremum(), centile(N, expr), %peak.IB
* bug fixes, as always

User-visible changes in version 1.3.0 (2015-05-25):
* support filenames with non-ascii characters
Expand Down
7 changes: 6 additions & 1 deletion fityk/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ string get_file_basename(const string& path)

Data::Data(BasicContext* ctx, Model *model)
: ctx_(ctx), model_(model),
x_step_(0.), has_sigma_(false)
x_step_(0.), has_sigma_(false), xps_source_energy_(0.)
{
}

Expand Down Expand Up @@ -80,6 +80,7 @@ void Data::clear()
x_step_ = 0;
active_.clear();
has_sigma_ = false;
xps_source_energy_ = 0.;
}

bool Data::completely_empty() const
Expand Down Expand Up @@ -331,6 +332,10 @@ void Data::load_file(const LoadSpec& spec)
block_name += "/";
block_name += block->get_name();
}
if (block->meta.has_key("source energy")) {
const string& energy = block->meta.get("source energy");
xps_source_energy_ = strtod(energy.c_str(), NULL);
}
}
} catch (const std::runtime_error& e) {
throw ExecuteError(e.what());
Expand Down
2 changes: 2 additions & 0 deletions fityk/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public :
void revert();
Model* model() { return model_; }
const Model* model() const { return model_; }
double xps_source_energy() const { return xps_source_energy_; }

private:
const BasicContext* ctx_;
Expand All @@ -93,6 +94,7 @@ public :
bool has_sigma_;
std::vector<Point> p_;
std::vector<int> active_;
double xps_source_energy_;

void post_load();
void verify_options(const xylib::DataSet* ds, const std::string& options);
Expand Down
22 changes: 22 additions & 0 deletions wxgui/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ enum {
ID_F_REDO ,
ID_F_HISTORY ,
ID_T_PD ,
ID_T_KEBE ,
ID_F_M ,
ID_F_M_END = ID_F_M+50 ,
ID_SESSION_LOG ,
Expand Down Expand Up @@ -329,6 +330,7 @@ BEGIN_EVENT_TABLE(FFrame, wxFrame)
EVT_MENU (ID_F_HISTORY, FFrame::OnFHistory)

EVT_MENU (ID_T_PD, FFrame::OnPowderDiffraction)
EVT_MENU (ID_T_KEBE, FFrame::OnXpsKEBE)

EVT_MENU (ID_G_M_ZOOM, FFrame::OnChangeMouseMode)
EVT_MENU (ID_G_M_RANGE, FFrame::OnChangeMouseMode)
Expand Down Expand Up @@ -676,6 +678,8 @@ void FFrame::set_menubar()
append_mi(tools_menu, ID_T_PD, wxBitmap(powdifpat16_xpm),
wxT("&Powder Diffraction"),
wxT("A tool for Pawley fitting"));
tools_menu->Append(ID_T_KEBE, "&XPS KE<->BE",
"Requires known source energy");

wxMenu* gui_menu = new wxMenu;
wxMenu* gui_menu_mode = new wxMenu;
Expand Down Expand Up @@ -1301,6 +1305,24 @@ void FFrame::OnPowderDiffraction (wxCommandEvent&)
PowderDiffractionDlg(this, -1).ShowModal();
}

void FFrame::OnXpsKEBE(wxCommandEvent&)
{
vector<int> dd = get_selected_data_indices();
v_foreach(int, i, dd) {
Data *data = ftk->dk.data(*i);
double e = data->xps_source_energy();
if (e > 0) {
exec("@" + S(*i) + ": X = " + eS(e) +
(data->get_x_min() > 0 ? " - x" : " + x"));
} else {
wxMessageBox("Switching between Kinetic and Binding Energy\n"
"works only when the source energy is known\n"
"from the data file in VAMAS or other XPS format.",
"Unknown source energy", wxOK|wxICON_ERROR);
}
}
}

void FFrame::OnMenuLogStartUpdate (wxUpdateUIEvent& event)
{
event.Enable(ftk->get_settings()->logfile.empty());
Expand Down
1 change: 1 addition & 0 deletions wxgui/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class FFrame: public wxFrame
void OnFHistory (wxCommandEvent& event);

void OnPowderDiffraction (wxCommandEvent&);
void OnXpsKEBE(wxCommandEvent&);

void OnMenuLogStartUpdate (wxUpdateUIEvent& event);
void OnMenuLogStopUpdate (wxUpdateUIEvent& event);
Expand Down

0 comments on commit 8372a6f

Please sign in to comment.