(#641) Use checkable button for point input from viewer

This commit is contained in:
Magne Sjaastad 2015-11-30 13:23:11 +01:00
parent 8b3adf0f5b
commit 3eade62961
7 changed files with 33 additions and 100 deletions

View File

@ -89,15 +89,17 @@ bool RicNewPolylineCrossSectionFeature::handleUiEvent(cvf::Object* uiEventObject
if (polylineUiEvent)
{
RimCrossSection* crossSection = selection[0];
if (crossSection->inputFromViewerEnabled())
{
RimCase* rimCase = NULL;
crossSection->firstAnchestorOrThisOfType(rimCase);
CVF_ASSERT(rimCase);
RimCase* rimCase = NULL;
crossSection->firstAnchestorOrThisOfType(rimCase);
CVF_ASSERT(rimCase);
crossSection->appendPointToPolyLine(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
crossSection->appendPointToPolyLine(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
// Further Ui processing is stopped when true is returned
return true;
// Further Ui processing is stopped when true is returned
return true;
}
}
}
@ -138,9 +140,9 @@ void RicNewPolylineCrossSectionFeatureCmd::redo()
RimCrossSection* crossSection = new RimCrossSection();
crossSection->name = "Polyline";
crossSection->type = RimCrossSection::CS_POLYLINE;
m_crossSectionCollection->appendCrossSection(crossSection);
crossSection->inputFromViewerEnabled = true;
crossSection->updateActiveUiCommandFeature();
m_crossSectionCollection->appendCrossSection(crossSection);
RiuSelectionManager::instance()->deleteAllItems();

View File

@ -86,13 +86,13 @@ RimCrossSection::RimCrossSection()
CAF_PDM_InitField (&m_extentLength, "ExtentLength", 200.0, "Extent length", "", "", "");
CAF_PDM_InitField (&showInactiveCells, "ShowInactiveCells", false, "Inactive Cells", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_activateAppendPointsCommand, "m_activateUiAppendPointsCommand", "", "", "", "");
m_activateAppendPointsCommand.xmlCapability()->setIOWritable(false);
m_activateAppendPointsCommand.xmlCapability()->setIOReadable(false);
m_activateAppendPointsCommand.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
m_activateAppendPointsCommand.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitFieldNoDefault(&inputFromViewerEnabled, "m_activateUiAppendPointsCommand", "", "", "", "");
inputFromViewerEnabled.xmlCapability()->setIOWritable(false);
inputFromViewerEnabled.xmlCapability()->setIOReadable(false);
inputFromViewerEnabled.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
inputFromViewerEnabled.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_activateAppendPointsCommand = false;
inputFromViewerEnabled = false;
uiCapability()->setUiChildrenHidden(true);
}
@ -131,11 +131,9 @@ void RimCrossSection::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
updateName();
}
if (changedField == &m_activateAppendPointsCommand)
if (changedField == &inputFromViewerEnabled)
{
updateActiveUiCommandFeature();
m_activateAppendPointsCommand = false;
// TODO rebuild geo and div
}
if (changedField == &m_userPolyline)
@ -169,7 +167,7 @@ void RimCrossSection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
else if (type == CS_POLYLINE)
{
geometryGroup->add(&m_userPolyline);
geometryGroup->add(&m_activateAppendPointsCommand);
geometryGroup->add(&inputFromViewerEnabled);
}
caf::PdmUiGroup* optionsGroup = uiOrdering.addNewGroup("Options");
@ -221,7 +219,6 @@ QList<caf::PdmOptionItemInfo> RimCrossSection::calculateValueOptions(const caf::
{
options.push_back(caf::PdmOptionItemInfo(eclWells[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(eclWells[i])), false, simWellIcon));
}
}
if (options.size() == 0)
@ -500,21 +497,17 @@ void RimCrossSection::clipToReservoir(std::vector<cvf::Vec3d> &polyLine) const
//--------------------------------------------------------------------------------------------------
void RimCrossSection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_activateAppendPointsCommand)
if (field == &inputFromViewerEnabled)
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*> (attribute);
RimView* rimView = NULL;
this->firstAnchestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
if (rimView->viewer()->activeUiCommandFeature())
if (inputFromViewerEnabled)
{
attrib->m_buttonText = "End point input";
attrib->m_buttonText = "Stop picking points";
}
else
{
attrib->m_buttonText = "Start point input";
attrib->m_buttonText = "Start picking points";
}
}
}
@ -531,35 +524,6 @@ void RimCrossSection::appendPointToPolyLine(const cvf::Vec3d& point)
rebuildGeometryAndScheduleCreateDisplayModel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCrossSection::updateActiveUiCommandFeature()
{
RimView* rimView = NULL;
this->firstAnchestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
if (!rimView->viewer()) return;
if (rimView->viewer()->activeUiCommandFeature())
{
rimView->viewer()->setActiveUiCommandFeature(NULL);
}
else
{
caf::CmdFeature* cmdFeature = caf::CmdFeatureManager::instance()->getCommandFeature("RicNewPolylineCrossSectionFeature");
CVF_ASSERT(cmdFeature);
RicCommandFeature* riCommandFeature = dynamic_cast<RicCommandFeature*>(cmdFeature);
CVF_ASSERT(riCommandFeature);
rimView->viewer()->setActiveUiCommandFeature(riCommandFeature);
}
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -70,11 +70,12 @@ public:
caf::PdmPtrField<RimWellPath*> wellPath;
caf::PdmPtrField<RimEclipseWell*> simulationWell;
caf::PdmField< bool > inputFromViewerEnabled;
std::vector< std::vector <cvf::Vec3d> > polyLines() const;
RivCrossSectionPartMgr* crossSectionPartMgr();
void appendPointToPolyLine(const cvf::Vec3d& point);
void updateActiveUiCommandFeature();
protected:
virtual caf::PdmFieldHandle* userDescriptionField();
@ -93,7 +94,6 @@ private:
caf::PdmField<double> m_extentLength;
caf::PdmField< std::vector< cvf::Vec3d> > m_userPolyline;
caf::PdmField< bool > m_activateAppendPointsCommand;
RimEclipseWellCollection* simulationWellCollection();
void updateWellCenterline() const;

View File

@ -649,20 +649,3 @@ cvf::Color3f RiuViewer::computeContrastColor() const
return contrastColor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setActiveUiCommandFeature(RicCommandFeature* uiCommandFeature)
{
CVF_ASSERT(m_viewerCommands);
m_viewerCommands->setActiveUiCommandFeature(uiCommandFeature);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicCommandFeature* RiuViewer::activeUiCommandFeature() const
{
return m_viewerCommands->activeUiCommandFeature();
}

View File

@ -89,9 +89,6 @@ public:
void setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel);
void setActiveUiCommandFeature(RicCommandFeature* uiCommandFeature);
RicCommandFeature* activeUiCommandFeature() const;
public slots:
virtual void slotSetCurrentFrame(int frameIndex);
virtual void slotEndAnimation();

View File

@ -57,6 +57,7 @@
#include "RivWellPipeSourceInfo.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmUiTreeView.h"
#include "cafSelectionManager.h"
@ -83,7 +84,13 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
m_currentGridIdx(-1),
m_currentCellIndex(-1)
{
caf::CmdFeature* cmdFeature = caf::CmdFeatureManager::instance()->getCommandFeature("RicNewPolylineCrossSectionFeature");
CVF_ASSERT(cmdFeature);
RicCommandFeature* riCommandFeature = dynamic_cast<RicCommandFeature*>(cmdFeature);
CVF_ASSERT(riCommandFeature);
m_activeUiCommandFeature = riCommandFeature;
}
//--------------------------------------------------------------------------------------------------
@ -563,22 +570,6 @@ void RiuViewerCommands::findCellAndGridIndex(const RivCrossSectionSourceInfo* cr
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::setActiveUiCommandFeature(RicCommandFeature* uiCommandFeature)
{
m_activeUiCommandFeature = uiCommandFeature;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicCommandFeature* RiuViewerCommands::activeUiCommandFeature() const
{
return m_activeUiCommandFeature;
}
//--------------------------------------------------------------------------------------------------
/// Perform picking and return the index of the face that was hit, if a drawable geo was hit
//--------------------------------------------------------------------------------------------------

View File

@ -55,10 +55,6 @@ public:
void findCellAndGridIndex(const RivCrossSectionSourceInfo* crossSectionSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex);
void setActiveUiCommandFeature(RicCommandFeature* uiCommandFeature);
RicCommandFeature* activeUiCommandFeature() const;
private slots:
void slotRangeFilterI();
void slotRangeFilterJ();