69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#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();
|
|
}
|