b311480e |
1 | // Created on: 2008-04-17 |
2 | // Created by: Customer Support |
3 | // Copyright (c) 2008-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | #include <V3d_LayerMgr.ixx> |
22 | |
23 | #include <Aspect_Window.hxx> |
24 | #include <Visual3d_View.hxx> |
25 | #include <V3d_ColorScale.hxx> |
aff395a3 |
26 | #include <Font_NameOfFont.hxx> |
7fd59977 |
27 | |
28 | |
29 | V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView ) |
30 | : myView(AView.operator->()) |
31 | { |
32 | Handle(Visual3d_View) theView = View()->View(); |
33 | if ( !theView.IsNull() ) { |
34 | Handle(Visual3d_ViewManager) theViewMgr = theView->ViewManager(); |
35 | if ( !theViewMgr.IsNull() ) { |
36 | V3d_LayerMgr* that = (V3d_LayerMgr*)this; |
37 | that->myOverlay = new Visual3d_Layer( theViewMgr, Aspect_TOL_OVERLAY, Standard_False ); |
38 | } |
39 | } |
40 | } |
41 | |
42 | void V3d_LayerMgr::Compute() |
43 | { |
44 | if (Begin()) |
45 | { |
46 | Redraw(); |
47 | End(); |
48 | } |
49 | } |
50 | |
51 | void V3d_LayerMgr::Resized() |
52 | { |
53 | Compute(); |
54 | } |
55 | |
56 | void V3d_LayerMgr::ColorScaleDisplay() |
57 | { |
58 | ColorScale(); |
59 | myColorScale->Display(); |
60 | myOverlay->AddLayerItem( myColorScaleLayerItem ); |
61 | } |
62 | |
63 | void V3d_LayerMgr::ColorScaleErase() |
64 | { |
65 | if ( !myColorScale.IsNull() ) |
66 | myColorScale->Erase(); |
67 | myOverlay->RemoveLayerItem( myColorScaleLayerItem ); |
68 | } |
69 | |
70 | Standard_Boolean V3d_LayerMgr::ColorScaleIsDisplayed() const |
71 | { |
72 | return ( myColorScale.IsNull() ? Standard_False : myColorScale->IsDisplayed() ); |
73 | } |
74 | |
75 | Handle(Aspect_ColorScale) V3d_LayerMgr::ColorScale() const |
76 | { |
77 | if ( myColorScale.IsNull() ) { |
78 | Handle(V3d_LayerMgr) that = this; |
79 | that->myColorScale = new V3d_ColorScale( this ); |
80 | that->myColorScaleLayerItem = new V3d_ColorScaleLayerItem( that->myColorScale ); |
81 | } |
82 | |
83 | return myColorScale; |
84 | } |
85 | |
86 | Standard_Boolean V3d_LayerMgr::Begin() |
87 | { |
88 | if ( myOverlay.IsNull() ) |
89 | return Standard_False; |
90 | |
91 | const Handle(Aspect_Window) &theWin = View()->Window(); |
92 | if ( theWin.IsNull() ) |
93 | return Standard_False; |
94 | |
95 | Standard_Integer aW( 0 ), aH( 0 ); |
96 | theWin->Size( aW, aH ); |
97 | |
98 | myOverlay->Clear(); |
99 | myOverlay->SetViewport( aW, aH ); //szv:!!! |
100 | myOverlay->Begin(); |
aff395a3 |
101 | myOverlay->SetTextAttributes( Font_NOF_ASCII_MONO, Aspect_TODT_NORMAL, Quantity_Color() ); |
7fd59977 |
102 | myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT ); |
103 | |
104 | return Standard_True; |
105 | } |
106 | |
107 | void V3d_LayerMgr::Redraw() |
108 | { |
109 | |
110 | } |
111 | |
112 | void V3d_LayerMgr::End() |
113 | { |
114 | if ( !myOverlay.IsNull() ) |
115 | myOverlay->End(); |
116 | } |