]> Creatis software - creaImageIO.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Mon, 20 Apr 2009 11:30:32 +0000 (11:30 +0000)
committerguigues <guigues>
Mon, 20 Apr 2009 11:30:32 +0000 (11:30 +0000)
appli/TestWxGimmickReaderDialog/main.cxx
appli/gimmick/main.cxx
src2/creaImageIOMultiThreadImageReader.cpp
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxTreeView.cpp

index 8be4ec45659f690fedc2e3d2b2420e72b17e7e18..f2885d18ea152884a0bceeb09c227dd0b44bd4fd 100644 (file)
@@ -25,8 +25,8 @@ bool myApp::OnInit( )
    wxInitAllImageHandlers();
 
    
-   creaImageIO::SetGimmickMessageLevel(1);
-   creaImageIO::SetGimmickDebugMessageLevel(1);
+   creaImageIO::SetGimmickMessageLevel(5);
+   creaImageIO::SetGimmickDebugMessageLevel(0);
    
 
    int min_dim = GIMMICK_2D_IMAGE_SELECTION;
index cecd0f76ba6ac8503f6e7d24fb8cfac8fae10caf..bee8ff1c269aa6b2137bbd82c9d695eaa1854764 100644 (file)
@@ -1,5 +1,5 @@
 #include <boost/program_options.hpp>
-
 using namespace boost;
 namespace po = boost::program_options;
 
@@ -10,84 +10,93 @@ using namespace std;
 
 int main(int ac, char* av[])
 {
-
-       creaImageIO::Gimmick g;
-       int verb,deb;
-       std::string handler("Local database");
-
-       //Describes first group of options
-       po::options_description generic("GENERIC");
-       generic.add_options()
+  
+  creaImageIO::Gimmick g;
+  int verb,deb;
+  std::string handler("Local database");
+  
+  //Describes first group of options
+  po::options_description generic("GENERIC");
+  generic.add_options()
     ("help,h", "Print help and exit")
-       ("version,V", "Print version and exit");
-
-       //Describes second group of options
-       po::options_description command("COMMANDS");
-       command.add_options()
+    ("version,V", "Print version and exit");
+  
+  //Describes second group of options
+  po::options_description command("COMMANDS");
+  command.add_options()
     ("print,p","Prints the local database tree  (default=off)")
     ("file,f",po::value< vector<string> >(),"Adds the file to the local database")
-       ("dir,d",po::value< vector<string> >(),"Adds the directory to the local database")
-       ("recurse,r","Recurse into sub-directories  (default=off)");
-
-       //Describes third group of options
-       po::options_description option("OPTIONS");
-       option.add_options()
+    ("dir,d",po::value< vector<string> >(),"Adds the directory to the local database")
+    ("sync,s","Synchronizes the local database with the files")
+    ("recurse,r","Recurse into sub-directories  (default=off)");
+  
+  //Describes third group of options
+  po::options_description option("OPTIONS");
+  option.add_options()
     ("verbose,v",po::value<int>(&verb),"Verbosity level (default=`1')")
-       ("debug,D",po::value<int>(&deb),"Debug messages level (default=`0')");
-
-
-       //Adds the groups into a big one
-       po::options_description cmdline_options;
-       cmdline_options.add(generic).add(command).add(option);
-
-       //Adds the corresponding variables
-       po::variables_map vm;
-       po::store(po::parse_command_line(ac, av, cmdline_options), vm);
-       po::notify(vm);    
+    ("debug,D",po::value<int>(&deb),"Debug messages level (default=`0')");
+  
+  
+  //Adds the groups into a big one
+  po::options_description cmdline_options;
+  cmdline_options.add(generic).add(command).add(option);
+  
+  //Adds the corresponding variables
+  po::variables_map vm;
+  po::store(po::parse_command_line(ac, av, cmdline_options), vm);
+  po::notify(vm);    
+  
+  //Does something on each option
+  //GENERIC
+  if (vm.count("help")) {
+    cout << "Usage: gimmick COMMAND [OPTIONS]:\n";
+    cout << cmdline_options << "\n";
+  }
+  if (vm.count("version")) {
+    cout << "gimmick 0.1.0\n";
+  }
+  
+  //OPTIONS
+  if (vm.count("verbose")) {
+    g.SetMessageLevel(verb);
+    cout << "Verbose level is now "<<verb<<"\n";
+  }
+  if (vm.count("debug")) {
+    g.SetDebugMessageLevel(deb);
+    cout << "Debug level is now "<<deb<<"\n";
+  }
+  
+  //COMMANDS
+  if (  vm.count("print")
+       ||vm.count("file")
+       ||vm.count("dir")
+       ||vm.count("sync")
+       )
 
-       //Does something on each option
-       //GENERIC
-       if (vm.count("help")) {
-               cout << "Usage: gimmick COMMAND [OPTIONS]:\n";
-               cout << cmdline_options << "\n";
-       }
-       if (vm.count("version")) {
-               cout << "gimmick 0.1.0\n";
-       }
-
-       //OPTIONS
-       if (vm.count("verbose")) {
-               g.SetMessageLevel(verb);
-               cout << "Verbose level is now "<<verb<<"\n";
-       }
-       if (vm.count("debug")) {
-               g.SetDebugMessageLevel(deb);
-               cout << "Debug level is now "<<deb<<"\n";
-       }
-
-       //COMMANDS
-       if(vm.count("print")||vm.count("file")||vm.count("dir"))
-       try
-    {
-     g.Initialize();
+    try
+      {
+       g.Initialize();
        if (vm.count("print")) {
-               g.GetTreeHandler(handler)->LoadChildren(0,0);
-               g.Print(handler);
+         g.GetTreeHandler(handler)->LoadChildren(0,0);
+         g.Print(handler);
        }
        if (vm.count("file")) {
-               std::vector<std::string> files=vm["file"].as< vector<string> >();
-        g.AddFiles(handler,files);
+         std::vector<std::string> files=vm["file"].as< vector<string> >();
+         g.AddFiles(handler,files);
        }
        if (vm.count("dir")) {
-               std::vector<std::string> dirs=vm["dir"].as< vector<string> >();
-               g.AddDir(handler,dirs.front(), vm.count("recurse"));
+         std::vector<std::string> dirs=vm["dir"].as< vector<string> >();
+         g.AddDir(handler,dirs.front(), vm.count("recurse"));
        }
-        g.Finalize();
-    }
-  catch (crea::Exception e)
-    {
-      e.Print();
-    }
-
+       if (vm.count("sync")) {
+         g.Synchronize(true,g.GetTreeHandler(handler));
+       }       
+       g.Finalize();
+      }
+    catch (crea::Exception e)
+      {
+       e.Print();
+      }
+  
   return 0;
 }
