1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0024637: Visualization - clean up implementation of rendering in immediate mode

Remove unused flag "DoubleBuf".
Remove Visual3d_TransientManager "class" (functionality moved to PrsMgr_PresentationManager).
Remove unused "Add" immediate mode.

V3d_View class - remove methods ::TransientManagerBeginDraw(), ::TransientManagerClearDraw(), ::TransientManagerBeginAddDraw().
Add method ::RedrawImmediate() to redraw only immediate presentations.

OpenGl_GraphicDriver - add methods ::DisplayImmediateStructure(), ::EraseImmediateStructure(), ::RedrawImmediate().
OpenGl_View - manage list of immediate structures.
OpenGl_Workspace - automate rendering workflow of immediate + persistent layers.

Merge PrsMgr_PresentationManager3d class into PrsMgr_PresentationManager.
Mark PrsMgr_PresentationManager3d as alias to PrsMgr_PresentationManager to simplify porting.

Prs3d_Presentation - remove unused field myStruct.
Prs3d_PresentationShadow - shadow link to existing presentation with custom attributes.
Graphic3d_Structure::Highlight() - do not register undisplayed structure in structure manager.

AIS_InteractiveContext, AIS_LocalContext add flag to prevent view update into methods
::MoveTo(), ::HilightNextDetected(), ::HilightPreviousDetected()
to allow update of customized immediate structures before redraw but after ::MoveTo().

Remove unused method AIS_InteractiveContext::Drag().

StdSelect_ViewerSelector3d do not user immediate mode in methods
::DisplayAreas(), ::ClearAreas(), ::ClearSensitive(), ::DisplaySensitive(),

GridEcho - update value in StdSelect_ViewerSelector3d::Pick() instead of V3d_View::Compute().
Do not use global variable for GridEcho vertex.
Redraw immediate mode not within GridEcho but at AIS_InteractiveContext, AIS_LocalContext layer.

V3d_View::ToPixMap() - disable autoupdate during FitAll.
Avoid Redraw() into FBO without ImmediateModeDrawToFront flag.

PrsMgr_PresentationManager stores list of temporary immediate presentations,
automatically cleared within BeginImmediateMode() call.
Methods with ambiguous names have been renamed
(new names now consistent with pre-existed method names in AIS_LocalContext class):
- BeginDraw -> BeginImmediateDraw
- EndDraw -> EndImmediateDraw
Remove now useless Remove() method (and ImmediateRemove() in AIS).

Visual3d_View now stores map of displayed immediate presentations.

ViewerTest_EventManager - eliminate double redraw in selection methods.

Fix warning
This commit is contained in:
kgv
2014-03-20 13:54:12 +04:00
committed by bugmaster
parent 01ca42b2c1
commit 679ecdeeac
60 changed files with 2773 additions and 3216 deletions

View File

