Salome HOME
#29478: Show names of groups in the view CR29478
authormpv <mpv@opencascade.com>
Thu, 2 Jun 2022 13:19:18 +0000 (16:19 +0300)
committerazv <azv@opencascade.com>
Wed, 8 Jun 2022 05:46:14 +0000 (08:46 +0300)
18 files changed:
src/CollectionPlugin/doc/groupFeature.rst
src/CollectionPlugin/doc/images/group_names.png [new file with mode: 0644]
src/ModuleBase/ModuleBase_IViewer.h
src/ModuleBase/ModuleBase_Preferences.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.h
src/SHAPERGUI/SHAPERGUI_msg_fr.ts
src/SHAPERGUI/resources/LightApp.xml.in
src/XGUI/SHAPER.xml
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_InspectionPanel.h
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_WorkshopListener.cpp

index becce7777eaedbae8bdbf0fd7653dd45ea0eebaa..0b150e91273ee441554be5dabe52fd128770c799 100644 (file)
@@ -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 (file)
index 0000000..a08c968
Binary files /dev/null and b/src/CollectionPlugin/doc/images/group_names.png differ
index e2b141900867bded454c036f13b560986ab4d856..3eded7892c7c67954703e7befc794c546d3f7ec4 100644 (file)
@@ -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<std::pair<std::wstring, std::vector<int> > > 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;
index 2447aa8b4982e781caa6ba854f357401e2cfb1e2..ad53e4475b681d44c1360111f3b3c6ed063c5ffe 100644 (file)
@@ -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");
 }
index d79dab4127b1d5a7dc211a8fafbc2682581d397c..7c51ccc9aeb3bdbb29db403f80b12357e4fa42a0 100644 (file)
@@ -1104,10 +1104,7 @@ bool askToDelete(const std::set<FeaturePtr> 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()) {
index c5702bf206bb46341523fda4359688169d1caad7..f8416f993c329078ba4a6aa134680061a9e9919d 100644 (file)
@@ -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();
 }
 
index 1f4fb0712b7e1a0fef205b67682f866c7d1c6d76..cd1759c2349a497c0981de80bcbe82f2c9cc9fc2 100644 (file)
@@ -30,6 +30,8 @@
 
 #include <Standard_Version.hxx>
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
+#include <AIS_TextLabel.hxx>
+#include <Graphic3d_Vec2.hxx>
 
 #include <QMouseEvent>
 #include <QContextMenuEvent>
@@ -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<Handle(AIS_TextLabel)>::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<OCCViewer_ViewFrame*>(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
index dc1e59fe529da1b6b53e5b6176e310fa8011fbe2..d914f7c1d20956981325f35b4fa5c1f3a3cee53d 100644 (file)
@@ -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<Handle(AIS_TextLabel)> myText;
 };
 
 
index 6499ca9e27713f9609b20c5543b32e6bf670f231..efbcf21d7a4d84860d3b98085f8d4226d85c6a81 100644 (file)
         <source>MEN_DESK_EDIT</source>
         <translation>MEN_DESK_EDIT</translation>
     </message>
+    <message>
+        <source>Group names display</source>
+        <translation>Affichage des noms de groupe</translation>
+    </message>
+    <message>
+        <source>Text font</source>
+        <translation>Police de texte</translation>
+    </message>
+    <message>
+        <source>Text size</source>
+        <translation>Taille du texte</translation>
+    </message>
+    <message>
+        <source>Text color</source>
+        <translation>Couleur du texte</translation>
+    </message>
 </context>
 <context>
     <name>SHAPERGUI_ToolbarItemsDlg</name>
index a288317694d758a8604bf99a9ad2c623fa42f9c9..35347b0a7833252b76b688ac2df211975017ce1e 100644 (file)
     <parameter name="scalar_bar_nb_intervals" value="20" />
     <parameter name="scalar_bar_text_color" value="#000000" />
     <parameter name="shaper_default_transparency" value="0"/>
