From: asl Date: Tue, 17 Nov 2015 07:32:16 +0000 (+0300) Subject: patch on the shape to support correctly the border color X-Git-Tag: v1.5~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9befc66f671bd8035cd0127f54e1b3e631d1c1d2;p=modules%2Fhydro.git patch on the shape to support correctly the border color --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 40a5fe2f..08c7da1f 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -4,6 +4,7 @@ include(../../CMake/UseQT4EXT.cmake) set(PROJECT_HEADERS HYDROGUI.h HYDROGUI_AbstractDisplayer.h + HYDROGUI_AISShape.h HYDROGUI_AISTrihedron.h HYDROGUI_BathymetryPrs.h HYDROGUI_CalculationDlg.h @@ -146,6 +147,7 @@ QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) set(PROJECT_SOURCES HYDROGUI_AbstractDisplayer.cxx + HYDROGUI_AISShape.cxx HYDROGUI_AISTrihedron.cxx HYDROGUI_BathymetryPrs.cxx HYDROGUI_CalculationDlg.cxx diff --git a/src/HYDROGUI/HYDROGUI_AISShape.cxx b/src/HYDROGUI/HYDROGUI_AISShape.cxx new file mode 100644 index 00000000..162e44cd --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_AISShape.cxx @@ -0,0 +1,74 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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. +// +// 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 +// + +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE(HYDROGUI_AISShape, AIS_Shape) +IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_AISShape, AIS_Shape) + +HYDROGUI_AISShape::HYDROGUI_AISShape( const TopoDS_Shape& theShape ) + : AIS_Shape( theShape ), + myBorderColor( Quantity_NOC_BLACK ) +{ +} + +HYDROGUI_AISShape::~HYDROGUI_AISShape() +{ +} + +Quantity_Color HYDROGUI_AISShape::GetBorderColor() const +{ + return myBorderColor; +} + +void HYDROGUI_AISShape::SetBorderColor( const Quantity_Color& theBorderColor ) +{ + myBorderColor = theBorderColor; + Redisplay( Standard_True ); +} + +void HYDROGUI_AISShape::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode ) +{ + thePresentation->Clear(); + + myDrawer->FaceBoundaryAspect()->SetColor( myBorderColor ); + myDrawer->FreeBoundaryAspect()->SetColor( myBorderColor ); + myDrawer->UnFreeBoundaryAspect()->SetColor( myBorderColor ); + myDrawer->LineAspect()->SetColor( myBorderColor ); + myDrawer->SeenLineAspect()->SetColor( myBorderColor ); + myDrawer->WireAspect()->SetColor( myBorderColor ); + myDrawer->UIsoAspect()->SetColor( myBorderColor ); + myDrawer->VIsoAspect()->SetColor( myBorderColor ); + + switch( theMode ) + { + case AIS_WireFrame: + case AIS_Shaded: + AIS_Shape::Compute( thePresentationManager, thePresentation, theMode ); + break; + } + + if( theMode==AIS_Shaded ) + StdPrs_WFDeflectionShape::Add( thePresentation, Shape(), myDrawer ); +} diff --git a/src/HYDROGUI/HYDROGUI_AISShape.h b/src/HYDROGUI/HYDROGUI_AISShape.h new file mode 100644 index 00000000..7353dcb5 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_AISShape.h @@ -0,0 +1,46 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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. +// +// 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 +// + + +#ifndef HYDROGUI_AISSHAPE_H +#define HYDROGUI_AISSHAPE_H + +#include + +DEFINE_STANDARD_HANDLE(HYDROGUI_AISShape, AIS_Shape) + +class HYDROGUI_AISShape : public AIS_Shape +{ +public: + DEFINE_STANDARD_RTTI(HYDROGUI_AISShape); + + HYDROGUI_AISShape( const TopoDS_Shape& ); + virtual ~HYDROGUI_AISShape(); + + Quantity_Color GetBorderColor() const; + void SetBorderColor( const Quantity_Color& theBorderColor ); + + virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode ); + +private: + Quantity_Color myBorderColor; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 1feb96ab..133873a9 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -33,10 +34,8 @@ #include #include -#include #include #include -#include #include #include #include @@ -500,7 +499,7 @@ Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) { return new HYDROGUI_Polyline( myTopoShape ); } else { - return new AIS_Shape( myTopoShape ); + return new HYDROGUI_AISShape( myTopoShape ); } } @@ -577,7 +576,7 @@ void HYDROGUI_Shape::updateShape( const bool theToDisplay, } // Coloring borders - colorShapeBorder( getActiveColor() ); + colorShapeBorder( myBorderColor ); } if ( !theToDisplay || !isVisible() || myContext.IsNull() ) @@ -658,27 +657,9 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor ) } else if ( myDisplayMode == AIS_Shaded ) { - if ( theColor.alpha() == 0 ) - { - anAttributes->SetFaceBoundaryDraw( false ); - } - else - { - anAttributes->SetFaceBoundaryDraw( true ); - - Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect(); - if ( !aBoundaryAspect.IsNull() ) - { - aBoundaryAspect->SetColor( aBorderColor ); - anAttributes->SetFaceBoundaryAspect( aBoundaryAspect ); - } - Handle(Prs3d_LineAspect) aWireAspect = anAttributes->WireAspect(); - if ( !aWireAspect.IsNull() ) - { - aWireAspect->SetColor( aBorderColor ); - anAttributes->SetWireAspect( aWireAspect ); - } - } + Handle(HYDROGUI_AISShape) aShape = Handle(HYDROGUI_AISShape)::DownCast( myShape ); + if( !aShape.IsNull() ) + aShape->SetBorderColor( aBorderColor ); } else if ( myDisplayMode == AIS_WireFrame ) { diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index 4ea4039e..24563aa1 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -31,9 +31,11 @@ #include +#ifndef LIGHT_MODE // IDL includes #include #include CORBA_SERVER_HEADER(GEOM_Gen) +#endif class SUIT_ViewManager; class OCCViewer_ViewFrame; @@ -341,6 +343,7 @@ public: */ static Handle(Image_PixMap) Pixmap( const QImage& theImage ); +#ifndef LIGHT_MODE /** * \brief Get the selected GEOM objects. * \param theModule the module @@ -349,6 +352,7 @@ public: */ static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule, QList theTypes ); +#endif /** * \brief Delete the GEOM objects. diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 167285a9..4762aafb 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -15,6 +15,7 @@ set(PROJECT_HEADERS test_HYDROData_ShapeFile.h test_HYDROData_StricklerTable.h test_HYDROGUI_ListModel.h + test_HYDROGUI_Shape.h test_Dependencies.h TestShape.h @@ -38,6 +39,7 @@ set(PROJECT_SOURCES test_HYDROData_ShapeFile.cxx test_HYDROData_StricklerTable.cxx test_HYDROGUI_ListModel.cxx + test_HYDROGUI_Shape.cxx test_Dependencies.cxx TestShape.cxx diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index 7ccb5c26..9c245ce2 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -57,4 +57,6 @@ set( EXTERNAL_FILES ../HYDROGUI/HYDROGUI_DataObject.cxx ../HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx ../HYDROGUI/HYDROGUI_Polyline.cxx + ../HYDROGUI/HYDROGUI_AISShape.cxx + ../HYDROGUI/HYDROGUI_Shape.cxx ) diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index 70dbd6fa..52917a31 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -84,9 +84,9 @@ OCCViewer_ViewWindow* TestViewer::viewWindow() return myViewWindow; } -Handle(AIS_InteractiveContext) context() +Handle(AIS_InteractiveContext) TestViewer::context() { - return TestViewer::viewer()->getAISContext(); + return viewer()->getAISContext(); } QColor TestViewer::GetColor(int i) diff --git a/src/HYDRO_tests/TestViewer.h b/src/HYDRO_tests/TestViewer.h index d33885b0..9030f33b 100644 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@ -24,6 +24,7 @@ class OCCViewer_ViewWindow; class TopoDS_Shape; class QString; class QColor; +class Handle_AIS_InteractiveContext; class Handle_AIS_InteractiveObject; class Handle_Aspect_ColorScale; @@ -33,6 +34,7 @@ public: static OCCViewer_ViewManager* viewManager(); static OCCViewer_Viewer* viewer(); static OCCViewer_ViewWindow* viewWindow(); + static Handle_AIS_InteractiveContext context(); static void eraseAll( bool isUpdate ); static void show( const Handle_AIS_InteractiveObject& theObject, diff --git a/src/HYDRO_tests/reference_data/Shape_preview_im_zone.png b/src/HYDRO_tests/reference_data/Shape_preview_im_zone.png new file mode 100644 index 00000000..fd1d1233 Binary files /dev/null and b/src/HYDRO_tests/reference_data/Shape_preview_im_zone.png differ diff --git a/src/HYDRO_tests/test_HYDROGUI_Shape.cxx b/src/HYDRO_tests/test_HYDROGUI_Shape.cxx new file mode 100644 index 00000000..e99db415 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROGUI_Shape.cxx @@ -0,0 +1,46 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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. +// +// 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 +// + +#undef HYDROGUI_EXPORTS + +#include +#include +#include +#include +#include + +void test_HYDROGUI_Shape::test_face_in_preview() +{ + TopoDS_Face aFace = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << + 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << + 31 << 114 ); + + Handle_AIS_InteractiveContext aContext = TestViewer::context(); + Handle_HYDROData_Entity anEntity; //it should be null as in preview + + HYDROGUI_Shape* aPreview = new HYDROGUI_Shape( aContext, anEntity ); + aPreview->setFace( aFace, true, true, "" ); + aPreview->setFillingColor( Qt::red, false, false ); + aPreview->setBorderColor( Qt::darkBlue, false, false ); + + TestViewer::show( aPreview->getAISObject(), AIS_Shaded, 0, true, "Shape_preview_im_zone" ); + CPPUNIT_ASSERT_IMAGES + + delete aPreview; +} diff --git a/src/HYDRO_tests/test_HYDROGUI_Shape.h b/src/HYDRO_tests/test_HYDROGUI_Shape.h new file mode 100644 index 00000000..a4d2942d --- /dev/null +++ b/src/HYDRO_tests/test_HYDROGUI_Shape.h @@ -0,0 +1,32 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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. +// +// 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 +// + +#include + +class test_HYDROGUI_Shape : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(test_HYDROGUI_Shape); + CPPUNIT_TEST(test_face_in_preview); + CPPUNIT_TEST_SUITE_END(); + +public: + void test_face_in_preview(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_Shape); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_Shape, "HYDROGUI_Shape");