1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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

@@ -95,9 +95,6 @@ is
exception ZClippingDefinitionError inherits OutOfRange;
---Category: The exceptions
exception TransientDefinitionError inherits OutOfRange;
---Category: The exceptions
exception LayerDefinitionError inherits OutOfRange;
---Category: The exceptions
@@ -259,10 +256,6 @@ is
---Purpose: 3D Visualiser
---Category: The classes
class TransientManager;
---Purpose: 3D Transient Visualiser
---Category: The classes
class Layer;
---Purpose: 2D Layer
---Category: The classes

View File

@@ -1,194 +0,0 @@
-- Created on: 1995-10-10
-- Created by: GG
-- Copyright (c) 1995-1999 Matra Datavision
-- Copyright (c) 1999-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.
class TransientManager from Visual3d inherits TShared
---Version:
---Purpose: This class allows to manage transient graphics
-- above one View.
-- A simple way to drawn something very quicly above
-- a complex scene (Hilighting,Sketching,...)
-- All transient graphics will be erased at the next
-- View::BeginDraw().
-- If RetainMode is active,
-- All transient graphics will be kept at the
-- next View::Update(),Redraw(). The transient graphics
-- is stored by this object and graphic library, the
-- graphic managed itself exposure,resizing,...
-- The method View::ClearDraw() is necessary to erase
-- all transient graphics.
-- If RetainMode is deactivate,
-- All transient graphics will be erased at the
-- next View::Update(),Redraw().
-- Remember that nothing is stored by this object and
-- graphic library,the application must managed itself
-- exposure,resizing,...
-- If double_buffering is activate,
-- all graphics are drawn in the back buffer and flushed
-- in the front buffer at the end of drawing but nothing
-- is done for to separate transient from structured
-- graphics,the only way to regenerate the structured
-- view is to Redraw() the view.
-- If double_buffering is deactivate,
-- the back buffer is preserved and used for restoring
-- the front buffer at begin drawing time.I recommend
-- to use the second way (without DB) if you want
-- to preserve the graphics and the performances!
uses
Array2OfReal from TColStd,
ExtendedString from TCollection,
PlaneAngle from Quantity,
Structure from Graphic3d,
AspectLine3d from Graphic3d,
AspectFillArea3d from Graphic3d,
AspectText3d from Graphic3d,
AspectMarker3d from Graphic3d,
TypeOfComposition from Graphic3d,
TextPath from Graphic3d,
HorizontalTextAlignment from Graphic3d,
VerticalTextAlignment from Graphic3d,
View from Visual3d
raises
TransientDefinitionError from Visual3d,
TransformError from Graphic3d
is
-------------------------
-- Category: Constructors
-------------------------
Create returns mutable TransientManager from Visual3d;
---Purpose: Creates a TransientManager <aView>.
---Category: Constructors
------------------------
-- Category: Destructors
------------------------
Destroy (me : mutable);
---Level: Public
---Purpose: Suppress the TransientManager <me>.
---Category: Destructors
---C++: alias ~
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
BeginDraw (myclass;
aView : View from Visual3d;
DoubleBuffer: Boolean = Standard_False;
RetainMode: Boolean = Standard_False)
returns Boolean from Standard
---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 ...
--
-- 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 :
-- Immediat mode is not implemented depending of the
-- graphic library used.
-- MBX,PIXMAP double buffering don't works depending of
-- the graphic board and the visual of the window supporting
-- the view.
-- Warning: No default attributes
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is already opened.
-- or the associated view is not mapped on a window.
raises TransientDefinitionError from Visual3d;
EndDraw (myclass;
Synchronize: Boolean = Standard_False)
---Level: Public
---Purpose: Flush all graphics to the front buffer.
-- Synchronize graphics to the screen if <Synchronize> is
-- TRUE (make becarefull to the performances!).
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is not opened.
raises TransientDefinitionError from Visual3d;
ClearDraw (myclass; aView : View from Visual3d;
aFlush : Boolean from Standard = Standard_True)
---Level: Public
---Purpose: Clear all transient graphics in the view <aView>
--- updates a scene if <aFlush> = true
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is already opened.
-- or the associated view is not mapped on a window.
raises TransientDefinitionError from Visual3d;
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
BeginAddDraw (myclass;
aView : View from Visual3d)
returns Boolean from Standard
---Level: Public
---Purpose: Begins any add graphics in the view <aView>
-- 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 :
-- Immediat mode is not implemented depending of the
-- graphic library used.
-- MBX,PIXMAP double buffering don't works depending of
-- the graphic board and the visual of the window supporting
-- the view.
-- Warning: No default attributes
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is already opened.
-- or the associated view is not mapped on a window.
raises TransientDefinitionError from Visual3d;
EndAddDraw (myclass)
---Purpose: Flush all add graphics to the front buffer.
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is not opened.
raises TransientDefinitionError from Visual3d;
---------------------------------------
-- Category: Graphic definition methods
---------------------------------------
DrawStructure (myclass;
AStructure : Structure from Graphic3d)
---Purpose: Drawn the structure <AStructure>.
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is not opened.
raises TransientDefinitionError from Visual3d;
end TransientManager from Visual3d;

