Browse Source

change tool_siasun. add map.

yuchuli 2 years ago
parent
commit
ffa0e928f7

+ 33 - 0
src/include/proto/siasun.proto

@@ -0,0 +1,33 @@
+syntax = "proto2";
+
+package iv.siasun;
+
+message kickpoint
+{
+	required double mfLon = 1;
+	required double mfLat = 2;
+};
+
+message kickpointarray
+{
+	repeated kickpoint mkick =1;
+};
+
+message waypoint
+{
+	required double mfLon = 1;
+	required double mfLat = 2;
+};
+
+message waypointarray
+{
+	repeated waypoint mwaypoint = 1;
+};
+
+message map
+{
+	required kickpointarray mkickarray = 1;
+	optional waypointarray mwayarray = 2;
+};
+
+

+ 2 - 2
src/tool/map_collectfromveh/myview.cpp

@@ -139,8 +139,8 @@ void MyView::mouseDoubleClickEvent(QMouseEvent *event)
     QScrollBar * psV = verticalScrollBar();
     QScrollBar * psH = horizontalScrollBar();
 
-    int centery = (psV->value() + psV->size().height()/2)/beishu;
-    int centerx = (psH->value() + psH->size().width()/2)/beishu;
+    double centery = (psV->value() + psV->size().height()/2)/beishu;
+    double centerx = (psH->value() + psH->size().width()/2)/beishu;
 
 
 //    qDebug("x is %d y is %d view center x is %d  centerx is %d",event->pos().x(),

+ 30 - 0
src/tool/tool_siasun/dialogkickpoint.cpp

@@ -0,0 +1,30 @@
+#include "dialogkickpoint.h"
+#include "ui_dialogkickpoint.h"
+
+DialogKickPoint::DialogKickPoint(iv::siasun::map * psissunmap, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogKickPoint)
+{
+    ui->setupUi(this);
+
+    setWindowTitle("Insert Pick Point.");
+    mpsissunmap = psissunmap;
+}
+
+DialogKickPoint::~DialogKickPoint()
+{
+    delete ui;
+}
+
+void DialogKickPoint::on_pushButton_Insert_clicked()
+{
+    double fLon = ui->lineEdit_Lon->text().toDouble();
+    double fLat = ui->lineEdit_Lat->text().toDouble();
+
+    iv::siasun::kickpointarray * pkickarray = mpsissunmap->mutable_mkickarray();
+    int i;
+    iv::siasun::kickpoint * pkickpoint = pkickarray->add_mkick();
+    pkickpoint->set_mflat(fLat);
+    pkickpoint->set_mflon(fLon);
+
+}

+ 28 - 0
src/tool/tool_siasun/dialogkickpoint.h

@@ -0,0 +1,28 @@
+#ifndef DIALOGKICKPOINT_H
+#define DIALOGKICKPOINT_H
+
+#include <QDialog>
+
+#include "siasun.pb.h"
+
+namespace Ui {
+class DialogKickPoint;
+}
+
+class DialogKickPoint : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogKickPoint(iv::siasun::map * psissunmap, QWidget *parent = 0);
+    ~DialogKickPoint();
+
+private slots:
+    void on_pushButton_Insert_clicked();
+
+private:
+    Ui::DialogKickPoint *ui;
+    iv::siasun::map * mpsissunmap;
+};
+
+#endif // DIALOGKICKPOINT_H

+ 78 - 0
src/tool/tool_siasun/dialogkickpoint.ui

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogKickPoint</class>
+ <widget class="QDialog" name="DialogKickPoint">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>345</width>
+    <height>200</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLineEdit" name="lineEdit_Lon">
+   <property name="geometry">
+    <rect>
+     <x>140</x>
+     <y>30</y>
+     <width>171</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>30</y>
+     <width>121</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>经度</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>90</y>
+     <width>121</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>纬度</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Lat">
+   <property name="geometry">
+    <rect>
+     <x>140</x>
+     <y>90</y>
+     <width>171</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Insert">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>150</y>
+     <width>141</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>插入</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 11 - 0
src/tool/tool_siasun/main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+
+    return a.exec();
+}

