Skip to content

Commit 6269abd

Browse files
author
cyjiang
committedMar 1, 2021
取消qChart
1 parent efe0c3e commit 6269abd

File tree

4 files changed

+115
-115
lines changed

4 files changed

+115
-115
lines changed
 

‎CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ find_package(catkin REQUIRED COMPONENTS rviz roscpp sensor_msgs
1717
image_transport
1818
)
1919

20-
find_package(Qt5 REQUIRED Core Widgets Multimedia Charts)
21-
set(QT_LIBRARIES Qt5::Widgets Qt5::Multimedia Qt5::Charts)
20+
find_package(Qt5 REQUIRED Core Widgets Multimedia)
21+
set(QT_LIBRARIES Qt5::Widgets Qt5::Multimedia)
2222
include_directories(${catkin_INCLUDE_DIRS})
2323
# Use this to define what the package will export (e.g. libs, headers).
2424
# Since the default here is to produce only a binary, we don't worry about

‎include/cyrobot_monitor/main_window.hpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <QVariant>
2929
#include <QHBoxLayout>
3030
#include <QVBoxLayout>
31-
#include <QtCharts>
3231
#include <QTimer>
3332
#include <QQueue>
3433
#include <map>
@@ -153,19 +152,19 @@ private slots:
153152
QRviz *map_rviz=NULL;
154153
QVariantList m_sendVelList,m_recvVelList,m_timeList;
155154
//曲线
156-
QSplineSeries* line;
155+
// QSplineSeries* line;
157156
//曲线点的最大数量
158157
int line_max = 10;
159158
//绘图变量和坐标
160-
QChart* chart;
161-
QValueAxis *axisX;
162-
QValueAxis *axisY;
163-
QQueue<QPointF> data1;
164-
QQueue<QPointF> data2;
159+
// QChart* chart;
160+
// QValueAxis *axisX;
161+
// QValueAxis *axisY;
162+
// QQueue<QPointF> data1;
163+
// QQueue<QPointF> data2;
165164
QTimer *m_timerChart;
166165
QTimer *m_timerPubImageMap;
167166
QTimer *m_timerCurrentTime;
168-
QChartView *chartView;
167+
// QChartView *chartView;
169168
DashBoard *speedDashBoard;
170169
};
171170
}// namespace cyrobot_monitor

‎src/main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <QtGui>
1313
#include <QApplication>
14+
#include <QDesktopWidget>
1415
#include "../include/cyrobot_monitor/main_window.hpp"
1516

1617

‎src/main_window.cpp

