]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOGimmickView.cpp
*** empty log message ***
[creaImageIO.git] / src2 / creaImageIOGimmickView.cpp
index 5da98b5c47d289f80b9300db674fe7c05dfe46e8..9d2b3dcb199d5a61c17dcb10a0bfdcf1b4bde850 100644 (file)
@@ -92,6 +92,29 @@ namespace creaImageIO
          selectionSize=0;
          valid=true;
   }
+
+
+  class ImageExtent
+  {
+  public:
+    ImageExtent(const std::string& x, const std::string& y, const std::string& z, const std::string& t);
+
+    void Clear() { mExtent[0] = mExtent[1] = mExtent[2] = mExtent[3] = 1; }
+
+    bool IsCompatible( const ImageExtent& );
+
+    void Add ( const ImageExtent& );
+               
+    int Get(int i) { return mExtent[i]; }
+    
+    int GetDimension() { return mDim; }
+
+  private:
+    int mExtent[4];
+    int mDim;
+  };
+
+
   //======================================================================
   ///Validates the dimension compliance of the images with the maximum and 
   ///minimum given, and between their sizes
@@ -132,79 +155,74 @@ namespace creaImageIO
                        }
        }
                
+       
+       int dim = 0;
+       int rows;
+       int cols;
+       int planes;
+       
+       //Dimention validation
+       //Compatibility with maximum and minimum
+       if(valid)
+         {     
+                   sscanf(row.c_str(),"%d",&rows);
+           sscanf(col.c_str(),"%d",&cols);
+           sscanf(plane.c_str(),"%d",&planes);
+           if(row==""){rows=1;}
+           if(col==""){cols=1;}
+           if(plane==""){planes=1;}
+           
+           std::cout << cols << "x"<<rows<<"x"<<planes << std::endl;
 
-               //Dimention validation
-               //Compatibility with maximum and minimum
-                       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) 
-                               {
-                                       mMessage="Unknown image dimension : cannot select !";
-                                       valid= false;
-                               }
-                               else if (dim>max_dim)
-                               {
-                                       mMessage="Selecting ";
-                                       mMessage+=dim;
-                                       mMessage+="D images is not allowed !";
-                                       valid= false;
-                               }
-                               if ( dim == max_dim )
-                               {
-                                       mMessage="Cannot add this image to selection : would result in a ";
-                                       mMessage+=(dim+1);
-                                       mMessage+="D image!";
-                                       
-                                       valid= false;
-                               }
-                               if ( dim < min_dim )
-                               {
-                                       GimmickMessage(1, "State Check: Dim: "
-                                               <<dim
-                                               <<" Dim min:"
-                                               <<min_dim
-                                               <<std::endl);
-                                       mMessage="Cannot build the selection as it would result in a ";
-                                       std::string a;
-                                       std::stringstream out;
-                                       out<<dim;
-                                       a=out.str();
-                                       mMessage+=a;
-                                       mMessage+="D image, and the minimum is ";
-                                       out<<min_dim;
-                                       a=out.str();
-                                       mMessage+=a;
-                                       mMessage+="D!";
-                                       valid= false;
-                               }
-                       }
+           if (planes>1) dim=3;
+           else if (cols>1) dim=2;
+           else if (rows>1) dim=1;
+           
+           if (dim == 0) 
+             {
+               mMessage="Unknown image dimension : cannot select !";
+               valid= false;
+             }
+           else if (dim>max_dim)
+             {
+               mMessage="Selecting ";
+               mMessage+=dim;
+               mMessage+="D images is not allowed !";
+               valid= false;
+             }
+           if ( dim == max_dim )
+             {
+               mMessage="Cannot add this image to selection : would result in a ";
+               mMessage+=(dim+1);
+               mMessage+="D image!";
+               
+               valid= false;
+             }
+           if ( dim < min_dim )
+             {
+               GimmickMessage(1, "State Check: Dim: "
+                              <<dim
+                              <<" Dim min:"
+                              <<min_dim
+                              <<std::endl);
+               std::stringstream out;
+               out << "Cannot build the selection as it would result in a ";
+               out << dim;
+               out << "D image, and the minimum is ";
+               out << min_dim;
+               out << "D!";
+               mMessage+=out.str();
+               valid= false;
+             }
+         }
        
        
        if(valid)
-       {
-               mMessage="Selection OK !";
-       }
+         {
+           std::stringstream out;
+           out << dim << "D image " << cols << "x"<< rows << "x"<< planes <<" selected";
+           mMessage = out.str();
+         }
        }
        mValidationSignal(valid);
        SetMessage(mMessage);