Esempio n. 1
0
void Tree::generateTree( float offset, float ra, float ra2, int stop ) {

	if ( stop == 0 )
		return;

	glColor3f( .67, .44, .23 );
	glTranslatef( 0, 0, offset );
	glRotatef( ra, 0, 1, 0 );
	glRotatef( ra2, 1, 0, 0 );
	glScalef( .6, .6, .6 );
	glutSolidCone( 2, 20, 10, 10 );

	glPushMatrix();
	generateTree( 7, 45, -30, stop - 1);
	glPopMatrix();

	glPushMatrix();
	generateTree( 7, -45, -30, stop - 1);
	glPopMatrix();

	glPushMatrix();
	generateTree( 7, 30, 60, stop - 1 );
	glPopMatrix();

	glPushMatrix();
	glColor3f( 0, 1, 0 );
	glTranslatef( 0, 0, 20 );
	glutSolidSphere( 8, 10, 10 );
	glPopMatrix();
	
}
 vector<TreeNode *> generateTrees(int n) {
     
     if(n==0)
       return generateTree(1, 0);
     else
       return generateTree(1, n);
 }
Esempio n. 3
0
string Tree::generateTree(string nextString)
{
	srand(randomSeed++);
	string finalString = "";
	list<string> tokens = splitStr(nextString, " ");
	for(list<string>::iterator iter = tokens.begin(); iter != tokens.end(); iter++)
	{
		if( !(iter->compare("t")) )
		{
			finalString += "t ";
			continue;
		}

		if( !(iter->compare("s")) )
		{
			finalString += generateTree("t t t t0");
			continue;
		}

		if( !(iter->compare("t0")) )
		{
			switch(rand()%4)
			{
				case 0:
					finalString += generateTree("t b b t1");
					break;
				case 1:
					finalString += generateTree("t b t1");
					break;
				case 2:
					finalString += generateTree("t b t1 b");
					break;
				case 3:
					finalString += generateTree("t t1");
					break;
			}
			continue;
		}
		if( !(iter->compare("t1")) )
		{
			switch(rand()%2)
			{
				case 0:
					finalString += "t b b b b ";
					break;
				case 1:
					finalString += "t b b b ";
					break;
			}
			continue;
		}
		finalString +=  *iter + " ";
	}
	return finalString;
}
Esempio n. 4
0
void FTVHelp::generateTree(QTextStream &t, const QList<FTVNode> &nl,int level)
{
  QCString spaces;
  spaces.fill(' ',level*2+8);
  QListIterator<FTVNode> nli(nl);
  FTVNode *n;
  for (nli.toFirst();(n=nli.current());++nli)
  {
    t << spaces << "<p>";
    generateIndent(t,n,0);
    if (n->isDir)
    {
      t << "<img " << FTV_IMGATTRIBS(folderclosed) << "onclick=\"toggleFolder('folder" << folderId << "', this)\"/>";
      generateLink(t,n);
      t << "</p>\n";
      t << spaces << "<div id=\"folder" << folderId << "\">\n";
      folderId++;
      generateTree(t,n->children,level+1);
      t << spaces << "</div>\n";
    }
    else
    {
      t << "<img " << FTV_IMGATTRIBS(doc) << "/>";
      generateLink(t,n);
      t << "</p>\n";
    }
  }
}
Esempio n. 5
0
int SHMParser::generateTree(SHMList<SHMString> list, int pos, SHMTreeNode* &root, bool first) {
	if (pos > list.size()) return -1;
	if (!root) return -1;
	int depth = 0;
	int i = 0;
	if (first) {
		root->setNodeType("fileRoot");
	} else {
		depth = indexFirstAlnum(list[pos]);
		root->setLineContents(list[pos].substr(depth));
		setNodeFamily(root);
		setNodeType(root);
		setNodeLineNumbers(root);
		setNodeAttributes(root);
		i = pos+1;
	}
	while (i<list.size()) {
		int nextDepth = indexFirstAlnum(list[i]);
		if (nextDepth > depth) {
			SHMTreeNode *nextSon = new SHMTreeNode();
			nextSon->setLineStart(root->lineStart());
			nextSon->setLineEnd(root->lineEnd());
			i = generateTree(list, i,nextSon,false);
			root->appendChild(nextSon);
		} else {
			break;
		}
	}
	return i;
}
Esempio n. 6
0
        void BVHSceneTree::build()
        {
            OCULAR_PROFILE()

            // 1. Generate the morton codes for each scene object and sort them
            // 2. Recursively build the tree top-down
            // 3. Recursively fit the bounds of each node around it's children

            const uint32_t numObjects = static_cast<uint32_t>(m_AllObjects.size());

            if(numObjects > 0)
            {
                std::vector<MortonPair> mortonPairs;  
                createMortonPairs(mortonPairs);

                m_Root = generateTree(nullptr, mortonPairs, 0, (numObjects) - 1);
                m_Root->type = SceneNodeType::Root;
            }
            else
            {
                m_Root = new BVHSceneNode();
                m_Root->type = SceneNodeType::Root;
            }

            fitNodeBounds(m_Root);
        }