+ 247 - 0
src/tool/tool_siasun/mainwindow.cpp

@@ -0,0 +1,247 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <iostream>
+#include <QMessageBox>
+#include <math.h>
+
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+#include "google/protobuf/text_format.h"
+
+#define VIEW_WIDTH 6000
+#define VIEW_HEIGHT 6000
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    setWindowTitle(tr("SIASUN Remote Control"));
+
+    mmyview = new MyView(ui->Map);
+    mmyview->setObjectName(QStringLiteral("graphicsView"));
+    mmyview->setGeometry(QRect(0, 0, 800, 530));
+    mmyview->setCacheMode(mmyview->CacheBackground);
+
+    mpscene = new QGraphicsScene;
+
+    mpscene = new  QGraphicsScene(0,0,VIEW_WIDTH,VIEW_HEIGHT);
+    mpscene->setBackgroundBrush(Qt::white);
+    mmyview->setScene(mpscene);
+
+    mmyview->centerOn(VIEW_WIDTH/2,VIEW_HEIGHT/2);
+
+    ui->tabWidget->setCurrentIndex(0);
+
+    mpdkp = new DialogKickPoint(&msissunmap, this);
+
+    connect(mmyview,SIGNAL(dbclickxy(double,double)),this,SLOT(ondbclick(double,double)));
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+void MainWindow::paintEvent(QPaintEvent * event)
+{
+    (void)event;
+    static double foldratio = 1.0;
+
+
+    double ratio = mmyview->getbeishu();
+    if(fabs(ratio - foldratio)>0.000001)
+    {
+        foldratio = ratio;
+        double fscale = 1.0/ratio;
+        unsigned int i;
+        for(i=0;i<mvectorPickPointItem.size();i++)
+        {
+            mvectorPickPointItem[i]->setScale(fscale);
+        }
+        for(i=0;i<mvectorMapPointItem.size();i++)
+        {
+            mvectorMapPointItem[i]->setScale(fscale);
+        }
+
+    }
+
+    mmyview->setScene(mpscene);
+
+}
+
+
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+    (void)event;
+    QSize sizemain = ui->centralWidget->size();
+    ui->tabWidget->setGeometry(0,0,sizemain.width(),sizemain.height());
+
+    QSize sizemap = ui->Map->size();
+    mmyview->setGeometry(0,0,sizemap.width(),sizemap.height());
+}
+
+void MainWindow::on_actionInsert_Kick_Point_triggered()
+{
+    mpdkp->setModal(false);
+    mpdkp->show();
+}
+
+void MainWindow::on_actionSave_triggered()
+{
+
+
+    QString strfilepath = "/home/yuchuli/testsia.txt";
+    using google::protobuf::TextFormat;
+    using google::protobuf::io::FileOutputStream;
+    using google::protobuf::io::ZeroCopyOutputStream;
+    std::string strout;
+    ZeroCopyOutputStream *output = new google::protobuf::io::StringOutputStream(&strout);//new FileOutputStream(file_descriptor);
+
+    bool success = TextFormat::Print(msissunmap, output);
+    if(success)
+    {
+        QFile xFile;
+        xFile.setFileName(strfilepath);
+        if(xFile.open(QIODevice::ReadWrite))
+        {
+            xFile.write(strout.data(),strout.size());
+            xFile.close();
+        }
+        //           std::cout<<strout<<std::endl;
+        //               qDebug(strout.data());
+    }
+    delete output;
+
+}
+
+void MainWindow::on_actionLoad_triggered()
+{
+    QString strfilepath = "/home/yuchuli/testsia.txt";
+
+    QFile xFile;
+    xFile.setFileName(strfilepath);
+    QByteArray ba;
+    if(xFile.open(QIODevice::ReadOnly))
+    {
+        ba = xFile.readAll();
+        xFile.close();
+    }
+    else
+    {
+        QMessageBox::warning(this,tr("Warning"),tr("Open File Fail."),QMessageBox::YesAll);
+        return;
+    }
+
+    using google::protobuf::TextFormat;
+    using google::protobuf::io::FileInputStream;
+    using google::protobuf::io::ZeroCopyInputStream;
+    std::string strout;
+    ZeroCopyInputStream *input = new google::protobuf::io::ArrayInputStream(ba.data(),ba.size());//new FileOutputStream(file_descriptor);
+
+    iv::siasun::map xsiasun;
+    bool success = TextFormat::Parse(input,&xsiasun);
+    if(success)
+    {
+        msissunmap.CopyFrom(xsiasun);
+    }
+    else
+    {
+        QMessageBox::warning(this,tr("Warning"),tr("Load map fail."),QMessageBox::YesAll);
+        delete input;
+        return;
+    }
+    delete input;
+
+    if(msissunmap.mutable_mkickarray()->mkick_size() == 0)
+    {
+        return;
+    }
+
+    iv::siasun::kickpointarray * pkickarray = msissunmap.mutable_mkickarray();
+
+    int i;
+    mlon0 = pkickarray->mutable_mkick(0)->mflon();
+    mlat0 = pkickarray->mutable_mkick(0)->mflat();
+
+    for(i=0;i<pkickarray->mkick_size();i++)
+    {
+        iv::siasun::kickpoint * ppoint = pkickarray->mutable_mkick(i);
+        double x0,y0;
+        double x,y;
+        GaussProjCal(ppoint->mflon(),ppoint->mflat(),&x,&y);
+        GaussProjCal(mlon0,mlat0,&x0,&y0);
+        x = x - x0;
+        y = y - y0;
+
+        double ratio = mmyview->getbeishu();
+        double fscale = 1.0/ratio;
+        QGraphicsEllipseItem * pmainitem;
+        pmainitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
+        pmainitem->setBrush(Qt::blue);
+        pmainitem->setPen(Qt::NoPen);
+        pmainitem->setPos(VIEW_WIDTH/2 + x,VIEW_HEIGHT/2 -y);
+        pmainitem->setScale(fscale);
+        mpscene->addItem(pmainitem);
+        mvectorPickPointItem.push_back(pmainitem);
+    }
+
+
+}
+
+void MainWindow::on_actionInsert_Map_Point_triggered()
+{
+    if(mbInsertMapPoint == false)
+    {
+        ui->actionInsert_Map_Point->setText(tr("Stop Insert Map Point"));
+        mbInsertMapPoint = true;
+    }
+    else
+    {
+        ui->actionInsert_Map_Point->setText(tr("Start Insert Map Point"));
+        mbInsertMapPoint = false;
+    }
+
+}
+
+void MainWindow::ondbclick(double x,double y)
+{
+    if(mbInsertMapPoint)
+    {
+
+        double fx,fy;
+        fx = x - VIEW_WIDTH/2;
+        fy = VIEW_HEIGHT/2 - y;
+        double x0,y0;
+        GaussProjCal(mlon0,mlat0,&x0,&y0);
+        double flonx,flaty;
+        flonx = fx + x0;
+        flaty = fy + y0;
+        double flon,flat;
+        GaussProjInvCal(flonx,flaty,&flon,&flat);
+        iv::siasun::waypointarray  * pwayarray  = msissunmap.mutable_mwayarray();
+        if(pwayarray == NULL)
+        {
+            std::cout<<"way array is NULL."<<std::endl;
+            iv::siasun::waypointarray * pnew = new iv::siasun::waypointarray;
+            msissunmap.set_allocated_mwayarray(pnew);
+            pwayarray = msissunmap.mutable_mwayarray();
+        }
+        iv::siasun::waypoint * pwaypoint = pwayarray->add_mwaypoint();
+        pwaypoint->set_mflat(flat);
+        pwaypoint->set_mflon(flon);
+
+
+        double ratio = mmyview->getbeishu();
+        double fscale = 1.0/ratio;
+        QGraphicsEllipseItem * pmainitem;
+        pmainitem = new QGraphicsEllipseItem(0-mfPointSize/2.0,0*(-1)-mfPointSize/2.0,mfPointSize,mfPointSize);
+        pmainitem->setBrush(Qt::green);
+        pmainitem->setPen(Qt::NoPen);
+        pmainitem->setPos(x,y);
+        pmainitem->setScale(fscale);
+        mpscene->addItem(pmainitem);
+        mvectorPickPointItem.push_back(pmainitem);
+    }
+}

