Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:48

0001 // Created on: 2011-03-06
0002 // Created by: Sergey ZERCHANINOV
0003 // Copyright (c) 2011-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Graphic3d_GraduatedTrihedron_HeaderFile
0017 #define _Graphic3d_GraduatedTrihedron_HeaderFile
0018 
0019 #include <Font_FontAspect.hxx>
0020 #include <NCollection_Array1.hxx>
0021 #include <Quantity_Color.hxx>
0022 #include <Standard_Integer.hxx>
0023 #include <TCollection_AsciiString.hxx>
0024 #include <TCollection_ExtendedString.hxx>
0025 
0026 class Graphic3d_CView;
0027 
0028 //! Defines the class of a graduated trihedron.
0029 //! It contains main style parameters for implementation of graduated trihedron
0030 //! @sa OpenGl_GraduatedTrihedron
0031 class Graphic3d_GraduatedTrihedron
0032 {
0033 
0034 public:
0035 
0036   //! Class that stores style for one graduated trihedron axis such as colors, lengths and customization flags.
0037   //! It is used in Graphic3d_GraduatedTrihedron.
0038   class AxisAspect
0039   {
0040   public:
0041 
0042     AxisAspect (const TCollection_ExtendedString theName = "", const Quantity_Color theNameColor = Quantity_NOC_BLACK,
0043                 const Quantity_Color theColor = Quantity_NOC_BLACK,
0044                 const Standard_Integer theValuesOffset = 10, const Standard_Integer theNameOffset = 30,
0045                 const Standard_Integer theTickmarksNumber = 5, const Standard_Integer theTickmarksLength = 10,
0046                 const Standard_Boolean theToDrawName = Standard_True,
0047                 const Standard_Boolean theToDrawValues = Standard_True,
0048                 const Standard_Boolean theToDrawTickmarks = Standard_True)
0049     : myName (theName),
0050       myToDrawName (theToDrawName),
0051       myToDrawTickmarks (theToDrawTickmarks),
0052       myToDrawValues (theToDrawValues),
0053       myNameColor (theNameColor),
0054       myTickmarksNumber (theTickmarksNumber),
0055       myTickmarksLength (theTickmarksLength),
0056       myColor (theColor),
0057       myValuesOffset (theValuesOffset),
0058       myNameOffset (theNameOffset)
0059     { }
0060 
0061   public:
0062 
0063     void SetName (const TCollection_ExtendedString& theName) { myName = theName; }
0064     const TCollection_ExtendedString& Name() const { return myName; }
0065 
0066     Standard_Boolean ToDrawName() const { return myToDrawName; }
0067     void SetDrawName (const Standard_Boolean theToDraw) { myToDrawName = theToDraw; }
0068 
0069     Standard_Boolean ToDrawTickmarks() const { return myToDrawTickmarks; }
0070     void SetDrawTickmarks (const Standard_Boolean theToDraw) { myToDrawTickmarks = theToDraw; }
0071 
0072     Standard_Boolean ToDrawValues() const { return myToDrawValues; }
0073     void SetDrawValues (const Standard_Boolean theToDraw) { myToDrawValues = theToDraw; }
0074 
0075     const Quantity_Color& NameColor() const { return myNameColor; }
0076     void SetNameColor (const Quantity_Color& theColor) { myNameColor = theColor; }
0077 
0078     //! Color of axis and values
0079     const Quantity_Color& Color() const { return myColor; }
0080 
0081     //! Sets color of axis and values
0082     void SetColor (const Quantity_Color& theColor) { myColor = theColor; }
0083 
0084     Standard_Integer TickmarksNumber() const { return myTickmarksNumber; }
0085     void SetTickmarksNumber (const Standard_Integer theValue) { myTickmarksNumber = theValue; }
0086 
0087     Standard_Integer TickmarksLength() const { return myTickmarksLength; }
0088     void SetTickmarksLength (const Standard_Integer theValue) { myTickmarksLength = theValue; }
0089 
0090     Standard_Integer ValuesOffset() const { return myValuesOffset; }
0091     void SetValuesOffset (const Standard_Integer theValue) { myValuesOffset = theValue; }
0092 
0093     Standard_Integer NameOffset() const { return myNameOffset; }
0094     void SetNameOffset (const Standard_Integer theValue) { myNameOffset = theValue; }
0095 
0096   protected:
0097 
0098     TCollection_ExtendedString myName;
0099 
0100     Standard_Boolean myToDrawName;
0101     Standard_Boolean myToDrawTickmarks;
0102     Standard_Boolean myToDrawValues;
0103 
0104     Quantity_Color   myNameColor;
0105 
0106     Standard_Integer myTickmarksNumber; //!< Number of splits along axes
0107     Standard_Integer myTickmarksLength; //!< Length of tickmarks
0108     Quantity_Color   myColor;           //!< Color of axis and values
0109 
0110     Standard_Integer myValuesOffset;    //!< Offset for drawing values
0111     Standard_Integer myNameOffset;      //!< Offset for drawing name of axis
0112   };
0113 
0114 public:
0115 
0116   typedef void (*MinMaxValuesCallback) (Graphic3d_CView*);
0117 
0118 public:
0119 
0120   //! Default constructor
0121   //! Constructs the default graduated trihedron with grid, X, Y, Z axes, and tickmarks
0122   Graphic3d_GraduatedTrihedron (const TCollection_AsciiString& theNamesFont = "Arial",
0123                                 const Font_FontAspect& theNamesStyle = Font_FA_Bold, const Standard_Integer theNamesSize = 12,
0124                                 const TCollection_AsciiString& theValuesFont = "Arial",
0125                                 const Font_FontAspect& theValuesStyle = Font_FA_Regular, const Standard_Integer theValuesSize = 12,
0126                                 const Standard_ShortReal theArrowsLength = 30.0f, const Quantity_Color theGridColor = Quantity_NOC_WHITE,
0127                                 const Standard_Boolean theToDrawGrid = Standard_True, const Standard_Boolean theToDrawAxes = Standard_True)
0128   : myCubicAxesCallback (NULL),
0129     myNamesFont (theNamesFont),
0130     myNamesStyle (theNamesStyle),
0131     myNamesSize (theNamesSize),
0132     myValuesFont (theValuesFont),
0133     myValuesStyle (theValuesStyle),
0134     myValuesSize (theValuesSize),
0135     myArrowsLength (theArrowsLength),
0136     myGridColor (theGridColor),
0137     myToDrawGrid (theToDrawGrid),
0138     myToDrawAxes (theToDrawAxes),
0139     myAxes(0, 2)
0140   {
0141     myAxes (0) = AxisAspect ("X", Quantity_NOC_RED, Quantity_NOC_RED);
0142     myAxes (1) = AxisAspect ("Y", Quantity_NOC_GREEN, Quantity_NOC_GREEN);
0143     myAxes (2) = AxisAspect ("Z", Quantity_NOC_BLUE1, Quantity_NOC_BLUE1);
0144   }
0145 
0146 public:
0147 
0148   AxisAspect& ChangeXAxisAspect() { return myAxes(0); }
0149   AxisAspect& ChangeYAxisAspect() { return myAxes(1); }
0150   AxisAspect& ChangeZAxisAspect() { return myAxes(2); }
0151 
0152   AxisAspect& ChangeAxisAspect (const Standard_Integer theIndex)
0153   {
0154     Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::ChangeAxisAspect: theIndex is out of bounds [0,2].");
0155     return myAxes (theIndex);
0156   }
0157 
0158   const AxisAspect& XAxisAspect() const { return myAxes(0); }
0159   const AxisAspect& YAxisAspect() const { return myAxes(1); }
0160   const AxisAspect& ZAxisAspect() const { return myAxes(2); }
0161 
0162   const AxisAspect& AxisAspectAt (const Standard_Integer theIndex) const
0163   {
0164     Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::AxisAspect: theIndex is out of bounds [0,2].");
0165     return myAxes (theIndex);
0166   }
0167 
0168   Standard_ShortReal ArrowsLength() const { return myArrowsLength; }
0169   void SetArrowsLength (const Standard_ShortReal theValue) { myArrowsLength = theValue; }
0170 
0171   const Quantity_Color& GridColor() const { return myGridColor; }
0172   void SetGridColor (const Quantity_Color& theColor) {myGridColor = theColor; }
0173 
0174   Standard_Boolean ToDrawGrid() const { return myToDrawGrid; }
0175   void SetDrawGrid (const Standard_Boolean theToDraw) { myToDrawGrid = theToDraw; }
0176 
0177   Standard_Boolean ToDrawAxes() const { return myToDrawAxes; }
0178   void SetDrawAxes (const Standard_Boolean theToDraw) { myToDrawAxes = theToDraw; }
0179 
0180   const TCollection_AsciiString& NamesFont() const { return myNamesFont; }
0181   void SetNamesFont (const TCollection_AsciiString& theFont) { myNamesFont = theFont; }
0182 
0183   Font_FontAspect NamesFontAspect() const { return myNamesStyle; }
0184   void SetNamesFontAspect (Font_FontAspect theAspect) { myNamesStyle = theAspect; }
0185 
0186   Standard_Integer NamesSize() const { return myNamesSize; }
0187   void SetNamesSize (const Standard_Integer theValue) { myNamesSize = theValue; }
0188 
0189   const TCollection_AsciiString& ValuesFont () const { return myValuesFont; }
0190   void SetValuesFont (const TCollection_AsciiString& theFont) { myValuesFont = theFont; }
0191 
0192   Font_FontAspect ValuesFontAspect() const { return myValuesStyle; }
0193   void SetValuesFontAspect (Font_FontAspect theAspect) { myValuesStyle = theAspect; }
0194 
0195   Standard_Integer ValuesSize() const { return myValuesSize; }
0196   void SetValuesSize (const Standard_Integer theValue) { myValuesSize = theValue; }
0197 
0198   Standard_Boolean CubicAxesCallback(Graphic3d_CView* theView) const
0199   {
0200     if (myCubicAxesCallback != NULL)
0201     {
0202       myCubicAxesCallback (theView);
0203       return Standard_True;
0204     }
0205     return Standard_False;
0206   }
0207   void SetCubicAxesCallback (const MinMaxValuesCallback theCallback) { myCubicAxesCallback = theCallback; }
0208 
0209 protected:
0210 
0211   MinMaxValuesCallback myCubicAxesCallback; //!< Callback function to define boundary box of displayed objects
0212 
0213   TCollection_AsciiString myNamesFont;  //!< Font name of names of axes: Courier, Arial, ...
0214   Font_FontAspect         myNamesStyle; //!< Style of names of axes: OSD_FA_Regular, OSD_FA_Bold,..
0215   Standard_Integer        myNamesSize;  //!< Size of names of axes: 8, 10,..
0216 
0217 protected:
0218 
0219   TCollection_AsciiString myValuesFont;  //!< Font name of values: Courier, Arial, ...
0220   Font_FontAspect         myValuesStyle; //!< Style of values: OSD_FA_Regular, OSD_FA_Bold, ...
0221   Standard_Integer        myValuesSize;  //!< Size of values: 8, 10, 12, 14, ...
0222 
0223 protected:
0224 
0225   Standard_ShortReal myArrowsLength;
0226   Quantity_Color     myGridColor;
0227 
0228   Standard_Boolean   myToDrawGrid;
0229   Standard_Boolean   myToDrawAxes;
0230 
0231   NCollection_Array1<AxisAspect> myAxes; //!< X, Y and Z axes parameters
0232 
0233 };
0234 #endif // Graphic3d_GraduatedTrihedron_HeaderFile