Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / GLViewer / GLViewer_Compass.cxx
1 //  Copyright (C) 2005 OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 //  Author : OPEN CASCADE
20 //
21
22 // File:      GLViewer_Compass.cxx
23 // Created:   November, 2004
24
25 #include "GLViewer_Compass.h"
26 #include "GLViewer_Drawer.h"
27
28 /*!
29   Constructor
30   \param color        - a color of compass
31   \param size         - a diameter of compass
32   \param pos          - a position
33   \param WidthTop     - width of wide part of arrow
34   \param WidthBottom  - width of base part of arrow
35   \param HeightTop    - height of arrow header
36   \param HeightBottom - height of arrow cut on bottom
37 */
38 GLViewer_Compass::GLViewer_Compass ( const QColor& color, const int size, const Position pos,
39                                const int WidthTop, const int WidthBottom, const int HeightTop,
40                                const int HeightBottom )
41 {
42     myCol = color;
43     mySize = size;
44     myPos = pos;
45     myArrowWidthTop = WidthTop;
46     myArrowWidthBottom = WidthBottom;
47     myArrowHeightTop = HeightTop;
48     myArrowHeightBottom = HeightBottom;
49     myIsVisible = true;
50     QFont* aFont = new QFont("Times",16);
51     myFont = new GLViewer_TexFont( aFont );
52     isGenereted = false;
53     //myFont->generateTexture();
54 }
55
56 /*!
57   Destructor
58 */
59 GLViewer_Compass::~GLViewer_Compass()
60 {
61     delete myFont;
62 }
63
64 /*!
65   Sets parameters of compass
66   \param color        - a color of compass
67   \param size         - a diameter of compass
68   \param pos          - a position
69 */
70 void GLViewer_Compass::setCompass( const QColor& color, const int size, const Position pos )
71 {
72   myCol = color;
73   mySize = size;
74   myPos = pos;
75 }
76
77 /*!
78   Sets visibility of compass 
79   \param vis - new visibility state
80 */
81 void GLViewer_Compass::setVisible( const bool vis )
82 {
83   myIsVisible = vis;
84 }
85
86 /*!
87   Sets size of compass
88   \param size - new size
89 */
90 void GLViewer_Compass::setSize( const int size )
91 {
92   if( size > 0 )
93     mySize=size;
94 }
95
96 /*!
97   Sets arrow width top
98   \param WidthTop - new arrow width top
99 */
100 void GLViewer_Compass::setArrowWidthTop( const int WidthTop )
101 {
102   if( WidthTop < myArrowWidthBottom || WidthTop > mySize )
103     return;
104   myArrowWidthTop=WidthTop;
105 }
106
107 /*!
108   Sets arrow width bottom
109   \param WidthBot - new arrow width bottom
110 */
111 void GLViewer_Compass::setArrowWidthBottom( const int WidthBot )
112
113   if( WidthBot > myArrowWidthTop || WidthBot < 1 )
114     return;     
115   myArrowWidthBottom=WidthBot;
116 }
117
118 /*!
119   Sets arrow height top
120   \param HeightTop - new arrow height top
121 */
122 void GLViewer_Compass::setArrowHeightTop( const int HeightTop )
123 {
124   if( HeightTop > (2*mySize-myArrowHeightBottom ) || HeightTop < 1 )
125     return;
126   myArrowHeightTop=HeightTop;
127 }
128
129 /*!
130   Sets arrow height bottom
131   \param HeightBot - new arrow height bottom
132 */
133 void GLViewer_Compass::setArrowHeightBottom( const int HeightBot )
134 {
135   if( HeightBot > ( 2*mySize-myArrowHeightTop ) || HeightBot < 1)
136     return;
137   myArrowHeightBottom=HeightBot;
138 }
139
140 /*!
141   \return font of compass
142 */
143 GLViewer_TexFont* GLViewer_Compass::getFont()
144
145     if(!isGenereted) 
146     {
147         myFont->generateTexture();
148         isGenereted = true;
149     }    
150     return myFont;
151 }
152
153 /*!
154   Sets font of compass
155   \param theFont - new font
156 */
157 void GLViewer_Compass::setFont( QFont theFont )
158 {
159     delete myFont;
160     myFont = new GLViewer_TexFont( &theFont );
161