Salome HOME
097a6edf87c337c962ac2a40914795c657a983f9
[modules/gui.git] / src / GLViewer / GLViewer_Compass.cxx
1 // File:      GLViewer_Compass.cxx
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 //================================================================
7 // Class       : GLViewer_Compass
8 // Description : Class implement representatiof of compass in one of corner in GLViewer
9 //================================================================
10
11 #include "GLViewer_Compass.h"
12 #include "GLViewer_Drawer.h"
13
14 //=======================================================================
15 // Function: GLViewer_Compass
16 // Purpose :
17 //=======================================================================
18 GLViewer_Compass::GLViewer_Compass ( const QColor& color, const int size, const Position pos,
19                                const int WidthTop, const int WidthBottom, const int HeightTop,
20                                const int HeightBottom )
21 {
22     myCol = color;
23     mySize = size;
24     myPos = pos;
25     myArrowWidthTop = WidthTop;
26     myArrowWidthBottom = WidthBottom;
27     myArrowHeightTop = HeightTop;
28     myArrowHeightBottom = HeightBottom;
29     myIsVisible = true;
30     QFont* aFont = new QFont("Times",16);
31     myFont = new GLViewer_TexFont( aFont );
32     isGenereted = false;
33     //myFont->generateTexture();
34 }
35
36 //=======================================================================
37 // Function: ~GLViewer_Compass
38 // Purpose :
39 //=======================================================================
40 GLViewer_Compass::~GLViewer_Compass()
41 {
42     delete myFont;
43 }
44
45 //=======================================================================
46 // Function: setCompass
47 // Purpose :
48 //=======================================================================
49 void GLViewer_Compass::setCompass( const QColor& color, const int size, const Position pos )
50 {
51   myCol = color;
52   mySize = size;
53   myPos = pos;
54 }
55
56 //=======================================================================
57 // Function: setVisible
58 // Purpose :
59 //=======================================================================
60 void GLViewer_Compass::setVisible( const bool vis )
61 {
62   myIsVisible = vis;
63 }
64
65 //=======================================================================
66 // Function: setSize
67 // Purpose :
68 //=======================================================================
69 void GLViewer_Compass::setSize( const int size )
70 {
71   if( size > 0 )
72     mySize=size;
73 }
74
75 //=======================================================================
76 // Function: setArrowWidthTop
77 // Purpose :
78 //=======================================================================
79 void GLViewer_Compass::setArrowWidthTop( const int WidthTop )
80 {
81   if( WidthTop < myArrowWidthBottom || WidthTop > mySize )
82     return;
83   myArrowWidthTop=WidthTop;
84 }
85
86 //=======================================================================
87 // Function: setArrowWidthBottom
88 // Purpose :
89 //=======================================================================
90 void GLViewer_Compass::setArrowWidthBottom( const int WidthBot )
91
92   if( WidthBot > myArrowWidthTop || WidthBot < 1 )
93     return;     
94   myArrowWidthBottom=WidthBot;
95 }
96
97 //=======================================================================
98 // Function: setArrowHeightTop
99 // Purpose :
100 //=======================================================================
101 void GLViewer_Compass::setArrowHeightTop( const int HeightTop )
102 {
103   if( HeightTop > (2*mySize-myArrowHeightBottom ) || HeightTop < 1 )
104     return;
105   myArrowHeightTop=HeightTop;
106 }
107
108 //=======================================================================
109 // Function: setArrowHeightBottom
110 // Purpose :
111 //=======================================================================
112 void GLViewer_Compass::setArrowHeightBottom( const int HeightBot )
113 {
114   if( HeightBot > ( 2*mySize-myArrowHeightTop ) || HeightBot < 1)
115     return;
116   myArrowHeightBottom=HeightBot;
117 }
118
119 //=======================================================================
120 // Function: getFont
121 // Purpose :
122 //=======================================================================
123 GLViewer_TexFont* GLViewer_Compass::getFont()
124
125     if(!isGenereted) 
126     {
127         myFont->generateTexture();
128         isGenereted = true;
129     }    
130     return myFont;
131 }
132
133 //=======================================================================
134 // Function: setFont
135 // Purpose :
136 //=======================================================================
137 void GLViewer_Compass::setFont( QFont theFont )
138 {
139     delete myFont;
140     myFont = new GLViewer_TexFont( &theFont );
141