C++ Distribution Example Plugin
Introduction
This page describes what is present in example_plugin
directory of the Windows distribution archive and how to use it.
- Note
- Please have a look at MeshLib С++ setup guide first.
Content
This example contains several files:
example_plugin.sln
- Visual Studio solution file
example_plugin.vcxproj
- Visual Studio project file
MyPlugin.items.json
- tools configuration file
MyPlugin.ui.json
- tools visualization in MeshLib/MeshInspector viewer
resource
- directory with icons in four different sizes for menu in viewer
MyPlugin.cpp
- source code with actual (demo) tools
Lets have a closer look at each of these points:
Solution File
example_plugin.sln
- This can be used to build an example with Visual Studio, it only includes example_plugin.vcxproj
in it.
Project File
example_plugin.vcxproj
- This file is configured so project can work with MeshLib distribuiton
- Debug only:
- Debug Configuration: C/C++ → Preprocessor → Preprocessor Definitions:
Add: _ITERATOR_DEBUG_LEVEL=0
- For all configurations:
- General Properties -> C++ Language Standard:
Set: /std:c++20
or later
- C/C++ → General → Additional Include Directories:
Add: C:\meshlib-built\install\include
- C/C++ → All Options → Additional Options:
Add: /bigobj /utf8
- Linker → Input → Additional Dependencies:
Add: C:\meshlib-built\install\lib\$(Configuration)\*.lib
- Copy other files to target directory:
<ItemGroup>
<CopyFileToFolders Include="MyPlugin.items.json">
<FileType>Document</FileType>
</CopyFileToFolders>
<CopyFileToFolders Include="MyPlugin.ui.json">
<FileType>Document</FileType>
</CopyFileToFolders>
<Content Include="resource\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Tools Configuration File
MyPlugin.items.json
- this file contains information about each tool that is present in the plugin:
- "Name" - name of the tool, should be same as in the code
- "Tooltip" - tooltip that is shown when user hover tool in UI
- "Icon" - unicode symbol from Fontawesome, it is shown in UI for the tool if there is no actual icon present in
resource
folder
- "Caption" - optional: label that is displayed instead of name in UI, if not present "Name" is used intead
- "HelpLink" - optional: link to web page that will be opened if "Help" button is pressed in UI
- "DropList" - optional: array with other tools that will be available in this tool drop list (see "List" in next section)
{
"Items": [
{
"Name": "My Tool",
"Tooltip": "Simple button that shows Hello World message",
"Icon": "\uE05D"
},
{
"Name": "My State Tool",
"Tooltip": "Simple dialog that shows Hello World message",
"Icon": "\uE05D"
}
]
}
Tools Visualization Order File
MyPlugin.ui.json
- this file has information about order of the plugin loading, and UI schema for present tools:
- "Order" - order of loading dll produced by this plugin, it can be used to determine constuction of tools in diferent plugins
- "LibName" - name of the dll that contains provided tools (in this case it is same dll)
- "Tabs" - tabs where tools are located in UI, could be new tabs or existing ones (specified plugins with less "Order" number)
- "Name" - name of the tab
- "Priority" - optional: tabs are ordered by this number
- "Groups" - specify groups of tools in single tab, could be new groups or existing ones (specified plugins with less "Order" number)
- "Name" - name of the group (it is not used now)
- "List" - list of the tools in this group
- "Name" - name of the tool, should be same as in the code and in the
items.json
file
{
"Order": 999,
"LibName": "example_plugin",
"Tabs": [
{
"Name": "MyPlugin",
"Priority": 20,
"Groups": [
{
"Name": "Primal",
"List": [
{
"Name": "My Tool"
},
{
"Name": "My State Tool"
}
]
}
]
}
]
}
Resoure Directory
resource
- directory with icons that is used in UI, it should have same structure as in example:
- resource
- icons
- X0_5 (16x16 px)
- X0_75 (24x24 px)
- X1 (32x32 px)
- X3 (96x96 px)
- Note
- Icons should have same name as tool in the code, in
items.json
file and in ui.json
file
Source Code File
MyPlugin.cpp
- this file contains two simple tools:
MyTool() : RibbonMenuItem( "My Tool" )
- shows "Hello World" modal window
MyStateTool() : StatePlugin( "My State Tool" )
- shows "Hello World" dialog window
For more information have a look at State Plugin Page
Usage
- Open solution file with Visual Studio
- Compile it
- Copy content of just appeared
x64\Release\
folder to MeshLib or MeshInspector app folder
- MeshLib:
install\app\Release
- MeshInspector:
C:\Program Files\MeshInspector\MeshInspector
, please note that you should use same version of MeshLib that is used in MeshInspector to avoid unexpected errors - Note
- take
x64\Debug\
if you want to test it in MeshLib debug app folder: install\app\Debug