Esempio n. 1
0
/* ndiff: name-based diff */
void ndiff(int col_a, int col_b,
	char token_a, char token_b,
	FILE *ptr_a, FILE *ptr_b,
	FILE *ptr_aba, FILE *ptr_abb,
	FILE *ptr_a_b, FILE *ptr_b_a) {

	int isMatch;
	char line_a[LINE_BUFFER];
	char line_b[LINE_BUFFER];
	char pattern_a[PATTERN_SIZE];
	char pattern_b[PATTERN_SIZE];
	Retrieval *root_a = trieGenerate();
	Retrieval *root_b = trieGenerate();
	// build a trie tree according to file_A
	while (fgets(line_a, LINE_BUFFER, ptr_a) != NULL) {
		if (*line_a == '\n') {
			; // skip the empty lines...
		}
		else {
			getPattern(line_a, pattern_a, token_a, col_a);
			trieIncert(pattern_a, &root_a);
		}
	}
	// search and generate target files A&B_B and B-A
	while (fgets(line_b, LINE_BUFFER, ptr_b) != NULL) {
		if (*line_b == '\n') {
			; // skip the empty lines...
		}
		else {
			getPattern(line_b, pattern_b, token_b, col_b);
			isMatch = trieSearch(pattern_b, root_a);
			if (isMatch) {
				fprintf(ptr_abb, "%s", line_b);
			}
			else {
				fprintf(ptr_b_a, "%s", line_b);
			}
			trieIncert(pattern_b, &root_b);
		}
	}
	free(root_a);
	fseek(ptr_a, 0, SEEK_SET); // move the pointer to the start
	// search and generate target files A&B_A and A-B
	while (fgets(line_a, LINE_BUFFER, ptr_a) != NULL) {
		if (*line_a == '\n') {
			; // skip the empty lines...
		}
		else {
			getPattern(line_a, pattern_a, token_a, col_a);
			isMatch = trieSearch(pattern_a, root_b);
			if (isMatch) {
				fprintf(ptr_aba, "%s", line_a);
			}
			else {
				fprintf(ptr_a_b, "%s", line_a);
			}
		}
	}
	free(root_b);
}
 void TypedTest_ImportAfterImport() {
   TranslationUnitDecl *FromTu0 = getTuDecl(getCode0(), Lang_CXX, "input0.cc");
   TranslationUnitDecl *FromTu1 = getTuDecl(getCode1(), Lang_CXX, "input1.cc");
   auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
   auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
   auto *ToD0 = Import(FromD0, Lang_CXX);
   auto *ToD1 = Import(FromD1, Lang_CXX);
   ASSERT_TRUE(ToD0);
   ASSERT_TRUE(ToD1);
   EXPECT_NE(ToD0, ToD1);
   if (shouldBeLinked())
     EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
   else
     EXPECT_FALSE(ToD1->getPreviousDecl());
 }
Esempio n. 3
0
void AnimationHandler::generateAnimations(std::vector<AnimationDescriptor*> animationList)
{
    CCLOG("AnimationHandler::generateAnimations initialized");
    CCLOG("=Generating animations objects.");

    int animCount = animationList.size();
    Vector<SpriteFrame*>* vectorBuffer = new Vector<SpriteFrame*>[animCount];
    for(int c = 0; c < animCount;c++)
    {
        auto elem = animationList.at(c);

        std::string pattern = elem->getPattern();
        int frameCount = elem->getFrameCount();
        float speed = elem->getAnimationSpeed() == 0? DEFAULT_SPEED : elem->getAnimationSpeed();
        std::string status = elem->getStatus();
        this->loadFrameBuffer(vectorBuffer[c], frameCount, pattern);

        _animations.push_back(Animation::createWithSpriteFrames(vectorBuffer[c], speed));
        _actions[status] = generateAction(elem, _animations.at(c));
        _actions[status]->retain();
    }

    delete[] vectorBuffer;

    CCLOG("AnimationHandler::generateAnimations done.");

}
Esempio n. 4
0
bool isIsomorphic(char* s, char* t) {
    int len_s = strlen(s);
    int len_t = strlen(t);
    if (len_s != len_t) return false;
    if (len_s == 0) return true;
    
    int pattern_s[len_s];
    int pattern_t[len_s];
    getPattern(s, pattern_s);
    getPattern(t, pattern_t);
    for (int i = 0; i < len_s; ++i) {
        if (pattern_s[i] != pattern_t[i])   return false;
    }
    
    return true;
}
Esempio n. 5
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__MTHSELECTOR_MOVE, "_mthSelector::move" )
   INT32 _mthSelector::move( _mthSelector &other )
   {
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY( SDB__MTHSELECTOR_MOVE ) ;
      if ( !_init )
      {
         PD_LOG( PDERROR, "selector has not been initalized yet" ) ;
         rc = SDB_INVALIDARG ;
         goto error ;
      }

      other.clear() ;

      rc = other.loadPattern( getPattern() ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to load pattern:%d", rc ) ;
         goto error ;
      }

      clear() ;
   done:
      PD_TRACE_EXITRC( SDB__MTHSELECTOR_MOVE, rc ) ;
      return rc ;
   error:
      goto done ;
   }
