void UIButton::internalCheckState() { if (hasAttr(STATE_PRESSED)) { m_color = m_button.m_pressedBkColor; m_font.m_color = m_button.m_pressedFontColor; m_button.m_frameColor = m_button.m_pressedFrameColor; } else if (hasAttr(STATE_HOT)) { m_color = m_button.m_hotBkColor; m_font.m_color = m_button.m_hotFontColor; m_button.m_frameColor = m_button.m_hotFrameColor; } else if (hasAttr(STATE_FOCUSED)) { m_color = m_button.m_focusedBkColor; m_font.m_color = m_button.m_focusedFontColor; m_button.m_frameColor = m_button.m_focusedFrameColor; } else { m_color = getTrueColor(m_button.m_normalBkColor); m_font.m_color = getTrueColor(m_button.m_normalFontColor); m_button.m_frameColor = getTrueColor(m_button.m_normalFrameColor); } }
Function::Function(const std::string& decl, NameSpace* pNameSpace): Decl(decl, pNameSpace), _flags(0), _retParam() { if (hasAttr(decl, "static")) _flags |= FN_STATIC; if (hasAttr(decl, "virtual")) _flags |= FN_VIRTUAL; if (hasAttr(decl, "inline")) _flags |= FN_INLINE; if (hasAttr(decl, "template")) _flags |= FN_TEMPLATE; if (isMethod() || isFunction()) { // parse the decl std::size_t pos = decl.rfind(name()); _retParam = decl.substr(0, pos-1); // eliminate static, virtual, inline, template _retParam = replace(_retParam, "static ", ""); _retParam = replace(_retParam, "virtual ", ""); _retParam = replace(_retParam, "inline ", ""); if (_flags & FN_TEMPLATE) { std::size_t pos = _retParam.find(">"); poco_assert (pos != std::string::npos); _retParam = _retParam.substr(pos+1); } Poco::trimInPlace(_retParam); } }
PassRefPtr<UIControl> UIControl::FindControl(UI_FIND_CALL proc, void* data, UINT flags) { if ((flags & UIFIND_VISIBLE) != 0 && !hasAttr(STATE_VISIBLE)) return nullptr; if ((flags & UIFIND_ENABLED) != 0 && !hasAttr(STATE_ENABLED)) return nullptr; if ((flags & UIFIND_HITTEST) != 0) return proc(this, data); return nullptr; }
bool SimObjBase::checkAttrs() { // added by yahara@tome (2011/02/22) // TODO: strange codes; it should be modified: by inamura on 2013-12-29 #define DEFINE_ATTR_STRING(NAME, TOKEN) (char *)TOKEN, #define DEFINE_ATTR_DOUBLE(NAME, TOKEN) (char *)TOKEN, #define DEFINE_ATTR_BOOL(NAME, TOKEN) (char *)TOKEN, // modified by inamura on 2013-12-29 // TODO: The above three definitions will be used to extract just attribution string from SimObjBaseAttrs.h // This way is too dangerous. by inamura static char *namesForAgent[] = { (char *)"name", (char *)"class", #include "SimObjBaseAttrs.h" }; static char *namesForEntities[] = { (char *)"name", (char *)"class", #define NO_AGENT_ATTRS #include "SimObjBaseAttrs.h" #undef NO_AGENT_ATTRS }; char **names = isAgent()? namesForAgent: namesForEntities; const char *myname = name(); bool b = true; for (int i=0; i<ARY_SIZE(names); i++) { const char *attrname = names[i]; if (hasAttr(attrname) == NULL) { b = false; LOG_ERR(("%s : no attribute \"%s\"", myname? myname:"noname", attrname)); } } return b; #undef DEFINE_ATTR_DOUBLE #undef DEFINE_ATTR_BOOL }
void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) { // If we use ``[[nodiscard]]`` attribute, we require at least C++17. Use a // macro or ``__attribute__`` with pre c++17 compilers by using // ReplacementString option. if ((NoDiscardMacro == "[[nodiscard]]" && !getLangOpts().CPlusPlus17) || !getLangOpts().CPlusPlus) return; auto FunctionObj = cxxRecordDecl(hasAnyName("::std::function", "::boost::function")); // Find all non-void const methods which have not already been marked to // warn on unused result. Finder->addMatcher( cxxMethodDecl( allOf(isConst(), isDefinitionOrInline(), unless(anyOf( returns(voidType()), isNoReturn(), isOverloadedOperator(), isVariadic(), hasTemplateReturnType(), hasClassMutableFields(), isConversionOperator(), hasAttr(clang::attr::WarnUnusedResult), hasType(isInstantiationDependentType()), hasAnyParameter(anyOf( parmVarDecl(anyOf(hasType(FunctionObj), hasType(references(FunctionObj)))), hasType(isNonConstReferenceOrPointer()), hasParameterPack())))))) .bind("no_discard"), this); }
float xmlutils::getAttrFloat(tinyxml2::XMLElement *e, std::string name, float defaultValue) { if(!hasAttr(e, name)) return defaultValue; std::string value = getAttrStr(e, name); return boost::lexical_cast<float>(value); }
std::string xmlutils::getAttrStr(tinyxml2::XMLElement *e, std::string name, std::string defaultValue) { if(!hasAttr(e, name)) return defaultValue; std::string value = getAttrStr(e, name); return value; }
double xmlutils::getAttrDouble(tinyxml2::XMLElement *e, std::string name, double defaultValue) { if(!hasAttr(e, name)) return defaultValue; std::string value = getAttrStr(e, name); return boost::lexical_cast<double>(value); }
boost::optional<std::string> PropertyFS::mapping() const { boost::optional<std::string> ret; std::string mapping; if (hasAttr("mapping")) { getAttr("mapping", mapping); ret = mapping; } return ret; }
std::string PropertyFS::name() const { std::string name; if (hasAttr("name")) { getAttr("name", name); return name; } else { throw MissingAttr("name"); } }
LinkType FeatureFS::linkType() const { if (hasAttr("link_type")) { std::string link_type; getAttr("link_type", link_type); return linkTypeFromString(link_type); } else { throw MissingAttr("data"); } }
boost::optional<std::string> PropertyFS::definition() const { boost::optional<std::string> ret; std::string definition; if (hasAttr("definition")) { getAttr("definition", definition); ret = definition; } return ret; }
boost::optional<std::string> PropertyFS::unit() const { boost::optional<std::string> ret; std::string unit; if (hasAttr("unit")) { getAttr("unit", unit); ret = unit; } return ret; }
std::string PropertyFS::id() const { std::string t; if (hasAttr("entity_id")) { getAttr("entity_id", t); } else { throw std::runtime_error("Entity has no id!"); } return t; }
EmberEntity* EntityWorldPickListener::findTerrainEntity() { auto entity = mView.getAvatar()->getEntity(); while (entity != nullptr) { if (entity->hasAttr("terrain")) { return static_cast<EmberEntity*>(entity); } entity = entity->getLocation(); } return nullptr; }
Variable::Variable(const std::string& decl, NameSpace* pNameSpace): Decl(decl, pNameSpace), _flags(0), _isPointer(false), _type() { if (hasAttr(decl, "static")) _flags |= VAR_STATIC; if (hasAttr(decl, "mutable")) _flags |= VAR_MUTABLE; if (hasAttr(decl, "volatile")) _flags |= VAR_VOLATILE; if (hasAttr(decl, "const")) _flags |= VAR_CONST; std::size_t pos = decl.rfind(name()); std::string tmp = decl.substr(0, pos); tmp = Poco::trim(tmp); pos = tmp.rfind("*"); _isPointer = (pos == (tmp.size()-1)); Poco::replaceInPlace(tmp, "static ", ""); Poco::replaceInPlace(tmp, "mutable ", ""); Poco::replaceInPlace(tmp, "volatile ", ""); Poco::replaceInPlace(tmp, "static\t", ""); Poco::replaceInPlace(tmp, "mutable\t", ""); Poco::replaceInPlace(tmp, "volatile\t", ""); if (tmp.find("const ") == 0) tmp = tmp.substr(6); if (tmp.find("const\t") == 0) tmp = tmp.substr(6); std::size_t rightCut = tmp.size(); while (rightCut > 0 && (tmp[rightCut-1] == '&' || tmp[rightCut-1] == '*' || tmp[rightCut-1] == '\t' || tmp[rightCut-1] == ' ')) --rightCut; _type = Poco::trim(tmp.substr(0, rightCut)); }
bool xmlutils::getAttrBool(tinyxml2::XMLElement *e, std::string name, bool defaultValue) { if(!hasAttr(e, name)) return defaultValue; std::string value = getAttrStr(e, name); if(value == "true") return true; if(value == "false") return false; std::stringstream ss; ss << "invalid value '" << value << "' for attribute '" << name << "': must be true or false"; throw std::range_error(ss.str()); }
bool FileFS::checkHeader() { bool check = true; std::vector<int> version; std::string str; // check format if (hasAttr("format")) { getAttr("format", str); if (str != FILE_FORMAT) { check = false; } } else { setAttr("format", FILE_FORMAT); } // check version if (hasAttr("version")) { getAttr("version", version); if (version != FILE_VERSION) { check = false; } } else { setAttr("version", FILE_VERSION); } return check; }
void IntegerTypesCheck::registerMatchers(MatchFinder *Finder) { // Find all TypeLocs. The relevant Style Guide rule only applies to C++. if (!getLangOpts().CPlusPlus) return; // Match any integer types, unless they are passed to a printf-based API: // // http://google.github.io/styleguide/cppguide.html#64-bit_Portability // "Where possible, avoid passing arguments of types specified by // bitwidth typedefs to printf-based APIs." Finder->addMatcher(typeLoc(loc(isInteger()), unless(hasAncestor(callExpr( callee(functionDecl(hasAttr(attr::Format))))))) .bind("tl"), this); IdentTable = llvm::make_unique<IdentifierTable>(getLangOpts()); }
void SimObjBase::copy(const SimObjBase &o) { const AttrM &attrs = o.attrs(); for (AttrM::const_iterator i=attrs.begin(); i!=attrs.end(); i++) { Attribute *a = i->second; Attribute *to = hasAttr(a->name()); if (to != NULL) { to->value().copy(a->value()); } else { this->push(new Attribute(*a)); } } m_ops = o.m_ops; }
EmberEntity* EmberEntity::getAttachedEntity(const std::string& namedPoint) { //HACK: this is just a temporary solution if (hasAttr(namedPoint)) { const Atlas::Message::Element& idElement = valueOfAttr(namedPoint); std::string id; if (Eris::Entity::extractEntityId(idElement, id)) { for (unsigned int i = 0; i < numContained(); ++i) { EmberEntity* entity = getEmberContained(i); if (entity && entity->getId() == id) { return entity; } } } } return 0; }
std::vector<std::string> EmberEntity::getActions() { //get the actions from Eris and return them a simple vector of strings std::vector<std::string> actions; if (hasAttr("actions")) { const Atlas::Message::Element& operations = valueOfAttr("actions"); if (operations.isList()) { const Atlas::Message::ListType& list = operations.asList(); actions.reserve(list.size()); Atlas::Message::ListType::const_iterator J = list.begin(); for (; J != list.end(); ++J) { if (J->isString()) { actions.push_back(J->asString()); } } } } return actions; }
std::vector<int> xmlutils::getAttrIntV(tinyxml2::XMLElement *e, std::string name, std::vector<int> defaultValue, int minLength, int maxLength, const char *sep) { if(hasAttr(e, name)) { try { std::vector<int> ret; string2vector(getAttrStr(e, name), ret, minLength, maxLength, sep); return ret; } catch(std::range_error &ex) { std::stringstream ss; ss << "attribute '" << name << "' " << ex.what(); throw std::range_error(ss.str()); } } else { return defaultValue; } }
void PropertyFS::setCreatedAt() { if (!hasAttr("created_at")) { time_t t = util::getTime(); setAttr("created_at", util::timeToStr(t)); } }
void PropertyFS::unit(const nix::none_t t) { if (hasAttr("unit")) { removeAttr("unit"); } forceUpdatedAt(); }
/** Goes thoguh a histogram NXS file and counts the number of pixels. * It also determines the name of the data field and axis to load * * @param nexusfilename :: nxs file path * @param entry_name :: name of the entry * @param bankNames :: returns the list of bank names */ void LoadTOFRawNexus::countPixels(const std::string &nexusfilename, const std::string &entry_name, std::vector<std::string> &bankNames) { m_numPixels = 0; m_numBins = 0; m_dataField = ""; m_axisField = ""; bankNames.clear(); // Create the root Nexus class auto file = new ::NeXus::File(nexusfilename); // Open the default data group 'entry' file->openGroup(entry_name, "NXentry"); // Also pop into the instrument file->openGroup("instrument", "NXinstrument"); // Look for all the banks std::map<std::string, std::string> entries = file->getEntries(); std::map<std::string, std::string>::iterator it; for (it = entries.begin(); it != entries.end(); ++it) { std::string name = it->first; if (name.size() > 4) { if (name.substr(0, 4) == "bank") { // OK, this is some bank data file->openGroup(name, it->second); // -------------- Find the data field name ---------------------------- if (m_dataField.empty()) { std::map<std::string, std::string> entries = file->getEntries(); std::map<std::string, std::string>::iterator it; for (it = entries.begin(); it != entries.end(); ++it) { if (it->second == "SDS") { file->openData(it->first); if (file->hasAttr("signal")) { int signal = 0; file->getAttr("signal", signal); if (signal == m_signalNo) { // That's the right signal! m_dataField = it->first; // Find the corresponding X axis std::string axes; m_assumeOldFile = false; if (!file->hasAttr("axes")) { if (1 != m_signalNo) { throw std::runtime_error( "Your chosen signal number, " + Strings::toString(m_signalNo) + ", corresponds to the data field '" + m_dataField + "' has no 'axes' attribute specifying."); } else { m_assumeOldFile = true; axes = "x_pixel_offset,y_pixel_offset,time_of_flight"; } } if (!m_assumeOldFile) { file->getAttr("axes", axes); } std::vector<std::string> allAxes; boost::split(allAxes, axes, boost::algorithm::detail::is_any_ofF<char>(",")); if (allAxes.size() != 3) throw std::runtime_error( "Your chosen signal number, " + Strings::toString(m_signalNo) + ", corresponds to the data field '" + m_dataField + "' which has only " + Strings::toString(allAxes.size()) + " dimension. Expected 3 dimensions."); m_axisField = allAxes.back(); g_log.information() << "Loading signal " << m_signalNo << ", " << m_dataField << " with axis " << m_axisField << std::endl; file->closeData(); break; } // Data has a 'signal' attribute } // Yes, it is a data field file->closeData(); } // each entry in the group } } file->closeGroup(); } // bankX name } } // each entry if (m_dataField.empty()) throw std::runtime_error("Your chosen signal number, " + Strings::toString(m_signalNo) + ", was not found in any of the data fields of any " "'bankX' group. Cannot load file."); for (it = entries.begin(); it != entries.end(); ++it) { std::string name = it->first; if (name.size() > 4) { if (name.substr(0, 4) == "bank") { // OK, this is some bank data file->openGroup(name, it->second); std::map<std::string, std::string> entries = file->getEntries(); if (entries.find("pixel_id") != entries.end()) { bankNames.push_back(name); // Count how many pixels in the bank file->openData("pixel_id"); std::vector<int64_t> dims = file->getInfo().dims; file->closeData(); if (!dims.empty()) { size_t newPixels = 1; for (auto dim : dims) newPixels *= dim; m_numPixels += newPixels; } } else { bankNames.push_back(name); // Get the number of pixels from the offsets arrays file->openData("x_pixel_offset"); std::vector<int64_t> xdim = file->getInfo().dims; file->closeData(); file->openData("y_pixel_offset"); std::vector<int64_t> ydim = file->getInfo().dims; file->closeData(); if (!xdim.empty() && !ydim.empty()) { m_numPixels += (xdim[0] * ydim[0]); } } if (entries.find(m_axisField) != entries.end()) { // Get the size of the X vector file->openData(m_axisField); std::vector<int64_t> dims = file->getInfo().dims; // Find the units, if available if (file->hasAttr("units")) file->getAttr("units", m_xUnits); else m_xUnits = "microsecond"; // use default file->closeData(); if (!dims.empty()) m_numBins = dims[0] - 1; } file->closeGroup(); } // bankX name } } // each entry file->close(); delete file; }
void PropertyFS::mapping(const nix::none_t t) { if (hasAttr("mapping")) { removeAttr("mapping"); forceUpdatedAt(); } }
void PropertyFS::definition(const nix::none_t t) { if (hasAttr("definition")) { removeAttr("definition"); } forceUpdatedAt(); }
void TerrainEntity::updateTerrain() { if (!hasAttr("terrain")) { std::cerr << "Entity has no terrain" << std::endl << std::flush; std::cerr << "Entity id " << getId() << std::endl << std::flush; return; } const Atlas::Message::Element &terrain = valueOfAttr("terrain"); if (!terrain.isMap()) { std::cerr << "Terrain is not a map" << std::endl << std::flush; } const Atlas::Message::MapType & tmap = terrain.asMap(); Atlas::Message::MapType::const_iterator I = tmap.find("points"); int xmin = 0, xmax = 0, ymin = 0, ymax = 0; if (I == tmap.end()) { std::cerr << "No terrain points" << std::endl << std::flush; } else { if (I->second.isList()) { // Legacy support for old list format. const Atlas::Message::ListType & plist = I->second.asList(); Atlas::Message::ListType::const_iterator J = plist.begin(); Atlas::Message::ListType::const_iterator Jend = plist.end(); for(; J != Jend; ++J) { if (!J->isList()) { std::cout << "Non list in points" << std::endl << std::flush; continue; } const Atlas::Message::ListType & point = J->asList(); if (point.size() != 3) { std::cout << "point without 3 nums" << std::endl << std::flush; continue; } int x = (int)point[0].asNum(); int y = (int)point[1].asNum(); xmin = std::min(xmin, x); xmax = std::max(xmax, x); ymin = std::min(ymin, y); ymax = std::max(ymax, y); Environment::getInstance().setBasePoint(x,y,point[2].asNum()); } } else if (I->second.isMap()) { const Atlas::Message::MapType & plist = I->second.asMap(); Atlas::Message::MapType::const_iterator J = plist.begin(); Atlas::Message::MapType::const_iterator Jend = plist.end(); for(; J != Jend; ++J) { if (!J->second.isList()) { std::cout << "Non list in points" << std::endl << std::flush; continue; } const Atlas::Message::ListType & point = J->second.asList(); if (point.size() != 3) { std::cout << "point without 3 nums" << std::endl << std::flush; continue; } int x = (int)point[0].asNum(); int y = (int)point[1].asNum(); xmin = std::min(xmin, x); xmax = std::max(xmax, x); ymin = std::min(ymin, y); ymax = std::max(ymax, y); Environment::getInstance().setBasePoint(x,y,point[2].asNum()); } } else { std::cerr << "Terrain is the wrong type" << std::endl << std::flush; } } // Read surfaces data Atlas::Message::MapType::const_iterator J = tmap.find("surfaces"); if (J == tmap.end()) { std::cerr << "Terrain surfaces does not exist" << std::endl; return; } if (J->second.isList() == false) { std::cerr << "Terrain surfaces is not a list" << std::endl; return; } const Atlas::Message::ListType & plist = J->second.asList(); Atlas::Message::ListType::const_iterator K = plist.begin(); Atlas::Message::ListType::const_iterator Kend = plist.end(); for(; K != Kend; ++K) { if (!(*K).isMap()) { std::cerr << "Surfaces entry is not a map" << std::endl; continue; } const Atlas::Message::MapType &L = K->asMap(); Atlas::Message::MapType::const_iterator name_itr = L.find("name"); Atlas::Message::MapType::const_iterator pattern_itr = L.find("pattern"); Atlas::Message::MapType::const_iterator params_itr = L.find("params"); if (name_itr == L.end() || pattern_itr == L.end()) { std::cerr << "Required params not here" << std::endl; continue; } const std::string &name = name_itr->second.asString(); const std::string &pattern = pattern_itr->second.asString(); printf("Name: %s - Pattern %s\n", name.c_str(), pattern.c_str()); Mercator::Shader::Parameters params; if (params_itr != L.end()) { const Atlas::Message::MapType & mlist = params_itr->second.asMap(); Atlas::Message::MapType::const_iterator M = mlist.begin(); Atlas::Message::MapType::const_iterator Mend = mlist.end(); for(; M != Mend; ++M) { // TODO: Check type first params[M->first] = M->second.asNum(); } } Environment::getInstance().setSurface(name, pattern, params); } }
/** Load a single bank into the workspace * * @param nexusfilename :: file to open * @param entry_name :: NXentry name * @param bankName :: NXdata bank name * @param WS :: workspace to modify * @param id_to_wi :: det ID to workspace index mapping */ void LoadTOFRawNexus::loadBank(const std::string &nexusfilename, const std::string &entry_name, const std::string &bankName, API::MatrixWorkspace_sptr WS, const detid2index_map &id_to_wi) { g_log.debug() << "Loading bank " << bankName << std::endl; // To avoid segfaults on RHEL5/6 and Fedora m_fileMutex.lock(); // Navigate to the point in the file auto file = new ::NeXus::File(nexusfilename); file->openGroup(entry_name, "NXentry"); file->openGroup("instrument", "NXinstrument"); file->openGroup(bankName, "NXdetector"); size_t m_numPixels = 0; std::vector<uint32_t> pixel_id; if (!m_assumeOldFile) { // Load the pixel IDs file->readData("pixel_id", pixel_id); m_numPixels = pixel_id.size(); if (m_numPixels == 0) { file->close(); m_fileMutex.unlock(); g_log.warning() << "Invalid pixel_id data in " << bankName << std::endl; return; } } else { // Load the x and y pixel offsets std::vector<float> xoffsets; std::vector<float> yoffsets; file->readData("x_pixel_offset", xoffsets); file->readData("y_pixel_offset", yoffsets); m_numPixels = xoffsets.size() * yoffsets.size(); if (0 == m_numPixels) { file->close(); m_fileMutex.unlock(); g_log.warning() << "Invalid (x,y) offsets in " << bankName << std::endl; return; } size_t bankNum = 0; if (bankName.size() > 4) { if (bankName.substr(0, 4) == "bank") { bankNum = boost::lexical_cast<size_t>(bankName.substr(4)); bankNum--; } else { file->close(); m_fileMutex.unlock(); g_log.warning() << "Invalid bank number for " << bankName << std::endl; return; } } // All good, so construct the pixel ID listing size_t numX = xoffsets.size(); size_t numY = yoffsets.size(); for (size_t i = 0; i < numX; i++) { for (size_t j = 0; j < numY; j++) { pixel_id.push_back( static_cast<uint32_t>(j + numY * (i + numX * bankNum))); } } } size_t iPart = 0; if (m_spec_max != Mantid::EMPTY_INT()) { uint32_t ifirst = pixel_id[0]; range_check out_range(m_spec_min, m_spec_max, id_to_wi); auto newEnd = std::remove_if(pixel_id.begin(), pixel_id.end(), out_range); pixel_id.erase(newEnd, pixel_id.end()); // check if beginning or end of array was erased if (ifirst != pixel_id[0]) iPart = m_numPixels - pixel_id.size(); m_numPixels = pixel_id.size(); if (m_numPixels == 0) { file->close(); m_fileMutex.unlock(); g_log.warning() << "No pixels from " << bankName << std::endl; return; }; } // Load the TOF vector std::vector<float> tof; file->readData(m_axisField, tof); size_t m_numBins = tof.size() - 1; if (tof.size() <= 1) { file->close(); m_fileMutex.unlock(); g_log.warning() << "Invalid " << m_axisField << " data in " << bankName << std::endl; return; } // Make a shared pointer MantidVecPtr Xptr; MantidVec &X = Xptr.access(); X.resize(tof.size(), 0); X.assign(tof.begin(), tof.end()); // Load the data. Coerce ints into double. std::string errorsField = ""; std::vector<double> data; file->openData(m_dataField); file->getDataCoerce(data); if (file->hasAttr("errors")) file->getAttr("errors", errorsField); file->closeData(); // Load the errors bool hasErrors = !errorsField.empty(); std::vector<double> errors; if (hasErrors) { try { file->openData(errorsField); file->getDataCoerce(errors); file->closeData(); } catch (...) { g_log.information() << "Error loading the errors field, '" << errorsField << "' for bank " << bankName << ". Will use sqrt(counts). " << std::endl; hasErrors = false; } } /*if (data.size() != m_numBins * m_numPixels) { file->close(); m_fileMutex.unlock(); g_log.warning() << "Invalid size of '" << m_dataField << "' data in " << bankName << std::endl; return; } if (hasErrors && (errors.size() != m_numBins * m_numPixels)) { file->close(); m_fileMutex.unlock(); g_log.warning() << "Invalid size of '" << errorsField << "' errors in " << bankName << std::endl; return; } */ // Have all the data I need m_fileMutex.unlock(); file->close(); for (size_t i = iPart; i < iPart + m_numPixels; i++) { // Find the workspace index for this detector detid_t pixelID = pixel_id[i - iPart]; size_t wi = id_to_wi.find(pixelID)->second; // Set the basic info of that spectrum ISpectrum *spec = WS->getSpectrum(wi); spec->setSpectrumNo(specid_t(wi + 1)); spec->setDetectorID(pixel_id[i - iPart]); // Set the shared X pointer spec->setX(X); // Extract the Y MantidVec &Y = spec->dataY(); Y.assign(data.begin() + i * m_numBins, data.begin() + (i + 1) * m_numBins); MantidVec &E = spec->dataE(); if (hasErrors) { // Copy the errors from the loaded document E.assign(errors.begin() + i * m_numBins, errors.begin() + (i + 1) * m_numBins); } else { // Now take the sqrt(Y) to give E E = Y; std::transform(E.begin(), E.end(), E.begin(), (double (*)(double))sqrt); } } // Done! }