Salome HOME
Merge branch 'occ/shaper2smesh'
[modules/gui.git] / src / GLViewer / GLViewer_Viewer2d.cxx
index d801cb6425c65a1d3e9bba79a482e0cc953fa6a9..9438c066c4da1fb49b4b57d9f350a321276feaeb 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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.
+// 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.
 //
-//  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 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.
 //
-//  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
+// 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
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  Author : OPEN CASCADE
 // File:      GLViewer_Viewer2d.cxx
 // Created:   November, 2004
@@ -103,7 +104,7 @@ void GLViewer_Viewer2d::onChangeBgColor()
     return;
   GLViewer_ViewPort2d* vp = ( ( GLViewer_ViewPort2d* )getActiveView()->getViewPort() );
 
-  QColor selColor = QColorDialog::getColor( vp->backgroundColor(), vp );       
+  QColor selColor = QColorDialog::getColor( vp->backgroundColor(), vp );        
   if ( selColor.isValid() ) {
     vp->setBackgroundColor( selColor );
   }
@@ -136,7 +137,7 @@ void GLViewer_Viewer2d::updateColors( QColor colorH, QColor colorS )
     */
 
 
-  activateAllDrawers( TRUE );
+  activateAllDrawers( true );
 }
 
 /*!
@@ -667,7 +668,7 @@ void GLViewer_Viewer2d::insertHeader( VectorFileType aType, QFile& hFile )
         header += "%%Pages: 1\n";
         header += "%%Page: 1\n\n";
         
-        hFile.write( header.toAscii() );
+        hFile.write( header.toLatin1() );
     }
     else if( aType == HPGL )
     {
@@ -681,7 +682,7 @@ void GLViewer_Viewer2d::insertHeader( VectorFileType aType, QFile& hFile )
         header += "LT;\n";
         header += "VS36;\n";
         
-        hFile.write( header.toAscii() );
+        hFile.write( header.toLatin1() );
     }
 }
 
@@ -695,12 +696,12 @@ void GLViewer_Viewer2d::insertEnding( VectorFileType aType, QFile& hFile )
     if( aType == POST_SCRIPT )
     {
         QString ending = "showpage\n\n%%EOF";
-        hFile.write( ending.toAscii() );
+        hFile.write( ending.toLatin1() );
     }
     else if( aType == HPGL )
     {
         QString ending = "PU;PA0,0;SP;EC;PG1;EC1;OE\n"; 
-        hFile.write( ending.toAscii() );
+        hFile.write( ending.toLatin1() );
     }
 }
 
@@ -730,7 +731,7 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap
     if ( !getActiveView() )
       return false;
 
-        QFile hFile( FileName.toAscii() );
+        QFile hFile( FileName.toUtf8() );
 
 #ifdef WIN32
     HDC hMetaFileDC;
@@ -792,7 +793,20 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap
         HDC screen_dc = GetDC( 0 ); //The screen device context
         HDC bitDC = CreateCompatibleDC ( screen_dc ); //The context compatible with screen
 
-        hMetaFileDC = CreateEnhMetaFile( bitDC, FileName.toAscii(), &r, "" );
+#ifdef UNICODE
+       LPTSTR str = new TCHAR[FileName.length() + 1];
+       str[FileName.toWCharArray(str)] = '\0';
+       LPTSTR empty = L"";
+#else  
+       QByteArray arr = FileName.toLatin1();
+       LPTSTR str = arr.constData();
+       LPTSTR empty = "";
+#endif
+
+        hMetaFileDC = CreateEnhMetaFile( bitDC, str, &r, empty );
+#ifdef UNICODE
+       delete str;
+#endif 
         SetMapMode( hMetaFileDC, MM_HIMETRIC );
         SetWindowOrgEx( hMetaFileDC, 0, r.bottom, NULL );
         HRGN ClipRgn = CreateRectRgn( 0, 0, AW, AH );
@@ -807,7 +821,7 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap
         ReleaseDC( 0, screen_dc );
         DeleteDC( bitDC );
 
-        aCurVP->getGLWidget()->translateBackgroundToEMF( hMetaFileDC, &aViewerCS, &aPaperCS );
+        aCurVP->getGLWidget()->translateBackgroundToEMF( hMetaFileDC, &aViewerCS, &aPaperCS ); 
     }
 #endif
 
@@ -818,7 +832,7 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap
                                arg( AW-mmLeft-mmRight ).arg( AH-mmBottom-mmTop );
         //It is set clipping path
 
-        hFile.write( aBuffer.toAscii() );
+        hFile.write( aBuffer.toLatin1() );
 
         aCurVP->getGLWidget()->translateBackgroundToPS( hFile, &aViewerCS, &aPaperCS );
     }