|
@@ -7,7 +7,7 @@ ControlOperationPage::ControlOperationPage(QWidget* parent)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
- HideLayout(false);
|
|
|
+ InitWnd();
|
|
|
}
|
|
|
|
|
|
ControlOperationPage::~ControlOperationPage()
|
|
@@ -47,21 +47,25 @@ void ControlOperationPage::clearLayout() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ControlOperationPage::on_ZoomUpButton_clicked() {
|
|
|
+void ControlOperationPage::on_ZoomUpButton_clicked()
|
|
|
+{
|
|
|
m_mousePos = ui->Operatewidget->geometry().center();
|
|
|
updateScale(m_scaleFactor * 1.1);
|
|
|
|
|
|
}
|
|
|
|
|
|
-void ControlOperationPage::on_ZoomOutButton_clicked() {
|
|
|
+void ControlOperationPage::on_ZoomOutButton_clicked()
|
|
|
+{
|
|
|
m_mousePos = ui->Operatewidget->geometry().center();
|
|
|
updateScale(m_scaleFactor * 0.9);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 更新缩放比例
|
|
|
-void ControlOperationPage::updateScale(double newScaleFactor) {
|
|
|
- if (newScaleFactor >= 1.0) {
|
|
|
+void ControlOperationPage::updateScale(double newScaleFactor)
|
|
|
+{
|
|
|
+ if (newScaleFactor >= 1.0)
|
|
|
+ {
|
|
|
m_scaleFactor = newScaleFactor;
|
|
|
}
|
|
|
else {
|
|
@@ -72,8 +76,10 @@ void ControlOperationPage::updateScale(double newScaleFactor) {
|
|
|
}
|
|
|
|
|
|
// 应用缩放
|
|
|
-void ControlOperationPage::applyScale() {
|
|
|
- if (m_currentMode == ModeImage) {
|
|
|
+void ControlOperationPage::applyScale()
|
|
|
+{
|
|
|
+ if (m_currentMode == ModeImage)
|
|
|
+ {
|
|
|
// 图片模式:缩放图片
|
|
|
int newWidth = m_currentPixmap.width() * m_scaleFactor;
|
|
|
int newHeight = m_currentPixmap.height() * m_scaleFactor;
|
|
@@ -82,7 +88,8 @@ void ControlOperationPage::applyScale() {
|
|
|
ui->Operatewidget->setPixmapAndPoint(scaledImage, m_previousScaleFactor, m_scaleFactor, m_mousePos);
|
|
|
m_previousScaleFactor = m_scaleFactor;
|
|
|
}
|
|
|
- else if (m_currentMode == ModeView && m_currentView) {
|
|
|
+ else if (m_currentMode == ModeView && m_currentView)
|
|
|
+ {
|
|
|
// View 模式:缩放 view
|
|
|
QTransform transform;
|
|
|
transform.scale(m_scaleFactor, m_scaleFactor);
|
|
@@ -96,11 +103,13 @@ void ControlOperationPage::applyScale() {
|
|
|
}
|
|
|
|
|
|
void ControlOperationPage::handleDoubleClick() {
|
|
|
- if (m_currentMode == ModeImage) {
|
|
|
+ if (m_currentMode == ModeImage)
|
|
|
+ {
|
|
|
QPixmap scaledImage = m_currentPixmap.scaled(m_currentPixmap.width(), m_currentPixmap.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
|
ui->Operatewidget->setPixmap(scaledImage); // 这里传递缩放后的图片
|
|
|
}
|
|
|
- else if (m_currentMode == ModeView && m_currentView) {
|
|
|
+ else if (m_currentMode == ModeView && m_currentView)
|
|
|
+ {
|
|
|
QTransform transform;
|
|
|
transform.scale(1, 1);
|
|
|
m_currentView->setTransform(transform);
|
|
@@ -126,35 +135,51 @@ void ControlOperationPage::updateMaterialWidget(kinds materialWndType)
|
|
|
|
|
|
void ControlOperationPage::KindsofWidget(kinds kind)
|
|
|
{
|
|
|
+ bool isRun = false;
|
|
|
ui->Operatewidget->clearPixmap();
|
|
|
QVBoxLayout* layout = new QVBoxLayout(ui->Operatewidget);
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
m_currentMode = ModeView;
|
|
|
if (kind == wafer_kind)
|
|
|
{
|
|
|
- m_wafer->initFrom(ui->Operatewidget);
|
|
|
- layout->addWidget(m_wafer->view);
|
|
|
- m_currentView = m_wafer->view;
|
|
|
+ if (m_wafer)
|
|
|
+ {
|
|
|
+ isRun = true;
|
|
|
+ m_wafer->initFrom(ui->Operatewidget);
|
|
|
+ layout->addWidget(m_wafer->view);
|
|
|
+ m_currentView = m_wafer->view;
|
|
|
+ }
|
|
|
}
|
|
|
else if (kind == waffle_kind)
|
|
|
{
|
|
|
- m_waffle->initFrom(ui->Operatewidget);
|
|
|
- layout->addWidget(m_waffle->view);
|
|
|
- m_currentView = m_waffle->view;
|
|
|
+ if (m_waffle)
|
|
|
+ {
|
|
|
+ isRun = true;
|
|
|
+ m_waffle->initFrom(ui->Operatewidget);
|
|
|
+ layout->addWidget(m_waffle->view);
|
|
|
+ m_currentView = m_waffle->view;
|
|
|
+ }
|
|
|
}
|
|
|
else if (kind == materialbox_kind)
|
|
|
{
|
|
|
- m_materialbox->initFrom(ui->Operatewidget);
|
|
|
- layout->addWidget(m_materialbox->view);
|
|
|
- m_currentView = m_materialbox->view;
|
|
|
+ if (m_materialbox)
|
|
|
+ {
|
|
|
+ isRun = true;
|
|
|
+ m_materialbox->initFrom(ui->Operatewidget);
|
|
|
+ layout->addWidget(m_materialbox->view);
|
|
|
+ m_currentView = m_materialbox->view;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- ui->Operatewidget->setLayout(layout);
|
|
|
- m_currentMode = ModeView;
|
|
|
-
|
|
|
- m_scaleFactor = 1.0;
|
|
|
- applyScale();
|
|
|
+ if (isRun)
|
|
|
+ {
|
|
|
+ ui->Operatewidget->setLayout(layout);
|
|
|
+ m_currentMode = ModeView;
|
|
|
|
|
|
+ m_scaleFactor = 1.0;
|
|
|
+ applyScale();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ControlOperationPage::setWafer(Wafer* wafer) {
|
|
@@ -176,17 +201,6 @@ void ControlOperationPage::setMaterialBox(MaterialBox* materialbox) {
|
|
|
|
|
|
void ControlOperationPage::initForm()
|
|
|
{
|
|
|
- {
|
|
|
- // 后面在做
|
|
|
- //if (m_pMainCameraBind != nullptr)
|
|
|
- //{
|
|
|
- // DeduplicationBox(ui->axisComboBox, m_pMainCameraBind->m_vecCAxis, 0);
|
|
|
- // DeduplicationBox(ui->axisTypeComboBox, m_pMainCameraBind->m_vecCAxis, 1);
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
connect(ui->Operatewidget, &ImageWidget::sendDoubleClicksignal, this, &ControlOperationPage::handleDoubleClick);
|
|
|
ui->Operatewidget->setMouseTracking(true);
|
|
|
}
|
|
@@ -196,7 +210,8 @@ ImageWidget* ControlOperationPage::getOperatewidget()
|
|
|
return ui->Operatewidget;
|
|
|
}
|
|
|
|
|
|
-void ControlOperationPage::resizeSingleUI() {
|
|
|
+void ControlOperationPage::resizeSingleUI(bool bMax /*= false*/)
|
|
|
+{
|
|
|
ui->DataSources->setGeometry(QRect(20, 20, 400, 32));
|
|
|
ui->Operatewidget->setGeometry(QRect(5, 5, 786, 786));
|
|
|
//ui->line_2->setGeometry(QRect(826, 20, 1, 953));
|
|
@@ -214,6 +229,11 @@ void ControlOperationPage::resizeSingleUI() {
|
|
|
ui->horizontalLayout->setGeometry(QRect(12, 882, 786, 32));
|
|
|
|
|
|
ui->BackGround->setGeometry(QRect(16, 68, 794, 794));
|
|
|
+
|
|
|
+ if (bMax)
|
|
|
+ {
|
|
|
+ ui->Operatewidget->m_nSingleCameraOperationWnd = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ControlOperationPage::resizeChartsAndCamerasUI() {
|
|
@@ -221,11 +241,38 @@ void ControlOperationPage::resizeChartsAndCamerasUI() {
|
|
|
}
|
|
|
|
|
|
|
|
|
+void ControlOperationPage::UpDateCameraBind(CameraBind* pCameraBind)
|
|
|
+{
|
|
|
+ m_pCameraBindCopy = pCameraBind;
|
|
|
+
|
|
|
+ // 有指针了在去刷新
|
|
|
+// if (m_pCameraBindCopy != nullptr)
|
|
|
+// {
|
|
|
+// DeduplicationBox(ui->moduleTypeComboBox, m_pCameraBindCopy->m_vecCAxis, 0);
|
|
|
+// DeduplicationBox(ui->axisTypeComboBox, m_pCameraBindCopy->m_vecCAxis, 1);
|
|
|
+// }
|
|
|
+}
|
|
|
+
|
|
|
void ControlOperationPage::on_switchJoystickBut_clicked()
|
|
|
{
|
|
|
ResetIdleTimer(true);
|
|
|
}
|
|
|
|
|
|
+void ControlOperationPage::MouseMovedSlots(const QPoint& delta)
|
|
|
+{
|
|
|
+ qDebug() << "MouseMovedSlots:" << delta;
|
|
|
+ if (m_pCameraBindCopy)
|
|
|
+ {
|
|
|
+ m_pCameraBindCopy->JCameraMove(0, delta.x(), delta.y());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void ControlOperationPage::RequestCursorMoveSlots(const QPoint& pos)
|
|
|
+{
|
|
|
+ QCursor::setPos(pos);
|
|
|
+}
|
|
|
+
|
|
|
void ControlOperationPage::timerEvent(QTimerEvent* event)
|
|
|
{
|
|
|
int nID = event->timerId();
|
|
@@ -235,6 +282,23 @@ void ControlOperationPage::timerEvent(QTimerEvent* event)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ControlOperationPage::mousePressEvent(QMouseEvent* event)
|
|
|
+{
|
|
|
+ if (event->button() == Qt::LeftButton)
|
|
|
+ {
|
|
|
+ LockMouse(true);
|
|
|
+ }
|
|
|
+ else if (event->button() == Qt::RightButton)
|
|
|
+ {
|
|
|
+ LockMouse(false);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ControlOperationPage::mouseMoveEvent(QMouseEvent* event)
|
|
|
+{
|
|
|
+ int a = 10;
|
|
|
+}
|
|
|
+
|
|
|
void ControlOperationPage::HideLayout(bool bShow)
|
|
|
{
|
|
|
for (int i = 0; i < ui->horizontalLayout->count(); ++i)
|
|
@@ -271,6 +335,71 @@ void ControlOperationPage::ResetIdleTimer(bool bStart /*= false*/)
|
|
|
HideLayout(bStart);
|
|
|
}
|
|
|
|
|
|
+void ControlOperationPage::InitWnd()
|
|
|
+{
|
|
|
+ HideLayout(false);
|
|
|
+
|
|
|
+ this->setMouseTracking(true);
|
|
|
+}
|
|
|
+
|
|
|
+void ControlOperationPage::CreateMouseMonitor(bool isStart)
|
|
|
+{
|
|
|
+ if (isStart)
|
|
|
+ {
|
|
|
+ m_pMousethread = new JMouseMonitorThread(this);
|
|
|
+ connect(m_pMousethread, &JMouseMonitorThread::MouseMovedSlg, this, &ControlOperationPage::MouseMovedSlots);
|
|
|
+ connect(m_pMousethread, &JMouseMonitorThread::RequestCursorMoveSlg, this, &ControlOperationPage::RequestCursorMoveSlots);
|
|
|
+
|
|
|
+ m_pMousethread->start();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_pMousethread->stop();
|
|
|
+ m_pMousethread->wait();
|
|
|
+ delete m_pMousethread;
|
|
|
+ m_pMousethread = nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void ControlOperationPage::LockMouse(bool islockMouse)
|
|
|
+{
|
|
|
+ if (m_pCameraBindCopy)
|
|
|
+ {
|
|
|
+ if (islockMouse)
|
|
|
+ {
|
|
|
+ if (!m_bMouseRun)
|
|
|
+ {
|
|
|
+ CreateMouseMonitor(true);
|
|
|
+ QPoint center = rect().center();
|
|
|
+ QPoint globalCenter = mapToGlobal(center);
|
|
|
+ m_pMousethread->setLockCenter(globalCenter);
|
|
|
+
|
|
|
+ QCursor::setPos(globalCenter);
|
|
|
+ setCursor(Qt::BlankCursor);
|
|
|
+ grabMouse();
|
|
|
+ m_bMouseRun = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (m_bMouseRun)
|
|
|
+ {
|
|
|
+ if (m_pMousethread)
|
|
|
+ {
|
|
|
+ m_pMousethread->unlock();
|
|
|
+ releaseMouse();
|
|
|
+ unsetCursor();
|
|
|
+ QCursor::setPos(mapToGlobal(rect().center()));
|
|
|
+
|
|
|
+ CreateMouseMonitor(false);
|
|
|
+ }
|
|
|
+ m_bMouseRun = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
template<class T>
|
|
|
void ControlOperationPage::DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex)
|
|
|
{
|