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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user