#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_DimensionSelectionMode.hxx>
-
#include <AIS_Shape.hxx>
#include <set>
{
}
-bool XGUI_Displayer::isVisible(ObjectPtr theObject)
+bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
{
return myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end();
}
boost::shared_ptr<GeomAPI_AISObject> anAIS;
GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ bool isShading = false;
if (aPrs) {
anAIS = aPrs->getAISObject(boost::shared_ptr<GeomAPI_AISObject>());
} else {
if (aShapePtr) {
anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
anAIS->createShape(aShapePtr);
+ isShading = true;
}
}
}
if (anAIS)
- display(theObject, anAIS, isUpdateViewer);
+ display(theObject, anAIS, isShading, isUpdateViewer);
}
}
-void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS,
- bool isUpdateViewer)
+void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS,
+ bool isShading, bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
myResult2AISObjectMap[theObject] = theAIS;
- aContext->Display(anAISIO, isUpdateViewer);
+ aContext->Display(anAISIO, false);
+ aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, isUpdateViewer);
}
}
return;
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
boost::shared_ptr<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theObject];
if (anObject) {
Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
myResult2AISObjectMap.erase(theObject);
}
-/*bool XGUI_Displayer::redisplay(ObjectPtr theObject,
- boost::shared_ptr<GeomAPI_AISObject> theAIS,
- const bool isUpdateViewer)
- {
- bool isCreated = false;
- Handle(AIS_InteractiveObject) anAIS =
- theAIS ? theAIS->impl<Handle(AIS_InteractiveObject)>() : Handle(AIS_InteractiveObject)();
- Handle(AIS_InteractiveContext) aContext = AISContext();
- // Open local context if there is no one
- if (!aContext->HasOpenedContext()) {
- aContext->ClearCurrents(false);
- aContext->OpenLocalContext(false /use displayed objects/, true /allow shape decomposition/);
- // set mouse sensitivity
- //aContext->SetSensitivityMode(StdSelect_SM_WINDOW);
- //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL);
- }
- // display or redisplay presentation
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
- if (isVisible(theObject) && anObj && !anObj->empty()) {
- aContext->Redisplay(anAIS, isUpdateViewer);
- //aContext->RecomputeSelectionOnly(anAIS);
- }
- else {
- myResult2AISObjectMap[theObject] = theAIS;
- aContext->Display(anAIS, isUpdateViewer);
- isCreated = true;
- }
- return isCreated;
- }*/
-
void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
{
if (!isVisible(theObject))
}
if (!aAISIO.IsNull()) {
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
aContext->Redisplay(aAISIO, isUpdateViewer);
//if (aContext->HasOpenedContext()) {
// aContext->Load(aAISIO, -1, true/*allow decomposition*/);
const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
// Open local context if there is no one
if (!aContext->HasOpenedContext()) {
aContext->ClearCurrents(false);
- aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+ //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+ aContext->OpenLocalContext();
+ aContext->NotUseDisplayedObjects();
}
// display or redisplay presentation
Handle(AIS_InteractiveObject) anAIS;
{
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
{
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
}
}
+bool XGUI_Displayer::isActive(ObjectPtr theObject) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return false;
+ if (!isVisible(theObject))
+ return false;
+
+ boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap.at(theObject);
+ Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+
+ TColStd_ListOfInteger aModes;
+ aContext->ActivatedModes(anAIS, aModes);
+ return aModes.Extent() > 0;
+}
+
void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const bool isStop,
const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
Handle(AIS_Shape) anAIS;
QList<ObjectPtr>::const_iterator anIt = theResults.begin(), aLast = theResults.end();
updateViewer();
}
-/*void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
- {
- Handle(AIS_InteractiveContext) ic = AISContext();
-
- AIS_ListOfInteractive aList;
- ic->DisplayedObjects(aList);
- AIS_ListIteratorOfListOfInteractive anIter(aList);
- for (; anIter.More(); anIter.Next()) {
- if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron)))
- continue;
+void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if (ic.IsNull())
+ return;
- // erase an object
- Handle(AIS_InteractiveObject) anIO = anIter.Value();
- ic->Erase(anIO, false);
+ ResultToAISMap::iterator aIt;
+ for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+ // erase an object
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = (*aIt).second;
+ Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anIO.IsNull())
+ ic->Remove(anIO, false);
+ }
+ myResult2AISObjectMap.clear();
+ if (isUpdateViewer)
+ updateViewer();
}
- myResult2AISObjectMap.clear();
- if (isUpdateViewer)
- updateViewer();
- }*/
void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
myResult2AISObjectMap.end();
updateViewer();
}
+void XGUI_Displayer::openLocalContext()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext()) {
+ aContext->ClearCurrents(false);
+ //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+ aContext->OpenLocalContext();
+ aContext->NotUseDisplayedObjects();
+ }
+}
+
void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
{
+ AISContext()->ClearSelected(false);
closeAllContexts(true);
}
}
}
+void XGUI_Displayer::activateObjectsOutOfContext(const std::list<int>& theModes,
+ Handle(SelectMgr_Filter) theFilter)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext())
+ return;
+
+ aContext->UseDisplayedObjects();
+ std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
+ for (; anIt != aLast; anIt++) {
+ aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+ }
+
+ if (!theFilter.IsNull())
+ aContext->AddFilter(theFilter);
+}
+
+
+void XGUI_Displayer::deactivateObjectsOutOfContext()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext())
+ return;
+
+ aContext->RemoveFilters();
+ aContext->NotUseDisplayedObjects();
+}
+
+
+void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate)
+{
+ if (theMode == NoMode)
+ return;
+
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ if (!aAISObj)
+ return;
+
+ Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
+}
+
+
+XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return NoMode;
+
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ if (!aAISObj)
+ return NoMode;
+
+ Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
+}
+