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:
Magne Sjaastad
2024-03-01 14:59:14 +01:00
committed by GitHub
parent 04b14cf52a
commit 818c5c0f9c
37 changed files with 1117 additions and 159 deletions

View File

@@ -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 );

View File

@@ -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 );

View File

@@ -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;
};