]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Support of the UTF-8 encoding.
authorrnv <rnv@opencascade.com>
Mon, 23 Jun 2014 06:44:13 +0000 (10:44 +0400)
committerrnv <rnv@opencascade.com>
Mon, 23 Jun 2014 06:44:13 +0000 (10:44 +0400)
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/VTKViewer/VTKViewer_FramedTextActor.cxx
src/VTKViewer/VTKViewer_FramedTextActor.h
src/VTKViewer/VTKViewer_PolyDataMapper.cxx

index 3f4383692dffb3cdce47aefeeb5f1aeee6fbff3f..20fafbeae10a3b3b7f4a144926496d6c871dcb29 100644 (file)
@@ -924,7 +924,7 @@ SALOME_Actor
 */
 void
 SALOME_Actor
-::SetNameActorOffset(int theOffset[2])
+::SetNameActorOffset(double theOffset[2])
 {
   myNameActor->SetOffset(theOffset);
 }
@@ -936,7 +936,7 @@ SALOME_Actor
 */
 void
 SALOME_Actor
-::GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const
+::GetNameActorSize(vtkRenderer* theRenderer, double theSize[2]) const
 {
   myNameActor->GetSize(theRenderer, theSize);
 }
@@ -950,7 +950,7 @@ SALOME_Actor
 {
   if( vtkRenderer* aRenderer = GetRenderer() )
   {
-    int anOffset[2] = { 0, 0 };
+    double anOffset[2] = { 0, 0 };
     VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
     vtkActorCollection* aCollection = aCopy.GetActors();
     for( int anIndex = 0, aNbItems = aCollection->GetNumberOfItems(); anIndex < aNbItems; anIndex++ )
@@ -962,7 +962,7 @@ SALOME_Actor
           anActor->SetNameActorOffset( anOffset );
           if( anActor->GetVisibility() )
           {
-            int aSize[2];
+            double aSize[2];
             anActor->GetNameActorSize( aRenderer, aSize );
             anOffset[0] = anOffset[0] + aSize[0];
             anOffset[1] = anOffset[1] + aSize[1];
index 57340054983f8e99877d5c141425a4da76af35e9..bac5d9ae5ccee4d98e5b7aeb8957d0eb58b28dbb 100644 (file)
@@ -202,12 +202,12 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   //! To set offset of name actor
   virtual
   void
-  SetNameActorOffset(int theOffset[2]);
+  SetNameActorOffset(double theOffset[2]);
 
   //! To get size of name actor
   virtual
   void
-  GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const;
+  GetNameActorSize(vtkRenderer* theRenderer, double theSize[2]) const;
 
   //! To update visibility of name actors
   virtual
index 9f9b6dd485ccba5210a1544dd116afa18dd5cf05..3de2711f132fc6dafbcc4a588d52f31457de9589 100644 (file)
@@ -64,12 +64,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 +96,6 @@ VTKViewer_FramedTextActor::VTKViewer_FramedTextActor()
 VTKViewer_FramedTextActor::~VTKViewer_FramedTextActor()
 {
   myTextActor->Delete();
-  myTextMapper->Delete();
   myTextProperty->Delete();
   myBarActor->Delete();
   myBarMapper->Delete();
@@ -148,9 +144,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 +160,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 +253,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 +268,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(QString::fromUtf8(theText));
 
   QStringList aTrimmedStringList;
   QStringList aStringList = aString.split("\n");
@@ -280,7 +276,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(aTrimmedStringList.join("\n").toUtf8().constData());
   Modified();
 }
 
@@ -290,7 +286,7 @@ void VTKViewer_FramedTextActor::SetText(const char* theText)
 //==================================================================
 char* VTKViewer_FramedTextActor::GetText()
 {
-  return myTextMapper->GetInput();
+  return myTextActor->GetInput();
 }
 
 //==================================================================
@@ -410,8 +406,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 +427,7 @@ VTKViewer_FramedTextActor
   if(aViewPortWidth == 1 || aViewPortHeight == 1)
     return anIsRenderedSomething;
 
-  if(!myTextMapper->GetInput())
+  if(!myTextActor->GetInput())
     return anIsRenderedSomething;
 
   myBar->Initialize();
@@ -449,8 +445,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 +507,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 +515,6 @@ VTKViewer_FramedTextActor
 
   myTextProperty->SetVerticalJustificationToCentered();
 
-  myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty);
   myBarActor ->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);
   myTextActor->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);
 
