FEM: Add index over frames visualizations

This commit is contained in:
Stefan Tröger
2025-04-19 11:23:04 +02:00
parent c1b11a19f7
commit d3fa7ad8f0
25 changed files with 804 additions and 183 deletions

View File

@@ -445,11 +445,12 @@ SET(FemGuiPythonUI_SRCS
Resources/ui/TaskPostExtraction.ui
Resources/ui/TaskPostHistogram.ui
Resources/ui/TaskPostLineplot.ui
Resources/ui/PostExtractionSummaryWidget.ui
Resources/ui/PostHistogramFieldViewEdit.ui
Resources/ui/PostHistogramFieldAppEdit.ui
Resources/ui/PostHistogramIndexAppEdit.ui
Resources/ui/PostLineplotFieldViewEdit.ui
Resources/ui/PostLineplotFieldAppEdit.ui
Resources/ui/PostLineplotIndexAppEdit.ui
)
ADD_CUSTOM_TARGET(FemPythonUi ALL

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>293</width>
<height>126</height>
<width>278</width>
<height>110</height>
</rect>
</property>
<property name="windowTitle">
@@ -68,7 +68,7 @@
<item row="1" column="2">
<widget class="QComboBox" name="Hatch">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -93,7 +93,7 @@
<item row="1" column="3">
<widget class="QSpinBox" name="HatchDensity">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -113,10 +113,20 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="Legend"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Legend:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::ColorButton" name="LineColor">
<widget class="QToolButton" name="LineColor">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -127,7 +137,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::ColorButton" name="BarColor">
<widget class="QToolButton" name="BarColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -139,27 +149,10 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="Legend"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Legend:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>Legend</tabstop>
<tabstop>BarColor</tabstop>

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>261</width>
<height>110</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Field:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="Field">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="Component">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Index:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="Index">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>296</width>
<height>186</height>
<width>271</width>
<height>174</height>
</rect>
</property>
<property name="windowTitle">

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>335</width>
<height>124</height>
<width>274</width>
<height>114</height>
</rect>
</property>
<property name="windowTitle">
@@ -28,25 +28,6 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="4">
<widget class="QDoubleSpinBox" name="MarkerSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Width of all lines (outline and hatch)</string>
</property>
<property name="maximum">
<double>99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -57,7 +38,7 @@
<item row="1" column="2">
<widget class="QComboBox" name="LineStyle">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -107,18 +88,8 @@
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QDoubleSpinBox" name="LineWidth">
<property name="maximum">
<double>99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::ColorButton" name="Color">
<widget class="QToolButton" name="Color">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -130,24 +101,50 @@
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="LineWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QDoubleSpinBox" name="MarkerSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Width of all lines (outline and hatch)</string>
</property>
<property name="maximum">
<double>99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>Legend</tabstop>
<tabstop>Color</tabstop>
<tabstop>LineStyle</tabstop>
<tabstop>LineWidth</tabstop>
<tabstop>MarkerStyle</tabstop>
<tabstop>MarkerSize</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>108</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Y Field:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="YField">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="YComponent">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Index:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="Index">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>Index</tabstop>
<tabstop>YField</tabstop>
<tabstop>YComponent</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -408,6 +408,21 @@ void TaskDlgPost::modifyStandardButtons(QDialogButtonBox* box)
}
}
void TaskDlgPost::processCollapsedWidgets() {
for (auto& widget : Content) {
if(auto task_box = dynamic_cast<Gui::TaskView::TaskBox*>(widget)) {
// get the task widget and check if it is a post widget
auto widget = task_box->groupLayout()->itemAt(0)->widget();
if(auto post_widget = dynamic_cast<TaskPostWidget*>(widget)) {
if(post_widget->initiallyCollapsed()) {
post_widget->setGeometry(QRect(QPoint(0,0), post_widget->sizeHint()));
task_box->hideGroupBox();
}
}
}
}
}
// ***************************************************************************
// box to set the coloring
@@ -571,6 +586,10 @@ void TaskPostFrames::applyPythonCode()
// we apply the views widgets python code
}
bool TaskPostFrames::initiallyCollapsed() {
return (ui->FrameTable->rowCount() == 0);
}
// ***************************************************************************
// in the following, the different filters sorted alphabetically

View File

@@ -156,6 +156,11 @@ public:
// executed when the apply button is pressed in the task dialog
virtual void apply() {};
// returns if the widget shall be collapsed when opening the task dialog
virtual bool initiallyCollapsed() {
return false;
};
protected:
App::DocumentObject* getObject() const
{
@@ -235,6 +240,9 @@ public:
/// returns for Close and Help button
QDialogButtonBox::StandardButtons getStandardButtons() const override;
/// makes sure all widgets are collapsed, if they want to be
void processCollapsedWidgets();
protected:
void recompute();
@@ -300,6 +308,8 @@ public:
void applyPythonCode() override;
bool initiallyCollapsed() override;
private:
void setupConnections();
void onSelectionChanged();

View File

@@ -166,4 +166,22 @@ void TaskPostExtraction::apply()
}
}
bool TaskPostExtraction::initiallyCollapsed()
{
Base::PyGILStateLocker lock;
try {
if (m_panel.hasAttr(std::string("initiallyCollapsed"))) {
Py::Callable method(m_panel.getAttr(std::string("initiallyCollapsed")));
auto result = Py::Boolean(method.apply());
return result.as_bool();
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
return false;
}
#include "moc_TaskPostExtraction.cpp"

View File

@@ -56,6 +56,7 @@ protected:
bool isGuiTaskOnly() override;
void apply() override;
void onPostDataChanged(Fem::FemPostObject* obj) override;
bool initiallyCollapsed() override;
private:
Py::Object m_panel;

View File

@@ -1007,6 +1007,7 @@ bool ViewProviderFemPostObject::setEdit(int ModNum)
postDlg = new TaskDlgPost(this);
setupTaskDialog(postDlg);
postDlg->connectSlots();
postDlg->processCollapsedWidgets();
Gui::Control().showDialog(postDlg);
}