mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add polygon file readers and make sure UI items are in sync
* Add polygon reader for POL file format * Add CSV import * Add helper function to create tag with color and text * Show polygon color as tag, allow color edit by clicking on tag * Support optional header in csv file * Add Reload on polygon file * Show warning icon if no polygons * Improve logging text * Do not show file polygon in view if no polygons are imported * Use appendMenuItems * Set default polygon color to orange * Enter edit state when creating a new polygon * Fix missing UI text in menu builder
This commit is contained in:
@@ -204,7 +204,7 @@ void CmdFeatureMenuBuilder::appendToMenu( QMenu* menu )
|
||||
}
|
||||
else
|
||||
{
|
||||
act = commandManager->action( m_items[i].itemName );
|
||||
act = commandManager->action( m_items[i].itemName, m_items[i].uiText );
|
||||
}
|
||||
|
||||
CAF_ASSERT( act );
|
||||
|
||||
@@ -47,12 +47,36 @@ std::unique_ptr<caf::PdmUiTreeViewItemAttribute::Tag> caf::PdmUiTreeViewItemAttr
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute,
|
||||
std::unique_ptr<caf::PdmUiTreeViewItemAttribute::Tag>
|
||||
caf::PdmUiTreeViewItemAttribute::createTag( const QColor& color, const QColor& backgroundColor, const QString& text )
|
||||
{
|
||||
auto tag = createTag();
|
||||
|
||||
auto weight1 = 100;
|
||||
double transparency = 0.3;
|
||||
int weight2 = std::max( 1, static_cast<int>( weight1 * 10 * transparency ) );
|
||||
|
||||
int weightsum = weight1 + weight2;
|
||||
|
||||
auto blendedColor = QColor( ( color.red() * weight1 + backgroundColor.red() * weight2 ) / weightsum,
|
||||
( color.green() * weight1 + backgroundColor.green() * weight2 ) / weightsum,
|
||||
( color.blue() * weight1 + backgroundColor.blue() * weight2 ) / weightsum );
|
||||
|
||||
tag->bgColor = blendedColor;
|
||||
tag->fgColor = color;
|
||||
tag->text = text;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute,
|
||||
const QString& iconResourceString )
|
||||
{
|
||||
if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
|
||||
{
|
||||
treeItemAttribute->tags.clear();
|
||||
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
|
||||
tag->icon = caf::IconProvider( iconResourceString );
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ public:
|
||||
};
|
||||
|
||||
static std::unique_ptr<Tag> createTag();
|
||||
static void createTagIfTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, const QString& iconString );
|
||||
static std::unique_ptr<Tag> createTag( const QColor& color, const QColor& backgroundColor, const QString& text );
|
||||
static void appendTagToTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, const QString& iconString );
|
||||
|
||||
std::vector<std::unique_ptr<Tag>> tags;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user