|
||||
File indexing completed on 2025-01-18 10:03:23
0001 // Copyright (c) 2022 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _DE_Wrapper_HeaderFile 0015 #define _DE_Wrapper_HeaderFile 0016 0017 #include <DE_ConfigurationNode.hxx> 0018 #include <Message_ProgressRange.hxx> 0019 #include <NCollection_DataMap.hxx> 0020 #include <NCollection_IndexedDataMap.hxx> 0021 #include <Standard_Mutex.hxx> 0022 #include <TColStd_ListOfAsciiString.hxx> 0023 0024 class TopoDS_Shape; 0025 class XSControl_WorkSession; 0026 class TDocStd_Document; 0027 0028 typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode)> DE_ConfigurationVendorMap; 0029 typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap> DE_ConfigurationFormatMap; 0030 0031 //! The main class for working with CAD file exchange. 0032 //! Loads and Saves special CAD transfer property. 0033 //! Consolidates all supported Formats and Vendors. 0034 //! Automatically recognizes CAD format and uses the preferred existed Vendor. 0035 //! Note: 0036 //! If Vendor's format is not binded, the configuration loading doesn't affect on its property. 0037 //! 0038 //! Nodes are grouped by Vendor's name and Format's type. 0039 //! The Vendors may have the same supported CAD formats. 0040 //! Use a Vendor's priority for transfer operations. 0041 //! 0042 //! The algorithm for standalone transfer operation: 0043 //! 1) Work with global wrapper directly or make deep copy and work with it 0044 //! 2) Update the supported vendors and formats 0045 //! 2.1) Create and initialize specialized configuration node of the required format and Vendor. 0046 //! 2.2) Bind the created node to the internal map(::Bind) 0047 //! 3) Configure the transfer property by resource string or file (::Load) 0048 //! 3.1) Configuration can disable or enable some Vendors and formats 0049 //! 3.2) Configuration can change the priority of Vendors 0050 //! 4) Initiate the transfer process by calling "::Write" or "::Read" methods 0051 //! 5) Validate the transfer process output 0052 class DE_Wrapper : public Standard_Transient 0053 { 0054 DEFINE_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient) 0055 0056 public: 0057 0058 //! Initializes all field by default 0059 Standard_EXPORT DE_Wrapper(); 0060 0061 //! Copies values of all fields 0062 //! @param[in] theWrapper object to copy 0063 Standard_EXPORT DE_Wrapper(const Handle(DE_Wrapper)& theWrapper); 0064 0065 //! Gets global configuration singleton. 0066 //! If wrapper is not set, create it by default as base class object. 0067 //! @return point to global configuration 0068 Standard_EXPORT static const Handle(DE_Wrapper)& GlobalWrapper(); 0069 0070 //! Sets global configuration singleton 0071 //! @param[in] theWrapper object to set as global configuration 0072 Standard_EXPORT static void SetGlobalWrapper(const Handle(DE_Wrapper)& theWrapper); 0073 0074 Standard_EXPORT static Standard_Mutex& GlobalLoadMutex(); 0075 0076 public: 0077 0078 //! Reads a CAD file, according internal configuration 0079 //! @param[in] thePath path to the import CAD file 0080 //! @param[out] theDocument document to save result 0081 //! @param[in] theWS current work session 0082 //! @param theProgress[in] progress indicator 0083 //! @return true if Read operation has ended correctly 0084 Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath, 0085 const Handle(TDocStd_Document)& theDocument, 0086 Handle(XSControl_WorkSession)& theWS, 0087 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0088 0089 //! Writes a CAD file, according internal configuration 0090 //! @param[in] thePath path to the export CAD file 0091 //! @param[out] theDocument document to export 0092 //! @param[in] theWS current work session 0093 //! @param theProgress[in] progress indicator 0094 //! @return true if Write operation has ended correctly 0095 Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath, 0096 const Handle(TDocStd_Document)& theDocument, 0097 Handle(XSControl_WorkSession)& theWS, 0098 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0099 0100 //! Reads a CAD file, according internal configuration 0101 //! @param[in] thePath path to the import CAD file 0102 //! @param[out] theDocument document to save result 0103 //! @param theProgress[in] progress indicator 0104 //! @return true if Read operation has ended correctly 0105 Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath, 0106 const Handle(TDocStd_Document)& theDocument, 0107 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0108 0109 //! Writes a CAD file, according internal configuration 0110 //! @param[in] thePath path to the export CAD file 0111 //! @param[out] theDocument document to export 0112 //! @param theProgress[in] progress indicator 0113 //! @return true if Write operation has ended correctly 0114 Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath, 0115 const Handle(TDocStd_Document)& theDocument, 0116 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0117 0118 //! Reads a CAD file, according internal configuration 0119 //! @param[in] thePath path to the import CAD file 0120 //! @param[out] theShape shape to save result 0121 //! @param[in] theWS current work session 0122 //! @param theProgress[in] progress indicator 0123 //! @return true if Read operation has ended correctly 0124 Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath, 0125 TopoDS_Shape& theShape, 0126 Handle(XSControl_WorkSession)& theWS, 0127 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0128 0129 //! Writes a CAD file, according internal configuration 0130 //! @param[in] thePath path to the export CAD file 0131 //! @param[out] theShape shape to export 0132 //! @param[in] theWS current work session 0133 //! @param theProgress[in] progress indicator 0134 //! @return true if Write operation has ended correctly 0135 Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath, 0136 const TopoDS_Shape& theShape, 0137 Handle(XSControl_WorkSession)& theWS, 0138 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0139 0140 //! Reads a CAD file, according internal configuration 0141 //! @param[in] thePath path to the import CAD file 0142 //! @param[out] theShape shape to save result 0143 //! @param theProgress[in] progress indicator 0144 //! @return true if Read operation has ended correctly 0145 Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath, 0146 TopoDS_Shape& theShape, 0147 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0148 0149 //! Writes a CAD file, according internal configuration 0150 //! @param[in] thePath path to the export CAD file 0151 //! @param[out] theShape shape to export 0152 //! @param theProgress[in] progress indicator 0153 //! @return true if Write operation has ended correctly 0154 Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath, 0155 const TopoDS_Shape& theShape, 0156 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0157 0158 public: 0159 0160 //! Updates values according the resource file 0161 //! @param[in] theResource file path to resource or resource value 0162 //! @param[in] theIsRecursive flag to update all nodes 0163 //! @return true if theResource has loaded correctly 0164 Standard_EXPORT Standard_Boolean Load(const TCollection_AsciiString& theResource = "", 0165 const Standard_Boolean theIsRecursive = Standard_True); 0166 0167 //! Updates values according the resource 0168 //! @param[in] theResource input resource to use 0169 //! @param[in] theIsRecursive flag to update all nodes 0170 //! @return true if theResource has loaded correctly 0171 Standard_EXPORT Standard_Boolean Load(const Handle(DE_ConfigurationContext)& theResource, 0172 const Standard_Boolean theIsRecursive = Standard_True); 0173 0174 //! Writes configuration to the resource file 0175 //! @param[in] theResourcePath file path to resource 0176 //! @param[in] theIsRecursive flag to write values of all nodes 0177 //! @param[in] theFormats list of formats to save. If empty, saves all available 0178 //! @param[in] theVendors list of providers to save. If empty, saves all available 0179 //! @return true if the Configuration has saved correctly 0180 Standard_EXPORT Standard_Boolean Save(const TCollection_AsciiString& theResourcePath, 0181 const Standard_Boolean theIsRecursive = Standard_True, 0182 const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(), 0183 const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString()); 0184 0185 //! Writes configuration to the string 0186 //! @param[in] theIsRecursive flag to write values of all nodes 0187 //! @param[in] theFormats list of formats to save. If empty, saves all available 0188 //! @param[in] theVendors list of providers to save. If empty, saves all available 0189 //! @return result resource string 0190 Standard_EXPORT TCollection_AsciiString Save(const Standard_Boolean theIsRecursive = Standard_True, 0191 const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(), 0192 const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString()); 0193 0194 //! Creates new node copy and adds to the map 0195 //! @param[in] theNode input node to copy 0196 //! @return Standard_True if binded 0197 Standard_EXPORT Standard_Boolean Bind(const Handle(DE_ConfigurationNode)& theNode); 0198 0199 //! Removes node with the same type from the map 0200 //! @param[in] theNode input node to remove the same 0201 //! @return Standard_True if removed 0202 Standard_EXPORT Standard_Boolean UnBind(const Handle(DE_ConfigurationNode)& theNode); 0203 0204 //! Finds a node associated with input format and vendor 0205 //! @param[in] theFormat input node CAD format 0206 //! @param[in] theVendor input node vendor name 0207 //! @param[out] theNode output node 0208 //! @return Standard_True if the node is found 0209 Standard_EXPORT Standard_Boolean Find(const TCollection_AsciiString& theFormat, 0210 const TCollection_AsciiString& theVendor, 0211 Handle(DE_ConfigurationNode)& theNode) const; 0212 0213 //! Changes provider priority to one format if it exists 0214 //! @param[in] theFormat input node CAD format 0215 //! @param[in] theVendorPriority priority of work with vendors 0216 //! @param[in] theToDisable flag for disabling nodes that are not included in the priority 0217 Standard_EXPORT void ChangePriority(const TCollection_AsciiString& theFormat, 0218 const TColStd_ListOfAsciiString& theVendorPriority, 0219 const Standard_Boolean theToDisable = Standard_False); 0220 0221 //! Changes provider priority to all loaded nodes 0222 //! @param[in] theVendorPriority priority of work with vendors 0223 //! @param[in] theToDisable flag for disabling nodes that are not included in the priority 0224 Standard_EXPORT void ChangePriority(const TColStd_ListOfAsciiString& theVendorPriority, 0225 const Standard_Boolean theToDisable = Standard_False); 0226 0227 //! Find available provider from the configuration. 0228 //! If there are several providers, choose the one with the highest priority. 0229 //! @param[in] thePath path to the CAD file 0230 //! @param[in] theToImport flag to finds for import. Standard_True-import, Standard_False-export 0231 //! @param[out] theProvider created new provider 0232 //! @return Standard_True if provider found and created 0233 Standard_EXPORT virtual Standard_Boolean FindProvider(const TCollection_AsciiString& thePath, 0234 const Standard_Boolean theToImport, 0235 Handle(DE_Provider)& theProvider) const; 0236 0237 //! Updates all registered nodes, all changes will be saved in nodes 0238 //! @param[in] theToForceUpdate flag that turns on/of nodes, according to updated ability to import/export 0239 Standard_EXPORT void UpdateLoad(const Standard_Boolean theToForceUpdate = Standard_False) const; 0240 0241 //! Gets flag that keeps changes on configuration nodes which are being updated, false by default 0242 Standard_Boolean KeepUpdates() const { return myKeepUpdates; } 0243 0244 //! Sets flag that keeps changes on configuration nodes which are being updated, false by default 0245 void SetKeepUpdates(const Standard_Boolean theToKeepUpdates) { myKeepUpdates = theToKeepUpdates; } 0246 0247 //! Gets format map, contains vendor map with nodes 0248 //! @return internal map of formats 0249 Standard_EXPORT const DE_ConfigurationFormatMap& Nodes() const; 0250 0251 //! Copies values of all fields 0252 //! @return new object with the same field values 0253 Standard_EXPORT virtual Handle(DE_Wrapper) Copy() const; 0254 0255 protected: 0256 0257 //! Sorts the vendors according to the priority to work 0258 //! Formats omitted from the resource are not modified 0259 //! Vendors omitted from the format scope are disabled 0260 //! @param[in] theResource resource to get priority 0261 void sort(const Handle(DE_ConfigurationContext)& theResource); 0262 0263 public: 0264 0265 DE_ConfigurationNode::DE_SectionGlobal GlobalParameters; //!< Internal parameters for the all translators 0266 0267 private: 0268 0269 Standard_Boolean myKeepUpdates; //!< Flag that keeps changes on configuration nodes which are being updated 0270 DE_ConfigurationFormatMap myConfiguration; //!< Internal map of formats 0271 }; 0272 0273 #endif // _DE_Wrapper_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |