CloudCompare2.11.0插件开发

一、UI文件生成

\quad 1、选择Qt自带的界面设计软件Designer,因为后面编译CloudCompare插件所使用的编译器是VS2019,故选择的是MSVC 2019 64位版的
在这里插入图片描述
\quad 2、新建一个UI对话框界面,即Dialog对话框
在这里插入图片描述
\quad 3、窗口添加组件
\quad 创建好的界面如下,接下来给这个窗口添加一些我们需要的组件
在这里插入图片描述
\quad 添加好组件后的窗口如下,将该UI文件保存到一个文件路径下,后面需要用到这个文件
在这里插入图片描述

二、代码文件配置

\quad 1、将CloudCompare源码中自带的插件例子复制一份,然后改成UIPlugin(也可改成其他名字)
在这里插入图片描述
\quad 2、在UIPlugin文件夹中新建一个src文件夹和ui文件夹,其中src文件夹放的是源代码文件,ui文件夹下放的是前面保存的UI文件,文件结构图如下
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
\quad 3、在src文件夹下新建一个UIPluginParameters.cpp文件和UIPluginParameters.h文件
在这里插入图片描述

三、资源文件配置

\quad 1、UIPlugin.qrc文件配置
在这里插入图片描述
\quad 2、info.json文件配置
在这里插入图片描述

四、CMake文件配置

\quad 1、在src文件夹下新建一个CMakeLists.txt文件,内容配置如下
在这里插入图片描述
\quad 2、在ui文件夹下新建一个CMakeLists.txt文件,内容配置如下
在这里插入图片描述
\quad 3、UIPlugin文件夹下的CMakeLists.txt文件配置
在这里插入图片描述
\quad 4、在UIPlugin文件夹所在路径下的CMakeLists.txt文件中添加如下内容
在这里插入图片描述
在这里插入图片描述
\quad 5、在CMake中先点击Configure配置文件,生成UIPlugin选项,然后在Ungrouped Entries中勾选中UIPlugin,如果在Ungrouped Entries中未找到自己写的插件的话,在PLUGIN中或许能找到,勾选后点击Configure
在这里插入图片描述
\quad 6、点击Generate生成解决方案,点击Open Project打开解决方案
在这里插入图片描述

五、相关代码

\quad 1、打开解决方案后,文件结构如下
在这里插入图片描述
\quad 2、先对UIPlugin.hUIPlugin.cpp文件进行如下修改
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
\quad 3、右键UIPlugin.ui文件,点击编译,生成ui_UIPlugin.h文件
在这里插入图片描述
\quad 4、在UIPluginParameters.hUIPluginParameters.cpp文件中写入以下内容
UIPluginParameters.h文件

#ifndef UIPLUGIN_PARAMETERS_HEADER
#define UIPLUGIN_PARAMETERS_HEADER

#include <ui_UIPlugin.h>

class UIPluginParameters :public QDialog
{
	Q_OBJECT

public:
	explicit UIPluginParameters(QWidget* parent = nullptr);
	~UIPluginParameters();

private:
	Ui::Dialog* ui;

private slots:
	void doConfirmBtn();
	void doCancelBtn();

};

#endif

注意:如果需要使用信号槽功能的话,请一定要加上Q_OBJECT,否则编译会报错!!!
UIPluginParameters.cpp文件

#include "UIPluginParameters.h"
#include <QMessageBox>

UIPluginParameters::UIPluginParameters(QWidget* parent) :
	QDialog(parent),
	ui(new Ui::Dialog)
{
	ui->setupUi(this);
	connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(doConfirmBtn()));
	connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(doCancelBtn()));
}

UIPluginParameters::~UIPluginParameters()
{
	delete ui;
}

void UIPluginParameters::doConfirmBtn()
{
	QMessageBox::information(this, "Tips", QString("The parameter value entered is %1").arg(ui->lineEdit->text()), QMessageBox::Ok);
	this->close();
}

void UIPluginParameters::doCancelBtn()
{
	QMessageBox::information(this, "Tips", QString("The cancel button has been clicked."), QMessageBox::Ok);
	this->close();
}

注意:① connect中的信号函数和槽函数一定要加括号,否则按钮点击将会没有任何反应
\quad \quad ② QString中的 %1是占位符,后面的arg中的变量为参数,若直接在QString中使用参数,则弹窗无法正确显示内容
\quad 5、在UIPlugin.cpp中添加一个头文件,同时作以下修改
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

//##########################################################################
//#                                                                        #
//#                CLOUDCOMPARE PLUGIN: ExamplePlugin                      #
//#                                                                        #
//#  This program is free software; you can redistribute it and/or modify  #
//#  it under the terms of the GNU General Public License as published by  #
//#  the Free Software Foundation; version 2 of the License.               #
//#                                                                        #
//#  This program is distributed in the hope that it will be useful,       #
//#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
//#  GNU General Public License for more details.                          #
//#                                                                        #
//#                             COPYRIGHT: XXX                             #
//#                                                                        #
//##########################################################################

// First:
//	Replace all occurrences of 'ExamplePlugin' by your own plugin class name in this file.
//	This includes the resource path to info.json in the constructor.

// Second:
//	Open ExamplePlugin.qrc, change the "prefix" and the icon filename for your plugin.
//	Change the name of the file to <yourPluginName>.qrc

