From 528a0ce123c24e65145594c4c19d422d69e641e9 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 2 Jun 2022 16:19:18 +0300 Subject: [PATCH] #29478: Show names of groups in the view --- src/CollectionPlugin/doc/groupFeature.rst | 8 ++ .../doc/images/group_names.png | Bin 0 -> 7600 bytes src/ModuleBase/ModuleBase_IViewer.h | 10 ++ src/ModuleBase/ModuleBase_Preferences.cpp | 6 -- src/ModuleBase/ModuleBase_Tools.cpp | 5 +- src/SHAPERGUI/SHAPERGUI.cpp | 99 ++++++++++-------- src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp | 95 +++++++++++++---- src/SHAPERGUI/SHAPERGUI_SalomeViewer.h | 14 ++- src/SHAPERGUI/SHAPERGUI_msg_fr.ts | 16 +++ src/SHAPERGUI/resources/LightApp.xml.in | 4 + src/XGUI/SHAPER.xml | 4 + src/XGUI/XGUI_Displayer.cpp | 52 +-------- src/XGUI/XGUI_InspectionPanel.h | 3 +- src/XGUI/XGUI_ViewerProxy.cpp | 25 ++--- src/XGUI/XGUI_ViewerProxy.h | 6 ++ src/XGUI/XGUI_Workshop.cpp | 51 ++++++++- src/XGUI/XGUI_Workshop.h | 3 + src/XGUI/XGUI_WorkshopListener.cpp | 8 +- 18 files changed, 261 insertions(+), 148 deletions(-) create mode 100644 src/CollectionPlugin/doc/images/group_names.png 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 0000000000000000000000000000000000000000..a08c96890359654eb4f50747e6a37117115e0ed7 GIT binary patch literal 7600 zcmd5>XIN89w+@IxM4BkQqk@VQL3*)(cs`}s00lx3&?AOWLkmIa27(?@@KEyEK&2-h zh;$Ml0s;!sOo4#Zgg|J4guo3V=idA8mgklqdG_qRX4brGy)$pt?49apZ!5A_ZZ7}; z5c%zb^<@BnkHPx|3+>@O(Z`s8c^AHr%eH3$rCkcsyc+@kGj?YHfQk&^b+6sLdm!Y3 zYX|@!ir@P25dz=d;ysiLwQ&i(66hBS^$PX{IC|Xyhico~TvZ9z*FL4Kr>naZ`~m<_ zRQ}ES%+&~wSu!n_*#CUW%boc-nH$FN0ul1u&*s@Sc#u zMdD+8lW>p|fZNV@_ypvBjHNmH1K{$H{r4MAKUipUhTkXw#QBPY0WOc85Xpjox3im@ zsLhdw-b#t`ajv&iy^ZuTa3YObXz_}iY+LFcPbt@wLA%edAiH!CTGmveGWS*(yU71~ zVYhjeDQrD!+B7#c@&Fj%SE2Z#*V*GH3_3@d+0a0h)^pps*%g8C)lV}U@`0uGoOMJW zcYxwThR<;YwV|5zH6c|sn;@1wD0Z2imBkp2T?ZTKkj(=?M<$%GeAz9!rzIwY`ngrZ zis@p@O!f#qbVwDu`Bfta5~za!-Ddle%|!@4KVfICk~ZnBrY@}WPTyB%)ve6v5GZT* zC1e;r7vG8QMVVL1X8Z&xK}{`;zxYTg{DXUQ@AS}WJ&Y5tTsT$}aT^QT#QP0RW4iCP zZu?w1Q_Wn9e3ZYoeB{EF-1?>VHDCBz(Z+?)#pNdss4^B!+R&%a!Mv}*FNVFe8cp6D zGt21!YqNSfCI?vG^e1Ve`8`O8fu4h ztYFLOorBYJvGDMZU{_hr%3~C`v?wj{q~TsDG&8RxdXu|M`$GQ8g2cS{!j3I&NT=!4 zo6FNSEMQAaL2b!JO%mX<8t%&3gGn0h2ZNep*rY)AtHJa$)<#({CiGQ@MR_e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8Rvn}oNCm? zos|54#QNVzT=0Sy>%M71jT4Ssz?l4FXSx25vC!6*Y*gd$_AFNZFzMbyh{m?I{a;fp z$Wze&9@DPMK)yf(q{_E0{T5MdUWJ;U8fRpUC8`WUj^Zrz`2yo0b6KAFr$Vg!6qXW@ zwIO8a_8c znFhvgV${;RT$wJV;l@5*)&y$RsHNx1y`*qtW4^M}*fQQ6#R<`>%^W!(Ygr;7I}f6B z!36!APje^^7Dgj@uNd#1FXZqXMY{3x3ccNu^B4Cs$Us8_UX>Xa zF?RtARUiCvfNCi|o}wvo&efAjS^6TVCoCHsi}z z0%s6^VzB%+4)(fT!db5J9JH9~vH2N8*j288gZ)6B93e=7o08(yNK43LBZU21?L(wA z1)JIoRnh|y!Hd|)(l;@xE0%>F!N0xB_ zrwruhuH(t%(f}pCq=cOJ?Gm@-zQFFBAkj?PC&WB+Ao_>`e#$?1S-=WV{jS>y#0>NB zjqJ6ja9(l*{3-_`=JZJt^jkjGM#!=~D}2 zF}q`s5Me{dR7h{`46{^`hxpij@Sj(aF1_;}*GeE|fg#~=Kq&&!`{5X01B2I9SDor7 zQF@9pAj|9PcZ8&M-UMyuQ;VPpvDlTjswDq;gz6VmsxV)azzf$x5-dgQ;cK|WgL^vx zf{8FAL=W(sd=aNksAQ^-8hj%bBt^sWhFH4>rFmz}OM6#YTWLxH8VOFn;A_z2;nZqu zt04;-U%gX{fk1tR#`$ijlN4%$59K9A*J;%#oJR1@wH3hC)0Il6J9tg?!Nxy;yd!eT z&RO~2H*#w^k-XP;J?r`4UjRJ!81Mi9 literal 0 HcmV?d00001 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 = -- 2.39.2