File indexing completed on 2025-01-18 10:03:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_CView_HeaderFile
0015 #define _Graphic3d_CView_HeaderFile
0016
0017 #include <Aspect_RenderingContext.hxx>
0018 #include <Aspect_SkydomeBackground.hxx>
0019 #include <Aspect_Window.hxx>
0020 #include <Graphic3d_BufferType.hxx>
0021 #include <Graphic3d_CubeMap.hxx>
0022 #include <Graphic3d_DataStructureManager.hxx>
0023 #include <Graphic3d_DiagnosticInfo.hxx>
0024 #include <Graphic3d_GraduatedTrihedron.hxx>
0025 #include <Graphic3d_NMapOfTransient.hxx>
0026 #include <Graphic3d_RenderingParams.hxx>
0027 #include <Graphic3d_SequenceOfStructure.hxx>
0028 #include <Graphic3d_Structure.hxx>
0029 #include <Graphic3d_TextureEnv.hxx>
0030 #include <Graphic3d_TypeOfAnswer.hxx>
0031 #include <Graphic3d_TypeOfBackfacingModel.hxx>
0032 #include <Graphic3d_TypeOfBackground.hxx>
0033 #include <Graphic3d_TypeOfShadingModel.hxx>
0034 #include <Graphic3d_TypeOfVisualization.hxx>
0035 #include <Graphic3d_Vec3.hxx>
0036 #include <Graphic3d_ZLayerId.hxx>
0037 #include <Graphic3d_ZLayerSettings.hxx>
0038 #include <Image_PixMap.hxx>
0039 #include <Standard_Transient.hxx>
0040 #include <TColStd_IndexedDataMapOfStringString.hxx>
0041
0042 class Aspect_NeutralWindow;
0043 class Aspect_XRSession;
0044 class Graphic3d_CView;
0045 class Graphic3d_Layer;
0046 class Graphic3d_StructureManager;
0047
0048 DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
0049
0050
0051
0052
0053
0054
0055 class Graphic3d_CView : public Graphic3d_DataStructureManager
0056 {
0057 friend class Graphic3d_StructureManager;
0058 DEFINE_STANDARD_RTTIEXT(Graphic3d_CView, Graphic3d_DataStructureManager)
0059 public:
0060
0061
0062 Standard_EXPORT Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theMgr);
0063
0064
0065 Standard_EXPORT virtual ~Graphic3d_CView();
0066
0067
0068 Standard_Integer Identification() const { return myId; }
0069
0070
0071 Standard_EXPORT virtual void Activate();
0072
0073
0074
0075 Standard_EXPORT virtual void Deactivate();
0076
0077
0078 Standard_Boolean IsActive() const { return myIsActive; }
0079
0080
0081
0082 Standard_EXPORT virtual void Remove();
0083
0084
0085 Standard_Boolean IsRemoved() const { return myIsRemoved; }
0086
0087
0088 virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
0089
0090
0091 virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
0092
0093 public:
0094
0095
0096 Graphic3d_TypeOfShadingModel ShadingModel() const { return myRenderParams.ShadingModel; }
0097
0098
0099
0100 Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel);
0101
0102
0103
0104 Graphic3d_TypeOfBackfacingModel BackfacingModel() const { return myBackfacing; }
0105
0106
0107 void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) { myBackfacing = theModel; }
0108
0109
0110 Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; }
0111
0112
0113 void SetVisualizationType (const Graphic3d_TypeOfVisualization theType) { myVisualization = theType; }
0114
0115
0116 Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode);
0117
0118
0119 Standard_Boolean ComputedMode() const { return myIsInComputedMode; }
0120
0121
0122 Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& theStructure);
0123
0124
0125 Standard_EXPORT void Update (const Graphic3d_ZLayerId theLayerId = Graphic3d_ZLayerId_UNKNOWN);
0126
0127
0128 Standard_EXPORT void Compute();
0129
0130
0131 Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const;
0132
0133
0134 virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
0135
0136
0137
0138 Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId,
0139 Handle(Graphic3d_Structure)& theComputedStruct) const;
0140
0141
0142
0143
0144
0145
0146 Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary = Standard_False) const;
0147
0148
0149
0150
0151
0152 Standard_EXPORT Bnd_Box MinMaxValues (const Graphic3d_MapOfStructure& theSet,
0153 const Standard_Boolean theToIncludeAuxiliary = Standard_False) const;
0154
0155
0156 const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; }
0157
0158 private:
0159
0160
0161 Standard_EXPORT Graphic3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const;
0162
0163
0164 Standard_EXPORT void Clear (Graphic3d_Structure* theStructure,
0165 const Standard_Boolean theWithDestruction);
0166
0167
0168 Standard_EXPORT void Connect (const Graphic3d_Structure* theMother,
0169 const Graphic3d_Structure* theDaughter);
0170
0171
0172 Standard_EXPORT void Disconnect (const Graphic3d_Structure* theMother,
0173 const Graphic3d_Structure* theDaughter);
0174
0175
0176 Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& theStructure);
0177
0178
0179 Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& theStructure);
0180
0181
0182 Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure);
0183
0184
0185 Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure,
0186 const Handle(TopLoc_Datum3D)& theTrsf);
0187
0188
0189
0190 Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& theStructure);
0191
0192
0193 Standard_EXPORT Standard_Integer IsComputed (const Graphic3d_Structure* theStructure) const;
0194
0195 Standard_Integer IsComputed (const Handle(Graphic3d_Structure)& theStructure) const { return IsComputed (theStructure.get()); }
0196
0197
0198 Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(Graphic3d_Structure)& theStructure) const;
0199
0200
0201 Standard_EXPORT void ChangePriority (const Handle(Graphic3d_Structure)& theStructure,
0202 const Graphic3d_DisplayPriority theOldPriority,
0203 const Graphic3d_DisplayPriority theNewPriority);
0204
0205
0206 Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
0207 const Graphic3d_ZLayerId theLayerId);
0208
0209
0210
0211 Standard_EXPORT Standard_Integer HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStructure) const;
0212
0213 public:
0214
0215
0216 virtual void Redraw() = 0;
0217
0218
0219 virtual void RedrawImmediate() = 0;
0220
0221
0222 virtual void Invalidate() = 0;
0223
0224
0225 virtual Standard_Boolean IsInvalidated() = 0;
0226
0227
0228 Standard_EXPORT virtual void Resized() = 0;
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242 virtual Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) = 0;
0243
0244
0245
0246
0247
0248 virtual void SetWindow (const Handle(Graphic3d_CView)& theParentVIew,
0249 const Handle(Aspect_Window)& theWindow,
0250 const Aspect_RenderingContext theContext) = 0;
0251
0252
0253 virtual Handle(Aspect_Window) Window() const = 0;
0254
0255
0256 virtual Standard_Boolean IsDefined() const = 0;
0257
0258
0259 virtual Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0;
0260
0261
0262 virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) = 0;
0263
0264
0265
0266
0267
0268 virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
0269 const Graphic3d_ZLayerSettings& theSettings,
0270 const Graphic3d_ZLayerId theLayerAfter) = 0;
0271
0272
0273
0274
0275
0276 virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
0277 const Graphic3d_ZLayerSettings& theSettings,
0278 const Graphic3d_ZLayerId theLayerBefore) = 0;
0279
0280
0281
0282 virtual Standard_Integer ZLayerMax() const = 0;
0283
0284
0285 virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0;
0286
0287
0288 virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0;
0289
0290
0291 Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
0292
0293
0294
0295
0296
0297 virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
0298
0299
0300 virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
0301 const Graphic3d_ZLayerSettings& theSettings) = 0;
0302
0303
0304 Standard_EXPORT Standard_Real ConsiderZoomPersistenceObjects();
0305
0306
0307 virtual Handle(Standard_Transient) FBO() const = 0;
0308
0309
0310 virtual void SetFBO (const Handle(Standard_Transient)& theFbo) = 0;
0311
0312
0313
0314 virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth,
0315 const Standard_Integer theHeight) = 0;
0316
0317
0318 virtual void FBORelease (Handle(Standard_Transient)& theFbo) = 0;
0319
0320
0321 virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
0322 Standard_Integer& theWidth,
0323 Standard_Integer& theHeight,
0324 Standard_Integer& theWidthMax,
0325 Standard_Integer& theHeightMax) = 0;
0326
0327
0328 virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
0329 const Standard_Integer theWidth,
0330 const Standard_Integer theHeight) = 0;
0331
0332 public:
0333
0334
0335
0336
0337 Standard_EXPORT virtual void CopySettings (const Handle(Graphic3d_CView)& theOther);
0338
0339
0340 const Graphic3d_RenderingParams& RenderingParams() const { return myRenderParams; }
0341
0342
0343 Graphic3d_RenderingParams& ChangeRenderingParams() { return myRenderParams; }
0344
0345 public:
0346
0347
0348 virtual Aspect_Background Background() const { return Aspect_Background (myBgColor.GetRGB()); }
0349
0350
0351 virtual void SetBackground (const Aspect_Background& theBackground) { myBgColor.SetRGB (theBackground.Color()); }
0352
0353
0354 virtual Aspect_GradientBackground GradientBackground() const = 0;
0355
0356
0357 virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) = 0;
0358
0359
0360 const Handle(Graphic3d_TextureMap)& BackgroundImage() { return myBackgroundImage; }
0361
0362
0363 const Handle(Graphic3d_CubeMap)& BackgroundCubeMap() const { return myCubeMapBackground; }
0364
0365
0366 const Handle(Graphic3d_CubeMap)& IBLCubeMap() const { return myCubeMapIBL; }
0367
0368
0369
0370
0371
0372
0373 virtual void SetBackgroundImage (const Handle(Graphic3d_TextureMap)& theTextureMap,
0374 Standard_Boolean theToUpdatePBREnv = Standard_True) = 0;
0375
0376
0377 virtual Aspect_FillMethod BackgroundImageStyle() const = 0;
0378
0379
0380 virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0;
0381
0382
0383 Graphic3d_TypeOfBackground BackgroundType() const { return myBackgroundType; }
0384
0385
0386 void SetBackgroundType (Graphic3d_TypeOfBackground theType) { myBackgroundType = theType; }
0387
0388
0389 const Aspect_SkydomeBackground& BackgroundSkydome() const { return mySkydomeAspect; }
0390
0391
0392 Standard_EXPORT void SetBackgroundSkydome (const Aspect_SkydomeBackground& theAspect,
0393 Standard_Boolean theToUpdatePBREnv = Standard_True);
0394
0395
0396
0397
0398 virtual void SetImageBasedLighting (Standard_Boolean theToEnableIBL) = 0;
0399
0400
0401 const Handle(Graphic3d_TextureEnv)& TextureEnv() const { return myTextureEnvData; }
0402
0403
0404 virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
0405
0406 public:
0407
0408
0409 virtual const Handle(Graphic3d_LightSet)& Lights() const = 0;
0410
0411
0412 virtual void SetLights (const Handle(Graphic3d_LightSet)& theLights) = 0;
0413
0414
0415 virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const = 0;
0416
0417
0418 virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) = 0;
0419
0420
0421
0422
0423
0424
0425
0426
0427 Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
0428 Graphic3d_DiagnosticInfo theFlags) const = 0;
0429
0430
0431 virtual TCollection_AsciiString StatisticInformation() const = 0;
0432
0433
0434 virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const = 0;
0435
0436 public:
0437
0438
0439
0440 Standard_Real UnitFactor() const { return myUnitFactor; }
0441
0442
0443 Standard_EXPORT void SetUnitFactor (Standard_Real theFactor);
0444
0445
0446 const Handle(Aspect_XRSession)& XRSession() const { return myXRSession; }
0447
0448
0449 void SetXRSession (const Handle(Aspect_XRSession)& theSession) { myXRSession = theSession; }
0450
0451
0452 Standard_EXPORT bool IsActiveXR() const;
0453
0454
0455 Standard_EXPORT virtual bool InitXR();
0456
0457
0458 Standard_EXPORT virtual void ReleaseXR();
0459
0460
0461 Standard_EXPORT virtual void ProcessXRInput();
0462
0463
0464 Standard_EXPORT void SetupXRPosedCamera();
0465
0466
0467
0468 Standard_EXPORT void UnsetXRPosedCamera();
0469
0470
0471 const Handle(Graphic3d_Camera)& PosedXRCamera() const { return myPosedXRCamera; }
0472
0473
0474 void SetPosedXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myPosedXRCamera = theCamera; }
0475
0476
0477 const Handle(Graphic3d_Camera)& BaseXRCamera() const { return myBaseXRCamera; }
0478
0479
0480 void SetBaseXRCamera (const Handle(Graphic3d_Camera)& theCamera) { myBaseXRCamera = theCamera; }
0481
0482
0483
0484
0485
0486 gp_Trsf PoseXRToWorld (const gp_Trsf& thePoseXR) const
0487 {
0488 const Handle(Graphic3d_Camera)& anOrigin = myBaseXRCamera;
0489 const gp_Ax3 anAxVr (gp::Origin(), gp::DZ(), gp::DX());
0490 const gp_Ax3 aCameraCS (anOrigin->Eye().XYZ(), -anOrigin->Direction(), -anOrigin->SideRight());
0491 gp_Trsf aTrsfCS;
0492 aTrsfCS.SetTransformation (aCameraCS, anAxVr);
0493 return aTrsfCS * thePoseXR;
0494 }
0495
0496
0497
0498
0499 gp_Ax1 ViewAxisInWorld (const gp_Trsf& thePoseXR) const
0500 {
0501 return gp_Ax1 (gp::Origin(), -gp::DZ()).Transformed (PoseXRToWorld (thePoseXR));
0502 }
0503
0504
0505 Standard_EXPORT void SynchronizeXRBaseToPosedCamera();
0506
0507
0508
0509 Standard_EXPORT void SynchronizeXRPosedToBaseCamera();
0510
0511
0512 Standard_EXPORT void ComputeXRPosedCameraFromBase (Graphic3d_Camera& theCam,
0513 const gp_Trsf& theXRTrsf) const;
0514
0515
0516 Standard_EXPORT void ComputeXRBaseCameraFromPosed (const Graphic3d_Camera& theCamPosed,
0517 const gp_Trsf& thePoseTrsf);
0518
0519
0520 Standard_EXPORT void TurnViewXRCamera (const gp_Trsf& theTrsfTurn);
0521
0522 public:
0523
0524
0525 virtual const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() { return myGTrihedronData; }
0526
0527
0528 virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) { (void )theTrihedronData; }
0529
0530
0531 virtual void GraduatedTrihedronErase() {}
0532
0533
0534
0535
0536 virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
0537 {
0538 (void )theMin;
0539 (void )theMax;
0540 }
0541
0542
0543 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0544
0545 public:
0546
0547
0548 bool IsSubview() const { return myParentView != nullptr; }
0549
0550
0551 Graphic3d_CView* ParentView() { return myParentView; }
0552
0553
0554
0555
0556
0557
0558 bool IsSubviewComposer() const { return myIsSubviewComposer; }
0559
0560
0561 void SetSubviewComposer (bool theIsComposer) { myIsSubviewComposer = theIsComposer; }
0562
0563
0564 const NCollection_Sequence<Handle(Graphic3d_CView)>& Subviews() const { return mySubviews; }
0565
0566
0567 Standard_EXPORT void AddSubview (const Handle(Graphic3d_CView)& theView);
0568
0569
0570 Standard_EXPORT bool RemoveSubview (const Graphic3d_CView* theView);
0571
0572
0573 Aspect_TypeOfTriedronPosition SubviewCorner() const { return mySubviewCorner; }
0574
0575
0576 void SetSubviewCorner (Aspect_TypeOfTriedronPosition thePos) { mySubviewCorner = thePos; }
0577
0578
0579 const Graphic3d_Vec2i& SubviewTopLeft() const { return mySubviewTopLeft; }
0580
0581
0582 bool IsSubViewRelativeSize() const { return mySubviewSize.x() <= 1.0 && mySubviewSize.y() <= 1.0; }
0583
0584
0585
0586
0587 const Graphic3d_Vec2d& SubviewSize() const { return mySubviewSize; }
0588
0589
0590 void SetSubviewSize (const Graphic3d_Vec2d& theSize) { mySubviewSize = theSize; }
0591
0592
0593
0594
0595 const Graphic3d_Vec2d& SubviewOffset() const { return mySubviewOffset; }
0596
0597
0598 void SetSubviewOffset (const Graphic3d_Vec2d& theOffset) { mySubviewOffset = theOffset; }
0599
0600
0601 const Graphic3d_Vec2i& SubviewMargins() const { return mySubviewMargins; }
0602
0603
0604 void SetSubviewMargins (const Graphic3d_Vec2i& theMargins) { mySubviewMargins = theMargins; }
0605
0606
0607 Standard_EXPORT void SubviewResized (const Handle(Aspect_NeutralWindow)& theWindow);
0608
0609 private:
0610
0611
0612 virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
0613 const Graphic3d_DisplayPriority thePriority) = 0;
0614
0615
0616 virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) = 0;
0617
0618
0619 virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
0620 const Graphic3d_ZLayerId theNewLayerId) = 0;
0621
0622
0623 virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
0624 const Graphic3d_DisplayPriority theNewPriority) = 0;
0625
0626 protected:
0627
0628 Standard_Integer myId;
0629 Graphic3d_RenderingParams myRenderParams;
0630
0631 NCollection_Sequence<Handle(Graphic3d_CView)> mySubviews;
0632 Graphic3d_CView* myParentView;
0633 Standard_Boolean myIsSubviewComposer;
0634 Aspect_TypeOfTriedronPosition mySubviewCorner;
0635 Graphic3d_Vec2i mySubviewTopLeft;
0636 Graphic3d_Vec2i mySubviewMargins;
0637 Graphic3d_Vec2d mySubviewSize;
0638 Graphic3d_Vec2d mySubviewOffset;
0639
0640 Handle(Graphic3d_StructureManager) myStructureManager;
0641 Handle(Graphic3d_Camera) myCamera;
0642 Graphic3d_SequenceOfStructure myStructsToCompute;
0643 Graphic3d_SequenceOfStructure myStructsComputed;
0644 Graphic3d_MapOfStructure myStructsDisplayed;
0645 Standard_Boolean myIsInComputedMode;
0646 Standard_Boolean myIsActive;
0647 Standard_Boolean myIsRemoved;
0648 Graphic3d_TypeOfBackfacingModel myBackfacing;
0649 Graphic3d_TypeOfVisualization myVisualization;
0650
0651 Quantity_ColorRGBA myBgColor;
0652 Handle(Graphic3d_TextureMap) myBackgroundImage;
0653 Handle(Graphic3d_CubeMap) myCubeMapBackground;
0654 Handle(Graphic3d_CubeMap) myCubeMapIBL;
0655 Handle(Graphic3d_TextureEnv) myTextureEnvData;
0656 Graphic3d_GraduatedTrihedron myGTrihedronData;
0657 Graphic3d_TypeOfBackground myBackgroundType;
0658 Aspect_SkydomeBackground mySkydomeAspect;
0659 Standard_Boolean myToUpdateSkydome;
0660
0661 Handle(Aspect_XRSession) myXRSession;
0662 Handle(Graphic3d_Camera) myBackXRCamera;
0663 Handle(Graphic3d_Camera) myBaseXRCamera;
0664 Handle(Graphic3d_Camera) myPosedXRCamera;
0665 Handle(Graphic3d_Camera) myPosedXRCameraCopy;
0666 Standard_Real myUnitFactor;
0667
0668 };
0669
0670 #endif