Esempio n. 7
0
int process(const char *fileName){

	// Reading file
	char *buffer;
	unsigned int fileSize = 0;

	int result = readFile(fileName, &buffer, fileSize);
	if(result != 0)
		return result; // If there was a problem, return its error code


	// First Byte must be a StartOfHeader SOH character
	if(buffer[0] != 1)
		return 2; // File is not compressed in huff format

	// Got number of padding bytes
	char paddingBits = buffer[1];

	unsigned int pos(2);
	TreeNode *root = generateTree(buffer, pos);

	// XXX TESTING
	printTreeElements(root);


	// Creating bitstring
	std::string bitString;
	for(unsigned int i = pos+2; i < fileSize; i++){
		bitString += bits_in_byte(buffer[i]).to_string();
	}


	std::string decodedString;
	decode(bitString, root, decodedString);
	
	

	char pops = (char) paddingBits / calculateShortestDistance(root);
	for(char i = 0; i < pops; i++){
		decodedString.pop_back();
	}


	std::string outputFileName(fileName);
	for(char i = 0; i < 4; i++){
		outputFileName.pop_back();
	}

	std::ofstream out(outputFileName);

	out << decodedString;

	out.close();

/*
*/
	return 0;
}	
Esempio n. 8
0
int main()
{
	char str[500];
	scanf("%s",str);
	int s = size(str);

	preorder(generateTree(s,str));
	return 0;
}
Esempio n. 9
0
Tree *Tree:: getTree()
{
    while(true){
       // qDebug()<<"atempt1";
        Tree* temp=generateTree();
        if(temp!=NULL){
            return temp;
        }
    }
    return NULL;
}
Esempio n. 10
0
void Map::reset()
{
  // Remove all trees
  _trees.clear();

  // Add initial tree
  generateTree(0);

  // Re-place bird
  placeBird();
}
 vector<TreeNode*> generateTree(int start, int end) {
     vector<TreeNode*> subtree;
     if(start > end) {subtree.push_back(nullptr); return subtree;}
     for(int k = start; k <= end; ++k)
     {
         vector<TreeNode*> left = generateTree(start,k-1);
         vector<TreeNode*> right = generateTree(k+1,end);
         for(auto i : left)
         {
             for(auto j : right)
             {
                 TreeNode *root = new TreeNode(k);
                 root->left = i;
                 root->right = j;
                 subtree.push_back(root);
             }
         }
         
     }
     return subtree;
 }
    vector<TreeNode *> generateTree(int start, int end){
     vector<TreeNode*> subTree; 
     
     if(start>end){
         subTree.push_back(NULL);
         return subTree;
     }
     
     for (int k = start; k <= end; k++) {
         vector<TreeNode*> leftSubs = generateTree(start, k - 1);
         vector<TreeNode*> rightSubs = generateTree(k + 1, end); 
         for(auto i:leftSubs )
             for(auto j:rightSubs){
                 TreeNode *node = new TreeNode(k);
                 node->left = i;
                 node->right = j;
                 subTree.push_back(node);
             }
         }
         return subTree;
 }
