Пример #1
0
/** A list of schedule items is read until the keyword 'end'. */
Schedule* Schedule::getSchedule(istream& input)
{
  char name[256], token[64];

  input >> name;
  next = new Schedule(name);
  memCheck(next,"Schedule::getSchedule(...): next");


  Schedule *schedPtr = next;

  /* read a list of schedule items until keyword "end" */
  ScheduleItem *itemList = next->itemListHead;

  verbose(2,"Reading items for schedule %s.",name);

  clearComment(input);
  input >> token;
  while (strcmp(token,"end"))
    {
      if (isalpha(token[0]))
	itemList = itemList->getSubSched(token,input);
      else 
	itemList = itemList->getPulse(atof(token),input);

      clearComment(input);
      input >> token;
    }
  
  if (itemList->head())
    warning(200,"Schedule %s is empty",name);


  return schedPtr;         
}
Пример #2
0
void InterfaceHandler::clearData()
{
    clearComment();
    setMoveData(0, true, 0, 0, false, false, false);
//    modeButton->setOn(false);
	  mainWidget->setToolsTabWidget(tabNormalScore);
    mainWidget->editButtonGroup->setButton(0);
//    editTools->hide();
    normalTools->capturesBlack->setText("0");
    normalTools->capturesWhite->setText("0");
	
    if (board->getGameMode() != modeObserve && 
		board->getGameMode() != modeMatch &&
		board->getGameMode() != modeTeach)
    {
		normalTools->pb_timeBlack->setText("00:00");
		normalTools->pb_timeWhite->setText("00:00");
    }
    normalTools->show();
    scoreButton->setOn(false);
    editPaste->setEnabled(false);
    editPasteBrother->setEnabled(false);
    slider->setValue(0);
    setSliderMax(SLIDER_INIT);
    scored_flag = false;
}
Пример #3
0
/*
 * Resets all displays on the board window
 */
void InterfaceHandler::clearData()
{
    // qDebug("void InterfaceHandler::clearData()");
	
	clearComment();
//	setMoveData(0, true, 0, 0, false, false, false);
//    modeButton->setOn(false);
//	  mainWidget->setToolsTabWidget(tabNormalScore);
//    mainWidget->editButtonGroup->setButton(0);
//    editTools->hide();
	boardwindow->capturesBlack->setText("0");
	boardwindow->capturesWhite->setText("0");
	
//	if (board->getGameMode() != modeObserve && 
//		board->getGameMode() != modeMatch &&
//		board->getGameMode() != modeTeach)
//	{
		boardwindow->pb_timeBlack->setText("00:00");
		boardwindow->pb_timeWhite->setText("00:00");
//	}
//    normalTools->show();
	boardwindow->scoreButton->setDown(false);
//	editPaste->setEnabled(false);
//	editPasteBrother->setEnabled(false);
	boardwindow->slider->setValue(0);
    boardwindow->slider->setMaximum(0);
	scored_flag = false;
}
Пример #4
0
 void Image::clearMetadata()
 {
     clearExifData();
     clearIptcData();
     clearXmpPacket();
     clearXmpData();
     clearComment();
 }
Пример #5
0
JsonDocument JsonDocument::fromJson(const QByteArray &json, bool allowComment)
{
    QJsonParseError error;
    QJsonDocument jsondoc = QJsonDocument::fromJson(allowComment ? clearComment(json) : json, &error);

    JsonDocument doc;
    if (error.error == QJsonParseError::NoError) {
        doc.value = jsondoc.toVariant();
        doc.valid = true;
    } else {
        doc.valid = false;
        doc.error = error.errorString();
    }
    return doc;
}
Пример #6
0
 void CrwImage::clearMetadata()
 {
     clearExifData();
     clearComment();
 }
Пример #7
0
/** It returns the pointer to the new object that is created.  After
    reading which type of dimension this is, it reads the initial zone
    boundary, followed by a list of pairs: number of intervals in the
    zone and the zone boundary. */
