示例#1
0
void list_quads( void ){
    int i;  SymRec sR1,sR2,sR3;
    printf("\nIntrmediate code: %d\n\n",quadCt);
    for( i=0; i<quadCt; i++ ){
        printf( "%3d: (%c,%6d,%6d,%6d)   ", i, quad[i].op,quad[i].a1,
                                                    quad[i].a2,quad[i].a3);
        sR1 = tbl(quad[i].a1); sR2 = tbl(quad[i].a2); sR3 = tbl(quad[i].a3);
        switch( quad[i].op ){
           case '=':
               printf("%6s = %s\n",sR3.sym, sR1.sym); break;
           case '+': case '*': case '-': case '/': case '%': case '>': case '<': 
               printf("%6s = %s %c %s\n", sR3.sym, sR1.sym, quad[i].op, sR2.sym); break;
           case 'w': printf("    print(%s)\n",sR3.sym); break;
           case 'V': if(quad[i].a2 == -1){ printf("%6s = %d\n",sR3.sym,quad[i].a1); break; }
		             else { printf("%6s = %d*10**(%d-6)\n", sR3.sym, quad[i].a1, quad[i].a2);  break; }
	       case 'H': printf("   return\n"); break;
	       case 'M': printf("%6s = -%s\n",sR3.sym, sR1.sym); break;
		   case 'I': printf("%6s = %s\n",sR3.sym, sR1.sym); break;
		   case 'R': printf("%6s = %s\n",sR3.sym, sR1.sym); break;
		   case 'N': printf("%6s = not %s\n",sR3.sym, sR1.sym); break;
		   case 'E': printf("%6s = %s %s %s\n", sR3.sym, sR1.sym, "equal", sR2.sym); break;
		   case 'A': printf("%6s = %s %s %s\n", sR3.sym, sR1.sym, "and", sR2.sym); break;
		   case 'O': printf("%6s = %s %s %s\n", sR3.sym, sR1.sym, "or", sR2.sym); break;
		   case 'z': printf("IF %s false, goto quad %d\n", sR1.sym, quad[i].a3); break;
		   case 'j': printf("  E true, jump to quad %d\n", quad[i].a3); break;
		   case '@': if(quad[i].a1 == -1){ printf("    *%s = %s\n", sR3.sym, sR2.sym); break; } 
		             else { printf("%6s = *%s\n", sR3.sym, sR1.sym); break;}
		   case '&': printf("%6s = &%s\n",sR3.sym, sR1.sym); break;
		   case 'r': printf("   Read %s\n",sR3.sym); break;
           default:  printf("     ?  ?  ?\n");
        }
    }
}
示例#2
0
文件: API.cpp 项目: HBzju/minisql
void API_Create_Table(string tablename,FieldTree *T)
{
//	try{
		//catalog meta data
		Table tbl(tablename);
		tbl.initializeTable(T);
		tbl.createTable();
		string primaryIdxName=tablename+"PRIMARY_INDEX";
		Index newIndex(primaryIdxName);
		IndexStruct Idx;
		Idx.attr_name = tbl.getPrimaryKey();
		Idx.index_name = primaryIdxName;
		Idx.table_name = tablename;

		newIndex.initializeIndex(&Idx);
		newIndex.createIndex();
		//End of catalog do
		//IndexManager do
		IndexInfo idxInfo;
		idxInfo.indexname = Idx.table_name + "PRIMARY_INDEX";
		idxInfo.attr_size=tbl.getPrimaryKeySize();
		idxInfo.maxKeyNum=(BLOCKSIZE-INDEX_BLOCK_INFO-4)/(4+idxInfo.attr_size);
		Create_Index_Init(idxInfo);
		//End of IndexManager do
/*	}
	catch(...){
		cout<<"Failed to Create Table."<<endl;
	}*/
}
示例#3
0
void Cursor::onUpdateVertexCache()
{
	clearVertices();

	std::vector<sf::Vertex> vertices;

	// pos coords.
	sf::Vector2f tl(myCursorTransform.getTransform().transformPoint(sf::Vector2f(0,0)));
	sf::Vector2f tr(myCursorTransform.getTransform().transformPoint(sf::Vector2f(getTextureRect().width,0)));
	sf::Vector2f br(myCursorTransform.getTransform().transformPoint(sf::Vector2f(getTextureRect().width,getTextureRect().height)));
	sf::Vector2f bl(myCursorTransform.getTransform().transformPoint(sf::Vector2f(0,getTextureRect().height)));

	// tex coords.
	sf::Vector2f ttl(getTextureRect().left, getTextureRect().top);
	sf::Vector2f tbr(getTextureRect().left + getTextureRect().width, getTextureRect().top + getTextureRect().height);
	sf::Vector2f ttr(tbr.x, ttl.y);
	sf::Vector2f tbl(ttl.x, tbr.y);

	// add vertices.
	vertices.push_back(sf::Vertex(tl, sf::Color::White, ttl));
	vertices.push_back(sf::Vertex(tr, sf::Color::White, ttr));
	vertices.push_back(sf::Vertex(bl, sf::Color::White, tbl));
	vertices.push_back(sf::Vertex(tr, sf::Color::White, ttr));
	vertices.push_back(sf::Vertex(br, sf::Color::White, tbr));
	vertices.push_back(sf::Vertex(bl, sf::Color::White, tbl));

	vertexAddTextured(vertices);
}
示例#4
0
int main()
{
	TableReader tbl(ReadTypeDump);
	string ret;
	int jumpbytes;
	
	if(tbl.OpenTable("test.tbl")==true){
		cout<<"open ok\n";
		if(tbl.GetTextValue("7890",ret,jumpbytes)==true)
			cout<<ret<<","<<jumpbytes<<"\n";
		else
			cout<<"cant find";
		if(tbl.GetTextValue("0e",ret,jumpbytes)==true)
			cout<<ret<<","<<jumpbytes<<"\n";
		else
			cout<<"cant find";
		if(tbl.GetTextValue("90",ret,jumpbytes)==true)
			cout<<ret<<","<<jumpbytes<<"\n";
		else
			cout<<"cant find";
		
        tbl.OutputError();
	}
	else{
        tbl.OutputError();
    }
	return 0;
}
示例#5
0
文件: Group.cpp 项目: foadnh/groups
 Group Group::direct(const Group& right) {
  int leftQty = order(), rightQty = right.order();
  int newQty = leftQty * rightQty;
  vector< vector<int> > tbl(newQty, vector<int>(newQty));
  for (int i=0; i<newQty; i++) {
   int xa = i / rightQty, xb = i % rightQty;
   for (int j=0; j<newQty; j++) {
    int ya = j / rightQty, yb = j % rightQty;
    tbl[i][j] = table[xa][ya] * rightQty + right.table[xb][yb];
   }
  }
  vector<int> invs = vector<int>(newQty);
  vector<int> ords = vector<int>(newQty);
  vector<string> ss = vector<string>(newQty);
  for (int i=0; i<newQty; i++) {
   int a = i / rightQty, b = i % rightQty;
   invs[i] = inverses[a] * rightQty + right.inverses[b];
   ords[i] = lcm(orders[a], right.orders[b]);
   if (i == 0) {
    ss[i] = "1";
   } else {
    ostringstream out;
    out << '(' << strs[a] << ", " << right.strs[b] << ')';
    ss[i] = out.str();
   }
  }
  return Group(tbl, invs, ords, ss, abel && right.abel);
 }
