Salome HOME
merge BR_LAND_COVER_MAP
[modules/hydro.git] / src / HYDRO_tests / TestViewer.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #pragma once
20
21 class OCCViewer_ViewManager;
22 class OCCViewer_Viewer;
23 class OCCViewer_ViewWindow;
24 class TopoDS_Shape;
25 class QString;
26 class QColor;
27 class Handle_AIS_InteractiveContext;
28 class Handle_AIS_InteractiveObject;
29 class Handle_Aspect_ColorScale;
30
31 class TestViewer
32 {
33 public:
34   static OCCViewer_ViewManager* viewManager();
35   static OCCViewer_Viewer* viewer();
36   static OCCViewer_ViewWindow* viewWindow();
37   static Handle_AIS_InteractiveContext context();
38
39   static void eraseAll( bool isUpdate );
40   static void show( const Handle_AIS_InteractiveObject& theObject,
41                     int theMode, int theSelectionMode, bool isFitAll, const char* theKey );
42   static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor );
43   static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey );
44   static bool AssertImages( QString& theMessage );
45   static QColor GetColor(int i);
46
47   static Handle_Aspect_ColorScale colorScale();
48   static void showColorScale( bool );
49
50   static void select( int theViewX, int theViewY );
51
52   static bool areScriptsEqual( const QString& theBaseName,
53                                bool isExpectedUtf8,
54                                bool isActualUtf8,
55                                int theLinesToOmit,
56                                QString& theMsg );
57
58 private:
59   static OCCViewer_ViewManager* myViewManager;
60   static OCCViewer_ViewWindow* myViewWindow;
61   static QString myKey;
62 };
63
64 #define CPPUNIT_ASSERT_IMAGES                              \
65   {                                                        \
66     QString aMessage;                                      \
67     if( !TestViewer::AssertImages( aMessage ) )            \
68     {                                                      \
69       TestViewer::showColorScale( false );                 \
70       std::string aMessageStl = aMessage.toStdString();    \
71       CPPUNIT_FAIL( aMessageStl.c_str() );                 \
72     }                                                      \
73   }                                                        \
74
75 #define CPPUNIT_ASSERT_SCRIPTS_EQUAL( theBaseName,         \
76                                       isExpectedUtf8,      \
77                                       isActualUtf8,        \
78                                       theLinesToOmit )     \
79   {                                                        \
80     QString aMsg;                                          \
81     if( !TestViewer::areScriptsEqual(                      \
82           theBaseName, isExpectedUtf8,                     \
83           isActualUtf8, theLinesToOmit, aMsg ) )           \
84     {                                                      \
85       std::string aStlMsg = "Scripts are not equal: " +    \
86         aMsg.toStdString();                                \
87       CPPUNIT_FAIL( aStlMsg );                             \
88     }                                                      \
89   }                                                        \
90                                                            \
91