@@ -123,7 +123,6 @@ uses
Coordinate from V3d,
Array2OfReal from TColStd,
ViewerPointer from V3d,
TransientManager from Visual3d,
TypeOfTriedronEcho from Aspect,
TypeOfTriedronPosition from Aspect,
RenderingContext from Aspect,
@@ -205,6 +204,14 @@ is
-- Must be called if the view is shown.
-- (Ex: DeIconification ) .
RedrawImmediate ( me );
---Level: Public
---Purpose: Updates layer of immediate presentations.
Invalidate ( me );
---Level: Public
---Purpose: Invalidates view content but does not redraw it.
Redraw ( me ;x,y,width,height: Integer from Standard);
---Level: Public
---Purpose: Redisplays the view area after esxposure.
@@ -1030,18 +1037,19 @@ is
-- in the reference frame of the view corresponding
-- to the intersection with the projection plane
-- of the eye/view point vector and display the grid marker.
-- Warning: When the grid is not active the result is identical
-- to the above Convert() method.
-- How to use :
-- Warning: When the grid is not active the result is identical to the above Convert() method.
-- How to use:
-- 1) Enable the grid echo display
-- myViewer->SetGridEcho(Standard_True);
-- 2) When application receive a move event :
-- 2) When application receive a move event:
-- 2.1) Check if any object is detected
-- if( myInteractiveContext->MoveTo(x,y) == AIS_SOD_Nothing ) {
-- 2.2) Check if the grid is active
-- if( myViewer->Grid()->IsActive() ) {
-- 2.3) Display the grid echo and gets the grid point
-- myView->ConvertToGrid(x,y,X,Y,Z);
-- myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (X,Y,Z));
-- myView->RedrawImmediate();
-- 2.4) Else this is the standard case
-- } else myView->Convert(x,y,X,Y,Z);
raises UnMapped from V3d;
@@ -1343,42 +1351,6 @@ is
ImmediateUpdate (me) is static protected;
---Purpose:
-----------------------------------------
---Category: TransientManager methods
-----------------------------------------
TransientManagerBeginDraw(me; DoubleBuffer: Boolean = Standard_False;
RetainMode : Boolean = Standard_False)
---Level: Public
---Purpose: Begins any graphics in the view <aView>
-- Redraw any structured graphics in the back buffer before
-- if <DoubleBuffer> is TRUE.
-- Restore the front buffer from the back before
-- if <DoubleBuffer> is FALSE.
-- if <RetainMode> is TRUE.
-- the graphic managed itself exposure,resizing ...
-- if <RetainMode> is FALSE.
-- the application must managed itself exposure,resizing ...
--
returns Boolean from Standard;
TransientManagerClearDraw(me);
---Level: Public
---Purpose: Clear all transient graphics in the view <aView>
TransientManagerBeginAddDraw(me)
---Level: Public
---Purpose: Begins any add graphics in the view <aView>
-- Redraw any structured graphics in the back buffer before
-- the application must managed itself exposure,resizing ...
-- Warning: Returns TRUE if transient drawing is enabled in
-- the associated view.
-- Returns FALSE ,if nothing works because something
-- is wrong for the transient principle :
--
returns Boolean from Standard;
SetComputedMode ( me : mutable; aMode : Boolean from Standard )
is static;
---Level: Advanced

View File

@@ -116,7 +116,6 @@ To solve the problem (for lack of a better solution) I make 2 passes.
#include <Standard_ErrorHandler.hxx>
#include <Standard_DivideByZero.hxx>
#include <Visual3d_TransientManager.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_Layer.hxx>
@@ -415,6 +414,30 @@ void V3d_View::Redraw() const
if( MyView->IsDefined() ) MyView->Redraw() ;
}
//=============================================================================
//function : RedrawImmediate
//purpose :
//=============================================================================
void V3d_View::RedrawImmediate() const
{
if (MyView->IsDefined())
{
MyView->RedrawImmediate();
}
}
//=============================================================================
//function : Invalidate
//purpose :
//=============================================================================
void V3d_View::Invalidate() const
{
if (MyView->IsDefined())
{
MyView->Invalidate();
}
}
//=============================================================================
//function : Redraw
//purpose :
@@ -2974,37 +2997,6 @@ V3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const
return V3d_TypeOfBackfacingModel(MyView -> BackFacingModel ());
}
//=============================================================================
//function : TransientManagerBeginDraw
//purpose :
//=============================================================================
Standard_Boolean V3d_View::TransientManagerBeginDraw(const Standard_Boolean DoubleBuffer,const Standard_Boolean RetainMode) const
{
return Visual3d_TransientManager::BeginDraw(MyView,DoubleBuffer,RetainMode);
}
//=============================================================================
//function : TransientManagerClearDraw
//purpose :
//=============================================================================
void V3d_View::TransientManagerClearDraw() const
{
Visual3d_TransientManager::ClearDraw(MyView);
}
//=============================================================================
//function : TransientManagerBeginAddDraw
//purpose :
//=============================================================================
Standard_Boolean V3d_View::TransientManagerBeginAddDraw() const
{
return Visual3d_TransientManager::BeginAddDraw(MyView);
}
//=============================================================================
//function : Init
//purpose :
//=============================================================================
void V3d_View::Init()
{
myComputedMode = MyViewer->ComputedMode();
@@ -3131,7 +3123,14 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
}
}
// render immediate structures into back buffer rather than front
Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver());
const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False);
const Standard_Boolean toAutoUpdate = myImmediateUpdate;
myImmediateUpdate = Standard_False;
AutoZFit();
myImmediateUpdate = toAutoUpdate;
if (theToKeepAspect)
{
@@ -3144,9 +3143,6 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
MyLayerMgr->Compute();
}
// render immediate structures into back buffer rather than front
Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver());
const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False);
Redraw();
if (!aDriver.IsNull())