+ 68 - 0
src/tool/tool_siasun/mainwindow.h

@@ -0,0 +1,68 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "myview.h"
+
+#include <thread>
+
+#include "dialogkickpoint.h"
+
+#include "siasun.pb.h"
+
+#include "gnss_coordinate_convert.h"
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+public:
+     void resizeEvent(QResizeEvent *event);
+     void paintEvent(QPaintEvent * event);
+
+private slots:
+     void on_actionInsert_Kick_Point_triggered();
+
+     void on_actionSave_triggered();
+
+     void on_actionLoad_triggered();
+
+     void on_actionInsert_Map_Point_triggered();
+
+     void ondbclick(double x,double y);
+
+private:
+    Ui::MainWindow *ui;
+
+    MyView * mmyview;
+    QGraphicsScene * mpscene;
+
+private:
+    DialogKickPoint * mpdkp;
+    iv::siasun::map msissunmap;
+    double mlon0 = 117.0;
+    double mlat0 = 39.0;
+
+private:
+
+    std::vector<QGraphicsEllipseItem * > mvectorPickPointItem;
+    std::vector<QGraphicsEllipseItem * > mvectorMapPointItem;
+
+
+//    QGraphicsEllipseItem * mpNowPosItem;
+    const double mfPointSize = 9.0;
+
+    bool mbInsertMapPoint = false;
+
+};
+
+#endif // MAINWINDOW_H

