#2163 Make intersection event handler

This commit is contained in:
Unknown
2017-11-21 15:58:39 +01:00
committed by Rebecca Cox
parent f7de89a584
commit d5819eaad7
6 changed files with 131 additions and 64 deletions

View File

@@ -77,55 +77,6 @@ void RicNewPolylineIntersectionFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("New Polyline Intersection");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPolylineIntersectionFeature::handleEvent(cvf::Object* eventObject)
{
std::vector<RimIntersection*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() == 1)
{
RicViewerEventObject* polylineUiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
if (polylineUiEvent)
{
RimIntersection* intersection = selection[0];
RimView* rimView = nullptr;
intersection->firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(polylineUiEvent->globalIntersectionPoint);
if (intersection->inputPolyLineFromViewerEnabled())
{
intersection->appendPointToPolyLine(domainCoord);
// Further Ui processing is stopped when true is returned
return true;
}
else if (intersection->inputExtrusionPointsFromViewerEnabled())
{
intersection->appendPointToExtrusionDirection(domainCoord);
// Further Ui processing is stopped when true is returned
return true;
}
else if (intersection->inputTwoAzimuthPointsFromViewerEnabled())
{
intersection->appendPointToAzimuthLine(domainCoord);
// Further Ui processing is stopped when true is returned
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -40,9 +40,9 @@ public:
explicit RicNewPolylineIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection);
virtual ~RicNewPolylineIntersectionFeatureCmd();
virtual QString name();
virtual void redo();
virtual void undo();
virtual QString name() override;
virtual void redo() override;
virtual void undo() override;
private:
caf::PdmPointer<RimIntersectionCollection> m_intersectionCollection;
@@ -53,7 +53,7 @@ private:
//==================================================================================================
///
//==================================================================================================
class RicNewPolylineIntersectionFeature : public caf::CmdFeature, public RicViewerEventInterface
class RicNewPolylineIntersectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
@@ -61,12 +61,9 @@ public:
RicNewPolylineIntersectionFeature();
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool handleEvent(cvf::Object* eventObject);
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};