00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MECHSYS_SELECTCALLBACK_H
00023 #define MECHSYS_SELECTCALLBACK_H
00024
00025
00026 #include "vtkCommand.h"
00027 #include "vtkRenderer.h"
00028 #include "vtkBorderRepresentation.h"
00029 #include "vtkSelectVisiblePoints.h"
00030 #include "vtkObject.h"
00031 #include "vtkCoordinate.h"
00032
00033 class SelectCallBack : public vtkCommand
00034 {
00035 public:
00036
00037 SelectCallBack() : _ren(NULL), _bord_repr(NULL), _vis_pts1(NULL), _vis_pts2(NULL) {}
00038
00039
00040 void Setup(vtkRenderer * Ren , vtkBorderRepresentation * BordRepr,
00041 vtkSelectVisiblePoints * VisPts1, vtkSelectVisiblePoints * VisPts2=NULL);
00042 void Execute(vtkObject * Caller, unsigned long eventId, void *);
00043
00044
00045 static SelectCallBack * New() { return new SelectCallBack; }
00046
00047 private:
00048
00049 vtkRenderer * _ren;
00050 vtkBorderRepresentation * _bord_repr;
00051 vtkSelectVisiblePoints * _vis_pts1;
00052 vtkSelectVisiblePoints * _vis_pts2;
00053 int * _C1;
00054 int * _C2;
00055
00056
00057 void _update_coords();
00058
00059 };
00060
00061
00063
00064
00065 inline void SelectCallBack::Setup(vtkRenderer * Ren , vtkBorderRepresentation * BordRepr,
00066 vtkSelectVisiblePoints * VisPts1, vtkSelectVisiblePoints * VisPts2 )
00067 {
00068 _ren = Ren;
00069 _bord_repr = BordRepr;
00070 _vis_pts1 = VisPts1;
00071 _vis_pts2 = VisPts2;
00072 _update_coords();
00073 if (_vis_pts1!=NULL) _vis_pts1 -> SetSelection(_C1[0],_C2[0],_C1[1],_C2[1]);
00074 if (_vis_pts2!=NULL) _vis_pts2 -> SetSelection(_C1[0],_C2[0],_C1[1],_C2[1]);
00075 }
00076
00077 inline void SelectCallBack::Execute(vtkObject * Caller, unsigned long eventId, void *)
00078 {
00079 if (_ren!=NULL && _bord_repr!=NULL)
00080 {
00081 _update_coords();
00082 if (_vis_pts1!=NULL) _vis_pts1 -> SetSelection(_C1[0],_C2[0],_C1[1],_C2[1]);
00083 if (_vis_pts2!=NULL) _vis_pts2 -> SetSelection(_C1[0],_C2[0],_C1[1],_C2[1]);
00084 }
00085 }
00086
00087 inline void SelectCallBack::_update_coords()
00088 {
00089 vtkCoordinate * c1 = _bord_repr->GetPositionCoordinate();
00090 vtkCoordinate * c2 = _bord_repr->GetPosition2Coordinate();
00091 _C1 = c1->GetComputedDisplayValue(_ren);
00092 _C2 = c2->GetComputedDisplayValue(_ren);
00093
00094
00095
00096
00097
00098 }
00099
00100 #endif // MECHSYS_SELECTCALLBACK_H
00101
00102