index 9d2c0908384742ad939640f2c4fc7ffa57af412e..9e4db3ced7ebd1bce3a3c987630dca2ae13adfa9 100644 (file)
@@ -44,7 +44,7 @@ namespace creaImageIO
     : //mDoNotSignal(false),
       mReader(0),
       mTotalMem(0),
-      mTotalMemMax(1500000)
+      mTotalMemMax(1000000)
   {
     //    std::cout << "#### MultiThreadImageReader::MultiThreadImageReader("
     //       << " #threads= " << number_of_threads <<" )"<<std::endl;
@@ -289,15 +289,20 @@ namespace creaImageIO
   vtkImageData* MultiThreadImageReader::GetImage(const std::string& filename)
   {
         // Start();
-    //    std::cout << "** MultiThreadImageReader::GetImage('"<<filename<<"')"
-    //       <<std::endl;
+    //       std::cout << "** MultiThreadImageReader::GetImage('"<<filename<<"')"
+    //          <<std::endl;
     
     do 
       {
-       wxMutexLocker lock(GetMultiThreadImageReaderUserMutex()); //mMutex);
+       //      wxMutexLocker lock(GetMultiThreadImageReaderUserMutex()); //mMutex);
                
-                 if (mNumberOfThreadedReadersRunning==0)
-//     if (mThreadedImageReaderList.size()==0)
+       //     std::cout << "** MultiThreadImageReader::GetImage('"<<filename
+       //             <<"') lock ok"
+       //               <<std::endl;
+    
+       //                if (mNumberOfThreadedReadersRunning==0)
+       //      if (mThreadedImageReaderList.size()==0)
+       if (true)
          {
            ImageToLoad itl(this,filename);
            ImageMapType::iterator i = mImages.find(&itl);
@@ -320,7 +325,8 @@ namespace creaImageIO
                                 GetMaximalPriorityWithoutLocking()+1);
            return pitl->GetImage();
          }
-       
+
+       /*      
        mRequestedFilename = filename;
        mRequestedImage = 0;
        ImageToLoad itl(this,filename);
@@ -359,11 +365,13 @@ namespace creaImageIO
            mImages[pitl] = 0;
            mQueue.insert(pitl);
          }
+       */
       }
     while (0);
 
     //    std::cout << "Waiting..."<<std::endl;
 
+    /*
     // Waiting that it is read
     int n = 0;
     do 
@@ -383,7 +391,7 @@ namespace creaImageIO
       }
     while (true);
     // 
-    
+    */
   }
   //=====================================================================
   
