当前位置: 首页>>代码示例>>C++>>正文


C++ SpatialDataView类代码示例

本文整理汇总了C++中SpatialDataView的典型用法代码示例。如果您正苦于以下问题:C++ SpatialDataView类的具体用法?C++ SpatialDataView怎么用?C++ SpatialDataView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SpatialDataView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: progress

bool ChangeUpDirection::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   ProgressTracker progress(pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()),
      "Rotating data.", "app", "{11adadb9-c133-49de-8cf5-a16372da2578}");

   RasterElement* pData = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());
   if (pData == NULL)
   {
      progress.report("No data element specified.", 0, ERRORS, true);
      return false;
   }
   bool display = false;
   if (!pInArgList->getPlugInArgValue("Display Results", display))
   {
      progress.report("Unsure if results should be displayed. Invalid argument.", 0, ERRORS, true);
      return false;
   }
   double rotation = 0.0;
   SpatialDataView* pOrigView = NULL;
   if (isBatch())
   {
      if (!pInArgList->getPlugInArgValue("Rotation", rotation))
      {
         progress.report("No rotation specified.", 0, ERRORS, true);
         return false;
      }
   }
   else
   {
      pOrigView = pInArgList->getPlugInArgValue<SpatialDataView>(Executable::ViewArg());
      if (pOrigView == NULL)
      {
         progress.report("No view specified.", 0, ERRORS, true);
         return false;
      }
      GraphicLayer* pLayer = dynamic_cast<GraphicLayer*>(pOrigView->getActiveLayer());
      if (pLayer == NULL)
      {
         pLayer = dynamic_cast<GraphicLayer*>(pOrigView->getTopMostLayer(ANNOTATION));
      }
      GraphicObject* pArrow = NULL;
      if (pLayer != NULL)
      {
         std::list<GraphicObject*> objects;
         pLayer->getObjects(ARROW_OBJECT, objects);
         if (!objects.empty())
         {
            pArrow = objects.back();
         }
         if (objects.size() > 1)
         {
            progress.report("Multiple arrow objects found. Using the most recently added one.", 0, WARNING, true);
         }
      }
      if (pArrow == NULL)
      {
         progress.report("Unable to locate up direction. Add an arrow annotation and re-run this plugin.",
            0, ERRORS, true);
         return false;
      }
      LocationType ur = pArrow->getUrCorner();
      LocationType ll = pArrow->getLlCorner();
      double xlen = ur.mX - ll.mX;
      double ylen = ur.mY - ll.mY;

      // Initial rotatation value. The 90 degrees is due to the difference
      // in the "0 point" (right vs. up). Also account for explicit rotation
      // of the annotation object. Convert this to radians.
      rotation = GeoConversions::convertDegToRad(90 + pArrow->getRotation());

      // Determine a rotation adjustment based on the bounding box
      rotation += atan2(ylen, xlen);
   }

   progress.report("Rotating data.", 10, NORMAL);
   ModelResource<RasterElement> pRotated(pData->copyShallow(pData->getName() + "_rotated", pData->getParent()));
   if (pRotated.get() == NULL)
   {
      progress.report("Unable to create destination raster element.", 0, ERRORS, true);
      return false;
   }

   int defaultBadValue(0);  // the rotate method will handle setting the default bad values into the rotated raster
   if (!RasterUtilities::rotate(pRotated.get(), pData, rotation, defaultBadValue,
      INTERP_NEAREST_NEIGHBOR, progress.getCurrentProgress(), &mAbort))
   {
      // error message already reported by rotate()
      return false;
   }
   pOutArgList->setPlugInArgValue("Rotated Element", pRotated.get());

   if (display)
   {
      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(
         Service<DesktopServices>()->createWindow(pRotated->getName(), SPATIAL_DATA_WINDOW));
      SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
//.........这里部分代码省略.........
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:ChangeUpDirection.cpp

示例2: getLayer

void EastArrowObjectImp::orient()
{
   if (isOriented() == true)
   {
      return;
   }

   GraphicLayer* pLayer = NULL;
   pLayer = getLayer();
   if (pLayer == NULL)
   {
      return;
   }

   View* pView = NULL;
   pView = pLayer->getView();
   if (pView == NULL)
   {
      return;
   }

   SpatialDataView* pSpatialDataView = NULL;
   if (pView->isKindOf("SpatialDataView") == true)
   {
      pSpatialDataView = static_cast<SpatialDataView*> (pView);
   }
   else if (pView->isKindOf("ProductView") == true)
   {
      ProductView* pProductView = static_cast<ProductView*> (pView);

      GraphicLayer* pLayoutLayer = NULL;
      pLayoutLayer = pProductView->getLayoutLayer();
      if (pLayoutLayer == pLayer)
      {
         list<GraphicObject*> viewObjects;
         pLayoutLayer->getObjects(VIEW_OBJECT, viewObjects);

         list<GraphicObject*>::iterator iter = viewObjects.begin();
         while (iter != viewObjects.end())
         {
            GraphicObject* pObject = *iter;
            if (pObject != NULL)
            {
               View* pObjectView = pObject->getObjectView();
               if (pObjectView != NULL)
               {
                  if (pObjectView->isKindOf("SpatialDataView") == true)
                  {
                     pSpatialDataView = static_cast<SpatialDataView*> (pObjectView);
                  }
               }
            }

            ++iter;
         }
      }
   }

   if (pSpatialDataView == NULL)
   {
      return;
   }

   LayerList* pLayerList = pSpatialDataView->getLayerList();
   VERIFYNRV(pLayerList != NULL);
   RasterElement* pRaster = pLayerList->getPrimaryRasterElement();
   VERIFYNRV(pRaster != NULL);
   if (!pRaster->isGeoreferenced())
   {
      return;
   }

   // Calculate the angle of the object relative to the pixel coordinates
   updateHandles();

   LocationType pixelStart = mHandles[7];

   ProductView* pProductView = dynamic_cast<ProductView*> (pView);
   if (pProductView != NULL)
   {
      // Convert to the screen coordinate system
      double dScreenX = 0;
      double dScreenY = 0;
      pLayer->translateDataToWorld(pixelStart.mX, pixelStart.mY, pixelStart.mX, pixelStart.mY);
      pProductView->translateWorldToScreen(pixelStart.mX, pixelStart.mY, dScreenX, dScreenY);
      
      // Convert to the spatial data view coordinate system
      pSpatialDataView->translateScreenToWorld(dScreenX,
         dScreenY, pixelStart.mX, pixelStart.mY);
      pLayer->translateWorldToData(pixelStart.mX, pixelStart.mY, pixelStart.mX, pixelStart.mY);
   }

   double dAngle;
   if (GeoAlgorithms::getAngleToNorth(pRaster, dAngle, pixelStart) == false)
   {
      return;
   }

   // Update the angle if the object is in the layout layer
   if (pProductView != NULL)
//.........这里部分代码省略.........
开发者ID:wzssyqa,项目名称:opticks-cmake,代码行数:101,代码来源:EastArrowObjectImp.cpp

示例3: set_layer_position

/**
 * Move a layer to a new position in the layer list.
 *
 * @param[in] [1]
 *            The name of the layer to move.
 * @param[in] INDEX
 *            The new 0 based index for the layer.
 * @param[in] WINDOW @opt
 *            The name of the window. Defaults to the active window.
 * @rsof
 * @usage print,set_layer_position("data.tif", INDEX=0)
 * @endusage
 */
IDL_VPTR set_layer_position(int argc, IDL_VPTR pArgv[], char* pArgk)
{
   IDL_VPTR idlPtr;
   typedef struct
   {
      IDL_KW_RESULT_FIRST_FIELD;
      int windowExists;
      IDL_STRING windowName;
      int indexExists;
      IDL_LONG index;
   } KW_RESULT;

   //IDL_KW_FAST_SCAN is the type of scan we are using, following it is the
   //name of the keyword, followed by the type, the mask(which should be 1),
   //flags, a boolean whether the value was populated and finally the value itself
   static IDL_KW_PAR kw_pars[] = {
      IDL_KW_FAST_SCAN,
      {"INDEX", IDL_TYP_LONG, 1, 0, reinterpret_cast<int*>(IDL_KW_OFFSETOF(indexExists)),
         reinterpret_cast<char*>(IDL_KW_OFFSETOF(index))},
      {"WINDOW", IDL_TYP_STRING, 1, 0, reinterpret_cast<int*>(IDL_KW_OFFSETOF(windowExists)),
         reinterpret_cast<char*>(IDL_KW_OFFSETOF(windowName))},
      {NULL}
   };

   IdlFunctions::IdlKwResource<KW_RESULT> kw(argc, pArgv, pArgk, kw_pars, 0, 1);

   std::string windowName;
   int index = -1;
   std::string name;

   if (kw->indexExists)
   {
      index = kw->index;
   }
   if (kw->windowExists)
   {
      windowName = IDL_STRING_STR(&kw->windowName);
   }

   if (argc < 2)
   {
      IDL_Message(IDL_M_GENERIC, IDL_MSG_RET, "set_layer_position takes a layer name as a parameter with a "
         "window as an optional keyword.  A keyword 'index' is needed to specify the position.");
      return IDL_StrToSTRING("failure");
   }
   //the name of the layer to set the posisiton of
   name = IDL_VarGetString(pArgv[0]);
   bool bSuccess = false;
   SpatialDataView* pView = dynamic_cast<SpatialDataView*>(IdlFunctions::getViewByWindowName(windowName));
   if (pView != NULL)
   {
      Layer* pLayer = IdlFunctions::getLayerByName(windowName, name, false);
      if (pLayer != NULL)
      {
         pView->setLayerDisplayIndex(pLayer, index);
         bSuccess = true;
      }
   }
   if (bSuccess)
   {
      idlPtr = IDL_StrToSTRING("success");
   }
   else
   {
      idlPtr = IDL_StrToSTRING("failure");
   }
   return idlPtr;
}
开发者ID:tclarke,项目名称:opticks-extras-IDL,代码行数:81,代码来源:LayerCommands.cpp

示例4: getRasterElement

void ChippingWindow::createView()
{
   if (mpChippingWidget == NULL)
   {
      return;
   }

   RasterElement* pRaster = getRasterElement();
   if (pRaster == NULL)
   {
      return;
   }

   // Create the new raster element from the primary element of the source.
   // Note that this does not chip displayed elements if they differ from the primary element.
   // This causes a special case below where the stretch values are being applied to the chipped layer.
   RasterElement* pRasterChip = pRaster->createChip(pRaster->getParent(), "_chip",
      mpChippingWidget->getChipRows(), mpChippingWidget->getChipColumns(), mpChippingWidget->getChipBands());
   if (pRasterChip == NULL)
   {
      QMessageBox::critical(this, windowTitle(), "Unable to create a new cube!");
      return;
   }

   const RasterDataDescriptor* pDescriptor =
      dynamic_cast<const RasterDataDescriptor*>(pRasterChip->getDataDescriptor());
   VERIFYNRV(pDescriptor != NULL);

   // Create a view for the new chip
   SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(
      Service<DesktopServices>()->createWindow(pRasterChip->getName(), SPATIAL_DATA_WINDOW));
   if (pWindow == NULL)
   {
      return;
   }

   SpatialDataView* pView = pWindow->getSpatialDataView();
   if (pView == NULL)
   {
      Service<DesktopServices>()->deleteWindow(pWindow);
      return;
   }

   UndoLock lock(pView);
   if (pView->setPrimaryRasterElement(pRasterChip) == false)
   {
      Service<DesktopServices>()->deleteWindow(pWindow);
      return;
   }

   // RasterLayerImp is needed for the call to setCurrentStretchAsOriginalStretch().
   RasterLayerImp* pLayer = dynamic_cast<RasterLayerImp*>(pView->createLayer(RASTER, pRasterChip));
   if (pLayer == NULL)
   {
      Service<DesktopServices>()->deleteWindow(pWindow);
      return;
   }

   string origName = pRaster->getName();

   SpatialDataWindow* pOrigWindow = dynamic_cast<SpatialDataWindow*>(
      Service<DesktopServices>()->getWindow(origName, SPATIAL_DATA_WINDOW));
   if (pOrigWindow != NULL)
   {
      SpatialDataView* pOrigView = pOrigWindow->getSpatialDataView();
      if (pOrigView != NULL)
      {
         LayerList* pLayerList = pOrigView->getLayerList();
         if (pLayerList != NULL)
         {
            RasterLayer* pOrigLayer = static_cast<RasterLayer*>(pLayerList->getLayer(RASTER, pRaster));
            if (pOrigLayer != NULL)
            {
               // Set the stretch type first so that stretch values are interpreted correctly.
               pLayer->setStretchType(GRAYSCALE_MODE, pOrigLayer->getStretchType(GRAYSCALE_MODE));
               pLayer->setStretchType(RGB_MODE, pOrigLayer->getStretchType(RGB_MODE));
               pLayer->setDisplayMode(pOrigLayer->getDisplayMode());

               // Set the properties of the cube layer in the new view.
               // For each channel, display the first band if the previously displayed band was chipped.
               vector<RasterChannelType> channels = StringUtilities::getAllEnumValues<RasterChannelType>();
               for (vector<RasterChannelType>::const_iterator iter = channels.begin(); iter != channels.end(); ++iter)
               {
                  bool bandCopied = true;
                  DimensionDescriptor newBand;
                  DimensionDescriptor oldBand = pOrigLayer->getDisplayedBand(*iter);
                  if (oldBand.isOriginalNumberValid() == true)
                  {
                     newBand = pDescriptor->getOriginalBand(oldBand.getOriginalNumber());
                  }

                  if (newBand.isValid() == false)
                  {
                     bandCopied = false;
                     newBand = pDescriptor->getBands().front();
                  }

                  // No need to explicitly set the RasterElement here since the new view only has one RasterElement.
                  pLayer->setDisplayedBand(*iter, newBand);

//.........这里部分代码省略.........
开发者ID:wzssyqa,项目名称:opticks-cmake,代码行数:101,代码来源:ChippingWindow.cpp

示例5: setupAnimations

bool MultiLayerMovie::setupAnimations()
{
   // Create the controller
   Service<AnimationServices> pServices;

   AnimationController* pController = pServices->getAnimationController("MultiLayerMovie");
   if (pController != NULL)
   {
      pServices->destroyAnimationController(pController);
   }

   pController = pServices->createAnimationController("MultiLayerMovie", FRAME_TIME);
   if (pController == NULL)
   {
      return false;
   }
   pController->setCanDropFrames(false);

   // Set the controller into each of the views
   SpatialDataView* pView = dynamic_cast<SpatialDataView*>(mpWindow->getView());
   if (pView == NULL)
   {
      pServices->destroyAnimationController(pController);
      return false;
   }

   pView->setAnimationController(pController);

   // Create the animations for each layer
   Animation* pAnimation1 = pController->createAnimation("MultiLayerMovie1");
   Animation* pAnimation2 = pController->createAnimation("MultiLayerMovie2");
   Animation* pAnimation3 = pController->createAnimation("MultiLayerMovie3");
   if (pAnimation1 == NULL || pAnimation2 == NULL || pAnimation3 == NULL)
   {
      pServices->destroyAnimationController(pController);
      return false;
   }

   // Set up the frames for each animation
   const int timeOffset = mNumBands/4;
   vector<AnimationFrame> frames1;
   vector<AnimationFrame> frames2;
   vector<AnimationFrame> frames3;
   for (int i = 0; i < mNumBands; ++i)
   {
      AnimationFrame frame1("frame", i, static_cast<double>(i)/mNumBands);
      AnimationFrame frame2("frame", i, static_cast<double>(i+timeOffset)/(mNumBands+timeOffset));
      AnimationFrame frame3("frame", i, static_cast<double>(i+2*timeOffset)/(mNumBands+timeOffset));
      frames1.push_back(frame1);
      frames2.push_back(frame2);
      frames3.push_back(frame3);
   }

   // Set the frames into the animations
   pAnimation1->setFrames(frames1);
   pAnimation2->setFrames(frames2);
   pAnimation3->setFrames(frames3);

   // Assign the animations to the layers
   mpLayer1->setAnimation(pAnimation1);
   mpLayer2->setAnimation(pAnimation2);
   mpLayer3->setAnimation(pAnimation3);

   return true;
}
开发者ID:pratikone,项目名称:gsoc2011-opticks,代码行数:65,代码来源:MultiLayerMovie.cpp

示例6: pStep


//.........这里部分代码省略.........
      }
      if (isAborted())
      {
         std::string msg = getName() + " has been aborted.";
         pStep->finalize(Message::Abort, msg);
         if (pProgress != NULL)
         {
            pProgress->updateProgress(msg, 0, ABORT);
         }
         
         free(OrigData);
         free(NewData);
         free(ConvoData);
         
         return false;
      }
      
      deltaValue = DeconvolutionFunc(OrigData, pOriginalImage, NewData, ConvoData, sigmaVal, gamaVal, 
                                     windowSize, pDesc->getRowCount(), pDesc->getColumnCount(), nFilterType, maxGrayValue, minGrayValue);


      pTempData = OrigData;
      OrigData = NewData;
      NewData = pTempData;

	  double errorRate = deltaValue/(maxGrayValue-minGrayValue);
	  if (errorRate < CONVERGENCE_THRESHOLD)
	  {
		  break;
	  }
   }
   
   free(NewData);
   free(ConvoData);


   //Output result
   unsigned int nCount = 0;
   for (int i = 0; i < pDesc->getRowCount(); i++)
   {
       for (int j = 0; j < pDesc->getColumnCount(); j++)		   
	   {		   
		   if (!pDestAcc.isValid())
           {       
		       std::string msg = "Unable to access the cube data.";        
			   pStep->finalize(Message::Failure, msg);
                       
			   if (pProgress != NULL)                      
			   {         
			       pProgress->updateProgress(msg, 0, ERRORS);       
			   }   
			   free(OrigData);                  
			   return false;              
		   }
			   
		   pDestAcc->toPixel(i, j);	
		   switchOnEncoding(ResultType, restoreImageValue, pDestAcc->getColumn(), (OrigData+nCount));
		   nCount++;

	   }
   }
   
   free(OrigData);  


   if (!isBatch())
   {
      Service<DesktopServices> pDesktop;

      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
         SPATIAL_DATA_WINDOW));

      SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
      if (pView == NULL)
      {
         std::string msg = "Unable to create view.";
         pStep->finalize(Message::Failure, msg);
         if (pProgress != NULL) 
         {
            pProgress->updateProgress(msg, 0, ERRORS);
         }
         return false;
      }

      pView->setPrimaryRasterElement(pResultCube.get());
      pView->createLayer(RASTER, pResultCube.get());
   }

   if (pProgress != NULL)
   {
      pProgress->updateProgress("Deconvolution enhancement is complete.", 100, NORMAL);
   }

   pOutArgList->setPlugInArgValue("Deconvolution enhancement Result", pResultCube.release());

   pStep->finalize();


   return true;
}
开发者ID:tclarke,项目名称:Astronomy-Image-Processing,代码行数:101,代码来源:Deconvolution.cpp

示例7: getSessionItemImage

bool ImageHandler::getSessionItemImage(SessionItem* pItem, QBuffer& buffer, const QString& format, int band, int* pBbox)
{
   if (format.isEmpty())
   {
      return false;
   }
   bool success = true;
   QImage image;
   Layer* pLayer = dynamic_cast<Layer*>(pItem);
   View* pView = dynamic_cast<View*>(pItem);
   if (pLayer != NULL)
   {
      SpatialDataView* pSDView = dynamic_cast<SpatialDataView*>(pLayer->getView());
      if (pSDView != NULL)
      {
         UndoLock ulock(pSDView);
         DimensionDescriptor cur;
         DisplayMode mode;
         RasterLayer* pRasterLayer = dynamic_cast<RasterLayer*>(pLayer);
         if (band >= 0 && pRasterLayer != NULL)
         {
            RasterElement* pRaster = pRasterLayer->getDisplayedRasterElement(GRAY);
            DimensionDescriptor bandDesc =
               static_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor())->getActiveBand(band);
            cur = pRasterLayer->getDisplayedBand(GRAY);
            mode = pRasterLayer->getDisplayMode();
            pRasterLayer->setDisplayedBand(GRAY, bandDesc);
            pRasterLayer->setDisplayMode(GRAYSCALE_MODE);
         }
         int bbox[4] = {0, 0, 0, 0};
         ColorType transparent(255, 255, 254);
         success = pSDView->getLayerImage(pLayer, image, transparent, bbox);
         if (pBbox != NULL)
         {
            memcpy(pBbox, bbox, sizeof(bbox));
         }
         QImage alphaChannel(image.size(), QImage::Format_Indexed8);
         if (image.hasAlphaChannel())
         {
            alphaChannel = image.alphaChannel();
         }
         else
         {
            alphaChannel.fill(0xff);
         }
         QRgb transColor = COLORTYPE_TO_QCOLOR(transparent).rgb();
         for (int y = 0; y < image.height(); y++)
         {
            for (int x = 0; x < image.width(); x++)
            {
               if (image.pixel(x, y) == transColor)
               {
                  alphaChannel.setPixel(x, y, 0x00);
               }
            }
         }
         image.setAlphaChannel(alphaChannel);
         if (mode.isValid())
         {
            pRasterLayer->setDisplayedBand(GRAY, cur);
            pRasterLayer->setDisplayMode(mode);
         }
      }
   }
   else if (pView != NULL)
   {
      success = pView->getCurrentImage(image);
   }
   else
   {
      success = false;
   }
   if (success)
   {
      buffer.open(QIODevice::WriteOnly);
      QImageWriter writer(&buffer, format.toAscii());
      success = writer.write(image);
   }
   return success;
}
开发者ID:Tom-VdE,项目名称:opticks,代码行数:80,代码来源:ImageHandler.cpp

示例8: pStep


//.........这里部分代码省略.........
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }

   


   FactoryResource<DataRequest> pRequest;
   pRequest->setInterleaveFormat(BSQ);
   DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());

   ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() +
      "_Edge_Detection_Result", pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType()));
   if (pResultCube.get() == NULL)
   {
      std::string msg = "A raster cube could not be created.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }
   FactoryResource<DataRequest> pResultRequest;
   pResultRequest->setWritable(true);
   DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
   

   for (long signed int row = 0; row < pDesc->getRowCount(); ++row)
   {
      if (pProgress != NULL)
      {
         pProgress->updateProgress("Calculating result", row * 100 / pDesc->getRowCount(), NORMAL);
      }
      if (isAborted())
      {
         std::string msg = getName() + " has been aborted.";
         pStep->finalize(Message::Abort, msg);
         if (pProgress != NULL)
         {
            pProgress->updateProgress(msg, 0, ABORT);
         }
         return false;
      }
      if (!pDestAcc.isValid())
      {
         std::string msg = "Unable to access the cube data.";
         pStep->finalize(Message::Failure, msg);
         if (pProgress != NULL) 
         {
            pProgress->updateProgress(msg, 0, ERRORS);
         }
         return false;
      }
      for (long signed int col = 0; col < pDesc->getColumnCount(); ++col)
      {
         switchOnEncoding(pDesc->getDataType(), gauss, pDestAcc->getColumn(), pSrcAcc, row, col,
            pDesc->getRowCount(), pDesc->getColumnCount());
         pDestAcc->nextColumn();
      }

      pDestAcc->nextRow();
   }

   

   if (!isBatch())
   {
      Service<DesktopServices> pDesktop;

      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
         SPATIAL_DATA_WINDOW));

      SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
      if (pView == NULL)
      {
         std::string msg = "Unable to create view.";
         pStep->finalize(Message::Failure, msg);
         if (pProgress != NULL) 
         {
            pProgress->updateProgress(msg, 0, ERRORS);
         }
         return false;
      }

      pView->setPrimaryRasterElement(pResultCube.get());
      pView->createLayer(RASTER, pResultCube.get());
   }

   if (pProgress != NULL)
   {
      pProgress->updateProgress("pagauss is compete.", 100, NORMAL);
   }

   pOutArgList->setPlugInArgValue("pagauss_Result", pResultCube.release());

   pStep->finalize();
   return true;
}
开发者ID:pratikone,项目名称:gsoc2011-opticks,代码行数:101,代码来源:pagauss.cpp

