#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ui_HPPA.h" #include "resononImager.h" #include "ImageViewer.h" #include "vincecontrol.h" #include "ImagerPositionSimulation.h" #include "fileOperation.h" #include "RgbCameraOperation.h" #include "imageProcessor.h" #include "fileOperation.h" #include "focusWindow.h" #include "aboutWindow.h" #include "adjustTable.h" #include "PowerControl.h" #include "RobotArmControl.h" #include "OneMotorControl.h" #include "TwoMotorControl.h" #include "imageControl.h" #include "hppaConfigFile.h" #include "path_tc.h" #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" #include "setWindow.h" #include "AppSettings.h" #include "FileNameLineEdit.h" #include "rgbCameraWindow.h" #include "DepthCameraWindow.h" #include "SingleLensReflexCameraWindow.h" #include "LayerTreeImageNode.h" #define PI 3.1415926 QT_CHARTS_USE_NAMESPACE//QChartView 使用 需要加宏, 否则无法使用 class WorkerThread : public QThread { Q_OBJECT private: public: ImagerOperationBase*m_Imager; WorkerThread(ImagerOperationBase* Imager) { m_Imager = Imager; } //void run() override //{ // while (true) // { // try // { // //double x = m_Imager->get_framerate(); // // //double x = m_Imager->m_ResononImager.get_framerate(); // int x = m_Imager->m_ResononImager.get_band_count(); // std::cout << "相机连接正常!slope为:" << x << std::endl; // } // catch (std::runtime_error *e)//CException *e // { // std::cout << "相机断开连接!" << e->what() << std::endl; // } // Sleep(1000); // } // QString result; // emit resultReady(result); //} signals: void resultReady(const QString &s); }; class WorkerThread3 : public QThread { Q_OBJECT private: public: WorkerThread3(CFocusMotorControl * ctrlFocusMotor); CFocusMotorControl *m_ctrlFocusMotor; protected: void run(); signals: void AutoFocusFinishedSignal(); }; class myClocks : public QThread { Q_OBJECT public: myClocks(QObject *parent = 0); public: void setCallback(void(*func)(QString)); protected: virtual void run(); private: std::function m_func; signals: void threadSignal(QString s); }; class WidgetWithBackgroundPicture : public QWidget { Q_OBJECT public: 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: QPixmap m_pixmap; }; class HPPA : public QMainWindow { Q_OBJECT public: HPPA(QWidget *parent = Q_NULLPTR); ~HPPA(); static HPPA* instance(); LayerTreeNode* rasterGroupNode() const; 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; FileNameLineEdit * m_FilenameLineEdit; QLabel * xmotor_state_label1; QLabel * ymotor_state_label1; Configfile mConfigfile; ImagerOperationBase* m_Imager;// int m_RecordState;//用来控制相机采集流程,取2的余数,1 → 正在采集,0 → 停止采集 QThread * m_RecordThread;//影像采集线程 QThread * m_CopyFileThread;//影像文件复制线程 FileOperation * m_FileOperation; QChartView * m_chartView; QChart* m_chart; //QLineSeries *series; //QChart *chart; QString operateWidget;//当前操作的控件名 //模拟相机位置 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); //采集线规划 int m_numberOfRecording;//表示ui.recordLine_tableWidget中的第几行 → 正在采集第几条线 // int m_TabWidgetCurrentIndex;//当手动选择TabWidget的标签时,记录变化后的tab index void getRequest(QString str); QActionGroup* mImagerGroup = nullptr; void createActionGroups(); void selectingImager(QAction* selectedAction); void updateImagerPicture(const QString& actionName); QActionGroup* moveplatformActionGroup = nullptr; void createMoveplatformActionGroup(); void selectingMoveplatform(QAction* selectedAction); QActionGroup* m_ScenarioActionGroup = nullptr; void createScenarioActionGroup(); void selectScenario(QAction* selectedAction); FILE* m_hTimesFile; CustomDockWidgetBase* m_dock_carousel; MyCarousel* m_carousel; QLabel* m_cam_label; QLabel* m_depthCamera_label; QPushButton* m_open_rgb_camera_btn; QPushButton* m_close_rgb_camera_btn; TabManager* m_tabManager; HyperImagerControl* m_hic; rgbCameraWindow* m_rgbCameraControlWindow; ImageControl* m_ic; DepthCameraWindow* m_depthCameraWindow; SingleLensReflexCameraWindow* m_singleLensReflexCameraWindow; 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; bool testImagerVality(); void showMessageBox(QString msg, QString title= QString::fromLocal8Bit("提示")); bool showResultMessageBox(QString title, QString msg); void disconnectImagerAndCleanup(); public Q_SLOTS: void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath); void focusPlotSpectralImg(int state); void onRecordFinishedSignal_WhenFrameNumberMeet(); void onRecordFinishedSignal_WhenFrameNumberNotMeet(); void onsequenceComplete(); void onExit(); void onOpenImg(); void onconnect();//连接相机 void testImagerStatus();//获取相机状态:连接是否正常 void autoExposureFinished(); void onAutoExposure(); void onFocus1(); void onFocus2(int command); void onFocusWindowClosed(); void onAbout(); void settingWindow(); void onDark(); void recordDarkFinish(); void onReference(); void recordWhiteFinish(); void onStartRecordStep1(); QWidget* onCreateTab(QString tabName); void onTabWidgetCurrentChanged(int index); void onActionOpenDirectory(); void onFramerateChanged(double framerate); void onIntegrationTimeChanged(double integrationTime); void onGainChanged(double gain); void onLeftMouseButtonPressed(int x, int y, QVector wavelengths, QVector spectrum);//点击影像像元显示光谱 void setAxis(QValueAxis* axisX, QValueAxis* axisY); void timerEvent(QTimerEvent *event); // void onimagerSimulatorMove(int x, int y); void OnSendLogToCallClass(QString str); void onPlotRgbImage(); void onPlotDepthImage(); void onClearLabel(); void onClearDepthLabel(); void onCopyFinished(); void requestFinished(QNetworkReply* reply); void recordFromRobotArm(int fileCounter); void createOneMotorScenario(); void createPlantPhenotypeScenario(); void onCreated3DModelPlantPhenotype(); void onCreated3DModelMicroscopicMotion(); void createMicroscopicMotionControlScenario(); void onCreated3DModelOneMotor(); void addLayer(const QString& baseName, const QString& filePath, bool refresh, bool isAddImage = true); void newImage(RasterLayer* ml, RasterImageLayer::RendererType, LayerTreeNode* parent, bool refresh=true); void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex); void removeLayerByTreeIndex(); void showColorImageByTreeIndex(); void removeImageByTreeIndex(); void removeAllLayersInRasterGroup(); 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; signals: void StartFocusSignal(); void StartRecordSignal(); void CopyFileThreadSignal(QString, QString); void RecordWhiteSignal(); void RecordDarlSignal(); void updateRecordingFileInfoSignal(const QString& filePath, const QString& baseName, int frameNumber); };