View File

@@ -1,239 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
/***********************************************************************
FONCTION :
----------
Classe Visual3d_TransientManager :
Declaration des variables specifiques au mode transient.
Une vue est definie par :
- un ViewManager
- un ContextView
- un ViewMapping
- une ViewOrientation
HISTORIQUE DES MODIFICATIONS :
--------------------------------
October 1995 : GG : Creation.
20-11-97 : CAL ; Disparition de la dependance avec math
01-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED.
18-12-97 : FMN ; Ajout mode AJOUT.
27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
10-06-98 : CAL ; Modification de la signature de DrawStructure.
25-09-98 : CAL ; Mise a jour de theCView = *(CALL_DEF_VIEW *)AView->CView ();
10-11-98 : CAL ; PRO16361. theCView dans ClearImmediatMode.
30-11-98 : FMN ; S4069 : Textes toujours visibles.
01-12-98 : CAL ; S4062. Ajout des layers.
************************************************************************/
// for the class
#include <Visual3d_TransientManager.ixx>
#include <Visual3d_ViewPtr.hxx>
#include <Visual3d_View.pxx>
#include <Aspect_CLayer2d.hxx>
#include <Graphic3d_CView.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_TypeOfPrimitive.hxx>
#include <Visual3d_Layer.hxx>
enum TypeOfImmediat {
Immediat_None,
Immediat_Transient,
Immediat_Ajout
};
//-Global data definitions
static Standard_Integer theDrawingState = 0;
static TypeOfImmediat theImmediatState = Immediat_None;
static Handle(Graphic3d_GraphicDriver)& _theGraphicDriver() {
static Handle(Graphic3d_GraphicDriver) theGraphicDriver;
return theGraphicDriver;
}
#define theGraphicDriver _theGraphicDriver()
static Graphic3d_CView& _theCView() {
static Graphic3d_CView theCView;
return theCView;
}
#define theCView _theCView()
static Aspect_CLayer2d UnderCLayer;
static Aspect_CLayer2d OverCLayer;
//
//-Constructors
//
Visual3d_TransientManager::Visual3d_TransientManager () {
}
//
//-Destructors
//
void Visual3d_TransientManager::Destroy () {
}
//-Methods, in order
Standard_Boolean Visual3d_TransientManager::BeginDraw (const Handle(Visual3d_View)& AView, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode) {
if (theDrawingState > 0) {
Graphic3d_CView* pview = (Graphic3d_CView*) AView->CView();
if( theImmediatState == Immediat_Transient &&
pview->ViewId == theCView.ViewId ) {
theDrawingState++;
return theDrawingState;
} else
Visual3d_TransientDefinitionError::Raise
("Drawing in progress !");
}
Handle(Visual3d_Layer) OverLayer = AView->OverLayer ();
Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer ();
OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
theCView = *(Graphic3d_CView* )AView->CView ();
if (! UnderLayer.IsNull ()){
UnderCLayer = UnderLayer->CLayer();
theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
}
if (! OverLayer.IsNull ()){
OverCLayer = OverLayer->CLayer();
theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer;
}
// Begin rendering
theGraphicDriver = AView->GraphicDriver();
if (theGraphicDriver->BeginImmediatMode
(theCView, UnderCLayer, OverCLayer, DoubleBuffer, RetainMode))
{
theDrawingState++;
theImmediatState = Immediat_Transient;
}
return theDrawingState;
}
void Visual3d_TransientManager::EndDraw (const Standard_Boolean Synchronize) {
if( theDrawingState <= 0 )
Visual3d_TransientDefinitionError::Raise ("Drawing not started !");
theDrawingState--;
if( theDrawingState > 0 ) return;
theImmediatState = Immediat_None;
// Flush all graphics
theGraphicDriver->EndImmediatMode(Synchronize);
}
void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView,
const Standard_Boolean aFlush)
{
if (theDrawingState > 0)
Visual3d_TransientDefinitionError::Raise
("Drawing in progress !");
// Begin rendering
theCView = *(Graphic3d_CView* )AView->CView ();
if (!AView->UnderLayer().IsNull()) {
UnderCLayer = AView->UnderLayer()->CLayer();
theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
}
if (!AView->OverLayer().IsNull()) {
OverCLayer = AView->OverLayer()->CLayer();
theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer;
}
theGraphicDriver = AView->GraphicDriver();
theGraphicDriver->ClearImmediatMode (theCView, aFlush);
}
//
//-Mode Ajout
//
Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_View)& AView)
{
if (theDrawingState > 0)
{
Graphic3d_CView* pview = (Graphic3d_CView* )AView->CView();
if( theImmediatState == Immediat_Ajout &&
pview->ViewId == theCView.ViewId ) {
theDrawingState++;
return theDrawingState;
} else
Visual3d_TransientDefinitionError::Raise
("Drawing in progress !");
}
// Begin rendering
theCView = *(Graphic3d_CView* )AView->CView ();
if (!AView->UnderLayer().IsNull()) {
UnderCLayer = AView->UnderLayer()->CLayer();
theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer;
}
if (!AView->OverLayer().IsNull()) {
OverCLayer = AView->OverLayer()->CLayer();
theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer;
}
theGraphicDriver = AView->GraphicDriver ();
if (theGraphicDriver->BeginAddMode (theCView))
{
theDrawingState++;
theImmediatState = Immediat_Ajout;
}
return theDrawingState;
}
void Visual3d_TransientManager::EndAddDraw () {
if( theDrawingState <= 0 )
Visual3d_TransientDefinitionError::Raise ("Drawing not started !");
theDrawingState--;
if( theDrawingState > 0 ) return;
theImmediatState = Immediat_None;
// Flush all graphics
theGraphicDriver->EndAddMode();
}
//
//-Graphic definition methods
//
void Visual3d_TransientManager::DrawStructure (const Handle(Graphic3d_Structure)& theStructure)
{
if (!theDrawingState)
{
Visual3d_TransientDefinitionError::Raise ("Drawing is not open !");
}
else if (!theStructure->IsEmpty())
{
theGraphicDriver->DrawStructure (*theStructure->CStructure());
}
}

