Files
ResInsight/ApplicationLibCode/Commands/CompletionCommands/RicCreateSegmentIntervalFeature.cpp
T
Magne Sjaastad 81bcc2657d #14962: Update MSW segments when segment intervals change
Segment interval edits, creation and deletion did not trigger the automatic MSW segment update, so the segment visualization along the well path was stale.
2026-10-19 20:00:04 +02:00

49 lines
1.7 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicCreateSegmentIntervalFeature.h"
#include "RimProject.h"
#include "RimSegmentCollection.h"
#include "RimSegmentInterval.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QIcon>
CAF_CMD_SOURCE_INIT( RicCreateSegmentIntervalFeature, "RicCreateSegmentIntervalFeature" );
bool RicCreateSegmentIntervalFeature::isCommandEnabled() const
{
return caf::SelectionManager::instance()->selectedItemOfType<RimSegmentCollection>() != nullptr;
}
void RicCreateSegmentIntervalFeature::onActionTriggered( bool isChecked )
{
auto* collection = caf::SelectionManager::instance()->selectedItemOfType<RimSegmentCollection>();
if ( !collection ) return;
auto* interval = collection->createInterval( 0.0, 2000.0, collection->linerDiameter(), collection->roughnessFactor() );
collection->updateConnectedEditors();
collection->updateMswSegments();
Riu3DMainWindowTools::selectAsCurrentItem( interval );
if ( auto* project = RimProject::current() ) project->scheduleCreateDisplayModelAndRedrawAllViews();
}
void RicCreateSegmentIntervalFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create Segment Interval" );
actionToSetup->setIcon( QIcon( ":/Segment.svg" ) );
}