#8186 Append points from clipboard to RimPolygonFilter

wip
This commit is contained in:
Magne Sjaastad 2021-10-29 15:41:03 +02:00
parent 8a8019427d
commit fc50dafc8c
5 changed files with 127 additions and 0 deletions

View File

@ -30,6 +30,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -64,6 +65,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicAppendPointsToPolygonFilterFeature.h"
CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" );
#include "RimPolygonFilter.h"
#include "RimPolylineTarget.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QClipboard>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled()
{
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !selectedObject ) return false;
RimPolygonFilter* polygonFilter = nullptr;
selectedObject->firstAncestorOrThisOfType( polygonFilter );
return ( polygonFilter != nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked )
{
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !selectedObject ) return;
RimPolygonFilter* polygonFilter = nullptr;
selectedObject->firstAncestorOrThisOfType( polygonFilter );
if ( !polygonFilter ) return;
QStringList listOfThreeDoubles;
QClipboard* clipboard = QApplication::clipboard();
if ( clipboard )
{
QString content = clipboard->text();
listOfThreeDoubles = content.split( "\n", QString::SkipEmptyParts );
}
std::vector<cvf::Vec3d> points;
caf::PdmValueFieldSpecialization<std::vector<cvf::Vec3d>>::setFromVariant( listOfThreeDoubles, points );
for ( const auto& p : points )
{
auto newTarget = new RimPolylineTarget;
newTarget->setAsPointTargetXYD( p );
polygonFilter->insertTarget( nullptr, newTarget );
}
polygonFilter->updateEditorsAndVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendPointsToPolygonFilterFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Append Points from Clipboard" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicAppendPointsToPolygonFilterFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -364,6 +364,7 @@ void RimPolygonFilter::defineCustomContextMenu( const caf::PdmFieldHandle* field
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicDeletePolylineTargetFeature";
menuBuilder << "RicAppendPointsToPolygonFilterFeature";
menuBuilder.appendToMenu( menu );
}

View File

@ -881,6 +881,7 @@ void RimExtrudedCurveIntersection::appendPointToPolyLine( const cvf::Vec3d& poin
m_userPolylineXyz.v().push_back( pointXyz );
m_userPolylineXyz.uiCapability()->updateConnectedEditors();
m_userPolylineXydForUi.uiCapability()->updateConnectedEditors();
rebuildGeometryAndScheduleCreateDisplayModel();
}