// Third:
//	Open the info.json file and fill in the information about the plugin.
//	 "type" should be one of: "Standard", "GL", or "I/O" (required)
//	 "name" is the name of the plugin (required)
//	 "icon" is the Qt resource path to the plugin's icon (from the .qrc file)
//	 "description" is used as a tootip if the plugin has actions and is displayed in the plugin dialog
//	 "authors", "maintainers", and "references" show up in the plugin dialog as well

#include <QtGui>

#include "UIPlugin.h"
#include "UIPluginParameters.h"

// Default constructor:
//	- pass the Qt resource path to the info.json file (from <yourPluginName>.qrc file) 
//  - constructor should mainly be used to initialize actions and other members
ExamplePlugin::ExamplePlugin( QObject *parent )
	: QObject( parent )
	, ccStdPluginInterface( ":/CC/plugin/UIPlugin/info.json" )
	, m_action( nullptr )
{
}

// This method should enable or disable your plugin actions
// depending on the currently selected entities ('selectedEntities').
void ExamplePlugin::onNewSelection( const ccHObject::Container &selectedEntities )
{
	if ( m_action == nullptr )
	{
		return;
	}
	
	// If you need to check for a specific type of object, you can use the methods
	// in ccHObjectCaster.h or loop and check the objects' classIDs like this:
	//
	//	for ( ccHObject *object : selectedEntities )
	//	{
	//		if ( object->getClassID() == CC_TYPES::VIEWPORT_2D_OBJECT )
	//		{
	//			// ... do something with the viewports
	//		}
	//	}
	
	// For example - only enable our action if something is selected.
	//m_action->setEnabled( !selectedEntities.empty() );
}

// This method returns all the 'actions' your plugin can perform.
// getActions() will be called only once, when plugin is loaded.
QList<QAction *> ExamplePlugin::getActions()
{
	// default action (if it has not been already created, this is the moment to do it)
	if ( !m_action )
	{
		// Here we use the default plugin name, description, and icon,
		// but each action should have its own.
		m_action = new QAction( getName(), this );
		m_action->setToolTip( getDescription() );
		m_action->setIcon( getIcon() );
		
		// Connect appropriate signal
		connect( m_action, &QAction::triggered, this, &ExamplePlugin::doAction );
	}

	return { m_action };
}

// This is an example of an action's method called when the corresponding action
// is triggered (i.e. the corresponding icon or menu entry is clicked in CC's
// main interface). You can access most of CC's components (database,
// 3D views, console, etc.) via the 'm_app' variable (see the ccMainAppInterface
// class in ccMainAppInterface.h).
void ExamplePlugin::doAction()
{	
	if ( m_app == nullptr )
	{
		// m_app should have already been initialized by CC when plugin is loaded
		Q_ASSERT( false );
		
		return;
	}

	/*** HERE STARTS THE ACTION ***/

	// Put your code here
	// --> you may want to start by asking for parameters (with a custom dialog, etc.)
	UIPluginParameters uipp;
	if (!uipp.exec())
	{
		return;
	}

	// This is how you can output messages
	// Display a standard message in the console
	//m_app->dispToConsole( "[ExamplePlugin] Hello world!", ccMainAppInterface::STD_CONSOLE_MESSAGE );
	
	// Display a warning message in the console
	//m_app->dispToConsole( "[ExamplePlugin] Warning: example plugin shouldn't be used as is", ccMainAppInterface::WRN_CONSOLE_MESSAGE );
	
	// Display an error message in the console AND pop-up an error box
	//m_app->dispToConsole( "Example plugin shouldn't be used - it doesn't do anything!", ccMainAppInterface::ERR_CONSOLE_MESSAGE );

	/*** HERE ENDS THE ACTION ***/
}

\quad 6、右键ALL_BUILD解决方案,点击生成,对所有项目进行编译,之后右键INSTALL解决方案,点击生成,安装CloudCompare

六、编译安装效果

在这里插入图片描述
在这里插入图片描述
\quad 至此,CloudCompare插件编译完成,且能使用

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jackson2.11.0是指jackson的最新版本,它包括jackson-core-2.11.0.jar、jackson-databind-2.11.0.jar和jackson-annotation-2.11.0.jar这三个文件。 建议使用jackson的2.11.0及以上版本,原因如下: 1. 较低版本的jackson-databind存在反序列化远程代码执行漏洞(CVE-2020-35490/CVE-2020-35491),攻击者可以通过精心构造的恶意数据利用该漏洞执行任意代码。因此,为了安全起见,建议使用2.11.0及以上版本。 2. jackson-databind 2.11.0及以上版本与spring-boot版本兼容,这意味着你可以在使用spring-boot框架的项目中使用这些版本。 如果你想在项目中使用jackson的XML数据格式支持,你需要引入以下依赖: ```xml <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> <version>2.11.0</version> </dependency> ``` 这将使你能够在项目中使用jackson来处理XML格式的数据。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [jackson-2.11.0.zip](https://download.csdn.net/download/weixin_43268636/12503301)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [解决jackson版本和springboot版本不兼容的问题](https://blog.csdn.net/qq_44837912/article/details/124934030)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [json处理-Jackson使用总结](https://blog.csdn.net/yuexiaqiying/article/details/109227279)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值