summaryrefslogtreecommitdiff
path: root/src/DPrsStd/DPrsStd_AISViewerCommands.cxx
blob: ce5a7f41e43da12c2546256f7a0ba99851855d3c (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// File:	DPrsStd_AISViewerCommnds.cxx
// Created:	Tue Oct 27 10:24:49 1998
// Author:	Denis PASCAL
//		<dp@dingox.paris1.matra-dtv.fr>



#include <DPrsStd.hxx>

#include <DPrsStd.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_ColorKind.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <TDF_Data.hxx> 
#include <TDF_Tool.hxx> 
#include <TDF_ChildIterator.hxx>
#include <DDF.hxx>
#include <DDocStd.hxx>
#include <TDocStd_Document.hxx> 
#include <ViewerTest.hxx>

#include <V3d_View.hxx>

// for AIS

#include <TPrsStd_AISPresentation.hxx>
#include <TPrsStd_AISViewer.hxx>
#include <ViewerTest.hxx>
#include <AIS_InteractiveContext.hxx> 
#include <ViewerTest.hxx>
#include <ViewerTest_Tool.hxx>
#include <V3d_View.hxx>


  
extern int ViewerMainLoop (Standard_Integer, const char**);

//=======================================================================
//function : DPrsStd_AISInitViewer
//purpose  : AISInitViewer (DOC)
//=======================================================================
extern void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)&);

static Standard_Integer DPrsStd_AISInitViewer (Draw_Interpretor& di,
					     Standard_Integer nb, 
					     const char** arg) 
{   
  if (nb == 2) {     
    Handle(TDocStd_Document) D;
    if (!DDocStd::GetDocument(arg[1],D)) return 1; 
    TDF_Label acces = D->GetData()->Root();   
    Handle(TPrsStd_AISViewer) viewer;
    if (!TPrsStd_AISViewer::Find (acces,viewer)) {
      TCollection_AsciiString title;  
      title.Prepend(arg[1]);   
      title.Prepend("_"); 
      title.Prepend("Document");  
      Handle(V3d_Viewer) vw = ViewerTest_Tool::MakeViewer (title.ToCString());
      viewer = TPrsStd_AISViewer::New (acces,vw);
    } 
    ViewerTest_Tool::InitViewerTest (viewer->GetInteractiveContext());
    DDF::ReturnLabel(di,viewer->Label());
    return 0;
  }
  di << "DPrsStd_AISInitViewer : Error" << "\n";
  return 1;
}


//=======================================================================
//function : TPrsStd_AISRepaint
//purpose  : 
//=======================================================================

static Standard_Integer DPrsStd_AISRepaint (Draw_Interpretor& di,
					    Standard_Integer nb, 
					    const char** arg) 
{   
  if (nb == 2) {     
    Handle(TDocStd_Document) D;
    if (!DDocStd::GetDocument(arg[1],D)) return 1; 
    TDF_Label acces = D->GetData()->Root(); 
    TPrsStd_AISViewer::Update(acces);
    return 0;
  }
  di << "DPrsStd_AISRepaint : Error" << "\n";
  return 1; 
}

//=======================================================================
//function : AISViewerCommands
//purpose  :
//=======================================================================


void DPrsStd::AISViewerCommands (Draw_Interpretor& theCommands)
{  

  static Standard_Boolean done = Standard_False;
  if (done) return;
  done = Standard_True;
  const char* g = "DPrsStd : standard presentation commands" ;  
 
  // standard commands working on AISViewer
  
  theCommands.Add ("AISInitViewer", 
                   "AISInitViewer (DOC)",
		   __FILE__, DPrsStd_AISInitViewer, g);    

  theCommands.Add ("AISRepaint", 
                   "update the AIS viewer",
		   __FILE__, DPrsStd_AISRepaint, g);      
}