Skip to content
Snippets Groups Projects
Plugin.h 4.09 KiB
Newer Older
Jean-François Remacle's avatar
Jean-François Remacle committed
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
// 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// Please report all bugs and problems to <gmsh@geuz.org>.
Christophe Geuzaine's avatar
Christophe Geuzaine committed

// To create a plugin for gmsh:
// 1) Create a dynamin lib (.so) containing 1 symbol 
//    GMSH_Plugin * GMSH_RegisterPlugin ();
// 2) 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.
Christophe Geuzaine's avatar
Christophe Geuzaine committed

#include <string.h>
#include <stdio.h>
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

#include "Options.h"
Christophe Geuzaine's avatar
Christophe Geuzaine committed
#include "Message.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#include "Views.h"
class PluginDialogBox;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Jean-François Remacle's avatar
Jean-François Remacle committed
class GMSH_Plugin
{
public :
  // a dialog box for user interface
  PluginDialogBox *dialogBox;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  // this is there for internal use, this variable will be used by the
  // PluginManager, just forget it
Jean-François Remacle's avatar
Jean-François Remacle committed
  void *hlib;

  // 3 kind of plugins, one for cad, one for mesh, one for postpro
  typedef enum {GMSH_CAD_PLUGIN, 
		GMSH_MESH_PLUGIN, 
		GMSH_POST_PLUGIN, 
		GMSH_SOLVE_PLUGIN} GMSH_PLUGIN_TYPE ;

  // returns the type of plugin for downcasting GMSH_Plugin into
  // GMSH_CAD_Plugin, GMSH_Mesh_Plugin and GMSH_Post_Plugin
Jean-François Remacle's avatar
Jean-François Remacle committed
  virtual GMSH_PLUGIN_TYPE getType() const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void getName(char *name) const = 0;
  virtual void getInfos(char *author, char *copyright, char *helpText) const = 0;

  // When an error is thrown by the plugin, the plugin manager will
  // show the message and hopefully continue
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void catchErrorMessage(char *errorMessage) const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // gmsh style numeric options
  virtual int getNbOptions() const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual StringXNumber *getOption(int iopt) = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  // gmsh style string options
  virtual int getNbOptionsStr() const = 0;
  virtual StringXString *getOptionStr(int iopt) = 0;

  // run the plugin
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void run() = 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:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  inline GMSH_PLUGIN_TYPE getType() const { return GMSH_Plugin::GMSH_POST_PLUGIN; }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual int getNbOptionsStr() const { return 0; };
  virtual StringXString *getOptionStr(int iopt) { return NULL; };
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void run(){ execute(0); }
  // If returned pointer is the same as the argument, then view is
  // simply modified, else, a new view is added in the view list
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual Post_View *execute(Post_View *) = 0;
/*
  A solver plugin. The idea here is to be able to associate
  some properties to physical entities. The goal is to be able
  to interface gmsh with a solver (ABAQUS...) i.e. create the 
  input file for the solver.
*/

class GMSH_Solve_Plugin : public GMSH_Plugin
{
public:
  virtual int getNbOptionsStr() const { return 0; };
  virtual StringXString *getOptionStr(int iopt) { return NULL; };
  virtual int getNbOptions() const { return 0; };
  virtual StringXNumber *getOption(int iopt) { return NULL; };
  inline GMSH_PLUGIN_TYPE getType() const { return GMSH_Plugin::GMSH_SOLVE_PLUGIN; }
  virtual void run() {};// do nothing
  virtual void popupPropertiesForPhysicalEntity (int dim) = 0;// popup dialog box
  virtual void receiveNewPhysicalGroup (int dim, int id) = 0;// add the given group to the solver data's
  virtual void loadSolverFile  ( FILE *f ) = 0;  // load the solver input file related to the gmsh geo file
  virtual void writeSolverFile ( FILE *f ) const = 0;  // save the solver file 
};

Jean-François Remacle's avatar
Jean-François Remacle committed
#endif