Esempio n. 6
0
void FindFilesDialog::slotSearch()
{
	KILE_DEBUG() << "\tgrep: start slot search" << m_proc;

	if (m_proc) {
		clearGrepJobs();
		finish();
		return;
	}

	if (template_combo->currentIndex() < KileGrep::tmEnv && pattern_combo->currentText().isEmpty()) {
		return;
	}

	KILE_DEBUG() << "\tgrep: start new search";
	QRegExp re(getPattern());
	if(!re.isValid()) {
		KMessageBox::error(m_ki->mainWindow(), i18n("Invalid regular expression: %1", re.errorString()), i18n("Grep Tool Error"));
		return;
	}

	resultbox->setCursor(QCursor(Qt::WaitCursor));
	search_button->setText(i18n("&Cancel"));
	if (template_combo->currentIndex() < KileGrep::tmEnv) {
		m_TemplateList[m_lastTemplateIndex] = template_edit->text();
	}

	// start grep command
	m_grepJobs = (m_mode == KileGrep::Project) ? m_projectfiles.count() : 1;
	startGrep();
}
Esempio n. 7
0
void DeathTestImpl::_doTest() {
#ifdef _WIN32
    log() << "Skipping death test on Windows";
    return;
#else
    int pipes[2];
    checkSyscall(pipe(pipes));
    pid_t child;
    checkSyscall(child = fork());
    if (child) {
        checkSyscall(close(pipes[1]));
        char buf[1000];
        std::ostringstream os;
        ssize_t bytesRead;
        while (0 < (bytesRead = read(pipes[0], buf, sizeof(buf)))) {
            os.write(buf, bytesRead);
            invariant(os);
        }
        checkSyscall(bytesRead);
        pid_t pid;
        int stat;
        while (child != (pid = waitpid(child, &stat, 0))) {
            invariant(pid == -1);
            const int err = errno;
            switch (err) {
                case EINTR:
                    continue;
                default:
                    severe() << "Unrecoverable error while waiting for " << child << ": "
                             << errnoWithDescription(err);
                    MONGO_UNREACHABLE;
            }
        }
        if (WIFSIGNALED(stat) || (WIFEXITED(stat) && WEXITSTATUS(stat) != 0)) {
            // Exited with a signal or non-zero code.  Should check the pattern, here,
            // but haven't figured out how, so just return.
            ASSERT_STRING_CONTAINS(os.str(), getPattern());
            return;
        } else {
            invariant(!WIFSTOPPED(stat));
        }
        FAIL("Expected death, found life\n\n") << os.str();
    }

    // This code only executes in the child process.
    checkSyscall(close(pipes[0]));
    checkSyscall(dup2(pipes[1], 1));
    checkSyscall(dup2(1, 2));
    try {
        _test->run();
    } catch (const TestAssertionFailureException& tafe) {
        log() << "Caught test exception while expecting death: " << tafe;
        // To fail the test, we must exit with a successful error code, because the parent process
        // is checking for the child to die with an exit code indicating an error.
        quickExit(EXIT_SUCCESS);
    }
    quickExit(EXIT_SUCCESS);
#endif
}
 int numberOfPatterns(int m, int n) {
     vector<vector<int>> skip(10, vector<int>(10));
     skip[1][3] = skip[3][1] = 2;
     skip[1][7] = skip[7][1] = 4;
     skip[7][9] = skip[9][7] = 8;
     skip[9][3] = skip[3][9] = 6;
     skip[1][9] = skip[9][1] = skip[3][7] = skip[7][3] = skip[2][8] = skip[8][2] = skip[4][6] = skip[6][4] = 5;
     
     vector<bool> visit(10, false);
     int ret = 0;
     for(int i = m; i <= n; ++i){
         ret += getPattern(visit, skip, 1, i-1) * 4; 
         ret += getPattern(visit, skip, 2, i-1) * 4;
         ret += getPattern(visit, skip, 5, i-1);
     }
     return ret;
 }
