summaryrefslogtreecommitdiff
path: root/src/V3d/V3d_LayerMgr.cxx
blob: 43beb2382ac5c8dd5d9413d8ca564a2d38700456 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// File:  V3d_LayerMgr.cxx
// Created: Thu Apr 17 12:34:25 2008
// Author:  Customer Support
//Copyright:  Open Cascade 2008

#include <V3d_LayerMgr.ixx>

#include <Aspect_Window.hxx>
#include <Visual3d_View.hxx>
#include <V3d_ColorScale.hxx>
#include <Graphic3d_NameOfFont.hxx>


V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView )
: myView(AView.operator->())
{
  Handle(Visual3d_View) theView = View()->View();
  if ( !theView.IsNull() ) {
    Handle(Visual3d_ViewManager) theViewMgr = theView->ViewManager();
    if ( !theViewMgr.IsNull() ) {
      V3d_LayerMgr* that = (V3d_LayerMgr*)this;
      that->myOverlay = new Visual3d_Layer( theViewMgr, Aspect_TOL_OVERLAY, Standard_False );
    }
  }
}

void V3d_LayerMgr::Compute()
{
  if (Begin())
  {
    Redraw();
    End();
  }
}

void V3d_LayerMgr::Resized()
{
  Compute();
}

void V3d_LayerMgr::ColorScaleDisplay()
{
  ColorScale();
  myColorScale->Display();
  myOverlay->AddLayerItem( myColorScaleLayerItem );
}

void V3d_LayerMgr::ColorScaleErase()
{
  if ( !myColorScale.IsNull() )
    myColorScale->Erase();
  myOverlay->RemoveLayerItem( myColorScaleLayerItem );
}

Standard_Boolean V3d_LayerMgr::ColorScaleIsDisplayed() const
{
  return ( myColorScale.IsNull() ? Standard_False : myColorScale->IsDisplayed() );
}

Handle(Aspect_ColorScale) V3d_LayerMgr::ColorScale() const
{
  if ( myColorScale.IsNull() ) {
    Handle(V3d_LayerMgr) that = this;
    that->myColorScale = new V3d_ColorScale( this );
    that->myColorScaleLayerItem = new V3d_ColorScaleLayerItem( that->myColorScale );
  }

  return myColorScale;
}

Standard_Boolean V3d_LayerMgr::Begin()
{
  if ( myOverlay.IsNull() )
    return Standard_False;

  const Handle(Aspect_Window) &theWin = View()->Window();
  if ( theWin.IsNull() )
    return Standard_False;

  Standard_Integer aW( 0 ), aH( 0 );
  theWin->Size( aW, aH );

  myOverlay->Clear();
  myOverlay->SetViewport( aW, aH ); //szv:!!!
  myOverlay->Begin();
  myOverlay->SetTextAttributes( Graphic3d_NOF_ASCII_MONO, Aspect_TODT_SUBTITLE, Quantity_Color() );
  myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT );

  return Standard_True;
}

void V3d_LayerMgr::Redraw()
{

}

void V3d_LayerMgr::End()
{
  if ( !myOverlay.IsNull() )
    myOverlay->End();
}