+105-105
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,16 @@ void MainWindow::slot_hide_table_widget(){
275275
}
276276
}
277277
void MainWindow::initOthers(){
278-
line = new QSplineSeries(this);
279-
chart = new QChart();
280-
chart->addSeries(line);
281-
axisX = new QValueAxis(this);
282-
axisY = new QValueAxis(this);
283-
284-
chartView = new QChartView(ui.widget_chart);
285-
chartView->setFixedWidth(ui.widget_chart->width());
286-
chartView->setFixedHeight(ui.widget_chart->height());
287-
chartView->setRenderHint(QPainter::Antialiasing);
278+
// line = new QSplineSeries(this);
279+
// chart = new QChart();
280+
// chart->addSeries(line);
281+
// axisX = new QValueAxis(this);
282+
// axisY = new QValueAxis(this);
283+
284+
// chartView = new QChartView(ui.widget_chart);
285+
// chartView->setFixedWidth(ui.widget_chart->width());
286+
// chartView->setFixedHeight(ui.widget_chart->height());
287+
// chartView->setRenderHint(QPainter::Antialiasing);
288288
m_timerChart=new QTimer;
289289
m_timerPubImageMap=new QTimer;
290290
m_timerPubImageMap->setInterval(100);
@@ -295,51 +295,51 @@ void MainWindow::initOthers(){
295295
m_timerChart->start();
296296
}
297297
void MainWindow::slot_chartTimerTimeout(){
298-
QVector<QPointF> list;
299-
QVector<QPointF> newlist;
300-
list = line->pointsVector();//获取现在图中列表
301-
if (list.size() < line_max)
302-
{
303-
//保持原来
304-
newlist = list;
305-
}
306-
else
307-
{
308-
//错位移动
309-
for(int i =1 ; i< list.size();i++)
310-
{
311-
newlist.append(QPointF(i-1,list.at(i).y()));
312-
}
313-
}
314-
newlist.append(QPointF(newlist.size(),rand()));//最后补上新的数据
315-
line->replace(newlist);//替换更新
316-
317-
318-
line->setName("send");//设置曲线名称
319-
line->setPen(QColor(255, 0, 0));//设置曲线颜色
320-
line->setUseOpenGL(true);//openGl 加速
321-
322-
chart->setTitle("Pressure Data");//设置图标标题
323-
chart->removeSeries(line);
324-
chart->addSeries(line);
325-
chart->createDefaultAxes();//设置坐标轴
326-
327-
// axisX->setRange(0,line_max);//范围
328-
// axisX->setTitleText("times(secs)");//标题
329-
axisX->setTickCount(10);//分隔个数
330-
axisX->setLineVisible(true);//可视化
331-
axisX->setLinePenColor(Qt::blue);//颜色
332-
333-
// axisY->setRange(-200,1200);
334-
// axisY->setTitleText("value");
335-
// axisY->setTickCount(6);
336-
// axisY->setLineVisible(true);
337-
// axisY->setLinePenColor(Qt::blue);
338-
339-
// chart->setAxisX(axisX,line);
340-
// chart->setAxisY(axisY,line);
341-
342-
chartView->setChart(chart);
298+
// QVector<QPointF> list;
299+
// QVector<QPointF> newlist;
300+
// list = line->pointsVector();//获取现在图中列表
301+
// if (list.size() < line_max)
302+
// {
303+
// //保持原来
304+
// newlist = list;
305+
// }
306+
// else
307+
// {
308+
// //错位移动
309+
// for(int i =1 ; i< list.size();i++)
310+
// {
311+
// newlist.append(QPointF(i-1,list.at(i).y()));
312+
// }
313+
// }
314+
// newlist.append(QPointF(newlist.size(),rand()));//最后补上新的数据
315+
// line->replace(newlist);//替换更新
316+
317+
318+
// line->setName("send");//设置曲线名称
319+
// line->setPen(QColor(255, 0, 0));//设置曲线颜色
320+
// line->setUseOpenGL(true);//openGl 加速
321+
322+
// chart->setTitle("Pressure Data");//设置图标标题
323+
// chart->removeSeries(line);
324+
// chart->addSeries(line);
325+
// chart->createDefaultAxes();//设置坐标轴
326+
327+
// // axisX->setRange(0,line_max);//范围
328+
// // axisX->setTitleText("times(secs)");//标题
329+
// axisX->setTickCount(10);//分隔个数
330+
// axisX->setLineVisible(true);//可视化
331+
// axisX->setLinePenColor(Qt::blue);//颜色
332+
333+
// // axisY->setRange(-200,1200);
334+
// // axisY->setTitleText("value");
335+
// // axisY->setTickCount(6);
336+
// // axisY->setLineVisible(true);
337+
// // axisY->setLinePenColor(Qt::blue);
338+
339+
// // chart->setAxisX(axisX,line);
340+
// // chart->setAxisY(axisY,line);
341+
342+
// chartView->setChart(chart);
343343
}
344344
void MainWindow::slot_pubImageMapTimeOut(){
345345
QImage image(600,600,QImage::Format_RGB888);
@@ -559,60 +559,60 @@ void MainWindow::quick_cmd_remove()
559559
//快捷指令添加按钮
560560
void MainWindow::quick_cmd_add()
561561
{
562-
QWidget *w=new QWidget;
563-
//阻塞其他窗体
564-
w->setWindowModality(Qt::ApplicationModal);
565-
QLabel *name=new QLabel;
566-
name->setText("名称:");
567-
QLabel *content=new QLabel;
568-
content->setText("脚本:");
569-
QLineEdit *name_val=new QLineEdit;
570-
QTextEdit *shell_val=new QTextEdit;
571-
QPushButton *ok_btn=new QPushButton;
572-
ok_btn->setText("ok");
573-
ok_btn->setIcon(QIcon("://images/ok.png"));
574-
QPushButton *cancel_btn=new QPushButton;
575-
cancel_btn->setText("cancel");
576-
cancel_btn->setIcon(QIcon("://images/false.png"));
577-
QHBoxLayout *lay1=new QHBoxLayout;
578-
lay1->addWidget(name);
579-
lay1->addWidget(name_val);
580-
QHBoxLayout *lay2=new QHBoxLayout;
581-
lay2->addWidget(content);
582-
lay2->addWidget(shell_val);
583-
QHBoxLayout *lay3=new QHBoxLayout;
584-
lay3->addWidget(ok_btn);
585-
lay3->addWidget(cancel_btn);
586-
QVBoxLayout *v1=new QVBoxLayout;
587-
v1->addLayout(lay1);
588-
v1->addLayout(lay2);
589-
v1->addLayout(lay3);
590-
591-
w->setLayout(v1);
592-
w->show();
593-
594-
connect(ok_btn,&QPushButton::clicked,[this,w,name_val,shell_val]
595-
{
596-
this->add_quick_cmd(name_val->text(),shell_val->toPlainText());
597-
w->close();
598-
});
562+
// QWidget *w=new QWidget;
563+
// //阻塞其他窗体
564+
// w->setWindowModality(Qt::ApplicationModal);
565+
// QLabel *name=new QLabel;
566+
// name->setText("名称:");
567+
// QLabel *content=new QLabel;
568+
// content->setText("脚本:");
569+
// QLineEdit *name_val=new QLineEdit;
570+
// QTextEdit *shell_val=new QTextEdit;
571+
// QPushButton *ok_btn=new QPushButton;
572+
// ok_btn->setText("ok");
573+
// ok_btn->setIcon(QIcon("://images/ok.png"));
574+
// QPushButton *cancel_btn=new QPushButton;
575+
// cancel_btn->setText("cancel");
576+
// cancel_btn->setIcon(QIcon("://images/false.png"));
577+
// QHBoxLayout *lay1=new QHBoxLayout;
578+
// lay1->addWidget(name);
579+
// lay1->addWidget(name_val);
580+
// QHBoxLayout *lay2=new QHBoxLayout;
581+
// lay2->addWidget(content);
582+
// lay2->addWidget(shell_val);
583+
// QHBoxLayout *lay3=new QHBoxLayout;
584+
// lay3->addWidget(ok_btn);
585+
// lay3->addWidget(cancel_btn);
586+
// QVBoxLayout *v1=new QVBoxLayout;
587+
// v1->addLayout(lay1);
588+
// v1->addLayout(lay2);
589+
// v1->addLayout(lay3);
590+
591+
// w->setLayout(v1);
592+
// w->show();
593+
594+
// connect(ok_btn,&QPushButton::clicked,[this,w,name_val,shell_val]
595+
// {
596+
// this->add_quick_cmd(name_val->text(),shell_val->toPlainText());
597+
// w->close();
598+
// });
599599
}
600600
//向treeWidget添加快捷指令
601601
void MainWindow::add_quick_cmd(QString name,QString val)
602602
{
603-
if(name=="") return;
604-
QTreeWidgetItem *head=new QTreeWidgetItem(QStringList()<<name);
605-
QCheckBox *check=new QCheckBox;
606-
//记录父子关系
607-
this->widget_to_parentItem_map[check]=head;
608-
//连接checkbox选中的槽函数
609-
connect(check,SIGNAL(stateChanged(int)),this,SLOT(quick_cmds_check_change(int)));
610-
QTreeWidgetItem *shell_content=new QTreeWidgetItem(QStringList()<<"shell");
611-
QTextEdit *shell_val=new QTextEdit;
612-
shell_val->setMaximumWidth(150);
613-
shell_val->setMaximumHeight(40);
614-
head->addChild(shell_content);
615-
shell_val->setText(val);
603+
// if(name=="") return;
604+
// QTreeWidgetItem *head=new QTreeWidgetItem(QStringList()<<name);
605+
// QCheckBox *check=new QCheckBox;
606+
// //记录父子关系
607+
// this->widget_to_parentItem_map[check]=head;
608+
// //连接checkbox选中的槽函数
609+
// connect(check,SIGNAL(stateChanged(int)),this,SLOT(quick_cmds_check_change(int)));
610+
// QTreeWidgetItem *shell_content=new QTreeWidgetItem(QStringList()<<"shell");
611+
// QTextEdit *shell_val=new QTextEdit;
612+
// shell_val->setMaximumWidth(150);
613+
// shell_val->setMaximumHeight(40);
614+
// head->addChild(shell_content);
615+
// shell_val->setText(val);
616616
}
617617
//快捷指令按钮处理的函数
618618
void MainWindow::quick_cmds_check_change(int state)

0 commit comments

Comments
 (0)
Please sign in to comment.