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();
};

View File

@ -106,13 +106,13 @@ void RimIntersectionBox::setModelBoundingBox(cvf::BoundingBox& boundingBox)
{
m_boundingBox = boundingBox;
minXCoord = cvf::Math::floor(boundingBox.min().x());
minYCoord = cvf::Math::floor(boundingBox.min().y());
minZCoord = cvf::Math::floor(boundingBox.min().z());
minXCoord = boundingBox.min().x() + boundingBox.extent().x() / 4.0;
minYCoord = boundingBox.min().y() + boundingBox.extent().y() / 4.0;
minZCoord = boundingBox.min().z() + boundingBox.extent().z() / 4.0;
maxXCoord = cvf::Math::ceil(boundingBox.max().x());
maxYCoord = cvf::Math::ceil(boundingBox.max().y());
maxZCoord = cvf::Math::ceil(boundingBox.max().z());
maxXCoord = boundingBox.max().x() - boundingBox.extent().x() / 4.0;
maxYCoord = boundingBox.max().y() - boundingBox.extent().y() / 4.0;
maxZCoord = boundingBox.max().z() - boundingBox.extent().z() / 4.0;
updateLabelsFromBoundingBox();
}

View File

@ -112,29 +112,9 @@ void RimIntersectionBoxCollection::appendPartsToModel(cvf::ModelBasicList* model
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBoxCollection::appendIntersectionBox()
void RimIntersectionBoxCollection::appendIntersectionBox(RimIntersectionBox* intersectionBox)
{
RimIntersectionBox* intersectionBox = new RimIntersectionBox();
intersectionBox->name = QString("Intersection Box");
RimCase* rimCase = NULL;
firstAnchestorOrThisOfType(rimCase);
if (rimCase)
{
intersectionBox->setModelBoundingBox(rimCase->activeCellsBoundingBox());
}
m_intersectionBoxes.push_back(intersectionBox);
updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox);
RimView* rimView = NULL;
firstAnchestorOrThisOfType(rimView);
if (rimView)
{
rimView->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ public:
caf::PdmField<bool> isActive;
void appendIntersectionBox();
void appendIntersectionBox(RimIntersectionBox* intersectionBox);
bool hasActiveCrossSectionForSimulationWell(RimEclipseWell* eclipseWell) const;