Esempio n. 9
0
void AddPatternMatcherImpl::operator()( boost::ptr_vector<Matcher> & matchers, const std::string & name, uint index, boost::ptr_vector< Restriction > & restrictions ) const {
	PatternRef pattern = getPattern( name );

	PatternMatcher * matcher = new PatternMatcher( *pattern );

	matcher->variable = Variable( *pattern, index );
	matcher->addRestrictions( restrictions );

	matchers.push_back( matcher );
}
void NOTATIONDatatypeValidator::checkContent( const XMLCh*             const content
                                          ,       ValidationContext* const context
                                          ,       bool                     asBase
                                          ,       MemoryManager*     const manager
                                          )
{

    //validate against base validator if any
    NOTATIONDatatypeValidator *pBaseValidator = (NOTATIONDatatypeValidator*) this->getBaseValidator();
    if (pBaseValidator)
        pBaseValidator->checkContent(content, context, true, manager);

    int thisFacetsDefined = getFacetsDefined();

    // we check pattern first
    if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        if (getRegex()->matches(content, manager) ==false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }
    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    checkValueSpace(content, manager);

    if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 &&
        (getEnumeration() != 0))
    {
        XMLCh* normContent = XMLString::replicate(content, manager);
        ArrayJanitor<XMLCh>  jan(normContent, manager);
        normalizeContent(normContent, manager);

        int i=0;
        int enumLength = getEnumeration()->size();
        for ( ; i < enumLength; i++)
        {
            if (XMLString::equals(normContent, getEnumeration()->elementAt(i)))
                break;
        }

        if (i == enumLength)
            ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager);
    }

    checkAdditionalFacet(content, manager);
}
Esempio n. 11
0
void Designer::handleButton()
{
	std::vector< std::pair<Block, QColor> > t = getPattern();
	std::vector<Block> b;
	for (int i = 0; i < (int) t.size(); i++)
		b.push_back(t[i].first);
	Solver s(b);
	s.useBothHandsWithTwoHandActions();
	if (b.size() < 1) {
		addMessage("Put at least one block in the grid.");
		return;
	}
	if (!s.isStable()) {
		addMessage("Please make a stable pattern.", true);
		return;
	}

	mainWindow->showWaiting();
	buildingArea->setActive(false);
	buildButton->setEnabled(false);

	mainWindow->moves = s.solve();
	if (mainWindow->moves.size() == 0) {
		addMessage("Robot can't build this.");
		mainWindow->hideWaiting();
		buildingArea->setActive(true);
		buildButton->setEnabled(true);
		//Probably requires putting more than 2 blocks at the same time
		return;
	}

	//TODO
	std::vector<Move> a = mainWindow->moves;
	int counter = 0;
	for (int i = 0; i < (int) a.size(); i++) {
		if (a[i].left != Move::NO_BLOCK) {
			counter++;
			std::cerr << "left ";
		}
		if (a[i].right != Move::NO_BLOCK) {
			counter--;
			std::cerr << "right ";
		}
	}
	std::cerr << counter << "-------------------\n";

	mainWindow->blocks = b;
	std::vector<QColor> c;
	for (int i = 0; i < (int) t.size(); i++)
		c.push_back(t[i].second);
	mainWindow->colors = c;
	convert();

	mainWindow->switchState();
}
Esempio n. 12
0
void AddPatternDefinitionImpl::operator()( const std::string & name, boost::ptr_vector<Alternative> & alts ) const {
	PatternRef pattern = getPattern( name );

	pattern->addAlternatives( alts ); // Добавляем альтернативы к шаблону
	pattern->updateDependencies(); // Обновляем зависимости шаблона

	for( boost::ptr_vector<Alternative>::const_iterator altIt = pattern->getAlternatives().begin(); altIt != pattern->getAlternatives().end(); ++ altIt ) {
		const Alternative & alt = *altIt;
		const_cast<Alternative &>( alt ).setTransform( std::auto_ptr<transforms::Transform>( transformBuilder.build( alt, alt.getTransformSource() ) ) ); // Устанавливаем преобразование
	}
}
Esempio n. 13
0
/*
 @brief 评价函数,用于alpha-beta叶节点的评价。只会评价棋局上某一方的得分。
 @param oriBoard 棋局
 @param team 要评价的一方
 @return 此方得分
 */
int Evaluate(int **oriBoard, PieceTeam team)
{
    int dr[] = {0, 1, 1, 1}; //右、右上、上、左上
    int dc[] = {1, 1, 0,-1}; //由于是从左下到右上的顺序搜的 所以只需要检查这四个方向,避免重复
//    int dr[] = { 1, 1, 0,-1,-1,-1, 0, 1}; //从正上方开始顺时针
//    int dc[] = { 0, 1, 1, 1, 0,-1,-1,-1};
    int **board = copy2DIntArray(oriBoard, kBoardRow, kBoardCol);
    PatType pattern[70] = {0};  // 存放模式的数组,key为模式,value为数量
    
    // 寻找棋盘上该方所有的模式并存入pattern数组
    for (int i=0; i<kBoardRow; ++i) {
        for (int j=0; j<kBoardCol; ++j) {
            if(board[i][j] != team)
                continue;
            for (int k=0; k<4; ++k) {   //检查4个方向
                int curPat = getPattern(board, team, GBIntPointMake(i, j), GBIntPointMake(dr[k], dc[k]));
                if (curPat > 0) {   //正向能够找到模式
                    ++pattern[curPat];
                }
                else if (curPat < 0) {  //正向有阻碍,尝试从最后一个位置反向查
                    curPat = -curPat;
                    int nr=i+dr[k]*(curPat-1), nc=j+dc[k]*(curPat-1);
                    // 获取到最后一个连续有子的位置
                    while (board[nr][nc] != team) {
                        nr -= dr[k];
                        nc -= dc[k];
                    }
                    curPat = getPattern(board, team, GBIntPointMake(nr, nc), GBIntPointMake(-dr[k], -dc[k]));
                    if (curPat > 0) {
                        ++pattern[curPat];
                    }
                }
            }
        }
    }
    
    delete2DIntArray(board);
    // 通过得到的模式来计算得分
    int score = CalScore(pattern);
    return score;
}
Esempio n. 14
0
 int getPattern(vector<bool>& visit, vector<vector<int>> skip, int cur, int remain){
     if(remain < 0) return 0;
     if(remain == 0) return 1;
     
     visit[cur] = true;
     int ret = 0;
     for(int i = 1; i <= 9; ++i){
         if(visit[i]==false && (skip[cur][i]==0 || visit[skip[cur][i]]==true)){
             ret += getPattern(visit, skip, i, remain-1);
         }
     }
     visit[cur] = false;
     return ret;
 }
