Salome HOME
de076a1e38a402afceacd286beb611782fac38c4
[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 #include <AIS_InteractiveContext.hxx>
22
23 class OCCViewer_ViewManager;
24 class OCCViewer_Viewer;
25 class OCCViewer_ViewWindow;
26 class TopoDS_Shape;
27 class QString;
28 class QColor;
29 class AIS_InteractiveObject;
30 class AIS_ColorScale;
31
32 class TestViewer
33 {
34 public:
35   static OCCViewer_ViewManager* viewManager();
36   static OCCViewer_Viewer* viewer();
37   static OCCViewer_ViewWindow* viewWindow();
38   static Handle(AIS_InteractiveContext) context();
39
40   static void eraseAll( bool isUpdate );
41   static void show( const Handle(AIS_InteractiveObject)& theObject,
42                     int theMode, int theSelectionMode, bool isFitAll, const char* theKey );
43   static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor );
44   static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey );
45   static bool AssertImages( QString& theMessage );
46   static QColor GetColor(int i);
47
48   static Handle(AIS_ColorScale) colorScale();
49   static void showColorScale( bool );
50
51   static void select( int theViewX, int theViewY );
52
53   static bool areScriptsEqual( const QString& theBaseName,
54                                bool isExpectedUtf8,
55                                bool isActualUtf8,
56                                int theLinesToOmit,
57                                QString& theMsg );
58
59 private:
60   static OCCViewer_ViewManager* myViewManager;
61   static OCCViewer_ViewWindow* myViewWindow;
62   static QString myKey;
63 };
64
65 #define CPPUNIT_ASSERT_IMAGES                              \
66   {                                                        \
67     QString aMessage;                                      \
68     if( !TestViewer::AssertImages( aMessage ) )            \
69     {                                                      \
70       TestViewer::showColorScale( false );                 \
71       std::string aMessageStl = aMessage.toStdString();    \
72       CPPUNIT_FAIL( aMessageStl.c_str() );                 \
73     }                                                      \
74   }                                                        \
75
76 #define CPPUNIT_ASSERT_SCRIPTS_EQUAL( theBaseName,         \
77                                       isExpectedUtf8,      \
78                                       isActualUtf8,        \
79                                       theLinesToOmit )     \
80   {                                                        \
81     QString aMsg;                                          \
82     if( !TestViewer::areScriptsEqual(                      \
83           theBaseName, isExpectedUtf8,                     \
84           isActualUtf8, theLinesToOmit, aMsg ) )           \
85     {                                                      \
86       std::string aStlMsg = "Scripts are not equal: " +    \
87         aMsg.toStdString();                                \
88       CPPUNIT_FAIL( aStlMsg );                             \
89     }                                                      \
90   }                                                        \
91                                                            \
92