-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#define TEXT_MARGIN 4
#define OFFSET_SPACING 2
+//VSR: uncomment below macro to support unicode text properly in SALOME
+// current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+ QString fromUtf8( const char* txt )
+ {
+#ifdef PAL22528_UNICODE
+ return QString::fromUtf8( txt );
+#else
+ return QString( txt );
+#endif
+ }
+ std::string toUtf8( const QString& txt )
+ {
+#ifdef PAL22528_UNICODE
+ return txt.toUtf8().constData();
+#else
+ return txt.toLatin1().constData();
+#endif
+ }
+}
+
//==================================================================
-vtkStandardNewMacro(VTKViewer_FramedTextActor);
+vtkStandardNewMacro(VTKViewer_FramedTextActor)
//==================================================================
// function : VTKViewer_FramedTextActor
myTextProperty->SetItalic(0);
myTextProperty->SetShadow(1);
myTextProperty->SetFontFamilyToArial();
-
- myTextMapper=vtkTextMapper::New();
- myTextMapper->SetInput("");
- myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty);
- myTextActor=vtkActor2D::New();
- myTextActor->SetMapper(myTextMapper);
+
+ myTextActor=vtkTextActor::New();
+ myTextActor->SetTextProperty(myTextProperty);
myBarActor->SetVisibility(1);
myTextActor->SetVisibility(1);
VTKViewer_FramedTextActor::~VTKViewer_FramedTextActor()
{
myTextActor->Delete();
- myTextMapper->Delete();
myTextProperty->Delete();
myBarActor->Delete();
myBarMapper->Delete();
// function : GetSize
// purpose :
//==================================================================
-void VTKViewer_FramedTextActor::GetSize(vtkRenderer* theRenderer, int theSize[2]) const
+void VTKViewer_FramedTextActor::GetSize(vtkRenderer* vport, double theSize[2]) const
{
- myTextMapper->GetSize(theRenderer, theSize);
+ myTextActor->GetSize(vport, theSize);
theSize[0] = theSize[0] + 2 * GetTextMargin() + OFFSET_SPACING;
theSize[1] = theSize[1] + 2 * GetTextMargin() + OFFSET_SPACING;
}
const double b)
{
myTextProperty->SetColor(r, g, b);
- myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty);
+ myTextActor->GetTextProperty()->ShallowCopy(myTextProperty);
Modified();
}
// function : SetOffset
// purpose :
//==================================================================
-void VTKViewer_FramedTextActor::SetOffset(const int theOffset[2])
+void VTKViewer_FramedTextActor::SetOffset(const double theOffset[2])
{
myHorizontalOffset = theOffset[0];
myVerticalOffset = theOffset[1];
{
// remove whitespaces from from the start and the end
// additionally, consider a case of multi-string text
- QString aString(theText);
+ QString aString(fromUtf8(theText));
QStringList aTrimmedStringList;
QStringList aStringList = aString.split("\n");
while(anIter.hasNext())
aTrimmedStringList.append(anIter.next().trimmed());
- myTextMapper->SetInput(aTrimmedStringList.join("\n").toLatin1().constData());
+ myTextActor->SetInput(toUtf8(aTrimmedStringList.join("\n")).c_str());
Modified();
}
//==================================================================
char* VTKViewer_FramedTextActor::GetText()
{
- return myTextMapper->GetInput();
+ return myTextActor->GetInput();
}
//==================================================================
int VTKViewer_FramedTextActor::RenderOverlay(vtkViewport *viewport)
{
int renderedSomething = 0;
- myBarActor->RenderOverlay(viewport);
renderedSomething +=myTextActor->RenderOverlay(viewport);
+ renderedSomething +=myBarActor->RenderOverlay(viewport);
return renderedSomething;
}
if(aViewPortWidth == 1 || aViewPortHeight == 1)
return anIsRenderedSomething;
- if(!myTextMapper->GetInput())
+ if(!myTextActor->GetInput())
return anIsRenderedSomething;
myBar->Initialize();
myBar->SetPolys(aPolys);
aPolys->Delete();
- int aTextSize[2];
- myTextMapper->GetSize(theViewport, aTextSize);
+ double aTextSize[2];
+ myTextActor->GetSize(theViewport, aTextSize);
int aBarWidth = aTextSize[0];
int aBarHeight = aTextSize[1];
y / (double)aViewPortHeight);
}
+
aPoints->SetPoint(0, xMin, yMax, 0.0);
aPoints->SetPoint(1, xMin, yMin, 0.0);
aPoints->SetPoint(2, xMax, yMax, 0.0);
myTextProperty->SetVerticalJustificationToCentered();
- myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty);
myBarActor ->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);
myTextActor->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);