1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0025611: Displaying 'zbufftrihedron' interferes with 'graduatedtrihedron':

- Graphic3d_CGraduatedTrihedron:  moved to Graphic3d_GraduatedTrihedron, added Graphic3d_AxisAspect for axes parameters
- OpenGl_GraduatedTrihedron: moved to primitive arrays, used Graphic3d_GraduatedTrihedron to store parameters
- ViewerTest: corrected vgraduatedtrihedron, added new parameters
- Graphic3d_ArrayOfPrimitives: added AddVertex (Graphic3d_Vec3)
- Graphic3d_GraphicDriver::GraduatedTrihedronMinMaxValues corrected interface
This commit is contained in:
aba 2015-03-06 12:23:44 +03:00 committed by bugmaster
parent 41e259eb8b
commit a79f67f8d8
23 changed files with 1708 additions and 1798 deletions

View File

@ -21,7 +21,7 @@ Graphic3d_CTexture.hxx
Graphic3d_CLight.hxx Graphic3d_CLight.hxx
Graphic3d_CUserDraw.hxx Graphic3d_CUserDraw.hxx
Graphic3d_CView.hxx Graphic3d_CView.hxx
Graphic3d_CGraduatedTrihedron.hxx Graphic3d_GraduatedTrihedron.hxx
Graphic3d_ViewAffinity.hxx Graphic3d_ViewAffinity.hxx
Graphic3d_ViewAffinity.cxx Graphic3d_ViewAffinity.cxx
Graphic3d_MapOfObject.hxx Graphic3d_MapOfObject.hxx

View File

@ -405,7 +405,7 @@ is
---Purpose: Describes rendering parameters and effects. ---Purpose: Describes rendering parameters and effects.
---Category: Imported types ---Category: Imported types
imported CGraduatedTrihedron; imported GraduatedTrihedron;
---Category: Imported types ---Category: Imported types
imported ClipPlane; imported ClipPlane;

View File

@ -38,6 +38,7 @@ uses
Buffer_Handle from Graphic3d, Buffer_Handle from Graphic3d,
BoundBuffer_Handle from Graphic3d, BoundBuffer_Handle from Graphic3d,
IndexBuffer_Handle from Graphic3d, IndexBuffer_Handle from Graphic3d,
Vec3 from Graphic3d,
Color from Quantity, Color from Quantity,
Pnt from gp, Pnt from gp,
Pnt2d from gp, Pnt2d from gp,
@ -87,6 +88,7 @@ is
raises OutOfRange from Standard; raises OutOfRange from Standard;
-- if the actual vertex number is >= <maxVertexs> -- if the actual vertex number is >= <maxVertexs>
---C++: inline ---C++: inline
---C++: alias "Standard_Integer AddVertex (const Graphic3d_Vec3& theVertex);"
AddVertex( me:mutable; AddVertex( me:mutable;
X,Y,Z: Real from Standard) X,Y,Z: Real from Standard)

View File

@ -63,6 +63,11 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& th
return AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z()); return AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
} }
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Graphic3d_Vec3& theVertex)
{
return AddVertex (theVertex.x(), theVertex.y(), theVertex.z());
}
inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX, inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX,
const Standard_Real theY, const Standard_Real theY,
const Standard_Real theZ) const Standard_Real theZ)

View File

@ -1,104 +0,0 @@
// Created on: 2011-03-06
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Graphic3d_CGraduatedTrihedron_HeaderFile
#define _Graphic3d_CGraduatedTrihedron_HeaderFile
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Quantity_Color.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Font_FontAspect.hxx>
class Visual3d_View;
//! Defines the C structure of a graduated trihedron.
class Graphic3d_CGraduatedTrihedron
{
public:
typedef void (*minMaxValuesCallback)(Visual3d_View*);
public:
/* Default constructor. Nullifies the view pointer */
Graphic3d_CGraduatedTrihedron () : xdrawname ( Standard_False ),
ydrawname ( Standard_False ),
zdrawname ( Standard_False ),
xdrawvalues ( Standard_False ),
ydrawvalues ( Standard_False ),
zdrawvalues ( Standard_False ),
drawgrid ( Standard_False ),
drawaxes ( Standard_False ),
nbx ( 0 ),nby ( 0 ),nbz ( 0 ),
xoffset ( 0 ),yoffset ( 0 ),zoffset ( 0 ),
xaxisoffset ( 0 ),yaxisoffset ( 0 ),zaxisoffset ( 0 ),
xdrawtickmarks ( Standard_False ),
ydrawtickmarks ( Standard_False ),
zdrawtickmarks ( Standard_False ),
xtickmarklength ( 0 ), ytickmarklength ( 0 ), ztickmarklength ( 0 ),
styleOfNames ( Font_FA_Undefined ),
sizeOfNames ( 0 ),
styleOfValues ( Font_FA_Undefined ),
sizeOfValues ( 0 ),
cbCubicAxes ( NULL ),
ptrVisual3dView(NULL)
{
//
}
/* Names of axes */
TCollection_ExtendedString xname, yname, zname;
/* Draw names */
Standard_Boolean xdrawname, ydrawname, zdrawname;
/* Draw values */
Standard_Boolean xdrawvalues, ydrawvalues, zdrawvalues;
/* Draw grid */
Standard_Boolean drawgrid;
/* Draw axes */
Standard_Boolean drawaxes;
/* Number of splits along axes */
Standard_Integer nbx, nby, nbz;
/* Offset for drawing values */
Standard_Integer xoffset, yoffset, zoffset;
/* Offset for drawing names of axes */
Standard_Integer xaxisoffset, yaxisoffset, zaxisoffset;
/* Draw tickmarks */
Standard_Boolean xdrawtickmarks, ydrawtickmarks, zdrawtickmarks;
/* Length of tickmarks */
Standard_Integer xtickmarklength, ytickmarklength, ztickmarklength;
/* Grid color */
Quantity_Color gridcolor;
/* Colors of axis names */
Quantity_Color xnamecolor, ynamecolor, znamecolor;
/* Colors of axis and values */
Quantity_Color xcolor, ycolor, zcolor;
/* Font name of names of axes: Courier, Arial, ... */
TCollection_AsciiString fontOfNames;
/* Style of names of axes: OSD_FA_Regular, OSD_FA_Bold, ... */
Font_FontAspect styleOfNames;
/* Size of names of axes: 8, 10, 12, 14, ... */
Standard_Integer sizeOfNames;
/* Font name of values: Courier, Arial, ... */
TCollection_AsciiString fontOfValues;
/* Style of values: OSD_FA_Regular, OSD_FA_Bold, ... */
Font_FontAspect styleOfValues;
/* Size of values: 8, 10, 12, 14, ... */
Standard_Integer sizeOfValues;
/* Callback function to define boundary box of displayed objects */
minMaxValuesCallback cbCubicAxes;
Visual3d_View* ptrVisual3dView;
};
#endif /*Graphic3d_CGraduatedTrihedron_HeaderFile*/

View File

