// Author: OCC team
// Copyright (C) CEA 2004
-//#include <GLViewerAfx.h>
+//================================================================
+// Class : GLViewer_Compass
+// Description : Class implement representatiof of compass in one of corner in GLViewer
+//================================================================
+
#include "GLViewer_Compass.h"
#include "GLViewer_Drawer.h"
+//=======================================================================
+// Function: GLViewer_Compass
+// Purpose :
+//=======================================================================
GLViewer_Compass::GLViewer_Compass ( const QColor& color, const int size, const Position pos,
const int WidthTop, const int WidthBottom, const int HeightTop,
- const int HeightBottom ){
+ const int HeightBottom )
+{
myCol = color;
mySize = size;
myPos = pos;
//myFont->generateTexture();
}
+//=======================================================================
+// Function: ~GLViewer_Compass
+// Purpose :
+//=======================================================================
GLViewer_Compass::~GLViewer_Compass()
{
delete myFont;
}
+//=======================================================================
+// Function: setCompass
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setCompass( const QColor& color, const int size, const Position pos )
+{
+ myCol = color;
+ mySize = size;
+ myPos = pos;
+}
+
+//=======================================================================
+// Function: setVisible
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setVisible( const bool vis )
+{
+ myIsVisible = vis;
+}
+
+//=======================================================================
+// Function: setSize
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setSize( const int size )
+{
+ if( size > 0 )
+ mySize=size;
+}
+
+//=======================================================================
+// Function: setArrowWidthTop
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setArrowWidthTop( const int WidthTop )
+{
+ if( WidthTop < myArrowWidthBottom || WidthTop > mySize )
+ return;
+ myArrowWidthTop=WidthTop;
+}
+
+//=======================================================================
+// Function: setArrowWidthBottom
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setArrowWidthBottom( const int WidthBot )
+{
+ if( WidthBot > myArrowWidthTop || WidthBot < 1 )
+ return;
+ myArrowWidthBottom=WidthBot;
+}
+
+//=======================================================================
+// Function: setArrowHeightTop
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setArrowHeightTop( const int HeightTop )
+{
+ if( HeightTop > (2*mySize-myArrowHeightBottom ) || HeightTop < 1 )
+ return;
+ myArrowHeightTop=HeightTop;
+}
+
+//=======================================================================
+// Function: setArrowHeightBottom
+// Purpose :
+//=======================================================================
+void GLViewer_Compass::setArrowHeightBottom( const int HeightBot )
+{
+ if( HeightBot > ( 2*mySize-myArrowHeightTop ) || HeightBot < 1)
+ return;
+ myArrowHeightBottom=HeightBot;
+}
+
+//=======================================================================
+// Function: getFont
+// Purpose :
+//=======================================================================
GLViewer_TexFont* GLViewer_Compass::getFont()
{
if(!isGenereted)
return myFont;
}
+//=======================================================================
+// Function: setFont
+// Purpose :
+//=======================================================================
void GLViewer_Compass::setFont( QFont theFont )
{
delete myFont;
#pragma warning( disable:4251 )
#endif
+/*! Class GLViewer_Compass
+ * Class implement representatiof of compass in one of corner in GLViewer.
+ * Compass it's a some round visual pointer rotated with view window and
+ * located in fixed place (in one fixed corner)
+ */
+
class GLViewer_TexFont;
class GLVIEWER_API GLViewer_Compass
{
public:
- enum Position { TopLeft, TopRight, BottomLeft, BottomRight };
-
- GLViewer_Compass( const QColor& color = QColor ( 0, 255, 0 ),
+ //! Position of compass
+ enum Position
+ {
+ TopLeft,
+ TopRight,
+ BottomLeft,
+ BottomRight
+ };
+
+ //! A constructor
+ /*!
+ *\param color - a color of compass
+ *\param size - a diameter of compass
+ *\param pos - a position
+ *\param WidthTop - width of wide part of arrow
+ *\param WidthBottom - width of base part of arrow
+ *\param HeightTop - height of arrow header
+ *\param HeightBottom - height of arrow cut on bottom
+ */
+ GLViewer_Compass( const QColor& color = QColor ( 0, 255, 0 ),
const int size = 60,
const Position pos = TopRight,
const int WidthTop = 20,
const int WidthBottom = 10,
const int HeightTop = 25,
const int HeightBottom = 7 );
- ~GLViewer_Compass();
-
- void setCompass( const QColor& color, const int size, const Position pos )
- {myCol=color;mySize=size;myPos=pos;};
- void setVisible( const bool vis = true );
- bool getVisible(){ return myIsVisible; };
-
- void setSize( const int size ){mySize=size;};
- int getSize(){ return mySize; };
-
- void setPos( const Position pos ){myPos=pos;};
- int getPos(){ return myPos; };
-
- void setColor( const QColor& color ){myCol=color;};
- QColor getColor(){ return myCol; };
-
- void setArrowWidthTop( const int WidthTop ){ if( WidthTop<myArrowWidthBottom ||
- WidthTop>mySize ) return;
- myArrowWidthTop=WidthTop; };
- int getArrowWidthTop(){return myArrowWidthTop;};
-
- void setArrowWidthBottom( const int WidthBot ){ if( WidthBot>myArrowWidthTop || WidthBot<1 )return;
- myArrowWidthBottom=WidthBot; };
- int getArrowWidthBottom(){return myArrowWidthBottom;};
-
- void setArrowHeightTop( const int HeightTop ){ if( HeightTop>(2*mySize-myArrowHeightBottom ) ||
- HeightTop<1 )return;
- myArrowHeightTop=HeightTop;};
- int getArrowHeightTop(){return myArrowHeightTop;};
-
- void setArrowHeightBottom( const int HeightBot ){ if( HeightBot>( 2*mySize-myArrowHeightTop ) ||
- HeightBot<1)return;
- myArrowHeightBottom=HeightBot;};
- int getArrowHeightBottom(){return myArrowHeightBottom;};
-
- GLViewer_TexFont* getFont();
- void setFont( QFont theFont );
+ //! A destructor
+ ~GLViewer_Compass();
+
+ //! A function installing main parameters of compass
+ void setCompass( const QColor& color, const int size, const Position pos );
+ //! A function installing a visible status
+ void setVisible( const bool vis = true );
+ //! Returns visible status
+ bool getVisible(){ return myIsVisible; };
+
+ //! A function installing diameter
+ void setSize( const int size );
+ //! Returns diameter
+ int getSize(){ return mySize; }
+
+ //! A function installing position
+ void setPos( const Position pos ){ myPos = pos; }
+ //! Returns position
+ int getPos(){ return myPos; }
+
+ //! A function installing color
+ void setColor( const QColor& color ){ myCol = color; }
+ //! Returns color
+ QColor getColor(){ return myCol; }
+
+ //! A function installing width of wide part of arrow
+ void setArrowWidthTop( const int WidthTop );
+ //! Returns width of wide part of arrow
+ int getArrowWidthTop(){ return myArrowWidthTop; }
+
+ //! A function installing width of base part of arrow
+ void setArrowWidthBottom( const int WidthBot );
+ //! Returns width of base part of arrow
+ int getArrowWidthBottom(){return myArrowWidthBottom;};
+
+ //! A function installing height of arrow header
+ void setArrowHeightTop( const int HeightTop );
+ //! Returns height of arrow header
+ int getArrowHeightTop(){return myArrowHeightTop;};
+
+ //! A function installing height of arrow cut on bottom
+ void setArrowHeightBottom( const int HeightBot );
+ //! Returns height of arrow cut on bottom
+ int getArrowHeightBottom(){return myArrowHeightBottom;};
+
+ //! A function installing
+ void setFont( QFont theFont );
+ //! Returns
+ GLViewer_TexFont* getFont();
protected:
- QColor myCol;
- int mySize;
- int myPos;
- bool myIsVisible;
- int myArrowWidthTop;
- int myArrowWidthBottom;
- int myArrowHeightTop;
- int myArrowHeightBottom;
- GLViewer_TexFont* myFont;
- bool isGenereted;
+ //! Compass color
+ QColor myCol;
+ //! Compass diameter
+ int mySize;
+ //! Compass position
+ int myPos;
+ //! Compass invisible status
+ bool myIsVisible;
+ //! Width of wide part of arrow
+ int myArrowWidthTop;
+ //! Width of base part of arrow
+ int myArrowWidthBottom;
+ //! Height of arrow header
+ int myArrowHeightTop;
+ //! Height of arrow cut on bottom
+ int myArrowHeightBottom;
+ //! Compass font
+ GLViewer_TexFont* myFont;
+ //! Status of generated font
+ bool isGenereted;
};
#ifdef WNT