]> Creatis software - creaMaracasVisu.git/commitdiff
#3556 Box TransformWidget2_tool vtk9itk5wx3-macos
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Wed, 8 May 2024 07:30:42 +0000 (09:30 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Wed, 8 May 2024 07:30:42 +0000 (09:30 +0200)
bbtk/bbs/boxes/FreePlane.bbg
bbtk/bbs/boxes/FreePlane.bbs
bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx
bbtk/src/bbcreaMaracasVisuTransformWidget2.h
bbtk/src/bbcreaMaracasVisuTransformWidget2_tool.cxx [new file with mode: 0644]
bbtk/src/bbcreaMaracasVisuTransformWidget2_tool.h [new file with mode: 0644]
bbtk/src/bbmaracasvisuSliderMinMax.cxx

index eb1ea4b271823d039a3044ebf54d7ab405c7795f..4b0868c711d33ed49ded106ef3bc79f7d8437825 100644 (file)
@@ -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/creaMaracasVisu/bbtk/bbs/boxes/FreePlane.bbg
 # ----------------------------------
 
@@ -7,10 +7,11 @@ APP_START
 CATEGORY:<VOID>
 DESCRIPTION:Description ??
 AUTHOR:Author ??
+EXPORTFORMAT:0
 COMPLEXBOX:TRUE
 COMPLEXBOXNAME:FreePlane
 PACKAGENAME:creaMaracasVisu
-COMPLEXOUTPUTS:4
+COMPLEXOUTPUTS:5
 COMPLEX_PORT
 widgetOut
 -62.602729:-39.249279:-900.000000
@@ -27,6 +28,10 @@ COMPLEX_PORT
 boxChange
 -109.488119:-40.220094:-900.000000
 FIN_COMPLEX_PORT
+COMPLEX_PORT
+box_TransformWidget2
+-30.291440:-37.573030:-900.000000
+FIN_COMPLEX_PORT
 COMPLEXINPUTS:5
 COMPLEX_PORT
 possiblePoint
@@ -225,7 +230,7 @@ ISEXEC:FALSE
 PORT
 Active:"true"
 FIN_BOX
-CONNECTIONS:46
+CONNECTIONS:47
 CONNECTION
 Box02:Out:Box04:In
 NumberOfControlPoints:0
@@ -364,4 +369,7 @@ NumberOfControlPoints:0
 CONNECTION
 Box16:BoxChange:boxChange:boxChange
 NumberOfControlPoints:0
+CONNECTION
+Box16:Box_TransformWidget2:box_TransformWidget2:box_TransformWidget2
+NumberOfControlPoints:0
 APP_END
index ebc297d1b4c17a2be8be54e4cab39d6b287f70f1..0e8eb482782732f4625410a7103e4f5526b89d32 100644 (file)
@@ -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/creaMaracasVisu/bbtk/bbs/boxes/FreePlane.bbs
 # ----------------------------------
 
@@ -137,6 +137,7 @@ output widgetOut Box01.Widget " "
 output transform Box16.Out " "
 output actualPoint Box08.Out " "
 output boxChange Box16.BoxChange " "
+output box_TransformWidget2 Box16.Box_TransformWidget2 " "
 
 
 endefine
index 2bb4f19f95aac03c2fbe00c7ee3c06316fd4ebf8..f35942cd1b635d59484e907cfba91c3a827ba274 100644 (file)
@@ -39,7 +39,9 @@ public:
     void OnRadioButtonZ(wxEvent& event);
     void OnRadioButtonN(wxEvent& event);
     void OnSave(wxCommandEvent& event);
+    void Save(std::string filename);
     void OnLoad(wxCommandEvent& event);
+    void Load(std::string filename);
     void OnReset(wxCommandEvent& event);
     void OnMoveDown(wxCommandEvent& event);
     void OnMoveUp(wxCommandEvent& event);
@@ -405,6 +407,26 @@ void TransformWidgetPanel::OnMemory(wxCommandEvent& event)
     mMemoryMatrix->DeepCopy( t->GetMatrix() );
 }
 
