Allow hiding of category name in color legend item

This commit is contained in:
Magne Sjaastad
2024-06-20 08:34:05 +02:00
parent 736bfd9a96
commit 3164b39225
5 changed files with 41 additions and 7 deletions

View File

@@ -38,15 +38,12 @@ CAF_CMD_SOURCE_INIT( RicInsertColorLegendItemFeature, "RicInsertColorLegendItemF
bool RicInsertColorLegendItemFeature::isCommandEnabled() const bool RicInsertColorLegendItemFeature::isCommandEnabled() const
{ {
RimColorLegend* legend = selectedColorLegend(); RimColorLegend* legend = selectedColorLegend();
if ( !legend ) return false;
if ( legend )
{
RimColorLegendCollection* colorLegendCollection = legend->firstAncestorOrThisOfType<RimColorLegendCollection>(); RimColorLegendCollection* colorLegendCollection = legend->firstAncestorOrThisOfType<RimColorLegendCollection>();
if ( !colorLegendCollection ) return true;
if ( colorLegendCollection && !colorLegendCollection->isStandardColorLegend( legend ) ) return true; return !colorLegendCollection->isStandardColorLegend( legend );
}
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -58,6 +58,15 @@ RimColorLegendItem::~RimColorLegendItem()
{ {
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimColorLegendItem::setCategoryFieldsHidden( bool hidden )
{
m_categoryName.uiCapability()->setUiHidden( hidden );
m_categoryValue.uiCapability()->setUiHidden( hidden );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -41,6 +41,8 @@ public:
RimColorLegendItem(); RimColorLegendItem();
~RimColorLegendItem() override; ~RimColorLegendItem() override;
void setCategoryFieldsHidden( bool hidden );
void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color ); void setValues( const QString& categoryName, int categoryValue, const cvf::Color3f& color );
void setCategoryValue( int categoryValue ); void setCategoryValue( int categoryValue );
void setReadOnly( bool doReadOnly ); void setReadOnly( bool doReadOnly );

View File

@@ -250,6 +250,8 @@ void RimCustomVfpPlot::createDefaultColors()
} }
m_legendConfig->setColorLegend( m_colorLegend ); m_legendConfig->setColorLegend( m_colorLegend );
setColorItemCategoryHidden();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -712,6 +714,14 @@ void RimCustomVfpPlot::onLoadDataAndUpdate()
m_plotWidget->scheduleReplot(); m_plotWidget->scheduleReplot();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomVfpPlot::initAfterRead()
{
setColorItemCategoryHidden();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1127,6 +1137,20 @@ void RimCustomVfpPlot::legendColorsChanged( const caf::SignalEmitter* emitter )
onLoadDataAndUpdate(); onLoadDataAndUpdate();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomVfpPlot::setColorItemCategoryHidden()
{
if ( m_colorLegend )
{
for ( auto item : m_colorLegend->colorLegendItems() )
{
item->setCategoryFieldsHidden( true );
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -96,6 +96,7 @@ private:
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override; void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
void deleteViewWidget() override; void deleteViewWidget() override;
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
void initAfterRead() override;
caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* userDescriptionField() override;
@@ -180,6 +181,7 @@ private:
caf::ColorTable curveColors() const; caf::ColorTable curveColors() const;
void legendColorsChanged( const caf::SignalEmitter* emitter ); void legendColorsChanged( const caf::SignalEmitter* emitter );
void setColorItemCategoryHidden();
private: private:
caf::PdmField<QString> m_plotTitle; caf::PdmField<QString> m_plotTitle;