mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Various operations on color legends
This commit is contained in:
parent
fd475589a5
commit
d39bcb31ab
@ -1,10 +1,16 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategories.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategoriesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCopyStandardLegendFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendItemFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategories.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategoriesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCopyStandardLegendFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendItemFeature.cpp
|
||||
)
|
||||
|
||||
|
||||
|
@ -0,0 +1,92 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "RicCopyStandardLegendFeature.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicCopyStandardLegendFeature, "RicCopyStandardLegendFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCopyStandardLegendFeature::isCommandEnabled()
|
||||
{
|
||||
if ( selectedColorLegend() ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyStandardLegendFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimColorLegend* standardLegend = selectedColorLegend();
|
||||
|
||||
if ( standardLegend )
|
||||
{
|
||||
// perform deep copy of standard legend object via XML
|
||||
RimColorLegend* customLegend = dynamic_cast<RimColorLegend*>(
|
||||
standardLegend->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
|
||||
customLegend->setColorLegendName( "Copy of " + standardLegend->colorLegendName() );
|
||||
|
||||
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
|
||||
|
||||
colorLegendCollection->appendCustomColorLegend( customLegend );
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( customLegend );
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( customLegend );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyStandardLegendFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/Legend.png" ) );
|
||||
actionToSetup->setText( "Copy Legend to Custom Legends" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegend* RicCopyStandardLegendFeature::selectedColorLegend()
|
||||
{
|
||||
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
|
||||
if ( !selectedObject ) return nullptr;
|
||||
|
||||
RimColorLegend* colorLegend = nullptr;
|
||||
|
||||
selectedObject->firstAncestorOrThisOfType( colorLegend );
|
||||
if ( colorLegend ) return colorLegend;
|
||||
|
||||
return nullptr;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimColorLegend;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCopyStandardLegendFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimColorLegend* selectedColorLegend();
|
||||
};
|
@ -16,7 +16,7 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicImportColorCategories.h"
|
||||
#include "RicImportColorCategoriesFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
@ -30,23 +30,35 @@
|
||||
#include "RifColorLegendData.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicImportColorCategories, "RicImportColorCategories" );
|
||||
CAF_CMD_SOURCE_INIT( RicImportColorCategoriesFeature, "RicImportColorCategoriesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportColorCategories::isCommandEnabled()
|
||||
bool RicImportColorCategoriesFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
RimColorLegendCollection* legendCollection = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( legendCollection );
|
||||
}
|
||||
|
||||
if ( legendCollection ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportColorCategories::onActionTriggered( bool isChecked )
|
||||
void RicImportColorCategoriesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
|
||||
@ -70,13 +82,13 @@ void RicImportColorCategories::onActionTriggered( bool isChecked )
|
||||
const std::vector<cvf::Color3f>& formationColors = formations->formationColors();
|
||||
|
||||
RimColorLegend* colorLegend = new RimColorLegend;
|
||||
colorLegend->setColorLegendName( "LYR imported color legend" );
|
||||
colorLegend->setColorLegendName( QFileInfo( fileName ).baseName() );
|
||||
|
||||
for ( size_t i = 0; i < formationColors.size(); i++ )
|
||||
{
|
||||
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
|
||||
|
||||
colorLegendItem->setValues( formationNames[i], i, formationColors[i] );
|
||||
colorLegendItem->setValues( formationNames[i], (int)i, formationColors[i] );
|
||||
|
||||
colorLegend->appendColorLegendItem( colorLegendItem );
|
||||
}
|
||||
@ -85,15 +97,18 @@ void RicImportColorCategories::onActionTriggered( bool isChecked )
|
||||
|
||||
RimColorLegendCollection* colorLegendCollection = proj->colorLegendCollection;
|
||||
|
||||
colorLegendCollection->appendColorLegend( colorLegend );
|
||||
colorLegendCollection->appendCustomColorLegend( colorLegend );
|
||||
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( colorLegend );
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( colorLegend );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportColorCategories::setupActionLook( QAction* actionToSetup )
|
||||
void RicImportColorCategoriesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/Formations16x16.png" ) );
|
||||
actionToSetup->setText( "Import Color Legend from LYR Formation File" );
|
@ -23,7 +23,7 @@
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportColorCategories : public caf::CmdFeature
|
||||
class RicImportColorCategoriesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
@ -0,0 +1,92 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "RicInsertColorLegendFeature.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicInsertColorLegendFeature, "RicInsertColorLegendFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicInsertColorLegendFeature::isCommandEnabled()
|
||||
{
|
||||
if ( selectedColorLegendCollection() ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// TODO: insert new color legend prior to entry of selected color legend ?
|
||||
/// C.f. RicNewAnalysisPlotFeature.cpp(70-71)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicInsertColorLegendFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimColorLegendCollection* colorLegendCollection = selectedColorLegendCollection();
|
||||
|
||||
if ( colorLegendCollection )
|
||||
{
|
||||
RimColorLegend* customLegend = new RimColorLegend();
|
||||
customLegend->setColorLegendName( "New Color Legend" );
|
||||
|
||||
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
|
||||
|
||||
colorLegendCollection->appendCustomColorLegend( customLegend );
|
||||
caf::SelectionManager::instance()->setSelectedItem( customLegend );
|
||||
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( customLegend );
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( customLegend );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicInsertColorLegendFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/Legend.png" ) );
|
||||
actionToSetup->setText( "New Custom Color Legend" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// C.f. RicNewAnalysisPlotFeature.cpp(42)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegendCollection* RicInsertColorLegendFeature::selectedColorLegendCollection()
|
||||
{
|
||||
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
|
||||
if ( !selectedObject ) return nullptr;
|
||||
|
||||
RimColorLegendCollection* colorLegendCollection = nullptr;
|
||||
|
||||
selectedObject->firstAncestorOrThisOfType( colorLegendCollection );
|
||||
if ( colorLegendCollection ) return colorLegendCollection;
|
||||
|
||||
return nullptr;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimColorLegendCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicInsertColorLegendFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimColorLegendCollection* selectedColorLegendCollection();
|
||||
};
|
@ -0,0 +1,102 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "RicInsertColorLegendItemFeature.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicInsertColorLegendItemFeature, "RicInsertColorLegendItemFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Disallows insert of color legend item in standard color legends
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicInsertColorLegendItemFeature::isCommandEnabled()
|
||||
{
|
||||
RimColorLegend* legend = selectedColorLegend();
|
||||
|
||||
if ( legend )
|
||||
{
|
||||
RimColorLegendCollection* colorLegendCollection = nullptr;
|
||||
|
||||
legend->firstAncestorOrThisOfType( colorLegendCollection );
|
||||
|
||||
if ( colorLegendCollection && !colorLegendCollection->isStandardColorLegend( legend ) ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// TODO: insert new color legend item prior to selected color legend item?
|
||||
/// C.f. RicNewAnalysisPlotFeature.cpp(70-71)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicInsertColorLegendItemFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimColorLegend* legend = selectedColorLegend();
|
||||
|
||||
if ( legend )
|
||||
{
|
||||
RimColorLegendItem* newLegendItem = new RimColorLegendItem();
|
||||
|
||||
legend->appendColorLegendItem( newLegendItem );
|
||||
legend->updateConnectedEditors();
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItem( newLegendItem );
|
||||
|
||||
legend->updateConnectedEditors();
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( newLegendItem );
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( newLegendItem );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicInsertColorLegendItemFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/Legend.png" ) );
|
||||
actionToSetup->setText( "Append Color Legend Item" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// C.f. RicNewAnalysisPlotFeature.cpp(42)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegend* RicInsertColorLegendItemFeature::selectedColorLegend()
|
||||
{
|
||||
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
|
||||
if ( !selectedObject ) return nullptr;
|
||||
|
||||
RimColorLegend* colorLegend = nullptr;
|
||||
|
||||
selectedObject->firstAncestorOrThisOfType( colorLegend );
|
||||
|
||||
if ( colorLegend ) return colorLegend;
|
||||
|
||||
return nullptr;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimColorLegend;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicInsertColorLegendItemFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimColorLegend* selectedColorLegend();
|
||||
};
|
@ -77,6 +77,8 @@
|
||||
#include "cafPdmReferenceHelper.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteItemFeature, "RicDeleteItemFeature" );
|
||||
@ -143,6 +145,8 @@ bool isDeletable( caf::PdmUiItem* uiItem )
|
||||
if ( dynamic_cast<RimPolylinesAnnotation*>( uiItem ) ) return true;
|
||||
if ( dynamic_cast<RimIntersectionResultDefinition*>( uiItem ) ) return true;
|
||||
if ( dynamic_cast<RimSurface*>( uiItem ) ) return true;
|
||||
if ( dynamic_cast<RimColorLegend*>( uiItem ) ) return true;
|
||||
if ( dynamic_cast<RimColorLegendItem*>( uiItem ) ) return true;
|
||||
|
||||
if ( dynamic_cast<RimGridCrossPlot*>( uiItem ) )
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ void RicImportFaciesFeature::onActionTriggered( bool isChecked )
|
||||
}
|
||||
|
||||
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
|
||||
colorLegendCollection->appendColorLegend( colorLegend );
|
||||
colorLegendCollection->appendCustomColorLegend( colorLegend );
|
||||
colorLegendCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,9 @@ RimColorLegend::~RimColorLegend()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimColorLegend::userDescriptionField()
|
||||
QString RimColorLegend::colorLegendName()
|
||||
{
|
||||
return &m_colorLegendName;
|
||||
return m_colorLegendName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -57,6 +57,19 @@ void RimColorLegend::setColorLegendName( const QString& colorLegendName )
|
||||
m_colorLegendName = colorLegendName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegend::setReadOnly( bool doReadOnly )
|
||||
{
|
||||
m_colorLegendName.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
for ( auto colorLegendItem : m_colorLegendItems )
|
||||
{
|
||||
colorLegendItem->setReadOnly( true );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -73,6 +86,14 @@ std::vector<RimColorLegendItem*> RimColorLegend::colorLegendItems() const
|
||||
return m_colorLegendItems.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimColorLegend::userDescriptionField()
|
||||
{
|
||||
return &m_colorLegendName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -42,7 +42,12 @@ public:
|
||||
~RimColorLegend() override;
|
||||
|
||||
public:
|
||||
QString colorLegendName();
|
||||
|
||||
void setColorLegendName( const QString& colorLegendName );
|
||||
|
||||
void setReadOnly( bool doReadOnly );
|
||||
|
||||
void appendColorLegendItem( RimColorLegendItem* colorLegendItem );
|
||||
|
||||
std::vector<RimColorLegendItem*> colorLegendItems() const;
|
||||
|
@ -18,6 +18,11 @@
|
||||
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "RimColorLegendItem.h"
|
||||
#include "RimProject.h"
|
||||
#include <QString>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegendCollection, "ColorLegendCollection" );
|
||||
|
||||
@ -26,10 +31,16 @@ CAF_PDM_SOURCE_INIT( RimColorLegendCollection, "ColorLegendCollection" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegendCollection::RimColorLegendCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "ColorLegendCollection", ":/Formations16x16.png", "", "" );
|
||||
CAF_PDM_InitObject( "Color Legend Collection", ":/Legend.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorLegends, "ColorLegends", "", "", "", "" );
|
||||
m_colorLegends.uiCapability()->setUiHidden( true );
|
||||
CAF_PDM_InitFieldNoDefault( &m_standardColorLegends,
|
||||
"StandardColorLegends",
|
||||
"Standard Color Legends",
|
||||
":/Legend.png",
|
||||
"",
|
||||
"" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_customColorLegends, "CustomColorLegends", "Custom Color Legends", ":/Legend.png", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -42,17 +53,86 @@ RimColorLegendCollection::~RimColorLegendCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::appendColorLegend( RimColorLegend* colorLegend )
|
||||
void RimColorLegendCollection::appendCustomColorLegend( RimColorLegend* colorLegend )
|
||||
{
|
||||
m_colorLegends.push_back( colorLegend );
|
||||
m_customColorLegends.push_back( colorLegend );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimColorLegend*> RimColorLegendCollection::colorLegends() const
|
||||
bool RimColorLegendCollection::isStandardColorLegend( RimColorLegend* legend )
|
||||
{
|
||||
return m_colorLegends.childObjects();
|
||||
for ( auto standardLegend : m_standardColorLegends )
|
||||
{
|
||||
if ( legend == standardLegend ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::deleteCustomColorLegends()
|
||||
{
|
||||
m_customColorLegends.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::createStandardColorLegends()
|
||||
{
|
||||
typedef caf::AppEnum<RimRegularLegendConfig::ColorRangesType> ColorRangeEnum;
|
||||
|
||||
for ( size_t typeIdx = 0; typeIdx < ColorRangeEnum::size(); typeIdx++ )
|
||||
{
|
||||
QString legendName = ColorRangeEnum::uiTextFromIndex( typeIdx );
|
||||
cvf::Color3ubArray colorArray =
|
||||
RimRegularLegendConfig::colorArrayFromColorType( ColorRangeEnum::fromIndex( typeIdx ) );
|
||||
|
||||
RimColorLegend* colorLegend = new RimColorLegend;
|
||||
colorLegend->setColorLegendName( legendName );
|
||||
|
||||
for ( int i = (int)colorArray.size() - 1; i > -1; i-- ) // reverse to assign last color to top of legend
|
||||
{
|
||||
cvf::Color3f color3f( colorArray[i] );
|
||||
QColor colorQ( colorArray[i].r(), colorArray[i].g(), colorArray[i].b() );
|
||||
|
||||
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
|
||||
colorLegendItem->setValues( colorQ.name(), i, color3f );
|
||||
|
||||
colorLegend->appendColorLegendItem( colorLegendItem );
|
||||
colorLegend->setReadOnly( true );
|
||||
}
|
||||
|
||||
m_standardColorLegends.push_back( colorLegend );
|
||||
}
|
||||
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimColorLegend*> RimColorLegendCollection::customColorLegends() const
|
||||
{
|
||||
std::vector<RimColorLegend*> allLegends;
|
||||
|
||||
auto standardLegends = m_standardColorLegends.childObjects();
|
||||
for ( auto l : standardLegends )
|
||||
{
|
||||
allLegends.push_back( l );
|
||||
}
|
||||
|
||||
auto customLegends = m_customColorLegends.childObjects();
|
||||
for ( auto l : customLegends )
|
||||
{
|
||||
allLegends.push_back( l );
|
||||
}
|
||||
|
||||
return allLegends;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -41,12 +41,19 @@ public:
|
||||
RimColorLegendCollection();
|
||||
~RimColorLegendCollection() override;
|
||||
|
||||
void appendColorLegend( RimColorLegend* colorLegend );
|
||||
void createStandardColorLegends();
|
||||
|
||||
std::vector<RimColorLegend*> colorLegends() const;
|
||||
void appendCustomColorLegend( RimColorLegend* customColorLegend );
|
||||
|
||||
bool isStandardColorLegend( RimColorLegend* colorLegend );
|
||||
|
||||
void deleteCustomColorLegends();
|
||||
|
||||
std::vector<RimColorLegend*> customColorLegends() const;
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimColorLegend*> m_colorLegends;
|
||||
caf::PdmChildArrayField<RimColorLegend*> m_standardColorLegends; // ResInsight standard (built-in) legends
|
||||
caf::PdmChildArrayField<RimColorLegend*> m_customColorLegends; // user specified legends
|
||||
};
|
||||
|
@ -33,6 +33,7 @@ RimColorLegendItem::RimColorLegendItem()
|
||||
CAF_PDM_InitObject( "ColorLegendItem", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_color, "Color", "Color", "", "", "" );
|
||||
m_color = cvf::Color3f( cvf::Color3::ColorIdent::BLACK );
|
||||
|
||||
CAF_PDM_InitField( &m_categoryValue, "CategoryValue", 0, "Category Value", "", "", "" );
|
||||
CAF_PDM_InitField( &m_categoryName, "CategoryName", QString( "" ), "Category Name", "", "", "" );
|
||||
@ -60,6 +61,16 @@ void RimColorLegendItem::setValues( const QString& categoryName, int categoryVal
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendItem::setReadOnly( bool doReadOnly )
|
||||
{
|
||||
m_categoryName.uiCapability()->setUiReadOnly( true );
|
||||
m_categoryValue.uiCapability()->setUiReadOnly( true );
|
||||
m_color.uiCapability()->setUiReadOnly( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -41,7 +41,9 @@ public:
|
||||
RimColorLegendItem();
|
||||
~RimColorLegendItem() override;
|
||||
|
||||
void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color );
|
||||
void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color );
|
||||
void setReadOnly( bool doReadOnly );
|
||||
|
||||
const cvf::Color3f& color() const;
|
||||
const QString& categoryName() const;
|
||||
int categoryValue() const;
|
||||
@ -49,6 +51,7 @@ public:
|
||||
public:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) override;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
private:
|
||||
|
@ -39,7 +39,9 @@
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
#include "RimCorrelationMatrixPlot.h"
|
||||
#include "RimCorrelationPlot.h"
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
@ -792,8 +794,20 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
}
|
||||
else if ( dynamic_cast<RimColorLegendCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicImportColorCategories";
|
||||
menuBuilder << "RicInsertColorLegendFeature";
|
||||
menuBuilder << "RicImportColorCategoriesFeature"; // import of color legend from LYR file
|
||||
}
|
||||
else if ( dynamic_cast<RimColorLegend*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicInsertColorLegendFeature";
|
||||
menuBuilder << "RicCopyStandardLegendFeature";
|
||||
menuBuilder << "RicInsertColorLegendItemFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimColorLegendItem*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicInsertColorLegendItemFeature";
|
||||
}
|
||||
|
||||
else if ( dynamic_cast<RimFormationNames*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicImportFormationNamesFeature";
|
||||
|
@ -133,6 +133,7 @@ RimProject::RimProject( void )
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &colorLegendCollection, "ColorLegendCollection", "Color Legend Collection", "", "", "" );
|
||||
colorLegendCollection = new RimColorLegendCollection();
|
||||
colorLegendCollection->createStandardColorLegends();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png", "", "" );
|
||||
scriptCollection.uiCapability()->setUiHidden( true );
|
||||
@ -256,6 +257,7 @@ void RimProject::close()
|
||||
m_dialogData->clearProjectSpecificData();
|
||||
|
||||
calculationCollection->deleteAllContainedObjects();
|
||||
colorLegendCollection->deleteCustomColorLegends();
|
||||
|
||||
delete viewLinkerCollection->viewLinker();
|
||||
viewLinkerCollection->viewLinker = nullptr;
|
||||
|
@ -2525,7 +2525,7 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot()
|
||||
|
||||
RimProject* proj = RimProject::current();
|
||||
RimColorLegendCollection* colorLegendCollection = proj->colorLegendCollection;
|
||||
std::vector<RimColorLegend*> legends = colorLegendCollection->colorLegends();
|
||||
std::vector<RimColorLegend*> legends = colorLegendCollection->customColorLegends();
|
||||
if ( legends.empty() )
|
||||
{
|
||||
RiaLogging::error( "No color legend found." );
|
||||
|
Loading…
Reference in New Issue
Block a user