From: mpv Date: Thu, 2 Jun 2022 13:19:18 +0000 (+0300) Subject: #29478: Show names of groups in the view X-Git-Tag: V9_9_1b1~13^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR29478;p=modules%2Fshaper.git #29478: Show names of groups in the view --- diff --git a/src/CollectionPlugin/doc/groupFeature.rst b/src/CollectionPlugin/doc/groupFeature.rst index becce7777..0b150e912 100644 --- a/src/CollectionPlugin/doc/groupFeature.rst +++ b/src/CollectionPlugin/doc/groupFeature.rst @@ -63,4 +63,12 @@ Created Group appears in the view. Created group +Information about the group, currently displayed in the viewer, is also visuzalised in the right-bottom corner of the viewer: the name of the group result and its color, indicated by background. +This option may be switched in the SHAPER preferences, tab Viewer, section "Group names display". Also there the font parameters of this text may be changed. + +.. figure:: images/group_names.png + :align: center + + Group names + **See Also** a sample TUI Script of :ref:`tui_create_group` operation. diff --git a/src/CollectionPlugin/doc/images/group_names.png b/src/CollectionPlugin/doc/images/group_names.png new file mode 100644 index 000000000..a08c96890 Binary files /dev/null and b/src/CollectionPlugin/doc/images/group_names.png differ diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index e2b141900..3eded7892 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -187,6 +187,16 @@ Q_OBJECT // \param theText is a title virtual void setColorScaleTitle(const QString& theText) = 0; + //! Type for mapping from text to color to display the names lines in different colors + typedef std::list > > TextColor; + + //! Sets the text displayed in right-top corner of the 3D view + //! \param theText the text to display, or empty string to erase presentation; + //! the first item is the font name and text color + //! \param theSize size of the text font + virtual void setText(const TextColor& theText, const int theSize) = 0; + + /// Switches On additional highlight for objects preselection void showSelectionHighlight() { myShowHighlight = true; diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index 2447aa8b4..ad53e4475 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -463,32 +463,26 @@ void ModuleBase_PreferencesDlg::createViewerPage(int thePageId) SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_x_position"); myPreferences->setItemProperty("min", 0, aItem); myPreferences->setItemProperty("max", 1, aItem); - aItem = myPreferences->addItem(tr("Y position"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_y_position"); myPreferences->setItemProperty("min", 0, aItem); myPreferences->setItemProperty("max", 1, aItem); - aItem = myPreferences->addItem(tr("Width"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_width"); myPreferences->setItemProperty("min", 0, aItem); myPreferences->setItemProperty("max", 1, aItem); - aItem = myPreferences->addItem(tr("Height"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_height"); myPreferences->setItemProperty("min", 0, aItem); myPreferences->setItemProperty("max", 1, aItem); - aItem = myPreferences->addItem(tr("Intervals number"), colorScaleGroup, SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_nb_intervals"); myPreferences->setItemProperty("min", 0, aItem); myPreferences->setItemProperty("max", 100, aItem); - aItem = myPreferences->addItem(tr("Text height"), colorScaleGroup, SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_height"); myPreferences->setItemProperty("min", 0, aItem); myPreferences->setItemProperty("max", 100, aItem); - aItem = myPreferences->addItem(tr("Text color"), colorScaleGroup, SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_color"); } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index d79dab412..7c51ccc9a 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -1104,10 +1104,7 @@ bool askToDelete(const std::set theFeatures, aText += QString(QObject::tr(aMsg)); aDetailedText += QString(QObject::tr(aMsgDetails)) .arg(aParamFeatureNames.join(aSep)); -#ifdef _DEBUG - QPushButton *aReplaceButton = -#endif - aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole); + aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole); } if (!aText.isEmpty()) { diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index c5702bf20..f8416f993 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -856,88 +856,94 @@ void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QStri //****************************************************** void SHAPERGUI::createPreferences() { - LightApp_Preferences* pref = preferences(); - if (!pref) + LightApp_Preferences* aPref = preferences(); + if (!aPref) return; ModuleBase_Preferences::updateConfigByResources(); QString aModName = moduleName(); - QtxPreferenceItem* item = pref->findItem(aModName, true ); + QtxPreferenceItem* item = aPref->findItem(aModName, true ); if ( item && (!item->isEmpty() )) { item->parentItem()->removeItem(item); delete item; } - int catId = pref->addPreference(aModName, -1 ); + int catId = aPref->addPreference(aModName, -1 ); if ( catId == -1 ) return; - SHAPERGUI_PrefMgr aMgr(pref, aModName); + SHAPERGUI_PrefMgr aMgr(aPref, aModName); ModuleBase_Preferences::createEditContent(&aMgr, catId); - int viewTab = pref->addItem(tr("Viewer"), catId); + int viewTab = aPref->addItem(tr("Viewer"), catId); // Create other parameters group in viewer tab - int otherGroup = pref->addItem(tr("Default selection"), viewTab); - pref->setItemProperty("columns", 3, otherGroup); - pref->addItem(tr("Faces"), otherGroup, + int otherGroup = aPref->addItem(tr("Default selection"), viewTab); + aPref->setItemProperty("columns", 3, otherGroup); + aPref->addItem(tr("Faces"), otherGroup, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "face-selection"); - pref->addItem(tr("Edges"), otherGroup, + aPref->addItem(tr("Edges"), otherGroup, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "edge-selection"); - pref->addItem(tr("Vertices"), otherGroup, + aPref->addItem(tr("Vertices"), otherGroup, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection"); - int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab); - pref->setItemProperty("columns", 2, sensitivityGroup); - pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin, + int sensitivityGroup = aPref->addItem(tr("Selection sensitivity"), viewTab); + aPref->setItemProperty("columns", 2, sensitivityGroup); + aPref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin, ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity"); - pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin, + aPref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin, ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity"); - int highlightGroup = pref->addItem(tr("Additional highlighting"), viewTab); - pref->setItemProperty("columns", 2, highlightGroup); - pref->addItem(tr("In 3d mode"), highlightGroup, + int highlightGroup = aPref->addItem(tr("Additional highlighting"), viewTab); + aPref->setItemProperty("columns", 2, highlightGroup); + aPref->addItem(tr("In 3d mode"), highlightGroup, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d"); - pref->addItem(tr("In 2d mode"), highlightGroup, + aPref->addItem(tr("In 2d mode"), highlightGroup, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d"); - int colorScaleGroup = pref->addItem(tr("Color scale"), viewTab); - pref->setItemProperty("columns", 4, colorScaleGroup); + int colorScaleGroup = aPref->addItem(tr("Color scale"), viewTab); + aPref->setItemProperty("columns", 4, colorScaleGroup); int aItem = aMgr.addPreference(tr("X position"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_x_position"); - pref->setItemProperty("min", 0, aItem); - pref->setItemProperty("max", 1, aItem); - + aPref->setItemProperty("min", 0, aItem); + aPref->setItemProperty("max", 1, aItem); aItem = aMgr.addPreference(tr("Y position"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_y_position"); - pref->setItemProperty("min", 0, aItem); - pref->setItemProperty("max", 1, aItem); - + aPref->setItemProperty("min", 0, aItem); + aPref->setItemProperty("max", 1, aItem); aItem = aMgr.addPreference(tr("Width"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_width"); - pref->setItemProperty("min", 0, aItem); - pref->setItemProperty("max", 1, aItem); - + aPref->setItemProperty("min", 0, aItem); + aPref->setItemProperty("max", 1, aItem); aItem = aMgr.addPreference(tr("Height"), colorScaleGroup, SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_height"); - pref->setItemProperty("min", 0, aItem); - pref->setItemProperty("max", 1, aItem); - + aPref->setItemProperty("min", 0, aItem); + aPref->setItemProperty("max", 1, aItem); aItem = aMgr.addPreference(tr("Intervals number"), colorScaleGroup, SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_nb_intervals"); - pref->setItemProperty("min", 0, aItem); - pref->setItemProperty("max", 100, aItem); - + aPref->setItemProperty("min", 0, aItem); + aPref->setItemProperty("max", 100, aItem); aItem = aMgr.addPreference(tr("Text height"), colorScaleGroup, SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_height"); - pref->setItemProperty("min", 0, aItem); - pref->setItemProperty("max", 100, aItem); - + aPref->setItemProperty("min", 0, aItem); + aPref->setItemProperty("max", 100, aItem); aItem = aMgr.addPreference(tr("Text color"), colorScaleGroup, SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_color"); - pref->retrieve(); + int aGroupNamesGroup = aMgr.addPreference(tr("Group names display"), viewTab, + SUIT_PreferenceMgr::GroupBox , ModuleBase_Preferences::VIEWER_SECTION, "group_names_display"); + aPref->setItemProperty("columns", 3, aGroupNamesGroup); + aMgr.addPreference(tr("Text font"), aGroupNamesGroup, + SUIT_PreferenceMgr::String, ModuleBase_Preferences::VIEWER_SECTION, "group_names_font"); + aItem = aMgr.addPreference(tr("Text size"), aGroupNamesGroup, + SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "group_names_size"); + aPref->setItemProperty("min", 8, aItem); + aPref->setItemProperty("max", 100, aItem); + aItem = aMgr.addPreference(tr("Text color"), aGroupNamesGroup, + SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "group_names_color"); + + aPref->retrieve(); } //****************************************************** @@ -954,9 +960,9 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the aValue = aProp->defaultValue(); aResMgr->setValue(theSection, theParam, QString(aValue.c_str())); - LightApp_Preferences* pref = preferences(); - if (pref) - pref->retrieve(); + LightApp_Preferences* aPref = preferences(); + if (aPref) + aPref->retrieve(); } aProp->setValue(aValue); @@ -1000,7 +1006,12 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the Events_MessageBool aCreateMsg(Events_Loop::eventByName(EVENT_CREATE_PART_ON_START), aCreate); aCreateMsg.send(); } - + else if (theSection == ModuleBase_Preferences::VIEWER_SECTION && + theParam.startsWith("group_names_")) + { // one of the group names parameter changed, so, update the groups names vizualization + myWorkshop->updateGroupsText(); + myWorkshop->displayer()->updateViewer(); + } myWorkshop->displayer()->redisplayObjects(); } diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index 1f4fb0712..cd1759c23 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -30,6 +30,8 @@ #include #include +#include +#include #include #include @@ -236,13 +238,13 @@ bool SHAPERGUI_SalomeViewer::canDragByMouse() const //********************************************** -void SHAPERGUI_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent) +void SHAPERGUI_SalomeViewer::onKeyPress(SUIT_ViewWindow* /*theView*/, QKeyEvent* theEvent) { emit keyPress(myView, theEvent); } //********************************************** -void SHAPERGUI_SalomeViewer::onKeyRelease(SUIT_ViewWindow* theView, QKeyEvent* theEvent) +void SHAPERGUI_SalomeViewer::onKeyRelease(SUIT_ViewWindow* /*theView*/, QKeyEvent* theEvent) { emit keyRelease(myView, theEvent); } @@ -588,6 +590,75 @@ void SHAPERGUI_SalomeViewer::setColorScaleTitle(const QString& theText) } } +void SHAPERGUI_SalomeViewer::setText( + const ModuleBase_IViewer::TextColor& theText, const int theSize) +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (aContext.IsNull()) + return; + NCollection_List::Iterator aPrsIter(myText); + if (!theText.empty()) + { + Quantity_Color aTextColor; + std::string aTextFont; + + double anOffset = -theSize - 1; // initial offset from the toolbar of the viewer + ModuleBase_IViewer::TextColor::const_iterator aLine = theText.cbegin(); + for (; aLine != theText.cend(); aLine++) + { + Quantity_Color aColor(aLine->second.at(0) / 255., + aLine->second.at(1) / 255., aLine->second.at(2) / 255., Quantity_TOC_RGB); + if (aLine == theText.cbegin()) + { // the first is the font name and text color + aTextColor = aColor; + aTextFont = std::string(aLine->first.begin(), aLine->first.end()); + continue; + } + + Handle(AIS_TextLabel) aPrs; + if (!aPrsIter.More()) + { // new presentation is added to the list forever + aPrs = new AIS_TextLabel; + aPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD); + aPrs->SetHJustification(Graphic3d_HTA_RIGHT); + aPrs->SetVJustification(Graphic3d_VTA_TOPFIRSTLINE); + aPrs->SetDisplayType(Aspect_TODT_SUBTITLE); + aPrs->SetTransparency(0.2); + static const Graphic3d_Vec2i aZOffset(0); + aPrs->SetTransformPersistence(new Graphic3d_TransformPers( + Graphic3d_TMF_2d, Aspect_TOTP_RIGHT_UPPER, aZOffset)); + } + else + { // update the existing presentation + aPrs = aPrsIter.ChangeValue(); + if (!aContext->IsDisplayed(aPrs)) + aContext->Display(aPrs, Standard_False); + } + // common part of parameters for new and existing prs + aPrs->SetText(aLine->first.c_str()); + aPrs->SetFont(aTextFont.c_str()); + aPrs->SetHeight(theSize); + aPrs->SetPosition(gp_Pnt(0, anOffset, 0)); + anOffset -= int(double(theSize) * 1.2 + 1); // to have a proportional gap between lines + aPrs->SetColor(aTextColor); + aPrs->SetColorSubTitle(aColor); + if (!aPrsIter.More()) + { // for the new presentation + aContext->Display(aPrs, Standard_False); + myText.Append(aPrs); + } + else + { // update existing presentation + aContext->Redisplay(aPrs, Standard_False, Standard_False); + aPrsIter.Next(); + } + } + } + // hide the left presentations, created previously, but unused for now + for (; aPrsIter.More(); aPrsIter.Next()) + aContext->Erase(aPrsIter.ChangeValue(), Standard_False); +} + void SHAPERGUI_SalomeViewer::setFitter(OCCViewer_Fitter* theFitter) { if (mySelector) @@ -600,23 +671,3 @@ OCCViewer_Fitter* SHAPERGUI_SalomeViewer::fitter() const return mySelector->viewer()->fitter(); return 0; } - - -//void SHAPERGUI_SalomeViewer::Zfitall() -//{ -// if (!mySelector || !mySelector->viewer()) -// return; -// SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); -// /// WORKAROUND for issue #1798. SUIT_ViewManager::closeAllViews() should nullify myActiveView -// /// As a result, we need to check views count in manager -// if (aMgr->getViews().size() > 0) { -// OCCViewer_ViewFrame* aView = dynamic_cast(aMgr->getActiveView()); -// if (aView) { -// OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW); -// Handle(V3d_View) aView3d = aWnd->getViewPort()->getView(); -// aView3d->ZFitAll(); -// if (aView3d->Depth() < 0.1) -// aView3d->DepthFitAll(); -// } -// } -//} \ No newline at end of file diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h index dc1e59fe5..d914f7c1d 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h @@ -37,6 +37,7 @@ class QKeyEvent; class SHAPERGUI_OCCSelector; class OCCViewer_Viewer; class SUIT_ViewManager; +class AIS_TextLabel; /** * \ingroup Salome @@ -168,7 +169,6 @@ Q_OBJECT /// \param toActivate - activation flag void activateViewer(bool toActivate); - // Methods for color scale management //! Returns True if ColorScale is visible @@ -208,12 +208,15 @@ Q_OBJECT // \param theText is a title virtual void setColorScaleTitle(const QString& theText); + //! Sets the text displayed in right-top corner of the 3D view + //! \param theText the text to display, or empty string to erase presentation; + //! the first item is the font name and text color + //! \param theSize size of the text font + virtual void setText(const ModuleBase_IViewer::TextColor& theText, const int theSize); + virtual void setFitter(OCCViewer_Fitter* theFitter); virtual OCCViewer_Fitter* fitter() const; - // Fit all along Z (perpendicular to display) - //virtual void Zfitall(); - private slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); @@ -242,6 +245,9 @@ Q_OBJECT SHAPERGUI_OCCSelector* mySelector; SHAPERGUI_SalomeView* myView; bool myIsSelectionChanged; + /// Presentation of names of all displayed SHAPER group results in 3D view, + /// a text in right-top corner of the view. + NCollection_List myText; }; diff --git a/src/SHAPERGUI/SHAPERGUI_msg_fr.ts b/src/SHAPERGUI/SHAPERGUI_msg_fr.ts index 6499ca9e2..efbcf21d7 100644 --- a/src/SHAPERGUI/SHAPERGUI_msg_fr.ts +++ b/src/SHAPERGUI/SHAPERGUI_msg_fr.ts @@ -107,6 +107,22 @@ MEN_DESK_EDIT MEN_DESK_EDIT + + Group names display + Affichage des noms de groupe + + + Text font + Police de texte + + + Text size + Taille du texte + + + Text color + Couleur du texte + SHAPERGUI_ToolbarItemsDlg diff --git a/src/SHAPERGUI/resources/LightApp.xml.in b/src/SHAPERGUI/resources/LightApp.xml.in index a28831769..35347b0a7 100644 --- a/src/SHAPERGUI/resources/LightApp.xml.in +++ b/src/SHAPERGUI/resources/LightApp.xml.in @@ -52,6 +52,10 @@ + + + +
diff --git a/src/XGUI/SHAPER.xml b/src/XGUI/SHAPER.xml index d2ae66807..6411ef537 100644 --- a/src/XGUI/SHAPER.xml +++ b/src/XGUI/SHAPER.xml @@ -33,6 +33,10 @@ + + + +
diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b9be6db91..8fda4fb34 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -224,6 +223,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, emit objectDisplayed(theObject, theAIS); selectionActivate()->activate(anAISIO, theUpdateViewer); } + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); @@ -261,7 +261,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(); @@ -352,6 +352,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) #ifdef DEBUG_FEATURE_REDISPLAY qDebug(" Redisplay happens"); #endif + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); } @@ -533,6 +534,7 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) aErased = true; } } + myWorkshop->updateGroupsText(); if (theUpdateViewer) updateViewer(); } @@ -639,21 +641,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()) @@ -915,39 +905,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, @@ -960,6 +917,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); diff --git a/src/XGUI/XGUI_InspectionPanel.h b/src/XGUI/XGUI_InspectionPanel.h index 373e12b2d..dcd6f144d 100644 --- a/src/XGUI/XGUI_InspectionPanel.h +++ b/src/XGUI/XGUI_InspectionPanel.h @@ -50,7 +50,8 @@ MAYBE_UNUSED const static char* INSPECTION_PANEL = "inspection_panel_dock"; * \ingroup GUI * A class which represents an inspection panel: to show content of currently selected objects */ -class XGUI_EXPORT XGUI_InspectionPanel : public QDockWidget, public GeomAlgoAPI_ShapeInfo::Translator +class XGUI_EXPORT XGUI_InspectionPanel : + public QDockWidget, public GeomAlgoAPI_ShapeInfo::Translator { Q_OBJECT public: diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index b1efe8a87..a0adccacb 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -726,24 +726,13 @@ void XGUI_ViewerProxy::setupColorScale() setColorScaleIntervals(aN); } - -//*************************************** -//void XGUI_ViewerProxy::Zfitall() -//{ -//#ifdef HAVE_SALOME -// myWorkshop->salomeConnector()->viewer()->Zfitall(); -//#else -// AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); -// AppElements_ViewWindow* aView = aViewer->activeViewWindow(); -// if (aView) { -// Handle(V3d_View) aView3d = aView->v3dView(); -// aView3d->ZFitAll(); -// if (aView3d->Depth() < 0.1) -// aView3d->DepthFitAll(); -// } -//#endif -//} - +void XGUI_ViewerProxy::setText( + const ModuleBase_IViewer::TextColor& theText, const int theSize) +{ +#ifdef HAVE_SALOME + myWorkshop->salomeConnector()->viewer()->setText(theText, theSize); +#endif +} #ifdef HAVE_SALOME void XGUI_ViewerProxy::setFitter(OCCViewer_Fitter* theFitter) diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 59e5d0b82..2ba62974b 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -166,6 +166,12 @@ Q_OBJECT //! Set color scale parameters according to user preferences and window size void setupColorScale(); + //! Sets the text displayed in right-top corner of the 3D view + //! \param theText the text to display, or empty string to erase presentation; + //! the first item is the font name and text color + //! \param theSize size of the text font + virtual void setText(const ModuleBase_IViewer::TextColor& theText, const int theSize); + // Fit all along Z (perpendicular to display) //virtual void Zfitall(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 624f64422..126c07066 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -2897,7 +2897,7 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList) void XGUI_Workshop::updateColorScaleVisibility() { QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); - viewer()->setColorScaleShown(false); + myViewerProxy->setColorScaleShown(false); if (anObjects.size() == 1) { FieldStepPtr aStep = std::dynamic_pointer_cast(anObjects.first()); @@ -2928,6 +2928,55 @@ void XGUI_Workshop::updateColorScaleVisibility() } } +//************************************************************** +void XGUI_Workshop::updateGroupsText() +{ + ModuleBase_IViewer::TextColor aText; + + int aSize = 10; + SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr(); + if (aResMgr->booleanValue("Viewer", "group_names_display")) { + // the first item in the TextColor list is font name -> text color + QColor aTextColor = aResMgr->colorValue("Viewer", "group_names_color"); + std::vector aTextCV; + aTextCV.push_back(aTextColor.red()); + aTextCV.push_back(aTextColor.green()); + aTextCV.push_back(aTextColor.blue()); + QString aFontName = aResMgr->stringValue("Viewer", "group_names_font"); + aText.push_back(std::pair >(aFontName.toStdWString(), aTextCV)); + aSize = aResMgr->integerValue("Viewer", "group_names_size"); + + DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument(); + int aNbGroups = aDoc->size(ModelAPI_ResultGroup::group()); + for (int aGIndex = 0; aGIndex < aNbGroups; aGIndex++) + { + ResultGroupPtr aGroup = std::dynamic_pointer_cast( + aDoc->object(ModelAPI_ResultGroup::group(), aGIndex)); + if (aGroup.get() && !aGroup->isDisabled() && aGroup->isDisplayed()) + { + std::vector aColor; + ModelAPI_Tools::getColor(aGroup, aColor); + if (aColor.empty()) + { // default groups colors + std::string aSection, aName, aDefault; + aGroup->colorConfigInfo(aSection, aName, aDefault); + if (!aSection.empty() && !aName.empty()) { + aColor = Config_PropManager::color(aSection, aName); + } + } + if (aColor.empty()) + { + aColor.push_back(150.); + aColor.push_back(150.); + aColor.push_back(150.); + } + aText.push_back(std::pair >(aGroup->data()->name(), aColor)); + } + } + } + myViewerProxy->setText(aText, aSize); +} + //************************************************************** void XGUI_Workshop::setNormalView(bool toInvert) diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 8b4f0ac36..19234656d 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -343,6 +343,9 @@ Q_OBJECT /// The method updates a Color Scale object in the viewer void updateColorScaleVisibility(); + /// The method updates a Text of Group names in the viewer. + void updateGroupsText(); + void showHelpPage(const QString& thePage) const; signals: diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 7514897c2..dfce8b8a4 100644 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -121,6 +121,7 @@ void XGUI_WorkshopListener::initializeEventListening() aLoop->registerListener(this, Events_Loop::eventByName("AbortOperation")); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE)); + aLoop->registerListener(this, ModelAPI_ObjectRenamedMessage::eventId()); } //****************************************************** @@ -220,11 +221,16 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& // the viewer's update context is unblocked, the viewer's update works XGUI_Displayer* aDisplayer = workshop()->displayer(); aDisplayer->enableUpdateViewer(true); - } else if ((theMessage->eventID() == + } + else if ((theMessage->eventID() == Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)) || (theMessage->eventID() == Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE))) { myWorkshop->updateAutoComputeState(); + } + else if (theMessage->eventID() == ModelAPI_ObjectRenamedMessage::eventId()) { + myWorkshop->updateGroupsText(); + myWorkshop->displayer()->updateViewer(); } else { //Show error dialog if error message received. std::shared_ptr anIngfoMsg =