OpenLexocad  27.1
CoreDocument.h
Go to the documentation of this file.
1 #pragma once
2 #pragma warning(disable : 4251)
3 
5 #include <Base/Observer.h>
6 #include <Core/DocObject.h>
7 #include <Core/PropertyBundle.h>
9 #include <Core/PropertyInteger.h> // Core::PropertyIndex
10 #include <Core/PropertyLink.h>
11 #include <Core/PropertyText.h>
13 
14 #include <QDateTime>
15 #include <unordered_map>
16 #include <unordered_set>
17 #include <map>
18 #include <set>
19 #include <vector>
20 #include <optional>
21 
22 //#include "GraphBuilder.h"
23 
24 #ifndef SWIG
25 #include <boost/signals2.hpp>
26 #endif
27 
28 #define DIR_NAME_INTERNAL_CATALOG "__internalCatalog__"
29 #define DIR_NAME_WEBGL_GT "webgl"
30 #define DIR_NAME_GEOID "geoid"
31 #define FILE_NAME_CAMERA_ANIMATION "CameraAnimation.ivc"
32 
33 typedef std::vector<Core::DocObject*> DOCOBJECTS;
34 typedef std::map<Core::DocObject*, std::vector<std::string>> DOCOBJECTS_ERROR_MAP;
35 
36 namespace zipios
37 {
38 class ZipInputStream;
39 }
40 
41 namespace App
42 {
43 class ElementTool;
44 }
45 
46 namespace Core
47 {
48 class Variant;
49 class ObjectGraph;
50 class DocObject;
51 class ExecObject;
52 class PropertyLinkBase;
53 class CoreDocumentImpl;
54 class PropertyGUID;
56 class Transaction;
57 class RelGraph;
58 
59 typedef std::vector<Core::DocObject*> ObjectVector;
60 typedef std::unordered_set<Core::DocObject*> ObjectSet;
61 typedef std::unordered_map<DocObject::IdType, Core::DocObject*> ObjectMap;
62 typedef std::vector<Core::ExecObject*> ExecObjectVector;
63 typedef std::unordered_set<Core::ExecObject*> ExecObjectSet;
64 typedef std::unordered_map<DocObject::IdType, Core::ExecObject*> ExecObjectMap;
65 typedef std::map<Base::Type, ObjectSet> ObjectTypeMap;
66 
68 {
72 };
73 typedef std::multimap<Base::String, Core::AttachmentEntry> Attachments;
74 
75 /*
76 Core::DocChanges
77 This class notifies the observers about a recompute of the document.
78 It can also be used to send messages to the Observers:
79 1. Example:
80 
81 Core::ExecObject* o = ...
82 
83 Core::DocChanges docChanges;
84 docChanges.Why = Core::DocChanges::MESSAGE_BY_NAME
85 docChanges.MsgName = "MsgObjectAdded";
86 docChanges.Value = Core::Variant(o);
87 emitAndNotify(docChanges);
88 
89 2. Example:
90 
91 enum DocMessage
92 {
93  MSG_OBJECT_ADDED = 1,
94  ...
95 }
96 
97 Core::ExecObject* o = ...
98 
99 Core::DocChanges docChanges;
100 docChanges.Why = Core::DocChanges::MESSAGE_BY_ID
101 docChanges.MsgId = DocMessage::MSG_OBJECT_ADDED;
102 docChanges.Value = Core::Variant(o);
103 emitAndNotify(docChanges);
104 */
105 
106 class LX_CORE_EXPORT DocChanges
107 {
108 public:
109  DocChanges(Core::CoreDocument* doc) : Value(0), Document(doc) {}
110 
111  enum why
112  {
115  MESSAGE_BY_ID
116  } Why = RECOMPUTED;
117 
118  std::string MsgName = "";
119  int MsgId = -1;
122 
123  std::vector<Core::DocObject*> NewObjects;
124  std::vector<Core::DocObject*> UpdatedObjects;
125  std::vector<Core::DocObject*> DeletedObjects;
126  std::map<Core::DocObject*, std::vector<std::string>> ErroneousObjects; // Objects that caused an error in recompute with its error messages
127 
128 private:
129  DocChanges() : MsgId(0), Document(nullptr){};
130 };
131 
132 // All Lexocad Core message Ids are in the range 1000 - 1999
133 const int LEXOCAD_CORE_MSGID = 1000;
134 
135 enum LX_CORE_EXPORT DocMessage
136 {
154  PostCheck = LEXOCAD_CORE_MSGID + 17
155 };
159 struct LX_CORE_EXPORT DocumentState
160 {
161  // Copy constructor
162  DocumentState() = default;
163  DocumentState(const DocumentState& rhs)
164  {
165  PropertyErrors = rhs.PropertyErrors;
166  LastErroneousObjects = rhs.LastErroneousObjects;
167  LastRecomputeTime = rhs.LastRecomputeTime;
168  LastNotifyTime = rhs.LastNotifyTime;
169  }
171  std::vector<std::string> PropertyErrors;
172  std::map<Core::DocObject*, std::vector<std::string>> LastErroneousObjects;
173  unsigned long LastRecomputeTime;
174  unsigned long LastNotifyTime;
176  void clear();
177 };
179 struct LX_CORE_EXPORT PropertyLinkDesc
180 {
181  PropertyLinkDesc(std::string sourceDocObjectID, std::string sourcePropertyName, Base::Type sourcePropertyTypeID, std::string targetDocObjectID,std::string propertyLinkName)
182  : m_SourceDocObjectID(sourceDocObjectID)
183  , m_SourcePropertyName(sourcePropertyName)
184  , m_SourcePropertyTypeID(sourcePropertyTypeID)
185  , m_TargetDocObjectID(targetDocObjectID)
186  , m_PropertyLinkName(propertyLinkName)
187  {
188  }
189 
190  // Copy constructor
192  {
193  m_SourceDocObjectID = rhs.m_SourceDocObjectID;
194  m_SourcePropertyName = rhs.m_SourcePropertyName;
195  m_SourcePropertyTypeID = rhs.m_SourcePropertyTypeID;
196  m_TargetDocObjectID = rhs.m_TargetDocObjectID;
197  m_PropertyLinkName = rhs.m_PropertyLinkName;
199  }
200 
201  std::string m_SourceDocObjectID;
202  std::string m_SourcePropertyName;
204 
205  std::string m_TargetDocObjectID;
206  std::string m_PropertyLinkName;
207 };
208 
209 
210 class LX_CORE_EXPORT CoreDocument : public Core::PropertyContainer, public Base::Subject<Core::DocChanges>
211 {
213  LX_NODE_HEADER();
214 
215 public:
216  friend class CoreApplication;
217  friend class CoreDocument_Factory;
218  friend class PropertyGUID;
220  friend class ::App::ElementTool;
221 
223  // //
224  // --------------------- BEGIN API --------------------- //
225  // //
226  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
227  // //
229 
230  enum Status
231  {
234  Closable = 2,
240  AllowPartialRecompute = 8, // allow recomputing editing object if SkipRecompute is set
241  TempDoc = 9, // Mark as temporary document without prompt for save
243  };
244 
251  Core::PropertyIndex application_mainversion; // This version major of the RESTORED document.
252  Core::PropertyIndex application_minorversion; // This version minor of the RESTORED document.
261  Core::PropertyText projectNumber; // related to PieceList
263 
265 
267  int getDocumentVersion() const;
269  bool addObject(Core::DocObject* e);
271  void removeObject(Core::DocObject* e);
273  void removeObjectFinal(Core::DocObject* e, bool deep = false);
274 
276  virtual void onFileOpened() {}
278  void onBeforeChangeProperty(const Core::DocObject* Who, const Property* What);
280  void onChangedProperty(const Core::DocObject* Who, const Property* What);
281 
282  virtual bool onChangedDebug(Core::DocObject* o, Core::Property* p);
283 
284 
287  Base::Type getCopyType() const;
289  void clearCopyType();
297  template <typename Type>
298  Type copyObjectShallow(Type o)
299  {
300  Core::DocObject* copy = o->shallowCopy(this);
301  assert(copy && "Document::copyObjectShallow could not copy object");
302  copy->setDocument(this);
303  copy->setNew();
304  copy->initDocObject();
305 
306  Type typedCopy = dynamic_cast<Type>(copy);
307  assert(typedCopy && "Document::copyObjectShallow could not cast object");
308 
309  return typedCopy;
310  }
311 
313  std::vector<Core::DocObject*> getObjects(bool includeDeletedObjects = false) const;
314  std::vector<const Core::DocObject*> getObjectsConst(bool includeDeletedObjects = false) const;
316  std::vector<Core::DocObject*> getObjectsSorted() const;
318  Core::DocObject* createObjectFromTypeName(const char* typeName);
322  std::vector<Core::DocObject*> getObjectsByTypeName(const std::string& typeName) const;
324  virtual void recompute();
327  virtual void recompute(
328  std::function<void(DOCOBJECTS newObj, DOCOBJECTS updatedObj, DOCOBJECTS deletedObj, DOCOBJECTS_ERROR_MAP errorObj)> onRecomputedCB);
330  virtual bool saveAs(const Base::String& filename);
334  bool isActive() const;
336  virtual bool isChanged();
339 
340  std::string getDocXMLAsString();
341 
343  bool testStatusBits(Status pos) const;
345  void setStatusBits(Status pos, bool on);
347 
367  void setUndoMode(int iMode);
370  int getUndoMode(void) const;
372  void setTransactionMode(int iMode);
381  int openTransaction(const char* name = 0);
383  void renameTransaction(const char* name, int id);
385  void commitTransaction();
387  void abortTransaction();
389  bool hasPendingTransaction() const;
391  int getTransactionID(bool undo, unsigned pos = 0) const;
394  bool isTransactionEmpty() const;
396  void setUndoLimit(unsigned int UndoMemSize = 0);
398  void setMaxUndoStackSize(unsigned int UndoMaxStackSize = 20);
400  unsigned int getMaxUndoStackSize(void)const;
402  void clearUndos();
404  int getAvailableUndos(int id = 0) const;
406  std::vector<std::string> getAvailableUndoNames() const;
408  bool undo(int id = 0);
410  int getAvailableRedos(int id = 0) const;
412  std::vector<std::string> getAvailableRedoNames() const;
414  bool redo(int id = 0);
416  bool isPerformingTransaction() const;
418 
420  virtual Core::DocObject* getObjectById(const DocObject::IdType& id) const;
423 
424 
425 
426 #ifndef SWIG
427  void emitAndNotify(Core::DocChanges& aDocChanges);
430  boost::signals2::signal<void(Core::DocChanges&)> signalDocChanges;
433  boost::signals2::signal<void(const Core::DocObject&)> signalNewObject;
435  boost::signals2::signal<void(const Core::DocObject&)> signalDeletedObject;
437  boost::signals2::signal<void(const Core::DocObject&, const Core::Property&)> signalBeforeChangeObject;
439  boost::signals2::signal<void(const Core::DocObject&, const Core::Property&)> signalChangedObject;
441  boost::signals2::signal<void()> signalBeforeRecompute;
443  boost::signals2::signal<void(const std::vector<Core::DocObject*>&, const std::vector<Core::DocObject*>&,const std::vector<Core::DocObject*>&)> signalRecomputed;
445  boost::signals2::signal<void()> signalRecomputeError;
447  boost::signals2::signal<void(const std::map<Core::DocObject*, std::vector<std::string>>&)> signalRecomputedErrorObjects;
449  boost::signals2::signal<void(const std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>&)> signalDefectLinks;
451  boost::signals2::signal<void()> signalNewFile;
453 #endif
454 
455 #ifndef LXAPI
456 
457 
458 
459 
460 
461 
463  // //
464  // ---------------------- END API ---------------------- //
465  // //
467 
470  template <typename T>
472  {
473  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
474  if (o)
475  return static_cast<T*>(o);
476 
477  return nullptr;
478  }
479 
482  template <typename T>
484  {
485  // Check if it really is immutable
486  if (T::isMutableStatic())
487  return nullptr;
488 
489  // Check if an immutable object with these values already exists
490  Core::DocObject* check = getImmutableObjectWithSameValues(T::getClassTypeId(), po);
491  if (check)
492  return static_cast<T*>(check);
493 
494  // If it doesn't exist make a new one and initialize it with the
495  // property values from the Core::PropertyBundle.
496  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
497  if (o)
498  {
499  o->_setPropertyValues(po, /* bool isInit = */ true);
500  o->setStatus(Core::PropertyContainer::Status::New); // At initialization the status needs to stay NEW
502  return static_cast<T*>(o);
503  }
504 
505  return nullptr;
506  }
507 
510  template <typename T>
512  {
513  // Check if it really is immutable
514  if (T::isMutableStatic())
515  return nullptr;
516 
517  // If it doesn't exist make a new one and initialize it with the
518  // property values from the Core::PropertyBundle.
519  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
520  if (o)
521  {
522  o->_setPropertyValues(po, /* bool isInit = */ true);
523  o->setStatus(Core::PropertyContainer::Status::New); // At initialization the status needs to stay NEW
525  return static_cast<T*>(o);
526  }
527 
528  return nullptr;
529  }
530 
532  template <typename T>
533  std::vector<T*> getObjectsByType() const
534  {
535  // get all resulting types including derived classes
536  Base::Type t = T::getClassTypeId();
537  std::set<Base::Type> typeset;
538  t.getAllChildren(typeset);
539  typeset.insert(t);
540 
541  std::vector<T*> returnObjs{};
542  for (const auto& type : typeset)
543  {
544  auto type2objects = getTypeMap().find(type);
545  if (type2objects == getTypeMap().end()) // do we know this type?
546  continue;
547 
548  const auto& docObjects = type2objects->second;
549  for (const auto& obj : docObjects) // get un-deleted objects of given type
550  {
551  if (!obj->isDeleted())
552  returnObjs.push_back(static_cast<T*>(obj));
553  }
554  }
555 
556  return returnObjs;
557  }
558 
560  template <typename T>
561  void getObjectsByType(std::vector<T*>& objs) const
562  {
563  const auto& objectMap = getObjectMap();
564  for (const auto& it : objectMap) //#todo go only over seconds
565  {
566  if (!it.second->isDeleted() && it.second->isDerivedFrom<T>()) // #todo why test for type when the type is in first?
567  objs.push_back((T*)it.second);
568  }
569  }
570 
572  void getObjectsFromTypeMap(Base::Type t, std::vector<Core::DocObject*>& ret) const;
573  const ObjectTypeMap& getTypeMap() const;
574 
575  void addPropertyLinkError(const std::string& from, const std::string& to);
576  const DocumentState& getDocumentState() const;
578  bool checkObjectLinks(const std::vector<const Core::DocObject*>& objvec,
579  std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>* errors = nullptr);
580  bool checkObjectLinks(const std::vector<const Core::DocObject*>& objvec,
581  const std::vector<const Core::DocObject*>& objToCheck,
582  std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>* errors = nullptr);
583  bool checkDeletedObjectLinks(const std::vector<const Core::DocObject*>& objToCheck,
584  std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>* errors);
585 
586 
588  std::vector<const Core::DocObject*> getInner(const Core::DocObject* me, std::function<bool(const Core::DocObject*)>* allowToAddObject = 0);
590  std::vector<const Core::DocObject*> getOuter(const Core::DocObject* me);
591 
592  std::vector<const Core::DocObject*> getLinksByProperties(const Core::DocObject* o) const;
593  std::vector<PropertyLinkDesc> getLinkDescByProperties(const Core::DocObject* o) const;
594  std::vector<const Core::DocObject*> getBackLinksByProperties(const Core::DocObject* source) const;
595 
596  void removeLinkInProperties(const Core::DocObject* source, Core::DocObject* link);
598 
600  std::string dumpGraph(void);
601  std::vector<std::string> check_graph();
603  std::vector<const Core::DocObject*> getLinksToMe(const Core::DocObject* o);
605  std::vector<const Core::DocObject*> getBackLinksToMe(const Core::DocObject* o);
607  std::vector<const Core::DocObject*> getLinksFromMe(const Core::DocObject* o);
609  std::vector<const Core::DocObject*> getBackLinksFromMe(const Core::DocObject* o);
610 
612  virtual bool maybeSave() { return true; }
614  std::vector<Core::DocObject*> getObjectsToSave();
615 
617  static void getDefaultVersionToSave(int& aMajorVersion, int& aMinorVersion);
619  static void getPreviousVersionToSave(int& aMajorVersion, int& aMinorVersion);
621  static QString getPreviousVersionToSaveStr();
622 
624  bool saveFile(bool toExport = false, bool saveBackupCopy = false);
627  bool toExport = false,
628  bool saveBackupCopy = false,
629  const Base::String& initialDir = Base::String());
630 
632  bool saveCopy(const Base::String& filename);
634  bool saveAsFileVersion(int aMajorVersion,
635  int aMinorVersion,
637  bool toExport = false,
638  bool saveBackupCopy = false,
639  const Base::String& initialDir = Base::String(),
640  bool dontRename = false);
642  void setOnSaveChangeToDefaultUser(bool onoff);
644  bool getOnSaveChangeToDefaultUser() const;
646  bool askAndSetNewFilename(QString& newFilename, const Base::String& initialDir = Base::String());
648  void setSaveBlocksUntilFinished(bool onoff);
650  bool getSaveBlocksUntilFinished() const;
651 
653  virtual void addInventorDirectory(const Base::String&) {}
656 
658  void setGuidPolicy(const Base::GlobalId_Policy& policy);
660  void setGuidPolicy(const Base::String& suffix, const Base::GlobalId_Policy& policy);
664  bool getGuidPolicy(const Base::String& suffix, Base::GlobalId_Policy& policy) const;
665 
666  void addReferenceFrom(Core::DocObject* from);
668  bool hasReferencesFrom(Core::DocObject* from) const;
669  const std::set<Core::DocObject*>& getReferences() const;
671  void setFullFileName(const Base::String& fullfilename);
672 
673  virtual const char* subject_name(void) { return "CoreDocument"; };
674 
675  virtual bool restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
676 
677  bool addFileToZip(const Base::String& entryName, const Base::String& path);
678  bool restoreFileFromZip(const Base::String& entryName, const Base::String& targetpath, bool binaryMode);
679 
681  void forceBackupOnNextSave();
682 
687 
689  size_t getRecomputeCount() const;
690 
691  virtual void setChanged(bool changed);
692 
693  bool getImmutableObjects(Base::Type t, ObjectSet& set) const;
695 
696  void setImportedIFCFile(QString a);
697  QString getImportedIFCFile();
698 
699  static std::pair<int,int> getAppVersionFromDocument( Base::String filename);
700 
701  void test_graph();
702  void onAddLink( PropertyLinkBaseBase*p, Core::DocObject* from ,Core::DocObject* o );
703  void onRemoveLink( PropertyLinkBaseBase*p, Core::DocObject* from ,Core::DocObject* o );
704  void onAddLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList );
705  void onRemoveLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList);
706  void onAddLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
707  void onRemoveLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
708 
709  void onAddBackLink( PropertyLinkBaseBase*p, Core::DocObject* from ,Core::DocObject* o );
710  void onRemoveBackLink( PropertyLinkBaseBase*p, Core::DocObject* from ,Core::DocObject* o );
711  void onAddBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList );
712  void onRemoveBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList);
713  void onAddBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
714  void onRemoveBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
716  void breakLinks( Core::DocObject* from );
717  std::vector<std::pair<Core::PropertyLinkBaseBase*,Core::DocObject*>> getInLinks(Core::DocObject* docObj);
718  std::vector<std::pair<Core::PropertyLinkBaseBase*,Core::DocObject*>> getInBackLinks(Core::DocObject* docObj);
719  std::vector<std::pair<Core::PropertyLinkBaseBase*,Core::DocObject*>> getOutLinks(Core::DocObject* docObj);
720  std::vector<std::pair<Core::PropertyLinkBaseBase*,Core::DocObject*>> getOutBackLinks(Core::DocObject* docObj);
721 
722 #endif
723 
724 protected:
725  CoreDocument();
726  // Copy constructor
727  CoreDocument(const CoreDocument& rhs);
728  virtual ~CoreDocument();
729 
731  virtual void deleteObject(Core::DocObject* o);
732 
735 
741  virtual Core::DocObject* restoreObject(const std::string& typeName, const std::string& typeHierarchy, const std::string& id);
742  void restoreProperty(Core::Property* property,
743  const Base::String& name,
744  Base::AbstractXMLReader& reader,
747  virtual void saveDocument(std::shared_ptr<Base::AbstractWriter> writer, int versionMajor2save, int versionMinor2save, bool showProgress);
749  virtual int restoreDocument(Base::XMLReader& reader, Core::Attachments& attachments);
751  virtual std::vector<Core::DocObject*> build_savemap(std::vector<std::string>& delete_log);
753  void addNewObjectsToGraph();
754  bool checkDeletedObjectLinks(const std::vector<const Core::DocObject*>& objvec,
755  const std::vector<const Core::DocObject*>& objToCheck,
756  std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>* errors);
761  virtual bool renameTypeFromOlderVersions(int, Base::String&) { return false; }
763  virtual void checkBeforeObjectRestoring(int, int) {}
770  virtual bool convertFromOlderVersions(int docVersion, int appVersion);
771 
772  virtual bool getPatchedUserTypes(const Base::String& filename, std::map<QString, QString>& id2TypeMap);
773 
775  virtual void cleanUndoStack() {}
777  virtual void storeDirectory(const QString&, Base::AbstractWriter&) {}
779  virtual void restoreDirectory(const QString&) {}
780 
782  virtual void initDocument(bool) {}
784  const ObjectMap& getObjectMap() const;
786  void createTempDirectory();
788  void cleanTempDirectory();
790  bool maybe_add_GUID(const Base::GlobalId& guid, Core::DocObject* o);
792  void add_GUID(const Base::GlobalId& guid, Core::DocObject* o);
794  void remove_GUID(const Base::GlobalId& guid, Core::DocObject* o);
796  void waitForSaveIsFinished();
797 
799  bool isCatalogFile() const;
800 
801  bool createBackupFile(const Base::String& path, bool savePath);
802  bool createBackupFileAfterOpeningDoc(const Base::String& path, bool savePath);
803 
804  // Internal, do not use
805  void __setEnableTimeStamps__(bool aOnOff);
806  bool __getEnableTimeStamps__() const;
807 
809  void _checkTransaction(Core::DocObject* pcDelObj, const Property* What, int line);
820  int _openTransaction(const char* name = 0, int id = 0);
822  void _commitTransaction(bool notify = false);
824  void _abortTransaction();
825  void _clearRedos();
826 
827 
828 
830  // Map of all objects
832  // For performance reasons we have a vector of all objects
834  // Map of immutable objects < Type, set of immutable objects >
836  // The object graph
838  // Set of objects per type
840 
843 
844  std::set<Core::DocObject*> _references;
845  std::map<Base::GlobalId, Core::DocObject*> _guid_map;
846  std::map<long, Core::DocObject*> _ifcId_map;
847 
850  size_t _recomputeCnt = 0;
851  bool mSolvingEnabled = true;
854 private:
856  bool openFile(const Base::String& filename, bool savePath = true);
857 
859  Core::DocObject* clone_and_replace_Object(const char* typeName, Core::DocObject* base);
861  bool close(bool dontNotify = false);
862  void onNewObjectTransaction(Core::DocObject* aDocObject);
863  void _cleanTempDirectory_Helper(const Base::String& dir);
864  void _copyFilesInTemp(Core::DocObject* original, Core::DocObject* copy);
865  bool _saveFile(Base::String saveFileName, int versionMajor2save, int versionMinor2save, bool toExport, bool saveBackupCopy, bool notify = true);
866  void _initNewObject(Core::DocObject* o, const DocObject::IdType& id = "");
867  void _saveDocFiles(std::shared_ptr<Base::AbstractWriter> writer, bool notify = true);
868  bool _docWrite(std::shared_ptr<Base::AbstractWriter> mainwriter,
869  QString tmpfile,
870  QString fileName,
871  bool inThread,
872  bool toExport,
873  bool saveBackupCopy,
874  std::vector<Base::String> tempFilesToDelete);
875  void cleanOldTempDirectories();
876  void dispatchMsg(const int aMsgId);
877  // never make it public, copyShare param must be controlled ONLY from CoreDocument
878  Core::DocObject* copyObjectInternal(Core::DocObject* o, DocObjectMap& copyMap, bool standardCopyOfShared = false, bool aCreateNewType = false);
879 
881  void notifyDocChange(DocChanges::why aWhy, DocMessage aMsgId, const Base::String& aValue);
882 
884  bool restoreDocuments(int& docVersion, int& appVersion);
885 
886  Base::Type m_copyType = Base::Type::badType();
887  QString m_importedIFCFile;
888  QDateTime _lastBackupFileTime;
889  int _backupFilesCounter = 0;
890  int _numOfExistBackupFiles = 0;
891  bool _onSaveChangeToDefaultUser = false;
892  bool _saveBlocksUntilFinished = false;
893  Base::String _tmpdirectory;
894 
895  // Map for <file suffix / GUID policy>
896  std::map<Base::String, Base::GlobalId_Policy> _guidPolicyMap;
897  std::map<Base::String, Base::String> _additionalFiles;
898 
899  std::list<Transaction*> mUndoTransactions;
900  std::map<int, Transaction*> mUndoMap;
901  std::list<Transaction*> mRedoTransactions;
902  std::map<int, Transaction*> mRedoMap;
903 
904  CoreDocumentImpl* _pimpl{};
905 };
906 
907 /* @brief This class takes care that time stamping can be securely
908  * deactivated as long as an instance of this class stays in scope.
909  * It restores the old state when the destructor is called.
910  */
911 class LX_CORE_EXPORT DocumentTimeStampSentinel
912 {
913 public:
914  DocumentTimeStampSentinel() = delete;
916  {
917  mOldEnableTimeStamps = mDoc->__getEnableTimeStamps__();
918  mDoc->__setEnableTimeStamps__(false);
919  }
920 
922  {
923  mDoc->__setEnableTimeStamps__(mOldEnableTimeStamps);
924  }
926  bool mOldEnableTimeStamps = true;
927 };
928 
929 
930 class LX_CORE_EXPORT DocumentFactory
931 {
932 public:
933  friend class CoreApplication;
936 
937  static std::map<std::string, Core::DocumentFactory*> registry;
938 
939 protected:
940  virtual Core::CoreDocument* createByFactory() = 0;
941  static Core::CoreDocument* create(const std::string& type);
942 };
943 
944 
945 class CoreDocument_Factory : public Core::DocumentFactory
946 {
947  virtual Core::CoreDocument* createByFactory()
948  {
950  return doc;
951  }
952 };
953 
954 } // namespace Core
955 
956 
957 
958 #define DECLARE_DOCUMENT_FACTORY(_factoryName_, _class_) \
959  class _factoryName_ : public Core::DocumentFactory \
960  { \
961  private: \
962  virtual Core::CoreDocument* createByFactory() \
963  { \
964  Core::CoreDocument* doc = new _class_; \
965  return doc; \
966  } \
967  };
968 
969 #define REGISTER_DOCUMENT_FACTORY(_factoryName_, _class_) Core::DocumentFactory::registry[#_class_] = (Core::DocumentFactory*)new _factoryName_();
std::vector< std::pair< Core::PropertyLinkBaseBase *, Core::DocObject * > > getInBackLinks(Core::DocObject *docObj)
void breakLinks(Core::DocObject *from)
RelGraph * _relGraph
Definition: CoreDocument.h:841
std::unordered_set< Core::DocObject * > ObjectSet
Definition: core_gt.h:58
Definition: CoreApplication.h:94
bool mSolvingEnabled
Definition: CoreDocument.h:851
std::string getDocXMLAsString()
Core::PropertyText createdBy
Definition: CoreDocument.h:255
void removeObject(Core::DocObject *e)
Removes an object from the document.
std::vector< const Core::DocObject * > getBackLinksByProperties(const Core::DocObject *source) const
CoreDocument()
virtual void checkBeforeObjectRestoring(int, int)
Is called before restoring objects of a document.
Definition: CoreDocument.h:763
Core::DocObject * copyToDifferentType(Core::DocObject *o, Base::Type typeToCreate, DocObjectMap &copyMap)
Creates an object of type 'typeToCreate' and copy properties from 'o' to it. Provides map of pairs or...
DocumentState _state
Definition: CoreDocument.h:829
boost::signals2::signal< void(const Core::DocObject &)> signalDeletedObject
signal on deleted Object
Definition: CoreDocument.h:435
Core::PropertyText projectNumber
Definition: CoreDocument.h:261
void onAddLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
std::map< Core::DocObject *, std::vector< std::string > > DOCOBJECTS_ERROR_MAP
Definition: CoreDocument.h:34
boost::signals2::signal< void(const Core::DocObject &, const Core::Property &)> signalChangedObject
signal on changed Object
Definition: CoreDocument.h:439
std::map< Base::GlobalId, Core::DocObject * > _guid_map
Definition: CoreDocument.h:845
bool restoreFileFromZip(const Base::String &entryName, const Base::String &targetpath, bool binaryMode)
Core::PropertyText compatibleInfo
Definition: CoreDocument.h:169
std::vector< Core::DocObject * > ObjectVector
Definition: core_gt.h:56
std::vector< const Core::DocObject * > getLinksByProperties(const Core::DocObject *o) const
std::map< long, Core::DocObject * > _ifcId_map
Definition: CoreDocument.h:846
void commitTransaction()
Commit the Command transaction. Do nothing If there is no Command transaction open.
bool checkObjectLinks(const std::vector< const Core::DocObject * > &objvec, std::vector< std::pair< const Core::DocObject *, const Core::DocObject * >> *errors=nullptr)
Checks the document for errors. Returns false if there is an error.
virtual std::vector< Core::DocObject * > build_savemap(std::vector< std::string > &delete_log)
Build a map of the objects that get saved. Objects that are marked for delete get removed.
Definition: Persistence.h:14
Core::DocObject::IdType getUniqueObjectIdFromInteger(size_t input) const
virtual void initDocument(bool)
Initialize document.. Can be overwritten to do some custom initialization.
Definition: CoreDocument.h:782
boost::signals2::signal< void()> signalBeforeRecompute
Signals before recompute.
Definition: CoreDocument.h:441
Definition: CoreDocument.h:156
T * addImmutableObject(Core::PropertyBundle< T > *po)
Definition: CoreDocument.h:483
std::vector< std::pair< Core::PropertyLinkBaseBase *, Core::DocObject * > > getInLinks(Core::DocObject *docObj)
FileOpened
Definition: CoreDocument.h:140
void forceBackupOnNextSave()
Modifies the _lastBackupFileTime to force backup when the document is saved next time.
Closing
Definition: CoreDocument.h:152
Definition: CoreDocument.h:161
Definition: CoreDocument.h:162
std::unordered_set< Core::ExecObject * > ExecObjectSet
Definition: CoreDocument.h:63
boost::signals2::signal< void(const std::vector< Core::DocObject * > &, const std::vector< Core::DocObject * > &, const std::vector< Core::DocObject * > &)> signalRecomputed
Signals NewObjects, UpdatedObjects, DeletedObjects being recomputed.
Definition: CoreDocument.h:443
virtual int restoreDocument(Base::XMLReader &reader, Core::Attachments &attachments)
Restores the document. Returns the doc version of the restored document.
std::vector< Core::DocObject * > getObjectsSorted() const
Returns all objects topologically sorted.
Definition: CoreDocument.h:163
size_t getRecomputeCount() const
get count of recomputes()
T * addImmutableObject_NoCheck(Core::PropertyBundle< T > *po)
Definition: CoreDocument.h:511
void onAddBackLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
std::string dumpGraph(void)
Returns a string representation of the graph.
AfterSave
Definition: CoreDocument.h:142
AddDirectoryPath
Definition: CoreDocument.h:144
Core::PropertyText name
Definition: CoreDocument.h:245
bool _needRestoreBeforeRecompute
Definition: CoreDocument.h:849
std::unordered_map< DocObject::IdType, Core::ExecObject * > ExecObjectMap
Definition: CoreDocument.h:64
Definition: PropertyContainer.h:107
void onRemoveBackLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
Core::DocObject * copyObject(Core::DocObject *o, DocObjectMap &copyMap=DocObjectMap())
Creates a copy of 'o' and adds it to the document, provides map of pairs original-copy to see which o...
std::multimap< Base::String, Core::AttachmentEntry > Attachments
Definition: CoreDocument.h:73
Core::PropertyIndex application_mainversion
Definition: CoreDocument.h:251
std::vector< Core::DocObject * > NewObjects
Definition: CoreDocument.h:123
void _commitTransaction(bool notify=false)
Internally called by App::Application to commit the Command transaction.
void clearCopyType()
Sets the copy type to Base::Type::badType(), next copied object will be copied as its own type.
void removeBackLinkInProperties(const Core::DocObject *source, Core::DocObject *link)
Definition: PropertyBundle.h:16
virtual bool convertFromOlderVersions(int docVersion, int appVersion)
Core::PropertyText documentTypeName
Definition: CoreDocument.h:253
GUID_Conflict
Definition: CoreDocument.h:148
virtual Core::DocObject * restoreObject(const std::string &typeName, const std::string &typeHierarchy, const std::string &id)
Tries to restore an object from a given type name.
Definition: CoreDocument.h:164
bool askAndSetNewFilename(QString &newFilename, const Base::String &initialDir=Base::String())
Ask user for filename (if not already passed in as newFilename) and set it to document....
Definition: CoreDocument.h:160
Core::PropertyText name
Definition: CoreDocument.h:167
virtual void addInventorDirectory(const Base::String &)
Inventor search directories - needs to be stored for IV/Z export, but SoInput is not OK....
Definition: CoreDocument.h:653
void onAddBackLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
std::vector< const Core::DocObject * > getInner(const Core::DocObject *me, std::function< bool(const Core::DocObject *)> *allowToAddObject=0)
Get ALL Links to me, also indirect.
void clearUndos()
Remove all stored Undos and Redos.
std::vector< std::string > getAvailableUndoNames() const
Returns a list of the Undo names.
PriceCalculationChanged
Definition: CoreDocument.h:153
Core::CoreDocument * Document
Definition: CoreDocument.h:121
DocumentFactory()
Definition: CoreDocument.h:934
The PropertyGUID class saves and restores GUIDs. It also handles the management of GUIDs in the Docum...
Definition: PropertyGUID.h:24
Definition: CoreDocument.h:154
const ObjectTypeMap & getTypeMap() const
Definition: CoreDocument.h:159
Base::String FileName
Definition: CoreDocument.h:69
int openTransaction(const char *name=0)
void renameTransaction(const char *name, int id)
Rename the current transaction if the id matches.
DocumentTimeStampSentinel(Core::CoreDocument *aDoc)
Definition: CoreDocument.h:915
void onChangedProperty(const Core::DocObject *Who, const Property *What)
callback from the Document objects after property was changed
Definition: PropertyText.h:11
bool __getEnableTimeStamps__() const
void resetHasErrorObjectsInRecompute()
reset result of last recompute();
virtual void setChanged(bool changed)
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
void waitForSaveIsFinished()
Saving runs in Threads, wait for finish.
virtual void deleteObject(Core::DocObject *o)
Physically deletes an object without informing the object maps.
boost::signals2::signal< void(const std::map< Core::DocObject *, std::vector< std::string >> &)> signalRecomputedErrorObjects
Signals recomputed error DocObjects.
Definition: CoreDocument.h:447
Definition: CoreDocument.h:159
virtual bool saveAs(const Base::String &filename)
Saves the document under this name.
void restoreProperty(Core::Property *property, const Base::String &name, Base::AbstractXMLReader &reader, Base::PersistenceVersion &version) override
LX_CORE_EXPORT Version & version
virtual Core::DocObject * addImmutableObjectMaterial(Core::PropertyContainer *pc)
why
Definition: CoreDocument.h:111
Definition: Type.h:52
boost::signals2::signal< void(const std::vector< std::pair< const Core::DocObject *, const Core::DocObject * >> &)> signalDefectLinks
Signals defect links from object1 to object2.
Definition: CoreDocument.h:449
void setImportedIFCFile(QString a)
void getObjectsFromTypeMap(Base::Type t, std::vector< Core::DocObject * > &ret) const
Returns all objects of type 'T'.
Definition: CoreDocument.h:210
bool saveAsFile(const Base::String &filename=Base::String(), bool toExport=false, bool saveBackupCopy=false, const Base::String &initialDir=Base::String())
Saves a new file under this name.
std::vector< Core::DocObject * > UpdatedObjects
Definition: CoreDocument.h:124
Definition: Variant.h:87
void cleanTempDirectory()
Cleans the temporary directory.
std::vector< Core::DocObject * > DOCOBJECTS
Definition: CoreDocument.h:33
RecomputeFinished
Definition: CoreDocument.h:145
Core::DocObject * getObjectByUserName(const Base::String &s) const
Returns the object with this userName.
void getAllChildren(std::set< Type > &children) const
bool addObject(Core::DocObject *e)
Adds an existing object to the document.
void setNew()
Sets the status to 'New'.
virtual bool getPatchedUserTypes(const Base::String &filename, std::map< QString, QString > &id2TypeMap)
void setSaveBlocksUntilFinished(bool onoff)
If true, saving will block until the whole save is finished and file is ready.
void setUndoLimit(unsigned int UndoMemSize=0)
Set the Undo limit in Byte!
Core::PropertyText documentVersion
Definition: CoreDocument.h:246
bool getImmutableObjects(Base::Type t, ObjectSet &set) const
virtual void createGroundPlate_deprecated()
To overwrite. Deprecated, do not use.
Definition: CoreDocument.h:655
virtual ~CoreDocument()
const ObjectMap & getObjectMap() const
Returns the object map.
virtual void restoreDirectory(const QString &)
Restores directory to temp.
Definition: CoreDocument.h:779
void setTransactionMode(int iMode)
switch the transaction mode
void onRemoveBackLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
boost::signals2::signal< void(Core::DocChanges &)> signalDocChanges
Signals DocChanges (To be removed)
Definition: CoreDocument.h:431
ObjectTypeMap _immutableObjectsMap
Definition: CoreDocument.h:835
std::vector< std::pair< Core::PropertyLinkBaseBase *, Core::DocObject * > > getOutBackLinks(Core::DocObject *docObj)
Core::CoreDocument * mDoc
Definition: CoreDocument.h:925
std::vector< std::string > check_graph()
Core::PropertyIndex documentMaxID
Definition: CoreDocument.h:250
const DocumentState & getDocumentState() const
Core::PropertyText filename
Definition: CoreDocument.h:254
std::vector< PropertyLinkDesc > getLinkDescByProperties(const Core::DocObject *o) const
~DocumentTimeStampSentinel()
Definition: CoreDocument.h:921
Definition: AbstractXMLReader.h:7
ObjectMap _all_objects_map
Definition: CoreDocument.h:831
virtual void onFileOpened()
Is called when the file was opened, but before the message FileOpened gets emitted....
Definition: CoreDocument.h:276
virtual void cleanUndoStack()
Cleans the undo stack. Must be overwritten.
Definition: CoreDocument.h:775
Core::DocObject * getImmutableObjectWithSameValues(Base::Type t, Core::PropertyContainer *pc) const
Returns the object that has the same values as 'pc'. Returns '0' if there is no such object.
std::vector< Core::DocObject * > getObjectsByTypeName(const std::string &typeName) const
Returns all objects of typeName.
void remove_GUID(const Base::GlobalId &guid, Core::DocObject *o)
Removes a guid without checking.
Core::PropertyIndex documentChanges
Definition: CoreDocument.h:249
Core::PropertyText company
Definition: CoreDocument.h:259
Status
Definition: CoreDocument.h:230
Definition: GlobalId.h:29
void setMaxUndoStackSize(unsigned int UndoMaxStackSize=20)
Set the Undo limit as stack size.
ErrorCanNotOpenFile
Definition: CoreDocument.h:146
DocChanges(Core::CoreDocument *doc)
Definition: CoreDocument.h:109
virtual bool maybeSave()
Can be overwritten to check if the undo stack is clean etc.
Definition: CoreDocument.h:612
Core::Variant Value
Definition: CoreDocument.h:120
std::vector< const Core::DocObject * > getBackLinksFromMe(const Core::DocObject *o)
Returns all objects 'o' directly linked from 'o'.
bool isPerformingTransaction() const
returns true if the document is in an Transaction phase, e.g. currently performing a redo/undo or rol...
std::map< Base::Type, ObjectSet > ObjectTypeMap
Definition: CoreDocument.h:65
QString getImportedIFCFile()
Core::PropertyText architect
Definition: CoreDocument.h:262
virtual Core::DocObject * getObjectById(const DocObject::IdType &id) const
Returns the object with this id.
Definition: Observer.h:16
Definition: CoreDocument.h:106
SaveStart
Definition: CoreDocument.h:151
Core::PropertyText filename
Definition: CoreDocument.h:176
Definition: Base.h:12
BeforeSave
Definition: CoreDocument.h:141
virtual void checkAndConfigureOpenedDocumentAfterRecompute(int, int)
Is called when opening a document after recompute. Can be overwritten to do some custom check routine...
Definition: CoreDocument.h:767
void onRemoveLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
bool saveAsFileVersion(int aMajorVersion, int aMinorVersion, const Base::String &filename=Base::String(), bool toExport=false, bool saveBackupCopy=false, const Base::String &initialDir=Base::String(), bool dontRename=false)
Saves a new file under this name.
bool hasErrorObjectsInRecompute()
get result of last recompute
std::vector< Core::DocObject * > DeletedObjects
Definition: CoreDocument.h:125
Base::String Info
Definition: CoreDocument.h:71
bool getSaveBlocksUntilFinished() const
Returns whether saving will block until the whole save is finished and file is ready.
virtual void storeDirectory(const QString &, Base::AbstractWriter &)
Stores directory at given path to zip stream.
Definition: CoreDocument.h:777
T * createObject()
Definition: CoreDocument.h:471
boost::signals2::signal< void()> signalNewFile
Signals new file.
Definition: CoreDocument.h:451
bool testStatusBits(Status pos) const
return the status bits
Definition: CoreDocument.h:911
void emitAndNotify(Core::DocChanges &aDocChanges)
Definition: GlobalId_Policy.h:7
std::vector< Core::DocObject * > getObjectsToSave()
Returns all objects that will be saved in document. Basically interface for build_savemap().
size_t _recomputeCnt
Definition: CoreDocument.h:850
bool maybe_add_GUID(const Base::GlobalId &guid, Core::DocObject *o)
Adds a guid to the map IF this id is not in use yet.
void addPropertyLinkError(const std::string &from, const std::string &to)
std::vector< const Core::DocObject * > getBackLinksToMe(const Core::DocObject *o)
Returns all objects that directly linked to 'o'.
std::set< Core::DocObject * > _references
Definition: CoreDocument.h:844
unsigned int getMaxUndoStackSize(void) const
Set the Undo limit as stack size.
bool createBackupFile(const Base::String &path, bool savePath)
Definition: CoreDocument.h:945
RelGraph * _relGraphBackLink
Definition: CoreDocument.h:842
void createTempDirectory()
Creates the temporary directory.
const int LEXOCAD_CORE_MSGID
Definition: CoreDocument.h:133
int getUndoMode(void) const
switch the level of Undo/Redo
Base::String getTmpDirectory()
Returns the temporary directory.
virtual DocObject * shallowCopy(Core::CoreDocument *toDoc)
std::vector< const Core::DocObject * > getOuter(const Core::DocObject *me)
Get ALL Links from me, also indirect.
bool isTransactionEmpty() const
Definition: CoreDocument.h:158
Definition: GlobalAttachment.h:10
friend class DocumentTimeStampSentinel
Definition: CoreDocument.h:141
int getTransactionID(bool undo, unsigned pos=0) const
Return the undo/redo transaction ID starting from the back.
void removeObjectFinal(Core::DocObject *e, bool deep=false)
Removes an object from the document.
bool addFileToZip(const Base::String &entryName, const Base::String &path)
Import
Definition: CoreDocument.h:150
void add_GUID(const Base::GlobalId &guid, Core::DocObject *o)
Adds a guid without checking.
int getDocumentVersion() const
Returns the version of the document.
Definition: Writer.h:16
~DocumentFactory()
Definition: CoreDocument.h:935
virtual bool renameTypeFromOlderVersions(int, Base::String &)
Definition: CoreDocument.h:761
Definition: CoreDocument.h:157
void test_graph()
virtual void setStatus(Status status)
Core::CoreDocument Core::PropertyContainer, Base::Subject recompute(std::function< void(DOCOBJECTS newObj, DOCOBJECTS updatedObj, DOCOBJECTS deletedObj, DOCOBJECTS_ERROR_MAP errorObj)> onRecomputedCB)
std::string IdType
Definition: DocObject.h:69
Definition: CoreDocument.h:155
void addReferenceFrom(Core::DocObject *from)
virtual bool isChanged()
Returns 'true' if the document is changed.
std::vector< T * > getObjectsByType() const
Return all object of given type and all derived classes.
Definition: CoreDocument.h:533
std::map< Core::DocObject *, std::vector< std::string > > ErroneousObjects
Definition: CoreDocument.h:126
bool undo(int id=0)
Will UNDO one step, returns False if no undo was done (Undos == 0).
const std::set< Core::DocObject * > & getReferences() const
boost::signals2::signal< void()> signalRecomputeError
Signals a recompute error.
Definition: CoreDocument.h:445
std::vector< std::pair< Core::PropertyLinkBaseBase *, Core::DocObject * > > getOutLinks(Core::DocObject *docObj)
Core::DocObject * createObjectFromType(Base::Type type)
Creates an object from type and adds it to the document.
int _openTransaction(const char *name=0, int id=0)
bool isCatalogFile() const
Returns true if this document's file is part of catalog.
Core::PropertyText documentGUID
Definition: CoreDocument.h:248
std::vector< const Core::DocObject * > getObjectsConst(bool includeDeletedObjects=false) const
Definition: CoreDocument.h:67
void onAddLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
Export
Definition: CoreDocument.h:149
void _clearRedos()
Core::PropertyText comment
Definition: CoreDocument.h:260
void abortTransaction()
Abort the actually running transaction.
void _abortTransaction()
Internally called by App::Application to abort the running transaction.
Core::DocObject * copySharedObject(Core::DocObject *o, DocObjectMap &copyMap)
Copy shared object. This is violating of the share, but in some cases this is useful....
bool hasReferencesFrom(Core::DocObject *from) const
ObjectVector _all_objects_vector
Definition: CoreDocument.h:833
Type copyObjectShallow(Type o)
Creates a copy of 'o' and adds it to the document. Performs shallow copy.
Definition: CoreDocument.h:298
bool _hasErrorObjectsInRecompute
Definition: CoreDocument.h:848
void onBeforeChangeProperty(const Core::DocObject *Who, const Property *What)
callback from the Document objects before property will be changed
NewFile
Definition: CoreDocument.h:139
Definition: CoreDocument.h:114
Base::String fileName
Definition: CoreDocument.h:264
Core::DocObject::IdType getUniqueObjectId() const
Returns the next available unique id.
std::unordered_map< DocObject::IdType, Core::DocObject * > ObjectMap
Definition: CoreDocument.h:61
void setGuidPolicy(const Base::GlobalId_Policy &policy)
Sets the default GUID policy. This determines what should be done if identical GUIDs are imported.
bool isActive() const
Returns 'true' if the Document is the active Document. Otherwise returns 'false'.
Definition: GraphBuilder.h:138
Core::DocObject * createObjectFromTypeName(const char *typeName)
Creates an object from type name and adds it to the document.
void addNewObjectsToGraph()
Adds objects with status 'New' to the graph.
LX_NODE_HEADER()
Definition: Reader.h:62
static const Type badType(void)
Definition: Type.h:99
Core::PropertyIndex application_minorversion
Definition: CoreDocument.h:252
bool saveFile(bool toExport=false, bool saveBackupCopy=false)
Saves the file.
void _checkTransaction(Core::DocObject *pcDelObj, const Property *What, int line)
checks if a valid transaction is open
void addToDocumentMaps(Core::DocObject *o)
Adds the object to all relevant maps.
Definition: Property.h:77
virtual void initDocObject()
std::vector< std::string > getAvailableRedoNames() const
Returns a list of the Redo names.
Base::String FeatName
Definition: CoreDocument.h:70
bool redo(int id=0)
Will REDO one step, returns False if no redo was done (Redos == 0).
virtual const char * subject_name(void)
Definition: CoreDocument.h:673
void __setEnableTimeStamps__(bool aOnOff)
std::vector< const Core::DocObject * > getLinksFromMe(const Core::DocObject *o)
Returns all objects 'o' directly linked from 'o'.
bool getOnSaveChangeToDefaultUser() const
Return whether the user get changed to default user on next save.
bool createBackupFileAfterOpeningDoc(const Base::String &path, bool savePath)
void onRemoveLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
void setStatusBits(Status pos, bool on)
set the status bits
ObjectGraph * _graph
Definition: CoreDocument.h:837
boost::signals2::signal< void(const Core::DocObject &)> signalNewObject
signal on new Object
Definition: CoreDocument.h:433
std::vector< Core::DocObject * > getObjects(bool includeDeletedObjects=false) const
Returns all objects in the document.
void setUndoMode(int iMode)
switch the level of Undo/Redo
void setDocument(Core::CoreDocument *doc)
Sets the CoreDocument of this DocObject.
CleanAll
Definition: CoreDocument.h:143
Base::GlobalId_Policy getGuidPolicy() const
Returns the default GUID policy.
friend class CoreApplication
Definition: CoreDocument.h:138
Definition: PropertyInteger.h:150
static std::map< std::string, Core::DocumentFactory * > registry
Definition: CoreDocument.h:937
std::vector< const Core::DocObject * > getLinksToMe(const Core::DocObject *o)
Returns all objects that directly linked to 'o'.
RecomputeError
Definition: CoreDocument.h:137
Base::String fileName
Definition: CoreDocument.h:186
Base::Type getCopyType() const
Definition: CoreDocument.h:113
Rename
Definition: CoreDocument.h:138
bool saveCopy(const Base::String &filename)
Saves a copy of the current document, no notify, only store the doc under this name.
virtual bool onChangedDebug(Core::DocObject *o, Core::Property *p)
void setFullFileName(const Base::String &fullfilename)
Sets the full file name including the path.
std::map< Core::DocObject *, Core::DocObject * > DocObjectMap
Definition: DocObject.h:10
Core::DocObject * getObjectByGlobalId(const Base::GlobalId &guid) const
Returns the DocObject with this GUID.
bool checkDeletedObjectLinks(const std::vector< const Core::DocObject * > &objToCheck, std::vector< std::pair< const Core::DocObject *, const Core::DocObject * >> *errors)
virtual void checkAndConfigureOpenedDocument()
Is called when opening a document. Can be overwritten to do some custom check routines.
Definition: CoreDocument.h:765
int getAvailableUndos(int id=0) const
Returns the number of stored Undos. If greater than 0 Undo will be effective.
Definition: CoreDocument.h:930
TYPESYSTEM_HEADER()
Definition: GraphBuilder.h:52
void removeReferenceFrom(Core::DocObject *from)
Status
Definition: CoreDocument.h:152
void resolveLinkInDocument(Core::PropertyLinkBase *link)
After opening a document this method restores the links declared in the document header.
Core::PropertyText lastModifiedDate
Definition: CoreDocument.h:258
auto onRecomputedCB
Definition: CoreDocument.h:247
std::vector< Core::ExecObject * > ExecObjectVector
Definition: CoreDocument.h:62
boost::signals2::signal< void(const Core::DocObject &, const Core::Property &)> signalBeforeChangeObject
signal before changing an Object
Definition: CoreDocument.h:437
virtual bool restoreGlobalAttachment(Base::GlobalAttachment *gAtta, std::istream *, uint64_t streamsize, const Base::String &entryName)
Core::PropertyText lastModifiedBy
Definition: CoreDocument.h:257
Definition: DocObject.h:51
void setOnSaveChangeToDefaultUser(bool onoff)
If true: Change to default user on next change. Usually from IFC User to Lexocad User.
Core::PropertyText creationDate
Definition: CoreDocument.h:256
friend class PropertyGUID
Definition: CoreDocument.h:140
ChangeToDefaultUser
Definition: CoreDocument.h:147
int getAvailableRedos(int id=0) const
Returns the number of stored Redos. If greater than 0 Redo will be effective.
ObjectTypeMap _typeObjects
Definition: CoreDocument.h:839
bool hasPendingTransaction() const
Check if a transaction is open.
virtual void saveDocument(std::shared_ptr< Base::AbstractWriter > writer, int versionMajor2save, int versionMinor2save, bool showProgress)
Saves the document.
void removeLinkInProperties(const Core::DocObject *source, Core::DocObject *link)