Skip to content

Commit

Permalink
+ add convenience method recomputeFeature()
Browse files Browse the repository at this point in the history
+ make method recompute() protected
  • Loading branch information
wwmayer committed Nov 6, 2016
1 parent bbf5548 commit 3b961bc
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 32 deletions.
8 changes: 8 additions & 0 deletions src/App/DocumentObject.cpp
Expand Up @@ -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())
Expand Down
7 changes: 5 additions & 2 deletions src/App/DocumentObject.h
Expand Up @@ -120,8 +120,6 @@ class AppExport DocumentObject: public App::TransactionalObject
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);}
Expand Down Expand Up @@ -162,6 +160,9 @@ class AppExport DocumentObject: public App::TransactionalObject
*/
virtual short mustExecute(void) const;

/// Recompute only this feature
bool recomputeFeature();

/// get the status Message
const char *getStatusString(void) const;

Expand Down Expand Up @@ -197,6 +198,8 @@ class AppExport DocumentObject: public App::TransactionalObject
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().
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Drawing/App/FeatureView.h
Expand Up @@ -52,18 +52,18 @@ class DrawingExport FeatureView : public App::DocumentObject
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;
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Drawing/Gui/TaskOrthoViews.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskDlgCreateNodeSet.cpp
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.cpp
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Part/App/PartFeature.h
Expand Up @@ -55,10 +55,6 @@ class PartExport Feature : public App::GeoFeature

/** @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;
//@}

Expand All @@ -71,6 +67,10 @@ class PartExport Feature : public App::GeoFeature
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
Expand Down
10 changes: 4 additions & 6 deletions src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp
Expand Up @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Robot/Gui/TaskDlgEdge2Trac.cpp
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/App/DrawHatch.cpp
Expand Up @@ -94,7 +94,7 @@ App::DocumentObjectExecReturn *DrawHatch::execute(void)
DrawViewPart* parent = getSourceView();
if (parent) {
parent->touch();
parent->recompute();
parent->recomputeFeature();
}
return App::DocumentObject::StdReturn;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/TechDraw/App/DrawProjGroup.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/TaskProjGroup.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -229,7 +229,7 @@ void TaskProjGroup::scaleTypeChanged(int index)
return;
}

multiView->recompute();
multiView->recomputeFeature();
Gui::Command::updateActive();
}

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 3b961bc

Please sign in to comment.