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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include <AIS_InteractiveContext.hxx>
22 #include <Standard_Version.hxx>
24 class OCCViewer_ViewManager;
25 class OCCViewer_Viewer;
26 class OCCViewer_ViewFrame;
31 class AIS_InteractiveObject;
34 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
35 #if OCC_VERSION_LARGE >= 0x07020000
36 const bool SWAP_RGB = false;
38 const bool SWAP_RGB = true;
44 static OCCViewer_ViewManager* viewManager();
45 static OCCViewer_Viewer* viewer();
46 static OCCViewer_ViewFrame* viewWindow();
47 static Handle(AIS_InteractiveContext) context();
49 static void eraseAll( bool isUpdate, bool eraseStructures = false );
50 static void show( const Handle(AIS_InteractiveObject)& theObject,
51 int theMode, int theSelectionMode, bool isFitAll, const char* theKey );
52 static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor,
53 int theUIANb = 10, int theVIANb = 10);
54 static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey,
55 int theUIANb = 10, int theVIANb = 10);
56 static bool AssertImages( QString& theMessage, const QImage* = 0, const char* theCase = 0, bool swapRGB = SWAP_RGB );
57 static QColor GetColor(int i);
59 static Handle(AIS_ColorScale) colorScale();
60 static void showColorScale( bool );
61 static bool ColorScaleIsDisplayed();
63 static void select( int theViewX, int theViewY );
65 static bool areScriptsEqual( const QString& theBaseName,
71 static void setKey( const QString& );
73 static QImage diff( const QImage& im1, const QImage& im2 );
76 static OCCViewer_ViewManager* myViewManager;
77 static OCCViewer_ViewFrame* myViewWindow;
81 #define CPPUNIT_ASSERT_IMAGES \
84 if( !TestViewer::AssertImages( aMessage ) ) \
86 TestViewer::showColorScale( false ); \
87 std::string aMessageStl = aMessage.toStdString(); \
88 CPPUNIT_FAIL( aMessageStl.c_str() ); \
92 #define CPPUNIT_ASSERT_IMAGES2( theImage, theCase ) \
95 if( !TestViewer::AssertImages( aMessage, theImage, theCase ) ) \
97 TestViewer::showColorScale( false ); \
98 std::string aMessageStl = aMessage.toStdString(); \
99 CPPUNIT_FAIL( aMessageStl.c_str() ); \
103 #define CPPUNIT_ASSERT_IMAGES3( theImage, theCase, theSwapRGB ) \
106 if( !TestViewer::AssertImages( aMessage, theImage, theCase, theSwapRGB ) ) \
108 TestViewer::showColorScale( false ); \
109 std::string aMessageStl = aMessage.toStdString(); \
110 CPPUNIT_FAIL( aMessageStl.c_str() ); \
114 #define CPPUNIT_ASSERT_SCRIPTS_EQUAL( theBaseName, \
120 if( !TestViewer::areScriptsEqual( \
121 theBaseName, isExpectedUtf8, \
122 isActualUtf8, theLinesToOmit, aMsg ) ) \
124 std::string aStlMsg = "Scripts are not equal: " + \
125 aMsg.toStdString(); \
126 CPPUNIT_FAIL( aStlMsg ); \