1 // Created on: 1992-04-06
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef Draw_Viewer_HeaderFile
18 #define Draw_Viewer_HeaderFile
19 
20 #include <gp_Pnt.hxx>
21 #include <gp_Vec.hxx>
22 #include <gp_Dir.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <gp_Vec2d.hxx>
25 #include <gp_Dir2d.hxx>
26 #include <gp_Trsf.hxx>
27 #include <gp_Ax1.hxx>
28 #include <Draw_Drawable3D.hxx>
29 #include <Draw_SequenceOfDrawable3D.hxx>
30 #include <Draw_Color.hxx>
31 
32 #ifdef _WIN32
33 #include <windows.h>
34 #endif
35 
36 const Standard_Integer MAXVIEW  = 30;
37 
38 class Draw_View;
39 
40 class Draw_Viewer {
41 
42   public :
43   Standard_EXPORT Draw_Viewer      ();
44   Standard_EXPORT Standard_Boolean DefineColor (const Standard_Integer i,
45 					   const char* colname);
46   Standard_EXPORT void   MakeView    (const Standard_Integer id,
47 				 const char*   typ,
48 				 const Standard_Integer X, const Standard_Integer Y,
49 				 const Standard_Integer W, const Standard_Integer H);
50   // build a view on a given window
51 #ifdef _WIN32
52   Standard_EXPORT void MakeView    (const Standard_Integer id,
53 			       const char*   typ,
54 			       const Standard_Integer X, const Standard_Integer Y,
55 			       const Standard_Integer W, const Standard_Integer H,
56 			       HWND win,
57 			       const Standard_Boolean useBuffer = Standard_False);
58 #endif
59   Standard_EXPORT void   MakeView    (const Standard_Integer id,
60 				 const char*  typ,
61 				 const char*  window);
62   Standard_EXPORT void   SetTitle    (const Standard_Integer id,
63 				 const char* name);
64   Standard_EXPORT void   ResetView   (const Standard_Integer id);
65   Standard_EXPORT void   SetZoom     (const Standard_Integer id,
66 				 const Standard_Real z);
67   Standard_EXPORT void   RotateView  (const Standard_Integer id,
68 				 const gp_Dir2d&,
69 				 const Standard_Real);
70   Standard_EXPORT void   RotateView  (const Standard_Integer id,
71 				 const gp_Pnt&,
72 				 const gp_Dir&,
73 				 const Standard_Real);
74   Standard_EXPORT void   SetFocal    (const Standard_Integer id,
75 				 const Standard_Real FocalDist);
76   Standard_EXPORT char*  GetType     (const Standard_Integer id) const;
77   Standard_EXPORT Standard_Real   Zoom        (const Standard_Integer id) const;
78   Standard_EXPORT Standard_Real   Focal       (const Standard_Integer id) const;
79   Standard_EXPORT void   SetTrsf     (const Standard_Integer id,
80 				 gp_Trsf& T);
81   Standard_EXPORT void   GetTrsf     (const Standard_Integer id,
82 				 gp_Trsf& T) const;
83   Standard_EXPORT void   GetPosSize  (const Standard_Integer id,
84 				 Standard_Integer& X, Standard_Integer& Y,
85 				 Standard_Integer& W, Standard_Integer& H);
86   Standard_EXPORT Standard_Boolean    Is3D        (const Standard_Integer id) const;
87   Standard_EXPORT void   GetFrame    (const Standard_Integer id,
88 				 Standard_Integer& xmin, Standard_Integer& ymin,
89 				 Standard_Integer& xmax, Standard_Integer& ymax);
90   Standard_EXPORT void   FitView     (const Standard_Integer id, const Standard_Integer frame);
91   Standard_EXPORT void   PanView     (const Standard_Integer id,
92 				 const Standard_Integer DX, const Standard_Integer DY);
93   Standard_EXPORT void   SetPan      (const Standard_Integer id,
94 				 const Standard_Integer DX, const Standard_Integer DY);
95   Standard_EXPORT void   GetPan      (const Standard_Integer id,
96 				 Standard_Integer& DX, Standard_Integer& DY);
97   Standard_EXPORT Standard_Boolean HasView    (const Standard_Integer id) const;
98   Standard_EXPORT void   DisplayView (const Standard_Integer id) const;
99   Standard_EXPORT void   HideView    (const Standard_Integer id) const;
100   Standard_EXPORT void   ClearView   (const Standard_Integer id) const;
101   Standard_EXPORT void   RemoveView  (const Standard_Integer id) ;
102   Standard_EXPORT void   RepaintView (const Standard_Integer id) const;
103 #ifdef _WIN32
104   Standard_EXPORT void   ResizeView  (const Standard_Integer id) const;
105   Standard_EXPORT void   UpdateView  (const Standard_Integer id, const Standard_Boolean forced = Standard_False) const;
106 #endif
107   Standard_EXPORT void   ConfigView  (const Standard_Integer id) const;
108   Standard_EXPORT void   PostScriptView (const Standard_Integer id,
109 				    const Standard_Integer VXmin,
110 				    const Standard_Integer VYmin,
111 				    const Standard_Integer VXmax,
112 				    const Standard_Integer VYmax,
113 				    const Standard_Integer PXmin,
114 				    const Standard_Integer PYmin,
115 				    const Standard_Integer PXmax,
116 				    const Standard_Integer PYmax,
117 				    std::ostream& sortie) const;
118   Standard_EXPORT void   PostColor(const Standard_Integer icol,
119 			      const Standard_Integer width,
120 			      const Standard_Real    gray);
121   Standard_EXPORT Standard_Boolean SaveView(const Standard_Integer id, const char* filename);
122   Standard_EXPORT void   RepaintAll  () const;
123   Standard_EXPORT void   Repaint2D  () const;
124   Standard_EXPORT void   Repaint3D  () const;
125   Standard_EXPORT void   DeleteView  (const Standard_Integer id);
126   Standard_EXPORT void   Clear       ();
127   Standard_EXPORT void   Clear2D     ();
128   Standard_EXPORT void   Clear3D     ();
129   Standard_EXPORT void   Flush       ();
130 
131   Standard_EXPORT void DrawOnView     (const Standard_Integer id,
132 				  const Handle(Draw_Drawable3D)& D) const;
133   Standard_EXPORT void HighlightOnView (const Standard_Integer id,
134 				   const Handle(Draw_Drawable3D)& D,
135 				   const Draw_ColorKind C = Draw_blanc) const;
136   Standard_EXPORT void AddDrawable    (const Handle(Draw_Drawable3D)& D);
137   Standard_EXPORT void RemoveDrawable (const Handle(Draw_Drawable3D)& D);
138   Standard_EXPORT Draw_Display MakeDisplay (const Standard_Integer id) const;
139 
140   Standard_EXPORT void Select (Standard_Integer& id,         // View, -1 if none
141 			  Standard_Integer& X,          // Pick coordinates
142 			  Standard_Integer& Y,
143 			  Standard_Integer& Button,     // Button pressed, 0 if none
144 			  Standard_Boolean  waitclick = Standard_True
145 			  );
146 
147   Standard_EXPORT Standard_Integer Pick(const Standard_Integer id,   // returns the index (or 0)
148 				   const Standard_Integer X,
149 				   const Standard_Integer Y,
150 				   const Standard_Integer Prec,
151 				   Handle(Draw_Drawable3D)& D,
152 				   const Standard_Integer First = 0) const; // search after this drawable
153 
154   Standard_EXPORT void LastPick(gp_Pnt& P1, gp_Pnt& P2, Standard_Real& Param);
155   // returns the extremities and parameter of the last picked segment
156 
157   Standard_EXPORT ~Draw_Viewer();
158   Standard_EXPORT Draw_Viewer& operator<<(const Handle(Draw_Drawable3D)&);
159   Standard_EXPORT const Draw_SequenceOfDrawable3D& GetDrawables();
160 
161   private :
162 
163     Draw_View*                myViews[MAXVIEW];
164     Draw_SequenceOfDrawable3D myDrawables;
165 };
166 
167 
168 #endif
169