mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
40080a99de
* Improve tree selection editor - always call defineEditorAttributes - use heightHint in editor attributes - use tree selection editor as default editor for std::vector * Use tree selection editor instead of list selection editor List selection editor must be used when editing std::vector<cvf::vec3d> and similar. Replace other use of list selection editor with tree selection editor. * Set checked state based on text string for integer only models For models with only integer values, use text string to define the items to be selected. The full list will always be visible, and the checked state will be updated when editing the filter text. Example: "1, 5-7" will set items 1, 5, 6, 7 checked and all other items unchecked * Minor fixes - Set placeholder text after content is added (to ensure correct data type) - Fix check of integers. `canConvert<int>()`returns true for both QString and int. Thus convert to string and then check for int conversion. * Activate filtering when unchecking all items in list with only integers - Reactivate filtering when uncheck of all items for a list with only integer values (to keep consistency between filter and list) - Update function name for clarity --------- Co-authored-by: Jørgen Herje <jorgen.herje@ceetronsolutions.com>
130 lines
5.0 KiB
C++
130 lines
5.0 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2021- Equinor 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 "RicCreateEnsembleSurfaceUi.h"
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "cafPdmObject.h"
|
|
#include "cafPdmUiCheckBoxEditor.h"
|
|
#include "cafPdmUiOrdering.h"
|
|
#include "cafPdmUiTreeSelectionEditor.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RicCreateEnsembleSurfaceUi, "RicCreateEnsembleSurfaceUi" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RicCreateEnsembleSurfaceUi::RicCreateEnsembleSurfaceUi()
|
|
{
|
|
CAF_PDM_InitObject( "Export Multiple Surfaces" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_layers, "Layers", "Layers" );
|
|
CAF_PDM_InitField( &m_autoCreateEnsembleSurfaces, "AutoCreateEnsembleSurfaces", false, "Create Ensemble Surfaces From Exported Files" );
|
|
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_autoCreateEnsembleSurfaces );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_minLayer, "MinLayer", "MinLayer" );
|
|
CAF_PDM_InitFieldNoDefault( &m_maxLayer, "MaxLayer", "MaxLayer" );
|
|
|
|
m_tabNames << "Configuration";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RicCreateEnsembleSurfaceUi::~RicCreateEnsembleSurfaceUi()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const QStringList& RicCreateEnsembleSurfaceUi::tabNames() const
|
|
{
|
|
return m_tabNames;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicCreateEnsembleSurfaceUi::setLayersMinMax( int minLayer, int maxLayer )
|
|
{
|
|
m_minLayer = minLayer;
|
|
m_maxLayer = maxLayer;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicCreateEnsembleSurfaceUi::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
|
{
|
|
if ( field == &m_layers )
|
|
{
|
|
auto myAttr = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>( attribute );
|
|
if ( myAttr )
|
|
{
|
|
myAttr->heightHint = 280;
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicCreateEnsembleSurfaceUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
{
|
|
if ( uiConfigName == m_tabNames[0] )
|
|
{
|
|
uiOrdering.add( &m_layers );
|
|
uiOrdering.add( &m_autoCreateEnsembleSurfaces );
|
|
}
|
|
uiOrdering.skipRemainingFields( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QList<caf::PdmOptionItemInfo> RicCreateEnsembleSurfaceUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
|
{
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
if ( fieldNeedingOptions == &m_layers )
|
|
{
|
|
for ( int layer = m_minLayer; layer < m_maxLayer; layer++ )
|
|
{
|
|
options.push_back( caf::PdmOptionItemInfo( QString::number( layer ), layer ) );
|
|
}
|
|
}
|
|
return options;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<int> RicCreateEnsembleSurfaceUi::layers() const
|
|
{
|
|
return m_layers();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicCreateEnsembleSurfaceUi::autoCreateEnsembleSurfaces() const
|
|
{
|
|
return m_autoCreateEnsembleSurfaces;
|
|
}
|