@ -0,0 +1,218 @@
// Created on: 2011-03-06
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Graphic3d_GraduatedTrihedron_HeaderFile
#define _Graphic3d_GraduatedTrihedron_HeaderFile
#include <Font_FontAspect.hxx>
#include <NCollection_Array1.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
class Visual3d_View;
//! Class that stores style for one graduated trihedron axis such as colors, lengths and customization flags.
//! It is used in Graphic3d_GraduatedTrihedron.
class Graphic3d_AxisAspect
{
public:
Graphic3d_AxisAspect (const TCollection_ExtendedString theName = "", const Quantity_Color theNameColor = Quantity_NOC_BLACK,
const Quantity_Color theColor = Quantity_NOC_BLACK,
const Standard_Integer theValuesOffset = 10, const Standard_Integer theNameOffset = 30,
const Standard_Integer theTickmarkNumber = 5, const Standard_Integer theTickmarkLength = 10,
const Standard_Boolean theToDrawName = Standard_True,
const Standard_Boolean theToDrawValues = Standard_True,
const Standard_Boolean theToDrawTickmarks = Standard_True)
: myName (theName),
myToDrawName (theToDrawName),
myToDrawTickmarks (theToDrawTickmarks),
myToDrawValues (theToDrawValues),
myNameColor (theNameColor),
myTickmarkNumber (theTickmarkNumber),
myTickmarkLength (theTickmarkLength),
myColor (theColor),
myValuesOffset (theValuesOffset),
myNameOffset (theNameOffset)
{ }
public:
void SetName (const TCollection_ExtendedString& theName) { myName = theName; }
const TCollection_ExtendedString& Name() const { return myName; }
const Standard_Boolean ToDrawName() const { return myToDrawName; }
void SetToDrawName (const Standard_Boolean theToDraw) { myToDrawName = theToDraw; }
const Standard_Boolean ToDrawTickmarks() const { return myToDrawTickmarks; }
void SetToDrawTickmarks (const Standard_Boolean theToDraw) { myToDrawTickmarks = theToDraw; }
const Standard_Boolean ToDrawValues() const { return myToDrawValues; }
void SetToDrawValues (const Standard_Boolean theToDraw) { myToDrawValues = theToDraw; }
const Quantity_Color& NameColor() const { return myNameColor; }
void SetNameColor (const Quantity_Color& theColor) { myNameColor = theColor; }
//! Color of axis and values
const Quantity_Color& Color() const { return myColor; }
//! Sets color of axis and values
void SetColor (const Quantity_Color& theColor) { myColor = theColor; }
const Standard_Integer TickmarkNumber() const { return myTickmarkNumber; }
void SetTickmarkNumber (const Standard_Integer theValue) { myTickmarkNumber = theValue; }
const Standard_Integer TickmarkLength() const { return myTickmarkLength; }
void SetTickmarkLength (const Standard_Integer theValue) { myTickmarkLength = theValue; }
const Standard_Integer ValuesOffset() const { return myValuesOffset; }
void SetValuesOffset (const Standard_Integer theValue) { myValuesOffset = theValue; }
const Standard_Integer NameOffset() const { return myNameOffset; }
void SetNameOffset (const Standard_Integer theValue) { myNameOffset = theValue; }
protected:
TCollection_ExtendedString myName;
Standard_Boolean myToDrawName;
Standard_Boolean myToDrawTickmarks;
Standard_Boolean myToDrawValues;
Quantity_Color myNameColor;
Standard_Integer myTickmarkNumber; //!< Number of splits along axes
Standard_Integer myTickmarkLength; //!< Length of tickmarks
Quantity_Color myColor; //!< Color of axis and values
Standard_Integer myValuesOffset; //!< Offset for drawing values
Standard_Integer myNameOffset; //!< Offset for drawing name of axis
};
//! Defines the class of a graduated trihedron.
//! It contains main style parameters for implementation of graduated trihedron
//! @sa OpenGl_GraduatedTrihedron
class Graphic3d_GraduatedTrihedron
{
public:
typedef void (*MinMaxValuesCallback) (Visual3d_View*);
public:
//! Default constructor
//! Constructs the default graduated trihedron with grid, X, Y, Z axes, and tickmarks
Graphic3d_GraduatedTrihedron (const TCollection_AsciiString& theNamesFont = "Arial",
const Font_FontAspect& theNameStyle = Font_FA_Bold, const Standard_Integer theNamesSize = 12,
const TCollection_AsciiString& theValuesFont = "Arial",
const Font_FontAspect& theValuesStyle = Font_FA_Regular, const Standard_Integer theValuesSize = 12,
const Standard_ShortReal theArrowLength = 30.0f, const Quantity_Color theGridColor = Quantity_NOC_WHITE,
const Standard_Boolean theToDrawGrid = Standard_True, const Standard_Boolean theToDrawAxes = Standard_True)
: myNamesFont (theNamesFont),
myNamesStyle (theNameStyle),
myNamesSize (theNamesSize),
myValuesFont (theValuesFont),
myValuesStyle (theValuesStyle),
myValuesSize (theValuesSize),
myArrowLength (theArrowLength),
myGridColor (theGridColor),
myToDrawGrid (theToDrawGrid),
myToDrawAxes (theToDrawAxes),
myAxes(0, 2)
{
myAxes (0) = Graphic3d_AxisAspect ("X", Quantity_NOC_RED, Quantity_NOC_RED);
myAxes (1) = Graphic3d_AxisAspect ("Y", Quantity_NOC_GREEN, Quantity_NOC_GREEN);
myAxes (2) = Graphic3d_AxisAspect ("Z", Quantity_NOC_BLUE1, Quantity_NOC_BLUE1);
PtrVisual3dView = NULL;
}
public:
Graphic3d_AxisAspect& ChangeXAxisAspect() { return myAxes(0); }
Graphic3d_AxisAspect& ChangeYAxisAspect() { return myAxes(1); }
Graphic3d_AxisAspect& ChangeZAxisAspect() { return myAxes(2); }
const Graphic3d_AxisAspect& XAxisAspect() const { return myAxes(0); }
const Graphic3d_AxisAspect& YAxisAspect() const { return myAxes(1); }
const Graphic3d_AxisAspect& ZAxisAspect() const { return myAxes(2); }
const Graphic3d_AxisAspect& AxisAspect (const Standard_Integer theIndex) const
{
Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::AxisAspect: theIndex is out of bounds [0,2].");
return myAxes (theIndex);
}
const Standard_ShortReal ArrowLength() const { return myArrowLength; }
void SetArrowLength (const Standard_ShortReal theValue) { myArrowLength = theValue; }
const Quantity_Color& GridColor() const { return myGridColor; }
void SetGridColor (const Quantity_Color& theColor) {myGridColor = theColor; }
const Standard_Boolean ToDrawGrid() const { return myToDrawGrid; }
void SetToDrawTickmarks (const Standard_Boolean theToDraw) { myToDrawGrid = theToDraw; }
const Standard_Boolean ToDrawAxes() const { return myToDrawAxes; }
void SetToDrawAxes (const Standard_Boolean theToDraw) { myToDrawAxes = theToDraw; }
const TCollection_AsciiString& NamesFont() const { return myNamesFont; }
void SetNamesFont (const TCollection_AsciiString& theFont) { myNamesFont = theFont; }
const Font_FontAspect& NamesFontAspect() const { return myNamesStyle; }
void SetNamesFontAspect (const Font_FontAspect& theAspect) { myNamesStyle = theAspect; }
const Standard_Integer NamesSize() const { return myNamesSize; }
void SetNamesSize (const Standard_Integer theValue) { myNamesSize = theValue; }
const TCollection_AsciiString& ValuesFont () const { return myValuesFont; }
void SetValuesFont (const TCollection_AsciiString& theFont) { myValuesFont = theFont; }
const Font_FontAspect& ValuesFontAspect() const { return myValuesStyle; }
void SetValuesFontAspect (const Font_FontAspect& theAspect) { myValuesStyle = theAspect; }
const Standard_Integer ValuesSize() const { return myValuesSize; }
void SetValuesSize (const Standard_Integer theValue) { myValuesSize = theValue; }
public:
MinMaxValuesCallback CubicAxesCallback; //!< Callback function to define boundary box of displayed objects
Visual3d_View* PtrVisual3dView;
protected:
TCollection_AsciiString myNamesFont; //!< Font name of names of axes: Courier, Arial, ...
Font_FontAspect myNamesStyle; //!< Style of names of axes: OSD_FA_Regular, OSD_FA_Bold,..
Standard_Integer myNamesSize; //!< Size of names of axes: 8, 10,..
protected:
TCollection_AsciiString myValuesFont; //!< Font name of values: Courier, Arial, ...
Font_FontAspect myValuesStyle; //!< Style of values: OSD_FA_Regular, OSD_FA_Bold, ...
Standard_Integer myValuesSize; //!< Size of values: 8, 10, 12, 14, ...
protected:
Standard_ShortReal myArrowLength;
Quantity_Color myGridColor;
Standard_Boolean myToDrawGrid;
Standard_Boolean myToDrawAxes;
NCollection_Array1<Graphic3d_AxisAspect> myAxes; //!< X, Y and Z axes parameters
};
#endif // Graphic3d_GraduatedTrihedron_HeaderFile

View File

