//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExecuteScriptFeature::onActionTriggered(bool isChecked) { std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts(); CVF_ASSERT(selection.size() > 0); RiuMainWindow* mainWindow = RiuMainWindow::instance(); mainWindow->showProcessMonitorDockPanel(); RimCalcScript* calcScript = selection[0]; RiaApplication* app = RiaApplication::instance(); QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { // TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing // absolutePath() is a function in QFileInfo QFileInfo fi(calcScript->absolutePath()); QString octaveFunctionSearchPath = fi.absolutePath(); QStringList arguments = app->octaveArguments(); arguments.append("--path"); arguments << octaveFunctionSearchPath; arguments << calcScript->absolutePath(); RiaApplication::instance()->launchProcess(octavePath, arguments); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuViewer::slotRangeFilterK() { size_t i, j, k; ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); RiuMainWindow* mainWindow = RiuMainWindow::instance(); RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); if (myModel) { RimCellRangeFilterCollection* rangeFilterCollection = m_reservoirView->rangeFilterCollection(); QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(rangeFilterCollection); QModelIndex insertedIndex; RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(collectionModelIndex, insertedIndex); rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size()); rangeFilter->cellCountK = 1; int startIndex = CVF_MAX(static_cast<int>(k + 1), 1); rangeFilter->startIndexK = startIndex; rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); mainWindow->setCurrentObjectInTreeView(rangeFilter); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicTileWindowsFeature::onActionTriggered(bool isChecked) { RiuMainWindow* mainWindow = RiuMainWindow::instance(); if (mainWindow) { mainWindow->tileWindows(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicTileWindowsFeature::isCommandEnabled() { RiuMainWindow* mainWindow = RiuMainWindow::instance(); if (mainWindow) { return mainWindow->isAnyMdiSubWindowVisible(); } return false; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExecuteScriptFeature::onActionTriggered(bool isChecked) { std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts(); CVF_ASSERT(selection.size() > 0); RiuMainWindow* mainWindow = RiuMainWindow::instance(); mainWindow->showProcessMonitorDockPanel(); RimCalcScript* calcScript = selection[0]; RiaApplication* app = RiaApplication::instance(); QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { QStringList arguments = RimCalcScript::createCommandLineArguments(calcScript->absoluteFileName()); RiaApplication::instance()->launchProcess(octavePath, arguments); } }
int main(int argc, char *argv[]) { RiaApplication app(argc, argv); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); setlocale(LC_NUMERIC,"C"); RiuMainWindow window; QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)"; window.setWindowTitle("ResInsight " + platform); window.setDefaultWindowSize(); window.show(); if (app.parseArguments()) { return app.exec(); } return 0; }
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) { RiuMainWindow* ruiMainWindow = RiuMainWindow::instance(); if (ruiMainWindow) { std::vector<RimCase*> cases; ruiMainWindow->selectedCases(cases); std::vector<qint64> caseIds; std::vector<QString> caseNames; std::vector<QString> caseTypes; std::vector<qint64> caseGroupIds; getCaseInfoFromCases(cases, caseIds, caseNames, caseTypes, caseGroupIds); quint64 byteCount = sizeof(quint64); quint64 selectionCount = caseIds.size(); for (size_t i = 0; i < selectionCount; i++) { byteCount += 2*sizeof(qint64); byteCount += caseNames[i].size() * sizeof(QChar); byteCount += caseTypes[i].size() * sizeof(QChar); } socketStream << byteCount; socketStream << selectionCount; for (size_t i = 0; i < selectionCount; i++) { socketStream << caseIds[i]; socketStream << caseNames[i]; socketStream << caseTypes[i]; socketStream << caseGroupIds[i]; } } return true; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicShowMainWindowFeature::onActionTriggered(bool isChecked) { this->disableModelChangeContribution(); RiuMainWindow* mainWnd = RiuMainWindow::instance(); if (mainWnd->isMinimized()) { mainWnd->showNormal(); mainWnd->update(); } else { mainWnd->show(); } mainWnd->raise(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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); }