2、设置光谱仪帧率、曝光时间、gain; 3、在页面中嵌入了rgb相机图传(通过opencv实现); 4、平台的相机位置模拟、x/y马达的分别控制、x/y马达的量程检测; 5、轨迹规划; 6、加入了张卓的自动调焦模块; 7、加入了自动电源控制;
104 lines
2.2 KiB
C++
104 lines
2.2 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "ImagerPositionSimulation.h"
|
|
|
|
|
|
ImagerPositionSimulation::ImagerPositionSimulation(QWidget *parent) :
|
|
QGraphicsView(parent)
|
|
{
|
|
this->resize(1000, 500);
|
|
|
|
topLeftToLowerRight = nullptr;
|
|
topRightToLowerLeft = nullptr;
|
|
|
|
m_Scene = new QGraphicsScene(this);
|
|
this->setScene(m_Scene);
|
|
|
|
setSceneRect();
|
|
|
|
|
|
imager = new imagerSimulatioin();
|
|
m_Scene->addItem(imager);
|
|
//imager->setPos(-100, -100);
|
|
|
|
QBrush redBrush(Qt::red);
|
|
QPen outlinePen(Qt::black);
|
|
|
|
/*m_rectangle = m_Scene->addRect(0, 0, 100, 100, outlinePen, redBrush);
|
|
m_rectangle->setFlag(QGraphicsRectItem::ItemIsMovable);*/
|
|
|
|
|
|
}
|
|
|
|
ImagerPositionSimulation::~ImagerPositionSimulation()
|
|
{
|
|
|
|
}
|
|
|
|
void ImagerPositionSimulation::setSceneRect()
|
|
{
|
|
QRectF graphicsViewSize = viewport()->rect();
|
|
|
|
m_Scene->setSceneRect(-graphicsViewSize.width(), -graphicsViewSize.height(), graphicsViewSize.width(), graphicsViewSize.height());
|
|
|
|
drawX();
|
|
}
|
|
|
|
QRectF ImagerPositionSimulation::sceneRect()
|
|
{
|
|
return m_Scene->sceneRect();
|
|
}
|
|
|
|
void ImagerPositionSimulation::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
QPoint viewPos = event->pos();
|
|
|
|
|
|
QGraphicsView::mousePressEvent(event);
|
|
}
|
|
|
|
void ImagerPositionSimulation::mouseReleaseEvent(QMouseEvent *event)
|
|
{
|
|
QPoint viewPos = event->pos();
|
|
|
|
////Êä³öÀàÐÍ
|
|
//const type_info &x = typeid(imager);
|
|
//qDebug() << "---------------type_info: " << x.name() << x.raw_name() << x.hash_code();
|
|
|
|
|
|
|
|
//qDebug() << "---------------ImagerPositionSimulation view coordinate: " << viewPos;
|
|
//qDebug() << "---------------ImagerPositionSimulation scene coordinate: " << this->mapToScene(viewPos);
|
|
|
|
|
|
QGraphicsView::mouseReleaseEvent(event);
|
|
}
|
|
|
|
void ImagerPositionSimulation::drawX()
|
|
{
|
|
QRectF rect = m_Scene->sceneRect();
|
|
|
|
QPen outlinePen(Qt::black);
|
|
|
|
if (topLeftToLowerRight == nullptr)
|
|
{
|
|
topLeftToLowerRight = m_Scene->addLine(rect.left(), rect.top(), rect.right(), rect.bottom(), outlinePen);
|
|
}
|
|
else
|
|
{
|
|
topLeftToLowerRight->setLine(rect.left(), rect.top(), rect.right(), rect.bottom());
|
|
}
|
|
|
|
|
|
if (topRightToLowerLeft == nullptr)
|
|
{
|
|
topRightToLowerLeft = m_Scene->addLine(rect.right(), rect.top(), rect.left(), rect.bottom(), outlinePen);
|
|
}
|
|
else
|
|
{
|
|
topRightToLowerLeft->setLine(rect.right(), rect.top(), rect.left(), rect.bottom());
|
|
}
|
|
|
|
|
|
}
|