当前位置:网站首页>VS QT VTK 左下角显示同步小坐标轴
VS QT VTK 左下角显示同步小坐标轴
2022-06-23 22:12:00 【windSnowLi】
主要参考
https://blog.csdn.net/qq_37996632/article/details/106415402
https://kitware.github.io/vtk-examples/site/Cxx/Qt/BorderWidgetQt
主要代码
#include "BorderWidgetQt.h"
#include <vtkBorderWidget.h>
#include <vtkCommand.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkSphereSource.h>
#include <vtkVersion.h>
#include <vtkAxesActor.h>
#include <vtkCamera.h>
class BorderCallback : public vtkCommand
{
public:
BorderCallback()
{
}
static BorderCallback* New()
{
return new BorderCallback;
}
virtual void Execute(vtkObject* vtkNotUsed(caller), unsigned long, void*)
{
// vtkBorderWidget *borderWidget =
// reinterpret_cast<vtkBorderWidget*>(caller);
}
};
// Constructor
BorderWidgetQt::BorderWidgetQt(QWidget* parent)
: QMainWindow(parent)
{
this->resize(600, 400);
this->vtkWidget = new QVTKOpenGLNativeWidget(this);
this->setCentralWidget(vtkWidget);
vtkNew<vtkNamedColors> colors;
// Sphere
vtkNew<vtkSphereSource> sphereSource;
sphereSource->Update();
vtkNew<vtkPolyDataMapper> sphereMapper;
sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
vtkNew<vtkActor> sphereActor;
sphereActor->SetMapper(sphereMapper);
sphereActor->GetProperty()->SetColor(colors->GetColor4d("Tomato").GetData());
// VTK Renderer
vtkNew<vtkRenderer> renderer;
renderer->AddActor(sphereActor);
renderer->SetBackground(colors->GetColor3d("SteelBlue").GetData());
// 相机拉远
renderer->ResetCamera();
renderer->GetActiveCamera()->Zoom(1.5);
// Connect VTK with Qt
this->vtkWidget->renderWindow()->AddRenderer(renderer);
// Add a border widget to the renderer
//vtkNew<vtkBorderWidget> bw;
//this->BorderWidget = bw;
//this->BorderWidget->SetInteractor(this->vtkWidget->interactor());
//this->BorderWidget->On();
vtkSmartPointer<vtkAxesActor> axes_actor = vtkSmartPointer<vtkAxesActor>::New();
axes_actor->SetPosition(0, 0, 0);
axes_actor->SetTotalLength(2, 2, 2);
axes_actor->SetShaftType(0);
axes_actor->SetCylinderRadius(0.02);
vtkSmartPointer<vtkOrientationMarkerWidget> widget =
vtkSmartPointer<vtkOrientationMarkerWidget>::New();;
this->BorderWidget = widget;
widget->SetOrientationMarker(axes_actor);
widget->SetInteractor(this->vtkWidget->interactor());
widget->SetEnabled(1);
widget->InteractiveOn();
}
效果

边栏推荐
- Fabric.js 手动加粗文本iText
- 嵌入式接口之TIM定时器与NVIC的STM32模板库函数的一些解释
- Data interpretation! Ideal L9 sprints to "sell more than 10000 yuan a month" to grab share from BBA
- “山大地纬杯”第十二届山东省ICPC大学生程序设计竞赛
- PyQt5_ Qtablewidget paging radio right-click menu control
- 《阿里云天池大赛赛题解析》——O2O优惠卷预测
- 【HackTheBox】Fawn
- laravel之任务队列
- Cs5213 HDMI to VGA with audio signal output scheme
- MySQL事務隔離
猜你喜欢
随机推荐
How can wechat video numbers be broadcast live on a PC?
PyQt5_QTableWidget分页单选右键菜单控件
百万消息量IM系统技术要点分享
Image segmentation - data annotation
嵌入式接口复习资料
The sandbox and bayz have reached cooperation to jointly drive the development of metauniverse in Brazil
2022 cloud consulting technology series storage & CDN special sharing meeting
BroadcastReciver 和LocalBroadcastManager区别
开发协同,高效管理 | 社区征文
Graph theory (tree diameter)
Practice of issuing vouchers for Tiktok payment of 100000 TPS traffic
What to check for AIX system monthly maintenance (II)
Stm32 - - - - interruption externe
思考(八十六):主从实现思路
MySQL transaction isolation
MySQL事務隔離
Several cases of index invalidation caused by MySQL
Fabric.js 手动加粗文本iText
Solve the problem that slf4j logs are not printed
Million message IM system technical points sharing








