]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.cxx
#3274 creaVtk Feature New Normal - BooleanOperationPolyDataFilter BoxWidget ClipPol...
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkBoxWidget.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaVtkBoxWidget.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include "vtkRenderWindow.h"
8 #include "vtkCommand.h"
9
10
11 namespace bbcreaVtk
12 {
13
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BoxWidget)
15 BBTK_BLACK_BOX_IMPLEMENTATION(BoxWidget,bbtk::AtomicBlackBox);
16 //===== 
17 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
18 //===== 
19
20 class bbBoxWidgetCallback : public vtkCommand
21   {
22    public:
23          BoxWidget *_box;
24      static bbBoxWidgetCallback *New()
25      { 
26                 return new bbBoxWidgetCallback; 
27         }
28         void SetBox( BoxWidget* box )
29         {
30                 _box=box;
31         }
32
33         void Execute(vtkObject *caller, unsigned long, void*) override
34         {
35        vtkBoxWidget *vtkwidget = reinterpret_cast<vtkBoxWidget*>(caller);
36                 vtkwidget->GetPlanes( _box->planes );
37                 _box->bbSignalOutputModification(std::string("ImplicitFunction"));
38         }
39  };
40
41
42
43 void BoxWidget::Process()
44 {
45
46 // THE MAIN PROCESSING METHOD BODY
47 //   Here we simply set the input 'In' value to the output 'Out'
48 //   And print out the output value
49 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
50 //    void bbSet{Input|Output}NAME(const TYPE&)
51 //    const TYPE& bbGet{Input|Output}NAME() const 
52 //    Where :
53 //    * NAME is the name of the input/output
54 //      (the one provided in the attribute 'name' of the tag 'input')
55 //    * TYPE is the C++ type of the input/output
56 //      (the one provided in the attribute 'type' of the tag 'input')
57 //    bbSetOutputOut( bbGetInputIn() );
58 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
59   
60
61         if ( bbGetInputRenderer()!=NULL )
62         {
63                 if (firsttime==true)
64                 {       
65                         firsttime       = false;
66                         boxWidget       = vtkBoxWidget::New();
67                         planes          = vtkPlanes::New();
68                         boxWidget->SetInteractor(  bbGetInputRenderer()->GetRenderWindow()->GetInteractor() );
69                         boxWidget->SetPlaceFactor(1.25);
70                         boxWidget->PlaceWidget(0,500,0,500,0,500);
71                         boxWidget->GetPlanes( planes );
72                 }
73          
74         //  boxWidget->SetProp3D(coneActor);
75                 bbBoxWidgetCallback *callback = bbBoxWidgetCallback::New();
76                 callback->SetBox( this );
77                 boxWidget->AddObserver(vtkCommand::InteractionEvent, callback);
78
79                 if (bbGetInputActive()==true)
80                 {
81                         boxWidget->On();
82                 }  else {
83                         boxWidget->Off();
84                 } // if Active
85                 bbSetOutputImplicitFunction( planes );
86         } else {
87                 printf("EED Warnning! BoxWidget::Process vtkRenderer not set.\n");
88         }// vtkRenderer != NULL
89
90 }
91 //===== 
92 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
93 //===== 
94 void BoxWidget::bbUserSetDefaultValues()
95 {
96
97 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
98 //    Here we initialize the input 'In' to 0
99         firsttime=true;
100     bbSetInputRenderer(NULL);
101     bbSetInputActive( false );
102
103 }
104 //===== 
105 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
106 //===== 
107 void BoxWidget::bbUserInitializeProcessing()
108 {
109
110 //  THE INITIALIZATION METHOD BODY :
111 //    Here does nothing 
112 //    but this is where you should allocate the internal/output pointers 
113 //    if any 
114
115   
116 }
117 //===== 
118 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
119 //===== 
120 void BoxWidget::bbUserFinalizeProcessing()
121 {
122
123 //  THE FINALIZATION METHOD BODY :
124 //    Here does nothing 
125 //    but this is where you should desallocate the internal/output pointers 
126 //    if any
127   
128 }
129 }
130 // EO namespace bbcreaVtk
131
132