BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Collection of utility functions for running quick simulations. More...
Functions | |
DAREFLCORE_EXPORT std::string | AddHtmlBackgroundTag (const std::string &line, const std::string &color) |
Returns string representing original 'line' wrapped in 'div' tag. More... | |
DAREFLCORE_EXPORT std::string | AddHtmlColorTag (const std::string &line, const std::string &color) |
Returns string representing original 'line' wrapped in html color tag. More... | |
DAREFLCORE_EXPORT std::string | AddHtmlColorTagToParts (const std::string &line, const std::vector< std::string > &parts, const std::string &color_parts, const std::string &color_rest) |
Returns string representing original 'line', where 'parts' are surrounded with color tag. More... | |
DAREFLCORE_EXPORT std::string | AddHtmlDivTag (const std::string &line) |
Returns string representing original 'line' wrapped in 'div' tag. More... | |
DAREFLCORE_EXPORT std::vector< Slice > | createBornAgainSlices (const multislice_t &multislice) |
DAREFLCORE_EXPORT GraphImportData | CreateData (const std::vector< std::vector< std::string >> &text_data, const ColumnInfo &axis, const ColumnInfo &intensity) |
Creates structure from text data. More... | |
DAREFLCORE_EXPORT std::vector< double > | CreateDiffVector (const std::vector< double > &a, const std::vector< double > &b) |
Returns vector representing elementwise 2*(a-b)/(a+b) difference over two vectors. More... | |
DAREFLCORE_EXPORT std::vector< std::pair< ColumnInfo, ColumnInfo > > | CreateGraphInfoPairs (const std::vector< ColumnInfo > &column_info) |
Pack ColumnInfo into pairs representing {AxisType, IntensityType}. More... | |
DAREFLCORE_EXPORT std::vector< ModelView::ExternalProperty > | CreateGraphProperties (ExperimentalDataModel *model) |
Returns vector of properties representing GraphItem content of the model. More... | |
DAREFLCORE_EXPORT accept_int_t | CreateLineNumberPatternValidator (const std::string &pattern) |
Creates a callback to define if given line number satisfies line number pattern. More... | |
DAREFLCORE_EXPORT accept_string_t | CreateLinePrefixValidator (const std::string &prefix_to_exclude) |
Creates a callback to define if given line has a valid content for further parsing. More... | |
DAREFLCORE_EXPORT multislice_t | CreateMultiSlice (const MultiLayerItem &multilayer) |
Creates multi-slice presentation of internal multilayer structure. More... | |
DAREFLCORE_EXPORT ModelView::ExternalProperty | CreateProperty (const ModelView::GraphItem *graph) |
Returns property representing given graph. More... | |
DAREFLCORE_EXPORT line_splitter_t | CreateSeparatorBasedSplitter (const std::string &separator) |
Creates line splitter based on separator. More... | |
DAREFLCORE_EXPORT std::vector< std::pair< int, int > > | ExpandLineNumberPattern (const std::string &pattern) |
Expands string representing line number pattern to inclusive pairs of line numbers. More... | |
DAREFLCORE_EXPORT std::pair< std::vector< double >, std::vector< double > > | ExtractTwoColumns (const std::vector< std::vector< std::string >> &text_data, size_t col1, size_t col2) |
Extracts double values from two columns of a string array. More... | |
DAREFLCORE_EXPORT ModelView::ExternalProperty | FindProperty (const std::vector< ModelView::ExternalProperty > &properties, const std::string &id) |
Finds the property with the same id in given vector and returns it. More... | |
DAREFLCORE_EXPORT std::vector< std::string > | LoadASCIIFile (const std::string &file_name) |
Loads ASCII file, returns it in the form of vector of strings. More... | |
DAREFLCORE_EXPORT void | SetDifference (const ModelView::Data1DItem *data1, const ModelView::Data1DItem *data2, ModelView::Data1DItem *target) |
Make target item represent difference of two Data1DItems. Target will get an axis as in data1. More... | |
Collection of utility functions for running quick simulations.
std::string gui2::Utils::AddHtmlBackgroundTag | ( | const std::string & | line, |
const std::string & | color | ||
) |
Returns string representing original 'line' wrapped in 'div' tag.
Definition at line 136 of file dataloader_utils.cpp.
Referenced by AddHtmlColorTagToParts().
std::string gui2::Utils::AddHtmlColorTag | ( | const std::string & | line, |
const std::string & | color | ||
) |
Returns string representing original 'line' wrapped in html color tag.
Definition at line 128 of file dataloader_utils.cpp.
Referenced by AddHtmlColorTagToParts().
std::string gui2::Utils::AddHtmlColorTagToParts | ( | const std::string & | line, |
const std::vector< std::string > & | parts, | ||
const std::string & | color_parts, | ||
const std::string & | color_rest | ||
) |
Returns string representing original 'line', where 'parts' are surrounded with color tag.
Definition at line 144 of file dataloader_utils.cpp.
References AddHtmlBackgroundTag(), AddHtmlColorTag(), and AddHtmlDivTag().
Referenced by gui2::LoaderPreviewPanel::showData().
std::string gui2::Utils::AddHtmlDivTag | ( | const std::string & | line | ) |
Returns string representing original 'line' wrapped in 'div' tag.
Definition at line 120 of file dataloader_utils.cpp.
Referenced by AddHtmlColorTagToParts().
std::vector< Slice > gui2::Utils::createBornAgainSlices | ( | const multislice_t & | multislice | ) |
Definition at line 74 of file quicksimutils.cpp.
References MaterialBySLD().
Referenced by gui2::MaterialProfile::CalculateProfile(), gui2::MaterialProfile::DefaultMaterialProfileLimits(), and gui2::SpecularToySimulation::runSimulation().
GraphImportData gui2::Utils::CreateData | ( | const std::vector< std::vector< std::string >> & | text_data, |
const ColumnInfo & | axis, | ||
const ColumnInfo & | intensity | ||
) |
Creates structure from text data.
Definition at line 201 of file dataloader_utils.cpp.
References gui2::GraphImportData::axis_units, gui2::GraphImportData::bin_centers, gui2::GraphImportData::bin_values, gui2::ColumnInfo::column, ExtractTwoColumns(), gui2::GraphImportData::signal_units, and gui2::ColumnInfo::units.
Referenced by gui2::DataLoaderDialog::onParseAllRequest().
std::vector< double > gui2::Utils::CreateDiffVector | ( | const std::vector< double > & | a, |
const std::vector< double > & | b | ||
) |
Returns vector representing elementwise 2*(a-b)/(a+b) difference over two vectors.
Resulting vector will have size equal to min(a.size(), b.size())
Definition at line 66 of file modelutils.cpp.
Referenced by SetDifference().
std::vector< std::pair< ColumnInfo, ColumnInfo > > gui2::Utils::CreateGraphInfoPairs | ( | const std::vector< ColumnInfo > & | column_info | ) |
Pack ColumnInfo into pairs representing {AxisType, IntensityType}.
For the moment we expect that only one column with AxisType exists. Number of intensity columns can be arbitrary.
Definition at line 185 of file dataloader_utils.cpp.
References gui2::Constants::AxisType, and gui2::Constants::IntensityType.
Referenced by gui2::DataLoaderDialog::onParseAllRequest().
std::vector< ModelView::ExternalProperty > gui2::Utils::CreateGraphProperties | ( | ExperimentalDataModel * | model | ) |
Returns vector of properties representing GraphItem content of the model.
Definition at line 46 of file modelutils.cpp.
References CreateProperty().
Referenced by gui2::ExperimentalDataController::update_all().
accept_int_t gui2::Utils::CreateLineNumberPatternValidator | ( | const std::string & | pattern | ) |
Creates a callback to define if given line number satisfies line number pattern.
"1, 4-6" will accept numbers {1, 4, 5, 6} and will refuse all others.
Definition at line 79 of file dataloader_utils.cpp.
References ExpandLineNumberPattern().
Referenced by gui2::DefaultParser::DefaultParser().
accept_string_t gui2::Utils::CreateLinePrefixValidator | ( | const std::string & | prefix_to_exclude | ) |
Creates a callback to define if given line has a valid content for further parsing.
Empty lines and lines starting from a given prefix will be excluded.
Definition at line 92 of file dataloader_utils.cpp.
Referenced by gui2::DefaultParser::DefaultParser().
multislice_t gui2::Utils::CreateMultiSlice | ( | const MultiLayerItem & | multilayer | ) |
Creates multi-slice presentation of internal multilayer structure.
Definition at line 67 of file quicksimutils.cpp.
Referenced by gui2::QuickSimController::process_multilayer().
ModelView::ExternalProperty gui2::Utils::CreateProperty | ( | const ModelView::GraphItem * | graph | ) |
Returns property representing given graph.
Used to link with the graph from various editors.
Definition at line 39 of file modelutils.cpp.
References ModelView::GraphItem::colorName(), ModelView::SessionItem::displayName(), ModelView::CompoundItem::displayName(), ModelView::SessionItem::identifier(), RealSpace::Particles::name(), and ModelView::SessionItem::parent().
Referenced by CreateGraphProperties(), and gui2::ExperimentalScanItem::setGraphItem().
line_splitter_t gui2::Utils::CreateSeparatorBasedSplitter | ( | const std::string & | separator | ) |
Creates line splitter based on separator.
Definition at line 104 of file dataloader_utils.cpp.
References ModelView ::Utils::RemoveRepeatedSpaces(), ModelView ::Utils::SplitString(), and ModelView ::Utils::TrimWhitespace().
Referenced by gui2::DefaultParser::DefaultParser().
std::vector< std::pair< int, int > > gui2::Utils::ExpandLineNumberPattern | ( | const std::string & | pattern | ) |
Expands string representing line number pattern to inclusive pairs of line numbers.
"1" will be expanded to { {1, 1} }, "1, 3-5" will be expanded to { {1, 1}, {3, 5} }
Definition at line 58 of file dataloader_utils.cpp.
References ModelView ::Utils::SplitString(), and ModelView ::Utils::StringToInteger().
Referenced by CreateLineNumberPatternValidator().
std::pair< std::vector< double >, std::vector< double > > gui2::Utils::ExtractTwoColumns | ( | const std::vector< std::vector< std::string >> & | text_data, |
size_t | col1, | ||
size_t | col2 | ||
) |
Extracts double values from two columns of a string array.
The row must be valid: string value must represent single double for both target columns, rows should have enough columns. If a row is invalid, it will be skipped, so resulting arrays have always the same length.
Definition at line 166 of file dataloader_utils.cpp.
References ModelView ::Utils::StringToDouble().
Referenced by CreateData().
ModelView::ExternalProperty gui2::Utils::FindProperty | ( | const std::vector< ModelView::ExternalProperty > & | properties, |
const std::string & | id | ||
) |
Finds the property with the same id
in given vector and returns it.
Definition at line 56 of file modelutils.cpp.
References ModelView::ExternalProperty::undefined().
Referenced by gui2::ExperimentalDataController::update_all().
std::vector< std::string > gui2::Utils::LoadASCIIFile | ( | const std::string & | file_name | ) |
Loads ASCII file, returns it in the form of vector of strings.
Definition at line 46 of file dataloader_utils.cpp.
Referenced by gui2::DataHandler::loadFile().
void gui2::Utils::SetDifference | ( | const ModelView::Data1DItem * | data1, |
const ModelView::Data1DItem * | data2, | ||
ModelView::Data1DItem * | target | ||
) |
Make target item represent difference of two Data1DItems. Target will get an axis as in data1.
Definition at line 78 of file modelutils.cpp.
References ModelView::Data1DItem::binCenters(), ModelView::Data1DItem::binValues(), CreateDiffVector(), ModelView::SessionItem::item(), ModelView::Data1DItem::setValues(), and ModelView::Data1DItem::T_AXIS.
Referenced by gui2::JobItem::updateDifferenceData().