]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOGimmickView.cpp
Validate is now linear
[creaImageIO.git] / src2 / creaImageIOGimmickView.cpp
index 0afd753353e7352663831cab8ad349ea8868950a..0a2b8e1800b944ea7685a10072d02e9bba22aae9 100644 (file)
@@ -38,6 +38,10 @@ namespace creaImageIO
   /// 
   void GimmickView::Initialize()
   {
+         row="";
+         col="";
+         plane="";
+         selectionSize=0;
   }
   //======================================================================
   
@@ -79,49 +83,47 @@ namespace creaImageIO
     i->second->UpdateLevel(l);    
   }
   //======================================================================
+  /// Clears the status and begins a new selection process
+  void GimmickView::ClearStatus()
+  {
+         row="";
+         col="";
+         plane="";
+         selectionSize=0;
+         valid=true;
+  }
+  //======================================================================
   ///Validates the dimension compliance of the images with the maximum and 
   ///minimum given, and between their sizes
-  bool GimmickView::ValidateSelected (std::vector<tree::Node*>& sel, int min_dim, int max_dim)
+  bool GimmickView::ValidateSelected (tree::Node* sel, int min_dim, int max_dim)
   {
        GimmickMessage(2,"Validating selected"<<std::endl);
-         
-       bool valid=true;
-         
-         // EED validate all
+       selectionSize++;
+         /*// EED validate all
          mValidationSignal(valid);
-         return valid;
+         return valid;*/
          
        int level;
        std::string mMessage;
-       if(sel.size()>0)
+       
+       if(row.compare("")==0 || col.compare("")==0)
        {
-               std::vector<tree::Node*>::iterator i;
-               std::string row;
-               std::string col;
-               std::string plane;
-               
-               //Validation between image sizes
-               for (i=sel.begin(); i!=sel.end() && valid; ++i)
-               {
-                       if(i==sel.begin())
-                       {
-                               row=(*i)->GetAttribute("D0028_0010");
-                               col=(*i)->GetAttribute("D0028_0011");
-                               plane=(*i)->GetAttribute("D0028_0012");
-                               level=(*i)->GetLevel();
-                               
-                       }
-                       else
+               row=(*sel).GetAttribute("D0028_0010");
+               col=(*sel).GetAttribute("D0028_0011");
+               plane=(*sel).GetAttribute("D0028_0012");
+               level=(*sel).GetLevel();
+       }
+       else
+       {
+               if(((*sel).GetAttribute("D0028_0010"))!=row ||
+                       ((*sel).GetAttribute("D0028_0011"))!=col ||
+                       ((*sel).GetAttribute("D0028_0012"))!=plane)
                        {
-                               if(((*i)->GetAttribute("D0028_0010"))!=row ||
-                                       ((*i)->GetAttribute("D0028_0011"))!=col ||
-                                       ((*i)->GetAttribute("D0028_0012"))!=plane)
-                                       {
-                                               mMessage="The selected images are not compatible.";
-                                               valid=false;
-                                       }
+                               mMessage="The selected images are not compatible.";
+                               valid=false;
                        }
-               }
+       }
+               
 
                //Dimention validation
                //Compatibility with maximum and minimum
@@ -168,27 +170,29 @@ namespace creaImageIO
                                        
                                        valid= false;
                                }
-                               if ( dim < min_dim && sel.size()<2 )
+                               if ( dim < min_dim )
                                {
-                                       GimmickDebugMessage(2, "State Check: Dim: "
+                                       GimmickMessage(1, "State Check: Dim: "
                                                <<dim
                                                <<" Dim min:"
                                                <<min_dim
                                                <<std::endl);
                                        mMessage="Cannot build the selection as it would result in a ";
-                                       mMessage+=dim;
+                                       std::string a;
+                                       std::stringstream out;
+                                       out<<dim;
+                                       a=out.str();
+                                       mMessage+=a;
                                        mMessage+="D image, and the minimum is ";
-                                       mMessage+=min_dim;
+                                       out<<min_dim;
+                                       a=out.str();
+                                       mMessage+=a;
                                        mMessage+="D!";
                                        valid= false;
                                }
                        }
-         }
-       else
-       {
-               mMessage="Cannot have 0 images selected";
-               valid=false;
-       }
+       
+       
        if(valid)
        {
                mMessage="Selection OK !";
@@ -303,10 +307,12 @@ namespace creaImageIO
        {
     if (filename.size()==0)
       {
+                 //What to do in this case?
+                 /*
                GimmickDebugMessage(5,
                                        "Pushing unknown image in queue"
                                        <<std::endl);
-               mImageEventQueue.push_back(ImageEventType(image));
+               mImageEventQueue.push_back(ImageEventType(image));*/
                return;
       }
     ImageEventTypeMap::iterator i;