void ossimPlanetQtLegendItem::recursiveAdd(QTreeWidgetItem* parent,
                                           const ossimRefPtr<ossimXmlNode> node)
{
   if(!node.valid())
   {
      return;
   }
   const std::vector<ossimRefPtr<ossimXmlNode> >& childNodes = node->getChildNodes();
   if(childNodes.size() == 0)
   {
      QTreeWidgetItem* item = new QTreeWidgetItem(parent);
      item->setText(0, node->getTag().c_str());
      item->setText(1, node->getText().c_str());
   }
   else
   {
      ossim_uint32 idx = 0;
      ossim_uint32 idxMax = 0;
      idxMax = childNodes.size();
      QTreeWidgetItem* item = new QTreeWidgetItem(parent);
      item->setText(0, node->getTag().c_str());
      item->setText(1, node->getText().c_str());
      for(idx = 0; idx < idxMax; ++idx)
      {         
         recursiveAdd(item, childNodes[idx]);
      }
   }
}
Esempio n. 2
0
ossimErrorCode ossimRpfFrame::parseFile(const ossimFilename& filename,
                                        bool minimalParse)
{
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimRpfFrame::parseFile: entered......" << std::endl;
   }
   ossimErrorCode result = ossimErrorCodes::OSSIM_OK;

   //Make sure any fileds have beend cleared
   clearFields();

   // Make sure all data is deleted.  The initialize call the
   // populate methods.  These methods will re-allocate the information
   deleteAll();


   theNitfFile = new ossimNitfFile;
   theNitfFile->parseFile(filename);
   
   const ossimRefPtr<ossimNitfFileHeader> nitfFileHeader =
      theNitfFile.valid() ? theNitfFile->getHeader() : 0;

   if(!nitfFileHeader)
   {
      theNitfFile = 0;

      return ossimErrorCodes::OSSIM_ERROR;
   }
   ossimNitfTagInformation info;
   nitfFileHeader->getTag(info, "RPFHDR");

   theFilename = filename;
   if(info.getTagName() == "RPFHDR")
   {
      ifstream in(filename.c_str(), ios::in|ios::binary);
      // set the get pointer for the stream to the start
      // of the Rpf header data
      in.seekg(info.getTagDataOffset(), ios::beg);

      if(theHeader) delete theHeader;
      theHeader = new ossimRpfHeader;
      
      // if(theHeader->parseStream(in) != ossimErrorCodes::OSSIM_OK)
      theHeader->parseStream(in);

      if ( in.fail() )
      {
         deleteAll();
         
         return ossimErrorCodes::OSSIM_ERROR;
      }
      else
         // if(!in.fail()&&theHeader)
      {
         result = populateAttributeSection(in);

         // This is needed for ossim-rpf --list-frames so NOT put in full parse section.
         if(!in.fail()&&(result == ossimErrorCodes::OSSIM_OK))
         {
            result = populateReplaceUpdateTable(in);
         }

         if ( minimalParse == false )
         {
            if(!in.fail()&&(result == ossimErrorCodes::OSSIM_OK))
            {
               populateCompressionSection(in);
            }
            if(!in.fail()&&(result == ossimErrorCodes::OSSIM_OK))
            {
               result = populateCoverageSection(in);
            }
            if(!in.fail()&&(result == ossimErrorCodes::OSSIM_OK))
            {
               result = populateImageSection(in);
            }
            if(!in.fail()&&(result == ossimErrorCodes::OSSIM_OK))
            {
               result = populateColorGrayscaleSection(in);
            }
            if(!in.fail()&&(result == ossimErrorCodes::OSSIM_OK))
            {
               result = populateMasks(in);
            }
         }
      }
   }
   else
   {
      return ossimErrorCodes::OSSIM_ERROR;
   }

   return ossimErrorCodes::OSSIM_OK;
}