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