#include <HYDROData_Iterator.h>
#include <HYDROData_Tool.h>
#include <AIS_DisplayMode.hxx>
-#include <BRepMesh_IncrementalMesh.hxx>
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Poly_Triangulation.hxx>
-#include <Prs3d_Root.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <StdSelect_BRepOwner.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
#include <TopoDS_Face.hxx>
#include <QColor>
#include <QString>
-IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_InteractiveObject )
-IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_InteractiveObject )
+IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
+IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandCoverMap)& theMap )
- : AIS_InteractiveObject()
+ : AIS_ColoredShape( theMap->GetShape() )
{
SetLandCoverMap( theMap );
}
void HYDROGUI_LandCoverMapPrs::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
{
myLCMap = theMap;
+ UpdateColors();
+}
+
+void HYDROGUI_LandCoverMapPrs::UpdateColors()
+{
+ Set( myLCMap->GetShape() );
+ SetMaterial( Graphic3d_NOM_PLASTIC );
+ HYDROData_LandCoverMap::Iterator anIt( myLCMap );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ TopoDS_Face aFace = anIt.Face();
+ QString aStricklerType = anIt.StricklerType();
+ Quantity_Color aColor = GetColor( aStricklerType );
+ SetCustomColor( aFace, aColor );
+ SetCustomWidth( aFace, 1.0 );
+ }
}
Handle(Aspect_ColorScale) HYDROGUI_LandCoverMapPrs::GetColorScale() const
void HYDROGUI_LandCoverMapPrs::SetColorScale( const Handle(Aspect_ColorScale)& theColorScale )
{
myColorScale = theColorScale;
+ double aMin = 0, aMax = 0;
+ if( myTable.IsNull() )
+ {
+ //TODO: go through all Strickler tables in the document to get the global range
+ }
+ else
+ myTable->GetCoefficientRange( aMin, aMax );
+
+ myColorScale->SetRange( aMin, aMax );
+ UpdateColors();
}
Handle(HYDROData_StricklerTable) HYDROGUI_LandCoverMapPrs::GetTable() const
Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
if( aTable->HasType( theStricklerType ) )
{
- QColor aColor = myTable->GetColor( theStricklerType );
+ QColor aColor = aTable->GetColor( theStricklerType );
return HYDROData_Tool::toOccColor( aColor );
}
}
return Quantity_Color();
}
-void DrawTriangulation( const Handle(Prs3d_Presentation)& thePresentation,
- const Handle(Poly_Triangulation)& theTriangulation,
- const Quantity_Color& theColor )
-{
- const TColgp_Array1OfPnt& aNodesArray = theTriangulation->Nodes();
- int aNbNodes = aNodesArray.Length();
-
- const Poly_Array1OfTriangle& aTrianglesArray = theTriangulation->Triangles();
- int aNbTriangles = aTrianglesArray.Length();
-
- Handle( Graphic3d_ArrayOfTriangles ) anArray = new Graphic3d_ArrayOfTriangles
- ( aNbNodes, aNbTriangles * 3, Standard_True, Standard_True, Standard_False );
-
- Prs3d_Root::NewGroup( thePresentation );
- Handle( Graphic3d_Group ) aGroup = Prs3d_Root::CurrentGroup( thePresentation );
- Handle( Graphic3d_AspectFillArea3d ) anAspect = new Graphic3d_AspectFillArea3d();
- Graphic3d_MaterialAspect aMaterialAspect( Graphic3d_NOM_PLASTIC );
- aMaterialAspect.SetColor( theColor );
- anAspect->SetFrontMaterial( aMaterialAspect );
- anAspect->SetBackMaterial( aMaterialAspect );
-
- Standard_Integer i;
-
- for( i = aNodesArray.Lower(); i <= aNodesArray.Upper(); i++ )
- {
- anArray->AddVertex( aNodesArray( i ), theColor );
- anArray->SetVertexNormal( i, 0, 0, 1 );
- }
-
- Standard_Integer anIndexTriangle[3] = { 0, 0, 0 };
- for( i = aTrianglesArray.Lower(); i<= aTrianglesArray.Upper(); i++ )
- {
- aTrianglesArray( i ).Get( anIndexTriangle[0], anIndexTriangle[1], anIndexTriangle[2] );
- anArray->AddEdge( anIndexTriangle[0] );
- anArray->AddEdge( anIndexTriangle[1] );
- anArray->AddEdge( anIndexTriangle[2] );
- }
- aGroup->AddPrimitiveArray( anArray );
- //aGroup->SetGroupPrimitivesAspect( anAspect );
-}
-
void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode )
{
- if( myLCMap.IsNull() )
- return;
-
thePresentation->Clear();
- const double aLinearDeflection = 1E-2;
- BRepMesh_IncrementalMesh aMesh( myLCMap->GetShape(), aLinearDeflection );
- aMesh.Perform();
- bool isOK = aMesh.IsDone();
+
+ 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 );
switch( theMode )
{
+ case AIS_WireFrame:
case AIS_Shaded:
- {
- HYDROData_LandCoverMap::Iterator anIt( myLCMap );
- for( ; anIt.More(); anIt.Next() )
- {
- TopoDS_Face aFace = anIt.Face();
- QString aStricklerType = anIt.StricklerType();
- Quantity_Color aColor = GetColor( aStricklerType );
-
- TopLoc_Location aLocation;
- Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation( aFace, aLocation );
- DrawTriangulation( thePresentation, aTriangulation, aColor );
- }
- }
- break;
- default:
+ AIS_ColoredShape::Compute( thePresentationManager, thePresentation, theMode );
break;
}
-}
-
-void HYDROGUI_LandCoverMapPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode )
-{
- if( myLCMap.IsNull() )
- return;
- if( theMode==0 )
- {
- /*theSelection->Clear();
- Bnd_Box B = BoundingBox();
- Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner( myLCMap->GetShape(), this );
- Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, B );
- theSelection->Add( aSensitiveBox );*/
- }
- else
- {
- //TODO
- }
+ if( theMode==AIS_Shaded )
+ StdPrs_WFDeflectionShape::Add( thePresentation, Shape(), myDrawer );
}
+
#include <HYDROData_LandCoverMap.h>
#include <HYDROData_StricklerTable.h>
-#include <AIS_InteractiveObject.hxx>
+#include <AIS_ColoredShape.hxx>
#include <Aspect_ColorScale.hxx>
-DEFINE_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_InteractiveObject )
+DEFINE_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
-class HYDROGUI_LandCoverMapPrs : public AIS_InteractiveObject
+class HYDROGUI_LandCoverMapPrs : public AIS_ColoredShape
{
public:
DEFINE_STANDARD_RTTI( HYDROGUI_LandCoverMapPrs );
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode );
- virtual void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode );
-
Quantity_Color GetColor( const QString& theStricklerType ) const;
+protected:
+ void UpdateColors();
+
private:
Handle(HYDROData_LandCoverMap) myLCMap;
Handle(Aspect_ColorScale) myColorScale;
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+// File : Basics_OCCTVersion.hxx
+// Author : Julia DOROVSKIKH, Open CASCADE S.A.S (julia.dorovskikh@opencascade.com)
+
+#ifndef BASICS_OCCTVERSION_HXX
+#define BASICS_OCCTVERSION_HXX
+
+#include <Standard_Version.hxx>
+
+//
+// NOTE: Since version 6.7.0 OCC_VERSION_DEVELOPMENT macro in the Standard_Version.hxx
+// points to the development status of the OCCT version: for example "dev", "alpha",
+// "beta", "rc1", etc.
+// OCC_VERSION_MAJOR, OCC_VERSION_MINOR and OCC_VERSION_MAINTENANCE macros
+// specify actual (final) version number; for development version it is a future
+// target version number (i.e. version number is incremented immediately after
+// releasing of the stable version).
+//
+
+#ifdef OCC_VERSION_SERVICEPACK
+# define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK)
+#else
+# ifdef OCC_VERSION_DEVELOPMENT
+# define OCC_VERSION_LARGE ((OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)-1)
+# else
+# define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
+# endif
+#endif
+
+#endif // BASICS_OCCTVERSION_HXX
ELSE()
link_directories( $ENV{CAS_ROOT_DIR}/lib )
ENDIF()
-SET( CAS_LIBRARIES TKernel TKLCAF TKCAF TKCDF TKMath TKG2d TKG3d TKBRep TKGeomBase TKTopAlgo TKGeomAlgo TKBool TKShHealing TKXSBase TKOffset TKHLR TKBO TKV3d TKService )
+SET( CAS_LIBRARIES TKernel TKLCAF TKCAF TKCDF TKMath TKG2d TKG3d TKBRep TKGeomBase TKTopAlgo TKGeomAlgo TKBool TKShHealing TKXSBase TKOffset TKHLR TKBO TKV3d TKService TKMesh )
link_directories( $ENV{QT4_ROOT_DIR}/lib )
IF( ${WIN32} )
#include <HYDROData_Tool.h>
#include <random.h>
#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewPort3d.h>
#ifdef WIN32
#pragma warning ( disable: 4251 )
#endif
#endif
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
+#include <Aspect_ColorScale.hxx>
#include <TopoDS_Iterator.hxx>
#include <QDir>
}
void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
- int theMode, int theSelectionMode, bool isFitAll )
+ int theMode, int theSelectionMode, bool isFitAll, const char* theKey )
{
context()->EraseAll( Standard_False );
context()->Display( theObject, theMode, theSelectionMode );
+ myKey = theKey;
+
if( isFitAll )
{
viewWindow()->onTopView();
return false;
}
+
+Handle_Aspect_ColorScale TestViewer::showColorScale()
+{
+ Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
+ if( aView.IsNull() )
+ return Handle(Aspect_ColorScale)();
+
+ Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
+ if( aColorScale.IsNull() )
+ return aColorScale;
+
+ Standard_Real anXPos = 0.05; //TODO
+ Standard_Real anYPos = 0.1; //TODO
+ Standard_Real aWidth = 0.2; //TODO
+ Standard_Real aHeight = 0.5; //TODO
+ Standard_Integer aTextHeight = 14; //TODO
+ Standard_Integer aNbIntervals = 30; //TODO
+
+ aColorScale->SetXPosition( anXPos );
+ aColorScale->SetYPosition( anYPos );
+ aColorScale->SetWidth( aWidth );
+ aColorScale->SetHeight( aHeight );
+ aColorScale->SetTextHeight( aTextHeight );
+ aColorScale->SetNumberOfIntervals( aNbIntervals );
+
+ aColorScale->SetTitle( "test" );
+ aColorScale->SetRange( 0, 1 );
+
+ if( !aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleDisplay();
+
+ return aColorScale;
+}
class QString;
class QColor;
class Handle_AIS_InteractiveObject;
+class Handle_Aspect_ColorScale;
class TestViewer
{
static OCCViewer_ViewWindow* viewWindow();
static void show( const Handle_AIS_InteractiveObject& theObject,
- int theMode, int theSelelctionMode, bool isFitAll );
+ int theMode, int theSelelctionMode, bool isFitAll, const char* theKey );
static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor );
static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey );
static bool AssertImages( QString& theMessage );
+ static Handle_Aspect_ColorScale showColorScale();
+
private:
static OCCViewer_ViewManager* myViewManager;
static OCCViewer_ViewWindow* myViewWindow;
#include <TestViewer.h>
#include <TopTools_ListOfShape.hxx>
#include <AIS_DisplayMode.hxx>
+#include <Aspect_ColorScale.hxx>
#include <QString>
#include <QColor>
}
}
-void test_HYDROData_LandCoverMap::test_land_cover_prs()
+void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
{
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
aPrs->SetTable( aTable );
- TestViewer::show( aPrs, AIS_Shaded, 1, true );
+ TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByTypes" );
+ CPPUNIT_ASSERT_IMAGES
+
+ aDoc->Close();
+}
+
+void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_StricklerTable) aTable =
+ Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+ CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
+
+ Handle(HYDROData_LandCoverMap) aMap =
+ Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+
+ TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+ CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
+
+ TopoDS_Face aLC2 = LandCover( 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 );
+ CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
+
+ TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1 << 47 << 51 << 45 <<
+ 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+ CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
+
+ Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
+ aPrs->SetTable( aTable );
+ aPrs->SetColorScale( TestViewer::showColorScale() );
+ TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByCoeff" );
+ CPPUNIT_ASSERT_IMAGES
aDoc->Close();
}
CPPUNIT_TEST( test_remove );
CPPUNIT_TEST( test_merge_faces_boxes );
CPPUNIT_TEST( test_merge_faces_circles );
- CPPUNIT_TEST( test_land_cover_prs );
+ CPPUNIT_TEST( test_land_cover_prs_by_types );
+ CPPUNIT_TEST( test_land_cover_prs_by_coeff );
CPPUNIT_TEST_SUITE_END();
public:
void test_remove();
void test_merge_faces_boxes();
void test_merge_faces_circles();
- void test_land_cover_prs();
+ void test_land_cover_prs_by_types();
+ void test_land_cover_prs_by_coeff();
};
CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );