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)
4 #include "bbcreaVtkBoxWidget.h"
5 #include "bbcreaVtkPackage.h"
7 #include "vtkRenderWindow.h"
8 #include "vtkCommand.h"
9 #include <vtkTransform.h>
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BoxWidget)
15 BBTK_BLACK_BOX_IMPLEMENTATION(BoxWidget,bbtk::AtomicBlackBox);
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)
20 class bbBoxWidgetCallback : public vtkCommand
24 static bbBoxWidgetCallback *New()
26 return new bbBoxWidgetCallback;
28 void SetBox( BoxWidget* box )
33 void Execute(vtkObject *caller, unsigned long, void*) override
35 vtkBoxWidget *vtkwidget = reinterpret_cast<vtkBoxWidget*>(caller);
36 vtkwidget->GetPlanes( _box->planes );
37 vtkwidget->GetTransform( _box->transformOut );
38 // _box->bbSignalOutputModification(std::string("ImplicitFunction"));
39 // _box->bbSignalOutputModification(std::string("TransformOut"));
40 _box->bbSignalOutputModification();
44 //-----------------------------------------------------
45 //-----------------------------------------------------
46 //-----------------------------------------------------
47 //-----------------------------------------------------
51 void BoxWidget::SetTransform( vtkLinearTransform* transform )
53 if ( bbGetInputImageInitSize()!=NULL)
57 bbGetInputImageInitSize()->GetExtent( ext );
58 bbGetInputImageInitSize()->GetSpacing( spc );
59 boxWidget->PlaceWidget( ext[0]*spc[0] , ext[1]*spc[0] , ext[2]*spc[1] , ext[3]*spc[1] , ext[4]*spc[2] , ext[5]*spc[2] );
62 boxWidget->SetTransform( (vtkTransform*)transform );
63 boxWidget->Modified();
64 boxWidget->GetPlanes( planes );
67 boxWidget->PlaceWidget(0,500,0,500,0,500);
71 void BoxWidget::Process()
74 // THE MAIN PROCESSING METHOD BODY
75 // Here we simply set the input 'In' value to the output 'Out'
76 // And print out the output value
77 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
78 // void bbSet{Input|Output}NAME(const TYPE&)
79 // const TYPE& bbGet{Input|Output}NAME() const
81 // * NAME is the name of the input/output
82 // (the one provided in the attribute 'name' of the tag 'input')
83 // * TYPE is the C++ type of the input/output
84 // (the one provided in the attribute 'type' of the tag 'input')
85 // bbSetOutputOut( bbGetInputIn() );
86 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
87 if ( bbGetInputRenderer()!=NULL )
92 boxWidget = vtkBoxWidget::New();
93 planes = vtkPlanes::New();
94 transformOut= vtkTransform::New();
95 boxWidget->SetInteractor( bbGetInputRenderer()->GetRenderWindow()->GetInteractor() );
96 SetTransform( bbGetInputTransformIn() );
99 // boxWidget->SetProp3D(coneActor);
100 bbBoxWidgetCallback *callback = bbBoxWidgetCallback::New();
101 callback->SetBox( this );
102 boxWidget->AddObserver(vtkCommand::InteractionEvent, callback);
104 if (bbGetInputActive()==true)
110 bbSetOutputImplicitFunction( planes );
111 boxWidget->GetTransform(transformOut);
112 bbSetOutputTransformOut( transformOut );
114 printf("EED Warnning! BoxWidget::Process vtkRenderer not set.\n");
115 }// vtkRenderer != NULL
116 bbSetOutputBox_BoxWidget( this );
119 // 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)
121 void BoxWidget::bbUserSetDefaultValues()
123 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
124 // Here we initialize the input 'In' to 0
126 bbSetInputRenderer(NULL);
127 bbSetInputTransformIn(NULL);
128 bbSetInputActive( false );
129 bbSetInputInitBoxChangeImage( false );
130 bbSetInputImageInitSize(NULL);
131 bbSetOutputTransformOut(NULL);
135 // 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)
137 void BoxWidget::bbUserInitializeProcessing()
139 // THE INITIALIZATION METHOD BODY :
141 // but this is where you should allocate the internal/output pointers
146 // 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)
148 void BoxWidget::bbUserFinalizeProcessing()
151 // THE FINALIZATION METHOD BODY :
153 // but this is where you should desallocate the internal/output pointers
157 } // EO namespace bbcreaVtk