]> Creatis software - creaImageIO.git/commitdiff
Clean Up Code and Added min dimension check
authorcaballero <caballero>
Wed, 25 Feb 2009 09:30:47 +0000 (09:30 +0000)
committercaballero <caballero>
Wed, 25 Feb 2009 09:30:47 +0000 (09:30 +0000)
appli/TestWxGimmickReaderDialog/main.cxx
src2/creaImageIOTreeView.h
src2/creaImageIOWxGimmickReaderDialog.cpp
src2/creaImageIOWxGimmickReaderDialog.h
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h
src2/creaImageIOWxTreeView.cpp

index 4ce9a54dd401755af12ad6f2116dfa7f6cef489d..4846e215333b183132fe7e365859dfe6d9f61a10 100644 (file)
@@ -41,7 +41,6 @@ bool myApp::OnInit( )
                                        wxSize(1200,800),
                                        min_dim,
                                        max_dim,
-                                       output_dim,
                                        threads);
    w.ShowModal();
    
index de4f7f23bd621f474f30e9a97a71a793cf399204..4f61518eda7e672922402dd7f3a241c22c469a1b 100644 (file)
@@ -46,18 +46,14 @@ namespace creaImageIO
          void SetMaxDimension(int maxdim){ mSelectionMaxDimension=maxdim; }
          ///Sets the minimum dimension allowed for selections
          void SetMinDimension(int mindim){ mSelectionMinDimension=mindim; }
-         ///Sets the output dimension desired for selections
-         void SetOutputDimension(int outdim){ mOutputDimension=outdim; }
-    
+         
     protected:
       TreeHandler* GetTreeHandler() { return mTreeHandler; }
          ///Gets the maximum dimension allowed for selections
          int GetMaxDimension(){ return mSelectionMaxDimension; }
          ///Gets the minimum dimension allowed for selections
          int GetMinDimension(){ return mSelectionMinDimension; }
-         ///Gets the output dimension desired for selections
-         int GetOutputDimension(){ return mOutputDimension; }
-
+        
     private:
       /// The TreeHandler with which it corresponds
       TreeHandler* mTreeHandler;
@@ -65,9 +61,7 @@ namespace creaImageIO
          int mSelectionMaxDimension;
          //The selection's minimum dimension
          int mSelectionMinDimension;
-         //The user desired output dimension
-         int mOutputDimension;
-    };
+         };
     // EO class TreeView
     //=====================================================================
   
index c12cd066b3998975b3656588b4bd730b629feb61..b04c27e9b36eb191825baa2a8f34bd0587d334a5 100644 (file)
@@ -11,7 +11,6 @@ namespace creaImageIO
                                               const wxSize& size,
                                               int min_dim,
                                                   int max_dim,
-                                                  int out_dim,
                                               int threads)
  :   wxDialog( parent, 
                  id, 
@@ -45,7 +44,6 @@ namespace creaImageIO
                                size,
                                min_dim,
                                max_dim,
-                               out_dim,
                                threads);
       mView->Initialize();
     }
index 54f929c044b0f2eb7160c3af039a11dea5085311..4d932214bebf7229f295268cae49481a14ead351 100644 (file)
@@ -25,7 +25,6 @@ namespace creaImageIO
                          const wxSize& size,
                          int image_min_dim = GIMMICK_2D_IMAGE_SELECTION,
                          int image_max_dim = GIMMICK_3D_IMAGE_SELECTION,
-                         int output_dim = NATIVE,
                          int threads = 0);
     
     Gimmick* GetGimmick() { return mGimmick; }
index cec329ba94ba9d9bc30c8651f121d8255b627930..99a007751758d8c6129b1fc7ce13280937b308f5 100644 (file)
@@ -63,7 +63,6 @@ namespace creaImageIO
                               const wxPoint& pos, const wxSize& size,
                               int min_dim,
                                   int max_dim,
-                                  int out_dim,
                               int number_of_threads)
     : wxPanel(parent,id,pos,size),
       GimmickView(gimmick),
@@ -102,7 +101,6 @@ namespace creaImageIO
 
        mSelectionMaxDimension=max_dim;
        mSelectionMinDimension=min_dim;
-       mOutputDimension=out_dim;
 
     // Create the views
     CreateTreeViews();
@@ -189,7 +187,6 @@ namespace creaImageIO
        
        view->SetMaxDimension(mSelectionMaxDimension);
        view->SetMinDimension(mSelectionMinDimension);
-       view->SetOutputDimension(mOutputDimension);
 
     // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
     // ALREADY IN THE MAP
index 235c8f0cd1f4619369e32205b328548a4efa3299..ac816a07ea5ad162c45c3057fbb38a90dca7ccb2 100644 (file)
@@ -32,7 +32,6 @@ namespace creaImageIO
                    const wxPoint& pos, const wxSize& size,
                    int min_dim = GIMMICK_2D_IMAGE_SELECTION,
                        int max_dim = GIMMICK_3D_IMAGE_SELECTION,
