+bool SHAPERGUI_SalomeViewer::isColorScaleVisible() const
+{
+ if (mySelector) {
+ return mySelector->viewer()->isColorScaleVisible();
+ }
+ return false;
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleShown(bool on)
+{
+ if (mySelector) {
+ mySelector->viewer()->setColorScaleShown(on);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScalePosition(double theX, double theY)
+{
+ if (mySelector) {
+ QWidget* aWindow = activeViewPort();
+ mySelector->viewer()->getColorScale()->SetPosition(aWindow->width() * theX,
+ aWindow->height() * theY);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleSize(double theW, double theH)
+{
+ if (mySelector) {
+ QWidget* aWindow = activeViewPort();
+ mySelector->viewer()->getColorScale()->SetSize(aWindow->width() * theW,
+ aWindow->height() * theH);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleRange(double theMin, double theMax)
+{
+ if (mySelector) {
+ mySelector->viewer()->getColorScale()->SetRange(theMin, theMax);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleIntervals(int theNb)
+{
+ if (mySelector) {
+ mySelector->viewer()->getColorScale()->SetNumberOfIntervals(theNb);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTextHeigth(int theH)
+{
+ if (mySelector) {
+ mySelector->viewer()->getColorScale()->SetTextHeight(theH);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTextColor(const QColor& theColor)
+{
+ if (mySelector) {
+ Quantity_Color aColor(theColor.redF(), theColor.greenF(), theColor.blueF(), Quantity_TOC_RGB);
+ mySelector->viewer()->getColorScale()->SetColor(aColor);
+ }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTitle(const QString& theText)
+{
+ if (mySelector) {
+ mySelector->viewer()->getColorScale()->SetTitle(theText.toStdString().c_str());
+ }
+}
+
+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)
+ mySelector->viewer()->setFitter(theFitter);
+}
+
+OCCViewer_Fitter* SHAPERGUI_SalomeViewer::fitter() const
+{
+ if (mySelector)
+ return mySelector->viewer()->fitter();
+ return 0;
+}