概述
本教程提供了创建箭头标注插件的教程
描述
通过插件管理模块创建箭头标注插件,支持单箭头(半径)和双箭头标注(距离)
示例代码
效果图

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);
att->SetLabel(std::wstring(L"距离标注双箭头"));
att->SetColor({ 0,0,1 });
att->SetFontSize(20);
att->SetPointSize(10);
mRender->pluginManage->SetProperty(id, att);
att2->SetLabel(std::wstring(L"半径标注单箭头"));
att2->SetColor({ 1,0,1 });
att2->SetFontSize(20);
att2->SetPointSize(10);
mRender->pluginManage->SetProperty(id2, att2);
mRender->cameraManage->ResetCamera();
mRender->entityManage->DoRepaint();
}
Mainwindow::~Mainwindow()
{
}
AMCAX_RENDER_API std::shared_ptr< IRenderComponent > CreateRenderComponent(QWidget *parent)
Create Render Component
@ kArrowAnnocation
Arrow Annotation, Supports Single and Double Arrow
定义 Constants.h:231
Arrow annotation
定义 PluginProperty.h:360
@ kDistance
Distance
定义 PluginProperty.h:365
@ kRadius
Radius
定义 PluginProperty.h:366
virtual void SetPointParameter(const Point3D &cPt, const Point3D &ePt, AnnoType type=AnnoType::kDistance)=0
Set endpoints
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(ArrowAnnocation)
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::ArrowAnnocationProp