0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / CDM / CDM_Application.cxx
1 // Created on: 1997-10-22
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <CDM_Application.hxx>
19 #include <CDM_Document.hxx>
20 #include <CDM_MessageDriver.hxx>
21 #include <CDM_MetaData.hxx>
22 #include <CDM_NullMessageDriver.hxx>
23 #include <CDM_Reference.hxx>
24 #include <Resource_Manager.hxx>
25 #include <Standard_Type.hxx>
26 #include <TCollection_ExtendedString.hxx>
27
28 IMPLEMENT_STANDARD_RTTIEXT(CDM_Application,Standard_Transient)
29
30 //=======================================================================
31 //function : SetDocumentVersion
32 //purpose  : 
33 //=======================================================================
34 void CDM_Application::SetDocumentVersion
35                         (const Handle(CDM_Document)& aDocument,
36                          const Handle(CDM_MetaData)& aMetaData) const
37 {
38   aDocument->SetModifications(aMetaData->DocumentVersion(this));
39 }
40
41 //=======================================================================
42 //function : SetReferenceCounter
43 //purpose  : 
44 //=======================================================================
45
46 void CDM_Application::SetReferenceCounter
47                         (const Handle(CDM_Document)& aDocument,
48                          const Standard_Integer aReferenceCounter)
49 {
50   aDocument->SetReferenceCounter(aReferenceCounter);
51 }
52
53 //=======================================================================
54 //function : MessageDriver
55 //purpose  : 
56 //=======================================================================
57
58 Handle(CDM_MessageDriver) CDM_Application::MessageDriver()
59 {
60   static Handle(CDM_NullMessageDriver) theMessageDriver
61     =new CDM_NullMessageDriver;
62   return theMessageDriver;
63 }
64
65 //=======================================================================
66 //function : Write
67 //purpose  : 
68 //=======================================================================
69
70 void CDM_Application::Write(const Standard_ExtString aString)
71 {
72   MessageDriver()->Write(aString);
73 }
74
75 //=======================================================================
76 //function : BeginOfUpdate
77 //purpose  : 
78 //=======================================================================
79
80 void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& aDocument)
81 {
82   TCollection_ExtendedString updating("Updating:");
83   updating+=aDocument->Presentation();
84   Write(updating.ToExtString());
85 }
86
87 //=======================================================================
88 //function : EndOfUpdate
89 //purpose  : 
90 //=======================================================================
91
92 void CDM_Application::EndOfUpdate
93                         (const Handle(CDM_Document)&       aDocument,
94                          const Standard_Boolean            theStatus,
95                          const TCollection_ExtendedString& /*ErrorString*/)
96 {
97   TCollection_ExtendedString message;
98   if (theStatus)
99     message="Updated:";
100   else
101     message="Error during updating:";
102       
103   message+=aDocument->Presentation();
104   Write(message.ToExtString());
105 }
106
107 //=======================================================================
108 //function : Name
109 //purpose  : returns the application name
110 //=======================================================================
111
112 TCollection_ExtendedString CDM_Application::Name() const
113 {
114   // Default: empty
115   return TCollection_ExtendedString();
116 }
117
118 //=======================================================================
119 //function : Version
120 //purpose  : returns the application version
121 //=======================================================================
122
123 TCollection_AsciiString CDM_Application::Version() const
124 {
125   // Default: empty
126   return TCollection_AsciiString();
127 }