#3343 HoloLens Export : Add factory to create option items for views

This commit is contained in:
Magne Sjaastad 2018-09-12 11:44:11 +02:00
parent f1dd707561
commit 08449ceb9e
4 changed files with 84 additions and 10 deletions

View File

@ -36,6 +36,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaOffshoreSphericalCoords.h
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedAverageCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedAverageCalculator.inl
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedGeometricMeanCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RiaOptionItemFactory.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -72,6 +73,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaSCurveCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaArcCurveCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaJCurveCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedGeometricMeanCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOptionItemFactory.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaOptionItemFactory.h"
#include "Rim3dView.h"
#include "RimCase.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName(Rim3dView* view, QList<caf::PdmOptionItemInfo>* optionItems)
{
if (!view || !optionItems) return;
QString caseName;
RimCase* rimCase = nullptr;
view->firstAncestorOrThisOfType(rimCase);
if (rimCase)
{
caseName = rimCase->caseUserDescription();
}
else
{
caseName = "<Unnamed case>";
}
QString displayName = caseName + " : " + view->name();
QIcon icon = view->uiCapability()->uiIcon();
optionItems->push_back(caf::PdmOptionItemInfo(displayName, view, false, icon));
}

View File

@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmUiItem.h"
#include <QList>
class Rim3dView;
class RiaOptionItemFactory
{
public:
static void appendOptionItemFromViewNameAndCaseName(Rim3dView* view, QList<caf::PdmOptionItemInfo>* optionItems);
};

View File

@ -19,6 +19,7 @@
#include "RicHoloLensExportToFolderUi.h"
#include "RiaApplication.h"
#include "RiaOptionItemFactory.h"
#include "RimCase.h"
#include "RimGridView.h"
@ -81,16 +82,7 @@ QList<caf::PdmOptionItemInfo> RicHoloLensExportToFolderUi::calculateValueOptions
for (RimGridView* v : visibleViews)
{
RimCase* rimCase = nullptr;
v->firstAncestorOrThisOfType(rimCase);
QIcon icon;
if (rimCase)
{
icon = rimCase->uiCapability()->uiIcon();
}
options.push_back(caf::PdmOptionItemInfo(v->name(), v, false, icon));
RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName(v, &options);
}
}