void FindReplace::SetUpFindText() { Searchable* searchable = GetAvailableSearchable(); if ( searchable ) { QString selected_text = searchable->GetSelectedText(); if ( !selected_text.isEmpty() ) { if ( m_RegexOptionAutoTokenise && GetSearchMode() == FindReplace::SearchMode_Regex ) { selected_text = TokeniseForRegex( selected_text, false ); } // We want to make the text selected in the editor // as the default search text, but only if it's not "too long" if ( selected_text.length() < MAXIMUM_SELECTED_TEXT_LIMIT ) { ui.cbFind->setEditText( selected_text ); } } } // Find text should be selected by default ui.cbFind->lineEdit()->selectAll(); SetFocus(); }
bool realsense2Driver::open(Searchable& config) { std::vector<RGBDSensorParamParser::RGBDParam*> params; for (auto& p:params_map) { params.push_back(&(p.second)); } m_verbose = config.check("verbose"); if (config.check("stereoMode")) { m_stereoMode = config.find("stereoMode").asBool(); } if (!m_paramParser->parseParam(config, params)) { yError()<<"realsense2Driver: failed to parse the parameters"; return false; } if (!initializeRealsenseDevice()) { yError()<<"realsense2Driver: failed to initialize the realsense device"; return false; } // setting Parameters if (!setParams()) { return false; } return true; }
bool JoypadControlServer::openAndAttachSubDevice(Searchable& prop) { Property p; m_subDeviceOwned = new PolyDriver; p.fromString(prop.toString().c_str()); p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before // if error occour during open, quit here. m_subDeviceOwned->open(p); if (!m_subDeviceOwned->isValid()) { yError("JoypadControlServer: opening subdevice... FAILED\n"); return false; } m_isSubdeviceOwned = true; if(!attach(m_subDeviceOwned)) return false; if(!m_parser.configure(m_device) ) { yError() << "JoypadControlServer: error configuring interfaces for parsers"; return false; } openPorts(); PeriodicThread::setPeriod(m_period); return PeriodicThread::start(); }
bool open(Searchable& p) { bool dev = true; if (p.check("nodevice")) { dev = false; } if (dev) { poly.open(p); if (!poly.isValid()) { printf("cannot open driver\n"); return false; } if (!p.check("mute")) { // Make sure we can write sound poly.view(put); if (put==NULL) { printf("cannot open interface\n"); return false; } } } port.setStrict(true); if (!port.open(p.check("name",Value("/yarphear")).asString())) { printf("Communication problem\n"); return false; } if (p.check("remote")) { Network::connect(p.check("remote",Value("/remote")).asString(), port.getName()); } return true; }
bool RGBDSensorWrapper::openAndAttachSubDevice(Searchable& prop) { Property p; subDeviceOwned = new PolyDriver; p.fromString(prop.toString().c_str()); p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before // if error occour during open, quit here. yDebug("opening IRGBDSensor subdevice\n"); subDeviceOwned->open(p); if (!subDeviceOwned->isValid()) { yError("opening controlBoardWrapper2 subdevice... FAILED\n"); return false; } isSubdeviceOwned = true; if(!attach(subDeviceOwned)) return false; RateThread::setRate(rate); RateThread::start(); return true; }
bool fakeMotorDeviceClient::open(Searchable &config) { printf("Opening Fake Motor Device Client ...\n"); string remote=config.check("remote",Value("/fakeyServer")).asString().c_str(); string local=config.check("local",Value("/fakeyClient")).asString().c_str(); statePort.open((local+"/state:i").c_str()); cmdPort.open((local+"/cmd:o").c_str()); rpcPort.open((local+"/rpc").c_str()); bool ok=true; ok&=Network::connect((remote+"/state:o").c_str(),statePort.getName().c_str(),"udp"); ok&=Network::connect(cmdPort.getName().c_str(),(remote+"/cmd:i").c_str(),"udp"); ok&=Network::connect(rpcPort.getName().c_str(),(remote+"/rpc").c_str(),"tcp"); if (ok) { configured=true; printf("Fake Motor Device Client successfully open\n"); return true; } else { statePort.close(); cmdPort.close(); rpcPort.close(); printf("Fake Motor Device Client failed to open\n"); return false; } }
Contact Contact::byConfig(Searchable& config) { Contact result; result.port = config.check("port_number",Value(-1)).asInt(); result.hostName = config.check("ip",Value("")).asString().c_str(); result.regName = config.check("name",Value("")).asString().c_str(); result.carrier = config.check("carrier",Value("tcp")).asString().c_str(); return result; }
ResourceFinder::ResourceFinder(Searchable& data, void *implementation) { this->implementation = implementation; if (!data.isNull()) { config.fromString(data.toString()); } nullConfig = data.isNull(); owned = false; isConfiguredFlag = true; }
Contact Contact::fromConfig(const Searchable& config) { Contact result; result.mPriv->port = config.check("port_number",Value(-1)).asInt(); result.mPriv->hostname = config.check("ip",Value("")).asString().c_str(); result.mPriv->regName = config.check("name",Value("")).asString().c_str(); result.mPriv->carrier = config.check("carrier",Value("tcp")).asString().c_str(); return result; }
Value ReachManager::GetValueFromConfig(Searchable& config, string valueName) { if(!config.check(valueName.c_str())) { cout << "ERROR with config file : couldn't find value : \"" << valueName << "\"." << endl; return false; } return config.find(valueName.c_str()); }
bool TextureInput::open(Searchable& config) { textureIndex = config.check("textureIndex",Value(-1), "texture index").asInt(); string texturePort = config.check("port",Value("/texture"),"local port name").asString(); string portStr = this->moduleName + texturePort.c_str(); port.open( portStr.c_str() ); return true; }
static bool checkForCarrier(const Bytes *header, Searchable& group) { Bottle code = group.findGroup("code").tail(); if (code.size()==0) return false; if (matchCarrier(header,code)) { ConstString name = group.find("name").asString(); if (NetworkBase::registerCarrier(name.c_str(),NULL)) { return true; } } return false; }
// Replaces the user's search term with the user's // replacement text in the entire document. int FindReplace::ReplaceAll() { m_MainWindow.GetCurrentContentTab().SaveTabContent(); clearMessage(); if ( !IsValidFindText() ) { return 0; } SetCodeViewIfNeeded( true ); int count = 0; if ( GetLookWhere() == FindReplace::LookWhere_CurrentFile || m_LookWhereCurrentFile) { Searchable *searchable = GetAvailableSearchable(); if ( !searchable ) { return 0; } count = searchable->ReplaceAll( GetSearchRegex(), ui.cbReplace->lineEdit()->text() ); } else { count = ReplaceInAllFiles(); } if ( count == 0 ) { ShowMessage( tr( "No replacements made" ) ); } else { QString message = tr( "%1 replacements made", 0, count ); ShowMessage( message.arg( count ) ); } if ( count > 0 ) { // Signal that the contents have changed and update the view m_MainWindow.GetCurrentBook()->SetModified( true ); m_MainWindow.GetCurrentContentTab().ContentChangedExternally(); } UpdatePreviousFindStrings(); UpdatePreviousReplaceStrings(); return count; }
bool RGBDSensorWrapper::openAndAttachSubDevice(Searchable& prop) { Property p; subDeviceOwned = new PolyDriver; p.fromString(prop.toString().c_str()); p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device",prop.find("subdevice").asString()); // subdevice was already checked before // if error occour during open, quit here. yDebug("opening IRGBDSensor subdevice\n"); subDeviceOwned->open(p); if (!subDeviceOwned->isValid()) { yError("opening controlBoardWrapper2 subdevice... FAILED\n"); return false; } isSubdeviceOwned = true; if(!attach(subDeviceOwned)) return false; // Configuring parsers IRgbVisualParams * rgbVis_p; IDepthVisualParams * depthVis_p; subDeviceOwned->view(rgbVis_p); subDeviceOwned->view(depthVis_p); if(!parser.configure(sensor_p) ) { yError() << "RGBD wrapper: error configuring interfaces for parsers"; return false; } /* bool conf = rgbParser.configure(rgbVis_p); conf &= depthParser.configure(depthVis_p); if(!conf) { yError() << "RGBD wrapper: error configuring interfaces for parsers"; return false; } */ RateThread::setRate(rate); RateThread::start(); return true; }
bool HapticDeviceWrapper::open(Searchable &config) { portStemName=config.check("name", Value(HAPTICDEVICE_WRAPPER_DEFAULT_NAME)).asString().c_str(); verbosity=config.check("verbosity",Value(0)).asInt(); int period=config.check("period", Value(HAPTICDEVICE_WRAPPER_DEFAULT_PERIOD)).asInt(); setRate(period); if (config.check("subdevice")) { Property p(config.toString().c_str()); p.setMonitor(config.getMonitor(),"subdevice"); p.unput("device"); p.put("device",config.find("subdevice").asString()); if (driver.open(p)) { IHapticDevice *d; driver.view(d); attach(d); } else { yError("*** Haptic Device Wrapper: failed to open the driver!"); return false; } } if (verbosity>0) yInfo("*** Haptic Device Wrapper: opened"); return true; }
bool HapticDeviceClient::open(Searchable &config) { if (!config.check("remote")) { yError("*** Haptic Device Client: \"remote\" option missing, failed to open!"); return false; } if (!config.check("local")) { yError("*** Haptic Device Client: \"local\" option missing, failed to open!"); return false; } string remote=config.find("remote").asString().c_str(); string local=config.find("local").asString().c_str(); verbosity=config.check("verbosity",Value(0)).asInt(); statePort.open((local+"/state:i").c_str()); feedbackPort.open((local+"/feedback:o").c_str()); rpcPort.open((local+"/rpc").c_str()); statePort.setClient(this); bool ok=true; ok&=Network::connect((remote+"/state:o").c_str(),statePort.getName().c_str(),"udp"); ok&=Network::connect(feedbackPort.getName().c_str(),(remote+"/feedback:i").c_str(),"tcp"); ok&=Network::connect(rpcPort.getName().c_str(),(remote+"/rpc").c_str(),"tcp"); if (!ok) { statePort.close(); feedbackPort.close(); rpcPort.close(); yError("*** Haptic Device Client: unable to connect to Haptic Device Wrapper, failed to open!"); return false; } if (verbosity>0) yInfo("*** Haptic Device Client: opened"); return true; }
// Counts the number of occurrences of the user's // term in the document. int FindReplace::Count() { clearMessage(); if ( !IsValidFindText() ) { return 0; } SetCodeViewIfNeeded( true ); int count = 0; if ( GetLookWhere() == FindReplace::LookWhere_CurrentFile || m_LookWhereCurrentFile) { Searchable *searchable = GetAvailableSearchable(); if ( !searchable ) { return 0; } count = searchable->Count( GetSearchRegex() ); } else { count = CountInFiles(); } if ( count == 0 ) { CannotFindSearchTerm(); } else { QString message = tr( "%1 matches found", 0, count ); ShowMessage( message.arg( count ) ); } UpdatePreviousFindStrings(); return count; }
// Starts the search for the user's term. bool FindReplace::FindText( Searchable::Direction direction ) { bool found = false; clearMessage(); if ( !IsValidFindText() ) { return found; } SetCodeViewIfNeeded(); if ( GetLookWhere() == FindReplace::LookWhere_CurrentFile || m_LookWhereCurrentFile) { Searchable *searchable = GetAvailableSearchable(); if ( !searchable ) { return found; } found = searchable->FindNext( GetSearchRegex(), direction ); } else { found = FindInAllFiles( direction ); } if ( found ) { clearMessage(); } else { CannotFindSearchTerm(); } UpdatePreviousFindStrings(); return found; }
void configure_search(RosTypeSearch& env, Searchable& p) { if (p.check("out")) { env.setTargetDirectory(p.find("out").toString().c_str()); } if (p.check("no-ros",Value(0)).asInt()!=0 || p.findGroup("no-ros").size()==1) { env.disableRos(); } if (p.check("web",Value(0)).asInt()!=0 || p.findGroup("web").size()==1) { env.enableWeb(); } if (p.check("soft",Value(0)).asInt()!=0 || p.findGroup("soft").size()==1) { env.softFail(); } env.lookForService(p.check("service")); }
bool AnalogWrapper::openAndAttachSubDevice(Searchable &prop) { Property p; subDeviceOwned = new PolyDriver; p.fromString(prop.toString().c_str()); // p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.unput("device"); p.put("device", prop.find("subdevice").asString()); // subdevice was already checked before // if error occour during open, quit here. yDebug("opening analogServer subdevice..."); subDeviceOwned->open(p); if (!subDeviceOwned->isValid()) { yError("opening analogServer subdevice... FAILED\n"); return false; } subDeviceOwned->view(analogSensor_p); if (analogSensor_p == 0) { yError("Opening IAnalogSensor interface of analogServer subdevice... FAILED\n"); return false; } int chNum = analogSensor_p->getChannels(); if (chNum <= 0) { yError("Calling analog sensor has invalid channels number %d.\n", chNum); return false; } attach(analogSensor_p); RateThread::setRate(_rate); RateThread::start(); return true; }
// Replaces the user's search term with the user's // replacement text if a match is selected. If it's not, // calls Find in the direction specified so it becomes selected. bool FindReplace::ReplaceText( Searchable::Direction direction ) { bool found = false; clearMessage(); if ( !IsValidFindText() ) { return found; } SetCodeViewIfNeeded( true ); Searchable *searchable = GetAvailableSearchable(); if ( searchable ) { // If we have the matching text selected, replace it // This will not do anything if matching text is not selected. found = searchable->ReplaceSelected( GetSearchRegex(), ui.cbReplace->lineEdit()->text(), direction ); } if ( direction == Searchable::Direction_Up) { if (FindPrevious()) { found = true; }; } else { if (FindNext()) { found = true; } } UpdatePreviousFindStrings(); UpdatePreviousReplaceStrings(); return found; }
bool ServerSerial::open(Searchable& prop) { verb = (prop.check("verbose",Value(0),"Specifies if the device is in verbose mode (0/1).").asInt())>0; if (verb) printf("running with verbose output\n"); Value *name; if (prop.check("subdevice",name,"name of specific control device to wrap")) { printf("Subdevice %s\n", name->toString().c_str()); if (name->isString()) { // maybe user isn't doing nested configuration Property p; p.setMonitor(prop.getMonitor(), "subdevice"); // pass on any monitoring p.fromString(prop.toString()); p.put("device",name->toString()); poly.open(p); } else { Bottle subdevice = prop.findGroup("subdevice").tail(); poly.open(subdevice); } if (!poly.isValid()) { printf("cannot make <%s>\n", name->toString().c_str()); } } else { printf("\"--subdevice <name>\" not set for server_serial\n"); return false; } if (!poly.isValid()) { return false; } ConstString rootName = prop.check("name",Value("/serial"), "prefix for port names").asString().c_str(); command_buffer.attach(toDevice); reply_buffer.attach(fromDevice); command_buffer.useCallback(callback_impl); toDevice.open((rootName+"/in").c_str()); fromDevice.open((rootName+"/out").c_str()); if (poly.isValid()) poly.view(serial); if(serial != NULL) { start(); return true; } printf("subdevice <%s> doesn't look like a serial port (no appropriate interfaces were acquired)\n", name->toString().c_str()); return false; }
virtual bool open(Searchable& config) { int i; char portname[10]; if (config.check("help","if present, display usage message")) { printf("Call with --name </portprefix> --file <configfile.ini>\n"); return false; } cols = config.check("width", 640, "Number of image columns").asInt(); lines = config.check("height", 480, "Number of image lines").asInt(); levels = config.check("levels", 4, "Number of scales in the scale space").asInt(); scales = new double[levels]; Bottle &xtmp = config.findGroup("scales"); if(xtmp.size() != levels+1) for (i = 0; i < levels; i++) scales[i] = pow(2.0,i+1); for (i = 1; i < xtmp.size(); i++) scales[i-1] = xtmp.get(i).asDouble(); ss.AllocateResources(lines, cols, levels, scales); infloat = cvCreateImage(cvSize(cols,lines), IPL_DEPTH_32F, 1); ingray = cvCreateImage(cvSize(cols,lines), IPL_DEPTH_8U, 1); outgray = cvCreateImage(cvSize(cols,lines), IPL_DEPTH_8U, 1); outfloat = cvCreateImageHeader(cvSize(cols,lines), IPL_DEPTH_32F, 1); portIn.open(getName("in")); portOut = new BufferedPort<ImageOf<PixelMono> >[levels]; for( i = 1; i <= levels; i++ ) { sprintf(portname, "out:%d", i); portOut[i-1].open(getName(portname)); } return true; };
bool fakeMotorDeviceServer::open(Searchable &config) { printf("Opening Fake Motor Device Server ...\n"); string local=config.check("local",Value("/fakeyServer")).asString().c_str(); int Ts=config.check("Ts",Value(10)).asInt(); statePort.open((local+"/state:o").c_str()); cmdPort.open((local+"/cmd:i").c_str()); rpcPort.open((local+"/rpc").c_str()); rpcPort.setReader(*this); // the part is composed of three rotational joints // whose bounds are given in degrees just below Matrix lim(3,2); lim(0,0)=-180.0; lim(0,1)=180.0; // joint 0 lim(1,0)=-90.0; lim(1,1)=90.0; // joint 1 lim(2,0)=-45.0; lim(2,1)=45.0; // joint 2 Vector q0; for (int i=0; i<lim.rows(); i++) q0.push_back((lim(i,0)+lim(i,1))/2.0); // the motors themselves are represented // by pure integrators that give back joints // positions when fed with joints velocities motors=new Integrator(0.001*Ts,q0,lim); vel.resize(motors->get().length(),0.0); setRate(Ts); start(); configured=true; printf("Fake Motor Device Server successfully open\n"); return true; }
bool ReachManager::open(Searchable& config) { cout << "config : " << config.toString() << endl; parameters["input_port"] = new Value(GetValueFromConfig(config, "input_port")); parameters["output_port"] = new Value(GetValueFromConfig(config, "output_port")); parameters["robot"] = new Value(GetValueFromConfig(config, "robot")); parameters["num_dof"] = new Value(GetValueFromConfig(config, "num_dof")); parameters["reach_command_code"] = new Value(GetValueFromConfig(config, "reach_command_code")); parameters["max_error"] = new Value(GetValueFromConfig(config, "max_error")); parameters["solver_name"] = new Value(GetValueFromConfig(config, "solver_name")); parameters["enabled_arm"] = new Value(GetValueFromConfig(config, "enabled_arm")); parameters["pos_vel_cont"] = new Value(GetValueFromConfig(config, "pos_vel_cont")); parameters["min_reach_dist"] = new Value(GetValueFromConfig(config, "min_reach_dist")); cout << "min reach dist : " << parameters["min_reach_dist"]->asDouble() << endl; parameters["reach_mode_dist"] = new Value(GetValueFromConfig(config, "reach_mode_dist")); cout << "reach mode dist : " << parameters["reach_mode_dist"]->asDouble() << endl; parameters["object_ID"] = new Value(GetValueFromConfig(config, "object_ID")); //cout << "cool !" << endl; inPort.open(parameters["input_port"]->asString().c_str()); outPort.open(parameters["output_port"]->asString().c_str()); //Network::connect(outPort.getName().c_str(), "/manager"); outFile.open("reaching.dat"); if(parameters["enabled_arm"]->asString() == "left") { OpenIKSolver("left"); } else if(parameters["enabled_arm"]->asString() == "right") { OpenIKSolver("right"); } else if(parameters["enabled_arm"]->asString() == "both") { OpenIKSolver("left"); OpenIKSolver("right"); } if(parameters["pos_vel_cont"]->asInt()) { InitPositionControl("right"); InitPositionControl("left"); } return true; }
bool AcousticMap::open(Searchable& config) { bool ok = true; if(!config.check("name")) { std::cout << "AuditoryMap: Error, module base name not found in configuration. Start the module with the --name option.." << std::endl; return false; } // module base name std::string strModuleName = std::string(config.find("name").asString().c_str()); // look for group EGO_SPHERE_ACOUSTIC_MAP Bottle botConfigAcoustic(config.toString().c_str()); botConfigAcoustic.setMonitor(config.getMonitor()); if (!config.findGroup("EGO_SPHERE_ACOUSTIC_MAP").isNull()) { botConfigAcoustic.clear(); botConfigAcoustic.fromString(config.findGroup("EGO_SPHERE_ACOUSTIC_MAP", "Loading visual map configuration from group EGO_SPHERE_ACOUSTIC_MAP.").toString()); } _salienceDecayRate = botConfigAcoustic.check("decayAcoustic", Value(0.95), "Decay for the acoustic saliency map (double).").asDouble(); _resXAcoustic = botConfigAcoustic.check("resXAcoustic", Value(80), "Width of internal acoustic map (int)").asInt(); _resYAcoustic = botConfigAcoustic.check("resYAcoustic", Value(60), "Height of internal acoustic map (int)").asInt(); _imgCart.resize(_resXAcoustic,_resYAcoustic); _imgRemapX.resize(_resXAcoustic,_resYAcoustic); _imgRemapY.resize(_resXAcoustic,_resYAcoustic); _imgSpher.resize(_resXAcoustic,_resYAcoustic); _imgMapResA.resize(_resXAcoustic,_resYAcoustic); ok = ok && _prtVctSound.open(std::string(strModuleName + std::string("/mapAuditory/vct_in")).c_str()); return ok; }
bool ClientCartesianController::open(Searchable &config) { ConstString remote, local, carrier; if (config.check("remote")) remote=config.find("remote").asString(); else return false; if (config.check("local")) local=config.find("local").asString(); else return false; carrier=config.check("carrier",Value("udp")).asString(); if (config.check("timeout")) timeout=config.find("timeout").asDouble(); portCmd.open((local+"/command:o").c_str()); portState.open((local+"/state:i").c_str()); portEvents.open((local+"/events:i").c_str()); portRpc.open((local+"/rpc:o").c_str()); bool ok=true; ok&=Network::connect(portRpc.getName().c_str(),(remote+"/rpc:i").c_str()); if (ok) { Bottle info; getInfoHelper(info); if (info.check("server_version")) { double server_version=info.find("server_version").asDouble(); if (server_version!=CARTCTRL_CLIENT_VER) { yError("version mismatch => server(%g) != client(%g); please update accordingly", server_version,CARTCTRL_CLIENT_VER); return false; } } else yWarning("unable to retrieve server version; please update the server"); } else { yError("unable to connect to the server rpc port!"); return false; } ok&=Network::connect(portCmd.getName().c_str(),(remote+"/command:i").c_str(),carrier.c_str()); ok&=Network::connect((remote+"/state:o").c_str(),portState.getName().c_str(),carrier.c_str()); ok&=Network::connect((remote+"/events:o").c_str(),portEvents.getName().c_str(),carrier.c_str()); // check whether the solver is alive and connected if (ok) { Bottle command, reply; command.addVocab(IKINCARTCTRL_VOCAB_CMD_GET); command.addVocab(IKINCARTCTRL_VOCAB_OPT_ISSOLVERON); if (!portRpc.write(command,reply)) { yError("unable to get reply from server!"); close(); return false; } if (reply.get(0).asVocab()==IKINCARTCTRL_VOCAB_REP_ACK) if (reply.size()>1) if (reply.get(1).asVocab()==IKINCARTCTRL_VOCAB_VAL_TRUE) return connected=true; yError("unable to connect to solver!"); close(); return false; } else { yError("unable to connect to server!"); close(); return false; } }
virtual bool open(Searchable& config) { if (config.check("help","if present, display usage message")) { printf("Call with --name </portprefix> --file <configfile.ini>\n"); return false; } // Defaults will correspond to a view field of 90 deg. _input_lines = config.check("h", 480, "Input image lines").asInt(); _input_cols = config.check("w", 640, "Input image columns").asInt(); _fx = config.check("fx", 320, "Focal distance (on horizontal pixel size units)").asDouble(); _fy = config.check("fy", 240, "Focal distance (on vertical pixel size units)").asDouble(); _cx = config.check("cx", 320, "Image center (on horizontal pixel size units)").asDouble(); _cy = config.check("cy", 240, "Image center (on vertical pixel size units)").asDouble(); _k1 = config.check("k1", 0, "Radial distortion (first parameter)").asDouble(); _k2 = config.check("k2", 0, "Radial distortion (second parameter)").asDouble(); _p1 = config.check("p1", 0, "Tangential distortion (first parameter)").asDouble(); _p2 = config.check("p2", 0, "Tangential distortion (second parameter)").asDouble(); _output_lines = config.check("oh", 480, "Output image lines").asInt(); _output_cols = config.check("ow", 640, "Output image columns").asInt(); _mapx = cvCreateImage(cvSize(_output_cols, _output_lines), IPL_DEPTH_32F, 1); _mapy = cvCreateImage(cvSize(_output_cols, _output_lines), IPL_DEPTH_32F, 1); if(!compute_sp_map(_input_lines, _input_cols, _output_lines, _output_cols, _fx, _fy, _cx, _cy, _k1, _k2, _p1, _p2, (float*)_mapx->imageData, (float*)_mapy->imageData)) return false; portImgIn.open(getName("in")); portImgOut.open(getName("out")); return true; };
bool RemoteControlBoardRemapper::open(Searchable& config) { Property prop; prop.fromString(config.toString().c_str()); std::string localPortPrefix; std::vector<std::string> remoteControlBoardsPorts; // Check if the required parameters are found if( prop.check("localPortPrefix") && prop.find("localPortPrefix").isString() ) { localPortPrefix = prop.find("localPortPrefix").asString().c_str(); } else { yError() <<"RemoteControlBoardRemapper: Error parsing parameters: \"localPortPrefix\" should be a string."; return false; } Bottle *remoteControlBoards=prop.find("remoteControlBoards").asList(); if(remoteControlBoards==0) { yError() <<"RemoteControlBoardRemapper: Error parsing parameters: \"remoteControlBoards\" should be followed by a list."; return false; } remoteControlBoardsPorts.resize(remoteControlBoards->size()); for(int ax=0; ax < remoteControlBoards->size(); ax++) { remoteControlBoardsPorts[ax] = remoteControlBoards->get(ax).asString().c_str(); } // Load the REMOTE_CONTROLBOARD_OPTIONS, containg any additional option to pass to the remote control boards Property remoteControlBoardsOptions; Bottle & optionsGroupBot = prop.findGroup("REMOTE_CONTROLBOARD_OPTIONS"); if( !(optionsGroupBot.isNull()) ) { remoteControlBoardsOptions.fromString(optionsGroupBot.toString()); } // Parameters loaded, open all the remote controlboards m_remoteControlBoardDevices.resize(remoteControlBoardsPorts.size(),0); PolyDriverList remoteControlBoardsList; for(size_t ctrlBrd=0; ctrlBrd < remoteControlBoardsPorts.size(); ctrlBrd++ ) { std::string remote = remoteControlBoardsPorts[ctrlBrd]; // Note: as local parameter we use localPortPrefix+remoteOfTheReportControlBoard std::string local = localPortPrefix+remote; Property options = remoteControlBoardsOptions; options.put("device", "remote_controlboard"); options.put("local", local); options.put("remote", remote); m_remoteControlBoardDevices[ctrlBrd] = new PolyDriver(); bool ok = m_remoteControlBoardDevices[ctrlBrd]->open(options); if( !ok || !(m_remoteControlBoardDevices[ctrlBrd]->isValid()) ) { yError() << "RemoteControlBoardRemapper: error opening remote_controlboard with remote \"" << remote << "\", opening the device failed."; closeAllRemoteControlBoards(); return false; } // We use the remote name of the remote_controlboard as the key for it, in absense of anything better remoteControlBoardsList.push((m_remoteControlBoardDevices[ctrlBrd]),remote.c_str()); } // Device opened, now we open the ControlBoardRemapper and then we call attachAll bool ok = ControlBoardRemapper::open(prop); if( !ok ) { yError() << "RemoteControlBoardRemapper: error opening the controlboardremapper device, opening the device failed."; ControlBoardRemapper::close(); closeAllRemoteControlBoards(); return false; } // If open went ok, we now call attachAll ok = ControlBoardRemapper::attachAll(remoteControlBoardsList); if( !ok ) { yError() << "RemoteControlBoardRemapper: error calling attachAll in the controlboardremapper device, opening the device failed."; ControlBoardRemapper::close(); closeAllRemoteControlBoards(); return false; } // All went ok, return true // TODO: close devices that are not actually used by the remapper return true; }
bool FindReplace::FindInAllFiles( Searchable::Direction direction ) { Searchable *searchable = 0; bool found = false; if ( IsCurrentFileInHTMLSelection() ) { searchable = GetAvailableSearchable(); if ( searchable ) { found = searchable->FindNext( GetSearchRegex(), direction, m_SpellCheck, false, false); } } if ( !found ) { // TODO: make this handle all types of files Resource *containing_resource = GetNextContainingHTMLResource( direction ); if ( containing_resource ) { // Save if editor or F&R has focus bool has_focus = HasFocus(); // Save selected resources since opening tabs changes selection QList<Resource *>selected_resources = GetHTMLFiles(); m_MainWindow.OpenResource( *containing_resource); while ( !m_MainWindow.GetCurrentContentTab().IsLoadingFinished() ) { // Make sure Qt processes events, signals and calls slots qApp->processEvents(); SleepFunctions::msleep( 100 ); } // Restore selection since opening tabs changes selection if ( GetLookWhere() == FindReplace::LookWhere_SelectedHTMLFiles && !m_SpellCheck) { m_MainWindow.SelectResources(selected_resources); } // Reset focus to F&R if it had it if (has_focus) { SetFocus(); } searchable = GetAvailableSearchable(); if ( searchable ) { found = searchable->FindNext( GetSearchRegex(), direction, m_SpellCheck, true, false ); } } else { if ( searchable ) { // Check the part of the original file above the cursor found = searchable->FindNext( GetSearchRegex(), direction, m_SpellCheck, false, false ); } } } return found; }