summaryrefslogtreecommitdiff
path: root/src/StepSelect/StepSelect_StepType.cxx
blob: 0943abeebd46e5fb58eab82e47bbad691139c953 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <StepSelect_StepType.ixx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <StepData_ReadWriteModule.hxx>
#include <StepData_UndefinedEntity.hxx>
#include <Interface_InterfaceError.hxx>
#include <Interface_Macros.hxx>


static TCollection_AsciiString lastvalue;


    StepSelect_StepType::StepSelect_StepType ()
    : IFSelect_Signature ("Step Type")      {  }

    void  StepSelect_StepType::SetProtocol
  (const Handle(Interface_Protocol)& proto)
{
  DeclareAndCast(StepData_Protocol,newproto,proto);
  if (newproto.IsNull()) Interface_InterfaceError::Raise("StepSelect_StepType");
  theproto = newproto;
  thelib.Clear();
  thelib.AddProtocol (theproto);
  thename.Clear();
  thename.AssignCat ("Step Type (Schema ");
  thename.AssignCat (theproto->SchemaName());
  thename.AssignCat (")");
}

    Standard_CString  StepSelect_StepType::Value
  (const Handle(Standard_Transient)& ent,
   const Handle(Interface_InterfaceModel)& model) const
{
  lastvalue.Clear();
  Handle(StepData_ReadWriteModule) module;
  Standard_Integer CN;
  Standard_Boolean ok = thelib.Select (ent,module,CN);
  if (!ok) {
    lastvalue.AssignCat ("..NOT FROM SCHEMA ");
    lastvalue.AssignCat (theproto->SchemaName());
    lastvalue.AssignCat ("..");
  } else {
    Standard_Boolean plex = module->IsComplex(CN);
    if (!plex) lastvalue = module->StepType(CN);
    else {
      lastvalue.AssignCat ("(");
      TColStd_SequenceOfAsciiString list;
      module->ComplexType (CN,list);
      Standard_Integer nb = list.Length();
      if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
      for (Standard_Integer i = 1; i <= nb; i ++) {
	if (i > 1) lastvalue.AssignCat (",");
	lastvalue.AssignCat (list.Value(i).ToCString());
      }
      lastvalue.AssignCat (")");
    }
  }
  if (lastvalue.Length() > 0) return lastvalue.ToCString();

  DeclareAndCast(StepData_UndefinedEntity,und,ent);
  if (und.IsNull()) return lastvalue.ToCString();
  if (und->IsComplex()) {
    lastvalue.AssignCat("(");
    while (!und.IsNull()) {
      lastvalue.AssignCat (und->StepType());
      und = und->Next();
      if (!und.IsNull()) lastvalue.AssignCat(",");
    }
    lastvalue.AssignCat(")");
  }
  else return und->StepType();
  return lastvalue.ToCString();
}