#include <AIS_Selection.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
+//#define DEBUG_WIRE
+#ifdef DEBUG_WIRE
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#endif
IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner);
IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
SetAutoHilight(aCompSolid.get() == NULL);
}
+bool ModuleBase_ResultPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseType,
+ const TopAbs_ShapeEnum& theCheckedType)
+{
+ bool aValid = theBaseType == theCheckedType;
+ if (!aValid) {
+ // currently this functionality is for all, as we have no separate wire selection mode
+ // lately it should be corrected to have the following check only for sketch presentations
+ aValid = theBaseType == TopAbs_FACE && theCheckedType == TopAbs_WIRE;
+ }
+ return aValid;
+}
+
void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs");
}
+#ifdef DEBUG_WIRE
+void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType)
+{
+ TopTools_IndexedMapOfShape aSubShapes;
+ TopExp::MapShapes (theShape, theType, aSubShapes);
+
+ Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1)));
+ int anExtent = aSubShapes.Extent();
+ for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex)
+ {
+ const TopoDS_Shape& aSubShape = aSubShapes (aShIndex);
+ int aValue = 0;
+ }
+}
+#endif
void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
// In order to avoid using custom selection modes
return;
-
if (myIsSketchMode) {
if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE)) {
+#ifdef DEBUG_WIRE
+ const TopoDS_Shape& aShape = Shape();
+ debugInfo(aShape, TopAbs_VERTEX); // 24
+ debugInfo(aShape, TopAbs_EDGE); // 12
+ debugInfo(aShape, TopAbs_WIRE); // 0
+ debugInfo(aShape, TopAbs_FACE); // 0
+#endif
BRep_Builder aBuilder;
TopoDS_Compound aComp;
aBuilder.MakeCompound(aComp);
for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
aBuilder.Add(aComp, aFace);
+ // for sketch presentation in the face mode wires should be selectable also
+ // accoring to #1343 Improvement of Extrusion and Revolution operations
+ appendWiresSelection(aSelection, aFace);
}
+#ifdef DEBUG_WIRE
+ debugInfo(aComp, TopAbs_VERTEX); // 24
+ debugInfo(aComp, TopAbs_EDGE); // 12
+ debugInfo(aComp, TopAbs_WIRE); // 4
+ debugInfo(aComp, TopAbs_FACE); // 2
+#endif
Set(aComp);
} else
Set(myOriginalShape);
return false;
}
+void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
+ const TopoDS_Shape& theShape)
+{
+ static TopAbs_ShapeEnum TypOfSel
+ = AIS_Shape::SelectionType(AIS_Shape::SelectionMode(TopAbs_WIRE));
+ // POP protection against crash in low layers
+ Standard_Real aDeflection = Prs3d::GetDeflection(theShape, myDrawer);
+ try {
+ StdSelect_BRepSelectionTool::Load(theSelection,
+ this,
+ theShape,
+ TypOfSel,
+ aDeflection,
+ myDrawer->HLRAngle(),
+ myDrawer->IsAutoTriangulation());
+ } catch ( Standard_Failure ) {
+ }
+}
TopoDS_Shape ModuleBase_ResultPrs::getSelectionShape() const
{
/// \param theResult a result object
Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
+ /// Returns true if the checked type can be accepted for the base selection type
+ /// It returns true if they are coicide or if the base type is face and the checked type is wire
+ /// @return boolean result
+ static Standard_EXPORT bool isValidShapeType(const TopAbs_ShapeEnum& theBaseType,
+ const TopAbs_ShapeEnum& theCheckedType);
+
//! Method which draws selected owners ( for fast presentation draw )
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
const Standard_Integer aMode) ;
private:
+ /// Appens sensitive and owners for wires of the given shape into selection
+ /// \param theSelection a current filled selection
+ /// \param theShape a shape
+ void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
+ const TopoDS_Shape& theShape);
/// Returns shape dependent on CompSolid selection mode
/// In case CompSolid selection mode it returns parent's compsolid shape
TopoDS_Shape getSelectionShape() const;
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_IModule.h>
+#include <ModuleBase_ResultPrs.h>
#include <ModelAPI_ResultConstruction.h>
QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
for (; anIt != aLast; anIt++) {
- if (aShapeType == *anIt)
+ TopAbs_ShapeEnum aCurrentShapeType = (TopAbs_ShapeEnum)*anIt;
+ if (aShapeType == aCurrentShapeType)
aValid = true;
- else if (*anIt == TopAbs_FACE) {
+ else if (aCurrentShapeType == TopAbs_FACE) {
// try to process the construction shape only if there is no a selected shape in the viewer
if (!theShape.get() && theResult.get()) {
ResultConstructionPtr aCResult =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
aValid = aCResult.get() && aCResult->facesNum() > 0;
}
+ aValid = ModuleBase_ResultPrs::isValidShapeType(aCurrentShapeType, aShapeType);
}
}
return aValid;