예제 #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuViewer::handlePickAction(int winPosX, int winPosY)
{
    RiaApplication* app = RiaApplication::instance();

    RiuMainWindow* mainWnd = RiuMainWindow::instance();
    if (!mainWnd) return;

    QString pickInfo = "No hits";
    QString resultInfo = "";

    uint faceIndex = cvf::UNDEFINED_UINT;
    cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);

    cvf::Part * firstHitPart = NULL;
    firstHitPart = pickPointAndFace(winPosX, winPosY, &faceIndex, &localIntersectionPoint);
    if (firstHitPart)
    {
        // If a drawable geometry was hit, get info about the picked geometry
        // and possibly the picked scalar value, if any
        if (faceIndex != cvf::UNDEFINED_UINT)
        {
            size_t gridIndex = firstHitPart->id();

            size_t cellIndex = cvf::UNDEFINED_SIZE_T;
            if (firstHitPart->sourceInfo())
            {
                const cvf::Array<size_t>* cellIndices = dynamic_cast<const cvf::Array<size_t>*>(firstHitPart->sourceInfo());
                if (cellIndices)
                {
                    cellIndex = cellIndices->get(faceIndex);

                    m_reservoirView->pickInfo(gridIndex, cellIndex, localIntersectionPoint, &pickInfo);

                    if (isAnimationActive())
                    {
                        m_reservoirView->appendCellResultInfo(gridIndex, cellIndex, &resultInfo);
                    }
#if 0
                    const RigReservoir* reservoir = m_reservoirView->eclipseCase()->reservoirData();
                    const RigGridBase* grid = reservoir->grid(gridIndex);
                    const RigCell& cell = grid->cell(cellIndex);
                    const caf::SizeTArray8& cellNodeIndices = cell.cornerIndices();
                    const std::vector<cvf::Vec3d>& nodes = reservoir->mainGrid()->nodes();
                    for (int i = 0; i < 8; ++i)
                    {
                        resultInfo += QString::number(i) + " : ";
                        for (int j = 0; j < 3; ++j)
                            resultInfo += QString::number(nodes[cellNodeIndices[i]][j], 'g', 10) + " ";
                         resultInfo += "\n";
                    }
#endif
                }
            }
        }
    }

    mainWnd->statusBar()->showMessage(pickInfo);
    mainWnd->setResultInfo(resultInfo);
}
예제 #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAdded) const
{
    QString resultInfo;
    QString pickInfo;

    RiuSelectionItem* selItem = const_cast<RiuSelectionItem*>(itemAdded);
    if (selItem != nullptr)
    {
        Rim2dIntersectionView* intersectionView = nullptr;

        if (selItem->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT)
        {
            const Riu2dIntersectionSelectionItem* wrapperSelItem = dynamic_cast<Riu2dIntersectionSelectionItem*>(selItem);
            if (wrapperSelItem)
            {
                intersectionView = wrapperSelItem->view();
                if (wrapperSelItem->eclipseSelectionItem())
                {
                    selItem = wrapperSelItem->eclipseSelectionItem();
                }
                else if (wrapperSelItem->geoMechSelectionItem())
                {
                    selItem = wrapperSelItem->geoMechSelectionItem();
                }
            }
        }

        if (selItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
        {
            const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(selItem);

            RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p();

            RiuResultTextBuilder textBuilder(eclipseView, eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex, eclipseView->currentTimeStep());
            textBuilder.setFace(eclipseSelectionItem->m_face);
            textBuilder.setNncIndex(eclipseSelectionItem->m_nncIndex);
            textBuilder.setIntersectionPointInDisplay(eclipseSelectionItem->m_localIntersectionPointInDisplay);
            textBuilder.set2dIntersectionView(intersectionView);

            resultInfo = textBuilder.mainResultText();

            pickInfo = textBuilder.geometrySelectionText(", ");
        }
        else if (selItem->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT)
        {
            const RiuGeoMechSelectionItem* geomSelectionItem = static_cast<const RiuGeoMechSelectionItem*>(selItem);

            RimGeoMechView* geomView = geomSelectionItem->m_view.p();
            RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep());
            textBuilder.setIntersectionPointInDisplay(geomSelectionItem->m_localIntersectionPointInDisplay);
            textBuilder.setFace(geomSelectionItem->m_elementFace);
            textBuilder.set2dIntersectionView(intersectionView);
            if (geomSelectionItem->m_hasIntersectionTriangle) textBuilder.setIntersectionTriangle(geomSelectionItem->m_intersectionTriangle);

            resultInfo = textBuilder.mainResultText();

            pickInfo = textBuilder.geometrySelectionText(", ");
        }
    }

    RiuMainWindow* mainWnd = RiuMainWindow::instance();
    mainWnd->statusBar()->showMessage(pickInfo);
    mainWnd->setResultInfo(resultInfo);
}