OpenLexocad  27.0
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>
10 #include <Core/PropertyLink.h>
11 #include <Core/PropertyText.h>
13 #include <Core/core_defines2.h>
14 
15 #include <QDateTime>
16 #include <boost/unordered_map.hpp>
17 #include <boost/unordered_set.hpp>
18 #include <map>
19 #include <set>
20 #include <vector>
21 
22 #define DIR_NAME_INTERNAL_CATALOG "__internalCatalog__"
23 #define DIR_NAME_WEBGL_GT "webgl"
24 #define DIR_NAME_GEOID "geoid"
25 #define FILE_NAME_CAMERA_ANIMATION "CameraAnimation.ivc"
26 
27 typedef std::vector<Core::DocObject*> DOCOBJECTS;
28 typedef std::map<Core::DocObject*, std::vector<std::string>> DOCOBJECTS_ERROR_MAP;
29 
30 namespace zipios
31 {
32 class ZipInputStream;
33 }
34 
35 namespace App
36 {
37 class ElementTool;
38 }
39 
40 namespace Core
41 {
42 class Variant;
43 class ObjectGraph;
44 class DocObject;
45 class ExecObject;
46 class PropertyLinkBase;
47 class CoreDocumentImpl;
48 class PropertyGUID;
50 
51 typedef std::vector<Core::DocObject*> ObjectVector;
52 typedef boost::unordered_set<Core::DocObject*> ObjectSet;
53 typedef boost::unordered_map<DocObject::IdType, Core::DocObject*> ObjectMap;
54 typedef std::vector<Core::ExecObject*> ExecObjectVector;
55 typedef boost::unordered_set<Core::ExecObject*> ExecObjectSet;
56 typedef boost::unordered_map<DocObject::IdType, Core::ExecObject*> ExecObjectMap;
57 typedef std::map<Base::Type, ObjectSet> ObjectTypeMap;
58 
60 {
63 };
64 typedef std::multimap<Base::String, Core::AttachmentEntry> Attachments;
65 
66 /*
67 Core::DocChanges
68 This class notifies the observers about a recompute of the document.
69 It can also be used to send messages to the Observers:
70 1. Example:
71 
72 Core::ExecObject* o = ...
73 
74 Core::DocChanges docChanges;
75 docChanges.Why = Core::DocChanges::MESSAGE_BY_NAME
76 docChanges.MsgName = "MsgObjectAdded";
77 docChanges.Value = Core::Variant(o);
78 notify(docChandes);
79 
80 2. Example:
81 
82 enum DocMessage
83 {
84  MSG_OBJECT_ADDED = 1,
85  ...
86 }
87 
88 Core::ExecObject* o = ...
89 
90 Core::DocChanges docChanges;
91 docChanges.Why = Core::DocChanges::MESSAGE_BY_ID
92 docChanges.MsgId = DocMessage::MSG_OBJECT_ADDED;
93 docChanges.Value = Core::Variant(o);
94 notify(docChandes);
95 */
96 
98 {
99 public:
100  DocChanges(Core::CoreDocument* doc) : Value(0), Document(doc) {}
101 
102  enum why
103  {
106  MESSAGE_BY_ID
107  } Why = RECOMPUTED;
108 
109  std::string MsgName = "";
110  int MsgId = -1;
113 
114  std::vector<Core::DocObject*> NewObjects;
115  std::vector<Core::DocObject*> UpdatedObjects;
116  std::vector<Core::DocObject*> DeletedObjects;
117  std::map<Core::DocObject*, std::vector<std::string>> ErroneousObjects; // Objects that caused an error in recompute with its error messages
118 
119 private:
120  DocChanges() : MsgId(0), Document(nullptr){};
121 };
122 
123 // All Lexocad Core message Ids are in the range 1000 - 1999
124 const int LEXOCAD_CORE_MSGID = 1000;
125 
126 enum CORE_EXPORT DocMessage
127 {
145  PostCheck = LEXOCAD_CORE_MSGID + 17
146 };
150 struct CORE_EXPORT DocumentState
151 {
152  // Copy constructor
153  DocumentState() = default;
154  DocumentState(const DocumentState& rhs)
155  {
156  PropertyErrors = rhs.PropertyErrors;
157  LastErroneousObjects = rhs.LastErroneousObjects;
158  LastRecomputeTime = rhs.LastRecomputeTime;
159  LastNotifyTime = rhs.LastNotifyTime;
160  }
162  std::vector<std::string> PropertyErrors;
163  std::map<Core::DocObject*, std::vector<std::string>> LastErroneousObjects;
164  unsigned long LastRecomputeTime;
165  unsigned long LastNotifyTime;
166 
167  void clear();
168 };
169 
171 {
172  PropertyLinkDesc(std::string sourceDocObjectID, std::string sourcePropertyName, Base::Type sourcePropertyTypeID, std::string targetDocObjectID)
173  : m_SourceDocObjectID(sourceDocObjectID)
174  , m_SourcePropertyName(sourcePropertyName)
175  , m_SourcePropertyTypeID(sourcePropertyTypeID)
176  , m_TargetDocObjectID(m_TargetDocObjectID)
177  {
178  }
179 
180  // Copy constructor
182  {
183  m_SourceDocObjectID = rhs.m_SourceDocObjectID;
184  m_SourcePropertyName = rhs.m_SourcePropertyName;
185  m_SourcePropertyTypeID = rhs.m_SourcePropertyTypeID;
186  m_TargetDocObjectID = rhs.m_TargetDocObjectID;
187  }
188 
189  std::string m_SourceDocObjectID;
190  std::string m_SourcePropertyName;
192 
193  std::string m_TargetDocObjectID;
194 };
195 
196 
197 class CORE_EXPORT CoreDocument : public Core::PropertyContainer, public Base::Subject<Core::DocChanges>
198 {
200  LX_NODE_HEADER();
201 
202 public:
203  friend class CoreApplication;
204  friend class CoreDocument_Factory;
205  friend class ::App::ElementTool;
206  friend class PropertyGUID;
208 
210  // //
211  // --------------------- BEGIN API --------------------- //
212  // //
213  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
214  // //
216 
232  Core::PropertyText projectNumber; // related to PieceList
234 
236 
238  int getDocumentVersion() const;
240  bool addObject(Core::DocObject* e);
242  void removeObject(Core::DocObject* e);
244  void removeObjectFinal(Core::DocObject* e, bool deep = false);
245 
248  Base::Type getCopyType() const;
250  void clearCopyType();
258  template <typename Type>
259  Type copyObjectShallow(Type o)
260  {
261  Core::DocObject* copy = o->shallowCopy(this);
262  assert(copy && "Document::copyObjectShallow could not copy object");
263  copy->setDocument(this);
264  copy->setNew();
265  copy->initDocObject();
266 
267  Type typedCopy = dynamic_cast<Type>(copy);
268  assert(typedCopy && "Document::copyObjectShallow could not cast object");
269 
270  return typedCopy;
271  }
272 
274  std::vector<Core::DocObject*> getObjects(bool includeDeletedObjects = false) const;
276  std::vector<Core::DocObject*> getObjectsSorted() const;
278  std::vector<Core::ExecObject*> getExecObjects(bool includeDeletedObjects = false) const;
280  Core::DocObject* createObjectFromTypeName(const char* typeName);
284  std::vector<Core::DocObject*> getObjectsByTypeName(const std::string& typeName) const;
286  virtual void recompute();
289  virtual void recompute(
290  std::function<void(DOCOBJECTS newObj, DOCOBJECTS updatedObj, DOCOBJECTS deletedObj, DOCOBJECTS_ERROR_MAP errorObj)> onRecomputedCB);
292  virtual bool saveAs(const Base::String& filename);
296  bool isActive() const;
298  virtual bool isChanged();
301 
302  std::string getDocXMLAsString();
303 
304 #ifndef LXAPI
305  virtual Core::DocObject* getObjectById(const DocObject::IdType& id) const;
309 
310 
311 
313  // //
314  // ---------------------- END API ---------------------- //
315  // //
317 
320  template <typename T>
322  {
323  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
324  if (o)
325  return static_cast<T*>(o);
326 
327  return nullptr;
328  }
329 
332  template <typename T>
334  {
335  // Check if it really is immutable
336  if (T::isMutableStatic())
337  return nullptr;
338 
339  // Check if an immutable object with these values already exists
340  Core::DocObject* check = getImmutableObjectWithSameValues(T::getClassTypeId(), po);
341  if (check)
342  return static_cast<T*>(check);
343 
344  // If it doesn't exist make a new one and initialize it with the
345  // property values from the Core::PropertyBundle.
346  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
347  if (o)
348  {
349  o->_setPropertyValues(po, /* bool isInit = */ true);
350  o->setStatus(Core::PropertyContainer::Status::New); // At initialization the status needs to stay NEW
352  return static_cast<T*>(o);
353  }
354 
355  return nullptr;
356  }
357 
360  template <typename T>
362  {
363  // Check if it really is immutable
364  if (T::isMutableStatic())
365  return nullptr;
366 
367  // If it doesn't exist make a new one and initialize it with the
368  // property values from the Core::PropertyBundle.
369  Core::DocObject* o = createObjectFromType(T::getClassTypeId());
370  if (o)
371  {
372  o->_setPropertyValues(po, /* bool isInit = */ true);
373  o->setStatus(Core::PropertyContainer::Status::New); // At initialization the status needs to stay NEW
375  return static_cast<T*>(o);
376  }
377 
378  return nullptr;
379  }
380 
382  template <typename T>
383  std::vector<T*> getObjectsByType() const
384  {
385  // get all resulting types including derived classes
386  Base::Type t = T::getClassTypeId();
387  std::set<Base::Type> typeset;
388  t.getAllChildren(typeset);
389  typeset.insert(t);
390 
391  std::vector<T*> returnObjs{};
392  for (const auto& type : typeset)
393  {
394  auto type2objects = getTypeMap().find(type);
395  if (type2objects == getTypeMap().end()) // do we know this type?
396  continue;
397 
398  const auto& docObjects = type2objects->second;
399  for (const auto& obj : docObjects) // get un-deleted objects of given type
400  {
401  if (!obj->isDeleted())
402  returnObjs.push_back(static_cast<T*>(obj));
403  }
404  }
405 
406  return returnObjs;
407  }
408 
410  template <typename T>
411  void getObjectsByType(std::vector<T*>& objs) const
412  {
413  const auto& objectMap = getObjectMap();
414  for (const auto& it : objectMap) //#todo go only over seconds
415  {
416  if (!it.second->isDeleted() && it.second->isDerivedFrom<T>()) // #todo why test for type when the type is in first?
417  objs.push_back((T*)it.second);
418  }
419  }
420 
422  void getObjectsFromTypeMap(Base::Type t, std::vector<Core::DocObject*>& ret) const;
423  const ObjectTypeMap& getTypeMap() const;
424 
425  void addPropertyLinkError(const std::string& from, const std::string& to);
426  const DocumentState& getDocumentState() const;
428  bool checkObjectLinks(std::vector<Core::DocObject*>& objvec,
429  std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>* errors = nullptr);
430  bool checkObjectLinks(std::vector<Core::DocObject*>& objvec,
431  std::vector<Core::DocObject*>& objToCheck,
432  std::vector<std::pair<const Core::DocObject*, const Core::DocObject*>>* errors = nullptr);
433 
434 
436  std::vector<const Core::DocObject*> getInner(const Core::DocObject* me, std::function<bool(const Core::DocObject*)>* allowToAddObject = 0);
438  std::vector<const Core::DocObject*> getOuter(const Core::DocObject* me);
439 
440  std::vector<const Core::DocObject*> getLinksByProperties(const Core::DocObject* o);
441  std::vector<PropertyLinkDesc> getLinkDescByProperties(const Core::DocObject* o);
442  void getBackLinksByProperties(const Core::DocObject* source, std::vector<const Core::DocObject*>& links);
443 
444  void removeLinkInProperties(const Core::DocObject* source, Core::DocObject* link);
446 
448  std::string dumpGraph(void);
449  std::vector<std::string> check_graph();
451  std::vector<const Core::DocObject*> getLinksToMe(const Core::DocObject* o);
453  std::vector<const Core::DocObject*> getBackLinksToMe(const Core::DocObject* o);
455  std::vector<const Core::DocObject*> getLinksFromMe(const Core::DocObject* o);
457  std::vector<const Core::DocObject*> getBackLinksFromMe(const Core::DocObject* o);
458 
460  virtual bool maybeSave() { return true; }
462  std::vector<Core::DocObject*> getObjectsToSave();
464  bool saveFile(bool toExport = false, bool saveBackupCopy = false);
467  bool toExport = false,
468  bool saveBackupCopy = false,
469  const Base::String& initialDir = Base::String());
471  bool saveAsFileVersion(int version,
473  bool toExport = false,
474  bool saveBackupCopy = false,
475  const Base::String& initialDir = Base::String(),
476  bool dontRename = false);
478  void setOnSaveChangeToDefaultUser(bool onoff);
480  bool getOnSaveChangeToDefaultUser() const;
482  bool askAndSetNewFilename(QString& newFilename, const Base::String& initialDir = Base::String());
484  void setSaveBlocksUntilFinished(bool onoff);
486  bool getSaveBlocksUntilFinished() const;
487 
489  virtual void addInventorDirectory(const Base::String&) {}
493  virtual void deleteObject(Core::DocObject* o);
495  void setGuidPolicy(const Base::GlobalId_Policy& policy);
497  void setGuidPolicy(const Base::String& suffix, const Base::GlobalId_Policy& policy);
501  bool getGuidPolicy(const Base::String& suffix, Base::GlobalId_Policy& policy) const;
502 
503  void addReferenceFrom(Core::DocObject* from);
505  bool hasReferencesFrom(Core::DocObject* from) const;
506  const std::set<Core::DocObject*>& getReferences() const;
508  void setFullFileName(const Base::String& fullfilename);
509 
510  virtual const char* subject_name(void) { return "CoreDocument"; };
511 
512  virtual bool restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
513 
514  bool addFileToZip(const Base::String& entryName, const Base::String& path);
515  bool restoreFileFromZip(const Base::String& entryName, const Base::String& targetpath, bool binaryMode);
516 
518  void forceBackupOnNextSave();
519 
524 
526  size_t getRecomputeCount() const;
527 
528  virtual void setChanged(bool changed);
529 
530  bool getImmutableObjects(Base::Type t, ObjectSet& set) const;
532 
533  void setImportedIFCFile(QString a);
534  QString getImportedIFCFile();
535 
536 #endif
537 
538 protected:
539  CoreDocument();
540  // Copy constructor
541  CoreDocument(const CoreDocument& rhs);
542 
543  virtual ~CoreDocument();
544 
545 
553  virtual Core::DocObject* restoreObject(const std::string& typeName, const std::string& typeHierarchy, const std::string& id);
554  void restoreProperty(Core::Property* property,
555  const Base::String& name,
556  Base::AbstractXMLReader& reader,
559  virtual void saveDocument(std::shared_ptr<Base::AbstractWriter> writer, int version2save, bool showProgress);
561  virtual int restoreDocument(Base::XMLReader& reader, Core::Attachments& attachments);
563  virtual std::vector<Core::DocObject*> build_savemap();
565  void addNewObjectsToGraph();
570  virtual bool renameTypeFromOlderVersions(int, Base::String&) { return false; }
572  virtual void checkBeforeObjectRestoring(int, int) {}
578  virtual void onFileOpened() {}
581  virtual bool convertFromOlderVersions(int docVersion, int appVersion);
582 
583  virtual bool getPatchedUserTypes(Base::String filename, std::map<QString, QString>& id2TypeMap);
584 
586  virtual void cleanUndoStack() {}
588  virtual void storeDirectory(const QString&, Base::AbstractWriter&) {}
590  virtual void restoreDirectory(const QString&) {}
591 
593  virtual void initDocument(bool) {}
595  const ObjectMap& getObjectMap() const;
597  void createTempDirectory();
599  void cleanTempDirectory();
601  bool maybe_add_GUID(const Base::GlobalId& guid, Core::DocObject* o);
603  void add_GUID(const Base::GlobalId& guid, Core::DocObject* o);
605  void remove_GUID(const Base::GlobalId& guid, Core::DocObject* o);
607  void waitForSaveIsFinished();
608 
610  bool isCatalogFile() const;
611 
612  bool createBackupFile(const Base::String& path, bool savePath);
613  bool createBackupFileAfterOpeningDoc(const Base::String& path, bool savePath);
614 
615  // Internal, do not use
616  void __setEnableTimeStamps__(bool aOnOff);
617  bool __getEnableTimeStamps__() const;
618 
620  // Map of all objects
622  // For performance reasons we have a vector of all objects
624  // Map of all executable objects
626  // Map of all non-executable objects
628  // Map of immutable objects < Type, set of immutable objects >
630  // Map of all objects
632  // The object graph
634  // Set of objects per type
636 
637  std::set<Core::DocObject*> _references;
638  std::map<Base::GlobalId, Core::DocObject*> _guid_map;
639  std::map<long, Core::DocObject*> _ifcId_map;
640 
643  size_t _recomputeCnt = 0;
644  bool mSolvingEnabled = true;
646 private:
648  bool openFile(const Base::String& filename, bool savePath = true);
649 
651  Core::DocObject* clone_and_replace_Object(const char* typeName, Core::DocObject* base);
653  bool close(bool dontNotify = false);
654  void _cleanTempDirectory_Helper(const Base::String& dir);
655  void _copyFilesInTemp(Core::DocObject* original, Core::DocObject* copy);
656  bool _saveFile(int version, bool toExport, bool saveBackupCopy);
657  void _initNewObject(Core::DocObject* o, const DocObject::IdType& id = "");
658  void _saveDocFiles(std::shared_ptr<Base::AbstractWriter> writer);
659  bool _docWrite(std::shared_ptr<Base::AbstractWriter> mainwriter,
660  QString tmpfile,
661  QString fileName,
662  bool inThread,
663  bool toExport,
664  bool saveBackupCopy,
665  std::vector<Base::String> tempFilesToDelete);
666  void cleanOldTempDirectories();
667  // never make it public, copyShare param must be controlled ONLY from CoreDocument
668  Core::DocObject* copyObjectInternal(Core::DocObject* o, DocObjectMap& copyMap, bool standardCopyOfShared = false, bool aCreateNewType = false);
669 
671  void notifyDocChange(DocChanges::why aWhy, DocMessage aMsgId, const Base::String& aValue);
672 
674  bool restoreDocuments(int& docVersion, int& appVersion);
675 
676  Base::Type m_copyType = Base::Type::badType();
677  QString m_importedIFCFile;
678  QDateTime _lastBackupFileTime;
679  int _backupFilesCounter;
680  int _numOfExistBackupFiles;
681  bool _onSaveChangeToDefaultUser = false;
682  bool _saveBlocksUntilFinished = false;
683  Base::String _tmpdirectory;
684 
685  // Map for <file suffix / GUID policy>
686  std::map<Base::String, Base::GlobalId_Policy> _guidPolicyMap;
687 
688  std::map<Base::String, Base::String> _additionalFiles;
689 
690  CoreDocumentImpl* _pimpl{};
691 };
692 
693 /* @brief This class takes care that time stamping can be securely
694  * deactivated as long as an instance of this class stays in scope.
695  * It restores the old state when the destructor is called.
696  */
698 {
699 public:
700  DocumentTimeStampSentinel() = delete;
702  {
703  mOldEnableTimeStamps = mDoc->__getEnableTimeStamps__();
704  mDoc->__setEnableTimeStamps__(false);
705  }
706 
708  {
709  mDoc->__setEnableTimeStamps__(mOldEnableTimeStamps);
710  }
712  bool mOldEnableTimeStamps = true;
713 };
714 
716 {
717 public:
718  friend class CoreApplication;
721 
722  static std::map<std::string, Core::DocumentFactory*> registry;
723 
724 protected:
725  virtual Core::CoreDocument* createByFactory() = 0;
726  static Core::CoreDocument* create(const std::string& type);
727 };
728 
729 
730 class CoreDocument_Factory : public Core::DocumentFactory
731 {
732  virtual Core::CoreDocument* createByFactory()
733  {
735  return doc;
736  }
737 };
738 
739 } // namespace Core
740 
741 
742 
743 #define DECLARE_DOCUMENT_FACTORY(_factoryName_, _class_) \
744  class _factoryName_ : public Core::DocumentFactory \
745  { \
746  private: \
747  virtual Core::CoreDocument* createByFactory() \
748  { \
749  Core::CoreDocument* doc = new _class_; \
750  return doc; \
751  } \
752  };
753 
754 #define REGISTER_DOCUMENT_FACTORY(_factoryName_, _class_) Core::DocumentFactory::registry[#_class_] = (Core::DocumentFactory*)new _factoryName_();
Core::PropertyText compatibleInfo
Definition: CoreDocument.h:219
Definition: CoreApplication.h:94
bool saveAsFileVersion(int version, 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 mSolvingEnabled
Definition: CoreDocument.h:644
std::string getDocXMLAsString()
bool checkObjectLinks(std::vector< 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.
#define CORE_EXPORT
Definition: core_defines2.h:10
Core::PropertyText createdBy
Definition: CoreDocument.h:226
void removeObject(Core::DocObject *e)
Removes an object from the document.
unsigned long LastNotifyTime
Definition: CoreDocument.h:165
std::vector< Core::ExecObject * > getExecObjects(bool includeDeletedObjects=false) const
Returns all executable objects.
CoreDocument()
virtual void checkBeforeObjectRestoring(int, int)
Is called before restoring objects of a document.
Definition: CoreDocument.h:572
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:619
Core::PropertyText projectNumber
Definition: CoreDocument.h:232
std::map< Core::DocObject *, std::vector< std::string > > DOCOBJECTS_ERROR_MAP
Definition: CoreDocument.h:28
std::map< Base::GlobalId, Core::DocObject * > _guid_map
Definition: CoreDocument.h:638
bool restoreFileFromZip(const Base::String &entryName, const Base::String &targetpath, bool binaryMode)
std::vector< Core::DocObject * > ObjectVector
Definition: core_gt.h:56
std::map< long, Core::DocObject * > _ifcId_map
Definition: CoreDocument.h:639
virtual void initDocument(bool)
Initialize document.. Can be overwritten to do some custom initialization.
Definition: CoreDocument.h:593
T * addImmutableObject(Core::PropertyBundle< T > *po)
Definition: CoreDocument.h:333
FileOpened
Definition: CoreDocument.h:131
void forceBackupOnNextSave()
Modifies the _lastBackupFileTime to force backup when the document is saved next time.
Closing
Definition: CoreDocument.h:143
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.
size_t getRecomputeCount() const
get count of recomputes()
T * addImmutableObject_NoCheck(Core::PropertyBundle< T > *po)
Definition: CoreDocument.h:361
std::string dumpGraph(void)
Returns a string representation of the graph.
AfterSave
Definition: CoreDocument.h:133
AddDirectoryPath
Definition: CoreDocument.h:135
Core::PropertyText name
Definition: CoreDocument.h:217
bool _needRestoreBeforeRecompute
Definition: CoreDocument.h:642
Definition: PropertyContainer.h:101
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:64
Core::PropertyIndex application_mainversion
Definition: CoreDocument.h:223
std::vector< Core::DocObject * > NewObjects
Definition: CoreDocument.h:114
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:224
GUID_Conflict
Definition: CoreDocument.h:139
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.
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::PropertyText name
Definition: CoreDocument.h:143
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:489
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.
PriceCalculationChanged
Definition: CoreDocument.h:144
Core::CoreDocument * Document
Definition: CoreDocument.h:112
DocumentFactory()
Definition: CoreDocument.h:719
The PropertyGUID class saves and restores GUIDs. It also handles the management of GUIDs in the Docum...
Definition: PropertyGUID.h:25
const ObjectTypeMap & getTypeMap() const
Base::String FileName
Definition: CoreDocument.h:61
std::vector< const Core::DocObject * > getLinksByProperties(const Core::DocObject *o)
DocumentTimeStampSentinel(Core::CoreDocument *aDoc)
Definition: CoreDocument.h:701
Definition: PropertyText.h:12
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:29
Definition: Persistance.h:20
void waitForSaveIsFinished()
Saving runs in Threads, wait for finish.
virtual void deleteObject(Core::DocObject *o)
Physically deletes an object without informing the object maps.
std::vector< std::string > PropertyErrors
Definition: CoreDocument.h:162
Definition: CoreDocument.h:150
virtual bool saveAs(const Base::String &filename)
Saves the document under this name.
LX_CORE_EXPORT Version & version
virtual Core::DocObject * addImmutableObjectMaterial(Core::PropertyContainer *pc)
why
Definition: CoreDocument.h:102
Definition: Type.h:56
void setImportedIFCFile(QString a)
void getObjectsFromTypeMap(Base::Type t, std::vector< Core::DocObject * > &ret) const
Returns all objects of type 'T'.
Definition: CoreDocument.h:197
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:115
Definition: Variant.h:90
void cleanTempDirectory()
Cleans the temporary directory.
std::vector< Core::DocObject * > DOCOBJECTS
Definition: CoreDocument.h:27
RecomputeFinished
Definition: CoreDocument.h:136
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'.
ObjectMap _non_exec_objects_map
Definition: CoreDocument.h:627
void setSaveBlocksUntilFinished(bool onoff)
If true, saving will block until the whole save is finished and file is ready.
Core::PropertyText documentVersion
Definition: CoreDocument.h:218
bool getImmutableObjects(Base::Type t, ObjectSet &set) const
virtual void createGroundPlate_deprecated()
To overwrite. Deprecated, do not use.
Definition: CoreDocument.h:491
virtual ~CoreDocument()
virtual std::vector< Core::DocObject * > build_savemap()
Build a map of the objects that get saved. Objects that are marked for delete get removed.
boost::unordered_map< DocObject::IdType, Core::ExecObject * > ExecObjectMap
Definition: CoreDocument.h:56
const ObjectMap & getObjectMap() const
Returns the object map.
virtual void restoreDirectory(const QString &)
Restores directory to temp.
Definition: CoreDocument.h:590
unsigned long LastRecomputeTime
Definition: CoreDocument.h:164
ObjectTypeMap _immutableObjectsMap
Definition: CoreDocument.h:629
Core::CoreDocument * mDoc
Definition: CoreDocument.h:711
void restoreProperty(Core::Property *property, const Base::String &name, Base::AbstractXMLReader &reader, Base::PersistanceVersion &version) override
std::vector< std::string > check_graph()
Core::PropertyIndex documentMaxID
Definition: CoreDocument.h:222
const DocumentState & getDocumentState() const
Core::PropertyText filename
Definition: CoreDocument.h:225
~DocumentTimeStampSentinel()
Definition: CoreDocument.h:707
Definition: AbstractXMLReader.h:10
ObjectMap _all_objects_map
Definition: CoreDocument.h:621
virtual void cleanUndoStack()
Cleans the undo stack. Must be overwritten.
Definition: CoreDocument.h:586
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:221
void getBackLinksByProperties(const Core::DocObject *source, std::vector< const Core::DocObject * > &links)
Core::PropertyText company
Definition: CoreDocument.h:230
Definition: GlobalId.h:32
ErrorCanNotOpenFile
Definition: CoreDocument.h:137
DocChanges(Core::CoreDocument *doc)
Definition: CoreDocument.h:100
virtual bool maybeSave()
Can be overwritten to check if the undo stack is clean etc.
Definition: CoreDocument.h:460
Core::Variant Value
Definition: CoreDocument.h:111
std::vector< const Core::DocObject * > getBackLinksFromMe(const Core::DocObject *o)
Returns all objects 'o' directly linked from 'o'.
std::map< Core::DocObject *, std::vector< std::string > > LastErroneousObjects
Definition: CoreDocument.h:163
std::map< Base::Type, ObjectSet > ObjectTypeMap
Definition: CoreDocument.h:57
virtual void onFileOpened()
Is called when the file was opened, but before the message FileOpened gets emitted....
Definition: CoreDocument.h:578
QString getImportedIFCFile()
Core::PropertyText architect
Definition: CoreDocument.h:233
virtual Core::DocObject * getObjectById(const DocObject::IdType &id) const
Returns the object with this id.
Definition: Observer.h:18
Definition: CoreDocument.h:97
SaveStart
Definition: CoreDocument.h:142
Core::PropertyText filename
Definition: CoreDocument.h:151
Definition: Base.h:19
BeforeSave
Definition: CoreDocument.h:132
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:576
bool hasErrorObjectsInRecompute()
get result of last recompute
std::vector< Core::DocObject * > DeletedObjects
Definition: CoreDocument.h:116
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:588
T * createObject()
Definition: CoreDocument.h:321
Definition: CoreDocument.h:697
Definition: GlobalId_Policy.h:8
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:643
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:637
bool createBackupFile(const Base::String &path, bool savePath)
Definition: CoreDocument.h:730
void createTempDirectory()
Creates the temporary directory.
const int LEXOCAD_CORE_MSGID
Definition: CoreDocument.h:124
Base::String getTmpDirectory()
Returns the temporary directory.
boost::unordered_map< DocObject::IdType, Core::DocObject * > ObjectMap
Definition: CoreDocument.h:53
virtual DocObject * shallowCopy(Core::CoreDocument *toDoc)
Copies the object to the specified document. Provide only shallow copy. Do not copy objects on link.
std::vector< const Core::DocObject * > getOuter(const Core::DocObject *me)
Get ALL Links from me, also indirect.
Definition: GlobalAttachment.h:11
friend class DocumentTimeStampSentinel
Definition: CoreDocument.h:133
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:141
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:27
~DocumentFactory()
Definition: CoreDocument.h:720
ObjectMap _solvable_objects_map
Definition: CoreDocument.h:631
virtual bool renameTypeFromOlderVersions(int, Base::String &)
Definition: CoreDocument.h:570
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:46
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:383
std::map< Core::DocObject *, std::vector< std::string > > ErroneousObjects
Definition: CoreDocument.h:117
const std::set< Core::DocObject * > & getReferences() const
boost::unordered_set< Core::ExecObject * > ExecObjectSet
Definition: CoreDocument.h:55
Core::DocObject * createObjectFromType(Base::Type type)
Creates an object from type and adds it to the document.
bool isCatalogFile() const
Returns true if this document's file is part of catalog.
Core::PropertyText documentGUID
Definition: CoreDocument.h:220
Definition: CoreDocument.h:59
Export
Definition: CoreDocument.h:140
Core::PropertyText comment
Definition: CoreDocument.h:231
Core::DocObject * copySharedObject(Core::DocObject *o, DocObjectMap &copyMap)
Copy shared object. This is violating of the share, but in some cases this is useful....
std::vector< PropertyLinkDesc > getLinkDescByProperties(const Core::DocObject *o)
bool hasReferencesFrom(Core::DocObject *from) const
ObjectVector _all_objects_vector
Definition: CoreDocument.h:623
Type copyObjectShallow(Type o)
Creates a copy of 'o' and adds it to the document. Performs shallow copy.
Definition: CoreDocument.h:259
bool _hasErrorObjectsInRecompute
Definition: CoreDocument.h:641
NewFile
Definition: CoreDocument.h:130
virtual bool getPatchedUserTypes(Base::String filename, std::map< QString, QString > &id2TypeMap)
Definition: CoreDocument.h:105
Base::String fileName
Definition: CoreDocument.h:235
Core::DocObject::IdType getUniqueObjectId() const
Returns the next available unique id.
void setGuidPolicy(const Base::GlobalId_Policy &policy)
Sets the default GUID policy. This determines what should be done if identical GUIDs are imported.
virtual void saveDocument(std::shared_ptr< Base::AbstractWriter > writer, int version2save, bool showProgress)
Saves the document.
bool isActive() const
Returns 'true' if the Document is the active Document. Otherwise returns 'false'.
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:103
bool saveFile(bool toExport=false, bool saveBackupCopy=false)
Saves the file.
void addToDocumentMaps(Core::DocObject *o)
Adds the object to all relevant maps.
Definition: Property.h:81
virtual void initDocObject()
Base::String FeatName
Definition: CoreDocument.h:62
virtual const char * subject_name(void)
Definition: CoreDocument.h:510
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)
ObjectGraph * _graph
Definition: CoreDocument.h:633
std::vector< Core::DocObject * > getObjects(bool includeDeletedObjects=false) const
Returns all objects in the document.
void setDocument(Core::CoreDocument *doc)
Sets the CoreDocument of this DocObject.
CleanAll
Definition: CoreDocument.h:134
Base::GlobalId_Policy getGuidPolicy() const
Returns the default GUID policy.
friend class CoreApplication
Definition: CoreDocument.h:129
Definition: PropertyInteger.h:140
static std::map< std::string, Core::DocumentFactory * > registry
Definition: CoreDocument.h:722
std::vector< const Core::DocObject * > getLinksToMe(const Core::DocObject *o)
Returns all objects that directly linked to 'o'.
RecomputeError
Definition: CoreDocument.h:128
Base::String fileName
Definition: CoreDocument.h:161
Base::Type getCopyType() const
Definition: CoreDocument.h:104
Rename
Definition: CoreDocument.h:129
void setFullFileName(const Base::String &fullfilename)
Sets the full file name including the path.
std::map< Core::DocObject *, Core::DocObject * > DocObjectMap
Definition: DocObject.h:11
Core::DocObject * getObjectByGlobalId(const Base::GlobalId &guid) const
Returns the DocObject with this GUID.
virtual void checkAndConfigureOpenedDocument()
Is called when opening a document. Can be overwritten to do some custom check routines.
Definition: CoreDocument.h:574
Definition: CoreDocument.h:715
TYPESYSTEM_HEADER()
Definition: GraphBuilder.h:47
void removeReferenceFrom(Core::DocObject *from)
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:229
auto onRecomputedCB
Definition: CoreDocument.h:213
std::vector< Core::ExecObject * > ExecObjectVector
Definition: CoreDocument.h:54
virtual bool restoreGlobalAttachment(Base::GlobalAttachment *gAtta, std::istream *, uint64_t streamsize, const Base::String &entryName)
ExecObjectMap _exec_objects_map
Definition: CoreDocument.h:625
Core::PropertyText lastModifiedBy
Definition: CoreDocument.h:228
Definition: DocObject.h:28
void setOnSaveChangeToDefaultUser(bool onoff)
If true: Change to default user on next change. Usually from IFC User to Lexocad User.
boost::unordered_set< Core::DocObject * > ObjectSet
Definition: core_gt.h:58
Core::PropertyText creationDate
Definition: CoreDocument.h:227
friend class PropertyGUID
Definition: CoreDocument.h:132
ChangeToDefaultUser
Definition: CoreDocument.h:138
ObjectTypeMap _typeObjects
Definition: CoreDocument.h:635
void removeLinkInProperties(const Core::DocObject *source, Core::DocObject *link)