Skip to content
Snippets Groups Projects
Plugin.h 2.01 KiB
Newer Older
Jean-François Remacle's avatar
Jean-François Remacle committed
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
/*
  The one who intend to create a plugin for gmsh have to 
    -) Create a dynamin lib (.so) containing 1 symbols
       GMSH_Plugin * GMSH_RegisterPlugin ();
    -) When there is an unacceptable error in the plugin,
    just throw this, the plugin manager will be able to 
    catch the exception.

  Some Plugins are default gmsh plugins and are insterted
  directly in the executable. I think that it's a good 
  way to start.
Jean-François Remacle's avatar
Jean-François Remacle committed
*/
#include <stdio.h>
#include "Options.h"

class PluginDialogBox;
class Post_View;
Jean-François Remacle's avatar
Jean-François Remacle committed
class GMSH_Plugin
{
public :
  /* a dialog box for user interface */
  PluginDialogBox *dialogBox;
Jean-François Remacle's avatar
Jean-François Remacle committed
  /*this is there for internal use, this variable will be
   used by the PluginManager, just forget it*/
  void *hlib;
  /* 3 kind of plugins, one for cad, one for mesh, one for postpro*/
  typedef enum GMSH_PLUGIN_TYPE {GMSH_CAD_PLUGIN, 
				 GMSH_MESH_PLUGIN, 
				 GMSH_POST_PLUGIN, 
				 GMSH_SOLVE_PLUGIN};
Jean-François Remacle's avatar
Jean-François Remacle committed
  /* returns the type of plugin for downcasting GMSH_Plugin into
     GMSH_CAD_Plugin, GMSH_Mesh_Plugin and GMSH_Post_Plugin */
  virtual GMSH_PLUGIN_TYPE getType() const = 0;
  virtual void getName (char *name) const = 0;
Jean-François Remacle's avatar
Jean-François Remacle committed
  virtual void getInfos (char *author, 
			 char *copyright,
			 char *help_text) const = 0;
  /* When an error is thrown by the plugin, the plugin manager
     will show the message and hopefully continue */
  virtual void CatchErrorMessage (char *errorMessage) const = 0;
  /* gmsh style option, ca be loaded, saved and set*/
  virtual int getNbOptions() const = 0;
  virtual void GetOption (int iopt, StringXNumber *option) const = 0;  
};

/* Base class for Post-Processing Plugins
   The user can either modify or duplicate 
   a Post_View */
class GMSH_Post_Plugin : public GMSH_Plugin
{
public:
  GMSH_PLUGIN_TYPE getType() const {return GMSH_Plugin::GMSH_POST_PLUGIN;}
  /* If returned pointer is the same as the argument, then view is simply modified,
    else, a new view is added in the view list */
  virtual Post_View *execute (Post_View *) = 0;
};