0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / QADNaming / QADNaming_BuilderCommands.cxx
CommitLineData
b311480e 1// Created on: 2002-04-25
2// Created by: Michael PONIKAROV
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#include <QADNaming.hxx>
23#include <TDF_Label.hxx>
24#include <Draw_Interpretor.hxx>
25#include <TNaming_Builder.hxx>
26#include <TopoDS_Shape.hxx>
27#include <DBRep.hxx>
28
29static Standard_Integer BuildNamedShape (Draw_Interpretor& di,
30 Standard_Integer nb,
31 const char** arg) {
32 if (nb > 4) {
33 TDF_Label aLabel;
34 if (!QADNaming::Entry(arg, aLabel)) return 1;
35 char anEvolution = arg[3][0];
36 Standard_Integer a,anInc = (anEvolution == 'P' || anEvolution == 'D') ? 1 : 2;
37// if (anEvolution == 'G')
38// for(a=1;arg[3][a]!=0 && arg[3][a]!='\n';a++) if (arg[3][a]=='2') anEvolution = '2';
39 TNaming_Builder aBuilder(aLabel);
40 TopoDS_Shape aShape1,aShape2;
41
42 for(a = 4;a < nb;a += anInc) {
43 aShape1 = DBRep::Get (arg[a]);
44 if (anInc == 2) {
45 if (a == nb - 1) {
46 di<<"For this type of evolution number of shapes must be even"<<"\n";
47 return 1;
48 }
49 aShape2 = DBRep::Get(arg[a+1]);
50 }
51
52 switch (anEvolution) {
53 case 'P':
54 aBuilder.Generated(aShape1);
55 break;
56 case 'G':
57 aBuilder.Generated(aShape1,aShape2);
58 break;
59 case 'M':
60 aBuilder.Modify(aShape1,aShape2);
61 break;
62 case 'D':
63 aBuilder.Delete(aShape1);
64 break;
65 case 'R':
1ec8a59e 66// aBuilder.Replace(aShape1,aShape2);
67 aBuilder.Modify(aShape1,aShape2);
7fd59977 68 break;
69 case 'S':
70 aBuilder.Select(aShape1,aShape2);
71 break;
72 default:
73 di<<"Unknown evolution type"<<"\n";
74 return 1;
75 }
76 }
77
78// if (nb >= 4) {
91322f44 79// OnlyModif = Draw::Atoi(arg[3]);
7fd59977 80// }
81 } else {
82 di<<"Usage: BuildName df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) shape1 [shape2 ...]"<<"\n";
83 return 1;
84 }
85 return 0;
86}
87
88
89void QADNaming::BuilderCommands(Draw_Interpretor& theCommands)
90{
91 static Standard_Boolean done = Standard_False;
92 if (done) return;
93 done = Standard_True;
94
95 const char* g = "Naming builder commands";
96
97 theCommands.Add("BuildNamedShape",
98 "BuildNamedShape df entry evolution(P[RIMITIVE] G[ENERATED] M[ODIFY] D[ELETE] R[EPLACE] S[ELECTED]) shape1 [shape2 ...]",
99 __FILE__,BuildNamedShape,g);
100}