Пример #1
0
//----------------------------------------------------------------------------------------------
/// Run the algorithm
void QueryMDWorkspace::exec() {
    // Extract the required normalisation.
    std::string strNormalisation = getPropertyValue("Normalisation");
    MDNormalization requestedNormalisation = whichNormalisation(strNormalisation);

    IMDWorkspace_sptr input = getProperty("InputWorkspace");

    const bool transformCoordsToOriginal = getProperty("TransformCoordsToOriginal");

    // Define a table workspace with a specific column schema.
    ITableWorkspace_sptr output = WorkspaceFactory::Instance().createTable();
    const std::string signalColumnName = "Signal/" + strNormalisation;
    const std::string errorColumnName = "Error/" + strNormalisation;
    output->addColumn("double", signalColumnName);
    output->addColumn("double", errorColumnName);
    output->addColumn("int", "Number of Events");

    const size_t ndims = input->getNumDims();
    for (size_t index = 0; index < ndims; ++index) {
        Mantid::Geometry::IMDDimension_const_sptr dim = input->getDimension(index);
        std::string dimInUnit = dim->getName() + "/" + dim->getUnits().ascii();
        output->addColumn("double", dimInUnit);
        // Magic numbers required to configure the X axis.
        output->getColumn(dimInUnit)->setPlotType(1);
    }

    // Magic numbers required to configure the Y axis.
    output->getColumn(signalColumnName)->setPlotType(2);
    output->getColumn(errorColumnName)->setPlotType(5);

    IMDIterator *it = input->createIterator();
    it->setNormalization(requestedNormalisation);

    bool bLimitRows = getProperty("LimitRows");
    int maxRows = 0;
    if (bLimitRows) {
        maxRows = getProperty("MaximumRows");
    }

    // Use the iterator to loop through each MDBoxBase and create a row for each
    // entry.
    int rowCounter = 0;

    Progress progress(this, 0, 1, int64_t(input->getNPoints()));
    while (true) {
        size_t cellIndex = 0;
        output->appendRow();
        output->cell<double>(rowCounter, cellIndex++) = it->getNormalizedSignal();
        output->cell<double>(rowCounter, cellIndex++) = it->getNormalizedError();
        output->cell<int>(rowCounter, cellIndex++) = int(it->getNumEvents());
        VMD center = it->getCenter();
        const size_t numberOriginal = input->getNumberTransformsToOriginal();
        if (transformCoordsToOriginal && numberOriginal > 0) {
            const size_t index = numberOriginal - 1;
            CoordTransform const *transform = input->getTransformToOriginal(index);
            VMD temp = transform->applyVMD(center);
            center = temp;
        }

        for (size_t index = 0; index < ndims; ++index) {
            output->cell<double>(rowCounter, cellIndex++) = center[index];
        }

        progress.report();
        if (!it->next() || (bLimitRows && ((rowCounter + 1) >= maxRows))) {
            break;
        }
        rowCounter++;
    }
    setProperty("OutputWorkspace", output);
    delete it;

    //
    IMDEventWorkspace_sptr mdew;
    CALL_MDEVENT_FUNCTION(this->getBoxData, input);
}
Пример #2
0
/** Set the labels for the Y dimensions
 * @param dim : IMDDimension */
void XYLimitsDialog::setYDim(Mantid::Geometry::IMDDimension_const_sptr dim)
{
  ui.lblYName->setText( QString::fromStdString(dim->getName()) );
  ui.lblYUnits->setText( QString::fromStdString(dim->getUnits()) );
}
Пример #3
0
/** Set the labels for the X dimensions
 * @param dim : IMDDimension */
void XYLimitsDialog::setXDim(Mantid::Geometry::IMDDimension_const_sptr dim) {
  ui.lblXName->setText(QString::fromStdString(dim->getName()));
  ui.lblXUnits->setText(toQStringInternal(dim->getUnits().utf8()));
}