Creating a new geostatistics plug-in for SGeMS

aboucher - Posted on 02 February 2009

New (geostatistics) algorithms can be added by writing a plug-in. The plug-in is composed of two elements: a shared library ( ".so" file on Unix, ".dll" file on Windows) and a textual description of the graphical interface used to prompt for parameters (".ui" file).

Defining a plug-in involves two steps:

  • deriving a new class from Geostat_algo and redefining the necessary virtual functions
  • writing the .ui description file, either directly in a text editor or using the Qt Designer software (the latter is certainly the prefered solution).

The first step in writing an algorithm plugin is to define a new class deriving from class Geostat_algo and to redefine the three virtual functions initialize, execute and name. The initialize function receives the parameters input by the user and initializes the parameters of the algorithm. These parameters are usually stored as member variables of the algorithm class. The execute function runs the algorithm using the parameters  previously initialized. The name function specifies the name of the algorithm.

Experience has shown that it is more practical to proceed in the following order:

  • write the execute function: this is the function that implements the algorithm. Writing the execute function first allows to easily identified the parameters required by the algorithm. New parameters are declared as member variables as they are identified.
  • Define the graphical user interface (".ui" file): set-up the fields necessary to input values for the parameters identified at the previous step.
  • write the initialize function: parse the user's input and initialize the parameters used by the execute function. The way the parameters are arranged depends on the type of widgets used in the graphical interface(".ui" file). Hence it is better to first define the user interface and then write the initialize function.
  • write the name function: return the name of the algorithm
  • Define a static member function called create_new_interface. The function has the following signature:
              Named_interface* create_new_interface( std::string& )