Exemple #1
0
void StatusViewer::load() {
    //Load the data
    if(image_) {
        
        ParametersConfiguration* conf = image_->parameters();
        magLabel_->setText(conf->getValue("CALCULATEDMAG"));
        qvalLabel_->setText(conf->getValue("QVAL"));
        phaseResLabel_->setText(conf->getValue("PHARES_SYM"));
        numSpotsLabel_->setText(conf->getValue("PHARES_NUM_SPOTS"));
        
        loadTable(binsTable_, conf, QStringList() << "RB" << "RP", QStringList() << "1" << "2" << "3" << "4" << "5" << "6", "_");
        loadTable(qvalTable_, conf, QStringList() << "U1" << "U2" << "UMA" << "UMB", 
                QStringList() << "IQ1" << "IQ2" << "IQ3" << "IQ4" << "IQ5" << "IQ6", "_");
        loadTable(tiltTable_, conf, QStringList() << "DEFOCUS" << "LATTICE" << "TTREFINE" << "MERGE",
                QStringList() << "TLTAXIS" << "TLTANG" << "TAXA" << "TANGL", "_");
        
        //Manually get the QVALs (as they are not in the format row_col)
        qvalTable_->item(0, 6)->setText(conf->getValue("QVAL1"));
        qvalTable_->item(1, 6)->setText(conf->getValue("QVAL2"));
        qvalTable_->item(2, 6)->setText(conf->getValue("QVALMA"));
        qvalTable_->item(3, 6)->setText(conf->getValue("QVALMB"));
        
    }
    
}
Exemple #2
0
void Configurator::readConfig(const std::string& path)
{
    const char* p = path.c_str();

    if (luaL_dofile(L, p) != 0) {
        std::cerr << "Failed to load/run file " << path << std::endl;
    }

    lua_getglobal(L, "resources");
    const char *resources = lua_tostring(L, -1);
    if (!resources) {
        std::cerr << "Failed to read var resources" << std::endl;
    }
    strings["resources"] = std::string(resources);

    lua_getglobal(L, "title");
    const char *title = lua_tostring(L, -1);
    if (!title) {
        std::cerr << "Failed to read var title" << std::endl;
    }
    strings["title"] = std::string(title);
    lua_pop(L, 1);

    loadTable("fonts");
    loadTable("textures");
    loadTable("sounds");
}
Exemple #3
0
static void loadTables(const Common::UString &nameM, const Common::UString &nameF,
                       TalkTable *&tableM, TalkTable *&tableF, Common::Encoding encoding) {

	Common::ScopedPtr<TalkTable> m(loadTable(nameM, encoding));
	Common::ScopedPtr<TalkTable> f(loadTable(nameF, encoding));

	tableM = m.release();
	tableF = f.release();
}
void CThreadImplHard::init(){
  long ltime = time(NULL);
  srand(ltime);
  history = fopen("history.txt","w");
  loadTable();  
  //ячейки lxwxh
  l =  WIDTH;
  w = LENGTH;
  h = 1;
  step = 0;
  //создаем КА implHard
  ptrCA = new implHard(0,l,w,h);
  uint id = 0;
  //находим общее количество клеток
  numCA = l*w*h;
  //очищаем КА1, и КА2 которые потом будут обмениваться
  listCA1.clear();
  listCA2.clear();
  for(unsigned long int i=0; i<numCA; ++i){
    //создаем два автомата и инициализируем их
    listCA1.push_back(new implHard(id,l,w,h));
    listCA1.at(id)->init(id);
    listCA2.push_back(new implHard(id,l,w,h));
    listCA2.at(id)->init(id);
      ++id;
  }
  //обозначаем выходной автомат
  ptrOutputListCA = &listCA1;
  //генерируем сетку
  genGrid();
}
Exemple #5
0
bool  LuaWrapper::callLuaFunc(const char* szTableName, const char* szFuncName, const char* sig, ...)
{
	int nIndexTop = gettop();
	va_list vl;
	va_start(vl, sig);
	bool bRet = true;

	if (!loadTable(szTableName))
	{
		luaL_error(m_luaState, "load table[%s] failed.", szTableName);
		bRet = false;
	}
	lua_pushstring(m_luaState, szFuncName);
	lua_gettable(m_luaState, -2);// key从栈弹出,并获取 table[key] 的值压入栈

	if (!lua_isfunction(m_luaState, -1))
	{
		luaL_error(m_luaState, "table [%s] field [ %s ] isn't an function.", szTableName, szFuncName);
		bRet = false;
	}
	else
	{

		bRet = doCallFunction(sig, vl);
	}

	va_end(vl);
	settop(nIndexTop);

	return bRet;
}
StoragePtr InterpreterInsertQuery::getTable()
{
    if (!cached_table)
        cached_table = loadTable();

    return cached_table;
}
Exemple #7
0
void loadTables(SS_Tables tables)
{
  for (; !SS_isTablesEmpty(tables); tables = SS_getTablesTail(tables)) {
    SS_Table table = SS_getTablesHead(tables);
    loadTable(table);
  }
}
Exemple #8
0
void LocalizerImpl::loadTable(const string &file, const string &language)
{
  clear();
  ifstream fin(file.c_str(), ios::in);

  if (!fin.good())
    return;

  int line=0;
  char bf[8*1024];
  while (!fin.eof()) {
    line++;
    fin.getline(bf, 8*1024);
  }

  fin.seekg(0);
  fin.clear();
  fin.seekg(0);

  vector<string> raw;
  raw.reserve(line);
  while (!fin.eof()) {
    bf[0] = 0;
    fin.getline(bf, 8*1024);
    if (bf[0]!=0 && bf[0]!='#')
      raw.push_back(bf);
  }

  loadTable(raw, language);
}
Exemple #9
0
void CQExperimentData::slotWeightMethod(int weightMethod)
{
  if (mpExperiment == NULL) return;

  if ((CExperiment::WeightMethod) weightMethod ==
      mpExperiment->getWeightMethod()) return;

  switch ((CExperiment::WeightMethod) weightMethod)
    {
      case CExperiment::VALUE_SCALING:
        mpTable->horizontalHeaderItem(COL_SCALE)->setText("Epsilon");
        break;

      default:
        mpTable->horizontalHeaderItem(COL_SCALE)->setText("Weight");
        break;
    }

  size_t Current =
    mpExperimentSetCopy->keyToIndex(mpExperiment->CCopasiParameter::getKey());
  size_t Next = Current + 1;

  // Find all experiments which are like this.
  while (Next < mpExperimentSetCopy->getExperimentCount() && mpCheckTo->isChecked())
    {
      CExperiment * pNext = mpExperimentSetCopy->getExperiment(Next);

      if (!isLikePreviousExperiment(pNext)) break;

      Next++;
    }

  // Update each of them.
  while (true)
    {
      Next--;

      CExperiment * pNext = mpExperimentSetCopy->getExperiment(Next);

      bool Changed = saveTable(pNext);

      if (Changed)
        {
          std::ifstream File;
          File.open(CLocaleString::fromUtf8(pNext->getFileName()).c_str());

          size_t CurrentLine = 1;
          pNext->read(File, CurrentLine);
          pNext->compile();
        }

      pNext->setWeightMethod((CExperiment::WeightMethod) weightMethod);
      pNext->calculateWeights();

      if (Next == Current) break;
    }

  loadTable(mpExperiment, false);
}
/*!
 *  \class MessageProgrammesDialog
 *  \fn MessageProgrammesDialog::MessageProgrammesDialog(QWidget *parent)
 *  \brief constructeur de la classe MessageProgrammesDialog
 *  \param[in] parent Parent de l'application (toujorus la MainWindow)
 *
 */
