1、美化:轮播看板+3d模型看板;
2、优化3d模型看板:使用时加载3D模型,避免内存泄漏,使用QStackedWidget进行切换;
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ gdal202.dll
|
|||||||
HPPA类图.drawio
|
HPPA类图.drawio
|
||||||
HPPA - 副本.ui
|
HPPA - 副本.ui
|
||||||
icon
|
icon
|
||||||
|
ignore_*
|
||||||
|
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|||||||
@ -17,35 +17,56 @@ MyCarousel::MyCarousel(QWidget* parent)
|
|||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
layout->addWidget(m_stackedWidget);
|
layout->addWidget(m_stackedWidget);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
m_autoPlayerTimer = new QTimer(this);
|
m_autoPlayerTimer = new QTimer(this);
|
||||||
connect(m_autoPlayerTimer, &QTimer::timeout,
|
connect(m_autoPlayerTimer, &QTimer::timeout,
|
||||||
this, &MyCarousel::slideRight);
|
this, &MyCarousel::slideRight);
|
||||||
|
|
||||||
m_nomalQSS= R"(
|
m_nomalQSS= R"(
|
||||||
QPushButton {
|
QPushButton
|
||||||
background-color: white;
|
{
|
||||||
|
background-color: #FFFFFF;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid white;
|
border: 1px solid #FFFFFF;
|
||||||
}
|
}
|
||||||
QPushButton:hover {
|
QPushButton:checked
|
||||||
background-color: yellow;
|
{
|
||||||
}
|
background-color: #08F8E8;
|
||||||
QPushButton:checked {
|
|
||||||
background-color: blue;
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid blue;
|
border: 1px solid #08F8E8;
|
||||||
}
|
}
|
||||||
)";
|
QPushButton:hover
|
||||||
|
{
|
||||||
m_lockedQSS = R"(
|
|
||||||
QPushButton {
|
|
||||||
background-color: red;
|
background-color: red;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid red;
|
border: 1px solid red;
|
||||||
}
|
}
|
||||||
QPushButton:hover {
|
/*QPushButton:!checked {
|
||||||
background-color: yellow;
|
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;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
}
|
}
|
||||||
|
|||||||
142
HPPA/HPPA.cpp
142
HPPA/HPPA.cpp
@ -123,9 +123,6 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
|
|
||||||
ui.mDockWidgetSimulator->setTile(QString::fromLocal8Bit("3Dģ<EFBFBD><EFBFBD>"));
|
|
||||||
ui.mDockWidgetSpectrometer->setTile(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|
||||||
|
|
||||||
//TOC
|
//TOC
|
||||||
CustomDockWidgetBase* dock_layers = new CustomDockWidgetBase(QString::fromLocal8Bit("layers"), this);
|
CustomDockWidgetBase* dock_layers = new CustomDockWidgetBase(QString::fromLocal8Bit("layers"), this);
|
||||||
dock_layers->setObjectName("mDockLayers");
|
dock_layers->setObjectName("mDockLayers");
|
||||||
@ -293,12 +290,39 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
mPanelMenu->addAction(m_dock_carousel->toggleViewAction());
|
mPanelMenu->addAction(m_dock_carousel->toggleViewAction());
|
||||||
//addDockWidget(Qt::LeftDockWidgetArea, m_dock_carousel);
|
//addDockWidget(Qt::LeftDockWidgetArea, m_dock_carousel);
|
||||||
|
|
||||||
|
QWidget* carouselContainer = new QWidget();
|
||||||
|
carouselContainer->setObjectName("carouselContainer");
|
||||||
|
carouselContainer->setStyleSheet(R"(
|
||||||
|
QWidget #carouselContainer
|
||||||
|
{
|
||||||
|
background-color: #0D1233;
|
||||||
|
|
||||||
|
border-top: 1px solid #2c586b;
|
||||||
|
border-left: 1px solid #2c586b;
|
||||||
|
border-right: 1px solid #2c586b;
|
||||||
|
border-bottom: 1px solid #2c586b;
|
||||||
|
|
||||||
|
border-top-left-radius: 0px;
|
||||||
|
border-top-right-radius: 0px;
|
||||||
|
border-bottom-left-radius: 0px;
|
||||||
|
border-bottom-right-radius: 0px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
QGridLayout* gridLayout_carouselContainer = new QGridLayout(carouselContainer);
|
||||||
|
gridLayout_carouselContainer->setSpacing(0);
|
||||||
|
gridLayout_carouselContainer->setObjectName(QString::fromUtf8("gridLayout_carouselContainer"));
|
||||||
|
gridLayout_carouselContainer->setVerticalSpacing(0);
|
||||||
|
gridLayout_carouselContainer->setContentsMargins(2, 2, 2, 2);
|
||||||
|
|
||||||
|
|
||||||
m_carousel = new MyCarousel();
|
m_carousel = new MyCarousel();
|
||||||
m_carousel->setObjectName(QString::fromUtf8("carousel"));
|
m_carousel->setObjectName(QString::fromUtf8("carousel"));
|
||||||
|
|
||||||
QScrollArea* sa = new QScrollArea();
|
QScrollArea* sa = new QScrollArea();
|
||||||
|
sa->setObjectName("sa");
|
||||||
sa->setStyleSheet(R"(
|
sa->setStyleSheet(R"(
|
||||||
border: none;
|
border: none;
|
||||||
|
background-color: #0D1233;
|
||||||
)");
|
)");
|
||||||
QGridLayout* gridLayout_sa = new QGridLayout(sa);
|
QGridLayout* gridLayout_sa = new QGridLayout(sa);
|
||||||
gridLayout_sa->setSpacing(6);
|
gridLayout_sa->setSpacing(6);
|
||||||
@ -307,33 +331,72 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
gridLayout_sa->setContentsMargins(0, 0, 0, 0);
|
gridLayout_sa->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
m_cam_label = new QLabel();
|
m_cam_label = new QLabel();
|
||||||
|
m_cam_label->setAlignment(Qt::AlignHCenter);
|
||||||
|
m_cam_label->setStyleSheet(R"(
|
||||||
|
background-color: #0D1233;
|
||||||
|
)");
|
||||||
gridLayout_sa->addWidget(m_cam_label);
|
gridLayout_sa->addWidget(m_cam_label);
|
||||||
|
|
||||||
m_carousel->addWidget(sa);
|
m_carousel->addWidget(sa);
|
||||||
m_carousel->addWidget(new QLabel("1"));
|
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||||
//m_carousel->addWidget(new QLabel("2"));
|
|
||||||
//m_carousel->addWidget(new QLabel("3"));
|
QWidget* tmp8 = new QWidget();
|
||||||
//m_carousel->addWidget(new QLabel("4"));
|
tmp8->setStyleSheet(R"(
|
||||||
//m_carousel->addWidget(new QLabel("5"));
|
background-color: #0D1233;
|
||||||
//m_carousel->addWidget(new QLabel("6"));
|
)");
|
||||||
//m_carousel->addWidget(new QLabel("7"));
|
m_carousel->addWidget(tmp8);
|
||||||
//m_carousel->addWidget(new QLabel("8"));
|
//m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||||
//m_carousel->addWidget(new QLabel("9"));
|
|
||||||
//m_carousel->addWidget(new QLabel("10"));
|
|
||||||
//m_carousel->addWidget(new QLabel("11"));
|
|
||||||
//m_carousel->addWidget(new QLabel("12"));
|
|
||||||
//m_carousel->addWidget(new QLabel("13"));
|
|
||||||
//m_carousel->addWidget(new QLabel("14"));
|
|
||||||
//m_carousel->addWidget(new QLabel("15"));
|
|
||||||
//m_carousel->addWidget(new QLabel("16"));
|
|
||||||
m_carousel->play();
|
m_carousel->play();
|
||||||
|
|
||||||
m_dock_carousel->setWidget(m_carousel);
|
gridLayout_carouselContainer->addWidget(m_carousel);
|
||||||
|
|
||||||
|
m_dock_carousel->setWidget(carouselContainer);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD>
|
||||||
|
ui.mDockWidgetSpectrometer->setTile(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||||
|
//ui.mDockWidgetSpectrometer->show();
|
||||||
initControlTabwidget();
|
initControlTabwidget();
|
||||||
m_tabManager = new TabManager(ui.controlTabWidget, this);
|
m_tabManager = new TabManager(ui.controlTabWidget, this);
|
||||||
|
|
||||||
|
//3Dģ<44>Ϳ<EFBFBD><CDBF><EFBFBD>
|
||||||
|
ui.mDockWidgetSimulator->setTile(QString::fromLocal8Bit("3Dģ<EFBFBD><EFBFBD>"));
|
||||||
|
//ui.mDockWidgetSimulator->show();
|
||||||
|
|
||||||
|
m_view3DModelManager = new View3DModelManager(this);
|
||||||
|
|
||||||
|
QWidget* modelWidgetContainer = new QWidget();
|
||||||
|
modelWidgetContainer->setObjectName("modelWidgetContainer");
|
||||||
|
modelWidgetContainer->setStyleSheet(R"(
|
||||||
|
QWidget #modelWidgetContainer
|
||||||
|
{
|
||||||
|
background-color: #0E1C4C;
|
||||||
|
|
||||||
|
border-top: 1px solid #2c586b;
|
||||||
|
border-left: 1px solid #2c586b;
|
||||||
|
border-right: 1px solid #2c586b;
|
||||||
|
border-bottom: 1px solid #2c586b;
|
||||||
|
|
||||||
|
border-top-left-radius: 0px;
|
||||||
|
border-top-right-radius: 0px;
|
||||||
|
border-bottom-left-radius: 10px;
|
||||||
|
border-bottom-right-radius: 10px;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
QGridLayout* gridLayout_modelWidgetContainer = new QGridLayout(modelWidgetContainer);
|
||||||
|
gridLayout_modelWidgetContainer->setSpacing(0);
|
||||||
|
gridLayout_modelWidgetContainer->setObjectName(QString::fromUtf8("gridLayout_modelWidgetContainer"));
|
||||||
|
gridLayout_modelWidgetContainer->setVerticalSpacing(0);
|
||||||
|
gridLayout_modelWidgetContainer->setContentsMargins(2, 2, 2, 2);
|
||||||
|
|
||||||
|
gridLayout_modelWidgetContainer->addWidget(m_view3DModelManager);
|
||||||
|
|
||||||
|
connect(m_view3DModelManager, SIGNAL(created3DModelPlantPhenotype()), this, SLOT(onCreated3DModelPlantPhenotype()));
|
||||||
|
connect(m_view3DModelManager, SIGNAL(created3DModelOneMotor()), this, SLOT(onCreated3DModelOneMotor()));
|
||||||
|
|
||||||
|
ui.mDockWidgetSimulator->setWidget(modelWidgetContainer);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ű<EFBFBD>
|
||||||
splitDockWidget(dock_layers, dock_hyperimgViewer, Qt::Horizontal);
|
splitDockWidget(dock_layers, dock_hyperimgViewer, Qt::Horizontal);
|
||||||
splitDockWidget(dock_hyperimgViewer, m_dock_carousel, Qt::Horizontal);
|
splitDockWidget(dock_hyperimgViewer, m_dock_carousel, Qt::Horizontal);
|
||||||
|
|
||||||
@ -344,10 +407,7 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
//ui.mDockWidgetRGBCamera->setMaximumHeight(498);
|
//ui.mDockWidgetRGBCamera->setMaximumHeight(498);
|
||||||
|
|
||||||
splitDockWidget(dock_layers, ui.mDockWidgetSimulator, Qt::Vertical);
|
splitDockWidget(dock_layers, ui.mDockWidgetSimulator, Qt::Vertical);
|
||||||
ui.mDockWidgetSimulator->show();
|
|
||||||
|
|
||||||
splitDockWidget(m_dock_carousel, ui.mDockWidgetSpectrometer, Qt::Vertical);
|
splitDockWidget(m_dock_carousel, ui.mDockWidgetSpectrometer, Qt::Vertical);
|
||||||
ui.mDockWidgetSpectrometer->show();
|
|
||||||
|
|
||||||
setStyleSheet(R"(
|
setStyleSheet(R"(
|
||||||
QMainWindow::separator{
|
QMainWindow::separator{
|
||||||
@ -739,6 +799,11 @@ void HPPA::selectScenario(QAction* selectedAction)
|
|||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HPPA::onCreated3DModelOneMotor()
|
||||||
|
{
|
||||||
|
connect(m_omc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DModelManager->m_viewMotor, SLOT(setLoc(std::vector<double>)));
|
||||||
|
}
|
||||||
|
|
||||||
void HPPA::createOneMotorScenario()
|
void HPPA::createOneMotorScenario()
|
||||||
{
|
{
|
||||||
//if (ui.mActionOneMotorScenario->isChecked())
|
//if (ui.mActionOneMotorScenario->isChecked())
|
||||||
@ -763,20 +828,19 @@ void HPPA::createOneMotorScenario()
|
|||||||
|
|
||||||
m_tabManager->showTab(m_omc);
|
m_tabManager->showTab(m_omc);
|
||||||
|
|
||||||
//<2F><EFBFBD>Ӧ<EFBFBD><D3A6>3Dģ<44><C4A3>
|
|
||||||
QString basePath = QCoreApplication::applicationDirPath();
|
|
||||||
QString model1 = basePath + "/3DModel/linear_stage_indoor1.obj";
|
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::OneMotor);
|
||||||
QString model2 = basePath + "/3DModel/linear_stage_indoor2.obj";
|
|
||||||
m_view3DLinearStage = new View3DLinearStage(model1, model2);
|
|
||||||
m_view3DLinearStage->setViewCenter(500, 100, 500);
|
|
||||||
m_view3DLinearStage->setDistance(1000);
|
|
||||||
ui.mDockWidgetSimulator->setWidget(m_view3DLinearStage);
|
|
||||||
connect(m_omc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DLinearStage, SLOT(setLoc(std::vector<double>)));
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>Ͻ<EFBFBD><CFBD>ֲ<EFBFBD>
|
//<2F><><EFBFBD>Ͻ<EFBFBD><CFBD>ֲ<EFBFBD>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HPPA::onCreated3DModelPlantPhenotype()
|
||||||
|
{
|
||||||
|
connect(m_tmc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DModelManager->m_viewPlant, SLOT(setLoc(std::vector<double>)));
|
||||||
|
}
|
||||||
|
|
||||||
void HPPA::createPlantPhenotypeScenario()
|
void HPPA::createPlantPhenotypeScenario()
|
||||||
{
|
{
|
||||||
//if (ui.mActionPlantPhenotypeScenario->isChecked())
|
//if (ui.mActionPlantPhenotypeScenario->isChecked())
|
||||||
@ -794,15 +858,9 @@ void HPPA::createPlantPhenotypeScenario()
|
|||||||
m_tabManager->showTab(m_pc);
|
m_tabManager->showTab(m_pc);
|
||||||
m_tabManager->showTab(m_tmc);
|
m_tabManager->showTab(m_tmc);
|
||||||
|
|
||||||
//<2F><EFBFBD>Ӧ<EFBFBD><D3A6>3Dģ<44><C4A3>
|
|
||||||
QString basePath = QCoreApplication::applicationDirPath();
|
|
||||||
QString model1 = basePath + "/3DModel/HPPA_frame.obj";
|
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::PlantPhenotype);
|
||||||
QString model2 = basePath + "/3DModel/HPPA_camera.obj";
|
|
||||||
m_view3DPlantPhenotype = new View3DPlantPhenotype(model1, model2);
|
|
||||||
m_view3DPlantPhenotype->setViewCenter(1000, 1000, -1000);
|
|
||||||
m_view3DPlantPhenotype->setDistance(5000);
|
|
||||||
ui.mDockWidgetSimulator->setWidget(m_view3DPlantPhenotype);
|
|
||||||
connect(m_tmc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DPlantPhenotype, SLOT(setLoc(std::vector<double>)));
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>Ͻ<EFBFBD><CFBD>ֲ<EFBFBD>
|
//<2F><><EFBFBD>Ͻ<EFBFBD><CFBD>ֲ<EFBFBD>
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,8 @@
|
|||||||
#include "View3D.h"
|
#include "View3D.h"
|
||||||
#include "TabManager.h"
|
#include "TabManager.h"
|
||||||
|
|
||||||
|
#include "View3DModelManager.h"
|
||||||
|
|
||||||
#define PI 3.1415926
|
#define PI 3.1415926
|
||||||
|
|
||||||
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<><CAB9> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<><CAB9> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||||
@ -239,9 +241,6 @@ private:
|
|||||||
QPushButton* m_open_rgb_camera_btn;
|
QPushButton* m_open_rgb_camera_btn;
|
||||||
QPushButton* m_close_rgb_camera_btn;
|
QPushButton* m_close_rgb_camera_btn;
|
||||||
|
|
||||||
View3DPlantPhenotype* m_view3DPlantPhenotype;
|
|
||||||
View3DLinearStage* m_view3DLinearStage;
|
|
||||||
|
|
||||||
TabManager* m_tabManager;
|
TabManager* m_tabManager;
|
||||||
|
|
||||||
adjustTable* m_adt;
|
adjustTable* m_adt;
|
||||||
@ -250,6 +249,8 @@ private:
|
|||||||
OneMotorControl* m_omc;
|
OneMotorControl* m_omc;
|
||||||
TwoMotorControl* m_tmc;
|
TwoMotorControl* m_tmc;
|
||||||
|
|
||||||
|
View3DModelManager* m_view3DModelManager;
|
||||||
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber);
|
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber);
|
||||||
@ -303,6 +304,8 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
void createOneMotorScenario();
|
void createOneMotorScenario();
|
||||||
void createPlantPhenotypeScenario();
|
void createPlantPhenotypeScenario();
|
||||||
|
void onCreated3DModelPlantPhenotype();
|
||||||
|
void onCreated3DModelOneMotor();
|
||||||
signals:
|
signals:
|
||||||
void StartFocusSignal();
|
void StartFocusSignal();
|
||||||
void StartRecordSignal();
|
void StartRecordSignal();
|
||||||
|
|||||||
@ -131,6 +131,7 @@
|
|||||||
<ClCompile Include="TwoMotorControl.cpp" />
|
<ClCompile Include="TwoMotorControl.cpp" />
|
||||||
<ClCompile Include="utility_tc.cpp" />
|
<ClCompile Include="utility_tc.cpp" />
|
||||||
<ClCompile Include="View3D.cpp" />
|
<ClCompile Include="View3D.cpp" />
|
||||||
|
<ClCompile Include="View3DModelManager.cpp" />
|
||||||
<QtRcc Include="HPPA.qrc" />
|
<QtRcc Include="HPPA.qrc" />
|
||||||
<QtUic Include="about.ui" />
|
<QtUic Include="about.ui" />
|
||||||
<QtUic Include="adjustTable.ui" />
|
<QtUic Include="adjustTable.ui" />
|
||||||
@ -165,6 +166,7 @@
|
|||||||
<QtMoc Include="image2display.h" />
|
<QtMoc Include="image2display.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<QtMoc Include="View3DModelManager.h" />
|
||||||
<QtMoc Include="View3D.h" />
|
<QtMoc Include="View3D.h" />
|
||||||
<QtMoc Include="adjustTable.h" />
|
<QtMoc Include="adjustTable.h" />
|
||||||
<QtMoc Include="PowerControl.h" />
|
<QtMoc Include="PowerControl.h" />
|
||||||
|
|||||||
@ -145,6 +145,9 @@
|
|||||||
<ClCompile Include="TabManager.cpp">
|
<ClCompile Include="TabManager.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="View3DModelManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="fileOperation.h">
|
<QtMoc Include="fileOperation.h">
|
||||||
@ -216,6 +219,9 @@
|
|||||||
<QtMoc Include="TabManager.h">
|
<QtMoc Include="TabManager.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="View3DModelManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="imageProcessor.h">
|
<ClInclude Include="imageProcessor.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;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user