@ -86,8 +86,9 @@ uses
CUserDraw from Graphic3d, CUserDraw from Graphic3d,
NListOfHAsciiString from Graphic3d, NListOfHAsciiString from Graphic3d,
FontAspect from Font, FontAspect from Font,
CGraduatedTrihedron from Graphic3d, GraduatedTrihedron from Graphic3d,
ClipPlane from Graphic3d, ClipPlane from Graphic3d,
Vec3 from Graphic3d,
Ax2 from gp Ax2 from gp
raises raises
@ -328,24 +329,26 @@ is
--------------------------------- ---------------------------------
GraduatedTrihedronDisplay(me : mutable; GraduatedTrihedronDisplay(me : mutable;
view : CView from Graphic3d; theView : CView from Graphic3d;
cubic : CGraduatedTrihedron from Graphic3d) theCubic : GraduatedTrihedron from Graphic3d)
---Purpose: call_togl_graduatedtrihedron_display ---Purpose: call_togl_graduatedtrihedron_display
is deferred; is deferred;
GraduatedTrihedronErase(me : mutable; GraduatedTrihedronErase(me : mutable;
view : CView from Graphic3d) theView : CView from Graphic3d)
---Purpose: call_togl_graduatedtrihedron_erase ---Purpose: call_togl_graduatedtrihedron_erase
is deferred; is deferred;
GraduatedTrihedronMinMaxValues(me : mutable; GraduatedTrihedronMinMaxValues (me : mutable;
xmin : ShortReal from Standard; theView : CView from Graphic3d;
ymin : ShortReal from Standard; theMin : Vec3 from Graphic3d;
zmin : ShortReal from Standard; theMax : Vec3 from Graphic3d)
xmax : ShortReal from Standard; ---Purpose: Sets minimum and maximum points of scene bounding box for Graduated Trihedron
ymax : ShortReal from Standard; -- stored in graphic view object.
zmax : ShortReal from Standard) -- @param theView [in] current graphic view
---Purpose: call_togl_graduatedtrihedron_minmaxvalues -- @param theMin [in] the minimum point of scene.
-- @param theMax [in] the maximum point of scene.
is deferred; is deferred;
---------------------------------- ----------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -16,70 +16,230 @@
#ifndef _OpenGl_GraduatedTrihedron_Header #ifndef _OpenGl_GraduatedTrihedron_Header
#define _OpenGl_GraduatedTrihedron_Header #define _OpenGl_GraduatedTrihedron_Header
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <gp_Ax1.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <NCollection_Array1.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Element.hxx> #include <OpenGl_Element.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Text.hxx> #include <OpenGl_Text.hxx>
#include <Graphic3d_CGraduatedTrihedron.hxx>
class Visual3d_View; class Visual3d_View;
class OpenGl_View; class OpenGl_View;
static const OpenGl_TextParam THE_LABEL_PARAMS =
{
16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
};
//! This class allows to render Graduated Trihedron, i.e. trihedron with grid.
//! it is based on Graphic3d_GraduatedTrihedron parameters and support its customization
//! on construction level only.
//! @sa Graphic3d_GraduatedTrihedron
class OpenGl_GraduatedTrihedron : public OpenGl_Element class OpenGl_GraduatedTrihedron : public OpenGl_Element
{ {
public:
DEFINE_STANDARD_ALLOC
public: public:
static void SetMinMax (const Standard_ShortReal xMin, const Standard_ShortReal yMin, const Standard_ShortReal zMin, OpenGl_GraduatedTrihedron (const Graphic3d_GraduatedTrihedron& theData);
const Standard_ShortReal xMax, const Standard_ShortReal yMax, const Standard_ShortReal zMax);
public:
OpenGl_GraduatedTrihedron (const Graphic3d_CGraduatedTrihedron& theData);
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
virtual void Release (OpenGl_Context* theCtx); virtual void Release (OpenGl_Context* theCtx);
//! Sets up-to-date values of scene bounding box.
//! Can be used in callback mechanism to get up-to-date values.
//! @sa Graphic3d_GraduatedTrihedron::CubicAxesCallback
void SetMinMax (const OpenGl_Vec3& theMin, const OpenGl_Vec3& theMax);
protected: protected:
virtual ~OpenGl_GraduatedTrihedron(); virtual ~OpenGl_GraduatedTrihedron();
private:
//! Axis of trihedron. It incapsulates geometry and style.
class Axis
{
public:
OpenGl_Vec3 Direction;
TEL_COLOUR NameColor;
OpenGl_AspectLine LineAspect;
mutable OpenGl_Text Label;
mutable OpenGl_PrimitiveArray* Tickmark;
mutable OpenGl_PrimitiveArray* Line;
mutable OpenGl_PrimitiveArray* Arrow;
public:
Axis (const Graphic3d_AxisAspect& theAspect = Graphic3d_AxisAspect(),
const OpenGl_Vec3& theDirection = OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
Axis& operator= (const Axis& theOther);
~Axis()
{
OpenGl_Element::Destroy (NULL, Line);
OpenGl_Element::Destroy (NULL, Tickmark);
OpenGl_Element::Destroy (NULL, Arrow);
}
void InitArrow (const Handle(OpenGl_Context)& theContext,
const Standard_ShortReal theLength,
const OpenGl_Vec3& theNormal) const;
void InitTickmark (const Handle(OpenGl_Context)& theContext,
const OpenGl_Vec3& theDir) const;
void InitLine (const Handle(OpenGl_Context)& theContext,
const OpenGl_Vec3& theDir) const;
void Release (OpenGl_Context* theCtx);
};
private:
//! Struct for triple of orthonormal vectors
//! and origin point, and axes for tickmarks.
//! It may be not a right or left coordinate system.
struct GridAxes
{
public:
GridAxes()
: Origin (0, 0, 0)
{
Axes[0] = OpenGl_Vec3 (1.0f, 0.0f, 0.0f);
Axes[1] = OpenGl_Vec3 (0.0f, 1.0f, 0.0f);
Axes[2] = OpenGl_Vec3 (0.0f, 0.0f, 1.0f);
Ticks[0] = OpenGl_Vec3 (0.0f, 0.0f, 0.0f);
Ticks[1] = OpenGl_Vec3 (0.0f, 0.0f, 0.0f);
Ticks[2] = OpenGl_Vec3 (0.0f, 0.0f, 0.0f);
}
public: //! @name Main grid directions
OpenGl_Vec3 Origin;
OpenGl_Vec3 Axes[3];
public: //! @name Directions for tickmarks
OpenGl_Vec3 Ticks[3];
};
private:
//! Gets normal of the view out of user.
//! @param theContext [in] OpenGL Context
//! @param theNormal [out] normal of the view out of user
//! @return distance corresponding to 1 pixel
Standard_ShortReal getNormal (const Handle(OpenGl_Context)& theContext,
OpenGl_Vec3& theNormal) const;
//! Gets distance to point (theX, theY, theZ) of bounding box along the normal
//! @param theNormal [in] normal of the view out of user
//! @param theCenter [in] geometry center of bounding box
//! @param theX [in] x of target point
//! @param theY [in] y of target point
//! @param theZ [in] z of terget point
Standard_ShortReal getDistanceToCorner (const OpenGl_Vec3& theNormal,
const OpenGl_Vec3& theCenter,
const Standard_ShortReal theX,
const Standard_ShortReal theY,
const Standard_ShortReal theZ) const;
//! Gets axes of grid
//! @param theCorners [in] the corners of grid
//! @param theGridAxes [out] grid axes, the base of graduated trihedron grid.
Standard_ExtCharacter getGridAxes (const Standard_ShortReal theCorners[8],
GridAxes& theGridAxes) const;
//! Render line from the transformed primitive array myLine
//! @param theWorkspace [in] the OpenGl Workspace
//! @param theMat [in] theMat that containes base transformation and is used for appling
//! translation and rotation
//! @param thaTx the X for vector of translation
//! @param thaTy the Y for vector of translation
//! @param thaTz the Z for vector of translation
void renderLine (const OpenGl_PrimitiveArray* theLine,
const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Mat4& theMat,
const Standard_ShortReal theXt,
const Standard_ShortReal theYt,
const Standard_ShortReal theZt) const;
//! Render grid lines perpendecular the axis of input index
//! @param theWorkspace [in] the OpenGl Workspace
//! @param theIndex [in] index of axis
//! @param theGridAxes [in] grid axes
//! @param theMat [in] theMat that containes base transformation and is used for appling
//! translation and rotation
void renderGridPlane (const Handle(OpenGl_Workspace)& theWorkspace,
const Standard_Integer& theIndex,
const GridAxes& theGridAxes,
OpenGl_Mat4& theMat) const;
//! Render the axis of input index
//! @param theWorkspace [in] the OpenGl Workspace
//! @param theIndex [in] index of axis
//! @param theMat [in] theMat that containes base transformation and is used for appling
//! translation and rotation
void renderAxis (const Handle(OpenGl_Workspace)& theWorkspace,
const Standard_Integer& theIndex,
const OpenGl_Mat4& theMat) const;
//! Render grid labels, tickmark lines and labels
//! @param theWorkspace [in] the OpenGl Workspace
//! @param theMat [in] theMat that containes base transformation and is used for appling
//! translation and rotation
//! @param theIndex [in] index of axis
//! @param theGridAxes [in] grid axes
//! @param theDpix [in] distance corresponding to 1 pixel
void renderTickmarkLabels (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Mat4& theMat,
const Standard_Integer theIndex,
const GridAxes& theGridAxes,
const Standard_ShortReal theDpix) const;
protected: //! @name Scene bounding box values
OpenGl_Vec3 myMin;
OpenGl_Vec3 myMax;
protected: protected:
mutable OpenGl_Text myLabelX; Axis myAxes[3]; //!< Axes for trihedron
mutable OpenGl_Text myLabelY;
mutable OpenGl_Text myLabelZ; Graphic3d_GraduatedTrihedron myData;
OpenGl_AspectLine myGridLineAspect; //!< Color grid properties
protected: //! @name Labels properties
mutable OpenGl_Text myLabelValues; mutable OpenGl_Text myLabelValues;
mutable OpenGl_AspectText myAspectLabels; mutable OpenGl_AspectText myAspectLabels;
mutable OpenGl_AspectText myAspectValues; mutable OpenGl_AspectText myAspectValues;
TEL_COLOUR myXNameColor;
TEL_COLOUR myYNameColor;
TEL_COLOUR myZNameColor;
bool myToDrawXName; private:
bool myToDrawYName;
bool myToDrawZName;
bool myToDrawXValues;
bool myToDrawYValues;
bool myToDrawZValues;
bool myToDrawGrid;
bool myToDrawAxes;
unsigned int myNbX, myNbY, myNbZ;
int myXOffset, myYOffset, myZOffset;
int myXAxisOffset, myYAxisOffset, myZAxisOffset;
Standard_Boolean myDrawXTickmarks;
Standard_Boolean myDrawYTickmarks;
Standard_Boolean myDrawZTickmarks;
unsigned int myXTickmarkLength, myYTickmarkLength, myZTickmarkLength;
float myGridColor[3];
TEL_COLOUR myXColor;
TEL_COLOUR myYColor;
TEL_COLOUR myZColor;
Graphic3d_CGraduatedTrihedron::minMaxValuesCallback myCbCubicAxes;
Visual3d_View* myPtrVisual3dView;
public: enum AxisFlags
{
DEFINE_STANDARD_ALLOC XOO_XYO = 1 << 1,
XOO_XOZ = 1 << 2,
OYO_OYZ = 1 << 3,
OYO_XYO = 1 << 4,
OOZ_XOZ = 1 << 5,
OOZ_OYZ = 1 << 6,
OYZ_XYZ = 1 << 7,
XOZ_XYZ = 1 << 8,
XYO_XYZ = 1 << 9
};
}; };

View File

@ -606,7 +606,7 @@ void OpenGl_GraphicDriver::SetBgGradientStyle (const Graphic3d_CView& t
// purpose : // purpose :
// ======================================================================= // =======================================================================
void OpenGl_GraphicDriver::GraduatedTrihedronDisplay (const Graphic3d_CView& theCView, void OpenGl_GraphicDriver::GraduatedTrihedronDisplay (const Graphic3d_CView& theCView,
const Graphic3d_CGraduatedTrihedron& theCubic) const Graphic3d_GraduatedTrihedron& theCubic)
{ {
const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
if (aCView != NULL) if (aCView != NULL)
@ -632,12 +632,13 @@ void OpenGl_GraphicDriver::GraduatedTrihedronErase (const Graphic3d_CView& theCV
// function : GraduatedTrihedronMinMaxValues // function : GraduatedTrihedronMinMaxValues
// purpose : // purpose :
// ======================================================================= // =======================================================================
void OpenGl_GraphicDriver::GraduatedTrihedronMinMaxValues (const Standard_ShortReal theMinX, void OpenGl_GraphicDriver::GraduatedTrihedronMinMaxValues (const Graphic3d_CView& theView,
const Standard_ShortReal theMinY, const Graphic3d_Vec3 theMin,
const Standard_ShortReal theMinZ, const Graphic3d_Vec3 theMax)
const Standard_ShortReal theMaxX,
const Standard_ShortReal theMaxY,
const Standard_ShortReal theMaxZ)
{ {
OpenGl_GraduatedTrihedron::SetMinMax (theMinX, theMinY, theMinZ, theMaxX, theMaxY, theMaxZ); const OpenGl_CView* aCView = (const OpenGl_CView* )theView.ptrView;
if (aCView != NULL)
{
aCView->View->GraduatedTrihedron()->SetMinMax (theMin, theMax);
}
} }

View File

@ -46,7 +46,7 @@
#include <Graphic3d_HorizontalTextAlignment.hxx> #include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx> #include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_CUserDraw.hxx> #include <Graphic3d_CUserDraw.hxx>
#include <Graphic3d_CGraduatedTrihedron.hxx> #include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_TypeOfComposition.hxx> #include <Graphic3d_TypeOfComposition.hxx>
#include <Graphic3d_ExportFormat.hxx> #include <Graphic3d_ExportFormat.hxx>
#include <Graphic3d_SortType.hxx> #include <Graphic3d_SortType.hxx>
@ -171,9 +171,28 @@ public:
Standard_EXPORT void TriedronDisplay (const Graphic3d_CView& ACView, const Aspect_TypeOfTriedronPosition APosition = Aspect_TOTP_CENTER, const Quantity_NameOfColor AColor = Quantity_NOC_WHITE, const Standard_Real AScale = 0.02, const Standard_Boolean AsWireframe = Standard_True); Standard_EXPORT void TriedronDisplay (const Graphic3d_CView& ACView, const Aspect_TypeOfTriedronPosition APosition = Aspect_TOTP_CENTER, const Quantity_NameOfColor AColor = Quantity_NOC_WHITE, const Standard_Real AScale = 0.02, const Standard_Boolean AsWireframe = Standard_True);
Standard_EXPORT void TriedronErase (const Graphic3d_CView& ACView); Standard_EXPORT void TriedronErase (const Graphic3d_CView& ACView);
Standard_EXPORT void TriedronEcho (const Graphic3d_CView& ACView, const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE); Standard_EXPORT void TriedronEcho (const Graphic3d_CView& ACView, const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE);
Standard_EXPORT void GraduatedTrihedronDisplay (const Graphic3d_CView& view, const Graphic3d_CGraduatedTrihedron& cubic);
Standard_EXPORT void GraduatedTrihedronErase (const Graphic3d_CView& view); //! Displays Graduated trihedron
Standard_EXPORT void GraduatedTrihedronMinMaxValues (const Standard_ShortReal xmin, const Standard_ShortReal ymin, const Standard_ShortReal zmin, const Standard_ShortReal xmax, const Standard_ShortReal ymax, const Standard_ShortReal zmax); //! @param theView [in] the graphic view
//! @param theCubic [in] Graduated Trihedon parameters.
//! @sa OpenGl_GraduatedTrihedron
//! @sa Graphic3d_GraduatedTrihedron
Standard_EXPORT void GraduatedTrihedronDisplay (const Graphic3d_CView& theView, const Graphic3d_GraduatedTrihedron& theCubic);
//! Erases Graduated Trihedron from the view.
//! theView [in] graphic view
//! @sa OpenGl_GraduatedTrihedron
Standard_EXPORT void GraduatedTrihedronErase (const Graphic3d_CView& theView);
//! Sets minimum and maximum points of scene bounding box for Graduated Trihedron
//! stored in graphic view object.
//! @param theView [in] current graphic view
//! @param theMin [in] the minimum point of scene.
//! @param theMax [in] the maximum point of scene.
//! @sa OpenGl_GraduatedTrihedron
Standard_EXPORT void GraduatedTrihedronMinMaxValues (const Graphic3d_CView& theView,
const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax);
Standard_EXPORT void Layer (Aspect_CLayer2d& ACLayer); Standard_EXPORT void Layer (Aspect_CLayer2d& ACLayer);
Standard_EXPORT void RemoveLayer (const Aspect_CLayer2d& ACLayer); Standard_EXPORT void RemoveLayer (const Aspect_CLayer2d& ACLayer);
Standard_EXPORT void BeginLayer (const Aspect_CLayer2d& ACLayer); Standard_EXPORT void BeginLayer (const Aspect_CLayer2d& ACLayer);

View File

@ -624,49 +624,8 @@ OpenGl_PrimitiveArray::OpenGl_PrimitiveArray (const OpenGl_GraphicDriver*
// dummy index buffer? // dummy index buffer?
myIndices.Nullify(); myIndices.Nullify();
} }
if (myAttribs.IsNull())
{
return;
}
switch (theType) setDrawMode (theType);
{
case Graphic3d_TOPA_POINTS:
myDrawMode = GL_POINTS;
break;
case Graphic3d_TOPA_POLYLINES:
myDrawMode = GL_LINE_STRIP;
break;
case Graphic3d_TOPA_SEGMENTS:
myDrawMode = GL_LINES;
break;
case Graphic3d_TOPA_TRIANGLES:
myDrawMode = GL_TRIANGLES;
break;
case Graphic3d_TOPA_TRIANGLESTRIPS:
myDrawMode = GL_TRIANGLE_STRIP;
break;
case Graphic3d_TOPA_TRIANGLEFANS:
myDrawMode = GL_TRIANGLE_FAN;
break;
#if !defined(GL_ES_VERSION_2_0)
case Graphic3d_TOPA_POLYGONS:
myDrawMode = GL_POLYGON;
break;
case Graphic3d_TOPA_QUADRANGLES:
myDrawMode = GL_QUADS;
break;
case Graphic3d_TOPA_QUADRANGLESTRIPS:
myDrawMode = GL_QUAD_STRIP;
break;
#else
case Graphic3d_TOPA_POLYGONS:
case Graphic3d_TOPA_QUADRANGLES:
case Graphic3d_TOPA_QUADRANGLESTRIPS:
#endif
case Graphic3d_TOPA_UNDEFINED:
break;
}
} }
// ======================================================================= // =======================================================================
@ -835,3 +794,77 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
aCtx->BindProgram (NULL); aCtx->BindProgram (NULL);
} }
// =======================================================================
// function : setDrawMode
// purpose :
// =======================================================================
void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray theType)
{
if (myAttribs.IsNull())
{
myDrawMode = DRAW_MODE_NONE;
return;
}
switch (theType)
{
case Graphic3d_TOPA_POINTS:
myDrawMode = GL_POINTS;
break;
case Graphic3d_TOPA_POLYLINES:
myDrawMode = GL_LINE_STRIP;
break;
case Graphic3d_TOPA_SEGMENTS:
myDrawMode = GL_LINES;
break;
case Graphic3d_TOPA_TRIANGLES:
myDrawMode = GL_TRIANGLES;
break;
case Graphic3d_TOPA_TRIANGLESTRIPS:
myDrawMode = GL_TRIANGLE_STRIP;
break;
case Graphic3d_TOPA_TRIANGLEFANS:
myDrawMode = GL_TRIANGLE_FAN;
break;
#if !defined(GL_ES_VERSION_2_0)
case Graphic3d_TOPA_POLYGONS:
myDrawMode = GL_POLYGON;
break;
case Graphic3d_TOPA_QUADRANGLES:
myDrawMode = GL_QUADS;
break;
case Graphic3d_TOPA_QUADRANGLESTRIPS:
myDrawMode = GL_QUAD_STRIP;
break;
#else
case Graphic3d_TOPA_POLYGONS:
case Graphic3d_TOPA_QUADRANGLES:
case Graphic3d_TOPA_QUADRANGLESTRIPS:
#endif
case Graphic3d_TOPA_UNDEFINED:
break;
}
}
// =======================================================================
// function : InitBuffers
// purpose :
// =======================================================================
void OpenGl_PrimitiveArray::InitBuffers (const Handle(OpenGl_Context)& theContext,
const Graphic3d_TypeOfPrimitiveArray theType,
const Handle(Graphic3d_IndexBuffer)& theIndices,
const Handle(Graphic3d_Buffer)& theAttribs,
const Handle(Graphic3d_BoundBuffer)& theBounds)
{
// Release old graphic resources
Release (theContext.operator->());
myIndices = theIndices;
myAttribs = theAttribs;
myBounds = theBounds;
setDrawMode (theType);
}