MessageProgrammesDialog::MessageProgrammesDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MessageProgrammesDialog)
{
    ui->setupUi(this);
    creerConnect();
    loadTable();
}
// Loads the target file data, execs the dialog
//     and saves it again if Accept is clicked
int TargetSettingsDialog::exec()
{
	loadTable();
	if(QDialog::exec() == QDialog::Rejected)
		return QDialog::Rejected;
	saveTable();
	return QDialog::Accepted;
}
// createTrans0
//---------------------------------------------------------------------------
void ColorTable::createTrans0(
    const int  &color1Percent,
    const int  &color2Percent,
    const char *filename)
{
    init(256 * 256);

    if(FileSystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(Exception e) {
            LOG( ("Error while loading palette'%s': %s", filename, e.what()) );
        }
    }

    LOG ( ("Creating colortable '%s'.", filename) );
    float color1        = float(color1Percent) / 100.0f;
    float color2        = float(color2Percent) / 100.0f;
    //int	  totalColors   = colorCount;
    //int   curColorIndex = 0;
    //int   num           = 0;
    //int   numInterval   = (totalColors) / 100;

    // Since the file was not found, create the color tables and dump
    // it to a file.
    unsigned curOffset = 0;

    for (unsigned index = 0; index < 256; index++) {
        const RGBColor col = Palette::color[index];

        for (unsigned indexPic = 0; indexPic < 256; indexPic++) {
            const RGBColor colPic = Palette::color[indexPic];

            curOffset = (int(index) << 8) + indexPic;

            RGBColor curColor((int) (color1 * col.red   + color2 * colPic.red),
                              (int) (color1 * col.green + color2 * colPic.green),
                              (int) (color1 * col.blue  + color2 * colPic.blue));

            // Makes the color table use color 0 as transparent.

            if (indexPic == 0) {
                setColor(curOffset, index);
            } else {

                setColor(curOffset, Palette::findNearestColor(curColor));
            }
        }
    }

    try {
        saveTable(filename);
    } catch(Exception e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s",
               filename, e.what()) );
    }
} // end ColorTable::createTrans0
/*!
 *  \fn void MessageProgrammesDialog::supprimerAll()
 *  \brief supprime tout le contenu du fichier de sauvegarde
 *
 *  supprime tout le contenu du fichier de sauvegarde puis redemande l'affichage du tableau
 */
