File indexing completed on 2025-01-18 10:05:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _V3d_Viewer_HeaderFile
0018 #define _V3d_Viewer_HeaderFile
0019
0020 #include <Aspect_GridDrawMode.hxx>
0021 #include <Aspect_GridType.hxx>
0022 #include <Graphic3d_StructureManager.hxx>
0023 #include <Graphic3d_Vertex.hxx>
0024 #include <Graphic3d_ZLayerSettings.hxx>
0025 #include <TColStd_MapOfInteger.hxx>
0026 #include <TColStd_SequenceOfInteger.hxx>
0027 #include <TCollection_ExtendedString.hxx>
0028 #include <V3d_ListOfLight.hxx>
0029 #include <V3d_ListOfView.hxx>
0030 #include <V3d_TypeOfOrientation.hxx>
0031 #include <V3d_TypeOfView.hxx>
0032 #include <V3d_TypeOfVisualization.hxx>
0033 #include <Quantity_Color.hxx>
0034
0035 class Aspect_Grid;
0036 class Graphic3d_AspectMarker3d;
0037 class Graphic3d_GraphicDriver;
0038 class Graphic3d_Group;
0039 class Graphic3d_Structure;
0040 class V3d_CircularGrid;
0041 class V3d_RectangularGrid;
0042 class V3d_View;
0043
0044
0045
0046
0047
0048 class V3d_Viewer : public Standard_Transient
0049 {
0050 friend class V3d_View;
0051 DEFINE_STANDARD_RTTIEXT(V3d_Viewer, Standard_Transient)
0052 public:
0053
0054
0055
0056
0057
0058 Standard_EXPORT V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver);
0059
0060
0061 Standard_EXPORT Standard_Boolean IfMoreViews() const;
0062
0063
0064 Standard_EXPORT Handle(V3d_View) CreateView();
0065
0066
0067 Standard_EXPORT void SetViewOn();
0068
0069
0070
0071 Standard_EXPORT void SetViewOn (const Handle(V3d_View)& theView);
0072
0073
0074
0075 Standard_EXPORT void SetViewOff();
0076
0077
0078
0079
0080 Standard_EXPORT void SetViewOff (const Handle(V3d_View)& theView);
0081
0082
0083 void Update() { Redraw(); }
0084
0085
0086
0087
0088
0089 Standard_EXPORT void Redraw() const;
0090
0091
0092 Standard_EXPORT void RedrawImmediate() const;
0093
0094
0095 Standard_EXPORT void Invalidate() const;
0096
0097
0098 Standard_EXPORT void Remove();
0099
0100
0101 const Handle(Graphic3d_GraphicDriver)& Driver() const { return myDriver; }
0102
0103
0104 Handle(Graphic3d_StructureManager) StructureManager() const { return myStructureManager; }
0105
0106
0107
0108 const Graphic3d_RenderingParams& DefaultRenderingParams() const { return myDefaultRenderingParams; }
0109
0110
0111 void SetDefaultRenderingParams (const Graphic3d_RenderingParams& theParams) { myDefaultRenderingParams = theParams; }
0112
0113
0114
0115 void SetDefaultBackgroundColor (const Quantity_Color& theColor) { myBackground.SetColor (theColor); }
0116
0117
0118 const Aspect_GradientBackground& GetGradientBackground() const { return myGradientBackground; }
0119
0120
0121
0122 void SetDefaultBgGradientColors (const Quantity_Color& theColor1,
0123 const Quantity_Color& theColor2,
0124 const Aspect_GradientFillMethod theFillStyle = Aspect_GradientFillMethod_Horizontal)
0125 {
0126 myGradientBackground.SetColors (theColor1, theColor2, theFillStyle);
0127 }
0128
0129
0130 Standard_Real DefaultViewSize() const { return myViewSize; }
0131
0132
0133 Standard_EXPORT void SetDefaultViewSize (const Standard_Real theSize);
0134
0135
0136 V3d_TypeOfOrientation DefaultViewProj() const { return myViewProj; }
0137
0138
0139 void SetDefaultViewProj (const V3d_TypeOfOrientation theOrientation) { myViewProj = theOrientation; }
0140
0141
0142 V3d_TypeOfVisualization DefaultVisualization() const { return myVisualization; }
0143
0144
0145 void SetDefaultVisualization (const V3d_TypeOfVisualization theType) { myVisualization = theType; }
0146
0147
0148 Graphic3d_TypeOfShadingModel DefaultShadingModel() const { return myDefaultRenderingParams.ShadingModel; }
0149
0150
0151 void SetDefaultShadingModel (const Graphic3d_TypeOfShadingModel theType) { myDefaultRenderingParams.ShadingModel = theType; }
0152
0153
0154 V3d_TypeOfView DefaultTypeOfView() const { return myDefaultTypeOfView; }
0155
0156
0157 void SetDefaultTypeOfView (const V3d_TypeOfView theType) { myDefaultTypeOfView = theType; }
0158
0159
0160 Quantity_Color DefaultBackgroundColor() const { return myBackground.Color(); }
0161
0162
0163 void DefaultBgGradientColors (Quantity_Color& theColor1, Quantity_Color& theColor2) const { myGradientBackground.Colors (theColor1, theColor2); }
0164
0165
0166
0167 Standard_EXPORT void GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const;
0168
0169
0170
0171
0172
0173
0174
0175 Standard_Boolean AddZLayer (Graphic3d_ZLayerId& theLayerId,
0176 const Graphic3d_ZLayerSettings& theSettings = Graphic3d_ZLayerSettings())
0177 {
0178 return InsertLayerBefore (theLayerId, theSettings, Graphic3d_ZLayerId_Top);
0179 }
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189 Standard_EXPORT Standard_Boolean InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
0190 const Graphic3d_ZLayerSettings& theSettings,
0191 const Graphic3d_ZLayerId theLayerAfter);
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 Standard_EXPORT Standard_Boolean InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
0202 const Graphic3d_ZLayerSettings& theSettings,
0203 const Graphic3d_ZLayerId theLayerBefore);
0204
0205
0206
0207
0208 Standard_EXPORT Standard_Boolean RemoveZLayer (const Graphic3d_ZLayerId theLayerId);
0209
0210
0211 Standard_EXPORT const Graphic3d_ZLayerSettings& ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const;
0212
0213
0214 Standard_EXPORT void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings);
0215
0216 public:
0217
0218
0219 const V3d_ListOfView& ActiveViews() const { return myActiveViews; }
0220
0221
0222 V3d_ListOfViewIterator ActiveViewIterator() const { return V3d_ListOfViewIterator (myActiveViews); }
0223
0224
0225 Standard_Boolean LastActiveView() const { return myActiveViews.Extent() == 1; }
0226
0227 public:
0228
0229
0230 const V3d_ListOfView& DefinedViews() const { return myDefinedViews; }
0231
0232
0233 V3d_ListOfViewIterator DefinedViewIterator() const { return V3d_ListOfViewIterator (myDefinedViews); }
0234
0235 public:
0236
0237
0238
0239
0240
0241
0242 Standard_EXPORT void SetDefaultLights();
0243
0244
0245 Standard_EXPORT void SetLightOn (const Handle(V3d_Light)& theLight);
0246
0247
0248 Standard_EXPORT void SetLightOn();
0249
0250
0251 Standard_EXPORT void SetLightOff (const Handle(V3d_Light)& theLight);
0252
0253
0254 Standard_EXPORT void SetLightOff();
0255
0256
0257 Standard_EXPORT void AddLight (const Handle(V3d_Light)& theLight);
0258
0259
0260 Standard_EXPORT void DelLight (const Handle(V3d_Light)& theLight);
0261
0262
0263 Standard_EXPORT void UpdateLights();
0264
0265 Standard_EXPORT Standard_Boolean IsGlobalLight (const Handle(V3d_Light)& TheLight) const;
0266
0267
0268 const V3d_ListOfLight& ActiveLights() const { return myActiveLights; }
0269
0270
0271 V3d_ListOfLightIterator ActiveLightIterator() const { return V3d_ListOfLightIterator (myActiveLights); }
0272
0273 public:
0274
0275
0276 const V3d_ListOfLight& DefinedLights() const { return myDefinedLights; }
0277
0278
0279 V3d_ListOfLightIterator DefinedLightIterator() const { return V3d_ListOfLightIterator (myDefinedLights); }
0280
0281 public:
0282
0283
0284 Standard_EXPORT void Erase() const;
0285
0286
0287 Standard_EXPORT void UnHighlight() const;
0288
0289 public:
0290
0291
0292 Standard_Boolean ComputedMode() const { return myComputedMode; }
0293
0294
0295 void SetComputedMode (const Standard_Boolean theMode) { myComputedMode = theMode; }
0296
0297
0298 Standard_Boolean DefaultComputedMode() const { return myDefaultComputedMode; }
0299
0300
0301 void SetDefaultComputedMode (const Standard_Boolean theMode) { myDefaultComputedMode = theMode; }
0302
0303 public:
0304
0305 const gp_Ax3& PrivilegedPlane() const { return myPrivilegedPlane; }
0306
0307 Standard_EXPORT void SetPrivilegedPlane (const gp_Ax3& thePlane);
0308
0309 Standard_EXPORT void DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const Standard_Real theSize = 1);
0310
0311 public:
0312
0313
0314 Standard_EXPORT void ActivateGrid (const Aspect_GridType aGridType, const Aspect_GridDrawMode aGridDrawMode);
0315
0316
0317 Standard_EXPORT void DeactivateGrid();
0318
0319
0320
0321 Standard_EXPORT void SetGridEcho (const Standard_Boolean showGrid = Standard_True);
0322
0323
0324
0325
0326
0327
0328
0329 Standard_EXPORT void SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& aMarker);
0330
0331
0332 Standard_Boolean GridEcho() const { return myGridEcho; }
0333
0334
0335 Standard_EXPORT Standard_Boolean IsGridActive();
0336
0337
0338 Handle(Aspect_Grid) Grid (bool theToCreate = true) { return Grid (myGridType, theToCreate); }
0339
0340
0341 Standard_EXPORT Handle(Aspect_Grid) Grid (Aspect_GridType theGridType, bool theToCreate = true);
0342
0343
0344 Aspect_GridType GridType() const { return myGridType; }
0345
0346
0347 Standard_EXPORT Aspect_GridDrawMode GridDrawMode();
0348
0349
0350 Standard_EXPORT void RectangularGridValues (Standard_Real& theXOrigin, Standard_Real& theYOrigin,
0351 Standard_Real& theXStep, Standard_Real& theYStep,
0352 Standard_Real& theRotationAngle);
0353
0354
0355
0356
0357
0358
0359 Standard_EXPORT void SetRectangularGridValues (const Standard_Real XOrigin, const Standard_Real YOrigin, const Standard_Real XStep, const Standard_Real YStep, const Standard_Real RotationAngle);
0360
0361
0362 Standard_EXPORT void CircularGridValues (Standard_Real& theXOrigin, Standard_Real& theYOrigin,
0363 Standard_Real& theRadiusStep,
0364 Standard_Integer& theDivisionNumber,
0365 Standard_Real& theRotationAngle);
0366
0367
0368
0369
0370
0371
0372 Standard_EXPORT void SetCircularGridValues (const Standard_Real XOrigin, const Standard_Real YOrigin, const Standard_Real RadiusStep, const Standard_Integer DivisionNumber, const Standard_Real RotationAngle);
0373
0374
0375 Standard_EXPORT void CircularGridGraphicValues (Standard_Real& theRadius,
0376 Standard_Real& theOffSet);
0377
0378
0379
0380
0381
0382 Standard_EXPORT void SetCircularGridGraphicValues (const Standard_Real Radius, const Standard_Real OffSet);
0383
0384
0385 Standard_EXPORT void RectangularGridGraphicValues (Standard_Real& theXSize, Standard_Real& theYSize,
0386 Standard_Real& theOffSet);
0387
0388
0389
0390
0391
0392 Standard_EXPORT void SetRectangularGridGraphicValues (const Standard_Real XSize, const Standard_Real YSize, const Standard_Real OffSet);
0393
0394
0395 Standard_EXPORT void ShowGridEcho (const Handle(V3d_View)& theView, const Graphic3d_Vertex& thePoint);
0396
0397
0398 Standard_EXPORT void HideGridEcho (const Handle(V3d_View)& theView);
0399
0400 public:
0401
0402
0403 Standard_DEPRECATED ("Deprecated method - IsGridActive() should be used instead")
0404 Standard_Boolean IsActive() { return IsGridActive(); }
0405
0406
0407 Standard_DEPRECATED ("Deprecated method - ActiveViews() should be used instead")
0408 void InitActiveViews() { myActiveViewsIterator.Initialize (myActiveViews); }
0409
0410
0411 Standard_DEPRECATED ("Deprecated method - ActiveViews() should be used instead")
0412 Standard_Boolean MoreActiveViews() const { return myActiveViewsIterator.More(); }
0413
0414
0415 Standard_DEPRECATED ("Deprecated method - ActiveViews() should be used instead")
0416 void NextActiveViews() { if (!myActiveViews.IsEmpty()) myActiveViewsIterator.Next(); }
0417
0418 Standard_DEPRECATED ("Deprecated method - ActiveViews() should be used instead")
0419 const Handle(V3d_View)& ActiveView() const { return myActiveViewsIterator.Value(); }
0420
0421
0422 Standard_DEPRECATED ("Deprecated method - DefinedViews() should be used instead")
0423 void InitDefinedViews() { myDefinedViewsIterator.Initialize (myDefinedViews); }
0424
0425
0426 Standard_DEPRECATED ("Deprecated method - DefinedViews() should be used instead")
0427 Standard_Boolean MoreDefinedViews() const { return myDefinedViewsIterator.More(); }
0428
0429
0430 Standard_DEPRECATED ("Deprecated method - DefinedViews() should be used instead")
0431 void NextDefinedViews() { if (!myDefinedViews.IsEmpty()) myDefinedViewsIterator.Next(); }
0432
0433 Standard_DEPRECATED ("Deprecated method - DefinedViews() should be used instead")
0434 const Handle(V3d_View)& DefinedView() const { return myDefinedViewsIterator.Value(); }
0435
0436
0437 Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead")
0438 void InitActiveLights() { myActiveLightsIterator.Initialize (myActiveLights); }
0439
0440
0441 Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead")
0442 Standard_Boolean MoreActiveLights() const { return myActiveLightsIterator.More(); }
0443
0444
0445 Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead")
0446 void NextActiveLights() { myActiveLightsIterator.Next(); }
0447
0448 Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead")
0449 const Handle(V3d_Light)& ActiveLight() const { return myActiveLightsIterator.Value(); }
0450
0451
0452 Standard_DEPRECATED ("Deprecated method - DefinedLights() should be used instead")
0453 void InitDefinedLights() { myDefinedLightsIterator.Initialize (myDefinedLights); }
0454
0455
0456 Standard_DEPRECATED ("Deprecated method - DefinedLights() should be used instead")
0457 Standard_Boolean MoreDefinedLights() const { return myDefinedLightsIterator.More(); }
0458
0459
0460 Standard_DEPRECATED ("Deprecated method - DefinedLights() should be used instead")
0461 void NextDefinedLights() { if (!myDefinedLights.IsEmpty()) myDefinedLightsIterator.Next(); }
0462
0463 Standard_DEPRECATED ("Deprecated method - DefinedLights() should be used instead")
0464 const Handle(V3d_Light)& DefinedLight() const { return myDefinedLightsIterator.Value(); }
0465
0466
0467 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0468
0469 private:
0470
0471
0472 const Aspect_Background& GetBackgroundColor() const { return myBackground; }
0473
0474
0475 Standard_EXPORT void AddView (const Handle(V3d_View)& theView);
0476
0477
0478 Standard_EXPORT void DelView (const V3d_View* theView);
0479
0480 private:
0481
0482 Handle(Graphic3d_GraphicDriver) myDriver;
0483 Handle(Graphic3d_StructureManager) myStructureManager;
0484 TColStd_MapOfInteger myLayerIds;
0485 Aspect_GenId myZLayerGenId;
0486
0487 V3d_ListOfView myDefinedViews;
0488 V3d_ListOfView myActiveViews;
0489 V3d_ListOfLight myDefinedLights;
0490 V3d_ListOfLight myActiveLights;
0491
0492 Aspect_Background myBackground;
0493 Aspect_GradientBackground myGradientBackground;
0494 Standard_Real myViewSize;
0495 V3d_TypeOfOrientation myViewProj;
0496 V3d_TypeOfVisualization myVisualization;
0497 V3d_TypeOfView myDefaultTypeOfView;
0498 Graphic3d_RenderingParams myDefaultRenderingParams;
0499
0500 V3d_ListOfView::Iterator myActiveViewsIterator;
0501 V3d_ListOfView::Iterator myDefinedViewsIterator;
0502 V3d_ListOfLight::Iterator myActiveLightsIterator;
0503 V3d_ListOfLight::Iterator myDefinedLightsIterator;
0504
0505 Standard_Boolean myComputedMode;
0506 Standard_Boolean myDefaultComputedMode;
0507
0508 gp_Ax3 myPrivilegedPlane;
0509 Handle(Graphic3d_Structure) myPlaneStructure;
0510 Standard_Boolean myDisplayPlane;
0511 Standard_Real myDisplayPlaneLength;
0512
0513 Handle(V3d_RectangularGrid) myRGrid;
0514 Handle(V3d_CircularGrid) myCGrid;
0515 Aspect_GridType myGridType;
0516 Standard_Boolean myGridEcho;
0517 Handle(Graphic3d_Structure) myGridEchoStructure;
0518 Handle(Graphic3d_Group) myGridEchoGroup;
0519 Handle(Graphic3d_AspectMarker3d) myGridEchoAspect;
0520 Graphic3d_Vertex myGridEchoLastVert;
0521
0522 };
0523
0524 DEFINE_STANDARD_HANDLE(V3d_Viewer, Standard_Transient)
0525
0526 #endif