0022972: Eliminate macro definitions that has compiler-provided analogs (WNT and...
[occt.git] / src / Draw / Draw_Viewer.hxx
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 #if !defined(__Draw_API) && !defined(HAVE_NO_DLL)
35 # ifdef __Draw_DLL
36 #  define __Draw_API __declspec( dllexport )
37 # else
38 #  define __Draw_API /*__declspec( dllimport )*/
39 # endif
40 #endif
41 #else
42 #  define __Draw_API  
43 #endif
44 const Standard_Integer MAXVIEW  = 30;
45
46 class Draw_View;
47
48 class Draw_Viewer {
49
50   public :
51   __Draw_API Draw_Viewer      ();
52   __Draw_API Standard_Boolean DefineColor (const Standard_Integer i,
53                                            const char* colname);
54   __Draw_API void   MakeView    (const Standard_Integer id,
55                                  const char*   typ,
56                                  const Standard_Integer X, const Standard_Integer Y, 
57                                  const Standard_Integer W, const Standard_Integer H);
58   // build a view on a given window
59 #ifdef _WIN32
60   __Draw_API void MakeView    (const Standard_Integer id,
61                                const char*   typ,
62                                const Standard_Integer X, const Standard_Integer Y,
63                                const Standard_Integer W, const Standard_Integer H,
64                                HWND win,
65                                const Standard_Boolean useBuffer = Standard_False);
66 #endif
67   __Draw_API void   MakeView    (const Standard_Integer id,
68                                  const char*  typ,
69                                  const char*  window);
70   __Draw_API void   SetTitle    (const Standard_Integer id,
71                                  const char* name);
72   __Draw_API void   ResetView   (const Standard_Integer id);
73   __Draw_API void   SetZoom     (const Standard_Integer id,
74                                  const Standard_Real z);
75   __Draw_API void   RotateView  (const Standard_Integer id,
76                                  const gp_Dir2d&,
77                                  const Standard_Real);
78   __Draw_API void   RotateView  (const Standard_Integer id,
79                                  const gp_Pnt&,
80                                  const gp_Dir&,
81                                  const Standard_Real);
82   __Draw_API void   SetFocal    (const Standard_Integer id,
83                                  const Standard_Real FocalDist);
84   __Draw_API char*  GetType     (const Standard_Integer id) const;
85   __Draw_API Standard_Real   Zoom        (const Standard_Integer id) const;
86   __Draw_API Standard_Real   Focal       (const Standard_Integer id) const;
87   __Draw_API void   SetTrsf     (const Standard_Integer id,
88                                  gp_Trsf& T);
89   __Draw_API void   GetTrsf     (const Standard_Integer id,
90                                  gp_Trsf& T) const;
91   __Draw_API void   GetPosSize  (const Standard_Integer id,
92                                  Standard_Integer& X, Standard_Integer& Y,
93                                  Standard_Integer& W, Standard_Integer& H);
94   __Draw_API Standard_Boolean    Is3D        (const Standard_Integer id) const; 
95   __Draw_API void   GetFrame    (const Standard_Integer id,
96                                  Standard_Integer& xmin, Standard_Integer& ymin,
97                                  Standard_Integer& xmax, Standard_Integer& ymax);
98   __Draw_API void   FitView     (const Standard_Integer id, const Standard_Integer frame);
99   __Draw_API void   PanView     (const Standard_Integer id,
100                                  const Standard_Integer DX, const Standard_Integer DY);
101   __Draw_API void   SetPan      (const Standard_Integer id,
102                                  const Standard_Integer DX, const Standard_Integer DY);
103   __Draw_API void   GetPan      (const Standard_Integer id,
104                                  Standard_Integer& DX, Standard_Integer& DY);
105   __Draw_API Standard_Boolean HasView    (const Standard_Integer id) const;
106   __Draw_API void   DisplayView (const Standard_Integer id) const;
107   __Draw_API void   HideView    (const Standard_Integer id) const;
108   __Draw_API void   ClearView   (const Standard_Integer id) const;
109   __Draw_API void   RemoveView  (const Standard_Integer id) ;
110   __Draw_API void   RepaintView (const Standard_Integer id) const;
111 #ifdef _WIN32
112   __Draw_API void   ResizeView  (const Standard_Integer id) const;
113   __Draw_API void   UpdateView  (const Standard_Integer id, const Standard_Boolean forced = Standard_False) const;
114 #endif  
115   __Draw_API void   ConfigView  (const Standard_Integer id) const;
116   __Draw_API void   PostScriptView (const Standard_Integer id,
117                                     const Standard_Integer VXmin,
118                                     const Standard_Integer VYmin,
119                                     const Standard_Integer VXmax,
120                                     const Standard_Integer VYmax,
121                                     const Standard_Integer PXmin,
122                                     const Standard_Integer PYmin,
123                                     const Standard_Integer PXmax,
124                                     const Standard_Integer PYmax,
125                                     ostream& sortie) const;
126   __Draw_API void   PostColor(const Standard_Integer icol,
127                               const Standard_Integer width,
128                               const Standard_Real    gray);
129   __Draw_API Standard_Boolean SaveView(const Standard_Integer id, const char* filename);
130   __Draw_API void   RepaintAll  () const;
131   __Draw_API void   Repaint2D  () const;
132   __Draw_API void   Repaint3D  () const;
133   __Draw_API void   DeleteView  (const Standard_Integer id);
134   __Draw_API void   Clear       ();
135   __Draw_API void   Clear2D     ();
136   __Draw_API void   Clear3D     ();
137   __Draw_API void   Flush       ();
138   
139   __Draw_API void DrawOnView     (const Standard_Integer id,
140                                   const Handle(Draw_Drawable3D)& D) const; 
141   __Draw_API void HighlightOnView (const Standard_Integer id,
142                                    const Handle(Draw_Drawable3D)& D,
143                                    const Draw_ColorKind C = Draw_blanc) const; 
144   __Draw_API void AddDrawable    (const Handle(Draw_Drawable3D)& D);
145   __Draw_API void RemoveDrawable (const Handle(Draw_Drawable3D)& D);
146   __Draw_API Draw_Display MakeDisplay (const Standard_Integer id) const;
147   
148   __Draw_API void Select (Standard_Integer& id,         // View, -1 if none
149                           Standard_Integer& X,          // Pick coordinates
150                           Standard_Integer& Y,
151                           Standard_Integer& Button,     // Button pressed, 0 if none
152                           Standard_Boolean  waitclick = Standard_True
153                           );
154
155   __Draw_API Standard_Integer Pick(const Standard_Integer id,   // returns the index (or 0)
156                                    const Standard_Integer X,
157                                    const Standard_Integer Y,
158                                    const Standard_Integer Prec,
159                                    Handle(Draw_Drawable3D)& D,
160                                    const Standard_Integer First = 0) const; // search after this drawable
161   
162   __Draw_API void LastPick(gp_Pnt& P1, gp_Pnt& P2, Standard_Real& Param);
163   // returns the extremities and parameter of the last picked segment
164   
165   __Draw_API ~Draw_Viewer();
166   __Draw_API Draw_Viewer& operator<<(const Handle(Draw_Drawable3D)&);
167   __Draw_API const Draw_SequenceOfDrawable3D& GetDrawables();
168
169   private :
170
171     Draw_View*                myViews[MAXVIEW];
172     Draw_SequenceOfDrawable3D myDrawables;
173 };
174
175
176 #endif