View File

@ -69,6 +69,13 @@ public:
//! Returns unique ID of primitive array. //! Returns unique ID of primitive array.
const Standard_Size GetUID() const { return myUID; } const Standard_Size GetUID() const { return myUID; }
//! Initialize indices, attributes and bounds with new data.
void InitBuffers (const Handle(OpenGl_Context)& theContext,
const Graphic3d_TypeOfPrimitiveArray theType,
const Handle(Graphic3d_IndexBuffer)& theIndices,
const Handle(Graphic3d_Buffer)& theAttribs,
const Handle(Graphic3d_BoundBuffer)& theBounds);
protected: protected:
//! VBO initialization procedures //! VBO initialization procedures
@ -95,6 +102,11 @@ private:
void drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const; void drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const;
//! Sets OpenGL draw mode according to the input type of primitive array.
//! If buffer of attributes is empty, draw mode is set to NONE to avoid invalid array rendering.
//! @param theType type of primitive array.
void setDrawMode (const Graphic3d_TypeOfPrimitiveArray theType);
protected: protected:
//! Destructor //! Destructor

View File

@ -447,9 +447,9 @@ static Standard_Boolean OpenGl_Utils::Project (const T
anOut.z() *= anOut.w(); anOut.z() *= anOut.w();
// Map x, y and z to range 0-1 // Map x, y and z to range 0-1
anOut.x() = anOut.x() * 0.5 + 0.5; anOut.x() = anOut.x() * static_cast<T> (0.5) + static_cast<T> (0.5);
anOut.y() = anOut.y() * 0.5 + 0.5; anOut.y() = anOut.y() * static_cast<T> (0.5) + static_cast<T> (0.5);
anOut.z() = anOut.z() * 0.5 + 0.5; anOut.z() = anOut.z() * static_cast<T> (0.5) + static_cast<T> (0.5);
// Map x,y to viewport // Map x,y to viewport
anOut.x() = anOut.x() * theViewport[2] + theViewport[0]; anOut.x() = anOut.x() * theViewport[2] + theViewport[0];

View File

@ -242,7 +242,7 @@ void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx, void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
const Graphic3d_CGraduatedTrihedron& theData) const Graphic3d_GraduatedTrihedron& theData)
{ {
OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron); OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData); myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData);

View File

@ -32,7 +32,7 @@
#include <InterfaceGraphic_Visual3d.hxx> #include <InterfaceGraphic_Visual3d.hxx>
#include <Graphic3d_CView.hxx> #include <Graphic3d_CView.hxx>
#include <Graphic3d_CGraduatedTrihedron.hxx> #include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx> #include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_ZLayerSettings.hxx> #include <Graphic3d_ZLayerSettings.hxx>
#include <Visual3d_TypeOfSurfaceDetail.hxx> #include <Visual3d_TypeOfSurfaceDetail.hxx>
@ -109,8 +109,9 @@ class OpenGl_View : public MMgt_TShared
const Standard_Boolean theAsWireframe); const Standard_Boolean theAsWireframe);
void TriedronErase (const Handle(OpenGl_Context)& theCtx); void TriedronErase (const Handle(OpenGl_Context)& theCtx);
OpenGl_GraduatedTrihedron* GraduatedTrihedron() const { return myGraduatedTrihedron; }
void GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx, void GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
const Graphic3d_CGraduatedTrihedron& theCubic); const Graphic3d_GraduatedTrihedron& theCubic);
void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx); void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
Standard_Real Height () const { return myCamera->ViewDimensions().X(); } Standard_Real Height () const { return myCamera->ViewDimensions().X(); }

View File

@ -122,6 +122,7 @@ uses
ExtendedString from TCollection, ExtendedString from TCollection,
PrintAlgo from Aspect, PrintAlgo from Aspect,
ClipPlane_Handle from Graphic3d, ClipPlane_Handle from Graphic3d,
GraduatedTrihedron from Graphic3d,
SequenceOfHClipPlane from Graphic3d, SequenceOfHClipPlane from Graphic3d,
RenderingMode from Graphic3d, RenderingMode from Graphic3d,
RenderingParams from Graphic3d, RenderingParams from Graphic3d,
@ -458,110 +459,12 @@ is
--------------------------------- ---------------------------------
GetGraduatedTrihedron(me; GetGraduatedTrihedron(me;
-- Names of axes -- theTrigedronData: out GraduatedTrihedron from Graphic3d)
xname, yname, zname : out ExtendedString from TCollection;
-- Draw names --
xdrawname, ydrawname, zdrawname : out Boolean from Standard;
-- Draw values --
xdrawvalues, ydrawvalues, zdrawvalues : out Boolean from Standard;
-- Draw grid --
drawgrid : out Boolean from Standard;
-- Draw axes --
drawaxes : out Boolean from Standard;
-- Number of splits along axes --
nbx, nby, nbz : out Integer from Standard;
-- Offset for drawing values --
xoffset, yoffset, zoffset : out Integer from Standard;
-- Offset for drawing names of axes --
xaxisoffset, yaxisoffset, zaxisoffset : out Integer from Standard;
-- Draw tickmarks --
xdrawtickmarks, ydrawtickmarks, zdrawtickmarks : out Boolean from Standard;
-- Length of tickmarks --
xtickmarklength, ytickmarklength, ztickmarklength : out Integer from Standard;
-- Grid color --
gridcolor : out Color from Quantity;
-- Colors of axis names --
xnamecolor, ynamecolor, znamecolor : out Color from Quantity;
-- Colors of axis and values --
xcolor, ycolor, zcolor : out Color from Quantity;
-- Name of font for names of axes --
fontOfNames : out AsciiString from TCollection;
-- Style of names of axes --
styleOfNames : out FontAspect from Font;
-- Size of names of axes --
sizeOfNames : out Integer from Standard;
-- Name of font for values --
fontOfValues : out AsciiString from TCollection;
-- Style of values --
styleOfValues : out FontAspect from Font;
-- Size of values --
sizeOfValues : out Integer from Standard)
---Purpose: Returns data of a graduated trihedron. ---Purpose: Returns data of a graduated trihedron.
is static; is static;
GraduatedTrihedronDisplay(me : mutable; GraduatedTrihedronDisplay(me : mutable;
-- Names of axes -- theTrigedronData: in GraduatedTrihedron from Graphic3d)
xname : ExtendedString from TCollection = "X";
yname : ExtendedString from TCollection = "Y";
zname : ExtendedString from TCollection = "Z";
-- Draw names --
xdrawname : Boolean from Standard = Standard_True;
ydrawname : Boolean from Standard = Standard_True;
zdrawname : Boolean from Standard = Standard_True;
-- Draw values --
xdrawvalues : Boolean from Standard = Standard_True;
ydrawvalues : Boolean from Standard = Standard_True;
zdrawvalues : Boolean from Standard = Standard_True;
-- Draw grid --
drawgrid : Boolean from Standard = Standard_True;
-- Draw axes --
drawaxes : Boolean from Standard = Standard_True;
-- Number of splits along axes --
nbx : Integer from Standard = 3;
nby : Integer from Standard = 3;
nbz : Integer from Standard = 3;
-- Offset for drawing values --
xoffset : Integer from Standard = 10;
yoffset : Integer from Standard = 10;
zoffset : Integer from Standard = 10;
-- Offset for drawing names of axes --
xaxisoffset : Integer from Standard = 30;
yaxisoffset : Integer from Standard = 30;
zaxisoffset : Integer from Standard = 30;
-- Draw tickmarks --
xdrawtickmarks : Boolean from Standard = Standard_True;
ydrawtickmarks : Boolean from Standard = Standard_True;
zdrawtickmarks : Boolean from Standard = Standard_True;
-- Length of tickmarks --
xtickmarklength : Integer from Standard = 10;
ytickmarklength : Integer from Standard = 10;
ztickmarklength : Integer from Standard = 10;
-- Grid color --
gridcolor : Color from Quantity = Quantity_NOC_WHITE;
-- X name color --
xnamecolor : Color from Quantity = Quantity_NOC_RED;
-- Y name color --
ynamecolor : Color from Quantity = Quantity_NOC_GREEN;
-- Z name color --
znamecolor : Color from Quantity = Quantity_NOC_BLUE1;
-- X color of axis and values --
xcolor : Color from Quantity = Quantity_NOC_RED;
-- Y color of axis and values --
ycolor : Color from Quantity = Quantity_NOC_GREEN;
-- Z color of axis and values --
zcolor : Color from Quantity = Quantity_NOC_BLUE1;
-- Name of font for names of axes --
fontOfNames : AsciiString from TCollection = "Arial";
-- Style of names of axes --
styleOfNames : FontAspect from Font = Font_FA_Bold;
-- Size of names of axes --
sizeOfNames : Integer from Standard = 12;
-- Name of font for values --
fontOfValues : AsciiString from TCollection = "Arial";
-- Style of values --
styleOfValues : FontAspect from Font = Font_FA_Regular;
-- Size of values --
sizeOfValues : Integer from Standard = 12)
---Purpose: Displays a graduated trihedron. ---Purpose: Displays a graduated trihedron.
is static; is static;