//------------------------------------------------------------------------------
// Get the current AI nextValue from the system catalog.
//------------------------------------------------------------------------------
int ColumnAutoInc::getNextValueFromSysCat( uint64_t& nextValue )
{
    std::string::size_type periodIdx = fTableName.find('.');

    std::string sName;
    std::string tName;
    sName.assign(fTableName, 0, periodIdx);
    tName.assign(fTableName, periodIdx + 1,
                 fTableName.length() - (periodIdx + 1));
    execplan::CalpontSystemCatalog::TableName tbl(sName, tName);
    uint64_t nextAuto = 0;

    try
    {
        boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatPtr =
            execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(
                BULK_SYSCAT_SESSION_ID);
        systemCatPtr->identity(execplan::CalpontSystemCatalog::EC);

        // Handle bad return code or thrown exception from
        // system catalog query.
        nextAuto = systemCatPtr->nextAutoIncrValue( tbl );

        if (nextAuto == 0)
        {
            throw std::runtime_error(
                "Not an auto-increment column, or column not found");
        }
        else if (nextAuto == AUTOINCR_SATURATED)
        {
            throw std::runtime_error(
                "auto-increment max value already reached");
        }

        nextValue = nextAuto;
    }
    catch (std::exception& ex)
    {
        std::ostringstream oss;
        oss << "Unable to get current auto-increment value for " <<
            sName << "." << tName << "; " << ex.what();
        fLog->logMsg( oss.str(), ERR_AUTOINC_INIT1, MSGLVL_ERROR );
        BulkLoad::addErrorMsg2BrmUpdater(tName, oss);
        return ERR_AUTOINC_INIT1;
    }
    catch (...)
    {
        std::ostringstream oss;
        oss << "Unable to get current auto-increment value for " <<
            sName << "." << tName << "; unknown exception";
        fLog->logMsg( oss.str(), ERR_AUTOINC_INIT2, MSGLVL_ERROR );
        BulkLoad::addErrorMsg2BrmUpdater(tName, oss);
        return ERR_AUTOINC_INIT2;
    }

    return NO_ERROR;
}
示例#7
0
文件: hw4.cpp 项目: xatier/QQP
	int lcs (const T* x,int m,const T* y,int n)
	{
		vector<vector<int> > tbl(m+1,vector<int>(n+1,0));
		int ans=lcs (x,m,y,n,tbl);
		cout << "Lcs :";
		lcs (x,m,y,n,const_cast<const vector<vector<int> > >(tbl));
		cout << endl;
		return ans;
	}
示例#8
0
//------------------------------------------------------------------------------
// TempXMLGenData constructor
//------------------------------------------------------------------------------
TempXMLGenData::TempXMLGenData(const std::string& jobId,
                         const std::string& schema,
                         const std::string& table)
{
    fParms[ JOBID] = jobId;                     // add or override default value
    fSchema = schema;
    execplan::CalpontSystemCatalog::TableName tbl(schema, table);
    fTables.push_back( tbl );
}
示例#9
0
    int GeneralWriter :: addTable ( const std :: string &table_name )
    {        
        stream_state new_state = uninitialized;

        switch ( state )
        {
        case schema_sent:
        case remote_name_and_schema_sent:
        case remote_name_schema_and_software_name_sent:
            new_state = have_table;
            break;
        case have_table:
        case have_column:
            new_state = state;
            break;
        default:
            throw "state violation adding table";
        }

        // create a pair between the outer db id ( 0 ) and this table name
        // this pair will act as an unique key of tables, whereas table_name
        // itself can be repeated if multiple databases are in use
        int_dbtbl tbl ( 0, table_name );

        // prediction this is the index
        int id = ( int ) tables.size() + 1;
        if ( id > 256 )
            throw "maximum number of tables exceeded";

        // make sure we never record a table name twice under the same db
        std :: pair < std :: map < int_dbtbl, int > :: iterator, bool > result = 
            table_name_idx.insert ( std :: pair < int_dbtbl, int > ( tbl, id ) );
        
        // if first time
        if ( result.second )
        {
            tables.push_back ( tbl );

            size_t str_size = table_name . size ();
            if ( str_size > 0x10000 )
                throw "maximum table name length exceeded";

            gwp_1string_evt_U16 hdr;
            init ( hdr, id, evt_new_table2 );
            set_size ( hdr, str_size );
            write_event ( & hdr . dad, sizeof hdr );
            internal_write ( table_name.data (), str_size );

            state = new_state;
        }
        
        // 1 based table id
        return result.first->second;
    }
