/** * Utility to center detector. */ void LoadILLReflectometry::centerDetector(double xCenter) { std::string componentName("uniq_detector"); V3D pos = m_loader.getComponentPosition(m_localWorkspace, componentName); // TODO confirm! pos.setX(pos.X() - xCenter); m_loader.moveComponent(m_localWorkspace, componentName, pos); }
/// Try to extract a V3D from the given string with different separators. V3D V3DFromHKLColumnExtractor::getHKLFromString( const std::string &hklString) const { auto delimiters = boost::is_any_of(" ,[];"); std::string workingCopy = boost::trim_copy_if(hklString, delimiters); std::vector<std::string> indicesStr; boost::split(indicesStr, workingCopy, delimiters); if (indicesStr.size() != 3) { throw std::invalid_argument("Input string cannot be parsed as HKL."); } V3D hkl; hkl.setX(boost::lexical_cast<double>(indicesStr[0])); hkl.setY(boost::lexical_cast<double>(indicesStr[1])); hkl.setZ(boost::lexical_cast<double>(indicesStr[2])); return hkl; }
/** Create or adjust "pos" parameter for a component * Assumed that name either equals "x", "y" or "z" otherwise this * method will not add or modify "pos" parameter * @param comp :: Component * @param name :: name of the parameter * @param value :: value * @param pDescription :: a pointer (may be NULL) to a string, containing * parameter's * description. If provided, the contents of the string is copied to the * parameters * memory */ void ParameterMap::addPositionCoordinate( const IComponent *comp, const std::string &name, const double value, const std::string *const pDescription) { Parameter_sptr param = get(comp, pos()); V3D position; if (param) { // so "pos" already defined position = param->value<V3D>(); } else { // so "pos" is not defined - therefore get position from component position = comp->getPos(); } // adjust position if (name.compare(posx()) == 0) position.setX(value); else if (name.compare(posy()) == 0) position.setY(value); else if (name.compare(posz()) == 0) position.setZ(value); else { g_log.warning() << "addPositionCoordinate() called with unrecognized " "coordinate symbol: " << name; // set description if one is provided if (pDescription) { param->setDescription(*pDescription); } return; } // clear the position cache clearPositionSensitiveCaches(); // finally add or update "pos" parameter addV3D(comp, pos(), position, pDescription); }