0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / QADNaming / QADNaming_BuilderCommands.cxx
... / ...
CommitLineData
1// Created on: 2002-04-25
2// Created by: Michael PONIKAROV
3// Copyright (c) 2002-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <QADNaming.hxx>
17#include <TDF_Label.hxx>
18#include <Draw_Interpretor.hxx>
19#include <TNaming_Builder.hxx>
20#include <TopoDS_Shape.hxx>
21#include <DBRep.hxx>
22
23static Standard_Integer BuildNamedShape (Draw_Interpretor& di,
24 Standard_Integer nb,
25 const char** arg) {
26 if (nb >= 4) {
27 TDF_Label aLabel;
28 if (!QADNaming::Entry(arg, aLabel)) return 1;
29 char anEvolution = arg[3][0];
30 Standard_Integer a,anInc = (anEvolution == 'P' || anEvolution == 'D') ? 1 : 2;
31// if (anEvolution == 'G')
32// for(a=1;arg[3][a]!=0 && arg[3][a]!='\n';a++) if (arg[3][a]=='2') anEvolution = '2';
33 TNaming_Builder aBuilder(aLabel);
34 TopoDS_Shape aShape1,aShape2;
35
36 for(a = 4;a < nb;a += anInc) {
37 aShape1 = DBRep::Get (arg[a]);
38 if (anInc == 2) {
39 if (a == nb - 1) {
40 di<<"For this type of evolution number of shapes must be even\n";
41 return 1;
42 }
43 aShape2 = DBRep::Get(arg[a+1]);
44 }
45
46 switch (anEvolution) {
47 case 'P':
48 aBuilder.Generated(aShape1);
49 break;
50 case 'G':
51 aBuilder.Generated(aShape1,aShape2);
52 break;
53 case 'M':
54 aBuilder.Modify(aShape1,aShape2);
55 break;
56 case 'D':
57 aBuilder.Delete(aShape1);
58 break;
59 case 'R':
60// aBuilder.Replace(aShape1,aShape2);
61 aBuilder.Modify(aShape1,aShape2);
62 break;
63 case 'S':
64 aBuilder.Select(aShape1,aShape2);
65 break;
66 default:
67 di<<"Unknown evolution type\n";
68 return 1;
69 }
70 }
71
72// if (nb >= 4) {
73// OnlyModif = Draw::Atoi(arg[3]);
74// }
75 } else {
76 di<<"Usage: BuildName df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) [shape1 shape2 ...]\n";
77 return 1;
78 }
79 return 0;
80}
81
82
83void QADNaming::BuilderCommands(Draw_Interpretor& theCommands)
84{
85 static Standard_Boolean done = Standard_False;
86 if (done) return;
87 done = Standard_True;
88
89 const char* g = "Naming builder commands";
90
91 theCommands.Add("BuildNamedShape",
92 "BuildNamedShape df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) [shape1 shape2 ...]",
93 __FILE__,BuildNamedShape,g);
94}