View File

@@ -11,32 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
/***********************************************************************
FONCTION :
----------
Classe V3d_View :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
16-08-98 : CAL ; S3892. Ajout grilles 3d.
16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1)
21-09-98 : CAL ; Activation de l'echo que si CSF_GraphicEcho est definie.
22-09-98 : BGN ; S3989 (anciennement S3819)
TypeOfTriedron* from Aspect (pas V3d)
02.15.100 : JR : Clutter
28/05/02 : VSV: ZBUFFER mode of Trihedron
************************************************************************/
#define IMP240100 //GG
// -> In Compute() method call MyViewer->ShowGridEcho()
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_View.jxx>
#include <TColStd_Array2OfReal.hxx>
@@ -48,14 +22,6 @@
#include <V3d_RectangularGrid.hxx>
#include <V3d_CircularGrid.hxx>
// For the echo of the chosen point
#include <Visual3d_TransientManager.hxx>
/*----------------------------------------------------------------------*/
/*
* Constant
*/
#define MYEPSILON1 0.0001 // Comparison with 0.0
#define MYEPSILON2 M_PI / 180. // Delta between 2 angles
@@ -176,9 +142,6 @@ Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const
// are perpendicular to MYEPSILON2 close radians
if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) {
NewPoint.SetCoord (X1, Y1, Z1);
#ifdef IMP240100
MyViewer->ShowGridEcho(this,NewPoint);
#endif //IMP240100
return NewPoint;
}
@@ -279,9 +242,6 @@ Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const
NewPoint.SetCoord (aResult.X(), aResult.Y(), aResult.Z());
}
#ifdef IMP240100
MyViewer->ShowGridEcho(this,NewPoint);
#endif //IMP240100
return NewPoint;
}

View File

@@ -151,6 +151,14 @@ is
-- all the views of the Viewer are exposed, as for
-- example in a global DeIconification.
RedrawImmediate ( me );
---Level: Public
---Purpose: Updates layer of immediate presentations.
Invalidate ( me );
---Level: Public
---Purpose: Invalidates viewer content but does not redraw it.
Remove (me:mutable);
---Level: Public
---Purpose: Suppresses the Viewer.
@@ -624,12 +632,17 @@ is
IsActive(me; aView: View from V3d)
returns Boolean from Standard is private;
ShowGridEcho(me : mutable;
aView: View from V3d;
aPoint: Vertex from Graphic3d) is private;
ShowGridEcho (me : mutable;
theView : View from V3d;
thePoint : Vertex from Graphic3d);
---Purpose:
-- Display grid echo at requested point in the view.
HideGridEcho (me : mutable;
theView : View from V3d);
---Purpose:
-- Temporarly hide grid echo.
AddZLayer ( me : mutable;
theLayerId : in out Integer from Standard )
returns Boolean from Standard is static;
@@ -708,6 +721,7 @@ fields
myGridEchoStructure: Structure from Graphic3d;
myGridEchoGroup: Group from Graphic3d;
myGridEchoAspect : AspectMarker3d from Graphic3d;
myGridEchoLastVert : Vertex from Graphic3d;
friends
class View from V3d,

View File

