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

@@ -52,7 +52,7 @@ TaskDlgMeshShapeNetgen::TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeN
, param(nullptr)
, ViewProviderFemMeshShapeNetgen(obj)
{
FemMeshShapeNetgenObject = dynamic_cast<Fem::FemMeshShapeNetgenObject*>(obj->getObject());
FemMeshShapeNetgenObject = obj->getObject<Fem::FemMeshShapeNetgenObject>();
if (FemMeshShapeNetgenObject) {
param = new TaskTetParameter(FemMeshShapeNetgenObject);
Content.push_back(param);

View File

@@ -103,7 +103,7 @@ const std::string TaskFemConstraint::getReferences(const std::vector<std::string
const std::string TaskFemConstraint::getScale() const
{
Fem::Constraint* pcConstraint = static_cast<Fem::Constraint*>(ConstraintView->getObject());
Fem::Constraint* pcConstraint = ConstraintView->getObject<Fem::Constraint>();
return std::to_string(pcConstraint->Scale.getValue());
}
@@ -131,7 +131,7 @@ void TaskFemConstraint::setSelection(QListWidgetItem* item)
void TaskFemConstraint::onReferenceDeleted(const int row)
{
Fem::Constraint* pcConstraint = static_cast<Fem::Constraint*>(ConstraintView->getObject());
Fem::Constraint* pcConstraint = ConstraintView->getObject<Fem::Constraint>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();

View File

@@ -80,8 +80,7 @@ TaskFemConstraintBearing::TaskFemConstraintBearing(ViewProviderFemConstraint* Co
ui->spinDistance->setMaximum(FLOAT_MAX);
// Get the feature data
Fem::ConstraintBearing* pcConstraint =
static_cast<Fem::ConstraintBearing*>(ConstraintView->getObject());
Fem::ConstraintBearing* pcConstraint = ConstraintView->getObject<Fem::ConstraintBearing>();
double distance = pcConstraint->Dist.getValue();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -154,8 +153,7 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m
return;
}
Fem::ConstraintBearing* pcConstraint =
static_cast<Fem::ConstraintBearing*>(ConstraintView->getObject());
Fem::ConstraintBearing* pcConstraint = ConstraintView->getObject<Fem::ConstraintBearing>();
App::DocumentObject* obj =
ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName);
Part::Feature* feat = static_cast<Part::Feature*>(obj);
@@ -232,8 +230,7 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m
void TaskFemConstraintBearing::onDistanceChanged(double l)
{
Fem::ConstraintBearing* pcConstraint =
static_cast<Fem::ConstraintBearing*>(ConstraintView->getObject());
Fem::ConstraintBearing* pcConstraint = ConstraintView->getObject<Fem::ConstraintBearing>();
pcConstraint->Dist.setValue(l);
}
@@ -259,8 +256,7 @@ void TaskFemConstraintBearing::onButtonLocation(const bool pressed)
void TaskFemConstraintBearing::onCheckAxial(const bool pressed)
{
Fem::ConstraintBearing* pcConstraint =
static_cast<Fem::ConstraintBearing*>(ConstraintView->getObject());
Fem::ConstraintBearing* pcConstraint = ConstraintView->getObject<Fem::ConstraintBearing>();
pcConstraint->AxialFree.setValue(pressed);
}

View File

@@ -86,8 +86,7 @@ TaskFemConstraintContact::TaskFemConstraintContact(ViewProviderFemConstraintCont
/* Note: */
// Get the feature data
Fem::ConstraintContact* pcConstraint =
static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
Fem::ConstraintContact* pcConstraint = ConstraintView->getObject<Fem::ConstraintContact>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -206,8 +205,7 @@ void TaskFemConstraintContact::addToSelectionSlave()
Gui::Selection().clearSelection();
return;
}
Fem::ConstraintContact* pcConstraint =
static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
Fem::ConstraintContact* pcConstraint = ConstraintView->getObject<Fem::ConstraintContact>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -268,8 +266,7 @@ void TaskFemConstraintContact::removeFromSelectionSlave()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintContact* pcConstraint =
static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
Fem::ConstraintContact* pcConstraint = ConstraintView->getObject<Fem::ConstraintContact>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
@@ -338,8 +335,7 @@ void TaskFemConstraintContact::addToSelectionMaster()
Gui::Selection().clearSelection();
return;
}
Fem::ConstraintContact* pcConstraint =
static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
Fem::ConstraintContact* pcConstraint = ConstraintView->getObject<Fem::ConstraintContact>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -399,8 +395,7 @@ void TaskFemConstraintContact::removeFromSelectionMaster()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintContact* pcConstraint =
static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
Fem::ConstraintContact* pcConstraint = ConstraintView->getObject<Fem::ConstraintContact>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -89,7 +89,7 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(
// Get the feature data
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintDisplacement>();
Base::Quantity fStates[6] {};
const char* sStates[3] {};
bool bStates[10] {};
@@ -241,7 +241,7 @@ void TaskFemConstraintDisplacement::addToSelection()
return;
}
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintDisplacement>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -312,7 +312,7 @@ void TaskFemConstraintDisplacement::removeFromSelection()
return;
}
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintDisplacement>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -69,8 +69,7 @@ TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed* C
/* Note: */
// Get the feature data
Fem::ConstraintFixed* pcConstraint =
static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
Fem::ConstraintFixed* pcConstraint = ConstraintView->getObject<Fem::ConstraintFixed>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -111,8 +110,7 @@ void TaskFemConstraintFixed::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintFixed* pcConstraint =
static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
Fem::ConstraintFixed* pcConstraint = ConstraintView->getObject<Fem::ConstraintFixed>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -183,8 +181,7 @@ void TaskFemConstraintFixed::removeFromSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintFixed* pcConstraint =
static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
Fem::ConstraintFixed* pcConstraint = ConstraintView->getObject<Fem::ConstraintFixed>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -208,7 +208,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(
// Get the feature data
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
Fem::FemAnalysis* pcAnalysis = nullptr;
if (FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) {
@@ -381,7 +381,7 @@ const Fem::FemSolverObject* TaskFemConstraintFluidBoundary::getFemSolver() const
void TaskFemConstraintFluidBoundary::updateBoundaryTypeUI()
{
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
std::string boundaryType = ui->comboBoundaryType->currentText().toStdString();
// std::string boundaryType = pcConstraint->BoundaryType.getValueAsString();
@@ -524,7 +524,7 @@ void TaskFemConstraintFluidBoundary::updateTurbulenceUI()
void TaskFemConstraintFluidBoundary::updateThermalBoundaryUI()
{
// Fem::ConstraintFluidBoundary* pcConstraint =
// static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject()); std::string
// ConstraintView->getObject<Fem::ConstraintFluidBoundary>(); std::string
// thermalBoundaryType = pcConstraint->ThermalBoundaryType.getValueAsString();
ui->labelHelpText->setText(
@@ -566,7 +566,7 @@ void TaskFemConstraintFluidBoundary::updateThermalBoundaryUI()
void TaskFemConstraintFluidBoundary::onBoundaryTypeChanged()
{
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
// temporarily change BoundaryType property, but command transaction should reset it back if you
// 'reject' late
pcConstraint->BoundaryType.setValue(ui->comboBoundaryType->currentIndex());
@@ -597,7 +597,7 @@ void TaskFemConstraintFluidBoundary::onBoundaryValueChanged(double)
void TaskFemConstraintFluidBoundary::onTurbulenceSpecificationChanged()
{
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
pcConstraint->TurbulenceSpecification.setValue(
ui->comboTurbulenceSpecification->currentIndex());
updateTurbulenceUI();
@@ -606,7 +606,7 @@ void TaskFemConstraintFluidBoundary::onTurbulenceSpecificationChanged()
void TaskFemConstraintFluidBoundary::onThermalBoundaryTypeChanged()
{
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
pcConstraint->ThermalBoundaryType.setValue(ui->comboThermalBoundaryType->currentIndex());
updateThermalBoundaryUI();
}
@@ -632,7 +632,7 @@ void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed)
return;
}
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
// we only handle the first selected object
Gui::SelectionObject& selectionElement = selection.at(0);
@@ -696,7 +696,7 @@ void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed)
void TaskFemConstraintFluidBoundary::onCheckReverse(const bool pressed)
{
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
pcConstraint->Reversed.setValue(pressed);
}
@@ -820,7 +820,7 @@ void TaskFemConstraintFluidBoundary::addToSelection()
return;
}
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -892,7 +892,7 @@ void TaskFemConstraintFluidBoundary::removeFromSelection()
return;
}
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintFluidBoundary>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -61,8 +61,7 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* C
this->groupLayout()->addWidget(proxy);
// Get the feature data
Fem::ConstraintForce* pcConstraint =
static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
Fem::ConstraintForce* pcConstraint = ConstraintView->getObject<Fem::ConstraintForce>();
auto force = pcConstraint->Force.getQuantityValue();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -127,8 +126,7 @@ void TaskFemConstraintForce::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintForce* pcConstraint =
static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
Fem::ConstraintForce* pcConstraint = ConstraintView->getObject<Fem::ConstraintForce>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -199,8 +197,7 @@ void TaskFemConstraintForce::removeFromSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintForce* pcConstraint =
static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
Fem::ConstraintForce* pcConstraint = ConstraintView->getObject<Fem::ConstraintForce>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
@@ -320,8 +317,7 @@ void TaskFemConstraintForce::onButtonDirection(const bool pressed)
try {
std::vector<std::string> direction(1, link.second);
Fem::ConstraintForce* pcConstraint =
static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
Fem::ConstraintForce* pcConstraint = ConstraintView->getObject<Fem::ConstraintForce>();
// update the direction
pcConstraint->Direction.setValue(link.first, direction);
@@ -336,8 +332,7 @@ void TaskFemConstraintForce::onButtonDirection(const bool pressed)
void TaskFemConstraintForce::onCheckReverse(const bool pressed)
{
Fem::ConstraintForce* pcConstraint =
static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
Fem::ConstraintForce* pcConstraint = ConstraintView->getObject<Fem::ConstraintForce>();
pcConstraint->Reversed.setValue(pressed);
}

View File

@@ -74,8 +74,7 @@ TaskFemConstraintGear::TaskFemConstraintGear(ViewProviderFemConstraint* Constrai
ui->checkReversed->blockSignals(true);
// Get the feature data
Fem::ConstraintGear* pcConstraint =
static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
Fem::ConstraintGear* pcConstraint = ConstraintView->getObject<Fem::ConstraintGear>();
double dia = pcConstraint->Diameter.getValue();
double force = pcConstraint->Force.getValue();
double angle = pcConstraint->ForceAngle.getValue();
@@ -137,8 +136,7 @@ void TaskFemConstraintGear::onSelectionChanged(const Gui::SelectionChanges& msg)
}
std::vector<std::string> references(1, subName);
Fem::ConstraintGear* pcConstraint =
static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
Fem::ConstraintGear* pcConstraint = ConstraintView->getObject<Fem::ConstraintGear>();
App::DocumentObject* obj =
ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName);
Part::Feature* feat = static_cast<Part::Feature*>(obj);
@@ -180,22 +178,19 @@ void TaskFemConstraintGear::onSelectionChanged(const Gui::SelectionChanges& msg)
void TaskFemConstraintGear::onDiameterChanged(double l)
{
Fem::ConstraintGear* pcConstraint =
static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
Fem::ConstraintGear* pcConstraint = ConstraintView->getObject<Fem::ConstraintGear>();
pcConstraint->Diameter.setValue(l);
}
void TaskFemConstraintGear::onForceChanged(double f)
{
Fem::ConstraintGear* pcConstraint =
static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
Fem::ConstraintGear* pcConstraint = ConstraintView->getObject<Fem::ConstraintGear>();
pcConstraint->Force.setValue(f);
}
void TaskFemConstraintGear::onForceAngleChanged(double a)
{
Fem::ConstraintGear* pcConstraint =
static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
Fem::ConstraintGear* pcConstraint = ConstraintView->getObject<Fem::ConstraintGear>();
pcConstraint->ForceAngle.setValue(a);
}
@@ -213,8 +208,7 @@ void TaskFemConstraintGear::onButtonDirection(const bool pressed)
void TaskFemConstraintGear::onCheckReversed(const bool pressed)
{
Fem::ConstraintGear* pcConstraint =
static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
Fem::ConstraintGear* pcConstraint = ConstraintView->getObject<Fem::ConstraintGear>();
pcConstraint->Reversed.setValue(pressed);
}

View File

@@ -105,8 +105,7 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
ui->btnRemove->blockSignals(true);
// Get the feature data
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -190,36 +189,31 @@ void TaskFemConstraintHeatflux::updateUI()
void TaskFemConstraintHeatflux::onAmbientTempChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
pcConstraint->AmbientTemp.setValue(val);
}
void TaskFemConstraintHeatflux::onFilmCoefChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
pcConstraint->FilmCoef.setValue(val);
}
void TaskFemConstraintHeatflux::onEmissivityChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
pcConstraint->Emissivity.setValue(val);
}
void TaskFemConstraintHeatflux::onHeatFluxChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
pcConstraint->DFlux.setValue(val);
}
void TaskFemConstraintHeatflux::Conv()
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ConstraintType = %s",
@@ -232,8 +226,7 @@ void TaskFemConstraintHeatflux::Conv()
void TaskFemConstraintHeatflux::Rad()
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ConstraintType = %s",
@@ -246,8 +239,7 @@ void TaskFemConstraintHeatflux::Rad()
void TaskFemConstraintHeatflux::Flux()
{
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ConstraintType = %s",
@@ -265,8 +257,7 @@ void TaskFemConstraintHeatflux::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -331,8 +322,7 @@ void TaskFemConstraintHeatflux::removeFromSelection()
return;
}
Fem::ConstraintHeatflux* pcConstraint =
static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
Fem::ConstraintHeatflux* pcConstraint = ConstraintView->getObject<Fem::ConstraintHeatflux>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
@@ -419,7 +409,7 @@ std::string TaskFemConstraintHeatflux::getAmbientTemp() const
temp = ui->qsb_ambienttemp_rad->value().getSafeUserString().toStdString();
}
else {
auto obj = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
auto obj = ConstraintView->getObject<Fem::ConstraintHeatflux>();
temp = obj->AmbientTemp.getQuantityValue().getSafeUserString().toStdString();
}

