X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Displayer.cpp;h=4b99d0e15b45ef765e5edac4595d70ab2413ba41;hb=4de8d53fef7532b6843d79c970f55ad46f98da62;hp=096749adb72ec4a89e3729695329a17e895a349e;hpb=380f01e1fce1a012267d604a1190d04bf4659447;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 096749adb..4b99d0e15 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include @@ -56,9 +56,7 @@ #include #include #include -#include #include -#include #include #ifdef BEFORE_TRIHEDRON_PATCH #include @@ -68,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +96,12 @@ /// defines the local context mouse selection sensitivity const int MOUSE_SENSITIVITY_IN_PIXEL = 10; +/// defines the display priority for results brought to front +constexpr int FRONT_DISPLAY_PRIORITY = 8; /* = Graphic3d_DisplayPriority_Highlight-1 */ + +/// defines the default (normal) display priority for all results +constexpr int DEFAULT_DISPLAY_PRIORITY = 5; /* = Graphic3d_DisplayPriority_Normal */ + //#define DEBUG_DISPLAY //#define DEBUG_FEATURE_REDISPLAY //#define DEBUG_SELECTION_FILTERS @@ -217,6 +222,13 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, int aDispMode = isShading? Shading : Wireframe; anAISIO->SetDisplayMode(aDispMode); aContext->Display(anAISIO, aDispMode, 0, false, AIS_DS_Displayed); + ResultPtr aResult = std::dynamic_pointer_cast(theObject); + if (ModelAPI_Tools::isBringToFront(aResult)) { + // NOTE: do not use a priority higher than 8 as highlight uses priority 9! + // Any higher level prevents the highlight from being visible as it would + // appear "behind" the Groups. + aContext->SetDisplayPriority(anAISIO, FRONT_DISPLAY_PRIORITY); + } #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif @@ -225,6 +237,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, emit objectDisplayed(theObject, theAIS); selectionActivate()->activate(anAISIO, theUpdateViewer); } + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); @@ -262,7 +275,7 @@ bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer) qDebug(QString("erase object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str()); qDebug(getResult2AISObjectMapInfo().c_str()); #endif - + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); @@ -330,6 +343,13 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO); if (!aResPrs.IsNull()) aResPrs->updateIsoLines(); + + // Only support the "Bring To Front" command for Groups (for now) + ResultGroupPtr aGroup = std::dynamic_pointer_cast(aResult); + if (aGroup.get()) { + bool isInFront = ModelAPI_Tools::isBringToFront(aResult); + aContext->SetDisplayPriority(aAISIO, (isInFront ? FRONT_DISPLAY_PRIORITY : DEFAULT_DISPLAY_PRIORITY)); + } } //myWorkshop->module()->storeSelection(); @@ -353,6 +373,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) #ifdef DEBUG_FEATURE_REDISPLAY qDebug(" Redisplay happens"); #endif + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); } @@ -534,6 +555,7 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) aErased = true; } } + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); } @@ -640,21 +662,9 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const myContextId = aContext.get(); if (!myWorkshop->selectionActivate()->isTrihedronActive()) selectionActivate()->deactivateTrihedron(true); - // Do not modify default drawer. The same is done in ModuleBase_ResultPrs - //aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0); - //aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0); // Commented out according to discussion in bug #2825 ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle(); - //Handle(Prs3d_Drawer) aSelStyle = aContext->SelectionStyle(); - //double aDeflection = - // QString(ModelAPI_ResultConstruction::DEFAULT_DEFLECTION().c_str()).toDouble(); - //try { - // aDeflection = Config_PropManager::real("Visualization", "construction_deflection"); - //} catch (...) {} - - //ModuleBase_IViewer::DefaultHighlightDrawer->SetDeviationCoefficient(aDeflection); - //aSelStyle->SetDeviationCoefficient(aDeflection); Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron(); if (!aTrihedron.IsNull()) @@ -916,39 +926,6 @@ bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const return ::canBeShaded(anAIS, myWorkshop->module()); } -//************************************************************** -//bool XGUI_Displayer::customizeObject(ObjectPtr theObject) -//{ -// AISObjectPtr anAISObj = getAISObject(theObject); -// // correct the result's color it it has the attribute -// ResultPtr aResult = std::dynamic_pointer_cast(theObject); -// -// // Customization of presentation -// GeomCustomPrsPtr aCustomPrs; -// FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); -// if (aFeature.get() != NULL) { -// GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast(aFeature); -// if (aCustPrs.get() != NULL) -// aCustomPrs = aCustPrs; -// } -// if (aCustomPrs.get() == NULL) { -// GeomPresentablePtr aPrs = std::dynamic_pointer_cast(theObject); -// // we ignore presentable not customized objects -// if (aPrs.get() == NULL) -// aCustomPrs = myCustomPrs; -// } -// bool isCustomized = aCustomPrs.get() && -// aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs); -// isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs) -// || isCustomized; -// -// // update presentation state if faces panel is active -// if (anAISObj.get() && myWorkshop->facesPanel()) -// isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized; -// -// return isCustomized; -//} - //************************************************************** QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject, const QColor& theColor, @@ -961,6 +938,7 @@ QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject, int aR, aG, aB; anAISObj->getColor(aR, aG, aB); anAISObj->setColor(theColor.red(), theColor.green(), theColor.blue()); + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); return QColor(aR, aG, aB); @@ -1195,11 +1173,7 @@ GeomPlanePtr XGUI_Displayer::getScreenPlane() const Handle(AIS_InteractiveContext) aContext = AISContext(); if (!aContext.IsNull()) { Handle(V3d_Viewer) aViewer = aContext->CurrentViewer(); - Handle(V3d_View) aView; - for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) { - aView = aViewer->ActiveView(); - break; - } + Handle(V3d_View) aView = aViewer->ActiveViews().First(); if (!aView.IsNull()) { double aEyeX, aEyeY, aEyeZ; aView->Eye(aEyeX, aEyeY, aEyeZ); @@ -1221,11 +1195,7 @@ double XGUI_Displayer::getViewScale() const Handle(AIS_InteractiveContext) aContext = AISContext(); if (!aContext.IsNull()) { Handle(V3d_Viewer) aViewer = aContext->CurrentViewer(); - Handle(V3d_View) aView; - for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) { - aView = aViewer->ActiveView(); - break; - } + Handle(V3d_View) aView = aViewer->ActiveViews().First(); return aView->Camera()->Scale(); } return 1;