示例9: string


//.........这里部分代码省略.........
   // Do not georeference
   GeoreferenceDescriptor* pLoadGeorefDescriptor = pLoadDescriptor->getGeoreferenceDescriptor();
   if (pLoadGeorefDescriptor != NULL)
   {
      pLoadGeorefDescriptor->setGeoreferenceOnImport(false);
   }

   // Validate the preview
   string errorMessage;
   bool bValidPreview = validate(pLoadDescriptor, vector<const DataDescriptor*>(), errorMessage);
   if (bValidPreview == false)
   {
      // Try an in-memory preview
      pLoadDescriptor->setProcessingLocation(IN_MEMORY);
      bValidPreview = validate(pLoadDescriptor, vector<const DataDescriptor*>(), errorMessage);
   }

   QWidget* pPreviewWidget = NULL;
   if (bValidPreview == true)
   {
      // Create the model element
      RasterElement* pRasterElement = static_cast<RasterElement*>(mpModel->createElement(pLoadDescriptor));
      if (pRasterElement != NULL)
      {
         // Add the progress and raster element to an input arg list
         PlugInArgList* pInArgList = NULL;
         bool bSuccess = getInputSpecification(pInArgList);
         if ((bSuccess == true) && (pInArgList != NULL))
         {
            bSuccess = pInArgList->setPlugInArgValue(Executable::ProgressArg(), pProgress);
            if (bSuccess)
            {
               bSuccess = pInArgList->setPlugInArgValue(Importer::ImportElementArg(), pRasterElement);
            }
         }

         // Load the data in batch mode
         bool bBatch = isBatch();
         setBatch();

         bSuccess = execute(pInArgList, NULL);

         // Restore to interactive mode if necessary
         if (bBatch == false)
         {
            setInteractive();
         }

         // Create the spatial data view
         if (bSuccess == true)
         {
            string name = pRasterElement->getName();

            SpatialDataView* pView = static_cast<SpatialDataView*>(mpDesktop->createView(name, SPATIAL_DATA_VIEW));
            if (pView != NULL)
            {
               // Set the spatial data in the view
               pView->setPrimaryRasterElement(pRasterElement);

               // Add the cube layer
               RasterLayer* pLayer = static_cast<RasterLayer*>(pView->createLayer(RASTER, pRasterElement));
               if (pLayer != NULL)
               {
                  // Get the widget from the view
                  pPreviewWidget = pView->getWidget();
               }
               else
               {
                  string message = "Could not create the cube layer!";
                  if (pProgress != NULL)
                  {
                     pProgress->updateProgress(message, 0, ERRORS);
                  }

                  mpModel->destroyElement(pRasterElement);
               }
            }
            else
            {
               string message = "Could not create the view!";
               if (pProgress != NULL)
               {
                  pProgress->updateProgress(message, 0, ERRORS);
               }

               mpModel->destroyElement(pRasterElement);
            }
         }
         else
         {
            mpModel->destroyElement(pRasterElement);
         }
      }
   }

   // Delete the data descriptor copy
   mpModel->destroyDataDescriptor(pLoadDescriptor);

   return pPreviewWidget;
}
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:RasterElementImporterShell.cpp

