//*************************************************************************************************
//! Parses a tagged TIFF image file for RPC info. Returns TRUE if successful.
//*************************************************************************************************
bool rspfQuickbirdRpcModel::parseTiffFile(const rspfFilename& file)
{
   setErrorStatus();

   // Make the gsd nan so it gets computed.
   theGSD.makeNan();

   rspfFilename tiffFile = file;
   rspfRefPtr<rspfTiffTileSource> tiff = new rspfTiffTileSource();
   if (!tiff->open(file))
   {
      return false;
   }

   theImageClipRect = tiff->getImageRectangle();

   parseMetaData(file);

   if (!parseRpcData(file))
      return false;

   if (!parseTileData(file))
      return false;

   finishConstruction();
   clearErrorStatus();
   return true;
}
//*************************************************************************************************
//! Constructor for multiple tile-files sharing common RPC model initializes given pointer
//! to multi-tile-files handler.
//*************************************************************************************************
rspfQuickbirdRpcModel::rspfQuickbirdRpcModel(const rspfQbTileFilesHandler* handler)
:  rspfRpcModel(),
   theSupportData(new rspfQuickbirdMetaData())
{
   setErrorStatus();
   if (!handler)
      return;


   // Make the gsd nan so it gets computed.
   theGSD.makeNan();

   theImageClipRect = handler->getImageRectangle();

   rspfFilename imageFile = handler->getFilename();
   if (!parseRpcData(imageFile))
      return;

   //loong
   if(!theSupportData->open(imageFile))
	   return;

   finishConstruction();
   clearErrorStatus();
   return;
}
示例#3
0
kpToolWidgetLineWidth::kpToolWidgetLineWidth (QWidget *parent, const QString &name)
    : kpToolWidgetBase (parent, name)
{
    int numLineWidths = sizeof (lineWidths) / sizeof (lineWidths [0]);

    int w = (width () - 2/*margin*/) * 3 / 4;
    int h = (height () - 2/*margin*/ - (numLineWidths - 1)/*spacing*/) * 3 / (numLineWidths * 4);

    for (int i = 0; i < numLineWidths; i++)
    {
        QImage image ((w <= 0 ? width () : w),
                        (h <= 0 ? height () : h), QImage::Format_ARGB32_Premultiplied);
        image.fill(QColor(Qt::transparent).rgba());


        kpPixmapFX::fillRect (&image,
            0, (image.height () - lineWidths [i]) / 2,
            image.width (), lineWidths [i],
            kpColor::Black);
        

        addOption (QPixmap::fromImage(image), QString::number (lineWidths [i]));
        startNewOptionRow ();
    }

    finishConstruction (0, 0);
}
kpToolWidgetSpraycanSize::kpToolWidgetSpraycanSize (QWidget *parent, const char *name)
    : kpToolWidgetBase (parent, name)
{
#if DEBUG_KP_TOOL_WIDGET_SPRAYCAN_SIZE
    kdDebug () << "kpToolWidgetSpraycanSize::kpToolWidgetSpraycanSize() CALLED!" << endl;
#endif

    for (int i = 0; i < int (sizeof (spraycanSizes) / sizeof (spraycanSizes [0])); i++)
    {
        int s = spraycanSizes [i];
        QString iconName = QString ("tool_spraycan_%1x%1").arg (s).arg(s);
        
    #if DEBUG_KP_TOOL_WIDGET_SPRAYCAN_SIZE
        kdDebug () << "\ticonName=" << iconName << endl;
    #endif

        QPixmap pixmap (s, s);
        pixmap.fill (Qt::white);
        
        QPainter painter (&pixmap);
        painter.drawPixmap (0, 0, UserIcon (iconName));
        painter.end ();

        QImage image = kpPixmapFX::convertToImage (pixmap);

        QBitmap mask (pixmap.width (), pixmap.height ());
        mask.fill (Qt::color0);

        painter.begin (&mask);
        painter.setPen (Qt::color1);
        
        for (int y = 0; y < image.height (); y++)
        {
            for (int x = 0; x < image.width (); x++)
            {
                if ((image.pixel (x, y) & RGB_MASK) == 0/*black*/)
                    painter.drawPoint (x, y);  // mark as opaque
            }
        }

        painter.end ();

        pixmap.setMask (mask);
        
        addOption (pixmap, i18n ("%1x%2").arg (s).arg (s)/*tooltip*/);
        if (i == 1)
            startNewOptionRow ();
    }

    finishConstruction (0, 0);
}
示例#5
0
kpToolWidgetFillStyle::kpToolWidgetFillStyle (QWidget *parent, const QString &name)
    : kpToolWidgetBase (parent, name)
{
    for (int i = 0; i < (int) FillStyleNum; i++)
    {
        QPixmap pixmap;

        pixmap = fillStylePixmap ((FillStyle) i,
                                  (width () - 2/*margin*/) * 3 / 4,
                                  (height () - 2/*margin*/ - 2/*spacing*/) * 3 / (3 * 4));
        addOption (pixmap, fillStyleName ((FillStyle) i)/*tooltip*/);

        startNewOptionRow ();
    }

    finishConstruction (0, 0);
}
示例#6
0
/**
 * Finish setting up the dialog; add ok and/or cancel buttons, set minimum
 * dimensions if appropriate, set the layout, etc.  Called near the end of
 * most subclass constructors.
 *
 * @param okButton True if the dialog includes an "OK" button
 * @param cancelButton True if the dialog contains a "Cancel" button
 * @param minWidth Minimum width in pixels.  If 0 or -1, don't set a minimum.
 * @param minHeight Minimum height in pixels.  If 0 or -1, don't set a minimum.
 * @return The widget containing the OK/Cancel buttons, 0 if not added
 */