Esempio n. 13
0
void FTVHelp::generateTreeViewInline(FTextStream &t)
{
  generateScript(t);
  t << "    <div class=\"directory-alt\">\n";
  t << "      <br/>\n";
  t << "      <div style=\"display: block;\">\n";

  generateTree(t,m_indentNodes[0],0);

  t << "      </div>\n";
  t << "    </div>\n";
}
Esempio n. 14
0
TreeNode* generateTree(char *buffer, unsigned int &pos){
	if(buffer[pos] == 21)
		return NULL;

	TreeNode *node = new TreeNode;
	node->character = 0;
	if(buffer[pos] == 7){
		pos++;
		node->left = generateTree(buffer, pos);
		pos++;
		node->right = generateTree(buffer, pos);
		return node;
	}

	node->character = buffer[pos];
	pos++;
	node->left = generateTree(buffer, pos);
	pos++;
	node->right = generateTree(buffer, pos);
	return node;

}
Esempio n. 15
0
void  Decompression::readFile(const char *file)
{
  std::ofstream  destFile;
  //string  destFileName(file);
  std::string  destFileName("decompressedFile.txt");
  FILE  *pFile;
  Node  *firstIt;
  char  c;
  unsigned short  res;
  unsigned int mask;

  //destFileName = destFileName.substr(0, destFileName.size() - 7);
  destFile.open(destFileName.c_str());
  if (destFile.bad())
    std::cerr << "Error creating decompressed file" << std::endl;
  else
    {
      pFile = fopen(file, "r");
      if (pFile == NULL)
	std::cerr << "Error opening file" << std::endl;
      else
	{
	  fileSize(pFile);
	  createTabOcc(pFile);

	  triToList();
	  generateTree();
	  firstIt = this->_items.front();

	  res = (fgetc(pFile));
	  res = res << 8;
	  c = fgetc(pFile);
	  mask = 32768;
	  res += (unsigned char)c;
	  while (this->_fileSize > 0)
	    {
	      destFile << getChar(firstIt, res, mask);
	      this->_fileSize--;
	      if (mask < 256)
		{
		  mask = mask * 256;
		  res = res << 8;
		  c = fgetc(pFile);
		  res += (unsigned char)c;
		}
	    }
	  fclose(pFile);
	}
      destFile.close();
    }
}
Esempio n. 16
0
void DebugPrintVisitor::generateTree(Node &node)
{
    for (int i = 0; i < step * depth; ++i)
    {
        os << indentChar;
    }
    node.accept(*this);
    ++depth;
    for (auto& child : node.childs())
    {
        if (child) generateTree(*child);
    }
    --depth;
}
Esempio n. 17
0
void Map::updateTrees(float move, uint score)
{
  // Check if most left tree is out of screen, if yes, remove it, and generate a new one
  sf::Sprite& tree = _trees.front();
  if(tree.getPosition().x < -tree.getGlobalBounds().width)
  {
    _trees.pop_front();
    generateTree(score);
  }

  // Move trees
  for( sf::Sprite& tree : _trees )
    tree.move(-move, 0);
}
Esempio n. 18
0
void Tree::startTree() {
	// Draw branch
	glColor3f( .67, .44, .23 );
	glRotatef( -90, 1, 0, 0 );
	glutSolidCone( 2, 20, 10, 10 );

	// Fractal
	glPushMatrix();
	generateTree( 7, 45, -30, 2 );
	glPopMatrix();
	
	glPushMatrix();
	generateTree( 7, -45, -30, 2 );
	glPopMatrix();

	glPushMatrix();
	generateTree( 7, 30, 60, 2 );
	glPopMatrix();


	glColor3f( 0, 1, 0 );
	glTranslatef( 0, 0, 20 );
	glutSolidSphere( 6, 10, 10 );
}
Esempio n. 19
0
int main ( int argc, char* argv[] ) { //PFC编码、解码算法统一测试入口
   /*DSA*/if ( 2 > argc ) { printf ( "Usage: %s <message#1> [message#2] ...\a\n", argv[0] ); return -1; }
   PFCForest* forest = initForest(); //初始化PFC森林
   PFCTree* tree = generateTree ( forest ); release ( forest ); //生成PFC编码树
   /*DSA*/print ( tree );
   PFCTable* table = generateTable ( tree ); //将PFC编码树转换为编码表
   /*DSA*/for ( int i = 0; i < N_CHAR; i++ ) printf ( " %c: %s\n", i + 0x20, * ( table->get ( i + 0x20 ) ) ); //输出编码表
   for ( int i = 1; i < argc; i++ ) { //对于命令行传入的每一明文串
      /*DSA*/printf ( "\nEncoding: %s\n", argv[i] ); //开始编码
      Bitmap codeString; //二进制编码串
      int n = encode ( table, codeString, argv[i] ); //将根据编码表生成(长度为n)
      /*DSA*/printf ( "%s\n", codeString.bits2string ( n ) ); //输出当前文本的编码串
      /*DSA*/printf ( "Decoding: " ); //开始解码
      decode ( tree, codeString, n ); //利用编码树,对长度为n的二进制编码串解码(直接输出)
   }
   release ( table ); release ( tree ); return 0; //释放编码表、编码树
}
Esempio n. 20
0
/******************************************************************************************
 * 无论编码森林由列表、完全堆还是左式堆实现,本测试过程都可适用
 * 编码森林的实现方式采用优先级队列时,编译前对应的工程只需设置相应标志:
 *    DSA_PQ_List、DSA_PQ_ComplHeap或DSA_PQ_LeftHeap
 ******************************************************************************************/
