X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKViewer%2FVTKViewer_FramedTextActor.cxx;h=efd2ae0c14acc423c25bc751e63673083e662116;hb=refs%2Fheads%2Fngr%2Fpython3_dev_pv5.4;hp=9f9b6dd485ccba5210a1544dd116afa18dd5cf05;hpb=034a705024b224972c148e1e3834c5ee38df184b;p=modules%2Fgui.git diff --git a/src/VTKViewer/VTKViewer_FramedTextActor.cxx b/src/VTKViewer/VTKViewer_FramedTextActor.cxx index 9f9b6dd48..efd2ae0c1 100644 --- a/src/VTKViewer/VTKViewer_FramedTextActor.cxx +++ b/src/VTKViewer/VTKViewer_FramedTextActor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -38,6 +38,30 @@ #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); @@ -64,12 +88,9 @@ VTKViewer_FramedTextActor::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); @@ -99,7 +120,6 @@ VTKViewer_FramedTextActor::VTKViewer_FramedTextActor() VTKViewer_FramedTextActor::~VTKViewer_FramedTextActor() { myTextActor->Delete(); - myTextMapper->Delete(); myTextProperty->Delete(); myBarActor->Delete(); myBarMapper->Delete(); @@ -148,9 +168,9 @@ int VTKViewer_FramedTextActor::GetPickable() // 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; } @@ -164,7 +184,7 @@ void VTKViewer_FramedTextActor::SetForegroundColor(const double r, const double b) { myTextProperty->SetColor(r, g, b); - myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty); + myTextActor->GetTextProperty()->ShallowCopy(myTextProperty); Modified(); } @@ -257,7 +277,7 @@ int VTKViewer_FramedTextActor::GetTextMargin() const // 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]; @@ -272,7 +292,7 @@ void VTKViewer_FramedTextActor::SetText(const char* theText) { // 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"); @@ -280,7 +300,7 @@ void VTKViewer_FramedTextActor::SetText(const char* theText) while(anIter.hasNext()) aTrimmedStringList.append(anIter.next().trimmed()); - myTextMapper->SetInput(aTrimmedStringList.join("\n").toLatin1().constData()); + myTextActor->SetInput(toUtf8(aTrimmedStringList.join("\n")).c_str()); Modified(); } @@ -290,7 +310,7 @@ void VTKViewer_FramedTextActor::SetText(const char* theText) //================================================================== char* VTKViewer_FramedTextActor::GetText() { - return myTextMapper->GetInput(); + return myTextActor->GetInput(); } //================================================================== @@ -410,8 +430,8 @@ void VTKViewer_FramedTextActor::ReleaseGraphicsResources(vtkWindow *win) int VTKViewer_FramedTextActor::RenderOverlay(vtkViewport *viewport) { int renderedSomething = 0; - myBarActor->RenderOverlay(viewport); renderedSomething +=myTextActor->RenderOverlay(viewport); + renderedSomething +=myBarActor->RenderOverlay(viewport); return renderedSomething; } @@ -431,7 +451,7 @@ VTKViewer_FramedTextActor if(aViewPortWidth == 1 || aViewPortHeight == 1) return anIsRenderedSomething; - if(!myTextMapper->GetInput()) + if(!myTextActor->GetInput()) return anIsRenderedSomething; myBar->Initialize(); @@ -449,8 +469,8 @@ VTKViewer_FramedTextActor 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]; @@ -511,6 +531,7 @@ VTKViewer_FramedTextActor y / (double)aViewPortHeight); } + aPoints->SetPoint(0, xMin, yMax, 0.0); aPoints->SetPoint(1, xMin, yMin, 0.0); aPoints->SetPoint(2, xMax, yMax, 0.0); @@ -518,7 +539,6 @@ VTKViewer_FramedTextActor myTextProperty->SetVerticalJustificationToCentered(); - myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty); myBarActor ->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate); myTextActor->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);