OneEyeMap.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. #include "OneEyeMap.h"
  2. #include "EyeMapInfo.h"
  3. #include "spdlog.h"
  4. #include "ui_oneeyemap.h"
  5. #include <QApplication>
  6. #include <QPainter>
  7. #include <QPaintEvent>
  8. #include "GlobalInfo.h"
  9. #include "OneOsc.h"
  10. OneEyeMap::OneEyeMap(QWidget *parent) :
  11. QWidget(parent),
  12. ui(new Ui::OneEyeMap)
  13. {
  14. ui->setupUi(this);
  15. m_logger = spdlog::get("EyeMap");
  16. if(m_logger == nullptr)
  17. {
  18. SPDLOG_ERROR("获取 EyeMap logger 失败");
  19. return;
  20. }
  21. /* 初始化变量,加载qss */
  22. // QFile fileQss(":/qss/OneEyeMap/OneEyeMap.qss");
  23. QFile fileQss(":/qss/OneEyeMap/OneEyeMap.qss");
  24. if(fileQss.open(QFile::ReadOnly))
  25. {
  26. QString qss = fileQss.readAll();
  27. this->setStyleSheet(qss);
  28. fileQss.close();
  29. } else
  30. {
  31. SPDLOG_LOGGER_ERROR(m_logger, "加载qss文件失败");
  32. }
  33. /* 初始化变量 */
  34. // m_info.uid = EyeMapUID::EMUID_0;
  35. /* 自定义大小 */
  36. // setFixedSize(1600, 900);
  37. /* 设置水平刻度和垂直刻度数目 */
  38. m_hScaleNum = 6;
  39. m_vScaleNum = 4;
  40. /* 设置绘制区域 */
  41. m_leftMargin = 70;
  42. m_topMargin = 24;
  43. m_rightMargin = 24;
  44. m_bottomMargin = 24;
  45. /* 设置刻度区域 */
  46. m_rectScaleValue.setX(0);
  47. m_rectScaleValue.setY(ui->widget_title->height());
  48. m_rectScaleValue.setWidth(this->width());
  49. m_rectScaleValue.setHeight(this->height() - ui->widget_title->height());
  50. /* 设置参考颜色区域 */
  51. m_rectRefColor.setX(m_rectScaleValue.width() - m_rightMargin - 60);
  52. m_rectRefColor.setY(m_rectScaleValue.y() + 7);
  53. m_rectRefColor.setWidth(60);
  54. m_rectRefColor.setHeight(10);
  55. /* 设置眼图区域 */
  56. m_rectEyeMap.setX(m_leftMargin);
  57. m_rectEyeMap.setY(m_rectScaleValue.y() + m_topMargin);
  58. m_rectEyeMap.setWidth(m_rectScaleValue.width() - m_leftMargin - m_rightMargin);
  59. m_rectEyeMap.setHeight(m_rectScaleValue.height() - m_topMargin - m_bottomMargin);
  60. /* 设置“暂无设备”、“设备离线”图片 */
  61. m_rectNoDevice.setRect(0, 0, 280, 160);
  62. m_pixmapNoDevice = new QPixmap(":/image/Resource/image/dev_none.png");
  63. m_pixmapDeviceOffline = new QPixmap(":/image/Resource/image/dev_outline.png");
  64. /* 设置定时器 */
  65. m_timer.setTimerType(Qt::PreciseTimer);
  66. m_timer.setSingleShot(false);
  67. connect(&m_timer, &QTimer::timeout, this, &OneEyeMap::do_update);
  68. m_timer.start(1000); /* 1s刷新一次 */
  69. // connect(&GOscDataInfo, &OscilloscopeData::signal_updateOneEyeMap, this, &OneEyeMap::do_updateColorMatrix);
  70. connect(&GOscDataInfo, &OscilloscopeData::signal_oscOffline, this, &OneEyeMap::do_deviceOffline);
  71. connect(&GOscDataInfo, &OscilloscopeData::signal_oscOnline, this, &OneEyeMap::do_deviceOnline);
  72. SPDLOG_LOGGER_INFO(m_logger, "{} OneEyeMap 初始化成功", m_info.channelInfo.channelName.toStdString());
  73. }
  74. OneEyeMap::~OneEyeMap()
  75. {
  76. delete ui;
  77. }
  78. /* 根据通道号获取示波器指针 */
  79. void OneEyeMap::getOneOscFromGlobalOscData()
  80. {
  81. /* 初始化本地的颜色矩阵 */
  82. if(m_colorMatrix == nullptr)
  83. {
  84. m_colorMatrix = new EyeColorMatrix();
  85. m_colorMatrix->initEyeMapData(this->width(), this->height());
  86. }
  87. m_osc = GOscDataInfo.findOsc(m_info.channelInfo.channel);
  88. if(m_osc == nullptr)
  89. {
  90. SPDLOG_LOGGER_ERROR(m_logger, "获取示波器指针错误! 通道号: {}", static_cast<int>(m_info.channelInfo.channel));
  91. return;
  92. }
  93. m_osc->setColorMatrixPtr(m_info.channelInfo.channel, m_colorMatrix);
  94. /* 先设置为不使用通道采集 */
  95. m_osc->setChannelUsed(m_info.channelInfo.channel, false);
  96. }
  97. /* 设置UID,只能设置一次 */
  98. // void OneEyeMap::setUID(EyeMapUID uid)
  99. // {
  100. // if(m_info.uid == EyeMapUID::EMUID_0)
  101. // {
  102. // m_info.uid = uid;
  103. // }
  104. // }
  105. /* 设置标题 */
  106. void OneEyeMap::setTitle(const QString &title)
  107. {
  108. m_info.title = title;
  109. ui->label_title->setText(title);
  110. }
  111. /* 设置颜色 */
  112. void OneEyeMap::setTitleBarColor(const QColor &color)
  113. {
  114. m_info.titleBarColor = color;
  115. // QString qss = QString("background-color: %1;border-radius: 4px;").arg(color.name());
  116. QString qss = QString("background-color: %1; border-top-left-radius: 4px; border-top-right-radius: 4px;").arg(color.name());
  117. ui->widget_title->setStyleSheet(qss);
  118. }
  119. /* 设置是否显示 */
  120. void OneEyeMap::setShow(bool isShow)
  121. {
  122. m_info.isShow = isShow;
  123. if(isShow)
  124. {
  125. m_osc->setChannelUsed(m_info.channelInfo.channel, true);
  126. this->show();
  127. } else
  128. {
  129. m_osc->setChannelUsed(m_info.channelInfo.channel, false);
  130. this->hide();
  131. }
  132. }
  133. /* 获取通道信息 */
  134. OneChannelInfo& OneEyeMap::getChannelInfo()
  135. {
  136. if(m_osc == nullptr)
  137. {
  138. SPDLOG_LOGGER_ERROR(m_logger, "通道号:{} 示波器指针为空", static_cast<int>(m_info.channelInfo.channel));
  139. return m_info.channelInfo;
  140. }
  141. if(m_osc->isOpen())
  142. {
  143. m_info.channelInfo.isConnected = true;
  144. m_info.channelInfo.channelName = GEyeMapInfo.getChannelName(m_info.channelInfo.channel, true);
  145. } else
  146. {
  147. m_info.channelInfo.isConnected = false;
  148. m_info.channelInfo.channelName = GEyeMapInfo.getChannelName(m_info.channelInfo.channel, false);
  149. }
  150. return m_info.channelInfo;
  151. }
  152. /* 设置电压值 */
  153. void OneEyeMap::setVoltageRange(OscVoltageRange range)
  154. {
  155. m_info.voltageRange = range;
  156. /* 设置示波器的电压范围 */
  157. if(m_osc != nullptr)
  158. {
  159. if(static_cast<int>(m_info.channelInfo.channel) % 2 == 1)
  160. {
  161. m_osc->setChannelARange(range);
  162. } else
  163. {
  164. m_osc->setChannelBRange(range);
  165. }
  166. }
  167. }
  168. /* 设置时间刻度 */
  169. void OneEyeMap::setTimeGridValue(OscTimeGridValue value)
  170. {
  171. m_info.tGridValue = value;
  172. /* 设置示波器的时间刻度 */
  173. if(m_osc != nullptr)
  174. {
  175. m_osc->setTimeGridValue(value);
  176. }
  177. }
  178. /* 更新组件信息 */
  179. void OneEyeMap::updateInfo(const OneEyeMapInfo &info)
  180. {
  181. // m_info = info;
  182. setTitle(info.title);
  183. setTitleBarColor(info.titleBarColor);
  184. setChannelInfo(info.channelInfo);
  185. setShow(info.isShow);
  186. setVoltageRange(info.voltageRange);
  187. setTimeGridValue(info.tGridValue);
  188. update();
  189. }
  190. /* 只更新设置个数页面的信息 */
  191. void OneEyeMap::updateSettingNum(const OneEyeMapInfo &info)
  192. {
  193. setNum(info.num);
  194. setTitle(info.title);
  195. setTitleBarColor(info.titleBarColor);
  196. setChannelInfo(info.channelInfo);
  197. }
  198. /* 重置眼图显示区域为默认 */
  199. void OneEyeMap::resetEyeMap()
  200. {
  201. m_colorMatrix->initEyeMapData(this->width(), this->height());
  202. update();
  203. }
  204. /* 刷新页面 */
  205. void OneEyeMap::do_update()
  206. {
  207. // SPDLOG_LOGGER_DEBUG(m_logger, "{} 刷新页面", m_info.title.toStdString());
  208. if(!m_osc->isOpen())
  209. {
  210. return;
  211. }
  212. update();
  213. }
  214. /* 设备离线了 */
  215. void OneEyeMap::do_deviceOffline(int oscNum)
  216. {
  217. /* 判断是不是这个编号 */
  218. if(static_cast<OscChnNum>(oscNum) != m_info.channelInfo.channel)
  219. {
  220. return;
  221. }
  222. SPDLOG_LOGGER_WARN(m_logger, "{} 离线了", oscNum, m_info.channelInfo.channelName.toStdString());
  223. m_isOpen = false;
  224. update();
  225. }
  226. /* 设备上线了 */
  227. void OneEyeMap::do_deviceOnline(int oscNum)
  228. {
  229. /* 判断是不是这个编号 */
  230. if(static_cast<OscChnNum>(oscNum) != m_info.channelInfo.channel)
  231. {
  232. return;
  233. }
  234. m_isOpen = true;
  235. update();
  236. }
  237. /**
  238. * @brief 绘制图形
  239. *
  240. * @param event
  241. */
  242. void OneEyeMap::paintEvent(QPaintEvent *event)
  243. {
  244. if(m_colorMatrix == nullptr)
  245. {
  246. return;
  247. }
  248. QPainter painter(this);
  249. painter.setRenderHint(QPainter::Antialiasing, true);
  250. /******************** 绘制背景 ********************/
  251. drawBackground(painter);
  252. ui->widget_title->show();
  253. /* 判断设备是否打开,没打开就显示“暂无设备”图片 */
  254. if(!m_isOpen)
  255. {
  256. // ui->widget_title->hide();
  257. drawNoDevice(painter);
  258. event->accept();
  259. return;
  260. }
  261. m_colorMatrix->mutexEyeData.lock();
  262. // SPDLOG_LOGGER_DEBUG(m_logger, "{} 获取到了颜色矩阵锁", m_info.title.toStdString());
  263. /******************** 绘制刻度值 ********************/
  264. drawScaleValue(painter);
  265. /******************** 绘制刻度网格 *********************/
  266. drawScale(painter);
  267. // SPDLOG_LOGGER_DEBUG(m_logger, "width = {}, height = {}", this->width(), this->height());
  268. // SPDLOG_LOGGER_DEBUG(m_logger, "m_rectScaleValue: x = {}, y = {}, width = {}, height = {}", m_rectScaleValue.x(), m_rectScaleValue.y(), m_rectScaleValue.width(), m_rectScaleValue.height());
  269. // SPDLOG_LOGGER_DEBUG(m_logger, "m_rectEyeMap: x = {}, y = {}, width = {}, height = {}", m_rectEyeMap.x(), m_rectEyeMap.y(), m_rectEyeMap.width(), m_rectEyeMap.height());
  270. /******************** 绘制眼图区域 ********************/
  271. drawEyeMap(painter);
  272. m_colorMatrix->mutexEyeData.unlock();
  273. event->accept();
  274. }
  275. /* 缩放事件 */
  276. void OneEyeMap::resizeEvent(QResizeEvent *event)
  277. {
  278. /* 设置刻度区域 */
  279. m_rectScaleValue.setX(0);
  280. m_rectScaleValue.setY(ui->widget_title->height());
  281. m_rectScaleValue.setWidth(this->width());
  282. m_rectScaleValue.setHeight(this->height() - ui->widget_title->height());
  283. /* 设置参考颜色区域 */
  284. m_rectRefColor.setX(m_rectScaleValue.width() - m_rightMargin - 60);
  285. m_rectRefColor.setY(m_rectScaleValue.y() + 7);
  286. m_rectRefColor.setWidth(60);
  287. m_rectRefColor.setHeight(10);
  288. /* 设置眼图区域 */
  289. m_rectEyeMap.setX(m_leftMargin);
  290. m_rectEyeMap.setY(m_rectScaleValue.y() + m_topMargin);
  291. m_rectEyeMap.setWidth(m_rectScaleValue.width() - m_leftMargin - m_rightMargin);
  292. m_rectEyeMap.setHeight(m_rectScaleValue.height() - m_topMargin - m_bottomMargin);
  293. /* 重新设置颜色矩阵 */
  294. if(m_colorMatrix != nullptr)
  295. {
  296. m_colorMatrix->initEyeMapData(this->width(), this->height());
  297. }
  298. /* 刷新一下页面 */
  299. update();
  300. event->accept();
  301. }
  302. /* 绘制背景 */
  303. void OneEyeMap::drawBackground(QPainter &painter)
  304. {
  305. /* 绘制背景颜色 */
  306. painter.setPen(Qt::NoPen);
  307. QBrush brush;
  308. brush.setColor("#1E1E1E");
  309. brush.setStyle(Qt::SolidPattern);
  310. painter.setBrush(brush);
  311. painter.drawRect(m_rectScaleValue);
  312. }
  313. /* 绘制刻度区域 */
  314. void OneEyeMap::drawScaleValue(QPainter &painter)
  315. {
  316. /* 绘制刻度值 */
  317. QPen pen;
  318. pen.setColor("#C8CCD2");
  319. painter.setPen(pen);
  320. QRect rectText(0, 0, 50, 14);
  321. QFont font;
  322. font.setFamily("思源黑体R");
  323. font.setPixelSize(14);
  324. painter.setFont(font);
  325. int oneScale = m_rectEyeMap.height() / m_vScaleNum;
  326. // SPDLOG_LOGGER_DEBUG(m_logger, "oneScale = {}", oneScale);
  327. /* 绘制电压值 */
  328. for(int i = 0; i <= m_vScaleNum; i++)
  329. {
  330. /* 计算字体区域坐标 */
  331. rectText.moveTo(10, m_rectEyeMap.y() + oneScale * i - 7);
  332. painter.drawText(rectText, Qt::AlignRight | Qt::AlignVCenter, getVScaleValue(i));
  333. }
  334. /* 绘制时间刻度值 */
  335. int oneTime = m_rectEyeMap.width() / m_hScaleNum;
  336. for(int i = 0; i <= m_hScaleNum; i++)
  337. {
  338. rectText.moveTo(m_rectEyeMap.x() + oneTime * i - 25, m_rectEyeMap.y() + m_rectEyeMap.height() + 4);
  339. painter.drawText(rectText, Qt::AlignCenter, getTimeValue(i));
  340. }
  341. /* 绘制参渐变考颜色 */
  342. drawRefColor(painter);
  343. }
  344. /* 绘制刻度 */
  345. void OneEyeMap::drawScale(QPainter &painter)
  346. {
  347. /* 限制操作区域,不过坐标零点依旧是widget的(0,0) */
  348. painter.setClipRect(m_rectEyeMap);
  349. /* 绘制背景颜色 */
  350. painter.setPen(Qt::NoPen);
  351. QBrush brush;
  352. brush.setColor(QColor(0, 0, 0, 0.8 * 255));
  353. brush.setStyle(Qt::SolidPattern);
  354. painter.setBrush(brush);
  355. painter.drawRect(m_rectEyeMap);
  356. /* 绘制刻度线 */
  357. QPen pen;
  358. pen.setWidth(1);
  359. pen.setStyle(Qt::SolidLine);
  360. /* 绘制中线 */
  361. int startX = m_rectEyeMap.x();
  362. int startY = m_rectEyeMap.y();
  363. int width = m_rectEyeMap.width();
  364. int height = m_rectEyeMap.height();
  365. pen.setColor(QColor(255, 255, 255, 0.35 * 255));
  366. pen.setWidth(2);
  367. painter.setPen(pen);
  368. painter.drawLine(startX, startY + (height / 2), startX + width, startY + (height / 2)); /* 绘制水平中线 */
  369. painter.drawLine(startX + (width / 2), startY, startX + (width / 2), startY + height); /* 绘制垂直中线 */
  370. /* 绘制中线上的刻度 */
  371. int hScale = m_hScaleNum * 5;
  372. int vScale = m_vScaleNum * 5;
  373. double scaleW = width * 1.0 / hScale;
  374. double scaleH = height * 1.0 / vScale;
  375. QVector<QLineF> wLines;
  376. QVector<QLineF> hLines;
  377. for(int i = 0; i < hScale; i++)
  378. {
  379. QLineF line1(startX + i * scaleW, startY + height / 2.0 - 4, startX + i * scaleW, startY + height / 2.0 + 4);
  380. wLines.append(line1);
  381. }
  382. for(int i = 0; i < vScale; i++)
  383. {
  384. QLineF line2(startX + width / 2.0 - 4, startY + height - i * scaleH, startX + width / 2.0 + 4, startY + height - i * scaleH);
  385. hLines.append(line2);
  386. }
  387. painter.drawLines(wLines);
  388. painter.drawLines(hLines);
  389. /* 绘制网格,这里是网格线 */
  390. pen.setWidth(1);
  391. pen.setColor(QColor(255, 255, 255, 0.15 * 255));
  392. painter.setPen(pen);
  393. scaleH = height * 1.0 / m_vScaleNum;
  394. scaleW = width * 1.0 / m_hScaleNum;
  395. /* 水平线 */
  396. for(int i = 1; i < m_vScaleNum; i++)
  397. {
  398. int y = startY + i * scaleH;
  399. QLineF line1(startX, y, startX + width, y);
  400. painter.drawLine(line1);
  401. }
  402. /* 垂直线 */
  403. for(int i = 1; i < m_hScaleNum; i++)
  404. {
  405. int x = startX + i * scaleW;
  406. QLineF line1(x, startY, x, startY + height);
  407. painter.drawLine(line1);
  408. }
  409. /* 绘制虚线 */
  410. // painter.setPen(pen);
  411. // scaleW = width / 10.0;
  412. // scaleH = height / 10.0;
  413. // int x = 0;
  414. // int y = 0;
  415. // QVector<QLineF> wGridLines;
  416. // QVector<QLineF> hGridLines;
  417. // for(int i = 1; i < 10; i++)
  418. // {
  419. // y = i * scaleH;
  420. // while(true)
  421. // {
  422. // x = x + 8;
  423. // QLineF line1(x, y, x + 2, y);
  424. // wGridLines.append(line1);
  425. // if(x >= width)
  426. // {
  427. // x = 0;
  428. // y = 0;
  429. // break;
  430. // }
  431. // }
  432. // }
  433. // x = 0;
  434. // y = 0;
  435. // for(int i = 1; i < 10; i++)
  436. // {
  437. // x = i * scaleW;
  438. // while(true)
  439. // {
  440. // y = y + 8;
  441. // QLineF line1(x, y, x, y + 2);
  442. // hGridLines.append(line1);
  443. // if(y >= height)
  444. // {
  445. // x = 0;
  446. // y = 0;
  447. // break;
  448. // }
  449. // }
  450. // }
  451. // painter.drawLines(wGridLines);
  452. // painter.drawLines(hGridLines);
  453. }
  454. /* 绘制眼图区域 */
  455. void OneEyeMap::drawEyeMap(QPainter &painter)
  456. {
  457. // SPDLOG_ERROR("绘制眼图区域");
  458. /* 绘制眼图,就是绘制 1000 * 256 个矩形 */
  459. painter.setPen(Qt::NoPen);
  460. for(int i = 0; i < g_HorPixel; i++)
  461. {
  462. for(int j = 0; j < g_VerPixel; j++)
  463. {
  464. /* 这里需要根据是否需要显示进行判断,不然全绘制太卡了 */
  465. if(m_colorMatrix->dataMatrix[i][j].isDraw == false)
  466. {
  467. continue;
  468. }
  469. /* 打印出颜色 */
  470. // SPDLOG_LOGGER_WARN(m_logger, "颜色: {}", m_eyeColorMatrix->dataMatrix[i][j].brush.color().name().toStdString());
  471. painter.setBrush(m_colorMatrix->dataMatrix[i][j].brush);
  472. painter.drawRect(m_colorMatrix->dataMatrix[i][j].rect);
  473. }
  474. }
  475. }
  476. /* 绘制“暂无设备” */
  477. void OneEyeMap::drawNoDevice(QPainter &painter)
  478. {
  479. int x = (this->width() - m_rectNoDevice.width()) / 2;
  480. int y = (this->height() - m_rectNoDevice.height()) / 2;
  481. m_rectNoDevice.moveTo(x, y);
  482. painter.drawPixmap(m_rectNoDevice, *m_pixmapDeviceOffline);
  483. }
  484. /* 绘制参考渐变色 */
  485. void OneEyeMap::drawRefColor(QPainter &painter)
  486. {
  487. QLinearGradient linearGradient(m_rectRefColor.topLeft(), m_rectRefColor.bottomRight());
  488. linearGradient.setColorAt(0, QColor("#003590"));
  489. linearGradient.setColorAt(0.4, QColor(0, 255, 255));
  490. linearGradient.setColorAt(0.6, QColor(0, 255, 0));
  491. linearGradient.setColorAt(0.8, QColor(255, 255, 0));
  492. linearGradient.setColorAt(1, QColor("#FF4123"));
  493. painter.setBrush(linearGradient);
  494. painter.setPen(Qt::NoPen);
  495. painter.drawRect(m_rectRefColor);
  496. }
  497. /* 获取一个格子的电压值 */
  498. QString OneEyeMap::getVScaleValue(int index)
  499. {
  500. index = 2 - index;
  501. if(m_info.voltageRange == OscVoltageRange::CR_100MV)
  502. {
  503. return QString::number(0.1 * index) + "V";
  504. } else if(m_info.voltageRange == OscVoltageRange::CR_250MV)
  505. {
  506. return QString::number(0.25 * index) + "V";
  507. } else if(m_info.voltageRange == OscVoltageRange::CR_500MV)
  508. {
  509. return QString::number(0.5 * index) + "V";
  510. } else if(m_info.voltageRange == OscVoltageRange::CR_1V)
  511. {
  512. return QString::number(1.0 * index) + "V";
  513. } else if(m_info.voltageRange == OscVoltageRange::CR_2V5)
  514. {
  515. return QString::number(2.5 * index) + "V";
  516. } else if(m_info.voltageRange == OscVoltageRange::CR_5V)
  517. {
  518. return QString::number(5.0 * index) + "V";
  519. } else if(m_info.voltageRange == OscVoltageRange::CR_8V)
  520. {
  521. return QString::number(8.0 * index) + "V";
  522. } else
  523. {
  524. return QString::number(0.1 * index) + "V";
  525. }
  526. }
  527. /* 获取一个时间值 */
  528. QString OneEyeMap::getTimeValue(int index)
  529. {
  530. QString str;
  531. switch (m_info.tGridValue)
  532. {
  533. case OscTimeGridValue::TGV_20NS:
  534. str = QString::number(index * 20 / 1000.0) + "us";
  535. break;
  536. case OscTimeGridValue::TGV_50NS:
  537. str = QString::number(index * 50 / 1000.0) + "us";
  538. break;
  539. case OscTimeGridValue::TGV_100NS:
  540. str = QString::number(index * 100 / 1000.0) + "us";
  541. break;
  542. case OscTimeGridValue::TGV_200NS:
  543. str = QString::number(index * 200 / 1000.0) + "us";
  544. break;
  545. case OscTimeGridValue::TGV_500NS:
  546. str = QString::number(index * 500 / 1000.0) + "us";
  547. break;
  548. case OscTimeGridValue::TGV_1US:
  549. str = QString::number(index * 1) + "us";
  550. break;
  551. case OscTimeGridValue::TGV_2US:
  552. str = QString::number(index * 2) + "us";
  553. break;
  554. case OscTimeGridValue::TGV_5US:
  555. str = QString::number(index * 5) + "us";
  556. break;
  557. case OscTimeGridValue::TGV_10US:
  558. str = QString::number(index * 10) + "us";
  559. break;
  560. case OscTimeGridValue::TGV_20US:
  561. str = QString::number(index * 20) + "us";
  562. break;
  563. case OscTimeGridValue::TGV_100US:
  564. str = QString::number(index * 100) + "us";
  565. break;
  566. default:
  567. str = "us";
  568. break;
  569. }
  570. return str;
  571. }