+    <parameter name="group_names_display" value="true" />
+    <parameter name="group_names_font" value="Arial Black" />
+    <parameter name="group_names_size" value="12" />
+    <parameter name="group_names_color" value="#000000" />
   </section>
   <section name="windows_geometry">
    <parameter name="SHAPER" value="@ByteArray[#00 #00 #00 #FF #00 #00 #00 #00 #FD #00 #00 #00 #03 #00 #00 #00 #00 #00 #00 #01 #00 #00 #00 #02 #DF #FC #02 #00 #00 #00 #02 #FB #00 #00 #00 #22 #00 #6F #00 #62 #00 #6A #00 #65 #00 #63 #00 #74 #00 #42 #00 #72 #00 #6F #00 #77 #00 #73 #00 #65 #00 #72 #00 #44 #00 #6F #00 #63 #00 #6B #01 #00 #00 #00 #B0 #00 #00 #02 #3D #00 #00 #00 #00 #00 #00 #00 #00 #FC #00 #00 #00 #B0 #00 #00 #02 #DF #00 #00 #00 #6B #00 #FF #FF #FF #FA #00 #00 #00 #00 #02 #00 #00 #00 #02 #FB #FF #FF #FF #FF #01 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #6B #00 #FF #FF #FF #FB #00 #00 #00 #26 #00 #70 #00 #72 #00 #6F #00 #70 #00 #65 #00 #72 #00 #74 #00 #79 #00 #5F #00 #70 #00 #61 #00 #6E #00 #65 #00 #6C #00 #5F #00 #64 #00 #6F #00 #63 #00 #6B #00 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #01 #1F #00 #FF #FF #FF #00 #00 #00 #01 #00 #00 #00 #00 #00 #00 #00 #00 #FC #02 #00 #00 #00 #02 #FB #00 #00 #00 #2A #00 #69 #00 #6E #00 #73 #00 #70 #00 #65 #00 #63 #00 #74 #00 #69 #00 #6F #00 #6E #00 #5F #00 #70 #00 #61 #00 #6E #00 #65 #00 #6C #00 #5F #00 #64 #00 #6F #00 #63 #00 #6B #00 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #D1 #00 #FF #FF #FF #FB #FF #FF #FF #FF #00 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #70 #00 #FF #FF #FF #00 #00 #00 #03 #00 #00 #07 #5C #00 #00 #00 #59 #FC #01 #00 #00 #00 #01 #FB #00 #00 #00 #22 #00 #70 #00 #79 #00 #74 #00 #68 #00 #6F #00 #6E #00 #43 #00 #6F #00 #6E #00 #73 #00 #6F #00 #6C #00 #65 #00 #44 #00 #6F #00 #63 #00 #6B #01 #00 #00 #00 #00 #00 #00 #07 #5C #00 #00 #00 #46 #00 #FF #FF #FF #00 #00 #06 #56 #00 #00 #02 #DF #00 #00 #00 #04 #00 #00 #00 #04 #00 #00 #00 #08 #00 #00 #00 #08 #FC #00 #00 #00 #04 #00 #00 #00 #02 #00 #00 #00 #05 #00 #00 #00 #1C #00 #53 #00 #61 #00 #6C #00 #6F #00 #6D #00 #65 #00 #53 #00 #74 #00 #61 #00 #6E #00 #64 #00 #61 #00 #72 #00 #64 #01 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #1A #00 #53 #00 #61 #00 #6C #00 #6F #00 #6D #00 #65 #00 #4D #00 #6F #00 #64 #00 #75 #00 #6C #00 #65 #00 #73 #01 #00 #00 #00 #F5 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #08 #00 #50 #00 #61 #00 #72 #00 #74 #01 #00 #00 #01 #B5 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #10 #00 #4D #00 #6F #00 #76 #00 #65 #00 #6D #00 #65 #00 #6E #00 #74 #01 #00 #00 #02 #DB #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #16 #00 #4D #00 #65 #00 #61 #00 #73 #00 #75 #00 #72 #00 #65 #00 #6D #00 #65 #00 #6E #00 #74 #01 #00 #00 #03 #B1 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #02 #00 #00 #00 #04 #00 #00 #00 #18 #00 #43 #00 #6F #00 #6E #00 #73 #00 #74 #00 #72 #00 #75 #00 #63 #00 #74 #00 #69 #00 #6F #00 #6E #01 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #0A #00 #42 #00 #75 #00 #69 #00 #6C #00 #64 #01 #00 #00 #00 #73 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #14 #00 #50 #00 #72 #00 #69 #00 #6D #00 #69 #00 #74 #00 #69 #00 #76 #00 #65 #00 #73 #01 #00 #00 #02 #1D #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #08 #00 #47 #00 #44 #00 #4D #00 #4C #01 #00 #00 #02 #D2 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #02 #00 #00 #00 #05 #00 #00 #00 #10 #00 #46 #00 #65 #00 #61 #00 #74 #00 #75 #00 #72 #00 #65 #00 #73 #01 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #0E #00 #42 #00 #6F #00 #6F #00 #6C #00 #65 #00 #61 #00 #6E #01 #00 #00 #01 #9E #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #16 #00 #43 #00 #6F #00 #6C #00 #6C #00 #65 #00 #63 #00 #74 #00 #69 #00 #6F #00 #6E #00 #73 #01 #00 #00 #02 #D7 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #0C #00 #46 #00 #69 #00 #6C #00 #6C #00 #65 #00 #74 #01 #00 #00 #03 #08 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #0C #00 #4D #00 #61 #00 #63 #00 #72 #00 #6F #00 #73 #01 #00 #00 #03 #5A #00 #00 #04 #02 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #02 #00 #00 #00 #02 #00 #00 #00 #0C #00 #53 #00 #6B #00 #65 #00 #74 #00 #63 #00 #68 #01 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #1E #00 #49 #00 #4E #00 #53 #00 #50 #00 #57 #00 #43 #00 #54 #00 #49 #00 #4F #00 #4E #00 #5F #00 #54 #00 #4F #00 #4F #00 #4C #01 #00 #00 #04 #48 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00]"/>
