Salome HOME
patch on the shape to support correctly the border color
authorasl <asl@opencascade.com>
Tue, 17 Nov 2015 07:32:16 +0000 (10:32 +0300)
committerasl <asl@opencascade.com>
Tue, 17 Nov 2015 07:32:51 +0000 (10:32 +0300)
12 files changed:
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_AISShape.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_AISShape.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/ExternalFiles.cmake
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/reference_data/Shape_preview_im_zone.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROGUI_Shape.cxx [new file with mode: 0644]
src/HYDRO_tests/test_HYDROGUI_Shape.h [new file with mode: 0644]

index 40a5fe2f524397395f184791a078e1ec6a11d5e3..08c7da1f49831e3a5be51074e62df823be7deee4 100644 (file)
@@ -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 (file)
index 0000000..162e44c
--- /dev/null
@@ -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 <HYDROGUI_AISShape.h>
+#include <AIS_DisplayMode.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
+
+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 (file)
index 0000000..7353dcb
--- /dev/null
@@ -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 <AIS_Shape.hxx>
+
+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
index 1feb96abd543ce574ea68ea8494ab18cc06b0502..133873a9189fd2aa1e3dcabcf38361f86d46e435 100644 (file)
@@ -19,6 +19,7 @@
 #include <HYDROGUI_Shape.h>
 #include <HYDROGUI_Tool.h>
 #include <HYDROGUI_Polyline.h>
+#include <HYDROGUI_AISShape.h>
 
 #include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Zone.h>
 #include <HYDROData_LandCoverMap.h>
 
-#include <AIS_Shape.hxx>
 #include <BRep_Builder.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
 #include <Prs3d_IsoAspect.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
@@ -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 )
     {
index 4ea4039edd77b2fec67829cf454ccb8205fad0db..24563aa1fdbf8198da965150ddacea87da4921e6 100644 (file)
 
 #include <Image_PixMap.hxx>
 
+#ifndef LIGHT_MODE
 // IDL includes
 #include <SALOMEconfig.h>
 #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<GEOM::shape_type> theTypes );
+#endif
 
   /**
    * \brief Delete the GEOM objects.
index 167285a9af7792c73996734f3b7a67d797a8a323..4762aafb443efcb21e33a14e25853f9d45b0e97d 100644 (file)
@@ -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
index 7ccb5c2661fec8db99807a35ca53e797de636b3e..9c245ce2294ae6909c6d3ece6393673fa831a2ec 100644 (file)
@@ -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
 )
index 70dbd6fa029fde4c157ff10eb897bccce48dd3af..52917a31a07c023cd60eae54b1c830e4956ed48d 100644 (file)
@@ -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)
index d33885b0ce00d0d5d2d6cca9edd5c8bb9d8eb9b8..9030f33b80e0ee44d3f2c6921ba4d0056ebd2559 100644 (file)
@@ -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 (file)
index 0000000..fd1d123
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 (file)
index 0000000..e99db41
--- /dev/null
@@ -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 <test_HYDROGUI_Shape.h>
+#include <HYDROGUI_Shape.h>
+#include <TestShape.h>
+#include <TestViewer.h>
+#include <TopoDS_Face.hxx>
+
+void test_HYDROGUI_Shape::test_face_in_preview()
+{
+  TopoDS_Face aFace = Face( QList<double>() << 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 (file)
index 0000000..a4d2942
--- /dev/null
@@ -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 <cppunit/extensions/HelperMacros.h>
+
+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");