本文整理汇总了C++中TraCIServer::readTypeCheckingBoundary方法的典型用法代码示例。如果您正苦于以下问题:C++ TraCIServer::readTypeCheckingBoundary方法的具体用法?C++ TraCIServer::readTypeCheckingBoundary怎么用?C++ TraCIServer::readTypeCheckingBoundary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraCIServer
的用法示例。
在下文中一共展示了TraCIServer::readTypeCheckingBoundary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNamedView
bool
TraCIServerAPI_GUI::processSet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
std::string warning = ""; // additional description for response
// variable
int variable = inputStorage.readUnsignedByte();
if (variable != VAR_VIEW_ZOOM && variable != VAR_VIEW_OFFSET && variable != VAR_VIEW_SCHEMA && variable != VAR_VIEW_BOUNDARY
&& variable != VAR_SCREENSHOT && variable != VAR_TRACK_VEHICLE
) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "Change GUI State: unsupported variable specified", outputStorage);
}
// id
std::string id = inputStorage.readString();
GUISUMOAbstractView* v = getNamedView(id);
if (v == 0) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "View '" + id + "' is not known", outputStorage);
}
// process
switch (variable) {
case VAR_VIEW_ZOOM: {
Position off, p;
double zoom = 1;
if (!server.readTypeCheckingDouble(inputStorage, zoom)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "The zoom must be given as a double.", outputStorage);
}
off.set(v->getChanger().getXPos(), v->getChanger().getYPos(), zoom);
v->setViewport(off, p);
}
break;
case VAR_VIEW_OFFSET: {
Position off, p;
if (!server.readTypeCheckingPosition2D(inputStorage, off)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "The view port must be given as a position.", outputStorage);
}
off.set(off.x(), off.y(), v->getChanger().getZoom());
v->setViewport(off, p);
}
break;
case VAR_VIEW_SCHEMA: {
std::string schema;
if (!server.readTypeCheckingString(inputStorage, schema)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "The scheme must be specified by a string.", outputStorage);
}
if (!v->setColorScheme(schema)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "The scheme is not known.", outputStorage);
}
}
break;
case VAR_VIEW_BOUNDARY: {
Boundary b;
if (!server.readTypeCheckingBoundary(inputStorage, b)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "The boundary must be specified by a bounding box.", outputStorage);
}
v->centerTo(b);
break;
}
case VAR_SCREENSHOT: {
std::string filename;
if (!server.readTypeCheckingString(inputStorage, filename)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "Making a snapshot requires a file name.", outputStorage);
}
std::string error = v->makeSnapshot(filename);
if (error != "") {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, error, outputStorage);
}
}
break;
case VAR_TRACK_VEHICLE: {
std::string id;
if (!server.readTypeCheckingString(inputStorage, id)) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "Tracking requires a string vehicle ID.", outputStorage);
}
if (id == "") {
v->stopTrack();
} else {
SUMOVehicle* veh = MSNet::getInstance()->getVehicleControl().getVehicle(id);
if (veh == 0) {
return server.writeErrorStatusCmd(CMD_SET_GUI_VARIABLE, "Could not find vehicle '" + id + "'.", outputStorage);
}
if (!static_cast<GUIVehicle*>(veh)->hasActiveAddVisualisation(v, GUIVehicle::VO_TRACKED)) {
v->startTrack(static_cast<GUIVehicle*>(veh)->getGlID());
static_cast<GUIVehicle*>(veh)->addActiveAddVisualisation(v, GUIVehicle::VO_TRACKED);
}
}
}
default:
break;
}
server.writeStatusCmd(CMD_SET_GUI_VARIABLE, RTYPE_OK, warning, outputStorage);
return true;
}