-                       int out_dim = NATIVE,
                    int number_of_threads = 0);
       /// Virtual destructor
       virtual ~WxGimmickView();
@@ -89,8 +88,6 @@ namespace creaImageIO
          int mSelectionMaxDimension;
          //The selection's minimum dimension
          int mSelectionMinDimension;
-         //The user desired output dimension
-         int mOutputDimension;
 
 
       wxString mCurrentDirectory;
index bd640783e8a210ffec1bdbec9dfa76f3317fd5fe..829549a2212feca51e2c8847897be80b15bde201 100644 (file)
@@ -456,10 +456,10 @@ namespace creaImageIO
   {
        int level=mLevelList.size();
        std::vector<tree::Node*> sel=GetSelected(level+1);
+       bool valid=true;
        if(sel.size()>0)
        {
                std::vector<tree::Node*>::iterator i;
-               bool valid=true;
                std::string row;
                std::string col;
                std::string plane;
@@ -492,52 +492,65 @@ namespace creaImageIO
                                << std::endl);
                //Dimention validation
                //Compatibility with maximum 
-               if(valid)
-               {       
-                       int rows;
-                       int cols;
-                       int planes;
-                       std::string s;
-                       std::istringstream t(s);
-                       s=row;
-                       t >> rows;
-                       if(row==""){rows=1;}
-                       s=col;
-                       t >> cols;
-                       if(col==""){cols=1;}
-                       s=plane;
-                       t >> planes;
-                       if(plane==""){planes=1;}
-
-                       int dim = 0;
-                       if (planes>1) dim=3;
-                       else if (cols>1) dim=2;
-                       else if (rows>1) dim=1;
-                   
-                       if (dim == 0) 
-                       {
-                       GimmickMessage(1,
-                               "Unknown image dimension : cannot select !" 
-                               <<dim<<" "
-                               <<plane<<" "
-                               <<col<<" "
-                               <<row<<" "
-                               << std::endl);
-                               valid= false;
-                       }
-                       else if (dim>GetMaxDimension())
-                       {
-                               GimmickMessage(1,"Selecting "<<dim<<"D images is not allowed !" 
-                               << std::endl);
-                               valid= false;
-                       }
-                       if ( dim == GetMaxDimension() )
-                       {
-                               GimmickMessage(1,"Cannot add this image to selection : would result in a "<<dim+1<<"D image !" << std::endl);
-                               valid= false;
+                       if(valid)
+                       {       
+                               int rows;
+                               int cols;
+                               int planes;
+                               std::string s;
+                               std::istringstream t(s);
+                               s=row;
+                               t >> rows;
+                               if(row==""){rows=1;}
+                               s=col;
+                               t >> cols;
+                               if(col==""){cols=1;}
+                               s=plane;
+                               t >> planes;
+                               if(plane==""){planes=1;}
+
+                               int dim = 0;
+                               if (planes>1) dim=3;
+                               else if (cols>1) dim=2;
+                               else if (rows>1) dim=1;
+                           
+                               if (dim == 0) 
+                               {
+                               GimmickMessage(1,
+                                       "Unknown image dimension : cannot select !" 
+                                       <<dim<<" "
+                                       <<plane<<" "
+                                       <<col<<" "
+                                       <<row<<" "
+                                       << std::endl);
+                                       valid= false;
+                               }
+                               else if (dim>GetMaxDimension())
+                               {
+                                       GimmickMessage(1,"Selecting "<<dim<<"D images is not allowed !" 
+                                       << std::endl);
+                                       valid= false;
+                               }
+                               if ( dim == GetMaxDimension() )
+                               {
+                                       GimmickMessage(1,"Cannot add this image to selection : would result in a "
+                                                                       <<dim+1<<"D image !" << std::endl);
+                                       valid= false;
+                               }
+                               if ( dim < GetMinDimension() && sel.size()<2 )
+                               {
+                                       GimmickMessage(1,"Cannot build the selection as it would result in a "
+                                                                       <<dim<<"D image, and the minimum is"<<GetMinDimension()<<"D!" << std::endl);
+                                       valid= false;
+                               }
                        }
-               }
-                 
+         }
+       else
+       {
+               GimmickMessage(1,"Cannot have 0 images selected"<< std::endl);
+               valid=false;
+       }
+       
                //Send an event telling wether the selection is valid or not
                wxCommandEvent event( 0, GetId() );
                event.SetEventObject( this );
@@ -546,7 +559,7 @@ namespace creaImageIO
                else
                {event.SetInt(1);}
                GetEventHandler()->ProcessEvent( event );
-         }
+         
        
   }