#817 New intersection box is created at center of active cells with half the size of active cells bounding box. Grid cell is hidden.

This commit is contained in:
Magne Sjaastad
2016-09-23 13:38:08 +02:00
parent 259df01e0a
commit bb81009b33
5 changed files with 59 additions and 36 deletions

View File

@@ -18,8 +18,11 @@
#include "RicAppendIntersectionBoxFeature.h"
#include "RimCase.h"
#include "RimIntersectionBox.h"
#include "RimIntersectionBoxCollection.h"
#include "RimView.h"
#include "RiuMainWindow.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
@@ -35,7 +38,10 @@ CAF_CMD_SOURCE_INIT(RicAppendIntersectionBoxFeature, "RicAppendIntersectionBoxFe
//--------------------------------------------------------------------------------------------------
bool RicAppendIntersectionBoxFeature::isCommandEnabled()
{
return true;
RimIntersectionBoxCollection* coll = RicAppendIntersectionBoxFeature::intersectionBoxCollection();
if (coll) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
@@ -43,16 +49,33 @@ bool RicAppendIntersectionBoxFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicAppendIntersectionBoxFeature::onActionTriggered(bool isChecked)
{
std::vector<caf::PdmObjectHandle*> collection;
caf::SelectionManager::instance()->objectsByType(&collection);
CVF_ASSERT(collection.size() == 1);
RimIntersectionBoxCollection* coll = RicAppendIntersectionBoxFeature::intersectionBoxCollection();
RimIntersectionBoxCollection* crossSectionCollection = NULL;
collection[0]->firstAnchestorOrThisOfType(crossSectionCollection);
if (coll)
{
RimIntersectionBox* intersectionBox = new RimIntersectionBox();
intersectionBox->name = QString("Intersection Box");
CVF_ASSERT(crossSectionCollection);
RimCase* rimCase = NULL;
coll->firstAnchestorOrThisOfType(rimCase);
if (rimCase)
{
intersectionBox->setModelBoundingBox(rimCase->activeCellsBoundingBox());
}
crossSectionCollection->appendIntersectionBox();
coll->appendIntersectionBox(intersectionBox);
coll->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox);
RimView* rimView = NULL;
coll->firstAnchestorOrThisOfType(rimView);
if (rimView)
{
rimView->showGridCells(false);
rimView->scheduleCreateDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
@@ -64,3 +87,20 @@ void RicAppendIntersectionBoxFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("New Intersection Box");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionBoxCollection* RicAppendIntersectionBoxFeature::intersectionBoxCollection()
{
RimIntersectionBoxCollection* intersectionBoxColl = nullptr;
std::vector<caf::PdmObjectHandle*> selectedObjects;
caf::SelectionManager::instance()->objectsByType(&selectedObjects);
if (selectedObjects.size() == 1)
{
selectedObjects[0]->firstAnchestorOrThisOfType(intersectionBoxColl);
}
return intersectionBoxColl;
}

View File

@@ -35,5 +35,8 @@ protected:
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
private:
static RimIntersectionBoxCollection* intersectionBoxCollection();
};