View File

@ -271,258 +271,14 @@ void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType )
MyView->TriedronEcho (AType); MyView->TriedronEcho (AType);
} }
void V3d_View::GetGraduatedTrihedron(/* Names of axes */ void V3d_View::GetGraduatedTrihedron (Graphic3d_GraduatedTrihedron& theTrihedronData) const
TCollection_ExtendedString &xname,
TCollection_ExtendedString &yname,
TCollection_ExtendedString &zname,
/* Draw names */
Standard_Boolean& xdrawname,
Standard_Boolean& ydrawname,
Standard_Boolean& zdrawname,
/* Draw values */
Standard_Boolean& xdrawvalues,
Standard_Boolean& ydrawvalues,
Standard_Boolean& zdrawvalues,
/* Draw grid */
Standard_Boolean& drawgrid,
/* Draw axes */
Standard_Boolean& drawaxes,
/* Number of splits along axes */
Standard_Integer& nbx,
Standard_Integer& nby,
Standard_Integer& nbz,
/* Offset for drawing values */
Standard_Integer& xoffset,
Standard_Integer& yoffset,
Standard_Integer& zoffset,
/* Offset for drawing names of axes */
Standard_Integer& xaxisoffset,
Standard_Integer& yaxisoffset,
Standard_Integer& zaxisoffset,
/* Draw tickmarks */
Standard_Boolean& xdrawtickmarks,
Standard_Boolean& ydrawtickmarks,
Standard_Boolean& zdrawtickmarks,
/* Length of tickmarks */
Standard_Integer& xtickmarklength,
Standard_Integer& ytickmarklength,
Standard_Integer& ztickmarklength,
/* Grid color */
Quantity_Color& gridcolor,
/* X name color */
Quantity_Color& xnamecolor,
/* Y name color */
Quantity_Color& ynamecolor,
/* Z name color */
Quantity_Color& znamecolor,
/* X color of axis and values */
Quantity_Color& xcolor,
/* Y color of axis and values */
Quantity_Color& ycolor,
/* Z color of axis and values */
Quantity_Color& zcolor,
/* Name of font for names of axes */
TCollection_AsciiString &fontOfNames,
/* Style of names of axes */
Font_FontAspect& styleOfNames,
/* Size of names of axes */
Standard_Integer& sizeOfNames,
/* Name of font for values */
TCollection_AsciiString &fontOfValues,
/* Style of values */
Font_FontAspect& styleOfValues,
/* Size of values */
Standard_Integer& sizeOfValues) const
{ {
MyView->GetGraduatedTrihedron(/* Names of axes */ MyView->GetGraduatedTrihedron (theTrihedronData);
xname,
yname,
zname,
/* Draw names */
xdrawname,
ydrawname,
zdrawname,
/* Draw values */
xdrawvalues,
ydrawvalues,
zdrawvalues,
/* Draw grid */
drawgrid,
/* Draw axes */
drawaxes,
/* Number of splits along axes */
nbx,
nby,
nbz,
/* Offset for drawing values */
xoffset,
yoffset,
zoffset,
/* Offset for drawing names of axes */
xaxisoffset,
yaxisoffset,
zaxisoffset,
/* Draw tickmarks */
xdrawtickmarks,
ydrawtickmarks,
zdrawtickmarks,
/* Length of tickmarks */
xtickmarklength,
ytickmarklength,
ztickmarklength,
/* Grid color */
gridcolor,
/* X name color */
xnamecolor,
/* Y name color */
ynamecolor,
/* Z name color */
znamecolor,
/* X color of axis and values */
xcolor,
/* Y color of axis and values */
ycolor,
/* Z color of axis and values */
zcolor,
/* Name of font for names of axes */
fontOfNames,
/* Style of names of axes */
styleOfNames,
/* Size of names of axes */
sizeOfNames,
/* Name of font for values */
fontOfValues,
/* Style of values */
styleOfValues,
/* Size of values */
sizeOfValues);
} }
void V3d_View::GraduatedTrihedronDisplay(/* Names of axes */ void V3d_View::GraduatedTrihedronDisplay(const Graphic3d_GraduatedTrihedron& theTrihedronData)
const TCollection_ExtendedString &xname,
const TCollection_ExtendedString &yname,
const TCollection_ExtendedString &zname,
/* Draw names */
const Standard_Boolean xdrawname,
const Standard_Boolean ydrawname,
const Standard_Boolean zdrawname,
/* Draw values */
const Standard_Boolean xdrawvalues,
const Standard_Boolean ydrawvalues,
const Standard_Boolean zdrawvalues,
/* Draw grid */
const Standard_Boolean drawgrid,
/* Draw axes */
const Standard_Boolean drawaxes,
/* Number of splits along axes */
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
/* Offset for drawing values */
const Standard_Integer xoffset,
const Standard_Integer yoffset,
const Standard_Integer zoffset,
/* Offset for drawing names of axes */
const Standard_Integer xaxisoffset,
const Standard_Integer yaxisoffset,
const Standard_Integer zaxisoffset,
/* Draw tickmarks */
const Standard_Boolean xdrawtickmarks,
const Standard_Boolean ydrawtickmarks,
const Standard_Boolean zdrawtickmarks,
/* Length of tickmarks */
const Standard_Integer xtickmarklength,
const Standard_Integer ytickmarklength,
const Standard_Integer ztickmarklength,
/* Grid color */
const Quantity_Color& gridcolor,
/* X name color */
const Quantity_Color& xnamecolor,
/* Y name color */
const Quantity_Color& ynamecolor,
/* Z name color */
const Quantity_Color& znamecolor,
/* X color of axis and values */
const Quantity_Color& xcolor,
/* Y color of axis and values */
const Quantity_Color& ycolor,
/* Z color of axis and values */
const Quantity_Color& zcolor,
/* Name of font for names of axes */
const TCollection_AsciiString &fontOfNames,
/* Style of names of axes */
const Font_FontAspect styleOfNames,
/* Size of names of axes */
const Standard_Integer sizeOfNames,
/* Name of font for values */
const TCollection_AsciiString &fontOfValues,
/* Style of values */
const Font_FontAspect styleOfValues,
/* Size of values */
const Standard_Integer sizeOfValues)
{ {
MyView->GraduatedTrihedronDisplay(/* Names of axes */ MyView->GraduatedTrihedronDisplay(theTrihedronData);
xname,
yname,
zname,
/* Draw names */
xdrawname,
ydrawname,
zdrawname,
/* Draw values */
xdrawvalues,
ydrawvalues,
zdrawvalues,
/* Draw grid */
drawgrid,
/* Draw axes */
drawaxes,
/* Number of splits along axes */
nbx,
nby,
nbz,
/* Offset for drawing values */
xoffset,
yoffset,
zoffset,
/* Offset for drawing names of axes */
xaxisoffset,
yaxisoffset,
zaxisoffset,
/* Draw tickmarks */
xdrawtickmarks,
ydrawtickmarks,
zdrawtickmarks,
/* Length of tickmarks */
xtickmarklength,
ytickmarklength,
ztickmarklength,
/* Grid color */
gridcolor,
/* X name color */
xnamecolor,
/* Y name color */
ynamecolor,
/* Z name color */
znamecolor,
/* X color of axis and values */
xcolor,
/* Y color of axis and values */
ycolor,
/* Z color of axis and values */
zcolor,
/* Name of font for names of axes */
fontOfNames,
/* Style of names of axes */
styleOfNames,
/* Size of names of axes */
sizeOfNames,
/* Name of font for values */
fontOfValues,
/* Style of values */
styleOfValues,
/* Size of values */
sizeOfValues);
} }
void V3d_View::GraduatedTrihedronErase() void V3d_View::GraduatedTrihedronErase()

View File

