commit 0b4ee4835540b984896946a114a42daeb67bf1cb
Author: tangchao0503 <735056338@qq.com>
Date: Tue Mar 14 22:52:38 2023 +0800
1、实现了光谱仪简单的采集功能:曝光、调焦、暗电流、采集影像、保存影像;
2、设置光谱仪帧率、曝光时间、gain;
3、在页面中嵌入了rgb相机图传(通过opencv实现);
4、平台的相机位置模拟、x/y马达的分别控制、x/y马达的量程检测;
5、轨迹规划;
6、加入了张卓的自动调焦模块;
7、加入了自动电源控制;
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b31d297
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,401 @@
+# tc
+GeneratedFiles/
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
\ No newline at end of file
diff --git a/HPPA.sln b/HPPA.sln
new file mode 100644
index 0000000..908f7ad
--- /dev/null
+++ b/HPPA.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.1267
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPPA", "HPPA\HPPA.vcxproj", "{E7886664-B69E-4781-BCBE-804574FB4033}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.ActiveCfg = Debug|x64
+ {E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.Build.0 = Debug|x64
+ {E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.ActiveCfg = Release|x64
+ {E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {FE57463D-FBEC-4B67-B97A-695B244BC71C}
+ EndGlobalSection
+EndGlobal
diff --git a/HPPA/FocusDialog.ui b/HPPA/FocusDialog.ui
new file mode 100644
index 0000000..22f5445
--- /dev/null
+++ b/HPPA/FocusDialog.ui
@@ -0,0 +1,183 @@
+
+
+ focusDialog
+
+
+
+ 0
+ 0
+ 453
+ 339
+
+
+
+ Dialog
+
+
+
+ :/HPPA/HPPA.ico:/HPPA/HPPA.ico
+
+
+ -
+
+
+ 连接调焦模块
+
+
+
-
+
+
+ true
+
+
+ 线性平台
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ -
+
+
+ 超声
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ 超声
+
+
+
+ -
+
+
+ 连接线性平台
+
+
+
+
+
+
+ -
+
+
+ 调整线性平台
+
+
+
-
+
+
+ LogicZero
+
+
+
+ -
+
+
+ +
+
+
+
+ -
+
+
+ 50
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ max
+
+
+
+ -
+
+
+ -
+
+
+
+ -
+
+
+ 50
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+ -
+
+
+ 调焦
+
+
+
-
+
+
+ 24
+
+
+
+ -
+
+
+ 自动调焦
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 171
+ 20
+
+
+
+
+ -
+
+
+ 手动调焦
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp
new file mode 100644
index 0000000..126c9c8
--- /dev/null
+++ b/HPPA/HPPA.cpp
@@ -0,0 +1,1976 @@
+#include "stdafx.h"
+//#include
+
+#include
+#include
+
+#include "HPPA.h"
+#include "ImageReaderWriter.h"
+
+
+
+
+HPPA::HPPA(QWidget *parent)
+ : QMainWindow(parent)
+{
+ ui.setupUi(this);
+
+ //״̬
+ xmotor_state_label1 = new QLabel();
+ ymotor_state_label1 = new QLabel();
+ xmotor_state_label1->setText("xMotor");
+ ymotor_state_label1->setText("yMotor");
+ ui.statusBar->addPermanentWidget(xmotor_state_label1);
+ ui.statusBar->addPermanentWidget(ymotor_state_label1);
+
+
+
+
+
+ connect(this->ui.action_exit, SIGNAL(triggered()), this, SLOT(onExit()));
+
+ //ui.cam_label->setScaledContents(true);
+
+ /*ui.splitter->setStretchFactor(0, 1);
+ ui.splitter->setStretchFactor(1, 1);
+ ui.splitter->setStretchFactor(2, 3);*/
+
+
+
+ //ڹQLineEdit
+ frame_number = new QLineEdit(ui.mainToolBar);
+ frame_number->setStyleSheet("QLineEdit{background-color:rgb(255,255,255);}");
+ frame_number->setMaximumWidth(100);
+ frame_number->setText("5000");
+ QAction *action = ui.mainToolBar->insertWidget(ui.action_start_recording, frame_number);
+
+ m_FilenameLineEdit = new QLineEdit(ui.mainToolBar);
+ m_FilenameLineEdit->setStyleSheet("QLineEdit{background-color:rgb(255,255,255);}");
+ m_FilenameLineEdit->setMaximumWidth(100);
+ m_FilenameLineEdit->setText("tmp_image");
+ QAction *action1 = ui.mainToolBar->insertWidget(ui.action_start_recording, m_FilenameLineEdit);
+
+
+
+
+ /*QToolBar *ptoolbar = ui.mainToolBar;
+ QAction *pAction = new QAction("tangchao");
+ ptoolbar->addAction(pAction);*/
+
+
+ //ʾ
+ m_chartView = new QChartView();
+ m_chartView->setRenderHint(QPainter::Antialiasing);
+ ui.spectral_gridLayout->addWidget(m_chartView);
+
+ //QLineSeries *series = new QLineSeries();
+ //QChart *chart = new QChart();
+
+
+ //Dz
+ m_Imager = nullptr;
+ m_RecordState = 0;
+ connect(this->ui.action_connect_imager, SIGNAL(triggered()), this, SLOT(onconnect()));//źۣź۰ںonconnect
+
+ //rgb
+ m_RgbCameraThread = new QThread();
+ m_RgbCamera = new RgbCameraOperation();
+ m_RgbCamera->moveToThread(m_RgbCameraThread);
+ m_RgbCameraThread->start();
+ connect(this->ui.open_rgb_camera_btn, SIGNAL(clicked()), m_RgbCamera, SLOT(OpenCamera()));//ʹź֪̣ͨ߳uị߳ˢƵ ɹǽ濨
+ connect(m_RgbCamera, SIGNAL(PlotSignal()), this, SLOT(onPlotRgbImage()));
+
+ //m_RgbCamera->setCallback(onPlotRgbImage);
+ //connect(this->ui.open_rgb_camera_btn, SIGNAL(clicked()), m_RgbCamera, SLOT(OpenCamera_callback()));//ʹûصˢ̣߳uị߳ϵƵ ʧ
+
+ connect(this->ui.close_rgb_camera_btn, SIGNAL(clicked()), this, SLOT(onCloseRgbCamera()));//ر
+ connect(m_RgbCamera, SIGNAL(CamClosed()), this, SLOT(onClearLabel()));
+
+
+ //֡ʷΧЩñsliderźźͲconnectǰsetMinimumısliderֵ
+ ui.FramerateSlider->setMinimum(1);
+ ui.FramerateSlider->setMaximum(250);
+ ui.GainSlider->setMinimum(0);
+ ui.GainSlider->setMaximum(24);
+ //ؼΪ
+ frame_number->setEnabled(false);
+
+ ui.framerate_lineEdit->setEnabled(false);
+ ui.integratioin_time_lineEdit->setEnabled(false);
+ ui.gain_lineEdit->setEnabled(false);
+
+ ui.FramerateSlider->setEnabled(false);
+ ui.IntegratioinTimeSlider->setEnabled(false);
+ ui.GainSlider->setEnabled(false);
+
+
+
+ //
+ m_xMotor = new VinceControl(NETTCP, 6002);//
+ m_yMotor = new VinceControl(NETTCP, 6001);//ԭ6001ԣ6003
+ m_xConnectCount = 0;
+ m_yConnectCount = 0;
+
+
+
+ //m_TestXmotorStausThread = new MotorWorkerThread(m_xMotor);
+ //m_TestXmotorStausThread->start();
+
+ startTimer(1000);
+
+
+ m_lManualSpeedOfXMotor = 6000;
+ m_lManualSpeedOfYMotor = 6000*2;//ϺũԺ20000
+
+ connect(this->ui.motor_reset_btn, SIGNAL(clicked()), this, SLOT(onMotorReset()));
+
+ connect(this->ui.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
+ connect(this->ui.xmotor_left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
+ connect(this->ui.xmotor_right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
+ connect(this->ui.xmotor_right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
+
+ connect(this->ui.ymotor_forward_btn, SIGNAL(pressed()), this, SLOT(onyMotorForward()));
+ connect(this->ui.ymotor_forward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
+ connect(this->ui.ymotor_backward_btn, SIGNAL(pressed()), this, SLOT(onyMotorBackward()));
+ connect(this->ui.ymotor_backward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
+
+ //ٶ
+ QRegExp rx("\\d{0,3}[1-9]$");
+ ui.xmotor_speed_lineEdit->setValidator(new QRegExpValidator(rx));
+
+ ui.xmotor_speed_slider->setRange(0, 3);//5.2734375cm/s=10000
+ ui.xmotor_speed_slider->setValue(1);
+ connect(this->ui.xmotor_speed_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnXmotorSpeedLineeditEditingFinished()));
+ //connect(this->ui.xmotor_speed_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnXmotorSpeedEditingFinished()));//ͨ˷ʽΪٶȣÿεɼȡٶȣȻ
+ connect(this->ui.xmotor_speed_slider, SIGNAL(valueChanged(double)), this, SLOT(OnXmotorSpeedSliderChanged(double)));
+
+ connect(this->ui.xmotor_location_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnXmotorLocationLineeditEditingFinished()));
+ connect(this->ui.xmotor_location_slider, SIGNAL(valueChanged(double)), this, SLOT(OnXmotorLocationSliderChanged(double)));
+ connect(this->ui.xmotor_location_slider, SIGNAL(sliderReleased()), this, SLOT(OnXmotorLocationSliderReleased()));
+ ui.xmotor_location_slider->setValue(0);
+
+
+
+
+ connect(this->ui.ymotor_location_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnYmotorLocationLineeditEditingFinished()));
+ connect(this->ui.ymotor_location_slider, SIGNAL(valueChanged(double)), this, SLOT(OnYmotorLocationSliderChanged(double)));
+ connect(this->ui.ymotor_location_slider, SIGNAL(sliderReleased()), this, SLOT(OnYmotorLocationSliderReleased()));
+ ui.ymotor_location_slider->setValue(0);
+
+
+
+ m_timerLocationFeedBackOfMotor_x_y = new QTimer();
+ connect(m_timerLocationFeedBackOfMotor_x_y, SIGNAL(timeout()), this, SLOT(ontimerLocationFeedBackOfMotor_x_y()));
+
+ m_timerYmotorLocationFeedBackAfterRecord = new QTimer();
+ connect(m_timerYmotorLocationFeedBackAfterRecord, SIGNAL(timeout()), this, SLOT(ontimerYmotorLocationFeedBackAfterRecord()));
+
+ //̲
+ connect(this->ui.test_range_btn, SIGNAL(clicked()), this, SLOT(ontestRangeOfMotor_x_y()));
+ m_timerTestRangeOfxMotor = new QTimer();
+ connect(m_timerTestRangeOfxMotor, SIGNAL(timeout()), this, SLOT(ontimerTestRangeOfxMotor()));
+ m_timerTestRangeOfyMotor = new QTimer();
+ connect(m_timerTestRangeOfyMotor, SIGNAL(timeout()), this, SLOT(ontimerTestRangeOfyMotor()));
+
+ widthScale = 1;
+ heightScale = 1;
+
+ //λģ
+ connect(ui.graphicsView->imager, SIGNAL(leftMouseButtonPressed(int, int)), this, SLOT(onimagerSimulatorMove(int, int)));
+
+
+ connect(m_xMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
+
+ //滮ɼ
+ ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
+ ui.recordLine_tableWidget->setStyleSheet("selection-background-color:rgb(255,209,128)");//ѡи
+
+ ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//ѡΪΪλ
+ //ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//ѡģʽѡ
+ //QHeaderView* headerView = ui.recordLine_tableWidget->verticalHeader();
+ //headerView->setHidden(true);//ȥĬԴк
+
+
+ ui.recordLine_tableWidget->setColumnCount(2);
+ ui.recordLine_tableWidget->setHorizontalHeaderLabels(QStringList() << "yPosition" << "xMaxPosition");
+
+ connect(ui.addRecordLine_btn, SIGNAL(clicked()), this, SLOT(onAddRecordLine_btn()));
+ connect(ui.removeRecordLine_btn, SIGNAL(clicked()), this, SLOT(onRemoveRecordLine_btn()));
+ connect(ui.generateRecordLine_btn, SIGNAL(clicked()), this, SLOT(onGenerateRecordLine_btn()));
+ connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
+ connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
+ connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
+
+
+ //
+ m_ForLoopControlThread = new QThread();
+ m_ForLoopControl = new ForLoopControl();
+ m_ForLoopControl->moveToThread(m_ForLoopControlThread);
+ m_ForLoopControlThread->start();
+
+
+ //connect(this->ui.action_start_recording, SIGNAL(triggered()), m_ForLoopControl, SLOT(startLoop()));//ںonconnect
+ connect(m_ForLoopControl, SIGNAL(recordSignal(int)), this, SLOT(onStartRecordStep2(int)));
+
+
+
+ m_timerMoveXmotor = new QTimer();
+ connect(m_timerMoveXmotor, SIGNAL(timeout()), this, SLOT(ontimerMoveXmotor()));
+ m_timerMoveYmotor = new QTimer();
+ connect(m_timerMoveYmotor, SIGNAL(timeout()), this, SLOT(ontimerMoveYmotor()));
+
+
+ //
+ ui.ImageViewerTabWidget->clear();//ǰ棬ɾеtab
+ //ui.ImageViewerTabWidget->setTabsClosable(true);//ÿҳйرհť
+ connect(m_ForLoopControl, SIGNAL(recordSignal(int)), this, SLOT(onCreateTab(int)));//tabWidget½һtabʾͼ
+ connect(ui.ImageViewerTabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabWidgetCurrentChanged(int)));
+
+ //Դ
+ connect(ui.lamp_power_open_btn, SIGNAL(clicked()), this, SLOT(onLampPowerOpen_btn()));
+ connect(ui.lamp_power_close_btn, SIGNAL(clicked()), this, SLOT(onLampPowerClose_btn()));
+
+ connect(ui.motor_power_open_btn, SIGNAL(clicked()), this, SLOT(onMotorPowerOpen_btn()));
+ connect(ui.motor_power_close_btn, SIGNAL(clicked()), this, SLOT(onMotorPowerClose_btn()));
+}
+
+HPPA::~HPPA()
+{
+ if (m_Imager != nullptr)
+ m_Imager->~ResononImager();//ͷԴ
+
+ if (isMotorConnected(m_xMotor))
+ {
+ m_xMotor->StopMotormove();
+ }
+ if (isMotorConnected(m_yMotor))
+ {
+ m_yMotor->StopMotormove();
+ }
+}
+
+void HPPA::CalculateIntegratioinTimeRange()
+{
+ double range = 1 / m_Imager->get_framerate() * 1000;//
+
+ ui.IntegratioinTimeSlider->blockSignals(true);//ΪsetMaximumᴥvalueChangedźţԵsetMaximumǰҪź
+ ui.IntegratioinTimeSlider->setMaximum(range);
+ ui.IntegratioinTimeSlider->blockSignals(false);
+}
+
+void HPPA::onStartRecordStep1()
+{
+ //ȷxλ С xɼλ
+ int validLineCount = 0;
+ for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
+ {
+ //xx = xx + ui.xmotor_location_slider->value() < ui.recordLine_tableWidget->item(i, 1)->text().toDouble();
+
+ if (ui.xmotor_location_slider->value() < ui.recordLine_tableWidget->item(i, 1)->text().toDouble())
+ {
+ validLineCount++;
+ }
+
+ }
+
+ if (validLineCount < ui.recordLine_tableWidget->rowCount())
+ {
+ QMessageBox::information(this, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("켣xλ"));
+ return;
+ }
+
+ //ȷɼߴ
+ if (ui.recordLine_tableWidget->rowCount() <= 0)
+ {
+ QMessageBox::information(this, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ɹ켣"));
+ return;
+ }
+
+
+ //ʼɼ
+ m_RecordState += 1;
+
+ if (m_RecordState % 2 == 1)
+ {
+ //жǷǴڵļ
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryFromString();
+ //string imgPath = directory + "\\tmp_image";
+ string imgPath = directory + "\\" + m_FilenameLineEdit->text().toStdString() + "_" + std::to_string(1);
+ int x = _access(imgPath.c_str(), 0);
+ if (!x)//ļھִдifĴ
+ {
+ enum QMessageBox::StandardButton response = QMessageBox::question(this, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ļڣǷǣ"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);;
+ if (response == QMessageBox::Yes)//
+ {
+ //std::cout << "" << std::endl;
+ }
+ else
+ {
+ //std::cout << "" << std::endl;
+ m_RecordState -= 1;//ǵĻҪԭ
+ return;
+ }
+ }
+
+
+ //
+ operateWidget = QObject::sender()->objectName();
+
+ //ļ
+ m_Imager->setFileName2Save(m_FilenameLineEdit->text().toStdString());
+
+ //ɾtab
+ ui.ImageViewerTabWidget->clear();
+
+ //ʼѭ
+ m_ForLoopControl->setLoopCount(ui.recordLine_tableWidget->rowCount());//Ϊѭ߳ѭ
+ emit StartLoopSignal();
+
+ //Ϊɫ
+ for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
+ {
+ for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
+ {
+ ui.recordLine_tableWidget->item(i, j)->setBackgroundColor(QColor(240, 240, 240));
+ }
+ }
+
+ ui.action_start_recording->setText(QString::fromLocal8Bit("ֹͣɼ"));
+ ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
+ }
+ else
+ {
+ m_Imager->setRecordControlState(false);//ֹͣɼ
+
+ m_ForLoopControl->m_boolQuitLoop = true;//ѭֹͣ
+
+ ui.action_start_recording->setText(QString::fromLocal8Bit("ɼ"));
+ ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+ }
+}
+
+void HPPA::onStartRecordStep2(int lineNumber)
+{
+ if (lineNumber >= 0)
+ {
+ m_numberOfRecording = lineNumber;
+ }
+
+ if (lineNumber >= 0)
+ {
+ //ʼƶyxƶDzɼĴҲ
+ double pos = ui.recordLine_tableWidget->item(lineNumber, 0)->text().toDouble();
+ m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
+ m_yMotor->MoveToLocation(ui.ymotor_location_slider->getPositionPulse(pos));
+ m_timerMoveYmotor->start(500);
+
+ //ڲɼΪɫ
+ for (size_t i = 0; i < ui.recordLine_tableWidget->columnCount(); i++)
+ {
+ ui.recordLine_tableWidget->item(lineNumber, i)->setBackgroundColor(QColor(255, 0, 0));
+ }
+ }
+ else if (lineNumber == -1)
+ {
+ std::cout << "Զֹɼ" << std::endl;
+ m_RecordState++;
+
+ ui.action_start_recording->setText(QString::fromLocal8Bit("ɼ"));
+ ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+
+ //yƶһɼߵλ
+ double ymotorPositionOfLine1Tmp = ui.recordLine_tableWidget->item(0, 0)->text().toDouble();
+ long ymotorPositionOfLine1 = ui.ymotor_location_slider->getPositionPulse(ymotorPositionOfLine1Tmp);
+ m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
+ m_yMotor->MoveToLocation(ymotorPositionOfLine1);
+ m_timerYmotorLocationFeedBackAfterRecord->start(500);
+ }
+ else if (lineNumber == -2)
+ {
+ std::cout << "ֶֹɼ" << std::endl;
+
+ //ֹͣy˶
+ m_yMotor->StopMotormove();
+
+ }
+}
+
+void HPPA::onCreateTab(int trackNumber)
+{
+ if (trackNumber >= 0)
+ {
+ QWidget * tabTmp = new QWidget();
+
+ QGridLayout *GridLayout = new QGridLayout();
+ GridLayout->addWidget(new ImageViewer(tabTmp));
+
+ tabTmp->setLayout(GridLayout);
+
+ ui.ImageViewerTabWidget->addTab(tabTmp, QString::number(trackNumber + 1));
+
+ ui.ImageViewerTabWidget->setCurrentIndex(trackNumber);
+ }
+
+}
+
+void HPPA::onTabWidgetCurrentChanged(int index)//½һtabonTabWidgetCurrentChanged
+{
+ if (index < 0)//ɾtabʱindex=-1
+ {
+ return;
+ }
+
+
+ //¼ǰ
+ m_TabWidgetCurrentIndex = index;
+
+ //ȡͼؼ
+ QWidget* currentWidget = ui.ImageViewerTabWidget->widget(index);
+ QList currentImageViewer = currentWidget->findChildren();
+
+ //disconnectȻconnectÿлһζconnectһΣۻconnectܶΣ
+ disconnect(currentImageViewer[0], SIGNAL(leftMouseButtonPressed(int, int)), this, SLOT(onLeftMouseButtonPressed(int, int)));
+ connect(currentImageViewer[0], SIGNAL(leftMouseButtonPressed(int, int)), this, SLOT(onLeftMouseButtonPressed(int, int)));
+}
+
+void HPPA::onActionOpenDirectory()
+{
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryFromString();
+
+ QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(directory)));
+
+ //QDesktopServices::openUrl(QUrl("file:C:\ASD", QUrl::TolerantMode));
+
+
+ ////std::cout << "Ӱļ" << std::endl;
+ //
+ //FileOperation * fileOperation = new FileOperation();
+ //string directory = fileOperation->getDirectoryFromString();
+
+ //string sourceImg = directory + "\\tmp_image";
+ //string sourceHdr = sourceImg + ".hdr";
+ //
+
+ //QString FileName2Save = QFileDialog::getSaveFileName(this,tr("save image"));
+
+ //if (FileName2Save.length()>0)
+ //{
+ // string targetImg = FileName2Save.toStdString();
+ // string targetHdr = targetImg + ".hdr";
+
+ // emit CopyFileThreadSignal(QString::fromStdString(sourceHdr), QString::fromStdString(targetHdr));
+ // emit CopyFileThreadSignal(QString::fromStdString(sourceImg), QString::fromStdString(targetImg));
+
+ // this->setEnabled(false);
+ //}
+ //else
+ //{
+ // std::cout << "ļȣ" << FileName2Save.length() << std::endl;
+ //}
+
+}
+
+void HPPA::OnFramerateLineeditEditingFinished()
+{
+ std::cout << "Lineedit֡------------------------------------------" << std::endl;
+ m_Imager->set_framerate(this->ui.framerate_lineEdit->text().toDouble());
+ ui.FramerateSlider->setValue(ui.framerate_lineEdit->text().toDouble());
+
+ CalculateIntegratioinTimeRange();
+}
+
+void HPPA::OnFramerateSliderChanged(double framerate)
+{
+ std::cout << "Slider֡------------------------------------------" << std::endl;
+ m_Imager->set_framerate(this->ui.framerate_lineEdit->text().toDouble());
+ ui.framerate_lineEdit->setText(QString::number(framerate));
+
+ CalculateIntegratioinTimeRange();
+}
+
+void HPPA::OnIntegratioinTimeEditingFinished()
+{
+ std::cout << "Lineeditûʱ------------------------------------------" << std::endl;
+ m_Imager->set_integration_time(this->ui.integratioin_time_lineEdit->text().toDouble());
+ ui.IntegratioinTimeSlider->setValue(ui.integratioin_time_lineEdit->text().toDouble());
+}
+
+void HPPA::OnIntegratioinTimeSliderChanged(double IntegratioinTime)
+{
+ std::cout << "Sliderûʱ------------------------------------------" << std::endl;
+ m_Imager->set_integration_time(IntegratioinTime);
+ ui.integratioin_time_lineEdit->setText(QString::number(IntegratioinTime));
+}
+
+void HPPA::OnGainEditingFinished()
+{
+ m_Imager->set_gain(this->ui.gain_lineEdit->text().toDouble());
+ ui.GainSlider->setValue(ui.gain_lineEdit->text().toDouble());
+}
+
+void HPPA::OnGainSliderChanged(double Gain)
+{
+ m_Imager->set_gain(this->ui.gain_lineEdit->text().toDouble());
+ ui.gain_lineEdit->setText(QString::number(Gain));
+}
+
+void HPPA::onLeftMouseButtonPressed(int x, int y)
+{
+ try
+ {
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryFromString();
+ string imgPath = directory + "\\" + m_FilenameLineEdit->text().toStdString() + "_" + std::to_string(m_TabWidgetCurrentIndex + 1);
+
+ ImageReaderWriter *ImageReader = new ImageReaderWriter(imgPath.c_str());
+
+
+ if (x < 0 || x>899 || y<0 || y>ImageReader->getyCount() - 1)
+ {
+ return;
+ }
+
+
+ float *data = ImageReader->ReadImage(x, y, 1, 1);
+
+
+ QLineSeries *series = new QLineSeries();
+ //series->clear();//////////////////////////////
+
+ for (size_t i = 0; i < m_Imager->getBandCount(); i++)
+ {
+ //mallocڴ÷1Ե
+ series->append(m_Imager->getWavelengthAtBand(i), data[i]);
+
+ ////mallocڴ÷2ָȡ
+ //series->append(m_Imager->getWavelengthAtBand(i), *data);
+ //data++;
+ }
+
+ QChart *chart = new QChart();
+ chart->legend()->hide();
+ chart->addSeries(series);
+ chart->createDefaultAxes();
+ //chart->setTitle("Simple line chart example");
+
+ m_chartView->setChart(chart);
+ //m_chartView->update();//////////////////////////////
+
+
+ /*std::cout << "x:" << x << std::endl;
+ std::cout << "y:" << y << std::endl;
+ std::cout << "ļ:" << imgPath << std::endl;*/
+
+ }
+ catch (const std::exception&)
+ {
+ std::cout << "ʾд" << std::endl;
+ }
+
+}
+
+void HPPA::timerEvent(QTimerEvent *event)
+{
+ try
+ {
+ if (!m_xMotor->IsMotorInit)
+ {
+ //return;
+
+ }
+ ByteBack xMotorState = m_xMotor->GetState();//ִ
+
+ std::cout << "------------------------------------------ٶȣ" << xMotorState.Speed << std::endl;
+
+ if (xMotorState.Speed == -1000000)
+ {
+ xmotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
+ SetXMotorWidgetEnable(false);
+ //std::cout << "xMotor: false" << std::endl;
+ }
+ else
+ {
+ m_xConnectCount++;
+ if (m_xConnectCount == 1)//һõ
+ {
+ m_xMotor->SendCommandtoMotor("cfg crn=3\n");
+ }
+
+ xmotor_state_label1->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
+ SetXMotorWidgetEnable(true);
+ //std::cout << "xMotor: ok" << std::endl;
+ }
+
+
+ ByteBack yMotorState = m_yMotor->GetState();
+
+ //std::cout << "------------------------------------------ٶȣ" << x.Speed << std::endl;
+
+ if (yMotorState.Speed == -1000000)
+ {
+ ymotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
+ SetYMotorWidgetEnable(false);
+ //std::cout << "yMotor: false" << std::endl;
+ }
+ else
+ {
+ m_yConnectCount++;
+ if (m_yConnectCount == 1)//һõ
+ {
+ m_yMotor->SendCommandtoMotor("cfg crn=2\n");
+ }
+
+ ymotor_state_label1->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
+ SetYMotorWidgetEnable(true);
+ //std::cout << "yMotor: ok" << std::endl;
+ }
+
+
+ }
+ catch (...)
+ {
+
+ }
+}
+
+void HPPA::onxMotorLeft()
+{
+ m_timerLocationFeedBackOfMotor_x_y->start(500);
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ m_xMotor->EnableMotro();
+ m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
+ m_xMotor->MoveMotar(false);
+}
+
+void HPPA::onxMotorRight()
+{
+ m_timerLocationFeedBackOfMotor_x_y->start(500);
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ m_xMotor->EnableMotro();
+ m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
+ m_xMotor->MoveMotar(true);
+}
+
+void HPPA::onxMotorStop()
+{
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ m_timerLocationFeedBackOfMotor_x_y->stop();
+ m_xMotor->StopMotormove();
+}
+
+void HPPA::onyMotorForward()
+{
+ operateWidget = QObject::sender()->objectName();
+
+ m_timerLocationFeedBackOfMotor_x_y->start(500);
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ m_yMotor->EnableMotro();
+ m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
+ m_yMotor->MoveMotar(true);
+}
+
+void HPPA::onyMotorBackward()
+{
+ operateWidget = QObject::sender()->objectName();
+
+ m_timerLocationFeedBackOfMotor_x_y->start(500);
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ m_yMotor->EnableMotro();
+ m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
+ m_yMotor->MoveMotar(false);
+}
+
+void HPPA::onyMotorStop()
+{
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ m_timerLocationFeedBackOfMotor_x_y->stop();
+ m_yMotor->StopMotormove();
+}
+
+void HPPA::onMotorReset()
+{
+ setMotorRange();
+
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ m_xMotor->SettingZeroLocation();
+ m_yMotor->SettingZeroLocation();
+
+
+}
+
+void HPPA::OnXmotorSpeedEditingFinished()
+{
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ m_xMotor->SettingSpeed(ui.xmotor_speed_lineEdit->text().toLong());
+}
+
+
+bool HPPA::isMotorConnected(VinceControl *motor)
+{
+ ByteBack x = motor->GetState();
+
+ //std::cout << "------------------------------------------ٶȣ" << x.Speed << std::endl;
+
+ if (x.Speed == -1000000)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void HPPA::SetXMotorWidgetEnable(bool enable)
+{
+ ui.test_range_btn->setEnabled(enable);
+ ui.motor_reset_btn->setEnabled(enable);
+
+ //ui.xmotor_left_btn->setEnabled(enable);
+ //ui.xmotor_right_btn->setEnabled(enable);
+ ui.xmotor_speed_lineEdit->setEnabled(enable);
+ ui.xmotor_speed_slider->setEnabled(enable);
+ ui.xmotor_location_lineEdit->setEnabled(enable);
+ ui.xmotor_location_slider->setEnabled(enable);
+}
+
+void HPPA::SetYMotorWidgetEnable(bool enable)
+{
+ ui.test_range_btn->setEnabled(enable);
+ ui.motor_reset_btn->setEnabled(enable);
+
+ //ui.ymotor_forward_btn->setEnabled(enable);
+ //ui.ymotor_backward_btn->setEnabled(enable);
+ ui.ymotor_location_lineEdit->setEnabled(enable);
+ ui.ymotor_location_slider->setEnabled(enable);
+}
+
+void HPPA::setMotorRange()
+{
+ try
+ {
+ //x̼¼ļԱʹ ÿζ̣˷ʱ
+
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryOfExe();
+ string xMotorRangeFilePath = directory + "\\xMotorRange";
+ string yMotorRangeFilePath = directory + "\\yMotorRange";
+
+
+ FILE * xMotorRangeFile = fopen(xMotorRangeFilePath.c_str(), "r+b");
+ FILE * yMotorRangeFile = fopen(yMotorRangeFilePath.c_str(), "r+b");
+
+
+ //FILE * xMotorRangeFile = fopen("xMotorRange", "r+b");
+ //FILE * yMotorRangeFile = fopen("yMotorRange", "r+b");
+
+ double xMotorRange;
+ double yMotorRange;
+
+ fread(&xMotorRange, sizeof(double), 1, xMotorRangeFile);
+ fread(&yMotorRange, sizeof(double), 1, yMotorRangeFile);
+
+ fclose(xMotorRangeFile);
+ fclose(yMotorRangeFile);
+
+ //std::cout << "xMotorRange" << xMotorRange << std::endl;
+ //std::cout << "yMotorRange" << yMotorRange << std::endl;
+
+
+ //xﷶΧ
+ ui.xmotor_location_slider->setMaximum(xMotorRange);
+ ui.xmotor_max_location_label->setText(QString::number(ui.xmotor_location_slider->maximum()));
+ //yﷶΧ
+ ui.ymotor_location_slider->setMaximum(yMotorRange);
+ ui.ymotor_max_location_label->setText(QString::number(ui.ymotor_location_slider->maximum()));
+
+
+ QRectF rect = ui.graphicsView->viewport()->rect();
+ widthScale = rect.width() / xMotorRange;//sceneRectĿϵx
+ heightScale = rect.height() / yMotorRange;//sceneRectĸ߶ϵy
+
+
+ ui.graphicsView->setSceneRect();
+ }
+ catch (...)
+ {
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromLocal8Bit("̲"));
+ msgBox.exec();
+ }
+}
+
+void HPPA::setImagerSimulationPos(double x, double y)
+{
+ x = widthScale * x;
+ y = heightScale * y;
+ ui.graphicsView->imager->setPos(x, y);
+}
+
+void HPPA::ontimerLocationFeedBackOfMotor_x_y()
+{
+ //std::cout << "------------------------------------------" << std::endl;
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ ByteBack xMotorState = m_xMotor->GetState();
+
+ //1ֶ/ɼx˶ʱ/ңԶĵλslider
+ if (xMotorState.Speed != 0)
+ {
+ double newPos = ui.xmotor_location_slider->getDistanceFromPulse(xMotorState.Location);
+
+ ui.xmotor_location_slider->setValue(newPos, false);
+ setImagerSimulationPos(newPos, ui.ymotor_location_slider->value());
+
+
+ QApplication::processEvents();
+ }
+
+
+
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ ByteBack yMotorState = m_yMotor->GetState();
+
+ //2ֶy˶ʱǰ/Զĵλslider
+ if (yMotorState.Speed != 0)
+ {
+ double newPos = ui.ymotor_location_slider->getDistanceFromPulse(yMotorState.Location);
+
+ ui.ymotor_location_slider->setValue(newPos, false);
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), newPos);
+
+ QApplication::processEvents();
+ }
+
+}
+
+void HPPA::ontimerYmotorLocationFeedBackAfterRecord()
+{
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ ByteBack yMotorState = m_yMotor->GetState();
+
+ //λ÷slider
+ if (yMotorState.Speed != 0)
+ {
+ double newPos = ui.ymotor_location_slider->getDistanceFromPulse(yMotorState.Location);
+
+ ui.ymotor_location_slider->setValue(newPos, false);
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), newPos);
+
+ QApplication::processEvents();
+ }
+ else//ô˺ܾȷķزɼǰλãҪͨɼǰ¼ľȷλ
+ {
+ m_timerYmotorLocationFeedBackAfterRecord->stop();
+
+ double ymotorPositionOfLine1Tmp = ui.recordLine_tableWidget->item(0, 0)->text().toDouble();//ymotorPositionOfLine1
+
+ ui.ymotor_location_slider->setValue(ymotorPositionOfLine1Tmp, false);
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), ymotorPositionOfLine1Tmp);
+ }
+}
+
+void HPPA::OnXmotorSpeedLineeditEditingFinished()
+{
+ ui.xmotor_speed_slider->setValue(ui.xmotor_speed_lineEdit->text().toDouble());
+}
+
+void HPPA::OnXmotorSpeedSliderChanged(double speed)
+{
+ ui.xmotor_speed_lineEdit->setText(QString::number(speed));
+}
+
+void HPPA::OnXmotorLocationLineeditEditingFinished()
+{
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ ui.xmotor_location_slider->setValue(ui.xmotor_location_lineEdit->text().toDouble());
+
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), ui.ymotor_location_slider->value());
+
+ m_xMotor->MoveToLocation(ui.xmotor_location_slider->OriginalValue());
+}
+
+void HPPA::OnXmotorLocationSliderChanged(double location)
+{
+ ui.xmotor_location_lineEdit->setText(QString::number(location));
+}
+
+void HPPA::OnXmotorLocationSliderReleased()
+{
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
+ m_xMotor->MoveToLocation(ui.xmotor_location_slider->OriginalValue());
+
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), ui.ymotor_location_slider->value());
+}
+
+void HPPA::OnYmotorLocationLineeditEditingFinished()
+{
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ ui.ymotor_location_slider->setValue(ui.ymotor_location_lineEdit->text().toDouble());
+
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), ui.ymotor_location_slider->value());
+
+ m_yMotor->MoveToLocation(ui.ymotor_location_slider->OriginalValue());
+}
+
+void HPPA::OnYmotorLocationSliderChanged(double location)
+{
+ ui.ymotor_location_lineEdit->setText(QString::number(location));
+}
+
+void HPPA::OnYmotorLocationSliderReleased()
+{
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
+ m_yMotor->MoveToLocation(ui.ymotor_location_slider->OriginalValue());
+
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), ui.ymotor_location_slider->value());
+}
+
+void HPPA::ontestRangeOfMotor_x_y()
+{
+ //x
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ m_xMotor->SettingZeroLocation();//ƶ0λõĽӽأλΪ0
+ m_timerTestRangeOfxMotor->start(500);
+
+ //y
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ m_yMotor->SettingZeroLocation();
+ m_timerTestRangeOfyMotor->start(500);
+}
+
+void HPPA::ontimerTestRangeOfxMotor()
+{
+ if (isMotorConnected(m_xMotor))
+ {
+ std::cout << "x+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ return;
+ }
+
+
+ ByteBack MotorState = m_xMotor->GetState();
+ //std::cout << "xٶȣ" << MotorState.Speed << std::endl;
+
+
+ if (MotorState.Speed == 0 && MotorState.Location == 0)//λΪ0ĵط
+ {
+ std::cout << "ʼx+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+
+ m_xMotor->EnableMotro();
+ m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
+ m_xMotor->MoveMotar(true);//ƶ
+ }
+
+ if (MotorState.Speed == 0 && MotorState.Location != 0)//λĵط
+ {
+ m_xMotor->MoveToLocation(0);
+ m_timerTestRangeOfxMotor->stop();
+
+ double maxDistance = ui.xmotor_location_slider->getDistanceFromPulse(MotorState.Location);
+
+ //x̼¼ļԱʹ ÿζ̣˷ʱ
+
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryOfExe();
+ string xMotorRangeFile = directory + "\\xMotorRange";
+
+ FILE * motorRange = fopen(xMotorRangeFile.c_str(), "w+b");
+
+ fwrite(&maxDistance, sizeof(double), 1, motorRange);
+ fclose(motorRange);
+
+ ui.xmotor_location_slider->setMaximum(maxDistance);
+ ui.xmotor_max_location_label->setText(QString::number(ui.xmotor_location_slider->maximum()));
+
+ //sceneRectĿϵx
+ QRectF rect = ui.graphicsView->viewport()->rect();
+ widthScale = rect.width() / maxDistance;
+ ui.graphicsView->setSceneRect();
+ }
+}
+
+void HPPA::ontimerTestRangeOfyMotor()
+{
+ if (isMotorConnected(m_yMotor))
+ {
+ std::cout << "y+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ return;
+ }
+
+ ByteBack MotorState = m_yMotor->GetState();
+
+ if (MotorState.Speed == 0 && MotorState.Location == 0)//λΪ0ĵط
+ {
+ std::cout << "ʼy+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+
+ m_yMotor->EnableMotro();
+ m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor);
+ m_yMotor->MoveMotar(true);//ǰƶ
+ }
+
+ if (MotorState.Speed == 0 && MotorState.Location != 0)//λĵط
+ {
+ m_yMotor->MoveToLocation(0);
+ m_timerTestRangeOfyMotor->stop();
+
+ double maxDistance = ui.ymotor_location_slider->getDistanceFromPulse(MotorState.Location);
+
+ //y̼¼ļԱʹ ÿζ̣˷ʱ
+
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryOfExe();
+ string yMotorRangeFile = directory + "\\yMotorRange";
+
+ FILE * motorRange = fopen(yMotorRangeFile.c_str(), "w+b");
+ fwrite(&maxDistance, sizeof(double), 1, motorRange);
+ fclose(motorRange);
+
+ ui.ymotor_location_slider->setMaximum(maxDistance);
+ ui.ymotor_max_location_label->setText(QString::number(ui.ymotor_location_slider->maximum()));
+
+ //sceneRectĸ߶ϵy
+ QRectF rect = ui.graphicsView->viewport()->rect();
+ heightScale = rect.height() / maxDistance;
+ ui.graphicsView->setSceneRect();
+ }
+}
+
+void HPPA::onAddRecordLine_btn()
+{
+ //
+ ByteBack MotorState = m_yMotor->GetState();
+ double currentPosOfYmotor = ui.ymotor_location_slider->getDistanceFromPulse(MotorState.Location);
+ double maxRangeOfXmotro = ui.xmotor_location_slider->maximum();
+
+ //ȡѡе
+ int currentRow = ui.recordLine_tableWidget->currentRow();
+ std::cout << "currentRow" << currentRow << std::endl;
+
+ if (currentRow == -1)//ûѡʱ
+ {
+ int RowCount = ui.recordLine_tableWidget->rowCount();//Returns the number of rows. 1ʼ
+ ui.recordLine_tableWidget->insertRow(RowCount);//һУβǴ0ʼ
+
+ ui.recordLine_tableWidget->setItem(RowCount, 0, new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2)));
+ ui.recordLine_tableWidget->setItem(RowCount, 1, new QTableWidgetItem(QString::number(maxRangeOfXmotro, 10, 2)));
+ }
+ else
+ {
+ ui.recordLine_tableWidget->insertRow(currentRow + 1);//һУβǴ0ʼ
+
+ ui.recordLine_tableWidget->setItem(currentRow + 1, 0, new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2)));
+ ui.recordLine_tableWidget->setItem(currentRow + 1, 1, new QTableWidgetItem(QString::number(maxRangeOfXmotro, 10, 2)));
+ }
+}
+
+void HPPA::onRemoveRecordLine_btn()
+{
+ int rowIndex = ui.recordLine_tableWidget->currentRow();
+ if (rowIndex != -1)
+ ui.recordLine_tableWidget->removeRow(rowIndex);
+}
+
+void HPPA::onGenerateRecordLine_btn()
+{
+ //
+ double height = ui.height_lineEdit->text().toDouble();
+ double fov = ui.fov_lineEdit->text().toDouble();
+ double swath = (height * tan(fov / 2 * PI / 180)) * 2;//tanǻ
+ ui.swath_lineEdit->setText(QString::number(swath));
+
+
+ //ȡΧ
+ double xMotorRange = ui.xmotor_location_slider->maximum();
+ double yMotorRange = ui.ymotor_location_slider->maximum();
+
+
+ //ȷжɼߣʽnumberOfRecordLine_tmp * swath - repetitiveLengthnumberOfRecordLine_tmp - 1 = overallLength
+ double overallLength = yMotorRange + swath;
+ double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble() / 100;
+ double repetitiveLength = repetitiveRate * swath;
+ double offset = ui.offset_lineEdit->text().toDouble();
+
+ double numberOfRecordLine_tmp = (overallLength - repetitiveLength - offset) / (swath - repetitiveLength);
+ double tmp = numberOfRecordLine_tmp - (int)numberOfRecordLine_tmp;
+ int numberOfRecordLine;
+ double threshold = ui.LastLineThreshold_lineEdit->text().toDouble();//numberOfRecordLine_tmpΪСʱжǷһɼ
+ if (tmp > threshold)
+ {
+ numberOfRecordLine = (int)numberOfRecordLine_tmp + 1;
+ //std::cout << "ڣ" << threshold << std::endl;
+ }
+ else
+ {
+ numberOfRecordLine = (int)numberOfRecordLine_tmp;
+ }
+
+
+
+ //ȥtableWidgetе
+ int rowCount = ui.recordLine_tableWidget->rowCount();
+ for (size_t i = 0; i < rowCount; i++)
+ {
+ ui.recordLine_tableWidget->removeRow(0);
+ }
+
+
+ //tableWidgetУɼߣ
+ for (size_t i = 0; i < numberOfRecordLine; i++)
+ {
+ //һ
+ int RowCount = ui.recordLine_tableWidget->rowCount();
+ ui.recordLine_tableWidget->insertRow(RowCount);
+
+ //yPosition
+ if (tmp > threshold && i == numberOfRecordLine - 1)//һеyPosition
+ {
+ ui.recordLine_tableWidget->setItem(i, 0, new QTableWidgetItem(QString::number(yMotorRange, 10, 2)));
+ }
+ else
+ {
+ double x = swath * i - i * repetitiveLength + offset;
+ ui.recordLine_tableWidget->setItem(i, 0, new QTableWidgetItem(QString::number(x, 10, 2)));
+ }
+
+ //x˶λ ֵΪx
+ ui.recordLine_tableWidget->setItem(i, 1, new QTableWidgetItem(QString::number(xMotorRange, 10, 2)));
+
+ }
+
+}
+
+void HPPA::onDeleteRecordLine_btn()
+{
+ int rowCount = ui.recordLine_tableWidget->rowCount();
+ for (size_t i = 0; i < rowCount; i++)
+ {
+ ui.recordLine_tableWidget->removeRow(0);
+ }
+}
+
+void HPPA::onSaveRecordLine2File_btn()
+{
+ //ȷɼߴ
+ if (ui.recordLine_tableWidget->rowCount() <= 0)
+ {
+ QMessageBox::information(this, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ɹ켣"));
+ return;
+ }
+
+ double height = ui.height_lineEdit->text().toDouble();
+ double fov = ui.fov_lineEdit->text().toDouble();
+ double swath = ui.swath_lineEdit->text().toDouble();
+ double offset = ui.offset_lineEdit->text().toDouble();
+ double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble();
+ double LastLineThreshold = ui.LastLineThreshold_lineEdit->text().toDouble();
+
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryOfExe();
+
+ QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine File"),
+ QString::fromStdString(directory),
+ tr("RecordLineFile (*.RecordLine)"));
+
+ if (RecordLineFilePath.isEmpty())
+ {
+ return;
+ }
+
+ FILE * RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "wb+");
+
+ fwrite(&height, sizeof(double), 1, RecordLineFileHandle);
+ fwrite(&fov, sizeof(double), 1, RecordLineFileHandle);
+ fwrite(&swath, sizeof(double), 1, RecordLineFileHandle);
+ fwrite(&offset, sizeof(double), 1, RecordLineFileHandle);
+ fwrite(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
+ fwrite(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
+
+ double number = ui.recordLine_tableWidget->rowCount()*ui.recordLine_tableWidget->columnCount();
+ fwrite(&number, sizeof(double), 1, RecordLineFileHandle);
+
+ double *data = new double[number];
+ //double data[number];
+ for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
+ {
+ for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
+ {
+ data[i*ui.recordLine_tableWidget->columnCount() + j] = ui.recordLine_tableWidget->item(i, j)->text().toDouble();
+ }
+ }
+
+ fwrite(data, sizeof(double), number, RecordLineFileHandle);
+
+ fclose(RecordLineFileHandle);
+ delete[] data;
+
+ QMessageBox::information(this, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ɹ"));
+}
+
+void HPPA::onReadRecordLineFile_btn()
+{
+ //ļ
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryOfExe();
+ //string RecordLineFilePath = directory + "\\test.RecordLine";
+
+ QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine File"),
+ QString::fromStdString(directory),
+ tr("RecordLineFile (*.RecordLine)"));
+
+ if (RecordLineFilePath.isEmpty())
+ {
+ return;
+ }
+
+ FILE * RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "r");
+ double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number;
+
+ //ȡ
+ fread(&height, sizeof(double), 1, RecordLineFileHandle);
+ fread(&fov, sizeof(double), 1, RecordLineFileHandle);
+ fread(&swath, sizeof(double), 1, RecordLineFileHandle);
+ fread(&offset, sizeof(double), 1, RecordLineFileHandle);
+ fread(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
+ fread(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
+ fread(&number, sizeof(double), 1, RecordLineFileHandle);
+
+ double *data = new double[number];
+ for (size_t i = 0; i < number; i++)
+ {
+ fread(data + i, sizeof(double), 1, RecordLineFileHandle);
+ //std::cout << *(data + i) << std::endl;
+ }
+
+ //д
+ ui.height_lineEdit->setText(QString::number(height));
+ ui.fov_lineEdit->setText(QString::number(fov));
+ ui.swath_lineEdit->setText(QString::number(swath));
+ ui.offset_lineEdit->setText(QString::number(offset));
+ ui.repetitiveRate_lineEdit->setText(QString::number(repetitiveRate));
+ ui.LastLineThreshold_lineEdit->setText(QString::number(LastLineThreshold));
+
+
+ //tableWidgetӲɼ
+ //1ȥtableWidgetе
+ int rowCount = ui.recordLine_tableWidget->rowCount();
+ for (size_t i = 0; i < rowCount; i++)
+ {
+ ui.recordLine_tableWidget->removeRow(0);
+ }
+ //2Уɼߣ
+ int RecordLineCount = number / ui.recordLine_tableWidget->columnCount();
+ for (size_t i = 0; i < RecordLineCount; i++)
+ {
+ ui.recordLine_tableWidget->insertRow(0);
+
+ }
+ //3tableWidget
+ for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
+ {
+ for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
+ {
+ ui.recordLine_tableWidget->setItem(i, j, new QTableWidgetItem(QString::number(data[i*ui.recordLine_tableWidget->columnCount() + j], 10, 2)));
+ }
+ }
+
+ fclose(RecordLineFileHandle);
+ delete[] data;
+
+ QMessageBox::information(this, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ȡɹ"));
+
+}
+
+void HPPA::ontimerMoveXmotor()
+{
+ //std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << std::endl;
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ ByteBack MotorState = m_xMotor->GetState();
+
+ //xλ÷slider
+ if (MotorState.Speed != 0)
+ {
+ double newPos = ui.xmotor_location_slider->getDistanceFromPulse(MotorState.Location);
+
+ ui.xmotor_location_slider->setValue(newPos, false);
+ setImagerSimulationPos(newPos, ui.ymotor_location_slider->value());
+
+ QApplication::processEvents();
+ }
+
+ //ɼxﷵسʼλãʼɼǰ¼λãm_lXmotorLocationOfStartRecord
+ if (MotorState.Speed == 0 && MotorState.Location != m_lXmotorLocationOfStartRecord //xλôֵӽأ֡ûвɼ
+ || !m_Imager->getRecordControlState())//ֹͣɼҪϻصʼλã1ֹͣɼ2֡ɼˣﻹ˶
+ {
+ //ֹͣɼ
+ m_Imager->setRecordControlState(false);
+
+ //xﷵزɼǰλ
+ m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor);
+ m_xMotor->MoveToLocation(m_lXmotorLocationOfStartRecord);
+ }
+
+ //һɼߵIJɼ
+ if (MotorState.Speed == 0 && MotorState.Location == m_lXmotorLocationOfStartRecord//xﷵسʼλ
+ || MotorState.Location - m_lXmotorLocationOfStartRecord < 300)//ɼǰλΪ0ʱҪ
+ {
+ //ֹͣ
+ m_timerMoveXmotor->stop();
+
+ //ɼɵΪɫ
+ for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
+ {
+ ui.recordLine_tableWidget->item(m_numberOfRecording, j)->setBackgroundColor(QColor(0, 255, 0));
+ }
+
+ //ȷxsliderλ
+ double pos = ui.xmotor_location_slider->getDistanceFromPulse(m_lXmotorLocationOfStartRecord);
+ ui.xmotor_location_slider->setValue(pos, false);
+ setImagerSimulationPos(pos, ui.ymotor_location_slider->value());
+
+ //ִһ
+ m_ForLoopControl->m_boolRecordNextLine = true;
+ }
+
+ //std::cout << "ʼλΪ" << m_lXmotorLocationOfStartRecord << std::endl;
+ //std::cout << "Ϊ" << MotorState.Location - m_lXmotorLocationOfStartRecord << std::endl;
+}
+
+void HPPA::ontimerMoveYmotor()
+{
+ //std::cout << "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" << std::endl;
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ ByteBack MotorState = m_yMotor->GetState();
+
+ //yλ÷slider
+ if (MotorState.Speed != 0)
+ {
+ double newPos = ui.ymotor_location_slider->getDistanceFromPulse(MotorState.Location);
+ //std::cout << "yλã" << newPos << std::endl;
+
+ ui.ymotor_location_slider->setValue(newPos, false);
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), newPos);
+
+ QApplication::processEvents();
+ }
+ else if (MotorState.Speed == 0)
+ {
+ //ֹͣñ
+ m_timerMoveYmotor->stop();
+
+ //ȷysliderλ
+ double pos = ui.recordLine_tableWidget->item(m_numberOfRecording, 0)->text().toDouble();
+ ui.ymotor_location_slider->setValue(pos, false);
+ setImagerSimulationPos(ui.xmotor_location_slider->value(), pos);
+
+ //ʼɼyǰһɼߵ;Уֹͣɼ
+ if (m_RecordState % 2 == 0)
+ {
+ //
+ for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
+ {
+ ui.recordLine_tableWidget->item(m_numberOfRecording, j)->setBackgroundColor(QColor(240, 240, 240));
+ }
+
+ return;
+ }
+
+ //ƶx
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+ m_xMotor->EnableMotro();
+ m_lXmotorLocationOfStartRecord = m_xMotor->GetLocationNow();//¼ǰλ
+ m_xMotor->SettingSpeed(ui.xmotor_speed_slider->OriginalValue());//ʼɼʱùٶ ŵ㣺˲ɼʱٶȺٶ
+
+
+ double xMaxPositionTmp = ui.recordLine_tableWidget->item(m_numberOfRecording, 1)->text().toDouble();
+ long xMaxPosition = ui.xmotor_location_slider->getPositionPulse(xMaxPositionTmp);
+ m_xMotor->MoveToLocation(xMaxPosition);
+ m_timerMoveXmotor->start(500);
+
+
+ //ʼɼӰ
+ m_Imager->setFrameNumber(this->frame_number->text().toInt());
+
+ emit StartRecordSignal();//俪ʼɼź
+ }
+}
+
+void HPPA::onimagerSimulatorMove(int x, int y)
+{
+ if (isMotorConnected(m_xMotor))
+ {
+ return;
+ }
+
+ //std::cout << "xϵ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+
+ double xLocatioin = abs(x) / widthScale;//λΪcmʵ
+ ui.xmotor_location_slider->setValue(xLocatioin, false);
+
+ double xx = ui.xmotor_location_slider->OriginalValue();//λΪʵ
+ m_xMotor->MoveToLocation(xx);
+
+
+ if (isMotorConnected(m_yMotor))
+ {
+ return;
+ }
+
+ //std::cout << "yϵ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+
+ double yLocatioin = abs(y) / heightScale;//λΪcmʵ
+ ui.ymotor_location_slider->setValue(yLocatioin, false);
+
+ double yy = ui.ymotor_location_slider->OriginalValue();//λΪʵ
+
+ //std::cout << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" << std::endl;
+ m_yMotor->MoveToLocation(yy);
+ //std::cout << "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" << std::endl;
+
+}
+
+void HPPA::OnSendLogToCallClass(QString str)
+{
+ qDebug() << str;
+}
+
+void HPPA::onPlotRgbImage()
+{
+ //std::cout << "ʾƵ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ QPixmap pixmap = QPixmap::fromImage(m_RgbCamera->m_qImage);
+
+ int width = ui.cam_label->width();
+ int height = ui.cam_label->height();
+ QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); //
+
+
+ ui.cam_label->setPixmap(fitpixmap);
+}
+
+void HPPA::onCloseRgbCamera()
+{
+ //std::cout << "رƵ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ m_RgbCamera->CloseCamera();
+}
+
+void HPPA::onClearLabel()
+{
+ ui.cam_label->clear();
+ ui.cam_label->setText("closed");
+}
+
+void HPPA::onCopyFinished()
+{
+ this->setEnabled(true);
+}
+
+void HPPA::getRequest(QString str)
+{
+ QNetworkRequest request;
+ QNetworkAccessManager* naManager = new QNetworkAccessManager(this);
+ QMetaObject::Connection connRet = QObject::connect(naManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
+ Q_ASSERT(connRet);
+
+ request.setUrl(QUrl(str));
+ QNetworkReply* reply = naManager->get(request);
+}
+
+void HPPA::onLampPowerOpen_btn()//onLampPowerOpen_btn
+{
+ QString xx = "http://192.168.1.3/setshutter?Portname=3&Value=1";
+ getRequest(xx);
+}
+
+void HPPA::onLampPowerClose_btn()//onLampPowerClose_btn
+{
+ QString xx = "http://192.168.1.3/setshutter?Portname=3&Value=0";
+ getRequest(xx);
+}
+
+void HPPA::onMotorPowerOpen_btn()
+{
+ QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=1";
+ getRequest(xx);
+}
+
+void HPPA::onMotorPowerClose_btn()
+{
+ QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=0";
+ getRequest(xx);
+}
+
+void HPPA::requestFinished(QNetworkReply* reply) {
+ // ȡhttp״̬
+ QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+ if (statusCode.isValid())
+ qDebug() << "status code=" << statusCode.toInt();
+
+ QVariant reason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
+ if (reason.isValid())
+ qDebug() << "reason=" << reason.toString();
+
+ QNetworkReply::NetworkError err = reply->error();
+ if (err != QNetworkReply::NoError) {
+ qDebug() << "Failed: " << reply->errorString();
+ }
+ else {
+ // ȡ
+ qDebug() << reply->readAll();
+ }
+}
+
+void HPPA::onExit()
+{
+ this->close();
+}
+
+void HPPA::onconnect()
+{
+ if (m_Imager != nullptr)
+ {
+ //std::cout << "Ѿӣ" << std::endl;
+ return;
+ }
+
+ try
+ {
+ //ɼӰ̣߳߳вɼڲɼн濨https://www.cnblogs.com/xia-weiwen/p/10306089.html
+ m_RecordThread = new QThread();
+ m_Imager = new ResononImager();
+ m_Imager->moveToThread(m_RecordThread);
+ m_RecordThread->start();
+
+ m_Imager->connect_imager(frame_number->text().toInt());
+ m_Imager->setFileName2Save(m_FilenameLineEdit->text().toStdString());
+ connect(m_Imager, SIGNAL(PlotSignal()), this, SLOT(onPlotHyperspectralImageRgbImage()));
+ connect(m_Imager, SIGNAL(RecordFinishedSignal_WhenFrameNumberMeet()), this, SLOT(onRecordFinishedSignal_WhenFrameNumberMeet()));
+ connect(m_Imager, SIGNAL(RecordFinishedSignal_WhenFrameNumberNotMeet()), this, SLOT(onRecordFinishedSignal_WhenFrameNumberNotMeet()));
+ connect(m_Imager, SIGNAL(SpectralSignal(int)), this, SLOT(PlotSpectral(int)));
+ //connect(m_Imager, SIGNAL(testImagerStatus()), this, SLOT(testImagerStatus()));
+
+
+ //ļ
+ m_CopyFileThread = new QThread();
+ m_FileOperation = new FileOperation();
+ m_FileOperation->moveToThread(m_CopyFileThread);
+ m_CopyFileThread->start();
+ connect(this, SIGNAL(CopyFileThreadSignal(QString, QString)), m_FileOperation, SLOT(copyFile(QString, QString)));
+ connect(m_FileOperation, SIGNAL(CopyFinishedSignal()), this, SLOT(onCopyFinished()));
+
+ //״̬
+ m_TestImagerStausThread = new WorkerThread(m_Imager);
+
+
+
+ connect(this->ui.action_auto_exposure, SIGNAL(triggered()), this, SLOT(onAutoExposure()));
+ connect(this->ui.action_focus, SIGNAL(triggered()), this, SLOT(onFocus1()));
+ connect(this, SIGNAL(StartFocusSignal()), m_Imager, SLOT(focus()));
+ connect(this->ui.action_dark, SIGNAL(triggered()), this, SLOT(onDark()));
+ connect(this->ui.action_reference, SIGNAL(triggered()), this, SLOT(onReference()));
+
+ connect(this->ui.action_start_recording, SIGNAL(triggered()), this, SLOT(onStartRecordStep1()));
+ connect(this, SIGNAL(StartLoopSignal()), m_ForLoopControl, SLOT(startLoop()));
+ connect(this, SIGNAL(StartRecordSignal()), m_Imager, SLOT(start_record()));
+
+ connect(this->ui.actionOpenDirectory, SIGNAL(triggered()), this, SLOT(onActionOpenDirectory()));
+
+
+
+
+ connect(this->ui.framerate_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnFramerateLineeditEditingFinished()));
+ connect(this->ui.FramerateSlider, SIGNAL(valueChanged(double)), this, SLOT(OnFramerateSliderChanged(double)));
+ connect(this->ui.integratioin_time_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnIntegratioinTimeEditingFinished()));
+ connect(this->ui.IntegratioinTimeSlider, SIGNAL(valueChanged(double)), this, SLOT(OnIntegratioinTimeSliderChanged(double)));
+ connect(this->ui.gain_lineEdit, SIGNAL(editingFinished()), this, SLOT(OnGainEditingFinished()));
+ connect(this->ui.GainSlider, SIGNAL(valueChanged(double)), this, SLOT(OnGainSliderChanged(double)));
+
+
+ //ؼΪ +
+ frame_number->setEnabled(true);
+
+ ui.framerate_lineEdit->setEnabled(true);
+ ui.integratioin_time_lineEdit->setEnabled(true);
+ ui.gain_lineEdit->setEnabled(true);
+
+ ui.FramerateSlider->setEnabled(true);
+ ui.IntegratioinTimeSlider->setEnabled(true);
+ ui.GainSlider->setEnabled(true);
+
+ /*QRegExp rx("\\d{0,3}[1-9]$");
+ ui.framerate_lineEdit->setValidator(new QRegExpValidator(rx));
+ frame_number->setValidator(new QRegExpValidator(rx));
+
+ ui.integratioin_time_lineEdit->setValidator(new QRegExpValidator(rx));
+ ui.gain_lineEdit->setValidator(new QRegExpValidator(rx));*/
+
+ //ȡʾ
+ ui.framerate_lineEdit->setText(QString::number(m_Imager->get_framerate(), 10, 2));
+ ui.FramerateSlider->setValue(m_Imager->get_framerate(), true);
+ CalculateIntegratioinTimeRange();
+
+ ui.integratioin_time_lineEdit->setText(QString::number(m_Imager->get_integration_time(), 10, 2));
+ ui.IntegratioinTimeSlider->setValue(m_Imager->get_integration_time());
+
+ ui.gain_lineEdit->setText(QString::number(m_Imager->get_gain(), 10, 2));
+ ui.GainSlider->setValue(m_Imager->get_gain());
+ }
+ catch (...)
+ {
+ delete m_Imager;
+ m_Imager = nullptr;
+
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromLocal8Bit(""));
+ msgBox.exec();
+ }
+
+
+
+}
+
+void HPPA::testImagerStatus()
+{
+ m_TestImagerStausThread->start();
+}
+
+void HPPA::onAutoExposure()
+{
+ double ReturnedExposureTime = m_Imager->auto_exposure();
+
+ //Զعõֵʾ
+ ui.IntegratioinTimeSlider->setValue(ReturnedExposureTime, false);
+
+
+ ui.mainToolBar->widgetForAction(ui.action_auto_exposure)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+ //ui.mainToolBar->widgetForAction(ui.action_auto_exposure)->setStyleSheet("QLineEdit{background-color:rgb(255,255,255);}");
+}
+
+void HPPA::onFocus1()
+{
+ focusWindow* w = new focusWindow(this, m_Imager);
+ connect(w, SIGNAL(StartManualFocusSignal(int)), this, SLOT(onFocus2(int)));
+
+ //w->setModal(true);//ôΪģֻ̬ܲǰ
+ w->show();
+ w->exec();
+
+ //disconnect(w, SIGNAL(StartManualFocusSignal(int)), this, SLOT(onFocus2(int)));
+}
+
+void HPPA::onFocus2(int command)
+{
+ if (command == 1)
+ {
+ //Ӱʾ
+ QWidget * tabTmp = new QWidget();
+
+ QGridLayout *GridLayout = new QGridLayout();
+ GridLayout->addWidget(new ImageViewer(tabTmp));
+
+ tabTmp->setLayout(GridLayout);
+
+ ui.ImageViewerTabWidget->addTab(tabTmp, QString::fromLocal8Bit(""));
+
+ //ui.ImageViewerTabWidget->setCurrentIndex(trackNumber);
+ ui.ImageViewerTabWidget->setCurrentWidget(tabTmp);
+
+
+ //ʼ
+ emit StartFocusSignal();
+ }
+ else if (command == 0)
+ {
+ m_Imager->setFocusControlState(false);
+ }
+}
+
+void HPPA::onDark()
+{
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromLocal8Bit("ȷͷǸϣ"));
+ msgBox.exec();
+ m_Imager->record_dark();
+
+ ui.mainToolBar->widgetForAction(ui.action_dark)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+}
+
+void HPPA::onReference()
+{
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromLocal8Bit("ȷװȷ"));
+ msgBox.exec();
+ m_Imager->record_white();
+
+ ui.mainToolBar->widgetForAction(ui.action_reference)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+}
+
+void HPPA::onPlotHyperspectralImageRgbImage()
+{
+ //ȡͼؼ
+ QWidget* currentWidget = ui.ImageViewerTabWidget->widget(m_numberOfRecording);
+ QList currentImageViewer = currentWidget->findChildren();
+ currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//ʾѾɼ֡
+
+ //Ҫʾͼ--opencv汾
+ ImageProcessor imageProcessor;
+ //cv::Mat rgbImage(*m_Imager->getRgbImage()->m_matRgbImage, cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());//2022.3.18ع
+ cv::Mat rgbImage(*m_Imager->getMatRgbImage(), cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());
+ cv::Mat rgbImageStretched = imageProcessor.CStretch(rgbImage, 0.02);
+
+ //ڽʾͼ
+ currentImageViewer[0]->SetImage(&QPixmap::fromImage(imageProcessor.Mat2QImage(rgbImageStretched)));//ͼ
+
+ //Ҫʾͼ--qt汾
+ //QRect CuttedRect = m_Imager->getRgbImage()->m_QRgbImage->rect();//Ȼȡimagerect
+ //CuttedRect.setHeight(m_Imager->getFrameCounter() - 1);//ürect
+ //QImage CuttedImage = m_Imager->getRgbImage()->m_QRgbImage->copy(CuttedRect);
+
+ //currentImageViewer[0]->SetImage(&QPixmap::fromImage(CuttedImage));//ͼ
+}
+
+void HPPA::PlotSpectral(int state)
+{
+ if (state == 1)
+ {
+ //ʾӰ
+ QWidget* currentWidget = ui.ImageViewerTabWidget->currentWidget();
+ QList currentImageViewer = currentWidget->findChildren();
+ currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFocusFrameCounter());//ʾѾɼ֡
+
+ ImageProcessor imageProcessor;
+ //cv::Mat grayImage(*m_Imager->getRgbImage()->m_matFocusGrayImage, cv::Range::all(), cv::Range::all());//2022.3.18ع
+ cv::Mat grayImage(*m_Imager->getMatFocusGrayImage(), cv::Range::all(), cv::Range::all());
+ //currentImageViewer[0]->SetImage(&QPixmap::fromImage(imageProcessor.Mat2QImage(grayImage)));//ͼ
+
+ currentImageViewer[0]->SetImage(&QPixmap::fromImage(m_Imager->getQImageFocusGrayImage()));//ͼ
+
+ //ƹ
+ QLineSeries *series = new QLineSeries();
+ //series->clear();//////////////////////////////
+ int sampleCount = m_Imager->getSampleCount();
+ for (size_t i = 0; i < sampleCount; i++)
+ {
+ //mallocڴ÷1Ե
+ //series->append(i, m_Imager->buffer[i + 5 * 900]);
+ series->append(i, m_Imager->buffer[900 * 150 + i]);
+ }
+
+ QChart *chart = new QChart();
+ chart->legend()->hide();
+ chart->addSeries(series);
+ chart->createDefaultAxes();
+ //chart->setTitle("Simple line chart example");
+
+ m_chartView->setChart(chart);
+ }
+ else
+ {
+ //ıϵİť
+ }
+
+
+
+ ////ʾӰ
+ //QWidget* currentWidget = ui.ImageViewerTabWidget->currentWidget();
+ //QList currentImageViewer = currentWidget->findChildren();
+ //
+
+ //ImageProcessor imageProcessor;
+ //
+
+ ////ƹ
+ //QLineSeries *series = new QLineSeries();
+ ////series->clear();//////////////////////////////
+ //int sampleCount = m_Imager->getSampleCount();
+ //
+
+ //QChart *chart = new QChart();
+ //chart->legend()->hide();
+ //chart->addSeries(series);
+ //chart->createDefaultAxes();
+ ////chart->setTitle("Simple line chart example");
+
+ //m_chartView->setChart(chart);
+
+ //while (state)
+ //{
+ // currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFocusFrameCounter());//ʾѾɼ֡
+ // cv::Mat grayImage(*m_Imager->getMatFocusGrayImage(), cv::Range::all(), cv::Range::all());
+ // currentImageViewer[0]->SetImage(&QPixmap::fromImage(imageProcessor.Mat2QImage(grayImage)));//ͼ
+
+ // for (size_t i = 0; i < sampleCount; i++)
+ // {
+ // //mallocڴ÷1Ե
+ // //series->append(i, m_Imager->buffer[i + 5 * 900]);
+ // series->append(i, m_Imager->buffer[900 * 150 + i]);
+ // }
+ // std::cout << "-----------------------------------------------" << std::endl;
+ //}
+
+}
+
+void HPPA::onRecordFinishedSignal_WhenFrameNumberMeet()
+{
+ std::cout << "ֹͣɼԭ֡ɼˡ" << std::endl;
+}
+
+void HPPA::onRecordFinishedSignal_WhenFrameNumberNotMeet()
+{
+ std::cout << "ֹͣɼԭ1֡ûвɼʱﵽλã2ֶֹͣɼ" << std::endl;
+}
+
+ForLoopControl::ForLoopControl()
+{
+
+}
+
+ForLoopControl::~ForLoopControl()
+{
+
+}
+
+void ForLoopControl::setLoopCount(int loopCount)
+{
+ m_loopCount = loopCount;
+}
+
+int ForLoopControl::getLoopCount() const
+{
+ return m_loopCount;
+}
+
+void ForLoopControl::startLoop()
+{
+ //std::cout << "" << m_loopCount << "ѭ" << std::endl;
+ for (size_t i = 0; i < m_loopCount; i++)
+ {
+ //std::cout << "" << i << "ѭ" << std::endl;
+
+ emit recordSignal(i);
+
+ m_boolRecordNextLine = false;
+ m_boolQuitLoop = false;
+ while (!m_boolRecordNextLine)
+ {
+ Sleep(500);
+
+ if (m_boolQuitLoop)
+ {
+ break;
+ }
+ }
+
+ if (m_boolQuitLoop)
+ {
+ break;
+ }
+ }
+
+ if (m_boolQuitLoop == false)
+ {
+ emit recordSignal(-1);
+ }
+ else if (m_boolQuitLoop == true)
+ {
+ emit recordSignal(-2);
+ }
+
+ //std::cout << "˳ѭ" << std::endl;
+}
+
+WorkerThread3::WorkerThread3(CFocusMotorControl * ctrlFocusMotor)
+{
+ m_ctrlFocusMotor = ctrlFocusMotor;
+}
+
+void WorkerThread3::run()
+{
+ m_ctrlFocusMotor->StartAutoFocus(820, 910, 20, 2);
+
+ emit AutoFocusFinishedSignal();
+}
\ No newline at end of file
diff --git a/HPPA/HPPA.h b/HPPA/HPPA.h
new file mode 100644
index 0000000..3384431
--- /dev/null
+++ b/HPPA/HPPA.h
@@ -0,0 +1,324 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "ui_HPPA.h"
+#include "resononImager.h"
+#include "ImageViewer.h"
+#include "vincecontrol.h"
+#include "ImagerPositionSimulation.h"
+#include "fileOperation.h"
+#include "RgbCameraOperation.h"
+#include "imageProcessor.h"
+
+#include "focusWindow.h"
+
+#define PI 3.1415926
+
+QT_CHARTS_USE_NAMESPACE//QChartView ʹ ҪӺ꣬ ʹ
+
+class WorkerThread : public QThread
+{
+ Q_OBJECT
+private:
+
+
+public:
+ ResononImager *m_Imager;
+
+ WorkerThread(ResononImager * Imager)
+ {
+ m_Imager = Imager;
+ }
+
+ //void run() override
+ //{
+ // while (true)
+ // {
+ // try
+ // {
+ // //double x = m_Imager->get_framerate();
+ //
+ // //double x = m_Imager->m_ResononImager.get_framerate();
+ // int x = m_Imager->m_ResononImager.get_band_count();
+
+ // std::cout << "slopeΪ" << x << std::endl;
+ // }
+ // catch (std::runtime_error *e)//CException *e
+ // {
+ // std::cout << "Ͽӣ" << e->what() << std::endl;
+ // }
+ // Sleep(1000);
+ // }
+
+ // QString result;
+ // emit resultReady(result);
+ //}
+
+signals:
+ void resultReady(const QString &s);
+};
+
+class WorkerThread3 : public QThread
+{
+ Q_OBJECT
+private:
+
+
+public:
+ WorkerThread3(CFocusMotorControl * ctrlFocusMotor);
+ CFocusMotorControl *m_ctrlFocusMotor;
+
+protected:
+ void run();
+
+signals:
+ void AutoFocusFinishedSignal();
+};
+
+
+class myClocks : public QThread
+{
+ Q_OBJECT
+public:
+ myClocks(QObject *parent = 0);
+public:
+ void setCallback(void(*func)(QString));
+
+protected:
+ virtual void run();
+
+private:
+ std::function m_func;
+signals:
+ void threadSignal(QString s);
+};
+
+
+class ForLoopControl :public QObject
+{
+ Q_OBJECT
+
+public:
+ ForLoopControl();
+ ~ForLoopControl();
+
+ void setLoopCount(int loopCount);
+ int getLoopCount() const;
+
+ bool m_boolRecordNextLine;
+ bool m_boolQuitLoop;
+
+protected:
+private:
+ int m_loopCount;
+
+
+public slots:
+ void startLoop();
+
+signals:
+ //Ӱźţ
+ //źŷֵʱintֵòɼڼɼˣ
+ //źŷ为ֵʱ-1ɼɣֶֹɼ-2ֶֹɼ
+ void recordSignal(int);
+};
+
+class HPPA : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ HPPA(QWidget *parent = Q_NULLPTR);
+ ~HPPA();
+
+ void CalculateIntegratioinTimeRange();//ͨ֡ʼʱ䷶Χsliderֵ
+
+ WorkerThread * m_TestImagerStausThread;//״̬߳
+
+private:
+ Ui::HPPAClass ui;
+ QLineEdit * frame_number;
+ QLineEdit * m_FilenameLineEdit;
+ QLabel * xmotor_state_label1;
+ QLabel * ymotor_state_label1;
+
+ ForLoopControl * m_ForLoopControl;
+ ResononImager * m_Imager;//
+
+ int m_RecordState;//ɼ
+
+ QThread * m_ForLoopControlThread;//
+ QThread * m_RecordThread;//Ӱɼ߳
+ QThread * m_RgbCameraThread;//rgbȡͼ߳
+ QThread * m_CopyFileThread;//Ӱļ߳
+ FileOperation * m_FileOperation;
+
+ QChartView * m_chartView;
+
+ //QLineSeries *series;
+ //QChart *chart;
+
+ //
+ VinceControl *m_yMotor;
+ VinceControl *m_xMotor;
+
+ long m_lXmotorLocationOfStartRecord;//ʼɼǰxλ
+ long m_lYmotorLocationOfStartRecord;//ʼɼǰyλ
+
+ unsigned long m_lManualSpeedOfXMotor;//X˶ٶȣͨʾֶ+X̲ʹٶȣ12000*0.00052734375=6.328125cm/s
+ unsigned long m_lManualSpeedOfYMotor;//YXΪͬĻYлеװãʵYٶ=Xٶ/5
+
+ int m_xConnectCount;//ʾ״̬0Ͽ1Ͽһӡ1ʾӣΪ״̬Ϊ1ʱĵ
+ int m_yConnectCount;
+
+ QTimer *m_timerMoveXmotor;
+ QTimer *m_timerMoveYmotor;
+
+ QTimer *m_timerTestRangeOfxMotor;//ڲx
+ QTimer *m_timerTestRangeOfyMotor;//ڲy
+ QTimer *m_timerLocationFeedBackOfMotor_x_y;//ֶƣx/y˶ʱλԶķslider
+ QTimer *m_timerYmotorLocationFeedBackAfterRecord;//ɼӰɺλʵʱصslider
+
+ QString operateWidget;//ǰĿؼ
+
+ //
+ bool isMotorConnected(VinceControl *motor);//жǷϿϿtruefalse
+ void SetXMotorWidgetEnable(bool enable);
+ void SetYMotorWidgetEnable(bool enable);
+ void setMotorRange();//̷Χ
+
+ //ģλ
+ double widthScale;//QGraphicsViewviewportʵwidthScale = rect.width() / maxDistance;
+ double heightScale;//QGraphicsViewviewportߺʵheightScale = rect.height() / maxDistance;
+ void setImagerSimulationPos(double x, double y);//ui.graphicsView->imager->setPos(x, y);
+
+ //ɼ߹滮
+ int m_numberOfRecording;//ʾui.recordLine_tableWidgetеĵڼ ڲɼڼ
+
+ //
+ int m_TabWidgetCurrentIndex;//ֶѡTabWidgetıǩʱ¼仯tab index
+ RgbCameraOperation *m_RgbCamera;
+
+ void getRequest(QString str);
+
+public Q_SLOTS:
+ void onPlotHyperspectralImageRgbImage();
+ void PlotSpectral(int state);
+ void onRecordFinishedSignal_WhenFrameNumberMeet();
+ void onRecordFinishedSignal_WhenFrameNumberNotMeet();
+
+ void onExit();
+ void onconnect();//
+ void testImagerStatus();//ȡ״̬Ƿ
+ void onAutoExposure();
+ void onFocus1();
+ void onFocus2(int command);
+ void onDark();
+ void onReference();
+ void onStartRecordStep1();
+ void onStartRecordStep2(int lineNumber);
+ void onCreateTab(int trackNumber);
+ void onTabWidgetCurrentChanged(int index);
+ void onActionOpenDirectory();
+
+ void OnFramerateLineeditEditingFinished();//
+ void OnFramerateSliderChanged(double framerate);//
+
+ void OnIntegratioinTimeEditingFinished();//
+ void OnIntegratioinTimeSliderChanged(double IntegratioinTime);//
+ void OnGainEditingFinished();//
+ void OnGainSliderChanged(double Gain);//
+
+ void onLeftMouseButtonPressed(int x, int y);//ӰԪʾ
+
+
+ //
+ void timerEvent(QTimerEvent *event);
+
+
+ void onxMotorLeft();
+ void onxMotorRight();
+ void onxMotorStop();
+
+ void onyMotorForward();
+ void onyMotorBackward();
+ void onyMotorStop();
+
+ void onMotorReset();
+
+ void OnXmotorSpeedEditingFinished();
+
+ void ontimerLocationFeedBackOfMotor_x_y();
+ void ontimerYmotorLocationFeedBackAfterRecord();
+
+ void OnXmotorSpeedLineeditEditingFinished();
+ void OnXmotorSpeedSliderChanged(double speed);
+ void OnXmotorLocationLineeditEditingFinished();
+ void OnXmotorLocationSliderChanged(double location);
+ void OnXmotorLocationSliderReleased();
+
+
+ void OnYmotorLocationLineeditEditingFinished();
+ void OnYmotorLocationSliderChanged(double location);
+ void OnYmotorLocationSliderReleased();
+
+
+
+ void ontestRangeOfMotor_x_y();
+ void ontimerTestRangeOfxMotor();
+ void ontimerTestRangeOfyMotor();
+
+ //ɼ߹滮
+ void onAddRecordLine_btn();
+ void onRemoveRecordLine_btn();
+ void onGenerateRecordLine_btn();
+ void onDeleteRecordLine_btn();
+ void onSaveRecordLine2File_btn();
+ void onReadRecordLineFile_btn();
+
+ void ontimerMoveXmotor();
+ void ontimerMoveYmotor();
+
+ //
+ void onimagerSimulatorMove(int x, int y);
+ void OnSendLogToCallClass(QString str);
+
+ void onPlotRgbImage();
+ void onCloseRgbCamera();
+ void onClearLabel();
+
+ void onCopyFinished();
+
+ void onLampPowerOpen_btn();
+ void onLampPowerClose_btn();
+
+ void onMotorPowerOpen_btn();
+ void onMotorPowerClose_btn();
+
+ void requestFinished(QNetworkReply* reply);
+
+signals:
+ void StartFocusSignal();
+ void StartLoopSignal();
+ void StartRecordSignal();
+ void CopyFileThreadSignal(QString, QString);
+
+};
+
diff --git a/HPPA/HPPA.ico b/HPPA/HPPA.ico
new file mode 100644
index 0000000..e76ecbc
Binary files /dev/null and b/HPPA/HPPA.ico differ
diff --git a/HPPA/HPPA.qrc b/HPPA/HPPA.qrc
new file mode 100644
index 0000000..5285ca9
--- /dev/null
+++ b/HPPA/HPPA.qrc
@@ -0,0 +1,5 @@
+
+
+ HPPA.ico
+
+
diff --git a/HPPA/HPPA.rc b/HPPA/HPPA.rc
new file mode 100644
index 0000000..510337b
Binary files /dev/null and b/HPPA/HPPA.rc differ
diff --git a/HPPA/HPPA.ui b/HPPA/HPPA.ui
new file mode 100644
index 0000000..8941a7a
--- /dev/null
+++ b/HPPA/HPPA.ui
@@ -0,0 +1,1765 @@
+
+
+ HPPAClass
+
+
+
+ 0
+ 0
+ 1136
+ 605
+
+
+
+ Hyper Plant Phenotypic Analysis
+
+
+
+ :/HPPA/HPPA.ico:/HPPA/HPPA.ico
+
+
+ background-color: rgb(240, 240, 240);
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ false
+
+
+ border-size:1px;
+
+
+
+
+
+
-
+
+
+ 打开摄像头
+
+
+
+ -
+
+
+ 关闭摄像头
+
+
+
+ -
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Plain
+
+
+ 摄像头关闭!
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::Box
+
+
+ QFrame::Raised
+
+
+
+
+
+
+
+
+ 1
+ 0
+
+
+
+ 0
+
+
+
+ Tab 1
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+
+
+
+ Tab 2
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ background-color: rgb(240, 240, 240);
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Vertical
+
+
+
+
+ 0
+ 1
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ 0
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ 3
+
+
+
+ camera
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 16777215
+
+
+
+ 帧率
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 100
+ 16777215
+
+
+
+ 积分时间
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+
+ 100
+ 16777215
+
+
+
+ gain
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ background-color: rgb(255, 255, 255);
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ stage
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QGroupBox{border:none}
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 19
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 19
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ ↓0
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 19
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ →
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 马达量程检测
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 66
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ ←0
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 归零
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ ↑
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ #QGroupBox{border:none}
+
+
+ x马达
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 20
+
+
+
+
+ 100
+ 20
+
+
+
+ 速度
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+ 1
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 17
+
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 37
+ 17
+
+
+
+
+ -
+
+
+
+ 16777215
+ 33
+
+
+
+ 3
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+
+ 100
+ 20
+
+
+
+ 位置
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 20
+
+
+
+
+ 16777215
+ 33
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 14
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 17
+
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 128
+ 17
+
+
+
+
+ -
+
+
+ nan
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ y马达
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+ 位置
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 21
+
+
+
+
+ 16777215
+ 33
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 146
+ 20
+
+
+
+
+ -
+
+
+ nan
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+ 轨迹规划
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 高度
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 100
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ 生成轨迹
+
+
+
+ -
+
+
+ 保存轨迹
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 视场角
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 17.6
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ 删除轨迹
+
+
+
+ -
+
+
+ 读取轨迹
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 偏移
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 幅宽
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+
+ -
+
+
+ 添加
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 重复率(%)
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+ false
+
+
+
+ -
+
+
+ 阈值
+
+
+
+ -
+
+
+ 0.7
+
+
+ Qt::AlignCenter
+
+
+ false
+
+
+
+ -
+
+
+ 移除
+
+
+
+
+
+ -
+
+
+
+
+
+
+ 电源控制
+
+
+ -
+
+
-
+
+
+ 卤素灯
+
+
+
+ -
+
+
+ 打开
+
+
+
+ -
+
+
+ 关闭
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+ 马 达
+
+
+
+ -
+
+
+ 打开
+
+
+
+ -
+
+
+ 关闭
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 254
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+ TopToolBarArea
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ exit
+
+
+
+
+ open
+
+
+ open
+
+
+
+
+ preference...
+
+
+
+
+ 采集
+
+
+
+
+ 调焦
+
+
+
+
+ 曝光
+
+
+
+
+ 暗电流
+
+
+
+
+ 白板
+
+
+
+
+ 连接相机
+
+
+
+
+ 打开文件夹
+
+
+
+
+ Pika L
+
+
+
+
+ Corning 410
+
+
+
+
+ Pika XC2
+
+
+
+
+
+
+ QDoubleSlider
+ QSlider
+
+
+
+ QMotorDoubleSlider
+ QSlider
+
+
+
+ ImagerPositionSimulation
+ QGraphicsView
+ imagerpositionsimulation.h
+
+
+ QYMotorDoubleSlider
+ QSlider
+
+
+
+
+
+
+
+
diff --git a/HPPA/HPPA.vcxproj b/HPPA/HPPA.vcxproj
new file mode 100644
index 0000000..fbc1abd
--- /dev/null
+++ b/HPPA/HPPA.vcxproj
@@ -0,0 +1,166 @@
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {E7886664-B69E-4781-BCBE-804574FB4033}
+ QtVS_v304
+ $(MSBuildProjectDirectory)\QtMsBuild
+ 10.0.17763.0
+
+
+
+ Application
+ v141
+
+
+ Application
+ v141
+
+
+
+
+
+
+ qt5.9.0_vs2017
+ core;network;gui;widgets;serialport;websockets;charts
+ debug
+
+
+ qt5.9.0_vs2017
+ core;network;gui;widgets;serialport;websockets;charts
+ release
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D:\software\Qt5.9.0\5.9\msvc2017_64\include;D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_vs2017\HPPA\HPPA;$(IncludePath)
+ D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\software\Qt5.9.0\5.9\msvc2017_64\lib;$(LibraryPath)
+
+
+ D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_vs2017\HPPA\HPPA;$(IncludePath)
+ D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\software\Qt5.9.0\5.9\msvc2017_64\lib;$(LibraryPath)
+
+
+
+ opencv_world3411.lib;opencv_world3411d.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5SerialPortd.lib;Qt5WebSocketsd.lib;Qt5Networkd.lib;Qt5Chartsd.lib;AutoFocus_InspireLinearMotor_DLL.lib;%(AdditionalDependencies)
+
+
+ _AMD64_;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+
+
+
+
+ opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5SerialPort.lib;Qt5WebSockets.lib;Qt5Network.lib;Qt5Charts.lib;AutoFocus_InspireLinearMotor_DLL.lib;%(AdditionalDependencies)
+
+
+
+
+ true
+ true
+ ProgramDatabase
+ Disabled
+ MultiThreadedDebugDLL
+
+
+ Windows
+ true
+
+
+
+
+ true
+ true
+ None
+ MaxSpeed
+ MultiThreadedDLL
+
+
+ Windows
+ false
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HPPA/HPPA.vcxproj.filters b/HPPA/HPPA.vcxproj.filters
new file mode 100644
index 0000000..6be9d8e
--- /dev/null
+++ b/HPPA/HPPA.vcxproj.filters
@@ -0,0 +1,153 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {99349809-55BA-4b9d-BF79-8FDBB0286EB3}
+ ui
+
+
+ {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}
+ ts
+
+
+
+
+ Resource Files
+
+
+ Form Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Form Files
+
+
+
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/HPPA/ImageReaderWriter.cpp b/HPPA/ImageReaderWriter.cpp
new file mode 100644
index 0000000..eebc154
--- /dev/null
+++ b/HPPA/ImageReaderWriter.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+#include
+
+#include "ImageReaderWriter.h"
+
+
+
+ImageReaderWriter::ImageReaderWriter(const char * fileName)
+{
+ GDALAllRegister();
+ m_poDataset = (GDALDataset *)GDALOpen(fileName, GA_ReadOnly);
+ if (m_poDataset == NULL)
+ {
+ std::cout << "Ӱʧܣ" << std::endl;
+ return;
+ }
+
+ //ȡӰϢ
+ m_DataType = m_poDataset->GetRasterBand(1)->GetRasterDataType();
+ m_iBands = m_poDataset->GetRasterCount();
+ m_iXCount = m_poDataset->GetRasterXSize();
+ m_iYCount = m_poDataset->GetRasterYSize();
+
+}
+
+ImageReaderWriter::ImageReaderWriter()
+{
+
+}
+
+float * ImageReaderWriter::ReadImage(int nXOff, int nYOff, int nXSize, int nYSize)
+{
+ int xBuff = nXSize;
+ int yBuff = nYSize;
+
+
+ if (m_DataType == GDT_Byte)
+ {
+ unsigned char *pDataBuffer = (unsigned char*)CPLMalloc(sizeof(unsigned int)*(1)*(1)*(m_iBands));//unsigned char=BYTE
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(unsigned char));
+ }
+ else if (m_DataType == GDT_UInt16)
+ {
+ //WORD *pDataBuffer = new WORD[1 * 1 * m_iBands];//WORD=unsigned short
+ //memset(pDataBuffer, 0, 1 * 1 * m_iBands*sizeof(WORD));
+
+ float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
+
+ CPLErr status = m_poDataset->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pDataBuffer, xBuff, yBuff, GDT_Float32, m_iBands, NULL, 0, 0, 0); //ȸߺ
+
+ if (status != CE_None)
+ {
+ std::cout << "ȡӰʧܣ" << std::endl;
+ return 0;
+ }
+
+ /*for (size_t i = 0; i < m_iBands; i++)
+ {
+ std::cout << *pDataBuffer << std::endl;
+ pDataBuffer++;
+ }*/
+
+ return pDataBuffer;
+ }
+ else if (m_DataType == GDT_UInt32)
+ {
+ unsigned int *pDataBuffer = (unsigned int*)CPLMalloc(sizeof(unsigned int)*(1)*(1)*(m_iBands));
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(unsigned int));
+ }
+ else if (m_DataType == GDT_Float32)
+ {
+ float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
+ }
+
+}
+
+int ImageReaderWriter::getXCount() const
+{
+ return m_iXCount;
+}
+
+int ImageReaderWriter::getyCount() const
+{
+ return m_iYCount;
+}
diff --git a/HPPA/ImageReaderWriter.h b/HPPA/ImageReaderWriter.h
new file mode 100644
index 0000000..cbf687f
--- /dev/null
+++ b/HPPA/ImageReaderWriter.h
@@ -0,0 +1,28 @@
+#ifndef IMAGE_READER_WRITER
+#define IMAGE_READER_WRITER
+#include "stdafx.h"
+#include "gdal_priv.h"
+#include "cpl_conv.h"
+
+class ImageReaderWriter
+{
+public:
+ ImageReaderWriter();
+ ImageReaderWriter(const char * fileName);
+ float * ReadImage(int nXOff, int nYOff, int nXSize, int nYSize);
+ //void WriteImage();
+
+ int getXCount() const;
+ int getyCount() const;
+
+
+protected:
+private:
+ GDALDataset *m_poDataset;
+ GDALDataType m_DataType;
+
+ int m_iBands;
+ int m_iXCount;
+ int m_iYCount;
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/ImageViewer.cpp b/HPPA/ImageViewer.cpp
new file mode 100644
index 0000000..ce71e03
--- /dev/null
+++ b/HPPA/ImageViewer.cpp
@@ -0,0 +1,227 @@
+#include "stdafx.h"
+#include
+
+#include
+#include
+
+#include "ImageViewer.h"
+
+
+#define VIEW_CENTER viewport()->rect().center()
+#define VIEW_WIDTH viewport()->rect().width()
+#define VIEW_HEIGHT viewport()->rect().height()
+
+
+ImageViewer::ImageViewer(QWidget* pParent) :QGraphicsView(pParent)
+{
+ m_qtGraphicsScene = new QGraphicsScene(this);
+ this->setScene(m_qtGraphicsScene);
+
+ m_framNumberLabel = new QLabel(this);
+ m_framNumberLabel->setAlignment(Qt::AlignHCenter);
+ m_framNumberLabel->setAlignment(Qt::AlignVCenter);
+
+ QFont ft;
+ ft.setPointSize(14);
+ m_framNumberLabel->setFont(ft);
+ m_framNumberLabel->setText("0");
+
+
+ m_GraphicsPixmapItemHandle = nullptr;
+
+ m_scale = 1.0;
+ m_zoomDelta = 0.1;
+ m_translateSpeed = 1.0;
+ m_bMouseTranslate = false;
+
+
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
+
+ImageViewer::~ImageViewer()
+{
+
+}
+
+void ImageViewer::DisplayFrameNumber(int frameNumber)
+{
+ m_framNumberLabel->setText(QString::number(frameNumber));
+ m_framNumberLabel->adjustSize();
+}
+
+void ImageViewer::SetImage(QPixmap *image)
+{
+ if (!HasImage())
+ {
+ m_GraphicsPixmapItemHandle = m_qtGraphicsScene->addPixmap(*image);
+ }
+ else
+ {
+ m_GraphicsPixmapItemHandle->setPixmap(*image);
+ }
+
+ setSceneRect(QRectF(image->rect()));
+
+}
+
+bool ImageViewer::HasImage()
+{
+ if (m_GraphicsPixmapItemHandle == nullptr)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+void ImageViewer::wheelEvent(QWheelEvent *event)
+{
+ //qDebug() << "---------------+++++++++++++++++++++++++++++++++++++++++++++++++++ ";
+ if (true)//HasImage()
+ {
+ //ΧŴhttps://blog.csdn.net/GoForwardToStep/article/details/77035287?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
+ // ȡǰviewλ;
+ QPointF cursorPoint = event->pos();
+ // ȡǰsceneλ;
+ QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
+
+ // ȡviewĿ;
+ qreal viewWidth = this->viewport()->width();
+ qreal viewHeight = this->viewport()->height();
+
+ // ȡǰλ൱viewСĺݱ;
+ qreal hScale = cursorPoint.x() / viewWidth;
+ qreal vScale = cursorPoint.y() / viewHeight;
+
+
+ // ֵĹ
+ QPoint scrollAmount = event->angleDelta();
+ // ֵʾԶʹ߷ŴֵʾʹС
+ scrollAmount.y() > 0 ? zoomIn() : zoomOut();
+
+
+ // sceneתΪŴС;
+ QPointF viewPoint = this->matrix().map(scenePos);
+ // ͨviewŴСչʾsceneλ;
+ horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
+ verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
+ }
+
+ QGraphicsView::wheelEvent(event);
+}
+
+void ImageViewer::scaling(qreal scaleFactor)
+{
+ //qDebug() << this->sceneRect();
+ scale(scaleFactor, scaleFactor);
+}
+
+void ImageViewer::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button()==Qt::LeftButton)
+ {
+ m_bMouseTranslate = true;
+ m_lastMousePos = event->pos();
+
+ //qDebug() << mapToScene(m_lastMousePos);
+
+ emit leftMouseButtonPressed(mapToScene(m_lastMousePos).x(), mapToScene(m_lastMousePos).y());
+ }
+
+
+ //If you do not perform all the necessary work in your implementation of the virtual function, you may need to call the base class's implementation.
+ QGraphicsView::mousePressEvent(event);
+}
+
+void ImageViewer::mouseMoveEvent(QMouseEvent *event)
+{
+ if (m_bMouseTranslate){
+ QPointF mouseDelta = mapToScene(event->pos()) - mapToScene(m_lastMousePos);
+ translate(mouseDelta);
+ }
+
+ m_lastMousePos = event->pos();
+ QGraphicsView::mousePressEvent(event);
+}
+
+void ImageViewer::mouseReleaseEvent(QMouseEvent *event)
+{
+ m_bMouseTranslate = false;
+ QGraphicsView::mouseReleaseEvent(event);
+}
+
+void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ QGraphicsView::mouseDoubleClickEvent(event);
+}
+
+void ImageViewer::zoomIn()
+{
+ zoom(1 + m_zoomDelta);
+}
+
+void ImageViewer::zoomOut()
+{
+ zoom(1 - m_zoomDelta);
+}
+
+void ImageViewer::zoom(float scaleFactor)
+{
+ // ֹС
+ qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
+ if (factor < 0.07 || factor > 100)
+ return;
+
+ scale(scaleFactor, scaleFactor);
+ m_scale *= scaleFactor;
+}
+
+void ImageViewer::translate(QPointF delta)
+{
+ // ݵǰ zoom ƽ
+ delta *= m_scale;
+ delta *= m_translateSpeed;
+
+ ////1
+ //scene()->setSceneRect(scene()->sceneRect().x() - delta.x(), scene()->sceneRect().y() - delta.y(),
+ // scene()->sceneRect().width(), scene()->sceneRect().height());
+ //scene()->update();
+
+ //2
+ // view µĵΪêλ scene
+ setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+ QPoint newCenter(VIEW_WIDTH / 2 - delta.x(), VIEW_HEIGHT / 2 - delta.y());
+ centerOn(mapToScene(newCenter));
+
+ // scene view ĵΪê
+ setTransformationAnchor(QGraphicsView::AnchorViewCenter);
+}
+
+void ImageViewer::setTranslateSpeed(qreal speed)
+{
+ // ٶȷΧ
+ Q_ASSERT_X(speed >= 0.0 && speed <= 2.0,
+ "InteractiveView::setTranslateSpeed", "Speed should be in range [0.0, 2.0].");
+ m_translateSpeed = speed;
+}
+
+qreal ImageViewer::translateSpeed() const
+{
+ return m_translateSpeed;
+}
+
+void ImageViewer::setZoomDelta(qreal delta)
+{
+ // Χ
+ Q_ASSERT_X(delta >= 0.0 && delta <= 1.0,
+ "InteractiveView::setZoomDelta", "Delta should be in range [0.0, 1.0].");
+ m_zoomDelta = delta;
+}
+
+qreal ImageViewer::zoomDelta() const
+{
+ return m_zoomDelta;
+}
diff --git a/HPPA/ImageViewer.h b/HPPA/ImageViewer.h
new file mode 100644
index 0000000..792817d
--- /dev/null
+++ b/HPPA/ImageViewer.h
@@ -0,0 +1,58 @@
+#ifndef IMAGE_VIEWER
+#define IMAGE_VIEWER
+
+#include "QGraphicsView"
+#include "qlabel.h"
+class ImageViewer :public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ ImageViewer(QWidget* pParent = NULL);
+ ~ImageViewer();
+
+
+ void DisplayFrameNumber(int frameNumber);
+
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+
+ void SetImage(QPixmap *image);
+ bool HasImage();
+
+ void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+ void scaling(qreal scaleFactor);
+
+ void zoomIn(); // Ŵ
+ void zoomOut(); // С
+ void zoom(float scaleFactor); // - scaleFactorŵı
+ void translate(QPointF delta); // ƽ
+
+ // ƽٶ
+ void setTranslateSpeed(qreal speed);
+ qreal translateSpeed() const;
+
+ // ŵ
+ void setZoomDelta(qreal delta);
+ qreal zoomDelta() const;
+protected:
+ QGraphicsScene *m_qtGraphicsScene;
+private:
+ QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
+ QLabel *m_framNumberLabel;//ʾʵʱɼ֡
+
+
+ qreal m_translateSpeed; // ƽٶ
+ qreal m_zoomDelta; // ŵ
+ bool m_bMouseTranslate; // ƽƱʶ
+ QPoint m_lastMousePos; // µλ
+ qreal m_scale; // ֵ
+
+
+signals:
+ void leftMouseButtonPressed(int, int);
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/ImagerPositionSimulation.cpp b/HPPA/ImagerPositionSimulation.cpp
new file mode 100644
index 0000000..31e981e
--- /dev/null
+++ b/HPPA/ImagerPositionSimulation.cpp
@@ -0,0 +1,103 @@
+#include "stdafx.h"
+
+#include "ImagerPositionSimulation.h"
+
+
+ImagerPositionSimulation::ImagerPositionSimulation(QWidget *parent) :
+QGraphicsView(parent)
+{
+ this->resize(1000, 500);
+
+ topLeftToLowerRight = nullptr;
+ topRightToLowerLeft = nullptr;
+
+ m_Scene = new QGraphicsScene(this);
+ this->setScene(m_Scene);
+
+ setSceneRect();
+
+
+ imager = new imagerSimulatioin();
+ m_Scene->addItem(imager);
+ //imager->setPos(-100, -100);
+
+ QBrush redBrush(Qt::red);
+ QPen outlinePen(Qt::black);
+
+ /*m_rectangle = m_Scene->addRect(0, 0, 100, 100, outlinePen, redBrush);
+ m_rectangle->setFlag(QGraphicsRectItem::ItemIsMovable);*/
+
+
+}
+
+ImagerPositionSimulation::~ImagerPositionSimulation()
+{
+
+}
+
+void ImagerPositionSimulation::setSceneRect()
+{
+ QRectF graphicsViewSize = viewport()->rect();
+
+ m_Scene->setSceneRect(-graphicsViewSize.width(), -graphicsViewSize.height(), graphicsViewSize.width(), graphicsViewSize.height());
+
+ drawX();
+}
+
+QRectF ImagerPositionSimulation::sceneRect()
+{
+ return m_Scene->sceneRect();
+}
+
+void ImagerPositionSimulation::mousePressEvent(QMouseEvent *event)
+{
+ QPoint viewPos = event->pos();
+
+
+ QGraphicsView::mousePressEvent(event);
+}
+
+void ImagerPositionSimulation::mouseReleaseEvent(QMouseEvent *event)
+{
+ QPoint viewPos = event->pos();
+
+ ////
+ //const type_info &x = typeid(imager);
+ //qDebug() << "---------------type_info: " << x.name() << x.raw_name() << x.hash_code();
+
+
+
+ //qDebug() << "---------------ImagerPositionSimulation view coordinate: " << viewPos;
+ //qDebug() << "---------------ImagerPositionSimulation scene coordinate: " << this->mapToScene(viewPos);
+
+
+ QGraphicsView::mouseReleaseEvent(event);
+}
+
+void ImagerPositionSimulation::drawX()
+{
+ QRectF rect = m_Scene->sceneRect();
+
+ QPen outlinePen(Qt::black);
+
+ if (topLeftToLowerRight == nullptr)
+ {
+ topLeftToLowerRight = m_Scene->addLine(rect.left(), rect.top(), rect.right(), rect.bottom(), outlinePen);
+ }
+ else
+ {
+ topLeftToLowerRight->setLine(rect.left(), rect.top(), rect.right(), rect.bottom());
+ }
+
+
+ if (topRightToLowerLeft == nullptr)
+ {
+ topRightToLowerLeft = m_Scene->addLine(rect.right(), rect.top(), rect.left(), rect.bottom(), outlinePen);
+ }
+ else
+ {
+ topRightToLowerLeft->setLine(rect.right(), rect.top(), rect.left(), rect.bottom());
+ }
+
+
+}
diff --git a/HPPA/ImagerPositionSimulation.h b/HPPA/ImagerPositionSimulation.h
new file mode 100644
index 0000000..a314b41
--- /dev/null
+++ b/HPPA/ImagerPositionSimulation.h
@@ -0,0 +1,35 @@
+#ifndef IMAGER_POSITION_SIMULATION
+#define IMAGER_POSITION_SIMULATION
+#include
+#include
+
+#include "imagerSimulatioin.h"
+
+class ImagerPositionSimulation :public QGraphicsView
+{
+ Q_OBJECT
+public:
+ ImagerPositionSimulation(QWidget* pParent = NULL);
+ ~ImagerPositionSimulation();
+
+ imagerSimulatioin *imager;
+
+ void drawX();
+
+ void setSceneRect();//QGraphicsViewviewportΪsceneRect
+
+ QRectF sceneRect();
+
+ void mousePressEvent(QMouseEvent *event);
+
+ void mouseReleaseEvent(QMouseEvent *event);
+
+private:
+ QGraphicsScene *m_Scene;
+ QGraphicsRectItem *m_rectangle;
+
+ QGraphicsLineItem *topLeftToLowerRight;
+ QGraphicsLineItem *topRightToLowerLeft;
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/QDoubleSlider.cpp b/HPPA/QDoubleSlider.cpp
new file mode 100644
index 0000000..3e98fa5
--- /dev/null
+++ b/HPPA/QDoubleSlider.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+#include "qDoubleSlider.h"
+QDoubleSlider::QDoubleSlider(QWidget* pParent /*= NULL*/) :
+QSlider(pParent),
+m_Multiplier(100.0)
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
+
+ setSingleStep(1);
+
+ setOrientation(Qt::Horizontal);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+//ⷢ
+void QDoubleSlider::notifyValueChanged(int Value)
+{
+ emit valueChanged((double)Value / m_Multiplier);
+}
+
+//
+void QDoubleSlider::setValue(double Value, bool BlockSignals)
+{
+ QSlider::blockSignals(BlockSignals);
+
+ QSlider::setValue(Value * m_Multiplier);
+
+ if (!BlockSignals)
+ emit valueChanged(Value);
+
+ QSlider::blockSignals(false);
+}
+
+void QDoubleSlider::setRange(double Min, double Max)
+{
+ QSlider::setRange(Min * m_Multiplier, Max * m_Multiplier);
+
+ emit rangeChanged(Min, Max);
+}
+
+void QDoubleSlider::setMinimum(double Min)
+{
+ QSlider::setMinimum(Min * m_Multiplier);
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QDoubleSlider::minimum() const
+{
+ return QSlider::minimum() / m_Multiplier;
+}
+
+void QDoubleSlider::setMaximum(double Max)
+{
+ QSlider::setMaximum(Max * m_Multiplier);
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QDoubleSlider::maximum() const
+{
+ return QSlider::maximum() / m_Multiplier;
+}
+
+double QDoubleSlider::value() const
+{
+ int Value = QSlider::value();
+ return (double)Value / m_Multiplier;
+}
diff --git a/HPPA/QDoubleSlider.h b/HPPA/QDoubleSlider.h
new file mode 100644
index 0000000..fc4a863
--- /dev/null
+++ b/HPPA/QDoubleSlider.h
@@ -0,0 +1,32 @@
+#ifndef Q_DOUBLE_SLIDER_H
+#define Q_DOUBLE_SLIDER_H
+#include
+#include
+class QDoubleSlider : public QSlider
+{
+ Q_OBJECT
+
+public:
+ QDoubleSlider(QWidget* pParent = NULL);
+
+ void setRange(double Min, double Max);
+ void setMinimum(double Min);
+ double minimum() const;
+ void setMaximum(double Max);
+ double maximum() const;
+ double value() const;
+
+ public slots:
+ void notifyValueChanged(int value);//źvalueChanged(int)wrap
+ void setValue(double Value, bool BlockSignals = true);//QSlider::setValuewrap
+
+ private slots:
+
+signals :
+ void valueChanged(double Value);
+ void rangeChanged(double Min, double Max);
+
+private:
+ double m_Multiplier;
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/QMotorDoubleSlider.cpp b/HPPA/QMotorDoubleSlider.cpp
new file mode 100644
index 0000000..9dc5a96
--- /dev/null
+++ b/HPPA/QMotorDoubleSlider.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+#include "QMotorDoubleSlider.h"
+QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :
+QSlider(pParent),
+//m_Multiplier(0.00054496986),//ϺũԺǰ0.00052734375/5=0.00010546875ĺȷֵΪ0.000544969862759644Ϊ0.00054496986/5=0.000108993972Ϊиеװ1Ҫ5
+m_Multiplier(0.00054496986),//˰ũ
+m_yMultiplier(0.000108993972)//
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
+
+ setSingleStep(1);
+
+ setOrientation(Qt::Horizontal);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+//ⷢ
+void QMotorDoubleSlider::notifyValueChanged(int Value)
+{
+ emit valueChanged((double)Value * m_Multiplier);//////////
+}
+
+//
+void QMotorDoubleSlider::setValue(double Value, bool BlockSignals)
+{
+ QSlider::blockSignals(BlockSignals);
+
+ QSlider::setValue(Value / m_Multiplier);////////////
+
+ if (!BlockSignals)
+ emit valueChanged(Value);
+
+ QSlider::blockSignals(false);
+}
+
+void QMotorDoubleSlider::setRange(double Min, double Max)
+{
+ QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
+
+ emit rangeChanged(Min, Max);
+}
+
+void QMotorDoubleSlider::setMinimum(double Min)
+{
+ QSlider::setMinimum(Min / m_Multiplier);//////
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QMotorDoubleSlider::minimum() const
+{
+ return QSlider::minimum() * m_Multiplier;/////
+}
+
+void QMotorDoubleSlider::setMaximum(double Max)
+{
+ QSlider::setMaximum(Max / m_Multiplier);//////
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QMotorDoubleSlider::maximum() const
+{
+ return QSlider::maximum() * m_Multiplier;///////
+}
+
+double QMotorDoubleSlider::value() const
+{
+ int Value = QSlider::value();
+ return (double)Value * m_Multiplier;//////
+}
+
+double QMotorDoubleSlider::OriginalValue() const
+{
+ int Value = QSlider::value();
+ return (double)Value;
+}
+
+long QMotorDoubleSlider::getPositionPulse(double position)
+{
+ return position / m_Multiplier;
+}
+
+double QMotorDoubleSlider::getDistanceFromPulse(int pulse)
+{
+ return pulse * m_Multiplier;
+}
diff --git a/HPPA/QMotorDoubleSlider.h b/HPPA/QMotorDoubleSlider.h
new file mode 100644
index 0000000..da1b88a
--- /dev/null
+++ b/HPPA/QMotorDoubleSlider.h
@@ -0,0 +1,38 @@
+#ifndef Q_MOTOR_DOUBLE_SLIDER_H
+#define Q_MOTOR_DOUBLE_SLIDER_H
+#include
+#include
+class QMotorDoubleSlider : public QSlider
+{
+ Q_OBJECT
+
+public:
+ QMotorDoubleSlider(QWidget* pParent = NULL);
+
+ double m_Multiplier;//ݹʽ廻Ϊ룺1(m_Multiplier)=/(360/*ϸֱ)ַhttps://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
+ double m_yMultiplier;//ǣ1.8135mm
+
+ void setRange(double Min, double Max);
+ void setMinimum(double Min);
+ double minimum() const;
+ void setMaximum(double Max);
+ double maximum() const;
+ double value() const;
+ double OriginalValue() const;//ֵҪʵʵֵǾ
+ long getPositionPulse(double position);//ݴľ뷵ֵ
+ double getDistanceFromPulse(int pulse);
+
+ public slots:
+ void notifyValueChanged(int value);//źvalueChanged(int)wrap
+ void setValue(double Value, bool BlockSignals = true);//QSlider::setValuewrap
+
+ private slots:
+
+signals :
+ void valueChanged(double Value);
+ void rangeChanged(double Min, double Max);
+
+private:
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/QYMotorDoubleSlider.cpp b/HPPA/QYMotorDoubleSlider.cpp
new file mode 100644
index 0000000..f8f4891
--- /dev/null
+++ b/HPPA/QYMotorDoubleSlider.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+#include "QYMotorDoubleSlider.h"
+QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :
+QSlider(pParent),
+//m_Multiplier(0.000108993972),//ϺũԺǰ0.00052734375/5=0.00010546875ĺȷֵΪ0.000544969862759644Ϊ0.00054496986/5=0.000108993972Ϊиеװ1Ҫ5
+m_Multiplier(0.000108993972),//˰ũ
+m_yMultiplier(0.000108993972)//
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
+
+ setSingleStep(1);
+
+ setOrientation(Qt::Horizontal);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+//ⷢ
+void QYMotorDoubleSlider::notifyValueChanged(int Value)
+{
+ emit valueChanged((double)Value * m_Multiplier);//////////
+}
+
+//
+void QYMotorDoubleSlider::setValue(double Value, bool BlockSignals)
+{
+ QSlider::blockSignals(BlockSignals);
+
+ QSlider::setValue(Value / m_Multiplier);////////////
+
+ if (!BlockSignals)
+ emit valueChanged(Value);
+
+ QSlider::blockSignals(false);
+}
+
+void QYMotorDoubleSlider::setRange(double Min, double Max)
+{
+ QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
+
+ emit rangeChanged(Min, Max);
+}
+
+void QYMotorDoubleSlider::setMinimum(double Min)
+{
+ QSlider::setMinimum(Min / m_Multiplier);//////
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QYMotorDoubleSlider::minimum() const
+{
+ return QSlider::minimum() * m_Multiplier;/////
+}
+
+void QYMotorDoubleSlider::setMaximum(double Max)
+{
+ QSlider::setMaximum(Max / m_Multiplier);//////
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QYMotorDoubleSlider::maximum() const
+{
+ return QSlider::maximum() * m_Multiplier;///////
+}
+
+double QYMotorDoubleSlider::value() const
+{
+ int Value = QSlider::value();
+ return (double)Value * m_Multiplier;//////
+}
+
+double QYMotorDoubleSlider::OriginalValue() const
+{
+ int Value = QSlider::value();
+ return (double)Value;
+}
+
+long QYMotorDoubleSlider::getPositionPulse(double position)
+{
+ return position / m_Multiplier;
+}
+
+double QYMotorDoubleSlider::getDistanceFromPulse(int pulse)
+{
+ return pulse * m_Multiplier;
+}
diff --git a/HPPA/QYMotorDoubleSlider.h b/HPPA/QYMotorDoubleSlider.h
new file mode 100644
index 0000000..bf7ff2e
--- /dev/null
+++ b/HPPA/QYMotorDoubleSlider.h
@@ -0,0 +1,38 @@
+#ifndef Q_YMOTOR_DOUBLE_SLIDER_H
+#define Q_YMOTOR_DOUBLE_SLIDER_H
+#include
+#include
+class QYMotorDoubleSlider : public QSlider//QYMotorDoubleSlider
+{
+ Q_OBJECT
+
+public:
+ QYMotorDoubleSlider(QWidget* pParent = NULL);
+
+ double m_Multiplier;//ݹʽ廻Ϊ룺1(m_Multiplier)=/(360/*ϸֱ)ַhttps://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
+ double m_yMultiplier;//ǣ1.8135mm
+
+ void setRange(double Min, double Max);
+ void setMinimum(double Min);
+ double minimum() const;
+ void setMaximum(double Max);
+ double maximum() const;
+ double value() const;
+ double OriginalValue() const;//ֵҪʵʵֵǾ
+ long getPositionPulse(double position);//ݴľ뷵ֵ
+ double getDistanceFromPulse(int pulse);
+
+ public slots:
+ void notifyValueChanged(int value);//źvalueChanged(int)wrap
+ void setValue(double Value, bool BlockSignals = true);//QSlider::setValuewrap
+
+ private slots:
+
+signals :
+ void valueChanged(double Value);
+ void rangeChanged(double Min, double Max);
+
+private:
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/RgbCameraOperation.cpp b/HPPA/RgbCameraOperation.cpp
new file mode 100644
index 0000000..ab24e12
--- /dev/null
+++ b/HPPA/RgbCameraOperation.cpp
@@ -0,0 +1,68 @@
+#include "stdafx.h"
+#include "RgbCameraOperation.h"
+
+RgbCameraOperation::RgbCameraOperation()
+{
+ cam = nullptr;
+ m_ImageProcessor = new ImageProcessor();
+ m_func = nullptr;
+}
+
+RgbCameraOperation::~RgbCameraOperation()
+{
+}
+
+void RgbCameraOperation::OpenCamera()
+{
+ std::cout << "ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam = new cv::VideoCapture(0);
+
+ record = true;
+
+ while (record)
+ {
+ //std::cout << "ɼӰ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam->read(frame);
+ m_qImage = m_ImageProcessor->Mat2QImage(frame);
+
+ emit PlotSignal();
+ }
+
+ cam->release();
+
+ emit CamClosed();
+
+}
+
+void RgbCameraOperation::OpenCamera_callback()
+{
+ std::cout << "ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam = new cv::VideoCapture(0);
+
+ record = true;
+
+ while (record)
+ {
+ //std::cout << "ɼӰ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam->read(frame);
+ m_qImage = m_ImageProcessor->Mat2QImage(frame);
+
+ if(m_func)
+ m_func();
+ }
+
+ cam->release();
+}
+
+
+void RgbCameraOperation::setCallback(void(*func)())
+{
+ m_func = func;
+}
+
+void RgbCameraOperation::CloseCamera()
+{
+ std::cout << "رͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+
+ record = false;
+}
diff --git a/HPPA/RgbCameraOperation.h b/HPPA/RgbCameraOperation.h
new file mode 100644
index 0000000..d993049
--- /dev/null
+++ b/HPPA/RgbCameraOperation.h
@@ -0,0 +1,47 @@
+#pragma once
+#ifndef RGBCAMERAOPERATION_H
+#define RGBCAMERAOPERATION_H
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include "imageProcessor.h"
+
+typedef void(*func)();
+
+class RgbCameraOperation:public QObject
+{
+ Q_OBJECT
+
+public:
+ RgbCameraOperation();
+ ~RgbCameraOperation();
+
+ QImage m_qImage;
+ void setCallback(void(*func)());
+
+private:
+ cv::Mat frame;
+ cv::VideoCapture *cam;
+
+ func m_func;
+
+ ImageProcessor* m_ImageProcessor;
+
+ bool record;
+
+public slots:
+ void OpenCamera();
+ void OpenCamera_callback();//ʹźŶʹûص֪ͨˢƵ
+ void CloseCamera();
+
+signals:
+ void PlotSignal();
+
+ void CamClosed();
+};
+#endif // !RGBCAMERAOPERATION_H
diff --git a/HPPA/cpp.hint b/HPPA/cpp.hint
new file mode 100644
index 0000000..78ee111
--- /dev/null
+++ b/HPPA/cpp.hint
@@ -0,0 +1,5 @@
+// 提示文件帮助 Visual Studio IDE 解释 Visual C++ 标识符,
+// 如函数和宏的名称。
+// 有关详细信息,请参见 https://go.microsoft.com/fwlink/?linkid=865984
+#define Q_OBJECT public: QT_WARNING_PUSH Q_OBJECT_NO_OVERRIDE_WARNING static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); QT_TR_FUNCTIONS private: Q_OBJECT_NO_ATTRIBUTES_WARNING Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); QT_WARNING_POP struct QPrivateSignal {}; QT_ANNOTATE_CLASS(qt_qobject, "")
+#define Q_OBJECT
diff --git a/HPPA/fileOperation.cpp b/HPPA/fileOperation.cpp
new file mode 100644
index 0000000..8c82ed5
--- /dev/null
+++ b/HPPA/fileOperation.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+#include "fileOperation.h"
+
+FileOperation::FileOperation()
+{
+
+}
+
+FileOperation::~FileOperation()
+{
+
+}
+
+string FileOperation::getDirectoryOfExe()
+{
+ string exeName = _pgmptr;
+
+ string directory;
+ const size_t last_slash_idx = exeName.rfind('\\');
+ if (std::string::npos != last_slash_idx)
+ {
+ directory = exeName.substr(0, last_slash_idx);
+ }
+
+ return directory;
+}
+
+string FileOperation::getDirectoryFromString(string directory)
+{
+ QString tmp = QString::fromStdString(directory);
+ QDir dir;
+ if (!dir.exists(tmp))
+ {
+ bool res = dir.mkpath(tmp);
+ //qDebug() << "½Ŀ¼Ƿɹ" << res;
+ }
+ return directory;
+}
+
+bool FileOperation::copyFile(QString source, QString target)
+{
+ string source1 = source.toStdString();
+ string target1 = target.toStdString();
+
+ char buffer[256];
+ int n;
+
+ ifstream in(source1, ios_base::in | ios_base::binary);
+ ofstream out(target1, ios_base::out | ios_base::binary);
+
+ if (!in || !out){ cerr << "Open File Failure,Please Try Again!"; exit(1); }
+
+ while (!in.eof())
+ {
+ in.read(buffer, 256); //ļжȡ256ֽڵݵ
+ n = in.gcount(); //һв֪ȡ˶ֽڵݣúһ¡
+ out.write(buffer, n); //дǸֽڵ
+ }
+ in.close();
+ out.close();
+
+ string::size_type idx;
+
+ idx = source1.find("hdr");
+ if (idx == string::npos) //ڡ
+ emit CopyFinishedSignal();
+
+ return 1;
+}
diff --git a/HPPA/fileOperation.h b/HPPA/fileOperation.h
new file mode 100644
index 0000000..170524a
--- /dev/null
+++ b/HPPA/fileOperation.h
@@ -0,0 +1,41 @@
+#ifndef FILE_OPERATIOIN_H
+#define FILE_OPERATIOIN_H
+
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class FileOperation :public QObject
+{
+ Q_OBJECT
+
+public:
+ FileOperation();
+ ~FileOperation();
+
+ string getDirectoryOfExe();//getDirectoryOfExe
+ string getDirectoryFromString(string directory="C:/HPPA_image");
+
+
+
+
+public Q_SLOTS:
+ bool copyFile(QString source, QString target);
+
+ /*bool moveFile(const string& source, const string& target);
+ bool deleteFile(const string& path);
+ bool hasFile(const string& path);
+
+ bool copyDirectory(const string& source, const string& target);
+ bool moveDirectory(const string& source, const string& target);
+ bool deleteDirectory(const string& path);*/
+
+
+
+signals:
+ void CopyFinishedSignal();//Ӱź
+};
+#endif
diff --git a/HPPA/focusWindow.cpp b/HPPA/focusWindow.cpp
new file mode 100644
index 0000000..f49bb9d
--- /dev/null
+++ b/HPPA/focusWindow.cpp
@@ -0,0 +1,297 @@
+#include "stdafx.h"
+#include "focusWindow.h"
+
+focusWindow::focusWindow(QWidget *parent, ResononImager * imager)
+{
+ ui.setupUi(this);
+
+ disableBeforeConnect(true);
+
+ setAttribute(Qt::WA_DeleteOnClose);//ùرմ͵ô
+
+ m_Imager = imager;
+ m_FocusState = 0;
+ m_ctrlFocusMotor = nullptr;
+
+ m_AutoFocusThread = new QThread();
+
+ connect(this->ui.connectMotor_btn, SIGNAL(clicked()), this, SLOT(onConnectMotor()));
+ connect(this->ui.logicZero_btn, SIGNAL(clicked()), this, SLOT(onMove2MotorLogicZero()));
+ connect(this->ui.max_btn, SIGNAL(clicked()), this, SLOT(onMove2MotorMax()));
+ connect(this->ui.add_btn, SIGNAL(clicked()), this, SLOT(onAdd()));
+ connect(this->ui.subtract_btn, SIGNAL(clicked()), this, SLOT(onSubtract()));
+ connect(this->ui.ultrasound_radioButton, SIGNAL(released()), this, SLOT(onUltrasound_radioButton()));
+ connect(this->ui.autoFocus_btn, SIGNAL(clicked()), this, SLOT(onAutoFocus()));
+ connect(this->ui.manualFocus_btn, SIGNAL(clicked()), this, SLOT(onManualFocus()));
+
+ //ҿôڣʾ
+ foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
+ {
+ QSerialPort serial;
+ serial.setPort(info);
+ if (serial.open(QIODevice::ReadWrite))
+ {
+ ui.motorPort_comboBox->addItem(serial.portName());
+ ui.ultrasoundPort_comboBox->addItem(serial.portName());
+ serial.close();
+ }
+ }
+
+ //Զ
+ ui.autoFocusProgress_progressBar->setMinimum(0);
+ ui.autoFocusProgress_progressBar->setMaximum(100);
+ ui.autoFocusProgress_progressBar->reset();
+}
+
+focusWindow::~focusWindow()
+{
+ printf("destroy focusWindow-------------------------\n");
+
+ delete m_ctrlFocusMotor;
+ //delete thread1, progressThread;
+}
+
+void focusWindow::disableBeforeConnect(bool disable)
+{
+ ui.controlMotor_groupBox->setDisabled(disable);
+ ui.autoFocus_btn->setDisabled(disable);
+}
+
+bool test(void *pCaller, int *x, int *y, void **pvdata)
+{
+ focusWindow *p = (focusWindow *)pCaller;
+
+ p->m_Imager->GetImageSize(*x, *y);
+ USHORT *pusData = new USHORT[(*x)*(*y)];
+
+ p->m_Imager->m_ResononImager.start();
+ p->m_Imager->m_ResononImager.get_frame(pusData);
+ p->m_Imager->m_ResononImager.stop();
+
+
+ BYTE *pbData = (BYTE*)pusData;
+ *pvdata = pbData;
+ return true;
+}
+
+void focusWindow::onConnectMotor()
+{
+ if (m_ctrlFocusMotor != nullptr)
+ {
+ printf("ظ-------------------------\n");
+ return;
+ }
+
+ bool isUltrasound = ui.ultrasound_radioButton->isChecked();
+
+ QString motorPortTmp = ui.motorPort_comboBox->currentText();
+ QString ultrasoundPortTmp = ui.ultrasoundPort_comboBox->currentText();
+
+ QRegExp rx("\\d+$");
+ rx.indexIn(motorPortTmp, 0);
+ int motorPort = rx.cap(0).toInt();
+ rx.indexIn(ultrasoundPortTmp, 0);
+ int ultrasoundPort = rx.cap(0).toInt();
+
+ int minPos = 120;
+ int maxPos = 1000;
+
+ if (isUltrasound)
+ {
+ PortInfo motor;
+ motor.iPortType = 0;
+ motor.indexParity = 0;
+
+ motor.iPortNumber = motorPort;
+ motor.indexBaudRate = 0x13;
+ motor.indexBytesize = 3;
+ motor.indexStopBits = 0;
+
+ PortInfo ultrasound;
+ ultrasound.iPortType = 0;
+ ultrasound.indexParity = 0;
+ ultrasound.iPortNumber = ultrasoundPort;
+ ultrasound.indexBaudRate = 0x0C;
+ ultrasound.indexBytesize = 3;
+ ultrasound.indexStopBits = 0;
+
+ m_ctrlFocusMotor = new CFocusMotorControl();
+
+ m_ctrlFocusMotor->SetLogicZero(minPos);
+ m_ctrlFocusMotor->SetLimit(minPos, maxPos);
+ m_iMotorMaxPos = maxPos;
+ m_ctrlFocusMotor->InitSystem(motor, ultrasound, test, this);
+ m_ctrlFocusMotor->MoveToLogicZero();
+ }
+ else
+ {
+ PortInfo motor;
+ motor.iPortType = 0;
+ motor.indexParity = 0;
+ motor.iPortNumber = motorPort;
+ motor.indexBaudRate = 0x13;
+ motor.indexBytesize = 3;
+ motor.indexStopBits = 0;
+
+ m_ctrlFocusMotor = new CFocusMotorControl();
+
+ m_ctrlFocusMotor->SetLogicZero(minPos);
+ m_ctrlFocusMotor->SetLimit(minPos, maxPos);
+ m_iMotorMaxPos = maxPos;
+ m_ctrlFocusMotor->InitSystem(motor, test, this);
+ m_ctrlFocusMotor->MoveToLogicZero();
+ }
+
+ disableBeforeConnect(false);
+}
+
+void focusWindow::onMove2MotorLogicZero()
+{
+ m_ctrlFocusMotor->MoveToLogicZero();
+}
+
+void focusWindow::onMove2MotorMax()
+{
+ m_ctrlFocusMotor->MoveToPos(m_iMotorMaxPos);
+}
+
+void focusWindow::onAdd()
+{
+ DriverInfo di;
+ m_ctrlFocusMotor->GetDriverStatus(di);
+
+ int stepSize = ui.addStepSize_lineEdit->text().toInt();
+
+ m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + stepSize);
+
+ m_ctrlFocusMotor->GetDriverStatus(di);
+ printf("λã%d", di.iAbsPosition);
+ std::cout << "ť" << std::endl;
+}
+
+void focusWindow::onSubtract()
+{
+ DriverInfo di;
+ m_ctrlFocusMotor->GetDriverStatus(di);
+
+ int stepSize = ui.subtractStepSize_lineEdit->text().toInt();
+
+ m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - stepSize);
+
+ m_ctrlFocusMotor->GetDriverStatus(di);
+ printf("λã%d", di.iAbsPosition);
+}
+
+void focusWindow::onAutoFocus()
+{
+ bool isUltrasound = ui.ultrasound_radioButton->isChecked();
+ WorkerThread2 *thread1 = new WorkerThread2(m_ctrlFocusMotor, isUltrasound);
+
+ connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
+
+ thread1->start();
+ this->setDisabled(true);
+
+ WorkerThread4 *progressThread = new WorkerThread4(m_ctrlFocusMotor);
+ connect(progressThread, SIGNAL(AutoFocusProgressSignal(int)), this, SLOT(onAutoFocusProgress(int)));
+ progressThread->start();
+ ui.autoFocusProgress_progressBar->reset();
+}
+
+void focusWindow::onManualFocus()
+{
+ m_FocusState += 1;
+ std::cout << "ť" << std::endl;
+
+
+ if (m_FocusState % 2 == 1)
+ {
+ //ʼ
+ emit StartManualFocusSignal(1);
+ ui.manualFocus_btn->setText(QString::fromLocal8Bit("ֹͣ"));
+
+ ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
+
+ //std::cout << "------------------------------------------" << m_FocusState << std::endl;
+ }
+ else
+ {
+ emit StartManualFocusSignal(0);
+ m_Imager->setFocusControlState(false);
+
+ ui.manualFocus_btn->setText(QString::fromLocal8Bit(""));
+
+ ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+ }
+}
+
+void focusWindow::onAutoFocusFinished()
+{
+ this->setDisabled(false);
+}
+
+void focusWindow::onAutoFocusProgress(int progress)
+{
+ //std::cout << "ȣ" << progress << std::endl;
+
+ ui.autoFocusProgress_progressBar->setValue(progress);
+}
+
+void focusWindow::onUltrasound_radioButton()
+{
+ bool isUltrasound = ui.ultrasound_radioButton->isChecked();
+
+ if (isUltrasound)
+ {
+ ui.ultrasoundPort_comboBox->setEnabled(true);
+ }
+ else
+ {
+ ui.ultrasoundPort_comboBox->setEnabled(false);
+ }
+}
+
+WorkerThread2::WorkerThread2(CFocusMotorControl * ctrlFocusMotor, bool isUltrasound)
+{
+ m_ctrlFocusMotor = ctrlFocusMotor;
+ m_bIsUltrasound = isUltrasound;
+}
+
+void WorkerThread2::run()
+{
+ if (m_bIsUltrasound)
+ {
+ m_ctrlFocusMotor->SetFitParams(0.0017, 0.3277);
+ m_ctrlFocusMotor->StartAutoFocus(5, 2);
+ }
+ else
+ {
+ m_ctrlFocusMotor->StartAutoFocus(820, 910, 10, 2);
+ }
+
+ emit AutoFocusFinishedSignal();
+}
+
+WorkerThread4::WorkerThread4(CFocusMotorControl * ctrlFocusMotor)
+{
+ m_ctrlFocusMotor = ctrlFocusMotor;
+}
+
+void WorkerThread4::run()
+{
+ while (true)
+ {
+ int progress = m_ctrlFocusMotor->GetProgressIndex();
+
+ //std::cout << "WorkerThread4::run----Զȣ" << progress << std::endl;
+
+ emit AutoFocusProgressSignal(progress);
+ if (progress == 100)
+ {
+ //std::cout << "Զɣ" << std::endl;
+ break;
+ }
+
+ msleep(200);
+ }
+}
\ No newline at end of file
diff --git a/HPPA/focusWindow.h b/HPPA/focusWindow.h
new file mode 100644
index 0000000..29846e8
--- /dev/null
+++ b/HPPA/focusWindow.h
@@ -0,0 +1,96 @@
+#pragma once
+
+#include "windows.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ui_FocusDialog.h"
+#include "AbstractPortMiscDefines.h"
+#include "CFocusMotorControl.h"
+
+#include "resononImager.h"
+
+class focusWindow:public QDialog
+{
+ Q_OBJECT
+
+public:
+ focusWindow(QWidget *parent = Q_NULLPTR);
+ focusWindow(QWidget *parent, ResononImager * imager);
+ ~focusWindow();
+
+ ResononImager * m_Imager;
+
+
+private:
+ Ui::focusDialog ui;
+ QThread *m_AutoFocusThread;
+ int m_FocusState;
+
+ int m_iMotorMaxPos;
+
+ CFocusMotorControl* m_ctrlFocusMotor;
+
+ void disableBeforeConnect(bool disable);
+
+public Q_SLOTS:
+ void onConnectMotor();
+ void onMove2MotorLogicZero();
+ void onMove2MotorMax();
+ void onAdd();
+ void onSubtract();
+ void onAutoFocus();
+ void onManualFocus();
+ void onAutoFocusFinished();
+ void onAutoFocusProgress(int progress);
+ void onUltrasound_radioButton();
+
+signals:
+ void StartManualFocusSignal(int);//1ʼ0ֹͣ
+};
+
+class WorkerThread2 : public QThread
+{
+ Q_OBJECT
+private:
+ bool m_bIsUltrasound;
+
+public:
+ WorkerThread2(CFocusMotorControl * ctrlFocusMotor,bool isUltrasound);
+ CFocusMotorControl *m_ctrlFocusMotor;
+
+protected:
+ void run();
+
+signals:
+ void AutoFocusFinishedSignal();
+};
+
+class WorkerThread4 : public QThread
+{
+ Q_OBJECT
+private:
+
+public:
+ WorkerThread4(CFocusMotorControl * ctrlFocusMotor);
+ CFocusMotorControl *m_ctrlFocusMotor;
+
+protected:
+ void run();
+
+signals:
+ void AutoFocusProgressSignal(int);
+};
diff --git a/HPPA/image2display.cpp b/HPPA/image2display.cpp
new file mode 100644
index 0000000..971bff6
--- /dev/null
+++ b/HPPA/image2display.cpp
@@ -0,0 +1,193 @@
+#include "stdafx.h"
+#include "image2display.h"
+#include
+
+CImage::CImage(QWidget* pParent) :QObject(pParent)
+{
+ m_QRgbImage = nullptr;
+ m_matRgbImage = nullptr;
+ m_matFocusGrayImage = nullptr;
+ m_qimageFocusGrayImage = nullptr;
+}
+
+void CImage::SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber)
+{
+ using namespace cv;
+
+ if (m_QRgbImage != nullptr)
+ {
+ delete m_QRgbImage;//⣿
+ }
+ //m_QRgbImage = new QImage(Sample, FrameNumber, QImage::Format_RGB888);
+
+
+ if (m_matRgbImage != nullptr)
+ {
+ delete m_matRgbImage;
+ }
+ m_matRgbImage = new Mat(FrameNumber, Sample, CV_16UC3, Scalar(0, 0, 0));
+
+
+
+
+
+ if (m_qimageFocusGrayImage == nullptr)
+ {
+ m_qimageFocusGrayImage = new QImage(Sample, BandCount, QImage::Format_RGB32);
+ }
+
+
+ if (m_matFocusGrayImage == nullptr)
+ {
+ m_matFocusGrayImage = new Mat(BandCount, Sample, CV_16U, Scalar(0));
+
+ //cv::Mat matAdjustPreview = Mat::zeros(BandCount, Sample, CV_16U);
+ }
+
+ //cv::Mat matAdjustPreview = Mat::zeros(BandCount, Sample, CV_16U);
+ //m_matFocusGrayImage = matAdjustPreview;
+
+
+
+
+
+
+
+
+ std::cout << "֡" << FrameNumber << std::endl;
+
+ m_iFrameCounter = 0;//ÿζΪ0
+ m_iSampleNumber = Sample;
+ m_iBandNumber = BandCount;
+ m_iFrameNumber = FrameNumber;
+
+ //std::cout << "rgbӰڴַΪ" << m_QRgbImage << std::endl;
+}
+
+void CImage::FillRgbImage(unsigned short *datacube)
+{
+ //uchar==unsigned charڴС1ֽڣΧΪ0-255
+ //uchar * imagebits24 = m_QRgbImage->bits();
+
+ //uchar * imagebits24 = m_QRgbImage->scanLine(m_iFrameCounter);//??????????????????????????????????????????????????????????????????????
+
+ unsigned short r, g, b;
+
+ for (int j = 0; j < m_iSampleNumber; j++)
+ {
+ //std::cout << "rgbͼд֡" << j << std::endl;
+
+ //ȡֵһ֡ӰУҵrgbԪֵ
+ r = *(datacube + 121 * m_iSampleNumber + j);
+ g = *(datacube + 79 * m_iSampleNumber + j);
+ b = *(datacube + 40 * m_iSampleNumber + j);
+
+ //Ԫֵֵcv::MatУԪֵhttps://zhuanlan.zhihu.com/p/51842288
+ //int dataType = m_matRgbImage->type();//ΪCV_16UC3ʱ18
+ //std::cout << "m_matRgbImageΪ" << dataType << std::endl;
+ if (m_matRgbImage->type() == CV_16UC3)
+ {
+ //std::cout << "ֵ" << std::endl;
+ m_matRgbImage->at(m_iFrameCounter, j)[2] = r;
+ m_matRgbImage->at(m_iFrameCounter, j)[1] = g;
+ m_matRgbImage->at(m_iFrameCounter, j)[0] = b;
+ }
+
+
+ ////Ԫֵ4095һ255ķΧֵQImage
+ //imagebits24[j * 3] = uchar(r * 255 / 4095);
+ //imagebits24[j * 3 + 1] = uchar(g * 255 / 4095);
+ //imagebits24[j * 3 + 2] = uchar(b * 255 / 4095);
+ }
+
+ m_iFrameCounter++;
+
+ //rgbͼƬ
+ if (m_iFrameCounter % m_iFramerate == 0 || m_iFrameCounter == m_iFrameNumber - 1)
+ {
+ ////ļ
+ //FileOperation * fileOperation = new FileOperation();
+ //string directory = fileOperation->getDirectoryOfExe();
+ //string rgbFilePathStrech = directory + "\\tmp_image_strech.png";//ûͼƬ
+ //string rgbFilePathNoStrech = directory + "\\tmp_image_no_strech.png";//ͼƬ
+
+ //m_QRgbImage->save(QString::fromStdString(rgbFilePathNoStrech), "PNG");
+
+ //cv::imwrite(rgbFilePathNoStrech, *m_matRgbImage);
+ //cv::imwrite(rgbFilePathStrech, CStretch(*m_matRgbImage, 0.01));
+
+ }
+}
+
+void CImage::FillFocusGrayImage(unsigned short * datacube)
+{
+ int rowCount = m_matFocusGrayImage->rows;
+ int colCount = m_matFocusGrayImage->cols;
+ for (unsigned short i = 0; i < m_matFocusGrayImage->rows; i++)
+ {
+ for (unsigned short j = 0; j < m_matFocusGrayImage->cols; j++)
+ {
+ //m_matFocusGrayImage->at(i, j) = *(datacube + m_matFocusGrayImage->cols*i + j);
+ m_matFocusGrayImage->at(i, j) = datacube[m_matFocusGrayImage->cols*i + j];
+ }
+ }
+
+
+
+ //int rowCount = m_matFocusGrayImage.rows;
+ //int colCount = m_matFocusGrayImage.cols;
+ ////memcpy(m_matFocusGrayImage.data, datacube, rowCount*colCount);
+ //for (unsigned short i = 0; i < m_matFocusGrayImage.rows; i++)
+ //{
+ // for (unsigned short j = 0; j < m_matFocusGrayImage.cols; j++)
+ // {
+ // m_matFocusGrayImage.at(i, j) = *(datacube + m_matFocusGrayImage.cols*i + j);
+ // //m_matFocusGrayImage.at(i, j) = datacube[colCount*i + j];
+ // }
+ //}
+
+ //matļ
+ //cv::imwrite("D:/delete/2222222222/test.bmp", m_matFocusGrayImage);
+}
+
+void CImage::FillFocusGrayQImage(unsigned short * datacube)
+{
+ float two_eight = pow(2.0, 8);
+ float two_sixteen = pow(2.0, 12);
+
+ int width = m_qimageFocusGrayImage->width();
+ int height = m_qimageFocusGrayImage->height();
+ for (unsigned short i = 0; i < height; i++)
+ {
+ for (unsigned short j = 0; j < width; j++)
+ {
+ //uint tmp = (two_eight* *(datacube + width * i + j)) / two_sixteen;
+ uint tmp = (two_eight* datacube[width*i + j]) / two_sixteen;
+ //uint tmp = datacube[width*i + j];
+
+
+ //m_qimageFocusGrayImage->setPixel(j, i, tmp);
+ m_qimageFocusGrayImage->setPixel(j, i, qRgb((unsigned char)tmp, (unsigned char)tmp, (unsigned char)tmp));
+ }
+ }
+
+ m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");
+
+
+
+
+ /*float two_eight = pow(2.0, 8);
+ float two_sixteen = pow(2.0, 16);
+ QImage *qi = new QImage(imwidth, imheight, QImage::Format_RGB32);
+ for (int i = 0; i < imheight; i++)
+ {
+ for (int j = 0; j < imwidth; j++)
+ {
+ floatData[i*imwidth + j] = (two_eight* floatData[i*imwidth + j]) / two_sixteen;
+ qi->setPixel(j, i, qRgb((unsigned char)floatData[i*imwidth + j], (unsigned char)floatData[i*imwidth + j], (unsigned char)floatData[i*imwidth + j]));
+
+
+ }
+ }*/
+
+}
diff --git a/HPPA/image2display.h b/HPPA/image2display.h
new file mode 100644
index 0000000..5d7594a
--- /dev/null
+++ b/HPPA/image2display.h
@@ -0,0 +1,58 @@
+#ifndef CIMAGE
+#define CIMAGE
+#include
+
+
+#include //ж
+//#include
+//#include
+
+#include "QObject"
+#include "QImage"
+
+#include "fileOperation.h"
+
+
+class CImage :public QObject
+{
+ Q_OBJECT
+public:
+ CImage(QWidget* pParent = NULL);
+ //~CImage();
+ void SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber);
+ void FillRgbImage(unsigned short *datacube);
+ void FillFocusGrayImage(unsigned short *datacube);
+ void FillFocusGrayQImage(unsigned short * datacube);
+
+ QImage *m_QRgbImage;
+ cv::Mat *m_matRgbImage;
+
+ QImage *m_qimageFocusGrayImage;
+ cv::Mat *m_matFocusGrayImage;//ڵʱʾһ֡ĻҶͼ
+ //cv::Mat m_matFocusGrayImage;//ڵʱʾһ֡ĻҶͼ
+
+
+ //Ƹrgbͼڼ֡У
+ //ҪΪ01úSetRgbImageWidthAndHeight2ÿοʼǰ
+ int m_iFrameCounter;
+
+
+ int m_iFramerate;//
+
+
+protected:
+
+private:
+ int m_iSampleNumber;//
+ int m_iBandNumber;//
+
+ int m_iFrameNumber;//
+
+public slots:
+
+signals :
+ void sendstr(QString str);
+ void sendstr1(QString str);
+ void refreslabelimg(QImage* img1);
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/imageProcessor.cpp b/HPPA/imageProcessor.cpp
new file mode 100644
index 0000000..4c1b6c5
--- /dev/null
+++ b/HPPA/imageProcessor.cpp
@@ -0,0 +1,169 @@
+#include "stdafx.h"
+#include "imageProcessor.h"
+
+ImageProcessor::ImageProcessor()
+{
+}
+
+ImageProcessor::~ImageProcessor()
+{
+}
+
+std::vector ImageProcessor::CHistogram(const cv::Mat img)
+{
+ cv::Mat mimg = img.clone();
+ int rows = mimg.rows;
+ int cols = mimg.cols;
+ //ͳÿҶȳֵĴ
+ std::vector hisnum(4096, 0);//
+ for (int i(0); i < rows; ++i)
+ {
+ //std::cout << "i" << i << std::endl;
+ for (int j(0); j < cols; ++j)
+ {
+ //std::cout << "j" << j << std::endl;
+ unsigned short gv = mimg.at(i, j);
+ //std::cout << "gvֵ" << gv << std::endl;
+
+ //ԷиֵͷǸڿ۳пΪֵ
+ //matΪCV_16UC3иֵʱֵΪ65535
+ if (gv > 4096)
+ {
+ ++hisnum[0];
+ }
+ else
+ {
+ ++hisnum[gv];
+ }
+
+
+ }
+ }
+ //ʼҶƵ
+ long int pnum = rows * cols;
+ std::vector hisp;
+ for (int i(0); i < hisnum.size(); ++i)
+ {
+ float p = (float)hisnum[i] / pnum;
+ hisp.push_back(cv::Point2f(i, p));
+ }
+ return hisp;
+}
+
+uint ImageProcessor::MaxRatio(const std::vector data, const float ratio)
+{
+ float maxp(0);
+ uint outnum(0);
+ for (int i(data.size() - 1); i >= 0; --i)
+ {
+ maxp += data[i].y;
+ if (maxp >= ratio)
+ {
+ outnum = i;
+ break;
+ }
+ }
+ return outnum;
+}
+
+uint ImageProcessor::MinRatio(const std::vector data, const float ratio)
+{
+ float minp(0);
+ uint outnum(0);
+ for (int i(0); i < data.size(); ++i)
+ {
+ minp += data[i].y;
+ if (minp >= ratio)
+ {
+ outnum = i;
+ break;
+ }
+ }
+ return outnum;
+}
+
+QImage ImageProcessor::Mat2QImage(cv::Mat cvImg)//https://www.cnblogs.com/annt/p/ant003.html
+{
+ QImage qImg;
+ if (cvImg.channels() == 3) //3 channels color image
+ {
+ cv::cvtColor(cvImg, cvImg, CV_BGR2RGB);
+ qImg = QImage((const unsigned char*)(cvImg.data),
+ cvImg.cols, cvImg.rows,
+ cvImg.cols*cvImg.channels(),
+ QImage::Format_RGB888);
+ }
+ else if (cvImg.channels() == 1) //grayscale image
+ {
+ qImg = QImage((const unsigned char*)(cvImg.data),
+ cvImg.cols, cvImg.rows,
+ cvImg.cols*cvImg.channels(),
+ QImage::Format_Indexed8);
+ }
+ else
+ {
+ qImg = QImage((const unsigned char*)(cvImg.data),
+ cvImg.cols, cvImg.rows,
+ cvImg.cols*cvImg.channels(),
+ QImage::Format_RGB888);
+ }
+
+ return qImg;
+}
+
+cv::Mat ImageProcessor::CStretchDeal(const cv::Mat img, const uint minnum, const uint maxnum)
+{
+ cv::Mat mimg = img.clone();
+ int rows = mimg.rows;
+ int cols = mimg.cols;
+ cv::Mat nimg = cv::Mat::zeros(rows, cols, CV_8U);
+ //һ
+ float dertnum = maxnum - minnum;
+ //ʼ
+ for (int i(0); i < rows; ++i)
+ {
+ for (int j(0); j < cols; ++j)
+ {
+ unsigned short a = mimg.at(i, j);
+ //СratioӦֵȡ0
+ if (a <= minnum)
+ nimg.at(i, j) = 0;
+ //ratioֵӦֵȡ255
+ else if (a >= maxnum)
+ nimg.at(i, j) = 255;
+ //мֵ쵽0-255
+ else
+ nimg.at(i, j) = 255 * (mimg.at(i, j) - minnum) / dertnum;
+ }
+ }
+ return nimg;
+}
+
+cv::Mat ImageProcessor::CStretch(const cv::Mat img, const float ratio)
+{
+ //ӰRGBҶֱͼ
+ cv::Mat mimg = img.clone();
+ cv::Mat bgr[3];
+ split(mimg, bgr);
+ std::vector hb = CHistogram(bgr[0]);
+ std::vector hg = CHistogram(bgr[1]);
+ std::vector hr = CHistogram(bgr[2]);
+ //ͳֱͼۼƵratioֵӦĻҶ
+ uint minb = MinRatio(hb, ratio);
+ uint ming = MinRatio(hg, ratio);
+ uint minr = MinRatio(hr, ratio);
+ uint maxb = MaxRatio(hb, ratio);
+ uint maxg = MaxRatio(hg, ratio);
+ uint maxr = MaxRatio(hr, ratio);
+ //ʼ칤
+ cv::Mat b, g, r;
+ b = CStretchDeal(bgr[0], minb, maxb);
+ g = CStretchDeal(bgr[1], ming, maxg);
+ r = CStretchDeal(bgr[2], minr, maxr);
+ //ϲ
+ cv::Mat newbgr;
+ newbgr.create(img.rows, img.cols, CV_32FC3);
+ cv::Mat nbgr[3] = { b, g, r };
+ merge(nbgr, 3, newbgr);
+ return newbgr;
+}
diff --git a/HPPA/imageProcessor.h b/HPPA/imageProcessor.h
new file mode 100644
index 0000000..c99fa73
--- /dev/null
+++ b/HPPA/imageProcessor.h
@@ -0,0 +1,41 @@
+#pragma once
+#ifndef IMAGEPROCESSOR
+#define IMAGEPROCESSOR
+
+#include //ж
+//#include
+//#include
+
+#include "QObject"
+#include "QImage"
+
+
+class ImageProcessor
+{
+public:
+ ImageProcessor();
+ ~ImageProcessor();
+
+ QImage Mat2QImage(cv::Mat cvImg);//https://www.cnblogs.com/annt/p/ant003.html
+
+ //envi 2%ԭ
+ //gdal汾 https://blog.csdn.net/HB_Programmer/article/details/82020703?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
+ //opencv汾 https://blog.csdn.net/qq_41824159/article/details/105469986
+ cv::Mat CStretchDeal(const cv::Mat img, const uint minnum, const uint maxnum);
+ uint MaxRatio(const std::vector data, const float ratio);
+ uint MinRatio(const std::vector data, const float ratio);
+ std::vector CHistogram(const cv::Mat img);
+ cv::Mat CStretch(const cv::Mat img, const float ratio);
+
+protected:
+
+private:
+
+
+
+public slots:
+
+signals:
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/imagerSimulatioin.cpp b/HPPA/imagerSimulatioin.cpp
new file mode 100644
index 0000000..a930241
--- /dev/null
+++ b/HPPA/imagerSimulatioin.cpp
@@ -0,0 +1,130 @@
+#include "stdafx.h"
+#include "imagerSimulatioin.h"
+
+imagerSimulatioin::imagerSimulatioin(QGraphicsItem *parent) :QGraphicsItem(parent)
+{
+ /*this->setFlag(QGraphicsItem::ItemIsSelectable);
+ this->setFlag(QGraphicsItem::ItemIsMovable);*/
+
+ setFlags(ItemIsSelectable | ItemIsMovable);
+
+ //itemChangeҪItemSendsGeometryChanges flag is needed to capture the change in position of QGraphicsItem
+ this->setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
+ m_height = 50;
+ m_width = 50;
+
+
+}
+
+imagerSimulatioin::~imagerSimulatioin()
+{
+
+}
+
+QRectF imagerSimulatioin::boundingRect() const
+{
+ qreal penWidth = 1;
+ return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
+ 20 + penWidth, 20 + penWidth);
+}
+
+void imagerSimulatioin::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QBrush blueBrush(Qt::green);
+ QColor blue(32, 159, 223);
+ blueBrush.setColor(blue);
+
+ QPen outlinePen(Qt::black);
+
+ painter->setPen(outlinePen);
+ painter->setBrush(blueBrush);
+
+ painter->drawRect(-m_width / 2, -m_height / 2, m_width, m_height);//Ըıitemԭ㣬setSceneRect(qreal x, qreal y, qreal w, qreal h)һ
+
+
+ //QPen outlinePen(Qt::red);
+
+ painter->drawPoint(0, 0);
+ painter->drawEllipse(QPoint(0, 0), 10, 10);
+
+ //painter->drawRoundedRect(-10, -10, 100, 100, 5, 5);
+
+}
+
+void imagerSimulatioin::setPos(qreal x, qreal y)
+{
+ if (x>0)
+ {
+ x = -x;
+ }
+ if (y>0)
+ {
+ y = -y;
+ }
+
+ x = floor(x);
+ y = floor(y);
+
+ QGraphicsItem::setPos(x, y);//ø౻ǵĺִӦ
+
+ scene()->update();
+}
+
+QVariant imagerSimulatioin::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == ItemPositionChange && scene())
+ {
+ // value is the new position.
+ QPointF newPos = value.toPointF();
+
+ QRectF rect = scene()->sceneRect();
+ if (!rect.contains(newPos))
+ {
+ // Keep the item inside the scene rect.
+ newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
+ newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
+ //qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
+ return newPos;
+ }
+ }
+
+ //qDebug() << "---------------";
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
+void imagerSimulatioin::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ scene()->update();
+
+ QPointF originOfItem = this->scenePos();//itemϽsceneе
+ //qDebug() << originOfItem;
+
+ QGraphicsItem::mouseMoveEvent(event);
+}
+
+void imagerSimulatioin::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ QPointF x = pos();//itemԭ㣨00sceneе
+ QPointF originOfItem = this->scenePos();//itemԭ㣨00sceneе
+
+ QPointF viewPos = event->pos();
+
+
+ //qDebug() << "---------------event coordinate: " << x;
+ //qDebug() << "---------------event coordinate: " << viewPos;
+ //qDebug() << "---------------event scene coordinate: " << this->mapToScene(viewPos);
+
+ //qDebug() << "---------------imagerSimulatioin origin coordinate: " << originOfItem;
+ //qDebug() << "---------------imagerSimulatioin center coordinate: " << centerOfItem;
+
+ qDebug() << "---------------imagerSimulatioin origin coordinate: " << originOfItem;
+
+ emit leftMouseButtonPressed(originOfItem.x(), originOfItem.y());
+
+
+ //update();//ʵʱ
+ scene()->update();
+
+ QGraphicsItem::mouseReleaseEvent(event);
+}
diff --git a/HPPA/imagerSimulatioin.h b/HPPA/imagerSimulatioin.h
new file mode 100644
index 0000000..52416ef
--- /dev/null
+++ b/HPPA/imagerSimulatioin.h
@@ -0,0 +1,34 @@
+#ifndef IMAGER_SIMULATIOIN
+#define IMAGER_SIMULATIOIN
+
+#include
+
+class imagerSimulatioin :public QObject,public QGraphicsItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem)
+public:
+ imagerSimulatioin(QGraphicsItem *parent = Q_NULLPTR);
+ ~imagerSimulatioin();
+
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ void setPos(qreal x, qreal y);
+
+ //QGraphicsSceneͼԪ϶Χhttps://www.cnblogs.com/sfy5848/p/6611824.html
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);//϶itemʱͣĻƣ϶Ӱ
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);//ſʱʱͼԪsceneе
+protected:
+
+
+
+private:
+ int m_width;
+ int m_height;
+
+signals :
+ void leftMouseButtonPressed(int, int);
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/main.cpp b/HPPA/main.cpp
new file mode 100644
index 0000000..5d8c67a
--- /dev/null
+++ b/HPPA/main.cpp
@@ -0,0 +1,10 @@
+#include "HPPA.h"
+#include
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ HPPA w;
+ w.show();
+ return a.exec();
+}
diff --git a/HPPA/resononImager.cpp b/HPPA/resononImager.cpp
new file mode 100644
index 0000000..a7254ad
--- /dev/null
+++ b/HPPA/resononImager.cpp
@@ -0,0 +1,435 @@
+#include "stdafx.h"
+#include
+#include
+#include
+#include
+#include "resononImager.h"
+
+ResononImager::ResononImager()
+{
+ m_iFrameCounter = 1;
+ m_bRecordControlState = true;
+
+ m_FileName2Save = "tmp_image";
+ m_FileSavedCounter = 1;
+
+ m_RgbImage = new CImage();
+
+ buffer = nullptr;
+ dark = nullptr;
+ white = nullptr;
+
+ m_HasDark = false;
+ m_HasWhite = false;
+ m_bFocusControlState = false;
+}
+
+ResononImager::~ResononImager()
+{
+ if (buffer != nullptr)
+ {
+ std::cout << "ͷŶڴ" << std::endl;
+ free(buffer);
+ free(dark);
+ free(white);
+ }
+}
+
+CImage * ResononImager::getRgbImage() const
+{
+ return m_RgbImage;
+}
+
+cv::Mat * ResononImager::getMatRgbImage() const
+{
+ return m_RgbImage->m_matRgbImage;
+}
+
+cv::Mat * ResononImager::getMatFocusGrayImage() const
+{
+ return m_RgbImage->m_matFocusGrayImage;
+}
+
+QImage ResononImager::getQImageFocusGrayImage() const
+{
+ return *m_RgbImage->m_qimageFocusGrayImage;
+}
+
+bool ResononImager::getRecordControlState() const
+{
+ return m_bRecordControlState;
+}
+
+void ResononImager::setRecordControlState(bool RecordControlState)
+{
+ m_bRecordControlState = RecordControlState;
+}
+
+int ResononImager::getFrameCounter() const
+{
+ return m_iFrameCounter;
+}
+
+int ResononImager::getFocusFrameCounter() const
+{
+ return m_iFocusFrameCounter;
+}
+
+void ResononImager::WriteHdr()
+{
+ //write an ENVI compatible header file
+ using namespace std;
+
+
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryFromString();
+
+ string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
+
+ std::ofstream outfile(hdrPath.c_str());
+ outfile << "ENVI\n";
+ outfile << "interleave = bil\n";
+ outfile << "data type = 12\n";
+ outfile << "bit depth = 12\n";
+ outfile << "samples = " << m_ResononImager.get_sample_count() << "\n";
+ outfile << "bands = " << m_ResononImager.get_band_count() << "\n";
+ outfile << "lines = " << m_iFrameCounter << "\n";
+ outfile << "framerate = " << m_ResononImager.get_framerate() << "\n";
+ outfile << "shutter = " << m_ResononImager.get_integration_time() << "\n";
+ outfile << "gain = " << m_ResononImager.get_gain() << "\n";
+ outfile << "wavelength = {";
+ outfile << std::setprecision(5);
+
+ int start = m_ResononImager.get_start_band();
+ int end = m_ResononImager.get_end_band();
+ for (int i = start; i < end - 1; i++)
+ {
+ outfile << m_ResononImager.get_wavelength_at_band(i) << ", ";
+ }
+ outfile << m_ResononImager.get_wavelength_at_band(end - 1) << "}\n";
+ outfile.close();
+}
+
+unsigned short ResononImager::GetMaxValue(unsigned short * dark, int number)
+{
+ unsigned short max = 0;
+ for (size_t i = 0; i < number; i++)
+ {
+ if (dark[i]>max)
+ {
+ max = dark[i];
+ }
+ }
+ //std::cout << "ֵ֡Ϊ" << max << std::endl;
+ return max;
+}
+
+void ResononImager::connect_imager(int frameNumber)
+{
+ m_ResononImager.connect();
+ set_framerate(30.0);
+ set_integration_time(1);
+ set_gain(0);
+
+ m_ResononImager.set_spectral_bin(2);
+ //m_ResononImager.set_spatial_bin(2);
+
+ set_buffer();
+ m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), frameNumber);
+ m_iFrameNumber = frameNumber;
+
+ emit testImagerStatus();
+
+ //std::cout << "------------------------------------------------------" << std::endl;
+}
+
+void ResononImager::start_record()
+{
+ using namespace std;
+
+ //std::cout << "------------------------------------------------------" << std::endl;
+
+ m_iFrameCounter = 0;
+ m_RgbImage->m_iFrameCounter = 0;//rgbͼĵ0
+ m_bRecordControlState = true;
+
+ //жڴbufferǷ
+ if (buffer == 0)
+ {
+ std::cerr << "Error: memory could not be allocated for datacube";
+ exit(EXIT_FAILURE);
+ }
+
+ FileOperation * fileOperation = new FileOperation();
+ string directory = fileOperation->getDirectoryFromString();
+ string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter);
+
+ m_fImage = fopen(imgPath.c_str(), "w+b");
+
+
+ size_t x;
+ double pixelValueTmp;
+
+ m_ResononImager.start();
+ while (m_bRecordControlState)
+ {
+ m_iFrameCounter++;
+
+ m_ResononImager.get_frame(buffer);
+
+ //ȥӦΪbufferdarkunsigned shortԵdark>bufferʱbuffer-dark=65535
+ if (m_HasDark)
+ {
+ for (size_t i = 0; i < m_FrameSize; i++)
+ {
+ buffer[i] = buffer[i] - dark[i];
+ }
+ }
+
+
+ //ת
+ if (m_HasWhite)
+ {
+ for (size_t i = 0; i < m_FrameSize; i++)
+ {
+ //װ壩Ϊ0
+ if (white[i] != 0)
+ {
+ pixelValueTmp = buffer[i];
+ buffer[i] = (pixelValueTmp / white[i]) * 10000;
+ }
+ else
+ {
+ buffer[i] = 0;
+ }
+
+
+ }
+ }
+
+ x = fwrite(buffer, 2, m_FrameSize, m_fImage);
+
+ //rgbȡԱڽʾ
+ m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
+
+ //std::cout << "" << m_iFrameCounter << "֡д" << x << "unsigned short" << std::endl;
+
+ //ÿ1sһνͼλ
+ if (m_iFrameCounter % (int)m_ResononImager.get_framerate() == 0)
+ {
+ emit PlotSignal();
+ }
+
+ if (m_iFrameCounter >= m_iFrameNumber)
+ {
+ break;
+ }
+
+ }
+ m_ResononImager.stop();
+
+ m_bRecordControlState = false;
+ WriteHdr();
+ m_FileSavedCounter++;
+
+ //һλͼǰҪһ
+ //m_RgbImage
+ emit PlotSignal();//ɼɺһλͼԷɼ֡֡ʵıʱͼȫ
+
+ if (m_iFrameCounter >= m_iFrameNumber)
+ {
+ emit RecordFinishedSignal_WhenFrameNumberMeet();
+ }
+ else
+ {
+ emit RecordFinishedSignal_WhenFrameNumberNotMeet();
+ }
+
+ //QThread::msleep(1001);
+ fclose(m_fImage);
+}
+
+void ResononImager::record_dark()
+{
+ std::cout << "ɼ" << std::endl;
+ m_ResononImager.start();
+ m_ResononImager.get_frame(dark);
+ m_ResononImager.stop();
+
+ m_HasDark = true;
+}
+
+void ResononImager::record_white()
+{
+ std::cout << "ɼװ壡" << std::endl;
+ m_ResononImager.start();
+ m_ResononImager.get_frame(white);
+ m_ResononImager.stop();
+
+ m_HasWhite = true;
+}
+
+double ResononImager::get_framerate()
+{
+ return m_ResononImager.get_framerate();
+}
+
+double ResononImager::get_integration_time()
+{
+ return m_ResononImager.get_integration_time();
+}
+
+double ResononImager::get_gain()
+{
+ return m_ResononImager.get_gain();
+}
+
+void ResononImager::set_framerate(const double frames_per_second)
+{
+
+ m_ResononImager.set_framerate(frames_per_second);
+ m_RgbImage->m_iFramerate = frames_per_second;
+}
+
+void ResononImager::set_integration_time(const double milliseconds)
+{
+ m_ResononImager.set_integration_time(milliseconds);
+}
+
+void ResononImager::set_gain(const double gain)
+{
+ m_ResononImager.set_gain(gain);
+}
+
+void ResononImager::set_buffer()
+{
+ //
+ if (buffer != nullptr)
+ {
+ std::cout << "ͷŶڴ" << std::endl;
+ free(buffer);
+ }
+
+ m_FrameSize = m_ResononImager.get_band_count()*m_ResononImager.get_sample_count();
+ //std::cout << "m_FrameSizeСΪ" << m_FrameSize << std::endl;
+
+ buffer = new unsigned short[m_FrameSize];
+ dark = new unsigned short[m_FrameSize];
+ white = new unsigned short[m_FrameSize];
+
+ std::cout << "bufferڴַ" << buffer << std::endl;
+ std::cout << "darkڴַ" << dark << std::endl;
+ std::cout << "whiteڴַ" << white << std::endl;
+}
+
+void ResononImager::setFrameNumber(int FrameNumber)
+{
+ m_iFrameNumber = FrameNumber;
+ m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), FrameNumber);
+}
+
+double ResononImager::auto_exposure()
+{
+ //һعʱΪڵǰ֡
+ double x = 1 / m_ResononImager.get_framerate()*1000;//ȡعʱ
+ m_ResononImager.set_integration_time(x);
+
+ //ڶͨѭѰعʱ
+ m_ResononImager.start();
+
+ while (true)
+ {
+ m_ResononImager.get_frame(buffer);
+ if (GetMaxValue(buffer, m_FrameSize) >= 4095)
+ {
+ set_integration_time(get_integration_time()*0.8);
+ std::cout << "Զع-----------" << std::endl;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ m_ResononImager.stop();
+
+ //std::cout << "Զع⣺" << get_integration_time() << std::endl;
+
+ return get_integration_time();
+}
+
+void ResononImager::setFocusControlState(bool FocusControlState)
+{
+ m_bFocusControlState = FocusControlState;
+}
+
+void ResononImager::setFileName2Save(string FileName)
+{
+ m_FileName2Save = FileName;
+ m_FileSavedCounter = 1;
+}
+
+double ResononImager::getWavelengthAtBand(int band)
+{
+ return m_ResononImager.get_wavelength_at_band(band);
+}
+
+int ResononImager::getBandCount()
+{
+ return m_ResononImager.get_band_count();
+}
+
+int ResononImager::getSampleCount()
+{
+ return m_ResononImager.get_sample_count();
+}
+
+int ResononImager::GetImageSize(int &iWidth, int &iHeight)
+{
+ /*using namespace GENAPI_NAMESPACE;
+ using namespace std;
+ INodeMap& nodemap = m_phCamera->GetNodeMap();
+
+ iWidth = (int)CIntegerPtr(nodemap.GetNode("Width"))->GetValue();
+ iHeight = (int)CIntegerPtr(nodemap.GetNode("Height"))->GetValue();*/
+
+ iWidth = getSampleCount();
+ iHeight = getBandCount();
+
+ return 0;
+}
+
+void ResononImager::focus()
+{
+ m_iFocusFrameCounter = 1;
+ //std::cout << "-----------" << std::endl;
+
+ double tmpFrmerate = m_ResononImager.get_framerate();
+ double tmpIntegrationTime = m_ResononImager.get_integration_time();
+
+
+ m_ResononImager.set_framerate(5);
+ auto_exposure();
+ std::cout << "õعʱΪ" << m_ResononImager.get_integration_time() << std::endl;
+
+ m_ResononImager.start();
+
+ //emit SpectralSignal(1);
+ m_bFocusControlState = true;
+ while (m_bFocusControlState)
+ {
+ m_ResononImager.get_frame(buffer);
+ //m_RgbImage->FillFocusGrayImage(buffer);
+ m_RgbImage->FillFocusGrayQImage(buffer);
+
+ emit SpectralSignal(1);
+
+ ++m_iFocusFrameCounter;
+ }
+ emit SpectralSignal(0);
+
+ m_ResononImager.stop();
+
+ m_ResononImager.set_framerate(tmpFrmerate);
+ m_ResononImager.set_integration_time(tmpIntegrationTime);
+}
diff --git a/HPPA/resononImager.h b/HPPA/resononImager.h
new file mode 100644
index 0000000..511b5a8
--- /dev/null
+++ b/HPPA/resononImager.h
@@ -0,0 +1,97 @@
+#ifndef RESONON_IMAGER
+#define RESONON_IMAGER
+
+#include
+#include
+
+#include "resonon_imager_basler.h"
+#include "image2display.h"
+#include "fileOperation.h"
+
+class ResononImager:public QObject
+{
+ Q_OBJECT
+
+public:
+ ResononImager();
+ ~ResononImager();
+
+ Resonon::PikaBasler m_ResononImager;//
+
+ CImage* getRgbImage() const;
+ cv::Mat * getMatRgbImage() const;
+ cv::Mat * getMatFocusGrayImage() const;
+ QImage getQImageFocusGrayImage() const;
+
+ bool getRecordControlState() const;
+ void setRecordControlState(bool RecordControlState);
+
+ int getFrameCounter() const;
+ int getFocusFrameCounter() const;
+
+ unsigned short * buffer;//洢ɼӰмһд뵽Ӳ
+
+ void set_buffer();
+ void setFrameNumber(int FrameNumber);
+ double auto_exposure();
+
+
+ void setFocusControlState(bool FocusControlState);
+
+ void setFileName2Save(string FileName);
+
+ double getWavelengthAtBand(int band);
+ int getBandCount();
+ int getSampleCount();
+
+ int GetImageSize(int &iWidth, int &iHeight);
+
+protected:
+private:
+ CImage* m_RgbImage;//ʾrgbͼ
+ int m_iFrameNumber;//Ҫɼ֡
+ int m_iFrameCounter;//¼ɼ֡
+ int m_iFocusFrameCounter;//¼ʱɼ֡
+ bool m_bRecordControlState;//ɼ״ִֹ̬ͣɼ
+ bool m_bFocusControlState;//Ƶ
+
+ //ڸӰļ
+ string m_FileName2Save;//Ӱļ
+ int m_FileSavedCounter;//˼Ӱļ
+
+ unsigned short * dark;//洢
+ unsigned short * white;//洢װ
+
+ FILE *m_fImage;//дӲ̵ļ
+ int m_FrameSize;//ʾһ֡жٸֵm_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
+ bool m_HasDark;//ɼ˰֮Ϊtrue
+ bool m_HasWhite;//ɼ˰װ֮Ϊtrue
+
+ void WriteHdr();
+ unsigned short GetMaxValue(unsigned short * dark, int number);
+
+public slots:
+ void connect_imager(int frameNumber);//ٻ
+ void start_record();
+ void record_dark();
+ void record_white();
+ void focus();
+
+ double get_framerate();
+ double get_integration_time();
+ double get_gain();
+
+ void set_framerate(const double frames_per_second);
+ void set_integration_time(const double milliseconds);
+ void set_gain(const double gain);
+
+signals:
+ void PlotSignal();//Ӱź
+ void RecordFinishedSignal_WhenFrameNumberMeet();//ɼźţҪɼ֡m_iFrameNumberɼ
+ void RecordFinishedSignal_WhenFrameNumberNotMeet();//ɼźţҪɼ֡m_iFrameNumberûвɼɣ;ֹͣɼ
+ void SpectralSignal(int);//1ڵƹף0ʾɣ
+
+
+ void testImagerStatus();//ʾԲ״̬Ƿӣӳ
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/resource.h b/HPPA/resource.h
new file mode 100644
index 0000000..0cc8414
--- /dev/null
+++ b/HPPA/resource.h
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ ɵİļ
+// HPPA.rc ʹ
+//
+#define IDI_ICON1 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/HPPA/stdafx.cpp b/HPPA/stdafx.cpp
new file mode 100644
index 0000000..fd4f341
--- /dev/null
+++ b/HPPA/stdafx.cpp
@@ -0,0 +1 @@
+#include "stdafx.h"
diff --git a/HPPA/stdafx.h b/HPPA/stdafx.h
new file mode 100644
index 0000000..983474e
--- /dev/null
+++ b/HPPA/stdafx.h
@@ -0,0 +1,3 @@
+#include
+#include
+#include