|
|
|
@ -3,6 +3,7 @@
|
|
|
|
#include "nmVTKCameraController.h"
|
|
|
|
#include "nmVTKCameraController.h"
|
|
|
|
#include "nmVTKImageExporter.h"
|
|
|
|
#include "nmVTKImageExporter.h"
|
|
|
|
#include "nmVTKInteractionManager.h"
|
|
|
|
#include "nmVTKInteractionManager.h"
|
|
|
|
|
|
|
|
#include "nmVTKOrientationMarkerController.h"
|
|
|
|
#include "nmVTKScene.h"
|
|
|
|
#include "nmVTKScene.h"
|
|
|
|
#include "nmVTKViewCommandController.h"
|
|
|
|
#include "nmVTKViewCommandController.h"
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,17 +29,18 @@ VTK_MODULE_INIT(vtkInteractionStyle)
|
|
|
|
|
|
|
|
|
|
|
|
nmWxVTKRenderContainerWidget::nmWxVTKRenderContainerWidget(QWidget* pParent)
|
|
|
|
nmWxVTKRenderContainerWidget::nmWxVTKRenderContainerWidget(QWidget* pParent)
|
|
|
|
: QWidget(pParent),
|
|
|
|
: QWidget(pParent),
|
|
|
|
m_pMainLayout(NULL),
|
|
|
|
m_pMainLayout(nullptr),
|
|
|
|
m_pStateStack(NULL),
|
|
|
|
m_pStateStack(nullptr),
|
|
|
|
m_pStatePage(NULL),
|
|
|
|
m_pStatePage(nullptr),
|
|
|
|
m_pStateLabel(NULL),
|
|
|
|
m_pStateLabel(nullptr),
|
|
|
|
m_pVtkWidget(NULL),
|
|
|
|
m_pVtkWidget(nullptr),
|
|
|
|
m_pRenderer(NULL),
|
|
|
|
m_pRenderer(nullptr),
|
|
|
|
m_pScene(NULL),
|
|
|
|
m_pScene(nullptr),
|
|
|
|
m_pCameraController(NULL),
|
|
|
|
m_pCameraController(nullptr),
|
|
|
|
m_pInteractionManager(NULL),
|
|
|
|
m_pInteractionManager(nullptr),
|
|
|
|
m_pImageExporter(NULL),
|
|
|
|
m_pImageExporter(nullptr),
|
|
|
|
m_pViewCommandController(NULL)
|
|
|
|
m_pViewCommandController(nullptr),
|
|
|
|
|
|
|
|
m_pOrientationMarkerController(nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
|
|
|
|
|
|
|
|
@ -68,7 +70,7 @@ nmWxVTKRenderContainerWidget::nmWxVTKRenderContainerWidget(QWidget* pParent)
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
vtkRenderWindowInteractor* pInteractor = getInteractor();
|
|
|
|
vtkRenderWindowInteractor* pInteractor = getInteractor();
|
|
|
|
m_pRenderer = vtkSmartPointer<vtkRenderer>::New();
|
|
|
|
m_pRenderer = vtkSmartPointer<vtkRenderer>::New();
|
|
|
|
if(pRenderWindow != NULL && m_pRenderer != NULL) {
|
|
|
|
if(pRenderWindow != nullptr && m_pRenderer != nullptr) {
|
|
|
|
pRenderWindow->AddRenderer(m_pRenderer);
|
|
|
|
pRenderWindow->AddRenderer(m_pRenderer);
|
|
|
|
m_pRenderer->SetGradientBackground(true);
|
|
|
|
m_pRenderer->SetGradientBackground(true);
|
|
|
|
m_pRenderer->SetBackground(0.67, 0.82, 0.94);
|
|
|
|
m_pRenderer->SetBackground(0.67, 0.82, 0.94);
|
|
|
|
@ -103,11 +105,17 @@ nmWxVTKRenderContainerWidget::nmWxVTKRenderContainerWidget(QWidget* pParent)
|
|
|
|
const bool bInteractionReady =
|
|
|
|
const bool bInteractionReady =
|
|
|
|
m_pInteractionManager->bindInteractor(pInteractor);
|
|
|
|
m_pInteractionManager->bindInteractor(pInteractor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 方向轴是独立辅助 Renderer;绑定失败只隐藏方向轴,不影响主视图初始化。
|
|
|
|
|
|
|
|
m_pOrientationMarkerController =
|
|
|
|
|
|
|
|
new nmVTKOrientationMarkerController();
|
|
|
|
|
|
|
|
m_pOrientationMarkerController->bindInteractor(
|
|
|
|
|
|
|
|
pInteractor, m_pRenderer);
|
|
|
|
|
|
|
|
|
|
|
|
// 6. 只接管右键菜单,左键、中键和滚轮继续交给 VTK。
|
|
|
|
// 6. 只接管右键菜单,左键、中键和滚轮继续交给 VTK。
|
|
|
|
m_pVtkWidget->installEventFilter(this);
|
|
|
|
m_pVtkWidget->installEventFilter(this);
|
|
|
|
|
|
|
|
|
|
|
|
// 7. 基础 VTK 对象完整时进入就绪页,否则保留明确错误状态。
|
|
|
|
// 7. 基础 VTK 对象完整时进入就绪页,否则保留明确错误状态。
|
|
|
|
if(pRenderWindow != NULL && m_pRenderer != NULL && bInteractionReady) {
|
|
|
|
if(pRenderWindow != nullptr && m_pRenderer != nullptr && bInteractionReady) {
|
|
|
|
showReadyState();
|
|
|
|
showReadyState();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
showErrorState(tr("Unable to initialize the render view."));
|
|
|
|
showErrorState(tr("Unable to initialize the render view."));
|
|
|
|
@ -119,51 +127,58 @@ nmWxVTKRenderContainerWidget::~nmWxVTKRenderContainerWidget()
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 先阻止新的右键菜单回调进入销毁中的对象。
|
|
|
|
// 1. 先阻止新的右键菜单回调进入销毁中的对象。
|
|
|
|
if(m_pVtkWidget != NULL) {
|
|
|
|
if(m_pVtkWidget != nullptr) {
|
|
|
|
m_pVtkWidget->removeEventFilter(this);
|
|
|
|
m_pVtkWidget->removeEventFilter(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 先销毁 QAction,避免后续服务拆除期间再触发容器槽函数。
|
|
|
|
// 2. 先销毁 QAction,避免后续服务拆除期间再触发容器槽函数。
|
|
|
|
if(m_pViewCommandController != NULL) {
|
|
|
|
if(m_pViewCommandController != nullptr) {
|
|
|
|
delete m_pViewCommandController;
|
|
|
|
delete m_pViewCommandController;
|
|
|
|
m_pViewCommandController = NULL;
|
|
|
|
m_pViewCommandController = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. MarkerWidget 持有 Interactor 和辅助 Renderer 引用,必须优先解绑。
|
|
|
|
|
|
|
|
if(m_pOrientationMarkerController != nullptr) {
|
|
|
|
|
|
|
|
m_pOrientationMarkerController->unbindInteractor();
|
|
|
|
|
|
|
|
delete m_pOrientationMarkerController;
|
|
|
|
|
|
|
|
m_pOrientationMarkerController = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 图片服务不拥有 RenderWindow,先解除引用再销毁服务。
|
|
|
|
// 4. 图片服务不拥有 RenderWindow,先解除引用再销毁服务。
|
|
|
|
if(m_pImageExporter != NULL) {
|
|
|
|
if(m_pImageExporter != nullptr) {
|
|
|
|
m_pImageExporter->setRenderWindow(NULL);
|
|
|
|
m_pImageExporter->setRenderWindow(nullptr);
|
|
|
|
delete m_pImageExporter;
|
|
|
|
delete m_pImageExporter;
|
|
|
|
m_pImageExporter = NULL;
|
|
|
|
m_pImageExporter = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Interactor 必须先释放对默认 Style 的 VTK 引用。
|
|
|
|
// 5. Interactor 必须先释放对默认 Style 的 VTK 引用。
|
|
|
|
if(m_pInteractionManager != NULL) {
|
|
|
|
if(m_pInteractionManager != nullptr) {
|
|
|
|
m_pInteractionManager->unbindInteractor();
|
|
|
|
m_pInteractionManager->unbindInteractor();
|
|
|
|
delete m_pInteractionManager;
|
|
|
|
delete m_pInteractionManager;
|
|
|
|
m_pInteractionManager = NULL;
|
|
|
|
m_pInteractionManager = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Scene 在 Renderer 移除前清空所有 Layer 和 Prop。
|
|
|
|
// 6. Scene 在 Renderer 移除前清空所有 Layer 和 Prop。
|
|
|
|
if(m_pScene != NULL) {
|
|
|
|
if(m_pScene != nullptr) {
|
|
|
|
m_pScene->clear();
|
|
|
|
m_pScene->clear();
|
|
|
|
delete m_pScene;
|
|
|
|
delete m_pScene;
|
|
|
|
m_pScene = NULL;
|
|
|
|
m_pScene = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 相机控制器仅解除 Renderer 非所有权引用。
|
|
|
|
// 7. 相机控制器仅解除 Renderer 非所有权引用。
|
|
|
|
if(m_pCameraController != NULL) {
|
|
|
|
if(m_pCameraController != nullptr) {
|
|
|
|
m_pCameraController->setRenderer(NULL);
|
|
|
|
m_pCameraController->setRenderer(nullptr);
|
|
|
|
delete m_pCameraController;
|
|
|
|
delete m_pCameraController;
|
|
|
|
m_pCameraController = NULL;
|
|
|
|
m_pCameraController = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 5、6. 最后从 RenderWindow 移除并释放当前实例 Renderer。
|
|
|
|
// 8. 最后从 RenderWindow 移除并释放当前实例 Renderer。
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
if(pRenderWindow != NULL && m_pRenderer != NULL) {
|
|
|
|
if(pRenderWindow != nullptr && m_pRenderer != nullptr) {
|
|
|
|
pRenderWindow->RemoveRenderer(m_pRenderer);
|
|
|
|
pRenderWindow->RemoveRenderer(m_pRenderer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_pRenderer = NULL;
|
|
|
|
m_pRenderer = nullptr;
|
|
|
|
// 7. QVTKWidget、状态页和布局随后由 Qt 父子关系自动销毁。
|
|
|
|
// QVTKWidget、状态页和布局随后由 Qt 父子关系自动销毁。
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVTKWidget* nmWxVTKRenderContainerWidget::getVtkWidget() const
|
|
|
|
QVTKWidget* nmWxVTKRenderContainerWidget::getVtkWidget() const
|
|
|
|
@ -178,14 +193,14 @@ vtkRenderer* nmWxVTKRenderContainerWidget::getRenderer() const
|
|
|
|
|
|
|
|
|
|
|
|
vtkRenderWindow* nmWxVTKRenderContainerWidget::getRenderWindow() const
|
|
|
|
vtkRenderWindow* nmWxVTKRenderContainerWidget::getRenderWindow() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return m_pVtkWidget != NULL ? m_pVtkWidget->GetRenderWindow() : NULL;
|
|
|
|
return m_pVtkWidget != nullptr ? m_pVtkWidget->GetRenderWindow() : nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vtkRenderWindowInteractor*
|
|
|
|
vtkRenderWindowInteractor*
|
|
|
|
nmWxVTKRenderContainerWidget::getInteractor() const
|
|
|
|
nmWxVTKRenderContainerWidget::getInteractor() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
return pRenderWindow != NULL ? pRenderWindow->GetInteractor() : NULL;
|
|
|
|
return pRenderWindow != nullptr ? pRenderWindow->GetInteractor() : nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nmVTKScene* nmWxVTKRenderContainerWidget::getScene() const
|
|
|
|
nmVTKScene* nmWxVTKRenderContainerWidget::getScene() const
|
|
|
|
@ -199,10 +214,16 @@ nmWxVTKRenderContainerWidget::getViewCommandController() const
|
|
|
|
return m_pViewCommandController;
|
|
|
|
return m_pViewCommandController;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nmVTKOrientationMarkerController*
|
|
|
|
|
|
|
|
nmWxVTKRenderContainerWidget::getOrientationMarkerController() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return m_pOrientationMarkerController;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::setViewCommandCapabilities(
|
|
|
|
void nmWxVTKRenderContainerWidget::setViewCommandCapabilities(
|
|
|
|
nmVTKViewCommandController::ViewCommands eCommands)
|
|
|
|
nmVTKViewCommandController::ViewCommands eCommands)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pViewCommandController != NULL) {
|
|
|
|
if(m_pViewCommandController != nullptr) {
|
|
|
|
m_pViewCommandController->setCapabilities(eCommands);
|
|
|
|
m_pViewCommandController->setCapabilities(eCommands);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -211,21 +232,21 @@ bool nmWxVTKRenderContainerWidget::installInteractionStyle(
|
|
|
|
vtkInteractorStyle* pStyle)
|
|
|
|
vtkInteractorStyle* pStyle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
return isGuiThread() && m_pInteractionManager != NULL &&
|
|
|
|
return isGuiThread() && m_pInteractionManager != nullptr &&
|
|
|
|
m_pInteractionManager->installInteractionStyle(pStyle);
|
|
|
|
m_pInteractionManager->installInteractionStyle(pStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool nmWxVTKRenderContainerWidget::restoreDefaultInteraction()
|
|
|
|
bool nmWxVTKRenderContainerWidget::restoreDefaultInteraction()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
return isGuiThread() && m_pInteractionManager != NULL &&
|
|
|
|
return isGuiThread() && m_pInteractionManager != nullptr &&
|
|
|
|
m_pInteractionManager->restoreDefaultInteraction();
|
|
|
|
m_pInteractionManager->restoreDefaultInteraction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::clearInteractionStyle()
|
|
|
|
void nmWxVTKRenderContainerWidget::clearInteractionStyle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
if(isGuiThread() && m_pInteractionManager != NULL) {
|
|
|
|
if(isGuiThread() && m_pInteractionManager != nullptr) {
|
|
|
|
m_pInteractionManager->clearInteractionStyle();
|
|
|
|
m_pInteractionManager->clearInteractionStyle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -235,7 +256,7 @@ void nmWxVTKRenderContainerWidget::renderView()
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
vtkRenderWindow* pRenderWindow = getRenderWindow();
|
|
|
|
// Scene、Layer 和相机均不隐式渲染,批量更新最终汇聚到此入口。
|
|
|
|
// Scene、Layer 和相机均不隐式渲染,批量更新最终汇聚到此入口。
|
|
|
|
if(isGuiThread() && pRenderWindow != NULL) {
|
|
|
|
if(isGuiThread() && pRenderWindow != nullptr) {
|
|
|
|
pRenderWindow->Render();
|
|
|
|
pRenderWindow->Render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -244,7 +265,7 @@ bool nmWxVTKRenderContainerWidget::fitTopViewWithoutRender()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
// 相机控制器本身不触发 Render,便于业务图层完成整批更新后只渲染一次。
|
|
|
|
// 相机控制器本身不触发 Render,便于业务图层完成整批更新后只渲染一次。
|
|
|
|
return isGuiThread() && m_pCameraController != NULL &&
|
|
|
|
return isGuiThread() && m_pCameraController != nullptr &&
|
|
|
|
m_pCameraController->setTopView();
|
|
|
|
m_pCameraController->setTopView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -256,9 +277,12 @@ void nmWxVTKRenderContainerWidget::showReadyState()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 状态页与 VTK 页尺寸稳定,切换页面不会重建 RenderWindow 或 Renderer。
|
|
|
|
// 状态页与 VTK 页尺寸稳定,切换页面不会重建 RenderWindow 或 Renderer。
|
|
|
|
m_pStateStack->setCurrentWidget(m_pVtkWidget);
|
|
|
|
m_pStateStack->setCurrentWidget(m_pVtkWidget);
|
|
|
|
if(m_pViewCommandController != NULL) {
|
|
|
|
if(m_pViewCommandController != nullptr) {
|
|
|
|
m_pViewCommandController->setViewAvailable(true);
|
|
|
|
m_pViewCommandController->setViewAvailable(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_pOrientationMarkerController != nullptr) {
|
|
|
|
|
|
|
|
m_pOrientationMarkerController->setViewAvailable(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -280,21 +304,21 @@ void nmWxVTKRenderContainerWidget::showRenderingState(
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::zoomIn()
|
|
|
|
void nmWxVTKRenderContainerWidget::zoomIn()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->zoomIn()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->zoomIn()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::zoomOut()
|
|
|
|
void nmWxVTKRenderContainerWidget::zoomOut()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->zoomOut()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->zoomOut()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::fitView()
|
|
|
|
void nmWxVTKRenderContainerWidget::fitView()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->fitView()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->fitView()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -302,35 +326,35 @@ void nmWxVTKRenderContainerWidget::fitView()
|
|
|
|
void nmWxVTKRenderContainerWidget::resetCamera()
|
|
|
|
void nmWxVTKRenderContainerWidget::resetCamera()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 控制器用返回值表示相机是否确实改变,成功时只提交一次渲染。
|
|
|
|
// 控制器用返回值表示相机是否确实改变,成功时只提交一次渲染。
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->resetCamera()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->resetCamera()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::setTopView()
|
|
|
|
void nmWxVTKRenderContainerWidget::setTopView()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->setTopView()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->setTopView()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::setFrontView()
|
|
|
|
void nmWxVTKRenderContainerWidget::setFrontView()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->setFrontView()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->setFrontView()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::setRightView()
|
|
|
|
void nmWxVTKRenderContainerWidget::setRightView()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL && m_pCameraController->setRightView()) {
|
|
|
|
if(m_pCameraController != nullptr && m_pCameraController->setRightView()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::setIsometricView()
|
|
|
|
void nmWxVTKRenderContainerWidget::setIsometricView()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL &&
|
|
|
|
if(m_pCameraController != nullptr &&
|
|
|
|
m_pCameraController->setIsometricView()) {
|
|
|
|
m_pCameraController->setIsometricView()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -341,7 +365,7 @@ void nmWxVTKRenderContainerWidget::setRotationCenter(
|
|
|
|
double dY,
|
|
|
|
double dY,
|
|
|
|
double dZ)
|
|
|
|
double dZ)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL &&
|
|
|
|
if(m_pCameraController != nullptr &&
|
|
|
|
m_pCameraController->setRotationCenter(dX, dY, dZ)) {
|
|
|
|
m_pCameraController->setRotationCenter(dX, dY, dZ)) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -349,7 +373,7 @@ void nmWxVTKRenderContainerWidget::setRotationCenter(
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::resetRotationCenter()
|
|
|
|
void nmWxVTKRenderContainerWidget::resetRotationCenter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pCameraController != NULL &&
|
|
|
|
if(m_pCameraController != nullptr &&
|
|
|
|
m_pCameraController->resetRotationCenter()) {
|
|
|
|
m_pCameraController->resetRotationCenter()) {
|
|
|
|
renderView();
|
|
|
|
renderView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -359,13 +383,13 @@ bool nmWxVTKRenderContainerWidget::eventFilter(
|
|
|
|
QObject* pObject,
|
|
|
|
QObject* pObject,
|
|
|
|
QEvent* pEvent)
|
|
|
|
QEvent* pEvent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(pObject == m_pVtkWidget && pEvent != NULL &&
|
|
|
|
if(pObject == m_pVtkWidget && pEvent != nullptr &&
|
|
|
|
pEvent->type() == QEvent::MouseButtonPress) {
|
|
|
|
pEvent->type() == QEvent::MouseButtonPress) {
|
|
|
|
QMouseEvent* pMouseEvent = static_cast<QMouseEvent*>(pEvent);
|
|
|
|
QMouseEvent* pMouseEvent = static_cast<QMouseEvent*>(pEvent);
|
|
|
|
if(pMouseEvent->button() == Qt::RightButton) {
|
|
|
|
if(pMouseEvent->button() == Qt::RightButton) {
|
|
|
|
// 菜单引用命令控制器长期持有的 QAction,不在每次右键时重复创建。
|
|
|
|
// 菜单引用命令控制器长期持有的 QAction,不在每次右键时重复创建。
|
|
|
|
QMenu oMenu(this);
|
|
|
|
QMenu oMenu(this);
|
|
|
|
if(m_pViewCommandController != NULL) {
|
|
|
|
if(m_pViewCommandController != nullptr) {
|
|
|
|
m_pViewCommandController->populateContextMenu(&oMenu);
|
|
|
|
m_pViewCommandController->populateContextMenu(&oMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!oMenu.isEmpty()) {
|
|
|
|
if(!oMenu.isEmpty()) {
|
|
|
|
@ -381,7 +405,7 @@ bool nmWxVTKRenderContainerWidget::eventFilter(
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::saveImage()
|
|
|
|
void nmWxVTKRenderContainerWidget::saveImage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pImageExporter == NULL) {
|
|
|
|
if(m_pImageExporter == nullptr) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 实际编码格式由 QImage 按调用方选择的扩展名决定。
|
|
|
|
// 实际编码格式由 QImage 按调用方选择的扩展名决定。
|
|
|
|
@ -399,7 +423,7 @@ void nmWxVTKRenderContainerWidget::saveImage()
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::copyImage()
|
|
|
|
void nmWxVTKRenderContainerWidget::copyImage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pImageExporter != NULL &&
|
|
|
|
if(m_pImageExporter != nullptr &&
|
|
|
|
!m_pImageExporter->copyImageToClipboard()) {
|
|
|
|
!m_pImageExporter->copyImageToClipboard()) {
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
tr("Copy Failed"),
|
|
|
|
tr("Copy Failed"),
|
|
|
|
@ -409,14 +433,14 @@ void nmWxVTKRenderContainerWidget::copyImage()
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::printImage()
|
|
|
|
void nmWxVTKRenderContainerWidget::printImage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pImageExporter != NULL) {
|
|
|
|
if(m_pImageExporter != nullptr) {
|
|
|
|
m_pImageExporter->printImage(this);
|
|
|
|
m_pImageExporter->printImage(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxVTKRenderContainerWidget::printPreview()
|
|
|
|
void nmWxVTKRenderContainerWidget::printPreview()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(m_pImageExporter != NULL) {
|
|
|
|
if(m_pImageExporter != nullptr) {
|
|
|
|
m_pImageExporter->printPreview(this);
|
|
|
|
m_pImageExporter->printPreview(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -426,8 +450,8 @@ void nmWxVTKRenderContainerWidget::showMessageState(
|
|
|
|
const QString& sMessage)
|
|
|
|
const QString& sMessage)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
Q_ASSERT(isGuiThread());
|
|
|
|
if(!isGuiThread() || m_pStateStack == NULL ||
|
|
|
|
if(!isGuiThread() || m_pStateStack == nullptr ||
|
|
|
|
m_pStatePage == NULL || m_pStateLabel == NULL) {
|
|
|
|
m_pStatePage == nullptr || m_pStateLabel == nullptr) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -439,14 +463,17 @@ void nmWxVTKRenderContainerWidget::showMessageState(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_pStateLabel->setText(sMessage);
|
|
|
|
m_pStateLabel->setText(sMessage);
|
|
|
|
m_pStateStack->setCurrentWidget(m_pStatePage);
|
|
|
|
m_pStateStack->setCurrentWidget(m_pStatePage);
|
|
|
|
if(m_pViewCommandController != NULL) {
|
|
|
|
if(m_pViewCommandController != nullptr) {
|
|
|
|
m_pViewCommandController->setViewAvailable(false);
|
|
|
|
m_pViewCommandController->setViewAvailable(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_pOrientationMarkerController != nullptr) {
|
|
|
|
|
|
|
|
m_pOrientationMarkerController->setViewAvailable(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool nmWxVTKRenderContainerWidget::isGuiThread() const
|
|
|
|
bool nmWxVTKRenderContainerWidget::isGuiThread() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QCoreApplication* pApplication = QCoreApplication::instance();
|
|
|
|
QCoreApplication* pApplication = QCoreApplication::instance();
|
|
|
|
return pApplication == NULL ||
|
|
|
|
return pApplication == nullptr ||
|
|
|
|
pApplication->thread() == QThread::currentThread();
|
|
|
|
pApplication->thread() == QThread::currentThread();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|