]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxGimmick.cpp
-------------------------------------------------------------
[creaImageIO.git] / src / creaImageIOWxGimmick.cpp
index 2bcc3ab50c53bc08f25fcdfd1ebbae703b725365..6a203a37d3d5bd05f5c92f5333d1829f38052259 100644 (file)
@@ -19,7 +19,8 @@
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 
-#include<wx/filefn.h>
+#include <wx/filefn.h>
+//#include <wx/tipwin.h>
 
 using namespace crea;
 
@@ -209,18 +210,6 @@ namespace creaImageIO
 
 
 
-  //================================================================
-  class WxGimmickSettingsDialog : public wxDialog
-  {
-  public:
-    WxGimmickSettingsDialog(wxWindow *parent);
-    ~WxGimmickSettingsDialog();
-    
-    
-  };
-  //================================================================
-
-
 
 
 
@@ -381,7 +370,7 @@ namespace creaImageIO
     rpanel->Layout(); 
   
     // previewer
-    mInteractor = new wxVTKRenderWindowInteractor(mPanelImage,-1);
+       mInteractor = new crea::creawxVTKRenderWindowInteractor(mPanelImage,-1);
     mInteractor->UseCaptureMouseOn();  
   
     mViewer    = vtkImageViewer2::New();
@@ -411,6 +400,7 @@ namespace creaImageIO
 
     ShowImage(mReader.GetImage(""));
 
+    mJustStarted = true;
   }
   //================================================================
     
@@ -859,6 +849,9 @@ namespace creaImageIO
        boost::filesystem::change_extension(filepath,GetDatabaseExtension());
        if ( boost::filesystem::exists(filepath) )
          {
+                 boost::filesystem::remove(filepath);  
+                         /* 
+                         LG : works on Linux but not Windows :
            if ( ! boost::filesystem::remove(filepath) )
              {
                wxMessageBox(_T("Could not overwrite ")
@@ -866,8 +859,10 @@ namespace creaImageIO
                             _T("Error"),
                             wxOK,this);
                return;
+               
        
              }
+                 */
          }
       }
     
@@ -1293,8 +1288,9 @@ namespace creaImageIO
          }
        if (data->IsDicomNode())
          {
-           /*
+           
            //      LG : BUGGY
+           /*
            std::string str("&Remove ");
            str += data->GetDicomNode()->GetTypeName();
            menu.Append(PopUp_Remove, std2wx(str));
@@ -1429,7 +1425,7 @@ namespace creaImageIO
   // Pop up menu callbacks
   void  WxGimmick::OnPopUpAbout(wxCommandEvent& event)
   {
-    wxMessageBox( _T("Give me my medical images quick ! \n\n  (c) CREATIS-LRMN 2008\n"),
+    wxMessageBox( _T("Give me my medical images quick ! \n\n  (c) CREATIS-LRMN 2008\n      laurent.guigues@creatis.insa-lyon.fr"),
                  _T("Gimmick!"),
                  wxOK | wxICON_INFORMATION, this);
   }
@@ -1844,7 +1840,7 @@ namespace creaImageIO
            return false;
          }
       }
-    std::cout << "Selecting : "<<node->ImageGetFullFileName() << std::endl;
+    //    std::cout << "Selecting : "<<node->ImageGetFullFileName() << std::endl;
     return true;
   }
   //================================================================
@@ -2144,6 +2140,16 @@ namespace creaImageIO
   void  WxGimmick::OnInternalIdle()
   {
     ProcessImageEvents();
+    if (mJustStarted)
+      {
+       // Show tip if no collection
+       if (GetDicomDatabaseList().size()==0)
+         {
+           ShowHelp();
+         }
+       mJustStarted = false;
+      }
+    //
   }
   //================================================================
  
@@ -2237,14 +2243,18 @@ namespace creaImageIO
          {     
            // n2D to 3D
            vtkImageData* out = vtkImageData::New();
-           out->CopyStructure(first);
+           out->CopyStructure(first);  
+           out->SetScalarType(first->GetScalarType());
            int ext[6];
            first->GetExtent(ext);
            ext[5] = im.size();
            out->SetExtent(ext);
+           // LG : TODO : Z Spacing  ?
            
            out->AllocateScalars();
-           out->Print(std::cout);
+           
+           //first->Print(std::cout);
+           //      out->Print(std::cout);
            
            int dim[3];
            first->GetDimensions(dim);
@@ -2252,17 +2262,36 @@ namespace creaImageIO
              ( (unsigned long)first->GetScalarPointer(0,1,0)
                - (unsigned long)first->GetScalarPointer(0,0,0))
              *dim[1];
-           std::cout << "imsize="<<imsize<<std::endl;
 
            int slice = 0;
            std::vector<DicomNode*>::iterator it;
            for (it=im.begin(); it!=im.end(); ++it) 
              {
+               //std::cout << "copying slice "<<slice <<std::endl;
                vtkImageData* cur = mReader.GetImage( (*it)->ImageGetFullFileName() );
                
                void* src = cur->GetScalarPointer(0,0,0);
                void* dst = out->GetScalarPointer(0,0,slice);
+               //              std::cout << "src="<<src<<std::endl;
+               //              std::cout << "dst="<<dst<<std::endl;
+               //              std::cout << "siz="<<imsize<<std::endl;
                memcpy(dst,src,imsize);
+
+               /*
+               // verif
+               int ii,jj;
+               for (ii=1;ii<4;ii++) {
+                 for (jj=1;jj<4;jj++) {
+                   int x = (int)(ii*dim[0] / 4);
+                   int y = (int)(jj*dim[1] / 4);
+                   std::cout << cur->GetScalarComponentAsFloat(x,y,0,0)
+                             << " vs "
+                             << out->GetScalarComponentAsFloat(x,y,slice,0)
+                             << std::endl;
+                 }
+               }
+               */
+
                slice++;
              }
            f.push_back(out);
@@ -2726,10 +2755,17 @@ namespace creaImageIO
     }
 
 
-
-
-
-
+    //====================================================================
+    void WxGimmick::ShowHelp()
+    {
+      if (mHelpWindow==0)
+       {
+         mHelpWindow = new WxGimmickHelpWindow(this);
+       }
+      mHelpWindow->CenterOnParent();
+      mHelpWindow->ShowModal();
+    }
+    //====================================================================
 
 
 
@@ -2911,38 +2947,7 @@ namespace creaImageIO
 
 
 
-             //================================================================
-             //================================================================
-             //================================================================
-             //================================================================
-
-             //================================================================
-             WxGimmickSettingsDialog::WxGimmickSettingsDialog(wxWindow *parent)
-             : 
-             wxDialog( parent, 
-                       -1, 
-                       _T("Settings"),
-                       wxDefaultPosition,
-                       wxSize(400,400),
-                       wxRESIZE_BORDER | 
-                       wxSYSTEM_MENU  |
-                       wxCLOSE_BOX |
-                       wxMAXIMIZE_BOX | 
-                       wxMINIMIZE_BOX | 
-                       wxCAPTION  
-                       )
-             {
-             } 
-             //================================================================
-    
-             //================================================================
-             WxGimmickSettingsDialog::~WxGimmickSettingsDialog()
-               {
-               }
-             //================================================================
-
-    
-
+