view src/include/vtkplot.hpp @ 44:4134a0f2423d

Finalise VTK implementation, biggest bugs squashed, linear wave equation works.
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Wed, 17 Mar 2010 01:25:28 -0600
parents 8aea477c7cf8
children 11395e64852f
line wrap: on
line source

#ifndef __VTKPLOTTING_HPP__
#define __VTKPLOTTING_HPP__

#include <string>

#include <vtkSmartPointer.h>
#include <vtkProgrammableFilter.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>

#include "interpolator.hpp"
namespace kwantix{

///A class for creating VTK plots
class vtkplot{
public:
  /*! \brief Constructor performs a Delaunay triangulation on data
   * \param data - An \f$n \times 3\f$ matrix where the first two
   *               columns are points in the x-y plane on which a
   *               Delaunay triangulation will be done, and the
   *               third column is the value at this point.
   */
  template<typename RBF>
  vtkplot(const interpolator<RBF>& u, 
          double zmin_in, double zmax_in,
          bool offscreen_in = false);
  ///Defines the view direction when plotting.
  void set_view_direction(double x, double y, double z);
  ///Without changing the triangulation, update the values.
  void update_values(const interp_values& vals_in);
  ///Enable offscreen plotting.
  void set_offscreen(bool offscreen_in = true);
  ///Set the base filename used for saving, to which numbers are appended.
  void set_base_filename(const std::string& basename);
  ///Actually do the plot, whether offscreen or onscreen.
  void plot() const;

  ///Enable window interaction
  void begin_interaction() const;

  ///The VTK callback for updating the surface points
  void AdjustPoints();
  ///Trampoline function for VTK callback
  static void trampoline(void* this_ptr);

private:
  
  ///Setup the initial pipeline
  template<typename RBF>
  void SetupPipeline(const interpolator<RBF>& u);
  
  ///A VTK callback to insert in the pipeline to modify an existing plotting pipeline
  vtkSmartPointer<vtkProgrammableFilter> programmableFilter;

  ///Setup the pipeline to plot offscreen or not
  void InitOffscreen();

  ///View direction
  double xview, yview, zview;

  ///Min and max ranges (for colour values)
  double zmin, zmax;

  ///Values with which to update the surface data
  interp_values vals;

  /*! \name VTK pipeline endpoints
   *
   * Endpoint of the VTK pipeline
   */
  //@{
  vtkSmartPointer<vtkRenderer> ren1;
	vtkSmartPointer<vtkRenderWindow> renWin;
  //@}

  ///The associated interpolator's hash
  size_t hash;
  ///Base filename
  string basename;
  ///Whether to plot offscreen or not
  bool offscreen;
};

}

#endif //__VTKPLOTTING_HPP__