2016-09-20 12:03:26 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2016- Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-09-20 12:03:26 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-09-20 12:03:26 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-09-20 12:03:26 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicAppendIntersectionBoxFeature.h"
|
|
|
|
|
|
2019-11-26 13:56:02 +01:00
|
|
|
#include "RimBoxIntersection.h"
|
2016-09-23 13:38:08 +02:00
|
|
|
#include "RimCase.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "RimGridView.h"
|
2016-09-30 08:40:46 +02:00
|
|
|
#include "RimIntersectionCollection.h"
|
2018-02-27 15:21:14 +01:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2016-09-20 12:03:26 +02:00
|
|
|
|
|
|
|
|
#include "cafCmdExecCommandManager.h"
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicAppendIntersectionBoxFeature, "RicAppendIntersectionBoxFeature" );
|
2016-09-20 12:03:26 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-09-20 12:03:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicAppendIntersectionBoxFeature::isCommandEnabled()
|
|
|
|
|
{
|
2016-09-30 09:49:48 +02:00
|
|
|
RimIntersectionCollection* coll = RicAppendIntersectionBoxFeature::intersectionCollection();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( coll ) return true;
|
2016-09-23 13:38:08 +02:00
|
|
|
|
2016-09-30 09:49:48 +02:00
|
|
|
return false;
|
2016-09-20 12:03:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-09-20 12:03:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicAppendIntersectionBoxFeature::onActionTriggered( bool isChecked )
|
2016-09-20 12:03:26 +02:00
|
|
|
{
|
2016-09-30 08:40:46 +02:00
|
|
|
RimIntersectionCollection* coll = RicAppendIntersectionBoxFeature::intersectionCollection();
|
2016-09-23 13:38:08 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( coll )
|
2016-09-23 13:38:08 +02:00
|
|
|
{
|
2019-11-26 13:14:55 +01:00
|
|
|
RimBoxIntersection* intersectionBox = new RimBoxIntersection();
|
2019-11-12 16:58:26 +01:00
|
|
|
intersectionBox->setName( "Intersection Box" );
|
2016-09-23 13:38:08 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
coll->appendIntersectionBoxAndUpdate( intersectionBox );
|
2016-09-20 12:03:26 +02:00
|
|
|
|
2016-09-30 09:49:48 +02:00
|
|
|
intersectionBox->setToDefaultSizeBox();
|
2016-09-28 12:39:43 +02:00
|
|
|
|
2016-09-23 13:38:08 +02:00
|
|
|
coll->updateConnectedEditors();
|
2019-09-06 10:40:57 +02:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( intersectionBox );
|
2016-09-20 12:03:26 +02:00
|
|
|
|
2018-01-15 14:52:22 +01:00
|
|
|
RimGridView* rimView = nullptr;
|
2019-09-06 10:40:57 +02:00
|
|
|
coll->firstAncestorOrThisOfTypeAsserted( rimView );
|
|
|
|
|
rimView->showGridCells( false );
|
2016-09-23 13:38:08 +02:00
|
|
|
}
|
2016-09-20 12:03:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-09-20 12:03:26 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicAppendIntersectionBoxFeature::setupActionLook( QAction* actionToSetup )
|
2016-09-20 12:03:26 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setIcon( QIcon( ":/IntersectionBox16x16.png" ) );
|
|
|
|
|
actionToSetup->setText( "New Intersection Box" );
|
2016-09-20 12:03:26 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-23 13:38:08 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-09-23 13:38:08 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-30 08:40:46 +02:00
|
|
|
RimIntersectionCollection* RicAppendIntersectionBoxFeature::intersectionCollection()
|
2016-09-23 13:38:08 +02:00
|
|
|
{
|
2016-09-30 08:40:46 +02:00
|
|
|
RimIntersectionCollection* intersectionBoxColl = nullptr;
|
2016-09-23 13:38:08 +02:00
|
|
|
|
|
|
|
|
std::vector<caf::PdmObjectHandle*> selectedObjects;
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selectedObjects );
|
|
|
|
|
if ( selectedObjects.size() == 1 )
|
2016-09-23 13:38:08 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
selectedObjects[0]->firstAncestorOrThisOfType( intersectionBoxColl );
|
2016-09-23 13:38:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return intersectionBoxColl;
|
|
|
|
|
}
|