//#define DEBUG_ACTIVATE_WINDOW
//#define DEBUG_SET_FOCUS
-//#define DEBUG_SELECTION_INFO
-
-#ifdef DEBUG_SELECTION_INFO
-#include <ModuleBase_ISelection.h>
-#include <ModuleBase_ViewerPrs.h>
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <AIS_Shape.hxx>
-#include <TopoDS_Shape.hxx>
-#include <AIS_LocalContext.hxx>
-#include <NCollection_List.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#endif
#ifdef WIN32
# define FSEP "\\"
return aFeatureStr;
}
-#ifdef DEBUG_SELECTION_INFO
-QString getShapeTypeInfo(const int theType)
-{
- QString anInfo = "Undefined";
- switch(theType) {
- case TopAbs_COMPOUND: anInfo = "compound"; break;
- case TopAbs_COMPSOLID: anInfo = "compsolid"; break;
- case TopAbs_SOLID: anInfo = "solid"; break;
- case TopAbs_SHELL: anInfo = "shell"; break;
- case TopAbs_FACE: anInfo = "face"; break;
- case TopAbs_WIRE: anInfo = "wire"; break;
- case TopAbs_EDGE: anInfo = "edge"; break;
- case TopAbs_VERTEX: anInfo = "vertex"; break;
- case TopAbs_SHAPE: anInfo = "shape"; break;
- case ModuleBase_ResultPrs::Sel_Result:
- anInfo = "result_shape"; break;
- default: break;
- }
- return anInfo;
-}
-
-QString getModeInfo(const int theMode)
-{
- QString anInfo = "Undefined";
- switch(theMode) {
- case 0: anInfo = "SHAPE(0)"; break;
- case 1: anInfo = "VERTEX(1)"; break;
- case 2: anInfo = "EDGE(2)"; break;
- case 3: anInfo = "WIRE(3)"; break;
- case 4: anInfo = "FACE(4)"; break;
- case 5: anInfo = "SHELL(5)"; break;
- case 6: anInfo = "SOLID(6)"; break;
- case 7: anInfo = "COMPSOLID(7)"; break;
- case 8: anInfo = "COMPOUND(8)"; break;
- case 100: anInfo = "Sel_Mode_First(100)"; break; //SketcherPrs_Tools
- case 101: anInfo = "Sel_Constraint(101)"; break;
- case 102: anInfo = "Sel_Dimension_All(102)"; break;
- case 103: anInfo = "Sel_Dimension_Line(103)"; break;
- case 104: anInfo = "Sel_Dimension_Text(104)"; break;
- default: break;
- }
- return anInfo;
-}
-
-QString displayedInteractiveObjects(Handle(AIS_InteractiveContext)& theContext,
- const bool theShapeInfoOnly = true)
-{
- if (theContext.IsNull())
- return "";
- AIS_ListOfInteractive aListOfIO;
- theContext->DisplayedObjects(aListOfIO, false);
- QStringList anObjects;
- AIS_ListIteratorOfListOfInteractive aIt;
- for (aIt.Initialize(aListOfIO); aIt.More(); aIt.Next()) {
- Handle(AIS_InteractiveObject) anAISIO = aIt.Value();
- Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISIO);
- if (theShapeInfoOnly && aShapePrs.IsNull())
- continue;
-
- QString anInfo = "IO";
- std::ostringstream aPtrStr;
- aPtrStr << "[" << anAISIO.Access() << "]";
- anInfo += aPtrStr.str().c_str();
-
- if (!aShapePrs.IsNull()) {
- const TopoDS_Shape& aShape = aShapePrs->Shape();
- if (aShape.IsNull()) {
- //Events_Error::throwException("An empty AIS presentation");
- }
- else
- anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
- }
- TColStd_ListOfInteger aTColModes;
- theContext->ActivatedModes(anAISIO, aTColModes);
- TColStd_ListIteratorOfListOfInteger itr( aTColModes );
- QIntList aModesActivatedForIO;
- bool isDeactivated = false;
- QStringList aModes;
- for (; itr.More(); itr.Next() ) {
- Standard_Integer aMode = itr.Value();
- aModes.append(getModeInfo(aMode));
- //int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
- }
- if (aModes.size() > 0)
- anInfo += QString(", activated modes: %1").arg(aModes.join(", "));
-
- anObjects += anInfo;
- }
- QString aValue = QString("displayedIO[%1]").arg(anObjects.size());
- if (anObjects.size() > 0)
- aValue += QString(":\n %1").arg(anObjects.join("\n "));
- return aValue;
-}
-
-QString activeOwners(Handle(AIS_InteractiveContext)& theContext, const bool theShapeInfoOnly = true)
-{
- if (theContext.IsNull())
- return "";
- Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
- TCollection_AsciiString aSelectionName = aLContext->SelectionName();
- aLContext->UnhilightPicked(Standard_False);
-
- NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
- aLContext->MainSelector()->ActiveOwners(anActiveOwners);
- NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
- Handle(SelectMgr_EntityOwner) anOwner;
- QStringList anObjects;
- for (; anOwnersIt.More(); anOwnersIt.Next()) {
- anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
- if (theShapeInfoOnly && BROwnr.IsNull())
- continue;
-
- QString anInfo = "Owner";
- std::ostringstream aPtrStr;
- aPtrStr << "[" << anOwner.Access() << "]";
- anInfo += aPtrStr.str().c_str();
-
- Handle(AIS_InteractiveObject) aAISObj =
- Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
- if (!aAISObj.IsNull()) {
- std::ostringstream aPtrStr;
- aPtrStr << "[" << aAISObj.Access() << "]";
- anInfo += QString(", selectable(IO): %1").arg(aPtrStr.str().c_str());
- }
-
- if (!BROwnr.IsNull() && BROwnr->HasShape()) {
- const TopoDS_Shape& aShape = BROwnr->Shape();
- if (aShape.IsNull()) {
- //Events_Error::throwException("An empty AIS presentation");
- }
- else
- anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
- }
- anObjects += anInfo;
- }
- QString aValue = QString("activeOwners[%1]").arg(anObjects.size());
- if (anObjects.size() > 0)
- aValue += QString(":\n %1").arg(anObjects.join("\n "));
- return aValue;
-}
-
-QString selectedOwners(Handle(AIS_InteractiveContext)& theContext,
- const bool theShapeInfoOnly = true)
-{
- QStringList anObjects;
- if (theContext.IsNull())
- return "";
-
- QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
- for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) {
- Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
- if (theShapeInfoOnly && BROwnr.IsNull())
- continue;
-
- if (aSelectedIds.contains((long)anOwner.Access()))
- continue;
- aSelectedIds.append((long)anOwner.Access());
-
- QString anInfo = "Owner";
- std::ostringstream aPtrStr;
- aPtrStr << "[" << anOwner.Access() << "]";
- anInfo += aPtrStr.str().c_str();
-
- if (!BROwnr.IsNull() && BROwnr->HasShape()) {
- const TopoDS_Shape& aShape = BROwnr->Shape();
- anInfo += QString(", shape type = %1").arg(getShapeTypeInfo(aShape.ShapeType()));
- }
- anObjects += anInfo;
- }
- QString aValue = QString("selectedOwners[%1]").arg(anObjects.size());
- if (anObjects.size() > 0)
- aValue += QString(":\n %1").arg(anObjects.join("\n "));
- return aValue;
-}
-#endif
-
-void selectionInfo(Handle(AIS_InteractiveContext)& theContext, const std::string& thePrefix)
-{
-#ifdef DEBUG_SELECTION_INFO
- QString aValue = QString("\n\n\nDEBUG_SELECTION_INFO for '%1'\n%2\n%3\n%4")
- .arg(thePrefix.c_str())
- .arg(displayedInteractiveObjects(theContext))
- .arg(activeOwners(theContext))
- .arg(selectedOwners(theContext));
- qDebug(aValue.toStdString().c_str());
-#endif
-}
-
typedef QMap<QString, int> ShapeTypes;
static ShapeTypes myShapeTypes;
#ifdef VINSPECTOR
if (myContextCallBack) myContextCallBack->Remove(anAIS);
#endif
- ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::erase -- Remove");
aErased = true;
}
}
#ifdef VINSPECTOR
if (myContextCallBack) myContextCallBack->Redisplay(aAISIO);
#endif
- ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::redisplay -- Redisplay");
if (aNeedToRestoreSelection)
myWorkshop->module()->restoreSelection();
#ifdef VINSPECTOR
if (myContextCallBack) myContextCallBack->ClearOutdatedSelection(anAIS);
#endif
- ModuleBase_Tools::selectionInfo(aContext,
- "XGUI_Displayer::deactivate -- ClearOutdatedSelection");
if (theUpdateViewer)
updateViewer();
}
}
}
}
- ModuleBase_Tools::selectionInfo(aContext,
- "XGUI_Displayer::setSelected -- AddOrRemoveSelected/UnhilightCurrents(no local context)");
if (theUpdateViewer)
updateViewer();
}
if (theUpdateViewer)
updateViewer();
}
- ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::eraseAll -- Remove");
myResult2AISObjectMap.clear();
#ifdef DEBUG_DISPLAY
qDebug("eraseAll");
#ifdef VINSPECTOR
if (theCallBack) theCallBack->Deactivate(theObject);
#endif
- ModuleBase_Tools::selectionInfo(theContext, "XGUI_Displayer::deactivateObject -- Deactivate");
//if (theClear) {
//theObject->ClearSelected();
// theContext->LocalContext()->ClearOutdatedSelection(theObject, true);
"edge-selection-sensitivity", 2);
aContext->SetSelectionSensitivity(theIO, theMode, aPrecision);
}
- ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::activateAIS -- Activate");
#ifdef DEBUG_ACTIVATE_AIS
ObjectPtr anObject = getObject(theIO);
if (myContextCallBack) myContextCallBack->Deactivate(theIO, theMode);
#endif
}
- ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::deactivateAIS -- Deactivate");
#ifdef DEBUG_DEACTIVATE_AIS
ObjectPtr anObject = getObject(theIO);
#ifdef VINSPECTOR
if (myContextCallBack) myContextCallBack->Remove(anAISIO);
#endif
- ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::eraseAIS -- Remove");
aErased = true;
}
}
#ifdef VINSPECTOR
if (myContextCallBack) myContextCallBack->ClearOutdatedSelection(theIO);
#endif
- ModuleBase_Tools::selectionInfo(aContext,
- "XGUI_Displayer::activate -- ClearSelected/ClearOutdatedSelection");
// For performance issues
//if (theUpdateViewer)
// updateViewer();