void MessageProgrammesDialog::supprimerAll()
{
    QFile fichier(Tools::absolutePathFile("src/programmes.txt"));
    if(fichier.open(QIODevice::WriteOnly |QIODevice::Truncate | QIODevice::Text))
    {
        fichier.close();
    }
    loadTable();
}
// createBrightenFilter
//---------------------------------------------------------------------------
void ColorTable::createBrightenFilter(
    const char *filename,
    const int  &brightness)
{
    assert(brightness > 0 && brightness <= 256);
    init(256 * 256);

    if(filesystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(std::exception& e) {
            LOG( ("Error while loading palette '%s': %s", filename,
                  e.what()) );
        }
    }

    LOG ( ("Creating ColorTable '%s'.", filename) );
    // Since the file was not found, create the color tables and dump
    // it to a file.
    int   curOffset;
    int   curRed;
    int   curGreen;
    int   curBlue;
    float nb;        // The new brightness color.

    float fBrightness = float(brightness) / 256.0f;

    for (int y = 0; y < 256; y++) {
        for (int x = 0; x < 256; x++) {
            nb = float(x) * fBrightness;
            curOffset = (y * 256) + x;

            // !SOMDEDAY! Try holding a threshold when any value gets to 255.
            curRed   = (int) (nb + Palette::color[y].r);
            curGreen = (int) (nb + Palette::color[y].g);
            curBlue  = (int) (nb + Palette::color[y].b);

            if (curRed   > 255) curRed   = 255;
            if (curGreen > 255) curGreen = 255;
            if (curBlue  > 255) curBlue  = 255;
            //curColor = Palette::color[y];

            setColor(curOffset, Palette::findNearestColor(curRed, curGreen, curBlue));
        }
    }

    try {
        saveTable(filename);
    } catch(std::exception& e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s", filename,
               e.what()) );
    }
} // end createBrightenFilter
CPersonalEdit::CPersonalEdit(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CPersonalEdit)
{
    m_parent = parent;
    m_actUsr = new CPersonal(((CMainWindow*)parent)->getUserID());
    ui->setupUi(this);
    connect(qApp,SIGNAL(focusChanged(QWidget*,QWidget*)),this,SLOT(setSelected(QWidget*,QWidget*)));
    loadTable();
    fillPersTable();
}
Exemple #16
0
bool EXP_IMP_DLL LuaWrapper::setTableField<char*>(const char* szTableName, const char*	szFieldName, char* Value)
{
	if( !loadTable(szTableName) )  return false;

	lua_pushstring(m_luaState, szFieldName);
	lua_pushstring(m_luaState, Value);
	lua_settable(m_luaState, -3);

	lua_pop(m_luaState, 1);
	return true;
}
Exemple #17
0
/**bref load all databases in mmap memory by request in inputData global structure*/
void GMemory::loadDB() {

    string db=inputData.data["db"];
    string ln=inputData.data["ln"];
    string mode=inputData.data["mode"];
    string pathCorpus;
    string path;

    aliKali=((GFontEditor*)inputData.fontEditor)->aliKali;  //load font pointer from fontEditor

    if(inputData.data["loadMode"]=="OCR") {
        //read font grammar data
        path="LETTERS_GRAMMAR";
        loadTable(path);
        fontTable=table[path].data;
        //cout<<" table->size()="<<fontTable->size()<<endl;
        indexRecord indexRec=createIndex(table[path],8,HASH_SEARCH);
        fontGMap=indexRec.mIndex;
        //string name="ྃ"; //3530339
        //int ind=indexRec.mIndex->getHKey(name,8);

        indexRec=createIndex(table[path],5,OCR_SEARCH);
        fontStackGMap=indexRec.mIndex;

        path="OCR_DICTIONARY";
        loadTable(path);
        textCorpus=table[path].data;
        //cout<<"textCorpus->size()="<<textCorpus->size()<<endl;
        indexRec=createIndex(table[path],0,OCR_SEARCH);
        textCorpusGMap=indexRec.mIndex;

        path="LETTERS_CORRELATION";
        loadTable(path);
        aliKali->correlationVector=table[path].data;
        //cout<<"textCorpus->size()="<<textCorpus->size()<<endl;
        indexRec=createIndex(table[path],0,HASH_SEARCH);
        aliKali->correlationMap=indexRec.mIndex;

    }

}
Exemple #18
0
// ---------------------------------------------------------------------------
//  The parameters are:
//
//  argV[1] = The source UCM file
//  argV[2] = The path to the output file
// ---------------------------------------------------------------------------
int main(int argC, char** argV)
{
    // We have to have 3 parameters
    if (argC != 3)
    {
        showUsage();
        return 1;
    }

    // Try to open the first file for input
    gInFile = fopen(argV[1], "rt");
    if (!gInFile)
    {
        cout << "Could not find input file: " << argV[1] << endl;
        return 1;
    }

    // Try to open the second file for output (truncated)
    gOutFile = fopen(argV[2], "wt+");
    if (!gOutFile)
    {
        cout << "Could not create output file: " << argV[1] << endl;
        return 1;
    }

    //
    //  This will parse the file and load the table. It will also look for
    //  a couple of key fields in the file header and store that data into
    //  globals.
    //
    loadTable();

    // If we didn't get any table entries, then give up
    if (!gMainTableSz)
    {
        cout << "No translation table entries were found in the file" << endl;
        return 1;
    }

    //
    //  Ok, we got the data loaded. Now lets output the tables. This method
    //  spit out both tables to the output file, in a format ready to be
    //  incorporated directly into the source code.
    //
    formatSBTables();

    // Close our files
    fclose(gInFile);
    fclose(gOutFile);

    return 0;
}
Exemple #19
0
/*
 * Common function to add ite at given index
 */
