+ add convenience method recomputeFeature()

+ make method recompute() protected
This commit is contained in:
wmayer 2016-11-06 17:16:50 +01:00
parent bbf5548899
commit 3b961bcb5f
13 changed files with 41 additions and 32 deletions

View File

@ -102,6 +102,14 @@ DocumentObjectExecReturn *DocumentObject::execute(void)
return StdReturn;
}
bool DocumentObject::recomputeFeature()
{
Document* doc = this->getDocument();
if (doc)
doc->recomputeFeature(this);
return isValid();
}
short DocumentObject::mustExecute(void) const
{
if(isTouched())

View File

@ -120,8 +120,6 @@ public:
bool isRestoring() const {return StatusBits.test(4);}
/// returns true if this objects is currently restoring from file
bool isDeleting() const {return StatusBits.test(5);}
/// recompute only this object
virtual App::DocumentObjectExecReturn *recompute(void);
/// return the status bits
unsigned long getStatus() const {return StatusBits.to_ulong();}
bool testStatus(ObjectStatus pos) const {return StatusBits.test((size_t)pos);}
@ -162,6 +160,9 @@ public:
*/
virtual short mustExecute(void) const;
/// Recompute only this feature
bool recomputeFeature();
/// get the status Message
const char *getStatusString(void) const;
@ -197,6 +198,8 @@ public:
const std::string & getOldLabel() const { return oldLabel; }
protected:
/// recompute only this object
virtual App::DocumentObjectExecReturn *recompute(void);
/** get called by the document to recompute this feature
* Normaly this method get called in the processing of
* Document::recompute().

View File

@ -52,18 +52,18 @@ public:
App::PropertyString ViewResult;
App::PropertyBool Visible;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
return "DrawingGui::ViewProviderDrawingView";
}
protected:
/** @name methods overide Feature */
//@{
/// recalculate the Feature
virtual App::DocumentObjectExecReturn *recompute(void);
virtual App::DocumentObjectExecReturn *execute(void);
//@}
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
return "DrawingGui::ViewProviderDrawingView";
}
};
typedef App::FeaturePythonT<FeatureView> FeatureViewPython;

View File

@ -314,7 +314,7 @@ OrthoViews::~OrthoViews()
for (int i = views.size() - 1; i >= 0; i--)
delete views[i];
page->recompute();
page->recomputeFeature();
}
void OrthoViews::slotDeletedDocument(const App::Document& Obj)

View File

@ -75,7 +75,7 @@ bool TaskDlgCreateNodeSet::accept()
{
try {
FemSetNodesObject->Nodes.setValues(param->tempSet);
FemSetNodesObject->recompute();
FemSetNodesObject->recomputeFeature();
//Gui::Document* doc = Gui::Application::Instance->activeDocument();
//if(doc)
// doc->resetEdit();

View File

@ -101,11 +101,11 @@ bool TaskDlgMeshShapeNetgen::accept()
if(param->touched)
{
Gui::WaitCursor wc;
App::DocumentObjectExecReturn* ret = FemMeshShapeNetgenObject->recompute();
if (ret) {
bool ret = FemMeshShapeNetgenObject->recomputeFeature();
if (!ret) {
wc.restoreCursor();
QMessageBox::critical(Gui::getMainWindow(), tr("Meshing failure"), QString::fromStdString(ret->Why));
delete ret;
QMessageBox::critical(Gui::getMainWindow(), tr("Meshing failure"),
QString::fromStdString(FemMeshShapeNetgenObject->getStatusString()));
return true;
}
}

View File

@ -55,10 +55,6 @@ public:
/** @name methods override feature */
//@{
/// recalculate the feature
/// recompute only this object
virtual App::DocumentObjectExecReturn *recompute(void);
virtual App::DocumentObjectExecReturn *execute(void);
virtual short mustExecute(void) const;
//@}
@ -71,6 +67,10 @@ public:
TopLoc_Location getLocation() const;
protected:
/// recompute only this object
virtual App::DocumentObjectExecReturn *recompute(void);
/// recalculate the feature
virtual App::DocumentObjectExecReturn *execute(void);
virtual void onChanged(const App::Property* prop);
/**
* Build a history of changes

View File

@ -638,15 +638,13 @@ TaskPrimitiveParameters::~TaskPrimitiveParameters()
}
void TaskPrimitiveParameters::objectChanged(const App::DocumentObject& obj, const App::Property& p) {
if(&obj == cs && strcmp(p.getName(), "Placement")==0) {
vp_prm->getObject()->recompute();
void TaskPrimitiveParameters::objectChanged(const App::DocumentObject& obj, const App::Property& p)
{
if (&obj == cs && strcmp(p.getName(), "Placement")==0) {
vp_prm->getObject()->recomputeFeature();
}
}
bool TaskPrimitiveParameters::accept()
{
primitive->setPrimitive(QString::fromUtf8(vp_prm->getObject()->getNameInDocument()));

View File

@ -96,7 +96,7 @@ bool TaskDlgEdge2Trac::accept()
try {
if (select->isSelectionValid()){
select->accept();
Edge2TaskObject->recompute();
Edge2TaskObject->recomputeFeature();
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if(doc)
doc->resetEdit();

View File

@ -69,14 +69,14 @@ void TaskDlgTrajectoryDressUp::clicked(int button)
// transfert the values to the object
param->writeValues();
// May throw an exception which we must handle here
pcObject->recompute();
pcObject->recomputeFeature();
}
}
bool TaskDlgTrajectoryDressUp::accept()
{
param->writeValues();
pcObject->recompute();
pcObject->recomputeFeature();
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if(doc)

View File

@ -94,7 +94,7 @@ App::DocumentObjectExecReturn *DrawHatch::execute(void)
DrawViewPart* parent = getSourceView();
if (parent) {
parent->touch();
parent->recompute();
parent->recomputeFeature();
}
return App::DocumentObject::StdReturn;
}

View File

@ -305,7 +305,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
addView(view); //from DrawViewCollection - add to ProjGroup Views
moveToCentre();
view->recompute();
view->recomputeFeature();
}
return view;
@ -641,7 +641,7 @@ void DrawProjGroup::updateChildren(double scale)
if(std::abs(view->Scale.getValue() - scale) > FLT_EPSILON) {
view->Scale.setValue(scale);
}
view->recompute();
view->recomputeFeature();
}
}
}

View File

@ -128,7 +128,7 @@ void TaskProjGroup::viewToggled(bool toggle)
changed = true;
}
if (changed) {
multiView->recompute();
multiView->recomputeFeature();
if (multiView->ScaleType.isValue("Automatic")) {
double scale = multiView->Scale.getValue();
setFractionalScale(scale);
@ -229,7 +229,7 @@ void TaskProjGroup::scaleTypeChanged(int index)
return;
}
multiView->recompute();
multiView->recomputeFeature();
Gui::Command::updateActive();
}
@ -304,7 +304,7 @@ void TaskProjGroup::scaleManuallyChanged(int i)
double scale = (double) a / (double) b;
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.Scale = %f", multiView->getNameInDocument()
, scale);
multiView->recompute();
multiView->recomputeFeature();
Gui::Command::updateActive();
}