/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <vector>
//#include <string>
#include <StringUtils.h>
#include <qvalidator.h>
//#include <qstring.h>



void Types3DInvisibleDialog::init(){
    static QRegExp regExp("(([0-9])+[,])+");
    typeListEdit->setValidator(new QRegExpValidator(regExp,this));
}

void Types3DInvisibleDialog::loadCurrentValues(std::vector<ushort > & types3DInvisibleVec){
   QString typeList;
   QString emptyStr;
   
   for(unsigned int i = 0 ; i < types3DInvisibleVec.size() ; ++i ){
//   for(set<ushort>::iterator sitr =types3DInvisibleSet ; i < types3DInvisibleSet.end() ; ++sitr ){
      
      typeList+=emptyStr.setNum(types3DInvisibleVec[i]);

      if( i != types3DInvisibleVec.size()-1)      
         typeList+=",";
   }
   typeListEdit->setText(typeList);
}

void Types3DInvisibleDialog::fillTypes3DInvisibleVec(std::vector<ushort> & types3DInvisibleVec){
      using namespace std;
       std::vector<string> vecTypesString;
   //    std::vector<unsigned short> vecTypesUShort;
      string typeList;
      typeList=typeListEdit->text().ascii();
      
      //remove trailing ,
      if(typeList[typeList.size()-1]==',')
         typeList=string(typeList,0,typeList.size()-1);
         
      //cerr<<"typeList="<<typeList<<endl;
      parseStringIntoList(typeList, vecTypesString ,",");
      //cerr<<"after parseStringIntoList  vecTypesString.size()="<<vecTypesString.size()<<endl;

/*      for(int i = 0  ; i < vecTypesString.size() ; ++i){

         cerr<<"vec["<<i<<"]="<<vecTypesString[i]<<endl;
      }*/
      
      types3DInvisibleVec.clear();
      for(int i = vecTypesString.size()-1 ; i >=0 ; --i ){
	  //for(int i = 0 ; i < vecTypesString.size() ; ++i ){
	  //cerr<<"vec_short["<<i<<"]="<<QString(vecTypesString[i]).toUShort()<<endl;
	  
  
	   types3DInvisibleVec.push_back(QString(vecTypesString[i]).toUShort());
	  //types3DInvisibleSet.insert(QString(vecTypesString[i]).toUShort());
	  //vecTypesUShort.push_back(QString(vecTypesString[i]).toUShort());
	 
      }

//      sort(vecTypesUShort.begin(),vecTypesUShort.end());
//      types3DInvisibleVec.assign()
//      for(int i = 0 ; i < vecTypesUShort.size() ; ++i ){
//	  
//      }
  }
