From: eduardo.davila@creatis.insa-lyon.fr Date: Wed, 8 May 2024 07:33:55 +0000 (+0200) Subject: #3523 Add to BoxWidget box Transform option X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=265497fce49b7e3d51970ad97d30471c3cad8b73;p=creaVtk.git #3523 Add to BoxWidget box Transform option --- diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbg b/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbg index 82da099..864ac86 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbg @@ -1,5 +1,5 @@ # ---------------------------------- -# - BBTKGEditor v 1.5 BBG BlackBox Diagram file +# - BBTKGEditor v 1.6 BBG BlackBox Diagram file # - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbg # ---------------------------------- @@ -7,29 +7,30 @@ APP_START CATEGORY: DESCRIPTION:Description ?? AUTHOR:InfoDev +EXPORTFORMAT:0 COMPLEXBOX:TRUE COMPLEXBOXNAME:VoiMPR-Interface PACKAGENAME:creaVtk COMPLEXOUTPUTS:5 COMPLEX_PORT widget --228.565150:-30.356903:-900.000000 +-233.224467:-59.144829:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT voi --36.558531:-36.949624:-900.000000 +-34.062468:-59.580595:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT boxchange -151.084421:-38.846161:-900.000000 +71.059928:-68.258319:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT active --280.622702:-31.286401:-900.000000 +-285.282019:-60.074327:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT boxchangeRender -1.781942:-39.802000:-900.000000 +4.278005:-62.432971:-900.000000 FIN_COMPLEX_PORT COMPLEXINPUTS:4 COMPLEX_PORT @@ -38,7 +39,7 @@ Image FIN_COMPLEX_PORT COMPLEX_PORT Execute -159.742221:89.981082:-900.000000 +75.201784:92.417406:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT voi_index @@ -48,7 +49,7 @@ COMPLEX_PORT voi_size 38.871902:91.444380:-900.000000 FIN_COMPLEX_PORT -BOXES:30 +BOXES:37 BOX creaMaracasVisu:SliderMinMax:Box03 ISEXEC:FALSE @@ -128,8 +129,8 @@ FIN_BOX BOX wx:LayoutLine:Box11 ISEXEC:FALSE --227.073381:-10.910358:-900.000000 --193.753381:-13.410358:-900.000000 +-231.732698:-39.698284:-900.000000 +-198.412698:-42.198284:-900.000000 FIN_BOX BOX vtk:ImageVtkProperties:Box30 @@ -170,8 +171,8 @@ FIN_BOX BOX std:MultipleInputs:Box40 ISEXEC:FALSE -153.356415:-13.712725:-900.000000 -175.326415:-16.212725:-900.000000 +69.546876:7.239660:-900.000000 +91.516876:4.739660:-900.000000 FIN_BOX BOX wx:CheckBox:Box42 @@ -307,7 +308,75 @@ ISEXEC:FALSE PORT Type:"0" FIN_BOX -CONNECTIONS:56 +BOX +wx:OutputText:Box45 +ISEXEC:FALSE +-131.403195:-12.118069:-900.000000 +-109.733195:-14.618069:-900.000000 +PORT +Title:"X" +FIN_BOX +BOX +wx:OutputText:Box46 +ISEXEC:FALSE +-107.557741:-11.877406:-900.000000 +-85.887741:-14.377406:-900.000000 +PORT +Title:"Y" +FIN_BOX +BOX +wx:LayoutLine:Box47 +ISEXEC:FALSE +-140.961664:-31.753791:-900.000000 +-107.641664:-34.253791:-900.000000 +PORT +Orientation:"H" +FIN_BOX +BOX +wx:OutputText:Box48 +ISEXEC:FALSE +-83.573489:-11.867957:-900.000000 +-61.903489:-14.367957:-900.000000 +PORT +Title:"Z" +FIN_BOX +BOX +std:ConcatStrings:Box49 +ISEXEC:FALSE +-130.366484:-1.801399:-900.000000 +-107.606484:-4.301399:-900.000000 +PORT +In1:"[" +PORT +In3:"," +PORT +In5:"]" +FIN_BOX +BOX +std:ConcatStrings:Box50 +ISEXEC:FALSE +-95.399556:-0.793525:-900.000000 +-72.639556:-3.293525:-900.000000 +PORT +In1:"[" +PORT +In3:"," +PORT +In5:"]" +FIN_BOX +BOX +std:ConcatStrings:Box51 +ISEXEC:FALSE +-68.253624:-2.614522:-900.000000 +-45.493624:-5.114522:-900.000000 +PORT +In1:"[" +PORT +In3:"," +PORT +In5:"]" +FIN_BOX +CONNECTIONS:72 CONNECTION Box03:BoxChange:Box06:In1 NumberOfControlPoints:0 @@ -476,4 +545,52 @@ NumberOfControlPoints:0 CONNECTION Box34:Out:Box05:InMax NumberOfControlPoints:0 +CONNECTION +Box45:Widget:Box47:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box46:Widget:Box47:Widget4 +NumberOfControlPoints:0 +CONNECTION +Box47:Widget:Box11:Widget9 +NumberOfControlPoints:0 +CONNECTION +Box03:BoxChange:Box45:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box48:Widget:Box47:Widget6 +NumberOfControlPoints:0 +CONNECTION +Box04:BoxChange:Box46:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box05:BoxChange:Box48:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box03:OutStart:Box49:In2 +NumberOfControlPoints:0 +CONNECTION +Box49:Out:Box45:In +NumberOfControlPoints:0 +CONNECTION +Box04:OutStart:Box50:In2 +NumberOfControlPoints:0 +CONNECTION +Box04:OutEnd:Box50:In4 +NumberOfControlPoints:0 +CONNECTION +Box50:Out:Box46:In +NumberOfControlPoints:0 +CONNECTION +Box51:Out:Box48:In +NumberOfControlPoints:0 +CONNECTION +Box05:OutStart:Box51:In2 +NumberOfControlPoints:0 +CONNECTION +Box05:OutEnd:Box51:In4 +NumberOfControlPoints:0 +CONNECTION +Box03:OutEnd:Box49:In4 +NumberOfControlPoints:0 APP_END diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbs b/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbs index 6088c3d..51af7fe 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbs @@ -1,5 +1,5 @@ # ---------------------------------- -# - BBTKGEditor v 1.5 BBS BlackBox Script (Complex Box) +# - BBTKGEditor v 1.6 BBS BlackBox Script (Complex Box) # - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/VoiMPR-Interface.bbs # ---------------------------------- @@ -116,6 +116,33 @@ new std:GetVectorIntElement Box43 new std:MathOperationVector Box44 set Box44.Type "0" +new wx:OutputText Box45 + set Box45.Title "X" + +new wx:OutputText Box46 + set Box46.Title "Y" + +new wx:LayoutLine Box47 + set Box47.Orientation "H" + +new wx:OutputText Box48 + set Box48.Title "Z" + +new std:ConcatStrings Box49 + set Box49.In1 "[" + set Box49.In3 "," + set Box49.In5 "]" + +new std:ConcatStrings Box50 + set Box50.In1 "[" + set Box50.In3 "," + set Box50.In5 "]" + +new std:ConcatStrings Box51 + set Box51.In1 "[" + set Box51.In3 "," + set Box51.In5 "]" + connect Box03.BoxChange Box06.In1 connect Box04.BoxChange Box06.In2 @@ -164,6 +191,22 @@ connect Box43.Out Box05.InMaxShow connect Box32.Out Box03.InMax connect Box33.Out Box04.InMax connect Box34.Out Box05.InMax +connect Box45.Widget Box47.Widget2 +connect Box46.Widget Box47.Widget4 +connect Box47.Widget Box11.Widget9 +connect Box03.BoxChange Box45.BoxExecute +connect Box48.Widget Box47.Widget6 +connect Box04.BoxChange Box46.BoxExecute +connect Box05.BoxChange Box48.BoxExecute +connect Box03.OutStart Box49.In2 +connect Box49.Out Box45.In +connect Box04.OutStart Box50.In2 +connect Box04.OutEnd Box50.In4 +connect Box50.Out Box46.In +connect Box51.Out Box48.In +connect Box05.OutStart Box51.In2 +connect Box05.OutEnd Box51.In4 +connect Box03.OutEnd Box49.In4 # Complex input ports input Image Box31.In " " diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkActor.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkActor.cxx index d2ea5dd..b7a8fa8 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkActor.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkActor.cxx @@ -5,7 +5,6 @@ #include "bbcreaVtkPackage.h" #include "vtkProperty.h" - namespace bbcreaVtk { diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.cxx index a973e3b..304e39d 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.cxx @@ -6,136 +6,159 @@ #include "vtkRenderWindow.h" #include "vtkCommand.h" - +#include namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BoxWidget) BBTK_BLACK_BOX_IMPLEMENTATION(BoxWidget,bbtk::AtomicBlackBox); -//===== +//===== // 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) -//===== +//===== class bbBoxWidgetCallback : public vtkCommand - { - public: - BoxWidget *_box; - static bbBoxWidgetCallback *New() - { - return new bbBoxWidgetCallback; - } - void SetBox( BoxWidget* box ) - { - _box=box; - } - - void Execute(vtkObject *caller, unsigned long, void*) override - { - vtkBoxWidget *vtkwidget = reinterpret_cast(caller); - vtkwidget->GetPlanes( _box->planes ); - _box->bbSignalOutputModification(std::string("ImplicitFunction")); - } - }; - - +{ +public: + BoxWidget *_box; + static bbBoxWidgetCallback *New() + { + return new bbBoxWidgetCallback; + } + void SetBox( BoxWidget* box ) + { + _box=box; + } + + void Execute(vtkObject *caller, unsigned long, void*) override + { + vtkBoxWidget *vtkwidget = reinterpret_cast(caller); + vtkwidget->GetPlanes( _box->planes ); + vtkwidget->GetTransform( _box->transformOut ); +// _box->bbSignalOutputModification(std::string("ImplicitFunction")); + // _box->bbSignalOutputModification(std::string("TransformOut")); + _box->bbSignalOutputModification(); + } +}; + +//----------------------------------------------------- +//----------------------------------------------------- +//----------------------------------------------------- +//----------------------------------------------------- + + + +void BoxWidget::SetTransform( vtkLinearTransform* transform ) +{ + if ( bbGetInputImageInitSize()!=NULL) + { + int ext[6]; + double spc[3]; + bbGetInputImageInitSize()->GetExtent( ext ); + bbGetInputImageInitSize()->GetSpacing( spc ); + 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] ); + if (transform!=NULL) + { + boxWidget->SetTransform( (vtkTransform*)transform ); + boxWidget->Modified(); + boxWidget->GetPlanes( planes ); + } // if + } else { + boxWidget->PlaceWidget(0,500,0,500,0,500); + }// if ImageInitSize +} void BoxWidget::Process() { - -// THE MAIN PROCESSING METHOD BODY -// Here we simply set the input 'In' value to the output 'Out' -// And print out the output value -// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : -// void bbSet{Input|Output}NAME(const TYPE&) -// const TYPE& bbGet{Input|Output}NAME() const -// Where : -// * NAME is the name of the input/output -// (the one provided in the attribute 'name' of the tag 'input') -// * TYPE is the C++ type of the input/output -// (the one provided in the attribute 'type' of the tag 'input') -// bbSetOutputOut( bbGetInputIn() ); -// std::cout << "Output value = " <SetInteractor( bbGetInputRenderer()->GetRenderWindow()->GetInteractor() ); - boxWidget->SetPlaceFactor(1.25); - if (bbGetInputImageInitSize()!=NULL) - { - int ext[6]; - bbGetInputImageInitSize()->GetExtent( ext ); - double spc[3]; - bbGetInputImageInitSize()->GetSpacing( spc ); - 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] ); - } else { - boxWidget->PlaceWidget(0,500,0,500,0,500); - }// if ImageInitSize - boxWidget->GetPlanes( planes ); - } // if firsttime - - // boxWidget->SetProp3D(coneActor); - bbBoxWidgetCallback *callback = bbBoxWidgetCallback::New(); - callback->SetBox( this ); - boxWidget->AddObserver(vtkCommand::InteractionEvent, callback); - - if (bbGetInputActive()==true) - { - boxWidget->On(); - } else { - boxWidget->Off(); - } // if Active - bbSetOutputImplicitFunction( planes ); - } else { - printf("EED Warnning! BoxWidget::Process vtkRenderer not set.\n"); - }// vtkRenderer != NULL - + + // THE MAIN PROCESSING METHOD BODY + // Here we simply set the input 'In' value to the output 'Out' + // And print out the output value + // INPUT/OUTPUT ACCESSORS ARE OF THE FORM : + // void bbSet{Input|Output}NAME(const TYPE&) + // const TYPE& bbGet{Input|Output}NAME() const + // Where : + // * NAME is the name of the input/output + // (the one provided in the attribute 'name' of the tag 'input') + // * TYPE is the C++ type of the input/output + // (the one provided in the attribute 'type' of the tag 'input') + // bbSetOutputOut( bbGetInputIn() ); + // std::cout << "Output value = " <SetInteractor( bbGetInputRenderer()->GetRenderWindow()->GetInteractor() ); + SetTransform( bbGetInputTransformIn() ); + } // if firsttime + + // boxWidget->SetProp3D(coneActor); + bbBoxWidgetCallback *callback = bbBoxWidgetCallback::New(); + callback->SetBox( this ); + boxWidget->AddObserver(vtkCommand::InteractionEvent, callback); + + if (bbGetInputActive()==true) + { + boxWidget->On(); + } else { + boxWidget->Off(); + } // if Active + bbSetOutputImplicitFunction( planes ); + boxWidget->GetTransform(transformOut); + bbSetOutputTransformOut( transformOut ); + } else { + printf("EED Warnning! BoxWidget::Process vtkRenderer not set.\n"); + }// vtkRenderer != NULL + + bbSetOutputBox_BoxWidget( this ); + + printf("EED BoxWidget::Process A\n"); + + } -//===== +//===== // 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) -//===== +//===== void BoxWidget::bbUserSetDefaultValues() { - -// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX -// Here we initialize the input 'In' to 0 - firsttime=true; + // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX + // Here we initialize the input 'In' to 0 + firsttime=true; bbSetInputRenderer(NULL); + bbSetInputTransformIn(NULL); bbSetInputActive( false ); + bbSetInputInitBoxChangeImage( false ); bbSetInputImageInitSize(NULL); + bbSetOutputTransformOut(NULL); } -//===== + +//===== // 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) -//===== +//===== void BoxWidget::bbUserInitializeProcessing() { - -// THE INITIALIZATION METHOD BODY : -// Here does nothing -// but this is where you should allocate the internal/output pointers -// if any - - + // THE INITIALIZATION METHOD BODY : + // Here does nothing + // but this is where you should allocate the internal/output pointers + // if any } -//===== + +//===== // 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) -//===== +//===== void BoxWidget::bbUserFinalizeProcessing() { - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - -} + + // THE FINALIZATION METHOD BODY : + // Here does nothing + // but this is where you should desallocate the internal/output pointers + // if any } -// EO namespace bbcreaVtk + +} // EO namespace bbcreaVtk diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.h b/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.h index cfa8bc6..1659b76 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkBoxWidget.h @@ -13,6 +13,7 @@ #include "vtkImplicitFunction.h" #include "vtkPlanes.h" #include "vtkImageData.h" +#include "vtkLinearTransform.h" namespace bbcreaVtk { @@ -25,17 +26,26 @@ class bbcreaVtk_EXPORT BoxWidget //===== // 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) //===== - BBTK_DECLARE_INPUT( Active , bool ); - BBTK_DECLARE_INPUT( Renderer , vtkRenderer* ); - BBTK_DECLARE_INPUT( ImageInitSize , vtkImageData* ); - BBTK_DECLARE_OUTPUT( ImplicitFunction , vtkImplicitFunction* ); + BBTK_DECLARE_INPUT( Active , bool ); + BBTK_DECLARE_INPUT( InitBoxChangeImage , bool ); + BBTK_DECLARE_INPUT( TransformIn , vtkLinearTransform* ); + BBTK_DECLARE_INPUT( Renderer , vtkRenderer* ); + BBTK_DECLARE_INPUT( ImageInitSize , vtkImageData* ); + BBTK_DECLARE_OUTPUT( ImplicitFunction , vtkImplicitFunction* ); + BBTK_DECLARE_OUTPUT( TransformOut , vtkLinearTransform* ); + BBTK_DECLARE_OUTPUT( Box_BoxWidget , BoxWidget* ); + BBTK_PROCESS(Process); - void Process(); + + void SetTransform( vtkLinearTransform* transform ); + void Process(); bool firsttime; vtkBoxWidget *boxWidget; vtkPlanes *planes; -//===== + vtkTransform *transformOut; + +//===== // 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) //===== }; @@ -47,10 +57,14 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(BoxWidget,bbtk::AtomicBlackBox); BBTK_CATEGORY("empty"); BBTK_INPUT(BoxWidget,Active,"(default false) true/false",bool,""); + BBTK_INPUT(BoxWidget,InitBoxChangeImage,"(default false) true/false",bool,""); + BBTK_INPUT(BoxWidget,TransformIn,"vtkLinearTransform",vtkLinearTransform*,""); BBTK_INPUT(BoxWidget,ImageInitSize,"(default NULL=> 0,500,0,500,0,500) Boudaring image size ",vtkImageData*,""); BBTK_INPUT(BoxWidget,Renderer,"vtkRenderer",vtkRenderer*,""); BBTK_OUTPUT(BoxWidget,ImplicitFunction,"vtkImplicitFunction",vtkImplicitFunction*,""); + BBTK_OUTPUT(BoxWidget,TransformOut,"vtkLinearTransform",vtkLinearTransform*,""); + BBTK_OUTPUT(BoxWidget,Box_BoxWidget,"bbtk Box BoxWidget",BoxWidget*,""); BBTK_END_DESCRIBE_BLACK_BOX(BoxWidget); //===== diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkClipPolyData.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkClipPolyData.cxx index 428518e..ad46cbc 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkClipPolyData.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkClipPolyData.cxx @@ -32,7 +32,9 @@ void ClipPolyData::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <