コード例 #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicPasteWellLogCurveFeature::onActionTriggered(bool isChecked)
{
    caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());

    RimWellLogTrack* wellLogTrack = nullptr;
    destinationObject->firstAncestorOrThisOfType(wellLogTrack);
    if (!wellLogTrack)
    {
        return;
    }

    std::vector<caf::PdmPointer<RimWellLogCurve> > sourceObjects = RicPasteWellLogCurveFeature::curves();

    for (size_t i = 0; i < sourceObjects.size(); i++)
    {
        RimWellLogFileCurve* fileCurve = dynamic_cast<RimWellLogFileCurve*>(sourceObjects[i].p());
        if (fileCurve)
        {
            RimWellLogFileCurve* newObject = dynamic_cast<RimWellLogFileCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
            CVF_ASSERT(newObject);

            wellLogTrack->addCurve(newObject);

            // Resolve references after object has been inserted into the project data model
            newObject->resolveReferencesRecursively();
            newObject->initAfterReadRecursively();

            newObject->loadDataAndUpdate();

            wellLogTrack->updateConnectedEditors();
        }

        RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(sourceObjects[i].p());
        if (extractionCurve)
        {
            RimWellLogExtractionCurve* newObject = dynamic_cast<RimWellLogExtractionCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
            CVF_ASSERT(newObject);

            wellLogTrack->addCurve(newObject);

            // Resolve references after object has been inserted into the project data model
            newObject->resolveReferencesRecursively();
            newObject->initAfterReadRecursively();

            newObject->loadDataAndUpdate();

            wellLogTrack->updateConnectedEditors();
        }
    }
}
コード例 #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogTrack* destTrack, 
                                                                  const std::vector<RimWellLogCurve*>& curves, 
                                                                  RimWellLogCurve* curveToInsertAfter)
{
    CVF_ASSERT(destTrack );

    std::set<RimWellLogTrack*> srcTracks;
    std::set<RimWellLogPlot*> srcPlots;

    for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
    {
        RimWellLogCurve* curve = curves[cIdx];

        RimWellLogTrack* wellLogPlotTrack;
        curve->firstAncestorOrThisOfType(wellLogPlotTrack);
        if (wellLogPlotTrack)
        {
            wellLogPlotTrack->removeCurve(curve);
            wellLogPlotTrack->updateConnectedEditors();
            srcTracks.insert(wellLogPlotTrack);
            RimWellLogPlot* plot;
            wellLogPlotTrack->firstAncestorOrThisOfType(plot);
            if (plot) srcPlots.insert(plot);
        }
    }

    size_t insertionStartIndex = 0;
    if (curveToInsertAfter) insertionStartIndex = destTrack->curveIndex(curveToInsertAfter) + 1;

    for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
    {
        destTrack->insertCurve(curves[cIdx], insertionStartIndex + cIdx);
    }

    for (std::set<RimWellLogPlot*>::iterator pIt = srcPlots.begin(); pIt != srcPlots.end(); ++pIt)
    {
        (*pIt)->calculateAvailableDepthRange();
    }

    for (std::set<RimWellLogTrack*>::iterator tIt = srcTracks.begin(); tIt != srcTracks.end(); ++tIt)
    {
        (*tIt)->updateXZoomAndParentPlotDepthZoom();
    }

    destTrack->loadDataAndUpdate();
    destTrack->updateXZoomAndParentPlotDepthZoom();
    destTrack->updateConnectedEditors();
}