- Copy ./templates/PluginTemplate.rar to C:/Users/($your_user_name)/Documents/Visual Studio 2015/Templates/ProjectTemplate/
- In VS2015, open Atlas.sln, go to Solution Explorer, right click on "Plugins", and choose Add->New Project
- In the new project dialog, choose from the left side, Installed->Visual C++->AtlasPlugin
- Set the name as your plugin name, and choose Location as ($project_root)/plugins
- Click OK. You'll see the project in Solution Explorer
- Make a new directory under plugins directory
- Copy a CMakeList file from another plugin directory
- Change the plugin name, dependencies, etc. as you need
- Create
$(project_name).cpp and $ (project_name).h files - Run CMake as mentioned in build_guild
- If the dependency is another plugin, specify it in the ($project_name).json file
- No matter what the dependency is, add it to the link targets in CMakeList and VS project properties
- Put any third-party dependency in the output directory (./x64/debug or ./x64/release)
- The recommended way is to use a .qrc file to embed the resource files into your output library (.dll or .a). Please refer to Qt resource management docs.
- An alternative way is to put your resources under Atlas/resources, and use it in your program with "resources/CATEGORY/FILE.EXTENSION"
- You should specify _pluginName and _pluginCategory in constructor
- You should make sure all dependencies and resources are available
- Then your plugin will be loaded on program start
- You can go to C:/Users/$(user_name)/AppData/Roaming/Atlas/Atlas/AtlasLog.txt or /tmp/Atlas/Atlas/AtlasLog.txt for more loading details
- The best way should be learning from an existing plugin, e.g. DrawLine or AddXYZ
- Inherit another plugin as a quick start
- Read through what is provided in PluginInterface and MousePicker
- setupUi() should always be implemented to provide entrance for the plugin
- Event callbacks like onLeftButton() will be called automatically when user input. So implement your interaction logic in those event callbacks
- Access _currentGeoPos for geographic coordinates
- Access _currentLocalPos and _currentWorldPos for renderer coordinates
- Access _anchoredWorldPos for anti-jittering coordinates (to put under _currentAnchor after calling updateAnchorPoint())
- Don't write to these coordinates because they are shared across all plugins
There are several options for you, the priority would be:
- _mainMap[ ] or _mapNode[ ]: any osgEarth supported data
- _pluginRoot: general osg nodes
- _currentAnchor: osg nodes that suffer from jittering (use _anchoredOffset as coordinate after calling updateAnchorPoint())
- Emit recordNode() after adding the data to the scene
- Emit removeData() when you want to remove it (no need to remove it from the scene by yourself, DataManager will do it)
- Emit switchData() to toggle a node
- Change a node's mask to make it visible on left or write sub-view
- QToolButton or Menu entry: activate plugin (toggle)
- Left button: start operation
- Mouse move: perform dragging
- Right button: cancel operation
- Double click: confirm operation
- QToolButton or Menu entry: deactivate plugin (toggle)
Of course, for those one-time functionalities, the procedure can be as short as:
- QToolButton or Menu entry: trigger the function
A basic Ui setup would be:
- QAction
- One-time operation: checkable = false. Connect trigger() with your functional slots.
- Procedural operation: checkable = true. Connect toggle() with PluginInterface::toggle(). And use _activated to check plugin status.
- QToolButton to wrap the action. Add it to *toolBar.
- Add the QAction to *menu.