View File

@@ -172,6 +172,11 @@ is
---Purpose: Updates screen in all cases.
---Category: Methods to modify the class definition
RedrawImmediate ( me : mutable )
is static;
---Level: Public
---Purpose: Updates layer of immediate presentations.
Redraw ( me : mutable; x,y,width,height: Integer from Standard )
is static;
---Level: Public
@@ -187,6 +192,18 @@ is
---Purpose: Updates screen in all cases.
---Category: Methods to modify the class definition
RedrawImmediate ( me : mutable;
theUnderLayer : Layer from Visual3d;
theOverLayer : Layer from Visual3d )
is static;
---Level: Public
---Purpose: Updates layer of immediate presentations.
Invalidate ( me : mutable )
is static;
---Level: Public
---Purpose: Invalidates view content but does not redraw it.
Redraw ( me : mutable;
AnUnderLayer : Layer from Visual3d;
AnOverLayer : Layer from Visual3d;
@@ -839,6 +856,30 @@ is
---Purpose: Display the structure <AStructure> to the view <me>.
---Category: Private methods
DisplayImmediate ( me : mutable;
theStructure : Structure from Graphic3d;
theIsSingleView : Boolean from Standard = Standard_True)
returns Boolean from Standard
is static;
---Level: Internal
---Purpose: Add structure to the list of immediate presentations.
-- @return true if structure has not been registered in this view
EraseImmediate ( me : mutable;
theStructure : Structure from Graphic3d )
returns Boolean from Standard
is static;
---Level: Internal
---Purpose: Removes the structure from the list of immediate presentations.
-- @return true if structure has been registered in view
ClearImmediate ( me : mutable )
returns Boolean from Standard
is static;
---Level: Internal
---Purpose: Clears list of immediate presentations.
-- @return true if list was not empty
Erase ( me : mutable;
AStructure : Structure from Graphic3d )
is static private;
@@ -1138,52 +1179,53 @@ is
fields
--
-- Classe : Visual3d_View
-- Classe: Visual3d_View
--
-- Purpose : Declaration of the variables specific to views.
-- Purpose: Declaration of the variables specific to views.
--
-- Reminder : A view is defined by:
-- - a ViewManager
-- - a ContextView
-- Reminder: A view is defined by:
-- - a ViewManager
-- - a ContextView
-- the associated C structure
MyCView : CView from Graphic3d;
-- the associated C structure
MyCView : CView from Graphic3d;
-- the context of the view : Aliasing, Depth-Cueing, Lights ...
MyContext : ContextView from Visual3d;
-- the context of the view : Aliasing, Depth-Cueing, Lights ...
MyContext : ContextView from Visual3d;
-- the associated window
MyWindow : Window from Aspect;
-- the associated window
MyWindow : Window from Aspect;
-- association Structure_COMPUTE and Structure_Computed
MyTOCOMPUTESequence : SequenceOfStructure from Graphic3d;
MyCOMPUTEDSequence : SequenceOfStructure from Graphic3d;
-- association Structure_COMPUTE and Structure_Computed
MyTOCOMPUTESequence : SequenceOfStructure from Graphic3d;
MyCOMPUTEDSequence : SequenceOfStructure from Graphic3d;
-- the graphic driver used
MyGraphicDriver : GraphicDriver from Graphic3d;
-- the graphic driver used
MyGraphicDriver : GraphicDriver from Graphic3d;
-- the background of the associated window
MyBackground : Background from Aspect;
-- the background of the associated window
MyBackground : Background from Aspect;
-- the gradient background of the associated window
MyGradientBackground : GradientBackground from Aspect;
-- the gradient background of the associated window
MyGradientBackground : GradientBackground from Aspect;
-- the displayed structures in the view
MyDisplayedStructure : MapOfStructure from Graphic3d;
-- the displayed structures in the view
MyDisplayedStructure : MapOfStructure from Graphic3d;
-- the ViewManager associated with the view
-- MyPtrViewManager : Address from Standard;
MyPtrViewManager : ViewManagerPtr from Visual3d;
myImmediateStructures : MapOfStructure from Graphic3d;
-- Booleans
MyCBitFields : CBitFields8 from Graphic3d;
-- the ViewManager associated with the view
MyPtrViewManager : ViewManagerPtr from Visual3d;
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
-- Booleans
MyCBitFields : CBitFields8 from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d;
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d;
friends
class ViewManager from Visual3d
class ViewManager from Visual3d
end View;

View File

@@ -136,8 +136,8 @@
#include <Visual3d_Light.hxx>
#include <Visual3d_SetOfLight.hxx>
#include <Visual3d_HSetOfLight.hxx>
#include <Visual3d_HSetOfView.hxx>
#include <Visual3d_SetIteratorOfSetOfLight.hxx>
#include <Visual3d_SetIteratorOfSetOfView.hxx>
#include <Graphic3d_TextureEnv.hxx>
@@ -1021,130 +1021,115 @@ void Visual3d_View::Deactivate () {
}
void Visual3d_View::Redraw () {
Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
void Visual3d_View::Redraw()
{
Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0);
}
void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
void Visual3d_View::Redraw (const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight)
{
Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(),
theX, theY, theWidth, theHeight);
}
void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
if (IsDeleted ()) return;
if ((! IsDefined ()) || (! IsActive ())) return;
if (! MyWindow->IsMapped ()) return;
// san - 14/04/2004 - set up Z buffer state before redrawing
// If the activation/desactivation of ZBuffer should be automatic
// depending on the presence or absence of facets.
if (MyViewManager->ZBufferAuto ()) {
Standard_Boolean BContainsFacet = ContainsFacet ();
Standard_Boolean BZBuffer = ZBufferIsActivated ();
// If the view contains facets
// and if ZBuffer is not active
if (BContainsFacet && ! BZBuffer)
SetZBufferActivity (1);
// If the view contains only facets
// and if ZBuffer is active
if (! BContainsFacet && BZBuffer)
SetZBufferActivity (0);
}
Aspect_CLayer2d OverCLayer;
Aspect_CLayer2d UnderCLayer;
OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
const Handle(Visual3d_Layer)& theOverLayer)
{
Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
}
void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
const Handle(Visual3d_Layer)& theOverLayer,
const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight)
{
if (IsDeleted()
|| !IsDefined()
|| !IsActive()
|| !MyWindow->IsMapped())
{
return;
}
if (IsDeleted ()) return;
if (MyGraphicDriver->IsDeviceLost())
{
MyViewManager->RecomputeStructures();
MyViewManager->RecomputeStructures (myImmediateStructures);
MyGraphicDriver->ResetDeviceLostFlag();
}
if ((! IsDefined ()) || (! IsActive ())) return;
if (! MyWindow->IsMapped ()) return;
// san - 14/04/2004 - set up Z buffer state before redrawing
// If activation/desactivation of ZBuffer should be automatic
// depending on the presence or absence of facets.
if (MyViewManager->ZBufferAuto ()) {
Standard_Boolean BContainsFacet = ContainsFacet ();
Standard_Boolean BZBuffer = ZBufferIsActivated ();
// If the view contains facets
// and if ZBuffer is not active
if (BContainsFacet && ! BZBuffer)
SetZBufferActivity (1);
// If the view contains only facets
// and if ZBuffer is active
if (! BContainsFacet && BZBuffer)
SetZBufferActivity (0);
}
Aspect_CLayer2d OverCLayer;
Aspect_CLayer2d UnderCLayer;
OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
// set up Z buffer state before redrawing
if (MyViewManager->ZBufferAuto())
{
const Standard_Boolean hasFacet = ContainsFacet();
const Standard_Boolean hasZBuffer = ZBufferIsActivated();
// if the view contains facets and if ZBuffer is not active
if (hasFacet && !hasZBuffer)
{
SetZBufferActivity (1);
}
// if the view contains only facets and if ZBuffer is active
if (!hasFacet && hasZBuffer)
{
SetZBufferActivity (0);
}
}
Aspect_CLayer2d anOverCLayer, anUnderCLayer;
anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
MyGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight);
}
void Visual3d_View::Update ()
void Visual3d_View::RedrawImmediate()
{
RedrawImmediate (MyViewManager->UnderLayer(), MyViewManager->OverLayer());
}
void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer,
const Handle(Visual3d_Layer)& theOverLayer)
{
if (IsDeleted()
|| !IsDefined()
|| !IsActive()
|| !MyWindow->IsMapped())
{
return;
}
Aspect_CLayer2d anOverCLayer, anUnderCLayer;
anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
MyGraphicDriver->RedrawImmediate (MyCView, anUnderCLayer, anOverCLayer);
}
void Visual3d_View::Invalidate()
{
MyGraphicDriver->Invalidate (MyCView);
}
void Visual3d_View::Update()
{
IsInitialized = Standard_True;
Compute ();
Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0);
}
void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
if (IsDeleted ()) return;
if ((! IsDefined ()) || (! IsActive ())) return;
if (! MyWindow->IsMapped ()) return;
if (MyGraphicDriver->IsDeviceLost())
{
MyViewManager->RecomputeStructures();
MyGraphicDriver->ResetDeviceLostFlag();
}
// If activation/desactivation of ZBuffer should be automatic
// depending on the presence or absence of facets.
if (MyViewManager->ZBufferAuto ()) {
Standard_Boolean BContainsFacet = ContainsFacet ();
Standard_Boolean BZBuffer = ZBufferIsActivated ();
// If the view contains facets
// and if ZBuffer is not active
if (BContainsFacet && ! BZBuffer)
SetZBufferActivity (1);
// If the view does not contain facets
// and if ZBuffer is active
if (! BContainsFacet && BZBuffer)
SetZBufferActivity (0);
}
Aspect_CLayer2d OverCLayer;
Aspect_CLayer2d UnderCLayer;
OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
//OSD::SetSignal (Standard_False);
MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
//OSD::SetSignal (Standard_True);
void Visual3d_View::Update (const Handle(Visual3d_Layer)& theUnderLayer,
const Handle(Visual3d_Layer)& theOverLayer)
{
IsInitialized = Standard_True;
Compute ();
Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
}
Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
@@ -1311,6 +1296,56 @@ Standard_Integer IndexD = IsComputed (ADaughter);
}
Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure,
const Standard_Boolean theIsSingleView)
{
if (!myImmediateStructures.Add (theStructure))
{
return Standard_False;
}
if (theIsSingleView)
{
Handle_Visual3d_HSetOfView aViews = MyViewManager->DefinedView();
for (Visual3d_SetIteratorOfSetOfView aViewIter (aViews->Set()); aViewIter.More(); aViewIter.Next())
{
if (aViewIter.Value().Access() != this)
{
aViewIter.Value()->EraseImmediate (theStructure);
}
}
}
MyGraphicDriver->DisplayImmediateStructure (MyCView, *theStructure->CStructure());
return Standard_True;
}
Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure)
{
const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure);
if (isErased)
{
MyGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure());
}
return isErased;
}
Standard_Boolean Visual3d_View::ClearImmediate()
{
if (myImmediateStructures.IsEmpty())
{
return Standard_False;
}
for (Graphic3d_MapIteratorOfMapOfStructure anIter (myImmediateStructures); anIter.More(); anIter.Next())
{
MyGraphicDriver->EraseImmediateStructure (MyCView, *anIter.Key()->CStructure());
}
myImmediateStructures.Clear();
return Standard_True;
}
void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
Display (AStructure, MyViewManager->UpdateMode ());

