0030480: Visualization - Clear of Select3D_SensitiveGroup does not update internal...
[occt.git] / src / StepSelect / StepSelect_StepType.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_InterfaceError.hxx>
16 #include <Interface_InterfaceModel.hxx>
17 #include <Interface_Macros.hxx>
18 #include <Interface_Protocol.hxx>
19 #include <Standard_Transient.hxx>
20 #include <Standard_Type.hxx>
21 #include <StepData_Protocol.hxx>
22 #include <StepData_ReadWriteModule.hxx>
23 #include <StepData_UndefinedEntity.hxx>
24 #include <StepSelect_StepType.hxx>
25 #include <TColStd_SequenceOfAsciiString.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(StepSelect_StepType,IFSelect_Signature)
28
29 static TCollection_AsciiString lastvalue;
30
31
32     StepSelect_StepType::StepSelect_StepType ()
33     : IFSelect_Signature ("Step Type")      {  }
34
35     void  StepSelect_StepType::SetProtocol
36   (const Handle(Interface_Protocol)& proto)
37 {
38   DeclareAndCast(StepData_Protocol,newproto,proto);
39   if (newproto.IsNull()) throw Interface_InterfaceError("StepSelect_StepType");
40   theproto = newproto;
41   thelib.Clear();
42   thelib.AddProtocol (theproto);
43   thename.Clear();
44   thename.AssignCat ("Step Type (Schema ");
45   thename.AssignCat (theproto->SchemaName());
46   thename.AssignCat (")");
47 }
48
49     Standard_CString  StepSelect_StepType::Value
50   (const Handle(Standard_Transient)& ent,
51    const Handle(Interface_InterfaceModel)& /*model*/) const
52 {
53   lastvalue.Clear();
54   Handle(StepData_ReadWriteModule) module;
55   Standard_Integer CN;
56   Standard_Boolean ok = thelib.Select (ent,module,CN);
57   if (!ok) {
58     lastvalue.AssignCat ("..NOT FROM SCHEMA ");
59     lastvalue.AssignCat (theproto->SchemaName());
60     lastvalue.AssignCat ("..");
61   } else {
62     Standard_Boolean plex = module->IsComplex(CN);
63     if (!plex) lastvalue = module->StepType(CN);
64     else {
65       lastvalue.AssignCat ("(");
66       TColStd_SequenceOfAsciiString list;
67       module->ComplexType (CN,list);
68       Standard_Integer nb = list.Length();
69       if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
70       for (Standard_Integer i = 1; i <= nb; i ++) {
71         if (i > 1) lastvalue.AssignCat (",");
72         lastvalue.AssignCat (list.Value(i).ToCString());
73       }
74       lastvalue.AssignCat (")");
75     }
76   }
77   if (lastvalue.Length() > 0) return lastvalue.ToCString();
78
79   DeclareAndCast(StepData_UndefinedEntity,und,ent);
80   if (und.IsNull()) return lastvalue.ToCString();
81   if (und->IsComplex()) {
82     lastvalue.AssignCat("(");
83     while (!und.IsNull()) {
84       lastvalue.AssignCat (und->StepType());
85       und = und->Next();
86       if (!und.IsNull()) lastvalue.AssignCat(",");
87     }
88     lastvalue.AssignCat(")");
89   }
90   else return und->StepType();
91   return lastvalue.ToCString();
92 }