File indexing completed on 2025-01-18 10:04:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _SelectMgr_ViewerSelector_HeaderFile
0018 #define _SelectMgr_ViewerSelector_HeaderFile
0019
0020 #include <OSD_Chronometer.hxx>
0021 #include <SelectMgr_BVHThreadPool.hxx>
0022 #include <SelectMgr_IndexedDataMapOfOwnerCriterion.hxx>
0023 #include <SelectMgr_SelectingVolumeManager.hxx>
0024 #include <SelectMgr_Selection.hxx>
0025 #include <SelectMgr_SelectableObject.hxx>
0026 #include <SelectMgr_SelectableObjectSet.hxx>
0027 #include <SelectMgr_StateOfSelection.hxx>
0028 #include <SelectMgr_ToleranceMap.hxx>
0029 #include <SelectMgr_TypeOfDepthTolerance.hxx>
0030 #include <SelectMgr_ViewerSelector.hxx>
0031 #include <Standard_OStream.hxx>
0032 #include <Standard_Transient.hxx>
0033 #include <StdSelect_TypeOfSelectionImage.hxx>
0034 #include <TColStd_HArray1OfInteger.hxx>
0035
0036 class SelectMgr_SensitiveEntitySet;
0037 class SelectMgr_EntityOwner;
0038 class Select3D_SensitiveEntity;
0039 class V3d_View;
0040
0041
0042 #ifdef Status
0043 #undef Status
0044 #endif
0045 typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_SensitiveEntitySet) > SelectMgr_MapOfObjectSensitives;
0046 typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_SensitiveEntitySet) >::Iterator SelectMgr_MapOfObjectSensitivesIterator;
0047
0048 typedef NCollection_DataMap<Standard_Integer, SelectMgr_SelectingVolumeManager> SelectMgr_FrustumCache;
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 class SelectMgr_ViewerSelector : public Standard_Transient
0081 {
0082 DEFINE_STANDARD_RTTIEXT(SelectMgr_ViewerSelector, Standard_Transient)
0083 friend class SelectMgr_SelectionManager;
0084 public:
0085
0086
0087 Standard_EXPORT SelectMgr_ViewerSelector();
0088
0089
0090 Standard_Integer CustomPixelTolerance() const { return myTolerances.CustomTolerance(); }
0091
0092
0093 Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
0094
0095
0096 Standard_Real Sensitivity() const { return myTolerances.Tolerance(); }
0097
0098
0099 Standard_Integer PixelTolerance() const { return myTolerances.Tolerance(); }
0100
0101
0102 Standard_EXPORT virtual void SortResult() const;
0103
0104
0105
0106 Handle(SelectMgr_EntityOwner) OnePicked() const
0107 {
0108 return mystored.IsEmpty()
0109 ? Handle(SelectMgr_EntityOwner)()
0110 : Picked (1);
0111 }
0112
0113
0114
0115
0116 bool ToPickClosest() const { return myToPreferClosest; }
0117
0118
0119 void SetPickClosest (bool theToPreferClosest) { myToPreferClosest = theToPreferClosest; }
0120
0121
0122
0123 SelectMgr_TypeOfDepthTolerance DepthToleranceType() const { return myDepthTolType; }
0124
0125
0126 Standard_Real DepthTolerance() const { return myDepthTolerance; }
0127
0128
0129
0130
0131
0132
0133 void SetDepthTolerance (SelectMgr_TypeOfDepthTolerance theType,
0134 Standard_Real theTolerance)
0135 {
0136 myDepthTolType = theType;
0137 myDepthTolerance = theTolerance;
0138 }
0139
0140
0141 Standard_Integer NbPicked() const { return mystored.Extent(); }
0142
0143
0144 Standard_EXPORT void ClearPicked();
0145
0146
0147 void Clear() { ClearPicked(); }
0148
0149
0150
0151 Standard_EXPORT Handle(SelectMgr_EntityOwner) Picked (const Standard_Integer theRank) const;
0152
0153
0154
0155 Standard_EXPORT const SelectMgr_SortCriterion& PickedData (const Standard_Integer theRank) const;
0156
0157
0158
0159 const Handle(Select3D_SensitiveEntity)& PickedEntity (const Standard_Integer theRank) const { return PickedData (theRank).Entity; }
0160
0161
0162
0163
0164 gp_Pnt PickedPoint (const Standard_Integer theRank) const { return PickedData (theRank).Point; }
0165
0166
0167 Standard_EXPORT Standard_Boolean RemovePicked (const Handle(SelectMgr_SelectableObject)& theObject);
0168
0169 Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const;
0170
0171
0172 const Handle(Select3D_BVHBuilder3d) EntitySetBuilder() { return myEntitySetBuilder; }
0173
0174
0175
0176 Standard_EXPORT void SetEntitySetBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder);
0177
0178
0179
0180
0181
0182
0183 Standard_EXPORT Standard_Boolean Modes (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
0184 TColStd_ListOfInteger& theModeList,
0185 const SelectMgr_StateOfSelection theWantedState = SelectMgr_SOS_Any) const;
0186
0187
0188
0189
0190 Standard_EXPORT Standard_Boolean IsActive (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
0191 const Standard_Integer theMode) const;
0192
0193
0194
0195
0196 Standard_EXPORT Standard_Boolean IsInside (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
0197 const Standard_Integer theMode) const;
0198
0199
0200 Standard_EXPORT SelectMgr_StateOfSelection Status (const Handle(SelectMgr_Selection)& theSelection) const;
0201
0202 Standard_EXPORT TCollection_AsciiString Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const;
0203
0204
0205 Standard_EXPORT void ActiveOwners (NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners) const;
0206
0207
0208 Standard_EXPORT void AddSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);
0209
0210
0211 Standard_EXPORT void AddSelectionToObject (const Handle(SelectMgr_SelectableObject)& theObject,
0212 const Handle(SelectMgr_Selection)& theSelection);
0213
0214
0215
0216 Standard_EXPORT void MoveSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);
0217
0218
0219 Standard_EXPORT void RemoveSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);
0220
0221
0222 Standard_EXPORT void RemoveSelectionOfObject (const Handle(SelectMgr_SelectableObject)& theObject,
0223 const Handle(SelectMgr_Selection)& theSelection);
0224
0225
0226
0227 Standard_EXPORT void RebuildObjectsTree (const Standard_Boolean theIsForce = Standard_False);
0228
0229
0230
0231
0232 Standard_EXPORT void RebuildSensitivesTree (const Handle(SelectMgr_SelectableObject)& theObject,
0233 const Standard_Boolean theIsForce = Standard_False);
0234
0235
0236 SelectMgr_SelectingVolumeManager& GetManager() { return mySelectingVolumeMgr; }
0237
0238
0239 const SelectMgr_SelectableObjectSet& SelectableObjects() const { return mySelectableObjects; }
0240
0241
0242 Standard_EXPORT void ResetSelectionActivationStatus();
0243
0244
0245
0246
0247 Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
0248
0249 public:
0250
0251
0252
0253 Standard_EXPORT void Pick (const Standard_Integer theXPix,
0254 const Standard_Integer theYPix,
0255 const Handle(V3d_View)& theView);
0256
0257
0258
0259
0260 Standard_EXPORT void Pick (const Standard_Integer theXPMin,
0261 const Standard_Integer theYPMin,
0262 const Standard_Integer theXPMax,
0263 const Standard_Integer theYPMax,
0264 const Handle(V3d_View)& theView);
0265
0266
0267 Standard_EXPORT void Pick (const TColgp_Array1OfPnt2d& thePolyline,
0268 const Handle(V3d_View)& theView);
0269
0270
0271
0272
0273 Standard_EXPORT void Pick (const gp_Ax1& theAxis,
0274 const Handle(V3d_View)& theView);
0275
0276
0277
0278
0279
0280
0281
0282
0283 Standard_EXPORT Standard_Boolean ToPixMap (Image_PixMap& theImage,
0284 const Handle(V3d_View)& theView,
0285 const StdSelect_TypeOfSelectionImage theType,
0286 const Standard_Integer thePickedIndex = 1);
0287
0288 public:
0289
0290
0291 Standard_EXPORT void DisplaySensitive (const Handle(V3d_View)& theView);
0292
0293 Standard_EXPORT void ClearSensitive (const Handle(V3d_View)& theView);
0294
0295 Standard_EXPORT void DisplaySensitive (const Handle(SelectMgr_Selection)& theSel,
0296 const gp_Trsf& theTrsf,
0297 const Handle(V3d_View)& theView,
0298 const Standard_Boolean theToClearOthers = Standard_True);
0299
0300
0301 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0302
0303 public:
0304
0305
0306 Standard_EXPORT void SetToPrebuildBVH(Standard_Boolean theToPrebuild, Standard_Integer theThreadsNum = -1);
0307
0308
0309 Standard_EXPORT void QueueBVHBuild(const Handle(Select3D_SensitiveEntity)& theEntity);
0310
0311
0312 Standard_EXPORT void WaitForBVHBuild();
0313
0314
0315 Standard_Boolean ToPrebuildBVH() const
0316 {
0317 return myToPrebuildBVH;
0318 }
0319
0320 protected:
0321
0322
0323
0324 Standard_EXPORT void TraverseSensitives (const Standard_Integer theViewId = -1);
0325
0326
0327
0328
0329
0330
0331
0332
0333 Standard_EXPORT void traverseObject (const Handle(SelectMgr_SelectableObject)& theObject,
0334 const SelectMgr_SelectingVolumeManager& theMgr,
0335 const Handle(Graphic3d_Camera)& theCamera,
0336 const Graphic3d_Mat4d& theProjectionMat,
0337 const Graphic3d_Mat4d& theWorldViewMat,
0338 const Graphic3d_Vec2i& theWinSize);
0339
0340
0341
0342 Standard_EXPORT void checkOverlap (const Handle(Select3D_SensitiveEntity)& theEntity,
0343 const gp_GTrsf& theInversedTrsf,
0344 SelectMgr_SelectingVolumeManager& theMgr);
0345
0346
0347 Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView);
0348
0349 private:
0350
0351
0352 Standard_Boolean isToScaleFrustum (const Handle(Select3D_SensitiveEntity)& theEntity);
0353
0354
0355
0356 Standard_Integer sensitivity (const Handle(Select3D_SensitiveEntity)& theEntity) const;
0357
0358 void Activate (const Handle(SelectMgr_Selection)& theSelection);
0359
0360 void Deactivate (const Handle(SelectMgr_Selection)& theSelection);
0361
0362
0363 void Remove (const Handle(SelectMgr_Selection)& aSelection);
0364
0365
0366 void computeFrustum (const Handle(Select3D_SensitiveEntity)& theEnt,
0367 const SelectMgr_SelectingVolumeManager& theMgrGlobal,
0368 const SelectMgr_SelectingVolumeManager& theMgrObject,
0369 const gp_GTrsf& theInvTrsf,
0370 SelectMgr_FrustumCache& theCachedMgrs,
0371 SelectMgr_SelectingVolumeManager& theResMgr);
0372
0373
0374 private:
0375
0376
0377 void updatePoint3d (SelectMgr_SortCriterion& theCriterion,
0378 const SelectBasics_PickResult& thePickResult,
0379 const Handle(Select3D_SensitiveEntity)& theEntity,
0380 const gp_GTrsf& theInversedTrsf,
0381 const SelectMgr_SelectingVolumeManager& theMgr) const;
0382
0383 protected:
0384
0385 Standard_Real myDepthTolerance;
0386 SelectMgr_TypeOfDepthTolerance myDepthTolType;
0387 Standard_Boolean myToPreferClosest;
0388 SelectMgr_IndexedDataMapOfOwnerCriterion mystored;
0389 SelectMgr_SelectingVolumeManager mySelectingVolumeMgr;
0390 mutable SelectMgr_SelectableObjectSet mySelectableObjects;
0391 SelectMgr_ToleranceMap myTolerances;
0392 NCollection_DataMap<Graphic3d_ZLayerId, Standard_Integer> myZLayerOrderMap;
0393 Handle(Select3D_BVHBuilder3d) myEntitySetBuilder;
0394 gp_Pnt myCameraEye;
0395 gp_Dir myCameraDir;
0396 Standard_Real myCameraScale;
0397
0398 Standard_Boolean myToPrebuildBVH;
0399 Handle(SelectMgr_BVHThreadPool) myBVHThreadPool;
0400
0401 mutable TColStd_Array1OfInteger myIndexes;
0402 mutable Standard_Boolean myIsSorted;
0403 Standard_Boolean myIsLeftChildQueuedFirst;
0404 SelectMgr_MapOfObjectSensitives myMapOfObjectSensitives;
0405
0406 Graphic3d_SequenceOfStructure myStructs;
0407
0408 };
0409
0410 DEFINE_STANDARD_HANDLE(SelectMgr_ViewerSelector, Standard_Transient)
0411
0412 #endif