View File

@@ -88,11 +88,21 @@ is
-- visualiser <me>.
---Category: Methods to modify the class definition
Redraw ( me )
is static;
---Level: Public
---Purpose: Redraws all the displayed structures.
---Category: Methods to modify the class definition
Redraw ( me )
is static;
---Level: Public
---Purpose: Redraws all the displayed structures.
---Category: Methods to modify the class definition
RedrawImmediate ( me )
is static;
---Level: Public
---Purpose: Updates layer of immediate presentations.
Invalidate ( me )
is static;
---Level: Public
---Purpose: Invalidates viewer content but does not redraw it.
Remove ( me : mutable )
is static;
@@ -100,13 +110,11 @@ is
---Purpose: Deletes and erases the 3D visualiser <me>.
---Category: Methods to modify the class definition
Update ( me )
is redefined static;
---Level: Public
---Purpose: Updates screen in function of modifications of
-- the structures.
-- Category: Methods to modify the class definition
-- Warning: Not necessary if the update mode is TOU_ASAP.
Update ( me )
is redefined static;
---Level: Public
---Purpose: Updates screen in function of modifications of the structures.
-- Category: Methods to modify the class definition
----------------------------
-- Category: Inquire methods

View File

@@ -388,61 +388,76 @@ void Visual3d_ViewManager::UnHighlight (const Handle(Graphic3d_Structure)& AStru
}
void Visual3d_ViewManager::Redraw () const {
void Visual3d_ViewManager::Redraw() const
{
// redraw all activated views
if (MyDefinedView.Extent() == 0)
{
return;
}
Standard_Integer MaxDx, MaxDy;
Standard_Integer Dx, Dy;
MaxDx = MaxDy = IntegerFirst ();
if (!MyUnderLayer.IsNull() || !MyOverLayer.IsNull())
{
Standard_Integer aWidth = 0, aHeight = 0;
Standard_Integer aWidthMax = 0;
Standard_Integer aHeightMax = 0;
for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView);
anIter.More(); anIter.Next())
{
anIter.Value()->Window()->Size (aWidth, aHeight);
aWidthMax = Max (aWidthMax, aWidth);
aHeightMax = Max (aHeightMax, aWidth);
}
if (!MyUnderLayer.IsNull())
{
MyUnderLayer->SetViewport (aWidthMax, aHeightMax);
}
if (!MyOverLayer.IsNull())
{
MyOverLayer->SetViewport (aWidthMax, aHeightMax);
}
}
//
// Redraw all activated views
//
Standard_Integer j = MyDefinedView.Extent ();
if (j == 0) return;
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ()) {
while (MyIterator.More ()) {
(MyIterator.Value ())->Window ()->Size (Dx, Dy);
if (Dx > MaxDx) MaxDx = Dx;
if (Dy > MaxDy) MaxDy = Dy;
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
if (! MyUnderLayer.IsNull ())
MyUnderLayer->SetViewport (MaxDx, MaxDy);
if (! MyOverLayer.IsNull ())
MyOverLayer->SetViewport (MaxDx, MaxDy);
for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView);
anIter.More(); anIter.Next())
{
anIter.Value()->Redraw (MyUnderLayer, MyOverLayer);
}
if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ())
MyIterator.Initialize (MyDefinedView);
while (MyIterator.More ()) {
(MyIterator.Value ())->Redraw (MyUnderLayer, MyOverLayer);
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
}
void Visual3d_ViewManager::Update () const {
void Visual3d_ViewManager::Update() const
{
Redraw();
}
//
// Update all activated views
//
Standard_Integer j = MyDefinedView.Extent ();
if (j == 0) return;
Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
void Visual3d_ViewManager::RedrawImmediate() const
{
if (MyDefinedView.Extent() == 0)
{
return;
}
while (MyIterator.More ()) {
(MyIterator.Value ())->Update (MyUnderLayer, MyOverLayer);
// update all activated views
for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView);
anIter.More(); anIter.Next())
{
anIter.Value()->RedrawImmediate (MyUnderLayer, MyOverLayer);
}
}
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
void Visual3d_ViewManager::Invalidate() const
{
if (MyDefinedView.Extent() == 0)
{
return;
}
// update all activated views
for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView);
anIter.More(); anIter.Next())
{
anIter.Value()->Invalidate();
}
}
Handle(Visual3d_HSetOfView) Visual3d_ViewManager::ActivatedView () const {