#2332 2D Intersection View: Show warning if intersection is not vertical

This commit is contained in:
Magne Sjaastad 2018-01-17 11:29:06 +01:00
parent 03de2aba5b
commit 3bcfc09baf
2 changed files with 28 additions and 7 deletions

View File

@ -28,6 +28,7 @@
#include "cafSelectionManagerTools.h" #include "cafSelectionManagerTools.h"
#include <QAction> #include <QAction>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature"); CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature");
@ -36,7 +37,7 @@ CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeatur
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewIntersectionViewFeature::isCommandEnabled() bool RicNewIntersectionViewFeature::isCommandEnabled()
{ {
std::vector<RimIntersection*> objects = selectedIntersections(); std::set<RimIntersection*> objects = selectedIntersections();
return !objects.empty(); return !objects.empty();
} }
@ -46,7 +47,7 @@ bool RicNewIntersectionViewFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked)
{ {
std::vector<RimIntersection*> intersections = selectedIntersections(); std::set<RimIntersection*> intersections = selectedIntersections();
Rim2dIntersectionView* objectToSelect = nullptr; Rim2dIntersectionView* objectToSelect = nullptr;
@ -58,6 +59,14 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked)
intersection->firstAncestorOrThisOfType(rimCase); intersection->firstAncestorOrThisOfType(rimCase);
if (rimCase) if (rimCase)
{ {
if (intersection->direction() != RimIntersection::CS_VERTICAL)
{
QString text = QString("Intersection '%1' is not a vertical intersection. The intersection view supports"
"only vertical intersections.").arg(intersection->name());
QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text);
}
Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection); Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection);
intersectionView->loadDataAndUpdate(); intersectionView->loadDataAndUpdate();
@ -85,9 +94,9 @@ void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimIntersection*> RicNewIntersectionViewFeature::selectedIntersections() std::set<RimIntersection*> RicNewIntersectionViewFeature::selectedIntersections()
{ {
std::vector<RimIntersection*> objects = caf::selectedObjectsByType<RimIntersection*>(); std::set<RimIntersection*> objects;
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
@ -98,7 +107,19 @@ std::vector<RimIntersection*> RicNewIntersectionViewFeature::selectedIntersectio
RimIntersection* intersection = dynamic_cast<RimIntersection*>(generalSelectionItem->m_object); RimIntersection* intersection = dynamic_cast<RimIntersection*>(generalSelectionItem->m_object);
if (intersection) if (intersection)
{ {
objects.push_back(intersection); objects.insert(intersection);
// Return only the intersection the user clicked on
return objects;
}
}
{
std::vector<RimIntersection*> selectedObjects = caf::selectedObjectsByType<RimIntersection*>();
for (auto obj : selectedObjects)
{
objects.insert(obj);
} }
} }

View File

@ -20,7 +20,7 @@
#include "cafCmdFeature.h" #include "cafCmdFeature.h"
#include <vector> #include <set>
class RimIntersection; class RimIntersection;
@ -37,5 +37,5 @@ protected:
void setupActionLook(QAction* actionToSetup) override; void setupActionLook(QAction* actionToSetup) override;
private: private:
static std::vector<RimIntersection*> selectedIntersections(); static std::set<RimIntersection*> selectedIntersections();
}; };