int main(int argc, char* argv[]) { //Huffman编码算法统一测试
   /*DSA*/if (3 > argc) { printf("Usage: %s <sample-text-file> <message#1> [message#2] ...\a\n", argv[0]); return -1; }
   int* freq = statistics(argv[1]); //根据样本文件,统计各字符的出现频率
   HuffForest* forest = initForest(freq); release(freq); //创建Huffman森林
   HuffTree* tree = generateTree(forest); release(forest); //生成Huffman编码树
   /*DSA*/print(tree); //输出编码树
   HuffTable* table = generateTable(tree); //将Huffman编码树转换为编码表
   /*DSA*/for (int i = 0; i < N_CHAR; i++) //输出编码表
      /*DSA*/printf(" %c: %s\n", i+0x20, *(table->get(i+0x20)));
   for (int i = 2; i < argc; i++) { //对于命令行传入的每一明文串
      /*DSA*/printf("\nEncoding: %s\n", argv[i]);
      Bitmap* codeString = new Bitmap; //二进制编码串将通过
      int n = encode(table, codeString, argv[i]); //调用编码算法生成(总长为n)
      /*DSA*/printf("%s\n", codeString->bits2string(n)); //输出编码串
      /*DSA*/printf("Decoding: ");
      decode(tree, codeString, n); //利用Huffman编码树,对长度为n的二进制编码串解码
      release(codeString);
   }
   release(table); release(tree); return 0; //释放编码表、编码树
}
Esempio n. 21
0
void Functions::add(QString name, QString term) {
    //check, if function name is already there
    if (getFunction(name) != nullptr) return;

    //if not, create a functiontree and use if for parsing
    FunctionTree* fTree = new FunctionTree(nullptr, true, name);

    //parse it
    generateTree(name, term, fTree);

    //skip unnessesary null-functions and id functions
    while (fTree->getRoot() != nullptr) fTree = fTree->getRoot();
    while (fTree->getFunc() == "id") {
        fTree = fTree->getLeft();
        delete (fTree->getRight());
        fTree->setRoot(nullptr, true);
    }

    //optimizesed it
    optimizeTree(fTree);
    fTrees.append(fTree);
}
Esempio n. 22
0
int main(int argc, const char * argv[]) {
    
    
//    vector<int> v ({1,2,3,4,5,5,6,});
//    vector<int> v ({0});
    vector<int> v ({1,2});
    
    TreeNode *r ;
    
//    r=nullptr;
//    maxDepth(r);
    
    r = generateTree(v);
    maxDepth(r);
    
    
    
    
    
    
    
    return 0;
}
Esempio n. 23
0
// write tree inside page
void FTVHelp::generateTreeViewInline(FTextStream &t)
{
    int preferredNumEntries = Config_getInt("HTML_INDEX_NUM_ENTRIES");
    t << "<div class=\"directory\">\n";
    QListIterator<FTVNode> li(m_indentNodes[0]);
    FTVNode *n;
    int d=1, depth=1;
    for (; (n=li.current()); ++li)
    {
        if (n->children.count()>0)
        {
            d = n->computeTreeDepth(2);
            if (d>depth) depth=d;
        }
    }
    int preferredDepth = depth;
    // write level selector
    if (depth>1)
    {
        t << "<div class=\"levels\">[";
        t << theTranslator->trDetailLevel();
        t << " ";
        int i;
        for (i=1; i<=depth; i++)
        {
            t << "<span onclick=\"javascript:toggleLevel(" << i << ");\">" << i << "</span>";
        }
        t << "]</div>";

        if (preferredNumEntries>0)
        {
            preferredDepth=1;
            for (int i=1; i<=depth; i++)
            {
                int num=0;
                QListIterator<FTVNode> li(m_indentNodes[0]);
                FTVNode *n;
                for (; (n=li.current()); ++li)
                {
                    num+=n->numNodesAtLevel(0,i);
                }
                if (num<=preferredNumEntries)
                {
                    preferredDepth=i;
                }
                else
                {
                    break;
                }
            }
        }
    }
    //printf("preferred depth=%d\n",preferredDepth);

    t << "<table class=\"directory\">\n";
    int index=0;
    generateTree(t,m_indentNodes[0],0,preferredDepth,index);
    t << "</table>\n";

    t << "</div><!-- directory -->\n";
}
Esempio n. 24
0
void FTVHelp::generateTree(FTextStream &t, const QList<FTVNode> &nl,int level,int maxLevel,int &index)
{
    QListIterator<FTVNode> nli(nl);
    FTVNode *n;
    for (nli.toFirst(); (n=nli.current()); ++nli)
    {
        t << "<tr id=\"row_" << generateIndentLabel(n,0) << "\"";
        if ((index&1)==0) // even row
            t << " class=\"even\"";
        if (level>=maxLevel) // item invisible by default
            t << " style=\"display:none;\"";
        else // item visible by default
            index++;
        t << "><td class=\"entry\">";
        bool nodeOpened = level+1<maxLevel;
        generateIndent(t,n,nodeOpened);
        if (n->isDir)
        {
            if (n->def && n->def->definitionType()==Definition::TypeGroup)
            {
                // no icon
            }
            else if (n->def && n->def->definitionType()==Definition::TypePage)
            {
                // no icon
            }
            else if (n->def && n->def->definitionType()==Definition::TypeNamespace)
            {
                t << "<span class=\"icona\"><span class=\"icon\">N</span></span>";
            }
            else if (n->def && n->def->definitionType()==Definition::TypeClass)
            {
                t << "<span class=\"icona\"><span class=\"icon\">C</span></span>";
            }
            else
            {
                t << "<span id=\"img_" << generateIndentLabel(n,0)
                  << "\" class=\"iconf"
                  << (nodeOpened?"open":"closed")
                  << "\" onclick=\"toggleFolder('" << generateIndentLabel(n,0)
                  << "')\">&#160;</span>";
            }
            generateLink(t,n);
            t << "</td><td class=\"desc\">";
            if (n->def)
            {
                generateBriefDoc(t,n->def);
            }
            t << "</td></tr>" << endl;
            folderId++;
            generateTree(t,n->children,level+1,maxLevel,index);
        }
        else // leaf node
        {
            FileDef *srcRef=0;
            if (n->def && n->def->definitionType()==Definition::TypeFile &&
                    ((FileDef*)n->def)->generateSourceFile())
            {
                srcRef = (FileDef*)n->def;
            }
            if (srcRef)
            {
                t << "<a href=\"" << srcRef->getSourceFileBase()
                  << Doxygen::htmlFileExtension
                  << "\">";
            }
            if (n->def && n->def->definitionType()==Definition::TypeGroup)
            {
                // no icon
            }
            else if (n->def && n->def->definitionType()==Definition::TypePage)
            {
                // no icon
            }
            else if (n->def && n->def->definitionType()==Definition::TypeNamespace)
            {
                t << "<span class=\"icona\"><span class=\"icon\">N</span></span>";
            }
            else if (n->def && n->def->definitionType()==Definition::TypeClass)
            {
                t << "<span class=\"icona\"><span class=\"icon\">C</span></span>";
            }
            else
            {
                t << "<span class=\"icondoc\"></span>";
            }
            if (srcRef)
            {
                t << "</a>";
            }
            generateLink(t,n);
            t << "</td><td class=\"desc\">";
            if (n->def)
            {
                generateBriefDoc(t,n->def);
            }
            t << "</td></tr>" << endl;
        }
    }
}
Esempio n. 25
0
// write tree inside page
void FTVHelp::generateTreeViewInline(QTextStream &t, enum PageType outputType)
{
   int preferredNumEntries = Config::getInt("html-index-num-entries");

   t << "<div class=\"directory\">\n";
     
   int d = 1;
   int depth = 1;

   // adjust for display output   
   reSortNodes(m_indentNodes[0]);

   for (auto n : m_indentNodes[0] ) { 

      if (n->children.count() > 0) {
         d = n->computeTreeDepth(2);

         if (d > depth) {
            depth = d;
         }
      }
   }

   int preferredDepth = depth;

   // write level selector
   if (depth > 1) {
      t << "<div class=\"levels\">[";
      t << theTranslator->trDetailLevel();
      t << " ";

      int i;
      for (i = 1; i <= depth; i++) {
         t << "<span onclick=\"javascript:toggleLevel(" << i << ");\">" << i << "</span>";
      }

      t << "]</div>";

      if (preferredNumEntries > 0) {
         preferredDepth = 1;

         for (int i = 1; i <= depth; i++) {
            int num = 0;
           
            for (auto n : m_indentNodes[0] ) {
               num += n->numNodesAtLevel(0, i);
            }

            if (num <= preferredNumEntries) {
               preferredDepth = i;
            } else {
               break;
            }
         }
      }
   }
  
   t << "<table class=\"directory\">\n";

   int index = 0;
   generateTree(t, m_indentNodes[0], 0, preferredDepth, index, outputType);

   t << "</table>\n";
   t << "</div><!-- directory -->\n" << endl;
}
Esempio n. 26
0
void FTVHelp::generateTree(QTextStream &t, const QList<FTVNode *> &nl, int level, int maxLevel, int &index, enum PageType outputType)
{
   static bool isStyleBB = Config::getBool("bb-style"); 

   for (auto n : nl) {
      t << "<tr id=\"row_" << generateIndentLabel(n, 0) << "\"";

      if ((index & 1) == 0) { 
         // even row
         t << " class=\"even\"";
      }

      if (level >= maxLevel) { 
         // item invisible by default
         t << " style=\"display:none;\"";

      } else { 
         // item visible by default
         index++;

      }

      t << "><td class=\"entry\">";

      bool nodeOpened = level + 1 < maxLevel;
      generateIndent(t, n, nodeOpened);

      if (n->isDir) {
         if (n->def && n->def->definitionType() == Definition::TypeGroup) {
            // no icon

         } else if (n->def && n->def->definitionType() == Definition::TypePage) {
            // no icon

         } else if (n->def && n->def->definitionType() == Definition::TypeNamespace) {
            t << "<span class=\"icona\"><span class=\"icon\">N</span></span>";

         } else if (n->def && n->def->definitionType() == Definition::TypeClass) {
            t << "<span class=\"icona\"><span class=\"icon\">C</span></span>";

         } else {
            t << "<span id=\"img_" << generateIndentLabel(n, 0)
              << "\" class=\"iconf"
              << (nodeOpened ? "open" : "closed")
              << "\" onclick=\"toggleFolder('" << generateIndentLabel(n, 0)
              << "')\">&#160;</span>";
         }

         generateLink(t, n);
         t << "</td>";

         if (isStyleBB && outputType == FTVHelp::Modules) {
            // modules.html only

            QString text = n->def->getDefFileName();
            text = text.mid( text.lastIndexOf('/')+1 ); 

            t << "<td class=\"hint\">";
            t << text;
            t << "</td>";
         }

         // brief description   
         t << "<td class=\"desc\">";

         if (n->def) {
            generateBriefDoc(t, n->def);
         } 
         
         t << "</td></tr>" << endl;

         folderId++;
         generateTree(t, n->children, level + 1, maxLevel, index, outputType);

      } else {   
         // leaf node
         QSharedPointer<FileDef> srcRef;

         if (n->def && n->def->definitionType() == Definition::TypeFile && (n->def.dynamicCast<FileDef>())->generateSourceFile()) {
            srcRef = n->def.dynamicCast<FileDef>();
         }

         if (srcRef) {
            t << "<a href=\"" << srcRef->getSourceFileBase()
              << Doxy_Globals::htmlFileExtension
              << "\">";
         }

         if (n->def && n->def->definitionType() == Definition::TypeGroup) {
            // no icon

         } else if (n->def && n->def->definitionType() == Definition::TypePage) {
            // no icon

         } else if (n->def && n->def->definitionType() == Definition::TypeNamespace) {
            t << "<span class=\"icona\"><span class=\"icon\">N</span></span>";

         } else if (n->def && n->def->definitionType() == Definition::TypeClass) {
            t << "<span class=\"icona\"><span class=\"icon\">C</span></span>";

         } else {
            t << "<span class=\"icondoc\"></span>";
         }

         if (srcRef) {
            t << "</a>";
         }

         generateLink(t, n);
         t << "</td>";

         if (isStyleBB && outputType == FTVHelp::Modules) {
            // modules.html only

            QString text = n->def->getDefFileName();
            text = text.mid( text.lastIndexOf('/')+1 ); 

            t << "<td class=\"hint\">";
            t << text;
            t << "</td>";
         }

         // brief description 
         t << "<td class=\"desc\">";

         if (n->def) {
            generateBriefDoc(t, n->def);
         }

         t << "</td></tr>" << endl;
      }
   }
}
Esempio n. 27
0
////////////////////////////////////////////////////////////////////////////////
/// CChanceTreeView::setupToolBar
///
/// @description  This function initializes the toolbar that is used for the
///               tree view.
/// @pre          None
/// @post         The tree view toolbar is initialized.
///
/// @limitations  None
///
////////////////////////////////////////////////////////////////////////////////
void CChanceTreeView::setupToolBar()
{
    QAction *tempAction;
    QLabel *tempLabel;
    QToolButton *tempButton;
    // Create toolbar.
    m_toolBar = new QToolBar( "Puzzle View", this );
    
    tempAction = m_toolBar->addAction( QIcon(":/toggleminmaxheuristics.png"),
                                       "Toggle min/max heuristic values" );
    tempAction->setCheckable( true );
    tempAction->setChecked( true );
    connect( tempAction, SIGNAL(toggled(bool)), m_graphView,
             SLOT(toggleMinMaxHeuristics(bool)) );
    
    tempAction = m_toolBar->addAction( QIcon(":/togglechanceheuristics.png"),
                                       "Toggle chance heuristic values" );
    tempAction->setCheckable( true );
    tempAction->setChecked( true );
    connect( tempAction, SIGNAL(toggled(bool)), m_graphView,
             SLOT(toggleChanceHeuristics(bool)) );

    // "Reorient View" button
    tempAction = m_toolBar->addAction( QIcon(":/orient.png"), "Reorient view" );
    connect( tempAction, SIGNAL(activated()), this, SLOT(switchOrientation()) );

    // "Show Graph" toggle button
    tempAction = m_toolBar->addAction( QIcon(":/graph.png"), "Show Graph" );
    tempAction->setCheckable( true );
    tempAction->setChecked( true );
    connect( tempAction, SIGNAL(toggled(bool)), m_graphView,
             SLOT(setShown(bool)) );

    // "Show Trace" toggle button
    tempAction = m_toolBar->addAction(QIcon(":/trace.png"), "Show Trace" );
    tempAction->setCheckable( true );
    tempAction->setChecked( true );
    connect( tempAction, SIGNAL(toggled(bool)), m_traceView,
             SLOT(setShown(bool)) );

    m_toolBar->addSeparator();

    // "Quick Edit Mode" toggle button
    m_quickEditAction = m_toolBar->addAction(QIcon(":/quickedit.png"),
                                      "Toggle Quick Edit Mode" );
    m_quickEditAction->setCheckable( true );
    m_quickEditAction->setChecked( false );
    connect( m_quickEditAction, SIGNAL(toggled(bool)), m_graphView,
             SLOT(setQuickEdit(bool)) );

    // "Generate Tree" button
    tempAction = m_toolBar->addAction(QIcon(":/graph.png"), "Generate Tree" );
    connect( tempAction, SIGNAL(activated()), m_graphView, SLOT(generateTree()) );

    // "Auto Name" button
    tempAction = m_toolBar->addAction(QIcon(":/autoname.png"), "Auto Name" );
    connect( tempAction, SIGNAL(activated()), m_graphView, SLOT(autoName()) );

    // "Auto Number" button
    tempAction = m_toolBar->addAction(QIcon(":/autonumber.png"), "Auto Number" );
    connect( tempAction, SIGNAL(activated()), m_graphView, SLOT(autoNumber()) );

    // "Auto Layout" button
    tempAction = m_toolBar->addAction(QIcon(":/autolayout.png"), "Auto Layout");
    connect( tempAction, SIGNAL(activated()), m_graphView, SLOT(autoLayout()) );

    m_toolBar->addSeparator();
    

    
    m_toolBar->addSeparator();

    // "AI Config Menu" button
    m_toolBar->addWidget(m_traceView->getAIConfigButton());

    // AI Label
    tempLabel = m_traceView->getAILabel();
    m_toolBar->addWidget( tempLabel );

    // Depth spinbox
    tempLabel = new QLabel( m_toolBar );
    tempLabel->setTextFormat(Qt::AutoText);
    tempLabel->setText( "  Depth" );
    m_toolBar->addWidget( tempLabel );
    m_toolBar->addWidget( m_traceView->getDepthSelector() );

    // QS Depth spinbox
    tempLabel = new QLabel( m_toolBar );
    tempLabel->setText( "  QS Depth" );
    m_toolBar->addWidget( tempLabel );
    m_toolBar->addWidget( m_traceView->getQSDepthSelector() );

    // Lower Bound spinbox
    tempLabel = new QLabel( m_toolBar );
    tempLabel->setText( "  Lower Bound" );
    m_toolBar->addWidget( tempLabel );
    m_toolBar->addWidget( m_traceView->getLowerBoundSelector() );

    // Upper Bound spinbox
    tempLabel = new QLabel( m_toolBar );
    tempLabel->setText( "  Upper Bound" );
    m_toolBar->addWidget( tempLabel );
    m_toolBar->addWidget( m_traceView->getUpperBoundSelector() );

    // "Save Trace" button
    tempAction = m_toolBar->addAction(QIcon(":/latex.png"), "Save Trace");
    connect( tempAction, SIGNAL(activated()), m_traceView, SLOT(saveTrace()) );
}
Esempio n. 28
0
void FTVHelp::generateTreeView(QString* OutString)
{
  QCString fileName;
  QFile f;
  static bool searchEngine = Config_getBool("SEARCHENGINE");
  
  generateTreeViewImages();
  
  // If top level index, generate alternative index.html as a frame
  if (m_topLevelIndex)
  {
    fileName=Config_getString("HTML_OUTPUT")+"/index"+Doxygen::htmlFileExtension;
    f.setName(fileName);
    if (!f.open(IO_WriteOnly))
    {
      err("Cannot open file %s for writing!\n",fileName.data());
      return;
    }
    else
    {
      QTextStream t(&f);
#if QT_VERSION >= 200
      t.setEncoding(QTextStream::UnicodeUTF8);
#endif
      //t << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n";
      t << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
      t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n";
      t << "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/>\n";
      t << "<title>"; 
      if (Config_getString("PROJECT_NAME").isEmpty())
      {
        t << "Doxygen Documentation";
      }
      else
      {
        t << Config_getString("PROJECT_NAME");
      }
      t << "</title>\n</head>" << endl;
      t << "<frameset cols=\"" << Config_getInt("TREEVIEW_WIDTH") << ",*\">" << endl;
      t << "  <frame src=\"tree" << Doxygen::htmlFileExtension << "\" name=\"treefrm\"/>" << endl;
      t << "  <frame src=\"main" << Doxygen::htmlFileExtension << "\" name=\"basefrm\"/>" << endl;
      t << "  <noframes>" << endl;
      t << "    <body>" << endl;
      t << "    <a href=\"main" << Doxygen::htmlFileExtension << "\">Frames are disabled. Click here to go to the main page.</a>" << endl;
      t << "    </body>" << endl;
      t << "  </noframes>" << endl;
      t << "</frameset>" << endl;
      t << "</html>" << endl;
      f.close();
    }
  }

  // Generate tree view
  if (!OutString)
    OutString = new QString;
  QTextOStream t(OutString);
  t.setEncoding(QTextStream::UnicodeUTF8);

  if (m_topLevelIndex)
  {
    if (searchEngine)
    {
      t << "<!-- This comment will put IE 6, 7 and 8 in quirks mode -->" << endl;
    }
    t << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    t << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
    t << "  <head>\n";
    t << "    <meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n";
    t << "    <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n";
    t << "    <meta http-equiv=\"Content-Language\" content=\"en\" />\n";
    if (searchEngine)
    {
      t << "    <link href=\"search/search.css\" rel=\"stylesheet\" type=\"text/css\"/>" << endl;
      t << "    <script type=\"text/javaScript\" src=\"search/search.js\"></script>" << endl;
    }
    t << "    <link rel=\"stylesheet\" href=\"";
    QCString cssname=Config_getString("HTML_STYLESHEET");
    if (cssname.isEmpty())
    {
      t << "doxygen.css";
    }
    else
    {
      QFileInfo cssfi(cssname);
      if (!cssfi.exists())
      {
        err("Error: user specified HTML style sheet file does not exist!\n");
      }
      t << cssfi.fileName();
    }
    t << "\"/>" << endl;
    t << "    <title>TreeView</title>\n";
  }
  t << "    <script type=\"text/javascript\">\n";
  t << "    <!-- // Hide script from old browsers\n";
  t << "    \n";

  /* User has clicked on a node (folder or +/-) in the tree */
  t << "    function toggleFolder(id, imageNode) \n";
  t << "    {\n";
  t << "      var folder = document.getElementById(id);\n";
  t << "      var l = imageNode.src.length;\n";
  /* If the user clicks on the book icon, we move left one image so 
   * the code (below) will also adjust the '+' icon. 
   */
  t << "      if (imageNode.src.substring(l-20,l)==\"" FTV_ICON_FILE(folderclosed) "\" || \n";
  t << "          imageNode.src.substring(l-18,l)==\"" FTV_ICON_FILE(folderopen)  "\")\n";
  t << "      {\n";
  t << "        imageNode = imageNode.previousSibling;\n";
  t << "        l = imageNode.src.length;\n";
  t << "      }\n";
  t << "      if (folder == null) \n";
  t << "      {\n";
  t << "      } \n";
  /* Node controls a open section, we need to close it */
  t << "      else if (folder.style.display == \"block\") \n";
  t << "      {\n";
  t << "        if (imageNode != null) \n";
  t << "        {\n";
  t << "          imageNode.nextSibling.src = \"" FTV_ICON_FILE(folderclosed) "\";\n";
  t << "          if (imageNode.src.substring(l-13,l) == \"" FTV_ICON_FILE(mnode) "\")\n";
  t << "          {\n";
  t << "            imageNode.src = \"" FTV_ICON_FILE(pnode) "\";\n";
  t << "          }\n";
  t << "          else if (imageNode.src.substring(l-17,l) == \"" FTV_ICON_FILE(mlastnode) "\")\n";
  t << "          {\n";
  t << "            imageNode.src = \"" FTV_ICON_FILE(plastnode) "\";\n";
  t << "          }\n";
  t << "        }\n";
  t << "        folder.style.display = \"none\";\n";
  t << "      } \n";
  t << "      else \n"; /* section is closed, we need to open it */
  t << "      {\n";
  t << "        if (imageNode != null) \n";
  t << "        {\n";
  t << "          imageNode.nextSibling.src = \"" FTV_ICON_FILE(folderopen) "\";\n";
  t << "          if (imageNode.src.substring(l-13,l) == \"" FTV_ICON_FILE(pnode) "\")\n";
  t << "          {\n";
  t << "            imageNode.src = \"" FTV_ICON_FILE(mnode) "\";\n";
  t << "          }\n";
  t << "          else if (imageNode.src.substring(l-17,l) == \"" FTV_ICON_FILE(plastnode) "\")\n";
  t << "          {\n";
  t << "            imageNode.src = \"" FTV_ICON_FILE(mlastnode) "\";\n";
  t << "          }\n";
  t << "        }\n";
  t << "        folder.style.display = \"block\";\n";
  t << "      }\n";
  t << "    }\n";
  t << "\n";
  t << "    // End script hiding -->        \n";
  t << "    </script>\n";
  if (m_topLevelIndex)
  {
    t << "  </head>\n";
    t << "\n";
    t << "  <body class=\"ftvtree\"";
    if (searchEngine)
    {
      t << " onload='searchBox.OnSelectItem(0);'";
    }
    t << ">\n";
    if (searchEngine)
    {
      t << "      <script type=\"text/javascript\"><!--\n";
      t << "      var searchBox = new SearchBox(\"searchBox\", \"search\", true);\n";
      t << "      --></script>\n";
      t << "      <div id=\"MSearchBox\" class=\"MSearchBoxInactive\">\n";
      t << "      <div class=\"MSearchBoxRow\"><span class=\"MSearchBoxLeft\">\n";
      t << "      <input type=\"text\" id=\"MSearchField\" value=\"Search\" \n";
      t << "           onfocus=\"searchBox.OnSearchFieldFocus(true)\" \n";
      t << "           onblur=\"searchBox.OnSearchFieldFocus(false)\" \n";
      t << "           onkeyup=\"searchBox.OnSearchFieldChange()\"/>\n";
      t << "      </span><span class=\"MSearchBoxRight\">\n";
      t << "      <img id=\"MSearchSelect\" src=\"search/search.png\"\n";
      t << "           onmouseover=\"return searchBox.OnSearchSelectShow()\"\n";
      t << "           onmouseout=\"return searchBox.OnSearchSelectHide()\"\n";
      t << "           alt=\"\"/>\n";
      t << "      </span></div><div class=\"MSearchBoxSpacer\">&nbsp;</div>\n";
      t << "      </div>\n";
      HtmlGenerator::writeSearchFooter(t,QCString());
    }
    t << "    <div class=\"directory\">\n";
    t << "      <h3 class=\"swap\"><span>";
    QCString &projName = Config_getString("PROJECT_NAME");
    if (projName.isEmpty())
    {
      t << "Root";
    }
    else
    {
      t << projName;
    }
    t << "</span></h3>\n";
  }
  else
  {
    t << "    <div class=\"directory-alt\">\n";
    t << "      <br/>\n";
  }
  t << "      <div style=\"display: block;\">\n";

  generateTree(t,m_indentNodes[0],0);

  t << "      </div>\n";
  t << "    </div>\n";
  
  if (m_topLevelIndex)
  {
    t << "  </body>\n";
    t << "</html>\n";
  }
  
  if (m_topLevelIndex)
  {
    fileName=Config_getString("HTML_OUTPUT")+"/tree"+Doxygen::htmlFileExtension;
    f.setName(fileName);
    if (!f.open(IO_WriteOnly))
    {
      err("Cannot open file %s for writing!\n",fileName.data());
      return;
    }
    else
    {
      QTextStream t(&f);
      t.setEncoding(QTextStream::UnicodeUTF8);
      t << *OutString << endl;
      f.close();
    }
  }
}
Esempio n. 29
0
// Generate trees
void generateAll() {
   std::string const dir = "./trees";
   generateTree("Tree", dir);
   generateTreeStruct("TreeStruct", dir);
}
Esempio n. 30
0
void Sentinel::think()
{	
	switch( m_behaviourState )
	{
		case ENEMY_SEARCHING:
			
			if ( playerInVisibleSector() )
			{
				if ( playersHeadIsVisible() )
				{
					m_behaviourState = ENEMY_SEES_PLAYER;
					turnTimer.start();
					objectAbsorbTimer.start();
					break;
				}
				else if ( playersSquareIsVisible() )
				{
					// TO DO: create a meanie if I can, near the player.
					// once that is done, no more meanies can be created until the
					// player moves square.
					
					
				}
			}
			
			if ( m_energy > m_initialEnergy + Tree::getInitialEnergy() && \
				 treeGenerationTimer.time() > SENTINEL_MIN_TIME_BETWEEN_TREE_GENERATION_EVENTS )
			{
				// create a tree to re-distribute what I absorbed
				treeGenerationTimer.start();
				generateTree();
			}
			
			if ( wishToAbsorbAnObject() && objectsVisible() )
			{
				m_behaviourState = ENEMY_ABSORBING_OBJECT;
				chooseObjectToAbsorb();
				turnTimer.start();
				objectAbsorbTimer.start();
				break;
			}
			
			rotate();
			break;
			
			//TO DO: sentinel tree creation
			
		case ENEMY_SEES_PLAYER:
			
			if ( !playerInVisibleSector() || !playersHeadIsVisible() )
			{
				m_behaviourState = ENEMY_SEARCHING;
			}
			else
			{
				if ( objectAbsorbTimer.time() > SENTINEL_DELAY_BEFORE_ABSORBING )
				{
					m_behaviourState = ENEMY_ABSORBING_PLAYER;
					objectAbsorbTimer.start();
				}
			}
			break;
			
		case ENEMY_ABSORBING_PLAYER:
			
			if ( !playerInVisibleSector() || !playersHeadIsVisible() )
			{
				m_behaviourState = ENEMY_SEARCHING;
			}
			else
			{
				absorbPlayer();
				objectAbsorbTimer.start();
			}
			
			break;
			
		case ENEMY_ABSORBING_OBJECT:
			
			if ( playerInVisibleSector() && playersHeadIsVisible() )
			{
				m_behaviourState = ENEMY_ABSORBING_PLAYER;
				turnTimer.start();
				objectAbsorbTimer.start();
			}
			else
			{
				absorbObject();
			}
			break;
			
		case ENEMY_BEING_ABSORBED:
			
			break;
			
	}
	
}