Salome HOME
#662: updated hilight/select presentations for land covers
authorasl <asl@opencascade.com>
Thu, 22 Oct 2015 06:48:17 +0000 (09:48 +0300)
committerasl <asl@opencascade.com>
Thu, 22 Oct 2015 06:48:17 +0000 (09:48 +0300)
src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
src/HYDROGUI/HYDROGUI_LandCoverMapPrs.h
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index 7a005c24d78239fa2239ed0aa267268c984cffd7..6f654a6d1888563bfb0dad24030c19489d644d02 100644 (file)
 #include <HYDROData_Tool.h>
 #include <AIS_DisplayMode.hxx>
 #include <Prs3d_IsoAspect.hxx>
+#include <SelectMgr_SequenceOfOwner.hxx>
 #include <StdPrs_WFDeflectionShape.hxx>
+#include <StdSelect_BRepOwner.hxx>
 #include <TopoDS_Face.hxx>
 #include <QColor>
 #include <QString>
 
+const Quantity_Color EDGES_COLOR = Quantity_NOC_WHITE;
+const int HILIGHT_ISO_NB = 10;
+
 IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
 IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
 
@@ -33,6 +38,8 @@ HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandC
   : AIS_ColoredShape( theMap->GetShape() )
 {
   SetLandCoverMap( theMap );
+  SetAutoHilight( Standard_False );
+  SetHilightAttributes( EDGES_COLOR );
 }
 
 HYDROGUI_LandCoverMapPrs::~HYDROGUI_LandCoverMapPrs()
@@ -135,13 +142,11 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3
 {
   thePresentation->Clear();
 
-  Quantity_Color anEdgeColor = Quantity_NOC_WHITE;
-
   myDrawer->UIsoAspect()->SetNumber( 0 );
   myDrawer->VIsoAspect()->SetNumber( 0 );
-  myDrawer->LineAspect()->SetColor( anEdgeColor );
-  myDrawer->FaceBoundaryAspect()->SetColor( anEdgeColor );
-  myDrawer->FreeBoundaryAspect()->SetColor( anEdgeColor );
+  myDrawer->LineAspect()->SetColor( EDGES_COLOR );
+  myDrawer->FaceBoundaryAspect()->SetColor( EDGES_COLOR );
+  myDrawer->FreeBoundaryAspect()->SetColor( EDGES_COLOR );
 
   switch( theMode )
   {
@@ -155,3 +160,34 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3
     StdPrs_WFDeflectionShape::Add( thePresentation, Shape(), myDrawer );
 }
 
+void HYDROGUI_LandCoverMapPrs::HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                                const SelectMgr_SequenceOfOwner& theOwners )
+{
+  Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( thePresentationManager );
+
+  SetHilightAttributes( EDGES_COLOR );
+
+  for( int i=1, n=theOwners.Length(); i<=n; i++ )
+  {
+    Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast( theOwners.Value( i ) );
+    if( !anOwner.IsNull() )
+      StdPrs_WFDeflectionShape::Add( aSelectPrs, anOwner->Shape(), HilightAttributes() );
+  }
+
+  HilightAttributes()->UIsoAspect()->SetNumber( 0 );
+  HilightAttributes()->VIsoAspect()->SetNumber( 0 );
+
+  aSelectPrs->SetDisplayPriority( 9 );
+  aSelectPrs->Display();
+}
+
+void HYDROGUI_LandCoverMapPrs::SetHilightAttributes( const Quantity_Color& theEdgesColor )
+{
+  HilightAttributes()->UIsoAspect()->SetNumber( HILIGHT_ISO_NB );
+  HilightAttributes()->UIsoAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->VIsoAspect()->SetNumber( HILIGHT_ISO_NB );
+  HilightAttributes()->VIsoAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->LineAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->FaceBoundaryAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->FreeBoundaryAspect()->SetColor( theEdgesColor );
+}
index 0e9888a1b8ee6ffb7c91a58f0c544478f4bd67a6..e1acc832233537f8a33a1df5da74bd7c4492cc9e 100644 (file)
@@ -47,10 +47,14 @@ public:
                         const Handle(Prs3d_Presentation)& thePresentation,
                         const Standard_Integer theMode );
 
+  virtual void HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                const SelectMgr_SequenceOfOwner& theOwners );
+
   Quantity_Color GetColor( const QString& theStricklerType ) const;
 
 protected:
   void UpdateColors();
+  void SetHilightAttributes( const Quantity_Color& theEdgesColor );
 
 private:
   Handle(HYDROData_LandCoverMap)   myLCMap;
index 44e3fc2c94f869f4d78c2cd614ea5c6e6fae2274..1fef8ca1a5dca3e73054239941adb43b0e6a04c7 100644 (file)
@@ -243,3 +243,10 @@ Handle_Aspect_ColorScale TestViewer::showColorScale( bool isShow )
   }
   return aColorScale;
 }
+
+void TestViewer::select( int theViewX, int theViewY )
+{
+  Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
+  context()->MoveTo( theViewX, theViewY, aView );
+  context()->Select();
+}
index 61f0d6bb6d9e67cec2ba5996d95a1c14e556c86e..d5bd15d6aed14ff9f39c237f3f1792843dc4dcba 100644 (file)
@@ -26,6 +26,8 @@ public:
 
   static Handle_Aspect_ColorScale showColorScale( bool );
 
+  static void select( int theViewX, int theViewY );
+
 private:
   static OCCViewer_ViewManager* myViewManager;
   static OCCViewer_ViewWindow* myViewWindow;
index 218a62161542c2f0854a3e7ecda63b327631dd41..2d7da92e5365cde7aafbb44f4fa9e677976fdc55 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png and b/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png differ
index 5e7e8fca263fbff9cb72595655ec1077a0f6cdbb..e1f52ed7c2190701facf6a4226208d923a1fa37a 100644 (file)
@@ -478,9 +478,13 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
                                             127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
 
+  // build presentation object 
   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
   aPrs->SetTable( aTable );
+  // show presentation in viewer
   TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" );
+  // select one of faces (first)
+  TestViewer::select( 200, 300 );
   CPPUNIT_ASSERT_IMAGES
 
   aDoc->Close();