uLib-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
vtkStructuredGrid.h
Go to the documentation of this file.
1 /*//////////////////////////////////////////////////////////////////////////////
2 // CMT Cosmic Muon Tomography project //////////////////////////////////////////
4 
5  Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
6  All rights reserved
7 
8  Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
9 
10  ------------------------------------------------------------------
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library.
23 
25 
26 
27 
28 #ifndef U_VTKSTRUCTUREDGRID_H
29 #define U_VTKSTRUCTUREDGRID_H
30 
31 #include <vtkLineSource.h>
32 #include <vtkBoundingBox.h>
33 #include <vtkCubeSource.h>
34 #include <vtkSmartPointer.h>
35 #include <vtkPolyDataMapper.h>
36 #include <vtkActor.h>
37 #include <vtkProperty.h>
38 
39 #include <vtkTransform.h>
40 #include <vtkTransformPolyDataFilter.h>
41 #include <vtkBoxWidget.h>
42 #include <vtkCommand.h>
43 
44 #include "Math/Dense.h"
45 
46 #include "uLibVtkInterface.h"
47 #include "Math/StructuredGrid.h"
48 
49 
50 namespace uLib {
51 namespace Vtk {
52 
53 class vtkStructuredGrid : public Puppet {
54  typedef StructuredGrid Content;
55 public:
56 
57  vtkStructuredGrid(Content &content);
58  ~vtkStructuredGrid();
59 
60  void SetTransform(class vtkTransform *t);
61 
62  class vtkBoxWidget * GetWidget();
63 
64  void Update();
65 
66 
67 private:
68  void InstallPipe();
69 
70  class vtkWidgetCallback : public vtkCommand
71  {
72  public:
73  static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
74 
75  void SetGrid(uLib::Vtk::vtkStructuredGrid *grid) { this->grid = grid; }
76 
77  virtual void Execute(vtkObject *caller, unsigned long, void*)
78  {
79  vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();
80  vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
81  widget->GetTransform(t);
82  grid->SetTransform(t);
83  }
84  private:
85  uLib::Vtk::vtkStructuredGrid *grid;
86  };
87 
88  vtkActor *m_Actor;
89  vtkBoxWidget *m_Widget;
90  StructuredGrid *m_Content;
91  vtkTransform *m_Transform;
92 };
93 
94 
95 } // vtk
96 } // uLib
97 
98 
99 #endif // VTKSTRUCTUREDGRID_H