Dimension* Dimension::getDimension(istream& input)
{
  char token[64];
  int dimType;
  double zoneBound;

  input >> token;
  switch(tolower(token[0]))
    {
    case 'x':
      dimType = DIM_X;
      break;
    case 'y':
      dimType = DIM_Y;
      break;
    case 'z':
      dimType = DIM_Z;
      break;
    case 'r':
      dimType = DIM_R;
      break;
    case 't':
      dimType = DIM_THETA;
      break;
    case 'p':
      dimType = DIM_PHI;
      break;
    default:
      error(130,"Invalid dimension type: %s",token);
    }

  next = new Dimension(dimType);
  memCheck(next,"Dimension::getDimension(...): next");

  Dimension *dimPtr = next;

  /* read first zone boundary */
  input >> dimPtr->start;

  /* read list of zone definitions until keyword "end" */
  Zone* zoneList = dimPtr->zoneListHead;

  verbose(2,"Reading zone boundaries for Dimension %s:",token);
  verbose(3,"Start: %g",dimPtr->start);

  clearComment(input);
  input >> token;
  while (strcmp(token,"end"))
    {
      input >> zoneBound;
      zoneList = zoneList->addZone(atoi(token),zoneBound);

      clearComment(input);
      input >> token;
    }

  if (zoneList->head())
    warning(131,"Dimension has no boundaries");

  return dimPtr;         
  

}
Пример #8
0
void Mixture::setGammaAttenCoef(int nGroups, ifstream& gAttenData)
{

  const int MaxEle = 106;
  Mixture *ptr = this;
  Root *root = NULL;
  double *gammaAttenData = NULL;
  double density, totalDens, interp;
  
  int gammaAttenZ[MaxEle], kza, Z, A;
  int gNum, idx, numEle;


  gammaAttenData = new double[nGroups*MaxEle];

  numEle = 0;
  /* read all attenuation coeffcient data */
  clearComment(gAttenData);
  gAttenData >> gammaAttenZ[numEle];
  while (!gAttenData.eof())
    {
      clearComment(gAttenData);
      for (gNum=0;gNum<nGroups;gNum++)
	gAttenData >> gammaAttenData[numEle*nGroups + gNum];

      numEle++;

      clearComment(gAttenData);
      gAttenData >> gammaAttenZ[numEle];
      
    }

  gammaAttenZ[numEle] = 999999;
      
  /* for each mixture in problem */
  while (ptr->next != NULL)
    {
      ptr = ptr->next;

      /* create & initialize array */
      ptr->gammaAttenCoef = new double[nGroups];
      for (gNum=0;gNum<nGroups;ptr->gammaAttenCoef[gNum++]=0) ;

      totalDens = 0;

      /* for each root in mixture */
      root = ptr->rootList->getNext();
      while (root != NULL)
	{
	  kza = root->getKza();
	  Z = kza/10000;
	  A = (kza - 10000*Z)/10;

	  /* get total density of this root */
	  density = root->mixConc(ptr)*A;
	  totalDens += density;

	  /* find data for this Z */
	  idx=-1;
	  while (gammaAttenZ[++idx] < Z) ;
	  if (gammaAttenZ[idx] == Z)
	    for (gNum=0;gNum<nGroups;gNum++)
	      ptr->gammaAttenCoef[gNum] += density*gammaAttenData[idx*nGroups+gNum];
	  else
	    /* if no data, interpolate */
	    if (idx > 0)
	      {
		/* if we are above last data point, extrapolate */
		if (idx == numEle)
		  idx--;
		interp = float(Z - gammaAttenZ[idx-1])/
		  float(gammaAttenZ[idx]-gammaAttenZ[idx-1]);
		for (gNum=0;gNum<nGroups;gNum++)
		  ptr->gammaAttenCoef[gNum] += density*
		    ( gammaAttenData[  idx  *nGroups+gNum] * interp      
		     +gammaAttenData[(idx-1)*nGroups+gNum] * (1 - interp) );
	      }

	  root = root->getNext();

	}

      for (gNum=0;gNum<nGroups;gNum++)
	ptr->gammaAttenCoef[gNum] = ptr->gammaAttenCoef[gNum]/totalDens;

    }
      
  delete gammaAttenData;
  
}
Пример #9
0
/** It reads each Component in the list up to keyword 'end', and returns
    a pointer to the newly created Mixture object. */
