- GimmickMessage(1,
- "Hello World Validate"
- <<std::endl);
- /*
- MyEvent event( MyCommandEvent, 0 );
- wxString bar( wxT("This is a Foo_DoFirstThing event") );
- event.SetText( bar );
- wxPostEvent( this, event );
- */
+ int level=mLevelList.size();
+ std::vector<tree::Node*> sel=GetSelected(level+1);
+ if(sel.size()>0)
+ {
+ std::vector<tree::Node*>::iterator i;
+ bool valid=true;
+ 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(mLevelList[level-1].key[1]);
+ col=(*i)->GetAttribute(mLevelList[level-1].key[2]);
+ plane=(*i)->GetAttribute(mLevelList[level-1].key[3]);
+ }
+ else
+ {
+ if(((*i)->GetAttribute(mLevelList[level-1].key[1]))!=row ||
+ ((*i)->GetAttribute(mLevelList[level-1].key[2]))!=col ||
+ ((*i)->GetAttribute(mLevelList[level-1].key[3]))!=plane)
+ {
+ valid=false;
+ }
+ }
+ }
+
+ GimmickMessage(1,
+ "State check: Planes:"
+ <<plane<<" Cols: "
+ <<col<<" Rows:"
+ <<row<<" "
+ << 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;
+ }
+ }
+
+ //Send an event telling wether the selection is valid or not
+ wxCommandEvent event( 0, GetId() );
+ event.SetEventObject( this );
+ if(valid)
+ {event.SetInt(0);}
+ else
+ {event.SetInt(1);}
+ GetEventHandler()->ProcessEvent( event );
+ }