#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>
}
-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;
+void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
+ const Handle(Visual3d_Layer)& theOverLayer)
+{
+ Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
+}
- if (! MyWindow->IsMapped ()) return;
+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;
+ }
- // 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);
- }
+ if (MyGraphicDriver->IsDeviceLost())
+ {
+ MyViewManager->RecomputeStructures();
+ MyViewManager->RecomputeStructures (myImmediateStructures);
+ MyGraphicDriver->ResetDeviceLostFlag();
+ }
- 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);
+ // 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::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) {
-
- if (IsDeleted ()) return;
-
- if ((! IsDefined ()) || (! IsActive ())) return;
-
- if (! MyWindow->IsMapped ()) return;
+void Visual3d_View::RedrawImmediate()
+{
+ RedrawImmediate (MyViewManager->UnderLayer(), MyViewManager->OverLayer());
+}
- // 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);
- }
+void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer,
+ const Handle(Visual3d_Layer)& theOverLayer)
+{
+ if (IsDeleted()
+ || !IsDefined()
+ || !IsActive()
+ || !MyWindow->IsMapped())
+ {
+ return;
+ }
- 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);
+ 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 ()
+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 {
<< ", " << OldPriority << ", " << NewPriority << ")\n";
cout << flush;
#endif
- MyGraphicDriver->EraseStructure
- (MyCView,
- *(Graphic3d_CStructure *)
- MyCOMPUTEDSequence.Value (Index)->CStructure ());
- MyGraphicDriver->DisplayStructure
- (MyCView,
- *(Graphic3d_CStructure *)
- MyCOMPUTEDSequence.Value (Index)->CStructure (),
- int (NewPriority));
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), NewPriority);
}
- else {
+ else
+ {
#ifdef TRACE
Standard_Integer StructId = AStructure->Identification ();
cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
<< ", " << OldPriority << ", " << NewPriority << ")\n";
cout << flush;
#endif
- MyGraphicDriver->EraseStructure
- (MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure ());
- MyGraphicDriver->DisplayStructure
- (MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure (),
- int (NewPriority));
+ MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), NewPriority);
}
}
}
+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 ());
if (Answer == Visual3d_TOA_YES ) {
if (IsDisplayed (AStructure)) return;
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), AStructure->DisplayPriority());
MyDisplayedStructure.Add (AStructure);
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
// to be displayed
if (! IsDisplayed (AStructure)) {
MyDisplayedStructure.Add (AStructure);
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), AStructure->DisplayPriority ());
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
return;
OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
Identification ();
MyDisplayedStructure.Add (AStructure);
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (NewIndex)->CStructure()), AStructure->DisplayPriority ());
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
return;
else {
// COMPUTED is removed if displayed
if (IsDisplayed (AStructure))
- MyGraphicDriver->EraseStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
}
}
} // if (Index != 0)
if (Answer != Visual3d_TOA_NO) {
if (! IsDisplayed (AStructure))
MyDisplayedStructure.Add (AStructure);
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)TheStructure->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority ());
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
} // Visual3d_TOA_COMPUTE
}
if (Answer != Visual3d_TOA_COMPUTE) {
- MyGraphicDriver->EraseStructure (
- MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure ()
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure()));
}
if (Answer == Visual3d_TOA_COMPUTE) {
<< StructId << " is removed. \n";
cout << flush;
#endif
- MyGraphicDriver->EraseStructure
- (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
}
// else is impossible
}
}
-void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
-
- MinMaxValues
- (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
-
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theZMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ Standard_Real& theZMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ MinMaxValues (MyDisplayedStructure,
+ theXMin, theYMin, theZMin,
+ theXMax, theYMax, theZMax,
+ theToIgnoreInfiniteFlag);
}
-void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
-
- if (ASet.IsEmpty ()) {
- XMin = RealFirst ();
- YMin = RealFirst ();
- ZMin = RealFirst ();
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
+ Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theZMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ Standard_Real& theZMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ if (theSet.IsEmpty ())
+ {
+ theXMin = RealFirst();
+ theYMin = RealFirst();
+ theZMin = RealFirst();
- XMax = RealLast ();
- YMax = RealLast ();
- ZMax = RealLast ();
+ theXMax = RealLast();
+ theYMax = RealLast();
+ theZMax = RealLast();
}
- else {
-
- Standard_Real Xm, Ym, Zm, XM, YM, ZM;
- Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
+ else
+ {
+ Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
+ Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
- XMin = RealLast ();
- YMin = RealLast ();
- ZMin = RealLast ();
+ theXMin = RealLast();
+ theYMin = RealLast();
+ theZMin = RealLast();
- XMax = RealFirst ();
- YMax = RealFirst ();
- ZMax = RealFirst ();
+ theXMax = RealFirst ();
+ theYMax = RealFirst ();
+ theZMax = RealFirst ();
- for ( Iterator.Initialize (ASet);
- Iterator.More ();
- Iterator.Next ()) {
+ for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
+ {
+ const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
- if ((Iterator.Key ())->IsInfinite ()){
+ if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
+ {
//XMin, YMin .... ZMax are initialized by means of infinite line data
- (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
- if ( Xm != RealFirst() && Xm < XMin )
- XMin = Xm ;
- if ( Ym != RealFirst() && Ym < YMin )
- YMin = Ym ;
- if ( Zm != RealFirst() && Zm < ZMin )
- ZMin = Zm ;
- if ( XM != RealLast() && XM > XMax )
- XMax = XM ;
- if ( YM != RealLast() && YM > YMax )
- YMax = YM ;
- if ( ZM != RealLast() && ZM > ZMax )
- ZMax = ZM ;
+ aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, Standard_False);
+ if (aXm != RealFirst() && aXm < theXMin)
+ {
+ theXMin = aXm;
+ }
+ if (aYm != RealFirst() && aYm < theYMin)
+ {
+ theYMin = aYm;
+ }
+ if (aZm != RealFirst() && aZm < theZMin)
+ {
+ theZMin = aZm;
+ }
+ if (aXM != RealLast() && aXM > theXMax)
+ {
+ theXMax = aXM;
+ }
+ if (aYM != RealLast() && aYM > theYMax)
+ {
+ theYMax = aYM;
+ }
+ if (aZM != RealLast() && aZM > theZMax)
+ {
+ theZMax = aZM;
+ }
}
+
// Only non-empty and non-infinite structures
// are taken into account for calculation of MinMax
- if (! (Iterator.Key ())->IsInfinite () &&
- ! (Iterator.Key ())->IsEmpty ()) {
- (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
- /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
- //"FitAll" operation ignores object with transform persitence parameter
- if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
- {
- if (Xm < XMin) XMin = Xm;
- if (Ym < YMin) YMin = Ym;
- if (Zm < ZMin) ZMin = Zm;
- if (XM > XMax) XMax = XM;
- if (YM > YMax) YMax = YM;
- if (ZM > ZMax) ZMax = ZM;
- }
+ if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
+ {
+ aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
+
+ /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
+ //"FitAll" operation ignores object with transform persitence parameter
+ if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
+ {
+ theXMin = Min (aXm, theXMin);
+ theYMin = Min (aYm, theYMin);
+ theZMin = Min (aZm, theZMin);
+ theXMax = Max (aXM, theXMax);
+ theYMax = Max (aYM, theYMax);
+ theZMax = Max (aZM, theZMax);
}
+ }
}
// The following cases are relevant
// For exemple if all structures are empty or infinite
- if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
- if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
- if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
+ if (theXMax < theXMin) { aXm = theXMin; theXMin = theXMax; theXMax = aXm; }
+ if (theYMax < theYMin) { aYm = theYMin; theYMin = theYMax; theYMax = aYm; }
+ if (theZMax < theZMin) { aZm = theZMin; theZMin = theZMax; theZMax = aZm; }
}
}
-void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
-
- MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
-
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ MinMaxValues (MyDisplayedStructure,
+ theXMin, theYMin,
+ theXMax, theYMax,
+ theToIgnoreInfiniteFlag);
}
-void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
-
-Standard_Real Xm, Ym, Zm, XM, YM, ZM;
-Standard_Real Xp, Yp, Zp;
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
+ Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
+ Standard_Real aXp, aYp, aZp;
- MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
+ MinMaxValues (theSet, aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
- Projects (Xm, Ym, Zm, Xp, Yp, Zp);
- XMin = Xp;
- YMin = Yp;
+ Projects (aXm, aYm, aZm, aXp, aYp, aZp);
+ theXMin = aXp;
+ theYMin = aYp;
- Projects (XM, YM, ZM, Xp, Yp, Zp);
- XMax = Xp;
- YMax = Yp;
+ Projects (aXM, aYM, aZM, aXp, aYp, aZp);
+ theXMax = aXp;
+ theYMax = aYp;
- if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
- if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
+ if (theXMax < theXMin) { aXp = theXMax; theXMax = theXMin; theXMin = aXp; }
+ if (theYMax < theYMin) { aYp = theYMax; theYMax = theYMin; theYMin = aYp; }
}
-
Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
Standard_Integer Result = MyDisplayedStructure.Extent ();
}
-void Visual3d_View::Projects (const Standard_Real AX,
- const Standard_Real AY,
- const Standard_Real AZ,
- Standard_Real& APX,
- Standard_Real& APY,
- Standard_Real& APZ)
+//=======================================================================
+//function : Projects
+//purpose :
+//=======================================================================
+void Visual3d_View::Projects (const Standard_Real theX,
+ const Standard_Real theY,
+ const Standard_Real theZ,
+ Standard_Real& thePX,
+ Standard_Real& thePY,
+ Standard_Real& thePZ) const
{
- Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
-
- Standard_Real aUmin, aVMin, aUMax, aVMax;
- Standard_Real aNear, aFar;
- aCamera->WindowLimit (aUmin, aVMin, aUMax, aVMax);
+ const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
- aNear = aCamera->ZNear();
- aFar = aCamera->ZFar();
+ gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
+ Standard_Real aXSize = aViewSpaceDimensions.X();
+ Standard_Real aYSize = aViewSpaceDimensions.Y();
+ Standard_Real aZSize = aViewSpaceDimensions.Z();
- gp_Pnt aPoint (AX, AY, AZ);
- aPoint = aCamera->Project (aPoint);
+ gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
- APX = (aPoint.X() + 1) * 0.5 * (aUMax - aUmin) + aUmin;
- APY = (aPoint.Y() + 1) * 0.5 * (aVMax - aVMin) + aVMin;
- APZ = aPoint.Z() * (aFar - aNear) + aNear;
+ // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
+ thePX = aPoint.X() * aXSize * 0.5;
+ thePY = aPoint.Y() * aYSize * 0.5;
+ thePZ = aPoint.Z() * aZSize * 0.5;
}
Standard_Integer Visual3d_View::Identification () const {
NewStructId = TheStructure->Identification ();
// The previous calculation is removed and the new one is dislayed
- MyGraphicDriver->EraseStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)TheStructure->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority());
#ifdef TRACE_LENGTH
if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
- MyGraphicDriver -> EraseStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
- );
- MyGraphicDriver -> DisplayStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- S1Iterator.Key () -> CStructure (),
- int ( S1Iterator.Key () -> DisplayPriority () )
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(S1Iterator.Key()->CStructure()), S1Iterator.Key()->DisplayPriority());
} // end if ( Index != 0 ) . . .
} // end if ( Answer . . . )
StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
- MyGraphicDriver -> EraseStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- S1Iterator.Key () -> CStructure ()
- );
- MyGraphicDriver -> DisplayStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
- int ( S1Iterator.Key () -> DisplayPriority () )
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), S1Iterator.Key()->DisplayPriority());
Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
} // end else
- MyGraphicDriver -> EraseStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- S1Iterator.Key () -> CStructure ()
- );
- MyGraphicDriver -> DisplayStructure (
- MyCView,
- *( Graphic3d_CStructure* )TheStructure -> CStructure (),
- int ( S1Iterator.Key () -> DisplayPriority () )
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), S1Iterator.Key()->DisplayPriority());
} // end else
} // end if
void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
const Standard_Integer theLayerId)
{
- MyGraphicDriver->ChangeZLayer (
- (*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId);
+ MyGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId);
}