+void TransformWidgetPanel::Save(std::string filename)
+{
+    FILE *ff;
+    ff = fopen( filename.c_str() , "w+" );
+    if (ff!=NULL)
+    {
+        fprintf(ff,"ActualPoint:\n");
+        fprintf(ff,"%f  %f  %f\n",mActualPoint[0], mActualPoint[1], mActualPoint[2] );
+        vtkMatrix4x4 *m = t->GetMatrix();
+        fprintf(ff,"Transform:\n");
+        fprintf(ff,"%f  %f  %f  %f  \n",m->GetElement(0,0), m->GetElement(1,0), m->GetElement(2,0), m->GetElement(3,0) );
+        fprintf(ff,"%f  %f  %f  %f  \n",m->GetElement(0,1), m->GetElement(1,1), m->GetElement(2,1), m->GetElement(3,1) );
+        fprintf(ff,"%f  %f  %f  %f  \n",m->GetElement(0,2), m->GetElement(1,2), m->GetElement(2,2), m->GetElement(3,2) );
+        fprintf(ff,"%f  %f  %f  %f\n\n",m->GetElement(0,3), m->GetElement(1,3), m->GetElement(2,3), m->GetElement(3,3) );
+        fclose(ff);
+    } else {   // else ff
+        printf("TransformWidgetPanel::OnSave  ...Error... creating file \n");
+    } //ff
+}
+
 void TransformWidgetPanel::OnSave(wxCommandEvent& event)
 {
     wxFileDialog* FD = new wxFileDialog( 0,
@@ -421,29 +443,63 @@ void TransformWidgetPanel::OnSave(wxCommandEvent& event)
     if (FD->GetReturnCode()==wxID_OK)
     {
         std::string filename= (const char*) ( FD->GetPath().mb_str() );
-        FILE *ff;
-        ff = fopen( filename.c_str() , "w+" );
-        if (ff!=NULL)
-        {
-            fprintf(ff,"ActualPoint:\n");
-            fprintf(ff,"%f  %f  %f\n",mActualPoint[0], mActualPoint[1], mActualPoint[2] );
-            vtkMatrix4x4 *m = t->GetMatrix();
-            fprintf(ff,"Transform:\n");
-            fprintf(ff,"%f  %f  %f  %f  \n",m->GetElement(0,0), m->GetElement(1,0), m->GetElement(2,0), m->GetElement(3,0) );
-            fprintf(ff,"%f  %f  %f  %f  \n",m->GetElement(0,1), m->GetElement(1,1), m->GetElement(2,1), m->GetElement(3,1) );
-            fprintf(ff,"%f  %f  %f  %f  \n",m->GetElement(0,2), m->GetElement(1,2), m->GetElement(2,2), m->GetElement(3,2) );
-            fprintf(ff,"%f  %f  %f  %f\n\n",m->GetElement(0,3), m->GetElement(1,3), m->GetElement(2,3), m->GetElement(3,3) );
-            fclose(ff);
-        } else {   // else ff
-            printf("TransformWidgetPanel::OnSave  ...Error... creating file \n");
-        } //ff
+        Save( filename );
     }     // dialog box
 }
 
+void TransformWidgetPanel::Load(std::string filename)
+{
+    FILE *ff;
+    ff = fopen( filename.c_str() , "r" );
+    if (ff!=NULL)
+    {
+        char tmpStr[128];
+        float t0,t1,t2,t3;
+        fscanf(ff,"%s\n",tmpStr);  // ActualPoint:
+        fscanf(ff,"%f  %f  %f\n",&t0,&t1,&t2);
+        mActualPoint[0]=t0;
+        mActualPoint[1]=t1;
+        mActualPoint[2]=t2;
+
+        vtkMatrix4x4 *m = t->GetMatrix();
+        fscanf(ff,"%s\n",tmpStr); // Transform:
+        fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
+        m->SetElement(0,0,t0);
+        m->SetElement(1,0,t1);
+        m->SetElement(2,0,t2);
+        m->SetElement(3,0,t3);
+        fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
+        m->SetElement(0,1,t0);
+        m->SetElement(1,1,t1);
+        m->SetElement(2,1,t2);
+        m->SetElement(3,1,t3);
+        fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
+        m->SetElement(0,2,t0);
+        m->SetElement(1,2,t1);
+        m->SetElement(2,2,t2);
+        m->SetElement(3,2,t3);
+        fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
+        m->SetElement(0,3,t0);
+        m->SetElement(1,3,t1);
+        m->SetElement(2,3,t2);
+        m->SetElement(3,3,t3);
+        t->Update();
+
+        mBox->bbSetOutputActualPoint( mActualPoint );
+        mBox->bbSignalOutputModification(std::string("ActualPoint"));
+        mBox->bbSetOutputOut( t );
+        mBox->bbSignalOutputModification(std::string("Out"));
+
+        fclose(ff);
+    } else {   // else ff
+        printf("TransformWidgetPanel::OnLoad  ...Error... reading file \n");
+    } //ff
+}
+
 void TransformWidgetPanel::OnLoad(wxCommandEvent& event)
 {
     wxFileDialog* FD = new wxFileDialog( 0,
-                                         _T("Load groups of points .."),
+                                         _T("Load configuration.."),
                                          _T(""),
                                          _T(""),
                                          _T("(*.fpConf)|*.fpConf"),
@@ -456,53 +512,8 @@ void TransformWidgetPanel::OnLoad(wxCommandEvent& event)
     if (FD->GetReturnCode()==wxID_OK)
     {
         std::string filename= (const char*) ( FD->GetPath().mb_str() );
-        FILE *ff;
-        ff = fopen( filename.c_str() , "r" );
-        if (ff!=NULL)
-        {
-            char tmpStr[128];
-            float t0,t1,t2,t3;
-            fscanf(ff,"%s\n",tmpStr);  // ActualPoint:
-            fscanf(ff,"%f  %f  %f\n",&t0,&t1,&t2);
-            mActualPoint[0]=t0;
-            mActualPoint[1]=t1;
-            mActualPoint[2]=t2;
-
-            vtkMatrix4x4 *m = t->GetMatrix();
-            fscanf(ff,"%s\n",tmpStr); // Transform:
-            fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
-            m->SetElement(0,0,t0);
-            m->SetElement(1,0,t1);
-            m->SetElement(2,0,t2);
-            m->SetElement(3,0,t3);
-            fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
-            m->SetElement(0,1,t0);
-            m->SetElement(1,1,t1);
-            m->SetElement(2,1,t2);
-            m->SetElement(3,1,t3);
-            fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
-            m->SetElement(0,2,t0);
-            m->SetElement(1,2,t1);
-            m->SetElement(2,2,t2);
-            m->SetElement(3,2,t3);
-            fscanf(ff,"%f %f  %f %f\n",&t0,&t1,&t2,&t3);
-            m->SetElement(0,3,t0);
-            m->SetElement(1,3,t1);
-            m->SetElement(2,3,t2);
-            m->SetElement(3,3,t3);
-            t->Update();
-
-            mBox->bbSetOutputActualPoint( mActualPoint );
-            mBox->bbSignalOutputModification(std::string("ActualPoint"));
-            mBox->bbSetOutputOut( t );
-            mBox->bbSignalOutputModification(std::string("Out"));
-
-            fclose(ff);
-        } else {   // else ff
-            printf("TransformWidgetPanel::OnLoad  ...Error... reading file \n");
-        } //ff
+        Load( filename );
     }     // dialog box
-
 }
 
 
@@ -555,6 +566,22 @@ BBTK_BLACK_BOX_IMPLEMENTATION(TransformWidget2,bbtk::WxBlackBox);
 //===== 
 // 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 TransformWidget2::Save(std::string filename)
+{
+    TransformWidgetPanel *w = (TransformWidgetPanel*) bbGetOutputWidget( );
+    w->Save(filename);
+}
+
+//------------------------------------------------------
+void TransformWidget2::Load(std::string filename)
+{
+    TransformWidgetPanel *w = (TransformWidgetPanel*) bbGetOutputWidget( );
+    w->Load(filename);
+}
+
+//------------------------------------------------------
 void TransformWidget2::Process()
 {
     TransformWidgetPanel *w = (TransformWidgetPanel*) bbGetOutputWidget( );
@@ -563,6 +590,7 @@ void TransformWidget2::Process()
     {
         firsttime=false;
         w->_OnSetPoint();
+        bbSetOutputBox_TransformWidget2(this);
     }// if
 }
 
@@ -582,6 +610,7 @@ void TransformWidget2::bbUserSetDefaultValues()
 {
     firsttime=true;
     bbSetInputType(1);
+    bbSetOutputBox_TransformWidget2(NULL);
 }
 
 //===== 
index 1e2e884c3e7e276023f1dfa6768d3eacdfd8985f..f77236d88368ec0b39e2710dde697d3675d0741d 100644 (file)
@@ -25,7 +25,10 @@ class bbcreaMaracasVisu_EXPORT TransformWidget2
     BBTK_DECLARE_INPUT(PossiblePoint,std::vector< double >);
     BBTK_DECLARE_OUTPUT(Out,vtkLinearTransform *);
     BBTK_DECLARE_OUTPUT(ActualPoint,std::vector< double >);
+    BBTK_DECLARE_OUTPUT(Box_TransformWidget2,TransformWidget2*);
     BBTK_PROCESS(Process);
+    void Save(std::string filename);
+    void Load(std::string filename);
     void Process();
     BBTK_CREATE_WIDGET(CreateWidget);
     void CreateWidget(wxWindow*);
@@ -44,6 +47,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(TransformWidget2,bbtk::WxBlackBox);
     BBTK_INPUT(TransformWidget2,PossiblePoint,"Potential Point [x y z]",std::vector<double>,"");
     BBTK_OUTPUT(TransformWidget2,Out,"vtkTransform result",vtkLinearTransform *,"");
     BBTK_OUTPUT(TransformWidget2,ActualPoint,"Origin [x,y,z]",std::vector<double>,"");
+    BBTK_OUTPUT(TransformWidget2,Box_TransformWidget2,"bbtk box TransformWidget2",TransformWidget2*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(TransformWidget2);
 //===== 
 // 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/bbtk/src/bbcreaMaracasVisuTransformWidget2_tool.cxx b/bbtk/src/bbcreaMaracasVisuTransformWidget2_tool.cxx
new file mode 100644 (file)
index 0000000..ed2c15d
--- /dev/null
@@ -0,0 +1,86 @@
+//===== 
+// 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)
+//===== 
+#include "bbcreaMaracasVisuTransformWidget2_tool.h"
+#include "bbcreaMaracasVisuPackage.h"
+namespace bbcreaMaracasVisu
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,TransformWidget2_tool)
+BBTK_BLACK_BOX_IMPLEMENTATION(TransformWidget2_tool,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)
+//===== 
+void TransformWidget2_tool::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 = " <<bbGetOutputOut() << std::endl;
+  
+    if (bbGetInputType()==1)
+    {
+        if (bbGetInputParam01().size()==1)
+        {
+            bbGetInputBox_TransformWidget2()->Save( bbGetInputParam01()[0] );
+        }
+    } // Type 1 Save
+    if (bbGetInputType()==2)
+    {
+        if (bbGetInputParam01().size()==1)
+        {
+            bbGetInputBox_TransformWidget2()->Load( bbGetInputParam01()[0] );
+        }
+    } // Type 2 Load
+
+}
+//===== 
+// 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 TransformWidget2_tool::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+   bbSetInputType(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)
+//===== 
+void TransformWidget2_tool::bbUserInitializeProcessing()
+{
+
+//  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 TransformWidget2_tool::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbcreaMaracasVisu
+
+
diff --git a/bbtk/src/bbcreaMaracasVisuTransformWidget2_tool.h b/bbtk/src/bbcreaMaracasVisuTransformWidget2_tool.h
new file mode 100644 (file)
index 0000000..e314c80
--- /dev/null
@@ -0,0 +1,53 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbcreaMaracasVisuTransformWidget2_tool_h_INCLUDED__
+#define __bbcreaMaracasVisuTransformWidget2_tool_h_INCLUDED__
+
+#include "bbcreaMaracasVisu_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "bbcreaMaracasVisuTransformWidget2.h"
+
+
+namespace bbcreaMaracasVisu
+{
+
+class bbcreaMaracasVisu_EXPORT TransformWidget2_tool
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(TransformWidget2_tool,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)
+//===== 
+  BBTK_DECLARE_INPUT(Type,int);
+    BBTK_DECLARE_INPUT(Param01,std::vector<std::string>);
+    BBTK_DECLARE_INPUT(Box_TransformWidget2,TransformWidget2*);
+//  BBTK_DECLARE_OUTPUT(Out,double);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// 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_BEGIN_DESCRIBE_BLACK_BOX(TransformWidget2_tool,bbtk::AtomicBlackBox);
+  BBTK_NAME("TransformWidget2_tool");
+  BBTK_AUTHOR("InfoDev");
+  BBTK_DESCRIPTION("No Description.");
+  BBTK_CATEGORY("empty");
+  BBTK_INPUT(TransformWidget2_tool,Type,"(default 0)  0:Nothing 1:Save file configuration 2:Load file configuration",int,"");
+  BBTK_INPUT(TransformWidget2_tool,Param01,"1:[FileName_save] 2:[FileName_load]",std::vector<std::string>,"");
+  BBTK_INPUT(TransformWidget2_tool,Box_TransformWidget2,"bbtk Box TransformWidget2",TransformWidget2*,"");
+//  BBTK_OUTPUT(TransformWidget2_tool,Out,"First output",double,"");
+BBTK_END_DESCRIBE_BLACK_BOX(TransformWidget2_tool);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbcreaMaracasVisu
+
+#endif // __bbcreaMaracasVisuTransformWidget2_tool_h_INCLUDED__
+
index e9cc90a0f2234b1a5b7a6efe6196d2c7fd4534cb..6b432f44a4ffd72c96f2429c94b5bead59b9cb3b 100644 (file)
@@ -110,12 +110,13 @@ void SliderMinMax::Process()
        if (mwxwidget!=NULL)
        {
                mwxwidget -> setRepresentedValues( bbGetInputInMin(), bbGetInputInMax() );
-               if (firsttime==true)
-               {
-                       firsttime=false;
+//             if (firsttime==true)
+//             {
+//                     firsttime=false;
                        mwxwidget -> SetStart(bbGetInputInMinShow());
-                       mwxwidget -> SetEnd(bbGetInputInMaxShow());  
-               }
+                       mwxwidget -> SetEnd(bbGetInputInMaxShow());
+//             }
+
                bbSetOutputOutStart(mwxwidget->GetStart());
                bbSetOutputOutEnd(mwxwidget->GetEnd());
                bbSetOutputOutActual(mwxwidget->GetActual());