next up previous contents
Next: Data Extraction Up: Writing Display Methods for Previous: Introduction

Preparation

The task of the preparational part of the display method is to provide access to the necessary objects and data structures. As an example the beginning of the hmesh2d isoline display method is printed below. In addition to the HMesh2d object the isoline method needs access to the function values. Therefore a pointer to a F_HDATA2D structure is initialized. As the isolines are colored according to their isovalue a colorbar is neccessary. Besides the obligatory graphic device the use of a lens is prepared. For more details concerning the different objects see their respective documentation.

HMESH2D* hmesh2d_isoline_disp(void)
{ 
  HMESH2D*       hmesh;
  F_HDATA2D*     f_hdata2d;
  COLORBAR*      colorbar;
  GRAPHICDEVICE* device; 
  
  static HMESH2D_LENS* lens = NULL; 

  /* get hmesh and function */

  hmesh = (HMESH2D*)START_METHOD(G_INSTANCE);
  ALERT(hmesh,"hmesh2d-isoline: No hmesh!",END_METHOD(NULL));
 
  f_hdata2d = (F_HDATA2D*)GRAPE(hmesh,"get-function")
    ("scalar","scalar","vector","default",NULL);
  ALERT(f_hdata2d,"hmesh2d-isoline-select: No function!",
    END_METHOD(NULL));
  
  /* get colorbar and graphicdevice */

  colorbar = (COLORBAR*)GRAPE(Colorbar,"get-stdcolorbar")
    (hmesh2d_isoline_disp,"isoline-disp");
  
  device = (GRAPHICDEVICE*)GRAPE(GraphicDevice,"get-stddev")();

  /* get lens */

  if(!lens)
    lens = (HMESH2D_LENS*)GRAPE(Hmesh2d_Lens,"get-lens")
      ("lens for hmesh2d-isoline");

  ...
}

Often the visualiztion algorithms implemented in display methods depend on parameters that allow the user to manipulate the resulting picture. To make this possible interactive elements must be added to the manager. Below an excerpt of the display method hmesh2d-shrink-disp is printed. This methods has one parameter which controls the size of the shrunk elements.

HMESH2D* hmesh2d_shrink_disp(void)
{  
  MANAGER* mgr;
  ...
  static GROUP*  group           = NULL;
  static SLIDER* shrink_size_ctl = NULL;
  static double  shrink_size     = 0.95;
  ...
 
  /* get manager */

  mgr = (MANAGER*)GRAPE(Manager,"get-stdmgr")();

  /* get interactives */
 
  if(!shrink_size_ctl)
    shrink_size_ctl = 
       (SLIDER*)new_item(Slider,
                         I_Label,"shrink-factor",
                         I_Var,&shrink_size,dfDouble,
                         I_MinMax,0.0,1.0,
                         I_Scale, 1.0,
                         I_Offset,0.0,
                         I_RSizeX,0.5,I_SizeY,1.0,
                         I_End); 
  if(!group)
    group = (GROUP*)new_item(Group,
                             I_Border,bfBorder|bfTitle,
                             I_Name,"hmesh2d-shrink",
                             I_Size,12.0,1.25,
                             I_Item,shrink_size_ctl,
                             I_End);

  if(GRAPE(mgr,"new-handle")(hmesh2d_shrink_disp,1))
    GRAPE(mgr,"add-inter")(group);

  ...


next up previous contents
Next: Data Extraction Up: Writing Display Methods for Previous: Introduction

SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.