diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index fca8cb7e0e..07d5e9563f 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -28,6 +28,7 @@ #include "cafSelectionManagerTools.h" #include +#include CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature"); @@ -36,7 +37,7 @@ CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeatur //-------------------------------------------------------------------------------------------------- bool RicNewIntersectionViewFeature::isCommandEnabled() { - std::vector objects = selectedIntersections(); + std::set objects = selectedIntersections(); return !objects.empty(); } @@ -46,7 +47,7 @@ bool RicNewIntersectionViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) { - std::vector intersections = selectedIntersections(); + std::set intersections = selectedIntersections(); Rim2dIntersectionView* objectToSelect = nullptr; @@ -58,6 +59,14 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) intersection->firstAncestorOrThisOfType(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); intersectionView->loadDataAndUpdate(); @@ -85,9 +94,9 @@ void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicNewIntersectionViewFeature::selectedIntersections() +std::set RicNewIntersectionViewFeature::selectedIntersections() { - std::vector objects = caf::selectedObjectsByType(); + std::set objects; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); @@ -98,7 +107,19 @@ std::vector RicNewIntersectionViewFeature::selectedIntersectio RimIntersection* intersection = dynamic_cast(generalSelectionItem->m_object); if (intersection) { - objects.push_back(intersection); + objects.insert(intersection); + + // Return only the intersection the user clicked on + + return objects; + } + } + + { + std::vector selectedObjects = caf::selectedObjectsByType(); + for (auto obj : selectedObjects) + { + objects.insert(obj); } } diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h index f11fe6d2eb..7f7a1af9d6 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h @@ -20,7 +20,7 @@ #include "cafCmdFeature.h" -#include +#include class RimIntersection; @@ -37,5 +37,5 @@ protected: void setupActionLook(QAction* actionToSetup) override; private: - static std::vector selectedIntersections(); + static std::set selectedIntersections(); };