Merge pull request #19917 from tritao/refactor-document-recompute
Core: Refactor code around document and feature recompute
This commit is contained in:
@@ -676,7 +676,7 @@ void TaskAttacher::onCheckFlip(bool on)
|
||||
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
pcAttach->MapReversed.setValue(on);
|
||||
ViewProvider->getObject()->getDocument()->recomputeFeature(ViewProvider->getObject());
|
||||
ViewProvider->getObject()->recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskAttacher::onButtonRef(const bool checked, unsigned idx)
|
||||
|
||||
@@ -528,17 +528,18 @@ bool CmdPartDesignNewSketch::isActive()
|
||||
// Common utility functions for all features creating solids
|
||||
//===========================================================================
|
||||
|
||||
void finishFeature(const Gui::Command* cmd, App::DocumentObject *Feat,
|
||||
static void finishFeature(const Gui::Command* cmd, App::DocumentObject *feature,
|
||||
App::DocumentObject* prevSolidFeature = nullptr,
|
||||
const bool hidePrevSolid = true,
|
||||
const bool updateDocument = true)
|
||||
{
|
||||
PartDesign::Body *pcActiveBody;
|
||||
PartDesign::Body *activeBody;
|
||||
|
||||
if (prevSolidFeature) {
|
||||
pcActiveBody = PartDesignGui::getBodyFor(prevSolidFeature, /*messageIfNot = */false);
|
||||
} else { // insert into the same body as the given previous one
|
||||
pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false);
|
||||
// insert into the same body as the given previous one
|
||||
activeBody = PartDesignGui::getBodyFor(prevSolidFeature, /*messageIfNot = */false);
|
||||
} else {
|
||||
activeBody = PartDesignGui::getBody(/*messageIfNot = */false);
|
||||
}
|
||||
|
||||
if (hidePrevSolid && prevSolidFeature)
|
||||
@@ -547,27 +548,24 @@ void finishFeature(const Gui::Command* cmd, App::DocumentObject *Feat,
|
||||
if (updateDocument)
|
||||
cmd->updateActive();
|
||||
|
||||
auto base = dynamic_cast<PartDesign::Feature*>(Feat);
|
||||
auto base = dynamic_cast<PartDesign::Feature*>(feature);
|
||||
if (base)
|
||||
base = dynamic_cast<PartDesign::Feature*>(base->getBaseObject(true));
|
||||
App::DocumentObject *obj = base;
|
||||
if (!obj)
|
||||
obj = pcActiveBody;
|
||||
obj = activeBody;
|
||||
|
||||
// Do this before calling setEdit to avoid to override the 'Shape preview' mode (#0003621)
|
||||
if (obj) {
|
||||
cmd->copyVisual(Feat, "ShapeAppearance", obj);
|
||||
cmd->copyVisual(Feat, "LineColor", obj);
|
||||
cmd->copyVisual(Feat, "PointColor", obj);
|
||||
cmd->copyVisual(Feat, "Transparency", obj);
|
||||
cmd->copyVisual(Feat, "DisplayMode", obj);
|
||||
cmd->copyVisual(feature, "ShapeAppearance", obj);
|
||||
cmd->copyVisual(feature, "LineColor", obj);
|
||||
cmd->copyVisual(feature, "PointColor", obj);
|
||||
cmd->copyVisual(feature, "Transparency", obj);
|
||||
cmd->copyVisual(feature, "DisplayMode", obj);
|
||||
}
|
||||
|
||||
// #0001721: use '0' as edit value to avoid switching off selection in
|
||||
// ViewProviderGeometryObject::setEditViewer
|
||||
PartDesignGui::setEdit(Feat,pcActiveBody);
|
||||
PartDesignGui::setEdit(feature, activeBody);
|
||||
cmd->doCommand(cmd->Gui,"Gui.Selection.clearSelection()");
|
||||
//cmd->doCommand(cmd->Gui,"Gui.Selection.addSelection(App.ActiveDocument.ActiveObject)");
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -72,7 +72,7 @@ void TaskFeatureParameters::recomputeFeature()
|
||||
if (!blockUpdate) {
|
||||
App::DocumentObject* obj = getObject();
|
||||
assert (obj);
|
||||
obj->getDocument()->recomputeFeature (obj);
|
||||
obj->recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,12 +158,7 @@ bool ViewProviderTransformed::onDelete(const std::vector<std::string> &s)
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
|
||||
void ViewProviderTransformed::recomputeFeature(bool recompute)
|
||||
{
|
||||
PartDesign::Transformed* pcTransformed = getObject<PartDesign::Transformed>();
|
||||
if(recompute || (pcTransformed->isError() || pcTransformed->mustExecute()))
|
||||
pcTransformed->recomputeFeature(true);
|
||||
|
||||
void ViewProviderTransformed::handleTranformedResult(PartDesign::Transformed* pcTransformed) {
|
||||
unsigned rejected = 0;
|
||||
TopoDS_Shape cShape = pcTransformed->rejected;
|
||||
TopExp_Explorer xp;
|
||||
@@ -209,6 +204,15 @@ void ViewProviderTransformed::recomputeFeature(bool recompute)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderTransformed::recomputeFeature(bool recompute)
|
||||
{
|
||||
PartDesign::Transformed* pcTransformed = getObject<PartDesign::Transformed>();
|
||||
if(recompute || (pcTransformed->isError() || pcTransformed->mustExecute()))
|
||||
pcTransformed->recomputeFeature(true);
|
||||
|
||||
handleTranformedResult(pcTransformed);
|
||||
}
|
||||
|
||||
void ViewProviderTransformed::showRejectedShape(TopoDS_Shape shape)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
|
||||
#include "ViewProvider.h"
|
||||
|
||||
namespace PartDesign {
|
||||
class Transformed;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskDlgTransformedParameters;
|
||||
@@ -58,6 +62,7 @@ protected:
|
||||
void unsetEdit(int ModNum) override;
|
||||
|
||||
bool checkDlgOpen(TaskDlgTransformedParameters* transformedDlg);
|
||||
void handleTranformedResult(PartDesign::Transformed* transformed);
|
||||
|
||||
// node for the representation of rejected repetitions
|
||||
SoGroup * pcRejectedRoot{nullptr};
|
||||
|
||||
@@ -157,7 +157,7 @@ void TaskBalloon::recomputeFeature()
|
||||
{
|
||||
App::DocumentObject* objVP = m_balloonVP->getObject();
|
||||
assert(objVP);
|
||||
objVP->getDocument()->recomputeFeature(objVP);
|
||||
objVP->recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskBalloon::onTextChanged()
|
||||
|
||||
@@ -180,7 +180,7 @@ void TaskDimension::recomputeFeature()
|
||||
}
|
||||
App::DocumentObject* objVP = m_dimensionVP->getObject();
|
||||
assert(objVP);
|
||||
objVP->getDocument()->recomputeFeature(objVP);
|
||||
objVP->recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskDimension::onTheoreticallyExactChanged()
|
||||
|
||||
@@ -296,7 +296,7 @@ void TaskLeaderLine::recomputeFeature()
|
||||
{
|
||||
App::DocumentObject* objVP = m_lineVP->getObject();
|
||||
assert(objVP);
|
||||
objVP->getDocument()->recomputeFeature(objVP);
|
||||
objVP->recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLeaderLine::onStartSymbolChanged()
|
||||
|
||||
Reference in New Issue
Block a user