Apollo 11.0
自动驾驶开放平台
main.cc 文件参考
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLFunctions>
#include <QtWidgets/QApplication>
#include "modules/tools/visualizer/main_window.h"
main.cc 的引用(Include)关系图:

浏览源代码.

函数

int main (int argc, char *argv[])
 

函数说明

◆ main()

int main ( int  argc,
char *  argv[] 
)

在文件 main.cc 第 23 行定义.

23 {
24 QApplication a(argc, argv);
25 int major, minor;
26 {
27 QOffscreenSurface surf;
28 surf.create();
29
30 QOpenGLContext ctx;
31 ctx.create();
32 ctx.makeCurrent(&surf);
33
34 std::stringstream strStreamObj;
35 strStreamObj << (const char*)ctx.functions()->glGetString(
36 GL_SHADING_LANGUAGE_VERSION);
37 double version;
38 strStreamObj >> version;
39 major = static_cast<int>(version);
40 minor = static_cast<int>(version * 10.0 - major * 10);
41 if (major < 3 && minor < 3) {
42 std::cout << "Shading Language Version ( " << version
43 << ") is much lower than 3.3" << std::endl;
44 return -1;
45 }
46 }
47 QSurfaceFormat format;
48
49 format.setVersion(major, minor);
50 format.setRenderableType(QSurfaceFormat::RenderableType::OpenGL);
51 format.setSwapBehavior(QSurfaceFormat::SwapBehavior::DoubleBuffer);
52 QSurfaceFormat::setDefaultFormat(format);
53
54 a.setStyleSheet(
55 "QSplitter::handle {"
56 " background: lightGray;"
57 " border-radius: 2px; "
58 "}");
59
60 apollo::cyber::Init(argv[0]);
61
62 MainWindow w;
63
64 auto topologyCallback =
65 [&w](const apollo::cyber::proto::ChangeMsg& change_msg) {
66 w.TopologyChanged(change_msg);
67 };
68
69 auto channelManager =
70 apollo::cyber::service_discovery::TopologyManager::Instance()
71 ->channel_manager();
72 channelManager->AddChangeListener(topologyCallback);
73
74 std::vector<apollo::cyber::proto::RoleAttributes> role_attr_vec;
75 channelManager->GetWriters(&role_attr_vec);
76 for (auto& role_attr : role_attr_vec) {
77 w.AddNewWriter(role_attr);
78 }
79
80 w.show();
81
82 return a.exec();
83}
void AddNewWriter(const apollo::cyber::proto::RoleAttributes &role)
void TopologyChanged(const apollo::cyber::proto::ChangeMsg &change_msg)
bool Init(const char *binary_name, const std::string &dag_info)
Definition init.cc:99