Пример #1
0
void ExportDlg::updateFromFile(const QString& strFilename)
{
   FileDescriptor* pFileDescriptor = mpExporter->getFileDescriptor();
   if (pFileDescriptor != NULL)
   {
      string filename;
      if (strFilename.isEmpty() == false)
      {
         QFileInfo fileInfo(strFilename);
         if (fileInfo.isDir() == false)
         {
            filename = fileInfo.absoluteFilePath().toStdString();
         }
      }

      pFileDescriptor->setFilename(filename);
   }
}
Пример #2
0
bool CreateExportFileDescriptor::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   StepResource pStep("Execute Wizard Item", "app", "E15CA38D-02CD-464B-8412-C0937D05A1FB");
   pStep->addProperty("Item", getName());
   mpStep = pStep.get();

   if (extractInputArgs(pInArgList) == false)
   {
      return false;
   }

   VERIFY(mpFilename != NULL);

   // Create a file descriptor with the values in the element's data descriptor
   FileDescriptor* pFileDescriptor = NULL;
   if (mpElement != NULL)
   {
      const RasterDataDescriptor* pRasterDescriptor =
         dynamic_cast<const RasterDataDescriptor*>(mpElement->getDataDescriptor());
      if (pRasterDescriptor != NULL)
      {
         // Start row
         DimensionDescriptor startRow;
         if (mpStartRow != NULL)
         {
            startRow = pRasterDescriptor->getOriginalRow(*mpStartRow - 1);
         }

         // End row
         DimensionDescriptor endRow;
         if (mpEndRow != NULL)
         {
            endRow = pRasterDescriptor->getOriginalRow(*mpEndRow - 1);
         }

         // Row skip
         unsigned int rowSkip = 0;
         if (mpRowSkipFactor != NULL)
         {
            rowSkip = *mpRowSkipFactor;
         }

         // Start column
         DimensionDescriptor startColumn;
         if (mpStartColumn != NULL)
         {
            startColumn = pRasterDescriptor->getOriginalColumn(*mpStartColumn - 1);
         }

         // End column
         DimensionDescriptor endColumn;
         if (mpEndColumn != NULL)
         {
            endColumn = pRasterDescriptor->getOriginalColumn(*mpEndColumn - 1);
         }

         // Column skip
         unsigned int columnSkip = 0;
         if (mpColumnSkipFactor != NULL)
         {
            columnSkip = *mpColumnSkipFactor;
         }

         // Start band
         DimensionDescriptor startBand;
         if (mpStartBand != NULL)
         {
            startBand = pRasterDescriptor->getOriginalBand(*mpStartBand - 1);
         }

         // End band
         DimensionDescriptor endBand;
         if (mpEndBand != NULL)
         {
            endBand = pRasterDescriptor->getOriginalBand(*mpEndBand - 1);
         }

         // Band skip
         unsigned int bandSkip = 0;
         if (mpBandSkipFactor != NULL)
         {
            bandSkip = *mpBandSkipFactor;
         }

         pFileDescriptor = RasterUtilities::generateFileDescriptorForExport(pRasterDescriptor,
            mpFilename->getFullPathAndName(), startRow, endRow, rowSkip, startColumn, endColumn, columnSkip,
            startBand, endBand, bandSkip);
      }
   }

   // Create a file descriptor with the input filename
   if (pFileDescriptor == NULL)
   {
      FactoryResource<FileDescriptor> pFactoryFileDescriptor;
      pFileDescriptor = pFactoryFileDescriptor.release();

      if (pFileDescriptor != NULL)
      {
         pFileDescriptor->setFilename(mpFilename->getFullPathAndName());
      }
   }

   if (pFileDescriptor == NULL)
   {
      reportError("Could not create the file descriptor!", "219F9340-1681-4BD8-90B4-2D9335E8B751");
      return false;
   }

   // Set the output arg value
   if (pOutArgList != NULL)
   {
      PlugInArg* pArg = NULL;

      // File descriptor
      if (pOutArgList->getArg("File Descriptor", pArg) && (pArg != NULL))
      {
         pArg->setActualValue(pFileDescriptor);
      }
      else
      {
         // Destroy the file descriptor
         Service<ApplicationServices> pApp;
         if (pApp.get() != NULL)
         {
            ObjectFactory* pObjFact = pApp->getObjectFactory();
            if (pObjFact != NULL)
            {
               pObjFact->destroyObject(pFileDescriptor, "FileDescriptor");
            }
         }

         reportError("Could not set the file descriptor output value!", "98FB7EB3-BC2A-4075-9DE2-FD28ABAECE5B");
         return false;
      }
   }

   reportComplete();
   return true;
}