#endif
return Standard_False;
}
- return myLocalContexts(myCurLocalIndex)->HasShape();
-
-
+ return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
}
//=======================================================================
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
if (!aShape.IsNull())
{
- aResShape = aShape->Shape().Located (TopLoc_Location (SelectedInteractive()->Transformation()) * aShape->Shape().Location());
+ TopLoc_Location aLocTrsf = SelectedInteractive()->Transformation().Form() == gp_Identity ?
+ TopLoc_Location() : TopLoc_Location (SelectedInteractive()->Transformation());
+ aResShape = aShape->Shape().Located (aLocTrsf * aShape->Shape().Location());
}
return aResShape;
Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
{
if(!HasOpenedContext()){
+ if (AIS_Selection::Selection(myCurrentName.ToCString())->Extent() == 0)
+ return NULL;
Handle(Standard_Transient) TR =AIS_Selection::Selection(myCurrentName.ToCString())->Value();
Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR);
return IO;}
HasShape(me) returns Boolean from Standard;
---Purpose: returns TRUE if the detected entity is a shape
-- coming from a Decomposition of an element.
+ HasSelectedShape(me) returns Boolean from Standard;
+ ---Purpose: returns true if current selection is not empty
+ -- and the owner of selected object contains a shape.
+ -- This method does not take into account decomposition
+ -- status of detected shape.
SelectedShape(me) returns Shape from TopoDS;
SelectedOwner(me) returns EntityOwner from SelectMgr;
return (hasshape&&comes);
}
+//================================================================
+// Function : HasSelectedShape
+// Purpose : Checks if there is a selected shape regardless of its decomposition status
+//================================================================
+Standard_Boolean AIS_LocalContext::HasSelectedShape() const
+{
+ if (AIS_Selection::CurrentSelection()->Extent() == 0)
+ return Standard_False;
+
+ Handle(Standard_Transient) aCurSelection = AIS_Selection::CurrentSelection()->Value();
+ if (aCurSelection.IsNull())
+ return Standard_False;
+
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aCurSelection);
+ Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (aBrepOwner.IsNull())
+ {
+ return Standard_False;
+ }
+ return aBrepOwner->HasShape();
+}
+
//==================================================
// Function:
// Purpose :
{
return TopoDS_Shape();
}
+
return aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
}
return 1;
}
- TCollection_AsciiString anOption (theArgNb >= 2 ? theArgVec[1] : "");
- anOption.LowerCase();
- if (anOption == "-detectedEntities"
- || anOption == "-entities")
+ Standard_Boolean toPrintEntities = Standard_False;
+ Standard_Boolean toCheckSelected = Standard_False;
+
+ for (Standard_Integer anArgIdx = 1; anArgIdx < theArgNb; ++anArgIdx)
+ {
+ TCollection_AsciiString anOption (theArgVec[anArgIdx]);
+ anOption.LowerCase();
+ if (anOption == "-detectedentities"
+ || anOption == "-entities")
+ {
+ toPrintEntities = Standard_True;
+ }
+ else if (anOption == "-hasselected")
+ {
+ toCheckSelected = Standard_True;
+ }
+ }
+
+ if (toCheckSelected)
+ {
+ aCtx->InitSelected();
+ TCollection_AsciiString hasSelected (static_cast<Standard_Integer> (aCtx->HasSelectedShape()));
+ theDI << "Check if context has selected shape: " << hasSelected << "\n";
+
+ return 0;
+ }
+
+ if (toPrintEntities)
{
theDI << "Detected entities:\n";
Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
__FILE__,VActivatedMode,group);
theCommands.Add("vstate",
- "vstate [-entities] [name1] ... [nameN]"
+ "vstate [-entities] [-hasSelected] [name1] ... [nameN]"
"\n\t\t: Reports show/hidden state for selected or named objects"
- "\n\t\t: -entities - print low-level information about detected entities",
+ "\n\t\t: -entities - print low-level information about detected entities"
+ "\n\t\t: -hasSelected - prints 1 if context has selected shape and 0 otherwise",
__FILE__,VState,group);
theCommands.Add("vpickshapes",
--- /dev/null
+puts "============"
+puts "CR25627"
+puts "============"
+puts ""
+#######################################################################
+# SelectedShape() and HasSelectedShape() of AIS_InteractiveContext
+# class do not work as expected.
+#######################################################################
+pload ALL
+
+vinit
+box aBox 5 5 5
+vdisplay aBox
+vfit
+vselect 100 100
+set aSelectionRes [vstate -hasSelected]
+if { [lsearch $aSelectionRes 0] != -1 } {
+ puts "ERROR: Incorrect result of HasSelectedShape of the context!"
+}
+vpickselected aSelected
+set aRes [vstate aSelected]
+if { $aRes == "aSelected doesn't exist!" } {
+ puts "ERROR: No shape selected in neutral point!"
+}
+set aCompRes [compare aBox aSelected]
+if { [lsearch $aCompRes not] != -1 } {
+ puts "ERROR: Selected box and selected shape from the context are not equal!"
+}
+
+vselect 0 0
+vremove aSelected
+
+vselmode aBox 6 1
+vselect 100 100
+set aSelectionRes [vstate -hasSelected]
+if { [lsearch $aSelectionRes 0] != -1 } {
+ puts "ERROR: Incorrect result of HasSelectedShape of the context!"
+}
+vpickselected aSelected
+set aRes [vstate aSelected]
+if { $aRes == "aSelected doesn't exist!" } {
+ puts "ERROR: No shape selected in local selection!"
+}
+set aCompRes [compare aBox aSelected]
+if { [lsearch $aCompRes not] != -1 } {
+ puts "ERROR: Selected box and selected solid are not equal!"
+}
+
+set only_screen 1