index 6bcf489dbcc3029ed8053ef5759502bafe2ad6ff..5b87845400cd574b220c6011c5294055a1d05f05 100644 (file)
@@ -289,6 +289,7 @@ namespace creaImageIO
   //=================================================
   void WxGimmickView::OnAddFiles(wxCommandEvent& event)
   {
+    mViewer->StopPlayer();
    long style = wxOPEN | wxFILE_MUST_EXIST | wxFD_MULTIPLE;
     std::string wc("*.*");
     wxFileDialog* FD = new wxFileDialog( 0, 
@@ -331,14 +332,16 @@ namespace creaImageIO
        UpdateTreeViewLevel("Local database",1);
        delete mProgressDialog;
        DisplayAddSummary();    
+
       }
-       
+       mViewer->StartPlayer(); 
   }
   //=================================================
 
   //=================================================
   void WxGimmickView::OnAddDir(wxCommandEvent& event)
   {
+    mViewer->StopPlayer();
     long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
     wxDirDialog* FD = 
       new wxDirDialog( 0, 
@@ -348,6 +351,7 @@ namespace creaImageIO
     
     if (FD->ShowModal()==wxID_OK)
       {
+
        
                  std::string dirname = wx2std (FD->GetPath());
                  bool recurse =  isNeedRecursive(dirname);
@@ -380,7 +384,9 @@ namespace creaImageIO
                UpdateTreeViewLevel("Local database",1);
                delete mProgressDialog;
                DisplayAddSummary();
+
          }
+    mViewer->StartPlayer();
   }
 
     //=================================================
index 2050e53eb036adee2b39bde5d3141be49ba56757..73ff7c48d4478e39e0d3074b16a9e4a353635d97 100644 (file)
@@ -403,7 +403,7 @@ namespace creaImageIO
   }
   //=====================================================================
   
- //=====================================================================
 //=====================================================================
   /// Recursive method called upon by UpdateLevel to refresh all windows
   void WxTreeView::RecursiveUpdateLevel( int level )
   {
@@ -413,11 +413,11 @@ namespace creaImageIO
                        <<level
                        <<")"<<std::endl);
     
-
+    
     const std::vector<tree::Node*>& sel(GetSelected(level));
-
+    
     int l = level - 1;
+    
     // to speed up inserting we hide the control temporarily
     GetCtrl(l)->Hide();
     GetCtrl(l)->DeleteAllItems();
@@ -434,76 +434,89 @@ namespace creaImageIO
        int _id=0;
        
        //Adds items and sets their attributes 