index 5c4ed01f5edb4ecfc861555e96f622b58cb230f5..78873a86ee301d0e36a53ffb69d3426164c47522 100644 (file)
@@ -32,6 +32,7 @@ class vtkTextMapper;
 class vtkTextProperty;
 class vtkViewport;
 class vtkWindow;
+class vtkTextActor;
 
 class VTKVIEWER_EXPORT VTKViewer_FramedTextActor : public vtkActor2D
 {
@@ -53,7 +54,7 @@ public:
   virtual void                SetPickable(int);
   virtual int                 GetPickable();
 
-  virtual void                GetSize(vtkRenderer* theRenderer, int theSize[2]) const;
+  virtual void                GetSize(vtkRenderer* vport, double theSize[2]) const;
 
   void                        SetText(const char* theText);
   char*                       GetText();
@@ -93,7 +94,7 @@ public:
   void                        SetTextMargin(const int theMargin);
   int                         GetTextMargin() const;
 
-  void                        SetOffset(const int theOffset[2]);
+  void                        SetOffset(const double theOffset[2]);
 
 protected:
   VTKViewer_FramedTextActor();
@@ -105,8 +106,7 @@ protected:
   vtkActor2D*                 myBarActor;
 
   vtkTextProperty*            myTextProperty;
-  vtkTextMapper*              myTextMapper;
-  vtkActor2D*                 myTextActor;
+  vtkTextActor*               myTextActor;
 
   vtkTimeStamp                myBuildTime;
 
index 0f1f19587d18142b2e2b8dd4e85b431454515d0a..91cc9207403e3df0f7c4e4e544ef167c640f7dad 100644 (file)
@@ -522,9 +522,15 @@ void VTKViewer_PolyDataMapper::InitTextures()
   if( !this->ImageData.GetPointer() )
     return;
 
+  glEnable( GL_TEXTURE_2D );
+  if( this->PointSpriteTexture == 0 ) {
+    glGenTextures( 1, &this->PointSpriteTexture );
+  }
+  glBindTexture( GL_TEXTURE_2D, this->PointSpriteTexture );
+  glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
-
+  
   if(this->BallEnabled) {
     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@@ -537,11 +543,6 @@ void VTKViewer_PolyDataMapper::InitTextures()
   unsigned char* dataPtr = (unsigned char*)this->ImageData->GetScalarPointer();
   glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, aSize[0], aSize[1], 0,
                 GL_RGBA, GL_UNSIGNED_BYTE, dataPtr );
-
-  //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-  glEnable( GL_TEXTURE_2D );
-  glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
-  glBindTexture( GL_TEXTURE_2D, this->PointSpriteTexture );
 }
 
 //-----------------------------------------------------------------------------
@@ -561,6 +562,7 @@ void VTKViewer_PolyDataMapper::RenderPiece( vtkRenderer* ren, vtkActor* act )
     MAPPER_SUPERCLASS::RenderPiece( ren, act );
     if( isUsePointSprites )
       this->CleanupPointSprites();
+    glBindTexture( GL_TEXTURE_2D, 0 );
   } else {
     vtkIdType numPts;
     vtkPolyData *input= this->GetInput();
@@ -670,8 +672,8 @@ void VTKViewer_PolyDataMapper::RenderPiece( vtkRenderer* ren, vtkActor* act )
       this->TimeToDraw = 0.0001;
 
     vglUseProgramObjectARB( 0 );
-
     this->CleanupPointSprites();
+    glBindTexture( GL_TEXTURE_2D, 0 );
   }  
 }