Beispiel #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimGridSummaryCase::associatedEclipseCase()
{
    if (!m_eclipseCase())
    {
        // Find a possible associated eclipse case

        RimProject* project;
        firstAncestorOrThisOfTypeAsserted(project);
        std::vector<RimCase*> allCases;
        project->allCases(allCases);
        for ( RimCase* someCase: allCases )
        {
            auto eclCase = dynamic_cast<RimEclipseCase*>(someCase);
            if ( eclCase )
            {
                QString sumHeaderFileName = summaryHeaderFilenameFromEclipseCase(eclCase);
                if ( sumHeaderFileName == m_summaryHeaderFilename )
                {
                    m_eclipseCase = eclCase;
                    this->updateAutoShortName();
                    this->updateTreeItemName();

                    break;
                }
            }
        }
    }

    return m_eclipseCase();
}
    virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>&  args, QDataStream& socketStream)
    {
        int argCaseGroupId = -1;

        if (args.size() == 2)
        {
            argCaseGroupId = args[1].toInt();
        }

        RimProject* proj = RiaApplication::instance()->project();
        RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL;
        if (analysisModels)
        {

            std::vector<RimCase*> cases;
            if (argCaseGroupId == -1)
            {
                proj->allCases(cases);
            }
            else
            {
                RimIdenticalGridCaseGroup* caseGroup = NULL;
                for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
                {
                    RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];

                    if (argCaseGroupId == cg->groupId())
                    {
                        caseGroup = cg;
                    }
                }

                if (caseGroup)
                {
                    for (size_t i = 0; i < caseGroup->statisticsCaseCollection()->reservoirs.size(); i++)
                    {
                        cases.push_back(caseGroup->statisticsCaseCollection()->reservoirs[i]);
                    }

                    for (size_t i = 0; i < caseGroup->caseCollection()->reservoirs.size(); i++)
                    {
                        cases.push_back(caseGroup->caseCollection()->reservoirs[i]);
                    }
                }
            }


            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 caseCount = caseIds.size();

            for (size_t i = 0; i < caseCount; i++)
            {
                byteCount += 2*sizeof(qint64);
                byteCount += caseNames[i].size() * sizeof(QChar);
                byteCount += caseTypes[i].size() * sizeof(QChar);
            }

            socketStream << byteCount;
            socketStream << caseCount;

            for (size_t i = 0; i < caseCount; i++)
            {
                socketStream << caseIds[i];
                socketStream << caseNames[i];
                socketStream << caseTypes[i];
                socketStream << caseGroupIds[i];
            }
        }

        return true;
    }