예제 #1
0
     /*
    Extract the geometry and function information 
    @param eventWs : event workspace to get the information from.
    */
    void MDEWLoadingPresenter::extractMetadata(Mantid::API::IMDEventWorkspace_sptr eventWs)
    {
      using namespace Mantid::Geometry;
      MDGeometryBuilderXML<NoDimensionPolicy> refresh;
      xmlBuilder= refresh; //Reassign.
      std::vector<MDDimensionExtents<coord_t> > ext = eventWs->getMinimumExtents(5);
      std::vector<IMDDimension_sptr> dimensions;
      size_t nDimensions = eventWs->getNumDims();
      for (size_t d=0; d<nDimensions; d++)
      {
        IMDDimension_const_sptr inDim = eventWs->getDimension(d);
        coord_t min = ext[d].getMin();
        coord_t max = ext[d].getMax();
        if (min > max)
        {
          min = 0.0;
          max = 1.0;
        }
        //std::cout << "dim " << d << min << " to " <<  max << std::endl;
        axisLabels.push_back(makeAxisTitle(inDim));
        MDHistoDimension_sptr dim(new MDHistoDimension(inDim->getName(), inDim->getName(), inDim->getUnits(), min, max, inDim->getNBins()));
        dimensions.push_back(dim);
      }

      //Configuring the geometry xml builder allows the object panel associated with this reader to later
      //determine how to display all geometry related properties.
      if(nDimensions > 0)
      {
        xmlBuilder.addXDimension( dimensions[0] );
      }
      if(nDimensions > 1)
      {
        xmlBuilder.addYDimension( dimensions[1] );
      }
      if(nDimensions > 2)
      {
        xmlBuilder.addZDimension( dimensions[2]  );
      }
      if(nDimensions > 3)
      {
        tDimension = dimensions[3];
        xmlBuilder.addTDimension(tDimension);
      }
      m_isSetup = true;
    }
     /*
    Extract the geometry and function information 

    This implementation is an override of the base-class method, which deals with the more common event based route. However the SQW files will provide complete
    dimensions with ranges already set. Less work needs to be done here than for event workspaces where the extents of each dimension need to be individually
    extracted.

    @param eventWs : event workspace to get the information from.
    */
    void SQWLoadingPresenter::extractMetadata(Mantid::API::IMDEventWorkspace_sptr eventWs)
    {
      using namespace Mantid::Geometry;
      MDGeometryBuilderXML<NoDimensionPolicy> refresh;
      this->xmlBuilder= refresh; //Reassign.
      std::vector<IMDDimension_sptr> dimensions;
      size_t nDimensions = eventWs->getNumDims();
      for (size_t d=0; d<nDimensions; d++)
      {
        IMDDimension_const_sptr inDim = eventWs->getDimension(d);
        axisLabels.push_back(makeAxisTitle(inDim));
        //Copy the dimension, but set the ID and name to be the same. This is an assumption in bintohistoworkspace.
        MDHistoDimension_sptr dim(new MDHistoDimension(inDim->getName(), inDim->getName(), inDim->getMDFrame(), inDim->getMinimum(), inDim->getMaximum(), size_t(10)));
        dimensions.push_back(dim);
      }

      //Configuring the geometry xml builder allows the object panel associated with this reader to later
      //determine how to display all geometry related properties.
      if(nDimensions > 0)
      {
        this->xmlBuilder.addXDimension( dimensions[0] );
      }
      if(nDimensions > 1)
      {
        this->xmlBuilder.addYDimension( dimensions[1] );
      }
      if(nDimensions > 2)
      {
        this->xmlBuilder.addZDimension( dimensions[2]  );
      }
      if(nDimensions > 3)
      {
        this->tDimension = dimensions[3];
        this->xmlBuilder.addTDimension(this->tDimension);
      }
      this->m_isSetup = true;
    }