Compare commits
51 Commits
1.9.0
...
7e119fbf91
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e119fbf91 | |||
| e3f882d77b | |||
| dac922eb29 | |||
| ae07b9c19e | |||
| 2cf86df608 | |||
| d358989579 | |||
| 0fb81ab3e8 | |||
| 8bbe402a63 | |||
| b23aedc6c7 | |||
| 06dffddfd0 | |||
| ca10848750 | |||
| 4af1187b7d | |||
| 30fa211a22 | |||
| 7473a45f41 | |||
| 6d8c2f0419 | |||
| 1c7780eb14 | |||
| 741e0e6734 | |||
| 5d5b440ba2 | |||
| 0b2744656b | |||
| ece7a34bfb | |||
| 452f7c8e5f | |||
| 0ac03f0eb5 | |||
| edfb72eaef | |||
| 7987abf711 | |||
| 09095592af | |||
| 4ad5c8b91e | |||
| 7f94513a16 | |||
| 8d2fe91043 | |||
| bdf956ed99 | |||
| e3b2d136d3 | |||
| 631216dc66 | |||
| 7d123ca11c | |||
| 8595f7cad7 | |||
| 30e63899a8 | |||
| 30306e9396 | |||
| f0f41f9a17 | |||
| f999d87da6 | |||
| 36ad438608 | |||
| bb1a01f402 | |||
| 797ff77f5f | |||
| 83ef26a1e2 | |||
| e7a73430d0 | |||
| fd5571712a | |||
| e14c5da80a | |||
| c2a3c28cdd | |||
| 52516d2f54 | |||
| af88a6a67e | |||
| 1e0cf1aa12 | |||
| 496f61c0e1 | |||
| ac241f45cc | |||
| 1867291c9b |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,5 +1,13 @@
|
||||
# tc
|
||||
GeneratedFiles/
|
||||
ResononAPISetup-3.12-64bit.exe
|
||||
gdal202.dll
|
||||
*.rej
|
||||
HPPA类图.drawio
|
||||
HPPA - 副本.ui
|
||||
icon
|
||||
ignore_*
|
||||
resources
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
28
HPPA/AspectRatioLabel.cpp
Normal file
28
HPPA/AspectRatioLabel.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "stdafx.h"
|
||||
#include "AspectRatioLabel.h"
|
||||
|
||||
AspectRatioLabel::AspectRatioLabel(QWidget* parent)
|
||||
: QLabel(parent)
|
||||
{
|
||||
setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
||||
void AspectRatioLabel::setOriginalPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
m_originalPixmap = pixmap;
|
||||
updateScaledPixmap();
|
||||
}
|
||||
|
||||
void AspectRatioLabel::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QLabel::resizeEvent(event);
|
||||
updateScaledPixmap();
|
||||
}
|
||||
|
||||
void AspectRatioLabel::updateScaledPixmap()
|
||||
{
|
||||
if (m_originalPixmap.isNull())
|
||||
return;
|
||||
|
||||
setPixmap(m_originalPixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
}
|
||||
22
HPPA/AspectRatioLabel.h
Normal file
22
HPPA/AspectRatioLabel.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QResizeEvent>
|
||||
|
||||
class AspectRatioLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AspectRatioLabel(QWidget* parent = nullptr);
|
||||
|
||||
void setOriginalPixmap(const QPixmap& pixmap);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
private:
|
||||
void updateScaledPixmap();
|
||||
QPixmap m_originalPixmap;
|
||||
};
|
||||
716
HPPA/CaptureCoordinator.cpp
Normal file
716
HPPA/CaptureCoordinator.cpp
Normal file
@ -0,0 +1,716 @@
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)),
|
||||
m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
|
||||
connect(this, &TwoMotionCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, &TwoMotionCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::start_record);
|
||||
connect(this, &TwoMotionCaptureCoordinator::stopRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::stop_record);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
|
||||
this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberNotMeet,
|
||||
// this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberNotMeet);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
|
||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||
}
|
||||
|
||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)),
|
||||
m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||
}
|
||||
|
||||
TwoMotionCaptureCoordinator::~TwoMotionCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::start(QVector<PathLine> pathLines)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
std::cout << "already running" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
getLocBeforeStart();
|
||||
|
||||
m_pathLines = pathLines;
|
||||
|
||||
m_isMoving2XMin = false;
|
||||
m_isMoving2XMax = false;
|
||||
m_isMoving2XStartLoc = false;
|
||||
|
||||
m_isMoving2YTargeLoc = false;
|
||||
m_isMoving2YStartLoc = false;
|
||||
m_isImagerFrameNumberMeet = false;
|
||||
|
||||
m_retryTimesMoving2XMin = 0;
|
||||
m_retryTimesMoving2XMax = 0;
|
||||
m_retryTimesMoving2YTargeLoc = 0;
|
||||
|
||||
m_isRunning = true;
|
||||
m_numCurrentPathLine = 0;
|
||||
processNextPathLine();
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::stop()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
std::cout << "The user manually stops the collection! " << std::endl;
|
||||
savePathLinesToCsv();
|
||||
|
||||
emit sequenceComplete(1);
|
||||
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
||||
//emit stopRecordHSISignal(m_numCurrentPathLine);
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::getLocBeforeStart()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(m_motorCtrl, &IrisMultiMotorController::locationSignal,
|
||||
[&](std::vector<double> pos) {
|
||||
m_locBeforeStart = pos;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_motorCtrl, "getLoc", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::getRecordState()
|
||||
{
|
||||
emit recordState(m_isRunning);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::move2LocBeforeStart()
|
||||
{
|
||||
std::cout << "\nmove2LocBeforeStart." << std::endl;
|
||||
|
||||
PathLine& tmp = m_pathLines[0];
|
||||
std::vector<double> speed;
|
||||
speed.push_back(tmp.speedTargetXMinPosition);
|
||||
speed.push_back(tmp.speedTargetYPosition);
|
||||
emit moveTo(m_locBeforeStart, speed, 1000);
|
||||
|
||||
m_isRunning = false;
|
||||
|
||||
m_isMoving2XMin = false;
|
||||
m_isMoving2XMax = false;
|
||||
m_isMoving2YTargeLoc = false;
|
||||
|
||||
m_isMoving2XStartLoc = true;
|
||||
m_isMoving2YStartLoc = true;
|
||||
}
|
||||
|
||||
QVector<PathLine> TwoMotionCaptureCoordinator::pathLines() const
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
return m_pathLines;
|
||||
}
|
||||
|
||||
double TwoMotionCaptureCoordinator::getTimeDiffMinutes(QDateTime startTime, QDateTime endTime)
|
||||
{
|
||||
qint64 diffMillis = startTime.msecsTo(endTime);
|
||||
double diffMinutes = (double)diffMillis / 60000;//min
|
||||
|
||||
return diffMinutes;
|
||||
}
|
||||
|
||||
bool TwoMotionCaptureCoordinator::savePathLinesToCsv(QString filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
if (filename.isEmpty())
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QString format1 = "yyyyMMdd_HHmmss";
|
||||
QString fileNameTmp = now.toString("yyyyMMdd_HHmmss");
|
||||
|
||||
filename = QDir::cleanPath(QString::fromStdString(directory) + QDir::separator() + "pathLines" + QDir::separator() + fileNameTmp + "_pathLines.csv");
|
||||
}
|
||||
|
||||
QDir dir = QFileInfo(filename).absoluteDir();
|
||||
|
||||
// 如果目录不存在,则递归创建
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkpath(".")) {
|
||||
qWarning() << "Failed to create directory:" << dir.path();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "timestamp1,timestamp2,timestamp3,time consuming(min),targetYPosition,actualYPosition,targetXMinPosition,actualXMinPosition,targetXMaxPosition,actualXMaxPosition\n";
|
||||
|
||||
for (const auto& data : m_pathLines)
|
||||
{
|
||||
out << data.timestamp1.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< data.timestamp2.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< data.timestamp3.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(getTimeDiffMinutes(data.timestamp2, data.timestamp3), 'f', 4) << ","
|
||||
<< QString::number(data.targetYPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualYPosition, 'f', 4) << ","
|
||||
<< QString::number(data.targetXMinPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualXMinPosition, 'f', 4) << ","
|
||||
<< QString::number(data.targetXMaxPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualXMaxPosition, 'f', 4)
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
PathLine &tmp = m_pathLines[m_numCurrentPathLine];
|
||||
|
||||
if (motorID == 1)//y马达
|
||||
{
|
||||
if (m_isMoving2YTargeLoc)
|
||||
{
|
||||
double threshold = getThre(tmp.targetYPosition, pos);
|
||||
|
||||
if (threshold > 5)
|
||||
{
|
||||
//没到准确位置,再次给马达发送命令
|
||||
if (m_retryTimesMoving2YTargeLoc < m_retryLimit)
|
||||
{
|
||||
m_retryTimesMoving2YTargeLoc++;
|
||||
|
||||
std::cout << "Y motor Moving2YTargeLoc error. Retry..." << std::endl;
|
||||
emit moveTo(1, tmp.targetYPosition, tmp.speedTargetYPosition, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_retryTimesMoving2YTargeLoc = 0;
|
||||
|
||||
tmp.actualYPosition = pos;
|
||||
|
||||
m_isMoving2YTargeLoc = false;
|
||||
|
||||
std::cout << "y motor is reached!!!! " << std::endl;
|
||||
startRecordHsi();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2YStartLoc)
|
||||
{
|
||||
m_isMoving2YStartLoc = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (motorID == 0)//x马达
|
||||
{
|
||||
if (m_isMoving2XMin)
|
||||
{
|
||||
double threshold = getThre(tmp.targetXMinPosition, pos);
|
||||
|
||||
if (threshold > 5)
|
||||
{
|
||||
//没到准确位置,再次给马达发送命令
|
||||
if (m_retryTimesMoving2XMin < m_retryLimit)
|
||||
{
|
||||
m_retryTimesMoving2XMin++;
|
||||
|
||||
std::cout << "X motor Moving2XMin error. Retry..." << std::endl;
|
||||
emit moveTo(0, tmp.targetXMinPosition, tmp.speedTargetXMinPosition, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_retryTimesMoving2XMin = 0;
|
||||
|
||||
tmp.actualXMinPosition = pos;
|
||||
|
||||
m_isMoving2XMin = false;
|
||||
|
||||
std::cout << "x motor is reached!!!! " << std::endl;
|
||||
startRecordHsi();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2XMax)
|
||||
{
|
||||
double threshold = getThre(tmp.targetXMaxPosition, pos);
|
||||
|
||||
if (threshold > 5 && !m_isImagerFrameNumberMeet)//马达没到准确位置 && 【非】光谱仪因帧数限制主动停止采集
|
||||
{
|
||||
//没到准确位置,再次给马达发送命令
|
||||
if (m_retryTimesMoving2XMax < m_retryLimit)
|
||||
{
|
||||
m_retryTimesMoving2XMax++;
|
||||
|
||||
std::cout << "X motor Moving2XMax error. Retry..." << std::endl;
|
||||
emit moveTo(0, tmp.targetXMaxPosition, tmp.speedTargetXMaxPosition, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_retryTimesMoving2XMax = 0;
|
||||
|
||||
tmp.actualXMaxPosition = pos;
|
||||
tmp.timestamp3 = QDateTime::currentDateTime();
|
||||
|
||||
std::cout << "Line " << m_numCurrentPathLine << " time span(min):" << getTimeDiffMinutes(tmp.timestamp2, tmp.timestamp3) << std::endl;
|
||||
|
||||
//停止采集高光谱数据
|
||||
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
||||
//emit stopRecordHSISignal(m_numCurrentPathLine);
|
||||
if (m_cameraCtrl!=nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
m_isMoving2XMax = false;
|
||||
m_isImagerFrameNumberMeet = false;
|
||||
m_numCurrentPathLine++;
|
||||
processNextPathLine();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2XStartLoc)
|
||||
{
|
||||
m_isMoving2XStartLoc = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double TwoMotionCaptureCoordinator::getThre(double targetLoc,double actualLoc)
|
||||
{
|
||||
double targetLocTmp;
|
||||
if (targetLoc == 0)
|
||||
{
|
||||
targetLocTmp = 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLocTmp = targetLoc;
|
||||
}
|
||||
double thre = abs(targetLoc - actualLoc) / targetLocTmp * 100;
|
||||
|
||||
return thre;
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::startRecordHsi()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (!m_isMoving2XMin && !m_isMoving2YTargeLoc)
|
||||
{
|
||||
//开始采集高光谱数据
|
||||
PathLine &tmp = m_pathLines[m_numCurrentPathLine];
|
||||
tmp.timestamp2 = QDateTime::currentDateTime();
|
||||
std::cout << "start recording hsi, moving to " << tmp.targetXMaxPosition << std::endl;
|
||||
|
||||
m_isMoving2XMax = true;
|
||||
emit moveTo(0, tmp.targetXMaxPosition, tmp.speedTargetXMaxPosition, 1000);
|
||||
|
||||
emit startRecordHSISignal(m_numCurrentPathLine);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
{
|
||||
m_isImagerFrameNumberMeet = true;
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::handleError(const QString& error)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::processNextPathLine()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
int numPathLines = m_pathLines.size();
|
||||
|
||||
if (numPathLines == 0)
|
||||
{
|
||||
move2LocBeforeStart();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2YTargeLoc || m_isMoving2XMin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_numCurrentPathLine > numPathLines - 1)
|
||||
{
|
||||
std::cout << "\nAll path lines is finished! " << std::endl;
|
||||
|
||||
move2LocBeforeStart();
|
||||
savePathLinesToCsv();
|
||||
|
||||
emit sequenceComplete(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\nNew path line: " << m_numCurrentPathLine << std::endl;
|
||||
emit startRecordLineNumSignal(m_numCurrentPathLine);
|
||||
|
||||
PathLine &tmp = m_pathLines[m_numCurrentPathLine];
|
||||
tmp.timestamp1 = QDateTime::currentDateTime();
|
||||
|
||||
std::vector<double> loc;
|
||||
loc.push_back(tmp.targetXMinPosition);
|
||||
loc.push_back(tmp.targetYPosition);
|
||||
std::vector<double> speed;
|
||||
speed.push_back(tmp.speedTargetXMinPosition);
|
||||
speed.push_back(tmp.speedTargetYPosition);
|
||||
|
||||
m_isMoving2YTargeLoc = true;
|
||||
m_isMoving2XMin = true;
|
||||
emit moveTo(loc, speed, 1000);
|
||||
}
|
||||
|
||||
OneMotionCaptureCoordinator::OneMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_motorCtrl, SLOT(move(int, bool, double, int)));
|
||||
connect(this, &OneMotionCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &OneMotionCaptureCoordinator::handleMotorStoped);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &OneMotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, &OneMotionCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::start_record);
|
||||
connect(this, &OneMotionCaptureCoordinator::stopRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::stop_record);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
|
||||
this, &OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
}
|
||||
|
||||
OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
return;
|
||||
}
|
||||
|
||||
m_isRunning = true;
|
||||
m_pathLine = pathLine;
|
||||
|
||||
getLocBeforeStart();
|
||||
m_pathLine.startPosition = m_locBeforeStart[0];
|
||||
m_pathLine.timestamp1 = QDateTime::currentDateTime();
|
||||
|
||||
//移动马达并开始采集高光谱
|
||||
emit moveSignal(0, false, m_pathLine.speedRecord, 1000);
|
||||
emit startRecordHSISignal();
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
{
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::getLocBeforeStart()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(m_motorCtrl, &IrisMultiMotorController::locationSignal,
|
||||
[&](std::vector<double> pos) {
|
||||
m_locBeforeStart = pos;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_motorCtrl, "getLoc", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::move2LocBeforeStart()
|
||||
{
|
||||
std::cout << "\nmove2LocBeforeStart." << std::endl;
|
||||
|
||||
emit moveTo(0, m_locBeforeStart[0], m_pathLine.speedBack, 1000);
|
||||
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
bool OneMotionCaptureCoordinator::saveToCsv(const QString& filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "startTime,stopTime,startPosition,stopPosition\n";
|
||||
|
||||
out << m_pathLine.timestamp1.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< m_pathLine.timestamp2.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(m_pathLine.startPosition, 'f', 4) << ","
|
||||
<< QString::number(m_pathLine.stopPosition, 'f', 4) << "\n";
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleMotorStoped(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
// 记录位置信息
|
||||
m_pathLine.stopPosition = pos;
|
||||
m_pathLine.timestamp2 = QDateTime::currentDateTime();
|
||||
|
||||
//光谱仪停止采集,马达回到初始位置
|
||||
emit stopRecordHSISignal();
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleError(const QString& error)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
DarkAndWhiteCaptureCoordinator::DarkAndWhiteCaptureCoordinator(
|
||||
int model,
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_model(model)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_motorCtrl, SLOT(move(int, bool, double, int)));
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &DarkAndWhiteCaptureCoordinator::handleMotorStoped);
|
||||
|
||||
if (m_model == 0)//dark
|
||||
{
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::record_dark);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordDarlFinishSignal,
|
||||
this, &DarkAndWhiteCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
}
|
||||
else if(m_model == 1)//white
|
||||
{
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::record_white);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordWhiteFinishSignal,
|
||||
this, &DarkAndWhiteCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DarkAndWhiteCaptureCoordinator::~DarkAndWhiteCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::startStepMotion(double speed)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_isRunning = true;
|
||||
|
||||
m_speed = speed;
|
||||
|
||||
getLocBeforeStart();
|
||||
|
||||
//移动马达并开始采集高光谱
|
||||
emit moveSignal(0, false, m_speed, 1000);
|
||||
emit startRecordHSISignal();
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
{
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::getLocBeforeStart()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(m_motorCtrl, &IrisMultiMotorController::locationSignal,
|
||||
[&](std::vector<double> pos) {
|
||||
m_locBeforeStart = pos;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_motorCtrl, "getLoc", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::move2LocBeforeStart()
|
||||
{
|
||||
std::cout << "\nmove2LocBeforeStart." << std::endl;
|
||||
|
||||
emit moveTo(0, m_locBeforeStart[0], m_speed, 1000);
|
||||
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::handleMotorStoped(int motorID, double pos)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (!m_isRunning) return;
|
||||
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
}
|
||||
210
HPPA/CaptureCoordinator.h
Normal file
210
HPPA/CaptureCoordinator.h
Normal file
@ -0,0 +1,210 @@
|
||||
#pragma once
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "IrisMultiMotorController.h"
|
||||
|
||||
struct PathLine
|
||||
{
|
||||
double targetYPosition;
|
||||
double actualYPosition;
|
||||
double speedTargetYPosition;
|
||||
|
||||
double targetXMinPosition;
|
||||
double actualXMinPosition;
|
||||
double speedTargetXMinPosition;
|
||||
|
||||
double targetXMaxPosition;
|
||||
double actualXMaxPosition;
|
||||
double speedTargetXMaxPosition;
|
||||
|
||||
QDateTime timestamp1;//开始航线
|
||||
QDateTime timestamp2;//开始采集高光谱
|
||||
QDateTime timestamp3;//结束采集高光谱
|
||||
|
||||
PathLine(double targetYPosition_=0, double targetXMinPosition_ = 0, double targetXMaxPosition_ = 0)
|
||||
: targetYPosition(targetYPosition_), actualYPosition(0), speedTargetYPosition(0),
|
||||
targetXMinPosition(targetXMinPosition_), actualXMinPosition(0), speedTargetXMinPosition(0),
|
||||
targetXMaxPosition(targetXMaxPosition_), actualXMaxPosition(0), speedTargetXMaxPosition(0),
|
||||
timestamp1(QDateTime::currentDateTime()), timestamp2(QDateTime::currentDateTime()), timestamp3(QDateTime::currentDateTime()) {}
|
||||
};
|
||||
Q_DECLARE_METATYPE(PathLine);
|
||||
//Q_DECLARE_METATYPE(QVector<PathLine>);
|
||||
|
||||
class TwoMotionCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~TwoMotionCaptureCoordinator();
|
||||
|
||||
QVector<PathLine> pathLines() const;
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);//0:所有采集线正常运行完成,1:用户主动取消采集
|
||||
void startRecordLineNumSignal(int lineNum);
|
||||
void finishRecordLineNumSignal(int lineNum);
|
||||
|
||||
void startRecordHSISignal(int lineNum);
|
||||
void stopRecordHSISignal(int lineNum);
|
||||
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveTo(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void recordState(bool state);
|
||||
|
||||
private slots:
|
||||
void start(QVector<PathLine> pathLines);
|
||||
void stop();
|
||||
void getRecordState();
|
||||
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
void handleError(const QString& error);
|
||||
|
||||
void move2LocBeforeStart();
|
||||
|
||||
private:
|
||||
void processNextPathLine();
|
||||
void startRecordHsi();
|
||||
void getLocBeforeStart();
|
||||
double getThre(double targetLoc, double actualLoc);
|
||||
|
||||
double getTimeDiffMinutes(QDateTime startTime, QDateTime endTime);
|
||||
bool savePathLinesToCsv(QString filename= QString());
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl=nullptr;
|
||||
QVector<PathLine> m_pathLines;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
bool m_isMoving2YTargeLoc;
|
||||
bool m_isMoving2XMin;
|
||||
bool m_isMoving2XMax;
|
||||
|
||||
int m_retryLimit = 3;
|
||||
int m_retryTimesMoving2YTargeLoc;
|
||||
int m_retryTimesMoving2XMin;
|
||||
int m_retryTimesMoving2XMax;
|
||||
|
||||
bool m_isImagerFrameNumberMeet;//光谱仪帧数限制到了,主动停止采集
|
||||
std::vector<double> m_locBeforeStart;
|
||||
|
||||
bool m_isMoving2XStartLoc;
|
||||
bool m_isMoving2YStartLoc;
|
||||
|
||||
int m_numCurrentPathLine;
|
||||
};
|
||||
|
||||
|
||||
struct OneMotionCapturePathLine
|
||||
{
|
||||
double startPosition;
|
||||
double stopPosition;
|
||||
double speedRecord;
|
||||
double speedBack;
|
||||
|
||||
QDateTime timestamp1;//开始
|
||||
QDateTime timestamp2;//结束
|
||||
|
||||
OneMotionCapturePathLine()
|
||||
: startPosition(0), stopPosition(0), speedRecord(0), speedBack(0),
|
||||
timestamp1(QDateTime::currentDateTime()), timestamp2(QDateTime::currentDateTime()) {}
|
||||
};
|
||||
Q_DECLARE_METATYPE(OneMotionCapturePathLine);
|
||||
|
||||
class OneMotionCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OneMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~OneMotionCaptureCoordinator();
|
||||
|
||||
bool saveToCsv(const QString& filename);
|
||||
|
||||
public slots:
|
||||
void startStepMotion(OneMotionCapturePathLine pathLine);
|
||||
void stopStepMotion();
|
||||
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveSignal(int, bool, double, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void startRecordHSISignal();
|
||||
void stopRecordHSISignal();
|
||||
|
||||
private slots:
|
||||
void handleMotorStoped(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
void handleError(const QString& error);
|
||||
|
||||
private:
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
OneMotionCapturePathLine m_pathLine;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
|
||||
std::vector<double> m_locBeforeStart;
|
||||
void getLocBeforeStart();
|
||||
void move2LocBeforeStart();
|
||||
};
|
||||
|
||||
class DarkAndWhiteCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DarkAndWhiteCaptureCoordinator(int model, IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~DarkAndWhiteCaptureCoordinator();
|
||||
|
||||
public slots:
|
||||
void startStepMotion(double speed);
|
||||
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveSignal(int, bool, double, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void startRecordHSISignal();
|
||||
|
||||
private slots:
|
||||
void handleMotorStoped(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
|
||||
private:
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
|
||||
double m_speed;
|
||||
int m_model;//0:dark,1:white
|
||||
|
||||
std::vector<double> m_locBeforeStart;
|
||||
void getLocBeforeStart();
|
||||
void move2LocBeforeStart();
|
||||
};
|
||||
285
HPPA/Carousel.cpp
Normal file
285
HPPA/Carousel.cpp
Normal file
@ -0,0 +1,285 @@
|
||||
#include "Carousel.h"
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDebug>
|
||||
|
||||
MyCarousel::MyCarousel(QWidget* parent)
|
||||
: QWidget(parent),
|
||||
m_stackedWidget(new QStackedWidget(this)),
|
||||
m_bottomButtonOverlay(nullptr),
|
||||
m_bottomButtonLayout(nullptr),
|
||||
m_bottomButtonGroup(nullptr),
|
||||
m_currentIndex(0),
|
||||
m_isPlaying(false),
|
||||
m_isLocked(false),
|
||||
m_lockedIndex(-1),
|
||||
m_playInterval(2000),
|
||||
m_intervalButtonSize(40)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_stackedWidget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_autoPlayerTimer = new QTimer(this);
|
||||
connect(m_autoPlayerTimer, &QTimer::timeout,
|
||||
this, &MyCarousel::slideRight);
|
||||
|
||||
m_nomalQSS= R"(
|
||||
QPushButton
|
||||
{
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #FFFFFF;
|
||||
}
|
||||
QPushButton:checked
|
||||
{
|
||||
background-color: #08F8E8;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #08F8E8;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 5px;
|
||||
border: 1px solid red;
|
||||
}
|
||||
/*QPushButton:!checked {
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #FFFFFF;
|
||||
}*/
|
||||
)";
|
||||
|
||||
m_lockedQSS = R"(
|
||||
QPushButton
|
||||
{
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #FFFFFF;
|
||||
}
|
||||
QPushButton:checked
|
||||
{
|
||||
background-color: #08F8E8;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #08F8E8;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 5px;
|
||||
border: 1px solid red;
|
||||
}
|
||||
)";
|
||||
}
|
||||
|
||||
void MyCarousel::addWidget(QWidget* w)
|
||||
{
|
||||
m_widgets.append(w);
|
||||
m_stackedWidget->addWidget(w);
|
||||
updateStackedWidgetVisibility();
|
||||
}
|
||||
|
||||
void MyCarousel::play()
|
||||
{
|
||||
if (m_widgets.isEmpty())
|
||||
return;
|
||||
|
||||
m_isPlaying = true;
|
||||
|
||||
// 创建底部按钮
|
||||
m_bottomButtonLayout = new QHBoxLayout();
|
||||
m_bottomButtonGroup = new QButtonGroup(this);
|
||||
m_bottomButtons.clear();
|
||||
|
||||
for (int i = 0; i < m_widgets.size(); ++i) {
|
||||
QPushButton* btn = new QPushButton(this);
|
||||
btn->setCheckable(true);
|
||||
btn->setFixedSize(m_intervalButtonSize, 3);
|
||||
btn->setStyleSheet(m_nomalQSS);
|
||||
btn->setFixedHeight(10);
|
||||
btn->setFixedWidth(10);
|
||||
|
||||
m_bottomButtonLayout->addWidget(btn);
|
||||
m_bottomButtonGroup->addButton(btn, i);
|
||||
m_bottomButtons.append(btn);
|
||||
|
||||
connect(btn, &QPushButton::clicked, this, [this, i]() {
|
||||
onButtonClicked(i);
|
||||
});
|
||||
}
|
||||
|
||||
m_bottomButtonOverlay = new QWidget(this);
|
||||
m_bottomButtonOverlay->setLayout(m_bottomButtonLayout);
|
||||
m_bottomButtonOverlay->setAttribute(Qt::WA_TranslucentBackground);
|
||||
m_bottomButtonOverlay->show();
|
||||
|
||||
m_autoPlayerTimer->setInterval(m_playInterval);
|
||||
m_autoPlayerTimer->start();
|
||||
|
||||
updateStackedWidgetVisibility();
|
||||
}
|
||||
|
||||
void MyCarousel::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
showContextMenu(event->globalPos());
|
||||
}
|
||||
|
||||
void MyCarousel::showContextMenu(const QPoint& pos)
|
||||
{
|
||||
QMenu menu(this);
|
||||
menu.setStyleSheet(R"(
|
||||
QMenu {
|
||||
background-color: #2a5dec;
|
||||
color: white;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #1a4ddc;
|
||||
}
|
||||
QMenu::separator {
|
||||
height: 1px;
|
||||
background: white;
|
||||
}
|
||||
)");
|
||||
|
||||
QAction* startAct = menu.addAction(QString::fromLocal8Bit("开始轮播"));
|
||||
QAction* stopAct = menu.addAction(QString::fromLocal8Bit("停止轮播"));
|
||||
|
||||
menu.addSeparator();
|
||||
QAction* incAct = menu.addAction("+1");
|
||||
QAction* decAct = menu.addAction("-1");
|
||||
|
||||
if (!m_isLocked)
|
||||
startAct->setEnabled(false);
|
||||
|
||||
if (m_isLocked)
|
||||
stopAct->setEnabled(false);
|
||||
|
||||
QAction* act = menu.exec(pos);
|
||||
|
||||
if (act == startAct)
|
||||
startAutoPlay();
|
||||
else if (act == stopAct)
|
||||
stopAutoPlay();
|
||||
else if (act == incAct) {
|
||||
m_playInterval += 1000;
|
||||
m_autoPlayerTimer->setInterval(m_playInterval);
|
||||
}
|
||||
else if (act == decAct) {
|
||||
if (m_playInterval > 1)
|
||||
m_playInterval -= 1000;
|
||||
m_autoPlayerTimer->setInterval(m_playInterval);
|
||||
}
|
||||
}
|
||||
|
||||
void MyCarousel::startAutoPlay()
|
||||
{
|
||||
updateButtonState(m_currentIndex);
|
||||
}
|
||||
|
||||
void MyCarousel::stopAutoPlay()
|
||||
{
|
||||
updateButtonState(m_currentIndex);
|
||||
}
|
||||
|
||||
void MyCarousel::onButtonClicked(int index)
|
||||
{
|
||||
updateButtonState(index);
|
||||
gotoWidget(index);
|
||||
}
|
||||
|
||||
void MyCarousel::updateButtonState(int index)
|
||||
{
|
||||
if (m_isLocked)
|
||||
{
|
||||
if (index == m_lockedIndex) {
|
||||
// 解锁
|
||||
m_isLocked = false;
|
||||
m_lockedIndex = -1;
|
||||
|
||||
if (m_isPlaying)
|
||||
m_autoPlayerTimer->start();
|
||||
|
||||
restoreButtonStyle(index);
|
||||
}
|
||||
else {
|
||||
// 切换锁定
|
||||
restoreButtonStyle(m_lockedIndex);
|
||||
setButtonLocked(index);
|
||||
m_lockedIndex = index;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 初次锁定
|
||||
m_isLocked = true;
|
||||
m_lockedIndex = index;
|
||||
m_autoPlayerTimer->stop();
|
||||
setButtonLocked(index);
|
||||
}
|
||||
}
|
||||
|
||||
void MyCarousel::setButtonLocked(int index)
|
||||
{
|
||||
QPushButton* btn = m_bottomButtons[index];
|
||||
btn->setText("");
|
||||
btn->setStyleSheet(m_lockedQSS);
|
||||
}
|
||||
|
||||
void MyCarousel::restoreButtonStyle(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
QPushButton* btn = m_bottomButtons[index];
|
||||
btn->setText("");
|
||||
btn->setStyleSheet(m_nomalQSS);
|
||||
}
|
||||
|
||||
void MyCarousel::slideLeft()
|
||||
{
|
||||
if (m_widgets.isEmpty() || m_isLocked || !m_isPlaying)
|
||||
return;
|
||||
|
||||
m_currentIndex = (m_currentIndex - 1 + m_widgets.size()) % m_widgets.size();
|
||||
updateStackedWidgetVisibility();
|
||||
}
|
||||
|
||||
void MyCarousel::slideRight()
|
||||
{
|
||||
if (m_widgets.isEmpty() || m_isLocked || !m_isPlaying)
|
||||
return;
|
||||
|
||||
m_currentIndex = (m_currentIndex + 1) % m_widgets.size();
|
||||
updateStackedWidgetVisibility();
|
||||
}
|
||||
|
||||
void MyCarousel::gotoWidget(int index)
|
||||
{
|
||||
m_currentIndex = index;
|
||||
updateStackedWidgetVisibility();
|
||||
}
|
||||
|
||||
void MyCarousel::updateStackedWidgetVisibility()
|
||||
{
|
||||
if (m_widgets.isEmpty())
|
||||
return;
|
||||
|
||||
m_stackedWidget->setCurrentIndex(m_currentIndex);
|
||||
|
||||
if (!m_isLocked) {
|
||||
for (int i = 0; i < m_bottomButtons.size(); ++i)
|
||||
m_bottomButtons[i]->setChecked(i == m_currentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void MyCarousel::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
if (!m_bottomButtonOverlay)
|
||||
return;
|
||||
|
||||
int count = m_widgets.size();
|
||||
int totalWidth = m_intervalButtonSize * count + 10 * (count - 1);
|
||||
|
||||
int x = (width() - totalWidth) / 2;
|
||||
int y = height() - m_intervalButtonSize;
|
||||
|
||||
m_bottomButtonOverlay->setGeometry(x, y, totalWidth, m_intervalButtonSize);
|
||||
}
|
||||
66
HPPA/Carousel.h
Normal file
66
HPPA/Carousel.h
Normal file
@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QStackedWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <QTimer>
|
||||
#include <QMenu>
|
||||
|
||||
class MyCarousel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MyCarousel(QWidget* parent = nullptr);
|
||||
|
||||
void addWidget(QWidget* w);
|
||||
void play();
|
||||
void gotoWidget(int index);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void slideLeft();
|
||||
void slideRight();
|
||||
void onButtonClicked(int index);
|
||||
|
||||
private:
|
||||
// UI
|
||||
QStackedWidget* m_stackedWidget;
|
||||
QWidget* m_bottomButtonOverlay;
|
||||
QHBoxLayout* m_bottomButtonLayout;
|
||||
QButtonGroup* m_bottomButtonGroup;
|
||||
|
||||
QVector<QWidget*> m_widgets;
|
||||
QVector<QPushButton*> m_bottomButtons;
|
||||
QString m_nomalQSS;
|
||||
QString m_lockedQSS;
|
||||
|
||||
// ״ֵ̬
|
||||
int m_currentIndex;
|
||||
bool m_isPlaying;
|
||||
bool m_isLocked;
|
||||
int m_lockedIndex;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
int m_playInterval;
|
||||
int m_intervalButtonSize;
|
||||
|
||||
QTimer* m_autoPlayerTimer;
|
||||
|
||||
private:
|
||||
void updateStackedWidgetVisibility();
|
||||
void updateButtonState(int index);
|
||||
|
||||
void setButtonLocked(int index);
|
||||
void restoreButtonStyle(int index);
|
||||
|
||||
void showContextMenu(const QPoint& pos);
|
||||
|
||||
void startAutoPlay();
|
||||
void stopAutoPlay();
|
||||
};
|
||||
204
HPPA/CustomDockWidgetBase.cpp
Normal file
204
HPPA/CustomDockWidgetBase.cpp
Normal file
@ -0,0 +1,204 @@
|
||||
#include "CustomDockWidgetBase.h"
|
||||
|
||||
CustomDockWidgetBase::CustomDockWidgetBase(QMainWindow* parent)
|
||||
: QDockWidget(parent),
|
||||
m_mainWindow(parent),
|
||||
m_isMaximized(false)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
CustomDockWidgetBase::CustomDockWidgetBase(QString title, QMainWindow* parent)
|
||||
: QDockWidget(title, parent),
|
||||
m_mainWindow(parent),
|
||||
m_isMaximized(false)
|
||||
{
|
||||
initialize();
|
||||
setTile(title);
|
||||
}
|
||||
|
||||
void CustomDockWidgetBase::initialize()
|
||||
{
|
||||
QWidget* titleBar_Background = new QWidget(this);
|
||||
titleBar_Background->setObjectName("titleBar_Background");
|
||||
QGridLayout* layout_titleBar_Background = new QGridLayout(titleBar_Background);
|
||||
layout_titleBar_Background->setContentsMargins(0, 0, 0, 0);
|
||||
titleBar_Background->setStyleSheet(R"(
|
||||
QWidget #titleBar_Background{
|
||||
background: #040125;
|
||||
}
|
||||
)");
|
||||
|
||||
QWidget* titleBar = new QWidget(titleBar_Background);
|
||||
titleBar->setObjectName("titleBar");
|
||||
QHBoxLayout* layout = new QHBoxLayout(titleBar);
|
||||
titleBar->setFixedHeight(30);
|
||||
|
||||
title_label = new QLabel(titleBar);
|
||||
|
||||
layout->setContentsMargins(10, 0, 10, 0);
|
||||
layout->addWidget(title_label);
|
||||
layout->addStretch();
|
||||
|
||||
m_maxButton = new QToolButton(titleBar);
|
||||
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
|
||||
|
||||
layout->addWidget(m_maxButton);
|
||||
|
||||
titleBar->setStyleSheet(R"(
|
||||
QWidget #titleBar{
|
||||
background: #0E1C4C;
|
||||
/*border: 4px solid #2c586b;*/
|
||||
/*padding-top: 10px;
|
||||
padding-bottom: 10px;*/
|
||||
|
||||
border-top: 1px solid #2c586b;
|
||||
border-left: 1px solid #2c586b;
|
||||
border-right: 1px solid #2c586b;
|
||||
border-bottom: none; /* ȡ<><C8A1><EFBFBD>ײ<EFBFBD><D7B2>߿<EFBFBD> */
|
||||
|
||||
border-top-left-radius: 5px;
|
||||
border-top-right-radius: 5px;
|
||||
}
|
||||
)");
|
||||
title_label->setStyleSheet("color: white;");
|
||||
m_maxButton->setStyleSheet("");
|
||||
|
||||
layout_titleBar_Background->addWidget(titleBar);
|
||||
|
||||
setTitleBarWidget(titleBar_Background);
|
||||
setFeatures(QDockWidget::DockWidgetClosable);
|
||||
connect(m_maxButton, &QToolButton::clicked, this, &CustomDockWidgetBase::toggleMaximize);
|
||||
}
|
||||
|
||||
void CustomDockWidgetBase::setTile(QString title)
|
||||
{
|
||||
title_label->setText(title);
|
||||
}
|
||||
|
||||
void CustomDockWidgetBase::hideMaxButton()
|
||||
{
|
||||
m_maxButton->hide();
|
||||
}
|
||||
|
||||
void CustomDockWidgetBase::toggleMaximize()
|
||||
{
|
||||
if (!m_isMaximized)
|
||||
{
|
||||
m_hiddenDocks.clear();
|
||||
m_originalSizes.clear();
|
||||
|
||||
m_savedState = m_mainWindow->saveState();
|
||||
|
||||
const QList<QDockWidget*> docks = m_mainWindow->findChildren<QDockWidget*>();
|
||||
for (QDockWidget* dock : docks)
|
||||
{
|
||||
m_originalSizes[dock] = dock->size();
|
||||
if (dock != this && dock->isVisible())
|
||||
{
|
||||
dock->hide();
|
||||
m_hiddenDocks.append(dock);
|
||||
}
|
||||
}
|
||||
|
||||
m_isMaximized = true;
|
||||
emit maximizeStateChanged(m_isMaximized);
|
||||
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (QDockWidget* dock : m_hiddenDocks)
|
||||
{
|
||||
dock->show();
|
||||
}
|
||||
|
||||
if (!m_savedState.isEmpty())
|
||||
{
|
||||
m_mainWindow->restoreState(m_savedState);
|
||||
m_savedState.clear();
|
||||
}
|
||||
|
||||
QList<QDockWidget*> docks;
|
||||
QList<int> widths, heights;
|
||||
for (auto it = m_originalSizes.begin(); it != m_originalSizes.end(); ++it)
|
||||
{
|
||||
docks.append(it.key());
|
||||
widths.append(it.value().width());
|
||||
heights.append(it.value().height());
|
||||
}
|
||||
|
||||
m_mainWindow->resizeDocks(docks, widths, Qt::Horizontal);
|
||||
m_mainWindow->resizeDocks(docks, heights, Qt::Vertical);
|
||||
|
||||
m_isMaximized = false;
|
||||
emit maximizeStateChanged(m_isMaximized);
|
||||
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CustomDockWidgetHideAbove::CustomDockWidgetHideAbove(QString title, QMainWindow* parent)
|
||||
:CustomDockWidgetBase(title, parent)
|
||||
{
|
||||
|
||||
}
|
||||
CustomDockWidgetHideAbove::CustomDockWidgetHideAbove(QMainWindow* parent)
|
||||
:CustomDockWidgetBase(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CustomDockWidgetHideAbove::toggleMaximize()
|
||||
{
|
||||
if (!m_isMaximized)
|
||||
{
|
||||
m_hiddenDocks.clear();
|
||||
m_originalSizes.clear();
|
||||
|
||||
m_savedState = m_mainWindow->saveState();
|
||||
|
||||
const QList<QDockWidget*> docks = m_mainWindow->findChildren<QDockWidget*>();
|
||||
for (QDockWidget* dock : docks)
|
||||
{
|
||||
m_originalSizes[dock] = dock->size();
|
||||
if (dock->objectName().contains("mDockCarousel") && dock->isVisible())
|
||||
{
|
||||
dock->hide();
|
||||
m_hiddenDocks.append(dock);
|
||||
}
|
||||
}
|
||||
|
||||
m_isMaximized = true;
|
||||
emit maximizeStateChanged(m_isMaximized);
|
||||
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (QDockWidget* dock : m_hiddenDocks)
|
||||
{
|
||||
dock->show();
|
||||
}
|
||||
|
||||
if (!m_savedState.isEmpty())
|
||||
{
|
||||
m_mainWindow->restoreState(m_savedState);
|
||||
m_savedState.clear();
|
||||
}
|
||||
|
||||
//QList<QDockWidget*> docks;
|
||||
//QList<int> widths, heights;
|
||||
//for (auto it = m_originalSizes.begin(); it != m_originalSizes.end(); ++it)
|
||||
//{
|
||||
// docks.append(it.key());
|
||||
// widths.append(it.value().width());
|
||||
// heights.append(it.value().height());
|
||||
//}
|
||||
|
||||
//m_mainWindow->resizeDocks(docks, widths, Qt::Horizontal);
|
||||
//m_mainWindow->resizeDocks(docks, heights, Qt::Vertical);
|
||||
|
||||
m_isMaximized = false;
|
||||
emit maximizeStateChanged(m_isMaximized);
|
||||
m_maxButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton));
|
||||
}
|
||||
}
|
||||
53
HPPA/CustomDockWidgetBase.h
Normal file
53
HPPA/CustomDockWidgetBase.h
Normal file
@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#include <QDockWidget>
|
||||
#include <QToolButton>
|
||||
#include <QStyle>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMainWindow>
|
||||
#include <QMap>
|
||||
#include <QSize>
|
||||
#include <QLabel>
|
||||
|
||||
class CustomDockWidgetBase :
|
||||
public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomDockWidgetBase(QString title, QMainWindow* parent = nullptr);
|
||||
explicit CustomDockWidgetBase(QMainWindow* parent = nullptr);
|
||||
void setTile(QString title);
|
||||
void hideMaxButton();
|
||||
|
||||
public slots:
|
||||
virtual void toggleMaximize();
|
||||
|
||||
signals:
|
||||
void maximizeStateChanged(bool isMaximized);
|
||||
|
||||
protected:
|
||||
QMainWindow* m_mainWindow = nullptr;
|
||||
QToolButton* m_maxButton = nullptr;
|
||||
bool m_isMaximized = false;
|
||||
|
||||
QList<QDockWidget*> m_hiddenDocks;
|
||||
QByteArray m_savedState;
|
||||
QMap<QDockWidget*, QSize> m_originalSizes;
|
||||
|
||||
QLabel* title_label;
|
||||
void initialize();
|
||||
};
|
||||
|
||||
class CustomDockWidgetHideAbove :
|
||||
public CustomDockWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomDockWidgetHideAbove(QString title, QMainWindow* parent = nullptr);
|
||||
explicit CustomDockWidgetHideAbove(QMainWindow* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void toggleMaximize();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
@ -6,217 +6,616 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>332</height>
|
||||
<width>557</width>
|
||||
<height>432</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="HPPA.qrc">
|
||||
<normaloff>:/HPPA/HPPA.ico</normaloff>:/HPPA/HPPA.ico</iconset>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
background-color: #142D7F;
|
||||
color: #e6eeff;
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
padding: 4px 8px;
|
||||
min-width: 70px;
|
||||
min-height: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
QGroupBox
|
||||
{
|
||||
border: 12px solid transparent;
|
||||
/*border-top: 12px solid transparent;
|
||||
border-right: 0px solid transparent;
|
||||
border-bottom: 0px solid transparent;
|
||||
border-left: 0px solid transparent;*/
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 10pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
height: 10px;
|
||||
background: #1e2a44;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 已滑过:渐变蓝 */
|
||||
QSlider::sub-page:horizontal {
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1f4fff,
|
||||
stop:0.5 #2f6bff,
|
||||
stop:1 #5fa0ff
|
||||
);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 未滑过 */
|
||||
QSlider::add-page:horizontal {
|
||||
height: 10px;
|
||||
background: #2a3550;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* ===== 滑块按钮 ===== */
|
||||
QSlider::handle:horizontal {
|
||||
width: 15px;
|
||||
height: 10px;
|
||||
|
||||
/* 蓝色实心 */
|
||||
background: #2f6bff;
|
||||
|
||||
/* 白色外圈 */
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 5px;
|
||||
|
||||
/* 垂直居中 */
|
||||
margin: -5px 0;
|
||||
}
|
||||
|
||||
/* 悬停 */
|
||||
QSlider::handle:horizontal:hover {
|
||||
background: #4d8dff;
|
||||
}
|
||||
|
||||
/* 按下 */
|
||||
QSlider::handle:horizontal:pressed {
|
||||
background: #1f4fff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QGroupBox" name="connectFocusModule_groupBox">
|
||||
<property name="title">
|
||||
<string>连接调焦模块</string>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="contentWidget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #contentWidget
|
||||
{
|
||||
background: #040125;
|
||||
/*border-radius: 8px 8px 8px 8px;*/
|
||||
border: 1px solid #2f6bff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>线性平台</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="motorPort_comboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="ultrasoundPort_comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>连接线性平台</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="controlFocus_groupBox">
|
||||
<property name="title">
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>171</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="manualFocus_btn">
|
||||
<property name="text">
|
||||
<string>手动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="controlMotor_groupBox">
|
||||
<property name="title">
|
||||
<string>调整线性平台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="updateCurrentLocation_btn">
|
||||
<widget class="QWidget" name="titlebarWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="currentLocation_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>46</height>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>null</string>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #titlebarWidget
|
||||
{
|
||||
background: #0E1C4C;
|
||||
border: 1px solid #2f6bff;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="iconLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>505</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="closeBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="HPPA.qrc">
|
||||
<normaloff>:/svg/resources/icons/svg/close.svg</normaloff>:/svg/resources/icons/svg/close.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>46</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>50</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>46</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>50</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="max_btn">
|
||||
<property name="text">
|
||||
<string>max</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="connectFocusModule_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #connectFocusModule_widget
|
||||
{
|
||||
background: #121945;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}
|
||||
|
||||
QRadioButton
|
||||
{
|
||||
color: #E2EDFF;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接调焦模块</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>线性平台</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="motorPort_comboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="ultrasoundPort_comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="is_new_version_radioButton">
|
||||
<property name="text">
|
||||
<string>新版</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>107</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>连接线性平台</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="controlMotor_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #controlMotor_widget
|
||||
{
|
||||
background: #121945;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="move2_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="updateCurrentLocation_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新实时位置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="currentLocation_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>null</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="max_btn">
|
||||
<property name="text">
|
||||
<string>max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>调整线性平台</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="controlFocus_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #controlFocus_widget
|
||||
{
|
||||
background: #121945;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>采样率</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="sample_ratio_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>20</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QProgressBar {
|
||||
border: 2px solid #08FACE; /* 边框颜色和宽度 */
|
||||
border-radius: 8px; /* 圆角 */
|
||||
background-color: #eee; /* 未完成部分颜色 */
|
||||
text-align: center; /* 百分比文本居中 */
|
||||
height: 13px; /* 高度 */
|
||||
}
|
||||
|
||||
QProgressBar::chunk {
|
||||
background-color: #08FACE; /* 渐变色进度块 */
|
||||
border-radius: 8px; /* 保持和整体圆角一致 */
|
||||
}</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>171</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="manualFocus_btn">
|
||||
<property name="text">
|
||||
<string>手动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
3324
HPPA/HPPA.cpp
3324
HPPA/HPPA.cpp
File diff suppressed because it is too large
Load Diff
292
HPPA/HPPA.h
292
HPPA/HPPA.h
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
@ -12,11 +12,14 @@
|
||||
#include <QLineSeries>
|
||||
#include <QChart>
|
||||
#include <QChartView>
|
||||
#include <QValueAxis>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QVector>
|
||||
#include <QItemSelection>
|
||||
|
||||
#include "ui_HPPA.h"
|
||||
#include "resononImager.h"
|
||||
@ -32,9 +35,10 @@
|
||||
#include "aboutWindow.h"
|
||||
#include "adjustTable.h"
|
||||
#include "PowerControl.h"
|
||||
#include "PathPlan.h"
|
||||
#include "RobotArmControl.h"
|
||||
#include "OneMotorControl.h"
|
||||
#include "TwoMotorControl.h"
|
||||
#include "imageControl.h"
|
||||
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
@ -42,9 +46,36 @@
|
||||
#include "ResononNirImager.h"
|
||||
#include "Corning410Imager.h"
|
||||
|
||||
#include "CustomDockWidgetBase.h"
|
||||
#include "Carousel.h"
|
||||
|
||||
#include "View3D.h"
|
||||
#include "TabManager.h"
|
||||
|
||||
#include "View3DModelManager.h"
|
||||
|
||||
#include "LayerTreeModel.h"
|
||||
#include "LayerTree.h"
|
||||
#include "MapLayer.h"
|
||||
#include "MapLayerStore.h"
|
||||
|
||||
#include "LayerTreeView.h"
|
||||
#include "LayerTreeViewMenuProvider.h"
|
||||
|
||||
#include "MapTool.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "MapToolSpectral.h"
|
||||
#include "MapTools.h"
|
||||
|
||||
#include "AspectRatioLabel.h"
|
||||
|
||||
#include "HyperImagerControl.h"
|
||||
|
||||
#include "recordFrameCounter.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<EFBFBD><EFBFBD> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
QT_CHARTS_USE_NAMESPACE//QChartView 使用 需要加宏, 否则无法使用
|
||||
|
||||
class WorkerThread : public QThread
|
||||
{
|
||||
@ -71,11 +102,11 @@ public:
|
||||
// //double x = m_Imager->m_ResononImager.get_framerate();
|
||||
// int x = m_Imager->m_ResononImager.get_band_count();
|
||||
|
||||
// std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>slopeΪ<EFBFBD><EFBFBD>" << x << std::endl;
|
||||
// std::cout << "相机连接正常!slope为:" << x << std::endl;
|
||||
// }
|
||||
// catch (std::runtime_error *e)//CException *e
|
||||
// {
|
||||
// std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>" << e->what() << std::endl;
|
||||
// std::cout << "相机断开连接!" << e->what() << std::endl;
|
||||
// }
|
||||
// Sleep(1000);
|
||||
// }
|
||||
@ -123,34 +154,29 @@ signals:
|
||||
void threadSignal(QString s);
|
||||
};
|
||||
|
||||
|
||||
class ForLoopControl :public QObject
|
||||
class WidgetWithBackgroundPicture : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ForLoopControl();
|
||||
~ForLoopControl();
|
||||
|
||||
void setLoopCount(int loopCount);
|
||||
int getLoopCount() const;
|
||||
|
||||
bool m_boolRecordNextLine;
|
||||
bool m_boolQuitLoop;
|
||||
explicit WidgetWithBackgroundPicture(QWidget* parent = nullptr)
|
||||
: QWidget(parent),
|
||||
m_pixmap(":/png/resources/icons/png/titile_bar_bgp.png") // 使用资源或绝对路径
|
||||
{
|
||||
// 可选:设置初始大小
|
||||
resize(800, 600);
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override
|
||||
{
|
||||
QPainter painter(this);
|
||||
QPixmap scaled = m_pixmap.scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
painter.drawPixmap(rect(), scaled);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_loopCount;
|
||||
|
||||
|
||||
public slots:
|
||||
void startLoop();
|
||||
|
||||
signals:
|
||||
//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źŷ<C5BA><C5B7><EFBFBD><EFBFBD><EFBFBD>ֵʱ<D6B5><CAB1>intֵ<74><D6B5><EFBFBD><EFBFBD><EFBFBD>òɼ<C3B2><C9BC>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ˣ<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źŷ<C5BA><C5B7>为ֵʱ<D6B5><CAB1>-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ֹ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>-2<><32><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ֹ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void recordSignal(int);
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
||||
class HPPA : public QMainWindow
|
||||
@ -161,17 +187,23 @@ public:
|
||||
HPPA(QWidget *parent = Q_NULLPTR);
|
||||
~HPPA();
|
||||
|
||||
void CalculateIntegratioinTimeRange();//ͨ<><CDA8>֡<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䷶Χ<E4B7B6><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>slider<65><72><EFBFBD><EFBFBD>ֵ
|
||||
static HPPA* instance();
|
||||
LayerTreeNode* rasterGroupNode() const;
|
||||
|
||||
WorkerThread * m_TestImagerStausThread;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
WorkerThread * m_TestImagerStausThread;//检测相机连接状态的线程
|
||||
|
||||
private:
|
||||
static HPPA* s_instance;
|
||||
Ui::HPPAClass ui;
|
||||
QTabWidget* m_imageViewerTabWidget;
|
||||
|
||||
QMenu* mPanelMenu = nullptr;
|
||||
QMenu* mToolbarMenu = nullptr;
|
||||
|
||||
void initMenubarToolbar();
|
||||
void initPanelToolbar();
|
||||
void initControlTabwidget();
|
||||
QWidget* tmp(QWidget* a);
|
||||
|
||||
QLineEdit * frame_number;
|
||||
QLineEdit * m_FilenameLineEdit;
|
||||
@ -180,60 +212,33 @@ private:
|
||||
|
||||
Configfile mConfigfile;
|
||||
|
||||
ForLoopControl * m_ForLoopControl;
|
||||
ImagerOperationBase* m_Imager;//
|
||||
|
||||
int m_RecordState;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD>ȡ2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD>0 <20><> ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
int m_RecordState;//用来控制相机采集流程,取2的余数,1 → 正在采集,0 → 停止采集
|
||||
|
||||
QThread * m_ForLoopControlThread;//
|
||||
QThread * m_RecordThread;//Ӱ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
QThread * m_RgbCameraThread;//rgb<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡͼ<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
QThread * m_CopyFileThread;//Ӱ<><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
QThread * m_RecordThread;//影像采集线程
|
||||
QThread * m_RgbCameraThread;//rgb相机获取图像线程
|
||||
QThread * m_CopyFileThread;//影像文件复制线程
|
||||
FileOperation * m_FileOperation;
|
||||
|
||||
QChartView * m_chartView;
|
||||
QChart* m_chart;
|
||||
|
||||
//QLineSeries *series;
|
||||
//QChart *chart;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
VinceControl *m_yMotor;
|
||||
VinceControl *m_xMotor;
|
||||
|
||||
long m_lXmotorLocationOfStartRecord;//<2F><>ʼ<EFBFBD>ɼ<EFBFBD>ǰx<C7B0><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
long m_lYmotorLocationOfStartRecord;//<2F><>ʼ<EFBFBD>ɼ<EFBFBD>ǰy<C7B0><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
|
||||
unsigned long m_lManualSpeedOfXMotor;//X<><58><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6>ٶȣ<D9B6>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+X<><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>12000*0.00052734375=6.328125cm/s
|
||||
unsigned long m_lManualSpeedOfYMotor;//Y<><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ͬ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>װ<EFBFBD>ã<EFBFBD>ʵ<EFBFBD><CAB5>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>=X<><58><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>/5
|
||||
|
||||
int m_xConnectCount;//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>0<EFBFBD><30><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD>1<EFBFBD><31><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬Ϊ1ʱ<31><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>
|
||||
int m_yConnectCount;
|
||||
|
||||
QTimer *m_timerMoveXmotor;
|
||||
QTimer *m_timerMoveYmotor;
|
||||
|
||||
QTimer *m_timerTestRangeOfxMotor;//<2F><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QTimer *m_timerTestRangeOfyMotor;//<2F><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QTimer *m_timerLocationFeedBackOfMotor_x_y;//<2F><><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ƣ<EFBFBD>x/y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Զ<EFBFBD><D4B6>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>slider<65><72>
|
||||
QTimer *m_timerYmotorLocationFeedBackAfterRecord;//<2F>ɼ<EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>ɺ<C9BA><F3A3ACBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʵʱ<CAB5><CAB1><EFBFBD>ص<EFBFBD>slider<65><72>
|
||||
|
||||
QString operateWidget;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD>
|
||||
QString operateWidget;//当前操作的控件名
|
||||
|
||||
bool isMotorConnected(VinceControl *motor);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false
|
||||
void SetXMotorWidgetEnable(bool enable);
|
||||
void SetYMotorWidgetEnable(bool enable);
|
||||
void setMotorRange();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̷<EFBFBD>Χ
|
||||
|
||||
//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
double widthScale;//QGraphicsView<65><77>viewport<72><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>widthScale = rect.width() / maxDistance;
|
||||
double heightScale;//QGraphicsView<65><77>viewport<72>ߺ<EFBFBD><DFBA><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>heightScale = rect.height() / maxDistance;
|
||||
//模拟相机位置
|
||||
double widthScale;//QGraphicsView的viewport宽和真实距离比例:widthScale = rect.width() / maxDistance;
|
||||
double heightScale;//QGraphicsView的viewport高和真实距离比例:heightScale = rect.height() / maxDistance;
|
||||
void setImagerSimulationPos(double x, double y);//ui.graphicsView->imager->setPos(x, y);
|
||||
|
||||
//<EFBFBD>ɼ<EFBFBD><EFBFBD>߹滮
|
||||
int m_numberOfRecording;//<EFBFBD><EFBFBD>ʾui.recordLine_tableWidget<EFBFBD>еĵڼ<EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD>
|
||||
//采集线规划
|
||||
int m_numberOfRecording;//表示ui.recordLine_tableWidget中的第几行 → 正在采集第几条线
|
||||
|
||||
//
|
||||
int m_TabWidgetCurrentIndex;//<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ѡ<EFBFBD><EFBFBD>TabWidget<EFBFBD>ı<EFBFBD>ǩʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>仯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>tab index
|
||||
int m_TabWidgetCurrentIndex;//当手动选择TabWidget的标签时,记录变化后的tab index
|
||||
RgbCameraOperation *m_RgbCamera;
|
||||
|
||||
void getRequest(QString str);
|
||||
@ -241,121 +246,128 @@ private:
|
||||
QActionGroup* mImagerGroup = nullptr;
|
||||
void createActionGroups();
|
||||
void selectingImager(QAction* selectedAction);
|
||||
void updateImagerPicture(const QString& actionName);
|
||||
|
||||
QActionGroup* moveplatformActionGroup = nullptr;
|
||||
void createMoveplatformActionGroup();
|
||||
void selectingMoveplatform(QAction* selectedAction);
|
||||
RobotArmControl* rac;
|
||||
|
||||
OneMotorControl* omc;
|
||||
QDockWidget* dock_omc;
|
||||
QActionGroup* m_ScenarioActionGroup = nullptr;
|
||||
void createScenarioActionGroup();
|
||||
void selectScenario(QAction* selectedAction);
|
||||
|
||||
|
||||
|
||||
|
||||
PathPlan* m_pathPlan;
|
||||
|
||||
FILE* m_hTimesFile;
|
||||
|
||||
CustomDockWidgetBase* m_dock_carousel;
|
||||
|
||||
MyCarousel* m_carousel;
|
||||
QLabel* m_cam_label;
|
||||
QPushButton* m_open_rgb_camera_btn;
|
||||
QPushButton* m_close_rgb_camera_btn;
|
||||
|
||||
TabManager* m_tabManager;
|
||||
|
||||
HyperImagerControl* m_hic;
|
||||
ImageControl* m_ic;
|
||||
adjustTable* m_adt;
|
||||
PowerControl* m_pc;
|
||||
RobotArmControl* m_rac;
|
||||
OneMotorControl* m_omc;
|
||||
TwoMotorControl* m_tmc;
|
||||
|
||||
View3DModelManager* m_view3DModelManager;
|
||||
|
||||
LayerTreeView* m_layerTreeView;
|
||||
LayerTree* m_LayerTree = nullptr;
|
||||
LayerTreeModel* m_LayerTreeModel = nullptr;
|
||||
LayerTreeNode* m_RasterGroup = nullptr; // 指向 "Raster" 分组,便于后续添加 layer
|
||||
|
||||
MapLayerStore* m_MapLayerStore = nullptr;
|
||||
|
||||
// Map tools
|
||||
MapTools* m_mapTools = nullptr;
|
||||
QActionGroup* m_mapToolActionGroup = nullptr;
|
||||
void initMapTools();
|
||||
void setMapTool();
|
||||
|
||||
QWidget* m_focusTab=nullptr;
|
||||
|
||||
recordFrameCounter* m_recordFrameCounter = nullptr;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage(int number);
|
||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
||||
void PlotSpectral(int state);
|
||||
void onRecordFinishedSignal_WhenFrameNumberMeet();
|
||||
void onRecordFinishedSignal_WhenFrameNumberNotMeet();
|
||||
void onsequenceComplete();
|
||||
|
||||
void onExit();
|
||||
void onconnect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void testImagerStatus();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
void onOpenImg();
|
||||
void onconnect();//连接相机
|
||||
void testImagerStatus();//获取相机状态:连接是否正常
|
||||
void autoExposureFinished();
|
||||
void onAutoExposure();
|
||||
void onFocus1();
|
||||
void onFocus2(int command);
|
||||
void onFocusWindowClosed();
|
||||
void onAbout();
|
||||
void onDark();
|
||||
void recordDarkFinish();
|
||||
void onReference();
|
||||
void recordWhiteFinish();
|
||||
void onStartRecordStep1();
|
||||
void onStartRecordStep2(int lineNumber);
|
||||
void onCreateTab(int trackNumber);
|
||||
QWidget* onCreateTab(QString tabName);
|
||||
void onTabWidgetCurrentChanged(int index);
|
||||
void onActionOpenDirectory();
|
||||
|
||||
void OnFramerateLineeditEditingFinished();//
|
||||
void OnFramerateSliderChanged(double framerate);//
|
||||
void onFramerateChanged(double framerate);
|
||||
void onIntegrationTimeChanged(double integrationTime);
|
||||
void onGainChanged(double gain);
|
||||
|
||||
void OnIntegratioinTimeEditingFinished();//
|
||||
void OnIntegratioinTimeSliderChanged(double IntegratioinTime);//
|
||||
void OnGainEditingFinished();//
|
||||
void OnGainSliderChanged(double Gain);//
|
||||
|
||||
void onLeftMouseButtonPressed(int x, int y);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
void onLeftMouseButtonPressed(int x, int y, QVector<double> wavelengths, QVector<double> spectrum);//点击影像像元显示光谱
|
||||
void setAxis(QValueAxis* axisX, QValueAxis* axisY);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
void deleteMotor();
|
||||
void newMotor();
|
||||
void timerEvent(QTimerEvent *event);
|
||||
void setMotorParamMicroscope(VinceControl* motor);
|
||||
void setXMotorParamFromCfgFile(VinceControl* motor);
|
||||
void setYMotorParamFromCfgFile(VinceControl* motor);
|
||||
void timerEvent(QTimerEvent *event);
|
||||
//
|
||||
void onimagerSimulatorMove(int x, int y);
|
||||
void OnSendLogToCallClass(QString str);
|
||||
|
||||
void onPlotRgbImage();
|
||||
void onCloseRgbCamera();
|
||||
void onClearLabel();
|
||||
|
||||
void onxMotorLeft();
|
||||
void onxMotorRight();
|
||||
void onxMotorStop();
|
||||
void onCopyFinished();
|
||||
|
||||
void onyMotorForward();
|
||||
void onyMotorBackward();
|
||||
void onyMotorStop();
|
||||
void requestFinished(QNetworkReply* reply);
|
||||
|
||||
void onMotorReset();
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
|
||||
void OnXmotorSpeedEditingFinished();
|
||||
void createOneMotorScenario();
|
||||
void createPlantPhenotypeScenario();
|
||||
void onCreated3DModelPlantPhenotype();
|
||||
void onCreated3DModelOneMotor();
|
||||
|
||||
void ontimerLocationFeedBackOfMotor_x_y();
|
||||
void ontimerYmotorLocationFeedBackAfterRecord();
|
||||
void addLayer(const QString& baseName, const QString& filePath, bool refresh);
|
||||
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex);
|
||||
void removeLayerByTreeIndex();
|
||||
void removeAllLayersInRasterGroup();
|
||||
|
||||
void OnXmotorSpeedLineeditEditingFinished();
|
||||
void OnXmotorSpeedSliderChanged(double speed);
|
||||
void OnXmotorLocationLineeditEditingFinished();
|
||||
void OnXmotorLocationSliderChanged(double location);
|
||||
void OnXmotorLocationSliderReleased();
|
||||
void onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
void onBandSelectionChanged(double rWave, double gWave, double bWave);
|
||||
|
||||
void onMapToolPanTriggered();
|
||||
void onMapToolSpectralTriggered();
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
void OnYmotorLocationLineeditEditingFinished();
|
||||
void OnYmotorLocationSliderChanged(double location);
|
||||
void OnYmotorLocationSliderReleased();
|
||||
|
||||
|
||||
|
||||
void ontestRangeOfMotor_x_y();
|
||||
void ontimerTestRangeOfxMotor();
|
||||
void ontimerTestRangeOfyMotor();
|
||||
|
||||
void ontimerMoveXmotor();
|
||||
void ontimerMoveYmotor();
|
||||
|
||||
//
|
||||
void onimagerSimulatorMove(int x, int y);
|
||||
void OnSendLogToCallClass(QString str);
|
||||
|
||||
void onPlotRgbImage();
|
||||
void onCloseRgbCamera();
|
||||
void onClearLabel();
|
||||
|
||||
void onCopyFinished();
|
||||
|
||||
void requestFinished(QNetworkReply* reply);
|
||||
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
void recordHyperSpecImg(int status);
|
||||
|
||||
void createOneMotorScenario();
|
||||
signals:
|
||||
void StartFocusSignal();
|
||||
void StartLoopSignal();
|
||||
void StartRecordSignal();
|
||||
void CopyFileThreadSignal(QString, QString);
|
||||
void BroadcastXMotorPosSignal(long long, int);
|
||||
|
||||
void RecordWhiteSignal();
|
||||
void RecordDarlSignal();
|
||||
};
|
||||
|
||||
|
||||
BIN
HPPA/HPPA.ico
BIN
HPPA/HPPA.ico
Binary file not shown.
|
Before Width: | Height: | Size: 66 KiB |
@ -1,5 +1,53 @@
|
||||
<RCC>
|
||||
<qresource prefix="/HPPA">
|
||||
<file>HPPA.ico</file>
|
||||
<qresource prefix="/svg">
|
||||
<file>resources/icons/svg/arrow_down.svg</file>
|
||||
<file>resources/icons/svg/arrow_up.svg</file>
|
||||
<file>resources/icons/svg/close.svg</file>
|
||||
<file>resources/icons/svg/connect_imager.svg</file>
|
||||
<file>resources/icons/svg/connect_imager_done.svg</file>
|
||||
<file>resources/icons/svg/connect_imager_ing.svg</file>
|
||||
<file>resources/icons/svg/dark.svg</file>
|
||||
<file>resources/icons/svg/dark_done.svg</file>
|
||||
<file>resources/icons/svg/dark_ing.svg</file>
|
||||
<file>resources/icons/svg/exposure.svg</file>
|
||||
<file>resources/icons/svg/exposure_done.svg</file>
|
||||
<file>resources/icons/svg/exposure_ing.svg</file>
|
||||
<file>resources/icons/svg/focus.svg</file>
|
||||
<file>resources/icons/svg/focus_done.svg</file>
|
||||
<file>resources/icons/svg/focus_ing.svg</file>
|
||||
<file>resources/icons/svg/openDirectory.svg</file>
|
||||
<file>resources/icons/svg/openDirectory_done.svg</file>
|
||||
<file>resources/icons/svg/pan.svg</file>
|
||||
<file>resources/icons/svg/pan_done.svg</file>
|
||||
<file>resources/icons/svg/record.svg</file>
|
||||
<file>resources/icons/svg/record_done.svg</file>
|
||||
<file>resources/icons/svg/record_ing.svg</file>
|
||||
<file>resources/icons/svg/reference.svg</file>
|
||||
<file>resources/icons/svg/reference_done.svg</file>
|
||||
<file>resources/icons/svg/reference_ing.svg</file>
|
||||
<file>resources/icons/svg/software_icon.svg</file>
|
||||
<file>resources/icons/svg/software_icon_small.svg</file>
|
||||
<file>resources/icons/svg/spectral.svg</file>
|
||||
<file>resources/icons/svg/spectral_done.svg</file>
|
||||
<file>resources/icons/svg/tree_tri_down.svg</file>
|
||||
<file>resources/icons/svg/tree_tri_right.svg</file>
|
||||
<file>resources/icons/svg/mIconRaster.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/png">
|
||||
<file>resources/icons/png/Spectral_Insight_27.png</file>
|
||||
<file>resources/icons/png/Spectral_Insight_54.png</file>
|
||||
<file>resources/icons/png/Spectral_Insight_170.png</file>
|
||||
<file>resources/icons/png/Spectral_Insight_340.png</file>
|
||||
<file>resources/icons/png/titile_bar_bgp.png</file>
|
||||
<file>resources/icons/png/titile_bar_bgp2x.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/imagerPicture">
|
||||
<file>resources/icons/imagerPicture/corning410.png</file>
|
||||
<file>resources/icons/imagerPicture/IR.png</file>
|
||||
<file>resources/icons/imagerPicture/L.png</file>
|
||||
<file>resources/icons/imagerPicture/XC2.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/ico">
|
||||
<file>resources/icons/ico/Spectral_Insight_128.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
HPPA/HPPA.rc
BIN
HPPA/HPPA.rc
Binary file not shown.
1738
HPPA/HPPA.ui
1738
HPPA/HPPA.ui
File diff suppressed because it is too large
Load Diff
@ -14,16 +14,16 @@
|
||||
<ProjectGuid>{E7886664-B69E-4781-BCBE-804574FB4033}</ProjectGuid>
|
||||
<Keyword>QtVS_v304</Keyword>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
@ -31,13 +31,13 @@
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||
<QtInstall>5.9_msvc2017_64</QtInstall>
|
||||
<QtModules>core;network;gui;widgets;serialport;websockets;charts</QtModules>
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;network;gui;svg;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>5.9_msvc2017_64</QtInstall>
|
||||
<QtModules>core;network;gui;widgets;serialport;websockets;charts</QtModules>
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;network;gui;svg;widgets;serialport;websockets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender;3dquick;charts</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
@ -55,12 +55,14 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>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_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;$(IncludePath)</IncludePath>
|
||||
<IncludePath>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_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>Spectral Insight</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<IncludePath>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_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;$(IncludePath)</IncludePath>
|
||||
<IncludePath>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_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>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_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>Spectral Insight</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
@ -106,17 +108,39 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="aboutWindow.cpp" />
|
||||
<ClCompile Include="adjustTable.cpp" />
|
||||
<ClCompile Include="AspectRatioLabel.cpp" />
|
||||
<ClCompile Include="CaptureCoordinator.cpp" />
|
||||
<ClCompile Include="Carousel.cpp" />
|
||||
<ClCompile Include="Corning410Imager.cpp" />
|
||||
<ClCompile Include="CustomDockWidgetBase.cpp" />
|
||||
<ClCompile Include="hppaConfigFile.cpp" />
|
||||
<ClCompile Include="HyperImagerControl.cpp" />
|
||||
<ClCompile Include="imageControl.cpp" />
|
||||
<ClCompile Include="ImagerOperationBase.cpp" />
|
||||
<ClCompile Include="imager_base.cpp" />
|
||||
<ClCompile Include="irisximeaimager.cpp" />
|
||||
<ClCompile Include="LayerTree.cpp" />
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp" />
|
||||
<ClCompile Include="LayerTreeLayerNode.cpp" />
|
||||
<ClCompile Include="LayerTreeModel.cpp" />
|
||||
<ClCompile Include="LayerTreeNode.cpp" />
|
||||
<ClCompile Include="LayerTreeView.cpp" />
|
||||
<ClCompile Include="LayerTreeViewMenuProvider.cpp" />
|
||||
<ClCompile Include="MapLayer.cpp" />
|
||||
<ClCompile Include="MapLayerStore.cpp" />
|
||||
<ClCompile Include="MapTool.cpp" />
|
||||
<ClCompile Include="MapToolPan.cpp" />
|
||||
<ClCompile Include="MapTools.cpp" />
|
||||
<ClCompile Include="MapToolSpectral.cpp" />
|
||||
<ClCompile Include="OneMotorControl.cpp" />
|
||||
<ClCompile Include="PathPlan.cpp" />
|
||||
<ClCompile Include="path_tc.cpp" />
|
||||
<ClCompile Include="PowerControl.cpp" />
|
||||
<ClCompile Include="QDoubleSlider.cpp" />
|
||||
<ClCompile Include="QMotorDoubleSlider.cpp" />
|
||||
<ClCompile Include="RasterDataProvider.cpp" />
|
||||
<ClCompile Include="RasterLayer.cpp" />
|
||||
<ClCompile Include="RasterRenderer.cpp" />
|
||||
<ClCompile Include="recordFrameCounter.cpp" />
|
||||
<ClCompile Include="resononImager.cpp" />
|
||||
<ClCompile Include="ResononNirImager.cpp" />
|
||||
<ClCompile Include="RgbCameraOperation.cpp" />
|
||||
@ -125,7 +149,11 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TabManager.cpp" />
|
||||
<ClCompile Include="TwoMotorControl.cpp" />
|
||||
<ClCompile Include="utility_tc.cpp" />
|
||||
<ClCompile Include="View3D.cpp" />
|
||||
<ClCompile Include="View3DModelManager.cpp" />
|
||||
<QtRcc Include="HPPA.qrc" />
|
||||
<QtUic Include="about.ui" />
|
||||
<QtUic Include="adjustTable.ui" />
|
||||
@ -142,10 +170,15 @@
|
||||
<ClCompile Include="imagerSimulatioin.cpp" />
|
||||
<ClCompile Include="ImageViewer.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<QtUic Include="hyperImagerControl.ui" />
|
||||
<QtUic Include="imgControl.ui" />
|
||||
<QtUic Include="oneMotorControl.ui" />
|
||||
<QtUic Include="PathPlan.ui" />
|
||||
<QtUic Include="PowerControl.ui" />
|
||||
<QtUic Include="RadianceConversion.ui" />
|
||||
<QtUic Include="ReflectanceConversion.ui" />
|
||||
<QtUic Include="RobotArmControl.ui" />
|
||||
<QtUic Include="twoMotorControl.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h" />
|
||||
@ -157,14 +190,40 @@
|
||||
<QtMoc Include="image2display.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="View3DModelManager.h" />
|
||||
<QtMoc Include="View3D.h" />
|
||||
<QtMoc Include="adjustTable.h" />
|
||||
<QtMoc Include="PowerControl.h" />
|
||||
<QtMoc Include="PathPlan.h" />
|
||||
<QtMoc Include="RobotArmControl.h" />
|
||||
<QtMoc Include="Corning410Imager.h" />
|
||||
<QtMoc Include="CaptureCoordinator.h" />
|
||||
<QtMoc Include="CustomDockWidgetBase.h" />
|
||||
<QtMoc Include="Carousel.h" />
|
||||
<QtMoc Include="imageControl.h" />
|
||||
<QtMoc Include="AspectRatioLabel.h" />
|
||||
<QtMoc Include="HyperImagerControl.h" />
|
||||
<ClInclude Include="imager_base.h" />
|
||||
<ClInclude Include="irisximeaimager.h" />
|
||||
<QtMoc Include="OneMotorControl.h" />
|
||||
<QtMoc Include="TwoMotorControl.h" />
|
||||
<QtMoc Include="TabManager.h" />
|
||||
<QtMoc Include="LayerTreeModel.h" />
|
||||
<QtMoc Include="LayerTreeNode.h" />
|
||||
<QtMoc Include="LayerTree.h" />
|
||||
<QtMoc Include="LayerTreeGroupNode.h" />
|
||||
<QtMoc Include="LayerTreeLayerNode.h" />
|
||||
<QtMoc Include="MapLayer.h" />
|
||||
<QtMoc Include="RasterLayer.h" />
|
||||
<QtMoc Include="MapLayerStore.h" />
|
||||
<ClInclude Include="LayerTreeView.h" />
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h" />
|
||||
<QtMoc Include="MapTool.h" />
|
||||
<QtMoc Include="MapToolPan.h" />
|
||||
<QtMoc Include="MapToolSpectral.h" />
|
||||
<QtMoc Include="MapTools.h" />
|
||||
<ClInclude Include="RasterDataProvider.h" />
|
||||
<ClInclude Include="RasterRenderer.h" />
|
||||
<QtMoc Include="recordFrameCounter.h" />
|
||||
<ClInclude Include="utility_tc.h" />
|
||||
<QtMoc Include="aboutWindow.h" />
|
||||
<ClInclude Include="hppaConfigFile.h" />
|
||||
@ -190,7 +249,7 @@
|
||||
<ResourceCompile Include="HPPA.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="HPPA.ico" />
|
||||
<Image Include="resources\icons\ico\Spectral_Insight_128.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||
|
||||
@ -21,12 +21,6 @@
|
||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\motor">
|
||||
<UniqueIdentifier>{eadfac5f-f4f9-49e2-9f99-0849bf074cf8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\motor">
|
||||
<UniqueIdentifier>{4672856c-86fb-46e3-94ff-0a296dcc6111}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="HPPA.qrc">
|
||||
@ -109,9 +103,6 @@
|
||||
<ClCompile Include="PowerControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PathPlan.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RobotArmControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -127,6 +118,87 @@
|
||||
<ClCompile Include="OneMotorControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CaptureCoordinator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TwoMotorControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CustomDockWidgetBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Carousel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="View3D.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TabManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="View3DModelManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTree.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeLayerNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapLayer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RasterLayer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RasterDataProvider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RasterRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapLayerStore.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeView.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeViewMenuProvider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imageControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapTool.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapToolPan.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapToolSpectral.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapTools.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AspectRatioLabel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HyperImagerControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="recordFrameCounter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -171,9 +243,6 @@
|
||||
<QtMoc Include="PowerControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="PathPlan.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="RobotArmControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -183,6 +252,78 @@
|
||||
<QtMoc Include="OneMotorControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TwoMotorControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="CaptureCoordinator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="CustomDockWidgetBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="Carousel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="View3D.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TabManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="View3DModelManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTree.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeGroupNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeLayerNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapLayer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="RasterLayer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapLayerStore.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="imageControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapToolSpectral.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapToolPan.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapTool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapTools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="AspectRatioLabel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="HyperImagerControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="recordFrameCounter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -215,6 +356,15 @@
|
||||
<ClInclude Include="irisximeaimager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RasterDataProvider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RasterRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LayerTreeView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="FocusDialog.ui">
|
||||
@ -238,6 +388,21 @@
|
||||
<QtUic Include="oneMotorControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="RadianceConversion.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="ReflectanceConversion.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="twoMotorControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="imgControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="hyperImagerControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
@ -248,7 +413,7 @@
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="HPPA.ico">
|
||||
<Image Include="resources\icons\ico\Spectral_Insight_128.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
|
||||
195
HPPA/HyperImagerControl.cpp
Normal file
195
HPPA/HyperImagerControl.cpp
Normal file
@ -0,0 +1,195 @@
|
||||
#include "HyperImagerControl.h"
|
||||
|
||||
HyperImagerControl::HyperImagerControl(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.framerate_spinBox, &QDoubleSpinBox::editingFinished, this, &HyperImagerControl::onFramerateSpinBoxEditingFinished);
|
||||
connect(ui.FramerateSlider, &QDoubleSlider::valueChanged, this, &HyperImagerControl::onFramerateSliderChanged);
|
||||
connect(ui.FramerateSlider, &QDoubleSlider::sliderReleased, this, &HyperImagerControl::onFramerateSliderReleased);
|
||||
|
||||
connect(ui.integratioin_time_spinBox, &QDoubleSpinBox::editingFinished, this, &HyperImagerControl::onIntegrationTimeSpinBoxEditingFinished);
|
||||
connect(ui.IntegratioinTimeSlider, &QDoubleSlider::valueChanged, this, &HyperImagerControl::onIntegrationTimeSliderChanged);
|
||||
connect(ui.IntegratioinTimeSlider, &QDoubleSlider::sliderReleased, this, &HyperImagerControl::onIntegrationTimeSliderReleased);
|
||||
|
||||
connect(ui.gain_spinBox, &QDoubleSpinBox::editingFinished, this, &HyperImagerControl::onGainSpinBoxEditingFinished);
|
||||
connect(ui.GainSlider, &QSlider::valueChanged, this, &HyperImagerControl::onGainSliderChanged);
|
||||
connect(ui.GainSlider, &QSlider::sliderReleased, this, &HyperImagerControl::onGainSliderReleased);
|
||||
|
||||
ui.GainSlider->setMaximum(12);
|
||||
ui.GainSlider->setMinimum(0);
|
||||
|
||||
ui.gain_spinBox->setMaximum(12);
|
||||
ui.gain_spinBox->setMinimum(0);
|
||||
|
||||
ui.widget_3->setStyleSheet(R"(
|
||||
QDoubleSpinBox {
|
||||
border: 1px solid #999;
|
||||
border-radius: 4px;
|
||||
padding: 2px 20px 2px 6px; /* 右侧留空间给按钮 */
|
||||
background: #0e1c4c;
|
||||
selection-background-color: #0078d7;
|
||||
font-size: 12px;
|
||||
color:#ACCDFF ;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: top right;
|
||||
width: 16px;
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::down-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: bottom right;
|
||||
width: 16px;
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-arrow {
|
||||
image: url(:/svg/resources/icons/svg/arrow_up.svg);
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::down-arrow {
|
||||
image: url(:/svg/resources/icons/svg/arrow_down.svg);
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button:hover,
|
||||
QDoubleSpinBox::down-button:hover {
|
||||
background: #e6f2ff;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button:pressed,
|
||||
QDoubleSpinBox::down-button:pressed {
|
||||
background: #cce4ff;
|
||||
}
|
||||
)");
|
||||
|
||||
}
|
||||
|
||||
HyperImagerControl::~HyperImagerControl()
|
||||
{
|
||||
}
|
||||
|
||||
void HyperImagerControl::setFrameRate(double frameRate)
|
||||
{
|
||||
ui.framerate_spinBox->setValue(frameRate);
|
||||
ui.FramerateSlider->setValue(frameRate);
|
||||
|
||||
updateIntegrationTimeRange(frameRate);
|
||||
}
|
||||
|
||||
void HyperImagerControl::setIntegrationTime(double integrationTime)
|
||||
{
|
||||
ui.integratioin_time_spinBox->setValue(integrationTime);
|
||||
ui.IntegratioinTimeSlider->setValue(integrationTime);
|
||||
|
||||
updateFramerateRange(integrationTime);
|
||||
}
|
||||
|
||||
void HyperImagerControl::setGain(double gain)
|
||||
{
|
||||
ui.gain_spinBox->setValue(gain);
|
||||
ui.GainSlider->setValue(gain);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onFramerateSpinBoxEditingFinished()
|
||||
{
|
||||
double framerate = ui.framerate_spinBox->value();
|
||||
ui.FramerateSlider->setValue(framerate);
|
||||
emit framerateChanged(framerate);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onFramerateSliderChanged(double framerate)
|
||||
{
|
||||
ui.framerate_spinBox->blockSignals(true);
|
||||
ui.framerate_spinBox->setValue(framerate);
|
||||
ui.framerate_spinBox->blockSignals(false);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onFramerateSliderReleased()
|
||||
{
|
||||
double framerate = ui.framerate_spinBox->value();
|
||||
emit framerateChanged(framerate);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onIntegrationTimeSpinBoxEditingFinished()
|
||||
{
|
||||
double integrationTime = ui.integratioin_time_spinBox->value();
|
||||
ui.IntegratioinTimeSlider->setValue(integrationTime);
|
||||
emit integrationTimeChanged(integrationTime);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onIntegrationTimeSliderChanged(double integrationTime)
|
||||
{
|
||||
ui.integratioin_time_spinBox->blockSignals(true);
|
||||
ui.integratioin_time_spinBox->setValue(integrationTime);
|
||||
ui.integratioin_time_spinBox->blockSignals(false);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onIntegrationTimeSliderReleased()
|
||||
{
|
||||
double integrationTime = ui.integratioin_time_spinBox->value();
|
||||
emit integrationTimeChanged(integrationTime);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onGainSpinBoxEditingFinished()
|
||||
{
|
||||
double gain = ui.gain_spinBox->value();
|
||||
ui.GainSlider->setValue(gain);
|
||||
emit gainChanged(gain);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onGainSliderChanged(double gain)
|
||||
{
|
||||
ui.gain_spinBox->blockSignals(true);
|
||||
ui.gain_spinBox->setValue(gain);
|
||||
ui.gain_spinBox->blockSignals(false);
|
||||
}
|
||||
|
||||
void HyperImagerControl::onGainSliderReleased()
|
||||
{
|
||||
double gain = ui.gain_spinBox->value();
|
||||
emit gainChanged(gain);
|
||||
}
|
||||
|
||||
void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
|
||||
{
|
||||
double maxIntegrationTime = 1.0 / frameRate * 1000.0; // 毫秒
|
||||
|
||||
ui.IntegratioinTimeSlider->blockSignals(true);
|
||||
ui.IntegratioinTimeSlider->setMaximum(maxIntegrationTime);
|
||||
ui.IntegratioinTimeSlider->setMinimum(1);
|
||||
ui.IntegratioinTimeSlider->blockSignals(false);
|
||||
|
||||
ui.integratioin_time_spinBox->blockSignals(true);
|
||||
ui.integratioin_time_spinBox->setMaximum(maxIntegrationTime);
|
||||
ui.integratioin_time_spinBox->setMinimum(1);
|
||||
ui.integratioin_time_spinBox->blockSignals(false);
|
||||
}
|
||||
|
||||
void HyperImagerControl::updateFramerateRange(double integrationTime)
|
||||
{
|
||||
double maxFramerate = 1.0 / (integrationTime / 1000.0); // 积分时间(毫秒)转帧率
|
||||
|
||||
if(maxFramerate > m_frameRateLimit)
|
||||
{
|
||||
maxFramerate = m_frameRateLimit;
|
||||
}
|
||||
|
||||
ui.FramerateSlider->blockSignals(true);
|
||||
ui.FramerateSlider->setMaximum(maxFramerate);
|
||||
ui.FramerateSlider->setMinimum(1);
|
||||
ui.FramerateSlider->blockSignals(false);
|
||||
|
||||
ui.framerate_spinBox->blockSignals(true);
|
||||
ui.framerate_spinBox->setMaximum(maxFramerate);
|
||||
ui.framerate_spinBox->setMinimum(1);
|
||||
ui.framerate_spinBox->blockSignals(false);
|
||||
}
|
||||
47
HPPA/HyperImagerControl.h
Normal file
47
HPPA/HyperImagerControl.h
Normal file
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_hyperImagerControl.h"
|
||||
|
||||
#include "AspectRatioLabel.h"
|
||||
|
||||
class QDoubleSlider;
|
||||
|
||||
class HyperImagerControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HyperImagerControl(QWidget* parent = nullptr);
|
||||
~HyperImagerControl();
|
||||
|
||||
AspectRatioLabel* imagerPictureLabel() const { return ui.imagerPictureLabel; }
|
||||
|
||||
void setFrameRate(double frameRate);
|
||||
void setIntegrationTime(double integrationTime);
|
||||
void setGain(double gain);
|
||||
|
||||
signals:
|
||||
void framerateChanged(double framerate);
|
||||
void integrationTimeChanged(double integrationTime);
|
||||
void gainChanged(double gain);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFramerateSpinBoxEditingFinished();
|
||||
void onFramerateSliderChanged(double framerate);
|
||||
void onFramerateSliderReleased();
|
||||
void onIntegrationTimeSpinBoxEditingFinished();
|
||||
void onIntegrationTimeSliderChanged(double integrationTime);
|
||||
void onIntegrationTimeSliderReleased();
|
||||
void onGainSpinBoxEditingFinished();
|
||||
void onGainSliderChanged(double gain);
|
||||
void onGainSliderReleased();
|
||||
|
||||
private:
|
||||
void updateIntegrationTimeRange(double frameRate);
|
||||
void updateFramerateRange(double integrationTime);
|
||||
double m_frameRateLimit = 150;//相机的最大帧率限制为250fps
|
||||
|
||||
Ui::HyperImagerControl ui;
|
||||
};
|
||||
@ -1,228 +1,338 @@
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
#include <QWheelEvent>
|
||||
#include <QPoint>
|
||||
|
||||
#include "ImageViewer.h"
|
||||
#include "RasterLayer.h"
|
||||
#include "MapTool.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)
|
||||
Mapcavas::Mapcavas(QWidget* pParent) :QGraphicsView(pParent)
|
||||
{
|
||||
m_qtGraphicsScene = new QGraphicsScene(this);
|
||||
this->setScene(m_qtGraphicsScene);
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
|
||||
m_framNumberLabel = new QLabel(this);
|
||||
m_framNumberLabel->setAlignment(Qt::AlignHCenter);
|
||||
m_framNumberLabel->setAlignment(Qt::AlignVCenter);
|
||||
// ʹ<><CAB9> Qt Ĭ<><C4AC> anchor <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
setTransformationAnchor(QGraphicsView::NoAnchor);
|
||||
setResizeAnchor(QGraphicsView::NoAnchor);
|
||||
|
||||
QFont ft;
|
||||
ft.setPointSize(14);
|
||||
m_framNumberLabel->setFont(ft);
|
||||
m_qtGraphicsScene = new QGraphicsScene(this);
|
||||
this->setScene(m_qtGraphicsScene);
|
||||
m_qtGraphicsScene->setSceneRect(-1e6, -1e6, 2e6, 2e6);
|
||||
|
||||
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_GraphicsPixmapItemHandle = nullptr;
|
||||
|
||||
m_scale = 1.0;
|
||||
m_zoomDelta = 0.1;
|
||||
m_translateSpeed = 1.0;
|
||||
m_bMouseTranslate = false;
|
||||
m_scale = 1.0;
|
||||
m_zoomDelta = 0.1;
|
||||
m_translateSpeed = 1.0;
|
||||
m_bMouseTranslate = false;
|
||||
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
}
|
||||
|
||||
ImageViewer::~ImageViewer()
|
||||
Mapcavas::~Mapcavas()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImageViewer::DisplayFrameNumber(int frameNumber)
|
||||
void Mapcavas::DisplayFrameNumber(int frameNumber)
|
||||
{
|
||||
m_framNumberLabel->setText(QString::number(frameNumber));
|
||||
m_framNumberLabel->adjustSize();
|
||||
m_framNumberLabel->setText(QString::number(frameNumber));
|
||||
m_framNumberLabel->adjustSize();
|
||||
}
|
||||
|
||||
void ImageViewer::SetImage(QPixmap *image)
|
||||
void Mapcavas::SetImage(QPixmap *image)
|
||||
{
|
||||
if (!HasImage())
|
||||
{
|
||||
m_GraphicsPixmapItemHandle = m_qtGraphicsScene->addPixmap(*image);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_GraphicsPixmapItemHandle->setPixmap(*image);
|
||||
}
|
||||
|
||||
setSceneRect(QRectF(image->rect()));
|
||||
|
||||
if (!HasImage())
|
||||
{
|
||||
m_GraphicsPixmapItemHandle = m_qtGraphicsScene->addPixmap(*image);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_GraphicsPixmapItemHandle->setPixmap(*image);
|
||||
}
|
||||
ensureSceneVisible();
|
||||
}
|
||||
|
||||
bool ImageViewer::HasImage()
|
||||
void Mapcavas::ensureSceneVisible()
|
||||
{
|
||||
if (m_GraphicsPixmapItemHandle == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
resetTransform();
|
||||
|
||||
auto view_rect = viewport()->rect();
|
||||
auto scene_rect = this->scene()->itemsBoundingRect();
|
||||
|
||||
double x_ratio = view_rect.width() / scene_rect.width();
|
||||
double y_ratio = view_rect.height() / scene_rect.height();
|
||||
double scale_factor = std::min(x_ratio, y_ratio) * 0.9;
|
||||
|
||||
scale(scale_factor, scale_factor);
|
||||
m_scale *= scale_factor;
|
||||
|
||||
centerOn(scene_rect.center());
|
||||
}
|
||||
|
||||
void ImageViewer::wheelEvent(QWheelEvent *event)
|
||||
bool Mapcavas::HasImage()
|
||||
{
|
||||
//qDebug() << "---------------+++++++++++++++++++++++++++++++++++++++++++++++++++ ";
|
||||
if (true)//HasImage()
|
||||
{
|
||||
//Χ<><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>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
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65><77>λ<EFBFBD><CEBB>;
|
||||
QPointF cursorPoint = event->pos();
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>scene<6E><65>λ<EFBFBD><CEBB>;
|
||||
QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
|
||||
|
||||
// <20><>ȡview<65>Ŀ<EFBFBD><C4BF><EFBFBD>;
|
||||
qreal viewWidth = this->viewport()->width();
|
||||
qreal viewHeight = this->viewport()->height();
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>൱<EFBFBD><E0B5B1>view<65><77>С<EFBFBD>ĺ<EFBFBD><C4BA>ݱ<EFBFBD><DDB1><EFBFBD>;
|
||||
qreal hScale = cursorPoint.x() / viewWidth;
|
||||
qreal vScale = cursorPoint.y() / viewHeight;
|
||||
|
||||
|
||||
// <20><><EFBFBD>ֵĹ<D6B5><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
QPoint scrollAmount = event->angleDelta();
|
||||
// <20><>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ʹ<EFBFBD><CAB9><EFBFBD>߷Ŵ<DFB7><C5B4><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||
scrollAmount.y() > 0 ? zoomIn() : zoomOut();
|
||||
|
||||
|
||||
// <20><>scene<6E><65><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
QPointF viewPoint = this->matrix().map(scenePos);
|
||||
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>չʾscene<6E><65>λ<EFBFBD><CEBB>;
|
||||
horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
|
||||
verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
|
||||
}
|
||||
|
||||
QGraphicsView::wheelEvent(event);
|
||||
if (m_GraphicsPixmapItemHandle == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageViewer::scaling(qreal scaleFactor)
|
||||
void Mapcavas::updateCrosshair(double sceneX, double sceneY)
|
||||
{
|
||||
//qDebug() << this->sceneRect();
|
||||
scale(scaleFactor, scaleFactor);
|
||||
QPen pen(Qt::red, 2.0);
|
||||
pen.setCosmetic(true); // constant screen-width regardless of zoom
|
||||
|
||||
if (!m_hLine)
|
||||
{
|
||||
m_hLine = m_qtGraphicsScene->addLine(0, 0, 0, 0, pen);
|
||||
m_hLine->setZValue(1e9);
|
||||
}
|
||||
if (!m_vLine)
|
||||
{
|
||||
m_vLine = m_qtGraphicsScene->addLine(0, 0, 0, 0, pen);
|
||||
m_vLine->setZValue(1e9);
|
||||
}
|
||||
|
||||
m_hLine->setPen(pen);
|
||||
m_vLine->setPen(pen);
|
||||
|
||||
m_hLine->setLine(sceneX - m_CrosshairHalfLen, sceneY,
|
||||
sceneX + m_CrosshairHalfLen, sceneY);
|
||||
m_vLine->setLine(sceneX, sceneY - m_CrosshairHalfLen,
|
||||
sceneX, sceneY + m_CrosshairHalfLen);
|
||||
}
|
||||
|
||||
void ImageViewer::mousePressEvent(QMouseEvent *event)
|
||||
void Mapcavas::removeCrosshair()
|
||||
{
|
||||
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);
|
||||
if (m_hLine)
|
||||
{
|
||||
if (m_hLine->scene())
|
||||
m_hLine->scene()->removeItem(m_hLine);
|
||||
delete m_hLine;
|
||||
m_hLine = nullptr;
|
||||
}
|
||||
if (m_vLine)
|
||||
{
|
||||
if (m_vLine->scene())
|
||||
m_vLine->scene()->removeItem(m_vLine);
|
||||
delete m_vLine;
|
||||
m_vLine = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
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 Mapcavas::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
// Always let the tool have a chance first
|
||||
if (m_mapTool)
|
||||
{
|
||||
m_mapTool->canvasWheelEvent(event);
|
||||
}
|
||||
|
||||
if (HasImage())
|
||||
{
|
||||
QPointF oldPos = mapToScene(event->pos());
|
||||
|
||||
QPoint scrollAmount = event->angleDelta();
|
||||
scrollAmount.y() > 0 ? zoomIn() : zoomOut();
|
||||
|
||||
QPointF newPos = mapToScene(event->pos());
|
||||
|
||||
QPointF delta = newPos - oldPos;
|
||||
translate(delta.x(), delta.y());
|
||||
}
|
||||
}
|
||||
|
||||
void ImageViewer::mouseReleaseEvent(QMouseEvent *event)
|
||||
void Mapcavas::scaling(qreal scaleFactor)
|
||||
{
|
||||
m_bMouseTranslate = false;
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
scale(scaleFactor, scaleFactor);
|
||||
}
|
||||
|
||||
void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
void Mapcavas::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QGraphicsView::mouseDoubleClickEvent(event);
|
||||
if (m_mapTool)
|
||||
{
|
||||
m_mapTool->canvasMousePressEvent(event);
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
return;
|
||||
}
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ImageViewer::zoomIn()
|
||||
void Mapcavas::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
zoom(1 + m_zoomDelta);
|
||||
if (m_mapTool)
|
||||
{
|
||||
m_mapTool->canvasMouseMoveEvent(event);
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ImageViewer::zoomOut()
|
||||
void Mapcavas::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
zoom(1 - m_zoomDelta);
|
||||
if (m_mapTool)
|
||||
{
|
||||
m_mapTool->canvasMouseReleaseEvent(event);
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void ImageViewer::zoom(float scaleFactor)
|
||||
void Mapcavas::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
// <20><>ֹ<EFBFBD><D6B9>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
|
||||
if (factor < 0.07 || factor > 100)
|
||||
return;
|
||||
if (m_mapTool)
|
||||
{
|
||||
m_mapTool->canvasMouseDoubleClickEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
scale(scaleFactor, scaleFactor);
|
||||
m_scale *= scaleFactor;
|
||||
QGraphicsView::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void ImageViewer::translate(QPointF delta)
|
||||
void Mapcavas::zoomIn()
|
||||
{
|
||||
// <20><><EFBFBD>ݵ<EFBFBD>ǰ zoom <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
delta *= m_scale;
|
||||
delta *= m_translateSpeed;
|
||||
|
||||
////<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>
|
||||
//scene()->setSceneRect(scene()->sceneRect().x() - delta.x(), scene()->sceneRect().y() - delta.y(),
|
||||
// scene()->sceneRect().width(), scene()->sceneRect().height());
|
||||
//scene()->update();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32>
|
||||
// view <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µĵ<C2B5><C4B5><EFBFBD>Ϊê<CEAA><C3AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ scene
|
||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
QPoint newCenter(VIEW_WIDTH / 2 - delta.x(), VIEW_HEIGHT / 2 - delta.y());
|
||||
centerOn(mapToScene(newCenter));
|
||||
|
||||
// scene <20><> view <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>Ϊê<CEAA><C3AA>
|
||||
setTransformationAnchor(QGraphicsView::AnchorViewCenter);
|
||||
zoom(1 + m_zoomDelta);
|
||||
}
|
||||
|
||||
void ImageViewer::setTranslateSpeed(qreal speed)
|
||||
void Mapcavas::zoomOut()
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶȷ<D9B6>Χ
|
||||
Q_ASSERT_X(speed >= 0.0 && speed <= 2.0,
|
||||
"InteractiveView::setTranslateSpeed", "Speed should be in range [0.0, 2.0].");
|
||||
m_translateSpeed = speed;
|
||||
zoom(1 - m_zoomDelta);
|
||||
}
|
||||
|
||||
qreal ImageViewer::translateSpeed() const
|
||||
void Mapcavas::zoom(float scaleFactor)
|
||||
{
|
||||
return m_translateSpeed;
|
||||
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::setZoomDelta(qreal delta)
|
||||
void Mapcavas::setTranslateSpeed(qreal speed)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
|
||||
Q_ASSERT_X(delta >= 0.0 && delta <= 1.0,
|
||||
"InteractiveView::setZoomDelta", "Delta should be in range [0.0, 1.0].");
|
||||
m_zoomDelta = delta;
|
||||
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::zoomDelta() const
|
||||
qreal Mapcavas::translateSpeed() const
|
||||
{
|
||||
return m_zoomDelta;
|
||||
return m_translateSpeed;
|
||||
}
|
||||
|
||||
void Mapcavas::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 Mapcavas::zoomDelta() const
|
||||
{
|
||||
return m_zoomDelta;
|
||||
}
|
||||
|
||||
// new: set associated raster layer
|
||||
void Mapcavas::setLayers(RasterLayer* layer)
|
||||
{
|
||||
m_rasterLayer = layer;
|
||||
}
|
||||
|
||||
RasterLayer* Mapcavas::rasterLayer() const
|
||||
{
|
||||
return m_rasterLayer;
|
||||
}
|
||||
|
||||
// new: refresh the map by rendering using the RasterLayer's render method
|
||||
void Mapcavas::freshmap()
|
||||
{
|
||||
if (!m_rasterLayer) return;
|
||||
|
||||
RasterLayer::RenderParams params = m_rasterLayer->currentRenderParams();
|
||||
QImage img = m_rasterLayer->render(params);
|
||||
if (img.isNull()) return;
|
||||
|
||||
QPixmap pm = QPixmap::fromImage(img);
|
||||
SetImage(&pm);
|
||||
}
|
||||
|
||||
void Mapcavas::freshmap(const RasterLayer::RenderParams& params)
|
||||
{
|
||||
if (!m_rasterLayer) return;
|
||||
|
||||
QImage img = m_rasterLayer->render(params);
|
||||
if (img.isNull()) return;
|
||||
|
||||
QPixmap pm = QPixmap::fromImage(img);
|
||||
SetImage(&pm);
|
||||
}
|
||||
|
||||
// MapTool management
|
||||
void Mapcavas::setMapTool(MapTool* tool)
|
||||
{
|
||||
if (m_mapTool)
|
||||
{
|
||||
m_mapTool->deactivate();
|
||||
}
|
||||
|
||||
m_mapTool = tool;
|
||||
|
||||
if (m_mapTool)
|
||||
{
|
||||
// Disable built-in drag mode so the tool controls everything
|
||||
setDragMode(QGraphicsView::NoDrag);
|
||||
m_mapTool->activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restore legacy drag mode when no tool
|
||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
}
|
||||
}
|
||||
|
||||
void Mapcavas::unsetMapTool(MapTool* tool)
|
||||
{
|
||||
if (m_mapTool && m_mapTool == tool)
|
||||
{
|
||||
m_mapTool->deactivate();
|
||||
m_mapTool = nullptr;
|
||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
}
|
||||
}
|
||||
|
||||
MapTool* Mapcavas::mapTool() const
|
||||
{
|
||||
return m_mapTool;
|
||||
}
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
#ifndef IMAGE_VIEWER
|
||||
#define IMAGE_VIEWER
|
||||
#ifndef MAPCAVAS_H
|
||||
#define MAPCAVAS_H
|
||||
|
||||
#include "QGraphicsView"
|
||||
#include "qlabel.h"
|
||||
class ImageViewer :public QGraphicsView
|
||||
#include <QVector>
|
||||
#include "RasterLayer.h"
|
||||
|
||||
class MapTool;
|
||||
|
||||
class Mapcavas : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImageViewer(QWidget* pParent = NULL);
|
||||
~ImageViewer();
|
||||
Mapcavas(QWidget* pParent = NULL);
|
||||
~Mapcavas();
|
||||
|
||||
|
||||
void DisplayFrameNumber(int frameNumber);
|
||||
@ -22,6 +27,10 @@ public:
|
||||
|
||||
void SetImage(QPixmap *image);
|
||||
bool HasImage();
|
||||
void ensureSceneVisible();
|
||||
|
||||
void updateCrosshair(double sceneX, double sceneY);
|
||||
void removeCrosshair();
|
||||
|
||||
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
||||
void scaling(qreal scaleFactor);
|
||||
@ -29,7 +38,6 @@ public:
|
||||
void zoomIn(); // <20>Ŵ<EFBFBD>
|
||||
void zoomOut(); // <20><>С
|
||||
void zoom(float scaleFactor); // <20><><EFBFBD><EFBFBD> - scaleFactor<6F><72><EFBFBD>ŵı<C5B5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void translate(QPointF delta); // ƽ<><C6BD>
|
||||
|
||||
// ƽ<><C6BD><EFBFBD>ٶ<EFBFBD>
|
||||
void setTranslateSpeed(qreal speed);
|
||||
@ -38,12 +46,27 @@ public:
|
||||
// <20><><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
void setZoomDelta(qreal delta);
|
||||
qreal zoomDelta() const;
|
||||
|
||||
// new: set raster layer and refresh map
|
||||
void setLayers(RasterLayer* layer);
|
||||
void freshmap();
|
||||
void freshmap(const RasterLayer::RenderParams& params);
|
||||
|
||||
RasterLayer* rasterLayer() const;
|
||||
|
||||
// MapTool management
|
||||
void setMapTool(MapTool* tool);
|
||||
void unsetMapTool(MapTool* tool);
|
||||
MapTool* mapTool() const;
|
||||
|
||||
protected:
|
||||
QGraphicsScene *m_qtGraphicsScene;
|
||||
private:
|
||||
QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
|
||||
QLabel *m_framNumberLabel;//<2F><>ʾʵʱ<CAB5>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>
|
||||
|
||||
|
||||
RasterLayer* m_rasterLayer = nullptr; // associated raster layer
|
||||
MapTool* m_mapTool = nullptr; // current active map tool
|
||||
|
||||
qreal m_translateSpeed; // ƽ<><C6BD><EFBFBD>ٶ<EFBFBD>
|
||||
qreal m_zoomDelta; // <20><><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -51,8 +74,12 @@ private:
|
||||
QPoint m_lastMousePos; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
qreal m_scale; // <20><><EFBFBD><EFBFBD>ֵ
|
||||
|
||||
double m_CrosshairHalfLen = 10.0;
|
||||
QGraphicsLineItem* m_hLine = nullptr; // horizontal line
|
||||
QGraphicsLineItem* m_vLine = nullptr; // vertical line
|
||||
|
||||
|
||||
signals:
|
||||
void leftMouseButtonPressed(int, int);
|
||||
void leftMouseButtonPressed(int, int, QVector<double>, QVector<double>);
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -6,7 +6,7 @@ ImagerOperationBase::ImagerOperationBase()
|
||||
m_bRecordControlState = true;
|
||||
|
||||
m_FileName2Save = "tmp_image";
|
||||
m_FileSavedCounter = 1;
|
||||
m_FileSavedCounter = 0;
|
||||
|
||||
m_RgbImage = new CImage();
|
||||
|
||||
@ -67,6 +67,8 @@ double ImagerOperationBase::auto_exposure()
|
||||
|
||||
imagerStopCollect();
|
||||
|
||||
emit autoExposureSignal();
|
||||
|
||||
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << getIntegrationTime() << std::endl;
|
||||
|
||||
return getIntegrationTime();
|
||||
@ -74,6 +76,8 @@ double ImagerOperationBase::auto_exposure()
|
||||
|
||||
void ImagerOperationBase::focus()
|
||||
{
|
||||
m_iFocusFramesNumber = 0;
|
||||
|
||||
m_iFocusFrameCounter = 1;
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
|
||||
|
||||
@ -85,16 +89,42 @@ void ImagerOperationBase::focus()
|
||||
auto_exposure();
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
|
||||
|
||||
int iWidth, iHeight;
|
||||
GetFrameSize(iWidth, iHeight);
|
||||
unsigned short* tmp = new unsigned short[m_FrameSize];
|
||||
|
||||
imagerStartCollect();
|
||||
|
||||
//emit SpectralSignal(1);
|
||||
m_bFocusControlState = true;
|
||||
while (m_bFocusControlState)
|
||||
{
|
||||
////<2F><>֡ƽ<D6A1><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
//memset((void*)buffer, 0, m_FrameSize * sizeof(unsigned short));
|
||||
//int fn = 5;
|
||||
//for (int i = 0; i < fn; i++)
|
||||
//{
|
||||
// getFrame(tmp);
|
||||
|
||||
// for (int j = 0; j < m_FrameSize; j++)
|
||||
// {
|
||||
// buffer[j] += tmp[j];
|
||||
// }
|
||||
//}
|
||||
//for (int j = 0; j < m_FrameSize; j++)
|
||||
//{
|
||||
// buffer[j] += buffer[j] / fn;
|
||||
//}
|
||||
|
||||
getFrame(buffer);
|
||||
|
||||
//m_RgbImage->FillFocusGrayImage(buffer);
|
||||
m_RgbImage->FillFocusGrayQImage(buffer);
|
||||
|
||||
double focusIndex = calcFocusIndexSobelPrivate(buffer);
|
||||
emit FocusIndexSobelSignal(focusIndex);
|
||||
std::cout << "focusIndex<EFBFBD><EFBFBD>" << focusIndex << std::endl;
|
||||
|
||||
emit SpectralSignal(1);
|
||||
|
||||
++m_iFocusFrameCounter;
|
||||
@ -102,6 +132,7 @@ void ImagerOperationBase::focus()
|
||||
emit SpectralSignal(0);
|
||||
|
||||
imagerStopCollect();
|
||||
delete[] tmp;
|
||||
|
||||
setFramerate(tmpFrmerate);
|
||||
setIntegrationTime(tmpIntegrationTime);
|
||||
@ -189,9 +220,9 @@ void ImagerOperationBase::record_white()
|
||||
|
||||
void ImagerOperationBase::start_record()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
|
||||
m_iFrameCounter = 0;
|
||||
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
|
||||
@ -204,7 +235,13 @@ void ImagerOperationBase::start_record()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// <20>ڿ<EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ<EFBFBD><CFA2>UI <20><><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD> MapLayer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// prepare file name that will be used for saving
|
||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
|
||||
|
||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||
|
||||
size_t x;
|
||||
@ -270,7 +307,7 @@ void ImagerOperationBase::start_record()
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||
{
|
||||
emit PlotSignal(m_iFrameCounter);
|
||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
@ -281,13 +318,18 @@ void ImagerOperationBase::start_record()
|
||||
}
|
||||
imagerStopCollect();
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(-1);//<2F><>1<EFBFBD><31><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ<EFBFBD><C8AB>2<EFBFBD><32>ʹ<EFBFBD>û<EFBFBD>е<EFBFBD>۲ɼ<DBB2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>俪ʼ<E4BFAA>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ᵼ<EFBFBD><E1B5BC><EFBFBD>ϴβɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>źŵ<C5BA><C5B5>õIJۺ<C4B2><DBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><CBBC>ݣ<EFBFBD>ע<EFBFBD>͵<EFBFBD>
|
||||
emit PlotSignal(m_FileSavedCounter, -1, filePath);
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> ImageFileSaved <20>źţ<C5BA>֪ͨ UI <20><><EFBFBD>Ѹ<EFBFBD><D1B8>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// m_FileName2Save2 <20><><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD> .bil <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "tmp_image_0.bil"<22><>
|
||||
emit ImageFileSaved(QString::fromStdString(m_FileName2Save2), m_FileSavedCounter);
|
||||
|
||||
m_FileSavedCounter++;
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
@ -312,7 +354,7 @@ void ImagerOperationBase::setFrameNumber(int FrameNumber)
|
||||
void ImagerOperationBase::setFileName2Save(string FileName)
|
||||
{
|
||||
m_FileName2Save = FileName;
|
||||
m_FileSavedCounter = 1;
|
||||
m_FileSavedCounter = 0;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
|
||||
@ -335,6 +377,61 @@ int ImagerOperationBase::GetFrameSize(int& iWidth, int& iHeight)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::getFocusIndexSobel()
|
||||
{
|
||||
imagerStartCollect();
|
||||
getFrame(buffer);
|
||||
imagerStopCollect();
|
||||
|
||||
double focusIndex = calcFocusIndexSobelPrivate(buffer);
|
||||
|
||||
emit FocusIndexSobelSignal(focusIndex);
|
||||
}
|
||||
|
||||
double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
|
||||
{
|
||||
int iSelection = 0;
|
||||
int iWidth, iHeight;
|
||||
GetFrameSize(iWidth, iHeight);
|
||||
|
||||
unsigned short* psData;
|
||||
psData = (unsigned short*)pvData;
|
||||
|
||||
cv::Mat gray(iHeight, iWidth, CV_16UC1, psData);//<2F><><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>gray.data<74><61><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>psDataһ<61><D2BB><EFBFBD><EFBFBD>
|
||||
/*string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_";
|
||||
string tmp1 = std::to_string(m_iFocusFramesNumber);
|
||||
string tmp2 = ".png";*/
|
||||
|
||||
string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_" + std::to_string(m_iFocusFramesNumber) + ".png";
|
||||
|
||||
//cv::imwrite(rgbFilePathNoStrech, gray);
|
||||
m_iFocusFramesNumber++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>
|
||||
//cv::Mat outputImage;
|
||||
//cv::Size kernelSize(5, 5);
|
||||
//double sigmaX = 1.5;
|
||||
//cv::GaussianBlur(gray, outputImage, kernelSize, sigmaX);
|
||||
|
||||
cv::Mat outputImage = gray;
|
||||
|
||||
cv::Mat gradX, gradY, absGradX, absGradY;
|
||||
|
||||
cv::Sobel(outputImage, gradX, CV_32F, 1, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪCV_16S<36><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cv::magnitude<64><65><EFBFBD><EFBFBD>
|
||||
cv::Sobel(outputImage, gradY, CV_32F, 0, 1);
|
||||
cv::convertScaleAbs(gradX, absGradX);
|
||||
cv::convertScaleAbs(gradY, absGradY);
|
||||
cv::Mat grad;
|
||||
cv::addWeighted(absGradX, 0.5, absGradY, 0.5, 0, grad);
|
||||
|
||||
cv::Mat magnitude, direction;
|
||||
cv::magnitude(gradX, gradY, magnitude);//
|
||||
cv::phase(gradX, gradY, direction, true); // true<75><65>ʾ<EFBFBD><CABE><EFBFBD>ؽǶȶ<C7B6><C8B6>ǻ<EFBFBD><C7BB><EFBFBD>
|
||||
|
||||
|
||||
return cv::mean(magnitude)[0];
|
||||
}
|
||||
|
||||
CImage* ImagerOperationBase::getRgbImage() const
|
||||
{
|
||||
return m_RgbImage;
|
||||
@ -365,6 +462,11 @@ void ImagerOperationBase::setRecordControlState(bool RecordControlState)
|
||||
m_bRecordControlState = RecordControlState;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::stop_record()
|
||||
{
|
||||
m_bRecordControlState = false;
|
||||
}
|
||||
|
||||
int ImagerOperationBase::getFrameCounter() const
|
||||
{
|
||||
return m_iFrameCounter;
|
||||
@ -408,6 +510,7 @@ void ImagerOperationBase::WriteHdr()
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "byte order = 0\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "utility_tc.h"
|
||||
|
||||
class MapLayer; // forward declaration
|
||||
|
||||
class ImagerOperationBase :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -55,6 +57,7 @@ public:
|
||||
void setFocusControlState(bool FocusControlState);
|
||||
int GetFrameSize(int& iWidth, int& iHeight);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
|
||||
@ -85,16 +88,21 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
int m_iFocusFramesNumber;
|
||||
double calcFocusIndexSobelPrivate(void* pvData);
|
||||
|
||||
public slots:
|
||||
virtual void connect_imager(int frameNumber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
|
||||
virtual double auto_exposure();
|
||||
virtual void focus();
|
||||
virtual void start_record();
|
||||
void stop_record();
|
||||
virtual void record_dark();
|
||||
virtual void record_white();
|
||||
|
||||
void getFocusIndexSobel();
|
||||
signals:
|
||||
void PlotSignal(int);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA>-1<EFBFBD><EFBFBD><EFBFBD>˴βɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
|
||||
void PlotSignal(int, int, QString);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA><C5A3><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD>Ӱ<EFBFBD>ڶ<F1A3BBB5><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>-1<><31><EFBFBD><EFBFBD><EFBFBD>˴βɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72>û<EFBFBD>вɼ<D0B2><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>;ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
void SpectralSignal(int);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9>ף<EFBFBD><D7A3><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
|
||||
@ -102,6 +110,15 @@ signals:
|
||||
void RecordWhiteFinishSignal();
|
||||
void RecordDarlFinishSignal();
|
||||
|
||||
void FocusIndexSobelSignal(double);
|
||||
|
||||
|
||||
void testImagerStatus();//<2F><>ʾ<EFBFBD><CABE><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void autoExposureSignal();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>.bil/.hdr<64><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ɺ<C9BA><F3B7A2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳɼ<D3B2><C9BC>̷߳<DFB3><CCB7><EFBFBD><EFBFBD><EFBFBD>Qt <20><><EFBFBD><EFBFBD> queued connection<6F><6E>
|
||||
void ImageFileSaved(const QString& path, int fileIndex);
|
||||
|
||||
// <20>ģ<DEB8><C4A3><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD> MapLayer*<2A><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>UI <20>㸺<EFBFBD><EFBFBD> MapLayer <20><><EFBFBD><EFBFBD><F3B2A2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex);
|
||||
};
|
||||
|
||||
47
HPPA/LayerTree.cpp
Normal file
47
HPPA/LayerTree.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "LayerTree.h"
|
||||
|
||||
LayerTree::LayerTree(QObject* parent)
|
||||
: LayerTreeGroup("__root__", parent)
|
||||
{
|
||||
setVisible(Qt::Checked);
|
||||
}
|
||||
|
||||
LayerTree::~LayerTree()
|
||||
{
|
||||
}
|
||||
|
||||
void LayerTree::setChildrenVisible(LayerTreeNode* n, Qt::CheckState state)
|
||||
{
|
||||
if (!n) return;
|
||||
const auto& cs = n->children();
|
||||
for (LayerTreeNode* c : cs) {
|
||||
c->setVisible(state);
|
||||
setChildrenVisible(c, state);
|
||||
}
|
||||
}
|
||||
|
||||
void LayerTree::updateParentVisibleFromChildren(LayerTreeNode* p)
|
||||
{
|
||||
if (!p) return;
|
||||
if (p->childCount() == 0) return;
|
||||
|
||||
int checked = 0, unchecked = 0, partial = 0;
|
||||
const auto& cs = p->children();
|
||||
for (LayerTreeNode* c : cs) {
|
||||
auto s = c->visible();
|
||||
if (s == Qt::Checked) checked++;
|
||||
else if (s == Qt::Unchecked) unchecked++;
|
||||
else partial++;
|
||||
}
|
||||
|
||||
Qt::CheckState newState;
|
||||
if (partial > 0) newState = Qt::PartiallyChecked;
|
||||
else if (checked > 0 && unchecked == 0) newState = Qt::Checked;
|
||||
else if (unchecked > 0 && checked == 0) newState = Qt::Unchecked;
|
||||
else newState = Qt::PartiallyChecked;
|
||||
|
||||
if (p->visible() != newState) {
|
||||
p->setVisible(newState);
|
||||
updateParentVisibleFromChildren(p->parentNode());
|
||||
}
|
||||
}
|
||||
26
HPPA/LayerTree.h
Normal file
26
HPPA/LayerTree.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "LayerTreeGroupNode.h"
|
||||
|
||||
/**
|
||||
* LayerTree<65><65>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
||||
* - <20>̳<EFBFBD><CCB3><EFBFBD> LayerTreeGroup<75><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8>ڵ<EFBFBD>
|
||||
* - <20>ṩ<EFBFBD>ɼ<EFBFBD><C9BC>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>븸<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>µľ<C2B5>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
||||
*
|
||||
* ע<>⣺beginInsertRows/endInsertRows <20><> Qt Model <20><><EFBFBD><EFBFBD>֪ͨӦ<D6AA><D3A6> Model <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
|
||||
* LayerTree ֻ<><D6BB><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>ȷ<EFBFBD>ԡ<EFBFBD>
|
||||
*/
|
||||
class LayerTree : public LayerTreeGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayerTree(QObject* parent = nullptr);
|
||||
~LayerTree() override;
|
||||
|
||||
LayerTree(const LayerTree&) = delete;
|
||||
LayerTree& operator=(const LayerTree&) = delete;
|
||||
|
||||
// <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD> Model <20><><EFBFBD>ã<EFBFBD>
|
||||
static void setChildrenVisible(LayerTreeNode* n, Qt::CheckState state);
|
||||
static void updateParentVisibleFromChildren(LayerTreeNode* parent);
|
||||
};
|
||||
103
HPPA/LayerTreeGroupNode.cpp
Normal file
103
HPPA/LayerTreeGroupNode.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include "LayerTreeGroupNode.h"
|
||||
#include "LayerTreeLayerNode.h"
|
||||
|
||||
LayerTreeGroup::LayerTreeGroup(const QString& name, QObject* parent)
|
||||
: LayerTreeNode(name, parent)
|
||||
{
|
||||
}
|
||||
|
||||
LayerTreeGroup* LayerTreeGroup::insertGroup(int index, const QString& name)
|
||||
{
|
||||
auto* group = new LayerTreeGroup(name);
|
||||
insertChildNode(index, group);
|
||||
return group;
|
||||
}
|
||||
|
||||
LayerTreeGroup* LayerTreeGroup::addGroup(const QString& name)
|
||||
{
|
||||
return insertGroup(childCount(), name);
|
||||
}
|
||||
|
||||
LayerTreeLayer* LayerTreeGroup::insertLayer(int index, LayerTreeLayer* layer)
|
||||
{
|
||||
if (!layer) return nullptr;
|
||||
insertChildNode(index, layer);
|
||||
return layer;
|
||||
}
|
||||
|
||||
LayerTreeLayer* LayerTreeGroup::addLayer(LayerTreeLayer* layer)
|
||||
{
|
||||
return insertLayer(childCount(), layer);
|
||||
}
|
||||
|
||||
void LayerTreeGroup::insertChildNode(int index, LayerTreeNode* node)
|
||||
{
|
||||
insertChild(index, node);
|
||||
}
|
||||
|
||||
void LayerTreeGroup::addChildNode(LayerTreeNode* node)
|
||||
{
|
||||
appendChild(node);
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeGroup::removeChildNode(LayerTreeNode* node)
|
||||
{
|
||||
if (!node) return nullptr;
|
||||
int row = -1;
|
||||
for (int i = 0; i < childCount(); ++i)
|
||||
{
|
||||
if (childAt(i) == node)
|
||||
{
|
||||
row = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (row < 0) return nullptr;
|
||||
removeChild(row, 1, false);
|
||||
return node;
|
||||
}
|
||||
|
||||
LayerTreeLayer* LayerTreeGroup::findLayer(const QString& name) const
|
||||
{
|
||||
const auto layers = findLayers();
|
||||
for (auto* l : layers)
|
||||
{
|
||||
if (l->name() == name)
|
||||
return l;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<LayerTreeLayer*> LayerTreeGroup::findLayers() const
|
||||
{
|
||||
QList<LayerTreeLayer*> result;
|
||||
for (int i = 0; i < childCount(); ++i)
|
||||
{
|
||||
LayerTreeNode* child = childAt(i);
|
||||
if (LayerTreeNode::isLayer(child))
|
||||
{
|
||||
result.append(static_cast<LayerTreeLayer*>(child));
|
||||
}
|
||||
else if (LayerTreeNode::isGroup(child))
|
||||
{
|
||||
result.append(static_cast<LayerTreeGroup*>(child)->findLayers());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<LayerTreeGroup*> LayerTreeGroup::findGroups() const
|
||||
{
|
||||
QList<LayerTreeGroup*> result;
|
||||
for (int i = 0; i < childCount(); ++i)
|
||||
{
|
||||
LayerTreeNode* child = childAt(i);
|
||||
if (LayerTreeNode::isGroup(child))
|
||||
{
|
||||
auto* g = static_cast<LayerTreeGroup*>(child);
|
||||
result.append(g);
|
||||
result.append(g->findGroups());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
44
HPPA/LayerTreeGroupNode.h
Normal file
44
HPPA/LayerTreeGroupNode.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include "LayerTreeNode.h"
|
||||
|
||||
class LayerTreeLayer;
|
||||
|
||||
/**
|
||||
* LayerTreeGroup<75><70>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
||||
* - <20><><EFBFBD><EFBFBD>Ϊ LayerTreeNode
|
||||
* - <20>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ڵ㣨LayerTreeLayer<65><72><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>飨LayerTreeGroup<75><70><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
class LayerTreeGroup : public LayerTreeNode
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayerTreeGroup(const QString& name = QString(),
|
||||
QObject* parent = nullptr);
|
||||
|
||||
Type type() const override { return Type::Group; }
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LayerTreeGroup* insertGroup(int index, const QString& name);
|
||||
LayerTreeGroup* addGroup(const QString& name);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ڵ<EFBFBD>
|
||||
LayerTreeLayer* insertLayer(int index, LayerTreeLayer* layer);
|
||||
LayerTreeLayer* addLayer(LayerTreeLayer* layer);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
||||
void insertChildNode(int index, LayerTreeNode* node);
|
||||
void addChildNode(LayerTreeNode* node);
|
||||
|
||||
// <20>Ƴ<EFBFBD><C6B3>ӽڵ㣨<DAB5><E3A3A8> delete<74><65><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>Ƴ<EFBFBD><C6B3>ڵ㣩
|
||||
LayerTreeNode* removeChildNode(LayerTreeNode* node);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
LayerTreeLayer* findLayer(const QString& name) const;
|
||||
QList<LayerTreeLayer*> findLayers() const;
|
||||
QList<LayerTreeGroup*> findGroups() const;
|
||||
|
||||
// <20>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>collapsed / groupOpacity <20><>
|
||||
};
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
using LayerTreeGroupNode = LayerTreeGroup;
|
||||
22
HPPA/LayerTreeLayerNode.cpp
Normal file
22
HPPA/LayerTreeLayerNode.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "LayerTreeLayerNode.h"
|
||||
|
||||
LayerTreeLayer::LayerTreeLayer(MapLayer* layer, QObject* parent)
|
||||
: LayerTreeNode(layer ? layer->name() : QString(), parent), m_layer(layer)
|
||||
{
|
||||
}
|
||||
|
||||
LayerTreeNode::Type LayerTreeLayer::type() const
|
||||
{
|
||||
return Type::Layer;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> MapLayer ָ<>루<EFBFBD><EBA3A8>ӵ<EFBFBD>У<EFBFBD>
|
||||
void LayerTreeLayer::setMapLayer(MapLayer* layer)
|
||||
{
|
||||
m_layer = layer;
|
||||
}
|
||||
|
||||
MapLayer* LayerTreeLayer::mapLayer() const
|
||||
{
|
||||
return m_layer;
|
||||
}
|
||||
28
HPPA/LayerTreeLayerNode.h
Normal file
28
HPPA/LayerTreeLayerNode.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "LayerTreeNode.h"
|
||||
#include "MapLayer.h"
|
||||
|
||||
/**
|
||||
* LayerTreeLayer<65><72>ͼ<EFBFBD><CDBC><EFBFBD>ڵ<EFBFBD>
|
||||
* - <20><><EFBFBD><EFBFBD>Ϊ LayerTreeNode
|
||||
* - <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> MapLayer ָ<>루<EFBFBD><EBA3A8>ӵ<EFBFBD>У<EFBFBD>
|
||||
*/
|
||||
class LayerTreeLayer : public LayerTreeNode
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayerTreeLayer(MapLayer* layer, QObject* parent = nullptr);
|
||||
|
||||
Type type() const override;
|
||||
|
||||
void setMapLayer(MapLayer* layer);
|
||||
MapLayer* mapLayer() const;
|
||||
|
||||
private:
|
||||
MapLayer* m_layer = nullptr;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>layerId / pointer / legendItems <20><>
|
||||
};
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
using LayerTreeLayerNode = LayerTreeLayer;
|
||||
183
HPPA/LayerTreeModel.cpp
Normal file
183
HPPA/LayerTreeModel.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
#include "LayerTreeModel.h"
|
||||
#include "LayerTreeGroupNode.h"
|
||||
#include "LayerTreeLayerNode.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
LayerTreeModel::LayerTreeModel(LayerTree* tree, QObject* parent, bool cascadeCheck)
|
||||
: QAbstractItemModel(parent),
|
||||
m_tree(tree),
|
||||
m_cascadeCheck(cascadeCheck)
|
||||
{
|
||||
Q_ASSERT(m_tree && "LayerTreeModel requires a valid LayerTree*");
|
||||
}
|
||||
|
||||
QModelIndex LayerTreeModel::index(int row, int column, const QModelIndex& parent) const
|
||||
{
|
||||
if (column != 0 || row < 0) return {};
|
||||
|
||||
LayerTreeNode* parentNode = nodeFromIndex(parent);
|
||||
if (!parentNode) return {};
|
||||
|
||||
LayerTreeNode* child = parentNode->childAt(row);
|
||||
if (!child) return {};
|
||||
|
||||
return createIndex(row, column, child);
|
||||
}
|
||||
|
||||
QModelIndex LayerTreeModel::parent(const QModelIndex& child) const
|
||||
{
|
||||
LayerTreeNode* node = nodeFromIndex(child);
|
||||
if (!node || node == m_tree) return {};
|
||||
|
||||
LayerTreeNode* p = node->parentNode();
|
||||
if (!p || p == m_tree) return {};
|
||||
|
||||
return createIndex(p->rowInParent(), 0, p);
|
||||
}
|
||||
|
||||
int LayerTreeModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
LayerTreeNode* p = nodeFromIndex(parent);
|
||||
return p ? p->childCount() : 0;
|
||||
}
|
||||
|
||||
int LayerTreeModel::columnCount(const QModelIndex&) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant LayerTreeModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
LayerTreeNode* n = nodeFromIndex(index);
|
||||
if (!n || n == m_tree) return {};
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return n->name();
|
||||
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
auto* tmp = nodeFromIndex(index);
|
||||
if (LayerTreeNode::isGroup(tmp))
|
||||
return QIcon();
|
||||
else if (LayerTreeNode::isLayer(tmp))
|
||||
{
|
||||
QString basePath = QCoreApplication::applicationDirPath();
|
||||
return QIcon(":/svg/resources/icons/svg/mIconRaster.svg");
|
||||
}
|
||||
}
|
||||
|
||||
//case Qt::CheckStateRole:
|
||||
// return static_cast<int>(n->visible());
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
return (n->type() == LayerTreeNode::Type::Group) ? "Group" : "Layer";
|
||||
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool LayerTreeModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
LayerTreeNode* n = nodeFromIndex(index);
|
||||
if (!n || n == m_tree) return false;
|
||||
|
||||
if (role == Qt::CheckStateRole) {
|
||||
auto newState = static_cast<Qt::CheckState>(value.toInt());
|
||||
if (n->visible() == newState) return true;
|
||||
|
||||
n->setVisible(newState);
|
||||
|
||||
// 1) <20><> -> <20><> <20><><EFBFBD><EFBFBD>
|
||||
if (m_cascadeCheck) {
|
||||
LayerTree::setChildrenVisible(n, newState);
|
||||
}
|
||||
|
||||
// 2) <20><> -> <20><> <20><><EFBFBD><EFBFBD> PartiallyChecked
|
||||
LayerTree::updateParentVisibleFromChildren(n->parentNode());
|
||||
|
||||
// <20><EFBFBD><F2BBAFA3><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻Ϊ<E6BBBB><CEAA> dataChanged<65><64>
|
||||
emit layoutChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags LayerTreeModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid()) return Qt::NoItemFlags;
|
||||
|
||||
LayerTreeNode* n = nodeFromIndex(index);
|
||||
if (!n || n == m_tree) return Qt::NoItemFlags;
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeModel::root() const
|
||||
{
|
||||
return m_tree;
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeModel::addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon)
|
||||
{
|
||||
if (!parent) parent = m_tree;
|
||||
|
||||
const int row = parent->childCount();
|
||||
beginInsertRows(indexFromNode(parent), row, row);
|
||||
LayerTreeNode* g = m_tree->addGroup(name);
|
||||
endInsertRows();
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeModel::addLayer(LayerTreeNode* parent, LayerTreeLayer* layerNode, const QIcon& icon)
|
||||
{
|
||||
if (!parent) parent = m_tree;
|
||||
if (!layerNode) return nullptr;
|
||||
|
||||
const int row = parent->childCount();
|
||||
beginInsertRows(indexFromNode(parent), row, row);
|
||||
parent->insertChild(row, layerNode);
|
||||
endInsertRows();
|
||||
|
||||
return layerNode;
|
||||
}
|
||||
|
||||
void LayerTreeModel::setCascadeCheckEnabled(bool enabled)
|
||||
{
|
||||
m_cascadeCheck = enabled;
|
||||
}
|
||||
|
||||
bool LayerTreeModel::cascadeCheckEnabled() const
|
||||
{
|
||||
return m_cascadeCheck;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3>Ƴ<EFBFBD><C6B3>ӽڵ㲢<DAB5><E3B2A2> model <20>Ϸ<EFBFBD><CFB7><EFBFBD> begin/endRemoveRows
|
||||
LayerTreeNode* LayerTreeModel::removeNode(LayerTreeNode* parent, int row)
|
||||
{
|
||||
if (!parent) parent = m_tree;
|
||||
if (row < 0 || row >= parent->childCount()) return nullptr;
|
||||
|
||||
LayerTreeNode* removed = parent->childAt(row);
|
||||
beginRemoveRows(indexFromNode(parent), row, row);
|
||||
parent->removeChild(row, 1, false);
|
||||
endRemoveRows();
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeModel::nodeFromIndex(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid()) return m_tree;
|
||||
return static_cast<LayerTreeNode*>(index.internalPointer());
|
||||
}
|
||||
|
||||
QModelIndex LayerTreeModel::indexFromNode(LayerTreeNode* n) const
|
||||
{
|
||||
if (!n || n == m_tree) return {};
|
||||
return createIndex(n->rowInParent(), 0, n);
|
||||
}
|
||||
52
HPPA/LayerTreeModel.h
Normal file
52
HPPA/LayerTreeModel.h
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#include <QCoreApplication>
|
||||
#include <QAbstractItemModel>
|
||||
#include "LayerTree.h"
|
||||
|
||||
class LayerTreeLayer; // forward declare
|
||||
|
||||
/**
|
||||
* LayerTreeModel<65><6C>Qt <20><><EFBFBD><EFBFBD><EFBFBD>㣨<EFBFBD><E3A3A8><EFBFBD>ٹ<EFBFBD><D9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* - 1 <20>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ͼ<EFBFBD>꣩+ checkbox
|
||||
* - <20><>ѡ<EFBFBD>ɼ<EFBFBD><C9BC>ԣ<EFBFBD><D4A3><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||||
*/
|
||||
class LayerTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayerTreeModel(LayerTree* tree,
|
||||
QObject* parent = nullptr,
|
||||
bool cascadeCheck = true);
|
||||
~LayerTreeModel() override = default;
|
||||
|
||||
// QAbstractItemModel <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex& parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex& child) const override;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> API<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD> begin/endInsertRows<77><73>
|
||||
LayerTreeNode* root() const;
|
||||
|
||||
LayerTreeNode* addGroup(LayerTreeNode* parent, const QString& name, const QIcon& icon = QIcon());
|
||||
LayerTreeNode* addLayer(LayerTreeNode* parent, LayerTreeLayer* layerNode, const QIcon& icon = QIcon());
|
||||
|
||||
void setCascadeCheckEnabled(bool enabled);
|
||||
bool cascadeCheckEnabled() const;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><D3B8>ڵ<EFBFBD><DAB5>Ƴ<EFBFBD><C6B3>ӽڵ㣨<DAB5><E3A3A8>װ LayerTree::removeNode <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> model ֪ͨ<CDA8><D6AA>
|
||||
LayerTreeNode* removeNode(LayerTreeNode* parent, int row);
|
||||
|
||||
private:
|
||||
LayerTree* m_tree = nullptr; // not owned
|
||||
bool m_cascadeCheck = true;
|
||||
|
||||
private:
|
||||
LayerTreeNode* nodeFromIndex(const QModelIndex& index) const;
|
||||
QModelIndex indexFromNode(LayerTreeNode* n) const;
|
||||
};
|
||||
135
HPPA/LayerTreeNode.cpp
Normal file
135
HPPA/LayerTreeNode.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
#include "LayerTreeNode.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
LayerTreeNode::LayerTreeNode(const QString& name, QObject* parent)
|
||||
: QObject(parent), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
LayerTreeNode::~LayerTreeNode()
|
||||
{
|
||||
qDeleteAll(m_children);
|
||||
m_children.clear();
|
||||
}
|
||||
|
||||
QString LayerTreeNode::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void LayerTreeNode::setName(const QString& name)
|
||||
{
|
||||
if (m_name != name)
|
||||
{
|
||||
m_name = name;
|
||||
emit nameChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
QIcon LayerTreeNode::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
void LayerTreeNode::setIcon(const QIcon& icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
}
|
||||
|
||||
Qt::CheckState LayerTreeNode::visible() const
|
||||
{
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
void LayerTreeNode::setVisible(Qt::CheckState s)
|
||||
{
|
||||
m_visible = s;
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeNode::parentNode() const
|
||||
{
|
||||
return m_parentNode;
|
||||
}
|
||||
|
||||
void LayerTreeNode::setParentNode(LayerTreeNode* p)
|
||||
{
|
||||
m_parentNode = p;
|
||||
// <20><> QObject <20><> parent Ҳ<><D2B2><EFBFBD>棨<EFBFBD><E6A3A8><EFBFBD><EFBFBD> Qt <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD> delete children<65><6E>
|
||||
if (p) this->setParent(p);
|
||||
else this->setParent(nullptr);
|
||||
}
|
||||
|
||||
int LayerTreeNode::rowInParent() const
|
||||
{
|
||||
if (!m_parentNode) return 0;
|
||||
|
||||
const auto& siblings = m_parentNode->m_children;
|
||||
for (int i = 0; i < siblings.size(); ++i)
|
||||
{
|
||||
if (siblings[i] == this) return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LayerTreeNode::childCount() const
|
||||
{
|
||||
return m_children.size();
|
||||
}
|
||||
|
||||
LayerTreeNode* LayerTreeNode::childAt(int row) const
|
||||
{
|
||||
if (row < 0 || row >= m_children.size()) return nullptr;
|
||||
return m_children[row];
|
||||
}
|
||||
|
||||
const QVector<LayerTreeNode*>& LayerTreeNode::children() const
|
||||
{
|
||||
return m_children;
|
||||
}
|
||||
|
||||
void LayerTreeNode::appendChild(LayerTreeNode* child)
|
||||
{
|
||||
insertChild(m_children.size(), child);
|
||||
}
|
||||
|
||||
void LayerTreeNode::insertChild(int row, LayerTreeNode* child)
|
||||
{
|
||||
if (!child) return;
|
||||
|
||||
if (row < 0 || row > m_children.size())
|
||||
row = m_children.size();
|
||||
|
||||
emit willAddChildren(this, row, row);
|
||||
child->setParentNode(this);
|
||||
m_children.insert(row, child);
|
||||
emit addedChildren(this, row, row);
|
||||
}
|
||||
|
||||
void LayerTreeNode::removeChild(int from, int count, bool destroy)
|
||||
{
|
||||
if (from < 0 || count <= 0 || from + count > m_children.size()) return;
|
||||
|
||||
emit willRemoveChildren(this, from, from + count - 1);
|
||||
|
||||
QVector<LayerTreeNode*> removed;
|
||||
removed.reserve(count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
removed.append(m_children.at(from));
|
||||
m_children.removeAt(from);
|
||||
}
|
||||
|
||||
for (LayerTreeNode* node : removed)
|
||||
{
|
||||
node->setParentNode(nullptr);
|
||||
}
|
||||
|
||||
emit removedChildren(this, from, from + count - 1);
|
||||
|
||||
if (destroy)
|
||||
{
|
||||
qDeleteAll(removed);
|
||||
}
|
||||
}
|
||||
91
HPPA/LayerTreeNode.h
Normal file
91
HPPA/LayerTreeNode.h
Normal file
@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QIcon>
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* LayerTreeNode<64><65><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ࣨ<EFBFBD><E0A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD>/ͼ<><CDBC>/<2F>ɼ<EFBFBD><C9BC><EFBFBD>/<2F><><EFBFBD>ӹ<EFBFBD>ϵ
|
||||
* - Group / Layer <20>ڵ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>̳<EFBFBD>ʵ<EFBFBD><CAB5>
|
||||
* - <20>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD>/ɾ<><C9BE><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ź<EFBFBD>֪ͨ
|
||||
*
|
||||
* ˵<><CBB5><EFBFBD><EFBFBD>
|
||||
* - <20><><EFBFBD><EFBFBD>ͬʱά<CAB1><CEAC>"<22><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>"<22><>m_parentNode<64><65><EFBFBD><EFBFBD> QObject parent<6E><74><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||||
* - children <20>ɽڵ<C9BD><DAB5>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷţ<CDB7><C5A3><EFBFBD><EFBFBD><EFBFBD>ʱ delete children<65><6E>
|
||||
*/
|
||||
class LayerTreeNode : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Type { Group, Layer };
|
||||
|
||||
explicit LayerTreeNode(const QString& name,
|
||||
QObject* parent = nullptr);
|
||||
~LayerTreeNode() override;
|
||||
|
||||
LayerTreeNode(const LayerTreeNode&) = delete;
|
||||
LayerTreeNode& operator=(const LayerTreeNode&) = delete;
|
||||
|
||||
virtual Type type() const = 0;
|
||||
|
||||
// ---- properties ----
|
||||
QString name() const;
|
||||
void setName(const QString& name);
|
||||
|
||||
QIcon icon() const;
|
||||
void setIcon(const QIcon& icon);
|
||||
|
||||
Qt::CheckState visible() const;
|
||||
void setVisible(Qt::CheckState s);
|
||||
|
||||
// ---- tree relations ----
|
||||
LayerTreeNode* parentNode() const;
|
||||
int rowInParent() const;
|
||||
|
||||
int childCount() const;
|
||||
LayerTreeNode* childAt(int row) const;
|
||||
const QVector<LayerTreeNode*>& children() const;
|
||||
|
||||
// ---- structure mutation (used by LayerTree / Model) ----
|
||||
void appendChild(LayerTreeNode* child);
|
||||
void insertChild(int row, LayerTreeNode* child);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> QgsLayerTreeNode::removeChildrenPrivate <20>Ľ<EFBFBD>
|
||||
// from: <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>, count: <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>, destroy: true <20><> delete <20><><EFBFBD>Ƴ<EFBFBD><C6B3>ڵ<EFBFBD>
|
||||
void removeChild(int from, int count, bool destroy = true);
|
||||
|
||||
// ---- static type helpers ----
|
||||
static inline bool isLayer(LayerTreeNode* node)
|
||||
{
|
||||
return node && node->type() == LayerTreeNode::Type::Layer;
|
||||
}
|
||||
|
||||
static inline bool isGroup(LayerTreeNode* node)
|
||||
{
|
||||
return node && node->type() == LayerTreeNode::Type::Group;
|
||||
}
|
||||
|
||||
signals:
|
||||
// <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ӽڵ<D3BD>֮ǰ/֮<><EFBFBD>
|
||||
void willAddChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||
void addedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||
|
||||
// <20><><EFBFBD>Ƴ<EFBFBD><C6B3>ӽڵ<D3BD>֮ǰ/֮<><EFBFBD>
|
||||
void willRemoveChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||
void removedChildren(LayerTreeNode* node, int indexFrom, int indexTo);
|
||||
|
||||
void nameChanged(LayerTreeNode* node, const QString& name);
|
||||
|
||||
protected:
|
||||
void setParentNode(LayerTreeNode* p);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QIcon m_icon;
|
||||
Qt::CheckState m_visible = Qt::Checked;
|
||||
|
||||
LayerTreeNode* m_parentNode = nullptr;
|
||||
QVector<LayerTreeNode*> m_children;
|
||||
};
|
||||
52
HPPA/LayerTreeView.cpp
Normal file
52
HPPA/LayerTreeView.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "LayerTreeView.h"
|
||||
#include "LayerTreeViewMenuProvider.h"
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
|
||||
LayerTreeView::LayerTreeView(QWidget* parent)
|
||||
: QTreeView(parent), m_menuProvider(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
LayerTreeView::~LayerTreeView()
|
||||
{
|
||||
delete m_menuProvider;
|
||||
}
|
||||
|
||||
void LayerTreeView::setMenuProvider(LayerTreeViewMenuProvider* provider)
|
||||
{
|
||||
m_menuProvider = provider;
|
||||
}
|
||||
|
||||
void LayerTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
if (!m_menuProvider)
|
||||
return;
|
||||
|
||||
const QModelIndex idx = indexAt(event->pos());
|
||||
if (idx.isValid())
|
||||
setCurrentIndex(idx);
|
||||
else
|
||||
setCurrentIndex(QModelIndex());
|
||||
|
||||
QMenu* menu = m_menuProvider->createContextMenu();
|
||||
menu->setStyleSheet(R"(
|
||||
QMenu {
|
||||
background-color: #2a5dec;
|
||||
color: white;
|
||||
}
|
||||
QMenu::item:selected {
|
||||
background-color: #1a4ddc;
|
||||
}
|
||||
QMenu::separator {
|
||||
height: 1px;
|
||||
background: white;
|
||||
}
|
||||
)");
|
||||
if (menu)
|
||||
{
|
||||
menu->exec(event->globalPos());
|
||||
delete menu;
|
||||
}
|
||||
//QTreeView::contextMenuEvent(event);
|
||||
}
|
||||
20
HPPA/LayerTreeView.h
Normal file
20
HPPA/LayerTreeView.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
class LayerTreeViewMenuProvider;
|
||||
|
||||
class LayerTreeView : public QTreeView
|
||||
{
|
||||
public:
|
||||
explicit LayerTreeView(QWidget* parent = nullptr);
|
||||
~LayerTreeView() override;
|
||||
|
||||
void setMenuProvider(LayerTreeViewMenuProvider* provider);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* event) override;
|
||||
|
||||
private:
|
||||
LayerTreeViewMenuProvider* m_menuProvider = nullptr; // not owned
|
||||
};
|
||||
55
HPPA/LayerTreeViewMenuProvider.cpp
Normal file
55
HPPA/LayerTreeViewMenuProvider.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "LayerTreeViewMenuProvider.h"
|
||||
#include "LayerTreeView.h"
|
||||
#include "LayerTreeModel.h"
|
||||
#include "LayerTreeNode.h"
|
||||
#include "HPPA.h"
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
|
||||
LayerTreeViewMenuProvider::LayerTreeViewMenuProvider(LayerTreeView* view, QObject* parent)
|
||||
: QObject(parent), m_view(view)
|
||||
{
|
||||
}
|
||||
|
||||
QMenu* LayerTreeViewMenuProvider::createContextMenu()
|
||||
{
|
||||
m_contextIndex = m_view->currentIndex();
|
||||
|
||||
QMenu* menu = new QMenu();
|
||||
|
||||
if (!m_contextIndex.isValid())
|
||||
{
|
||||
return menu;
|
||||
}
|
||||
|
||||
const LayerTreeModel* model = static_cast<const LayerTreeModel*>(m_contextIndex.model());
|
||||
if (!model)
|
||||
{
|
||||
return menu;
|
||||
}
|
||||
|
||||
LayerTreeNode* node = static_cast<LayerTreeNode*>(m_contextIndex.internalPointer());
|
||||
if (!node)
|
||||
{
|
||||
return menu;
|
||||
}
|
||||
|
||||
if (node->type() == LayerTreeNode::Type::Layer)
|
||||
{
|
||||
QAction* removeAction = new QAction(QStringLiteral("<EFBFBD>Ƴ<EFBFBD>ͼ<EFBFBD><EFBFBD>"), menu);
|
||||
connect(removeAction, &QAction::triggered, HPPA::instance(), &HPPA::removeLayerByTreeIndex);
|
||||
menu->addAction(removeAction);
|
||||
}
|
||||
else if (node->type() == LayerTreeNode::Type::Group)
|
||||
{
|
||||
HPPA* app = HPPA::instance();
|
||||
if (app && node == app->rasterGroupNode())
|
||||
{
|
||||
QAction* removeAllAction = new QAction(QStringLiteral("<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>"), menu);
|
||||
connect(removeAllAction, &QAction::triggered, app, &HPPA::removeAllLayersInRasterGroup);
|
||||
menu->addAction(removeAllAction);
|
||||
}
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
24
HPPA/LayerTreeViewMenuProvider.h
Normal file
24
HPPA/LayerTreeViewMenuProvider.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMenu>
|
||||
#include <QObject>
|
||||
#include <QModelIndex>
|
||||
|
||||
class LayerTreeView;
|
||||
class LayerTreeModel;
|
||||
class MapLayer;
|
||||
|
||||
class LayerTreeViewMenuProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayerTreeViewMenuProvider(LayerTreeView* view, QObject* parent = nullptr);
|
||||
~LayerTreeViewMenuProvider() override = default;
|
||||
|
||||
// <20><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> index <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߸<EFBFBD><DFB8><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> QMenu*
|
||||
QMenu* createContextMenu();
|
||||
|
||||
private:
|
||||
LayerTreeView* m_view = nullptr; // not owned
|
||||
QModelIndex m_contextIndex;
|
||||
};
|
||||
26
HPPA/MapLayer.cpp
Normal file
26
HPPA/MapLayer.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "MapLayer.h"
|
||||
|
||||
MapLayer::MapLayer(const QString& name, const QString& uri)
|
||||
: QObject(nullptr), m_name(name), m_uri(uri)
|
||||
{
|
||||
}
|
||||
|
||||
QString MapLayer::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void MapLayer::setName(const QString& n)
|
||||
{
|
||||
m_name = n;
|
||||
}
|
||||
|
||||
QString MapLayer::dataPath() const
|
||||
{
|
||||
return m_uri;
|
||||
}
|
||||
|
||||
void MapLayer::setDataPath(const QString& p)
|
||||
{
|
||||
m_uri = p;
|
||||
}
|
||||
30
HPPA/MapLayer.h
Normal file
30
HPPA/MapLayer.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMetaType>
|
||||
|
||||
class MapLayer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class LayerType { Raster, Vector };
|
||||
|
||||
explicit MapLayer(const QString& name, const QString& uri);
|
||||
|
||||
virtual ~MapLayer() override = default;
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString& n);
|
||||
|
||||
QString dataPath() const;
|
||||
void setDataPath(const QString& p);
|
||||
|
||||
virtual LayerType layerType() const = 0;
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_uri;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(MapLayer*)
|
||||
92
HPPA/MapLayerStore.cpp
Normal file
92
HPPA/MapLayerStore.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
#include "MapLayerStore.h"
|
||||
#include "MapLayer.h"
|
||||
|
||||
MapLayerStore::MapLayerStore(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
void MapLayerStore::addLayer(MapLayer* layer, QWidget* widget)
|
||||
{
|
||||
if (!layer) return;
|
||||
MapLayer* raw = layer;
|
||||
m_layers.emplace_back(std::shared_ptr<MapLayer>(layer));
|
||||
if (widget)
|
||||
m_layerWidgets[raw] = widget;
|
||||
emit layerAdded(raw);
|
||||
}
|
||||
|
||||
void MapLayerStore::removeLayer(MapLayer* layer)
|
||||
{
|
||||
if (!layer) return;
|
||||
for (auto it = m_layers.begin(); it != m_layers.end(); ++it) {
|
||||
if (it->get() == layer) {
|
||||
emit layerAboutToBeRemoved(layer);
|
||||
m_layers.erase(it);
|
||||
m_layerWidgets.erase(layer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapLayerStore::removeLayerByName(const QString& name)
|
||||
{
|
||||
for (auto it = m_layers.begin(); it != m_layers.end(); ++it) {
|
||||
if ((*it)->name() == name) {
|
||||
MapLayer* raw = it->get();
|
||||
emit layerAboutToBeRemoved(raw);
|
||||
m_layers.erase(it);
|
||||
m_layerWidgets.erase(raw);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MapLayer* MapLayerStore::getLayer(const QString& name) const
|
||||
{
|
||||
for (const auto& l : m_layers) {
|
||||
if (l->name() == name) return l.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MapLayer* MapLayerStore::getLayerAt(int index) const
|
||||
{
|
||||
if (index < 0 || index >= (int)m_layers.size()) return nullptr;
|
||||
return m_layers[index].get();
|
||||
}
|
||||
|
||||
int MapLayerStore::layerCount() const
|
||||
{
|
||||
return (int)m_layers.size();
|
||||
}
|
||||
|
||||
QWidget* MapLayerStore::widgetForLayer(MapLayer* layer) const
|
||||
{
|
||||
auto it = m_layerWidgets.find(layer);
|
||||
if (it == m_layerWidgets.end()) return nullptr;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
QWidget* MapLayerStore::widgetForLayer(const QString& absolutePath) const
|
||||
{
|
||||
for (const auto& sp : m_layers) {
|
||||
if (sp && sp->dataPath() == absolutePath) {
|
||||
MapLayer* raw = sp.get();
|
||||
auto it = m_layerWidgets.find(raw);
|
||||
if (it != m_layerWidgets.end()) return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MapLayer* MapLayerStore::layerForWidget(QWidget* widget) const
|
||||
{
|
||||
if (!widget) return nullptr;
|
||||
for (const auto& kv : m_layerWidgets) {
|
||||
if (kv.second == widget) return kv.first;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
51
HPPA/MapLayerStore.h
Normal file
51
HPPA/MapLayerStore.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class MapLayer;
|
||||
class QWidget;
|
||||
|
||||
class MapLayerStore : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MapLayerStore(QObject* parent = nullptr);
|
||||
~MapLayerStore() override = default;
|
||||
|
||||
// Take ownership of the layer (store will own and manage its lifetime)
|
||||
// Now also accept the associated QWidget so UI widget can be retrieved by layer pointer
|
||||
void addLayer(MapLayer* layer, QWidget* widget = nullptr);
|
||||
|
||||
// Remove by pointer or by name. Destruction happens when removed from store.
|
||||
public slots:
|
||||
void removeLayer(MapLayer* layer);
|
||||
void removeLayerByName(const QString& name);
|
||||
|
||||
// Queries
|
||||
MapLayer* getLayer(const QString& name) const;
|
||||
MapLayer* getLayerAt(int index) const;
|
||||
int layerCount() const;
|
||||
|
||||
// Get associated widget for a layer (or nullptr if none)
|
||||
QWidget* widgetForLayer(MapLayer* layer) const;
|
||||
// Get associated widget by layer absolute data path
|
||||
QWidget* widgetForLayer(const QString& absolutePath) const;
|
||||
|
||||
// Reverse lookup: find the MapLayer associated with a given widget (or nullptr)
|
||||
MapLayer* layerForWidget(QWidget* widget) const;
|
||||
|
||||
signals:
|
||||
void layerAdded(MapLayer* layer);
|
||||
// Emitted just before the layer is destroyed/removed from store
|
||||
void layerAboutToBeRemoved(MapLayer* layer);
|
||||
|
||||
private:
|
||||
// store shared ownership so other parts can keep raw pointers safely (or use QPointer)
|
||||
std::vector<std::shared_ptr<MapLayer>> m_layers;
|
||||
// mapping from raw MapLayer pointer to associated QWidget*
|
||||
std::unordered_map<MapLayer*, QWidget*> m_layerWidgets;
|
||||
};
|
||||
110
HPPA/MapTool.cpp
Normal file
110
HPPA/MapTool.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "stdafx.h"
|
||||
#include "MapTool.h"
|
||||
#include "ImageViewer.h"
|
||||
#include <QAction>
|
||||
|
||||
MapTool::MapTool(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_cursor(Qt::ArrowCursor)
|
||||
{
|
||||
}
|
||||
|
||||
MapTool::~MapTool()
|
||||
{
|
||||
if (m_canvas && m_canvas->mapTool() == this)
|
||||
{
|
||||
m_canvas->unsetMapTool(this);
|
||||
}
|
||||
}
|
||||
|
||||
QAction* MapTool::action() const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
void MapTool::setAction(QAction* action)
|
||||
{
|
||||
m_action = action;
|
||||
}
|
||||
|
||||
void MapTool::setMapcavas(Mapcavas* canvas)
|
||||
{
|
||||
if (m_canvas == canvas)
|
||||
return;
|
||||
|
||||
if (m_isActive && m_canvas)
|
||||
{
|
||||
//deactivate();
|
||||
}
|
||||
|
||||
m_canvas = canvas;
|
||||
}
|
||||
|
||||
Mapcavas* MapTool::canvas() const
|
||||
{
|
||||
return m_canvas;
|
||||
}
|
||||
|
||||
void MapTool::setCursor(const QCursor& cursor)
|
||||
{
|
||||
m_cursor = cursor;
|
||||
}
|
||||
|
||||
QCursor MapTool::cursor() const
|
||||
{
|
||||
return m_cursor;
|
||||
}
|
||||
|
||||
void MapTool::activate()
|
||||
{
|
||||
if (m_canvas)
|
||||
{
|
||||
m_canvas->viewport()->setCursor(m_cursor);
|
||||
}
|
||||
if (m_action)
|
||||
{
|
||||
m_action->setChecked(true);
|
||||
}
|
||||
m_isActive = true;
|
||||
emit activated();
|
||||
}
|
||||
|
||||
void MapTool::deactivate()
|
||||
{
|
||||
if (m_action)
|
||||
{
|
||||
m_action->setChecked(false);
|
||||
}
|
||||
m_isActive = false;
|
||||
emit deactivated();
|
||||
}
|
||||
|
||||
bool MapTool::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
void MapTool::canvasMousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
|
||||
void MapTool::canvasMouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
|
||||
void MapTool::canvasMouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
|
||||
void MapTool::canvasMouseDoubleClickEvent(QMouseEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
|
||||
void MapTool::canvasWheelEvent(QWheelEvent* e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
63
HPPA/MapTool.h
Normal file
63
HPPA/MapTool.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef MAPTOOL_H
|
||||
#define MAPTOOL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QCursor>
|
||||
#include <QMouseEvent>
|
||||
#include <QAction>
|
||||
|
||||
class Mapcavas;
|
||||
class QAction;
|
||||
|
||||
class MapTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Flag
|
||||
{
|
||||
NoFlags = 0,
|
||||
Transient = 1 << 1,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
MapTool(QObject* parent = nullptr);
|
||||
virtual ~MapTool();
|
||||
|
||||
virtual Flags flags() const { return NoFlags; }
|
||||
|
||||
QAction* action() const;
|
||||
void setAction(QAction* action);
|
||||
|
||||
void setMapcavas(Mapcavas* canvas);
|
||||
Mapcavas* canvas() const;
|
||||
|
||||
virtual void setCursor(const QCursor& cursor);
|
||||
QCursor cursor() const;
|
||||
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
bool isActive() const;
|
||||
|
||||
virtual void canvasMousePressEvent(QMouseEvent* e);
|
||||
virtual void canvasMouseReleaseEvent(QMouseEvent* e);
|
||||
virtual void canvasMouseMoveEvent(QMouseEvent* e);
|
||||
virtual void canvasMouseDoubleClickEvent(QMouseEvent* e);
|
||||
virtual void canvasWheelEvent(QWheelEvent* e);
|
||||
|
||||
signals:
|
||||
void activated();
|
||||
void deactivated();
|
||||
|
||||
protected:
|
||||
Mapcavas* m_canvas = nullptr;
|
||||
|
||||
private:
|
||||
QAction* m_action = nullptr;
|
||||
QCursor m_cursor;
|
||||
bool m_isActive = false;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(MapTool::Flags)
|
||||
|
||||
#endif // MAPTOOL_H
|
||||
65
HPPA/MapToolPan.cpp
Normal file
65
HPPA/MapToolPan.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
#include "stdafx.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "ImageViewer.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsView>
|
||||
|
||||
MapToolPan::MapToolPan(QObject* parent)
|
||||
: MapTool(parent)
|
||||
{
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
||||
MapToolPan::~MapToolPan()
|
||||
{
|
||||
}
|
||||
|
||||
void MapToolPan::activate()
|
||||
{
|
||||
MapTool::activate();
|
||||
if (canvas())
|
||||
{
|
||||
canvas()->setDragMode(QGraphicsView::NoDrag);
|
||||
}
|
||||
}
|
||||
|
||||
void MapToolPan::deactivate()
|
||||
{
|
||||
m_dragging = false;
|
||||
MapTool::deactivate();
|
||||
}
|
||||
|
||||
void MapToolPan::canvasMousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
{
|
||||
m_dragging = true;
|
||||
m_lastPos = e->pos();
|
||||
if (canvas())
|
||||
{
|
||||
canvas()->viewport()->setCursor(Qt::ClosedHandCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapToolPan::canvasMouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_dragging && canvas())
|
||||
{
|
||||
QPointF delta = canvas()->mapToScene(e->pos()) - canvas()->mapToScene(m_lastPos);
|
||||
canvas()->translate(delta.x(), delta.y());
|
||||
m_lastPos = e->pos();
|
||||
}
|
||||
}
|
||||
|
||||
void MapToolPan::canvasMouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
{
|
||||
m_dragging = false;
|
||||
if (canvas())
|
||||
{
|
||||
canvas()->viewport()->setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
HPPA/MapToolPan.h
Normal file
27
HPPA/MapToolPan.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef MAPTOOLPAN_H
|
||||
#define MAPTOOLPAN_H
|
||||
|
||||
#include "MapTool.h"
|
||||
#include <QPoint>
|
||||
|
||||
class MapToolPan : public MapTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapToolPan(QObject* parent = nullptr);
|
||||
~MapToolPan();
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
|
||||
void canvasMousePressEvent(QMouseEvent* e) override;
|
||||
void canvasMouseMoveEvent(QMouseEvent* e) override;
|
||||
void canvasMouseReleaseEvent(QMouseEvent* e) override;
|
||||
|
||||
private:
|
||||
bool m_dragging = false;
|
||||
QPoint m_lastPos;
|
||||
};
|
||||
|
||||
#endif // MAPTOOLPAN_H
|
||||
57
HPPA/MapToolSpectral.cpp
Normal file
57
HPPA/MapToolSpectral.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "stdafx.h"
|
||||
#include "MapToolSpectral.h"
|
||||
#include "ImageViewer.h"
|
||||
#include "RasterLayer.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QPen>
|
||||
#include <cmath>
|
||||
|
||||
MapToolSpectral::MapToolSpectral(QObject* parent)
|
||||
: MapTool(parent)
|
||||
{
|
||||
setCursor(Qt::CrossCursor);
|
||||
}
|
||||
|
||||
MapToolSpectral::~MapToolSpectral()
|
||||
{
|
||||
}
|
||||
|
||||
void MapToolSpectral::activate()
|
||||
{
|
||||
MapTool::activate();
|
||||
}
|
||||
|
||||
void MapToolSpectral::deactivate()
|
||||
{
|
||||
canvas()->removeCrosshair();
|
||||
MapTool::deactivate();
|
||||
}
|
||||
|
||||
void MapToolSpectral::canvasMousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
if (!canvas())
|
||||
return;
|
||||
|
||||
const QPointF scenePt = canvas()->mapToScene(e->pos());
|
||||
const int x = static_cast<int>(std::floor(scenePt.x()));
|
||||
const int y = static_cast<int>(std::floor(scenePt.y()));
|
||||
|
||||
RasterLayer* rl = canvas()->rasterLayer();
|
||||
if (rl && rl->isValidPixel(x, y))
|
||||
{
|
||||
// Place crosshair at pixel center
|
||||
canvas()->updateCrosshair(x + 0.5, y + 0.5);
|
||||
|
||||
QVector<double> wavelengths;
|
||||
QVector<double> spectrum;
|
||||
if (rl->readPixelSpectrum(x, y, wavelengths, spectrum))
|
||||
{
|
||||
emit spectralClicked(x, y, wavelengths, spectrum);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
HPPA/MapToolSpectral.h
Normal file
28
HPPA/MapToolSpectral.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef MAPTOOLSPECTRAL_H
|
||||
#define MAPTOOLSPECTRAL_H
|
||||
|
||||
#include "MapTool.h"
|
||||
#include <QVector>
|
||||
|
||||
class QGraphicsLineItem;
|
||||
|
||||
class MapToolSpectral : public MapTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapToolSpectral(QObject* parent = nullptr);
|
||||
~MapToolSpectral();
|
||||
|
||||
void canvasMousePressEvent(QMouseEvent* e) override;
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
|
||||
signals:
|
||||
void spectralClicked(int x, int y, QVector<double> wavelengths, QVector<double> spectrum);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // MAPTOOLSPECTRAL_H
|
||||
50
HPPA/MapTools.cpp
Normal file
50
HPPA/MapTools.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "stdafx.h"
|
||||
#include "MapTools.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "MapToolSpectral.h"
|
||||
|
||||
MapTools::MapTools(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_tools.insert(Pan, new MapToolPan(this));
|
||||
m_tools.insert(Spectral, new MapToolSpectral(this));
|
||||
}
|
||||
|
||||
MapTools::~MapTools()
|
||||
{
|
||||
qDeleteAll(m_tools);
|
||||
m_tools.clear();
|
||||
}
|
||||
|
||||
MapToolPan* MapTools::mapToolPan() const
|
||||
{
|
||||
return qobject_cast<MapToolPan*>(m_tools.value(Pan));
|
||||
}
|
||||
|
||||
MapToolSpectral* MapTools::mapToolSpectral() const
|
||||
{
|
||||
return qobject_cast<MapToolSpectral*>(m_tools.value(Spectral));
|
||||
}
|
||||
|
||||
MapTool* MapTools::mapTool(Tool tool) const
|
||||
{
|
||||
return m_tools.value(tool, nullptr);
|
||||
}
|
||||
|
||||
MapTool* MapTools::activeTool() const
|
||||
{
|
||||
return m_activeTool;
|
||||
}
|
||||
|
||||
void MapTools::setActiveTool(MapTool* tool)
|
||||
{
|
||||
m_activeTool = tool;
|
||||
}
|
||||
|
||||
void MapTools::setMapcavas(Mapcavas* canvas)
|
||||
{
|
||||
if (m_activeTool)
|
||||
{
|
||||
m_activeTool->setMapcavas(canvas);
|
||||
}
|
||||
}
|
||||
41
HPPA/MapTools.h
Normal file
41
HPPA/MapTools.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef MAPTOOLS_H
|
||||
#define MAPTOOLS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
class MapTool;
|
||||
class MapToolPan;
|
||||
class MapToolSpectral;
|
||||
class Mapcavas;
|
||||
|
||||
class MapTools : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Tool
|
||||
{
|
||||
Pan,
|
||||
Spectral,
|
||||
};
|
||||
|
||||
MapTools(QObject* parent = nullptr);
|
||||
~MapTools();
|
||||
|
||||
MapToolPan* mapToolPan() const;
|
||||
MapToolSpectral* mapToolSpectral() const;
|
||||
|
||||
MapTool* mapTool(Tool tool) const;
|
||||
|
||||
MapTool* activeTool() const;
|
||||
void setActiveTool(MapTool* tool);
|
||||
|
||||
void setMapcavas(Mapcavas* canvas);
|
||||
|
||||
private:
|
||||
QHash<Tool, MapTool*> m_tools;
|
||||
MapTool* m_activeTool = nullptr;
|
||||
};
|
||||
|
||||
#endif // MAPTOOLS_H
|
||||
@ -32,7 +32,7 @@ void OneMotorControl::onConnectMotor()
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
m_motorThread.start();
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
|
||||
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
@ -53,12 +53,10 @@ void OneMotorControl::onConnectMotor()
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
|
||||
connect(this, SIGNAL(recordHyperSpecImgOneMotorSignal(int, double, double)), m_multiAxisController, SLOT(recordHyperSpecImgOneMotor(int, double, double)));
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(startRecordLineSignal(int)), this, SIGNAL(startRecordLineSignal(int)));
|
||||
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
}
|
||||
|
||||
@ -66,6 +64,8 @@ void OneMotorControl::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
|
||||
emit broadcastLocationSignal(loc);
|
||||
}
|
||||
|
||||
void OneMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
||||
@ -119,15 +119,60 @@ void OneMotorControl::onxMotorStop()
|
||||
emit stopSignal(0);
|
||||
}
|
||||
|
||||
void OneMotorControl::moveMotorAndRecordHyperSpecImg(int updateIntervalMs)
|
||||
void OneMotorControl::setImager(ImagerOperationBase* imager)
|
||||
{
|
||||
double runSpeed = ui.speed_lineEdit->text().toDouble();
|
||||
double returnSpeed = ui.return_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit recordHyperSpecImgOneMotorSignal(updateIntervalMs, runSpeed, returnSpeed);
|
||||
m_Imager = imager;
|
||||
}
|
||||
|
||||
void OneMotorControl::moveMotor2StartPosAndStopRecord()
|
||||
void OneMotorControl::record_dark()
|
||||
{
|
||||
m_multiAxisController->cancelRecord();
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_darkCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_darkCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(0, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_darkCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void OneMotorControl::record_white()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_whiteCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_whiteCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(1, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_whiteCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void OneMotorControl::run()
|
||||
{
|
||||
if (m_coordinator == nullptr)
|
||||
{
|
||||
qRegisterMetaType<OneMotionCapturePathLine>("OneMotionCapturePathLine");
|
||||
m_coordinator = new OneMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
connect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
||||
connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
||||
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
||||
}
|
||||
|
||||
OneMotionCapturePathLine tmp;
|
||||
tmp.speedRecord = ui.speed_lineEdit->text().toDouble();
|
||||
tmp.speedBack = ui.return_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit start(tmp);
|
||||
}
|
||||
|
||||
void OneMotorControl::stop()
|
||||
{
|
||||
emit stopStepMotionSignal();
|
||||
}
|
||||
|
||||
void OneMotorControl::onSequenceComplete()
|
||||
{
|
||||
emit sequenceComplete();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include "IrisMultiMotorController.h"
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
class OneMotorControl : public QDialog
|
||||
{
|
||||
@ -15,8 +16,13 @@ public:
|
||||
OneMotorControl(QWidget* parent = nullptr);
|
||||
~OneMotorControl();
|
||||
|
||||
void moveMotorAndRecordHyperSpecImg(int updateIntervalMs);
|
||||
void moveMotor2StartPosAndStopRecord();
|
||||
void setImager(ImagerOperationBase* imager);
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
void record_dark();
|
||||
void record_white();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
@ -32,6 +38,8 @@ public Q_SLOTS:
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
|
||||
void onSequenceComplete();
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
@ -42,12 +50,22 @@ signals:
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void recordHyperSpecImgOneMotorSignal(int updateIntervalMs, double runSpeed, double returnSpeed);
|
||||
void start(OneMotionCapturePathLine);
|
||||
void stopStepMotionSignal();
|
||||
|
||||
void sequenceComplete();
|
||||
|
||||
void broadcastLocationSignal(std::vector<double>);
|
||||
|
||||
void startRecordLineSignal(int);
|
||||
private:
|
||||
Ui::OneMotorControl_UI ui;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
|
||||
OneMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||
ImagerOperationBase* m_Imager;
|
||||
|
||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||
};
|
||||
|
||||
@ -1,308 +0,0 @@
|
||||
#include "PathPlan.h"
|
||||
#include <iostream>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <fileOperation.h>
|
||||
|
||||
PathPlan::PathPlan(VinceControl* xMotor, VinceControl* yMotor, QMotorDoubleSlider* xSlider, QMotorDoubleSlider* ySlider, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_xMotor = xMotor;
|
||||
m_yMotor = yMotor;
|
||||
|
||||
m_xSlider = xSlider;
|
||||
m_ySlider = ySlider;
|
||||
|
||||
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
|
||||
ui.recordLine_tableWidget->setStyleSheet("selection-background-color:rgb(255,209,128)");//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
|
||||
|
||||
ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ
|
||||
//ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ģʽ<C4A3><CABD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//QHeaderView* headerView = ui.recordLine_tableWidget->verticalHeader();
|
||||
//headerView->setHidden(true);//ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>к<EFBFBD>
|
||||
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
PathPlan::~PathPlan()
|
||||
{}
|
||||
|
||||
void PathPlan::setMotor(VinceControl* xMotor, VinceControl* yMotor)
|
||||
{
|
||||
m_xMotor = xMotor;
|
||||
m_yMotor = yMotor;
|
||||
}
|
||||
|
||||
QTableWidget* PathPlan::getRecordLineTableWidget()
|
||||
{
|
||||
return ui.recordLine_tableWidget;
|
||||
}
|
||||
|
||||
void PathPlan::onAddRecordLine_btn()
|
||||
{
|
||||
//<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ByteBack MotorState = m_yMotor->GetState();
|
||||
double currentPosOfYmotor = m_ySlider->getDistanceFromPulse(MotorState.Location);
|
||||
double maxRangeOfXmotro = m_xSlider->maximum();
|
||||
|
||||
//<2F><>ȡѡ<C8A1><D1A1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
int currentRow = ui.recordLine_tableWidget->currentRow();
|
||||
std::cout << "currentRow<EFBFBD><EFBFBD>" << currentRow << std::endl;
|
||||
|
||||
QTableWidgetItem* Item1 = new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2));
|
||||
QTableWidgetItem* Item2 = new QTableWidgetItem(QString::number(maxRangeOfXmotro, 10, 2));
|
||||
Item1->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item2->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
if (currentRow == -1)//<2F><>û<EFBFBD><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʱ
|
||||
{
|
||||
int RowCount = ui.recordLine_tableWidget->rowCount();//Returns the number of rows. <20><>1<EFBFBD><31>ʼ<EFBFBD><CABC>
|
||||
ui.recordLine_tableWidget->insertRow(RowCount);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3>β<EFBFBD><CEB2>Ǵ<EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
|
||||
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 1, Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(currentRow + 1);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3>β<EFBFBD><CEB2>Ǵ<EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
|
||||
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 1, Item2);
|
||||
}
|
||||
}
|
||||
|
||||
void PathPlan::onRemoveRecordLine_btn()
|
||||
{
|
||||
int rowIndex = ui.recordLine_tableWidget->currentRow();
|
||||
if (rowIndex != -1)
|
||||
ui.recordLine_tableWidget->removeRow(rowIndex);
|
||||
}
|
||||
|
||||
void PathPlan::onGenerateRecordLine_btn()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double height = ui.height_lineEdit->text().toDouble();
|
||||
double fov = ui.fov_lineEdit->text().toDouble();
|
||||
double swath = (height * tan(fov / 2 * PI / 180)) * 2;//tan<61><6E><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD>
|
||||
ui.swath_lineEdit->setText(QString::number(swath));
|
||||
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
|
||||
double xMotorRange = m_xSlider->maximum();
|
||||
double yMotorRange = m_ySlider->maximum();
|
||||
|
||||
|
||||
//ȷ<><C8B7><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC>ߣ<EFBFBD><DFA3><EFBFBD>ʽ<EFBFBD><CABD>numberOfRecordLine_tmp * swath - repetitiveLength<74><68>numberOfRecordLine_tmp - 1<><31> = 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();//<2F><>numberOfRecordLine_tmpΪС<CEAA><D0A1>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
|
||||
if (tmp > threshold)
|
||||
{
|
||||
numberOfRecordLine = (int)numberOfRecordLine_tmp + 1;
|
||||
//std::cout << "<22><><EFBFBD>ڣ<EFBFBD>" << threshold << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfRecordLine = (int)numberOfRecordLine_tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ȥ<><C8A5>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
|
||||
|
||||
//<2F><>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ɼ<EFBFBD><C9BC>ߣ<EFBFBD>
|
||||
QTableWidgetItem* tmpItem;
|
||||
for (size_t i = 0; i < numberOfRecordLine; i++)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
int RowCount = ui.recordLine_tableWidget->rowCount();
|
||||
ui.recordLine_tableWidget->insertRow(RowCount);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>yPosition
|
||||
if (tmp > threshold && i == numberOfRecordLine - 1)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>е<EFBFBD>yPosition
|
||||
{
|
||||
tmpItem = new QTableWidgetItem(QString::number(yMotorRange, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
double x = swath * i - i * repetitiveLength + offset;
|
||||
tmpItem = new QTableWidgetItem(QString::number(x, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>λ<EFBFBD><CEBB> <20><> ֵ<><D6B5><EFBFBD><EFBFBD>Ϊx<CEAA><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
tmpItem = new QTableWidgetItem(QString::number(xMotorRange, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 1, tmpItem);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PathPlan::onDeleteRecordLine_btn()
|
||||
{
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void PathPlan::onSaveRecordLine2File_btn()
|
||||
{
|
||||
//ȷ<><C8B7><EFBFBD>ɼ<EFBFBD><C9BC>ߴ<EFBFBD><DFB4><EFBFBD>
|
||||
if (ui.recordLine_tableWidget->rowCount() <= 0)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ켣<EFBFBD><EFBFBD>"));
|
||||
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("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
}
|
||||
|
||||
void PathPlan::onReadRecordLineFile_btn()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
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(), "rb");
|
||||
double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number;
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
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;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д
|
||||
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));
|
||||
|
||||
|
||||
//<2F><>tableWidget<65><74><EFBFBD>Ӳɼ<D3B2><C9BC><EFBFBD>
|
||||
//<2F><>1<EFBFBD><31>ȥ<EFBFBD><C8A5>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
//<2F><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ɼ<EFBFBD><C9BC>ߣ<EFBFBD>
|
||||
int RecordLineCount = number / ui.recordLine_tableWidget->columnCount();
|
||||
for (size_t i = 0; i < RecordLineCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(0);
|
||||
|
||||
}
|
||||
//<2F><>3<EFBFBD><33><EFBFBD><EFBFBD>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
QTableWidgetItem* tmp = new QTableWidgetItem(QString::number(data[i * ui.recordLine_tableWidget->columnCount() + j], 10, 5));
|
||||
tmp->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, j, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(RecordLineFileHandle);
|
||||
delete[] data;
|
||||
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_PathPlan.h"
|
||||
#include "vincecontrol.h"
|
||||
#include <QMotorDoubleSlider.h>
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
class PathPlan : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathPlan(VinceControl* xMotor, VinceControl* yMotor, QMotorDoubleSlider* xSlider, QMotorDoubleSlider* ySlider, QWidget* parent = nullptr);
|
||||
~PathPlan();
|
||||
|
||||
void setMotor(VinceControl* xMotor, VinceControl* yMotor);
|
||||
QTableWidget* getRecordLineTableWidget();
|
||||
|
||||
private:
|
||||
Ui::PathPlanClass ui;
|
||||
|
||||
VinceControl* m_xMotor;
|
||||
VinceControl* m_yMotor;
|
||||
|
||||
QMotorDoubleSlider* m_xSlider;
|
||||
QMotorDoubleSlider* m_ySlider;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onAddRecordLine_btn();
|
||||
void onRemoveRecordLine_btn();
|
||||
void onGenerateRecordLine_btn();
|
||||
void onDeleteRecordLine_btn();
|
||||
void onSaveRecordLine2File_btn();
|
||||
void onReadRecordLineFile_btn();
|
||||
};
|
||||
@ -6,114 +6,246 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>294</width>
|
||||
<height>119</height>
|
||||
<width>432</width>
|
||||
<height>346</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>PowerControl</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_20">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>卤素灯</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="lamp_power_open_btn">
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="lamp_power_close_btn">
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_19">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>马 达</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="motor_power_open_btn">
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="motor_power_close_btn">
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_20">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox
|
||||
{
|
||||
border: 12px solid transparent;
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 19pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="1,1,1,1" columnstretch="1,3,1">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>42</height>
|
||||
<height>145</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>卤素灯</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="lamp_power_open_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="lamp_power_close_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>马 达</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="motor_power_open_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="motor_power_close_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>144</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
||||
@ -7,6 +7,7 @@ m_Multiplier(100.0)
|
||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
|
||||
|
||||
setSingleStep(1);
|
||||
setRange(1, 500);
|
||||
|
||||
setOrientation(Qt::Horizontal);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
@ -23,8 +23,8 @@ public:
|
||||
private slots:
|
||||
|
||||
signals :
|
||||
void valueChanged(double Value);
|
||||
void rangeChanged(double Min, double Max);
|
||||
void valueChanged(double Value);//QSlider<65><72>valueChanged<65>źŵIJ<C5B5><C4B2><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
void rangeChanged(double Min, double Max);//QSlider<65><72>rangeChanged<65>źŵIJ<C5B5><C4B2><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
|
||||
private:
|
||||
double m_Multiplier;
|
||||
|
||||
167
HPPA/RadianceConversion.ui
Normal file
167
HPPA/RadianceConversion.ui
Normal file
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RadianceConversion_UI</class>
|
||||
<widget class="QDialog" name="RadianceConversion_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>177</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>辐亮度转换</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>影像</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>定标文件</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="imgPath_lineEdit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="calFilePath_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="imgSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="calFileSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="conversion_btn">
|
||||
<property name="text">
|
||||
<string>转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>191</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
225
HPPA/RasterDataProvider.cpp
Normal file
225
HPPA/RasterDataProvider.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
#include "RasterDataProvider.h"
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#if HPPA_HAVE_GDAL
|
||||
#include <gdal_priv.h>
|
||||
#include <cpl_conv.h>
|
||||
#endif
|
||||
|
||||
RasterDataProvider::RasterDataProvider(const QString& uri)
|
||||
: m_uri(uri), m_dataset(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
RasterDataProvider::~RasterDataProvider()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
bool RasterDataProvider::open()
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
GDALAllRegister();
|
||||
m_dataset = (GDALDataset*)GDALOpen((const char*)m_uri.toLocal8Bit().constData(), GA_ReadOnly);
|
||||
if (!m_dataset) {
|
||||
qWarning() << "RasterDataProvider: failed to open dataset:" << m_uri;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
Q_UNUSED(m_uri);
|
||||
qWarning() << "RasterDataProvider: GDAL not available, open will fail.";
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void RasterDataProvider::close()
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
if (m_dataset) {
|
||||
GDALClose((GDALDatasetH)m_dataset);
|
||||
m_dataset = nullptr;
|
||||
}
|
||||
#else
|
||||
m_dataset = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
int RasterDataProvider::bandCount() const
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
if (!m_dataset) return 0;
|
||||
return m_dataset->GetRasterCount();
|
||||
#else
|
||||
Q_UNUSED(this);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int RasterDataProvider::width() const
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
if (!m_dataset) return 0;
|
||||
return m_dataset->GetRasterXSize();
|
||||
#else
|
||||
Q_UNUSED(this);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int RasterDataProvider::height() const
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
if (!m_dataset) return 0;
|
||||
return m_dataset->GetRasterYSize();
|
||||
#else
|
||||
Q_UNUSED(this);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RasterDataProvider::isValidPixel(int x, int y) const
|
||||
{
|
||||
const int w = width();
|
||||
const int h = height();
|
||||
return x >= 0 && y >= 0 && x < w && y < h;
|
||||
}
|
||||
|
||||
std::vector<double> RasterDataProvider::parseEnviHdrWavelengths() const
|
||||
{
|
||||
std::vector<double> res;
|
||||
|
||||
QFileInfo fi(m_uri);
|
||||
QString hdrPath = fi.path() + "/" + fi.completeBaseName() + ".hdr";
|
||||
QFile hdr(hdrPath);
|
||||
if (!hdr.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
QString text = QString::fromLocal8Bit(hdr.readAll());
|
||||
hdr.close();
|
||||
|
||||
QRegularExpression rx("wavelength\\s*=\\s*\\{([^}]*)\\}", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);
|
||||
QRegularExpressionMatch m = rx.match(text);
|
||||
if (!m.hasMatch()) {
|
||||
return res;
|
||||
}
|
||||
|
||||
const QString body = m.captured(1);
|
||||
const QStringList parts = body.split(',', QString::SkipEmptyParts);
|
||||
res.reserve(parts.size());
|
||||
for (const QString& p : parts) {
|
||||
bool ok = false;
|
||||
double v = p.trimmed().toDouble(&ok);
|
||||
if (ok) {
|
||||
res.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<double> RasterDataProvider::bandWavelengths() const
|
||||
{
|
||||
std::vector<double> res;
|
||||
#if HPPA_HAVE_GDAL
|
||||
if (!m_dataset) return res;
|
||||
|
||||
// 1) Try ENVI dataset-level metadata first: wavelength = { ... }
|
||||
const char* dsWave = m_dataset->GetMetadataItem("wavelength", "ENVI");
|
||||
if (!dsWave) dsWave = m_dataset->GetMetadataItem("Wavelength", "ENVI");
|
||||
if (dsWave) {
|
||||
QString dsWaveStr = QString::fromLocal8Bit(dsWave);
|
||||
dsWaveStr.remove('{').remove('}');
|
||||
const QStringList parts = dsWaveStr.split(',', QString::SkipEmptyParts);
|
||||
res.reserve(parts.size());
|
||||
for (const QString& p : parts) {
|
||||
bool ok = false;
|
||||
double v = p.trimmed().toDouble(&ok);
|
||||
if (ok) res.push_back(v);
|
||||
}
|
||||
if (!res.empty()) return res;
|
||||
}
|
||||
|
||||
// 2) Try per-band metadata
|
||||
for (int i = 1; i <= m_dataset->GetRasterCount(); ++i) {
|
||||
GDALRasterBand* band = m_dataset->GetRasterBand(i);
|
||||
if (!band) continue;
|
||||
const char* val = band->GetMetadataItem("Wavelength");
|
||||
if (!val) val = band->GetMetadataItem("wavelength");
|
||||
if (val) {
|
||||
bool ok = false;
|
||||
double v = QString::fromLocal8Bit(val).trimmed().toDouble(&ok);
|
||||
res.push_back(ok ? v : -1.0);
|
||||
} else {
|
||||
res.push_back(-1.0);
|
||||
}
|
||||
}
|
||||
if (!res.empty()) return res;
|
||||
#endif
|
||||
|
||||
// 3) Fallback: parse ENVI .hdr directly
|
||||
return parseEnviHdrWavelengths();
|
||||
}
|
||||
|
||||
bool RasterDataProvider::readPixelSpectrum(int x, int y, std::vector<double>& outSpectrum) const
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
outSpectrum.clear();
|
||||
if (!m_dataset) return false;
|
||||
if (!isValidPixel(x, y)) return false;
|
||||
|
||||
const int bands = m_dataset->GetRasterCount();
|
||||
if (bands <= 0) return false;
|
||||
|
||||
outSpectrum.resize(bands);
|
||||
for (int i = 0; i < bands; ++i) {
|
||||
GDALRasterBand* band = m_dataset->GetRasterBand(i + 1);
|
||||
if (!band) return false;
|
||||
|
||||
float value = 0.0f;
|
||||
CPLErr err = band->RasterIO(
|
||||
GF_Read,
|
||||
x, y,
|
||||
1, 1,
|
||||
&value,
|
||||
1, 1,
|
||||
GDT_Float32,
|
||||
0, 0);
|
||||
|
||||
if (err != CE_None) return false;
|
||||
outSpectrum[i] = static_cast<double>(value);
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
Q_UNUSED(x);
|
||||
Q_UNUSED(y);
|
||||
Q_UNUSED(outSpectrum);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RasterDataProvider::readBandAsFloat(int bandIndex, std::vector<float>& outBuffer) const
|
||||
{
|
||||
#if HPPA_HAVE_GDAL
|
||||
if (!m_dataset) return false;
|
||||
int bands = m_dataset->GetRasterCount();
|
||||
if (bandIndex < 0 || bandIndex >= bands) return false;
|
||||
GDALRasterBand* band = m_dataset->GetRasterBand(bandIndex + 1);
|
||||
if (!band) return false;
|
||||
int w = m_dataset->GetRasterXSize();
|
||||
int h = m_dataset->GetRasterYSize();
|
||||
outBuffer.assign(w * h, 0.0f);
|
||||
CPLErr err = band->RasterIO(GF_Read, 0, 0, w, h, outBuffer.data(), w, h, GDT_Float32, 0, 0);
|
||||
return err == CE_None;
|
||||
#else
|
||||
Q_UNUSED(bandIndex);
|
||||
Q_UNUSED(outBuffer);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
50
HPPA/RasterDataProvider.h
Normal file
50
HPPA/RasterDataProvider.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
#if __has_include(<gdal_priv.h>)
|
||||
#define HPPA_HAVE_GDAL 1
|
||||
#include <gdal_priv.h>
|
||||
#include <cpl_conv.h>
|
||||
#else
|
||||
#define HPPA_HAVE_GDAL 0
|
||||
#endif
|
||||
|
||||
class RasterDataProvider
|
||||
{
|
||||
public:
|
||||
explicit RasterDataProvider(const QString& uri);
|
||||
~RasterDataProvider();
|
||||
|
||||
bool open();
|
||||
void close();
|
||||
|
||||
int bandCount() const;
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
bool isValidPixel(int x, int y) const;
|
||||
|
||||
// Returns per-band wavelength metadata if available. If not available, returns empty vector.
|
||||
std::vector<double> bandWavelengths() const;
|
||||
|
||||
// Read spectrum of one pixel (x,y) across all bands.
|
||||
bool readPixelSpectrum(int x, int y, std::vector<double>& outSpectrum) const;
|
||||
|
||||
// Read a single band (0-based index) into a float buffer of size width()*height().
|
||||
// Returns true on success.
|
||||
bool readBandAsFloat(int bandIndex, std::vector<float>& outBuffer) const;
|
||||
|
||||
QString uri() const { return m_uri; }
|
||||
|
||||
private:
|
||||
QString m_uri;
|
||||
std::vector<double> parseEnviHdrWavelengths() const;
|
||||
#if HPPA_HAVE_GDAL
|
||||
GDALDataset* m_dataset = nullptr;
|
||||
#else
|
||||
// no-op when GDAL not available
|
||||
void* m_dataset = nullptr;
|
||||
#endif
|
||||
};
|
||||
116
HPPA/RasterLayer.cpp
Normal file
116
HPPA/RasterLayer.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
#include "RasterLayer.h"
|
||||
#include "RasterDataProvider.h"
|
||||
#include "RasterRenderer.h"
|
||||
#include <algorithm>
|
||||
|
||||
RasterLayer::RasterLayer(const QString& name, const QString& uri)
|
||||
: MapLayer(name, uri)
|
||||
{
|
||||
// lazy creation
|
||||
}
|
||||
|
||||
RasterLayer::~RasterLayer()
|
||||
{
|
||||
}
|
||||
|
||||
MapLayer::LayerType RasterLayer::layerType() const
|
||||
{
|
||||
return MapLayer::LayerType::Raster;
|
||||
}
|
||||
|
||||
RasterDataProvider* RasterLayer::dataProvider() const
|
||||
{
|
||||
return m_provider ? m_provider.get() : nullptr;
|
||||
}
|
||||
|
||||
RasterRenderer* RasterLayer::renderer() const
|
||||
{
|
||||
return m_renderer ? m_renderer.get() : nullptr;
|
||||
}
|
||||
|
||||
bool RasterLayer::openDataProvider()
|
||||
{
|
||||
if (!m_provider) m_provider = std::make_unique<RasterDataProvider>(dataPath());
|
||||
if (!m_provider) return false;
|
||||
bool ok = m_provider->open();
|
||||
if (ok && !m_renderer) m_renderer = std::make_unique<RasterRenderer>(m_provider.get());
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RasterLayer::isValidPixel(int x, int y)
|
||||
{
|
||||
if (!m_provider) {
|
||||
if (!openDataProvider()) return false;
|
||||
}
|
||||
return m_provider->isValidPixel(x, y);
|
||||
}
|
||||
|
||||
bool RasterLayer::readPixelSpectrum(int x, int y, QVector<double>& wavelengths, QVector<double>& spectrum)
|
||||
{
|
||||
if (!m_provider) {
|
||||
if (!openDataProvider()) return false;
|
||||
}
|
||||
|
||||
std::vector<double> wl;
|
||||
std::vector<double> sp;
|
||||
|
||||
if (!m_provider->readPixelSpectrum(x, y, sp)) return false;
|
||||
|
||||
wl = m_provider->bandWavelengths();
|
||||
|
||||
wavelengths = QVector<double>::fromStdVector(wl);
|
||||
spectrum = QVector<double>::fromStdVector(sp);
|
||||
|
||||
if (wavelengths.size() != spectrum.size()) {
|
||||
wavelengths.resize(spectrum.size());
|
||||
for (int i = 0; i < wavelengths.size(); ++i) {
|
||||
wavelengths[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QImage RasterLayer::render(const RenderParams& params)
|
||||
{
|
||||
if (!m_provider) {
|
||||
if (!openDataProvider()) return QImage();
|
||||
}
|
||||
if (!m_renderer) m_renderer = std::make_unique<RasterRenderer>(m_provider.get());
|
||||
RasterRenderer::Params p;
|
||||
p.rWave = params.rWave;
|
||||
p.gWave = params.gWave;
|
||||
p.bWave = params.bWave;
|
||||
p.minValue = params.minValue;
|
||||
p.maxValue = params.maxValue;
|
||||
return m_renderer->render(p);
|
||||
}
|
||||
|
||||
RasterLayer::RenderParams RasterLayer::currentRenderParams() const
|
||||
{
|
||||
return m_currentParams;
|
||||
}
|
||||
|
||||
void RasterLayer::setCurrentRenderParams(const RenderParams& params)
|
||||
{
|
||||
m_currentParams = params;
|
||||
}
|
||||
|
||||
bool RasterLayer::wavelengthRange(double& minWave, double& maxWave) const
|
||||
{
|
||||
auto wl = bandWavelengths();
|
||||
if (wl.empty()) return false;
|
||||
minWave = *std::min_element(wl.begin(), wl.end());
|
||||
maxWave = *std::max_element(wl.begin(), wl.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<double> RasterLayer::bandWavelengths() const
|
||||
{
|
||||
if (!m_provider) {
|
||||
// need to open provider to read wavelengths - cast away const for lazy init
|
||||
auto* self = const_cast<RasterLayer*>(this);
|
||||
if (!self->openDataProvider()) return {};
|
||||
}
|
||||
return m_provider->bandWavelengths();
|
||||
}
|
||||
55
HPPA/RasterLayer.h
Normal file
55
HPPA/RasterLayer.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include <memory>
|
||||
#include <QImage>
|
||||
#include <QVector>
|
||||
|
||||
class RasterDataProvider;
|
||||
class RasterRenderer;
|
||||
|
||||
class RasterLayer : public MapLayer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RasterLayer(const QString& name, const QString& uri);
|
||||
~RasterLayer();
|
||||
|
||||
LayerType layerType() const override;
|
||||
|
||||
// Access provider/renderer
|
||||
RasterDataProvider* dataProvider() const;
|
||||
RasterRenderer* renderer() const;
|
||||
|
||||
// Create or open provider based on this layer's uri
|
||||
bool openDataProvider();
|
||||
|
||||
bool isValidPixel(int x, int y);
|
||||
bool readPixelSpectrum(int x, int y, QVector<double>& wavelengths, QVector<double>& spectrum);
|
||||
|
||||
struct RenderParams {
|
||||
double rWave = 665.0; // default wavelengths (nm)
|
||||
double gWave = 560.0;
|
||||
double bWave = 490.0;
|
||||
double minValue = 0.0; // optional stretch
|
||||
double maxValue = 4095.0;
|
||||
};
|
||||
|
||||
// Render the raster using current provider and renderer. Returns an empty QImage on failure.
|
||||
QImage render(const RenderParams& params);
|
||||
|
||||
// Current render params stored per layer
|
||||
RenderParams currentRenderParams() const;
|
||||
void setCurrentRenderParams(const RenderParams& params);
|
||||
|
||||
// Get wavelength range from data provider (min, max). Returns false if unavailable.
|
||||
bool wavelengthRange(double& minWave, double& maxWave) const;
|
||||
|
||||
// Get all band wavelengths
|
||||
std::vector<double> bandWavelengths() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<RasterDataProvider> m_provider;
|
||||
std::unique_ptr<RasterRenderer> m_renderer;
|
||||
RenderParams m_currentParams;
|
||||
};
|
||||
86
HPPA/RasterRenderer.cpp
Normal file
86
HPPA/RasterRenderer.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include "RasterRenderer.h"
|
||||
#include "RasterDataProvider.h"
|
||||
#include <QDebug>
|
||||
#include <algorithm>
|
||||
|
||||
RasterRenderer::RasterRenderer(RasterDataProvider* provider)
|
||||
: m_provider(provider)
|
||||
{
|
||||
}
|
||||
|
||||
void RasterRenderer::stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal)
|
||||
{
|
||||
size_t n = in.size();
|
||||
out.resize(n);
|
||||
if (maxVal <= minVal) {
|
||||
std::fill(out.begin(), out.end(), 0);
|
||||
return;
|
||||
}
|
||||
float denom = 1.0f / (maxVal - minVal);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
float v = (in[i] - minVal) * denom;
|
||||
v = std::min(std::max(v, 0.0f), 1.0f);
|
||||
out[i] = static_cast<unsigned char>(v * 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
QImage RasterRenderer::render(const Params& params)
|
||||
{
|
||||
if (!m_provider) return QImage();
|
||||
int bands = m_provider->bandCount();
|
||||
int w = m_provider->width();
|
||||
int h = m_provider->height();
|
||||
if (w <= 0 || h <= 0) return QImage();
|
||||
|
||||
// Find nearest bands for requested wavelengths if wavelengths available
|
||||
std::vector<double> wavelengths = m_provider->bandWavelengths();
|
||||
|
||||
auto chooseBandIndexForWave = [&](double wave)->int {
|
||||
if (wavelengths.empty()) {
|
||||
// fallback: select R,G,B as first three bands
|
||||
if (bands >= 3) return (wave==params.rWave?0:(wave==params.gWave?1:2));
|
||||
if (bands >= 1) return 0;
|
||||
return -1;
|
||||
}
|
||||
int best = -1; double bestDiff = 1e12;
|
||||
for (int i = 0; i < (int)wavelengths.size(); ++i) {
|
||||
if (wavelengths[i] < 0) continue;
|
||||
double d = std::abs(wavelengths[i] - wave);
|
||||
if (d < bestDiff) { bestDiff = d; best = i; }
|
||||
}
|
||||
if (best >= 0) return best;
|
||||
// fallback
|
||||
return std::min(2, bands-1);
|
||||
};
|
||||
|
||||
int rIdx = chooseBandIndexForWave(params.rWave);
|
||||
int gIdx = chooseBandIndexForWave(params.gWave);
|
||||
int bIdx = chooseBandIndexForWave(params.bWave);
|
||||
|
||||
std::vector<float> rbuf, gbuf, bbuf;
|
||||
if (rIdx >= 0) m_provider->readBandAsFloat(rIdx, rbuf);
|
||||
if (gIdx >= 0) m_provider->readBandAsFloat(gIdx, gbuf);
|
||||
if (bIdx >= 0) m_provider->readBandAsFloat(bIdx, bbuf);
|
||||
|
||||
std::vector<unsigned char> r8, g8, b8;
|
||||
float minV = static_cast<float>(params.minValue);
|
||||
float maxV = static_cast<float>(params.maxValue);
|
||||
if (!rbuf.empty()) stretchTo8bit(rbuf, r8, minV, maxV);
|
||||
if (!gbuf.empty()) stretchTo8bit(gbuf, g8, minV, maxV);
|
||||
if (!bbuf.empty()) stretchTo8bit(bbuf, b8, minV, maxV);
|
||||
|
||||
QImage out(w, h, QImage::Format_RGB888);
|
||||
for (int y = 0; y < h; ++y) {
|
||||
unsigned char* scan = out.scanLine(y);
|
||||
for (int x = 0; x < w; ++x) {
|
||||
int idx = y * w + x;
|
||||
unsigned char rc = (r8.size() > (size_t)idx) ? r8[idx] : 0;
|
||||
unsigned char gc = (g8.size() > (size_t)idx) ? g8[idx] : 0;
|
||||
unsigned char bc = (b8.size() > (size_t)idx) ? b8[idx] : 0;
|
||||
scan[x*3 + 0] = rc;
|
||||
scan[x*3 + 1] = gc;
|
||||
scan[x*3 + 2] = bc;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
29
HPPA/RasterRenderer.h
Normal file
29
HPPA/RasterRenderer.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QImage>
|
||||
#include <vector>
|
||||
|
||||
class RasterDataProvider;
|
||||
|
||||
class RasterRenderer
|
||||
{
|
||||
public:
|
||||
struct Params {
|
||||
double rWave = 665.0;
|
||||
double gWave = 560.0;
|
||||
double bWave = 490.0;
|
||||
double minValue = 0.0;
|
||||
double maxValue = 255.0;
|
||||
};
|
||||
|
||||
explicit RasterRenderer(RasterDataProvider* provider);
|
||||
|
||||
// Render to an 8-bit RGB image. Returns empty image on failure.
|
||||
QImage render(const Params& params);
|
||||
|
||||
private:
|
||||
RasterDataProvider* m_provider;
|
||||
|
||||
// helper to map float buffer to 8-bit with min/max stretch
|
||||
static void stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal);
|
||||
};
|
||||
167
HPPA/ReflectanceConversion.ui
Normal file
167
HPPA/ReflectanceConversion.ui
Normal file
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ReflectanceConversion_UI</class>
|
||||
<widget class="QDialog" name="ReflectanceConversion_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>177</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>反射率转换</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>影像</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>白板影像</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="imgPath_lineEdit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="whiteImgPath_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="imgSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="whiteImgSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="conversion_btn">
|
||||
<property name="text">
|
||||
<string>转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>191</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -286,6 +286,7 @@ void ResononNirImager::start_record()
|
||||
}
|
||||
|
||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||
|
||||
size_t x;
|
||||
@ -353,7 +354,7 @@ void ResononNirImager::start_record()
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||
{
|
||||
emit PlotSignal(m_iFrameCounter);
|
||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter, filePath);
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
@ -365,14 +366,14 @@ void ResononNirImager::start_record()
|
||||
}
|
||||
imagerStopCollect();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(m_FileSavedCounter, -1, filePath);//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(-1);//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberMeet();
|
||||
@ -399,6 +400,7 @@ void ResononNirImager::WriteHdr()
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "byte order = 0\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
|
||||
62
HPPA/TabManager.cpp
Normal file
62
HPPA/TabManager.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "TabManager.h"
|
||||
|
||||
TabManager::TabManager(QTabWidget* tabWidget, QObject* parent)
|
||||
: QObject(parent),
|
||||
m_tabWidget(tabWidget)
|
||||
{
|
||||
Q_ASSERT(m_tabWidget);
|
||||
}
|
||||
|
||||
void TabManager::hideTab(QWidget* page)
|
||||
{
|
||||
if (!page || !m_tabWidget)
|
||||
return;
|
||||
|
||||
int index = m_tabWidget->indexOf(page);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
if (m_hiddenTabs.contains(page))
|
||||
return;
|
||||
|
||||
TabInfo info;
|
||||
info.index = index;
|
||||
info.text = m_tabWidget->tabText(index);
|
||||
info.icon = m_tabWidget->tabIcon(index);
|
||||
info.toolTip = m_tabWidget->tabToolTip(index);
|
||||
|
||||
m_hiddenTabs.insert(page, info);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5>ǵ<EFBFBD>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>հ<EFBFBD>
|
||||
if (m_tabWidget->currentIndex() == index)
|
||||
{
|
||||
int next = (index > 0) ? index - 1 : 0;
|
||||
m_tabWidget->setCurrentIndex(next);
|
||||
}
|
||||
|
||||
m_tabWidget->removeTab(index);
|
||||
emit tabHidden(page);
|
||||
}
|
||||
|
||||
void TabManager::showTab(QWidget* page)
|
||||
{
|
||||
if (!page || !m_tabWidget)
|
||||
return;
|
||||
|
||||
if (!m_hiddenTabs.contains(page))
|
||||
return;
|
||||
|
||||
TabInfo info = m_hiddenTabs.take(page);
|
||||
|
||||
//int insertIndex = qMin(info.index, m_tabWidget->count());
|
||||
int insertIndex = m_tabWidget->count();
|
||||
m_tabWidget->insertTab(insertIndex, page, info.icon, info.text);
|
||||
m_tabWidget->setTabToolTip(insertIndex, info.toolTip);
|
||||
|
||||
emit tabShown(page);
|
||||
}
|
||||
|
||||
bool TabManager::isHidden(QWidget* page) const
|
||||
{
|
||||
return m_hiddenTabs.contains(page);
|
||||
}
|
||||
32
HPPA/TabManager.h
Normal file
32
HPPA/TabManager.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QTabWidget>
|
||||
#include <QHash>
|
||||
|
||||
class TabManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TabManager(QTabWidget* tabWidget, QObject* parent = nullptr);
|
||||
|
||||
void hideTab(QWidget* page);
|
||||
void showTab(QWidget* page);
|
||||
bool isHidden(QWidget* page) const;
|
||||
|
||||
signals:
|
||||
void tabHidden(QWidget* page);
|
||||
void tabShown(QWidget* page);
|
||||
|
||||
private:
|
||||
struct TabInfo
|
||||
{
|
||||
int index;
|
||||
QString text;
|
||||
QIcon icon;
|
||||
QString toolTip;
|
||||
};
|
||||
|
||||
QTabWidget* m_tabWidget = nullptr;
|
||||
QHash<QWidget*, TabInfo> m_hiddenTabs;
|
||||
};
|
||||
527
HPPA/TwoMotorControl.cpp
Normal file
527
HPPA/TwoMotorControl.cpp
Normal file
@ -0,0 +1,527 @@
|
||||
#include "TwoMotorControl.h"
|
||||
|
||||
TwoMotorControl::TwoMotorControl(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选择行为,以行为单位
|
||||
//ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//设置选择模式,选择单行
|
||||
//QHeaderView* headerView = ui.recordLine_tableWidget->verticalHeader();
|
||||
//headerView->setHidden(true);//去除左边默认自带序列号
|
||||
|
||||
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
||||
|
||||
connect(ui.addRecordLine_btn, SIGNAL(clicked()), this, SLOT(onAddRecordLine_btn()));
|
||||
connect(ui.removeRecordLine_btn, SIGNAL(clicked()), this, SLOT(onRemoveRecordLine_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()));
|
||||
}
|
||||
|
||||
void TwoMotorControl::setImager(ImagerOperationBase* imager)
|
||||
{
|
||||
m_Imager = imager;
|
||||
}
|
||||
|
||||
void TwoMotorControl::setPosFileName(QString posFileName)
|
||||
{
|
||||
isWritePosFile = true;
|
||||
m_posFileName = posFileName;
|
||||
m_posFileHandle = fopen(posFileName.toStdString().c_str(), "w+");
|
||||
}
|
||||
|
||||
bool TwoMotorControl::getState()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool tmp = false;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(
|
||||
m_coordinator, &TwoMotionCaptureCoordinator::recordState,
|
||||
[&](bool state) {
|
||||
tmp = state;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_coordinator, "getRecordState", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void TwoMotorControl::record_dark()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_darkCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_darkCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(0, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_darkCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void TwoMotorControl::record_white()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_whiteCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_whiteCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(1, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_whiteCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void TwoMotorControl::run()
|
||||
{
|
||||
if (m_coordinator==nullptr)
|
||||
{
|
||||
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
|
||||
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_coordinatorThread);
|
||||
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
||||
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
||||
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
||||
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
||||
m_coordinatorThread.start();
|
||||
}
|
||||
|
||||
if (getState())
|
||||
{
|
||||
//std::cout << "已经开始运行,请勿重复点击!!!!!!!!" << std::endl;
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("已经开始运行,请勿重复点击!!!!!!!!!"));
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<PathLine> pathLines;
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
//int columnCount = ui.recordLine_tableWidget->columnCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
PathLine tmp;
|
||||
|
||||
tmp.targetYPosition = ui.recordLine_tableWidget->item(i, 0)->text().toDouble();
|
||||
tmp.speedTargetYPosition = ui.recordLine_tableWidget->item(i, 1)->text().toDouble();
|
||||
tmp.targetXMinPosition = ui.recordLine_tableWidget->item(i, 2)->text().toDouble();
|
||||
tmp.speedTargetXMinPosition = ui.recordLine_tableWidget->item(i, 3)->text().toDouble();
|
||||
tmp.targetXMaxPosition = ui.recordLine_tableWidget->item(i, 4)->text().toDouble();
|
||||
tmp.speedTargetXMaxPosition = ui.recordLine_tableWidget->item(i, 5)->text().toDouble();
|
||||
|
||||
pathLines.append(tmp);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
emit start(pathLines);
|
||||
}
|
||||
|
||||
void TwoMotorControl::stop()
|
||||
{
|
||||
emit stopSignal();
|
||||
}
|
||||
|
||||
TwoMotorControl::~TwoMotorControl()
|
||||
{
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
|
||||
m_coordinatorThread.quit();
|
||||
m_coordinatorThread.wait();
|
||||
}
|
||||
|
||||
void TwoMotorControl::onConnectMotor()
|
||||
{
|
||||
try
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\twoMotorConfigFile.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
|
||||
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.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||
connect(this->ui.xmotor_left_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()));
|
||||
|
||||
connect(this->ui.move2loc_x_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||
connect(this->ui.move2loc_y_pushButton, SIGNAL(pressed()), this, SLOT(onyMove2Loc()));
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
|
||||
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||
|
||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(on_rangeMeasurement()));
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
emit testConnectivitySignal(1, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::receiveStartRecordLineNum(int lineNum)
|
||||
{
|
||||
emit startLineNumSignal(lineNum);
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->columnCount(); i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->item(lineNum, i)->setBackgroundColor(QColor(255, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::receiveFinishRecordLineNum(int lineNum)
|
||||
{
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->columnCount(); i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->item(lineNum, i)->setBackgroundColor(QColor(0, 255, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onSequenceComplete()
|
||||
{
|
||||
isWritePosFile = false;
|
||||
fclose(m_posFileHandle);
|
||||
|
||||
emit sequenceComplete();
|
||||
}
|
||||
|
||||
void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
||||
{
|
||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||
if (connectivity[0])
|
||||
{
|
||||
this->ui.xMotorStateLabel->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: #08FACE;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.xMotorStateLabel->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
if (connectivity[1])
|
||||
{
|
||||
this->ui.yMotorStateLabel->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: #08FACE;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.yMotorStateLabel->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorRight()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, false, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorLeft()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, true, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorStop()
|
||||
{
|
||||
emit stopSignal(0);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorforward()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(1, false, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorbackward()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(1, true, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorStop()
|
||||
{
|
||||
emit stopSignal(1);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMove2Loc()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_x_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(0, l, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMove2Loc()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_y_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(1, l, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::displayRealTimeLoc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
if (isWritePosFile)
|
||||
{
|
||||
long long timeOs = getNanosecondsSinceMidnight();
|
||||
fprintf(m_posFileHandle, "%lld,%f\n", timeOs, loc[0]);
|
||||
}
|
||||
this->ui.xmotor_realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
|
||||
tmp = round(loc[1] * 100) / 100;
|
||||
this->ui.ymotor_realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
|
||||
emit broadcastLocationSignal(loc);
|
||||
}
|
||||
|
||||
void TwoMotorControl::zeroStart()
|
||||
{
|
||||
zeroStartSignal(0);
|
||||
zeroStartSignal(1);
|
||||
}
|
||||
|
||||
void TwoMotorControl::on_rangeMeasurement()
|
||||
{
|
||||
double s0 = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(0, s0, 1000);
|
||||
|
||||
s0 = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(1, s0, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onAddRecordLine_btn()
|
||||
{
|
||||
//准备数据:获取y马达的当前位置,获取x马达的当前位置和最大位置
|
||||
double currentPosOfYmotor = 15;
|
||||
|
||||
double currentPosOfXmotor = 0;
|
||||
double maxRangeOfXmotor = 50;
|
||||
|
||||
//获取选中行的索引
|
||||
int currentRow = ui.recordLine_tableWidget->currentRow();
|
||||
std::cout << "currentRow:" << currentRow << std::endl;
|
||||
|
||||
QTableWidgetItem* Item1 = new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2));
|
||||
QTableWidgetItem* Item2 = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
QTableWidgetItem* Item3 = new QTableWidgetItem(QString::number(currentPosOfXmotor, 10, 2));
|
||||
QTableWidgetItem* Item4 = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
QTableWidgetItem* Item5 = new QTableWidgetItem(QString::number(maxRangeOfXmotor, 10, 2));
|
||||
QTableWidgetItem* Item6 = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
Item1->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item2->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item3->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item4->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item5->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item6->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
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, Item1);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 1, Item2);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 2, Item3);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 3, Item4);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 4, Item5);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 5, Item6);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(currentRow + 1);//增加一行,形参是从0开始的
|
||||
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 1, Item2);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 2, Item3);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 3, Item4);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 4, Item5);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 5, Item6);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onRemoveRecordLine_btn()
|
||||
{
|
||||
int rowIndex = ui.recordLine_tableWidget->currentRow();
|
||||
if (rowIndex != -1)
|
||||
ui.recordLine_tableWidget->removeRow(rowIndex);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onDeleteRecordLine_btn()
|
||||
{
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onSaveRecordLine2File_btn()
|
||||
{
|
||||
//确保采集线存在
|
||||
if (ui.recordLine_tableWidget->rowCount() <= 0)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先生成轨迹!"));
|
||||
return;
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine3 File"),
|
||||
QString::fromStdString(directory),
|
||||
tr("RecordLineFile3 (*.RecordLine3)"));
|
||||
|
||||
if (RecordLineFilePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "wb+");
|
||||
|
||||
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 TwoMotorControl::onReadRecordLineFile_btn()
|
||||
{
|
||||
//打开文件
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine3 File"),
|
||||
QString::fromStdString(directory),
|
||||
tr("RecordLineFile (*.RecordLine3)"));
|
||||
|
||||
if (RecordLineFilePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "rb");
|
||||
double number;
|
||||
|
||||
//读取数据
|
||||
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;
|
||||
}
|
||||
|
||||
//向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);
|
||||
|
||||
}
|
||||
//(3)向tableWidget填充数据
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
QTableWidgetItem* tmp = new QTableWidgetItem(QString::number(data[i * ui.recordLine_tableWidget->columnCount() + j], 10, 5));
|
||||
tmp->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, j, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(RecordLineFileHandle);
|
||||
delete[] data;
|
||||
|
||||
//QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("读取成功!"));
|
||||
}
|
||||
98
HPPA/TwoMotorControl.h
Normal file
98
HPPA/TwoMotorControl.h
Normal file
@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "ui_twoMotorControl.h"
|
||||
|
||||
#include "IrisMultiMotorController.h"
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
|
||||
|
||||
class TwoMotorControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TwoMotorControl(QWidget* parent = nullptr);
|
||||
~TwoMotorControl();
|
||||
|
||||
void setImager(ImagerOperationBase* imager);
|
||||
void setPosFileName(QString posFileName);
|
||||
|
||||
void record_dark();
|
||||
void record_white();
|
||||
|
||||
private:
|
||||
ImagerOperationBase* m_Imager;
|
||||
bool getState();
|
||||
|
||||
bool isWritePosFile = false;
|
||||
QString m_posFileName;
|
||||
FILE* m_posFileHandle;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
void displayRealTimeLoc(std::vector<double> loc);
|
||||
void display_motors_connectivity(std::vector<int> connectivity);
|
||||
//void onxMove2Loc();
|
||||
void zeroStart();
|
||||
void on_rangeMeasurement();
|
||||
|
||||
void onxMotorRight();
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
void onxMove2Loc();
|
||||
|
||||
void onyMotorforward();
|
||||
void onyMotorbackward();
|
||||
void onyMotorStop();
|
||||
void onyMove2Loc();
|
||||
|
||||
void onAddRecordLine_btn();
|
||||
void onRemoveRecordLine_btn();
|
||||
void onDeleteRecordLine_btn();
|
||||
void onSaveRecordLine2File_btn();
|
||||
void onReadRecordLineFile_btn();
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
void receiveStartRecordLineNum(int lineNum);
|
||||
void receiveFinishRecordLineNum(int lineNum);
|
||||
void onSequenceComplete();
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopSignal(int);
|
||||
|
||||
void rangeMeasurement(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void start(QVector<PathLine>);
|
||||
void stopSignal();
|
||||
|
||||
void startLineNumSignal(int lineNum);
|
||||
void sequenceComplete();//所有采集线正常运行完成
|
||||
|
||||
void broadcastLocationSignal(std::vector<double>);
|
||||
|
||||
private:
|
||||
Ui::twoMotorControl_UI ui;
|
||||
QThread m_coordinatorThread;
|
||||
TwoMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||
|
||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
};
|
||||
375
HPPA/View3D.cpp
Normal file
375
HPPA/View3D.cpp
Normal file
@ -0,0 +1,375 @@
|
||||
#include "View3D.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QShowEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <Qt3DExtras/QForwardRenderer>
|
||||
#include <QtMath>
|
||||
#include <Qt3DRender/QAttribute>
|
||||
#include <QGeometryRenderer>
|
||||
|
||||
View3DBase::View3DBase(const QString& baseModelPath,
|
||||
const QString& armModelPath,
|
||||
QWidget* parent)
|
||||
: QWidget(parent),
|
||||
m_container(nullptr),
|
||||
m_baseModelPath(baseModelPath),
|
||||
m_armModelPath(armModelPath)
|
||||
{
|
||||
m_view = new Qt3DExtras::Qt3DWindow();
|
||||
// 部分 Qt5.9 构建可能需要强转 frame graph,但 defaultFrameGraph() 通常可用
|
||||
QColor c1("#0D1233");
|
||||
m_view->defaultFrameGraph()->setClearColor(c1);
|
||||
|
||||
m_rootEntity = new Qt3DCore::QEntity();
|
||||
|
||||
initScene();
|
||||
initCamera();
|
||||
|
||||
// 自动旋转臂(如果不需要可注释掉 timer/connect)
|
||||
//connect(&m_timer, &QTimer::timeout, this, [=]() {
|
||||
// m_angle += 1.0f;
|
||||
// m_t += 1.0f;
|
||||
// if (m_angle >= 360.0f) m_angle = 0.0f;
|
||||
// if (m_armTransform)
|
||||
// {
|
||||
// //m_armTransform->setRotationX(m_angle);
|
||||
// //m_armTransform->setTranslation(QVector3D(m_t, 0, 0));
|
||||
//
|
||||
// Qt3DCore::QTransform transform;
|
||||
// transform.setTranslation(QVector3D(2, 0, 0));
|
||||
|
||||
// QMatrix4x4 M = m_armTransform->matrix();
|
||||
// M = transform.matrix() * M; // 左乘:在世界坐标系叠加
|
||||
// m_armTransform->setMatrix(M);
|
||||
|
||||
// qDebug() << m_armTransform->matrix();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
void View3DBase::setViewCenter(float x, float y, float z)
|
||||
{
|
||||
m_viewCenter.setX(x);
|
||||
m_viewCenter.setY(y);
|
||||
m_viewCenter.setZ(z);
|
||||
}
|
||||
|
||||
void View3DBase::setDistance(float distance)
|
||||
{
|
||||
m_distance = distance;
|
||||
}
|
||||
|
||||
void View3DBase::initScene()
|
||||
{
|
||||
/*auto* lightEntity = new Qt3DCore::QEntity(m_rootEntity);
|
||||
|
||||
auto* light = new Qt3DRender::QPointLight(lightEntity);
|
||||
light->setColor(Qt::white);
|
||||
light->setIntensity(1.2f);
|
||||
|
||||
auto* lightTransform = new Qt3DCore::QTransform(lightEntity);
|
||||
lightTransform->setTranslation(QVector3D(500, 500, 500));
|
||||
|
||||
lightEntity->addComponent(light);
|
||||
lightEntity->addComponent(lightTransform);*/
|
||||
|
||||
// ===== 创建 base 根节点 =====
|
||||
auto* baseModel = new Qt3DCore::QEntity(m_rootEntity);
|
||||
auto* baseLoader = new Qt3DRender::QSceneLoader(baseModel);
|
||||
baseLoader->setSource(QUrl::fromLocalFile(m_baseModelPath));
|
||||
|
||||
//connect(baseLoader, &Qt3DRender::QSceneLoader::statusChanged,
|
||||
// this, &View3DBase::onSceneLoaderStatusChanged);
|
||||
|
||||
|
||||
m_baseTransform = new Qt3DCore::QTransform();
|
||||
m_baseTransform->setTranslation(QVector3D(0, 0, 0));
|
||||
baseModel->addComponent(baseLoader);
|
||||
baseModel->addComponent(m_baseTransform);
|
||||
|
||||
connect(baseLoader, &Qt3DRender::QSceneLoader::statusChanged,
|
||||
this, [=](Qt3DRender::QSceneLoader::Status status) {
|
||||
|
||||
if (status == Qt3DRender::QSceneLoader::Ready) {
|
||||
applyWhiteMaterialRecursive(baseModel);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ===== 创建 arm 根节点 =====
|
||||
auto* armModel = new Qt3DCore::QEntity(m_rootEntity);
|
||||
auto* armLoader = new Qt3DRender::QSceneLoader(armModel);
|
||||
armLoader->setSource(QUrl::fromLocalFile(m_armModelPath));
|
||||
|
||||
m_armTransform = new Qt3DCore::QTransform();
|
||||
m_armTransform->setTranslation(QVector3D(0, 0, 0));
|
||||
armModel->addComponent(armLoader);
|
||||
armModel->addComponent(m_armTransform);
|
||||
|
||||
connect(armLoader, &Qt3DRender::QSceneLoader::statusChanged,
|
||||
this, [=](Qt3DRender::QSceneLoader::Status status) {
|
||||
|
||||
if (status == Qt3DRender::QSceneLoader::Ready) {
|
||||
applyWhiteMaterialRecursive(armModel);
|
||||
}
|
||||
});
|
||||
|
||||
// 坐标轴依然挂在 root,不会被移动
|
||||
//createAxes();
|
||||
|
||||
m_view->setRootEntity(m_rootEntity);
|
||||
|
||||
qDebug() << m_baseTransform->matrix();
|
||||
qDebug() << m_armTransform->matrix();
|
||||
|
||||
//m_armTransform->setTranslation(QVector3D(2000, 0, 0));
|
||||
//m_baseTransform->setTranslation(QVector3D(-1000, -1000, -1000));
|
||||
|
||||
qDebug() << m_baseTransform->matrix();
|
||||
qDebug() << m_armTransform->matrix();
|
||||
}
|
||||
|
||||
void View3DBase::applyWhiteMaterialRecursive(Qt3DCore::QEntity* entity)
|
||||
{
|
||||
// 如果这个 entity 有 mesh,就给它加白色材质
|
||||
auto meshes = entity->componentsOfType<Qt3DRender::QGeometryRenderer>();
|
||||
if (!meshes.isEmpty()) {
|
||||
auto* mat = new Qt3DExtras::QPhongMaterial(entity);
|
||||
QColor c1("#cccccc");
|
||||
mat->setDiffuse(c1);
|
||||
mat->setAmbient(c1);
|
||||
mat->setSpecular(c1);
|
||||
mat->setShininess(50.0f);
|
||||
entity->addComponent(mat);
|
||||
}
|
||||
|
||||
// 递归处理子节点
|
||||
const auto children = entity->children();
|
||||
for (QObject* obj : children) {
|
||||
auto* childEntity = qobject_cast<Qt3DCore::QEntity*>(obj);
|
||||
if (childEntity)
|
||||
applyWhiteMaterialRecursive(childEntity);
|
||||
}
|
||||
}
|
||||
|
||||
void View3DBase::createAxes()
|
||||
{
|
||||
// 参数
|
||||
float axisLength = 500.0f;
|
||||
float axisRadius = 50.0f;
|
||||
|
||||
// ----- X axis (red) -----
|
||||
Qt3DCore::QEntity* xAxis = new Qt3DCore::QEntity(m_rootEntity);
|
||||
auto* xMesh = new Qt3DExtras::QCylinderMesh();
|
||||
xMesh->setRadius(axisRadius);
|
||||
xMesh->setLength(axisLength);
|
||||
xMesh->setRings(16);
|
||||
xMesh->setSlices(16);
|
||||
|
||||
auto* xTrans = new Qt3DCore::QTransform();
|
||||
// cylinder 默认沿 Y 轴,绕 Z 轴 90 度让其沿 X
|
||||
xTrans->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), 90.0f));
|
||||
xTrans->setTranslation(QVector3D(axisLength / 2.0f, 0.0f, 0.0f));
|
||||
|
||||
auto* xMat = new Qt3DExtras::QPhongMaterial();
|
||||
xMat->setDiffuse(QColor(Qt::red));
|
||||
|
||||
xAxis->addComponent(xMesh);
|
||||
xAxis->addComponent(xTrans);
|
||||
xAxis->addComponent(xMat);
|
||||
|
||||
// ----- Y axis (green) -----
|
||||
Qt3DCore::QEntity* yAxis = new Qt3DCore::QEntity(m_rootEntity);
|
||||
auto* yMesh = new Qt3DExtras::QCylinderMesh();
|
||||
yMesh->setRadius(axisRadius);
|
||||
yMesh->setLength(axisLength*2);
|
||||
yMesh->setRings(16);
|
||||
yMesh->setSlices(16);
|
||||
|
||||
auto* yTrans = new Qt3DCore::QTransform();
|
||||
// Y 轴无需旋转(cylinder 默认沿 Y)
|
||||
yTrans->setTranslation(QVector3D(0.0f, axisLength / 2.0f, 0.0f));
|
||||
|
||||
auto* yMat = new Qt3DExtras::QPhongMaterial();
|
||||
yMat->setDiffuse(QColor(Qt::green));
|
||||
|
||||
yAxis->addComponent(yMesh);
|
||||
yAxis->addComponent(yTrans);
|
||||
yAxis->addComponent(yMat);
|
||||
|
||||
// ----- Z axis (blue) -----
|
||||
Qt3DCore::QEntity* zAxis = new Qt3DCore::QEntity(m_rootEntity);
|
||||
auto* zMesh = new Qt3DExtras::QCylinderMesh();
|
||||
zMesh->setRadius(axisRadius);
|
||||
zMesh->setLength(axisLength*3);
|
||||
zMesh->setRings(16);
|
||||
zMesh->setSlices(16);
|
||||
|
||||
auto* zTrans = new Qt3DCore::QTransform();
|
||||
// 让 cylinder 沿 Z:绕 X 轴 90 度
|
||||
zTrans->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 90.0f));
|
||||
zTrans->setTranslation(QVector3D(0.0f, 0.0f, axisLength / 2.0f));
|
||||
|
||||
auto* zMat = new Qt3DExtras::QPhongMaterial();
|
||||
zMat->setDiffuse(QColor(Qt::blue));
|
||||
|
||||
zAxis->addComponent(zMesh);
|
||||
zAxis->addComponent(zTrans);
|
||||
zAxis->addComponent(zMat);
|
||||
}
|
||||
|
||||
void View3DBase::initCamera()
|
||||
{
|
||||
m_camera = m_view->camera();
|
||||
// 16:10 假设窗口比例,后续 resize 时相机透视会保持
|
||||
m_camera->lens()->setPerspectiveProjection(50.0f, 16.0f / 10.0f, 0.1f, 10000.0f);
|
||||
updateCameraPosition();
|
||||
}
|
||||
|
||||
void View3DBase::updateCameraPosition()
|
||||
{
|
||||
float yaw = qDegreesToRadians(m_yawDeg);
|
||||
float pitch = qDegreesToRadians(m_pitchDeg);
|
||||
|
||||
float x = m_distance * qCos(pitch) * qSin(yaw);
|
||||
float y = m_distance * qSin(pitch);
|
||||
float z = m_distance * qCos(pitch) * qCos(yaw);
|
||||
|
||||
QVector3D camPos = m_viewCenter + QVector3D(x, y, z);
|
||||
m_camera->setPosition(camPos);
|
||||
m_camera->setViewCenter(m_viewCenter);
|
||||
}
|
||||
|
||||
void View3DBase::showEvent(QShowEvent* event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
|
||||
if (!m_container) {
|
||||
m_container = QWidget::createWindowContainer(m_view, this);
|
||||
m_view->installEventFilter(this);
|
||||
|
||||
auto* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_container);
|
||||
layout->setMargin(0);
|
||||
setLayout(layout);
|
||||
|
||||
// 启动自动旋转 timer(如果你不需要可以注释)
|
||||
m_timer.start(100);
|
||||
}
|
||||
}
|
||||
|
||||
bool View3DBase::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj == m_view)
|
||||
{
|
||||
// 鼠标按下
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
auto* e = static_cast<QMouseEvent*>(event);
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
m_mouseDragging = true;
|
||||
m_lastMousePos = e->pos();
|
||||
}
|
||||
else if (e->button() == Qt::MiddleButton) {
|
||||
m_middleDragging = true;
|
||||
m_lastMousePos = e->pos();
|
||||
}
|
||||
}
|
||||
// 鼠标释放
|
||||
else if (event->type() == QEvent::MouseButtonRelease) {
|
||||
auto* e = static_cast<QMouseEvent*>(event);
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
m_mouseDragging = false;
|
||||
}
|
||||
else if (e->button() == Qt::MiddleButton) {
|
||||
m_middleDragging = false;
|
||||
}
|
||||
}
|
||||
// 鼠标移动
|
||||
else if (event->type() == QEvent::MouseMove) {
|
||||
auto* e = static_cast<QMouseEvent*>(event);
|
||||
QPoint pos = e->pos();
|
||||
QPoint delta = pos - m_lastMousePos;
|
||||
|
||||
// 左键:orbit(旋转)
|
||||
if (m_mouseDragging) {
|
||||
float sensitivity = 0.3f;
|
||||
m_yawDeg -= delta.x() * sensitivity;
|
||||
m_pitchDeg += delta.y() * sensitivity;
|
||||
|
||||
if (m_pitchDeg > 89.0f) m_pitchDeg = 89.0f;
|
||||
if (m_pitchDeg < -89.0f) m_pitchDeg = -89.0f;
|
||||
|
||||
updateCameraPosition();
|
||||
}
|
||||
|
||||
// 中键:pan(平移 viewCenter)
|
||||
if (m_middleDragging) {
|
||||
float speed = 2.0f;
|
||||
|
||||
// 根据摄像机方向计算平移方向
|
||||
QVector3D camPos = m_camera->position();
|
||||
QVector3D forward = (m_viewCenter - camPos).normalized();
|
||||
QVector3D up(0, 1, 0);
|
||||
QVector3D right = QVector3D::crossProduct(forward, up).normalized();
|
||||
|
||||
// 世界坐标变化量
|
||||
QVector3D deltaMove =
|
||||
-right * (delta.x() * speed) +
|
||||
up * (delta.y() * speed);
|
||||
|
||||
// 将平移应用到两个模型根 Transform
|
||||
if (m_baseRootTransform)
|
||||
m_baseRootTransform->setTranslation(
|
||||
m_baseRootTransform->translation() + deltaMove*-1);
|
||||
|
||||
if (m_armRootTransform)
|
||||
m_armRootTransform->setTranslation(
|
||||
m_armRootTransform->translation() + deltaMove*-1);
|
||||
}
|
||||
|
||||
m_lastMousePos = pos;
|
||||
}
|
||||
// 滚轮缩放
|
||||
else if (event->type() == QEvent::Wheel) {
|
||||
auto* e = static_cast<QWheelEvent*>(event);
|
||||
// Qt5: angleDelta 返回像素值(通常为 120 per notch)
|
||||
int delta = e->angleDelta().y();
|
||||
if (delta == 0) delta = e->delta(); // 备选
|
||||
m_distance -= delta * 2.0f; // 缩放速度
|
||||
if (m_distance < 2.0f) m_distance = 2.0f;
|
||||
if (m_distance > 10000.0f) m_distance = 10000.0f;
|
||||
updateCameraPosition();
|
||||
}
|
||||
}
|
||||
|
||||
// 让 Qt 继续处理(保持原行为)
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
View3DPlantPhenotype::View3DPlantPhenotype(const QString& baseModelPath, const QString& armModelPath, QWidget* parent)
|
||||
:View3DBase(baseModelPath, armModelPath, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void View3DPlantPhenotype::setLoc(std::vector<double> loc)
|
||||
{
|
||||
double x = round(loc[0] * 100) / 100;
|
||||
double y = round(loc[1] * 100) / 100;
|
||||
|
||||
m_armTransform->setTranslation(QVector3D(x, y, 0));
|
||||
}
|
||||
|
||||
View3DLinearStage::View3DLinearStage(const QString& baseModelPath, const QString& armModelPath, QWidget* parent)
|
||||
:View3DBase(baseModelPath, armModelPath, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void View3DLinearStage::setLoc(std::vector<double> loc)
|
||||
{
|
||||
double x = round(loc[0] * 100) / 100;
|
||||
|
||||
m_armTransform->setTranslation(QVector3D(x, 0, 0));
|
||||
}
|
||||
112
HPPA/View3D.h
Normal file
112
HPPA/View3D.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifndef VIEW3D_H
|
||||
#define VIEW3D_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QQuaternion>
|
||||
#include <QColor>
|
||||
|
||||
#include <Qt3DCore/QEntity>
|
||||
#include <Qt3DCore/QTransform>
|
||||
#include <Qt3DExtras/Qt3DWindow>
|
||||
#include <Qt3DRender/QCamera>
|
||||
#include <Qt3DExtras/QOrbitCameraController>
|
||||
#include <Qt3DExtras/QPhongMaterial>
|
||||
#include <Qt3DRender/QSceneLoader>
|
||||
#include <Qt3DExtras/QCylinderMesh>
|
||||
#include <QPointLight>
|
||||
|
||||
class View3DBase : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit View3DBase(const QString& baseModelPath,
|
||||
const QString& armModelPath,
|
||||
QWidget* parent = nullptr);
|
||||
void setViewCenter(float x, float y, float z);
|
||||
void setDistance(float distance);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
|
||||
void initScene();
|
||||
void initCamera();
|
||||
void updateCameraPosition();
|
||||
void createAxes();
|
||||
|
||||
QString m_baseModelPath;
|
||||
QString m_armModelPath;
|
||||
|
||||
Qt3DExtras::Qt3DWindow* m_view;
|
||||
QWidget* m_container;
|
||||
Qt3DCore::QEntity* m_rootEntity;
|
||||
|
||||
Qt3DCore::QEntity* m_baseEntity;
|
||||
Qt3DCore::QEntity* m_armEntity;
|
||||
Qt3DCore::QTransform* m_armTransform;
|
||||
Qt3DCore::QTransform* m_baseTransform;
|
||||
|
||||
QTimer m_timer;
|
||||
float m_angle = 0; // arm auto rotation
|
||||
float m_t = 0;
|
||||
|
||||
// ----- Camera control -----
|
||||
Qt3DRender::QCamera* m_camera = nullptr;
|
||||
float m_distance = 5000.0f;
|
||||
float m_yawDeg = 0.0f;
|
||||
float m_pitchDeg = 0.0f;
|
||||
QVector3D m_viewCenter = QVector3D(1000, 1000, -1000);
|
||||
|
||||
// Mouse state
|
||||
bool m_mouseDragging = false; // left button: orbit
|
||||
bool m_middleDragging = false; // middle button: pan
|
||||
QPoint m_lastMousePos;
|
||||
|
||||
Qt3DCore::QTransform* m_baseRootTransform = nullptr;
|
||||
Qt3DCore::QTransform* m_armRootTransform = nullptr;
|
||||
|
||||
void applyWhiteMaterialRecursive(Qt3DCore::QEntity* entity);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setLoc(std::vector<double> loc) = 0;
|
||||
};
|
||||
|
||||
class View3DPlantPhenotype : public View3DBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
View3DPlantPhenotype(const QString& baseModelPath,
|
||||
const QString& armModelPath,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
public Q_SLOTS:
|
||||
void setLoc(std::vector<double> loc);
|
||||
};
|
||||
|
||||
class View3DLinearStage : public View3DBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
View3DLinearStage(const QString& baseModelPath,
|
||||
const QString& armModelPath,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
public Q_SLOTS:
|
||||
void setLoc(std::vector<double> loc);
|
||||
};
|
||||
#endif // VIEW3D_H
|
||||
68
HPPA/View3DModelManager.cpp
Normal file
68
HPPA/View3DModelManager.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include "View3DModelManager.h"
|
||||
|
||||
View3DModelManager::View3DModelManager(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_stackedWidget = new QStackedWidget();
|
||||
m_stackedWidget->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_stackedWidget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void View3DModelManager::switchScenario(ScenarioType type)
|
||||
{
|
||||
if (type == ScenarioType::PlantPhenotype) {
|
||||
ensurePlantPhenotypeView();
|
||||
m_stackedWidget->setCurrentWidget(m_viewPlant);
|
||||
}
|
||||
else {
|
||||
ensureOneMotorView();
|
||||
m_stackedWidget->setCurrentWidget(m_viewMotor);
|
||||
}
|
||||
|
||||
emit scenarioChanged(type);
|
||||
}
|
||||
|
||||
void View3DModelManager::ensurePlantPhenotypeView()
|
||||
{
|
||||
if (m_viewPlant)
|
||||
return;
|
||||
|
||||
QString basePath = QCoreApplication::applicationDirPath();
|
||||
|
||||
m_viewPlant = new View3DPlantPhenotype(
|
||||
basePath + "/3DModel/HPPA_frame.obj",
|
||||
basePath + "/3DModel/HPPA_camera.obj",
|
||||
m_stackedWidget
|
||||
);
|
||||
|
||||
m_viewPlant->setViewCenter(1000, 1000, -1000);
|
||||
m_viewPlant->setDistance(5000);
|
||||
|
||||
m_stackedWidget->addWidget(m_viewPlant);
|
||||
|
||||
emit created3DModelPlantPhenotype();
|
||||
}
|
||||
|
||||
void View3DModelManager::ensureOneMotorView()
|
||||
{
|
||||
if (m_viewMotor)
|
||||
return;
|
||||
|
||||
QString basePath = QCoreApplication::applicationDirPath();
|
||||
|
||||
m_viewMotor = new View3DLinearStage(
|
||||
basePath + "/3DModel/linear_stage_indoor1.obj",
|
||||
basePath + "/3DModel/linear_stage_indoor2.obj",
|
||||
m_stackedWidget
|
||||
);
|
||||
|
||||
m_viewMotor->setViewCenter(500, 100, 500);
|
||||
m_viewMotor->setDistance(1000);
|
||||
|
||||
m_stackedWidget->addWidget(m_viewMotor);
|
||||
|
||||
emit created3DModelOneMotor();
|
||||
}
|
||||
40
HPPA/View3DModelManager.h
Normal file
40
HPPA/View3DModelManager.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QStackedWidget>
|
||||
#include <QCoreApplication>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "View3D.h"
|
||||
|
||||
class View3DPlantPhenotype;
|
||||
class View3DLinearStage;
|
||||
|
||||
class View3DModelManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class ScenarioType {
|
||||
PlantPhenotype,
|
||||
OneMotor
|
||||
};
|
||||
|
||||
explicit View3DModelManager(QWidget* parent = nullptr);
|
||||
|
||||
void switchScenario(ScenarioType type);
|
||||
|
||||
View3DPlantPhenotype* m_viewPlant = nullptr;
|
||||
View3DLinearStage* m_viewMotor = nullptr;
|
||||
|
||||
signals:
|
||||
void scenarioChanged(ScenarioType type);
|
||||
void created3DModelPlantPhenotype();
|
||||
void created3DModelOneMotor();
|
||||
|
||||
private:
|
||||
void ensurePlantPhenotypeView();
|
||||
void ensureOneMotorView();
|
||||
|
||||
private:
|
||||
QStackedWidget* m_stackedWidget = nullptr;
|
||||
};
|
||||
371
HPPA/about.ui
371
HPPA/about.ui
@ -9,103 +9,300 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>629</width>
|
||||
<height>463</height>
|
||||
<width>486</width>
|
||||
<height>401</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>HPPA.ico</normaloff>HPPA.ico</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>250</y>
|
||||
<width>434</width>
|
||||
<height>134</height>
|
||||
</rect>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="companylname_label">
|
||||
<property name="text">
|
||||
<string>公司:北京依锐思遥感技术有限公司</string>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="contentWidget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #contentWidget
|
||||
{
|
||||
background: #040125;
|
||||
/*border-radius: 8px 8px 8px 8px;*/
|
||||
border: 1px solid #2f6bff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>地址:北京市海淀区清河安宁庄东路18号5号楼二层205</string>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>电话:010-51292601</string>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>邮箱:hanshanlong@iris-rs.cn</string>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>150</y>
|
||||
<width>141</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:1.9.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>70</y>
|
||||
<width>391</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hyper Plant Phenotypic Analysis</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>50</y>
|
||||
<width>141</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>HPPA.ico</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="titlebarWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #titlebarWidget
|
||||
{
|
||||
background: #0E1C4C;
|
||||
border: 1px solid #2f6bff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="iconLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="HPPA.qrc">:/png/resources/icons/png/Spectral_Insight_27.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color:#E2EDFF;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关于</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>505</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="closeBtn">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 10pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="HPPA.qrc">
|
||||
<normaloff>:/svg/resources/icons/svg/close.svg</normaloff>:/svg/resources/icons/svg/close.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>20</y>
|
||||
<width>171</width>
|
||||
<height>171</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="HPPA.qrc">:/png/resources/icons/png/Spectral_Insight_170.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>210</y>
|
||||
<width>306</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color: #E2EDFF;
|
||||
font: 10pt "Adobe Devanagari";
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>地址:北京市海淀区清河安宁庄东路18号5号楼二层205</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>电话:010-51292601</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>邮箱:hanshanlong@iris-rs.cn</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="companylname_label">
|
||||
<property name="text">
|
||||
<string>公司:北京依锐思遥感技术有限公司</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>50</y>
|
||||
<width>171</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="verticalSpacing">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color:#E2EDFF;
|
||||
font: italic 18pt "Adobe Devanagari";
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Spectral Insight</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="versionLabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color:#E2EDFF;
|
||||
font: 10pt "Adobe Devanagari";
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:3.0.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="HPPA.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "aboutWindow.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
|
||||
aboutWindow::aboutWindow(QWidget* parent)
|
||||
{
|
||||
@ -9,14 +10,22 @@ aboutWindow::aboutWindow(QWidget* parent)
|
||||
QString text = ui.companylname_label->text();
|
||||
ui.companylname_label->setText("<a style='color: green; text-decoration: none' href = http://www.iris-rs.cn/pr.jsp?_jcp=3_10>" + text);
|
||||
|
||||
Qt::WindowFlags flags = 0;
|
||||
//flags |= Qt::WindowMinimizeButtonHint;
|
||||
flags |= Qt::WindowCloseButtonHint;
|
||||
flags |= Qt::MSWindowsFixedSizeDialogHint;
|
||||
setWindowFlags(flags);
|
||||
//Qt::WindowFlags flags = 0;
|
||||
////flags |= Qt::WindowMinimizeButtonHint;
|
||||
//flags |= Qt::WindowCloseButtonHint;
|
||||
//flags |= Qt::MSWindowsFixedSizeDialogHint;
|
||||
//setWindowFlags(flags);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
|
||||
connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit()));
|
||||
}
|
||||
|
||||
aboutWindow::~aboutWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void aboutWindow::onExit()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
#include <QtWidgets/qdialog.h>
|
||||
#include <qstring.h>
|
||||
|
||||
|
||||
#include "ui_about.h"
|
||||
|
||||
class aboutWindow :public QDialog
|
||||
@ -19,6 +20,7 @@ private:
|
||||
Ui::aboutDialog ui;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onExit();
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@ -6,24 +6,127 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>687</width>
|
||||
<height>389</height>
|
||||
<width>501</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>adjustTable</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox
|
||||
{
|
||||
border: 12px solid transparent;
|
||||
/*border-top: 12px solid transparent;
|
||||
border-right: 0px solid transparent;
|
||||
border-bottom: 0px solid transparent;
|
||||
border-left: 0px solid transparent;*/
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 19pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4" rowstretch="1,2,2,2,1" columnstretch="1,10,1">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>66</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>252号升降台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>18</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="objective_table252_up_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -33,10 +136,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="objective_table252_down_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -46,10 +149,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="objective_table252_stop_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -62,16 +165,63 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>253号升降台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>18</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="objective_table1_up_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -81,10 +231,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="objective_table1_down_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -94,10 +244,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="objective_table1_stop_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -110,16 +260,63 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>254号升降台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>18</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="objective_table2_up_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -129,10 +326,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="objective_table2_down_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -142,10 +339,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="objective_table2_stop_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -158,6 +355,32 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>65</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
||||
@ -1,11 +1,23 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "focusWindow.h"
|
||||
#include <QSvgRenderer>
|
||||
#include <QMouseEvent>
|
||||
|
||||
focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
ui.titlebarWidget->installEventFilter(this);
|
||||
|
||||
QSvgRenderer svgRenderer(QString(":/svg/resources/icons/svg/focus.svg"));
|
||||
QPixmap pixmap(24, 24);
|
||||
pixmap.fill(Qt::transparent); // 背景透明
|
||||
QPainter painter(&pixmap);
|
||||
svgRenderer.render(&painter);
|
||||
ui.iconLabel->setPixmap(pixmap);
|
||||
|
||||
//读取配置文件
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
@ -18,7 +30,7 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
|
||||
disableBeforeConnect(true);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);//<EFBFBD><EFBFBD><EFBFBD>ùرմ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
setAttribute(Qt::WA_DeleteOnClose);//设置关闭窗体就调用窗体的析构函数
|
||||
|
||||
m_Imager = imager;
|
||||
m_FocusState = 0;
|
||||
@ -38,7 +50,10 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
connect(this->ui.updateCurrentLocation_btn, SIGNAL(clicked()), this, SLOT(onUpdateCurrentLocation()));
|
||||
connect(this->ui.moveto_btn, SIGNAL(clicked()), this, SLOT(onMoveto()));
|
||||
|
||||
//<2F><><EFBFBD>ҿ<EFBFBD><D2BF>ô<EFBFBD><C3B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit()));
|
||||
|
||||
//查找可用串口,并显示
|
||||
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
QSerialPort serial;
|
||||
@ -51,25 +66,76 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
}
|
||||
}
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//设置自动调焦进度条
|
||||
ui.autoFocusProgress_progressBar->setMinimum(0);
|
||||
ui.autoFocusProgress_progressBar->setMaximum(100);
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
|
||||
m_dSpeed = 1.0;
|
||||
|
||||
}
|
||||
|
||||
focusWindow::~focusWindow()
|
||||
{
|
||||
printf("destroy focusWindow-------------------------\n");
|
||||
|
||||
emit StartManualFocusSignal(0);//<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>û<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رմ<EFBFBD><EFBFBD><EFBFBD>
|
||||
emit StartManualFocusSignal(0);//当用户没有点击停止调焦就关闭窗口
|
||||
emit closeSignal();
|
||||
|
||||
delete m_ctrlFocusMotor;
|
||||
//delete thread1, progressThread;
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
|
||||
m_MotionCaptureCoordinatorThread.quit();
|
||||
m_MotionCaptureCoordinatorThread.wait();
|
||||
}
|
||||
|
||||
void focusWindow::onExit()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
bool focusWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == ui.titlebarWidget)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
m_bDrag = true;
|
||||
m_dragPosition = mouseEvent->globalPos() - frameGeometry().topLeft();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event->type() == QEvent::MouseMove)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (m_bDrag && (mouseEvent->buttons() & Qt::LeftButton))
|
||||
{
|
||||
move(mouseEvent->globalPos() - m_dragPosition);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event->type() == QEvent::MouseButtonRelease)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
m_bDrag = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void focusWindow::disableBeforeConnect(bool disable)
|
||||
{
|
||||
ui.controlMotor_groupBox->setDisabled(disable);
|
||||
ui.controlMotor_widget->setDisabled(disable);
|
||||
ui.autoFocus_btn->setDisabled(disable);
|
||||
}
|
||||
|
||||
@ -92,142 +158,239 @@ bool test(void *pCaller, int *x, int *y, void **pvdata)
|
||||
|
||||
void focusWindow::onConnectMotor()
|
||||
{
|
||||
if (m_ctrlFocusMotor != nullptr)
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------------------------\n");
|
||||
return;
|
||||
}
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
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();
|
||||
|
||||
|
||||
|
||||
if (isUltrasound)
|
||||
{
|
||||
PortInfo motor;
|
||||
motor.iPortType = 0;
|
||||
motor.indexParity = 0;
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
m_motorThread.start();
|
||||
|
||||
motor.iPortNumber = motorPort;
|
||||
motor.indexBaudRate = 0x13;
|
||||
motor.indexBytesize = 3;
|
||||
motor.indexStopBits = 0;
|
||||
//归零
|
||||
//emit zeroStartSignal(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(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, ultrasound, test, this);
|
||||
//m_ctrlFocusMotor->MoveToLogicZero();
|
||||
//自动调焦逻辑
|
||||
m_coordinator = new MotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_MotionCaptureCoordinatorThread);
|
||||
connect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(startStepMotion(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
connect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
m_MotionCaptureCoordinatorThread.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
PortInfo motor;
|
||||
motor.iPortType = 0;
|
||||
motor.indexParity = 0;
|
||||
motor.iPortNumber = motorPort;
|
||||
motor.indexBaudRate = 0x13;
|
||||
motor.indexBytesize = 3;
|
||||
motor.indexStopBits = 0;
|
||||
if (m_ctrlFocusMotor != nullptr)
|
||||
{
|
||||
printf("不能重复连接-------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
m_ctrlFocusMotor = new CFocusMotorControl();
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
|
||||
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, test, this);
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
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();
|
||||
|
||||
|
||||
|
||||
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(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
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(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, test, this);
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
disableBeforeConnect(false);
|
||||
}
|
||||
|
||||
void focusWindow::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
this->ui.currentLocation_lineEdit->setText(QString::number(tmp));
|
||||
}
|
||||
|
||||
void focusWindow::onx_rangeMeasurement()
|
||||
{
|
||||
emit rangeMeasurementSignal(0, m_dSpeed, 1000);
|
||||
}
|
||||
|
||||
void focusWindow::onMove2MotorLogicZero()
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit zeroStartSignal(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onMove2MotorMax()
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToPos(m_iMaxPos);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit move2MaxLocSignal(0, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToPos(m_iMaxPos);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAdd()
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
double rdistance = ui.addStepSize_lineEdit->text().toDouble();
|
||||
|
||||
int stepSize = ui.addStepSize_lineEdit->text().toInt();
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit rmoveSignal(0, (double)abs(rdistance), m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + stepSize);
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + rdistance);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onSubtract()
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
double rdistance = ui.subtractStepSize_lineEdit->text().toDouble();
|
||||
|
||||
int stepSize = ui.subtractStepSize_lineEdit->text().toInt();
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit rmoveSignal(0, (double)abs(rdistance) * -1, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - stepSize);
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - rdistance);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocus()
|
||||
{
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
WorkerThread2 *thread1 = new WorkerThread2(m_ctrlFocusMotor, isUltrasound);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//先按照一定间隔从负极限到正极限获取一系列(位置,调焦指数)
|
||||
m_iStepSize = ui.sample_ratio_lineEdit->text().toInt();
|
||||
ui.autoFocusProgress_progressBar->setMinimum(0);
|
||||
ui.autoFocusProgress_progressBar->setMaximum(m_iStepSize);
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
|
||||
connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
|
||||
//获取马达最大位置
|
||||
std::vector<double> maxRangeLocations = m_multiAxisController->getMaxPos();
|
||||
double maxPos = maxRangeLocations[0];
|
||||
emit startStepMotion(m_dSpeed, m_iStepSize, 0, maxPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
WorkerThread2* thread1 = new WorkerThread2(m_ctrlFocusMotor, isUltrasound);
|
||||
|
||||
thread1->start();
|
||||
connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
|
||||
|
||||
thread1->start();
|
||||
|
||||
WorkerThread4* progressThread = new WorkerThread4(m_ctrlFocusMotor);
|
||||
connect(progressThread, SIGNAL(AutoFocusProgressSignal(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
progressThread->start();
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
}
|
||||
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()
|
||||
{
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
m_FocusState += 1;
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><EFBFBD>" << std::endl;
|
||||
std::cout << "点击调焦按钮!" << std::endl;
|
||||
|
||||
|
||||
if (m_FocusState % 2 == 1)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//开始调焦
|
||||
emit StartManualFocusSignal(1);
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("停止调焦"));
|
||||
|
||||
ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
|
||||
|
||||
ui.autoFocus_btn->setDisabled(true);
|
||||
|
||||
//std::cout << "------------------------------------------<EFBFBD><EFBFBD>" << m_FocusState << std::endl;
|
||||
//std::cout << "------------------------------------------:" << m_FocusState << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit StartManualFocusSignal(0);
|
||||
m_Imager->setFocusControlState(false);
|
||||
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("调焦"));
|
||||
|
||||
ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
|
||||
|
||||
@ -237,30 +400,192 @@ void focusWindow::onManualFocus()
|
||||
|
||||
void focusWindow::onUpdateCurrentLocation()
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
ui.currentLocation_lineEdit->setText(QString::number(di.iAbsPosition));
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//因为新版的马达控制是实时反馈位置信息,所以不需要做任何事
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
ui.currentLocation_lineEdit->setText(QString::number(di.iAbsPosition));
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onMoveto()
|
||||
{
|
||||
int pos = ui.currentLocation_lineEdit->text().toInt();
|
||||
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD>鿴<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Χ<EFBFBD><CEA7>
|
||||
double pos = ui.move2_lineEdit->text().toDouble();
|
||||
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit move2LocSignal(0, (double)pos, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
//需要做参数有效性验证,查看是否在有效范围内
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(pos);
|
||||
m_ctrlFocusMotor->MoveToPos(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocusFinished()
|
||||
{
|
||||
this->setDisabled(false);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//通过高斯拟合获取最佳位置
|
||||
QVector<PositionData> positionData = m_coordinator->getAllPositionData();
|
||||
|
||||
onUpdateCurrentLocation();
|
||||
std::vector<double> actualPositions;
|
||||
std::vector<double> cameraIndices;
|
||||
|
||||
actualPositions.reserve(positionData.size());
|
||||
cameraIndices.reserve(positionData.size());
|
||||
|
||||
int scaleFactor = 100;
|
||||
for (const auto& data : positionData)
|
||||
{
|
||||
actualPositions.push_back(data.actualPosition * scaleFactor);
|
||||
cameraIndices.push_back(data.cameraIndex);
|
||||
}
|
||||
double a_init, mu_init, sigma_init, c_init;
|
||||
getGaussianInitParam(actualPositions, cameraIndices, a_init, mu_init, sigma_init, c_init);
|
||||
|
||||
double a = a_init, mu = mu_init, sigma = sigma_init, c = c_init;
|
||||
gaussian_fit(actualPositions, cameraIndices, a, mu, sigma, c);
|
||||
|
||||
mu_init = mu_init / scaleFactor;
|
||||
mu = mu / scaleFactor;
|
||||
|
||||
std::cout << "mu 初值:" << mu_init << std::endl << "mu 拟合值:" << mu << std::endl;
|
||||
|
||||
//对拟合值进行判断,排除错误拟合情况(地物没有纹理)
|
||||
std::vector<double> maxRangeLocations = m_multiAxisController->getMaxPos();
|
||||
double maxPos = maxRangeLocations[0];
|
||||
if (mu < 0 || mu > maxPos)
|
||||
{
|
||||
std::cout << "拟合失败!!!!!" << std::endl;
|
||||
m_goodPos = mu_init;
|
||||
m_isAutoFocusSuccess = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "拟合成功!!!!!" << std::endl;
|
||||
m_goodPos = mu;
|
||||
m_isAutoFocusSuccess = true;
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QString format1 = "yyyyMMdd_HHmmss";
|
||||
QString fileName = now.toString("yyyyMMdd_HHmmss");
|
||||
|
||||
QString fitDataFile = QDir::cleanPath(QString::fromStdString(directory) + QDir::separator() + fileName + "_" + QString::number(m_iStepSize) + "interval_" + QString::number(mu) + ".csv");
|
||||
m_coordinator->saveToCsv(fitDataFile);
|
||||
|
||||
//由于马达移动准确性较低,自动调焦完成后,直接移动到m_goodPos效果不好,所以先移动到tmpPos,然后移动到m_goodPos
|
||||
double tmpPos = m_goodPos - positionData[positionData.size() - 1].actualPosition / 10;
|
||||
m_isMoveAfterAutoFocus = true;
|
||||
emit move2LocSignal(0, (double)tmpPos, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
onUpdateCurrentLocation();
|
||||
}
|
||||
|
||||
this->setDisabled(false);
|
||||
}
|
||||
|
||||
void focusWindow::moveAfterAutoFocus(int motorID, double location)
|
||||
{
|
||||
if (!m_isMoveAfterAutoFocus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\n已经到达位置:" << location << std::endl;
|
||||
|
||||
//移动马达到最佳位置
|
||||
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||
|
||||
double tmp = abs(location - m_goodPos) / m_goodPos * 100;
|
||||
if (tmp<5)
|
||||
{
|
||||
if (!m_isAutoFocusSuccess)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||
msgBox.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("自动调焦成功!"));
|
||||
msgBox.exec();
|
||||
}
|
||||
m_isMoveAfterAutoFocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init)
|
||||
{
|
||||
auto minmax_element = std::minmax_element(index.begin(), index.end());
|
||||
a_init = *minmax_element.second - *minmax_element.first;
|
||||
mu_init = pos[std::distance(index.begin(), minmax_element.second)];
|
||||
c_init = *minmax_element.first;
|
||||
|
||||
//sigma_init
|
||||
double half_max = (*minmax_element.second + *minmax_element.first) / 2.0;
|
||||
size_t peak_idx = std::distance(index.begin(), minmax_element.second);
|
||||
size_t left_idx = peak_idx;// 找左半高点
|
||||
while (left_idx > 0 && index[left_idx] > half_max) left_idx--;
|
||||
size_t right_idx = peak_idx;// 找右半高点
|
||||
while (right_idx < index.size() - 1 && index[right_idx] > half_max) right_idx++;
|
||||
double fwhm = pos[right_idx] - pos[left_idx];
|
||||
sigma_init = fwhm / 2.3548;
|
||||
}
|
||||
|
||||
// 使用 Gauss-Newton 进行高斯拟合
|
||||
void focusWindow::gaussian_fit(const std::vector<double>& x_data,
|
||||
const std::vector<double>& y_data,
|
||||
double& a, double& mu, double& sigma, double& c)
|
||||
{
|
||||
const int max_iter = 100;
|
||||
for (int iter = 0; iter < max_iter; iter++)
|
||||
{
|
||||
Eigen::MatrixXd J(x_data.size(), 4);
|
||||
Eigen::VectorXd r(x_data.size());
|
||||
|
||||
for (size_t i = 0; i < x_data.size(); i++)
|
||||
{
|
||||
double xi = x_data[i];
|
||||
double yi = y_data[i];
|
||||
double exp_part = std::exp(-(xi - mu) * (xi - mu) / (2 * sigma * sigma));
|
||||
double fi = a * exp_part + c;
|
||||
|
||||
r(i) = yi - fi;
|
||||
|
||||
// 雅可比
|
||||
J(i, 0) = -exp_part; // ∂f/∂a
|
||||
J(i, 1) = -a * exp_part * ((xi - mu) / (sigma * sigma)); // ∂f/∂mu
|
||||
J(i, 2) = -a * exp_part * ((xi - mu) * (xi - mu) / (sigma * sigma * sigma)); // ∂f/∂sigma
|
||||
J(i, 3) = -1.0; // ∂f/∂c
|
||||
}
|
||||
|
||||
Eigen::VectorXd delta = (J.transpose() * J).ldlt().solve(-J.transpose() * r);
|
||||
|
||||
a += delta(0);
|
||||
mu += delta(1);
|
||||
sigma += delta(2);
|
||||
c += delta(3);
|
||||
|
||||
if (delta.norm() < 1e-8) break;
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocusProgress(int progress)
|
||||
{
|
||||
//std::cout << "<EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>" << progress << std::endl;
|
||||
//std::cout << "进度:" << progress << std::endl;
|
||||
|
||||
ui.autoFocusProgress_progressBar->setValue(progress);
|
||||
}
|
||||
@ -287,7 +612,7 @@ WorkerThread2::WorkerThread2(CFocusMotorControl * ctrlFocusMotor, bool isUltraso
|
||||
|
||||
void WorkerThread2::run()
|
||||
{
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
//配置文件
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
@ -326,15 +651,185 @@ void WorkerThread4::run()
|
||||
{
|
||||
int progress = m_ctrlFocusMotor->GetProgressIndex();
|
||||
|
||||
//std::cout << "WorkerThread4::run----<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>" << progress << std::endl;
|
||||
//std::cout << "WorkerThread4::run----自动调焦进度:" << progress << std::endl;
|
||||
|
||||
emit AutoFocusProgressSignal(progress);
|
||||
if (progress == 100)
|
||||
{
|
||||
//std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>" << std::endl;
|
||||
//std::cout << "自动调焦完成!" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
msleep(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
MotionCaptureCoordinator::MotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_currentPos(0)
|
||||
, m_endPos(0)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &MotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &MotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, SIGNAL(getFocusIndexSobel()),
|
||||
m_cameraCtrl, SLOT(getFocusIndexSobel()));
|
||||
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::FocusIndexSobelSignal,
|
||||
this, &MotionCaptureCoordinator::handleCaptureComplete);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
|
||||
// this, &MotionCaptureCoordinator::handleError);
|
||||
}
|
||||
|
||||
MotionCaptureCoordinator::~MotionCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::startStepMotion(double speed, int stepInterval, double startPos, double endPos)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
return;
|
||||
}
|
||||
|
||||
m_counter = 0;
|
||||
|
||||
m_positionData.clear();
|
||||
|
||||
m_speed = speed;
|
||||
m_iStepInterval = stepInterval;
|
||||
m_iStepIntervalRealTime = 1;
|
||||
m_currentPos = startPos;
|
||||
m_endPos = endPos;
|
||||
m_posInternal = (endPos - startPos) / stepInterval;
|
||||
|
||||
m_isRunning = true;
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit sequenceStopped();
|
||||
}
|
||||
|
||||
QVector<PositionData> MotionCaptureCoordinator::getAllPositionData() const
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
return m_positionData;
|
||||
}
|
||||
|
||||
bool MotionCaptureCoordinator::saveToCsv(const QString& filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "Timestamp,targetPosition,ActualPosition,FocusIndex\n";
|
||||
|
||||
for (const auto& data : m_positionData)
|
||||
{
|
||||
out << data.timestamp.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(data.targetPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualPosition, 'f', 4) << ","
|
||||
<< QString::number(data.cameraIndex, 'f', 4) << "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
//验证马达运动位置是否到达指定位置
|
||||
//if (pos != m_currentPos) return;
|
||||
|
||||
// 记录位置信息
|
||||
PositionData data;
|
||||
data.targetPosition = m_currentPos;
|
||||
data.actualPosition = pos;
|
||||
data.timestamp = QDateTime::currentDateTime();
|
||||
m_positionData.append(data);
|
||||
|
||||
// 开始采集
|
||||
emit getFocusIndexSobel();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
// 更新最近一条记录的相机指数
|
||||
//if (!m_positionData.isEmpty() &&
|
||||
// m_positionData.last().targetPosition == m_positionData.last().actualPosition)
|
||||
//{
|
||||
// m_positionData.last().cameraIndex = index;
|
||||
//}
|
||||
m_positionData.last().cameraIndex = index;
|
||||
|
||||
m_currentPos += m_posInternal;
|
||||
m_iStepIntervalRealTime++;
|
||||
emit progressChanged(m_iStepIntervalRealTime);
|
||||
|
||||
m_counter += 1;
|
||||
|
||||
std::cout << "第" << m_counter << "次采集:" << std::endl;
|
||||
std::cout << "目标位置:" << m_positionData.last().targetPosition << std::endl;
|
||||
std::cout << "实际位置:" << m_positionData.last().actualPosition << std::endl;
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handleError(const QString& error)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::processNextPosition()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
if (m_currentPos > m_endPos)
|
||||
{
|
||||
m_isRunning = false;
|
||||
emit sequenceComplete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
emit moveTo(0, m_currentPos, m_speed, 1000);
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
|
||||
#include "ui_FocusDialog.h"
|
||||
#include "AbstractPortMiscDefines.h"
|
||||
@ -26,6 +28,71 @@
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "IrisMultiMotorController.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <cmath>
|
||||
|
||||
// <20><><EFBFBD>ݼ<EFBFBD>¼<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||
struct PositionData {
|
||||
double targetPosition; // Ŀ<><C4BF>λ<EFBFBD><CEBB>
|
||||
double actualPosition; // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
double cameraIndex; // <20><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>ָ<EFBFBD><D6B8>
|
||||
QDateTime timestamp; // ʱ<><CAB1><EFBFBD><EFBFBD>
|
||||
|
||||
PositionData(double target = 0, double actual = 0.0, double index = 0.0)
|
||||
: targetPosition(target), actualPosition(actual),
|
||||
cameraIndex(index), timestamp(QDateTime::currentDateTime()) {}
|
||||
};
|
||||
|
||||
// Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
class MotionCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~MotionCaptureCoordinator();
|
||||
|
||||
QVector<PositionData> getAllPositionData() const;
|
||||
bool saveToCsv(const QString& filename);
|
||||
|
||||
public slots:
|
||||
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);//-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զλ<D4B6><CEBB>
|
||||
void stopStepMotion();
|
||||
|
||||
signals:
|
||||
void progressChanged(int progress);
|
||||
void sequenceComplete();
|
||||
void sequenceStopped();
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void getFocusIndexSobel();
|
||||
|
||||
private slots:
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
void handleError(const QString& error);
|
||||
|
||||
private:
|
||||
void processNextPosition();
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
QVector<PositionData> m_positionData;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
double m_posInternal;
|
||||
double m_currentPos;
|
||||
double m_endPos;
|
||||
bool m_isRunning;
|
||||
double m_speed;
|
||||
|
||||
int m_iStepInterval;
|
||||
int m_iStepIntervalRealTime;
|
||||
int m_counter;
|
||||
};
|
||||
|
||||
class focusWindow:public QDialog
|
||||
{
|
||||
@ -38,8 +105,13 @@ public:
|
||||
|
||||
ImagerOperationBase* m_Imager;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
private:
|
||||
QPoint m_dragPosition;
|
||||
bool m_bDrag = false;
|
||||
|
||||
Ui::focusDialog ui;
|
||||
QThread *m_AutoFocusThread;
|
||||
int m_FocusState;
|
||||
@ -50,6 +122,21 @@ private:
|
||||
|
||||
void disableBeforeConnect(bool disable);
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
double m_dSpeed;
|
||||
|
||||
QThread m_MotionCaptureCoordinatorThread;
|
||||
MotionCaptureCoordinator* m_coordinator;
|
||||
|
||||
int m_iStepSize;
|
||||
double m_goodPos;
|
||||
bool m_isAutoFocusSuccess;
|
||||
bool m_isMoveAfterAutoFocus = false;
|
||||
void getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init);
|
||||
void gaussian_fit(const std::vector<double>& x_data, const std::vector<double>& y_data, double& a, double& mu, double& sigma, double& c);
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
void onMove2MotorLogicZero();
|
||||
@ -64,8 +151,24 @@ public Q_SLOTS:
|
||||
void onAutoFocusProgress(int progress);
|
||||
void onUltrasound_radioButton();
|
||||
|
||||
void display_x_loc(std::vector<double> loc);
|
||||
void onx_rangeMeasurement();
|
||||
|
||||
void moveAfterAutoFocus(int motorID, double location);
|
||||
|
||||
void onExit();
|
||||
|
||||
signals:
|
||||
void StartManualFocusSignal(int);//1<><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2MaxLocSignal(int, double, int);
|
||||
void rmoveSignal(int, double, double, int);
|
||||
void rangeMeasurementSignal(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
|
||||
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);
|
||||
void closeSignal();
|
||||
};
|
||||
|
||||
class WorkerThread2 : public QThread
|
||||
|
||||
341
HPPA/hyperImagerControl.ui
Normal file
341
HPPA/hyperImagerControl.ui
Normal file
@ -0,0 +1,341 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HyperImagerControl</class>
|
||||
<widget class="QWidget" name="HyperImagerControl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>437</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Color Adjust</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox
|
||||
{
|
||||
border: 12px solid transparent;
|
||||
/*border-top: 12px solid transparent;
|
||||
border-right: 0px solid transparent;
|
||||
border-bottom: 0px solid transparent;
|
||||
border-left: 0px solid transparent;*/
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 10pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
height: 10px;
|
||||
background: #1e2a44;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 已滑过:渐变蓝 */
|
||||
QSlider::sub-page:horizontal {
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1f4fff,
|
||||
stop:0.5 #2f6bff,
|
||||
stop:1 #5fa0ff
|
||||
);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 未滑过 */
|
||||
QSlider::add-page:horizontal {
|
||||
height: 10px;
|
||||
background: #2a3550;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* ===== 滑块按钮 ===== */
|
||||
QSlider::handle:horizontal {
|
||||
width: 15px;
|
||||
height: 10px;
|
||||
|
||||
/* 蓝色实心 */
|
||||
background: #2f6bff;
|
||||
|
||||
/* 白色外圈 */
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 5px;
|
||||
|
||||
/* 垂直居中 */
|
||||
margin: -5px 0;
|
||||
}
|
||||
|
||||
/* 悬停 */
|
||||
QSlider::handle:horizontal:hover {
|
||||
background: #4d8dff;
|
||||
}
|
||||
|
||||
/* 按下 */
|
||||
QSlider::handle:horizontal:pressed {
|
||||
background: #1f4fff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="3,2">
|
||||
<item row="0" column="0">
|
||||
<widget class="AspectRatioLabel" name="imagerPictureLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="framerate_spinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QDoubleSlider" name="FramerateSlider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>gain</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>积分时间</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="gain_spinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSlider" name="GainSlider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="integratioin_time_spinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QDoubleSlider" name="IntegratioinTimeSlider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帧率</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>hz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>ms</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AspectRatioLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>AspectRatioLabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QDoubleSlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header location="global">qdoubleslider.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
347
HPPA/imageControl.cpp
Normal file
347
HPPA/imageControl.cpp
Normal file
@ -0,0 +1,347 @@
|
||||
#include "imageControl.h"
|
||||
#include "RasterLayer.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
ImageControl::ImageControl(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
// Spinbox valueChanged: only sync the paired slider (no render)
|
||||
connect(ui.spinRed, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ImageControl::onSpinRedValueChanged);
|
||||
connect(ui.spinGreen, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ImageControl::onSpinGreenValueChanged);
|
||||
connect(ui.spinBlue, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ImageControl::onSpinBlueValueChanged);
|
||||
|
||||
// Spinbox editingFinished: commit on Enter key / focus lost (trigger render)
|
||||
connect(ui.spinRed, &QDoubleSpinBox::editingFinished, this, &ImageControl::onSpinRedEditingFinished);
|
||||
connect(ui.spinGreen, &QDoubleSpinBox::editingFinished, this, &ImageControl::onSpinGreenEditingFinished);
|
||||
connect(ui.spinBlue, &QDoubleSpinBox::editingFinished, this, &ImageControl::onSpinBlueEditingFinished);
|
||||
|
||||
// Slider valueChanged: only sync the paired spinbox (no render)
|
||||
// Slider now represents band index (0 .. N-1)
|
||||
connect(ui.sliderRed, &QSlider::valueChanged, this, &ImageControl::onSliderRedValueChanged);
|
||||
connect(ui.sliderGreen, &QSlider::valueChanged, this, &ImageControl::onSliderGreenValueChanged);
|
||||
connect(ui.sliderBlue, &QSlider::valueChanged, this, &ImageControl::onSliderBlueValueChanged);
|
||||
|
||||
// Slider sliderReleased: commit on mouse release (trigger render)
|
||||
connect(ui.sliderRed, &QSlider::sliderReleased, this, &ImageControl::onSliderRedReleased);
|
||||
connect(ui.sliderGreen, &QSlider::sliderReleased, this, &ImageControl::onSliderGreenReleased);
|
||||
connect(ui.sliderBlue, &QSlider::sliderReleased, this, &ImageControl::onSliderBlueReleased);
|
||||
|
||||
// Connect preset buttons
|
||||
connect(ui.btnTrueColor, &QPushButton::clicked, this, &ImageControl::onTrueColorClicked);
|
||||
connect(ui.btnColorInfrared, &QPushButton::clicked, this, &ImageControl::onColorInfraredClicked);
|
||||
|
||||
// Spinbox only commits on Enter, not on every keystroke
|
||||
ui.spinRed->setKeyboardTracking(false);
|
||||
ui.spinGreen->setKeyboardTracking(false);
|
||||
ui.spinBlue->setKeyboardTracking(false);
|
||||
|
||||
ui.groupAdjustments->setStyleSheet(R"(
|
||||
QDoubleSpinBox {
|
||||
border: 1px solid #999;
|
||||
border-radius: 4px;
|
||||
padding: 2px 20px 2px 6px; /* <20>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>ť */
|
||||
background: #0e1c4c;
|
||||
selection-background-color: #0078d7;
|
||||
font-size: 12px;
|
||||
color:#ACCDFF ;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: top right;
|
||||
width: 16px;
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::down-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: bottom right;
|
||||
width: 16px;
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-arrow {
|
||||
image: url(:/svg/resources/icons/svg/arrow_up.svg);
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::down-arrow {
|
||||
image: url(:/svg/resources/icons/svg/arrow_down.svg);
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button:hover,
|
||||
QDoubleSpinBox::down-button:hover {
|
||||
background: #e6f2ff;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button:pressed,
|
||||
QDoubleSpinBox::down-button:pressed {
|
||||
background: #cce4ff;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
ImageControl::~ImageControl()
|
||||
{
|
||||
}
|
||||
|
||||
void ImageControl::setActiveLayer(RasterLayer* layer)
|
||||
{
|
||||
m_activeLayer = layer;
|
||||
|
||||
if (!layer) {
|
||||
setEnabled(false);
|
||||
m_wavelengths.clear();
|
||||
return;
|
||||
}
|
||||
setEnabled(true);
|
||||
|
||||
// Get band wavelengths from the layer's header
|
||||
m_wavelengths = layer->bandWavelengths();
|
||||
std::sort(m_wavelengths.begin(), m_wavelengths.end());
|
||||
|
||||
if (m_wavelengths.empty()) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_minWave = m_wavelengths.front();
|
||||
m_maxWave = m_wavelengths.back();
|
||||
|
||||
// Compute spinbox step as the average wavelength interval between adjacent bands
|
||||
double step = 1.0;
|
||||
if (m_wavelengths.size() >= 2) {
|
||||
step = (m_maxWave - m_minWave) / (m_wavelengths.size() - 1);
|
||||
}
|
||||
|
||||
blockAllSignals(true);
|
||||
|
||||
// Configure spinbox ranges and step
|
||||
ui.spinRed->setMinimum(m_minWave);
|
||||
ui.spinRed->setMaximum(m_maxWave);
|
||||
ui.spinRed->setSingleStep(step);
|
||||
ui.spinGreen->setMinimum(m_minWave);
|
||||
ui.spinGreen->setMaximum(m_maxWave);
|
||||
ui.spinGreen->setSingleStep(step);
|
||||
ui.spinBlue->setMinimum(m_minWave);
|
||||
ui.spinBlue->setMaximum(m_maxWave);
|
||||
ui.spinBlue->setSingleStep(step);
|
||||
|
||||
// Slider now represents band index (0 .. N-1), step = 1
|
||||
int maxIdx = static_cast<int>(m_wavelengths.size()) - 1;
|
||||
ui.sliderRed->setMinimum(0);
|
||||
ui.sliderRed->setMaximum(maxIdx);
|
||||
ui.sliderRed->setSingleStep(1);
|
||||
ui.sliderRed->setPageStep(1);
|
||||
ui.sliderGreen->setMinimum(0);
|
||||
ui.sliderGreen->setMaximum(maxIdx);
|
||||
ui.sliderGreen->setSingleStep(1);
|
||||
ui.sliderGreen->setPageStep(1);
|
||||
ui.sliderBlue->setMinimum(0);
|
||||
ui.sliderBlue->setMaximum(maxIdx);
|
||||
ui.sliderBlue->setSingleStep(1);
|
||||
ui.sliderBlue->setPageStep(1);
|
||||
|
||||
// Set current values from layer's render params
|
||||
auto params = layer->currentRenderParams();
|
||||
|
||||
int rIdx = nearestBandIndex(params.rWave);
|
||||
int gIdx = nearestBandIndex(params.gWave);
|
||||
int bIdx = nearestBandIndex(params.bWave);
|
||||
|
||||
ui.spinRed->setValue(m_wavelengths[rIdx]);
|
||||
ui.spinGreen->setValue(m_wavelengths[gIdx]);
|
||||
ui.spinBlue->setValue(m_wavelengths[bIdx]);
|
||||
|
||||
ui.sliderRed->setValue(rIdx);
|
||||
ui.sliderGreen->setValue(gIdx);
|
||||
ui.sliderBlue->setValue(bIdx);
|
||||
|
||||
blockAllSignals(false);
|
||||
}
|
||||
|
||||
RasterLayer* ImageControl::activeLayer() const
|
||||
{
|
||||
return m_activeLayer;
|
||||
}
|
||||
|
||||
int ImageControl::nearestBandIndex(double wave) const
|
||||
{
|
||||
if (m_wavelengths.empty()) return 0;
|
||||
int best = 0;
|
||||
double bestDiff = std::abs(m_wavelengths[0] - wave);
|
||||
for (int i = 1; i < static_cast<int>(m_wavelengths.size()); ++i) {
|
||||
double d = std::abs(m_wavelengths[i] - wave);
|
||||
if (d < bestDiff) {
|
||||
bestDiff = d;
|
||||
best = i;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
void ImageControl::setControlsToBandIndex(QDoubleSpinBox* spin, QSlider* slider, int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= static_cast<int>(m_wavelengths.size())) return;
|
||||
double wv = m_wavelengths[idx];
|
||||
spin->blockSignals(true);
|
||||
spin->setValue(wv);
|
||||
spin->blockSignals(false);
|
||||
slider->blockSignals(true);
|
||||
slider->setValue(idx);
|
||||
slider->blockSignals(false);
|
||||
}
|
||||
|
||||
// --- Spinbox valueChanged: snap to nearest band, sync slider, no render ---
|
||||
|
||||
void ImageControl::onSpinRedValueChanged(double val)
|
||||
{
|
||||
int idx = nearestBandIndex(val);
|
||||
ui.sliderRed->blockSignals(true);
|
||||
ui.sliderRed->setValue(idx);
|
||||
ui.sliderRed->blockSignals(false);
|
||||
}
|
||||
|
||||
void ImageControl::onSpinGreenValueChanged(double val)
|
||||
{
|
||||
int idx = nearestBandIndex(val);
|
||||
ui.sliderGreen->blockSignals(true);
|
||||
ui.sliderGreen->setValue(idx);
|
||||
ui.sliderGreen->blockSignals(false);
|
||||
}
|
||||
|
||||
void ImageControl::onSpinBlueValueChanged(double val)
|
||||
{
|
||||
int idx = nearestBandIndex(val);
|
||||
ui.sliderBlue->blockSignals(true);
|
||||
ui.sliderBlue->setValue(idx);
|
||||
ui.sliderBlue->blockSignals(false);
|
||||
}
|
||||
|
||||
// --- Slider valueChanged: map band index to wavelength, sync spinbox, no render ---
|
||||
|
||||
void ImageControl::onSliderRedValueChanged(int val)
|
||||
{
|
||||
if (val < 0 || val >= static_cast<int>(m_wavelengths.size())) return;
|
||||
ui.spinRed->blockSignals(true);
|
||||
ui.spinRed->setValue(m_wavelengths[val]);
|
||||
ui.spinRed->blockSignals(false);
|
||||
}
|
||||
|
||||
void ImageControl::onSliderGreenValueChanged(int val)
|
||||
{
|
||||
if (val < 0 || val >= static_cast<int>(m_wavelengths.size())) return;
|
||||
ui.spinGreen->blockSignals(true);
|
||||
ui.spinGreen->setValue(m_wavelengths[val]);
|
||||
ui.spinGreen->blockSignals(false);
|
||||
}
|
||||
|
||||
void ImageControl::onSliderBlueValueChanged(int val)
|
||||
{
|
||||
if (val < 0 || val >= static_cast<int>(m_wavelengths.size())) return;
|
||||
ui.spinBlue->blockSignals(true);
|
||||
ui.spinBlue->setValue(m_wavelengths[val]);
|
||||
ui.spinBlue->blockSignals(false);
|
||||
}
|
||||
|
||||
// --- Spinbox editingFinished: snap to nearest band wavelength, then commit ---
|
||||
|
||||
void ImageControl::onSpinRedEditingFinished()
|
||||
{
|
||||
int idx = nearestBandIndex(ui.spinRed->value());
|
||||
setControlsToBandIndex(ui.spinRed, ui.sliderRed, idx);
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
void ImageControl::onSpinGreenEditingFinished()
|
||||
{
|
||||
int idx = nearestBandIndex(ui.spinGreen->value());
|
||||
setControlsToBandIndex(ui.spinGreen, ui.sliderGreen, idx);
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
void ImageControl::onSpinBlueEditingFinished()
|
||||
{
|
||||
int idx = nearestBandIndex(ui.spinBlue->value());
|
||||
setControlsToBandIndex(ui.spinBlue, ui.sliderBlue, idx);
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
// --- Slider sliderReleased: commit on mouse release ---
|
||||
|
||||
void ImageControl::onSliderRedReleased()
|
||||
{
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
void ImageControl::onSliderGreenReleased()
|
||||
{
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
void ImageControl::onSliderBlueReleased()
|
||||
{
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
// --- Preset buttons ---
|
||||
|
||||
void ImageControl::onTrueColorClicked()
|
||||
{
|
||||
blockAllSignals(true);
|
||||
int rIdx = nearestBandIndex(665.0);
|
||||
int gIdx = nearestBandIndex(560.0);
|
||||
int bIdx = nearestBandIndex(490.0);
|
||||
setControlsToBandIndex(ui.spinRed, ui.sliderRed, rIdx);
|
||||
setControlsToBandIndex(ui.spinGreen, ui.sliderGreen, gIdx);
|
||||
setControlsToBandIndex(ui.spinBlue, ui.sliderBlue, bIdx);
|
||||
blockAllSignals(false);
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
void ImageControl::onColorInfraredClicked()
|
||||
{
|
||||
blockAllSignals(true);
|
||||
int rIdx = nearestBandIndex(800.0);
|
||||
int gIdx = nearestBandIndex(665.0);
|
||||
int bIdx = nearestBandIndex(560.0);
|
||||
setControlsToBandIndex(ui.spinRed, ui.sliderRed, rIdx);
|
||||
setControlsToBandIndex(ui.spinGreen, ui.sliderGreen, gIdx);
|
||||
setControlsToBandIndex(ui.spinBlue, ui.sliderBlue, bIdx);
|
||||
blockAllSignals(false);
|
||||
emitBandChange();
|
||||
}
|
||||
|
||||
void ImageControl::emitBandChange()
|
||||
{
|
||||
double r = ui.spinRed->value();
|
||||
double g = ui.spinGreen->value();
|
||||
double b = ui.spinBlue->value();
|
||||
|
||||
// Update active layer's stored render params
|
||||
if (m_activeLayer) {
|
||||
auto params = m_activeLayer->currentRenderParams();
|
||||
params.rWave = r;
|
||||
params.gWave = g;
|
||||
params.bWave = b;
|
||||
m_activeLayer->setCurrentRenderParams(params);
|
||||
}
|
||||
|
||||
emit bandSelectionChanged(r, g, b);
|
||||
}
|
||||
|
||||
void ImageControl::blockAllSignals(bool block)
|
||||
{
|
||||
ui.spinRed->blockSignals(block);
|
||||
ui.spinGreen->blockSignals(block);
|
||||
ui.spinBlue->blockSignals(block);
|
||||
ui.sliderRed->blockSignals(block);
|
||||
ui.sliderGreen->blockSignals(block);
|
||||
ui.sliderBlue->blockSignals(block);
|
||||
}
|
||||
69
HPPA/imageControl.h
Normal file
69
HPPA/imageControl.h
Normal file
@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <vector>
|
||||
|
||||
#include "ui_imgControl.h"
|
||||
|
||||
class RasterLayer;
|
||||
|
||||
class ImageControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImageControl(QWidget* parent = nullptr);
|
||||
~ImageControl();
|
||||
|
||||
// Populate controls from a RasterLayer's wavelength info and current render params
|
||||
void setActiveLayer(RasterLayer* layer);
|
||||
RasterLayer* activeLayer() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
// Emitted when user changes any of the R/G/B wavelength values
|
||||
void bandSelectionChanged(double rWave, double gWave, double bWave);
|
||||
|
||||
private Q_SLOTS:
|
||||
// Sync slider position while dragging spinbox (no render)
|
||||
void onSpinRedValueChanged(double val);
|
||||
void onSpinGreenValueChanged(double val);
|
||||
void onSpinBlueValueChanged(double val);
|
||||
|
||||
// Sync spinbox display while dragging slider (no render)
|
||||
void onSliderRedValueChanged(int val);
|
||||
void onSliderGreenValueChanged(int val);
|
||||
void onSliderBlueValueChanged(int val);
|
||||
|
||||
// Commit: spinbox Enter key pressed / focus lost
|
||||
void onSpinRedEditingFinished();
|
||||
void onSpinGreenEditingFinished();
|
||||
void onSpinBlueEditingFinished();
|
||||
|
||||
// Commit: slider mouse released
|
||||
void onSliderRedReleased();
|
||||
void onSliderGreenReleased();
|
||||
void onSliderBlueReleased();
|
||||
|
||||
void onTrueColorClicked();
|
||||
void onColorInfraredClicked();
|
||||
|
||||
private:
|
||||
void emitBandChange();
|
||||
void blockAllSignals(bool block);
|
||||
|
||||
// Find the band index whose wavelength is closest to the given value
|
||||
int nearestBandIndex(double wave) const;
|
||||
// Set spinbox and slider to wavelength of the given band index
|
||||
void setControlsToBandIndex(QDoubleSpinBox* spin, QSlider* slider, int idx);
|
||||
|
||||
Ui::ImageControl ui;
|
||||
RasterLayer* m_activeLayer = nullptr;
|
||||
double m_minWave = 374.5;
|
||||
double m_maxWave = 948.1;
|
||||
std::vector<double> m_wavelengths; // band wavelengths from header
|
||||
};
|
||||
294
HPPA/imgControl.ui
Normal file
294
HPPA/imgControl.ui
Normal file
@ -0,0 +1,294 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImageControl</class>
|
||||
<widget class="QWidget" name="ImageControl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>520</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Color Adjust</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox
|
||||
{
|
||||
border: 12px solid transparent;
|
||||
/*border-top: 12px solid transparent;
|
||||
border-right: 0px solid transparent;
|
||||
border-bottom: 0px solid transparent;
|
||||
border-left: 0px solid transparent;*/
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 10pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
height: 10px;
|
||||
background: #1e2a44;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 已滑过:渐变蓝 */
|
||||
QSlider::sub-page:horizontal {
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1f4fff,
|
||||
stop:0.5 #2f6bff,
|
||||
stop:1 #5fa0ff
|
||||
);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 未滑过 */
|
||||
QSlider::add-page:horizontal {
|
||||
height: 10px;
|
||||
background: #2a3550;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* ===== 滑块按钮 ===== */
|
||||
QSlider::handle:horizontal {
|
||||
width: 15px;
|
||||
height: 10px;
|
||||
|
||||
/* 蓝色实心 */
|
||||
background: #2f6bff;
|
||||
|
||||
/* 白色外圈 */
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 5px;
|
||||
|
||||
/* 垂直居中 */
|
||||
margin: -5px 0;
|
||||
}
|
||||
|
||||
/* 悬停 */
|
||||
QSlider::handle:horizontal:hover {
|
||||
background: #4d8dff;
|
||||
}
|
||||
|
||||
/* 按下 */
|
||||
QSlider::handle:horizontal:pressed {
|
||||
background: #1f4fff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupAdjustments">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color: #ACCDFF;
|
||||
font-size: 14px;
|
||||
font: 9pt "Adobe Devanagari";
|
||||
}</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>调整</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelRed">
|
||||
<property name="text">
|
||||
<string>红</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinRed">
|
||||
<property name="minimum">
|
||||
<double>374.500000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>948.100000000000023</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>643.100000000000023</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSlider" name="sliderRed">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="labelRedNm">
|
||||
<property name="text">
|
||||
<string>nm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelGreen">
|
||||
<property name="text">
|
||||
<string>绿</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinGreen">
|
||||
<property name="minimum">
|
||||
<double>374.500000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>948.100000000000023</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>548.799999999999955</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSlider" name="sliderGreen">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="labelGreenNm">
|
||||
<property name="text">
|
||||
<string>nm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelBlue">
|
||||
<property name="text">
|
||||
<string>蓝</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinBlue">
|
||||
<property name="minimum">
|
||||
<double>374.500000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>948.100000000000023</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>461.600000000000023</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSlider" name="sliderBlue">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="labelBlueNm">
|
||||
<property name="text">
|
||||
<string>nm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupPresets">
|
||||
<property name="title">
|
||||
<string>预设</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btnTrueColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>真彩色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="btnColorInfrared">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>假彩色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -6,217 +6,313 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>346</height>
|
||||
<width>678</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>一轴马达控制</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>实时位置</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>运行速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>返回速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="realTimeLoc_lineEdit">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="speed_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0.1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="return_speed_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="move2loc_lineEdit">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="connect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="zero_start_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>归零</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="move2loc_pushButton">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;
|
||||
font: 19pt "新宋体";*/
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
QLabel
|
||||
{
|
||||
color: #ACCDFF;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QLineEdit {
|
||||
background-color: #142D7F;
|
||||
color: #e6eeff;
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
padding: 4px 8px;
|
||||
min-width: 70px;
|
||||
min-height: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
QLineEdit:hover {
|
||||
border: 1px solid #4d8dff;
|
||||
}
|
||||
|
||||
QLineEdit:focus {
|
||||
border: 1px solid #6aa2ff;
|
||||
background-color: #23345c;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="1,3,1" columnstretch="1,3,1">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>87</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>161</width>
|
||||
<width>127</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>实时位置</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="realTimeLoc_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="connect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>运行速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="speed_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0.1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="zero_start_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>归零</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>返回速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="return_speed_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="move2loc_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="move2loc_pushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="left_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -226,10 +322,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="right_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -239,41 +335,64 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="motor_state_label">
|
||||
<property name="text">
|
||||
<string>马达状态</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="5" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>状态</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="motor_state_label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: red;
|
||||
border-radius: 4px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>127</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>191</height>
|
||||
<height>87</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
||||
57
HPPA/recordFrameCounter.cpp
Normal file
57
HPPA/recordFrameCounter.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "stdafx.h"
|
||||
#include "recordFrameCounter.h"
|
||||
|
||||
recordFrameCounter::recordFrameCounter(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_stackedWidget = new QStackedWidget();
|
||||
m_stackedWidget->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QLabel* titleLabel = new QLabel(QString::fromLocal8Bit("帧数: "));
|
||||
titleLabel->setStyleSheet("color: white;");
|
||||
layout->addWidget(titleLabel);
|
||||
layout->addWidget(m_stackedWidget);
|
||||
}
|
||||
|
||||
void recordFrameCounter::addCounter(QWidget* tabWidget)
|
||||
{
|
||||
QLabel* label = new QLabel("0");
|
||||
label->setStyleSheet("color: white;");
|
||||
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
m_labelMap.insert(tabWidget, label);
|
||||
m_stackedWidget->addWidget(label);
|
||||
m_stackedWidget->setCurrentWidget(label);
|
||||
}
|
||||
|
||||
void recordFrameCounter::removeCounter(QWidget* tabWidget)
|
||||
{
|
||||
auto it = m_labelMap.find(tabWidget);
|
||||
if (it != m_labelMap.end())
|
||||
{
|
||||
QLabel* label = it.value();
|
||||
m_stackedWidget->removeWidget(label);
|
||||
delete label;
|
||||
m_labelMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void recordFrameCounter::switchTo(QWidget* tabWidget)
|
||||
{
|
||||
auto it = m_labelMap.find(tabWidget);
|
||||
if (it != m_labelMap.end())
|
||||
{
|
||||
m_stackedWidget->setCurrentWidget(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
void recordFrameCounter::updateFrameCount(QWidget* tabWidget, int frameCount)
|
||||
{
|
||||
auto it = m_labelMap.find(tabWidget);
|
||||
if (it != m_labelMap.end())
|
||||
{
|
||||
it.value()->setText(QString::number(frameCount));
|
||||
}
|
||||
}
|
||||
24
HPPA/recordFrameCounter.h
Normal file
24
HPPA/recordFrameCounter.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMap>
|
||||
|
||||
class recordFrameCounter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit recordFrameCounter(QWidget* parent = nullptr);
|
||||
|
||||
void addCounter(QWidget* tabWidget);
|
||||
void removeCounter(QWidget* tabWidget);
|
||||
void switchTo(QWidget* tabWidget);
|
||||
void updateFrameCount(QWidget* tabWidget, int frameCount);
|
||||
|
||||
private:
|
||||
QStackedWidget* m_stackedWidget = nullptr;
|
||||
QMap<QWidget*, QLabel*> m_labelMap;
|
||||
};
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
// Microsoft Visual C++ <20><><EFBFBD>ɵİ<C9B5><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
// <20><> HPPA.rc ʹ<><CAB9>
|
||||
//
|
||||
#define IDI_ICON1 101
|
||||
#define IDI_ICON1 106
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_RESOURCE_VALUE 107
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
|
||||
1011
HPPA/twoMotorControl.ui
Normal file
1011
HPPA/twoMotorControl.ui
Normal file
File diff suppressed because it is too large
Load Diff
@ -112,6 +112,24 @@ std::string removeFileExtension(std::string filename)
|
||||
|
||||
}
|
||||
|
||||
// 从绝对路径中提取文件名(不包含扩展名)
|
||||
std::string getFileNameFromPath(const std::string &fullPath)
|
||||
{
|
||||
// 找到最后一个路径分隔符,支持 '/' 和 '\\'
|
||||
size_t lastSlash = fullPath.find_last_of("/\\");
|
||||
size_t start = (lastSlash == std::string::npos) ? 0 : lastSlash + 1;
|
||||
|
||||
// 找到最后一个点,确保点在文件名范围内
|
||||
size_t lastDot = fullPath.find_last_of('.');
|
||||
if (lastDot == std::string::npos || lastDot < start) {
|
||||
// 没有扩展名或点在路径之前,直接返回从 start 到结尾的子串
|
||||
return fullPath.substr(start);
|
||||
}
|
||||
|
||||
// 返回从 start 到 lastDot 之间的文件名(不含扩展名)
|
||||
return fullPath.substr(start, lastDot - start);
|
||||
}
|
||||
|
||||
QList<QString> getFileInfo(QString file)
|
||||
{
|
||||
QFileInfo fileInfo = QFileInfo(file);
|
||||
|
||||
@ -20,6 +20,7 @@ void swap(unsigned short * a, unsigned short * b);
|
||||
|
||||
bool createDir(QString fullPath);
|
||||
std::string removeFileExtension(std::string filename);
|
||||
std::string getFileNameFromPath(const std::string& fullPath);
|
||||
|
||||
QList<QString> getFileInfo(QString file);
|
||||
|
||||
|
||||
43
cfg_file_backup/HPPA.cfg
Normal file
43
cfg_file_backup/HPPA.cfg
Normal file
@ -0,0 +1,43 @@
|
||||
SN = "2004";
|
||||
autoFocus :
|
||||
{
|
||||
PositionRestriction :
|
||||
{
|
||||
max = 1000;
|
||||
min = 120;
|
||||
};
|
||||
TuningStepSize :
|
||||
{
|
||||
coarse = 10;
|
||||
fine = 2;
|
||||
};
|
||||
FitParams :
|
||||
{
|
||||
fa = 0.0017;
|
||||
fb = 0.3277;
|
||||
};
|
||||
AutoFocusRange :
|
||||
{
|
||||
max = 688;
|
||||
min = 144;
|
||||
};
|
||||
};
|
||||
motionPlatform :
|
||||
{
|
||||
x :
|
||||
{
|
||||
StepAnglemar = 1.8;
|
||||
Lead = 1.0;
|
||||
SubdivisionMultiples = 8;
|
||||
ScaleFactor = 1.0;
|
||||
MaxRange = 30.742266;
|
||||
};
|
||||
y :
|
||||
{
|
||||
StepAnglemar = 1.8;
|
||||
Lead = 1.0;
|
||||
SubdivisionMultiples = 8;
|
||||
ScaleFactor = 1.0;
|
||||
MaxRange = 31.283163;
|
||||
};
|
||||
};
|
||||
60
cfg_file_backup/oneMotorConfigFile.cfg
Normal file
60
cfg_file_backup/oneMotorConfigFile.cfg
Normal file
@ -0,0 +1,60 @@
|
||||
SN = "0";
|
||||
motors :
|
||||
{
|
||||
motor1 :
|
||||
{
|
||||
platformParams :
|
||||
{
|
||||
hardwareParams :
|
||||
{
|
||||
StepAngle = 1.8;
|
||||
Lead = 4.0;
|
||||
ScaleFactor = 1.0;
|
||||
};
|
||||
runParams :
|
||||
{
|
||||
RecordSpeed = 1.8;
|
||||
MoveSpeed = 1.8;
|
||||
ReturnSpeed = 1.8;
|
||||
MaxRange = 120.0;
|
||||
};
|
||||
};
|
||||
motorParams :
|
||||
{
|
||||
Manufacturer = 0;
|
||||
CommunicationProtocol = 0;
|
||||
connectionParams :
|
||||
{
|
||||
SerialPortNumber = "COM10";
|
||||
BaudRate = 9600;
|
||||
};
|
||||
initParams :
|
||||
{
|
||||
limit :
|
||||
{
|
||||
msr = 1;
|
||||
msv = 0;
|
||||
psr = 2;
|
||||
psv = 0;
|
||||
};
|
||||
other :
|
||||
{
|
||||
acc = 20000.0;
|
||||
cra = 4.0;
|
||||
crh = 1.0;
|
||||
crn = 4.0;
|
||||
dec = 20000.0;
|
||||
mcs = 7;
|
||||
};
|
||||
zeroStart :
|
||||
{
|
||||
osv = 0;
|
||||
snr = 0;
|
||||
zmd = 2;
|
||||
zsd = 3000;
|
||||
zsp = 2400;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
60
cfg_file_backup/oneMotorConfigFile_focus.cfg
Normal file
60
cfg_file_backup/oneMotorConfigFile_focus.cfg
Normal file
@ -0,0 +1,60 @@
|
||||
SN = "0";
|
||||
motors :
|
||||
{
|
||||
motor1 :
|
||||
{
|
||||
platformParams :
|
||||
{
|
||||
hardwareParams :
|
||||
{
|
||||
StepAngle = 1.8;
|
||||
Lead = 1.37;
|
||||
ScaleFactor = 1.0;
|
||||
};
|
||||
runParams :
|
||||
{
|
||||
RecordSpeed = 1.0;
|
||||
MoveSpeed = 1.0;
|
||||
ReturnSpeed = 1.0;
|
||||
MaxRange = 11.559696;
|
||||
};
|
||||
};
|
||||
motorParams :
|
||||
{
|
||||
Manufacturer = 0;
|
||||
CommunicationProtocol = 1;
|
||||
connectionParams :
|
||||
{
|
||||
SerialPortNumber = "COM10";
|
||||
BaudRate = 9600;
|
||||
};
|
||||
initParams :
|
||||
{
|
||||
limit :
|
||||
{
|
||||
msr = 1;
|
||||
msv = 1;
|
||||
psr = 2;
|
||||
psv = 1;
|
||||
};
|
||||
other :
|
||||
{
|
||||
acc = 19200.0;
|
||||
cra = 0.2;
|
||||
crh = 0.0;
|
||||
crn = 0.2;
|
||||
dec = 19200.0;
|
||||
mcs = 6;
|
||||
};
|
||||
zeroStart :
|
||||
{
|
||||
osv = 1;
|
||||
snr = 0;
|
||||
zmd = 1;
|
||||
zsd = 4000;
|
||||
zsp = 2400;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user