Esempio n. 15
0
DateTimeFormatter *DateTimeFormat::StyleFormatter::getFormatter(Locale *locale) {
    locale = (locale == NULL ? Locale::getDefault() : locale);
    string key = to_string(iType + (iDateStyle << 4) + (iTimeStyle << 8)) + locale->tostring();
    DateTimeFormatter *f = NULL;
//    synchronized (cCache) {
        f = cCache[key];
        if (f == NULL) {
            string pattern = getPattern(locale);
            f = DateTimeFormat::forPattern(pattern);
            cCache.insert(pair<string, DateTimeFormatter*>(key, f));
        }
//    }
    return f;
}
Esempio n. 16
0
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericValidator
// -----------------------------------------------------------------------
void FloatDatatypeValidator::checkContent(const XMLCh*             const content
                                         ,      ValidationContext* const context
                                         ,      bool                     asBase
                                         ,      MemoryManager*     const manager)
{

    //validate against base validator if any
    FloatDatatypeValidator *pBase = (FloatDatatypeValidator*) this->getBaseValidator();
    if (pBase)
        pBase->checkContent(content, context, true, manager);

    // we check pattern first
    if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        if (getRegex()->matches(content, manager) ==false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }
    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    XMLFloat theValue(content, manager);
    XMLFloat *theData = &theValue;

    if (getEnumeration() != 0)
    {
        int i=0;
        int enumLength = getEnumeration()->size();
        for ( ; i < enumLength; i++)
        {
            if (compareValues(theData, (XMLFloat*) getEnumeration()->elementAt(i))==0)
                break;
        }

        if (i == enumLength)
            ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager);
    }

    boundsCheck(theData, manager);
}
  // Type-parameterized test.
  void TypedTest_ImportChain() {
    std::string Code = getCode() + getCode();
    auto Pattern = getPattern();

    TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX, "input0.cc");

    auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu, Pattern);
    auto *FromD1 = LastDeclMatcher<DeclTy>().match(FromTu, Pattern);

    auto *ToD0 = Import(FromD0, Lang_CXX);
    auto *ToD1 = Import(FromD1, Lang_CXX);

    EXPECT_TRUE(ToD0);
    ASSERT_TRUE(ToD1);
    EXPECT_NE(ToD0, ToD1);
    EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
  }
