]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxGimmickView.cpp
new Output format and structure for Gimmick. Based on creaImageIO Output document...
[creaImageIO.git] / src / creaImageIOWxGimmickView.cpp
index 91185a56339be44eeed9d790087d31952aa4e5e0..f13c5e01823351ee46f29f898654879d85e07d42 100644 (file)
@@ -10,6 +10,8 @@
 #include <creaImageIOWxDescriptorPanel.h>
 #include <creaImageIOWxDumpPanel.h>
 #include <creaImageIOWxExportDlg.h>
+#include <creaImageIOWxOutputDlg.h>
+#include <creaImageIOOutputModel.h>
 
 using namespace crea;
 // Icons
@@ -298,18 +300,117 @@ namespace creaImageIO
   {
        std::vector<std::string> files;
        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
-       ReadImagesNotThreaded(s, files, dim);
+       //ReadImagesNotThreaded(s, files, dim);
+
+
+               std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+       //              ReadImagesNotThreadedInfosInVector(db_name,output, files,dim,1);
   }
 
+
+
   //======================================================================
   void WxGimmickView::GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
   {
        std::vector<std::string> files;
+       std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+
        ReadImagesNotThreadedInVector(s, files, dim);
   }
+
+
+  /// By default if out_infos is empty, we dont' provide informations, we return only vtkImageData 
+  /// if out_infos has only one entry "all" we provide all database informations
+  void WxGimmickView::getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> i_attr, 
+                                                                         bool mult, const std::string out_model)
+  {
+       // First we select the files
+    std::vector<std::string> files;
+       std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+       GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+
+       std::string asking;
+       std::string dim;
+       bool bsingle = isSingle(files.front());
+       int i_dim_out;
+       mGimmick->GetSetting(SETTINGS_OUTPUT_ASK, asking);
+       mGimmick->GetSetting(SETTINGS_OUTPUT_DIM, dim);
+
+       if (asking == "true")
+       {
+               // display the output dialog box
+               // get dim
+               int idim;
+               sscanf(dim.c_str(),"%d",&idim);
+               WxOutputDlg *dlg = new WxOutputDlg(this,files, idim -1, bsingle);
+               if (dlg->ShowModal() == wxID_OK)
+               {
+                       dim = dlg->getDim();
+                       mGimmick->UpdateSetting(SETTINGS_OUTPUT_ASK, dlg->getAsking());
+                       mGimmick->UpdateSetting(SETTINGS_OUTPUT_DIM, dim);
+               }
+               else
+               {
+                       return;
+               } 
+       }
+       else
+       {
+       }
+       sscanf(dim.c_str(),"%d",&i_dim_out);
+
+
+       // Next we create the structure for dicom output infos
+       OutputAttr Oattr;
+       Oattr.db = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
+       if(i_attr.empty())
+       {
+               // We don't send informations!
+       }
+       else if( i_attr.size() == 1 && i_attr.front() == "ALL")
+       {
+               // we send all database
+               Oattr.inside.push_back("ALL");
+       }
+       else if( (i_attr.size() == 1 && i_attr.front() != "ALL") 
+               || (i_attr.size() >1) )
+       {
+               mGimmick->fillVectInfos(i_attr, Oattr);
+       }
+       else
+       {
+               // nothing
+       }
+
+       // Next we create model and sort files
+       std::vector<std::string> sort_files(files);
+       double zspacing = 1;
+       if( !out_model.empty() )
+       {
+       /*      OutputModel mod(out_model);
+               mGimmick->isAttributeExist(db_name, mod);
+               mod.sort(files, sort_files);
+       */}
+
+       if ( sort_files.size() > 1 && ( (bsingle && i_dim_out == 1) || (!bsingle && i_dim_out ==3) ) )
+       {
+               OutputModel *mod = new OutputModel();
+               zspacing = mod->orderFilesWithZspacing(sort_files);
+               delete mod;
+       }
+       // Now we read and create the waiting output (vtkImageData * or OutGimmickData *)
+       readImages(outG, sort_files, Oattr, i_dim_out, zspacing);
+  }
+
+
+
+
   //======================================================================
 
+  //======================================================================
+
+
   //======================================================================
   void WxGimmickView::GetSelectedFiles(std::vector<std::string>& s)
   {