From: davila Date: Wed, 15 Oct 2014 15:35:57 +0000 (+0200) Subject: #2452 BBTK Feature New Normal - ComboBox in wx package X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b05f82ac827b39aceb736aaace5eb5cc3e914814;p=bbtk.git #2452 BBTK Feature New Normal - ComboBox in wx package --- diff --git a/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbg b/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbg index d7ffcd7..31e4013 100644 --- a/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbg +++ b/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbg @@ -18,11 +18,11 @@ FIN_COMPLEX_PORT COMPLEXINPUTS:5 COMPLEX_PORT Image --85.916642:51.532520:-900.000000 +-82.600387:87.016452:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT TitleAtribute -38.925088:53.676472:-900.000000 +36.935335:85.180898:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT wxvtkbaseview_01 @@ -40,14 +40,14 @@ BOXES:11 BOX toolsbbtk:SaveMHD-Button:Box00 ISEXEC:FALSE --110.966828:-4.496330:-900.000000 --65.391828:-14.496330:-900.000000 +-106.048862:0.749501:-900.000000 +-60.473862:-9.250499:-900.000000 FIN_BOX BOX creaMaracasVisu:ViewerNV:Box02 ISEXEC:FALSE --61.126666:-4.994216:-900.000000 --15.551666:-14.994216:-900.000000 +-54.569378:0.907343:-900.000000 +6.070622:-9.092657:-900.000000 FIN_BOX BOX wx:LayoutTab:Box03 @@ -56,18 +56,6 @@ ISEXEC:FALSE 30.695720:-114.285815:-900.000000 FIN_BOX BOX -wx:LayoutSplit:Box04 -ISEXEC:FALSE --44.771221:-81.345902:-900.000000 -0.803779:-91.345902:-900.000000 -PORT -Orientation:"V" -PORT -Proportion:"30" -PORT -WinTitle:"Info. image" -FIN_BOX -BOX vtk:vtkImageDataPointerRelay:Box09 ISEXEC:FALSE -91.353292:33.000764:-900.000000 @@ -76,8 +64,8 @@ FIN_BOX BOX toolsbbtk:ImageVtkPropertiesWidget:Box10 ISEXEC:FALSE --186.562751:-2.876554:-900.000000 --115.387751:-12.876554:-900.000000 +-180.333327:2.041412:-900.000000 +-109.158327:-7.958588:-900.000000 FIN_BOX BOX wx:LayoutLine:Box07 @@ -86,6 +74,8 @@ ISEXEC:FALSE -66.494068:-62.859982:-900.000000 PORT Orientation:"H" +PORT +WinTitle:"Info" FIN_BOX BOX vtk:RescaleSlopeIntercept:Box08 @@ -95,7 +85,7 @@ ISEXEC:FALSE PORT A:"0" PORT -B:"1000" +B:"90" PORT OutputFormat:"VTK_UNSIGNED_SHORT" PORT @@ -116,20 +106,29 @@ ISEXEC:FALSE 119.643147:-55.369167:-900.000000 PORT Active:"false" +PORT +lstBaseColor:"0 0 1 0 1 1 1 1 0 1 0 0" FIN_BOX BOX wx:LayoutLine:Box13 ISEXEC:FALSE 53.203629:-68.313438:-900.000000 -110.763629:-78.313438:-900.000000 +98.778629:-78.313438:-900.000000 PORT WinTitle:"Color Layer" FIN_BOX +BOX +wx:LayoutLine:Box14 +ISEXEC:FALSE +-44.314991:-50.436135:-900.000000 +13.245009:-60.436135:-900.000000 +PORT +Orientation:"H" +PORT +WinTitle:"View" +FIN_BOX CONNECTIONS:19 CONNECTION -Box02:Widget:Box04:Widget2 -NumberOfControlPoints:0 -CONNECTION Image:Image:Box09:In NumberOfControlPoints:0 CONNECTION @@ -148,12 +147,6 @@ CONNECTION Box10:widget:Box07:Widget1 NumberOfControlPoints:0 CONNECTION -Box07:Widget:Box04:Widget1 -NumberOfControlPoints:0 -CONNECTION -Box04:Widget:Box03:Widget1 -NumberOfControlPoints:0 -CONNECTION Box03:Widget:widget:widget NumberOfControlPoints:0 CONNECTION @@ -169,18 +162,27 @@ CONNECTION Box11:Out:Box12:In NumberOfControlPoints:0 CONNECTION -wxvtkbaseview_01:wxvtkbaseview_01:Box12:WxVtkBaseView +wxvtkbaseview_03:wxvtkbaseview_03:Box12:WxVtkBaseView2 +NumberOfControlPoints:0 +CONNECTION +Box12:Widget:Box13:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box07:Widget:Box03:Widget3 +NumberOfControlPoints:0 +CONNECTION +Box02:Widget:Box14:Widget1 NumberOfControlPoints:0 CONNECTION wxvtkbaseview_02:wxvtkbaseview_02:Box12:WxVtkBaseView1 NumberOfControlPoints:0 CONNECTION -wxvtkbaseview_03:wxvtkbaseview_03:Box12:WxVtkBaseView2 +wxvtkbaseview_01:wxvtkbaseview_01:Box12:WxVtkBaseView NumberOfControlPoints:0 CONNECTION -Box12:Widget:Box13:Widget1 +Box13:Widget:Box03:Widget1 NumberOfControlPoints:0 CONNECTION -Box13:Widget:Box03:Widget2 +Box14:Widget:Box03:Widget2 NumberOfControlPoints:0 APP_END diff --git a/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbs b/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbs index c25a3d9..b1df0a6 100644 --- a/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbs +++ b/packages/toolsbbtk/bbs/boxes/BaseViewerInfo.bbs @@ -23,21 +23,17 @@ new ViewerNV Box02 new LayoutTab Box03 -new LayoutSplit Box04 - set Box04.Orientation "V" - set Box04.Proportion "30" - set Box04.WinTitle "Info. image" - new vtkImageDataPointerRelay Box09 new ImageVtkPropertiesWidget Box10 new LayoutLine Box07 set Box07.Orientation "H" + set Box07.WinTitle "Info" new RescaleSlopeIntercept Box08 set Box08.A "0" - set Box08.B "1000" + set Box08.B "90" set Box08.OutputFormat "VTK_UNSIGNED_SHORT" set Box08.Type "2" @@ -46,31 +42,36 @@ new ImageChangeInformation Box11 new ColorLayerImageView Box12 set Box12.Active "false" + set Box12.lstBaseColor "0 0 1 0 1 1 1 1 0 1 0 0" new LayoutLine Box13 set Box13.WinTitle "Color Layer" +new LayoutLine Box14 + set Box14.Orientation "H" + set Box14.WinTitle "View" + -connect Box02.Widget Box04.Widget2 connect Box09.Out Box00.In connect Box09.Out Box10.in connect Box09.Out Box02.In connect Box00.Widget Box07.Widget2 connect Box10.widget Box07.Widget1 -connect Box07.Widget Box04.Widget1 -connect Box04.Widget Box03.Widget1 connect Box09.Out Box08.In connect Box08.Out Box11.In connect Box11.Out Box12.In connect Box12.Widget Box13.Widget1 -connect Box13.Widget Box03.Widget2 +connect Box07.Widget Box03.Widget3 +connect Box02.Widget Box14.Widget1 +connect Box13.Widget Box03.Widget1 +connect Box14.Widget Box03.Widget2 # Complex input ports input Image Box09.In " " input TitleAtribute Box03.WinTitle " " -input wxvtkbaseview_01 Box12.WxVtkBaseView " " -input wxvtkbaseview_02 Box12.WxVtkBaseView1 " " input wxvtkbaseview_03 Box12.WxVtkBaseView2 " " +input wxvtkbaseview_02 Box12.WxVtkBaseView1 " " +input wxvtkbaseview_01 Box12.WxVtkBaseView " " # Complex output ports output widget Box03.Widget " " diff --git a/packages/vtk/bbs/boxes/TransformWidget.bbg b/packages/vtk/bbs/boxes/TransformWidget.bbg index 5a54fba..6127e6f 100644 --- a/packages/vtk/bbs/boxes/TransformWidget.bbg +++ b/packages/vtk/bbs/boxes/TransformWidget.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /home/davila/Creatis/All/creatools_source/bbtk/packages/vtk/bbs/boxes/TransformWidget.bbg +# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/vtk/bbs/boxes/TransformWidget.bbg # ---------------------------------- APP_START @@ -23,19 +23,23 @@ COMPLEX_PORT BoxChange -190.649216:-158.865916:-900.000000 FIN_COMPLEX_PORT -COMPLEXINPUTS:0 +COMPLEXINPUTS:1 +COMPLEX_PORT +TitleWindow +36.138665:171.471207:-900.000000 +FIN_COMPLEX_PORT BOXES:29 BOX wx:LayoutTab:Box00 ISEXEC:FALSE 14.507537:-147.233687:-900.000000 -60.082537:-157.233687:-900.000000 +72.067537:-157.233687:-900.000000 FIN_BOX BOX wx:LayoutLine:Box01 ISEXEC:FALSE -41.534584:-108.537426:-900.000000 -4.040416:-118.537426:-900.000000 +16.025416:-118.537426:-900.000000 PORT WinTitle:"Rotation" FIN_BOX @@ -43,7 +47,7 @@ BOX wx:Slider:Box03 ISEXEC:FALSE -197.665356:146.434686:-900.000000 --132.404978:136.434686:-900.000000 +-146.265356:136.434686:-900.000000 PORT ChangeResolution:"true" PORT @@ -61,7 +65,7 @@ BOX wx:Slider:Box04 ISEXEC:FALSE -153.996282:129.813557:-900.000000 --119.179436:119.813557:-900.000000 +-102.596282:119.813557:-900.000000 PORT ChangeResolution:"true" PORT @@ -79,7 +83,7 @@ BOX wx:Slider:Box05 ISEXEC:FALSE -68.019168:146.959188:-900.000000 --35.244168:136.959188:-900.000000 +-16.619168:136.959188:-900.000000 PORT ChangeResolution:"true" PORT @@ -97,7 +101,7 @@ BOX wx:LayoutLine:Box06 ISEXEC:FALSE 23.720064:-108.213700:-900.000000 -69.295064:-118.213700:-900.000000 +81.280064:-118.213700:-900.000000 PORT WinTitle:"Translate" FIN_BOX @@ -105,7 +109,7 @@ BOX wx:Slider:Box07 ISEXEC:FALSE -11.514057:86.479654:-900.000000 -21.260943:76.479654:-900.000000 +39.885943:76.479654:-900.000000 PORT ChangeResolution:"true" PORT @@ -123,7 +127,7 @@ BOX wx:Slider:Box08 ISEXEC:FALSE 6.385006:71.964258:-900.000000 -39.160006:61.964258:-900.000000 +57.785006:61.964258:-900.000000 PORT ChangeResolution:"true" PORT @@ -141,7 +145,7 @@ BOX wx:Slider:Box09 ISEXEC:FALSE 28.124282:58.249919:-900.000000 -60.899282:48.249919:-900.000000 +79.524282:48.249919:-900.000000 PORT ChangeResolution:"true" PORT @@ -159,7 +163,7 @@ BOX wx:LayoutLine:Box10 ISEXEC:FALSE 101.086854:-111.014230:-900.000000 -146.661854:-121.014230:-900.000000 +158.646854:-121.014230:-900.000000 PORT WinTitle:"Scale" FIN_BOX @@ -167,7 +171,7 @@ BOX wx:Slider:Box11 ISEXEC:FALSE 70.956408:111.372736:-900.000000 -103.731408:101.372736:-900.000000 +122.356408:101.372736:-900.000000 PORT ChangeResolution:"true" PORT @@ -187,7 +191,7 @@ BOX wx:Slider:Box12 ISEXEC:FALSE 88.855471:96.857340:-900.000000 -121.630471:86.857340:-900.000000 +140.255471:86.857340:-900.000000 PORT ChangeResolution:"true" PORT @@ -207,7 +211,7 @@ BOX wx:Slider:Box13 ISEXEC:FALSE 102.852794:83.842614:-900.000000 -135.627794:73.842614:-900.000000 +154.252794:73.842614:-900.000000 PORT ChangeResolution:"true" PORT @@ -233,7 +237,7 @@ BOX std:ConcatStrings:Box15 ISEXEC:FALSE -223.525177:80.984845:-900.000000 --152.540071:70.984845:-900.000000 +-177.950177:70.984845:-900.000000 PORT In2:" " PORT @@ -311,7 +315,7 @@ BOX vtk:Transform:Box28 ISEXEC:FALSE -235.026591:62.160050:-900.000000 --171.547037:52.160050:-900.000000 +-189.451591:52.160050:-900.000000 FIN_BOX BOX std:ConcatStrings:Box29 @@ -345,7 +349,7 @@ ISEXEC:FALSE -116.001331:8.470310:-900.000000 -70.426331:-1.529690:-900.000000 FIN_BOX -CONNECTIONS:48 +CONNECTIONS:49 CONNECTION Box01:Widget:Box00:Widget1 NumberOfControlPoints:0 @@ -490,4 +494,7 @@ NumberOfControlPoints:0 CONNECTION Box32:Out:Box14:In NumberOfControlPoints:0 +CONNECTION +TitleWindow:TitleWindow:Box00:WinTitle +NumberOfControlPoints:0 APP_END diff --git a/packages/vtk/bbs/boxes/TransformWidget.bbs b/packages/vtk/bbs/boxes/TransformWidget.bbs index 0135c82..42da296 100644 --- a/packages/vtk/bbs/boxes/TransformWidget.bbs +++ b/packages/vtk/bbs/boxes/TransformWidget.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) -# - /home/davila/Creatis/All/creatools_source/bbtk/packages/vtk/bbs/boxes/TransformWidget.bbs +# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/vtk/bbs/boxes/TransformWidget.bbs # ---------------------------------- include std @@ -195,11 +195,13 @@ connect Box30.Out Box32.In connect Box32.Out Box14.In # Complex input ports +input TitleWindow Box00.WinTitle " " # Complex output ports output Transform Box14.Out " " output Window Box00.Widget " " output BoxChange Box14.BoxChange " " +message endefine diff --git a/packages/wx/src/bbwxComboBox.cxx b/packages/wx/src/bbwxComboBox.cxx index 4d4ce17..e76d44f 100644 --- a/packages/wx/src/bbwxComboBox.cxx +++ b/packages/wx/src/bbwxComboBox.cxx @@ -9,6 +9,8 @@ #include #include +#include +#include namespace bbwx { @@ -20,14 +22,17 @@ namespace bbwx ComboBoxWidget( ComboBox* box, wxWindow *parent, int iSelection, std::string title, - std::vector< std::string > lstIn ); + std::vector< std::string > lstIn, + int typeForm ); ~ComboBoxWidget(); void OnComboBox(wxEvent& event); private: - ComboBox *mBox; + int mTypeForm; + ComboBox *mBox; + wxListBox *wxlistbox; wxChoice *wxchoice; }; @@ -42,28 +47,19 @@ namespace bbwx wxWindow *parent, int iSelection, std::string title, - std::vector< std::string > lstIn ) + std::vector< std::string > lstIn, + int typeForm) : wxPanel( parent, -1) , - mBox(box) + mBox(box), + mTypeForm(typeForm) { - wxPanel *panel = this; + wxPanel *panel = this; + wxlistbox = NULL; + wxchoice = NULL; + int i; - - //--------------------------------------------------------------------- - // 1) Creation de wxChoise widget - - wxchoice = new wxChoice ( panel , -1 ); - - Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); - - int i; - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - wxchoice->SetSelection(iSelection); //--------------------------------------------------------------------- // 2) Insertion of the components in the window @@ -74,10 +70,38 @@ namespace bbwx { sizer->Add( new wxStaticText(panel,-1, bbtk::std2wx(title) ) ); } - sizer->Add( wxchoice,1,wxGROW ); sizer->AddGrowableCol(0); panel->SetSizer(sizer); + + //--------------------------------------------------------------------- + // 1) Creation de wxChoise widget + + if (mTypeForm==1) + { + + wxlistbox = new wxListBox ( panel , -1 ); + Connect( wxlistbox->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); + for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); + } // for i + wxlistbox->SetSelection(iSelection); + sizer->Add( wxlistbox,1,wxGROW ); + + } else { + + wxchoice = new wxChoice ( panel , -1 ); + Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); + for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); + } // for i + wxchoice->SetSelection(iSelection); + sizer->Add( wxchoice,1,wxGROW ); + } + + // panel->SetAutoLayout(true); // panel->Layout(); @@ -91,10 +115,15 @@ namespace bbwx //-------------------------------------------------------------------------- void ComboBoxWidget::OnComboBox(wxEvent& event) { + int iSelection; + if (mTypeForm==1) + { + iSelection = wxlistbox->GetSelection(); + } else { + iSelection = wxchoice->GetSelection(); + } - int iSelection = wxchoice->GetSelection(); mBox->bbSetInputSelection( iSelection ); - mBox->bbSetOutputOut( iSelection ); mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) ); mBox->bbSignalOutputModification("Out"); @@ -125,7 +154,8 @@ void ComboBox::CreateWidget(wxWindow* parent) parent, bbGetInputSelection() , bbGetInputTitle(), - bbGetInputIn() ); + bbGetInputIn(), + bbGetInputForm() ); bbSetOutputOut( bbGetInputSelection() ); bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] ); @@ -140,6 +170,7 @@ void ComboBox::bbUserSetDefaultValues() { bbSetInputSelection(0); bbSetInputTitle(""); + bbSetInputForm(0); } //===== // 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) diff --git a/packages/wx/src/bbwxComboBox.h b/packages/wx/src/bbwxComboBox.h index 2d59f16..a1182f9 100644 --- a/packages/wx/src/bbwxComboBox.h +++ b/packages/wx/src/bbwxComboBox.h @@ -21,6 +21,7 @@ class bbwx_EXPORT ComboBox BBTK_DECLARE_INPUT(Title,std::string); BBTK_DECLARE_INPUT(Selection, int ); BBTK_DECLARE_INPUT(In,std::vector< std::string >); + BBTK_DECLARE_INPUT(Form, int ); BBTK_DECLARE_OUTPUT(Out, int ); BBTK_DECLARE_OUTPUT(OutString, std::string ); BBTK_PROCESS(Process); @@ -40,6 +41,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ComboBox,bbtk::WxBlackBox); BBTK_INPUT(ComboBox,Title,"Title prepended to the text",std::string,""); BBTK_INPUT(ComboBox,Selection,"i element to be selected (default 0)",int,""); BBTK_INPUT(ComboBox,In,"Vector of strings",std::vector< std::string >,""); + BBTK_INPUT(ComboBox,Form,"0 Combobox, 1 List (default 0)",int,""); BBTK_OUTPUT(ComboBox,Out,"i Item selected",int,""); BBTK_OUTPUT(ComboBox,OutString,"string Item selected",std::string,""); diff --git a/packages/wx/src/bbwxFileSelector.cxx b/packages/wx/src/bbwxFileSelector.cxx index d195b70..4757485 100644 --- a/packages/wx/src/bbwxFileSelector.cxx +++ b/packages/wx/src/bbwxFileSelector.cxx @@ -111,6 +111,7 @@ namespace bbwx if (FD->GetReturnCode()==wxID_OK) { bbSetOutputOut( bbtk::wx2std (FD->GetPath()) ); + bbSignalOutputModification(std::string("Out")); } else {