void DisplayWindow::writeCppFile(QString dir, string path)
{
    ofstream ofile(path.c_str());
    ofile << "#include <fstream>\n#include <string>\n#include <LightParameter.h>\n#include <NeoPixelCodeConverter.h>\n#include <vector>\n\n";
    ofile << "using namespace std;\n\n";
    ofile << "NeoPixelCodeConverter b;\nvector<LightParameter> a;\n\n";
    ofile << "int main()\n{\n\n";
    ofile<<"int* ";

    for(int t = 0; t < vecOfStructures->size(); t++)
    {
        uint32_t c1 = vecOfStructures->at(t).Color1;
        uint32_t c2 = vecOfStructures->at(t).Color1;

        ofile<<"arr = new int["<<vecOfStructures->at(t).grouplength<<"] {";
        for( int j = 0; j < vecOfStructures->at(t).grouplength; j++)
        {
            ofile<<vecOfStructures->at(t).group[j]<<", ";
        }
        ofile<<"};\n";

        ofile<< "a.push_back(LightParameter(";
        ofile<< getPattern(vecOfStructures->at(t).pattern).toStdString() << ", ";
        ofile<< getDirection(vecOfStructures->at(t).direction).toStdString() << ", ";
        ofile<< vecOfStructures->at(t).startTime << ", ";
        ofile<< vecOfStructures->at(t).cycles << ", ";
        ofile<< vecOfStructures->at(t).index << ", ";
        ofile<< vecOfStructures->at(t).onTime << ", ";
        ofile<< vecOfStructures->at(t).offTime << ", ";
        ofile<< vecOfStructures->at(t).brightness << ", ";
        ofile<< "b.Color(" <<int(parentForDWin->Red(c1))<<",";
        ofile<< int(parentForDWin->Green(c1))<<",";
        ofile<< int(parentForDWin->Blue(c1))<<"), ";
        ofile<< "b.Color(" <<int(parentForDWin->Red(c2))<<",";
        ofile<< int(parentForDWin->Green(c2))<<",";
        ofile<<int(parentForDWin->Blue(c2))<<"), ";
        ofile<< vecOfStructures->at(t).interval << ", ";
        ofile<< "arr, " << vecOfStructures->at(t).grouplength << "));\n";
        ofile<<"delete [] arr;\n\n";
    }
    ofile<< "b.create(a, " << getNumModules() << ", " << vecOfStructures->size() << ", \"" <<
            QString(dir + "/out/out.ino").toStdString() << "\"";
    ofile<< ");\n\n}";

    ofile.close();
}
Esempio n. 19
0
void BooleanDatatypeValidator::checkContent( const XMLCh*             const content
                                           ,       ValidationContext* const context
                                           ,       bool                     asBase
                                           ,       MemoryManager*     const manager)
{

    //validate against base validator if any
    BooleanDatatypeValidator *pBaseValidator = (BooleanDatatypeValidator*) this->getBaseValidator();
    if (pBaseValidator !=0)
        pBaseValidator->checkContent(content, context, true, manager);

    // we check pattern first
    if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        if (getRegex()->matches(content, manager) ==false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }
    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    unsigned int   i = 0;
    for ( ; i < XMLUni::fgBooleanValueSpaceArraySize; i++ )
    {
        if ( XMLString::equals(content, XMLUni::fgBooleanValueSpace[i]))
            break;
    }

    if (i == XMLUni::fgBooleanValueSpaceArraySize)
        ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                           , XMLExcepts::VALUE_Invalid_Name
                           , content
                           , SchemaSymbols::fgDT_BOOLEAN
                           , manager);
        //Not valid boolean type

}
Esempio n. 20
0
// Color Profile
void MainDialog::OnLb_profileChoiceSelected(wxCommandEvent& event)
{
	std::lock_guard<std::recursive_mutex> lck(m_mx);
	
	m_sel_profile = m_lb_profile->GetSelection();
	
	if (m_sel_profile == wxNOT_FOUND)
		m_sel_profile = -1;
		
	if (m_sel_profile >= 0)
	{
		m_gradient->setImage(m_profiles[m_sel_profile]->getGradient());

		//////////////////////////////////////////////////////////////////////////
		// Profile Editor handling

		// If it's a gradient profile
		if (m_profiles[m_sel_profile]->getType() == ColorProfile::TYPE_GRADIENT)
		{
			m_button_edit_profile->Enable(true);

			// Update the editor
			if (m_profile_editor.IsVisible())
			{
				auto profile = dynamic_cast<GradientProfile *>(m_profiles[m_sel_profile].get());

				m_profile_editor.SetPattern(profile->getPattern());
				m_profile_editor.SetGranularity(profile->getGranularity());
			}
		}
		else
		{
			m_button_edit_profile->Enable(false);

			if (m_profile_editor.IsVisible())
				m_profile_editor.Hide();
		}
		//////////////////////////////////////////////////////////////////////////
	}
	
	UpdateFrame();
}
Esempio n. 21
0
bool wordPattern(char* pattern, char* str) {
    if (pattern == NULL && str == NULL) return true;

    int word_num = getWordNum(str);
    int pattern_num = strlen(pattern);
    if (word_num != pattern_num)    return false;

    // get each pattern then comapre the pattern
    int a[pattern_num];
    getPattern(pattern, pattern_num, a);

    int b[pattern_num];
    getStrPattern(str, pattern_num, b);

    // compare pattern
    for (int i = 0; i < pattern_num; ++i) {
        if (a[i] != b[i])   return false;
    }
    return true;
}
Esempio n. 22
0
// Edit Profile
void MainDialog::OnButton_edit_profileButtonClicked(wxCommandEvent& event)
{
	std::lock_guard<std::recursive_mutex> lck(m_mx);

	m_sel_profile = m_lb_profile->GetSelection();

	if (m_sel_profile == wxNOT_FOUND)
		m_sel_profile = -1;

	if (m_sel_profile >= 0 && m_profiles[m_sel_profile]->getType() == ColorProfile::TYPE_GRADIENT)
	{
		auto profile = dynamic_cast<GradientProfile *>(m_profiles[m_sel_profile].get());

		m_profile_editor.SetPattern(profile->getPattern());
		m_profile_editor.SetGranularity(profile->getGranularity());

		m_profile_editor.Show();
		m_profile_editor.SetFocus();
	}
}
Esempio n. 23
0
QString FindFilesDialog::getShellPattern()
{
	QString pattern = getPattern();
	pattern.replace('\'', "'\\''");
	return KShell::quoteArg(pattern);
}
//
//   Assign facets
//        assign common facets
//        assign additional facet
//
void AbstractNumericFacetValidator::assignFacet(MemoryManager* const manager)
{

    RefHashTableOf<KVStringPair>* facets = getFacets();

    if (!facets)     // no facets defined
        return;

    XMLCh* key;

    RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager);

    while (e.hasMoreElements())
    {
        KVStringPair pair = e.nextElement();
        key = pair.getKey();
        XMLCh* value = pair.getValue();

        if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN))
        {
            setPattern(value);
            if (getPattern())
                setFacetsDefined(DatatypeValidator::FACET_PATTERN);
            // do not construct regex until needed
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXINCLUSIVE))
        {
            try
            {
                setMaxInclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXEXCLUSIVE))
        {
            try
            {
                setMaxExclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MININCLUSIVE))
        {
            try
            {
                setMinInclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MINEXCLUSIVE))
        {
            try
            {
                setMinExclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgATT_FIXED))
        {
            unsigned int val;
            bool         retStatus;
            try
            {
                retStatus = XMLString::textToBin(value, val, fMemoryManager);
            }
            catch (RuntimeException&)
            {
                ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager);
            }

            if (!retStatus)
            {
                ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager);
            }

            setFixed(val);
            //no setFacetsDefined here

        }
        else
        {
            assignAdditionalFacet(key, value, manager);
        }

    }//while

}// end of assigneFacet()
void DisplayWindow::DisplayInfo()
{
    ui->displayInfo->clear();
    for (int m = 0; m < vecOfStructures->size(); m++)
    {
        qDebug() << "got here";
        
        
        PrintNewLn(QString("Group %1 ").arg(m));

        QTextCharFormat format;
        format.setFontWeight(QFont::Bold);
        format.setForeground(QBrush(QColor(200,0,0)));
        PrintSameLn(format, QString("(EDIT)"));
        PrintSameLn(format, QString("  "));
        PrintSameLn(format, QString("(DELETE)"));

        format.setFontWeight(QFont::Normal);
        format.setForeground(QBrush(Qt::black));
        PrintSameLn(format, QString(" :"));

        QString group = "LEDs: #";
        QString sep = ", #";
        for(int n = 0; n < vecOfStructures->at(m).grouplength; n++)
        {
            QString id = QString::number(vecOfStructures->at(m).group[n]);
            group = QString(group + id + sep);
        }
        group.chop(3);

        PrintNewLnTab(group);
        PrintNewLnTab(QString("Grouplength: %1")
                 .arg(vecOfStructures->at(m).grouplength));
        PrintNewLnTab(QString("Pattern: " +
                         getPattern(vecOfStructures->at(m).pattern)));
        PrintNewLnTab(QString("Direction: " +
                         getDirection(vecOfStructures->at(m).direction)));
        PrintNewLnTab(QString("Start Time: %1")
                 .arg(vecOfStructures->at(m).startTime));
        PrintNewLnTab(QString("Interval: %1")
                 .arg(vecOfStructures->at(m).interval));
        PrintNewLnTab(QString("Cycles: %1")
                 .arg(vecOfStructures->at(m).cycles));
        PrintNewLnTab(QString("Calculated Stop Time: %1 Seconds")
                 .arg((parentForDWin->getStopTime(vecOfStructures->at(m)))
                      /1000.0));
        if (vecOfStructures->at(m).pattern != RAINBOW_CYCLE)
        {
        uint32_t c1 = vecOfStructures->at(m).Color1;
        PrintNewLnTab(QString("Color 1 RGB: (%1, %2,  %3)")
                 .arg(parentForDWin->Red(c1)).arg(parentForDWin->Green(c1))
                      .arg(parentForDWin->Blue(c1)));
        }
        if (vecOfStructures->at(m).Color2 != 0)
        {
            uint32_t c2 = vecOfStructures->at(m).Color2;
            PrintNewLnTab(QString("Color 2 RGB: (%1, %2,  %3)")
                     .arg(parentForDWin->Red(c2)).arg(parentForDWin->Green(c2))
                          .arg(parentForDWin->Blue(c2)));
        }
        PrintNewLn(QString(""));
    }
}
Esempio n. 26
0
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericValidator
// -----------------------------------------------------------------------
void DecimalDatatypeValidator::checkContent(const XMLCh*             const content
                                           ,      ValidationContext* const context
                                           ,      bool                     asBase
                                           ,      MemoryManager*     const manager)
{
    //validate against base validator if any
    DecimalDatatypeValidator *pBase = (DecimalDatatypeValidator*) this->getBaseValidator();
    if (pBase)
        pBase->checkContent(content, context, true, manager);

    int thisFacetsDefined = getFacetsDefined();

    // we check pattern first
    if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        // lazy construction
        if (getRegex() ==0) {
            try {
                // REVISIT: cargillmem fMemoryManager vs manager
                setRegex(new (fMemoryManager) RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption, fMemoryManager));                
            }
            catch (XMLException &e)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager);
            }
        }

        if (getRegex()->matches(content, manager) ==false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }
    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;
    XMLCh *errorMsg = 0;
    try {
        XMLBigDecimal  compareDataValue(content, manager);
        XMLBigDecimal* compareData = &compareDataValue;        
        
        if (getEnumeration())
        {
            int i=0;
            int enumLength = getEnumeration()->size();
            for ( ; i < enumLength; i++)
            {
                if (compareValues(compareData, (XMLBigDecimal*) getEnumeration()->elementAt(i)) ==0 )
                    break;
            }

            if (i == enumLength)
                ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager);
        }

        boundsCheck(compareData, manager);

        if ( (thisFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0 )
        {
            if ( compareData->getScale() > fFractionDigits )
            {                
                XMLCh value1[BUF_LEN+1];
                XMLCh value2[BUF_LEN+1];
                XMLString::binToText(compareData->getScale(), value1, BUF_LEN, 10, manager);
                XMLString::binToText(fFractionDigits, value2, BUF_LEN, 10, manager);
                ThrowXMLwithMemMgr3(InvalidDatatypeFacetException
                                 , XMLExcepts::VALUE_exceed_fractDigit
                                 , compareData->getRawData()
                                 , value1
                                 , value2
                                 , manager);
            }
        }

        if ( (thisFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0 )
        {
            if ( compareData->getTotalDigit() > fTotalDigits )
            {                
                XMLCh value1[BUF_LEN+1];
                XMLCh value2[BUF_LEN+1];
                XMLString::binToText(compareData->getTotalDigit(), value1, BUF_LEN, 10, manager);
                XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10, manager);
                ThrowXMLwithMemMgr3(InvalidDatatypeFacetException
                                 , XMLExcepts::VALUE_exceed_totalDigit
                                 , compareData->getRawData()
                                 , value1
                                 , value2
                                 , manager);
            }

            /***
             E2-44 totalDigits

             ... by restricting it to numbers that are expressible as i � 10^-n
             where i and n are integers such that |i| < 10^totalDigits and 0 <= n <= totalDigits.
            ***/

            if ( compareData->getScale() > fTotalDigits )  
            {                
                XMLCh value1[BUF_LEN+1];
                XMLCh value2[BUF_LEN+1];
                XMLString::binToText(compareData->getScale(), value1, BUF_LEN, 10, manager);
                XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10, manager);
                ThrowXMLwithMemMgr3(InvalidDatatypeFacetException
                                 , XMLExcepts::VALUE_exceed_totalDigit
                                 , compareData->getRawData()
                                 , value1
                                 , value2
                                 , manager);
            }        
        }
    }
    catch (XMLException &e)
    {
       errorMsg = XMLString::replicate(e.getMessage(), manager);
    }
    if(errorMsg)
    {
       ArrayJanitor<XMLCh> jan(errorMsg, manager);
       ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, errorMsg, manager);
    }
}
void UnionDatatypeValidator::init(DatatypeValidator*            const baseValidator
                                , RefHashTableOf<KVStringPair>* const facets
                                , RefArrayVectorOf<XMLCh>*      const enums
                                , MemoryManager*                const manager)
{
    if (enums)
        setEnumeration(enums, false);

    // Set Facets if any defined
    if (facets)
    {
        XMLCh* key;
        XMLCh* value;
        RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager);

        while (e.hasMoreElements())
        {
            KVStringPair pair = e.nextElement();
            key = pair.getKey();
            value = pair.getValue();

            if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN))
            {
                setPattern(value);
                if (getPattern())
                    setFacetsDefined(DatatypeValidator::FACET_PATTERN);
                // do not construct regex until needed
            }
            else
            {
                 ThrowXMLwithMemMgr1(InvalidDatatypeFacetException
                         , XMLExcepts::FACET_Invalid_Tag
                         , key
                         , manager);
            }
        }//while

        /***
           Schema constraint: Part I -- self checking
        ***/
        // Nil

        /***
           Schema constraint: Part II base vs derived checking
        ***/
        // check 4.3.5.c0 must: enumeration values from the value space of base
        if ( ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0) &&
            (getEnumeration() !=0))
        {
            int i = 0;
            int enumLength = getEnumeration()->size();
            try
            {
                for ( ; i < enumLength; i++)
                {
                    // ask parent do a complete check
                    //
                    // enum need NOT be passed this->checkContent()
                    // since there are no other facets for Union, parent
                    // checking is good enough.
                    //
                    baseValidator->validate(getEnumeration()->elementAt(i), (ValidationContext*)0, manager);

                }
            }

            catch ( XMLException& )
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException
                            , XMLExcepts::FACET_enum_base
                            , getEnumeration()->elementAt(i)
                            , manager);
            }
        }

    }// End of Facet setting

    /***
        Inherit facets from base.facets

        The reason of this inheriting (or copying values) is to ease
        schema constraint checking, so that we need NOT trace back to our
        very first base validator in the hierachy. Instead, we are pretty
        sure checking against immediate base validator is enough.
    ***/

    UnionDatatypeValidator *pBaseValidator = (UnionDatatypeValidator*) baseValidator;

    // inherit enumeration
    if (((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) !=0) &&
        ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) == 0))
    {
        setEnumeration(pBaseValidator->getEnumeration(), true);
    }

}
//
// 1) the bottom level UnionDTV would check against
//        pattern and enumeration as well
// 2) each UnionDTV(s) above the bottom level UnionDTV and
//        below the native UnionDTV (the top level DTV)
//        would check against pattern only.
// 3) the natvie Union DTV (the top level DTV) would invoke
//        memberTypeValidator to validate
//
void UnionDatatypeValidator::checkContent(const XMLCh*             const content
                                        ,       ValidationContext* const context
                                        ,       bool                     asBase
                                        ,       MemoryManager*     const manager)
{

    DatatypeValidator* bv = getBaseValidator();
    if (bv)
        ((UnionDatatypeValidator*)bv)->checkContent(content, context, true, manager);
    else
    {   // 3) native union type
        // check content against each member type validator in Union
        // report an error only in case content is not valid against all member datatypes.
        //
        bool memTypeValid = false;
        for ( unsigned int i = 0; i < fMemberTypeValidators->size(); ++i )
        {
            if ( memTypeValid )
                break;

            try
            {
                fMemberTypeValidators->elementAt(i)->validate(content, context, manager);
                memTypeValid = true;
                
                //set the validator of the type actually used to validate the content
                DatatypeValidator *dtv = fMemberTypeValidators->elementAt(i);
                fValidatedDatatype = dtv;
                // context will be null during schema construction
                if(context)
                    context->setValidatingMemberType(dtv);
            }
            catch (XMLException&)
            {
                //absorbed
            }
        } // for

        if ( !memTypeValid )
        {
            ThrowXMLwithMemMgr1(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_no_match_memberType
                    , content
                    , manager);
            //( "Content '"+content+"' does not match any union types" );
        }
    }

    // 1) and 2). we check pattern first
    if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        if (getRegex()->matches(content, manager) == false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }
    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    if ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0 &&
        (getEnumeration() != 0))
    {

        // If the content match (compare equal) any enumeration with
        // any of the member types, it is considerd valid.
        //
        RefVectorOf<DatatypeValidator>* memberDTV = getMemberTypeValidators();
        RefArrayVectorOf<XMLCh>* tmpEnum = getEnumeration();
        unsigned int memberTypeNumber = memberDTV->size();
        unsigned int enumLength = tmpEnum->size();

        for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex)
        {
            for ( unsigned int enumIndex = 0; enumIndex < enumLength; ++enumIndex)
            {
                try
                {
                    if (memberDTV->elementAt(memberIndex)->compare(content, tmpEnum->elementAt(enumIndex), manager) == 0)
                        return;
                }
                catch (XMLException&)
                {
                    //absorbed
                }
            } // for enumIndex
        } // for memberIndex

        ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager);

    } // enumeration

}
Esempio n. 29
0
//
// here content is a list of items
//
void ListDatatypeValidator::checkContent(       BaseRefVectorOf<XMLCh>*       tokenVector
                                        , const XMLCh*                  const content
                                        ,       ValidationContext*      const context
                                        ,       bool                          asBase
                                        ,       MemoryManager*          const manager)
{
    DatatypeValidator* bv = getBaseValidator();

    if (bv->getType() == DatatypeValidator::List)
        ((ListDatatypeValidator*)bv)->checkContent(tokenVector, content, context, true, manager);
    else
    {   // the ultimate itemType DTV
        for (unsigned int i = 0; i < tokenVector->size(); i++)
            bv->validate(tokenVector->elementAt(i), context, manager);
    }

    int thisFacetsDefined = getFacetsDefined();

    // we check pattern first
    if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 )
    {
        // lazy construction
        if (getRegex() == 0)
        {
            try {
                setRegex(new (fMemoryManager) RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption, fMemoryManager));            	
            }
            catch (XMLException &e)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager);
            }
        }

        //check every item in the list as a whole
        if (getRegex()->matches(content, manager) == false)
        {
            ThrowXMLwithMemMgr2(InvalidDatatypeValueException
                    , XMLExcepts::VALUE_NotMatch_Pattern
                    , content
                    , getPattern()
                    , manager);
        }

    }

    // if this is a base validator, we only need to check pattern facet
    // all other facet were inherited by the derived type
    if (asBase)
        return;

    unsigned int tokenNumber = tokenVector->size();

    if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) &&
        (tokenNumber > getMaxLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(getMaxLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_GT_maxLen
                , getContent()
                , value1
                , value2
                , manager);
    }

    if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) &&
        (tokenNumber < getMinLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(getMinLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_LT_minLen
                , getContent()
                , value1
                , value2
                , manager);
    }

    if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) &&
        (tokenNumber != AbstractStringValidator::getLength()))
    {
        XMLCh value1[BUF_LEN+1];
        XMLCh value2[BUF_LEN+1];
        XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager);
        XMLString::binToText(AbstractStringValidator::getLength(), value2, BUF_LEN, 10, manager);

        ThrowXMLwithMemMgr3(InvalidDatatypeValueException
                , XMLExcepts::VALUE_NE_Len
                , getContent()
                , value1
                , value2
                , manager);
    }

    if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 &&
        (getEnumeration() != 0))
    {
        int i;
        int enumLength = getEnumeration()->size();

        for ( i = 0; i < enumLength; i++)
        {
            //optimization: we do a lexical comparision first
            // this may be faster for string and its derived
            if (XMLString::equals(getEnumeration()->elementAt(i), getContent()))
                break; // a match found

            // do a value space check
            // this is needed for decimal (and probably other types
            // such as datetime related)
            // eg.
            // tokenVector = "1 2 3.0 4" vs enumeration = "1 2 3 4.0"
            //
            if (valueSpaceCheck(tokenVector, getEnumeration()->elementAt(i), manager))
                break;
        }

        if (i == enumLength)
            ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, getContent(), manager);

    } // enumeration

}
Esempio n. 30
0
LifeDialog::LifeDialog( int scale, QWidget * parent, const char * name )
    : QWidget( parent, name )
{
    qb = new QPushButton( "Quit!", this );
    cb = new QComboBox( this, "comboBox" );
    life = new LifeWidget(scale, this);
    life->move( SIDEBORDER, TOPBORDER );


    connect( qb, SIGNAL(clicked()), qApp, SLOT(quit()) );
    qb->setGeometry( SIDEBORDER, SIDEBORDER, qb->sizeHint().width(), 25 );
    timer = new LifeTimer( this );

    connect( timer, SIGNAL(timeout()), life, SLOT(nextGeneration()) );
    pb = new QPushButton( "Pause", this );
    pb->setToggleButton( TRUE );
    connect( pb, SIGNAL(toggled(bool)), timer, SLOT(pause(bool)) );
    pb->resize( pb->sizeHint().width(), 25 );
    pb->move( width() - SIDEBORDER - pb->width(), SIDEBORDER );

    sp = new QLabel( "Speed:", this );
    sp->adjustSize();
    sp->move( SIDEBORDER, 45 );
    scroll = new QSlider( 0, LifeTimer::MAXSPEED, 50,
			     LifeTimer::MAXSPEED / 2,
			     QSlider::Horizontal, this );
    connect( scroll, SIGNAL(valueChanged(int)),
	     timer,  SLOT(setSpeed(int)) );

    scroll->move( sp->width() + 2 * SIDEBORDER, 45 );
    scroll->resize( 200, 15 );

    life->setFrameStyle( QFrame::Panel | QFrame::Sunken );
    life->show();

    srand( QTime(0,0,0).msecsTo(QTime::currentTime()) );
    int sel =  rand() % NPATS;
    getPattern( sel );

    cb->move( 2*SIDEBORDER + qb->width(), SIDEBORDER);
    cb->insertItem( "Glider Gun " );
    cb->insertItem( "Figure Eight " );
    cb->insertItem( "Pulsar " );
    cb->insertItem( "Barber Pole P2 " );
    cb->insertItem( "Achim P5 " );
    cb->insertItem( "Hertz P4 " );
    cb->insertItem( "Tumbler " );
    cb->insertItem( "Pulse1 P4" );
    cb->insertItem( "Shining Flower P5 " );
    cb->insertItem( "Pulse2 P6 " );
    cb->insertItem( "Pinwheel, Clock P4 " );
    cb->insertItem( "Pentadecatholon " );
    cb->insertItem( "Piston " );
    cb->insertItem( "Piston2 " );
    cb->insertItem( "Switch Engine " );
    cb->insertItem( "Gears (Gear, Flywheel, Blinker) " );
    cb->insertItem( "Turbine8 " );
    cb->insertItem( "P16 " );
    cb->insertItem( "Puffer " );
    cb->insertItem( "Escort " );
    cb->insertItem( "Dart Speed 1/3 " );
    cb->insertItem( "Period 4 Speed 1/2 " );
    cb->insertItem( "Another Period 4 Speed 1/2 " );
    cb->insertItem( "Smallest Known Period 3 Spaceship Speed 1/3 " );
    cb->insertItem( "Turtle Speed 1/3 " );
    cb->insertItem( "Smallest Known Period 5 Speed 2/5 " );
    cb->insertItem( "Sym Puffer " );
    cb->insertItem( "], Near Ship, Pi Heptomino " );
    cb->insertItem( "R Pentomino " );
    cb->setAutoResize( FALSE );
    cb->setCurrentItem( sel );
    cb->show();
    connect( cb, SIGNAL(activated(int)), SLOT(getPattern(int)) );

    QSize s;
    s = life->minimumSize();
    setMinimumSize( s.width() + 2 * SIDEBORDER, 
		    s.height() + TOPBORDER + SIDEBORDER );
    s = life->maximumSize();
    setMaximumSize( s.width() + 2 * SIDEBORDER, 
		    s.height() + TOPBORDER + SIDEBORDER );
    s = life->sizeIncrement();
    setSizeIncrement( s.width(), s.height() );

    resize( QMIN(512, qApp->desktop()->width()),
	    QMIN(480, qApp->desktop()->height()) );
}