void MovieSequenceForm::addAtIndex(int index)
{
  MovieSegment segment;
  mvMovieGetSegment(segment);
  if (index >= mSegments->size())
    mSegments->push_back(segment);
  else
    mSegments->insert(mSegments->begin() + index, segment);
  loadTable();
  table->selectRow(index);
  updateEnables(mMovieEnabled, mMakingMovie);
  mModified = true;
}
Exemple #20
0
/*
 * Delete current item
 */
void MovieSequenceForm::deleteClicked()
{
  int index = table->currentRow();
  if (index < 0 || index >= mSegments->size())
    return;
  mSegments->erase(mSegments->begin() + index);
  loadTable();
  if (index >= mSegments->size())
    index = mSegments->size() - 1;
  if (index >= 0)
    table->selectRow(index);
  updateEnables(mMovieEnabled, mMakingMovie);
  mModified = true;
}
table* readInFile(table *alphabet, char *filename) {
	FILE *file = fopen(filename, "r");
	int i = 0;
	char c;
	float f;

	while (i++ < 26) {
		fscanf(file, "%c %f\n", &c, &f);
		alphabet = loadTable(alphabet, c, f, 1);
	}

	fclose(file);
	return alphabet;
}
TEST_F(ReplaceTableTests, basic_replace_table_test) {
  auto t1 = Loader::shortcuts::load("test/lin_xxs.tbl");
  auto t2 = Loader::shortcuts::load("test/10_30_group.tbl");

  auto sm = StorageManager::getInstance();
  sm->loadTable("replaceMe", t1);

  ASSERT_TABLE_EQUAL(t1, sm->getTable("replaceMe"));

  ReplaceTable rt("replaceMe");
  rt.addInput(t2);
  rt.execute();

  ASSERT_TABLE_EQUAL(t2, sm->getTable("replaceMe"));
}
Exemple #23
0
void CQExperimentData::slotSeparator()
{
  if (!mpExperiment) return;

  //  saveTable(mpExperiment);

  if (mpCheckTab->isChecked())
    mpExperiment->setSeparator("\t");
  else
    mpExperiment->setSeparator(TO_UTF8(mpEditSeparator->text()));

  mpExperiment->setNumColumns((unsigned C_INT32) mpExperiment->guessColumnNumber());
  mpExperiment->readColumnNames();

  loadTable(mpExperiment, true);
}
Exemple #24
0
static void hgPar(char *db, char *parSpecFile, char *parTable, boolean fileOutput)
/* hgPar - create PAR track. */
{
struct parSpec *parSpec, *parSpecs = parSpecLoadAll(parSpecFile);
checkSpecs(db, parSpecs);

struct bed4 *beds = NULL;
for (parSpec = parSpecs; parSpec != NULL; parSpec = parSpec->next)
    beds = slCat(beds, convertParSpec(parSpec));

slSort(&beds, bedCmp);
if (fileOutput)
    writeTable(beds, parTable);
else
    loadTable(beds, db, parTable);
}
// lightDark table builder logic.
// 0-----------Color (x)----------255
// |
// |
// brightness (y)
// |
// |
// 255
//---------------------------------------------------------------------------
void ColorTable::createLightDarkFilter(const char *filename)
{
    init(256 * 256);

    if(filesystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(std::exception& e) {
            LOG( ("Error while loading palette'%s': %s", filename, e.what()) );
        }
    }

    LOG ( ("Creating colortable '%s'.", filename) );

    int curOffset;
    int curRed;
    int curGreen;
    int curBlue;

    for (int y = 0; y < 256; y++) {
        int x;
        for (x = 0; x <= 128; x++) {
            curOffset = x + (y << 8);
            curRed   = Palette::color[y].r   * x / 128;
            curGreen = Palette::color[y].g * x / 128;
            curBlue  = Palette::color[y].b  * x / 128;

            setColor(curOffset, Palette::findNearestColor(curRed, curGreen, curBlue));
        }
        for (x = 129; x < 256; x++) {
            curOffset = x + (y << 8);
            curRed   = Palette::color[y].r + ((255 - Palette::color[y].r) * (x-128) / 127);
            curGreen = Palette::color[y].g + ((255 - Palette::color[y].g) * (x-128) / 127);
            curBlue  = Palette::color[y].b + ((255 - Palette::color[y].b) * (x-128) / 127);

            setColor(curOffset, Palette::findNearestColor(curRed, curGreen, curBlue));
        }
    }

    try {
        saveTable(filename);
    } catch(std::exception& e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s", filename, e.what()) );
    }
} // end ColorTable::createLightDarkFilter
int main(int argc, char **argv) {
	if (argc < 2) {
		printf("\nInput file needed. Exiting...\n");
		return 0;
	}

	FILE *input = fopen(argv[1], "r");
	char pt, c;
	int i = 0, numChars, shifts[3] = {0};
   	float charCount[26] = {0};
	table *alphabet = NULL;
	
	alphabet = readInFile(alphabet, "letterFrequencies.txt");
	
	numChars = countFrequency(input, charCount);
	computeFrequency(numChars, charCount);

	printf("\nFREQUENCY ANALYSIS ATTACK ON THE SHIFT CIPHER"
			"\n--------------------------------------");

	table *inputFrequencies = NULL;
	
	int a = 0;
	while (a < 26) {
		inputFrequencies = loadTable(inputFrequencies, a+97, charCount[a], 0);
		a++;
	}
	
	pickTopShifts(inputFrequencies, shifts);
	table *temp = inputFrequencies;

	printf("\nTESTING TOP 3 SHIFT POSSIBILITIES\n");
	for (i = 0; i < 3; i++) {
		rewind(input);
		printf("\nDecryption %d/3; Shift :%d\t", i+1, shifts[i]-4);
		while((c = getc(input)) != EOF){
			pt = decrypt(c, shifts[i]-4);
			putchar(pt);
		}
	}

	printf("\n");
	fclose(input);
	return 0;
}
Exemple #27
0
double EXP_IMP_DLL LuaWrapper::getTableField<double>(const char* szTableName, const char*	szFieldName)
{
	double dRet = 0.0;

	if( !loadTable(szTableName) )
	{
		return dRet;
	}
	lua_pushstring(m_luaState, szFieldName);
	lua_gettable(m_luaState, -2);// key从栈弹出,并获取 table[key] 的值压入栈

	if(!lua_isnumber(m_luaState, -1))
		luaL_error(m_luaState, "table [%s] field [ %s ] isn't an double.", szTableName, szFieldName);

	dRet = (double)lua_tonumber(m_luaState, -1);
	lua_pop(m_luaState, 2); /* remove result and table*/
	return dRet;
}
Exemple #28
0
std::string EXP_IMP_DLL LuaWrapper::getTableField<std::string>(const char* szTableName, const char*	szFieldName)
{
	std::string strRet = "";

	if( !loadTable(szTableName) )
	{
		return strRet;
	}
	lua_pushstring(m_luaState, szFieldName);
	lua_gettable(m_luaState, -2);// key从栈弹出,并获取 table[key] 的值压入栈

	if( !lua_isstring(m_luaState, -1))
		luaL_error(m_luaState, "table [%s] field [ %s ] isn't an string.", szTableName, szFieldName);

	strRet = lua_tostring(m_luaState, -1);
	
	lua_pop(m_luaState, 2); /* remove result and table*/
	return strRet;
}
Exemple #29
0
bool EXP_IMP_DLL LuaWrapper::getTableField<bool>(const char* szTableName, const char*	szFieldName)
{
	bool bRet = false;

	if( !loadTable(szTableName) )
	{
		return bRet;
	}
	lua_pushstring(m_luaState, szFieldName);
	lua_gettable(m_luaState, -2);// key从栈弹出,并获取 table[key] 的值压入栈
	
	if(!lua_isboolean(m_luaState, -1))
		luaL_error(m_luaState, "table [%s] field [ %s ] isn't an boolean.", szTableName, szFieldName);

	bRet = lua_toboolean(m_luaState, -1);

	lua_pop(m_luaState, 2); /* remove result and table*/
	return bRet;
}
Exemple #30
0
void GMemory::exportAllRecords(string&tableName,string path) {
    path+="/";
    path=str_replace("//", "/", path);
    tableRecord &rec=table[tableName];
    if(!rec.status)loadTable(tableName);  //if table not exsist, create it
    GVector*dict=rec.data;
    for(int n=0; n<dict->size(); n++) {
        TString st;
        dict->getTStr(n,&st);
        string res;
        string fileName=path+st[0]+".txt";
        if(!st.size())continue;
        for(int n=0; n<st.size(); n++) {
            string s=st[n];
            res+=s+"\n";
        }
        writeText(res, fileName.c_str());
    }

};