Salome HOME
Unicode support: correct handling of unicode on GUI level
[modules/gui.git] / src / GLViewer / GLViewer_Object.cxx
index e5e3baa0518de9ba80878e6674de51225b6c37b5..fa54128d72b893d4bfc7bc77c445d94b40d9d0f7 100644 (file)
@@ -1,34 +1,32 @@
-//  Copyright (C) 2005 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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  Author : OPEN CASCADE
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-//#include <GLViewerAfx.h>
 #include "GLViewer_Object.h"
 #include "GLViewer_Drawer.h"
 #include "GLViewer_AspectLine.h"
-#include "GLViewer_Geom.h"
 #include "GLViewer_Text.h"
 #include "GLViewer_Group.h"
 
-//#include <cmath>
-//using namespace std;
+#include <SUIT_DataOwner.h>
 
 /*!
   Default constructor
@@ -141,8 +139,8 @@ QByteArray GLViewer_Object::getByteCopy()
     int i = 0;
     int anISize = sizeof( int );
 
-    const char* aTypeStr = myType.data();
-    const char* aToolTipStr = myToolTipText.data();
+    const char* aTypeStr = myType.toLatin1().constData();
+    const char* aToolTipStr = myToolTipText.toUtf8().constData();
 
     int aTypeLength = myType.length();
     int aToolTipLength = myToolTipText.length();
@@ -163,9 +161,10 @@ QByteArray GLViewer_Object::getByteCopy()
     
     int sizeOf8Float = sizeof( aRectData );
 
-    QByteArray aResult( 2*anISize + sizeOf8Float + 
-                        aTypeLength + aToolTipLength +
-                        aGLText.size() + aAspect.size() );
+    QByteArray aResult;
+    aResult.resize( 2*anISize + sizeOf8Float + 
+                    aTypeLength + aToolTipLength +
+                    aGLText.size() + aAspect.size() );
     // puts 8 float values into the byte array
     char* aPointer = (char*)&aRectData;
     for( i = 0; i < sizeOf8Float; i++, aPointer++ )
@@ -187,17 +186,17 @@ QByteArray GLViewer_Object::getByteCopy()
 
     int aCurPos = 2*anISize + sizeOf8Float + aTypeLength + aToolTipLength;
     // adds aspect byte array
-    for( i = aCurPos; i < aCurPos + aAspect.size(); i++ )
+    for ( i = aCurPos; i < (int)( aCurPos + aAspect.size() ); i++ )
         aResult[i] = aAspect[i - aCurPos];
 
     aCurPos = aCurPos + aAspect.size();
     // adds GL text byte array
-    for( i = aCurPos; i < aCurPos + aGLText.size(); i++ )
+    for ( i = aCurPos; i < (int)( aCurPos + aGLText.size() ); i++ )
         aResult[i] = aGLText[i - aCurPos];    
 
     aCurPos += aGLText.size();
     aPointer = (char*)&myOwner;
-    for( i = 0; i < sizeof( GLViewer_Owner* ); i++, aPointer++ )
+    for( i = 0; i < sizeof( SUIT_DataOwner* ); i++, aPointer++ )
         aResult[ aCurPos + i ] = *aPointer;
 
     return aResult;
@@ -225,7 +224,9 @@ bool GLViewer_Object::initializeFromByteCopy( QByteArray theArray )
     GLViewer_AspectLine* aAspectLine = new GLViewer_AspectLine();
     int aGLAspLineSize = (aAspectLine->getByteCopy()).size();
 
-    QByteArray aGLTextArray, aAspect( aGLAspLineSize );
+    QByteArray aGLTextArray, aAspect;
+    aGLTextArray.resize( aGLAspLineSize );
+    aAspect.resize( aGLAspLineSize );
 
     if( aSize < 2*anISize + 8*aFSize + aGLTextMinSize + aGLAspLineSize )
         return false;