introduce flag to skip recomputes of a document when needed
This commit is contained in:
@@ -55,6 +55,7 @@ recompute path. Also enables more complicated dependencies beyond trees.
|
||||
# include <algorithm>
|
||||
# include <sstream>
|
||||
# include <climits>
|
||||
# include <bitset>
|
||||
#endif
|
||||
|
||||
#include <boost/graph/topological_sort.hpp>
|
||||
@@ -139,8 +140,7 @@ struct DocumentP
|
||||
std::map<Vertex,DocumentObject*> vertexMap;
|
||||
bool rollback;
|
||||
bool undoing; ///< document in the middle of undo or redo
|
||||
bool closable;
|
||||
bool keepTrailingDigits;
|
||||
std::bitset<32> StatusBits;
|
||||
int iUndoMode;
|
||||
unsigned int UndoMemSize;
|
||||
unsigned int UndoMaxStackSize;
|
||||
@@ -153,8 +153,8 @@ struct DocumentP
|
||||
iTransactionMode = 0;
|
||||
rollback = false;
|
||||
undoing = false;
|
||||
closable = true;
|
||||
keepTrailingDigits = true;
|
||||
StatusBits.set((size_t)Document::Closable, true);
|
||||
StatusBits.set((size_t)Document::KeepTrailingDigits, true);
|
||||
iUndoMode = 0;
|
||||
UndoMemSize = 0;
|
||||
UndoMaxStackSize = 20;
|
||||
@@ -165,6 +165,16 @@ struct DocumentP
|
||||
|
||||
PROPERTY_SOURCE(App::Document, App::PropertyContainer)
|
||||
|
||||
bool Document::testStatus(Status pos) const
|
||||
{
|
||||
return d->StatusBits.test((size_t)pos);
|
||||
}
|
||||
|
||||
void Document::setStatus(Status pos, bool on)
|
||||
{
|
||||
d->StatusBits.set((size_t)pos, on);
|
||||
}
|
||||
|
||||
void Document::writeDependencyGraphViz(std::ostream &out)
|
||||
{
|
||||
// // caching vertex to DocObject
|
||||
@@ -1156,8 +1166,8 @@ void Document::writeObjects(const std::vector<App::DocumentObject*>& obj,
|
||||
std::vector<App::DocumentObject*>
|
||||
Document::readObjects(Base::XMLReader& reader)
|
||||
{
|
||||
bool keepDigits = d->keepTrailingDigits;
|
||||
d->keepTrailingDigits = !reader.doNameMapping();
|
||||
bool keepDigits = testStatus(Document::KeepTrailingDigits);
|
||||
setStatus(Document::KeepTrailingDigits, !reader.doNameMapping());
|
||||
std::vector<App::DocumentObject*> objs;
|
||||
|
||||
// read the object types
|
||||
@@ -1185,8 +1195,9 @@ Document::readObjects(Base::XMLReader& reader)
|
||||
Base::Console().Error("Cannot create object '%s': (%s)\n", name.c_str(), e.what());
|
||||
}
|
||||
}
|
||||
|
||||
reader.readEndElement("Objects");
|
||||
d->keepTrailingDigits = keepDigits;
|
||||
setStatus(Document::KeepTrailingDigits, keepDigits);
|
||||
|
||||
// read the features itself
|
||||
reader.readElement("ObjectData");
|
||||
@@ -1518,12 +1529,12 @@ vector<DocumentObject*> Document::getTouched(void) const
|
||||
|
||||
void Document::setClosable(bool c)
|
||||
{
|
||||
d->closable = c;
|
||||
setStatus(Document::Closable, c);
|
||||
}
|
||||
|
||||
bool Document::isClosable() const
|
||||
{
|
||||
return d->closable;
|
||||
return testStatus(Document::Closable);
|
||||
}
|
||||
|
||||
int Document::countObjects(void) const
|
||||
@@ -1691,8 +1702,14 @@ void Document::_rebuildDependencyList(void)
|
||||
|
||||
void Document::recompute()
|
||||
{
|
||||
// The 'SkipRecompute' flag can be (tmp.) set to avoid to many
|
||||
// time expensive recomputes
|
||||
bool skip = testStatus(Document::SkipRecompute);
|
||||
if (skip)
|
||||
return;
|
||||
|
||||
// delete recompute log
|
||||
for( std::vector<App::DocumentObjectExecReturn*>::iterator it=_RecomputeLog.begin();it!=_RecomputeLog.end();++it)
|
||||
for (std::vector<App::DocumentObjectExecReturn*>::iterator it=_RecomputeLog.begin();it!=_RecomputeLog.end();++it)
|
||||
delete *it;
|
||||
_RecomputeLog.clear();
|
||||
|
||||
@@ -2356,7 +2373,7 @@ std::string Document::getUniqueObjectName(const char *Name) const
|
||||
else {
|
||||
// remove also trailing digits from clean name which is to avoid to create lengthy names
|
||||
// like 'Box001001'
|
||||
if (!d->keepTrailingDigits) {
|
||||
if (!testStatus(KeepTrailingDigits)) {
|
||||
std::string::size_type index = CleanName.find_last_not_of("0123456789");
|
||||
if (index+1 < CleanName.size()) {
|
||||
CleanName = CleanName.substr(0,index+1);
|
||||
|
||||
Reference in New Issue
Block a user