X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Displayer.cpp;h=096749adb72ec4a89e3729695329a17e895a349e;hb=8f43b985d2f7170b8dfa06abd3edc7d6cb0c2e1f;hp=3f7d23326ef5544ae0d448665bd08a89e2c2c3bf;hpb=e05cf89c2b21303c51d9102315a82ac095eed3df;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 3f7d23326..096749adb 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -72,11 +72,13 @@ #include #include #include +#include #include #include #include +#include #ifdef TINSPECTOR #include @@ -88,6 +90,10 @@ #include +#ifdef _MSC_VER +#pragma warning(disable: 4702) +#endif + /// defines the local context mouse selection sensitivity const int MOUSE_SENSITIVITY_IN_PIXEL = 10; @@ -124,9 +130,12 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS //************************************************************** XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) -: myWorkshop(theWorkshop), myNeedUpdate(false), - myViewerBlockedRecursiveCount(0), myContextId(0) +: myWorkshop(theWorkshop), + myViewerBlockedRecursiveCount(0), + myContextId(0), + myNeedUpdate(false) { + BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True); } //************************************************************** @@ -157,6 +166,8 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer) aScreen->setViewScale(getViewScale()); } anAIS = aPrs->getAISObject(anAIS); + if (anAIS.get()) + myWorkshop->module()->customizePresentation(theObject, anAIS); } else { anAIS = myWorkshop->module()->createPresentation(theObject); isShading = true; @@ -205,7 +216,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, int aDispMode = isShading? Shading : Wireframe; anAISIO->SetDisplayMode(aDispMode); - aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed); + aContext->Display(anAISIO, aDispMode, 0, false, AIS_DS_Displayed); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif @@ -314,12 +325,17 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) double aTransparency = ModelAPI_Tools::getTransparency(aResult); if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency())) aAISObj->setTransparency(aTransparency); + + // Set Iso-Lines + Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO); + if (!aResPrs.IsNull()) + aResPrs->updateIsoLines(); } - myWorkshop->module()->storeSelection(); + //myWorkshop->module()->storeSelection(); -#ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY - myWorkshop->selector()->deselectPresentation(aAISIO); -#endif +//#ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY + //myWorkshop->selector()->deselectPresentation(aAISIO); +//#endif if (aContext->IsDisplayed(aAISIO)) aContext->Redisplay(aAISIO, false); @@ -331,7 +347,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) #endif //if (aNeedToRestoreSelection) - myWorkshop->module()->restoreSelection(); + //myWorkshop->module()->restoreSelection(); aRedisplayed = true; #ifdef DEBUG_FEATURE_REDISPLAY @@ -572,7 +588,8 @@ ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) if (!theIO.IsNull()) { anAISObj->setImpl(new Handle(AIS_InteractiveObject)(theIO)); } - anObject = myWorkshop->module()->findPresentedObject(anAISObj); + if (myWorkshop->module()) + anObject = myWorkshop->module()->findPresentedObject(anAISObj); } return anObject; } @@ -627,10 +644,6 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const //aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0); //aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0); - //Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron(); - //aTrihedron->getHighlightPointAspect()->SetScale(2.0); - //aTrihedron->getHighlightPointAspect()->SetTypeOfMarker(Aspect_TOM_O_STAR); - // Commented out according to discussion in bug #2825 ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle(); //Handle(Prs3d_Drawer) aSelStyle = aContext->SelectionStyle(); @@ -642,6 +655,10 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const //ModuleBase_IViewer::DefaultHighlightDrawer->SetDeviationCoefficient(aDeflection); //aSelStyle->SetDeviationCoefficient(aDeflection); + + Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron(); + if (!aTrihedron.IsNull()) + ModuleBase_Tools::setPointBallHighlighting(aTrihedron.get()); } return aContext; } @@ -696,7 +713,7 @@ bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSele Handle(AIS_InteractiveContext) aContext = AISContext(); Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!aContext.IsNull() && !anAISIO.IsNull()) { - aContext->Display(anAISIO, theDisplayMode, 0, false/*update viewer*/, true, AIS_DS_Displayed); + aContext->Display(anAISIO, theDisplayMode, 0, false/*update viewer*/, AIS_DS_Displayed); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif @@ -1025,9 +1042,9 @@ void XGUI_Displayer::getPresentations(const ObjectPtr& theObject, ModelAPI_Tools::allResults(aFeature, aResults); std::list::const_iterator anIt = aResults.begin(), aLast = aResults.end(); for (; anIt != aLast; ++anIt) { - AISObjectPtr aAISObj = getAISObject(*anIt); - if (aAISObj.get() != NULL) { - Handle(AIS_InteractiveObject) anAIS = aAISObj->impl(); + AISObjectPtr aCurAISObj = getAISObject(*anIt); + if (aCurAISObj.get() != NULL) { + Handle(AIS_InteractiveObject) anAIS = aCurAISObj->impl(); if (!anAIS.IsNull() && !thePresentations.Contains(anAIS)) thePresentations.Add(anAIS); } @@ -1051,7 +1068,6 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const 0 /*wireframe*/, -1 /* selection mode */, Standard_True /* update viewer*/, - Standard_False /* allow decomposition */, AIS_DS_Displayed /* xdisplay status */); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(aTrihedron); @@ -1091,7 +1107,7 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th /// OCCT: to write about the problem that active owners method returns one owner several times QList aSelectedIds; // Remember of selected address in order to avoid duplicates for (; anOwnersIt.More(); anOwnersIt.Next()) { - anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value()); + anOwner = anOwnersIt.Value(); if (aSelectedIds.contains((size_t)anOwner.get())) continue; aSelectedIds.append((size_t)anOwner.get()); @@ -1099,6 +1115,14 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner); if (!BROwnr.IsNull() && BROwnr->HasShape()) { const TopoDS_Shape& aShape = BROwnr->Shape(); + + Handle(ModuleBase_ResultPrs) aResPrs = + Handle(ModuleBase_ResultPrs)::DownCast(BROwnr->Selectable()); + TopoDS_Shape aRealShape; + if (!aResPrs.IsNull()) { + aRealShape = aResPrs->originalShape(); + } + if (aShape.IsNull()) continue; @@ -1115,7 +1139,15 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th // isSame should be used here as it does not check orientation of shapes // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is // different for Edges shapes in model shape and owner even if this is the same shape - if (ModuleBase_Tools::isSameShape(aParameterShape, aShape)) { + bool isSame = ModuleBase_Tools::isSameShape(aParameterShape, aShape); + if (!isSame) { + // In case of using HideFaces panel we can have instead of an original shape + // a compaund of faces which represent original shape with hidden faces. + // So, we have to compare the parameter with original shape + if (!aRealShape.IsNull()) + isSame = ModuleBase_Tools::isSameShape(aParameterShape, aRealShape); + } + if (isSame) { Handle(AIS_InteractiveObject) anOwnerPresentation = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); NCollection_Map aPresentations = @@ -1134,7 +1166,7 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th Handle(AIS_Shape) anOwnerPresentation = Handle(AIS_Shape)::DownCast(anOwner->Selectable()); const TopoDS_Shape& aPresentationShape = anOwnerPresentation->Shape(); - if (aParameterShape.IsSame(anOwnerPresentation->Shape()) && + if (aParameterShape.IsSame(aPresentationShape) && !aCompsolidPresentations.Contains(anOwnerPresentation)) aCompsolidPresentations.Add(anOwnerPresentation); }