+ 101 - 0
src/tool/tool_siasun/mainwindow.ui

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QTabWidget" name="tabWidget">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>10</y>
+      <width>251</width>
+      <height>161</height>
+     </rect>
+    </property>
+    <property name="currentIndex">
+     <number>1</number>
+    </property>
+    <widget class="QWidget" name="Map">
+     <attribute name="title">
+      <string>Map</string>
+     </attribute>
+    </widget>
+    <widget class="QWidget" name="Control">
+     <attribute name="title">
+      <string>Control</string>
+     </attribute>
+    </widget>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionLoad"/>
+    <addaction name="actionSave"/>
+   </widget>
+   <widget class="QMenu" name="menuMap">
+    <property name="title">
+     <string>Map</string>
+    </property>
+    <addaction name="separator"/>
+    <addaction name="actionInsert_Kick_Point"/>
+    <addaction name="actionInsert_Map_Point"/>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuMap"/>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+  <action name="actionInsert_Kick_Point">
+   <property name="text">
+    <string>Insert Kick Point</string>
+   </property>
+  </action>
+  <action name="actionLoad">
+   <property name="text">
+    <string>Load Map</string>
+   </property>
+  </action>
+  <action name="actionSave">
+   <property name="text">
+    <string>Save Map</string>
+   </property>
+  </action>
+  <action name="actionInsert_Map_Point">
+   <property name="text">
+    <string>Start Insert Map Point</string>
+   </property>
+  </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

+ 223 - 0
src/tool/tool_siasun/myview.cpp

