-------------------------------------------------------------------------- constructor --------------------------------------------------------------------------
| 954 | // constructor |
| 955 | //-------------------------------------------------------------------------- |
| 956 | Document::Document(const char* documentName) |
| 957 | : d(new DocumentP), myName(documentName) |
| 958 | { |
| 959 | // Remark: In a constructor we should never increment a Python object as we cannot be sure |
| 960 | // if the Python interpreter gets a reference of it. E.g. if we increment but Python don't |
| 961 | // get a reference then the object wouldn't get deleted in the destructor. |
| 962 | // So, we must increment only if the interpreter gets a reference. |
| 963 | // Remark: We force the document Python object to own the DocumentPy instance, thus we don't |
| 964 | // have to care about ref counting any more. |
| 965 | setAutoCreated(false); |
| 966 | Base::PyGILStateLocker lock; |
| 967 | d->DocumentPythonObject = Py::Object(new DocumentPy(this), true); |
| 968 | |
| 969 | #ifdef FC_LOGUPDATECHAIN |
| 970 | Console().log("+App::Document: %p\n", this); |
| 971 | #endif |
| 972 | std::string CreationDateString = Base::Tools::currentDateTimeString(); |
| 973 | std::string Author = GetApplication() |
| 974 | .GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document") |
| 975 | ->GetASCII("prefAuthor", ""); |
| 976 | std::string AuthorComp = |
| 977 | GetApplication() |
| 978 | .GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document") |
| 979 | ->GetASCII("prefCompany", ""); |
| 980 | ADD_PROPERTY_TYPE(Label, ("Unnamed"), 0, Prop_ReadOnly, "The name of the document"); |
| 981 | ADD_PROPERTY_TYPE(FileName, |
| 982 | (""), |
| 983 | 0, |
| 984 | PropertyType(Prop_Transient | Prop_ReadOnly), |
| 985 | "The path to the file where the document is saved to"); |
| 986 | ADD_PROPERTY_TYPE(CreatedBy, (Author.c_str()), 0, Prop_None, "The creator of the document"); |
| 987 | ADD_PROPERTY_TYPE(CreationDate, |
| 988 | (CreationDateString.c_str()), |
| 989 | 0, |
| 990 | Prop_ReadOnly, |
| 991 | "Date of creation"); |
| 992 | ADD_PROPERTY_TYPE(LastModifiedBy, (""), 0, Prop_None, 0); |
| 993 | ADD_PROPERTY_TYPE(LastModifiedDate, ("Unknown"), 0, Prop_ReadOnly, "Date of last modification"); |
| 994 | ADD_PROPERTY_TYPE(Company, |
| 995 | (AuthorComp.c_str()), |
| 996 | 0, |
| 997 | Prop_None, |
| 998 | "Additional tag to save the name of the company"); |
| 999 | ADD_PROPERTY_TYPE(UnitSystem, (""), 0, Prop_None, "Unit system to use in this project"); |
| 1000 | // Set up the possible enum values for the unit system |
| 1001 | |
| 1002 | UnitSystem.setEnums(Base::UnitsApi::getDescriptions()); |
| 1003 | // Get the preferences/General unit system as the default for a new document |
| 1004 | ParameterGrp::handle hGrpu = |
| 1005 | GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Units"); |
| 1006 | UnitSystem.setValue(hGrpu->GetInt("UserSchema", 0)); |
| 1007 | ADD_PROPERTY_TYPE(Comment, (""), 0, Prop_None, "Additional tag to save a comment"); |
| 1008 | ADD_PROPERTY_TYPE(Meta, (), 0, Prop_None, "Map with additional meta information"); |
| 1009 | ADD_PROPERTY_TYPE(Material, (), 0, Prop_None, "Map with material properties"); |
| 1010 | // create the uuid for the document |
| 1011 | Base::Uuid id; |
| 1012 | ADD_PROPERTY_TYPE(Id, (""), 0, Prop_None, "ID of the document"); |
| 1013 | ADD_PROPERTY_TYPE(Uid, (id), 0, Prop_ReadOnly, "UUID of the document"); |
nothing calls this directly
no test coverage detected