Gui: Use getObject<T>() helpers in classes

This commit is generated using regex based find and replace:

```
s/[\w:]+_cast\s*<([^>]+)\*>\s*\(\s*getObject\(\s*\)\)/getObject<$1>/
s/[\w:]+_cast\s*<([^>]+)\*>\s*\(\s*([^)]*)\s*->\s*getObject\(\s*\)\)/$2->getObject<$1>()/
```

To regenerate if needed.
This commit is contained in:
Kacper Donat
2024-10-27 20:26:31 +01:00
parent 44f3b37200
commit 954b729b56
131 changed files with 535 additions and 628 deletions

View File

@@ -512,29 +512,26 @@ TaskPostDataAlongLine::TaskPostDataAlongLine(ViewProviderFemPostDataAlongLine* v
ui->point2Y->setDecimals(UserDecimals);
ui->point2Z->setDecimals(UserDecimals);
Base::Unit lengthUnit =
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->Point1.getUnit();
Base::Unit lengthUnit = getObject<Fem::FemPostDataAlongLineFilter>()->Point1.getUnit();
ui->point1X->setUnit(lengthUnit);
ui->point1Y->setUnit(lengthUnit);
ui->point1Z->setUnit(lengthUnit);
lengthUnit = static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->Point2.getUnit();
lengthUnit = getObject<Fem::FemPostDataAlongLineFilter>()->Point2.getUnit();
ui->point2X->setUnit(lengthUnit);
ui->point2Y->setUnit(lengthUnit);
ui->point2Z->setUnit(lengthUnit);
const Base::Vector3d& vec1 =
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->Point1.getValue();
const Base::Vector3d& vec1 = getObject<Fem::FemPostDataAlongLineFilter>()->Point1.getValue();
ui->point1X->setValue(vec1.x);
ui->point1Y->setValue(vec1.y);
ui->point1Z->setValue(vec1.z);
const Base::Vector3d& vec2 =
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->Point2.getValue();
const Base::Vector3d& vec2 = getObject<Fem::FemPostDataAlongLineFilter>()->Point2.getValue();
ui->point2X->setValue(vec2.x);
ui->point2Y->setValue(vec2.y);
ui->point2Z->setValue(vec2.z);
int res = static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->Resolution.getValue();
int res = getObject<Fem::FemPostDataAlongLineFilter>()->Resolution.getValue();
ui->resolution->setValue(res);
setupConnectionsStep2();
@@ -649,7 +646,7 @@ void TaskPostDataAlongLine::onSelectPointsClicked()
if (!marker) {
// Derives from QObject and we have a parent object, so we don't
// require a delete.
auto obj = static_cast<Fem::FemPostDataAlongLineFilter*>(getObject());
auto obj = getObject<Fem::FemPostDataAlongLineFilter>();
marker = new DataAlongLineMarker(viewer, obj);
marker->setParent(this);
}
@@ -755,7 +752,7 @@ void TaskPostDataAlongLine::point1Changed(double)
auto currentField = getTypedView<ViewProviderFemPostObject>()->Field.getValue();
getTypedView<ViewProviderFemPostObject>()->Field.setValue(currentField);
// also the axis data must be refreshed to get correct plots
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->GetAxisData();
getObject<Fem::FemPostDataAlongLineFilter>()->GetAxisData();
}
catch (const Base::Exception& e) {
e.ReportException();
@@ -786,7 +783,7 @@ void TaskPostDataAlongLine::point2Changed(double)
auto currentField = getTypedView<ViewProviderFemPostObject>()->Field.getValue();
getTypedView<ViewProviderFemPostObject>()->Field.setValue(currentField);
// also the axis data must be refreshed to get correct plots
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->GetAxisData();
getObject<Fem::FemPostDataAlongLineFilter>()->GetAxisData();
}
catch (const Base::Exception& e) {
e.what();
@@ -795,11 +792,11 @@ void TaskPostDataAlongLine::point2Changed(double)
void TaskPostDataAlongLine::resolutionChanged(int val)
{
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->Resolution.setValue(val);
getObject<Fem::FemPostDataAlongLineFilter>()->Resolution.setValue(val);
// recompute the feature
getObject()->recomputeFeature();
// axis data must be refreshed
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->GetAxisData();
getObject<Fem::FemPostDataAlongLineFilter>()->GetAxisData();
// eventually a full recompute is necessary
getView()->getObject()->getDocument()->recompute();
}
@@ -853,23 +850,23 @@ void TaskPostDataAlongLine::onFieldActivated(int i)
{
getTypedView<ViewProviderFemPostObject>()->Field.setValue(i);
std::string FieldName = ui->Field->currentText().toStdString();
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->PlotData.setValue(FieldName);
getObject<Fem::FemPostDataAlongLineFilter>()->PlotData.setValue(FieldName);
updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->VectorMode, ui->VectorMode);
auto vecMode = static_cast<ViewProviderFemPostObject*>(getView())->VectorMode.getEnum();
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->PlotDataComponent.setValue(vecMode);
getObject<Fem::FemPostDataAlongLineFilter>()->PlotDataComponent.setValue(vecMode);
}
void TaskPostDataAlongLine::onVectorModeActivated(int i)
{
getTypedView<ViewProviderFemPostObject>()->VectorMode.setValue(i);
int comp = ui->VectorMode->currentIndex();
static_cast<Fem::FemPostDataAlongLineFilter*>(getObject())->PlotDataComponent.setValue(comp);
getObject<Fem::FemPostDataAlongLineFilter>()->PlotDataComponent.setValue(comp);
}
std::string TaskPostDataAlongLine::Plot()
{
auto obj = static_cast<Fem::FemPostDataAlongLineFilter*>(getObject());
auto obj = getObject<Fem::FemPostDataAlongLineFilter>();
std::string yLabel;
// if there is only one component, it is the magnitude
if (obj->PlotDataComponent.getEnum().maxValue() < 1) {
@@ -932,14 +929,12 @@ TaskPostDataAtPoint::TaskPostDataAtPoint(ViewProviderFemPostDataAtPoint* view, Q
ui->centerY->setDecimals(UserDecimals);
ui->centerZ->setDecimals(UserDecimals);
const Base::Unit lengthUnit =
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Center.getUnit();
const Base::Unit lengthUnit = getObject<Fem::FemPostDataAtPointFilter>()->Center.getUnit();
ui->centerX->setUnit(lengthUnit);
ui->centerY->setUnit(lengthUnit);
ui->centerZ->setUnit(lengthUnit);
const Base::Vector3d& vec =
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Center.getValue();
const Base::Vector3d& vec = getObject<Fem::FemPostDataAtPointFilter>()->Center.getValue();
ui->centerX->setValue(vec.x);
ui->centerY->setValue(vec.y);
ui->centerZ->setValue(vec.z);
@@ -948,9 +943,8 @@ TaskPostDataAtPoint::TaskPostDataAtPoint(ViewProviderFemPostDataAtPoint* view, Q
updateEnumerationList(getTypedView<ViewProviderFemPostObject>()->Field, ui->Field);
// read in point value
auto pointValue = static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->PointData[0];
showValue(pointValue,
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.getValue());
auto pointValue = getObject<Fem::FemPostDataAtPointFilter>()->PointData[0];
showValue(pointValue, getObject<Fem::FemPostDataAtPointFilter>()->Unit.getValue());
connect(ui->centerX,
qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
@@ -1120,11 +1114,11 @@ void TaskPostDataAtPoint::onFieldActivated(int i)
std::string FieldName = ui->Field->currentText().toStdString();
// there is no "None" for the FieldName property, thus return here
if (FieldName == "None") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("");
ui->ValueAtPoint->clear();
return;
}
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->FieldName.setValue(FieldName);
getObject<Fem::FemPostDataAtPointFilter>()->FieldName.setValue(FieldName);
// Set the unit for the different known result types.
@@ -1137,51 +1131,51 @@ void TaskPostDataAtPoint::onFieldActivated(int i)
|| (FieldName == "Stress xy component") || (FieldName == "Stress xz component")
|| (FieldName == "Stress yy component") || (FieldName == "Stress yz component")
|| (FieldName == "Stress zz component")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("Pa");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("Pa");
}
// The Elmer names are different. If there are EigenModes, the names are unique for
// every mode. Therefore we only check for the beginning of the name.
else if ((FieldName.find("tresca", 0) == 0) || (FieldName.find("vonmises", 0) == 0)
|| (FieldName.find("stress_", 0) == 0)
|| (FieldName.find("principal stress", 0) == 0)) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("Pa");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("Pa");
}
else if ((FieldName == "current density") || (FieldName == "current density re")
|| (FieldName == "current density im") || (FieldName == "current density abs")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("A/m^2");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("A/m^2");
}
else if ((FieldName == "Displacement") || (FieldName == "Displacement Magnitude")
|| (FieldName.find("displacement", 0) == 0)) { // Elmer name
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("m");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("m");
}
else if (FieldName == "electric energy density") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("J/m^3");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("J/m^3");
}
else if ((FieldName == "electric field") || (FieldName == "electric field re")
|| (FieldName == "electric field im") || (FieldName == "electric field abs")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("V/m");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("V/m");
}
else if (FieldName == "electric flux") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("A*s/m^2");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("A*s/m^2");
}
else if (FieldName == "electric force density") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("N/m^2");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("N/m^2");
}
else if ((FieldName == "harmonic loss linear") || (FieldName == "harmonic loss quadratic")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("W");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("W");
}
else if ((FieldName == "joule heating") || (FieldName == "nodal joule heating")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("J");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("J");
}
else if ((FieldName == "magnetic field strength") || (FieldName == "magnetic field strength re")
|| (FieldName == "magnetic field strength im")
|| (FieldName == "magnetic field strength abs")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("A/m");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("A/m");
}
else if ((FieldName == "magnetic flux density") || (FieldName == "magnetic flux density re")
|| (FieldName == "magnetic flux density im")
|| (FieldName == "magnetic flux density abs")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("T");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("T");
}
else if ((FieldName == "maxwell stress 1") || (FieldName == "maxwell stress 2")
|| (FieldName == "maxwell stress 3") || (FieldName == "maxwell stress 4")
@@ -1192,41 +1186,40 @@ void TaskPostDataAtPoint::onFieldActivated(int i)
|| (FieldName == "maxwell stress im 1") || (FieldName == "maxwell stress im 2")
|| (FieldName == "maxwell stress im 3") || (FieldName == "maxwell stress im 4")
|| (FieldName == "maxwell stress im 5") || (FieldName == "maxwell stress im 6")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("As/m^3");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("As/m^3");
}
else if (FieldName == "nodal force") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("N");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("N");
}
else if ((FieldName == "potential") || (FieldName == "potential re")
|| (FieldName == "potential im") || (FieldName == "potential abs")
|| (FieldName == "av") || (FieldName == "av re") || (FieldName == "av im")
|| (FieldName == "av abs")) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("V");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("V");
}
else if (FieldName == "potential flux") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("W/m^2");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("W/m^2");
}
// potential loads are in Coulomb: https://www.elmerfem.org/forum/viewtopic.php?t=7780
else if (FieldName == "potential loads") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("C");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("C");
}
else if (
// CalculiX name
FieldName == "Temperature" ||
// Elmer name
((FieldName.find("temperature", 0) == 0) && (FieldName != "temperature flux"))) {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("K");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("K");
}
else if (FieldName == "temperature flux") {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("W/m^2");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("W/m^2");
}
else {
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.setValue("");
getObject<Fem::FemPostDataAtPointFilter>()->Unit.setValue("");
}
auto pointValue = static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->PointData[0];
showValue(pointValue,
static_cast<Fem::FemPostDataAtPointFilter*>(getObject())->Unit.getValue());
auto pointValue = getObject<Fem::FemPostDataAtPointFilter>()->PointData[0];
showValue(pointValue, getObject<Fem::FemPostDataAtPointFilter>()->Unit.getValue());
}
void TaskPostDataAtPoint::showValue(double pointValue, const char* unitStr)
@@ -1300,10 +1293,8 @@ TaskPostClip::TaskPostClip(ViewProviderFemPostClip* view,
ui->CreateButton->setPopupMode(QToolButton::InstantPopup);
// load the default values
ui->CutCells->setChecked(
static_cast<Fem::FemPostClipFilter*>(getObject())->CutCells.getValue());
ui->InsideOut->setChecked(
static_cast<Fem::FemPostClipFilter*>(getObject())->InsideOut.getValue());
ui->CutCells->setChecked(getObject<Fem::FemPostClipFilter>()->CutCells.getValue());
ui->InsideOut->setChecked(getObject<Fem::FemPostClipFilter>()->InsideOut.getValue());
}
TaskPostClip::~TaskPostClip() = default;
@@ -1338,7 +1329,7 @@ void TaskPostClip::collectImplicitFunctions()
QStringList items;
std::size_t currentItem = 0;
App::DocumentObject* currentFunction =
static_cast<Fem::FemPostClipFilter*>(getObject())->Function.getValue();
getObject<Fem::FemPostClipFilter>()->Function.getValue();
const std::vector<App::DocumentObject*>& funcs =
static_cast<Fem::FemPostFunctionProvider*>(pipeline->Functions.getValue())
->Functions.getValues();
@@ -1388,17 +1379,17 @@ void TaskPostClip::onFunctionBoxCurrentIndexChanged(int idx)
static_cast<Fem::FemPostFunctionProvider*>(pipeline->Functions.getValue())
->Functions.getValues();
if (idx >= 0) {
static_cast<Fem::FemPostClipFilter*>(getObject())->Function.setValue(funcs[idx]);
getObject<Fem::FemPostClipFilter>()->Function.setValue(funcs[idx]);
}
else {
static_cast<Fem::FemPostClipFilter*>(getObject())->Function.setValue(nullptr);
getObject<Fem::FemPostClipFilter>()->Function.setValue(nullptr);
}
}
}
// load the correct view
Fem::FemPostFunction* fobj = static_cast<Fem::FemPostFunction*>(
static_cast<Fem::FemPostClipFilter*>(getObject())->Function.getValue());
getObject<Fem::FemPostClipFilter>()->Function.getValue());
Gui::ViewProvider* view = nullptr;
if (fobj) {
view = Gui::Application::Instance->getViewProvider(fobj);
@@ -1419,13 +1410,13 @@ void TaskPostClip::onFunctionBoxCurrentIndexChanged(int idx)
void TaskPostClip::onCutCellsToggled(bool val)
{
static_cast<Fem::FemPostClipFilter*>(getObject())->CutCells.setValue(val);
getObject<Fem::FemPostClipFilter>()->CutCells.setValue(val);
recompute();
}
void TaskPostClip::onInsideOutToggled(bool val)
{
static_cast<Fem::FemPostClipFilter*>(getObject())->InsideOut.setValue(val);
getObject<Fem::FemPostClipFilter>()->InsideOut.setValue(val);
recompute();
}
@@ -1449,13 +1440,13 @@ TaskPostContours::TaskPostContours(ViewProviderFemPostContours* view, QWidget* p
updateEnumerationList(getTypedObject<Fem::FemPostContoursFilter>()->Field, ui->fieldsCB);
updateEnumerationList(getTypedObject<Fem::FemPostContoursFilter>()->VectorMode, ui->vectorsCB);
// for a new filter, initialize the coloring
auto colorState = static_cast<Fem::FemPostContoursFilter*>(getObject())->NoColor.getValue();
auto colorState = getObject<Fem::FemPostContoursFilter>()->NoColor.getValue();
if (!colorState && getTypedView<ViewProviderFemPostObject>()->Field.getValue() == 0) {
getTypedView<ViewProviderFemPostObject>()->Field.setValue(1);
}
ui->numberContoursSB->setValue(
static_cast<Fem::FemPostContoursFilter*>(getObject())->NumberOfContours.getValue());
getObject<Fem::FemPostContoursFilter>()->NumberOfContours.getValue());
ui->noColorCB->setChecked(colorState);
// connect
@@ -1483,7 +1474,7 @@ void TaskPostContours::updateFields()
{
// update the ViewProvider Field
// since the ViewProvider can have another field sorting, we cannot use the same index
if (!static_cast<Fem::FemPostContoursFilter*>(getObject())->NoColor.getValue()) {
if (!getObject<Fem::FemPostContoursFilter>()->NoColor.getValue()) {
std::string objectField =
getTypedObject<Fem::FemPostContoursFilter>()->Field.getValueAsString();
getTypedView<ViewProviderFemPostObject>()->Field.setValue(objectField.c_str());
@@ -1495,7 +1486,7 @@ void TaskPostContours::updateFields()
void TaskPostContours::onFieldsChanged(int idx)
{
static_cast<Fem::FemPostContoursFilter*>(getObject())->Field.setValue(idx);
getObject<Fem::FemPostContoursFilter>()->Field.setValue(idx);
blockVectorUpdate = true;
updateEnumerationList(getTypedObject<Fem::FemPostContoursFilter>()->VectorMode, ui->vectorsCB);
@@ -1508,7 +1499,7 @@ void TaskPostContours::onFieldsChanged(int idx)
// since a new field can be e.g. no vector while the previous one was,
// we must also update the VectorMode
if (!static_cast<Fem::FemPostContoursFilter*>(getObject())->NoColor.getValue()) {
if (!getObject<Fem::FemPostContoursFilter>()->NoColor.getValue()) {
auto newMode = getTypedObject<Fem::FemPostContoursFilter>()->VectorMode.getValue();
getTypedView<ViewProviderFemPostObject>()->VectorMode.setValue(newMode);
}
@@ -1516,7 +1507,7 @@ void TaskPostContours::onFieldsChanged(int idx)
void TaskPostContours::onVectorModeChanged(int idx)
{
static_cast<Fem::FemPostContoursFilter*>(getObject())->VectorMode.setValue(idx);
getObject<Fem::FemPostContoursFilter>()->VectorMode.setValue(idx);
recompute();
if (!blockVectorUpdate) {
// we can have the case that the previous field had VectorMode "Z" but
@@ -1525,7 +1516,7 @@ void TaskPostContours::onVectorModeChanged(int idx)
// first to get the possible VectorModes of that field
updateFields();
// now we can set the VectorMode
if (!static_cast<Fem::FemPostContoursFilter*>(getObject())->NoColor.getValue()) {
if (!getObject<Fem::FemPostContoursFilter>()->NoColor.getValue()) {
getTypedView<ViewProviderFemPostObject>()->VectorMode.setValue(idx);
}
}
@@ -1533,13 +1524,13 @@ void TaskPostContours::onVectorModeChanged(int idx)
void TaskPostContours::onNumberOfContoursChanged(int number)
{
static_cast<Fem::FemPostContoursFilter*>(getObject())->NumberOfContours.setValue(number);
getObject<Fem::FemPostContoursFilter>()->NumberOfContours.setValue(number);
recompute();
}
void TaskPostContours::onNoColorChanged(bool state)
{
static_cast<Fem::FemPostContoursFilter*>(getObject())->NoColor.setValue(state);
getObject<Fem::FemPostContoursFilter>()->NoColor.setValue(state);
if (state) {
// no color
getTypedView<ViewProviderFemPostObject>()->Field.setValue(long(0));
@@ -1621,7 +1612,7 @@ void TaskPostCut::collectImplicitFunctions()
QStringList items;
std::size_t currentItem = 0;
App::DocumentObject* currentFunction =
static_cast<Fem::FemPostClipFilter*>(getObject())->Function.getValue();
getObject<Fem::FemPostClipFilter>()->Function.getValue();
const std::vector<App::DocumentObject*>& funcs =
static_cast<Fem::FemPostFunctionProvider*>(pipeline->Functions.getValue())
->Functions.getValues();
@@ -1671,17 +1662,17 @@ void TaskPostCut::onFunctionBoxCurrentIndexChanged(int idx)
static_cast<Fem::FemPostFunctionProvider*>(pipeline->Functions.getValue())
->Functions.getValues();
if (idx >= 0) {
static_cast<Fem::FemPostCutFilter*>(getObject())->Function.setValue(funcs[idx]);
getObject<Fem::FemPostCutFilter>()->Function.setValue(funcs[idx]);
}
else {
static_cast<Fem::FemPostCutFilter*>(getObject())->Function.setValue(nullptr);
getObject<Fem::FemPostCutFilter>()->Function.setValue(nullptr);
}
}
}
// load the correct view
Fem::FemPostFunction* fobj = static_cast<Fem::FemPostFunction*>(
static_cast<Fem::FemPostCutFilter*>(getObject())->Function.getValue());
Fem::FemPostFunction* fobj =
static_cast<Fem::FemPostFunction*>(getObject<Fem::FemPostCutFilter>()->Function.getValue());
Gui::ViewProvider* view = nullptr;
if (fobj) {
view = Gui::Application::Instance->getViewProvider(fobj);
@@ -1718,10 +1709,8 @@ TaskPostScalarClip::TaskPostScalarClip(ViewProviderFemPostScalarClip* view, QWid
// load the default values
updateEnumerationList(getTypedObject<Fem::FemPostScalarClipFilter>()->Scalars, ui->Scalar);
ui->InsideOut->setChecked(
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->InsideOut.getValue());
App::PropertyFloatConstraint& scalar_prop =
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->Value;
ui->InsideOut->setChecked(getObject<Fem::FemPostScalarClipFilter>()->InsideOut.getValue());
App::PropertyFloatConstraint& scalar_prop = getObject<Fem::FemPostScalarClipFilter>()->Value;
double scalar_factor = scalar_prop.getValue();
// set spinbox scalar_factor, don't forget to sync the slider
@@ -1767,12 +1756,11 @@ void TaskPostScalarClip::applyPythonCode()
void TaskPostScalarClip::onScalarCurrentIndexChanged(int idx)
{
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->Scalars.setValue(idx);
getObject<Fem::FemPostScalarClipFilter>()->Scalars.setValue(idx);
recompute();
// update constraints and values
App::PropertyFloatConstraint& scalar_prop =
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->Value;
App::PropertyFloatConstraint& scalar_prop = getObject<Fem::FemPostScalarClipFilter>()->Value;
double scalar_factor = scalar_prop.getValue();
double min = scalar_prop.getConstraints()->LowerBound;
double max = scalar_prop.getConstraints()->UpperBound;
@@ -1794,8 +1782,7 @@ void TaskPostScalarClip::onScalarCurrentIndexChanged(int idx)
void TaskPostScalarClip::onSliderValueChanged(int v)
{
App::PropertyFloatConstraint& value =
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->Value;
App::PropertyFloatConstraint& value = getObject<Fem::FemPostScalarClipFilter>()->Value;
double val = value.getConstraints()->LowerBound * (1 - double(v) / 100.)
+ double(v) / 100. * value.getConstraints()->UpperBound;
@@ -1810,8 +1797,7 @@ void TaskPostScalarClip::onSliderValueChanged(int v)
void TaskPostScalarClip::onValueValueChanged(double v)
{
App::PropertyFloatConstraint& value =
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->Value;
App::PropertyFloatConstraint& value = getObject<Fem::FemPostScalarClipFilter>()->Value;
value.setValue(v);
recompute();
@@ -1826,7 +1812,7 @@ void TaskPostScalarClip::onValueValueChanged(double v)
void TaskPostScalarClip::onInsideOutToggled(bool val)
{
static_cast<Fem::FemPostScalarClipFilter*>(getObject())->InsideOut.setValue(val);
getObject<Fem::FemPostScalarClipFilter>()->InsideOut.setValue(val);
recompute();
}
@@ -1848,7 +1834,7 @@ TaskPostWarpVector::TaskPostWarpVector(ViewProviderFemPostWarpVector* view, QWid
// load the default values for warp display
updateEnumerationList(getTypedObject<Fem::FemPostWarpVectorFilter>()->Vector, ui->Vector);
double warp_factor = static_cast<Fem::FemPostWarpVectorFilter*>(getObject())
double warp_factor = getObject<Fem::FemPostWarpVectorFilter>()
->Factor.getValue(); // get the standard warp factor
// set spinbox warp_factor, don't forget to sync the slider
@@ -1910,7 +1896,7 @@ void TaskPostWarpVector::applyPythonCode()
void TaskPostWarpVector::onVectorCurrentIndexChanged(int idx)
{
// combobox to choose the result to warp
static_cast<Fem::FemPostWarpVectorFilter*>(getObject())->Vector.setValue(idx);
getObject<Fem::FemPostWarpVectorFilter>()->Vector.setValue(idx);
recompute();
}
@@ -1925,7 +1911,7 @@ void TaskPostWarpVector::onSliderValueChanged(int slider_value)
//
double warp_factor =
ui->Min->value() + ((ui->Max->value() - ui->Min->value()) / 100.) * slider_value;
static_cast<Fem::FemPostWarpVectorFilter*>(getObject())->Factor.setValue(warp_factor);
getObject<Fem::FemPostWarpVectorFilter>()->Factor.setValue(warp_factor);
recompute();
// sync the spinbox
@@ -1941,7 +1927,7 @@ void TaskPostWarpVector::onValueValueChanged(double warp_factor)
// TODO warp factor should not be smaller than min and greater than max,
// but problems on automate change of warp_factor, see on_Max_valueChanged
static_cast<Fem::FemPostWarpVectorFilter*>(getObject())->Factor.setValue(warp_factor);
getObject<Fem::FemPostWarpVectorFilter>()->Factor.setValue(warp_factor);
recompute();
// sync the slider, see above for formula
@@ -1973,7 +1959,7 @@ void TaskPostWarpVector::onMaxValueChanged(double)
// set warp factor to max, if warp factor > max
if (ui->Value->value() > ui->Max->value()) {
double warp_factor = ui->Max->value();
static_cast<Fem::FemPostWarpVectorFilter*>(getObject())->Factor.setValue(warp_factor);
getObject<Fem::FemPostWarpVectorFilter>()->Factor.setValue(warp_factor);
recompute();
// sync the slider, see above for formula