概述
本教程提供了包围盒标注创建的教程
描述
通过插件管理模块创建包围标注插件,支持立方体,球形,圆柱三种场景
示例代码
效果图
"立方体标注"
"球体标注"
"圆柱标注"
main.cpp
#include <QApplication>
#include "Mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Mainwindow w;
w.show();
return a.exec();
}
Mainwindow.cpp
#include "Mainwindow.h"
Mainwindow::Mainwindow(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
mRender = mRenderComponent->CreateBasicRender();
ui.gridLayout->addWidget(mRender->widget);
AMCAXRender::BoundAnnocationProp::BoxParams box;
box.center = { 0,0,0 };
box.len = 5;
box.width = 10;
box.hight = 2;
box.center = { -20,-20,-20 };
box.directionX = { 1,0,0 };
box.directionY = { 0,1,0 };
AMCAXRender::BoundAnnocationProp::SphereParams sphere;
AMCAXRender::BoundAnnocationProp::CylinderParams cylinder;
att->SetBoxParameter(box);
att->SetSphereParameter(sphere);
att->SetCylinderParameter(cylinder);
att->SetColor({ 0,0,1 });
att->SetPointSize(20);
att->SetUnit("mm");
mRender->pluginManage->SetProperty(id, att);
mRender->cameraManage->ResetCamera();
mRender->entityManage->DoRepaint();
}
Mainwindow::~Mainwindow()
{
}
AMCAX_RENDER_API std::shared_ptr< IRenderComponent > CreateRenderComponent(QWidget *parent)
Create Render Component
@ kBoundsAnnocation
Bounding Box Annotation Plugin
定义 Constants.h:232
Bounding box annotation plugin
定义 PluginProperty.h:404
Point3D center1
Center point
定义 PluginProperty.h:426
Point3D center2
Center point
定义 PluginProperty.h:427
double radius
Radius
定义 PluginProperty.h:428
Point3D normal
Cylinder central axis direction
定义 PluginProperty.h:429
Point3D center
Center point
定义 PluginProperty.h:420
double radius
Radius
定义 PluginProperty.h:421
Mainwindow.h
#pragma once
#include <QWidget>
#include "ui_Mainwindow.h"
class Mainwindow : public QWidget
{
Q_OBJECT
public:
Mainwindow(QWidget *parent = nullptr);
~Mainwindow();
private:
Ui::MainwindowClass ui;
std::shared_ptr<AMCAXRender::IRenderComponent> mRenderComponent;
std::shared_ptr<AMCAXRender::CBasicRender> mRender;
};
Mainwindow.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainwindowClass</class>
<widget class="QWidget" name="MainwindowClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Mainwindow</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout"/>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(BoundsAnnocation)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
find_package(AMCAXRender )
find_package(Qt6 COMPONENTS Widgets Core Gui REQUIRED)
file(GLOB ALL_UI_FILES *.ui)
file(GLOB ALL_FILES *.cpp *.h)
add_executable(${PROJECT_NAME} ${ALL_UI_FILES} ${ALL_FILES})
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets)
target_link_libraries(${PROJECT_NAME} PRIVATE AMCAXRender::AMCAXRender)
更多
更多属性请参考 AMCAXRender::BoundAnnocationProp