b311480e |
1 | // Created on: 1998-10-27 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <DPrsStd.hxx> |
18 | |
7fd59977 |
19 | #include <Draw.hxx> |
20 | #include <Draw_Appli.hxx> |
21 | #include <Draw_Interpretor.hxx> |
22 | #include <Draw_ColorKind.hxx> |
23 | #include <TCollection_AsciiString.hxx> |
24 | #include <TDocStd_Document.hxx> |
25 | #include <TDF_Label.hxx> |
26 | #include <TDF_Data.hxx> |
27 | #include <TDF_Tool.hxx> |
28 | #include <TDF_ChildIterator.hxx> |
29 | #include <DDF.hxx> |
30 | #include <DDocStd.hxx> |
7fd59977 |
31 | #include <ViewerTest.hxx> |
7fd59977 |
32 | #include <V3d_View.hxx> |
7fd59977 |
33 | #include <TPrsStd_AISPresentation.hxx> |
34 | #include <TPrsStd_AISViewer.hxx> |
7fd59977 |
35 | #include <AIS_InteractiveContext.hxx> |
7fd59977 |
36 | |
37 | //======================================================================= |
38 | //function : DPrsStd_AISInitViewer |
39 | //purpose : AISInitViewer (DOC) |
40 | //======================================================================= |
7fd59977 |
41 | |
0e93d9e5 |
42 | static Standard_Integer DPrsStd_AISInitViewer (Draw_Interpretor& theDI, |
43 | Standard_Integer theArgNb, |
44 | const char** theArgVec) |
7fd59977 |
45 | { |
0e93d9e5 |
46 | if (theArgNb != 2) |
47 | { |
48 | std::cout << "DPrsStd_AISInitViewer : Error\n"; |
49 | return 1; |
50 | } |
51 | |
52 | Handle(TDocStd_Document) aDoc; |
53 | if (!DDocStd::GetDocument (theArgVec[1], aDoc)) |
54 | { |
55 | return 1; |
7fd59977 |
56 | } |
0e93d9e5 |
57 | |
58 | TDF_Label aRoot = aDoc->GetData()->Root(); |
59 | Handle(TPrsStd_AISViewer) aDocViewer; |
60 | TCollection_AsciiString aViewName = TCollection_AsciiString ("Driver1/Document_") + theArgVec[1] + "/View1"; |
61 | if (!TPrsStd_AISViewer::Find (aRoot, aDocViewer)) |
62 | { |
63 | ViewerTest::ViewerInit (0, 0, 0, 0, aViewName.ToCString(), ""); |
64 | aDocViewer = TPrsStd_AISViewer::New (aRoot, ViewerTest::GetAISContext()); |
65 | } |
66 | |
67 | DDF::ReturnLabel (theDI, aDocViewer->Label()); |
68 | return 0; |
7fd59977 |
69 | } |
70 | |
71 | |
72 | //======================================================================= |
73 | //function : TPrsStd_AISRepaint |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | static Standard_Integer DPrsStd_AISRepaint (Draw_Interpretor& di, |
78 | Standard_Integer nb, |
79 | const char** arg) |
80 | { |
81 | if (nb == 2) { |
82 | Handle(TDocStd_Document) D; |
83 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
84 | TDF_Label acces = D->GetData()->Root(); |
85 | TPrsStd_AISViewer::Update(acces); |
86 | return 0; |
87 | } |
88 | di << "DPrsStd_AISRepaint : Error" << "\n"; |
89 | return 1; |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : AISViewerCommands |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | |
98 | void DPrsStd::AISViewerCommands (Draw_Interpretor& theCommands) |
99 | { |
100 | |
101 | static Standard_Boolean done = Standard_False; |
102 | if (done) return; |
103 | done = Standard_True; |
104 | const char* g = "DPrsStd : standard presentation commands" ; |
105 | |
106 | // standard commands working on AISViewer |
107 | |
108 | theCommands.Add ("AISInitViewer", |
109 | "AISInitViewer (DOC)", |
110 | __FILE__, DPrsStd_AISInitViewer, g); |
111 | |
112 | theCommands.Add ("AISRepaint", |
113 | "update the AIS viewer", |
114 | __FILE__, DPrsStd_AISRepaint, g); |
115 | } |