示例#10
0
int 
main(int argc, char *argv[])
{
	progname = basename(argv[0]);
# ifndef gcos
signal(SIGPIPE, badsig);
# endif
# ifdef gcos
if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */
# endif
exit(tbl(argc,argv));
}
示例#11
0
bool hsclient::query(const char* oper, const char* values[], int num,
	const char* limit_offset, char mop,
	const char* to_values[], int to_num)
{
	acl_assert(tbl_curr_);

	bool retried = false;

	while (true)
	{
		// 创建请求数据
		hsproto::build_request(buf_, tbl_curr_->id_, oper, values,
			num, limit_offset, mop, to_values, to_num);

		if (debugOn_)
			printf("%s(%d)>>>send: (%s)\n",
				__FUNCTION__, __LINE__, buf_.c_str());

		// 与数据库通信并从数据库获得结果
		if (chat() == true)
			break;

		// 如果与数据库通信失败当允许重试时若重试也失败则返回错误
		if (retry_enable_ == false || retried)
		{
			close_stream();
			return (false);
		}

		retried = true;

		// 先缓冲当前表结构中的信息
		string dbn(tbl_curr_->dbn_), tbl(tbl_curr_->tbl_);
		string idx(tbl_curr_->idx_), flds(tbl_curr_->flds_);

		// 先关闭旧的连接对象及所有的表对象
		close_stream();

		// 再重新打开连接对象并打开表对象
		if (open_tbl(dbn.c_str(), tbl.c_str(), idx.c_str(),
				flds.c_str(), true) == false)
		{
			logger_error("reopen error");
			return (false);
		}
	}

	if (debugOn_)
		printf("%s(%d): gets: (%s)\n",
			__FUNCTION__, __LINE__, buf_.c_str());
	return (proto_.parse_respond(tbl_curr_->nfld_, buf_, error_, serror_));
}
示例#12
0
文件: t1.c 项目: 5432935/crossbridge
int main(int argc,char *argv[])
{
extern init_options();
# ifdef unix
void badsig(void);
signal(SIGPIPE, badsig);
# endif
# ifdef gcos
if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */
# endif
init_options();
exit(tbl(argc,argv));
return 0;
}
示例#13
0
文件: mysql.cpp 项目: sequoiar/SilkJS
static JSVAL list_fields(JSARGS args) {
	HandleScope scope;
	MYSQL *handle = (MYSQL *) args[0]->IntegerValue();
	const char *table = NULL;
	const char *wild = NULL;
	if (args.Length() > 1) {
		String::Utf8Value tbl(args[1]->ToString());
		table = *tbl;
	}
	if (args.Length() > 2) {
		String::Utf8Value pat(args[1]->ToString());
		wild = *pat;
	}
	return scope.Close(Integer::New((unsigned long)mysql_list_fields(handle, table, wild)));
}
void HeightmapSampling::addTable(grasp_template::GraspTemplate& t) const
{
  Vector3d table_point, dir_1(1, 0, 0), dir_2(0, 1, 0);
  table_point.x() = table_pose_.position.x;
  table_point.y() = table_pose_.position.y;
  table_point.z() = table_pose_.position.z;
  Quaterniond table_orientation;
  table_orientation.w() = table_pose_.orientation.w;
  table_orientation.x() = table_pose_.orientation.x;
  table_orientation.y() = table_pose_.orientation.y;
  table_orientation.z() = table_pose_.orientation.z;
  dir_1 = table_orientation * dir_1;
  dir_2 = table_orientation * dir_2;

  table_point = t.object_to_template_rotation_.inverse() * (table_point -
      t.object_to_template_translation_);
  dir_1 = t.object_to_template_rotation_.inverse() * dir_1;
  dir_2 = t.object_to_template_rotation_.inverse() * dir_2;

  Vector3d n = dir_1.cross(dir_2);
  n.normalize();
  const double tile_length_x = t.heightmap_.getMapLengthX() / t.heightmap_.getNumTilesX();
  const double tile_length_y = t.heightmap_.getMapLengthY() / t.heightmap_.getNumTilesY();
  const double x0 = -t.heightmap_.getMapLengthX() / 2.0 + tile_length_x / 2.0;
  const double y0 = -t.heightmap_.getMapLengthY() / 2.0 + tile_length_y / 2.0;

  if (abs(n.z()) < 0.000001)
  {
    return;
  }

  for (unsigned int ix = 0; ix < t.heightmap_.getNumTilesX(); ix++)
  {
    for (unsigned int iy = 0; iy < t.heightmap_.getNumTilesY(); iy++)
    {
      const double x = x0 + ix * tile_length_x;
      const double y = y0 + iy * tile_length_y;

      double z = (n.dot(table_point) - (x * n.x() + y * n.y())) / n.z();
      Vector3d tbl(x, y, z);
      tbl = tbl - table_point;

      const double cur_tile_val = t.heightmap_.getGridTile(x, y);
      if (cur_tile_val < z || t.heightmap_.isEmpty(cur_tile_val))
        t.heightmap_.setGridTileTable(x, y, z);
    }
  }
}
示例#15
0
// [件名]テキストボックスからのフォーカスOUT
void CMsgForm::OnKillfocusEditTitle()
{
	CString strBak = m_EditTitle;
	UpdateData(TRUE);	// DDX更新
	if (m_EditTitle == strBak) return;	// 変更がない場合

	/// RDFLテーブルの更新
	CTblRdfl tbl(theApp.m_strDBPath);
	if (tbl.SelectRec(theApp.m_lngRdflId) <= 0) return;
	tbl.strTitle = m_EditTitle;		// 件名
	tbl.UpdateRec(theApp.m_lngRdflId);

	/// リスト上の[件名]表示の更新
	CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
	CMsgList *pfview = (CMsgList *)pFrame->m_pMsgList->GetWnd();
	CReportCtrl &rc = pfview->m_wndList;
	rc.SetItemText(pfview->m_hActive, 3, m_EditTitle);
}
示例#16
0
 int uniquePathsWithObstacles(vector<vector<int> > &obstacleGrid) {
     int m = obstacleGrid.size();
     int n = obstacleGrid[0].size();
     
     vector<vector<int>> tbl(m, vector<int>(n, 0));
     for(int i = 0; i < m; i++){
         for(int j = 0; j < n; j++){
             if(obstacleGrid[i][j] == 1){
                 tbl[i][j] = 0;
                 continue;
             }
             
             // no obstacle 
             if(i == 0 && j == 0) tbl[i][j] = 1;
             else if(i == 0 && j > 0) tbl[i][j] = tbl[i][j-1];
             else if(j == 0 && i > 0) tbl[i][j] = tbl[i-1][j];
             else tbl[i][j] = tbl[i-1][j] + tbl[i][j-1];
         }
     }
     
     return tbl[m-1][n-1];
 }
示例#17
0
文件: main.cpp 项目: karagog/gutil
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QSqlDatabase db( QSqlDatabase::addDatabase("QSQLITE", TEST_CONN_STR));
    db.setDatabaseName("test_database.sqlite");

    DatabaseLogger dlog(TEST_CONN_STR);
    dlog.InitializeDatabase();

    dlog.Log("Hello World!", "First Message", DatabaseLogger::Warning);
    dlog.Log("Hello Sir Charles!", "Second Message", DatabaseLogger::Info);
    dlog.Log("Oh Dear!!!", "Error Message", DatabaseLogger::Error);
    
    QTableView *tbl(new QTableView);

    DatabaseLogModel *dblm( new DatabaseLogModel(dlog, tbl) );
    dblm->select();
    tbl->setModel(dblm);

    tbl->show();
    return a.exec();
}
示例#18
0
 int minDistance(string word1, string word2) {
     int m = word1.size();
     int n = word2.size();
     
     vector<vector<int>> tbl(m+1, vector<int>(n+1, 0));
     
     for(int i = 0; i <= m; i++){
         for(int j = 0; j <= n; j++){
             if(i == 0) tbl[i][j] = j;
             if(j == 0) tbl[i][j] = i;
             
             if(i > 0 && j > 0){
                 if(word1[i-1] == word2[j-1]){
                     tbl[i][j] = tbl[i-1][j-1];
                 }else{
                     tbl[i][j] = min(min(tbl[i-1][j-1], tbl[i-1][j]), tbl[i][j-1])+1;
                 }
             }
         }
     }
     
     return tbl[m][n];
 }
