Files
HPPA/HPPA/QMotorDoubleSlider.cpp
tangchao0503 6469bff15d fix & add
1、在界面上实现选择相机类型的功能;
2、创建了一个光谱仪操作的纯虚基类(ImagerOperationBase)并实现了大部分的操作,具体类型的光谱仪应继承此类并实现纯虚函数;
3、添加了 resonon 的 nir 320 相机,修改 resonon 的 pica l 相机的实现:继承 ImagerOperationBase;
4、重构类 QMotorDoubleSlider,提高其通用性,所有马达相关的 slider 都使用此类;
5、适配 resonon nir 320 显微镜使用的 2 轴线性平台,有些特殊的马达参数设置(setMotorParamMicroscope 函数)绑定了 nir 的相机类型参数;
6、修改:将线性平台的量程信息保存在cfg配置文件中,并修改配置文件读写类来读写此量程信息;
2024-12-11 17:33:29 +08:00

94 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stdafx.h"
#include "QMotorDoubleSlider.h"
QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
{
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
setSingleStep(1);
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
m_Multiplier = 0;
}
void QMotorDoubleSlider::setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionMultiples)
{
//根据公式将脉冲换算为距离1脉冲距离(m_Multiplier)=导程/(360/步距角*细分倍数)网址https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
//m_Multiplier(0.00054496986),//上海农科院修改前0.00052734375/5=0.00010546875修改后准确值为0.000544969862759644近似为0.00054496986/5=0.000108993972因为有个机械装置1脉冲距离需要除以5
//m_Multiplier(0.00054496986)//兴安盟农研所
m_Multiplier = lead / (360 / stepAnglemar * subdivisionMultiples) * scaleFactor;
}
//向外发射
void QMotorDoubleSlider::notifyValueChanged(int Value)
{
emit valueChanged((double)Value * m_Multiplier);//////////
}
//接收外边
void QMotorDoubleSlider::setValue(double Value, bool BlockSignals)
{
QSlider::blockSignals(BlockSignals);
QSlider::setValue(Value / m_Multiplier);////////////
if (!BlockSignals)
emit valueChanged(Value);
QSlider::blockSignals(false);
}
void QMotorDoubleSlider::setRange(double Min, double Max)
{
QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
emit rangeChanged(Min, Max);
}
void QMotorDoubleSlider::setMinimum(double Min)
{
QSlider::setMinimum(Min / m_Multiplier);//////
emit rangeChanged(minimum(), maximum());
}
double QMotorDoubleSlider::minimum() const
{
return QSlider::minimum() * m_Multiplier;/////
}
void QMotorDoubleSlider::setMaximum(double Max)
{
QSlider::setMaximum(Max / m_Multiplier);//////
emit rangeChanged(minimum(), maximum());
}
double QMotorDoubleSlider::maximum() const
{
return QSlider::maximum() * m_Multiplier;///////
}
double QMotorDoubleSlider::value() const
{
int Value = QSlider::value();
return (double)Value * m_Multiplier;//////
}
double QMotorDoubleSlider::OriginalValue() const
{
int Value = QSlider::value();
return (double)Value;
}
long QMotorDoubleSlider::getPositionPulse(double position)
{
return position / m_Multiplier;
}
double QMotorDoubleSlider::getDistanceFromPulse(int pulse)
{
return pulse * m_Multiplier;
}