@ -23,6 +23,7 @@
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_ExportFormat.hxx> #include <Graphic3d_ExportFormat.hxx>
#include <Graphic3d_NameOfTextureEnv.hxx> #include <Graphic3d_NameOfTextureEnv.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_TextureEnv.hxx> #include <Graphic3d_TextureEnv.hxx>
#include <Graphic3d_TextureParams.hxx> #include <Graphic3d_TextureParams.hxx>
#include <Graphic3d_TypeOfTextureFilter.hxx> #include <Graphic3d_TypeOfTextureFilter.hxx>
@ -3646,103 +3647,328 @@ static int VColorScale (Draw_Interpretor& theDI,
//============================================================================== //==============================================================================
//function : VGraduatedTrihedron //function : VGraduatedTrihedron
//purpose : Displays a graduated trihedron //purpose : Displays or hides a graduated trihedron
//============================================================================== //==============================================================================
static Standard_Boolean GetColor (const TCollection_AsciiString& theValue,
static void AddMultibyteString (TCollection_ExtendedString &name, const char *arg) Quantity_Color& theColor)
{ {
const char *str = arg; Quantity_NameOfColor aColorName;
while (*str) TCollection_AsciiString aVal = theValue;
aVal.UpperCase();
if (!Quantity_Color::ColorFromName (aVal.ToCString(), aColorName))
{ {
unsigned short c1 = *str++; return Standard_False;
unsigned short c2 = *str++;
if (!c1 || !c2) break;
name += (Standard_ExtCharacter)((c1 << 8) | c2);
} }
theColor = Quantity_Color (aColorName);
return Standard_True;
} }
static int VGraduatedTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv) static int VGraduatedTrihedron (Draw_Interpretor& /*theDi*/, Standard_Integer theArgNum, const char** theArgs)
{ {
// Check arguments if (theArgNum < 2)
if (argc != 2 && argc < 5)
{ {
di<<"Error: "<<argv[0]<<" - invalid number of arguments\n"; std::cout << theArgs[0] << " error: wrong number of parameters. Type 'help"
di<<"Usage: type help "<<argv[0]<<"\n"; << theArgs[0] <<"' for more information.\n";
return 1; //TCL_ERROR return 1; //TCL_ERROR
} }
Handle(V3d_View) aV3dView = ViewerTest::CurrentView(); NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
TCollection_AsciiString aParseKey;
for (Standard_Integer anArgIt = 1; anArgIt < theArgNum; ++anArgIt)
{
TCollection_AsciiString anArg (theArgs [anArgIt]);
// Create 3D view if it doesn't exist if (anArg.Value (1) == '-' && !anArg.IsRealValue())
if ( aV3dView.IsNull() )
{ {
ViewerTest::ViewerInit(); aParseKey = anArg;
aV3dView = ViewerTest::CurrentView(); aParseKey.Remove (1);
if( aV3dView.IsNull() ) aParseKey.LowerCase();
{ aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
di << "Error: Cannot create a 3D view\n"; continue;
return 1; //TCL_ERROR
}
} }
// Erase (==0) or display (!=0) if (aParseKey.IsEmpty())
const int display = Draw::Atoi(argv[1]);
if (display)
{ {
// Text font continue;
TCollection_AsciiString font; }
if (argc < 6)
font.AssignCat("Courier");
else
font.AssignCat(argv[5]);
// Text is multibyte aMapOfArgs(aParseKey)->Append (anArg);
const Standard_Boolean isMultibyte = (argc < 7)? Standard_False : (Draw::Atoi(argv[6]) != 0); }
// Set axis names // Check parameters
TCollection_ExtendedString xname, yname, zname; for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
if (argc >= 5) aMapIt.More(); aMapIt.Next())
{ {
if (isMultibyte) const TCollection_AsciiString& aKey = aMapIt.Key();
const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
// Bool key, without arguments
if ((aKey.IsEqual ("on") || aKey.IsEqual ("off"))
&& anArgs->IsEmpty())
{ {
AddMultibyteString(xname, argv[2]); continue;
AddMultibyteString(yname, argv[3]); }
AddMultibyteString(zname, argv[4]);
// One argument
if ( (aKey.IsEqual ("xname") || aKey.IsEqual ("yname") || aKey.IsEqual ("zname"))
&& anArgs->Length() == 1)
{
continue;
}
// On/off arguments
if ((aKey.IsEqual ("xdrawname") || aKey.IsEqual ("ydrawname") || aKey.IsEqual ("zdrawname")
|| aKey.IsEqual ("xdrawticks") || aKey.IsEqual ("ydrawticks") || aKey.IsEqual ("zdrawticks")
|| aKey.IsEqual ("xdrawvalues") || aKey.IsEqual ("ydrawvalues") || aKey.IsEqual ("zdrawvalues"))
&& anArgs->Length() == 1 && (anArgs->Value(1).IsEqual ("on") || anArgs->Value(1).IsEqual ("off")))
{
continue;
}
// One string argument
if ( (aKey.IsEqual ("xnamecolor") || aKey.IsEqual ("ynamecolor") || aKey.IsEqual ("znamecolor")
|| aKey.IsEqual ("xcolor") || aKey.IsEqual ("ycolor") || aKey.IsEqual ("zcolor"))
&& anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
{
continue;
}
// One integer argument
if ( (aKey.IsEqual ("xticks") || aKey.IsEqual ("yticks") || aKey.IsEqual ("zticks")
|| aKey.IsEqual ("xticklength") || aKey.IsEqual ("yticklength") || aKey.IsEqual ("zticklength")
|| aKey.IsEqual ("xnameoffset") || aKey.IsEqual ("ynameoffset") || aKey.IsEqual ("znameoffset")
|| aKey.IsEqual ("xvaluesoffset") || aKey.IsEqual ("yvaluesoffset") || aKey.IsEqual ("zvaluesoffset"))
&& anArgs->Length() == 1 && anArgs->Value(1).IsIntegerValue())
{
continue;
}
// One real argument
if ( aKey.IsEqual ("arrowlength")
&& anArgs->Length() == 1 && (anArgs->Value(1).IsIntegerValue() || anArgs->Value(1).IsRealValue()))
{
continue;
}
// Two string arguments
if ( (aKey.IsEqual ("namefont") || aKey.IsEqual ("valuesfont"))
&& anArgs->Length() == 1 && !anArgs->Value(1).IsIntegerValue() && !anArgs->Value(1).IsRealValue())
{
continue;
}
TCollection_AsciiString aLowerKey;
aLowerKey = "-";
aLowerKey += aKey;
aLowerKey.LowerCase();
std::cout << theArgs[0] << ": " << aLowerKey << " is unknown option, or the arguments are unacceptable.\n";
std::cout << "Type help for more information.\n";
return 1;
}
Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
if (anAISContext.IsNull())
{
std::cout << theArgs[0] << ": " << " please use 'vinit' command to initialize view.\n";
return 1;
}
Standard_Boolean toDisplay = Standard_True;
Quantity_Color aColor;
Graphic3d_GraduatedTrihedron aTrihedronData;
// Process parameters
Handle(TColStd_HSequenceOfAsciiString) aValues;
if (aMapOfArgs.Find ("off", aValues))
{
toDisplay = Standard_False;
}
// AXES NAMES
if (aMapOfArgs.Find ("xname", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetName (aValues->Value(1));
}
if (aMapOfArgs.Find ("yname", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetName (aValues->Value(1));
}
if (aMapOfArgs.Find ("zname", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetName (aValues->Value(1));
}
if (aMapOfArgs.Find ("xdrawname", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetToDrawName (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("ydrawname", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetToDrawName (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("zdrawname", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetToDrawName (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("xnameoffset", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("ynameoffset", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("znameoffset", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetNameOffset (aValues->Value(1).IntegerValue());
}
// COLORS
if (aMapOfArgs.Find ("xnamecolor", aValues))
{
if (!GetColor (aValues->Value(1), aColor))
{
std::cout << theArgs[0] << "error: -xnamecolor wrong color name.\n";
return 1;
}
aTrihedronData.ChangeXAxisAspect().SetNameColor (aColor);
}
if (aMapOfArgs.Find ("ynamecolor", aValues))
{
if (!GetColor (aValues->Value(1), aColor))
{
std::cout << theArgs[0] << "error: -ynamecolor wrong color name.\n";
return 1;
}
aTrihedronData.ChangeYAxisAspect().SetNameColor (aColor);
}
if (aMapOfArgs.Find ("znamecolor", aValues))
{
if (!GetColor (aValues->Value(1), aColor))
{
std::cout << theArgs[0] << "error: -znamecolor wrong color name.\n";
return 1;
}
aTrihedronData.ChangeZAxisAspect().SetNameColor (aColor);
}
if (aMapOfArgs.Find ("xcolor", aValues))
{
if (!GetColor (aValues->Value(1), aColor))
{
std::cout << theArgs[0] << "error: -xcolor wrong color name.\n";
return 1;
}
aTrihedronData.ChangeXAxisAspect().SetColor (aColor);
}
if (aMapOfArgs.Find ("ycolor", aValues))
{
if (!GetColor (aValues->Value(1), aColor))
{
std::cout << theArgs[0] << "error: -ycolor wrong color name.\n";
return 1;
}
aTrihedronData.ChangeYAxisAspect().SetColor (aColor);
}
if (aMapOfArgs.Find ("zcolor", aValues))
{
if (!GetColor (aValues->Value(1), aColor))
{
std::cout << theArgs[0] << "error: -zcolor wrong color name.\n";
return 1;
}
aTrihedronData.ChangeZAxisAspect().SetColor (aColor);
}
// TICKMARKS
if (aMapOfArgs.Find ("xticks", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetTickmarkNumber (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("yticks", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetTickmarkNumber (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("zticks", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetTickmarkNumber (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("xticklength", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetTickmarkLength (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("yticklength", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetTickmarkLength (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("zticklength", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetTickmarkLength (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("xdrawticks", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetToDrawTickmarks (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("ydrawticks", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetToDrawTickmarks (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("zdrawticks", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetToDrawTickmarks (aValues->Value(1).IsEqual ("on"));
}
// VALUES
if (aMapOfArgs.Find ("xdrawvalues", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetToDrawValues (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("ydrawvalues", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetToDrawValues (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("zdrawvalues", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetToDrawValues (aValues->Value(1).IsEqual ("on"));
}
if (aMapOfArgs.Find ("xvaluesoffset", aValues))
{
aTrihedronData.ChangeXAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("yvaluesoffset", aValues))
{
aTrihedronData.ChangeYAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
}
if (aMapOfArgs.Find ("zvaluesoffset", aValues))
{
aTrihedronData.ChangeZAxisAspect().SetValuesOffset (aValues->Value(1).IntegerValue());
}
// ARROWS
if (aMapOfArgs.Find ("arrowlength", aValues))
{
aTrihedronData.SetArrowLength ((Standard_ShortReal) aValues->Value(1).RealValue());
}
// FONTS
if (aMapOfArgs.Find ("namefont", aValues))
{
aTrihedronData.SetNamesFont (aValues->Value(1));
}
if (aMapOfArgs.Find ("valuesfont", aValues))
{
aTrihedronData.SetValuesFont (aValues->Value(1));
}
// The final step: display of erase trihedron
if (toDisplay)
{
ViewerTest::CurrentView()->GraduatedTrihedronDisplay (aTrihedronData);
} }
else else
{ {
xname += argv[2]; ViewerTest::CurrentView()->GraduatedTrihedronErase();
yname += argv[3];
zname += argv[4];
} }
}
else
{
xname += "X (mm)";
yname += "Y (mm)";
zname += "Z (mm)";
}
aV3dView->GraduatedTrihedronDisplay(xname, yname, zname,
Standard_True/*xdrawname*/, Standard_True/*ydrawname*/, Standard_True/*zdrawname*/,
Standard_True/*xdrawvalues*/, Standard_True/*ydrawvalues*/, Standard_True/*zdrawvalues*/,
Standard_True/*drawgrid*/,
Standard_True/*drawaxes*/,
5/*nbx*/, 5/*nby*/, 5/*nbz*/,
10/*xoffset*/, 10/*yoffset*/, 10/*zoffset*/,
30/*xaxisoffset*/, 30/*yaxisoffset*/, 30/*zaxisoffset*/,
Standard_True/*xdrawtickmarks*/, Standard_True/*ydrawtickmarks*/, Standard_True/*zdrawtickmarks*/,
10/*xtickmarklength*/, 10/*ytickmarklength*/, 10/*ztickmarklength*/,
Quantity_NOC_WHITE/*gridcolor*/,
Quantity_NOC_RED/*xnamecolor*/,Quantity_NOC_GREEN/*ynamecolor*/,Quantity_NOC_BLUE1/*znamecolor*/,
Quantity_NOC_RED/*xcolor*/,Quantity_NOC_GREEN/*ycolor*/,Quantity_NOC_BLUE1/*zcolor*/,font);
}
else
aV3dView->GraduatedTrihedronErase();
ViewerTest::GetAISContext()->UpdateCurrentViewer(); ViewerTest::GetAISContext()->UpdateCurrentViewer();
aV3dView->Redraw(); ViewerTest::CurrentView()->Redraw();
return 0; return 0;
} }
@ -7808,7 +8034,27 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"Available text positions: left, right, center, none;\n", "Available text positions: left, right, center, none;\n",
__FILE__,VColorScale,group); __FILE__,VColorScale,group);
theCommands.Add("vgraduatedtrihedron", theCommands.Add("vgraduatedtrihedron",
"vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname [Font [isMultibyte]]]", "vgraduatedtrihedron : -on/-off [-xname Name] [-yname Name] [-zname Name] [-arrowlength Value]\n"
"\t[-namefont Name] [-valuesfont Name]\n"
"\t[-xdrawname on/off] [-ydrawname on/off] [-zdrawname on/off]\n"
"\t[-xnameoffset IntVal] [-ynameoffset IntVal] [-znameoffset IntVal]"
"\t[-xnamecolor Color] [-ynamecolor Color] [-znamecolor Color]\n"
"\t[-xdrawvalues on/off] [-ydrawvalues on/off] [-zdrawvalues on/off]\n"
"\t[-xvaluesoffset IntVal] [-yvaluesoffset IntVal] [-zvaluesoffset IntVal]"
"\t[-xcolor Color] [-ycolor Color] [-zcolor Color]\n"
"\t[-xdrawticks on/off] [-ydrawticks on/off] [-zdrawticks on/off]\n"
"\t[-xticks Number] [-yticks Number] [-zticks Number]\n"
"\t[-xticklength IntVal] [-yticklength IntVal] [-zticklength IntVal]\n"
" - Displays or erases graduated trihedron"
" - xname, yname, zname - names of axes, default: X, Y, Z\n"
" - namefont - font of axes names. Default: Arial\n"
" - xnameoffset, ynameoffset, znameoffset - offset of name from values or tickmarks or axis. Default: 30\n"
" - xnamecolor, ynamecolor, znamecolor - colors of axes names\n"
" - xvaluesoffset, yvaluesoffset, zvaluesoffset - offset of values from tickmarks or axis. Default: 10\n"
" - valuesfont - font of axes values. Default: Arial\n"
" - xcolor, ycolor, zcolor - color of axis and values\n"
" - xticks, yticks, xzicks - number of tickmark on axes. Default: 5\n"
" - xticklength, yticklength, xzicklength - length of tickmark on axes. Default: 10\n",
__FILE__,VGraduatedTrihedron,group); __FILE__,VGraduatedTrihedron,group);
theCommands.Add("vprintview" , theCommands.Add("vprintview" ,
"vprintview : width height filename [algo=0] [tile_width tile_height] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile", "vprintview : width height filename [algo=0] [tile_width tile_height] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",

View File

@ -104,7 +104,7 @@ uses
FontAspect from Font, FontAspect from Font,
AsciiString from TCollection, AsciiString from TCollection,
ExtendedString from TCollection, ExtendedString from TCollection,
CGraduatedTrihedron from Graphic3d, GraduatedTrihedron from Graphic3d,
NMapOfTransient from Graphic3d, NMapOfTransient from Graphic3d,
TypeOfStructure from Graphic3d, TypeOfStructure from Graphic3d,
@ -515,87 +515,13 @@ is
------------------------------------------ ------------------------------------------
GetGraduatedTrihedron(me; GetGraduatedTrihedron(me;
-- Names of axes -- theTrigedronData: out GraduatedTrihedron from Graphic3d)
xname, yname, zname : out ExtendedString from TCollection;
-- Draw names --
xdrawname, ydrawname, zdrawname : out Boolean from Standard;
-- Draw values --
xdrawvalues, ydrawvalues, zdrawvalues : out Boolean from Standard;
-- Draw grid --
drawgrid : out Boolean from Standard;
-- Draw axes --
drawaxes : out Boolean from Standard;
-- Number of splits along axes --
nbx, nby, nbz : out Integer from Standard;
-- Offset for drawing values --
xoffset, yoffset, zoffset : out Integer from Standard;
-- Offset for drawing names of axes --
xaxisoffset, yaxisoffset, zaxisoffset : out Integer from Standard;
-- Draw tickmarks --
xdrawtickmarks, ydrawtickmarks, zdrawtickmarks : out Boolean from Standard;
-- Length of tickmarks --
xtickmarklength, ytickmarklength, ztickmarklength : out Integer from Standard;
-- Grid color --
gridcolor : out Color from Quantity;
-- Colors of axis names --
xnamecolor, ynamecolor, znamecolor : out Color from Quantity;
-- Colors of axis and values --
xcolor, ycolor, zcolor : out Color from Quantity;
-- Name of font for names of axes --
fontOfNames : out AsciiString from TCollection;
-- Style of names of axes --
styleOfNames : out FontAspect from Font;
-- Size of names of axes --
sizeOfNames : out Integer from Standard;
-- Name of font for values --
fontOfValues : out AsciiString from TCollection;
-- Style of values --
styleOfValues : out FontAspect from Font;
-- Size of values --
sizeOfValues : out Integer from Standard)
returns Boolean from Standard returns Boolean from Standard
is static; is static;
---Purpose: Returns data of a graduated trihedron if displayed (return value is True) ---Purpose: Returns data of a graduated trihedron if displayed (return value is True)
GraduatedTrihedronDisplay(me : mutable; GraduatedTrihedronDisplay(me : mutable;
-- Names of axes -- theTrigedronData: in GraduatedTrihedron from Graphic3d)
xname, yname, zname : ExtendedString from TCollection;
-- Draw names --
xdrawname, ydrawname, zdrawname : Boolean from Standard;
-- Draw values --
xdrawvalues, ydrawvalues, zdrawvalues : Boolean from Standard;
-- Draw grid --
drawgrid : Boolean from Standard;
-- Draw axes --
drawaxes : Boolean from Standard;
-- Number of splits along axes --
nbx, nby, nbz : Integer from Standard;
-- Offset for drawing values --
xoffset, yoffset, zoffset : Integer from Standard;
-- Offset for drawing names of axes --
xaxisoffset, yaxisoffset, zaxisoffset : Integer from Standard;
-- Draw tickmarks --
xdrawtickmarks, ydrawtickmarks, zdrawtickmarks : Boolean from Standard;
-- Length of tickmarks --
xtickmarklength, ytickmarklength, ztickmarklength : Integer from Standard;
-- Grid color --
gridcolor : Color from Quantity;
-- Colors of axis names --
xnamecolor, ynamecolor, znamecolor : Color from Quantity;
-- Colors of axis and values --
xcolor, ycolor, zcolor : Color from Quantity;
-- Name of font for names of axes --
fontOfNames : AsciiString from TCollection;
-- Style of names of axes --
styleOfNames : FontAspect from Font;
-- Size of names of axes --
sizeOfNames : Integer from Standard;
-- Name of font for values --
fontOfValues : AsciiString from TCollection;
-- Style of values --
styleOfValues : FontAspect from Font;
-- Size of values --
sizeOfValues : Integer from Standard)
---Purpose: Displays a graduated trihedron. ---Purpose: Displays a graduated trihedron.
is static; is static;
@ -1195,7 +1121,7 @@ fields
myStructsDisplayed : MapOfStructure from Graphic3d; myStructsDisplayed : MapOfStructure from Graphic3d;
myImmediateStructures : MapOfStructure from Graphic3d; myImmediateStructures : MapOfStructure from Graphic3d;
MyGTrihedron : CGraduatedTrihedron from Graphic3d; myGTrihedron : GraduatedTrihedron from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d; myDefaultCamera : Camera_Handle from Graphic3d;

View File

@ -2084,14 +2084,18 @@ void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho theType)
static void SetMinMaxValuesCallback (Visual3d_View* theView) static void SetMinMaxValuesCallback (Visual3d_View* theView)
{ {
Graphic3d_CView* aCView = (Graphic3d_CView* )(theView->CView());
Bnd_Box aBox = theView->MinMaxValues(); Bnd_Box aBox = theView->MinMaxValues();
if (!aBox.IsVoid()) if (!aBox.IsVoid())
{ {
gp_Pnt aMin = aBox.CornerMin(); gp_Pnt aMin = aBox.CornerMin();
gp_Pnt aMax = aBox.CornerMax(); gp_Pnt aMax = aBox.CornerMax();
Graphic3d_Vec3 aMinVec ((Standard_ShortReal )aMin.X(), (Standard_ShortReal )aMin.Y(), (Standard_ShortReal )aMin.Z());
Graphic3d_Vec3 aMaxVec ((Standard_ShortReal )aMax.X(), (Standard_ShortReal )aMax.Y(), (Standard_ShortReal )aMax.Z());
const Handle(Graphic3d_GraphicDriver)& aDriver = theView->GraphicDriver(); const Handle(Graphic3d_GraphicDriver)& aDriver = theView->GraphicDriver();
aDriver->GraduatedTrihedronMinMaxValues ((Standard_ShortReal )aMin.X(), (Standard_ShortReal )aMin.Y(), (Standard_ShortReal )aMin.Z(), aDriver->GraduatedTrihedronMinMaxValues (*aCView, aMinVec, aMaxVec);
(Standard_ShortReal )aMax.X(), (Standard_ShortReal )aMax.Y(), (Standard_ShortReal )aMax.Z());
} }
} }
@ -2099,90 +2103,14 @@ static void SetMinMaxValuesCallback (Visual3d_View* theView)
// function : GetGraduatedTrihedron // function : GetGraduatedTrihedron
// purpose : // purpose :
// ======================================================================= // =======================================================================
Standard_Boolean Visual3d_View::GetGraduatedTrihedron (TCollection_ExtendedString& theXName, Standard_Boolean Visual3d_View::GetGraduatedTrihedron (Graphic3d_GraduatedTrihedron& theTrihedronData) const
TCollection_ExtendedString& theYName,
TCollection_ExtendedString& theZName,
Standard_Boolean& theToDrawXName,
Standard_Boolean& theToDrawYName,
Standard_Boolean& theToDrawZName,
Standard_Boolean& theToDrawXValues,
Standard_Boolean& theToDrawYValues,
Standard_Boolean& theToDrawZValues,
Standard_Boolean& theToDrawGrid,
Standard_Boolean& theToDrawAxes,
Standard_Integer& theNbX,
Standard_Integer& theNbY,
Standard_Integer& theNbZ,
Standard_Integer& theXOffset,
Standard_Integer& theYOffset,
Standard_Integer& theZOffset,
Standard_Integer& theXAxisOffset,
Standard_Integer& theYAxisOffset,
Standard_Integer& theZAxisOffset,
Standard_Boolean& theToDrawXTickMarks,
Standard_Boolean& theToDrawYTickMarks,
Standard_Boolean& theToDrawZTickMarks,
Standard_Integer& theXTickMarkLength,
Standard_Integer& theYTickMarkLength,
Standard_Integer& theZTickMarkLength,
Quantity_Color& theGridColor,
Quantity_Color& theXNameColor,
Quantity_Color& theYNameColor,
Quantity_Color& theZNameColor,
Quantity_Color& theXColor,
Quantity_Color& theYColor,
Quantity_Color& theZColor,
TCollection_AsciiString& theFontOfNames,
Font_FontAspect& theStyleOfNames,
Standard_Integer& theSizeOfNames,
TCollection_AsciiString& theFontOfValues,
Font_FontAspect& theStyleOfValues,
Standard_Integer& theSizeOfValues) const
{ {
if (!MyGTrihedron.ptrVisual3dView) if (!myGTrihedron.PtrVisual3dView)
{ {
return Standard_False; return Standard_False;
} }
theXName = MyGTrihedron.xname; theTrihedronData = myGTrihedron;
theYName = MyGTrihedron.yname;
theZName = MyGTrihedron.zname;
theToDrawXName = MyGTrihedron.xdrawname;
theToDrawYName = MyGTrihedron.ydrawname;
theToDrawZName = MyGTrihedron.zdrawname;
theToDrawXValues = MyGTrihedron.xdrawvalues;
theToDrawYValues = MyGTrihedron.ydrawvalues;
theToDrawZValues = MyGTrihedron.zdrawvalues;
theToDrawGrid = MyGTrihedron.drawgrid;
theToDrawAxes = MyGTrihedron.drawaxes;
theNbX = MyGTrihedron.nbx;
theNbY = MyGTrihedron.nby;
theNbZ = MyGTrihedron.nbz;
theXOffset = MyGTrihedron.xoffset;
theYOffset = MyGTrihedron.yoffset;
theZOffset = MyGTrihedron.zoffset;
theXAxisOffset = MyGTrihedron.xaxisoffset;
theYAxisOffset = MyGTrihedron.yaxisoffset;
theZAxisOffset = MyGTrihedron.zaxisoffset;
theToDrawXTickMarks = MyGTrihedron.xdrawtickmarks;
theToDrawYTickMarks = MyGTrihedron.ydrawtickmarks;
theToDrawZTickMarks = MyGTrihedron.zdrawtickmarks;
theXTickMarkLength = MyGTrihedron.xtickmarklength;
theYTickMarkLength = MyGTrihedron.ytickmarklength;
theZTickMarkLength = MyGTrihedron.ztickmarklength;
theGridColor = MyGTrihedron.gridcolor;
theXNameColor = MyGTrihedron.xnamecolor;
theYNameColor = MyGTrihedron.ynamecolor;
theZNameColor = MyGTrihedron.znamecolor;
theXColor = MyGTrihedron.xcolor;
theYColor = MyGTrihedron.ycolor;
theZColor = MyGTrihedron.zcolor;
theFontOfNames = MyGTrihedron.fontOfNames;
theStyleOfNames = MyGTrihedron.styleOfNames;
theSizeOfNames = MyGTrihedron.sizeOfNames;
theFontOfValues = MyGTrihedron.fontOfValues;
theStyleOfValues = MyGTrihedron.styleOfValues;
theSizeOfValues = MyGTrihedron.sizeOfValues;
return Standard_True; return Standard_True;
} }
@ -2190,89 +2118,14 @@ Standard_Boolean Visual3d_View::GetGraduatedTrihedron (TCollection_ExtendedStrin
// function : GraduatedTrihedronDisplay // function : GraduatedTrihedronDisplay
// purpose : // purpose :
// ======================================================================= // =======================================================================
void Visual3d_View::GraduatedTrihedronDisplay (const TCollection_ExtendedString& theXName, void Visual3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
const TCollection_ExtendedString& theYName,
const TCollection_ExtendedString& theZName,
const Standard_Boolean theToDrawXName,
const Standard_Boolean theToDrawYName,
const Standard_Boolean theToDrawZName,
const Standard_Boolean theToDrawXValues,
const Standard_Boolean theToDrawYValues,
const Standard_Boolean theToDrawZValues,
const Standard_Boolean theToDrawGrid,
const Standard_Boolean theToDrawAxes,
const Standard_Integer theNbX,
const Standard_Integer theNbY,
const Standard_Integer theNbZ,
const Standard_Integer theXOffset,
const Standard_Integer theYOffset,
const Standard_Integer theZOffset,
const Standard_Integer theXAxisOffset,
const Standard_Integer theYAxisOffset,
const Standard_Integer theZAxisOffset,
const Standard_Boolean theToDrawXTickMarks,
const Standard_Boolean theToDrawYTickMarks,
const Standard_Boolean theToDrawZTickMarks,
const Standard_Integer theXTickMarkLength,
const Standard_Integer theYTickMarkLength,
const Standard_Integer theZTickMarkLength,
const Quantity_Color& theGridColor,
const Quantity_Color& theXNameColor,
const Quantity_Color& theYNameColor,
const Quantity_Color& theZNameColor,
const Quantity_Color& theXColor,
const Quantity_Color& theYColor,
const Quantity_Color& theZColor,
const TCollection_AsciiString& theFontOfNames,
const Font_FontAspect theStyleOfNames,
const Standard_Integer theSizeOfNames,
const TCollection_AsciiString& theFontOfValues,
const Font_FontAspect theStyleOfValues,
const Standard_Integer theSizeOfValues)
{ {
MyGTrihedron.xname = theXName; myGTrihedron = theTrihedronData;
MyGTrihedron.yname = theYName;
MyGTrihedron.zname = theZName;
MyGTrihedron.xdrawname = theToDrawXName;
MyGTrihedron.ydrawname = theToDrawYName;
MyGTrihedron.zdrawname = theToDrawZName;
MyGTrihedron.xdrawvalues = theToDrawXValues;
MyGTrihedron.ydrawvalues = theToDrawYValues;
MyGTrihedron.zdrawvalues = theToDrawZValues;
MyGTrihedron.drawgrid = theToDrawGrid;
MyGTrihedron.drawaxes = theToDrawAxes;
MyGTrihedron.nbx = theNbX;
MyGTrihedron.nby = theNbY;
MyGTrihedron.nbz = theNbZ;
MyGTrihedron.xoffset = theXOffset;
MyGTrihedron.yoffset = theYOffset;
MyGTrihedron.zoffset = theZOffset;
MyGTrihedron.xaxisoffset = theXAxisOffset;
MyGTrihedron.yaxisoffset = theYAxisOffset;
MyGTrihedron.zaxisoffset = theZAxisOffset;
MyGTrihedron.xdrawtickmarks = theToDrawXTickMarks;
MyGTrihedron.ydrawtickmarks = theToDrawYTickMarks;
MyGTrihedron.zdrawtickmarks = theToDrawZTickMarks;
MyGTrihedron.xtickmarklength = theXTickMarkLength;
MyGTrihedron.ytickmarklength = theYTickMarkLength;
MyGTrihedron.ztickmarklength = theZTickMarkLength;
MyGTrihedron.gridcolor = theGridColor;
MyGTrihedron.xnamecolor = theXNameColor;
MyGTrihedron.ynamecolor = theYNameColor;
MyGTrihedron.znamecolor = theZNameColor;
MyGTrihedron.xcolor = theXColor;
MyGTrihedron.ycolor = theYColor;
MyGTrihedron.zcolor = theZColor;
MyGTrihedron.fontOfNames = theFontOfNames;
MyGTrihedron.styleOfNames = theStyleOfNames;
MyGTrihedron.sizeOfNames = theSizeOfNames;
MyGTrihedron.fontOfValues = theFontOfValues;
MyGTrihedron.styleOfValues = theStyleOfValues;
MyGTrihedron.sizeOfValues = theSizeOfValues;
MyGTrihedron.ptrVisual3dView = this; myGTrihedron.PtrVisual3dView = this;
MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback; myGTrihedron.CubicAxesCallback = SetMinMaxValuesCallback;
myGraphicDriver->GraduatedTrihedronDisplay (MyCView, MyGTrihedron);
myGraphicDriver->GraduatedTrihedronDisplay (MyCView, myGTrihedron);
} }
// ======================================================================= // =======================================================================
@ -2281,7 +2134,7 @@ void Visual3d_View::GraduatedTrihedronDisplay (const TCollection_ExtendedString&
// ======================================================================= // =======================================================================
void Visual3d_View::GraduatedTrihedronErase() void Visual3d_View::GraduatedTrihedronErase()
{ {
MyGTrihedron.ptrVisual3dView = NULL; myGTrihedron.PtrVisual3dView = NULL;
myGraphicDriver->GraduatedTrihedronErase (MyCView); myGraphicDriver->GraduatedTrihedronErase (MyCView);
} }

23
tests/bugs/vis/bug25611_1 Normal file
View File

@ -0,0 +1,23 @@
puts "========"
puts "OCC25611"
puts "========"
puts ""
############################################################################
puts "Displaying \'zbufftrihedron\' interferes with \'vgraduatedtrihedron\'"
############################################################################
set anImage $imagedir/${casename}.png
vinit View1
psphere s 10
vdisplay s
vaxo
vfit
vsetdispmode s 1
vgraduatedtrihedron -on
vzbufftrihedron
vdump $anImage
vclear
vclose View1

38
tests/bugs/vis/bug25611_2 Normal file
View File

@ -0,0 +1,38 @@
puts "========"
puts "OCC25611"
puts "========"
puts ""
############################################################################
puts "Displaying \'zbufftrihedron\' interferes with \'vgraduatedtrihedron\'"
puts "Test graduated trihedron parameters"
############################################################################
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
set anImage3 $imagedir/${casename}_3.png
set anImage4 $imagedir/${casename}_4.png
vinit View1
psphere s 10
vdisplay s
vaxo
vfit
vsetdispmode s 1
# Font and color parameters
vgraduatedtrihedron -on -xname X(mm) -yname Y(mm) -zname Z(mm) -xnamecolor PINK -ycolor GREENYELLOW -namefont Courier -valuesfont Courier
vdump $anImage1
# Boolean parameters
vgraduatedtrihedron -on -xdrawname off -ydrawvalues off -zdrawticks off
vdump $anImage2
# Tickmark parameters
vgraduatedtrihedron -on -xticks 10 -xticklength 15 -xvaluesoffset 20 -xnameoffset 40
vdump $anImage3
#Arrow parameters
vgraduatedtrihedron -on -arrowlength 50
vdump $anImage4
vclose View1