Salome HOME
Separate action "Find bottom" for context menu.
[modules/hydro.git] / src / HYDROData / HYDROData_Application.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <HYDROData_Application.h>
24
25 #include <TColStd_SequenceOfExtendedString.hxx>
26
27 IMPLEMENT_STANDARD_HANDLE(HYDROData_Application,TDocStd_Application)
28 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Application,TDocStd_Application)
29
30 static HYDROData_Application* TheApplication = new HYDROData_Application;
31
32 //=======================================================================
33 //function : getApplication
34 //purpose  : 
35 //=======================================================================
36 HYDROData_Application* HYDROData_Application::GetApplication() 
37 {
38   return TheApplication;
39 }
40
41 //=======================================================================
42 //function : GetDocument
43 //purpose  : 
44 //=======================================================================
45 bool HYDROData_Application::GetDocumentId(const Handle(HYDROData_Document)& theDocument,
46                                           int&                              theDocId) const
47 {
48   DataMapOfStudyIDDocument::Iterator aMapit( myDocuments );
49   for ( ; aMapit.More(); aMapit.Next() )
50   {
51     if ( aMapit.Value() != theDocument )
52       continue;
53
54     theDocId = aMapit.Key();
55     return true;
56   }
57
58   return false;
59 }
60
61 //=======================================================================
62 //function : GetDocument
63 //purpose  : 
64 //=======================================================================
65 Handle(HYDROData_Document) HYDROData_Application::GetDocument(int theStudyID) const
66 {
67   if (myDocuments.IsBound(theStudyID)) {
68     return myDocuments.Find(theStudyID);
69   }
70   // document not found => create the new one
71   return Handle(HYDROData_Document)();
72 }
73
74 //=======================================================================
75 //function : OCAFApp_Application
76 //purpose  : 
77 //=======================================================================
78 HYDROData_Application::HYDROData_Application ()
79 {
80   // store handle to the application to avoid nullification
81   static Handle(HYDROData_Application) TheKeepHandle;
82   TheKeepHandle = this;
83 }
84
85 //=======================================================================
86 //function : addDocument
87 //purpose  : 
88 //=======================================================================
89 void HYDROData_Application::AddDocument(int theStudyID, const Handle(HYDROData_Document)& theDocument)
90 {
91   myDocuments.Bind(theStudyID, theDocument);
92 }
93
94 //=======================================================================
95 //function : removeDocument
96 //purpose  : 
97 //=======================================================================
98 void HYDROData_Application::RemoveDocument(const Handle(HYDROData_Document)& theDocument)
99 {
100   DataMapOfStudyIDDocument::Iterator anIter(myDocuments);
101   for(; anIter.More(); anIter.Next())
102     if (anIter.Value() == theDocument) {
103       myDocuments.UnBind(anIter.Key());
104       break;
105     }
106 }
107
108 //=======================================================================
109 //function : Formats
110 //purpose  : 
111 //=======================================================================
112 void HYDROData_Application::Formats(TColStd_SequenceOfExtendedString& theFormats) 
113 {
114   theFormats.Append(TCollection_ExtendedString ("BinOcaf")); // standard binary schema
115 }
116
117 //=======================================================================
118 //function : ResourcesName
119 //purpose  : 
120 //=======================================================================
121 Standard_CString HYDROData_Application::ResourcesName()
122 {
123   return Standard_CString("Standard");
124 }