示例#19
0
文件: t1.c 项目: 99years/plan9
void
main(int argc, char *argv[])
{
	exits(tbl(argc, argv)? "error" : 0);
}
示例#20
0
//	リストア処理実行ボタン
void CBackupDialog::OnBtnRestore() 
{
	UpdateData(TRUE);	// DDX更新

	CString str;
	CFileFind finder;

	// リストアデータフォルダ
	BOOL blFind = FALSE;
	CString strFolder;
	m_edtRestorePath.GetWindowText(strFolder);
	if (strFolder.IsEmpty()) return;
	CFileSpec fs(strFolder);
	if (fs.Exist()) {
		if (fs.GetFileName() == _T("tapur.backup")) {
			blFind = TRUE;
		} else {
			fs.SetFullSpec(strFolder + _T("\\tapur.backup"));
			if (fs.Exist()) {
				strFolder += _T("\\tapur.backup");
				blFind = TRUE;
			}
		}
	}
	if (!blFind) {
		str.LoadString(IDS_MSGBOX913);
		AfxMessageBox(str, MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
		return;
	}

	str.LoadString(IDS_MSGBOX912);
	if (AfxMessageBox(str, MB_YESNO | MB_APPLMODAL | MB_ICONQUESTION ) != IDYES) return;

	// リストア処理
	CFileSpec fs_out(theApp.m_strDataFolder);	// user data folder
	CString strOrgFolder = fs_out.GetFolder();	// data folder
	fs_out.SetFullSpec(strOrgFolder);
	if (fs_out.Exist()) {
		if (!fs_out.FileDelete(TRUE, this->m_hWnd)) goto PROC_CANCEL;
	}
	if (!fs.FileCopy(strOrgFolder, TRUE, TRUE, this->m_hWnd)) goto PROC_CANCEL;

	// データベースの書き換え
	BOOL bWorking = finder.FindFile(strOrgFolder + _T("\\*"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (!finder.IsDirectory()) continue;
		str = finder.GetFileName();
		if (str == _T(".") || str == _T("..")) continue;

		CString strTbl = finder.GetFilePath() + _T("\\") + _T(DBFILE_NAME);
		CTblRdfl tbl(strTbl);
		CString strWhere(_T("lngSystemFlag>=0"));
		long lngCnt = tbl.CountRec(strWhere);	// all
		if (lngCnt == 0) continue;

		CString strSet = _T("strRemarks1='") + finder.GetFilePath() + _T("'");
		if (!tbl.UpdateRec(strSet, strWhere)) goto PROC_CANCEL;
	} 

	str.LoadString(IDS_MSGBOX918);
	AfxMessageBox(str, MB_OK | MB_APPLMODAL | MB_ICONINFORMATION);
	return;
PROC_CANCEL:
	str.LoadString(IDS_MSGBOX920);
	AfxMessageBox(str, MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION);
}
示例#21
0
void DDF(vec_pair_GF2X_long& factors, const GF2X& ff, long verbose)
{
   GF2X f = ff;

   if (IsZero(f)) Error("DDF: bad args");

   factors.SetLength(0);

   if (deg(f) == 0)
      return;

   if (deg(f) == 1) {
      AddFactor(factors, f, 1, verbose);
      return;
   }


   long GCDTableSize = GF2X_BlockingFactor;

   GF2XModulus F;
   build(F, f);

   long i, d, limit, old_n;
   GF2X g, X;


   vec_GF2X tbl(INIT_SIZE, GCDTableSize);

   SetX(X);

   i = 0;
   SqrMod(g, X, F);
   d = 1;
   limit = GCDTableSize;


   while (2*d <= deg(f)) {

      old_n = deg(f);
      add(tbl[i], g, X);
      i++;
      if (i == limit) {
         ProcessTable(f, factors, F, i, tbl, d, verbose);
         i = 0;
      }

      d = d + 1;
      if (2*d <= deg(f)) {
         // we need to go further

         if (deg(f) < old_n) {
            // f has changed 

            build(F, f);
            rem(g, g, F);
         }

         SqrMod(g, g, F);
      }
   }

   ProcessTable(f, factors, F, i, tbl, d-1, verbose);

   if (!IsOne(f)) AddFactor(factors, f, deg(f), verbose);
}
示例#22
0
void DDF(vec_pair_ZZ_pX_long& factors, const ZZ_pX& ff, const ZZ_pX& hh, 
         long verbose)
{
   ZZ_pX f = ff;
   ZZ_pX h = hh;

   if (!IsOne(LeadCoeff(f)))
      Error("DDF: bad args");

   factors.SetLength(0);

   if (deg(f) == 0)
      return;

   if (deg(f) == 1) {
      AddFactor(factors, f, 1, verbose);
      return;
   }

   long CompTableSize = 2*SqrRoot(deg(f)); 

   long GCDTableSize = ZZ_pX_BlockingFactor;

   ZZ_pXModulus F;
   build(F, f);

   ZZ_pXArgument H;

   build(H, h, F, min(CompTableSize, deg(f)));

   long i, d, limit, old_n;
   ZZ_pX g, X;


   vec_ZZ_pX tbl(INIT_SIZE, GCDTableSize);

   SetX(X);

   i = 0;
   g = h;
   d = 1;
   limit = GCDTableSize;


   while (2*d <= deg(f)) {

      old_n = deg(f);
      sub(tbl[i], g, X);
      i++;
      if (i == limit) {
         ProcessTable(f, factors, F, i, tbl, d, verbose);
         i = 0;
      }

      d = d + 1;
      if (2*d <= deg(f)) {
         // we need to go further

         if (deg(f) < old_n) {
            // f has changed 

            build(F, f);
            rem(h, h, f);
            rem(g, g, f);
            build(H, h, F, min(CompTableSize, deg(f)));
         }

         CompMod(g, g, H, F);
      }
   }

   ProcessTable(f, factors, F, i, tbl, d-1, verbose);

   if (!IsOne(f)) AddFactor(factors, f, deg(f), verbose);
}
示例#23
0
void
comline(void)
{
	long c1, c2;

	while(C==' ' || c=='\t')
		;
comx:
	if((c1=c) == '\n')
		return;
	c2 = C;
	if(c1=='.' && c2!='.')
		inmacro = NO;
	if(msflag && c1 == '['){
		refer(c2);
		return;
	}
	if(c2 == '\n')
		return;
	if(c1 == '\\' && c2 == '\"')
		SKIP;
	else
	if (filesp==files && c1=='E' && c2=='Q')
			eqn();
	else
	if(filesp==files && c1=='T' && (c2=='S' || c2=='C' || c2=='&')) {
		if(msflag)
			stbl(); 
		else
			tbl();
	}
	else
	if(c1=='T' && c2=='E')
		intable = NO;
	else if (!inmacro &&
			((c1 == 'd' && c2 == 'e') ||
		   	 (c1 == 'i' && c2 == 'g') ||
		   	 (c1 == 'a' && c2 == 'm')))
				macro();
	else
	if(c1=='s' && c2=='o') {
		if(iflag)
			SKIP;
		else {
			getfname();
			if(fname[0]) {
				if(infile = opn(fname))
					*++filesp = infile;
				else infile = *filesp;
			}
		}
	}
	else
	if(c1=='n' && c2=='x')
		if(iflag)
			SKIP;
		else {
			getfname();
			if(fname[0] == '\0')
				exits(0);
			if(Bfildes(&(infile->Biobufhdr)) != 0)
				Bterm(&(infile->Biobufhdr));
			infile = *filesp = opn(fname);
		}
	else
	if(c1 == 't' && c2 == 'm')
		SKIP;
	else
	if(c1=='h' && c2=='w')
		SKIP; 
	else
	if(msflag && c1 == 'T' && c2 == 'L') {
		SKIP_TO_COM;
		goto comx; 
	}
	else
	if(msflag && c1=='N' && c2 == 'R')
		SKIP;
	else
	if(msflag && c1 == 'A' && (c2 == 'U' || c2 == 'I')){
		if(mac==MM)SKIP;
		else {
			SKIP_TO_COM;
			goto comx; 
		}
	} else
	if(msflag && c1=='F' && c2=='S') {
		SKIP_TO_COM;
		goto comx; 
	}
	else
	if(msflag && (c1=='S' || c1=='N') && c2=='H') {
		SKIP_TO_COM;
		goto comx; 
	} else
	if(c1 == 'U' && c2 == 'X') {
		if(wordflag)
			Bprint(&(bout.Biobufhdr), "UNIX\n");
		else
			Bprint(&(bout.Biobufhdr), "UNIX ");
	} else
	if(msflag && c1=='O' && c2=='K') {
		SKIP_TO_COM;
		goto comx; 
	} else
	if(msflag && c1=='N' && c2=='D')
		SKIP;
	else
	if(msflag && mac==MM && c1=='H' && (c2==' '||c2=='U'))
		SKIP;
	else
	if(msflag && mac==MM && c2=='L') {
		if(disp || c1=='R')
			sdis('L', 'E');
		else {
			SKIP;
			Bprint(&(bout.Biobufhdr), " .");
		}
	} else
	if(!msflag && c1=='P' && c2=='S') {
		inpic();
	} else
	if(msflag && (c1=='D' || c1=='N' || c1=='K'|| c1=='P') && c2=='S') { 
		sdis(c1, 'E'); 
	} else
	if(msflag && (c1 == 'K' && c2 == 'F')) { 
		sdis(c1,'E'); 
	} else
	if(msflag && c1=='n' && c2=='f')
		sdis('f','i');
	else
	if(msflag && c1=='c' && c2=='e')
		sce();
	else {
		if(c1=='.' && c2=='.') {
			if(msflag) {
				SKIP;
				return;
			}
			while(C == '.')
				;
		}
		inmacro++;
		if(c1 <= 'Z' && msflag)
			regline(YES,ONE);
		else {
			if(wordflag)
				C;
			regline(YES,TWO);
		}
		inmacro--;
	}
}
trans_global_vec macFlowJoWorkspace::getGlobalTrans(){

	trans_global_vec tgVec;

	string path="/Workspace/CalibrationTables/Table";
	xmlXPathContextPtr context = xmlXPathNewContext(doc);
	xmlXPathObjectPtr result = xmlXPathEval((xmlChar *)path.c_str(), context);
	if(xmlXPathNodeSetIsEmpty(result->nodesetval))
	{
		COUT<<"no calibration Tables found!"<<endl;
		return(tgVec);
	}
	/*
	 * during the traversing of the calibration table list,
	 * we try to split these tables into groups by their prefix names(which should match the compensation names defined in CompensationMatrices node)
	 */
	for(int i=0;i<result->nodesetval->nodeNr;i++)
	{
		wsNode calTblNode(result->nodesetval->nodeTab[i]);

		transformation *curTran=new transformation();
		calibrationTable caltbl("flowJo",2);
		string tname=calTblNode.getProperty("name");
		if(tname.empty())
			throw(domain_error("empty name for calibration table"));

		if(g_loglevel>=GATING_SET_LEVEL)
			COUT<<"parsing calibrationTable:"<<tname<<endl;
		/*
		 * parse the string from tname to extract channel name
		 */
		size_t nPrefix=tname.find("<");
		size_t nsuffix=tname.find(">");
		bool isGeneric=(nPrefix==string::npos)|(nsuffix==string::npos);
		string transGroupName;
		if(isGeneric)
		{
			/*
			 * generic cal table (non-channel-specific)
			 */
			curTran->setName(tname);
			curTran->setChannel("*");
			transGroupName="Generic";
		}
		else
		{
			/*
			 * channel-specific cal table
			 */
			curTran->setName(boost::trim_copy((tname.substr(0,nPrefix))));
			curTran->setChannel(tname.substr(nPrefix,tname.length()-nPrefix));
			transGroupName=curTran->getName();
		}

		string sTbl=calTblNode.getContent();
		/*
		 * parse the stream to x,y double arrays
		 */
		valarray<double> tbl(toArray(sTbl));
		unsigned nX=tbl.size()/2;

		caltbl.init(nX);

		caltbl.setY(tbl[slice(0,nX,2)]);
		caltbl.setX(tbl[slice(1,nX,2)]);

		curTran->setCalTbl(caltbl);

		/*since it is base class of transformation,which means the caltbl is already given by workspace
		 * no need to compute later on. so set this flag to be true to assure the subsequent interpolation can be performed
		 */
		curTran->setComputeFlag(true);

		/*Find the respective reference(iterator) by name from the trans_global_vec
		 * If not found,push back a new entry in the vector and return its reference
		 */
		trans_global_vec::iterator tRes=findTransGroup(tgVec,curTran->getName());

		if(tRes==tgVec.end())//if not exsit yet, then push back the new instance
		{
			if(g_loglevel>=GATING_SET_LEVEL)
				COUT<<"creating new transformation group:"<<transGroupName<<endl;
			trans_global newTg;
			newTg.setGroupName(transGroupName);
			tgVec.push_back(newTg);
			tgVec.back().addTrans(curTran->getChannel(),curTran);
		}
		else
			//if already exists, then save the current transformation into the respective transGroup
			tRes->addTrans(curTran->getChannel(),curTran);

	}

	xmlXPathFreeObject(result);
	xmlXPathFreeContext(context);

	return tgVec;
}
示例#25
0
bool Application::_searchLogFilePath(const char* logDir, WatchFileVector& watchList)
{
	KLuaTableWraper tbl("application_configure");
	listDir(logDir, tbl, watchList);
	return true;
}
示例#26
0
void CalcERtoSVR(int as_id,float rad)
{
	int op_num=0;
	Geometry*g = &neuron[0][as_id];
	vec3 pt;

	float max_svr=40;
	int svr_num=40,er_num=20;
	float *all_vl2=new float[svr_num];
	int *all_vl2_num=new int[svr_num];
	int *hist=new int[svr_num*er_num],svr_summ=0;
	memset(all_vl2,0,svr_num*sizeof(float));
	memset(all_vl2_num,0,svr_num*sizeof(int));
	memset(hist,0,svr_num*er_num*sizeof(int));
	int hist_num=0;
	
	Table tbl(3,svr_num+2);
	Table tbl2(er_num+2,svr_num+2);
		
	tbl.SetValue("SVR",0,0);
	tbl.SetValue("Ver/Vas",0,0);
	for(int i=0;i<svr_num;i++)	
		tbl.SetValue((i+1)*max_svr/svr_num,0,i+1);
	tbl2.SetValue("Ver/Vas",1,0);
	tbl2.SetValue("%svr",2,0);
	
	for(int i=0;i<svr_num;i++)	
		tbl2.SetValue((i+1)*max_svr/svr_num,0,i+1);
	for(int i=0;i<er_num;i++)	
		tbl2.SetValue((i+1)/(float)er_num,1+i,0);

	int iter=0;
	Geometry*g0=new Geometry();
	while(1)
	{
		pt = GetIntirePoint(g);
		g0->renull();
		GetInSphere0(g,pt,rad,g0);
		
		float V_as = mc_CalcVolume(g0,pt,rad,pt,1);
		float S_as = mc_CalcArea(g0,pt,rad);
		float V_er = 0;
		
		for(int i=0;i<CD_depo[as_id].size();i++)
		{
			Geometry* g_er = &neuron[4][CD_depo[as_id][i]];
			if(!g_er->tr.size())continue;
			g0->renull();
			GetInSphere0(g_er,pt,rad,g0);
			//printf("(%d)",g0->tr.size());
			
			bool ins_er = g_er->Inside(pt);
			V_er += g_er->color.y*mc_CalcVolume(g0,pt,rad,pt,ins_er);
			
		}

		float svr = S_as/V_as;
		float vv = V_er/V_as;

		int hi = er_num*vv;
		int hj = svr_num*(svr/max_svr);
		if(hj>=0 && hj<svr_num)
		{
			all_vl2[hj] = (vv + (all_vl2_num[hj]*all_vl2[hj]))/(all_vl2_num[hj]+1);
			all_vl2_num[hj]++;
			svr_summ++;

			if(hi>=0 && hi<er_num)
			{
				hist[hi+er_num*hj]++;
				hist_num++;
			}
		}

		iter++;
		printf("%d) v svr: %g %g\n",iter,vv,svr);
//
		if(!(iter%5))
		{
			for(int j=0;j<svr_num;j++)
			{
				tbl.SetValue((float)(all_vl2[j]),1,j+1);
				tbl.SetValue((all_vl2_num[j]/(float)svr_summ),2,j+1);
			}
			tbl.StoreToFile("results\\er_svr_astr"+str::ToString(as_id)+"_Radius"+str::ToString(int(rad*1000))+"nm.txt");
		//
			for(int i=0;i<er_num;i++)
			for(int j=0;j<svr_num;j++)
			{
				tbl2.SetValue((float)(hist[i+j*er_num])/hist_num,i+1,j+1);
			}
			tbl.StoreToFile("results\\er_svr_astr"+str::ToString(as_id)+"_Radius"+str::ToString(int(rad*1000))+"nm.txt");
			tbl2.StoreToFile("results\\HIST_er_svr_astr"+str::ToString(as_id)+"_Radius"+str::ToString(int(rad*1000))+"nm.txt");
			
			if(iter>=5000)break;
		}

	}
	
	delete[]all_vl2;
	delete[]all_vl2_num;
	delete[]hist;
	
}
示例#27
0
//
//  機能     : 画面の更新
//  
//  機能説明 : 
//  
//  返り値   : BOOL
//  
//  備考     : 
//  
BOOL CMsgForm::UpdateForm(BOOL blPlayStop) 
//BOOL CMsgForm::UpdateForm() 
{
	CFileSpec fs;
	CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();

	/// カレントレコード
	if (theApp.m_lngRdflId <= 0) return FALSE;

	/// 再生中のファイルを停止する(フォーカスが移動するので注意!)
//	PlayStop();
	if (blPlayStop) PlayStop();

	//// プログレスバークリア
	if (m_Prog) m_Prog.SetPos(0);	


	/// 初期設定
	m_lngPlayTime = 0;
	m_strAudioFile.Empty();
	m_strVideoFile.Empty();
	m_Play.EnableWindow(FALSE);
	m_Stop.EnableWindow(FALSE);
	m_Pause.EnableWindow(FALSE);
	m_File.EnableWindow(FALSE);
	m_VFile.EnableWindow(FALSE);
	m_AppPlay.EnableWindow(FALSE);
	m_AppVPlay.EnableWindow(FALSE);
	m_Time.SetWindowText(_T("[ 00:00 ]"));

	/// RDFLテーブル検索
	CTblRdfl tbl(theApp.m_strDBPath);
	if (tbl.SelectRec(theApp.m_lngRdflId) <= 0) {
		return FALSE;
	}

	/// [件名]取得
	m_EditTitle = tbl.strTitle;
	//// [送信者名]取得
	CString strSender;
	if (tbl.strSenderId == _T("0")) {
		//// 不明な発信者(SkypeIn)
		strSender.LoadString(IDS_MSG_DEF);
		m_SenderName.SetWindowText(strSender);
		m_SenderId.SetWindowText(_T(""));
	} else {
		m_SenderName.SetWindowText(tbl.strSenderName);
		m_SenderId.SetWindowText(tbl.strSenderId);
	}
	//// [日時]取得
	_TCHAR strDate[64];
	CnvDateString((LPCTSTR)tbl.dlngSystemNew, strDate);
	m_Date.SetWindowText(strDate);
	/// 音声/ビデオファイル名取得
	int intFormatType = 0;
	CTPsetup tps(theApp.m_strDataFolder);
	tps.SetCallerId(tbl.strSenderId);
	m_strVideoFile = tps.FindRdfVideoFileName(tbl.strRemarks1, tbl.dlngSystemNew, _T("$$"));
	m_strAudioFile = tps.FindRdfWavFileName(tbl.strRemarks1, tbl.dlngSystemNew, _T("$$"));
	if (m_strAudioFile.IsEmpty()) {
		m_strAudioFile = tps.FindRdfMp3FileName(tbl.strRemarks1, tbl.dlngSystemNew, _T("$$"));
		intFormatType = 1;
	}

	CString strBar;
	if (!m_strAudioFile.IsEmpty()) {
	/// 受信音声ファイルがある場合
		CString strTmp;
		//// STatusBar用文字列
		fs.SetFullSpec(m_strAudioFile);
		strBar = fs.GetFileName();
		/// 受信音声ファイルの時間表示
		float fTime = m_pAudio->GetPlaySize(m_strAudioFile);
		if (fTime < 0) {
			_stprintf_s(te.errstr, MAX_ERRSTR, _T("Audio file may be broken:%s"), m_strAudioFile);
			te.ErrorMessage(ERRTYPE_LOGONLY, _T(__FILE__), __LINE__, ERR_TAPUR, te.errstr);
			return FALSE;
		}
		m_lngPlayTime = (fTime > 0) ? (long)fTime : 1;	// 1秒以下は1秒とする
		strTmp.Format(_T("[ %02i:%02i ]"), (m_lngPlayTime/60), (m_lngPlayTime%60));
		m_Time.SetWindowText(strTmp);
		//// 再生・エクスポートボタンを有効
		m_Play.EnableWindow(TRUE);
		m_File.EnableWindow(TRUE);
		m_AppPlay.EnableWindow(TRUE);

	}
	if (!m_strVideoFile.IsEmpty()) {
	/// 受信ビデオファイルがある場合
		//// STatusBar用文字列
		if (strBar.GetLength() > 0) {
			strBar += _T("/avi");
		} else {
			fs.SetFullSpec(m_strVideoFile);
			strBar = fs.GetFileName();
		}
		//// エクスポートボタンを有効
		m_VFile.EnableWindow(TRUE);
		m_AppVPlay.EnableWindow(TRUE);
	}

	/// StatusBarにファイル名、データタイプ表示
	pFrame->SetStatusText(strBar);
	if (tbl.lngRespType == 0) {
		strBar = _T("REC");
		if (tbl.lngClsCode1 == 1 || tbl.lngClsCode1 == 3) {
			strBar += _T("/IN");
		} else if (tbl.lngClsCode1 == 2 || tbl.lngClsCode1 == 4) {
			strBar += _T("/OUT");
		}
	} else {
		strBar = _T("ANSWER");
	}
	pFrame->SetStatusText(strBar, 1);

	/// 再生ファイルが存在しない場合、表示のみで未再生リストを再生済みに変更
	if (m_strAudioFile.IsEmpty() && m_strVideoFile.IsEmpty() && tbl.lngViewFlag != 1) {
		// (???)ChgMsgMark()でテーブル更新すると、テーブルロックが解除されていないため、ここで更新する
		tbl.lngViewFlag = 1;
		tbl.UpdateRec(theApp.m_lngRdflId);
		CMsgList *pfview = (CMsgList *)pFrame->m_pMsgList->GetWnd();
		pfview->ChgMsgMark(FALSE);
	}

	UpdateData(FALSE);	// DDX更新

	return TRUE;
}
示例#28
0
void RichEdit::TableProps()
{
	if(IsSelection() || cursorp.table == 0)
		return;
	RichEditTableProperties dlg;
	dlg.Breaker(dlg.destroy, IDNO);
	RichTable::Format fmt = text.GetTableFormat(cursorp.table);
	String ratios;
	for(int i = 0; i < fmt.column.GetCount(); i++) {
		if(i)
			ratios << ':';
		ratios << "1";
	}
	dlg.ratios.SetFilter(CharFilterEqualize);
	dlg.ratios <<= ratios;
	CtrlRetriever r;
	Advn(r, dlg.before.SetUnit(unit), fmt.before);
	Advn(r, dlg.after.SetUnit(unit), fmt.after);
	Advn(r, dlg.lm.SetUnit(unit), fmt.lm);
	Advn(r, dlg.rm.SetUnit(unit), fmt.rm);
	Advn(r, dlg.frame.SetUnit(unit), fmt.frame);
	r(dlg.framecolor, fmt.framecolor);
	Advn(r, dlg.grid.SetUnit(unit), fmt.grid);
	Advn(r, dlg.header, fmt.header);
	Advn(r, dlg.keep, fmt.keep);
	Advn(r, dlg.newpage, fmt.newpage);
	Advn(r, dlg.newhdrftr, fmt.newhdrftr);
	dlg.header_qtf = fmt.header_qtf;
	dlg.footer_qtf = fmt.footer_qtf;
	r(dlg.gridcolor, fmt.gridcolor);
	dlg.SyncHdrFtr();
	dlg.newhdrftr.Enable(cursorp.level == 1);
	dlg.hdrftr.Enable(cursorp.level == 1);
	for(;;) {
		switch(dlg.Run()) {
		case IDCANCEL:
			return;
		case IDNO:
			NextUndo();
			DestroyTable();
			return;
		default:
			r.Retrieve();
			if(dlg.newhdrftr) {
				fmt.header_qtf = dlg.header_qtf;
				fmt.footer_qtf = dlg.footer_qtf;
			}
			else
				fmt.header_qtf = fmt.footer_qtf = Null;
			const RichTable& tbl = text.GetConstTable(cursorp.table);
			bool valid = true;
			Point violator(0, 0);
			int vspan = 0;
			for(int rw = 0; valid && rw < fmt.header && rw < tbl.GetRows(); rw++)
				for(int co = 0; valid && co < tbl.GetColumns(); co++)
					if(tbl(rw, co) && (vspan = tbl[rw][co].vspan) + rw > fmt.header) {
						valid = false;
						violator.x = co;
						violator.y = rw;
						break;
					}
			if(!valid) {
				Exclamation(NFormat(t_("Invalid header row count %d, cell at rw %d, co %d has vspan = %d."),
					fmt.header, violator.y + 1, violator.x + 1, vspan));
				continue;
			}
			NextUndo();
			SaveTableFormat(cursorp.table);
			if(dlg.equalize) {
				Vector<String> r = Split((String)~dlg.ratios, ':');
				for(int i = 0; i < fmt.column.GetCount(); i++)
					fmt.column[i] = i < r.GetCount() ? max(atoi(r[i]), 1) : 1;
			}
			text.SetTableFormat(cursorp.table, fmt);
			Finish();
			return;
		}
	}
}
示例#29
0
//
//  機能     : 画面の更新
//  
//  機能説明 : 
//  
//  返り値   : BOOL
//  
//  備考     : 
//  
BOOL CRsfSimpleForm::UpdateForm() 
{
	/// カレントレコード
	if (theApp.m_lngRsflId <= 0) return FALSE;

	/// 再生中のファイルを停止する
//	PlayStop();

	// StatusBarのクリア
	CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
	pFrame->SetStatusText(_T(""), 0);
	pFrame->SetStatusText(_T(""), 1);

	// ラジオボタンの参照定義(DDXは扱いにくいので)
	// (クラスメンバーで宣言すると正常に動作しない)
	CButton *rd_rec = (CButton *)GetDlgItem(IDC_RDO_REC);
	CButton *rd_vrec = (CButton *)GetDlgItem(IDC_RDO_VREC);
	CButton *rd_discon = (CButton *)GetDlgItem(IDC_RDO_DISCONNECT);

	/// 初期設定
	m_blAudio = FALSE;
    m_blChat = FALSE;
    m_blVideo = FALSE;
    m_blImg = FALSE;
	m_blBeep = FALSE;
	m_blPrg = FALSE;
	rd_rec->SetCheck(0);
	rd_vrec->SetCheck(0);
	rd_discon->SetCheck(1);

	/// 応答設定テーブルを選択
	CTblRsfl tbl(theApp.m_strDBPath);
	CString strWhere;
	_TCHAR buf[64];
	strWhere.Empty();
	_ltot_s(theApp.m_lngRsflId, buf, sizeof(buf)/sizeof(buf[0]), 10);
	strWhere = strWhere + _T("ID") + _T("=") + buf;
	_ltot_s(RESPBASE_TYPE_SIMPLE, buf, sizeof(buf)/sizeof(buf[0]), 10);
	strWhere = strWhere + _T(" and ") + _T("lngRespType") + _T("=") + buf;
	if (tbl.SelectRec(strWhere) <= 0) {
		return FALSE;
	}

	/// 選択された応答設定RSFをロード
	CTPsetup tps(theApp.m_strDataFolder);
	if (tbl.lngDefaultFlag == 1) {
		m_strSenderId = _T("0");	// default setting
	} else {
		m_strSenderId = tbl.strSenderId;
	}
	tps.SetCallerId(m_strSenderId);
	UST_RSF *pst = tps.LoadRSF();
	if (pst == NULL) return FALSE;

	/// 選択された応答設定RSFを参照
	UST_RSF_RESP *pst_resp;
	for (int i = 0; i < pst->resp_cnt; i++) {
		pst_resp = pst->resp + i;
		//// BEEPのON/OFF
		if (pst_resp->beep > 0) {
			m_blBeep = TRUE;
		}
		switch(pst_resp->type) {
		case RESP_TYPE_PLAY:
			//// 再生内容のON/OFF
			if (pst_resp->play_type & RESP_PLAY_TYPE_AUDIO) {
				m_blAudio = TRUE;
			}
			if (pst_resp->play_type & RESP_PLAY_TYPE_VIDEO) {
				m_blVideo = TRUE;
			}
			if (pst_resp->play_type & RESP_PLAY_TYPE_IMAGE) {
				m_blImg = TRUE;
			}
			if (pst_resp->play_type & RESP_PLAY_TYPE_CHAT) {
				m_blChat = TRUE;
			}
			break;
		//// 録音内容のON/OFF
		case RESP_TYPE_RECORD:
			rd_rec->SetCheck(1);
			rd_vrec->SetCheck(0);
			rd_discon->SetCheck(0);
			break;
		case RESP_TYPE_VRECORD:
			rd_rec->SetCheck(0);
			rd_vrec->SetCheck(1);
			rd_discon->SetCheck(0);
			break;
		case RESP_TYPE_DISCONNECT:
			// 全ての設定で使用されるので、設定すべきことはない
			break;
		//// プログラム連携のON/OFF
		case RESP_TYPE_EXEC:
			m_blPrg = TRUE;
			break;
		default:
			break;
		}
	}

	/// 応答音声ファイルの時間表示
	CString strPlayFile;
	CString strSize;
	CFileSpec fs;
	strSize = _T("[ 00:00 ]");
	strPlayFile = tps.RsfAudioFileName(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
		CAudio *pAudio = pFrame->m_pAudio;
		pAudio->m_PlayFile = strPlayFile;
		float fTime = pAudio->GetPlaySize();
		if (fTime > 0.0) {
			long lngTime = (long)(fTime+1);
			strSize.Format(_T("[ %02i:%02i ]"), (lngTime/60), (lngTime%60));
		}
	}
	m_lblAudioSize.SetText((LPCTSTR)strSize);

	/// 応答ビデオファイルの時間表示
	strSize = _T("[ 00:00 ]");
	strPlayFile = tps.RsfVideoFileName(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		CMainFrame *pFrame = (CMainFrame*)::AfxGetMainWnd();
		CVideo *pVideo = pFrame->m_pVideo;
		pVideo->SetPlayFile(strPlayFile);
		float fTime = pVideo->GetPlaySize();
		if (fTime > 0.0) {
			long lngTime = (long)(fTime+1);
			strSize.Format(_T("[ %02i:%02i ]"), (lngTime/60), (lngTime%60));
		}
	}
	m_lblVideoSize.SetText((LPCTSTR)strSize);

	/// 画像ファイルのサイズ表示
	strSize = _T("[ 0 Kbytes ]");
	strPlayFile = tps.FindRsfImgFile(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		strSize.Format(_T("[ %d Kbytes ]"), fs.FileSize()/1024);
	}
	m_lblImgSize.SetText((LPCTSTR)strSize);

	/// チャットテキストファイルのサイズ表示
	strSize = _T("[ 0 bytes ]");
	strPlayFile = tps.RsfChatFileName(_T("$"));
	fs.SetFullSpec(strPlayFile);
	if (fs.Exist()) {
		strSize.Format(_T("[ %d bytes ]"), fs.FileSize());
	}
	m_lblChatSize.SetText((LPCTSTR)strSize);

 	/// 連携プログラムコンボボックスを選択
	CString str, strPrgId;
	strPrgId.Format(_T("%d"), pst_resp->exec_id);
	int idx = 0;
	for(int i = 0; i <  m_aryPrgId.GetSize(); i++) {
		str = m_aryPrgId.GetAt(i);
		if (strPrgId == str) {
			idx = i;
			break;
		}
	}
	m_idxPrg = idx;

	/// 連携プログラムCSVファイルが存在しない場合、テンプレートCSVフォルダからコピー
	CString strBinDir, strFile;
	fs.SetFullSpec(FS_APPDIR);
	strBinDir = fs.GetFullSpec() + _T("bin");	// テンプレートCSVフォルダ
	for(int i = 0; i <  m_aryPrgId.GetSize(); i++) {
		strPrgId = m_aryPrgId.GetAt(i);
		strFile = tps.RsfPrgFileName(_T("$$$$"), strPrgId);	// 連携プログラムCSVファイル
		fs.SetFullSpec(strFile);
		if (!fs.Exist()) {
			fs.SetFullSpec(strBinDir + "\\" + strPrgId + ".csv");
			if (fs.Exist()) {
				fs.FileCopy(strFile, FALSE);	// 上書きはしない
			}
		}
	}

	UpdateData(FALSE);	// DDX更新

	return TRUE;
}
示例#30
0
   /**
   * Method called when the save button is pressed.
   * Gets the (possibly) edited values from the data table and saves it to the specified file.
   * @param event not used
   */
   void OnSaveTable (wxCommandEvent &WXUNUSED(event))
   {
      const wxString fn = dynamic_cast <wxTextCtrl *>(FindWindowById(MonkeyTable_FileName))->GetValue();
      const int filter = dynamic_cast <wxChoice *>(FindWindowById(MonkeyTable_FileFmt))->GetSelection();
      const int enc = dynamic_cast <wxChoice *>(FindWindowById(MonkeyTable_FileEnc))->GetSelection();

      const long flags = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;
      wxFileDialog dialog(this, MM_MSG_SAVETBL, prefs.get(wxT("directories/save-table")), fn, filters[filter], flags);

      wxDataViewListCtrl *datavw = dynamic_cast <wxDataViewListCtrl *> (FindWindowById(MonkeyTable_DataTable));
      wxDataViewListStore *store = datavw->GetStore();
      wxString buf;

      // iterates through the data table rows
      for (int i = 0; i < static_cast<int>(store->GetCount()); i++)
      {
         wxVariant byte, value;

         store->GetValueByRow(byte, i, 0);
         store->GetValueByRow(value, i, 1);

         buf += byte.GetString() + wxT("=") + value.GetString() + wxT("\r\n");
      }

      // checks if the table contains non-ANSI characters
      if (enc == 0 && !buf.IsAscii())
         return ShowWarning(_("Can't save in the specified encoding:\nThe table contains non-ANSI characters."));

      if (dialog.ShowModal() == wxID_CANCEL) return;

      prefs.set(wxT("directories/save-table"), dialog.GetDirectory());
      wxFile tbl(dialog.GetPath(), wxFile::write);

      if (!tbl.IsOpened())
         return ShowWarning(_("The table file couldn't be created. Try again."));

      switch (enc)
      {
         // encodes the file in ANSI (ISO-8859-1)
         case 0: tbl.Write(buf, wxCSConv(wxT("iso-8859-1")));
                 break;

         // encodes the file in Unicode (UTF-8)
         case 1: tbl.Write(buf, wxConvUTF8);
                 break;

         // encodes the file in Unicode (UTF-16)
         case 2: tbl.Write(buf.data().AsWChar(), buf.size() * sizeof(wxChar));
                 break;

         // Does not work. Delved deep in the wx implementation and didn't find shit yet.
         // So... WIP.
         /*case 3: {
            wxCSConv enc(wxFONTENCODING_SHIFT_JIS);
            
            if (enc.IsOk())
               tbl.Write(buf, enc);
            else
               ShowWarning(_("Your system does not support conversion to Shift JIS."));
         }
         break;*/
      }

      tbl.Close();
      ShowInfo(_("Table saved successfully."), wxT("Monkey-Moore"));

      Close();
   }