Mixture* Mixture::getMixture(istream &input)
{
  char name[256], token[64];
  int type;

  input >> name;
  next = new Mixture(name);
  memCheck(next,"Mixture::getMixture(...): next");

  Mixture *mixPtr = next;

  /* read a list of componenets until keyword "end" */
  Component* compList = mixPtr->compListHead;
  Component* targetCompList = mixPtr->targetCompListHead;
  mixPtr->nComps = 0;

  verbose(2,"Reading constituent list for Mixture %s with constituents:",name);
  clearComment(input);
  input >> token;
  while (strcmp(token,"end"))
    {
      mixPtr->nComps++;

      switch(tolower(token[0]))
	{
	case 'm':
	  debug(2,"Creating new Constituent object of material type");
	  type = COMP_MAT;
	  break;
	case 'e':
	  debug(2,"Creating new Constituent object of element type");
	  type = COMP_ELE;
	  break;
/*	case 'i':
	  debug(2,"Creating new Constituent object of isotope type");
	  type = COMP_ISO;
	  break; */
	case 'l':
	  debug(2,"Creating new Constituent object of similar type");
	  type = COMP_SIM;
	  break;
	case 't':
	  Chain::modeReverse();
	  /* don't count this in component list */
	  mixPtr->nComps--;
	  clearComment(input);
	  input >> token;
	  switch(tolower(token[0]))
	    {
	    case 'e':
	      type = TARGET_ELE;
	      break;
	    case 'i':
	      type = TARGET_ISO;
	      break;
	    default:
	      error(180,"Target materials for reverse calculations can only be elements or isotopes and not '%s'",token);
	    }
	  break;
	default:
	  error(181,"Invalid material constituent: %s", token);
	}
      if (type <= COMP_SIM)
	/* add each component to the list */
	compList = compList->getComponent(type,input,mixPtr);
      else
	targetCompList = targetCompList->getComponent(type,input,mixPtr);

      clearComment(input);
      input >> token;
    }
  
  if (compList->head())
    warning(182,"Mixture %s has no constituents",name);
  
  /* treat a single component as if there is no component:
   * total only */
  if (mixPtr->nComps == 1)
    mixPtr->nComps = 0;
  mixPtr->outputList = new Result[mixPtr->nComps+1];
  
  debug(1,"Finished reading Mixture %s.", name);
  return mixPtr;         
}
Пример #10
0
void TcDatabase::loadEngine(const QString& filename)
{
    m_sqls.clear();
    if ( m_handle.isOpen() )
    {
        if ( dbType() == SQLSERVER )
        {
            // 取出存储过程名
            QSqlQuery procedures_query = QSqlQuery(m_handle);
            QSqlQuery query = QSqlQuery(m_handle);
            if ( procedures_query.exec("exec sp_procedures_rowset2") )
            {
                while(procedures_query.next())
                {
                    QSqlRecord procedures = procedures_query.record();
                    QSqlField  fieldSchema = procedures.field("PROCEDURE_SCHEMA");
                    if ( fieldSchema.isValid() && fieldSchema.value() != "sys" )
                    {
                        QSqlField  field = procedures.field("PROCEDURE_NAME");
                        if ( field.isValid() )
                        {
                            SQLContext cnt;
                            QString procedureID = field.value().toString().toLower();
                            int index = procedureID.indexOf(";");
                            if ( index >= 0 )
                            {
                                procedureID = procedureID.left(index);
                            }
                            cnt.id = procedureID;
                            QString paramsLine;
                            if ( query.exec("exec sp_procedure_params_rowset '"+procedureID+"'") )
                            {
                                while(query.next())
                                {
                                    QSqlRecord paramField = query.record();
                                    QSqlField  paramName = paramField.field("PARAMETER_NAME");
                                    QString pname = paramName.value().toString();

                                    if ( pname.compare("@RETURN_VALUE", Qt::CaseInsensitive) != 0 )
                                    {
                                        QSqlField  paramType = paramField.field("TYPE_NAME");
                                        pname.remove(0, 1);

                                        QString ptype = paramType.value().toString().toLower();
                                        if ( ptype == "nvarchar" )
                                        {
                                            ptype = "string";
                                        }

                                        cnt.params.insert(pname, ptype);
                                        paramsLine += ", :" + pname;
                                    }
                                }
                                query.finish();

                                if ( ! paramsLine.isEmpty() )
                                {
                                    paramsLine.remove(0, 2);
                                }
                            }
                            cnt.text = "exec " + procedureID + " " + paramsLine;
                            m_sqls[procedureID] = cnt;
                            Q_EMIT dbiLoading(m_sqls.count(), procedureID);
                        }
                    }
                }
                procedures_query.finish();
            }
        }else
        if ( dbType() == MYSQL )
        {
            // 取出存储过程名
            QString sql = "SELECT `name`, `param_list`, `body`, `returns` FROM `mysql`.`proc` WHERE `language` = 'SQL' AND `db` = '"+dbName()+"';";
            QSqlQuery query = QSqlQuery(m_handle);
            if ( query.exec(sql) )
            {
                QSqlField  field;
                while(query.next())
                {
                    QSqlRecord procedures = query.record();

                    QString param_line;

                    SQLContext cnt;
                    cnt.id     = procedures.field("name").value().toString();
                    cnt.params =  getParamList(param_line, procedures.field("param_list").value().toString());
                    cnt.text   = "call " + cnt.id + "(" + param_line + ");";
                    //cnt.text   = procedures.field("body").value().toString();
                    m_sqls[cnt.id] = cnt;
                    Q_EMIT dbiLoading(m_sqls.count(), cnt.id);
                    Q_EMIT dbiLoading(m_sqls.count(), cnt.text);
                }
                query.finish();
            }
        }else
        if ( dbType() == POSTGRESQL )
        {
            // 取出存储过程名
            QSqlQuery storedproc_query = QSqlQuery(m_handle);
            QSqlQuery query = QSqlQuery(m_handle);
            if ( storedproc_query.exec("SELECT specific_name"
                                           " , routine_name"
                                        " FROM information_schema.routines"
                                       " WHERE specific_schema = 'public'"
                                         " AND routine_schema  = 'public'"
                                         " AND routine_type    = 'FUNCTION';") )
            {
                while(storedproc_query.next())
                {
                    QSqlRecord storedprocs = storedproc_query.record();
                    QSqlField  fieldspecific = storedprocs.field("specific_name");
                    QSqlField  fieldsqlid    = storedprocs.field("routine_name" );
                    if ( fieldspecific.isValid() && fieldsqlid.isValid() )
                    {
                        SQLContext cnt;
                        cnt.id = fieldsqlid.value().toString().toLower();
                        QString paramsLine;
                        if ( query.exec("SELECT parameter_name"
                                            " , udt_name"
                                         " FROM information_schema.parameters"
                                        " WHERE specific_schema = 'public'"
                                          " AND specific_name   = '"+fieldspecific.value().toString()+"'"
                                          " AND parameter_mode   = 'IN'"
                                        " ORDER BY ordinal_position;") )
                        {
                            while(query.next())
                            {
                                QSqlRecord fields = query.record();
                                QSqlField  paramName = fields.field("parameter_name");
                                QSqlField  paramType = fields.field("udt_name"      );
                                if ( paramName.isValid() && paramType.isValid() )
                                {
                                    cnt.params.insert(paramName.value().toString(),
                                                      paramType.value().toString());
                                    paramsLine += ", :" + paramName.value().toString();
                                }
                            }
                            query.finish();

                            if ( ! paramsLine.isEmpty() )
                            {
                                paramsLine.remove(0, 2);
                            }
                        }
                        cnt.text = "SELECT * FROM " + cnt.id + "(" + paramsLine + ");";
                        m_sqls[cnt.id] = cnt;
                        Q_EMIT dbiLoading(m_sqls.count(), cnt.id);
                    }
                }
                storedproc_query.finish();
            }
        }
    }
    QStringList filenames;
    QDir dir(filename);
    if ( dir.exists() )
    {
        filenames = dir.entryList(QStringList(), QDir::Files, QDir::Name);
        for( int i=0; i<filenames.count(); i++ )
        {
            QString ddlfile = filenames.at(i);
            filenames[i] = dir.absolutePath() + QDir::separator() + ddlfile;
        }
    }else
    {
        QFileInfo sqlsInfo(filename);
        if ( sqlsInfo.exists() )
        {
            filenames.append(filename);
        }
    }
    foreach(QString ddlfile, filenames)
    {
        QFile f(ddlfile);
        if ( f.open(QFile::Text | QFile::ReadOnly) )
        {
            m_engineFile = ddlfile;

            QTextStream in(&f);

            int                     rdType = 0;
            QString                 sqlId;
            QString                 sqlText;
            QMultiHash<QString, QString> sqlParams;
            while(!in.atEnd())
            {
                QString line = in.readLine().trimmed();
                clearComment(line);
                if ( line.isEmpty() )
                {

                }else
                if ( line.startsWith("SQL:", Qt::CaseInsensitive) )
                {
                    if ( ! sqlId.isEmpty() && ! sqlText.isEmpty() )
                    {
                        sqlText.replace("@", ":");

                        SQLContext cnt;
                        cnt.id     = sqlId;
                        cnt.text   = sqlText;
                        cnt.params = sqlParams;
                        m_sqls[sqlId] = cnt;
                        Q_EMIT dbiLoading(m_sqls.count(), sqlId);
                    }
                    sqlId = line.mid(4).trimmed().toLower();
                    sqlText.clear();
                    sqlParams.clear();
                    rdType = 1;
                }else
                if ( line.startsWith("Params:", Qt::CaseInsensitive) )
                {
                    rdType = 2;
                }else
                if ( ! sqlId.isEmpty() )
                {
                    switch(rdType)
                    {
                    case 1:
                        sqlText += line + "\n";
                        break;
                    case 2:
                    {
                        QString paramName;
                        QString paramType = "string";
                        int pos;
                        if ( (pos=line.indexOf(" ")) >0 )
                        {
                            paramName = line.left(pos);
                            line = line.remove(0, pos).trimmed();
                            if ( (pos=line.indexOf(" ")) >0 )
                            {
                                paramType = line.left(pos);
                            }else
                            {
                                paramType = line;
                            }
                        }else
                        {
                            paramName = line;
                        }
                        QChar c = paramName.at(0);
                        if ( c == ':' || c == '@' )
                        {
                            paramName.remove(0, 1);
                        }
                        sqlParams.insert(paramName, paramType.toLower());
                        break;
                    }
                    }
                }
            }
            f.close();

            if ( ! sqlId.isEmpty() && ! sqlText.isEmpty() )
            {
                SQLContext cnt;
                cnt.id     = sqlId;
                cnt.text   = sqlText;
                cnt.params = sqlParams;
                m_sqls[sqlId] = cnt;
                Q_EMIT dbiLoading(m_sqls.count(), sqlId);
            }
        }
    }
Пример #11
0
OutputFormat* OutputFormat::getOutFmts(istream& input)
{
  const char *Out_Res = " izm";

  int type;
  char token[64];
  char *fileNamePtr;

  input >> token; 
  type = strchr(Out_Res,tolower(token[0]))-Out_Res;

  next = new OutputFormat(type);

  verbose(2,"Added output at resolution %d (%s)",type,token);
  
  /* read a list of output types until keyword "end" */
  clearComment(input);
  input >> token; 
  while (strcmp(token,"end"))
    {
      /* match the first character of the type in the constant string */
      type = strchr(Out_Types,tolower(token[0]))-Out_Types; 
      if (type<0)
	error(230,"Output type '%s' is not currently supported.",
	      token);

      verbose(3,"Added output type %d (%s)",1<<type,token);

      switch (1<<type)
	{
	case OUTFMT_UNITS:
	  next->outTypes |= 1<<type;
	  delete[] next->actUnits;
	  input >> token;
	  next->actUnits = new char[strlen(token)+1];
	  strcpy(next->actUnits,token);
	  next->actMult = (tolower(token[0]) == 'c'?BQ_CI:1);

	  delete[] next->normUnits;
	  input >> token;
	  next->normUnits = new char[strlen(token)+2];
	  strcpy((next->normUnits)+1,token);
	  if (tolower(token[0]) == 'v') {
	    next->normUnits[0] = ' ';
	  } else {
	    next->normUnits[0] = '/';
	  }
	  switch (tolower(token[0]))
	    {
	    case 'm':
	      next->normType = OUTNORM_M3;
	      break;
	    case 'g':
	      next->normType = OUTNORM_G;
	      break;
	    case 'k':
	      next->normType = OUTNORM_KG;
	      break;
	    case 'v':
	      next->normType = OUTNORM_VOL_INT;
	      break;
	    default:
	      next->normType = OUTNORM_CM3;
	      break;
	    }
	  break;
	case OUTFMT_WDR:
          next->outTypes |= 1<<type;
	  input >> token;
	  fileNamePtr = new char[strlen(token)+1];
	  strcpy(fileNamePtr,token);
	  next->wdrFilenames.insert(fileNamePtr);
	  verbose(4,"Added WDR/Clearance file %s", token);
	  break;
	case OUTFMT_SRC:
	  next->outTypes |= 1<<type;
	  /* set gamma source file name here */
	  next->gammaSrc= new GammaSrc(input,GAMMASRC_RAW_SRC);
	  break;
	case OUTFMT_CDOSE:
          next->outTypes |= 1<<type;
	  //Need to determine which dose approximation is defined
          char approx_token[64];
          input >> approx_token;
	  if (approx_token[0] == 'l' || approx_token[0] == 'L') {

	    //adjust outTypes
	    //next->outTypes -= OUTFMT_CDOSE;
	    next->outTypes += OUTFMT_EXP; 
	    /* setup gamma source for exposure dose with line approximation */
	    next->exposureDose = new GammaSrc(input, GAMMASRC_EXPOSURE);
	  }
	  else if ( approx_token[0] == 'v' || approx_token[0] == 'V' ) {
	    //adjust outTypes
	    //next->outTypes -= OUTFMT_CDOSE;
	    next->outTypes += OUTFMT_EXP_CYL_VOL; 
	    /* setup gamma source for exposure dose with line approximation */
	    next->exposureCylVolDose = new GammaSrc(input, GAMMASRC_EXPOSURE_CYLINDRICAL_VOLUME);
	  }
	  else if (approx_token[0] == 'c' || approx_token[0] == 'C') {
	    next->outTypes |= 1<<type;
	     /* setup gamma source for contact dose */
	     next->contactDose = new GammaSrc(input,GAMMASRC_CONTACT);
	    }

	  //Add more types of dose output here
	  break;

	case OUTFMT_ADJ:
	  next->outTypes |= 1<<type;
	  /* setup gamma source for adjoint dose */
	  next->outTypes |= 1<<type;
	  next->adjointDose = new GammaSrc(input,GAMMASRC_ADJOINT);
          break;	
	
	default:
        /* use logical and to set the correct bit in the outTypes field */
	   next->outTypes |= 1<<type;
	  break;
	   
	}

      clearComment(input);
      input >> token;
    }	      

  return next;

}