@@ -0,0 +1,223 @@
+#include "myview.h"
+#include <QScrollBar>
+#include <iostream>
+#define VIEW_CENTER viewport()->rect().center()
+const double PI = 3.1415926535898;
+
+MyView::MyView(QWidget *parent) :
+     QGraphicsView(parent),
+    beishu(1.00000)
+{
+    setDragMode(QGraphicsView::ScrollHandDrag);
+
+//    grabGesture(Qt::PanGesture);
+    grabGesture(Qt::PinchGesture);
+ //   grabGesture(Qt::SwipeGesture);
+}
+
+
+
+
+void MyView::mousePressEvent(QMouseEvent *event)
+{
+//    qDebug("x is %d",event->pos().x());
+    bottonstatus = true;
+    QGraphicsView::mousePressEvent(event);
+}
+void MyView::mouseMoveEvent(QMouseEvent *event)
+{
+    if(mbInPinch == true)return;
+    QGraphicsView::mouseMoveEvent(event);
+
+//    QScrollBar * ps = verticalScrollBar();
+//    std::cout<<" size is "<<ps->size().height()<<" v = "<<ps->value()<<std::endl;
+//    QScrollBar * ps2= horizontalScrollBar();
+//     std::cout<<" size is "<<ps2->size().width()<<" h = "<<ps2->value()<<std::endl;
+}
+void MyView::mouseReleaseEvent(QMouseEvent *event)
+{
+    bottonstatus = false;
+    QGraphicsView::mouseReleaseEvent(event);
+}
+
+// 放大/缩小
+void MyView::wheelEvent(QWheelEvent *event)
+{
+    // 滚轮的滚动量
+    QPoint scrollAmount = event->angleDelta();
+    // 正值表示滚轮远离使用者(放大),负值表示朝向使用者(缩小)
+    scrollAmount.y() > 0 ? zoomIn() : zoomOut();
+}
+
+
+// 放大
+void MyView::zoomIn()
+{
+
+    int width,hgt;
+    width = sceneRect().width();
+    hgt = sceneRect().height();
+    QScrollBar * psV = verticalScrollBar();
+    QScrollBar * psH = horizontalScrollBar();
+
+
+//    qDebug("%d %d ",width,hgt);
+
+
+    int centery = (psV->value() + psV->size().height()/2)/beishu;
+    int centerx = (psH->value() + psH->size().width()/2)/beishu;
+
+#ifndef ANDROID
+    scale(1.1, 1.1);
+    beishu *= 1.1;
+#else
+    scale(1.6, 1.6);
+    beishu *= 1.6;
+#endif
+ //   centerOn(450, 700 - (200 / beishu));
+
+
+
+//    qDebug("beishu is %f",beishu);
+
+    centerOn(centerx,centery);
+
+    emit beishuchange(beishu);
+
+
+
+//    QPoint x = viewport()->rect().center();
+
+
+//    std::cout<<" x is"<<sceneRect().bottom()<<" y is "<<sceneRect().y()<<std::endl;
+//    QScrollBar * ps = verticalScrollBar();
+//    std::cout<<" size is "<<ps->size().height()<<" v = "<<ps->value()<<std::endl;
+
+}
+
+// 缩小
+void MyView::zoomOut()
+{
+
+    int width,hgt;
+    width = sceneRect().width();
+    hgt = sceneRect().height();
+    QScrollBar * psV = verticalScrollBar();
+    QScrollBar * psH = horizontalScrollBar();
+
+    int centery = (psV->value() + psV->size().height()/2)/beishu;
+    int centerx = (psH->value() + psH->size().width()/2)/beishu;
+
+#ifndef ANDROID
+    scale(1 / 1.1, 1 / 1.1);
+    beishu /= 1.1;
+#else
+    scale(1 / 1.6, 1 / 1.6);
+    beishu /= 1.6;
+#endif
+//    centerOn(450, 700 - (200 / beishu));
+
+
+    centerOn(centerx,centery);
+
+    emit beishuchange(beishu);
+}
+
+void MyView::zoomone()
+{
+
+    scale(1 /beishu, 1 / beishu);
+    beishu  = 1.0;
+
+    emit beishuchange(beishu);
+
+}
+
+void MyView::mouseDoubleClickEvent(QMouseEvent *event)
+{
+
+    QScrollBar * psV = verticalScrollBar();
+    QScrollBar * psH = horizontalScrollBar();
+
+    double centery = (psV->value() + psV->size().height()/2)/beishu;
+    double centerx = (psH->value() + psH->size().width()/2)/beishu;
+
+
+//    qDebug("x is %d y is %d view center x is %d  centerx is %d",event->pos().x(),
+//           event->pos().y(),
+//           viewport()->rect().center().x(),centerx);
+
+    double viewx,viewy;
+    if(beishu == 0)return;
+    viewx = centerx +(event->pos().x() - viewport()->rect().center().x())/beishu;
+    viewy = centery +(event->pos().y() - viewport()->rect().center().y())/beishu;
+
+    QPoint viewpoint;
+    viewpoint.setX(viewx);
+    viewpoint.setY(viewy);
+
+    emit dbclickxy(viewx,viewy);
+    qDebug("view x is %f view y is %f ",viewx,viewy);
+}
+
+bool MyView::event(QEvent *event)
+{
+    if (event->type() == QEvent::Gesture)
+    {
+ //       qDebug("gestrue event");
+ //       return true;
+        return gestureEvent(static_cast<QGestureEvent*>(event));
+    }
+
+    return QGraphicsView::event(event);
+}
+
+bool MyView::gestureEvent(QGestureEvent *event)
+{
+    if (QGesture *pinch = event->gesture(Qt::PinchGesture))
+        pinchTriggered(static_cast<QPinchGesture *>(pinch));
+    return true;
+}
+
+void MyView::pinchTriggered(QPinchGesture *gesture)
+{
+
+    static double currentStepScaleFactor = 1;
+    static double oldfactor = 1;
+    QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
+    if (changeFlags & QPinchGesture::ScaleFactorChanged) {
+        currentStepScaleFactor = gesture->totalScaleFactor();
+        mbInPinch = true;
+    }
+    if (gesture->state() == Qt::GestureFinished) {
+//        scaleFactor *= currentStepScaleFactor;
+//        qDebug("scale is %f ",currentStepScaleFactor);
+
+        currentStepScaleFactor = 1;
+        oldfactor = 1;
+        mbInPinch = false;
+    }
+
+    int width,hgt;
+    width = sceneRect().width();
+    hgt = sceneRect().height();
+    QScrollBar * psV = verticalScrollBar();
+    QScrollBar * psH = horizontalScrollBar();
+
+    int centery = (psV->value() + psV->size().height()/2)/beishu;
+    int centerx = (psH->value() + psH->size().width()/2)/beishu;
+
+    double fscale = currentStepScaleFactor/oldfactor;
+    scale(fscale,fscale);
+    beishu *= fscale;
+    oldfactor = currentStepScaleFactor;
+
+    centerOn(centerx,centery);
+
+}
+
+double MyView::getbeishu()
+{
+    return beishu;
+}
+

