Developers Knowledge Base

Read articles and post questions in this comprehensive developer community and support forum.
Showing results for 
Search instead for 
Do you mean 

Extending Spatial Modeler

by Technical Evangelist ‎10-06-2015 10:50 AM - edited ‎06-22-2016 01:51 PM (704 Views)

Spatial Modeler can be extended by adding new operators, data types, data conversions, and dialogs for the user to set parameters for operators.  All of these are plug-in pieces that are discovered at runtime by examining DLLs in specified locations.  Each plug-in DLL may contain any number and combination of these plug-in objects.

 

By default Spatial Modeler looks for plug-in DLLs in the usr/lib/<Configuration>/Operators subfolder under <IMAGINE_HOME> or <SDK_HOME> and in the Hexagon/SpatialModeler/Plugins/15/<Configuration> subfolder under the Common Files directory (where <Configuration> is one of the supported configuration and platform combinations—see the Environment section above).  However, if you are running Spatial Models in your own environment, you may place your DLL in any location and add that directory to Spatial Modeler’s path by calling SpatialModelerEnvironment::AppendDirectory().  The examples below all place their plug-ins in the smsdk/Plugins subfolder in the installation directory.  See the source code for smExampleModelRunner for how this directory is added to Spatial Modeler’s path.

 

Another way to define the location of a plugin DLL is through an XML file located in Spatial Modeler’s path.  This is useful when you don’t want Spatial Modeler to load every DLL in a directory while searching for a plugin DLL.  Using the XML file lets you directly define the path of the DLL to use, and any additional search paths to find support DLLs.  An example of the contents of the XML file is shown below.

 

<?xml version="1.0" encoding="utf-8"?>
<SpatialModelerPath xmlns="http://tempuri.org/XMLSchema.xsd">
    <DLL>$MY_APP_HOME\some_other_directory\testPlugin.dll</DLL>
    <SearchPath>$MY_APP_HOME\some_other_dll_path\</SearchPath>
    <SearchPath>$MY_APP_HOME\yet_another_dll_path\</SearchPath>
</SpatialModelerPath>

One of the projects built by the SpatialModelerExamplesSolution solution is smExampleModelRunner.  This project builds an executable that allows you to easily run the example models provided to demonstrate the use of the plug-in objects.  You can run this executable in the debugger to step through the example plug-in objects.  Note that the example models use data from the smsdk/examples/data directory and that the output of these models goes to this directory as well.  The descriptions below will indicate which model demonstrates the example object(s).

 

Previous article:  Example 2: Loading/Saving/Editing a Spatial Model

Next article:  Creating an operator

 

Overview
Contributors