index d2ae6680702804e19c1d446ba99d34a5c5e483ba..6411ef5376b77142a9feb45c0aa90fb076a67d4f 100644 (file)
     <parameter name="scalar_bar_text_height" value="14" />
     <parameter name="scalar_bar_nb_intervals" value="20" />
     <parameter name="scalar_bar_text_color" value="#000000" />
+    <parameter name="group_names_display" value="true" />
+    <parameter name="group_names_font" value="Arial Black" />
+    <parameter name="group_names_size" value="12" />
+    <parameter name="group_names_color" value="#000000" />
   </section>
   <section name="Menu" >
     <!-- Menu bar preferences -->
index b9be6db91d79f0761591c15155c0553c28f23ff2..8fda4fb34480ead10ae437d8eff6481bf4974222 100644 (file)
@@ -36,7 +36,6 @@
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
 
 #include <ModuleBase_BRepOwner.h>
 #include <ModuleBase_IModule.h>
@@ -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<ModelAPI_Result>(theObject);
-//
-//  // Customization of presentation
-//  GeomCustomPrsPtr aCustomPrs;
-//  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-//  if (aFeature.get() != NULL) {
-//    GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
-//    if (aCustPrs.get() != NULL)
-//      aCustomPrs = aCustPrs;
-//  }
-//  if (aCustomPrs.get() == NULL) {
-//    GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(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);
index 373e12b2d496797b9a4920e5d4eba5d78aa34485..dcd6f144d84ac711b420acedfa39992e2dd002bd 100644 (file)
@@ -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:
index b1efe8a8708f1643efc38b090b0bf8d2c2bf9309..a0adccacb6552b04473cee4a746e3cccf187b212 100644 (file)
@@ -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)
index 59e5d0b82df13afd85f403ff4ad610a8854a38c8..2ba62974bf7690d97aafc1a6e76de580ad927167 100644 (file)
@@ -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();
 
index 624f6442233e1efdc94170689afdc72cac4ad8e9..126c07066fdc9a2a6e1fd23be40e2529138f75f5 100644 (file)
@@ -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<ModelAPI_ResultField::ModelAPI_FieldStep>(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<int> 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<std::wstring, std::vector<int> >(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<ModelAPI_ResultGroup>(
+        aDoc->object(ModelAPI_ResultGroup::group(), aGIndex));
+      if (aGroup.get() && !aGroup->isDisabled() && aGroup->isDisplayed())
+      {
+        std::vector<int> 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<std::wstring, std::vector<int> >(aGroup->data()->name(), aColor));
+      }
+    }
+  }
+  myViewerProxy->setText(aText, aSize);
+}
+
 
 //**************************************************************
 void XGUI_Workshop::setNormalView(bool toInvert)
index 8b4f0ac362ee478f2caeb1bd2698a1b1a893db5b..19234656d4e9273fa790ebc486f1c92601b95628 100644 (file)
@@ -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:
index 7514897c211a56a706dc2a057a5344e89f21ea1d..dfce8b8a474ffc5fba3eb56db54d21f2f193e6ec 100644 (file)
@@ -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<Events_Message>&
     // 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<Events_InfoMessage> anIngfoMsg =