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.
// \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;
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");
}
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()) {
//******************************************************
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();
}
//******************************************************
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);
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();
}
#include <Standard_Version.hxx>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
+#include <AIS_TextLabel.hxx>
+#include <Graphic3d_Vec2.hxx>
#include <QMouseEvent>
#include <QContextMenuEvent>
//**********************************************
-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);
}
}
}
+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)
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
class SHAPERGUI_OCCSelector;
class OCCViewer_Viewer;
class SUIT_ViewManager;
+class AIS_TextLabel;
/**
* \ingroup Salome
/// \param toActivate - activation flag
void activateViewer(bool toActivate);
-
// Methods for color scale management
//! Returns True if ColorScale is visible
// \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*);
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;
};
<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>
<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]"/>
<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 -->
#include <ModelAPI_Tools.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
#include <ModuleBase_BRepOwner.h>
#include <ModuleBase_IModule.h>
emit objectDisplayed(theObject, theAIS);
selectionActivate()->activate(anAISIO, theUpdateViewer);
}
+ myWorkshop->updateGroupsText();
if (theUpdateViewer)
updateViewer();
qDebug(QString("erase object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str());
qDebug(getResult2AISObjectMapInfo().c_str());
#endif
-
+ myWorkshop->updateGroupsText();
if (theUpdateViewer)
updateViewer();
#ifdef DEBUG_FEATURE_REDISPLAY
qDebug(" Redisplay happens");
#endif
+ myWorkshop->updateGroupsText();
if (theUpdateViewer)
updateViewer();
}
aErased = true;
}
}
+ myWorkshop->updateGroupsText();
if (theUpdateViewer)
updateViewer();
}
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())
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,
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);
* \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:
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)
//! 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();
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());
}
}
+//**************************************************************
+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)
/// 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:
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());
}
//******************************************************
// 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 =