示例10: pStep

bool SetDataSetWavelengths::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   if (pInArgList == NULL)
   {
      return false;
   }

   StepResource pStep(string("Execute ") + getName(), "Spectral", "863CB0EE-5BC0-4A49-8FCB-FBC385F1AD2D");

   // Extract the input args
   Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(ProgressArg());

   RasterElement* pDataset = pInArgList->getPlugInArgValue<RasterElement>(DataElementArg());
   if ((pDataset == NULL) && (isBatch() == false))
   {
      SpatialDataView* pView = pInArgList->getPlugInArgValue<SpatialDataView>(ViewArg());
      if (pView != NULL)
      {
         LayerList* pLayerList = pView->getLayerList();
         if (pLayerList != NULL)
         {
            pDataset = pLayerList->getPrimaryRasterElement();
         }
      }
   }

   if (pDataset == NULL)
   {
      string message = "The data set input value is invalid.";
      if (pProgress != NULL)
      {
         pProgress->updateProgress(message, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, message);
      return false;
   }

   DynamicObject* pWavelengthData = pInArgList->getPlugInArgValue<DynamicObject>(Wavelengths::WavelengthsArg());
   if (pWavelengthData == NULL)
   {
      string message = "The " + Wavelengths::WavelengthsArg() + " input value is invalid.";
      if (pProgress != NULL)
      {
         pProgress->updateProgress(message, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, message);
      return false;
   }

   // Apply the wavelength data to the data set
   Wavelengths wavelengths(pWavelengthData);
   if (wavelengths.applyToDataset(pDataset) == false)
   {
      string message = "The wavelengths could not be applied to the data set.  The number of wavelength values "
         "may not match the number of bands in the data set.";
      if (pProgress != NULL)
      {
         pProgress->updateProgress(message, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, message);
      return false;
   }

   pStep->finalize(Message::Success);
   return true;
}
开发者ID:yuguess,项目名称:GSoC,代码行数:69,代码来源:SetDataSetWavelengths.cpp

示例11: addGeoKeys

bool TiffDetails::addGeoKeys(TIFF* pOut, int width, int height, const SessionItem *pItem)
{
   if ((pOut == NULL) || (width == 0) || (height == 0))
   {
      return false;
   }

   const View* pInputView = dynamic_cast<const View*>(pItem);
   if (pInputView == NULL)
   {
      return false;
   }

   RasterElement* pGeoreferencedRaster = NULL; // First raster element we find with georeferencing information
   const ProductView* pView = dynamic_cast<const ProductView*>(pInputView);
   if (pView != NULL)
   {
      AnnotationLayer* pAnno = pView->getLayoutLayer();
      if (pAnno == NULL)
      {
         return false;
      }

      /* NOTE: If we find more than one SpatialDataView with a georeferenced RasterElement, we will only provide
      geo-data for the FIRST one - because two views could theoretically screw up the
      geo-data if one is in Australia and the other in Canada.
      */

      // get all the view objects
      std::list<GraphicObject*> objs;
      pAnno->getObjects(VIEW_OBJECT, objs);

      // for every object, find the data set with a geocoord matrix
      for (std::list<GraphicObject*>::iterator it = objs.begin(); it != objs.end(); ++it)
      {
         GraphicObject* pObj = *it;
         if (pObj != NULL)
         {
            SpatialDataView* pSpView = dynamic_cast<SpatialDataView*>(pObj->getObjectView());
            if (pSpView != NULL)
            {
               LayerList* pLayerList = pSpView->getLayerList();
               if (pLayerList != NULL)
               {
                  RasterElement* pRaster = pLayerList->getPrimaryRasterElement();
                  if (pRaster != NULL && pRaster->isGeoreferenced())
                  {
                     pGeoreferencedRaster = pRaster;
                     break;
                  }
               }
            }
         }
      }
   }

   const SpatialDataView* pSpView = dynamic_cast<const SpatialDataView*>(pInputView);
   if (pSpView != NULL)
   {
      LayerList* pLayerList = pSpView->getLayerList();
      if (pLayerList != NULL)
      {
         RasterElement* pRaster = pLayerList->getPrimaryRasterElement();
         if (pRaster != NULL && pRaster->isGeoreferenced())
         {
            pGeoreferencedRaster = pRaster;
         }
      }
   }

   if (pGeoreferencedRaster == NULL)
   {
      return false;
   }

   GTIF* pGtif = GTIFNew(pOut);
   if (pGtif == NULL)
   {
      return false;
   }

   LocationType lowerLeft;
   LocationType upperLeft;
   LocationType upperRight;
   LocationType lowerRight;
   pInputView->getVisibleCorners(lowerLeft, upperLeft, upperRight, lowerRight);

   LocationType latLong;
   //get the lat/long's (0,0)
   latLong = pGeoreferencedRaster->convertPixelToGeocoord(upperLeft);
   double ll1y = latLong.mY;               //delta long
   double ll1x = latLong.mX;               //delta lat

   latLong = pGeoreferencedRaster->convertPixelToGeocoord(upperRight);
   double ll2y = latLong.mY;               //long
   double ll2x = latLong.mX;               //lat

   latLong = pGeoreferencedRaster->convertPixelToGeocoord(lowerLeft);
   double ll3y = latLong.mY;               //long
   double ll3x = latLong.mX;               //lat
//.........这里部分代码省略.........
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:TiffDetails.cpp

示例12: extractInputs

bool ShapeFileExporter::extractInputs(const PlugInArgList* pInArgList, string& message)
{
   if (pInArgList == NULL)
   {
      message = "Invalid argument list.";
      return false;
   }

   FileDescriptor* pFileDescriptor = pInArgList->getPlugInArgValue<FileDescriptor>(Exporter::ExportDescriptorArg());
   if (pFileDescriptor == NULL)
   {
      message = "No file specified.";
      return false;
   }
   mShapefile.setFilename(pFileDescriptor->getFilename().getFullPathAndName());

   if (isBatch())
   {
      mpAoi = pInArgList->getPlugInArgValue<AoiElement>("AoiElement");
      mpGeoref = pInArgList->getPlugInArgValue<RasterElement>("RasterElement");
   }
   else
   {
      AoiLayer* pLayer = pInArgList->getPlugInArgValue<AoiLayer>(Exporter::ExportItemArg());
      if (pLayer == NULL)
      {
         message = "Input argument list did not include anything to export.";
         return false;
      }

      mpAoi = dynamic_cast<AoiElement*>(pLayer->getDataElement());
      SpatialDataView* pView = dynamic_cast<SpatialDataView*>(pLayer->getView());
      if (pView != NULL)
      {
         mpLayers = pView->getLayerList();
         if (mpLayers != NULL)
         {
            mpGeoref = mpLayers->getPrimaryRasterElement();
         }
      }
   }

   if (mpAoi == NULL)
   {
      message = "Could not identify the data element to export.";
      return false;
   }

   // The BitMaskIterator does not support negative extents and
   // the BitMask does not correctly handle the outside flag so
   // the BitMaskIterator is used for cases when the outside flag is true and
   // the BitMask is used for cases when the outside flag is false.
   // This is the case when the outside flag is false. The case where the
   // outside flag is true for this condition is handled in
   // ShapeFile::addFeatures()
   const BitMask* pMask = mpAoi->getSelectedPoints();
   if (mpAoi->getGroup()->getObjects().empty() == true && 
      pMask->isOutsideSelected() == false)
   {
      message = "The AOI does not contain any points to export.";
      return false;
   }

   if (mpGeoref == NULL)
   {
      message = "Could not identify the georeference to use for export.";
      return false;
   }

   //add aoi to shape file
   mShapefile.setShape(ShapefileTypes::MULTIPOINT_SHAPE);
   string err;
   mShapefile.addFeatures(mpAoi, mpGeoref, err);

   return true;
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:76,代码来源:ShapeFileExporter.cpp

示例13: getLlCorner

string MeasurementObjectImp::generateGeoStrings() const
{
   LocationType llCorner = getLlCorner();
   LocationType urCorner = getUrCorner();
   LocationType llCornerLatLon;
   LocationType urCornerLatLon;
   bool unitsValid = false;

   // Get lat lon coordinates and terrain raster
   const RasterElement* pTerrain = NULL;

   bool geoValid(false);
   if (mpGeoreference.get() != NULL)
   {
      GraphicLayer* pLayer = getLayer();
      if (pLayer != NULL)
      {
         SpatialDataView* pView = dynamic_cast<SpatialDataView*>(pLayer->getView());
         if (pView != NULL)
         {
            LayerList* pLayerList = pView->getLayerList();
            VERIFYRV(pLayerList != NULL, "");
            VERIFYRV(pLayerList->getPrimaryRasterElement() == mpGeoreference.get(), "");

            pTerrain = mpGeoreference->getTerrain();

            Layer* pPrimaryRasterLayer = pLayerList->getLayer(RASTER, mpGeoreference.get());
            if (pPrimaryRasterLayer != NULL)
            {
               pPrimaryRasterLayer->translateWorldToData(llCorner.mX, llCorner.mY, llCorner.mX, llCorner.mY);
               pPrimaryRasterLayer->translateWorldToData(urCorner.mX, urCorner.mY, urCorner.mX, urCorner.mY);
            }
         }
      }

      if (mpGeoreference->isGeoreferenced())
      {
         bool llValid(false);
         bool urValid(false);
         llCornerLatLon = mpGeoreference->convertPixelToGeocoord(llCorner, false, &llValid);
         urCornerLatLon = mpGeoreference->convertPixelToGeocoord(urCorner, false, &urValid);
         geoValid = llValid && urValid;
      }
   }

   mUsingInaccurateGeocoords = !geoValid;
   unitsValid = geoValid;

   //String Variables
   string startLoc = "";
   string endLoc = "";
   string distance = "";
   string bearing = "";
   string distanceUnit = "";

   GeoAlgorithms algs;
   double distanceVal = 0;
   double azimuthVal = 0;

   // Create GeoPoint objects
   LatLonPoint startLlPoint = llCornerLatLon;
   LatLonPoint endLlPoint = urCornerLatLon;
   UtmPoint startUtmPoint = startLlPoint;
   UtmPoint endUtmPoint = endLlPoint;
   MgrsPoint startMgrsPoint = startLlPoint;
   MgrsPoint endMgrsPoint = endLlPoint;

   // find elevations
   double elevation1(0.0);
   double elevation2(0.0);
   if (pTerrain != NULL)
   {
      const RasterDataDescriptor* pDescriptor =
         dynamic_cast<const RasterDataDescriptor*>(pTerrain->getDataDescriptor());
      if (pDescriptor != NULL)
      {
         const vector<DimensionDescriptor>& activeRows = pDescriptor->getRows();
         const vector<DimensionDescriptor>& activeColumns = pDescriptor->getColumns();
         if ( llCorner.mY >= 0 && llCorner.mY < activeRows.size() &&
              llCorner.mX >= 0 && llCorner.mX < activeColumns.size() &&
              urCorner.mY >= 0 && urCorner.mY < activeRows.size() &&
              urCorner.mX >= 0 && urCorner.mX < activeColumns.size() )
         {
            DimensionDescriptor llRowDim(activeRows[llCorner.mY]);
            DimensionDescriptor llColumnDim(activeColumns[llCorner.mX]);
            DimensionDescriptor urRowDim(activeRows[urCorner.mY]);
            DimensionDescriptor urColumnDim(activeColumns[urCorner.mX]);
            elevation1 = pTerrain->getPixelValue(llColumnDim, llRowDim, DimensionDescriptor(), COMPLEX_MAGNITUDE);
            elevation2 = pTerrain->getPixelValue(urColumnDim, urRowDim, DimensionDescriptor(), COMPLEX_MAGNITUDE);
            const Units* pElevationUnits = pDescriptor->getUnits();
            if (pElevationUnits != NULL)
            {
               double scale = pElevationUnits->getScaleFromStandard();
               elevation1 *= scale;
               elevation2 *= scale;
            }
         }
      }
   }

//.........这里部分代码省略.........
开发者ID:Siddharthk,项目名称:opticks,代码行数:101,代码来源:MeasurementObjectImp.cpp

示例14: pStep

SpatialDataView* RasterElementImporterShell::createView() const
{
   if (mpRasterElement == NULL)
   {
      return NULL;
   }

   StepResource pStep("Create view", "app", "F41DCDE3-A5C9-4CE7-B9D4-7DF5A9063840");
   if (mpProgress != NULL)
   {
      mpProgress->updateProgress("Creating view...", 99, NORMAL);
   }

   // Get the data set name
   const string& name = mpRasterElement->getName();
   if (name.empty() == true)
   {
      string message = "The data set name is invalid!  A view cannot be created.";
      if (mpProgress != NULL)
      {
         mpProgress->updateProgress(message, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, message);
      return NULL;
   }

   // Create the spatial data window
   SpatialDataView* pView = NULL;

   SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(mpDesktop->createWindow(name, SPATIAL_DATA_WINDOW));
   if (pWindow != NULL)
   {
      pView = pWindow->getSpatialDataView();
   }

   if (pView == NULL)
   {
      string message = "Could not create the view window!";
      if (mpProgress != NULL)
      {
         mpProgress->updateProgress(message, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, message);
      return NULL;
   }

   // Set the spatial data in the view
   pView->setPrimaryRasterElement(mpRasterElement);

   // Create the layers
   {
      UndoLock lock(pView);
      createRasterLayer(pView, pStep.get());
      createGcpLayer(pView, pStep.get());

      const RasterDataDescriptor* pRasterDescriptor =
         dynamic_cast<const RasterDataDescriptor*>(mpRasterElement->getDataDescriptor());
      if (pRasterDescriptor != NULL)
      {
         const GeoreferenceDescriptor* pGeorefDescriptor = pRasterDescriptor->getGeoreferenceDescriptor();
         if ((pGeorefDescriptor != NULL) && (pGeorefDescriptor->getCreateLayer() == true))
         {
            createLatLonLayer(pView, pStep.get());
         }
      }
   }

   // Check for at least one layer in the view
   LayerList* pLayerList = pView->getLayerList();
   VERIFYRV(pLayerList != NULL, NULL);

   if (pLayerList->getNumLayers() == 0)
   {
      mpDesktop->deleteWindow(pWindow);

      string message = "The view contains no layers, so it will not be created.";
      if (mpProgress != NULL)
      {
         mpProgress->updateProgress(message, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, message);
      return NULL;
   }

   pStep->finalize(Message::Success);
   return pView;
}
开发者ID:Tom-VdE,项目名称:opticks,代码行数:90,代码来源:RasterElementImporterShell.cpp

示例15: draw

void MeasurementObjectImp::draw(double zoomFactor) const
{
   const_cast<MeasurementObjectImp*>(this)->updateGeoreferenceAttachment();

   // Verify that factor values are valid
   if ((mArrowRelStartLoc < 0.0) || (mArrowRelStartLoc > mArrowRelEndLoc) || (mArrowRelStartLoc > 1.0) ||
      (mArrowRelEndLoc < 0.0) || (mArrowRelEndLoc > 1.0) || (mBarEndLength < 0))
   {
      return;
   }
    
   // Draw the main line
   LineObjectImp::draw(zoomFactor);
   
   // Get the current view 
   SpatialDataView* pView = NULL;

   MeasurementLayerImp* pLayer = dynamic_cast<MeasurementLayerImp*>(getLayer());
   if (pLayer != NULL)
   {
      pView = dynamic_cast<SpatialDataView*>(pLayer->getView());
   }

   if (pView == NULL)
   {
      return;
   }

   // Misc Variables
   LocationType junkLocation;    // junk variable used to call methods that require unneeded parameters
   double startPerc = 0.0;       // The relative start location along a line to start drawing
   double lineLength = 0;        // The length of the main line
   double pixelSize = 0;         // The number of screen pixels in a scene pixel
   double lineWidth = 0;         // The width of the main line
   double sqrtLineWidth = 0;     // The square root of the line width
   LocationType llCorner;        // lower left corner of annotation bounding box
   LocationType urCorner;        // upper right corner of annotation bounding box
   ColorType textColor;          // The color to draw the text
   ColorType lineColor;          // The color to draw the line
   ColorType fillColor;          // The color to draw the stippled line

   // Misc Calculations
   pixelSize = DrawUtil::getPixelSize(junkLocation.mX, junkLocation.mY, junkLocation.mX, junkLocation.mY);
   llCorner = getLlCorner();
   urCorner = getUrCorner();
   lineWidth = getLineWidth();
   sqrtLineWidth = sqrt(lineWidth);
   textColor = getTextColor();
   lineLength = sqrt(pow(abs(urCorner.mX - llCorner.mX), 2) + pow(abs(urCorner.mY - llCorner.mY), 2));
   lineColor = getLineColor();
   fillColor = getFillColor();

   // Get text font info (used for all text, set to italic if using inaccurate extrapolation)
   QFont font = getFont();
   font.setItalic(mUsingInaccurateGeocoords);

   // Calculate arrow info (line only)
   LocationType arrowStartPoint; // The start point of the arrow line
   LocationType arrowEndPoint;   // The end point of the arrow line
   double arrowOffset = 0;       // Normal offset from main line to arrow
   double arrowLength = 0;       // The length of the arrow line (in pixels)
   arrowOffset = (pixelSize == 0.0) ? 0.0 : mArrowOffset * sqrtLineWidth / pixelSize;
   DrawUtil::getParallelLine(llCorner, urCorner, arrowOffset, mArrowRelStartLoc, mArrowRelEndLoc,
      arrowStartPoint, arrowEndPoint);
   arrowLength = sqrt(pow(abs(arrowEndPoint.mX - arrowStartPoint.mX), 2) + 
      pow(abs(arrowEndPoint.mY - arrowStartPoint.mY), 2));

   // Calculate arrow head info (Only half arrow head is drawn)
   LocationType arrowHeadBasePoint; // Location of arrow head base point
   double arrowHeadOffset = 0;      // Perpendicular offset from arrow line to arrow head base
   arrowHeadOffset = (pixelSize == 0.0) ? 0.0 : (mArrowHeadOffset * sqrtLineWidth) / pixelSize;
   
   // Adjust arrow head size if arrow length becomes smaller then arrow head length.
   while (arrowHeadOffset > arrowLength)
   {  // Since arrow head is at 45 degree angle, arrowHeadOffset is same as arrow head length

      // Adjust size of arrow head
      if (arrowHeadOffset >= 1)
      {
         arrowHeadOffset -= 1;
      }
      else if (arrowHeadOffset > .2)
      {
         arrowHeadOffset = arrowHeadOffset - .1;
      }
      else
      {
         break;
      }
      arrowHeadOffset = (arrowHeadOffset < 0) ? 0.0 : arrowHeadOffset;
   }
   
   // Get arrow head base point coordinates from calculated arrow head info
   startPerc = (arrowLength == 0.0) ? 0.0 : 1 - (arrowHeadOffset/arrowLength);
   startPerc = (startPerc < 0.0) ? 0.0 : startPerc;
   startPerc = (startPerc > 1.0) ? 1.0 : startPerc;
   DrawUtil::getParallelLine(arrowStartPoint, arrowEndPoint, arrowHeadOffset, startPerc, 1.0f,
                             arrowHeadBasePoint, junkLocation);

   // End bar coordinates
//.........这里部分代码省略.........
开发者ID:Siddharthk,项目名称:opticks,代码行数:101,代码来源:MeasurementObjectImp.cpp


注:本文中的SpatialDataView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。