Back to index

salome-gui  6.5.0
GLViewer_Compass.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  Author : OPEN CASCADE
00024 // File:      GLViewer_Compass.cxx
00025 // Created:   November, 2004
00026 //
00027 #include "GLViewer_Compass.h"
00028 #include "GLViewer_Drawer.h"
00029 
00040 GLViewer_Compass::GLViewer_Compass ( const QColor& color, const int size, const Position pos,
00041                                const int WidthTop, const int WidthBottom, const int HeightTop,
00042                                const int HeightBottom )
00043 {
00044     myCol = color;
00045     mySize = size;
00046     myPos = pos;
00047     myArrowWidthTop = WidthTop;
00048     myArrowWidthBottom = WidthBottom;
00049     myArrowHeightTop = HeightTop;
00050     myArrowHeightBottom = HeightBottom;
00051     myIsVisible = true;
00052     QFont* aFont = new QFont("Times",16);
00053     myFont = new GLViewer_TexFont( aFont );
00054     isGenereted = false;
00055     //myFont->generateTexture();
00056 }
00057 
00061 GLViewer_Compass::~GLViewer_Compass()
00062 {
00063     delete myFont;
00064 }
00065 
00072 void GLViewer_Compass::setCompass( const QColor& color, const int size, const Position pos )
00073 {
00074   myCol = color;
00075   mySize = size;
00076   myPos = pos;
00077 }
00078 
00083 void GLViewer_Compass::setVisible( const bool vis )
00084 {
00085   myIsVisible = vis;
00086 }
00087 
00092 void GLViewer_Compass::setSize( const int size )
00093 {
00094   if( size > 0 )
00095     mySize=size;
00096 }
00097 
00102 void GLViewer_Compass::setArrowWidthTop( const int WidthTop )
00103 {
00104   if( WidthTop < myArrowWidthBottom || WidthTop > mySize )
00105     return;
00106   myArrowWidthTop=WidthTop;
00107 }
00108 
00113 void GLViewer_Compass::setArrowWidthBottom( const int WidthBot )
00114 { 
00115   if( WidthBot > myArrowWidthTop || WidthBot < 1 )
00116     return;     
00117   myArrowWidthBottom=WidthBot;
00118 }
00119 
00124 void GLViewer_Compass::setArrowHeightTop( const int HeightTop )
00125 {
00126   if( HeightTop > (2*mySize-myArrowHeightBottom ) || HeightTop < 1 )
00127     return;
00128   myArrowHeightTop=HeightTop;
00129 }
00130 
00135 void GLViewer_Compass::setArrowHeightBottom( const int HeightBot )
00136 {
00137   if( HeightBot > ( 2*mySize-myArrowHeightTop ) || HeightBot < 1)
00138     return;
00139   myArrowHeightBottom=HeightBot;
00140 }
00141 
00145 GLViewer_TexFont* GLViewer_Compass::getFont()
00146 { 
00147     if(!isGenereted) 
00148     {
00149         myFont->generateTexture();
00150         isGenereted = true;
00151     }    
00152     return myFont;
00153 }
00154 
00159 void GLViewer_Compass::setFont( QFont theFont )
00160 {
00161     delete myFont;
00162     myFont = new GLViewer_TexFont( &theFont );
00163 }