OpenLexocad  28.0
CoreDocument.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Base/Observer.h>
4 #include <Core/DocObject.h>
5 #include <Core/PropertyBundle.h>
6 #include <Core/PropertyInteger.h> // Core::PropertyIndex
7 #include <Core/PropertyText.h>
8 
9 #include <QDateTime>
10 
11 #ifndef SWIG
12 #include <boost/signals2/signal.hpp> // for signal
13 #endif
14 
15 #define DIR_NAME_INTERNAL_CATALOG "__internalCatalog__"
16 #define DIR_NAME_WEBGL_GT "webgl"
17 #define DIR_NAME_GEOID "geoid"
18 #define DIR_NAME_BCF "Bcf"
19 #define FILE_NAME_CAMERA_ANIMATION "CameraAnimation.ivc"
20 
21 typedef std::vector<Core::DocObject*> DOCOBJECTS;
22 typedef std::map<Core::DocObject*, std::vector<std::string>> DOCOBJECTS_ERROR_MAP;
23 
24 namespace Base
25 {
26 class XMLReader;
27 class GlobalAttachment;
28 }
29 
30 namespace App
31 {
32 class ElementTool;
33 }
34 
35 namespace Core
36 {
37 class ObjectGraph;
38 class ExecObject;
39 class PropertyLinkBase;
40 class CoreDocumentImpl;
41 class Transaction;
42 class RelGraph;
43 class PropertyLinkBaseBase;
44 
45 typedef std::vector<Core::DocObject*> ObjectVector;
46 typedef std::unordered_set<Core::DocObject*> ObjectSet;
47 typedef std::unordered_map<DocObject::IdType, Core::DocObject*> ObjectMap;
48 typedef std::vector<Core::ExecObject*> ExecObjectVector;
49 typedef std::unordered_set<Core::ExecObject*> ExecObjectSet;
50 typedef std::unordered_map<DocObject::IdType, Core::ExecObject*> ExecObjectMap;
51 typedef std::map<Base::Type, ObjectSet> ObjectTypeMap;
52 
53 
54 class LX_CORE_EXPORT Link : public std::vector<std::pair<Core::PropertyLinkBaseBase*,Core::DocObject*>>
55 {
56 public:
57  bool isSameAs(const Link& rhs ) const;
58 };
59 
60 
61 
62 struct LX_CORE_EXPORT LinkError
63 {
64  Core::DocObject* source = nullptr;
65  Core::DocObject* target = nullptr;
66  Core::PropertyLinkBaseBase* property = nullptr;
67 
68 };
69 
70 struct LX_CORE_EXPORT LinkStore
71 {
72  LinkStore(Core::DocObject* s,Core::PropertyLinkBaseBase* p, Core::DocObject* t): source(s),target(t),property(p){}
76 };
77 
78 
80 {
84 };
85 typedef std::multimap<Base::String, Core::AttachmentEntry> Attachments;
86 
87 /*
88 Core::DocChanges
89 This class notifies the observers about a recompute of the document.
90 It can also be used to send messages to the Observers:
91 1. Example:
92 
93 Core::ExecObject* o = ...
94 
95 Core::DocChanges docChanges;
96 docChanges.Why = Core::DocChanges::MESSAGE_BY_NAME
97 docChanges.MsgName = "MsgObjectAdded";
98 docChanges.Value = Core::Variant(o);
99 emitAndNotify(docChanges);
100 
101 2. Example:
102 
103 enum DocMessage
104 {
105  MSG_OBJECT_ADDED = 1,
106  ...
107 }
108 
109 Core::ExecObject* o = ...
110 
111 Core::DocChanges docChanges;
112 docChanges.Why = Core::DocChanges::MESSAGE_BY_ID
113 docChanges.MsgId = DocMessage::MSG_OBJECT_ADDED;
114 docChanges.Value = Core::Variant(o);
115 emitAndNotify(docChanges);
116 */
117 
118 class LX_CORE_EXPORT DocChanges
119 {
120 public:
121  DocChanges(Core::CoreDocument* doc) : Value(0), Document(doc) {}
122 
123  enum why
124  {
127  MESSAGE_BY_ID
128  } Why = RECOMPUTED;
129 
130  bool mustNotify() const
131  {
132  if (Why != RECOMPUTED) return true;
133 
134  // Notify if there is at least one new object or at least one deleted object. Otherwise e.g. Layer window doesn't react on deleted or added
135  // layers (CmdDeleteEmptyLayers redo and undo). Or ViewProviderProxyElement is not removed when App::ProxyElement is removed removed by
136  // removeObjectFinal (problem in 35617).
137  if (!NewObjects.empty() || !DeletedObjects.empty())
138  return true;
139 
140  for (auto lObj : UpdatedObjects)
141  {
142  if (lObj->mustNotify())
143  {
144  return true;
145  }
146  }
147 
148  return false;
149  }
150 
151  bool hasVisibilityChanges(std::vector<Core::DocObject*>& aDocObjects) const
152  {
153  for (auto lObj : UpdatedObjects)
154  {
155  if (lObj->hasVisiblityChanged())
156  {
157  aDocObjects.emplace_back(lObj);
158  }
159  }
160  return (bool)aDocObjects.size();
161  }
162 
164  {
165  for (auto lObj : UpdatedObjects)
166  {
167  if (!lObj->hasOnlyVisibilityChanged())
168  {
169  return false;
170  }
171  }
172 
173  return true;
174  }
175 
176  std::string MsgName = "";
177  int MsgId = -1;
180 
181  std::vector<Core::DocObject*> NewObjects;
182  std::vector<Core::DocObject*> UpdatedObjects;
183  std::vector<Core::DocObject*> DeletedObjects;
184  std::map<Core::DocObject*, std::vector<std::string>> ErroneousObjects; // Objects that caused an error in recompute with its error messages
185 
186 private:
187  DocChanges() : MsgId(0), Document(nullptr){};
188 };
189 
190 // All Lexocad Core message Ids are in the range 1000 - 1999
191 const int LEXOCAD_CORE_MSGID = 1000;
192 
193 enum LX_CORE_EXPORT DocMessage
194 {
212  PostCheck = LEXOCAD_CORE_MSGID + 17
213 };
214 
215 
216 
217 struct LX_CORE_EXPORT DocumentState
218 {
219  // Copy constructor
220  DocumentState() = default;
222  {
223  PropertyErrors = rhs.PropertyErrors;
224  LastErroneousObjects = rhs.LastErroneousObjects;
225  LastRecomputeTime = rhs.LastRecomputeTime;
226  LastNotifyTime = rhs.LastNotifyTime;
227  }
228 
229  std::vector<std::string> PropertyErrors;
230  std::map<Core::DocObject*, std::vector<std::string>> LastErroneousObjects;
231  unsigned long LastRecomputeTime;
232  unsigned long LastNotifyTime;
233 
234  void clear();
235 };
236 
237 struct LX_CORE_EXPORT PropertyLinkDesc
238 {
239  PropertyLinkDesc(std::string sourceDocObjectID, std::string sourcePropertyName, Base::Type sourcePropertyTypeID, std::string targetDocObjectID,std::string propertyLinkName)
240  : m_SourceDocObjectID(sourceDocObjectID)
241  , m_SourcePropertyName(sourcePropertyName)
242  , m_SourcePropertyTypeID(sourcePropertyTypeID)
243  , m_TargetDocObjectID(targetDocObjectID)
244  , m_PropertyLinkName(propertyLinkName)
245  {
246  }
247 
248  // Copy constructor
250  {
251  m_SourceDocObjectID = rhs.m_SourceDocObjectID;
252  m_SourcePropertyName = rhs.m_SourcePropertyName;
253  m_SourcePropertyTypeID = rhs.m_SourcePropertyTypeID;
254  m_TargetDocObjectID = rhs.m_TargetDocObjectID;
255  m_PropertyLinkName = rhs.m_PropertyLinkName;
256 
257  }
258 
259  std::string m_SourceDocObjectID;
260  std::string m_SourcePropertyName;
262 
263  std::string m_TargetDocObjectID;
264  std::string m_PropertyLinkName;
265 };
266 
267 
268 class LX_CORE_EXPORT CoreDocument : public Core::PropertyContainer, public Base::Subject<Core::DocChanges>
269 {
271  LX_NODE_HEADER();
272 
273 public:
274  friend class CoreApplication;
275  friend class CoreDocument_Factory;
276  friend class PropertyGUID;
278  friend class ::App::ElementTool;
279 
281  // //
282  // --------------------- BEGIN API --------------------- //
283  // //
284  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
285  // //
287 
288  enum Status
289  {
290  SkipRecompute = 0,
291  KeepTrailingDigits = 1,
292  Closable = 2,
293  Restoring = 3,
294  Recomputing = 4,
295  PartialRestore = 5,
296  Importing = 6,
297  PartialDoc = 7,
298  AllowPartialRecompute = 8, // allow recomputing editing object if SkipRecompute is set
299  TempDoc = 9, // Mark as temporary document without prompt for save
300  RestoreError = 10
301  };
302 
309  Core::PropertyIndex application_mainversion; // This version major of the RESTORED document.
310  Core::PropertyIndex application_minorversion; // This version minor of the RESTORED document.
319  Core::PropertyText projectNumber; // related to PieceList
321 
323 
325  int getDocumentVersion() const;
331  virtual void removeObjectFinal(Core::DocObject* e, bool deep = false);
333  void removeObjects(const std::vector<Core::DocObject*>& objects);
334 
336  virtual void onFileOpened() {}
338  void onBeforeChangeProperty(const Core::DocObject* Who, const Property* What);
340  void onChangedProperty(const Core::DocObject* Who, const Property* What);
341 
343 
344 
358  template <typename Type>
359  Type copyObjectShallow(Type o)
360  {
361  Core::DocObject* copy = o->shallowCopy(this);
362  assert(copy && "Document::copyObjectShallow could not copy object");
363  copy->setDocument(this);
364  copy->setNew();
365  copy->initDocObject();
366 
367  Type typedCopy = dynamic_cast<Type>(copy);
368  assert(typedCopy && "Document::copyObjectShallow could not cast object");
369 
370  return typedCopy;
371  }
372 
374  std::vector<Core::DocObject*> getObjects(bool includeDeletedObjects = false) const;
375  std::vector<const Core::DocObject*> getObjectsConst(bool includeDeletedObjects = false) const;
377  virtual std::vector<Core::DocObject*> getObjectsSorted() const;
383  std::vector<Core::DocObject*> getObjectsByTypeName(const std::string& typeName) const;
385  virtual void recompute();
388  virtual void recompute(
389  std::function<void(DOCOBJECTS newObj, DOCOBJECTS updatedObj, DOCOBJECTS deletedObj, DOCOBJECTS_ERROR_MAP errorObj)> onRecomputedCB);
391  virtual bool saveAs(const Base::String& filename);
395  bool isActive() const;
397  virtual bool isChanged();
400 
401  std::string getDocXMLAsString();
402 
404  bool testStatusBits(Status pos) const;
406  void setStatusBits(Status pos, bool on);
408 
428  void setUndoMode(int iMode);
431  int getUndoMode(void) const;
433  void setTransactionMode(int iMode);
442  int openTransaction(const char* name = 0);
444  void renameTransaction(const char* name, int id);
450  bool hasPendingTransaction() const;
452  const char* getPendingTransactionName() const;
454  int getTransactionID(bool undo, unsigned pos = 0) const;
457  bool isTransactionEmpty() const;
459  void setUndoLimit(unsigned int UndoMemSize = 0);
461  void setMaxUndoStackSize(unsigned int UndoMaxStackSize = 20);
463  unsigned int getMaxUndoStackSize(void)const;
465  void clearUndos();
467  int getAvailableUndos(int id = 0) const;
469  std::vector<std::string> getAvailableUndoNames() const;
471  bool undo(int id = 0);
473  int getAvailableRedos(int id = 0) const;
475  std::vector<std::string> getAvailableRedoNames() const;
477  bool redo(int id = 0);
481 
486 
487  // Filename Recommend - used in SaveAs.
489 
490 
491 #ifndef SWIG
492  virtual void emitAndNotify(Core::DocChanges& aDocChanges);
495  boost::signals2::signal<void(Core::DocChanges&)> signalDocChanges;
498  boost::signals2::signal<void(const Core::DocObject&)> signalNewObject;
500  boost::signals2::signal<void(const Core::DocObject&)> signalDeletedObject;
502  //boost::signals2::signal<void(const std::vector<Core::DocObject*>&)> signalVisibilityChanged;
504  boost::signals2::signal<void(const Core::DocObject&, const Core::Property&)> signalBeforeChangeObject;
506  boost::signals2::signal<void(const Core::DocObject&, const Core::Property&)> signalChangedObject;
508  boost::signals2::signal<void()> signalBeforeRecompute;
510  boost::signals2::signal<void(const std::vector<Core::DocObject*>&, const std::vector<Core::DocObject*>&,const std::vector<Core::DocObject*>&)> signalRecomputed;
512  boost::signals2::signal<void()> signalRecomputeError;
514  boost::signals2::signal<void(const std::map<Core::DocObject*, std::vector<std::string>>&)> signalRecomputedErrorObjects;
516  boost::signals2::signal<void(const std::vector<Core::LinkError>&)> signalDefectLinks;
518  boost::signals2::signal<void()> signalNewFile;
520 #endif
521 
522 #ifndef LXAPI
523 
524 
525 
526 
527 
528 
530  // //
531  // ---------------------- END API ---------------------- //
532  // //
534 
537  template <typename T>
539  {
540  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
541  if (o)
542  return static_cast<T*>(o);
543 
544  return nullptr;
545  }
546 
549  template <typename T>
551  {
552  // Check if it really is immutable
553  if (T::isMutableStatic())
554  return nullptr;
555 
556  // Check if an immutable object with these values already exists
557  Core::DocObject* check = getImmutableObjectWithSameValues(T::getClassTypeId(), po);
558  if (check)
559  return static_cast<T*>(check);
560 
561  // If it doesn't exist make a new one and initialize it with the
562  // property values from the Core::PropertyBundle.
563  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
564  if (o)
565  {
566  o->_setPropertyValues(po, /* bool isInit = */ true);
567  o->setStatus(Core::PropertyContainer::Status::New); // At initialization the status needs to stay NEW
568  addImmutableObjectMaterial(o);
569  return static_cast<T*>(o);
570  }
571 
572  return nullptr;
573  }
574 
577  template <typename T>
579  {
580  // Check if it really is immutable
581  if (T::isMutableStatic())
582  return nullptr;
583 
584  // If it doesn't exist make a new one and initialize it with the
585  // property values from the Core::PropertyBundle.
586  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
587  if (o)
588  {
589  o->_setPropertyValues(po, /* bool isInit = */ true);
590  o->setStatus(Core::PropertyContainer::Status::New); // At initialization the status needs to stay NEW
591  addImmutableObjectMaterial(o);
592  return static_cast<T*>(o);
593  }
594 
595  return nullptr;
596  }
597 
599  template <typename T>
600  std::vector<T*> getObjectsByType() const
601  {
602  // get all resulting types including derived classes
603  Base::Type t = T::getClassTypeId();
604  std::set<Base::Type> typeset;
605  t.getAllChildren(typeset);
606  typeset.insert(t);
607 
608  std::vector<T*> returnObjs{};
609  for (const auto& type : typeset)
610  {
611  auto type2objects = getTypeMap().find(type);
612  if (type2objects == getTypeMap().end()) // do we know this type?
613  continue;
614 
615  const auto& docObjects = type2objects->second;
616  for (const auto& obj : docObjects) // get un-deleted objects of given type
617  {
618  if (!obj->isDeleted())
619  returnObjs.push_back(static_cast<T*>(obj));
620  }
621  }
622 
623  return returnObjs;
624  }
625 
627  template <typename T>
628  void getObjectsByType(std::vector<T*>& objs) const
629  {
630  const auto& objectMap = getObjectMap();
631  for (const auto& it : objectMap) //#todo go only over seconds
632  {
633  if (!it.second->isDeleted() && it.second->isDerivedFrom<T>()) // #todo why test for type when the type is in first?
634  objs.push_back((T*)it.second);
635  }
636  }
637 
639  void getObjectsFromTypeMap(Base::Type t, std::vector<Core::DocObject*>& ret) const;
640  const ObjectTypeMap& getTypeMap() const;
641 
642  void addPropertyLinkError(const std::string& from, const std::string& to);
645  bool checkObjectLinks(const std::vector<const Core::DocObject*>& objvec,
646  std::vector<Core::LinkError>* errors = nullptr);
647  bool checkObjectLinks(const std::vector<const Core::DocObject*>& objvec,
648  const std::vector<const Core::DocObject*>& objToCheck,
649  std::vector<Core::LinkError>* errors= nullptr);
650  bool checkDeletedObjectLinks(const std::vector<const Core::DocObject*>& objToCheck,
651  std::vector<Core::LinkError>* errors);
652 
653  bool checkObjectLinks( std::vector<Core::LinkError>* errors );
654 
655  bool checkDeletedObjectLinks(const std::vector<const Core::DocObject*>& objvec,
656  const std::vector<const Core::DocObject*>& objToCheck,
657  std::vector<Core::LinkError>* errors);
658 
660  virtual std::vector<const Core::DocObject*> getInner(const Core::DocObject* me, std::function<bool(const Core::DocObject*)>* allowToAddObject = 0);
662  virtual std::vector<const Core::DocObject*> getOuter(const Core::DocObject* me);
663 
665 
666  std::vector<const Core::DocObject*> getLinksByProperties(const Core::DocObject* o) const;
667  std::vector<PropertyLinkDesc> getLinkDescByProperties(const Core::DocObject* o) const;
668  std::vector<const Core::DocObject*> getBackLinksByProperties(const Core::DocObject* source) const;
669 
672 
674  std::string dumpGraph(void);
675  virtual std::vector<std::string> check_graph();
677  virtual std::vector<const Core::DocObject*> getLinksToMe(const Core::DocObject* o);
679  virtual std::vector<const Core::DocObject*> getBackLinksToMe(const Core::DocObject* o);
681  virtual std::vector<const Core::DocObject*> getLinksFromMe(const Core::DocObject* o);
683  virtual std::vector<const Core::DocObject*> getBackLinksFromMe(const Core::DocObject* o);
684 
686  virtual bool maybeSave() { return true; }
688  std::vector<Core::DocObject*> getObjectsToSave();
689 
691  static void getDefaultVersionToSave(int& aMajorVersion, int& aMinorVersion);
693  static void getPreviousVersionToSave(int& aMajorVersion, int& aMinorVersion);
695  static QString getPreviousVersionToSaveStr();
696 
698  bool saveFile(bool toExport = false, bool saveBackupCopy = false);
700  bool saveAsFile(const Base::String& filename = Base::String(),
701  bool toExport = false,
702  bool saveBackupCopy = false,
703  const Base::String& initialDir = Base::String());
704 
706  bool saveCopy(const Base::String& filename);
708  bool saveAsFileVersion(int aMajorVersion,
709  int aMinorVersion,
710  const Base::String& filename = Base::String(),
711  bool toExport = false,
712  bool saveBackupCopy = false,
713  const Base::String& initialDir = Base::String(),
714  bool dontRename = false);
720  bool askAndSetNewFilename(QString& newFilename, const Base::String& initialDir = Base::String());
722  void setSaveBlocksUntilFinished(bool onoff);
725 
727  virtual void addInventorDirectory(const Base::String&) {}
730 
734  void setGuidPolicy(const Base::String& suffix, const Base::GlobalId_Policy& policy);
738  bool getGuidPolicy(const Base::String& suffix, Base::GlobalId_Policy& policy) const;
739 
743  const std::set<Core::DocObject*>& getReferences() const;
745  void setFullFileName(const Base::String& fullfilename);
746 
747  virtual const char* subject_name(void) { return "CoreDocument"; };
748 
749  virtual bool restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
750 
751  bool addFileToZip(const Base::String& entryName, const Base::String& path);
752  bool restoreFileFromZip(const Base::String& entryName, const Base::String& targetpath, bool binaryMode);
753 
756 
761 
763  size_t getRecomputeCount() const;
764 
765  virtual void setChanged(bool changed);
766 
769 
770  void setImportedIFCFile(QString a);
772 
773  static std::pair<int,int> getAppVersionFromDocument( Base::String filename);
774 
775  void test_graph();
778  void onAddLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList );
779  void onRemoveLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList);
780  void onAddLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
781  void onRemoveLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
782 
785  void onAddBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList );
786  void onRemoveBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::list<Core::DocObject*>& linkList);
787  void onAddBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
788  void onRemoveBackLinks( PropertyLinkBaseBase*p, Core::DocObject* from ,const std::unordered_set<Core::DocObject*>& linkSet );
796 
798 
799 #endif
800 
801 protected:
803  // Copy constructor
805  virtual ~CoreDocument();
806 
808  virtual void deleteObject(Core::DocObject* o);
809 
812 
818  virtual Core::DocObject* restoreObject(const std::string& typeName, const std::string& typeHierarchy, const std::string& id);
820  const Base::String& name,
821  Base::AbstractXMLReader& reader,
824  virtual void saveDocument(std::shared_ptr<Base::AbstractWriter> writer, int versionMajor2save, int versionMinor2save, bool showProgress);
826  virtual int restoreDocument(Base::XMLReader& reader, Core::Attachments& attachments);
828  virtual std::vector<Core::DocObject*> build_savemap(std::vector<std::string>& delete_log);
830  virtual void addNewObjectsToGraph();
831 
836  virtual bool renameTypeFromOlderVersions(int, Base::String&) { return false; }
838  virtual void checkBeforeObjectRestoring(int, int) {}
845  virtual bool convertFromOlderVersions(int docVersion, int appVersion);
846 
847  virtual bool getPatchedUserTypes(const Base::String& filename, std::map<QString, QString>& id2TypeMap);
848 
850  virtual void cleanUndoStack() {}
852  virtual void storeDirectory(const QString&, Base::AbstractWriter&) {}
854  virtual void restoreDirectory(const QString&) {}
855 
857  virtual void initDocument(bool) {}
859  const ObjectMap& getObjectMap() const;
867  void add_GUID(const Base::GlobalId& guid, Core::DocObject* o);
872 
874  bool isCatalogFile() const;
875 
876  bool createBackupFile(const Base::String& path, bool savePath);
877  bool createBackupFileAfterOpeningDoc(const Base::String& path, bool savePath);
878 
879  // Internal, do not use
880  void __setEnableTimeStamps__(bool aOnOff);
882 
884  void _checkTransaction(Core::DocObject* pcDelObj, const Property* What, int line);
895  int _openTransaction(const char* name = 0, int id = 0);
897  void _commitTransaction(bool notify = false);
900  void _clearRedos();
901 
902 
903 
905  // Map of all objects
907  // For performance reasons we have a vector of all objects
909  // Map of immutable objects < Type, set of immutable objects >
911  // The object graph
912  //ObjectGraph* _graph;
913  // Set of objects per type
915 
918 
919  std::set<Core::DocObject*> _references;
920  std::map<Base::GlobalId, Core::DocObject*> _guid_map;
921  std::map<long, Core::DocObject*> _ifcId_map;
922 
923  bool _hasErrorObjectsInRecompute = false;
924  bool _needRestoreBeforeRecompute = false;
925  size_t _recomputeCnt = 0;
926  bool mSolvingEnabled = true;
929 private:
931  bool openFile(const Base::String& filename, bool savePath = true);
932 
934  Core::DocObject* clone_and_replace_Object(const char* typeName, Core::DocObject* base);
936  bool close(bool dontNotify = false);
937  void onNewObjectTransaction(Core::DocObject* aDocObject);
938  void _cleanTempDirectory_Helper(const Base::String& dir);
939  void _copyFilesInTemp(Core::DocObject* original, Core::DocObject* copy);
940  bool _saveFile(Base::String saveFileName, int versionMajor2save, int versionMinor2save, bool toExport, bool saveBackupCopy, bool notify = true);
941  void _initNewObject(Core::DocObject* o, const DocObject::IdType& id = "");
942  void _saveDocFiles(std::shared_ptr<Base::AbstractWriter> writer, bool notify = true);
943  bool _docWrite(std::shared_ptr<Base::AbstractWriter> mainwriter,
944  QString tmpfile,
945  QString fileName,
946  bool inThread,
947  bool toExport,
948  bool saveBackupCopy,
949  std::vector<Base::String> tempFilesToDelete);
950  void cleanOldTempDirectories();
951  void dispatchMsg(const int aMsgId);
952  // never make it public, copyShare param must be controlled ONLY from CoreDocument
953  Core::DocObject* copyObjectInternal(Core::DocObject* o, DocObjectMap& copyMap, bool standardCopyOfShared = false, bool aCreateNewType = false);
954 
956  void notifyDocChange(DocChanges::why aWhy, DocMessage aMsgId, const Base::String& aValue);
957 
959  bool restoreDocuments(int& docVersion, int& appVersion);
960 
961  Base::Type m_copyType = Base::Type::badType();
962  QString m_importedIFCFile;
963  QDateTime _lastBackupFileTime;
964  int _backupFilesCounter = 0;
965  int _numOfExistBackupFiles = 0;
966  bool _onSaveChangeToDefaultUser = false;
967  bool _saveBlocksUntilFinished = false;
968  Base::String _tmpdirectory;
969 
970  // Map for <file suffix / GUID policy>
971  std::map<Base::String, Base::GlobalId_Policy> _guidPolicyMap;
972  std::map<Base::String, Base::String> _additionalFiles;
973 
974  std::list<Transaction*> mUndoTransactions;
975  std::map<int, Transaction*> mUndoMap;
976  std::list<Transaction*> mRedoTransactions;
977  std::map<int, Transaction*> mRedoMap;
978 
979  CoreDocumentImpl* _pimpl{};
980 };
981 
982 /* @brief This class takes care that time stamping can be securely
983  * deactivated as long as an instance of this class stays in scope.
984  * It restores the old state when the destructor is called.
985  */
986 class LX_CORE_EXPORT DocumentTimeStampSentinel
987 {
988 public:
991  {
992  mOldEnableTimeStamps = mDoc->__getEnableTimeStamps__();
993  mDoc->__setEnableTimeStamps__(false);
994  }
995 
997  {
998  mDoc->__setEnableTimeStamps__(mOldEnableTimeStamps);
999  }
1001  bool mOldEnableTimeStamps = true;
1002 };
1003 
1004 
1005 class LX_CORE_EXPORT DocumentFactory
1006 {
1007 public:
1008  friend class CoreApplication;
1011 
1012  static std::map<std::string, Core::DocumentFactory*> registry;
1013 
1014 protected:
1016  static Core::CoreDocument* create(const std::string& type);
1017 };
1018 
1019 
1021 {
1022  virtual Core::CoreDocument* createByFactory()
1023  {
1025  return doc;
1026  }
1027 };
1028 
1029 } // namespace Core
1030 
1031 
1032 
1033 #define DECLARE_DOCUMENT_FACTORY(_factoryName_, _class_) \
1034  class _factoryName_ : public Core::DocumentFactory \
1035  { \
1036  private: \
1037  virtual Core::CoreDocument* createByFactory() \
1038  { \
1039  Core::CoreDocument* doc = new _class_; \
1040  return doc; \
1041  } \
1042  };
1043 
1044 #define REGISTER_DOCUMENT_FACTORY(_factoryName_, _class_) Core::DocumentFactory::registry[#_class_] = (Core::DocumentFactory*)new _factoryName_();
Base::GlobalId_Policy
Definition: GlobalId_Policy.h:7
Core::CoreDocument::maybeSave
virtual bool maybeSave()
Can be overwritten to check if the undo stack is clean etc.
Definition: CoreDocument.h:686
Core::DocumentState::clear
void clear()
Core::CoreDocument::__getEnableTimeStamps__
bool __getEnableTimeStamps__() const
Base::Type
Definition: Type.h:51
Core::LEXOCAD_CORE_MSGID
const int LEXOCAD_CORE_MSGID
Definition: CoreDocument.h:191
Core::CoreDocument::removeLinkInProperties
void removeLinkInProperties(const Core::DocObject *source, Core::DocObject *link)
Core::ExecObjectSet
std::unordered_set< Core::ExecObject * > ExecObjectSet
Definition: CoreDocument.h:49
Core::CoreDocument::initDocument
virtual void initDocument(bool)
Initialize document.. Can be overwritten to do some custom initialization.
Definition: CoreDocument.h:857
Core::DocumentState::PropertyErrors
std::vector< std::string > PropertyErrors
Definition: CoreDocument.h:229
Core::CoreDocument::isPerformingTransaction
bool isPerformingTransaction() const
returns true if the document is in an Transaction phase, e.g. currently performing a redo/undo or rol...
Core::CoreDocument::removeBackLinkInProperties
void removeBackLinkInProperties(const Core::DocObject *source, Core::DocObject *link)
Core::CoreDocument::onAddBackLinks
void onAddBackLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
Core::CoreDocument::creationDate
Core::PropertyText creationDate
Definition: CoreDocument.h:314
Core::CoreDocument::getObjectsByType
std::vector< T * > getObjectsByType() const
Return all object of given type and all derived classes.
Definition: CoreDocument.h:600
Core::CoreDocument::replaceLink
bool replaceLink(Core::DocObject *old, Core::DocObject *newLink)
Base::Type::badType
static const Type badType(void)
Definition: Type.h:97
Core::CoreDocument::compatibleInfo
Core::PropertyText compatibleInfo
Definition: CoreDocument.h:305
Core::CoreDocument::getAppVersionFromDocument
static std::pair< int, int > getAppVersionFromDocument(Base::String filename)
GUID_Conflict
GUID_Conflict
Definition: CoreDocument.h:206
Core::CoreDocument::restoreGlobalAttachment
virtual bool restoreGlobalAttachment(Base::GlobalAttachment *gAtta, std::istream *, uint64_t streamsize, const Base::String &entryName)
Core::CoreDocument::application_mainversion
Core::PropertyIndex application_mainversion
Definition: CoreDocument.h:309
Core::CoreDocument::copyObject
Core::DocObject * copyObject(Core::DocObject *o, DocObjectMap &copyMap)
Creates a copy of 'o' and adds it to the document, provides map of pairs original-copy to see which o...
Core::CoreDocument::saveCopy
bool saveCopy(const Base::String &filename)
Saves a copy of the current document, no notify, only store the doc under this name.
Core::CoreDocument
Definition: CoreDocument.h:269
Core::CoreDocument::copyObject
Core::DocObject * copyObject(Core::DocObject *o)
Core::CoreDocument::setMaxUndoStackSize
void setMaxUndoStackSize(unsigned int UndoMaxStackSize=20)
Set the Undo limit as stack size.
Core::CoreDocument::setOnSaveChangeToDefaultUser
void setOnSaveChangeToDefaultUser(bool onoff)
If true: Change to default user on next change. Usually from IFC User to Lexocad User.
Core::CoreDocument::createBackupFile
bool createBackupFile(const Base::String &path, bool savePath)
Core::CoreDocument::getObjectByUserName
Core::DocObject * getObjectByUserName(const Base::String &s) const
Returns the object with this userName.
Rename
Rename
Definition: CoreDocument.h:196
Core::CoreDocument::_ifcId_map
std::map< long, Core::DocObject * > _ifcId_map
Definition: CoreDocument.h:921
Core::CoreDocument::test_graph
void test_graph()
Core::CoreDocument::getAvailableUndoNames
std::vector< std::string > getAvailableUndoNames() const
Returns a list of the Undo names.
Core::DocumentFactory::createByFactory
virtual Core::CoreDocument * createByFactory()=0
Core::DocChanges::why
why
Definition: CoreDocument.h:124
CleanAll
CleanAll
Definition: CoreDocument.h:201
Core::CoreDocument::addNewObjectsToGraph
virtual void addNewObjectsToGraph()
Adds objects with status 'New' to the graph.
Core::CoreDocument::deleteObject
virtual void deleteObject(Core::DocObject *o)
Physically deletes an object without informing the object maps.
Core::PropertyContainer::setStatus
virtual void setStatus(Status status)
Core::DocChanges::mustNotify
bool mustNotify() const
Definition: CoreDocument.h:130
Core::CoreDocument::onChangedProperty
void onChangedProperty(const Core::DocObject *Who, const Property *What)
callback from the Document objects after property was changed
Core::CoreDocument::signalNewObject
boost::signals2::signal< void(const Core::DocObject &)> signalNewObject
signal on new Object
Definition: CoreDocument.h:498
Core::DocumentState::LastRecomputeTime
unsigned long LastRecomputeTime
Definition: CoreDocument.h:231
Export
Export
Definition: CoreDocument.h:207
Core::CoreDocument::_typeObjects
ObjectTypeMap _typeObjects
Definition: CoreDocument.h:914
Base::Type::getAllChildren
void getAllChildren(std::set< Type > &children) const
ErrorCanNotOpenFile
ErrorCanNotOpenFile
Definition: CoreDocument.h:204
Core::CoreDocument::projectNumber
Core::PropertyText projectNumber
Definition: CoreDocument.h:319
Core::CoreDocument::_abortTransaction
void _abortTransaction()
Internally called by App::Application to abort the running transaction.
Core::CoreDocument::signalBeforeRecompute
boost::signals2::signal< void()> signalBeforeRecompute
Signals before recompute.
Definition: CoreDocument.h:508
Core::CoreDocument::getCopyType
Base::Type getCopyType() const
Core::DocChanges::NewObjects
std::vector< Core::DocObject * > NewObjects
Definition: CoreDocument.h:181
Core::CoreDocument::createBackupFileAfterOpeningDoc
bool createBackupFileAfterOpeningDoc(const Base::String &path, bool savePath)
Core::CoreDocument::waitForSaveIsFinished
void waitForSaveIsFinished()
Saving runs in Threads, wait for finish.
Core::CoreDocument::removeObject
void removeObject(Core::DocObject *e)
Removes an object from the document.
Core::CoreDocument::checkDeletedObjectLinks
bool checkDeletedObjectLinks(const std::vector< const Core::DocObject * > &objvec, const std::vector< const Core::DocObject * > &objToCheck, std::vector< Core::LinkError > *errors)
Core::CoreDocument::getGuidPolicy
Base::GlobalId_Policy getGuidPolicy() const
Returns the default GUID policy.
Base::GlobalId
Definition: GlobalId.h:28
Observer.h
Core::CoreDocument::addImmutableObjectMaterial
virtual Core::DocObject * addImmutableObjectMaterial(Core::PropertyContainer *pc)
Core::DocChanges::ErroneousObjects
std::map< Core::DocObject *, std::vector< std::string > > ErroneousObjects
Definition: CoreDocument.h:184
Core::CoreDocument::getMaxUndoStackSize
unsigned int getMaxUndoStackSize(void) const
Set the Undo limit as stack size.
Core::CoreDocument::convertFromOlderVersions
virtual bool convertFromOlderVersions(int docVersion, int appVersion)
Core::CoreDocument::getBackLinksByProperties
std::vector< const Core::DocObject * > getBackLinksByProperties(const Core::DocObject *source) const
Core::DocObjectMap
std::map< Core::DocObject *, Core::DocObject * > DocObjectMap
Definition: DocObject.h:50
Core::CoreDocument::_state
DocumentState _state
Definition: CoreDocument.h:904
RecomputeFinished
RecomputeFinished
Definition: CoreDocument.h:203
Core::CoreDocument::createObjectFromType
Core::DocObject * createObjectFromType(Base::Type type)
Creates an object from type and adds it to the document.
Core::DocumentTimeStampSentinel::DocumentTimeStampSentinel
DocumentTimeStampSentinel()=delete
Core::DocumentState::DocumentState
DocumentState()=default
Core::CoreDocument::clearUndos
void clearUndos()
Remove all stored Undos and Redos.
Core::CoreDocument::hasErrorObjectsInRecompute
bool hasErrorObjectsInRecompute()
get result of last recompute
Core::CoreDocument::isTransactionEmpty
bool isTransactionEmpty() const
Core::CoreDocument::getTypeMap
const ObjectTypeMap & getTypeMap() const
Core::DocChanges::hasOnlyVisibilityChanges
bool hasOnlyVisibilityChanges() const
Definition: CoreDocument.h:163
Core::CoreDocument::storeDirectory
virtual void storeDirectory(const QString &, Base::AbstractWriter &)
Stores directory at given path to zip stream.
Definition: CoreDocument.h:852
DocObject.h
Core::DocChanges::DocChanges
DocChanges(Core::CoreDocument *doc)
Definition: CoreDocument.h:121
Core::CoreDocument::__setEnableTimeStamps__
void __setEnableTimeStamps__(bool aOnOff)
Core::CoreDocument::getOnSaveChangeToDefaultUser
bool getOnSaveChangeToDefaultUser() const
Return whether the user get changed to default user on next save.
Core::ExecObjectMap
std::unordered_map< DocObject::IdType, Core::ExecObject * > ExecObjectMap
Definition: CoreDocument.h:50
Core::CoreDocument::maybe_add_GUID
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.
Core::CoreDocument::_references
std::set< Core::DocObject * > _references
Definition: CoreDocument.h:919
Core::CoreDocument::addObject
bool addObject(Core::DocObject *e)
Adds an existing object to the document.
Core::CoreDocument::setStatusBits
void setStatusBits(Status pos, bool on)
set the status bits
Core::CoreDocument::createObjectFromTypeName
Core::DocObject * createObjectFromTypeName(const char *typeName)
Creates an object from type name and adds it to the document.
Core::CoreDocument::getObjects
std::vector< Core::DocObject * > getObjects(bool includeDeletedObjects=false) const
Returns all objects in the document.
Core::CoreDocument::getObjectsByType
void getObjectsByType(std::vector< T * > &objs) const
Returns all objects of type 'T'.
Definition: CoreDocument.h:628
Core::CoreDocument::isActive
bool isActive() const
Returns 'true' if the Document is the active Document. Otherwise returns 'false'.
Core::CoreDocument::documentTypeName
Core::PropertyText documentTypeName
Definition: CoreDocument.h:311
Core::CoreDocument::restoreObject
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.
Core::DocChanges::MESSAGE_BY_NAME
@ MESSAGE_BY_NAME
Definition: CoreDocument.h:126
Core::CoreDocument::getBackLinksToMe
virtual std::vector< const Core::DocObject * > getBackLinksToMe(const Core::DocObject *o)
Returns all objects that directly linked to 'o'.
Core::CoreDocument::onFileOpened
virtual void onFileOpened()
Is called when the file was opened, but before the message FileOpened gets emitted....
Definition: CoreDocument.h:336
Core::CoreDocument::checkBeforeObjectRestoring
virtual void checkBeforeObjectRestoring(int, int)
Is called before restoring objects of a document.
Definition: CoreDocument.h:838
Core::CoreDocument::onRemoveBackLinks
void onRemoveBackLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
Core::CoreDocument::getUniqueObjectId
Core::DocObject::IdType getUniqueObjectId() const
Returns the next available unique id.
Core::CoreDocument::getGuidPolicy
bool getGuidPolicy(const Base::String &suffix, Base::GlobalId_Policy &policy) const
Returns the GUID policy for a file suffix.
Core::CoreDocument::getPreviousVersionToSave
static void getPreviousVersionToSave(int &aMajorVersion, int &aMinorVersion)
Returns application's mainversion to be saved in the document saved as PREVIOUS version.
Core::CoreDocument::checkAndConfigureOpenedDocumentAfterRecompute
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:842
Core::DocumentFactory::~DocumentFactory
~DocumentFactory()
Definition: CoreDocument.h:1010
Core::CoreDocument::addToDocumentMaps
virtual void addToDocumentMaps(Core::DocObject *o)
Adds the object to all relevant maps.
Core::CoreDocument::getObjectsByTypeName
std::vector< Core::DocObject * > getObjectsByTypeName(const std::string &typeName) const
Returns all objects of typeName.
Core::CoreDocument::saveAs
virtual bool saveAs(const Base::String &filename)
Saves the document under this name*.
BeforeSave
BeforeSave
Definition: CoreDocument.h:199
Core::CoreDocument::getAvailableRedoNames
std::vector< std::string > getAvailableRedoNames() const
Returns a list of the Redo names.
Core::ObjectTypeMap
std::map< Base::Type, ObjectSet > ObjectTypeMap
Definition: CoreDocument.h:51
Core::CoreDocument::setFullFileName
void setFullFileName(const Base::String &fullfilename)
Sets the full file name including the path.
Core::CoreDocument::getLinkDescByProperties
std::vector< PropertyLinkDesc > getLinkDescByProperties(const Core::DocObject *o) const
Core::CoreDocument::documentVersion
Core::PropertyText documentVersion
Definition: CoreDocument.h:304
Core::CoreDocument::dumpGraph
std::string dumpGraph(void)
Returns a string representation of the graph.
Core::CoreDocument::emitAndNotify
virtual void emitAndNotify(Core::DocChanges &aDocChanges)
Core::CoreDocument::name
Core::PropertyText name
Definition: CoreDocument.h:303
Core::CoreDocument::onRemoveLinks
void onRemoveLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
Core::PropertyContainer
Definition: PropertyContainer.h:93
Core::CoreDocument::copySharedObject
Core::DocObject * copySharedObject(Core::DocObject *o, DocObjectMap &copyMap)
Copy shared object. This is violating of the share, but in some cases this is useful....
Core::CoreDocument::_openTransaction
int _openTransaction(const char *name=0, int id=0)
Core::Attachments
std::multimap< Base::String, Core::AttachmentEntry > Attachments
Definition: CoreDocument.h:85
Core::CoreDocument::onChangedDebug
virtual bool onChangedDebug(Core::DocObject *o, Core::Property *p)
Core::DocChanges::hasVisibilityChanges
bool hasVisibilityChanges(std::vector< Core::DocObject * > &aDocObjects) const
Definition: CoreDocument.h:151
Core::CoreDocument::getImmutableObjects
bool getImmutableObjects(Base::Type t, ObjectSet &set) const
Core::CoreDocument::onAddBackLink
void onAddBackLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
Core::CoreDocument::signalNewFile
boost::signals2::signal< void()> signalNewFile
Signals new file.
Definition: CoreDocument.h:518
Core::CoreDocument::filename
Core::PropertyText filename
Definition: CoreDocument.h:312
Core::CoreDocument::CoreDocument
CoreDocument()
Core::CoreDocument::getObjectsFromTypeMap
void getObjectsFromTypeMap(Base::Type t, std::vector< Core::DocObject * > &ret) const
Returns all objects of type 'T'.
Core::CoreDocument::openTransaction
int openTransaction(const char *name=0)
Core::DocObject
Definition: DocObject.h:54
Core::CoreDocument::_relGraph
RelGraph * _relGraph
Definition: CoreDocument.h:916
Core::CoreDocument::onBeforeChangeProperty
void onBeforeChangeProperty(const Core::DocObject *Who, const Property *What)
callback from the Document objects before property will be changed
Core::CoreDocument::addReferenceFrom
void addReferenceFrom(Core::DocObject *from)
Core::DocChanges::DeletedObjects
std::vector< Core::DocObject * > DeletedObjects
Definition: CoreDocument.h:183
Core::CoreDocument::signalDeletedObject
boost::signals2::signal< void(const Core::DocObject &)> signalDeletedObject
signal on deleted Object
Definition: CoreDocument.h:500
Core::CoreDocument::restoreFileFromZip
bool restoreFileFromZip(const Base::String &entryName, const Base::String &targetpath, bool binaryMode)
Core::DocumentFactory
Definition: CoreDocument.h:1006
Core::CoreDocument::getTmpDirectory
Base::String getTmpDirectory()
Returns the temporary directory.
Core::DocumentTimeStampSentinel::~DocumentTimeStampSentinel
~DocumentTimeStampSentinel()
Definition: CoreDocument.h:996
Core::CoreDocument::onRemoveLink
void onRemoveLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
Core::CoreDocument::Status
Status
Definition: CoreDocument.h:289
Core::CoreDocument::getObjectsConst
std::vector< const Core::DocObject * > getObjectsConst(bool includeDeletedObjects=false) const
Base::PersistenceVersion
Definition: Persistence.h:13
Core::CoreDocument::getOutLinks
Core::Link getOutLinks(Core::DocObject *docObj)
Core::CoreDocument::getUndoMode
int getUndoMode(void) const
switch the level of Undo/Redo
DOCOBJECTS_ERROR_MAP
std::map< Core::DocObject *, std::vector< std::string > > DOCOBJECTS_ERROR_MAP
Definition: CoreDocument.h:22
Core::DocumentFactory::registry
static std::map< std::string, Core::DocumentFactory * > registry
Definition: CoreDocument.h:1012
Core::CoreDocument::removeObjects
void removeObjects(const std::vector< Core::DocObject * > &objects)
Removes objects from the document.
Core::DocumentState
Definition: CoreDocument.h:218
Core::CoreDocument::checkDeletedObjectLinks
bool checkDeletedObjectLinks(const std::vector< const Core::DocObject * > &objToCheck, std::vector< Core::LinkError > *errors)
Core::CoreDocument::saveAsFileVersion
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.
Core::DocChanges::RECOMPUTED
@ RECOMPUTED
Definition: CoreDocument.h:125
Core::CoreDocument::getOuter
virtual std::vector< const Core::DocObject * > getOuter(const Core::DocObject *me)
Get ALL Links from me, also indirect.
Core
Definition: Base.h:5
Core::CoreDocument::setRecommendFileNameForSave
void setRecommendFileNameForSave(const Base::String &s)
Core::CoreDocument::documentMaxID
Core::PropertyIndex documentMaxID
Definition: CoreDocument.h:308
Core::CoreDocument::isChanged
virtual bool isChanged()
Returns 'true' if the document is changed.
Core::CoreDocument::getInLinks
Core::Link getInLinks(Core::DocObject *docObj)
Core::CoreDocument::cleanUndoStack
virtual void cleanUndoStack()
Cleans the undo stack. Must be overwritten.
Definition: CoreDocument.h:850
Core::CoreDocument::onAddLinks
void onAddLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::list< Core::DocObject * > &linkList)
Core::CoreDocument::renameTransaction
void renameTransaction(const char *name, int id)
Rename the current transaction if the id matches.
Core::Variant
Definition: Variant.h:78
Core::CoreDocument::createGroundPlate_deprecated
virtual void createGroundPlate_deprecated()
To overwrite. Deprecated, do not use.
Definition: CoreDocument.h:729
Core::DocChanges::UpdatedObjects
std::vector< Core::DocObject * > UpdatedObjects
Definition: CoreDocument.h:182
Core::ObjectVector
std::vector< Core::DocObject * > ObjectVector
Definition: core_types.h:57
Core::CoreDocument::getPendingTransactionName
const char * getPendingTransactionName() const
Returns pending transaction name. Returns nullptr if there is no pending transaction.
Core::CoreDocument::checkAndConfigureOpenedDocument
virtual void checkAndConfigureOpenedDocument()
Is called when opening a document. Can be overwritten to do some custom check routines.
Definition: CoreDocument.h:840
LX_NODE_HEADER
#define LX_NODE_HEADER()
Definition: PropertyMacros.h:7
Core::CoreDocument::~CoreDocument
virtual ~CoreDocument()
Core::CoreDocument::getDocumentVersion
int getDocumentVersion() const
Returns the version of the document.
Core::DocumentFactory::create
static Core::CoreDocument * create(const std::string &type)
Core::AttachmentEntry::Info
Base::String Info
Definition: CoreDocument.h:83
Core::CoreDocument::_all_objects_map
ObjectMap _all_objects_map
Definition: CoreDocument.h:906
Core::CoreDocument::documentChanges
Core::PropertyIndex documentChanges
Definition: CoreDocument.h:307
PropertyText.h
Core::CoreDocument::setSaveBlocksUntilFinished
void setSaveBlocksUntilFinished(bool onoff)
If true, saving will block until the whole save is finished and file is ready.
Base::AbstractWriter
Definition: Writer.h:13
Base::XMLReader
Definition: Reader.h:23
Core::CoreDocument::company
Core::PropertyText company
Definition: CoreDocument.h:317
Core::CoreDocument::forceBackupOnNextSave
void forceBackupOnNextSave()
Modifies the _lastBackupFileTime to force backup when the document is saved next time.
Core::CoreDocument::signalChangedObject
boost::signals2::signal< void(const Core::DocObject &, const Core::Property &)> signalChangedObject
signal on changed Object
Definition: CoreDocument.h:506
Core::CoreDocument::isCatalogFile
bool isCatalogFile() const
Returns true if this document's file is part of catalog.
Core::CoreDocument::clearCopyType
void clearCopyType()
Sets the copy type to Base::Type::badType(), next copied object will be copied as its own type.
Core::DocObject::initDocObject
virtual void initDocObject()
Core::CoreDocument::getLinksByProperties
std::vector< const Core::DocObject * > getLinksByProperties(const Core::DocObject *o) const
Core::AttachmentEntry::FeatName
Base::String FeatName
Definition: CoreDocument.h:82
Core::CoreDocument::getAvailableRedos
int getAvailableRedos(int id=0) const
Returns the number of stored Redos. If greater than 0 Redo will be effective.
Core::CoreDocument::comment
Core::PropertyText comment
Definition: CoreDocument.h:318
Core::CoreDocument::onAddLink
void onAddLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
Core::CoreApplication
Definition: CoreApplication.h:71
Core::CoreDocument::checkRelGraph
bool checkRelGraph()
Core::CoreDocument::copyToDifferentType
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...
FileOpened
FileOpened
Definition: CoreDocument.h:198
Closing
Closing
Definition: CoreDocument.h:210
ChangeToDefaultUser
ChangeToDefaultUser
Definition: CoreDocument.h:205
Core::CoreDocument::_all_objects_vector
ObjectVector _all_objects_vector
Definition: CoreDocument.h:908
Base::AbstractXMLReader
Definition: AbstractXMLReader.h:7
Core::CoreDocument::getDocXMLAsString
std::string getDocXMLAsString()
Core::CoreDocument::breakLinks
void breakLinks(Core::DocObject *from)
Core::CoreDocument::check_graph
virtual std::vector< std::string > check_graph()
Core::CoreDocument::cleanTempDirectory
void cleanTempDirectory()
Cleans the temporary directory.
Core::CoreDocument::addImmutableObject
T * addImmutableObject(const Core::PropertyBundle< T > *po)
Definition: CoreDocument.h:550
Core::ObjectSet
std::unordered_set< Core::DocObject * > ObjectSet
Definition: core_types.h:59
Core::DocumentFactory::DocumentFactory
DocumentFactory()
Definition: CoreDocument.h:1009
DOCOBJECTS
std::vector< Core::DocObject * > DOCOBJECTS
Definition: CoreDocument.h:21
Core::DocChanges::Value
Core::Variant Value
Definition: CoreDocument.h:178
PropertyInteger.h
Core::PropertyText
Definition: PropertyText.h:8
Core::CoreDocument::getPatchedUserTypes
virtual bool getPatchedUserTypes(const Base::String &filename, std::map< QString, QString > &id2TypeMap)
Core::CoreDocument::getObjectById
virtual Core::DocObject * getObjectById(const DocObject::IdType &id) const
Returns the object with this id.
Core::CoreDocument::setGuidPolicy
void setGuidPolicy(const Base::GlobalId_Policy &policy)
Sets the default GUID policy. This determines what should be done if identical GUIDs are imported.
Core::CoreDocument::getImmutableObjectWithSameValues
Core::DocObject * getImmutableObjectWithSameValues(Base::Type t, const Core::PropertyContainer *pc) const
Returns the object that has the same values as 'pc'. Returns '0' if there is no such object.
Core::CoreDocument::undo
bool undo(int id=0)
Will UNDO one step, returns False if no undo was done (Undos == 0).
Core::CoreDocument::getOutBackLinks
Core::Link getOutBackLinks(Core::DocObject *docObj)
Core::CoreDocument::onRemoveBackLinks
void onRemoveBackLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::unordered_set< Core::DocObject * > &linkSet)
Core::CoreDocument::application_minorversion
Core::PropertyIndex application_minorversion
Definition: CoreDocument.h:310
Core::CoreDocument::setImportedIFCFile
void setImportedIFCFile(QString a)
Core::CoreDocument::signalBeforeChangeObject
boost::signals2::signal< void(const Core::DocObject &, const Core::Property &)> signalBeforeChangeObject
signal on visibility changed Object
Definition: CoreDocument.h:504
Core::AttachmentEntry
Definition: CoreDocument.h:80
Core::CoreDocument::architect
Core::PropertyText architect
Definition: CoreDocument.h:320
Core::DocChanges
Definition: CoreDocument.h:119
Core::CoreDocument::remove_GUID
void remove_GUID(const Base::GlobalId &guid, Core::DocObject *o)
Removes a guid without checking.
Core::CoreDocument::getPreviousVersionToSaveStr
static QString getPreviousVersionToSaveStr()
Returns application's version as string to be displayed in the menu for action Save as PREVIOUS versi...
Core::CoreDocument::add_GUID
void add_GUID(const Base::GlobalId &guid, Core::DocObject *o)
Adds a guid without checking.
PriceCalculationChanged
PriceCalculationChanged
Definition: CoreDocument.h:211
Core::CoreDocument::getRecomputeCount
size_t getRecomputeCount() const
get count of recomputes()
Core::CoreDocument::getSaveBlocksUntilFinished
bool getSaveBlocksUntilFinished() const
Returns whether saving will block until the whole save is finished and file is ready.
Core::CoreDocument::getImportedIFCFile
QString getImportedIFCFile()
Core::CoreDocument::restoreDocument
virtual int restoreDocument(Base::XMLReader &reader, Core::Attachments &attachments)
Restores the document. Returns the doc version of the restored document.
Core::DocumentState::DocumentState
DocumentState(const DocumentState &rhs)
Definition: CoreDocument.h:221
Core::CoreDocument::getInBackLinks
Core::Link getInBackLinks(Core::DocObject *docObj)
Core::CoreDocument::getAllLinksByProperties
Core::Link getAllLinksByProperties(const Core::DocObject *source) const
Core::DocumentTimeStampSentinel::mDoc
Core::CoreDocument * mDoc
Definition: CoreDocument.h:1000
RecomputeError
RecomputeError
Definition: CoreDocument.h:195
Core::CoreDocument::signalRecomputedErrorObjects
boost::signals2::signal< void(const std::map< Core::DocObject *, std::vector< std::string >> &)> signalRecomputedErrorObjects
Signals recomputed error DocObjects.
Definition: CoreDocument.h:514
Core::CoreDocument::setUndoLimit
void setUndoLimit(unsigned int UndoMemSize=0)
Set the Undo limit in Byte!
Core::CoreDocument::fileName
Base::String fileName
Definition: CoreDocument.h:322
Core::CoreDocument::createObject
T * createObject()
Definition: CoreDocument.h:538
Core::CoreDocument::signalRecomputed
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:510
Core::CoreDocument::signalDefectLinks
boost::signals2::signal< void(const std::vector< Core::LinkError > &)> signalDefectLinks
Signals defect links from object1 to object2.
Definition: CoreDocument.h:516
Core::CoreDocument::getDefaultVersionToSave
static void getDefaultVersionToSave(int &aMajorVersion, int &aMinorVersion)
Returns application's mainversion to be saved in the document.
Core::DocumentTimeStampSentinel::DocumentTimeStampSentinel
DocumentTimeStampSentinel(Core::CoreDocument *aDoc)
Definition: CoreDocument.h:990
Core::version
LX_CORE_EXPORT Version & version
Core::CoreDocument::getObjectByGlobalId
Core::DocObject * getObjectByGlobalId(const Base::GlobalId &guid) const
Returns the DocObject with this GUID.
SaveStart
SaveStart
Definition: CoreDocument.h:209
Core::DocObject::IdType
std::string IdType
Definition: DocObject.h:71
Core::CoreDocument::onAddLinks
void onAddLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::unordered_set< Core::DocObject * > &linkSet)
Core::DocumentState::LastNotifyTime
unsigned long LastNotifyTime
Definition: CoreDocument.h:232
Core::CoreDocument::documentGUID
Core::PropertyText documentGUID
Definition: CoreDocument.h:306
Core::CoreDocument::checkObjectLinks
bool checkObjectLinks(const std::vector< const Core::DocObject * > &objvec, std::vector< Core::LinkError > *errors=nullptr)
Checks the document for errors. Returns false if there is an error.
Core::CoreDocument::addImmutableObject_NoCheck
T * addImmutableObject_NoCheck(Core::PropertyBundle< T > *po)
Definition: CoreDocument.h:578
Core::CoreDocument::getObjectMap
const ObjectMap & getObjectMap() const
Returns the object map.
Core::CoreDocument::redo
bool redo(int id=0)
Will REDO one step, returns False if no redo was done (Redos == 0).
Core::CoreDocument::hasReferencesFrom
bool hasReferencesFrom(Core::DocObject *from) const
Core::PropertyIndex
Definition: PropertyInteger.h:129
Core::CoreDocument::commitTransaction
void commitTransaction()
Commit the Command transaction. Do nothing If there is no Command transaction open.
Core::CoreDocument::_clearRedos
void _clearRedos()
Base::GlobalAttachment
Definition: GlobalAttachment.h:8
Core::CoreDocument::saveAsFile
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.
Core::CoreDocument::signalRecomputeError
boost::signals2::signal< void()> signalRecomputeError
Signals a recompute error.
Definition: CoreDocument.h:512
Core::DocChanges::Document
Core::CoreDocument * Document
Definition: CoreDocument.h:179
Core::CoreDocument::getAvailableUndos
int getAvailableUndos(int id=0) const
Returns the number of stored Undos. If greater than 0 Undo will be effective.
Core::CoreDocument::CoreDocument
CoreDocument(const CoreDocument &rhs)
Core::Property
Definition: Property.h:72
Core::CoreDocument::recompute
virtual void recompute(std::function< void(DOCOBJECTS newObj, DOCOBJECTS updatedObj, DOCOBJECTS deletedObj, DOCOBJECTS_ERROR_MAP errorObj)> onRecomputedCB)
Core::CoreDocument::getLinksFromMe
virtual std::vector< const Core::DocObject * > getLinksFromMe(const Core::DocObject *o)
Returns all objects 'o' directly linked from 'o'.
Core::CoreDocument::getObjectsToSave
std::vector< Core::DocObject * > getObjectsToSave()
Returns all objects that will be saved in document. Basically interface for build_savemap().
Core::CoreDocument::onAddBackLinks
void onAddBackLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::unordered_set< Core::DocObject * > &linkSet)
Core::CoreDocument::copyObjectShallow
Type copyObjectShallow(Type o)
Creates a copy of 'o' and adds it to the document. Performs shallow copy.
Definition: CoreDocument.h:359
Core::CoreDocument::checkObjectLinks
bool checkObjectLinks(std::vector< Core::LinkError > *errors)
Core::CoreDocument::addInventorDirectory
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:727
Core::CoreDocument::onRemoveLinks
void onRemoveLinks(PropertyLinkBaseBase *p, Core::DocObject *from, const std::unordered_set< Core::DocObject * > &linkSet)
Core::CoreDocument::saveFile
bool saveFile(bool toExport=false, bool saveBackupCopy=false)
Saves the file.
Core::DocumentState::LastErroneousObjects
std::map< Core::DocObject *, std::vector< std::string > > LastErroneousObjects
Definition: CoreDocument.h:230
Core::PropertyContainer::Status::New
@ New
Core::CoreDocument::abortTransaction
void abortTransaction()
Abort the actually running transaction.
Core::CoreDocument::addPropertyLinkError
void addPropertyLinkError(const std::string &from, const std::string &to)
Base::Subject
Definition: Observer.h:9
Core::AttachmentEntry::FileName
Base::String FileName
Definition: CoreDocument.h:81
Core::DocObject::shallowCopy
virtual DocObject * shallowCopy(Core::CoreDocument *toDoc)
Core::CoreDocument::askAndSetNewFilename
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....
Core::CoreDocument::resolveLinkInDocument
void resolveLinkInDocument(Core::PropertyLinkBase *link)
After opening a document this method restores the links declared in the document header.
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
Core::CoreDocument::setChanged
virtual void setChanged(bool changed)
Core::RelGraph
Definition: RelGraph.h:26
Core::CoreDocument::recompute
virtual void recompute()
Recomputes the document.
Core::CoreDocument::setTransactionMode
void setTransactionMode(int iMode)
switch the transaction mode
Core::CoreDocument::getTransactionID
int getTransactionID(bool undo, unsigned pos=0) const
Return the undo/redo transaction ID starting from the back.
Core::DocumentTimeStampSentinel
Definition: CoreDocument.h:987
Core::CoreDocument::_checkTransaction
void _checkTransaction(Core::DocObject *pcDelObj, const Property *What, int line)
checks if a valid transaction is open
Core::CoreDocument::createTempDirectory
void createTempDirectory()
Creates the temporary directory.
Core::CoreDocument::restoreDirectory
virtual void restoreDirectory(const QString &)
Restores directory to temp.
Definition: CoreDocument.h:854
Core::CoreDocument::onRemoveBackLink
void onRemoveBackLink(PropertyLinkBaseBase *p, Core::DocObject *from, Core::DocObject *o)
Core::CoreDocument::getObjectsSorted
virtual std::vector< Core::DocObject * > getObjectsSorted() const
Returns all objects topologically sorted.
Core::CoreDocument::getDocumentState
const DocumentState & getDocumentState() const
Core::CoreDocument::subject_name
virtual const char * subject_name(void)
Definition: CoreDocument.h:747
PropertyBundle.h
Core::CoreDocument::createdBy
Core::PropertyText createdBy
Definition: CoreDocument.h:313
Core::CoreDocument::checkObjectLinks
bool checkObjectLinks(const std::vector< const Core::DocObject * > &objvec, const std::vector< const Core::DocObject * > &objToCheck, std::vector< Core::LinkError > *errors=nullptr)
Core::CoreDocument::getLinksToMe
virtual std::vector< const Core::DocObject * > getLinksToMe(const Core::DocObject *o)
Returns all objects that directly linked to 'o'.
Core::CoreDocument::getUniqueObjectIdFromInteger
Core::DocObject::IdType getUniqueObjectIdFromInteger(size_t input) const
Core::CoreDocument::lastModifiedDate
Core::PropertyText lastModifiedDate
Definition: CoreDocument.h:316
Core::CoreDocument::getBackLinksFromMe
virtual std::vector< const Core::DocObject * > getBackLinksFromMe(const Core::DocObject *o)
Returns all objects 'o' directly linked from 'o'.
TYPESYSTEM_HEADER
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
Core::CoreDocument::_guid_map
std::map< Base::GlobalId, Core::DocObject * > _guid_map
Definition: CoreDocument.h:920
Core::CoreDocument::_relGraphBackLink
RelGraph * _relGraphBackLink
Definition: CoreDocument.h:917
Core::CoreDocument::addFileToZip
bool addFileToZip(const Base::String &entryName, const Base::String &path)
Core::CoreDocument::lastModifiedBy
Core::PropertyText lastModifiedBy
Definition: CoreDocument.h:315
Core::CoreDocument::removeReferenceFrom
void removeReferenceFrom(Core::DocObject *from)
Core::CoreDocument::build_savemap
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.
Core::CoreDocument_Factory
Definition: CoreDocument.h:1021
Core::CoreDocument::removeObjectFinal
virtual void removeObjectFinal(Core::DocObject *e, bool deep=false)
Removes an object from the document.
Core::ObjectMap
std::unordered_map< DocObject::IdType, Core::DocObject * > ObjectMap
Definition: CoreDocument.h:47
Core::PropertyGUID
The PropertyGUID class saves and restores GUIDs. It also handles the management of GUIDs in the Docum...
Definition: PropertyGUID.h:21
Core::CoreDocument::_immutableObjectsMap
ObjectTypeMap _immutableObjectsMap
Definition: CoreDocument.h:910
Core::CoreDocument::setGuidPolicy
void setGuidPolicy(const Base::String &suffix, const Base::GlobalId_Policy &policy)
Sets the GUID policy for a file suffix. This determines what should be done if identical GUIDs are im...
Core::PropertyContainer::setNew
void setNew()
Sets the status to 'New'.
NewFile
NewFile
Definition: CoreDocument.h:197
Core::CoreDocument::getInner
virtual 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.
Core::CoreDocument::saveDocument
virtual void saveDocument(std::shared_ptr< Base::AbstractWriter > writer, int versionMajor2save, int versionMinor2save, bool showProgress)
Saves the document.
Core::CoreDocument::restoreProperty
void restoreProperty(Core::Property *property, const Base::String &name, Base::AbstractXMLReader &reader, Base::PersistenceVersion &version) override
Restores property from from reader in specified version.
Core::DocObject::setDocument
void setDocument(Core::CoreDocument *doc)
Sets the CoreDocument of this DocObject.
Core::CoreDocument::testStatusBits
bool testStatusBits(Status pos) const
return the status bits
Core::CoreDocument::_commitTransaction
void _commitTransaction(bool notify=false)
Internally called by App::Application to commit the Command transaction.
AfterSave
AfterSave
Definition: CoreDocument.h:200
Core::PropertyBundle
Definition: PropertyBundle.h:13
Base
Definition: AbstractXMLReader.h:5
Core::CoreDocument::renameTypeFromOlderVersions
virtual bool renameTypeFromOlderVersions(int, Base::String &)
Definition: CoreDocument.h:836
AddDirectoryPath
AddDirectoryPath
Definition: CoreDocument.h:202
Core::CoreDocument::getReferences
const std::set< Core::DocObject * > & getReferences() const
Core::CoreDocument::resetHasErrorObjectsInRecompute
void resetHasErrorObjectsInRecompute()
reset result of last recompute();
Core::CoreDocument::hasPendingTransaction
bool hasPendingTransaction() const
Check if a transaction is open.
Core::ExecObjectVector
std::vector< Core::ExecObject * > ExecObjectVector
Definition: CoreDocument.h:48
Import
Import
Definition: CoreDocument.h:208