7fd59977 |
1 | // File: V3d_LayerMgr.cxx |
2 | // Created: Thu Apr 17 12:34:25 2008 |
3 | // Author: Customer Support |
4 | //Copyright: Open Cascade 2008 |
5 | |
6 | #include <V3d_LayerMgr.ixx> |
7 | |
8 | #include <Aspect_Window.hxx> |
9 | #include <Visual3d_View.hxx> |
10 | #include <V3d_ColorScale.hxx> |
11 | #include <Graphic3d_NameOfFont.hxx> |
12 | |
13 | |
14 | V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView ) |
15 | : myView(AView.operator->()) |
16 | { |
17 | Handle(Visual3d_View) theView = View()->View(); |
18 | if ( !theView.IsNull() ) { |
19 | Handle(Visual3d_ViewManager) theViewMgr = theView->ViewManager(); |
20 | if ( !theViewMgr.IsNull() ) { |
21 | V3d_LayerMgr* that = (V3d_LayerMgr*)this; |
22 | that->myOverlay = new Visual3d_Layer( theViewMgr, Aspect_TOL_OVERLAY, Standard_False ); |
23 | } |
24 | } |
25 | } |
26 | |
27 | void V3d_LayerMgr::Compute() |
28 | { |
29 | if (Begin()) |
30 | { |
31 | Redraw(); |
32 | End(); |
33 | } |
34 | } |
35 | |
36 | void V3d_LayerMgr::Resized() |
37 | { |
38 | Compute(); |
39 | } |
40 | |
41 | void V3d_LayerMgr::ColorScaleDisplay() |
42 | { |
43 | ColorScale(); |
44 | myColorScale->Display(); |
45 | myOverlay->AddLayerItem( myColorScaleLayerItem ); |
46 | } |
47 | |
48 | void V3d_LayerMgr::ColorScaleErase() |
49 | { |
50 | if ( !myColorScale.IsNull() ) |
51 | myColorScale->Erase(); |
52 | myOverlay->RemoveLayerItem( myColorScaleLayerItem ); |
53 | } |
54 | |
55 | Standard_Boolean V3d_LayerMgr::ColorScaleIsDisplayed() const |
56 | { |
57 | return ( myColorScale.IsNull() ? Standard_False : myColorScale->IsDisplayed() ); |
58 | } |
59 | |
60 | Handle(Aspect_ColorScale) V3d_LayerMgr::ColorScale() const |
61 | { |
62 | if ( myColorScale.IsNull() ) { |
63 | Handle(V3d_LayerMgr) that = this; |
64 | that->myColorScale = new V3d_ColorScale( this ); |
65 | that->myColorScaleLayerItem = new V3d_ColorScaleLayerItem( that->myColorScale ); |
66 | } |
67 | |
68 | return myColorScale; |
69 | } |
70 | |
71 | Standard_Boolean V3d_LayerMgr::Begin() |
72 | { |
73 | if ( myOverlay.IsNull() ) |
74 | return Standard_False; |
75 | |
76 | const Handle(Aspect_Window) &theWin = View()->Window(); |
77 | if ( theWin.IsNull() ) |
78 | return Standard_False; |
79 | |
80 | Standard_Integer aW( 0 ), aH( 0 ); |
81 | theWin->Size( aW, aH ); |
82 | |
83 | myOverlay->Clear(); |
84 | myOverlay->SetViewport( aW, aH ); //szv:!!! |
85 | myOverlay->Begin(); |
25289ec1 |
86 | myOverlay->SetTextAttributes( Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, Quantity_Color() ); |
7fd59977 |
87 | myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT ); |
88 | |
89 | return Standard_True; |
90 | } |
91 | |
92 | void V3d_LayerMgr::Redraw() |
93 | { |
94 | |
95 | } |
96 | |
97 | void V3d_LayerMgr::End() |
98 | { |
99 | if ( !myOverlay.IsNull() ) |
100 | myOverlay->End(); |
101 | } |