db2a7758b6e04d38a7b5cce874409390e59bce37
[occt.git] / src / V3d / V3d_LayerMgr.cxx
1 // Created on: 2008-04-17
2 // Created by: Customer Support
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <Aspect_Window.hxx>
18 #include <Font_NameOfFont.hxx>
19 #include <Standard_Type.hxx>
20 #include <V3d_LayerMgr.hxx>
21 #include <V3d_View.hxx>
22 #include <Visual3d_Layer.hxx>
23 #include <Visual3d_View.hxx>
24
25 V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView )
26 : myView(AView.operator->())
27 {
28   Handle(Visual3d_View) theView = View()->View();
29   if ( !theView.IsNull() ) {
30     Handle(Visual3d_ViewManager) theViewMgr = theView->ViewManager();
31     if ( !theViewMgr.IsNull() ) {
32       V3d_LayerMgr* that = (V3d_LayerMgr*)this;
33       that->myOverlay = new Visual3d_Layer( theViewMgr, Aspect_TOL_OVERLAY, Standard_False );
34     }
35   }
36 }
37
38 void V3d_LayerMgr::Compute()
39 {
40   if (Begin())
41   {
42     Redraw();
43     End();
44   }
45 }
46
47 void V3d_LayerMgr::Resized()
48 {
49   Compute();
50 }
51
52 Standard_Boolean V3d_LayerMgr::Begin()
53 {
54   if ( myOverlay.IsNull() )
55     return Standard_False;
56
57   const Handle(Aspect_Window) &theWin = View()->Window();
58   if ( theWin.IsNull() )
59     return Standard_False;
60
61   Standard_Integer aW( 0 ), aH( 0 );
62   theWin->Size( aW, aH );
63
64   myOverlay->Clear();
65   myOverlay->SetViewport( aW, aH ); //szv:!!!
66   myOverlay->Begin();
67   myOverlay->SetTextAttributes( Font_NOF_ASCII_MONO, Aspect_TODT_NORMAL, Quantity_Color() );
68   myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT );
69
70   return Standard_True;
71 }
72
73 void V3d_LayerMgr::Redraw()
74 {
75
76 }
77
78 void V3d_LayerMgr::End()
79 {
80   if ( !myOverlay.IsNull() )
81     myOverlay->End();
82 }