@@ -11,32 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
/***********************************************************************
FONCTION :
----------
Classe V3d_Viewer :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
15-11-97 : FMN ; Ajout texture mapping
02-02-98 : FMN ; Mise a niveau WNT
23-02-98 : FMN ; Remplacement PI par Standard_PI
16-07-98 : CAL ; S3892. Ajout grilles 3d.
************************************************************************/
//GER61351 //GG_15/12/99 Adds SetDefaultBackgroundColor() and DefaultBackgroundColor() methods
#define IMP240100 //GG
// Initalize grid echo fields
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_Light.hxx>
@@ -75,10 +49,9 @@ myComputedMode (theComputedMode),
myDefaultComputedMode (theDefaultComputedMode),
myPrivilegedPlane (gp_Ax3 (gp_Pnt (0.,0.,0), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.))),
myDisplayPlane (Standard_False),
myDisplayPlaneLength (theViewSize)
#ifdef IMP240100
,myGridEcho (Standard_True), myGridEchoStructure(), myGridEchoGroup()
#endif
myDisplayPlaneLength (theViewSize),
myGridEcho (Standard_True),
myGridEchoLastVert (ShortRealLast(), ShortRealLast(), ShortRealLast())
{
MyViewer = new Visual3d_ViewManager (theDriver);
// san (16/09/2010): It has been decided to turn depth test ON
@@ -156,16 +129,26 @@ Standard_Boolean V3d_Viewer::DefaultComputedMode() const {
return myDefaultComputedMode;
}
void V3d_Viewer::Update() {
void V3d_Viewer::Update()
{
MyViewer->Update();
}
void V3d_Viewer::Redraw()const {
void V3d_Viewer::Redraw()const
{
MyViewer->Redraw();
}
void V3d_Viewer::RedrawImmediate() const
{
MyViewer->RedrawImmediate();
}
void V3d_Viewer::Invalidate() const
{
MyViewer->Invalidate();
}
void V3d_Viewer::Remove() {
MyViewer->Remove();

View File

@@ -11,218 +11,317 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
/***********************************************************************
FONCTION :
----------
Classe V3d_Viewer :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
16-07-98 : CAL ; S3892. Ajout grilles 3d.
22-09-98 : CAL ; Erreur de compilation sur WNT dans V3d_Viewer_4.cxx.
************************************************************************/
#define IMP200100 //GG
// -> Add GridDrawMode() method.
// -> Compute the case Aspect_TDM_None
// in ActivateGrid(..)
#define IMP240100 //GG
// -> Add SetGridEcho() & GridEcho() methods
// -> Add ShowGridEcho() private method.
#define OCC281 //SAV added new field to store grid echo aspect
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_Viewer.jxx>
/*----------------------------------------------------------------------*/
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Visual3d_View.hxx>
Handle(Aspect_Grid) V3d_Viewer::Grid () const {
if (myGridType == Aspect_GT_Circular)
return myCGrid;
else if (myGridType == Aspect_GT_Rectangular)
return myRGrid;
else
return myRGrid;
// =======================================================================
// function : Grid
// purpose :
// =======================================================================
Handle(Aspect_Grid) V3d_Viewer::Grid() const
{
switch (myGridType)
{
case Aspect_GT_Circular: return myCGrid;
case Aspect_GT_Rectangular: return myRGrid;
}
return myRGrid;
}
Aspect_GridType V3d_Viewer::GridType () const {
return myGridType;
// =======================================================================
// function : GridType
// purpose :
// =======================================================================
Aspect_GridType V3d_Viewer::GridType() const
{
return myGridType;
}
#ifdef IMP200100
Aspect_GridDrawMode V3d_Viewer::GridDrawMode () const {
return Grid()->DrawMode();
}
#endif
void V3d_Viewer::ActivateGrid (const Aspect_GridType aType, const Aspect_GridDrawMode aMode) {
Grid ()->Erase ();
myGridType = aType;
Grid ()->SetDrawMode (aMode);
#ifdef IMP200100
if( aMode != Aspect_GDM_None ) Grid ()->Display ();
#else
Grid ()->Display ();
#endif
Grid ()->Activate ();
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
#ifndef IMP200100 //Do nothing more than the previous Grid()->Activate()
ActiveView ()->SetGridActivity (Standard_True);
#endif
}
Update ();
// =======================================================================
// function : GridDrawMode
// purpose :
// =======================================================================
Aspect_GridDrawMode V3d_Viewer::GridDrawMode() const
{
return Grid()->DrawMode();
}
void V3d_Viewer::DeactivateGrid () {
Grid ()->Erase ();
myGridType = Aspect_GT_Rectangular;
Grid ()->Deactivate ();
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
ActiveView ()->SetGridActivity (Standard_False);
}
Update ();
// =======================================================================
// function : ActivateGrid
// purpose :
// =======================================================================
void V3d_Viewer::ActivateGrid (const Aspect_GridType theType,
const Aspect_GridDrawMode theMode)
{
Grid()->Erase();
myGridType = theType;
Grid()->SetDrawMode (theMode);
if (theMode != Aspect_GDM_None)
{
Grid()->Display();
}
Grid()->Activate();
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->SetGrid (myPrivilegedPlane, Grid());
}
Update();
}
Standard_Boolean V3d_Viewer::IsActive () const {
return Grid ()->IsActive ();
}
void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theXStep, Quantity_Length& theYStep, Quantity_PlaneAngle& theRotationAngle) const {
theXOrigin = myRGrid->XOrigin ();
theYOrigin = myRGrid->YOrigin ();
theXStep = myRGrid->XStep ();
theYStep = myRGrid->YStep ();
theRotationAngle = myRGrid->RotationAngle ();
}
void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theXStep, const Quantity_Length theYStep, const Quantity_PlaneAngle theRotationAngle) {
myRGrid->SetGridValues
(theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGrid (myPrivilegedPlane, myRGrid);
Update ();
}
void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theRadiusStep, Standard_Integer& theDivisionNumber, Quantity_PlaneAngle& theRotationAngle) const {
theXOrigin = myCGrid->XOrigin ();
theYOrigin = myCGrid->YOrigin ();
theRadiusStep = myCGrid->RadiusStep ();
theDivisionNumber = myCGrid->DivisionNumber ();
theRotationAngle = myCGrid->RotationAngle ();
}
void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theRadiusStep, const Standard_Integer theDivisionNumber, const Quantity_PlaneAngle theRotationAngle) {
myCGrid->SetGridValues
(theXOrigin, theYOrigin, theRadiusStep,
theDivisionNumber, theRotationAngle);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGrid (myPrivilegedPlane, myCGrid);
Update ();
}
void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const {
myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}
void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, const Quantity_Length theYSize, const Quantity_Length theOffSet) {
myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGridGraphicValues (myRGrid);
Update ();
}
void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const {
myCGrid->GraphicValues (theRadius, theOffSet);
}
void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) {
myCGrid->SetGraphicValues (theRadius, theOffSet);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGridGraphicValues (myCGrid);
Update ();
}
#ifdef IMP240100
void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) {
myGridEcho = showGrid;
}
void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) {
if( myGridEchoStructure.IsNull() ) {
myGridEchoStructure = new Graphic3d_Structure(Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
// =======================================================================
// function : DeactivateGrid
// purpose :
// =======================================================================
void V3d_Viewer::DeactivateGrid()
{
Grid()->Erase();
myGridType = Aspect_GT_Rectangular;
Grid()->Deactivate();
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->SetGridActivity (Standard_False);
if (myGridEcho
&& !myGridEchoStructure.IsNull())
{
ActiveView()->View()->EraseImmediate (myGridEchoStructure);
}
#ifdef OCC281
myGridEchoAspect = aMarker;
#endif
myGridEchoGroup->SetPrimitivesAspect (aMarker);
}
Update();
}
Standard_Boolean V3d_Viewer::GridEcho() const {
// =======================================================================
// function : IsActive
// purpose :
// =======================================================================
Standard_Boolean V3d_Viewer::IsActive() const
{
return Grid()->IsActive();
}
// =======================================================================
// function : RectangularGridValues
// purpose :
// =======================================================================
void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin,
Quantity_Length& theYOrigin,
Quantity_Length& theXStep,
Quantity_Length& theYStep,
Quantity_PlaneAngle& theRotationAngle) const
{
theXOrigin = myRGrid->XOrigin();
theYOrigin = myRGrid->YOrigin();
theXStep = myRGrid->XStep();
theYStep = myRGrid->YStep();
theRotationAngle = myRGrid->RotationAngle();
}
// =======================================================================
// function : SetRectangularGridValues
// purpose :
// =======================================================================
void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin,
const Quantity_Length theYOrigin,
const Quantity_Length theXStep,
const Quantity_Length theYStep,
const Quantity_PlaneAngle theRotationAngle)
{
myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->SetGrid (myPrivilegedPlane, myRGrid);
}
Update();
}
// =======================================================================
// function : CircularGridValues
// purpose :
// =======================================================================
void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin,
Quantity_Length& theYOrigin,
Quantity_Length& theRadiusStep,
Standard_Integer& theDivisionNumber,
Quantity_PlaneAngle& theRotationAngle) const
{
theXOrigin = myCGrid->XOrigin();
theYOrigin = myCGrid->YOrigin();
theRadiusStep = myCGrid->RadiusStep();
theDivisionNumber = myCGrid->DivisionNumber();
theRotationAngle = myCGrid->RotationAngle();
}
// =======================================================================
// function : SetCircularGridValues
// purpose :
// =======================================================================
void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin,
const Quantity_Length theYOrigin,
const Quantity_Length theRadiusStep,
const Standard_Integer theDivisionNumber,
const Quantity_PlaneAngle theRotationAngle)
{
myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep,
theDivisionNumber, theRotationAngle);
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->SetGrid (myPrivilegedPlane, myCGrid);
}
Update();
}
// =======================================================================
// function : RectangularGridGraphicValues
// purpose :
// =======================================================================
void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize,
Quantity_Length& theYSize,
Quantity_Length& theOffSet) const
{
myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}
// =======================================================================
// function : SetRectangularGridGraphicValues
// purpose :
// =======================================================================
void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize,
const Quantity_Length theYSize,
const Quantity_Length theOffSet)
{
myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->SetGridGraphicValues (myRGrid);
}
Update();
}
// =======================================================================
// function : CircularGridGraphicValues
// purpose :
// =======================================================================
void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius,
Quantity_Length& theOffSet) const
{
myCGrid->GraphicValues (theRadius, theOffSet);
}
// =======================================================================
// function : SetCircularGridGraphicValues
// purpose :
// =======================================================================
void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius,
const Quantity_Length theOffSet)
{
myCGrid->SetGraphicValues (theRadius, theOffSet);
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->SetGridGraphicValues (myCGrid);
}
Update();
}
// =======================================================================
// function : SetGridEcho
// purpose :
// =======================================================================
void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid)
{
if (myGridEcho == theToShowGrid)
{
return;
}
myGridEcho = theToShowGrid;
if (theToShowGrid
|| myGridEchoStructure.IsNull())
{
return;
}
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->View()->EraseImmediate (myGridEchoStructure);
}
}
// =======================================================================
// function : SetGridEcho
// purpose :
// =======================================================================
void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker)
{
if (myGridEchoStructure.IsNull())
{
myGridEchoStructure = new Graphic3d_Structure (Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
}
myGridEchoAspect = theMarker;
myGridEchoGroup->SetPrimitivesAspect (theMarker);
}
// =======================================================================
// function : GridEcho
// purpose :
// =======================================================================
Standard_Boolean V3d_Viewer::GridEcho() const
{
return myGridEcho;
}
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Visual3d_TransientManager.hxx>
void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView,
const Graphic3d_Vertex& aVertex ) {
if( myGridEcho ) {
if( myGridEchoStructure.IsNull() ) {
myGridEchoStructure = new Graphic3d_Structure(Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
#ifdef OCC281
myGridEchoAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_STAR,
Quantity_Color( Quantity_NOC_GRAY90 ),
3.0 );
myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
#else
Handle(Graphic3d_AspectMarker3d) markerAttrib =
new Graphic3d_AspectMarker3d(Aspect_TOM_STAR,
Quantity_Color(Quantity_NOC_GRAY90),3.0);
myGridEchoGroup->SetPrimitivesAspect (markerAttrib);
#endif
}
static Graphic3d_Vertex lastVertex;
if( aVertex.Distance(lastVertex) != 0.0 ) {
lastVertex = aVertex;
myGridEchoGroup->Clear();
#ifdef OCC281
myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
#endif
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (aVertex.X(), aVertex.Y(), aVertex.Z());
myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
Visual3d_TransientManager::BeginDraw(
aView->View(), Standard_False, Standard_False);
Visual3d_TransientManager::DrawStructure (myGridEchoStructure);
Visual3d_TransientManager::EndDraw (Standard_True);
}
// =======================================================================
// function : ShowGridEcho
// purpose :
// =======================================================================
void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView,
const Graphic3d_Vertex& theVertex)
{
if (!myGridEcho)
{
return;
}
if (myGridEchoStructure.IsNull())
{
myGridEchoStructure = new Graphic3d_Structure (Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0);
myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
}
if (theVertex.X() == myGridEchoLastVert.X()
&& theVertex.Y() == myGridEchoLastVert.Y()
&& theVertex.Z() == myGridEchoLastVert.Z())
{
return;
}
myGridEchoLastVert = theVertex;
myGridEchoGroup->Clear();
myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
theView->View()->DisplayImmediate (myGridEchoStructure, Standard_True);
}
// =======================================================================
// function : HideGridEcho
// purpose :
// =======================================================================
void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView)
{
if (myGridEchoStructure.IsNull())
{
return;
}
myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast());
theView->View()->EraseImmediate (myGridEchoStructure);
}
#endif