+ 60 - 0
src/tool/tool_siasun/myview.h

@@ -0,0 +1,60 @@
+#ifndef MYVIEW_H
+#define MYVIEW_H
+
+#include <qtimer.h>
+#include <qpainter.h>
+#include <QGraphicsView>
+#include <QWheelEvent>
+#include <QKeyEvent>
+#include <QPoint>
+#include <QPointF>
+#include <QGraphicsItem>
+#include <QKeyEvent>
+
+#include <QGestureEvent>
+#include <QPinchGesture>
+
+
+
+class MyView : public QGraphicsView
+{
+    Q_OBJECT
+
+public:
+    explicit MyView(QWidget *parent =0);
+    qreal x, y, beishu;
+
+    void zoomone();
+
+    double getbeishu();
+protected:
+    void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+    void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+
+    bool event(QEvent *event) Q_DECL_OVERRIDE;
+public Q_SLOTS:
+    void zoomIn();  // 放大
+    void zoomOut();  // 缩小
+
+signals:
+    void dbclickxy(double x,double y);
+    void beishuchange(double beishu);
+
+private:
+    bool bottonstatus = false;
+    QPoint myview_lastMousePos;
+
+private:
+    bool gestureEvent(QGestureEvent *event);
+    void pinchTriggered(QPinchGesture*);
+
+    bool mbInPinch = false;
+
+
+
+};
+
+#endif // MYVIEW_H

+ 55 - 0
src/tool/tool_siasun/tool_siasun.pro

@@ -0,0 +1,55 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2022-07-15T10:50:51
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = tool_siasun
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+
+SOURCES += \
+        main.cpp \
+        mainwindow.cpp \
+    myview.cpp \
+    dialogkickpoint.cpp \
+    ../../common/common/math/gnss_coordinate_convert.cpp
+
+HEADERS += \
+        mainwindow.h \
+    myview.h \
+    dialogkickpoint.h \
+    ../../include/msgtype/siasun.pb.h \
+    ../../common/common/math/gnss_coordinate_convert.h
+
+FORMS += \
+        mainwindow.ui \
+    dialogkickpoint.ui
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+
+}
+
+INCLUDEPATH += ../../common/common/math
+
+LIBS += -livprotoif