概述
本教程提供了在指定平面距离/角度测量插件的使用教程
描述
通过插件管理模块创建测量插件,包含角度/距离测量
示例代码
效果图
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"
#include<iostream>
Mainwindow::Mainwindow(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
mRender = mRenderComponent->CreateBasicRender();
ui.gridLayout->addWidget(mRender->widget);
connect(ui.pushButton_Linear, &QPushButton::clicked, this, &Mainwindow::CreateLinearDimensions);
connect(ui.pushButton_angle, &QPushButton::clicked, this, &Mainwindow::CreateAngleDimensions);
}
Mainwindow::~Mainwindow()
{
}
void Mainwindow::CreateLinearDimensions()
{
mRender->pluginManage->SetProperty(id, att);
mRender->entityManage->DoRepaint();
mRender->cameraManage->ResetCamera();
}
void Mainwindow::CreateAngleDimensions()
{
mRender->pluginManage->SetProperty(id, att);
mRender->entityManage->DoRepaint();
mRender->cameraManage->ResetCamera();
}
AMCAX_RENDER_API std::shared_ptr< IRenderComponent > CreateRenderComponent(QWidget *parent)
Create Render Component
@ kLinearDimension
LinearDimension
定义 Constants.h:238
@ kAngleDimension
AngleDimension
定义 Constants.h:239
Angle Dimension
定义 PluginProperty.h:711
virtual void SetBasePlane(const Point3D &origin, const Point3D &normal)=0
Set the base plane
Distance Dimension
定义 PluginProperty.h:697
virtual void SetBasePlane(const Point3D &origin, const Point3D &normal)=0
Set the base plane
Mainwindow.h
#pragma once
#include <QWidget>
#include "ui_Mainwindow.h"
class Mainwindow : public QWidget
{
Q_OBJECT
public:
Mainwindow(QWidget *parent = nullptr);
~Mainwindow();
void CreateLinearDimensions();
void CreateAngleDimensions();
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="1" column="0">
<layout class="QGridLayout" name="gridLayout"/>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_Linear">
<property name="text">
<string>距离测量</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_angle">
<property name="text">
<string>角度测量</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>419</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(plugin_Dimensions)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
list(APPEND CMAKE_PREFIX_PATH ${AMCAXRender_PATH})
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::LinearDimensionProp,AMCAXRender::AngleDimensionProp