Ejemplo n.º 1
0
SDL_RWops *PHYSFSRWOPS_openAppend(const char *const fname)
{
#ifdef __APPLE__
    if (!checkFilePath(fname))
        return nullptr;
#endif
    return create_rwops(PhysFs::openAppend(fname));
} /* PHYSFSRWOPS_openAppend */
Ejemplo n.º 2
0
/** Called when asyn clients call pasynOctet->write().
  * For all parameters it sets the value in the parameter library and calls any
  * registered callbacks.
  * \param[in] pasynUser pasynUser structure that encodes the reason and
  *            address.
  * \param[in] value Address of the string to write.
  * \param[in] nChars Number of characters to write.
  * \param[out] nActual Number of characters actually written. */
asynStatus hdf5Driver::writeOctet (asynUser *pasynUser, const char *value,
                                    size_t nChars, size_t *nActual)
{
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    const char *functionName = "writeOctet";

    // Not interested in base class parameters
    if(function < FIRST_HDF5_PARAM)
        return ADDriver::writeOctet(pasynUser, value, nChars, nActual);

    if(function == HDF5FilePath)
    {
        bool exists = checkFilePath(value);
        setIntegerParam(HDF5FileExists, exists);
        setStringParam(function, value);
        if(exists)
        {
            int acquiring;
            getIntegerParam(ADStatus, &acquiring);
            if(acquiring != ADStatusAcquire)
            {
                openFile(value);

            }
        }
    }

    callParamCallbacks();

    if (status)
        asynPrint(pasynUser, ASYN_TRACE_ERROR,
                "%s:%s: status=%d, function=%d, value=%s",
                driverName, functionName, status, function, value);
    else
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
                "%s:%s: function=%d, value=%s\n",
                driverName, functionName, function, value);

    *nActual = nChars;
    return status;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]) {
  vector<int> w;	//w[0] is match, w[1] is mismatch, w[2] is indel
  w.push_back(2), w.push_back(-1), w.push_back(-2), w.push_back(0);
  vector < string > seq;
  if (argc < 2 || argc > 5) {
    cout << ErrorInfo << endl;
    return EXIT_FAILURE;
  }

  for (int t = 1; t < argc; t++) {
    if (argv[t][0] == '-') {
      int score = 0;
      if (argv[t][1] == 'm') {
        sscanf(argv[t], "-m%d", &score);
        w[MATCH] = score;
      } else if (argv[t][1] == 's') {
        sscanf(argv[t], "-s%d", &score);
        w[MISMATCH] = -score;
      } else if (argv[t][1] == 'i') {
        sscanf(argv[t], "-i%d", &score);
        w[INDEL] = -score;
      }
    } else {
      if (checkFilePath(argv[t]))
        seq.push_back(argv[t]);
      else {
        printf("Cannot open the file: %s.\n", argv[t]);
        return EXIT_FAILURE;
      }
    }
  }
  if (seq.size() != 1) {
    printf("Please input paths of TWO DNA sequence file!\n");
    cout << ErrorInfo << endl;
    return EXIT_FAILURE;
  }

  CMultipleGlobalAlignment mgl(seq[0], w);
  mgl.runMultipleGlobalAlignment();
  return EXIT_SUCCESS;
}
Ejemplo n.º 4
0
QScriptValue Level::save(const QScriptValue &fpArg) {
  if (getFrameCount() == 0) {
    return context()->throwError(tr("Can't save an empty level"));
  }

  // get the path
  TFilePath fp;
  QScriptValue err = checkFilePath(context(), fpArg, fp);
  if (err.isError()) return err;
  QString fpStr = fpArg.toString();

  // handle conversion (if it is needed and possible)
  TFileType::Type fileType = TFileType::getInfo(fp);

  bool isCompatible = false;
  if (TFileType::isFullColor(fileType)) {
    if (m_sl->getType() == OVL_XSHLEVEL) isCompatible = true;
  } else if (TFileType::isVector(fileType)) {
    if (m_sl->getType() == PLI_XSHLEVEL) isCompatible = true;
  } else if (fileType & TFileType::CMAPPED_IMAGE) {
    if (m_sl->getType() == TZP_XSHLEVEL) isCompatible = true;
  } else {
    return context()->throwError(tr("Unrecognized file type :").arg(fpStr));
  }
  if (!isCompatible) {
    return context()->throwError(
        tr("Can't save a %1 level to this file type : %2")
            .arg(getType())
            .arg(fpStr));
  }

  try {
    m_sl->save(fp);
  } catch (TSystemException se) {
    return context()->throwError(
        tr("Exception writing %1")
            .arg(QString::fromStdWString(se.getMessage())));
  }
  return context()->thisObject();
}
Ejemplo n.º 5
0
QScriptValue Level::load(const QScriptValue &fpArg) {
  if (m_sl) {
    m_scene->getLevelSet()->removeLevel(m_sl, true);
    m_sl->release();
    m_sl = 0;
  }

  // get the path
  TFilePath fp;
  QScriptValue err = checkFilePath(context(), fpArg, fp);
  if (err.isError()) return err;
  QString fpStr = fpArg.toString();

  try {
    if (!TSystem::doesExistFileOrLevel(fp)) {
      return context()->throwError(tr("File %1 doesn't exist").arg(fpStr));
    }
    TFileType::Type fileType = TFileType::getInfo(fp);
    if (TFileType::isVector(fileType))
      m_type = PLI_XSHLEVEL;
    else if (0 != (fileType & TFileType::CMAPPED_IMAGE))
      m_type = TZP_XSHLEVEL;
    else if (0 != (fileType & TFileType::RASTER_IMAGE))
      m_type = OVL_XSHLEVEL;
    else {
      return context()->throwError(tr("File %1 is unsupported").arg(fpStr));
    }
    TXshLevel *xl = m_scene->loadLevel(fp);
    if (xl) {
      m_sl = xl->getSimpleLevel();
      m_sl->addRef();
    }
    return context()->thisObject();
  } catch (...) {
    return context()->throwError(tr("Exception reading %1").arg(fpStr));
  }
}
Ejemplo n.º 6
0
void SettingsDialog::checkFilePaths()
{
    checkFilePath(ui_settingsDialog->imageLineEdit);
    checkFilePath(ui_settingsDialog->soundLineEdit);
}
Ejemplo n.º 7
0
/*!
SLAssimpImporter::loadMaterial loads the AssImp material an returns the SLMaterial.
The materials and textures are added to the SLScene material and texture 
vectors.
*/
SLMaterial* SLAssimpImporter::loadMaterial(SLint index, 
                                           aiMaterial *material,
                                           SLstring modelPath)
{
    // Get the materials name
    aiString matName;
    material->Get(AI_MATKEY_NAME, matName);
    SLstring name = matName.data;
    if (name.empty()) name = "Import Material";
   
    // Create SLMaterial instance. It is also added to the SLScene::_materials vector
    SLMaterial* mat = new SLMaterial(name.c_str());

    // set the texture types to import into our material
    const SLint		textureCount = 4;
    aiTextureType	textureTypes[textureCount];
    textureTypes[0] = aiTextureType_DIFFUSE;
    textureTypes[1] = aiTextureType_NORMALS;
    textureTypes[2] = aiTextureType_SPECULAR;
    textureTypes[3] = aiTextureType_HEIGHT;
   
    // load all the textures for this material and add it to the material vector
    for(SLint i = 0; i < textureCount; ++i) 
    {   if(material->GetTextureCount(textureTypes[i]) > 0) 
        {   aiString aipath;
            material->GetTexture(textureTypes[i], 0, &aipath, nullptr, nullptr, nullptr, nullptr, nullptr);
            SLTextureType texType = textureTypes[i]==aiTextureType_DIFFUSE  ? TT_color :
                                textureTypes[i]==aiTextureType_NORMALS  ? TT_normal :
                                textureTypes[i]==aiTextureType_SPECULAR ? TT_gloss :
                                textureTypes[i]==aiTextureType_HEIGHT   ? TT_height : 
                                TT_unknown;
            SLstring texFile = checkFilePath(modelPath, aipath.data);
            SLGLTexture* tex = loadTexture(texFile, texType);
            mat->textures().push_back(tex);
        }
    }
   
    // get color data
    aiColor3D ambient, diffuse, specular, emissive;
    SLfloat shininess, refracti, reflectivity, opacity;
    material->Get(AI_MATKEY_COLOR_AMBIENT, ambient);
    material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
    material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
    material->Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
    material->Get(AI_MATKEY_SHININESS, shininess);
    material->Get(AI_MATKEY_REFRACTI, refracti);
    material->Get(AI_MATKEY_REFLECTIVITY, reflectivity);
    material->Get(AI_MATKEY_OPACITY, opacity);

    // increase shininess if specular color is not low.
    // The material will otherwise be to bright
    if (specular.r > 0.5f &&
        specular.g > 0.5f &&
        specular.b > 0.5f &&
        shininess < 0.01f)
        shininess = 10.0f;

    // set color data
    mat->ambient(SLCol4f(ambient.r, ambient.g, ambient.b));
    mat->diffuse(SLCol4f(diffuse.r, diffuse.g, diffuse.b));
    mat->specular(SLCol4f(specular.r, specular.g, specular.b));
    mat->emission(SLCol4f(emissive.r, emissive.g, emissive.b));
    mat->shininess(shininess);
    //mat->kr(reflectivity);
    //mat->kt(1.0f-opacity);
    //mat->kn(refracti);

    return mat;
}
void GlobalArgsTabu::checkArgs() const {
    checkEmpty();
    checkMin();
    checkFilePath();
}