View File

@@ -56,7 +56,7 @@ TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(
// Get the feature data
Fem::ConstraintInitialTemperature* pcConstraint =
static_cast<Fem::ConstraintInitialTemperature*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintInitialTemperature>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();

View File

@@ -79,7 +79,7 @@ TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation(
/* Note: */
// Get the feature data
Fem::ConstraintPlaneRotation* pcConstraint =
static_cast<Fem::ConstraintPlaneRotation*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintPlaneRotation>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -138,7 +138,7 @@ void TaskFemConstraintPlaneRotation::addToSelection()
return;
}
Fem::ConstraintPlaneRotation* pcConstraint =
static_cast<Fem::ConstraintPlaneRotation*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintPlaneRotation>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -218,7 +218,7 @@ void TaskFemConstraintPlaneRotation::removeFromSelection()
return;
}
Fem::ConstraintPlaneRotation* pcConstraint =
static_cast<Fem::ConstraintPlaneRotation*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintPlaneRotation>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -56,8 +56,7 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(
this->groupLayout()->addWidget(proxy);
// Get the feature data
Fem::ConstraintPressure* pcConstraint =
static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
Fem::ConstraintPressure* pcConstraint = ConstraintView->getObject<Fem::ConstraintPressure>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -120,8 +119,7 @@ void TaskFemConstraintPressure::updateUI()
void TaskFemConstraintPressure::onCheckReverse(const bool pressed)
{
Fem::ConstraintPressure* pcConstraint =
static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
Fem::ConstraintPressure* pcConstraint = ConstraintView->getObject<Fem::ConstraintPressure>();
pcConstraint->Reversed.setValue(pressed);
}
@@ -133,8 +131,7 @@ void TaskFemConstraintPressure::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintPressure* pcConstraint =
static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
Fem::ConstraintPressure* pcConstraint = ConstraintView->getObject<Fem::ConstraintPressure>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -188,8 +185,7 @@ void TaskFemConstraintPressure::removeFromSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintPressure* pcConstraint =
static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
Fem::ConstraintPressure* pcConstraint = ConstraintView->getObject<Fem::ConstraintPressure>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -68,8 +68,7 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley
ui->spinTensionForce->blockSignals(true);
// Get the feature data
Fem::ConstraintPulley* pcConstraint =
static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
Fem::ConstraintPulley* pcConstraint = ConstraintView->getObject<Fem::ConstraintPulley>();
double otherdia = pcConstraint->OtherDiameter.getValue();
double centerdist = pcConstraint->CenterDistance.getValue();
bool isdriven = pcConstraint->IsDriven.getValue();
@@ -110,29 +109,25 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley
void TaskFemConstraintPulley::onOtherDiameterChanged(double l)
{
Fem::ConstraintPulley* pcConstraint =
static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
Fem::ConstraintPulley* pcConstraint = ConstraintView->getObject<Fem::ConstraintPulley>();
pcConstraint->OtherDiameter.setValue(l);
}
void TaskFemConstraintPulley::onCenterDistanceChanged(double l)
{
Fem::ConstraintPulley* pcConstraint =
static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
Fem::ConstraintPulley* pcConstraint = ConstraintView->getObject<Fem::ConstraintPulley>();
pcConstraint->CenterDistance.setValue(l);
}
void TaskFemConstraintPulley::onTensionForceChanged(double force)
{
Fem::ConstraintPulley* pcConstraint =
static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
Fem::ConstraintPulley* pcConstraint = ConstraintView->getObject<Fem::ConstraintPulley>();
pcConstraint->TensionForce.setValue(force);
}
void TaskFemConstraintPulley::onCheckIsDriven(const bool pressed)
{
Fem::ConstraintPulley* pcConstraint =
static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
Fem::ConstraintPulley* pcConstraint = ConstraintView->getObject<Fem::ConstraintPulley>();
pcConstraint->IsDriven.setValue(pressed);
}

View File

@@ -109,7 +109,7 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
/* Note: */
// Get the feature data
auto pcConstraint = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject());
auto pcConstraint = ConstraintView->getObject<Fem::ConstraintRigidBody>();
const Base::Vector3d& refNode = pcConstraint->ReferenceNode.getValue();
const Base::Vector3d& disp = pcConstraint->Displacement.getValue();
@@ -273,8 +273,7 @@ void TaskFemConstraintRigidBody::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintRigidBody* pcConstraint =
static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject());
Fem::ConstraintRigidBody* pcConstraint = ConstraintView->getObject<Fem::ConstraintRigidBody>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -347,8 +346,7 @@ void TaskFemConstraintRigidBody::removeFromSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintRigidBody* pcConstraint =
static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject());
Fem::ConstraintRigidBody* pcConstraint = ConstraintView->getObject<Fem::ConstraintRigidBody>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
@@ -405,7 +403,7 @@ void TaskFemConstraintRigidBody::onReferenceDeleted()
void TaskFemConstraintRigidBody::onRotModeXChanged(int item)
{
const char* val = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject())
const char* val = ConstraintView->getObject<Fem::ConstraintRigidBody>()
->RotationalModeX.getEnumVector()[item]
.c_str();
@@ -424,7 +422,7 @@ void TaskFemConstraintRigidBody::onRotModeXChanged(int item)
}
void TaskFemConstraintRigidBody::onRotModeYChanged(int item)
{
const char* val = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject())
const char* val = ConstraintView->getObject<Fem::ConstraintRigidBody>()
->RotationalModeY.getEnumVector()[item]
.c_str();
@@ -443,7 +441,7 @@ void TaskFemConstraintRigidBody::onRotModeYChanged(int item)
}
void TaskFemConstraintRigidBody::onRotModeZChanged(int item)
{
const char* val = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject())
const char* val = ConstraintView->getObject<Fem::ConstraintRigidBody>()
->RotationalModeZ.getEnumVector()[item]
.c_str();
@@ -463,7 +461,7 @@ void TaskFemConstraintRigidBody::onRotModeZChanged(int item)
void TaskFemConstraintRigidBody::onTransModeXChanged(int item)
{
const char* val = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject())
const char* val = ConstraintView->getObject<Fem::ConstraintRigidBody>()
->TranslationalModeX.getEnumVector()[item]
.c_str();
@@ -482,7 +480,7 @@ void TaskFemConstraintRigidBody::onTransModeXChanged(int item)
}
void TaskFemConstraintRigidBody::onTransModeYChanged(int item)
{
const char* val = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject())
const char* val = ConstraintView->getObject<Fem::ConstraintRigidBody>()
->TranslationalModeY.getEnumVector()[item]
.c_str();
@@ -501,7 +499,7 @@ void TaskFemConstraintRigidBody::onTransModeYChanged(int item)
}
void TaskFemConstraintRigidBody::onTransModeZChanged(int item)
{
const char* val = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject())
const char* val = ConstraintView->getObject<Fem::ConstraintRigidBody>()
->TranslationalModeZ.getEnumVector()[item]
.c_str();
@@ -521,7 +519,7 @@ void TaskFemConstraintRigidBody::onTransModeZChanged(int item)
void TaskFemConstraintRigidBody::onRefNodeXChanged(double value)
{
auto obj = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject());
auto obj = ConstraintView->getObject<Fem::ConstraintRigidBody>();
Base::Vector3d refNode = obj->ReferenceNode.getValue();
refNode.x = value;
obj->ReferenceNode.setValue(refNode);
@@ -529,7 +527,7 @@ void TaskFemConstraintRigidBody::onRefNodeXChanged(double value)
void TaskFemConstraintRigidBody::onRefNodeYChanged(double value)
{
auto obj = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject());
auto obj = ConstraintView->getObject<Fem::ConstraintRigidBody>();
Base::Vector3d refNode = obj->ReferenceNode.getValue();
refNode.y = value;
obj->ReferenceNode.setValue(refNode);
@@ -537,7 +535,7 @@ void TaskFemConstraintRigidBody::onRefNodeYChanged(double value)
void TaskFemConstraintRigidBody::onRefNodeZChanged(double value)
{
auto obj = static_cast<Fem::ConstraintRigidBody*>(ConstraintView->getObject());
auto obj = ConstraintView->getObject<Fem::ConstraintRigidBody>();
Base::Vector3d refNode = obj->ReferenceNode.getValue();
refNode.z = value;
obj->ReferenceNode.setValue(refNode);

View File

@@ -69,8 +69,7 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring
/* Note: */
// Get the feature data
Fem::ConstraintSpring* pcConstraint =
static_cast<Fem::ConstraintSpring*>(ConstraintView->getObject());
Fem::ConstraintSpring* pcConstraint = ConstraintView->getObject<Fem::ConstraintSpring>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -130,8 +129,7 @@ void TaskFemConstraintSpring::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintSpring* pcConstraint =
static_cast<Fem::ConstraintSpring*>(ConstraintView->getObject());
Fem::ConstraintSpring* pcConstraint = ConstraintView->getObject<Fem::ConstraintSpring>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -185,8 +183,7 @@ void TaskFemConstraintSpring::removeFromSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintSpring* pcConstraint =
static_cast<Fem::ConstraintSpring*>(ConstraintView->getObject());
Fem::ConstraintSpring* pcConstraint = ConstraintView->getObject<Fem::ConstraintSpring>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -61,7 +61,7 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(
// Get the feature data
Fem::ConstraintTemperature* pcConstraint =
static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintTemperature>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -164,7 +164,7 @@ void TaskFemConstraintTemperature::onCFluxChanged(double)
void TaskFemConstraintTemperature::onConstrTypeChanged(int item)
{
auto obj = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
auto obj = ConstraintView->getObject<Fem::ConstraintTemperature>();
obj->ConstraintType.setValue(item);
const char* type = obj->ConstraintType.getValueAsString();
if (strcmp(type, "Temperature") == 0) {
@@ -190,7 +190,7 @@ void TaskFemConstraintTemperature::addToSelection()
return;
}
Fem::ConstraintTemperature* pcConstraint =
static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintTemperature>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -241,7 +241,7 @@ void TaskFemConstraintTemperature::removeFromSelection()
return;
}
Fem::ConstraintTemperature* pcConstraint =
static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
ConstraintView->getObject<Fem::ConstraintTemperature>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

View File

@@ -106,8 +106,7 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(
&TaskFemConstraintTransform::angleChanged);
// Get the feature data
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -155,11 +154,10 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(
ui->lw_Rect->clear();
// Transformable surfaces
Gui::Command::doCommand(
Gui::Command::Doc,
TaskFemConstraintTransform::getSurfaceReferences(
(static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument())
.c_str());
Gui::Command::doCommand(Gui::Command::Doc,
TaskFemConstraintTransform::getSurfaceReferences(
(ConstraintView->getObject<Fem::Constraint>())->getNameInDocument())
.c_str());
std::vector<App::DocumentObject*> ObjDispl = pcConstraint->RefDispl.getValues();
std::vector<std::string> SubElemDispl = pcConstraint->RefDispl.getSubValues();
@@ -226,8 +224,7 @@ void TaskFemConstraintTransform::xAxisChanged(double x)
{
(void)x;
Base::Rotation rot = getRotation();
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
pcConstraint->Rotation.setValue(rot);
}
@@ -235,8 +232,7 @@ void TaskFemConstraintTransform::yAxisChanged(double y)
{
(void)y;
Base::Rotation rot = getRotation();
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
pcConstraint->Rotation.setValue(rot);
}
@@ -244,8 +240,7 @@ void TaskFemConstraintTransform::zAxisChanged(double z)
{
(void)z;
Base::Rotation rot = getRotation();
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
pcConstraint->Rotation.setValue(rot);
}
@@ -253,8 +248,7 @@ void TaskFemConstraintTransform::angleChanged(double a)
{
(void)a;
Base::Rotation rot = getRotation();
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
pcConstraint->Rotation.setValue(rot);
}
@@ -266,8 +260,7 @@ void TaskFemConstraintTransform::Rect()
"App.ActiveDocument.%s.TransformType = %s",
name.c_str(),
get_transform_type().c_str());
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
if (!Objects.empty()) {
setSelection(ui->lw_Rect->item(0));
@@ -283,8 +276,7 @@ void TaskFemConstraintTransform::Cyl()
"App.ActiveDocument.%s.TransformType = %s",
name.c_str(),
get_transform_type().c_str());
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
if (!Objects.empty()) {
setSelection(ui->lw_Rect->item(0));
@@ -318,8 +310,7 @@ void TaskFemConstraintTransform::addToSelection()
return;
}
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@@ -428,8 +419,7 @@ void TaskFemConstraintTransform::removeFromSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintTransform* pcConstraint =
static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
Fem::ConstraintTransform* pcConstraint = ConstraintView->getObject<Fem::ConstraintTransform>();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;

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

View File

@@ -78,6 +78,11 @@ public:
void setPoint(int idx, const SbVec3f& pt) const;
Gui::View3DInventorViewer* getView() const;
App::DocumentObject* getObject() const;
template<class T>
T* getObject() const
{
return Base::freecad_dynamic_cast<T>(getObject());
}
QMetaObject::Connection connSelectPoint;
protected:
@@ -146,6 +151,11 @@ protected:
{
return *m_object;
}
template<class T>
T* getObject() const
{
return Base::freecad_dynamic_cast<T>(getObject());
}
template<typename T>
T* getTypedObject() const
{

View File

@@ -199,7 +199,7 @@ bool ViewProviderFemAnalysis::setEdit(int ModNum)
// Gui::Control().showDialog(padDlg);
// else
// Fem::FemAnalysis* pcAna = static_cast<Fem::FemAnalysis*>(this->getObject());
// Fem::FemAnalysis* pcAna = this->getObject<Fem::FemAnalysis>();
// Gui::Control().showDialog(new TaskDlgAnalysis(pcAna));
// return true;
return false;

View File

@@ -170,7 +170,7 @@ void ViewProviderFemConstraint::onChanged(const App::Property* prop)
void ViewProviderFemConstraint::updateData(const App::Property* prop)
{
auto pcConstraint = static_cast<const Fem::Constraint*>(this->getObject());
auto pcConstraint = this->getObject<const Fem::Constraint>();
if (prop == &pcConstraint->Points || prop == &pcConstraint->Normals
|| prop == &pcConstraint->Scale) {
@@ -202,7 +202,7 @@ void ViewProviderFemConstraint::handleChangedPropertyName(Base::XMLReader& reade
void ViewProviderFemConstraint::updateSymbol()
{
auto obj = static_cast<const Fem::Constraint*>(this->getObject());
auto obj = this->getObject<const Fem::Constraint>();
const std::vector<Base::Vector3d>& points = obj->Points.getValue();
const std::vector<Base::Vector3d>& normals = obj->Normals.getValue();
if (points.size() != normals.size()) {
@@ -225,7 +225,7 @@ void ViewProviderFemConstraint::transformSymbol(const Base::Vector3d& point,
const Base::Vector3d& normal,
SbMatrix& mat) const
{
auto obj = static_cast<const Fem::Constraint*>(this->getObject());
auto obj = this->getObject<const Fem::Constraint>();
SbVec3f axisY(0, 1, 0);
float s = obj->getScaleFactor();
SbVec3f scale(s, s, s);
@@ -240,7 +240,7 @@ void ViewProviderFemConstraint::transformSymbol(const Base::Vector3d& point,
void ViewProviderFemConstraint::transformExtraSymbol() const
{
if (pExtraTrans) {
auto obj = static_cast<const Fem::Constraint*>(this->getObject());
auto obj = this->getObject<const Fem::Constraint>();
float s = obj->getScaleFactor();
SbMatrix mat;
mat.setScale(s);

View File

@@ -67,7 +67,7 @@ bool ViewProviderFemConstraintBearing::setEdit(int ModNum)
void ViewProviderFemConstraintBearing::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintBearing* pcConstraint = static_cast<Fem::ConstraintBearing*>(this->getObject());
Fem::ConstraintBearing* pcConstraint = this->getObject<Fem::ConstraintBearing>();
if (prop == &pcConstraint->References) {
Base::Console().Error("\n"); // enable a breakpoint here

View File

@@ -70,8 +70,7 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum)
void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop)
{
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(this->getObject());
Fem::ConstraintDisplacement* pcConstraint = this->getObject<Fem::ConstraintDisplacement>();
if (prop == &pcConstraint->xFree) {
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(0));

View File

@@ -78,8 +78,7 @@ bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum)
void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintFluidBoundary* pcConstraint =
static_cast<Fem::ConstraintFluidBoundary*>(this->getObject());
Fem::ConstraintFluidBoundary* pcConstraint = this->getObject<Fem::ConstraintFluidBoundary>();
float scaledwidth =
WIDTH * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only
float scaledheight = HEIGHT * pcConstraint->Scale.getValue();

View File

@@ -66,7 +66,7 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum)
void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
{
auto pcConstraint = static_cast<Fem::ConstraintForce*>(this->getObject());
auto pcConstraint = this->getObject<Fem::ConstraintForce>();
if (prop == &pcConstraint->Reversed || prop == &pcConstraint->DirectionVector) {
updateSymbol();
@@ -80,7 +80,7 @@ void ViewProviderFemConstraintForce::transformSymbol(const Base::Vector3d& point
const Base::Vector3d& normal,
SbMatrix& mat) const
{
auto obj = static_cast<const Fem::ConstraintForce*>(this->getObject());
auto obj = this->getObject<const Fem::ConstraintForce>();
bool rev = obj->Reversed.getValue();
float s = obj->getScaleFactor();
// Symbol length from .iv file

View File

@@ -69,7 +69,7 @@ bool ViewProviderFemConstraintGear::setEdit(int ModNum)
void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
{
Fem::ConstraintGear* pcConstraint = static_cast<Fem::ConstraintGear*>(this->getObject());
Fem::ConstraintGear* pcConstraint = this->getObject<Fem::ConstraintGear>();
// Gets called whenever a property of the attached object changes
if (prop == &pcConstraint->BasePoint) {

View File

@@ -43,7 +43,7 @@ ViewProviderFemConstraintOnBoundary::~ViewProviderFemConstraintOnBoundary() = de
void ViewProviderFemConstraintOnBoundary::highlightReferences(const bool on)
{
Fem::Constraint* pcConstraint = static_cast<Fem::Constraint*>(this->getObject());
Fem::Constraint* pcConstraint = this->getObject<Fem::Constraint>();
const auto& subSets = pcConstraint->References.getSubListValues();
for (auto& subSet : subSets) {

View File

@@ -67,7 +67,7 @@ bool ViewProviderFemConstraintPressure::setEdit(int ModNum)
void ViewProviderFemConstraintPressure::updateData(const App::Property* prop)
{
auto pcConstraint = static_cast<Fem::ConstraintPressure*>(this->getObject());
auto pcConstraint = this->getObject<Fem::ConstraintPressure>();
if (prop == &pcConstraint->Reversed) {
updateSymbol();
@@ -81,7 +81,7 @@ void ViewProviderFemConstraintPressure::transformSymbol(const Base::Vector3d& po
const Base::Vector3d& normal,
SbMatrix& mat) const
{
auto obj = static_cast<const Fem::ConstraintPressure*>(this->getObject());
auto obj = this->getObject<const Fem::ConstraintPressure>();
float rotAngle = obj->Reversed.getValue() ? F_PI : 0.0f;
float s = obj->getScaleFactor();
// Symbol length from .iv file

View File

@@ -67,7 +67,7 @@ bool ViewProviderFemConstraintPulley::setEdit(int ModNum)
void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintPulley* pcConstraint = static_cast<Fem::ConstraintPulley*>(this->getObject());
Fem::ConstraintPulley* pcConstraint = this->getObject<Fem::ConstraintPulley>();
if (prop == &pcConstraint->BasePoint) {
if (pcConstraint->Height.getValue() > Precision::Confusion()) {

View File

@@ -65,7 +65,7 @@ bool ViewProviderFemConstraintRigidBody::setEdit(int ModNum)
void ViewProviderFemConstraintRigidBody::updateData(const App::Property* prop)
{
auto obj = static_cast<Fem::ConstraintRigidBody*>(this->getObject());
auto obj = this->getObject<Fem::ConstraintRigidBody>();
if (prop == &obj->ReferenceNode) {
updateSymbol();
@@ -78,7 +78,7 @@ void ViewProviderFemConstraintRigidBody::transformExtraSymbol() const
{
SoTransform* symTrans = getExtraSymbolTransform();
if (symTrans) {
auto obj = static_cast<const Fem::ConstraintRigidBody*>(this->getObject());
auto obj = this->getObject<const Fem::ConstraintRigidBody>();
float s = obj->getScaleFactor();
const Base::Vector3d& refNode = obj->ReferenceNode.getValue();
SbVec3f tra(refNode.x, refNode.y, refNode.z);

View File

@@ -70,7 +70,7 @@ bool ViewProviderFemConstraintTransform::setEdit(int ModNum)
void ViewProviderFemConstraintTransform::updateData(const App::Property* prop)
{
auto obj = static_cast<Fem::ConstraintTransform*>(this->getObject());
auto obj = this->getObject<Fem::ConstraintTransform>();
if (prop == &obj->Rotation) {
updateSymbol();
@@ -106,7 +106,7 @@ void ViewProviderFemConstraintTransform::transformSymbol(const Base::Vector3d& p
const Base::Vector3d& normal,
SbMatrix& mat) const
{
auto obj = static_cast<const Fem::ConstraintTransform*>(this->getObject());
auto obj = this->getObject<const Fem::ConstraintTransform>();
std::string transType = obj->TransformType.getValueAsString();
if (transType == "Rectangular") {
@@ -131,7 +131,7 @@ void ViewProviderFemConstraintTransform::transformSymbol(const Base::Vector3d& p
void ViewProviderFemConstraintTransform::transformExtraSymbol() const
{
auto obj = static_cast<const Fem::ConstraintTransform*>(this->getObject());
auto obj = this->getObject<const Fem::ConstraintTransform>();
std::string transType = obj->TransformType.getValueAsString();
if (transType == "Cylindrical") {
SoTransform* trans = getExtraSymbolTransform();

View File

@@ -280,7 +280,7 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes() const
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
{
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
const SMESHDS_Mesh* data = static_cast<Fem::FemMeshObject*>(vp->getObject())
const SMESHDS_Mesh* data = vp->getObject<Fem::FemMeshObject>()
->FemMesh.getValue()
.getSMesh()
->GetMeshDS();

View File

@@ -123,9 +123,8 @@ void ViewProviderFemPostClip::setupTaskDialog(TaskDlgPost* dlg)
// add the function box
assert(dlg->getView() == this);
dlg->appendBox(new TaskPostClip(
this,
&static_cast<Fem::FemPostClipFilter*>(dlg->getView()->getObject())->Function));
dlg->appendBox(
new TaskPostClip(this, &dlg->getView()->getObject<Fem::FemPostClipFilter>()->Function));
// add the display options
FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg);
@@ -166,9 +165,8 @@ void ViewProviderFemPostCut::setupTaskDialog(TaskDlgPost* dlg)
{
// add the function box
assert(dlg->getView() == this);
dlg->appendBox(new TaskPostCut(
this,
&static_cast<Fem::FemPostCutFilter*>(dlg->getView()->getObject())->Function));
dlg->appendBox(
new TaskPostCut(this, &dlg->getView()->getObject<Fem::FemPostCutFilter>()->Function));
// add the display options
FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg);

View File

@@ -71,7 +71,7 @@ void FunctionWidget::setViewProvider(ViewProviderFemPostFunction* view)
{
// NOLINTBEGIN
m_view = view;
m_object = static_cast<Fem::FemPostFunction*>(view->getObject());
m_object = view->getObject<Fem::FemPostFunction>();
m_connection = m_object->getDocument()->signalChangedObject.connect(
std::bind(&FunctionWidget::onObjectsChanged, this, sp::_1, sp::_2));
// NOLINTEND
@@ -94,7 +94,7 @@ ViewProviderFemPostFunctionProvider::~ViewProviderFemPostFunctionProvider() = de
std::vector<App::DocumentObject*> ViewProviderFemPostFunctionProvider::claimChildren() const
{
return static_cast<Fem::FemPostFunctionProvider*>(getObject())->Functions.getValues();
return getObject<Fem::FemPostFunctionProvider>()->Functions.getValues();
}
std::vector<App::DocumentObject*> ViewProviderFemPostFunctionProvider::claimChildren3D() const
@@ -112,7 +112,7 @@ void ViewProviderFemPostFunctionProvider::onChanged(const App::Property* prop)
void ViewProviderFemPostFunctionProvider::updateData(const App::Property* prop)
{
Gui::ViewProviderDocumentObject::updateData(prop);
Fem::FemPostFunctionProvider* obj = static_cast<Fem::FemPostFunctionProvider*>(getObject());
Fem::FemPostFunctionProvider* obj = getObject<Fem::FemPostFunctionProvider>();
if (prop == &obj->Functions) {
updateSize();
}
@@ -405,7 +405,7 @@ ViewProviderFemPostBoxFunction::~ViewProviderFemPostBoxFunction() = default;
void ViewProviderFemPostBoxFunction::draggerUpdate(SoDragger* m)
{
Fem::FemPostBoxFunction* func = static_cast<Fem::FemPostBoxFunction*>(getObject());
Fem::FemPostBoxFunction* func = getObject<Fem::FemPostBoxFunction>();
SoHandleBoxDragger* dragger = static_cast<SoHandleBoxDragger*>(m);
const SbVec3f& center = dragger->translation.getValue();
@@ -419,7 +419,7 @@ void ViewProviderFemPostBoxFunction::draggerUpdate(SoDragger* m)
void ViewProviderFemPostBoxFunction::updateData(const App::Property* p)
{
Fem::FemPostBoxFunction* func = static_cast<Fem::FemPostBoxFunction*>(getObject());
Fem::FemPostBoxFunction* func = getObject<Fem::FemPostBoxFunction>();
if (!isDragging()
&& (p == &func->Center || p == &func->Length || p == &func->Width || p == &func->Height)) {
const Base::Vector3d& center = func->Center.getValue();
@@ -502,7 +502,7 @@ void BoxWidget::setViewProvider(ViewProviderFemPostFunction* view)
{
FemGui::FunctionWidget::setViewProvider(view);
setBlockObjectUpdates(true);
Fem::FemPostBoxFunction* func = static_cast<Fem::FemPostBoxFunction*>(getObject());
Fem::FemPostBoxFunction* func = getObject<Fem::FemPostBoxFunction>();
Base::Unit unit = func->Center.getUnit();
ui->centerX->setUnit(unit);
ui->centerY->setUnit(unit);
@@ -523,7 +523,7 @@ void BoxWidget::setViewProvider(ViewProviderFemPostFunction* view)
void BoxWidget::onChange(const App::Property& p)
{
setBlockObjectUpdates(true);
Fem::FemPostBoxFunction* func = static_cast<Fem::FemPostBoxFunction*>(getObject());
Fem::FemPostBoxFunction* func = getObject<Fem::FemPostBoxFunction>();
if (&p == &func->Center) {
const Base::Vector3d& vec = static_cast<const App::PropertyVector*>(&p)->getValue();
ui->centerX->setValue(vec.x);
@@ -551,7 +551,7 @@ void BoxWidget::centerChanged(double)
Base::Vector3d vec(ui->centerX->value().getValue(),
ui->centerY->value().getValue(),
ui->centerZ->value().getValue());
static_cast<Fem::FemPostBoxFunction*>(getObject())->Center.setValue(vec);
getObject<Fem::FemPostBoxFunction>()->Center.setValue(vec);
}
}
@@ -559,7 +559,7 @@ void BoxWidget::lengthChanged(double)
{
if (!blockObjectUpdates()) {
double l = ui->length->value().getValue();
static_cast<Fem::FemPostBoxFunction*>(getObject())->Length.setValue(l);
getObject<Fem::FemPostBoxFunction>()->Length.setValue(l);
}
}
@@ -567,7 +567,7 @@ void BoxWidget::widthChanged(double)
{
if (!blockObjectUpdates()) {
double w = ui->width->value().getValue();
static_cast<Fem::FemPostBoxFunction*>(getObject())->Width.setValue(w);
getObject<Fem::FemPostBoxFunction>()->Width.setValue(w);
}
}
@@ -575,7 +575,7 @@ void BoxWidget::heightChanged(double)
{
if (!blockObjectUpdates()) {
double h = ui->height->value().getValue();
static_cast<Fem::FemPostBoxFunction*>(getObject())->Height.setValue(h);
getObject<Fem::FemPostBoxFunction>()->Height.setValue(h);
}
}
@@ -598,7 +598,7 @@ ViewProviderFemPostCylinderFunction::~ViewProviderFemPostCylinderFunction() = de
void ViewProviderFemPostCylinderFunction::draggerUpdate(SoDragger* m)
{
Fem::FemPostCylinderFunction* func = static_cast<Fem::FemPostCylinderFunction*>(getObject());
Fem::FemPostCylinderFunction* func = getObject<Fem::FemPostCylinderFunction>();
SoJackDragger* dragger = static_cast<SoJackDragger*>(m);
const SbVec3f& center = dragger->translation.getValue();
SbVec3f norm(0, 0, 1);
@@ -610,7 +610,7 @@ void ViewProviderFemPostCylinderFunction::draggerUpdate(SoDragger* m)
void ViewProviderFemPostCylinderFunction::updateData(const App::Property* p)
{
Fem::FemPostCylinderFunction* func = static_cast<Fem::FemPostCylinderFunction*>(getObject());
Fem::FemPostCylinderFunction* func = getObject<Fem::FemPostCylinderFunction>();
if (!isDragging() && (p == &func->Center || p == &func->Radius || p == &func->Axis)) {
Base::Vector3d trans = func->Center.getValue();
Base::Vector3d axis = func->Axis.getValue();
@@ -698,7 +698,7 @@ void CylinderWidget::setViewProvider(ViewProviderFemPostFunction* view)
{
FemGui::FunctionWidget::setViewProvider(view);
setBlockObjectUpdates(true);
Fem::FemPostCylinderFunction* func = static_cast<Fem::FemPostCylinderFunction*>(getObject());
Fem::FemPostCylinderFunction* func = getObject<Fem::FemPostCylinderFunction>();
Base::Unit unit = func->Center.getUnit();
ui->centerX->setUnit(unit);
ui->centerY->setUnit(unit);
@@ -714,7 +714,7 @@ void CylinderWidget::setViewProvider(ViewProviderFemPostFunction* view)
void CylinderWidget::onChange(const App::Property& p)
{
setBlockObjectUpdates(true);
Fem::FemPostCylinderFunction* func = static_cast<Fem::FemPostCylinderFunction*>(getObject());
Fem::FemPostCylinderFunction* func = getObject<Fem::FemPostCylinderFunction>();
if (&p == &func->Axis) {
const Base::Vector3d& vec = static_cast<const App::PropertyVector*>(&p)->getValue();
ui->axisX->setValue(vec.x);
@@ -740,7 +740,7 @@ void CylinderWidget::centerChanged(double)
Base::Vector3d vec(ui->centerX->value().getValue(),
ui->centerY->value().getValue(),
ui->centerZ->value().getValue());
static_cast<Fem::FemPostCylinderFunction*>(getObject())->Center.setValue(vec);
getObject<Fem::FemPostCylinderFunction>()->Center.setValue(vec);
}
}
@@ -750,15 +750,14 @@ void CylinderWidget::axisChanged(double)
Base::Vector3d vec(ui->axisX->value().getValue(),
ui->axisY->value().getValue(),
ui->axisZ->value().getValue());
static_cast<Fem::FemPostCylinderFunction*>(getObject())->Axis.setValue(vec);
getObject<Fem::FemPostCylinderFunction>()->Axis.setValue(vec);
}
}
void CylinderWidget::radiusChanged(double)
{
if (!blockObjectUpdates()) {
static_cast<Fem::FemPostCylinderFunction*>(getObject())
->Radius.setValue(ui->radius->value().getValue());
getObject<Fem::FemPostCylinderFunction>()->Radius.setValue(ui->radius->value().getValue());
}
}
@@ -790,7 +789,7 @@ ViewProviderFemPostPlaneFunction::~ViewProviderFemPostPlaneFunction() = default;
void ViewProviderFemPostPlaneFunction::draggerUpdate(SoDragger* m)
{
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
Fem::FemPostPlaneFunction* func = getObject<Fem::FemPostPlaneFunction>();
SoJackDragger* dragger = static_cast<SoJackDragger*>(m);
// the new axis of the plane
@@ -832,7 +831,7 @@ void ViewProviderFemPostPlaneFunction::onChanged(const App::Property* prop)
void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p)
{
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
Fem::FemPostPlaneFunction* func = getObject<Fem::FemPostPlaneFunction>();
if (!isDragging() && (p == &func->Origin || p == &func->Normal)) {
if (!m_detectscale) {
@@ -925,7 +924,7 @@ void PlaneWidget::applyPythonCode()
void PlaneWidget::setViewProvider(ViewProviderFemPostFunction* view)
{
FemGui::FunctionWidget::setViewProvider(view);
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
Fem::FemPostPlaneFunction* func = getObject<Fem::FemPostPlaneFunction>();
const Base::Unit unit = func->Origin.getUnit();
setBlockObjectUpdates(true);
ui->originX->setUnit(unit);
@@ -941,7 +940,7 @@ void PlaneWidget::setViewProvider(ViewProviderFemPostFunction* view)
void PlaneWidget::onChange(const App::Property& p)
{
setBlockObjectUpdates(true);
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
Fem::FemPostPlaneFunction* func = getObject<Fem::FemPostPlaneFunction>();
if (&p == &func->Normal) {
const Base::Vector3d& vec = static_cast<const App::PropertyVector*>(&p)->getValue();
ui->normalX->setValue(vec.x);
@@ -963,7 +962,7 @@ void PlaneWidget::normalChanged(double)
Base::Vector3d vec(ui->normalX->value().getValue(),
ui->normalY->value().getValue(),
ui->normalZ->value().getValue());
static_cast<Fem::FemPostPlaneFunction*>(getObject())->Normal.setValue(vec);
getObject<Fem::FemPostPlaneFunction>()->Normal.setValue(vec);
}
}
@@ -973,7 +972,7 @@ void PlaneWidget::originChanged(double)
Base::Vector3d vec(ui->originX->value().getValue(),
ui->originY->value().getValue(),
ui->originZ->value().getValue());
static_cast<Fem::FemPostPlaneFunction*>(getObject())->Origin.setValue(vec);
getObject<Fem::FemPostPlaneFunction>()->Origin.setValue(vec);
}
}
@@ -1015,7 +1014,7 @@ SoTransformManip* ViewProviderFemPostSphereFunction::setupManipulator()
void ViewProviderFemPostSphereFunction::draggerUpdate(SoDragger* m)
{
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
Fem::FemPostSphereFunction* func = getObject<Fem::FemPostSphereFunction>();
SoHandleBoxDragger* dragger = static_cast<SoHandleBoxDragger*>(m);
// the new axis of the plane
@@ -1029,7 +1028,7 @@ void ViewProviderFemPostSphereFunction::draggerUpdate(SoDragger* m)
void ViewProviderFemPostSphereFunction::updateData(const App::Property* p)
{
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
Fem::FemPostSphereFunction* func = getObject<Fem::FemPostSphereFunction>();
if (!isDragging() && (p == &func->Center || p == &func->Radius)) {
@@ -1093,7 +1092,7 @@ void SphereWidget::setViewProvider(ViewProviderFemPostFunction* view)
{
FemGui::FunctionWidget::setViewProvider(view);
setBlockObjectUpdates(true);
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
Fem::FemPostSphereFunction* func = getObject<Fem::FemPostSphereFunction>();
Base::Unit unit = func->Center.getUnit();
ui->centerX->setUnit(unit);
ui->centerY->setUnit(unit);
@@ -1108,7 +1107,7 @@ void SphereWidget::setViewProvider(ViewProviderFemPostFunction* view)
void SphereWidget::onChange(const App::Property& p)
{
setBlockObjectUpdates(true);
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
Fem::FemPostSphereFunction* func = getObject<Fem::FemPostSphereFunction>();
if (&p == &func->Radius) {
double val = static_cast<const App::PropertyDistance*>(&p)->getValue();
ui->radius->setValue(val);
@@ -1128,15 +1127,14 @@ void SphereWidget::centerChanged(double)
Base::Vector3d vec(ui->centerX->value().getValue(),
ui->centerY->value().getValue(),
ui->centerZ->value().getValue());
static_cast<Fem::FemPostSphereFunction*>(getObject())->Center.setValue(vec);
getObject<Fem::FemPostSphereFunction>()->Center.setValue(vec);
}
}
void SphereWidget::radiusChanged(double)
{
if (!blockObjectUpdates()) {
static_cast<Fem::FemPostSphereFunction*>(getObject())
->Radius.setValue(ui->radius->value().getValue());
getObject<Fem::FemPostSphereFunction>()->Radius.setValue(ui->radius->value().getValue());
}
}

View File

@@ -761,7 +761,7 @@ void ViewProviderFemPostObject::WriteTransparency()
void ViewProviderFemPostObject::updateData(const App::Property* p)
{
Fem::FemPostObject* postObject = static_cast<Fem::FemPostObject*>(getObject());
Fem::FemPostObject* postObject = getObject<Fem::FemPostObject>();
if (p == &postObject->Data) {
updateVtk();
}
@@ -846,7 +846,7 @@ bool ViewProviderFemPostObject::setupPipeline()
return false;
}
auto postObject = static_cast<Fem::FemPostObject*>(getObject());
auto postObject = getObject<Fem::FemPostObject>();
vtkDataObject* data = postObject->Data.getValue();
if (!data) {
@@ -903,7 +903,7 @@ void ViewProviderFemPostObject::onChanged(const App::Property* prop)
bool ResetColorBarRange;
// the point filter delivers a single value thus recoloring the bar is senseless
if (static_cast<Fem::FemPostObject*>(getObject())->getTypeId()
if (getObject<Fem::FemPostObject>()->getTypeId()
== Base::Type::fromName("Fem::FemPostDataAtPointFilter")) {
ResetColorBarRange = false;
}

View File

@@ -53,7 +53,7 @@ ViewProviderFemPostPipeline::~ViewProviderFemPostPipeline() = default;
std::vector<App::DocumentObject*> ViewProviderFemPostPipeline::claimChildren() const
{
Fem::FemPostPipeline* pipeline = static_cast<Fem::FemPostPipeline*>(getObject());
Fem::FemPostPipeline* pipeline = getObject<Fem::FemPostPipeline>();
std::vector<App::DocumentObject*> children;
if (pipeline->Functions.getValue()) {
@@ -75,7 +75,7 @@ std::vector<App::DocumentObject*> ViewProviderFemPostPipeline::claimChildren3D()
void ViewProviderFemPostPipeline::updateData(const App::Property* prop)
{
FemGui::ViewProviderFemPostObject::updateData(prop);
Fem::FemPostPipeline* pipeline = static_cast<Fem::FemPostPipeline*>(getObject());
Fem::FemPostPipeline* pipeline = getObject<Fem::FemPostPipeline>();
if (prop == &pipeline->Functions) {
updateFunctionSize();
}
@@ -85,7 +85,7 @@ void ViewProviderFemPostPipeline::updateFunctionSize()
{
// we need to get the bounding box and set the function provider size
Fem::FemPostPipeline* obj = static_cast<Fem::FemPostPipeline*>(getObject());
Fem::FemPostPipeline* obj = getObject<Fem::FemPostPipeline>();
if (!obj->Functions.getValue()
|| !obj->Functions.getValue()->isDerivedFrom(
@@ -178,7 +178,7 @@ void ViewProviderFemPostPipeline::updateColorBars()
void ViewProviderFemPostPipeline::transformField(char* FieldName, double FieldFactor)
{
Fem::FemPostPipeline* obj = static_cast<Fem::FemPostPipeline*>(getObject());
Fem::FemPostPipeline* obj = getObject<Fem::FemPostPipeline>();
vtkSmartPointer<vtkDataObject> data = obj->Data.getValue();
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);

View File

@@ -37,7 +37,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetElementNodes, Gui::ViewProviderGeometryOb
bool ViewProviderSetElementNodes::doubleClicked()
{
Gui::TaskView::TaskDialog* dlg =
new TaskDlgCreateElementSet(static_cast<Fem::FemSetElementNodesObject*>(getObject()));
new TaskDlgCreateElementSet(getObject<Fem::FemSetElementNodesObject>());
Gui::Control().showDialog(dlg);
return true;
}

View File

@@ -31,16 +31,16 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetElements, Gui::ViewProviderGeometryObject
bool ViewProviderSetElements::doubleClicked()
{
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject
// *>(getObject())); Gui::Control().showDialog(dlg);
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject
// >()); Gui::Control().showDialog(dlg);
return true;
}
bool ViewProviderSetElements::setEdit(int)
{
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject
// *>(getObject())); Gui::Control().showDialog(dlg);
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject
// >()); Gui::Control().showDialog(dlg);
return true;
}

View File

@@ -31,16 +31,16 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetFaces, Gui::ViewProviderGeometryObject)
bool ViewProviderSetFaces::doubleClicked()
{
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject
// *>(getObject())); Gui::Control().showDialog(dlg);
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject
// >()); Gui::Control().showDialog(dlg);
return true;
}
bool ViewProviderSetFaces::setEdit(int)
{
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject
// *>(getObject())); Gui::Control().showDialog(dlg);
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject
// >()); Gui::Control().showDialog(dlg);
return true;
}

View File

@@ -31,16 +31,16 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetGeometry, Gui::ViewProviderGeometryObject
bool ViewProviderSetGeometry::doubleClicked()
{
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject
// *>(getObject())); Gui::Control().showDialog(dlg);
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject
// >()); Gui::Control().showDialog(dlg);
return true;
}
bool ViewProviderSetGeometry::setEdit(int)
{
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject
// *>(getObject())); Gui::Control().showDialog(dlg);
// Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject
// >()); Gui::Control().showDialog(dlg);
return true;
}

View File

@@ -35,8 +35,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetNodes, Gui::ViewProviderGeometryObject)
bool ViewProviderSetNodes::doubleClicked()
{
Gui::TaskView::TaskDialog* dlg =
new TaskDlgCreateNodeSet(static_cast<Fem::FemSetNodesObject*>(getObject()));
Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject>());
Gui::Control().showDialog(dlg);
return true;
}
@@ -44,8 +43,7 @@ bool ViewProviderSetNodes::doubleClicked()
bool ViewProviderSetNodes::setEdit(int)
{
Gui::TaskView::TaskDialog* dlg =
new TaskDlgCreateNodeSet(static_cast<Fem::FemSetNodesObject*>(getObject()));
Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(getObject<Fem::FemSetNodesObject>());
Gui::Control().showDialog(dlg);
return true;
}