QDialogButtonBox *PBDialog::finishLayout(bool okButton, bool cancelButton,
                                         int minWidth, int minHeight)
{
    QDialogButtonBox *okCancelRow = 0;
    okCancelRow = addOkCancelButtons(static_cast<QBoxLayout *>(layout()),
                                     okButton, cancelButton);
#if defined(Q_WS_HILDON) || defined(Q_WS_MAEMO_5)
    if (addButton) {
        okCancelRow->addButton(addButton, QDialogButtonBox::ActionRole);
        okCancelRow->addButton(editButton, QDialogButtonBox::ActionRole);
        okCancelRow->addButton(deleteButton, QDialogButtonBox::ActionRole);
    }
    if (upButton) {
        okCancelRow->addButton(upButton, QDialogButtonBox::ActionRole);
        okCancelRow->addButton(downButton, QDialogButtonBox::ActionRole);
    }
#endif
    finishConstruction(minWidth, minHeight);
    return okCancelRow;
}
//*************************************************************************************************
//! Constructor for multiple tile-files sharing common RPC model initializes given pointer
//! to multi-tile-files handler.
//*************************************************************************************************
ossimQuickbirdRpcModel::ossimQuickbirdRpcModel(const ossimQbTileFilesHandler* handler)
:  ossimRpcModel(),
   theSupportData(0)
{
   setErrorStatus();
   if (!handler)
      return;

   // Make the gsd nan so it gets computed.
   theGSD.makeNan();

   theImageClipRect = handler->getImageRectangle();

   ossimFilename imageFile = handler->getFilename();
   if (!parseRpcData(imageFile))
      return;

   finishConstruction();
   clearErrorStatus();
   return;
}
示例#8
0
WidgetColor::WidgetColor (QWidget *parent, const QString &name)
    : WidgetBase (parent, name)
{
    const int w = (width () - 2 /*margin*/ - 2 /*spacing*/) / 3;
    const int h = (height () - 2 /*margin*/ - 3 /*spacing*/) / 3;

    for (unsigned int color = 0; color < sizeof(ColorTable) / sizeof(int); color++)
    {
        QImage previewPixmap (w, h, QImage::Format_ARGB32);
        previewPixmap.fill(Qt::transparent);
        QPainter painter(&previewPixmap);
        painter.fillRect(2,2,previewPixmap.width() - 4,previewPixmap.height() - 4,ColorTable1[color]);

        addOption (QPixmap::fromImage(previewPixmap), colorName (color) /*tooltip*/);

        if (color % 3 == 2)
            startNewOptionRow ();
    }

    finishConstruction (0, 0);
}
kpToolWidgetLineWidth::kpToolWidgetLineWidth (QWidget *parent, const char *name)
    : kpToolWidgetBase (parent, name)
{
    setInvertSelectedPixmap ();

    int numLineWidths = sizeof (lineWidths) / sizeof (lineWidths [0]);

    int w = (width () - 2/*margin*/) * 3 / 4;
    int h = (height () - 2/*margin*/ - (numLineWidths - 1)/*spacing*/) * 3 / (numLineWidths * 4);

    for (int i = 0; i < numLineWidths; i++)
    {
        QPixmap pixmap ((w <= 0 ? width () : w),
                        (h <= 0 ? height () : h));
        pixmap.fill (Qt::white);

        QBitmap maskBitmap (pixmap.width (), pixmap.height ());
        maskBitmap.fill (Qt::color0/*transparent*/);
        
        
        QPainter painter (&pixmap), maskPainter (&maskBitmap);
        painter.setPen (Qt::black), maskPainter.setPen (Qt::color1/*opaque*/);
        painter.setBrush (Qt::black), maskPainter.setBrush (Qt::color1/*opaque*/);

        QRect rect = QRect (0, (pixmap.height () - lineWidths [i]) / 2,
                            pixmap.width (), lineWidths [i]);
        painter.drawRect (rect), maskPainter.drawRect (rect);

        painter.end (), maskPainter.end ();
        
        
        pixmap.setMask (maskBitmap);

        addOption (pixmap, QString::number (lineWidths [i]));
        startNewOptionRow ();
    }

    finishConstruction (0, 0);
}
示例#10
0
//*****************************************************************************
//  CONSTRUCTOR: ossimIkonosRpcModel
//  
//  Constructs given filenames for metadata and RPC data.
//  
//*****************************************************************************
ossimIkonosRpcModel::ossimIkonosRpcModel(const ossimFilename& metadata,
                                         const ossimFilename& rpcdata)
   :
   ossimRpcModel(),
   theSupportData(0)
{
   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #2: entering..." << std::endl;

   theSupportData = new ossimIkonosMetaData();

   parseMetaData(metadata);
   parseRpcData (rpcdata);
   finishConstruction();

   //***
   // Save current state in RPC model format:
   //***
   ossimString drivePart;
   ossimString pathPart;
   ossimString filePart;
   ossimString extPart;
   metadata.split(drivePart,
                  pathPart,
                  filePart,
                  extPart);
   
   ossimFilename init_rpc_geom;
   init_rpc_geom.merge(drivePart,
                       pathPart,
                       INIT_RPC_GEOM_FILENAME,
                       "");
//      (metadata.path().dirCat(ossimRpcModel::INIT_RPC_GEOM_FILENAME));
   ossimKeywordlist kwl (init_rpc_geom);
   saveState(kwl);
   
   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #2: returning..." << std::endl;
}
//*************************************************************************************************
//! Parses a NITF image file for RPC info. Returns TRUE if successful.
//*************************************************************************************************
bool rspfQuickbirdRpcModel::parseNitfFile(const rspfFilename& file)
{
   setErrorStatus();
   rspfFilename nitfFile = file;
   
   rspfRefPtr<rspfNitfFile> nitfFilePtr = new rspfNitfFile;
   
   if(!nitfFilePtr->parseFile(nitfFile))
   {
      nitfFile = nitfFile.setExtension("NTF");
      if(!nitfFilePtr->parseFile(nitfFile))
      {
         nitfFile = nitfFile.setExtension("ntf");
         if(!nitfFilePtr->parseFile(nitfFile))
            return false;
      }
   }
   
   rspfRefPtr<rspfNitfImageHeader> ih = nitfFilePtr->getNewImageHeader(0);
   if (!ih)
      return false;

   theImageClipRect = ih->getImageRect();
 
   // Give preference to external RPC data file:
   bool useInternalRpcTags = false;
   if(!parseRpcData(file))
      useInternalRpcTags = true;
   
   if (!parseTileData(file))
      return false;
  
   // Check for IMD (metadata) file:
   parseMetaData(file);

   // Get the gsd.
   theGSD.line = rspf::nan();
   theGSD.samp = rspf::nan();
   
   rspfRefPtr<rspfNitfRegisteredTag> tag;
   tag = ih->getTagData(PIAIMC_TAG);
   if (tag.valid())
   {
      rspfNitfPiaimcTag* p = PTR_CAST(rspfNitfPiaimcTag, tag.get());
      if (p)
      {
         theGSD.line = p->getMeanGsdInMeters();
         theGSD.samp = theGSD.line;
      }
   }
   if (rspf::isnan(theGSD.line))
   {
      tag = ih->getTagData(USE00A_TAG);
      if (tag.valid())
      {
         rspfNitfUse00aTag* p = PTR_CAST(rspfNitfUse00aTag, tag.get());
         if (p)
         {
            theGSD.line = p->getMeanGsdInMeters();
            theGSD.samp = theGSD.line;
         }
      }
   }

   // If external RPC data file was correctly parsed, then we can bypass this code block. Otherwise
   // need to parse internal NITF tags for RPC data:
   if (useInternalRpcTags)
   {
      // Get the the RPC tag:
      rspfNitfRpcBase* rpcTag = NULL;
      
      // Look for the RPC00B tag first.
      tag = ih->getTagData(RPC00B_TAG);
      if (tag.valid())
         rpcTag = PTR_CAST(rspfNitfRpcBase, tag.get());
      
      if (!tag.valid())
      {
         // Look for RPC00A tag.
         tag = ih->getTagData(RPC00A_TAG);
         if (tag.valid())
            rpcTag = PTR_CAST(rspfNitfRpcBase, tag.get());
      }
      
      if (!rpcTag)
         return false;
      
      // Set the polynomial type.
      if (rpcTag->getRegisterTagName() == "RPC00B")
         thePolyType = B;
      else
         thePolyType = A;

      // Parse coefficients:
      for (rspf_uint32 i=0; i<20; ++i)
      {
         theLineNumCoef[i] = rpcTag->getLineNumeratorCoeff(i).toFloat64();
         theLineDenCoef[i] = rpcTag->getLineDenominatorCoeff(i).toFloat64();
         theSampNumCoef[i] = rpcTag->getSampleNumeratorCoeff(i).toFloat64();
         theSampDenCoef[i] = rpcTag->getSampleDenominatorCoeff(i).toFloat64();
      }

      // Initialize other items in tags:
      theLineScale  = rpcTag->getLineScale().toFloat64();
      theSampScale  = rpcTag->getSampleScale().toFloat64();
      theLatScale   = rpcTag->getGeodeticLatScale().toFloat64();
      theLonScale   = rpcTag->getGeodeticLonScale().toFloat64();
      theHgtScale   = rpcTag->getGeodeticHeightScale().toFloat64();
      theLineOffset = rpcTag->getLineOffset().toFloat64();
      theSampOffset = rpcTag->getSampleOffset().toFloat64();
      theLatOffset  = rpcTag->getGeodeticLatOffset().toFloat64();
      theLonOffset  = rpcTag->getGeodeticLonOffset().toFloat64();
      theHgtOffset  = rpcTag->getGeodeticHeightOffset().toFloat64();
      theImageID    = ih->getImageId();
   }

   finishConstruction();
   clearErrorStatus();
   return true;
}
void HarfBuzzFont::doOpenSingleData(const Containers::ArrayReference<const unsigned char> data, const Float size) {
    FreeTypeFont::doOpenSingleData(data, size);
    if(!FreeTypeFont::doIsOpened()) return;

    finishConstruction();
}
void HarfBuzzFont::doOpenFile(const std::string& filename, const Float size) {
    FreeTypeFont::doOpenFile(filename, size);
    if(!FreeTypeFont::doIsOpened()) return;

    finishConstruction();
}
示例#14
0
bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename)
{
   bool result = false;
   
   ossimRefPtr<ossimTiffTileSource> tiff = new ossimTiffTileSource();

   if ( tiff->open(filename) )
   {
      if ( !theSupportData )
      {
         theSupportData = new ossimIkonosMetaData();
      }

      if ( theSupportData->open(filename) == false )
      {
         if(traceDebug())
         {
            // Currently not required by model so we will not error out here.
            ossimNotify(ossimNotifyLevel_DEBUG)
               << "WARNING: ossimIkonosMetaData::open returned false.\n"
               << std::endl;
         }
      }
      else
      {
         // copy ossimIkonosMetada-sensor into ossimIkonosRpcModel-sensorId
         theSensorID = theSupportData->getSensorID();
      }

      //convert file to rpc filename and hdr filename so we can get some info
      ossimFilename rpcfile = filename.noExtension();
      rpcfile += "_rpc.txt";
      
      ossimFilename hdrfile = filename;
      hdrfile.setExtension(ossimString("hdr"));
      
      if( parseHdrData(hdrfile) )
      {
         // parseRpcData sets the error status on error.
         parseRpcData (rpcfile);
         if ( !getErrorStatus() ) //check for errors in parsing rpc data
         {
            finishConstruction();
            
            //---
            // Save current state in RPC model format:
            //---
            ossimString drivePart;
            ossimString pathPart;
            ossimString filePart;
            ossimString extPart;
            filename.split(drivePart,
                           pathPart,
                           filePart,
                           extPart);
            
            ossimFilename init_rpc_geom;
            init_rpc_geom.merge(drivePart,
                                pathPart,
                                INIT_RPC_GEOM_FILENAME,
                                "");

            ossimKeywordlist kwl (init_rpc_geom);
            saveState(kwl);

            // If we get here set the return status to true.
            result = true;

         } // matches: if ( !getErrorStatus() )
   
      } // matches: if( parseHdrData(hdrfile) )

   } // matches:  if ( tiff->open(filename) )
   
   if ( traceExec() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "return status: " << (result?"true\n":"false\n")
         << "DEBUG ossimIkonosRpcModel parseTiffFile: returning..."
         << std::endl;
   }

   return result;
}
示例#15
0
//*****************************************************************************
//  CONSTRUCTOR: ossimIkonosRpcModel
//  
//  Constructs given a geometry file that specifies the filenames for the
//  metadata and RPC data files.
//  
//*****************************************************************************
ossimIkonosRpcModel::ossimIkonosRpcModel(const ossimFilename& geom_file)
   :  ossimRpcModel(),
      theSupportData(0)
{
   if (traceExec())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "DEBUG ossimIkonosRpcModel Constructor #1: entering..."
         << std::endl;
   }

   theSupportData = new ossimIkonosMetaData();
   
   ossimKeywordlist kwl(geom_file);
   const char* value;
   
   //***
   // Assure this keywordlist contains correct type info:
   //***
   value = kwl.find(ossimKeywordNames::TYPE_KW);
   if (!value || (strcmp(value, "ossimIkonosRpcModel")))
   {
      if (traceDebug())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << "DEBUG  ossimIkonosRpcModel Constructor #1:"
            << "\nFailed attempt to construct. sensor type \""<<value
            << "\" does not match \"ossimIkonosRpcModel\"." << std::endl;
      }

      theErrorStatus++;
      if (traceExec())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << "DEBUG  ossimIkonosRpcModel Constructor #1: returning..."
            << std::endl;
      }
      return;
   }

   //***
   // Read meta data filename from geom file:
   //***
   value = kwl.find(META_DATA_FILE);
   if (!value)
   {
      theErrorStatus++;
      if (traceExec())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << "DEBUG ossimIkonosRpcModel Constructor #1: returning..."
            << std::endl;
      }
      return;
   }

   ossimFilename metadata (value);

   //***
   // Read RPC data filename from geom file:
   //***
   value = kwl.find(RPC_DATA_FILE);
   if (!value)
   {
      theErrorStatus++;
      if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG  ossimIkonosRpcModel Constructor #1: returning..." << std::endl;
      return;
   }
   ossimFilename rpcdata (value);

   parseMetaData(metadata);
   parseRpcData (rpcdata);
   finishConstruction();

   ossimString drivePart;
   ossimString pathPart;
   ossimString filePart;
   ossimString extPart;
   geom_file.split(drivePart,
                   pathPart,
                   filePart,
                   extPart);

   

   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG returning..." << std::endl;
   
   return;
}