-
+       
        GetTreeHandler()->LoadChildren(*i,1);
        tree::Node::ChildrenListType::reverse_iterator j;
        for (j = (*i)->GetChildrenList().rbegin(); 
             j!= (*i)->GetChildrenList().rend(); 
             ++j)
          {
-                       GimmickDebugMessage(1,
-                                               "adding children "
-                                               <<(*j)->GetLabel()
-                                               <<"'"
-                                               <<std::endl);
-
-                               wxListItem item;
-                               item.SetMask(wxLIST_MASK_STATE | 
-                                       wxLIST_MASK_TEXT |
-                                       //                       wxLIST_MASK_IMAGE |
-                                       wxLIST_MASK_DATA |
-                                       //                       wxLIST_MASK_WIDTH |
-                                       wxLIST_MASK_FORMAT
-                                       );
-                           
-                               ItemData* data = new ItemData;
-                               data->node = *j;
-                               data->id = _id;
-
-                               item.SetId(_id);
-                               item.SetData(data);
-                           
-                               _id++;
-                               GetCtrl(l)->InsertItem(item);
-                           
-                               //Setting attributes
-                               for (int k=0; k<GetCtrl(l)->GetColumnCount(); ++k)                              
-                               {
-                                       std::string val;
-                                       //  Temporary correction : it works but no explanation about the problem FCY
-                                       if(k==0 && level <3)
-                                               val = (*j)->GetAttribute("NumberOfChildren");
-                                       else
-                                               val = (*j)->GetAttribute(mLevelList[l].key[k]);
-                                       if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
-                                       {
-                                               boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
-                                               val = to_iso_extended_string(d1);
-                                       }
-                                       else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
-                                       {
-                                               if (val != "" || val != " ")
-                                                       val = val.substr(0,2) + " : " + val.substr(2,2) + " : " + val.substr(4,2);
-                                       }
-                                       else
-                                       {
-
-                                       }
-                                       if (val.size()==0) val = "?";
-                                       item.SetText( crea::std2wx(val));
-                                       item.SetColumn(k);
-                                       GetCtrl(l)->SetItem(item);
-                               }       
-                           
-                       }
+           GimmickDebugMessage(1,
+                               "adding children "
+                               <<(*j)->GetLabel()
+                               <<"'"
+                               <<std::endl);
+           
+           wxListItem item;
+           item.SetMask(wxLIST_MASK_STATE | 
+                        wxLIST_MASK_TEXT |
+                        //                      wxLIST_MASK_IMAGE |
+                        wxLIST_MASK_DATA |
+                        //                      wxLIST_MASK_WIDTH |
+                        wxLIST_MASK_FORMAT
+                        );
+           
+           ItemData* data = new ItemData;
+           data->node = *j;
+           data->id = _id;
+           
+           item.SetId(_id);
+           item.SetData(data);
+           
+           _id++;
+           GetCtrl(l)->InsertItem(item);
+           
+           //Setting attributes
+           for (int k=0; k<GetCtrl(l)->GetColumnCount(); ++k)                          
+             {
+               std::string val;
+               //  Temporary correction : it works but no explanation about the problem FCY
+               if(k==0 && level <3)
+                 val = (*j)->GetAttribute("NumberOfChildren");
+               else
+                 val = (*j)->GetAttribute(mLevelList[l].key[k]);
+               if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
+                 {
+                   //                                    std::cout << "["<<val<< "]" << std::endl;
+                   std::string valtmp(val);
+                   try
+                     {
+                       boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));                                 
+                       val = to_iso_extended_string(d1);
+                     }
+                   catch (...)
+                     {
+                       val =  valtmp;
+                     }
+                   //                                    std::cout << "["<<val<< "]" << std::endl;     
+                 }
+               else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
+                 {
+                   if ((val.size()>6) && 
+                       (val != "" || val != " "))
+                     val = val.substr(0,2) + " : " 
+                       + val.substr(2,2) + " : " 
+                       + val.substr(4,2);
+                 }
+               else
+                 {
+                   
+                 }
+               if (val.size()==0) val = "?";
+               item.SetText( crea::std2wx(val));
+               item.SetColumn(k);
+               GetCtrl(l)->SetItem(item);
+             } 
+           
+         }
       }
-
+    
     SortLevel(l);
     GetCtrl(l)->Show();
- }
 }
   //=====================================================================
-
-
+  
+  
   //================================================================
   void WxTreeView::OnItemDeSelected(wxListEvent& event)
   { 
@@ -518,12 +531,12 @@ namespace creaImageIO
        if ( GetCtrl(level) == obj ) break;
       } 
     SetSelectedUpToDate(level,false);
-       // to allow a first selection in images TreeView
-       if (level==mLevelList.size()-1) 
-                OnItemSelected(event);
+    // to allow a first selection in images TreeView
+    if (level==mLevelList.size()-1) 
+      OnItemSelected(event);
   }
   //================================================================
-
+  
   //================================================================
   void WxTreeView::OnItemSelected(wxListEvent& event)
   {